Skip to content

Commit

Permalink
Added 640x200 CGA images
Browse files Browse the repository at this point in the history
  • Loading branch information
leuat committed Apr 12, 2024
1 parent 1d48fcc commit 8b6c95f
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 160 deletions.
2 changes: 2 additions & 0 deletions TRSE.pro
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ SOURCES += main.cpp\
source/ImageEditor/hexview.cpp \
source/ImageEditor/qlabellimage.cpp \
source/LeLib/limage/limageagon.cpp \
source/LeLib/limage/limagecga_hires.cpp \
source/LeLib/limage/limagecoco3.cpp \
source/LeLib/limage/limagelevelgeneric.cpp \
source/LeLib/limage/limageprimo.cpp \
Expand Down Expand Up @@ -584,6 +585,7 @@ HEADERS += mainwindow.h \
source/ImageEditor/hexview.h \
source/ImageEditor/qlabellimage.h \
source/LeLib/limage/limageagon.h \
source/LeLib/limage/limagecga_hires.h \
source/LeLib/limage/limagecoco3.h \
source/LeLib/limage/limagelevelgeneric.h \
source/LeLib/limage/limageprimo.h \
Expand Down
1 change: 1 addition & 0 deletions imageworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ImageWorker::ImageWorker()
{

m_types.append(ImageType("CGA png Palette 1", "X86",LImage::Type::CGA, LColorList::Type::CGA1_HIGH));
m_types.append(ImageType("CGA hires", "X86",LImage::Type::CGA_HIRES, LColorList::Type::MONO));
m_types.append(ImageType("Amiga 320x256", "AMIGA",LImage::Type::AMIGA320x256, LColorList::Type::C64));
m_types.append(ImageType("Amiga 320x200", "AMIGA",LImage::Type::AMIGA320x200, LColorList::Type::C64));
m_types.append(ImageType("MultiColor bitmap", "C64", LImage::Type::MultiColorBitmap,LColorList::Type::C64));
Expand Down
6 changes: 6 additions & 0 deletions source/LeLib/limage/limage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ unsigned char LImage::TypeToChar(LImage::Type t)
return 45;
if (t==PRIMO)
return 46;
if (t==CGA_HIRES)
return 47;


return 255;
Expand Down Expand Up @@ -238,6 +240,8 @@ QString LImage::TypeToString(LImage::Type t)
return "Generic AGON image";
if (t==PRIMO)
return "Generic PRIMO image";
if (t==CGA_HIRES)
return "Hires CGA";


return "Unknown image type";
Expand Down Expand Up @@ -341,6 +345,8 @@ LImage::Type LImage::CharToType(unsigned char c)
return AGON;
if (c==46)
return PRIMO;
if (c==47)
return CGA_HIRES;

return NotSupported;

Expand Down
2 changes: 1 addition & 1 deletion source/LeLib/limage/limage.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Q_OBJECT
Sprites, VIC20_MultiColorbitmap, Sprites2, CGA, AMIGA320x200, AMIGA320x256, ATARI320x200,
OK64_256x256,X16_640x480, NES, LMetaChunk, LevelEditorNES, SpritesNES, GAMEBOY, LevelEditorGameboy, HybridCharset,
AmstradCPC, AmstradCPCGeneric, BBC, VGA, Spectrum, SNES,LevelEditorSNES,VZ200, CustomC64, JDH8, LImageGeneric, GenericSprites, CGA160x100,
AmstradSprites, SNESGeneric, TIM, TVC, COCO3, THOMSON, TIMG, LevelEditorGeneric, AGON, PRIMO
AmstradSprites, SNESGeneric, TIM, TVC, COCO3, THOMSON, TIMG, LevelEditorGeneric, AGON, PRIMO,CGA_HIRES
};


Expand Down
2 changes: 1 addition & 1 deletion source/LeLib/limage/limagecga.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LImageCGA : public LImageQImage

QStringList SpriteCompiler(QString name, QString currentDir,QString src, QString dst, int x, int y, int w, int h,QString pparam) override;

void toCGA(QByteArray& even, QByteArray& odd,QByteArray& evenMask, QByteArray& oddMask, int x1, int y1, int w, int h);
virtual void toCGA(QByteArray& even, QByteArray& odd,QByteArray& evenMask, QByteArray& oddMask, int x1, int y1, int w, int h);


};
Expand Down
67 changes: 67 additions & 0 deletions source/LeLib/limage/limagecga_hires.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include "limagecga_hires.h".h"
LImageCGAHires::LImageCGAHires(LColorList::Type t) : LImageCGA(t)
{
Initialize(640,200);
m_scale = 1;
m_type = LImage::Type::CGA_HIRES;
m_supports.asmExport = false;
m_supports.binaryLoad = false;
m_supports.binarySave = true;
m_supports.flfSave = true;
m_supports.flfLoad = true;
m_supports.displayMC1 = false;
m_supports.displayMC2 = false;
m_supports.displayForeground = false;
m_supports.displayBackground = false;
m_GUIParams[btnEditFullCharset] = "Char";
m_supports.displayCharOperations = true;
m_GUIParams[tabCharset] = "1";
m_updateCharsetPosition = true;
m_colorList.m_isCharset = true;
m_charWidth=80;
m_charHeight=25;
m_updateCharsetPosition = true;
m_supports.displayCharOperations = true;
}
void LImageCGAHires::toCGA(QByteArray &even, QByteArray &odd, QByteArray &evenMask, QByteArray &oddMask, int x1, int y1, int w, int h)
{
int cur=0;
char curC=0;
char curM=0;
for (int y=0;y<h;y++) {
for (int x=0;x<w*2;x++) {
// QColor c = QColor(m_qImage->pixel(x,y));
// qDebug() << m_qImage->pixel(x,y);
char idx = m_qImage->pixel(x+x1,y+y1);//m_colorList.getIndex(c);
// qDebug() << QString::number(cur) << c;
char midx = 0;
if (idx!=0) midx=0b1;
curM = curM | (midx<<(7-(curC)));
cur = cur | (idx<<(7-(curC)));
curC++;
if (curC==8) {
if ((y&1)==0)
even.append(cur);
else odd.append(cur);
if ((y&1)==0)
evenMask.append(curM);
else oddMask.append(curM);
curC=0;
cur=0;
curM = 0;
}
}
}
}
16 changes: 16 additions & 0 deletions source/LeLib/limage/limagecga_hires.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef LIMAGECGA_H_H
#define LIMAGECGA_H_H

#include "source/LeLib/limage/limagecga.h"
#include "source/LeLib/util/util.h"
class LImageCGAHires : public LImageCGA
{
public:

LImageCGAHires(LColorList::Type t);

void toCGA(QByteArray& even, QByteArray& odd, QByteArray& evenMask, QByteArray& oddMask,int x1, int y1, int w, int h) override;

};

#endif // LIMAGECGA_H
2 changes: 2 additions & 0 deletions source/LeLib/limage/limagefactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ LImage *LImageFactory::Create(LImage::Type t, LColorList::Type colorType) {
return new LImageAgon(colorType);
if (t == LImage::PRIMO)
return new LImagePrimo(colorType);
if (t == LImage::CGA_HIRES)
return new LImageCGAHires(colorType);

qDebug() << "ERROR: LImageFactory could not find type " << t;
return nullptr;
Expand Down
1 change: 1 addition & 0 deletions source/LeLib/limage/limagefactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#include "source/LeLib/limage/limagelevelgeneric.h"
#include "source/LeLib/limage/limageagon.h"
#include "source/LeLib/limage/limageprimo.h"
#include "source/LeLib/limage/limagecga_hires.h"

class LImageFactory {
public:
Expand Down
6 changes: 5 additions & 1 deletion source/Raytracer/rayobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ void RayObjectRegular3D::Render(Camera& cam, QImage &img) {
int a = m_faces[k*3];
int b = m_faces[k*3+1];
int c = m_faces[k*3+2];
if (m_rotNormals[k].z()<0.35)
if (m_rotNormals[k].z()<-0.0)
{
points[0] = QPointF(m_projected[a].x(),m_projected[a].y());
points[1] = QPointF(m_projected[b].x(),m_projected[b].y());
Expand All @@ -932,6 +932,10 @@ void RayObjectRegular3D::Render(Camera& cam, QImage &img) {
tmp.append(m_projected[b].y()+img.height()/2);
tmp.append(m_projected[c].x()+img.width()/2);
tmp.append(m_projected[c].y()+img.height()/2);
float l = QVector3D::dotProduct(m_rotNormals[k],QVector3D(0,-2,3).normalized());
int val = std::fmax(0.0f, -l)*4.0;
tmp.append((uchar)val);
qDebug() << (uchar)val;
// qDebug() << m_projected[a].y()+img.height()/2;
tmp.append(k);
// tmp.append((-m_rotNormals[k].z()+0.35)*8);
Expand Down
1 change: 1 addition & 0 deletions units/X86/gfx/cga16.tru
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var
size:integer;
tmpb:byte;
dx,dy,wx,wy : integer;

@use "system/screen"


Expand Down
Loading

0 comments on commit 8b6c95f

Please sign in to comment.