From 01a7e7ad60819d247bfe815a8e2183a46c1c6437 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 9 Jun 2011 08:20:53 +0200 Subject: CGE: Add several sources based on headers --- engines/cge/vga13h.cpp | 1775 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1775 insertions(+) create mode 100644 engines/cge/vga13h.cpp (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp new file mode 100644 index 0000000000..227304668b --- /dev/null +++ b/engines/cge/vga13h.cpp @@ -0,0 +1,1775 @@ +#include +#include "vga13h.h" +#include "bitmap.h" +#include "vol.h" +#include "text.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG +#define REPORT +#endif + +#define OK(f) ((f).Error==0) +#define FADE_STEP 2 + +#define TMR_DIV ((0x8000/TMR_RATE)*2) + + +//-------------------------------------------------------------------------- + +#ifdef REPORT +static char Report[] = "NearHeap=..... FarHeap=......\n"; +#define NREP 9 +#define FREP 24 +#endif + + + +static VgaRegBlk VideoMode[] = { + + { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode + + { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 + { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 + { 0x06, VGAGRA, 0x02, 0x00 }, // misc + + { 0x14, VGACRT, 0x40, 0x00 }, // underline + { 0x13, VGACRT, 0xFF, 0x28 }, // screen width + { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control + + { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end + { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line + + { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode + +// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end +// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb +// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr + + { 0x00 } }; + + + Boolean SpeedTest = FALSE; + SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; + SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; + SPRITE * Sys = NULL; + +extern "C" void SNDMIDIPlay (void); + + + + + + +char * NumStr (char * str, int num) +{ + char * p = strchr(str, '#'); + if (p) wtom(num, p, 10, 5); + return str; +} + + + + + + + + +static void Video (void) +{ + static word SP_S; + + asm push bx + asm push bp + asm push si + asm push di + asm push es + asm xor bx,bx // video page #0 + SP_S = _SP; + asm int VIDEO + _SP = SP_S; + asm pop es + asm pop di + asm pop si + asm pop bp + asm pop bx +} + + + + + + +word far * SaveScreen (void) +{ + word cxy, cur, siz, far * scr = NULL, far * sav; + + // horizontal size of text mode screen + asm mov ah,0x0F // get current video mode + Video(); // BIOS video service + asm xchg ah,al // answer in ah + asm push ax // preserve width + + // vertical size of text mode screen + asm mov dl,24 // last row on std screen + asm xor bx,bx // valid request in BH + asm mov ax,0x1130 // get EGA's last row # + Video(); // BIOS video service + asm inc dl // # of rows = last+1 + + // compute screen size in words + asm pop ax // restore width + asm mul dl // width * height + + siz = _AX; + + asm mov ax,0x40 // system data segment + asm mov es,ax + asm mov ax,0B000H // Mono + asm cmp byte ptr es:[0x49],0x07 + asm je sto + asm mov ax,0B800H // Color + sto: // store screen address + asm mov word ptr scr+2,ax + + _AH = 0x0F; Video(); // active page + + // take cursor shape + _AH = 0x03; Video(); // get cursor size + cur = _CX; + + // take cursor position + _DH = 0; + _AH = 0x03; Video(); // get cursor + cxy = _DX; + + sav = farnew(word, siz+3); // +3 extra words for size and cursor + if (sav) + { + sav[0] = siz; + sav[1] = cur; + sav[2] = cxy; + _fmemcpy(sav+3, scr, siz * 2); + } + return sav; +} + + + + + +void RestoreScreen (word far * &sav) +{ + word far * scr = NULL; + + asm mov ax,0x40 // system data segment + asm mov es,ax + asm mov ax,0B000H // Mono + asm cmp byte ptr es:[0x49],0x07 + asm je sto + asm mov ax,0B800H // Color + sto: // store screen address + asm mov word ptr scr+2,ax + + _fmemcpy(scr, sav+3, sav[0] * 2); + + _AH = 0x0F; Video(); // active page + + // set cursor shape + _CX = sav[1]; + _AH = 0x01; Video(); // set cursor size + + // set cursor position + _DX = sav[2]; + _AH = 0x02; Video(); // set cursor + + farfree(sav); + sav = NULL; +} + + + + + + +DAC MkDAC (byte r, byte g, byte b) +{ + static DAC x; + x.R = r; + x.G = g; + x.B = b; + return x; +} + + + + +RGB MkRGB (byte r, byte g, byte b) +{ + static TRGB x; + x.dac.R = r; + x.dac.G = g; + x.dac.B = b; + return x.rgb; +} + + + + + + +SPRITE * Locate (int ref) +{ + SPRITE * spr = VGA::ShowQ.Locate(ref); + return (spr) ? spr : VGA::SpareQ.Locate(ref); +} + + + + + +//-------------------------------------------------------------------------- + + +Boolean HEART::Enable = FALSE; +word * HEART::XTimer = NULL; + + + + +HEART::HEART (void) +: ENGINE(TMR_DIV) +{ +} + + +/* +extern "C" void TimerProc (void) +{ + static SPRITE * spr; + static byte run = 0; + + // decrement external timer word + if (HEART::XTimer) + if (*HEART::XTimer) -- *HEART::XTimer; + else HEART::XTimer = NULL; + + if (! run && HEART::Enable) // check overrun flag + { + static word oldSP, oldSS; + + ++ run; // disable 2nd call until current lasts + asm mov ax,ds + asm mov oldSS,ss + asm mov oldSP,sp + asm mov ss,ax + asm mov sp,0xFF80 + + // system pseudo-sprite + if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); + + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) + { + if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); + } + asm mov ss,oldSS + asm mov sp,oldSP + -- run; + } +} +*/ + + +void interrupt ENGINE::NewTimer (...) +{ + static SPRITE * spr; + static byte run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; + + ___1152_Hz___: + + SNDMIDIPlay(); + asm dec cntr1 + asm jz ___72_Hz___ + asm mov al,0x20 // send... + asm out 0x020,al // ...e-o-i + return; + + ___72_Hz___: + + asm mov cntr1,TMR_RATE1 + asm dec cntr2 + asm jnz my_eoi + + ___18_Hz___: + + OldTimer(); + asm mov cntr2,TMR_RATE2 + asm jmp short my_int + + // send E-O-I + my_eoi: + asm mov al,0x20 + asm out 0x020,al + asm sti // enable interrupts + + my_int: //------72Hz-------// + + // decrement external timer word + if (HEART::XTimer) + if (*HEART::XTimer) -- *HEART::XTimer; + else HEART::XTimer = NULL; + + if (! run && HEART::Enable) // check overrun flag + { + static word oldSP, oldSS; + + ++ run; // disable 2nd call until current lasts + asm mov ax,ds + asm mov oldSS,ss + asm mov oldSP,sp + asm mov ss,ax + asm mov sp,0xFF80 + + // system pseudo-sprite + if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); + + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) + { + if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); + } + asm mov ss,oldSS + asm mov sp,oldSP + -- run; + } +} + + + + + +void HEART::SetXTimer (word * ptr) +{ + if (XTimer && ptr != XTimer) *XTimer = 0; + XTimer = ptr; +} + + + + +void HEART::SetXTimer (word * ptr, word time) +{ + SetXTimer(ptr); + *ptr = time; +} + + + + +//-------------------------------------------------------------------------- + + + + + + + +SPRITE::SPRITE (BMP_PTR * shp) +: X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), + Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), + Ext(NULL), Ref(-1), Cave(0) +{ + memset(File, 0, sizeof(File)); + *((word *)&Flags) = 0; + SetShapeList(shp); +} + + + + + + +SPRITE::~SPRITE (void) +{ + Contract(); +} + + + + +BMP_PTR SPRITE::Shp (void) +{ + register SPREXT * e = Ext; + if (e) if (e->Seq) + { + int i = e->Seq[SeqPtr].Now; + #ifdef DEBUG + if (i >= ShpCnt) + { + //char s[256]; + //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", + // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); + //VGA::Exit(s, File); + VGA::Exit("Invalid PHASE in SPRITE::Shp()", File); + } + #endif + return e->ShpList[i]; + } + return NULL; +} + + + + + +BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) +{ + BMP_PTR * r = (Ext) ? Ext->ShpList : NULL; + + ShpCnt = 0; + W = 0; + H = 0; + + if (shp) + { + BMP_PTR * p; + for (p = shp; *p; p ++) + { + BMP_PTR b = (*p); // ->Code(); + if (b->W > W) W = b->W; + if (b->H > H) H = b->H; + ++ ShpCnt; + } + Expand(); + Ext->ShpList = shp; + if (! Ext->Seq) SetSeq((ShpCnt < 2) ? Seq1 : Seq2); + } + return r; +} + + + + + +void SPRITE::MoveShapes (byte far * buf) +{ + BMP_PTR * p; + for (p = Ext->ShpList; *p; p ++) + { + buf += (*p)->MoveVmap(buf); + } +} + + + + + +Boolean SPRITE::Works (SPRITE * spr) +{ + if (spr) if (spr->Ext) + { + SNAIL::COM * c = spr->Ext->Take; + if (c != NULL) + { + c += spr->TakePtr; + if (c->Ref == Ref) + if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) + return TRUE; + } + } + return FALSE; +} + + + + + +SEQ * SPRITE::SetSeq (SEQ * seq) +{ + Expand(); + register SEQ * s = Ext->Seq; + Ext->Seq = seq; + if (SeqPtr == NO_SEQ) Step(0); + else + if (Time == 0) Step(SeqPtr); + return s; +} + + + + + + +Boolean SPRITE::SeqTest (int n) +{ + if (n >= 0) return (SeqPtr == n); + if (Ext) return (Ext->Seq[SeqPtr].Next == SeqPtr); + return TRUE; +} + + + + + + +SNAIL::COM * SPRITE::SnList (SNLIST type) +{ + register SPREXT * e = Ext; + if (e) return (type == NEAR) ? e->Near : e->Take; + return NULL; +} + + + + + + +void SPRITE::SetName (char * n) +{ + if (Ext) + { + if (Ext->Name) + { + delete[] Ext->Name; + Ext->Name = NULL; + } + if (n) + { + if ((Ext->Name = new char[strlen(n)+1]) != NULL) strcpy(Ext->Name, n); + else VGA::Exit("No core", n); + } + } +} + + + + + +SPRITE * SPRITE::Expand (void) +{ + if (! Ext) + { + Boolean enbl = HEART::Enable; + HEART::Enable = FALSE; + if ((Ext = new SPREXT) == NULL) DROP("No core", NULL); + if (*File) + { + static char * Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; + char line[LINE_MAX], fname[MAXPATH]; + BMP_PTR * shplist = new BMP_PTR [ShpCnt+1]; + SEQ * seq = NULL; + int shpcnt = 0, + seqcnt = 0, + neacnt = 0, + takcnt = 0, + maxnow = 0, + maxnxt = 0, + lcnt = 0, + len; + + SNAIL::COM * nea = NULL; + SNAIL::COM * tak = NULL; + MergeExt(fname, File, SPR_EXT); + if (INI_FILE::Exist(fname)) // sprite description file exist + { + INI_FILE sprf(fname); + if (! OK(sprf)) + { + VGA::Exit("Bad SPR", fname); + } + + while ((len = sprf.Read(line)) != 0) + { + ++ lcnt; + if (len && line[len-1] == '\n') line[-- len] = '\0'; + if (len == 0 || *line == '.') continue; + + switch (TakeEnum(Comd, strtok(line, " =\t"))) + { + case 0 : // Name + SetName(strtok(NULL, "")); break; + case 1 : // Phase + shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/")); + break; + case 2 : // Seq + seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); + if (seq == NULL) + VGA::Exit("No core", fname); + SEQ * s = &seq[seqcnt ++]; + s->Now = atoi(strtok(NULL, " \t,;/")); + if (s->Now > maxnow) maxnow = s->Now; + s->Next = atoi(strtok(NULL, " \t,;/")); + switch (s->Next) + { + case 0xFF : s->Next = seqcnt; break; + case 0xFE : s->Next = seqcnt-1; break; + } + if (s->Next > maxnxt) maxnxt = s->Next; + s->Dx = atoi(strtok(NULL, " \t,;/")); + s->Dy = atoi(strtok(NULL, " \t,;/")); + s->Dly = atoi(strtok(NULL, " \t,;/")); + break; + case 3 : // Near + if (NearPtr != NO_PTR) + { + nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); + if (nea == NULL) VGA::Exit("No core", fname); + else + { + SNAIL::COM * c = &nea[neacnt ++]; + if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + VGA::Exit(NumStr("Bad NEAR in ######", lcnt), fname); + c->Ref = atoi(strtok(NULL, " \t,;/")); + c->Val = atoi(strtok(NULL, " \t,;/")); + c->Ptr = NULL; + } + } + break; + case 4 : // Take + if (TakePtr != NO_PTR) + { + tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); + if (tak == NULL) VGA::Exit("No core", fname); + else + { + SNAIL::COM * c = &tak[takcnt ++]; + if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + VGA::Exit(NumStr("Bad NEAR in ######", lcnt), fname); + c->Ref = atoi(strtok(NULL, " \t,;/")); + c->Val = atoi(strtok(NULL, " \t,;/")); + c->Ptr = NULL; + } + } + break; + } + } + } + else // no sprite description: try to read immediately from .BMP + { + shplist[shpcnt ++] = new BITMAP(File); + } + shplist[shpcnt] = NULL; + if (seq) + { + if (maxnow >= shpcnt) VGA::Exit("Bad PHASE in SEQ", fname); + if (maxnxt >= seqcnt) VGA::Exit("Bad JUMP in SEQ", fname); + SetSeq(seq); + } + else SetSeq((ShpCnt == 1) ? Seq1 : Seq2); + disable(); + + SetShapeList(shplist); + enable(); + if (nea) nea[neacnt-1].Ptr = Ext->Near = nea; else NearPtr = NO_PTR; + if (tak) tak[takcnt-1].Ptr = Ext->Take = tak; else TakePtr = NO_PTR; + } + HEART::Enable = enbl; + } + return this; +} + + + + +SPRITE * SPRITE::Contract (void) +{ + register SPREXT * e = Ext; + if (e) + { + if (e->Name) delete[] e->Name; + if (Flags.BDel && e->ShpList) + { + int i; + for (i = 0; e->ShpList[i]; i ++) delete e->ShpList[i]; + if (MemType(e->ShpList) == NEAR_MEM) delete[] e->ShpList; + } + if (MemType(e->Seq) == NEAR_MEM) free(e->Seq); + if (e->Near) free(e->Near); + if (e->Take) free(e->Take); + delete e; + Ext = NULL; + } + return this; +} + + + + + + +SPRITE * SPRITE::BackShow (Boolean fast) +{ + Expand(); + Show(2); + Show(1); + if (fast) Show(0); + Contract(); + return this; +} + + + + + + + + +void SPRITE::Step (int nr) +{ + if (nr >= 0) SeqPtr = nr; + if (Ext) + { + SEQ * seq; + if (nr < 0) SeqPtr = Ext->Seq[SeqPtr].Next; + seq = Ext->Seq + SeqPtr; + if (seq->Dly >= 0) + { + Goto(X + (seq->Dx), Y + (seq->Dy)); + Time = seq->Dly; + } + } +} + + + + + + +void SPRITE::Tick (void) +{ + Step(); +} + + + + + +void SPRITE::MakeXlat (byte far * x) +{ + if (Ext) + { + BMP_PTR * b; + + if (Flags.Xlat) KillXlat(); + for (b = Ext->ShpList; *b; b ++) (*b)->M = x; + Flags.Xlat = TRUE; + } +} + + + + + +void SPRITE::KillXlat (void) +{ + if (Flags.Xlat && Ext) + { + BMP_PTR * b; + byte far * m = (*Ext->ShpList)->M; + + switch (MemType(m)) + { + case NEAR_MEM : delete[] (byte *) m; break; + case FAR_MEM : farfree(m); break; + } + for (b = Ext->ShpList; *b; b ++) (*b)->M = NULL; + Flags.Xlat = FALSE; + } +} + + + + + +void SPRITE::Goto (int x, int y) +{ + int xo = X, yo = Y; + if (W < SCR_WID) + { + if (x < 0) x = 0; + if (x + W > SCR_WID) x = (SCR_WID - W); + X = x; + } + if (H < SCR_HIG) + { + if (y < 0) y = 0; + if (y + H > SCR_HIG) y = (SCR_HIG - H); + Y = y; + } + if (Next) if (Next->Flags.Slav) Next->Goto(Next->X-xo+X, Next->Y-yo+Y); + if (Flags.Shad) Prev->Goto(Prev->X-xo+X, Prev->Y-yo+Y); +} + + + + + + + + + + + + +void SPRITE::Center (void) +{ + Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); +} + + + + + + + + +void SPRITE::Show (void) +{ + register SPREXT * e; + asm cli // critic section... + e = Ext; + e->x0 = e->x1; + e->y0 = e->y1; + e->b0 = e->b1; + e->x1 = X; + e->y1 = Y; + e->b1 = Shp(); + asm sti // ...done! + if (! Flags.Hide) + { + if (Flags.Xlat) e->b1->XShow(e->x1, e->y1); + else e->b1->Show(e->x1, e->y1); + } +} + + + + + + + +void SPRITE::Show (word pg) +{ + byte far * a = VGA::Page[1]; + VGA::Page[1] = VGA::Page[pg & 3]; + Shp()->Show(X, Y); + VGA::Page[1] = a; +} + + + + + + + + +void SPRITE::Hide (void) +{ + register SPREXT * e = Ext; + if (e->b0) e->b0->Hide(e->x0, e->y0); +} + + + + +BMP_PTR SPRITE::Ghost (void) +{ + register SPREXT * e = Ext; + if (e->b1) + { + BMP_PTR bmp = new BITMAP(0, 0, (byte far *)NULL); + if (bmp == NULL) VGA::Exit("No core"); + bmp->W = e->b1->W; + bmp->H = e->b1->H; + if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) VGA::Exit("No Core"); + bmp->V = (byte far *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + bmp->M = (byte far *) MK_FP(e->y1, e->x1); + return bmp; + } + return NULL; +} + + + + + + +SPRITE * SpriteAt (int x, int y) +{ + SPRITE * spr = NULL, * tail = VGA::ShowQ.Last(); + if (tail) + { + for (spr = tail->Prev; spr; spr = spr->Prev) + if (! spr->Flags.Hide && ! spr->Flags.Tran) + if (spr->Shp()->SolidAt(x-spr->X, y-spr->Y)) + break; + } + return spr; +} + + + + + +//-------------------------------------------------------------------------- + + + + + + +QUEUE::QUEUE (Boolean show) +: Head(NULL), Tail(NULL), Show(show) +{ +} + + + + +QUEUE::~QUEUE (void) +{ + Clear(); +} + + + + +void QUEUE::Clear (void) +{ + while (Head) + { + SPRITE * s = Remove(Head); + if (s->Flags.Kill) delete s; + } +} + + + + +void QUEUE::ForAll (void (*fun)(SPRITE *)) +{ + SPRITE * s = Head; + while (s) + { + SPRITE * n = s->Next; + fun(s); + s = n; + } +} + + + + + +void QUEUE::Append (SPRITE * spr) +{ + if (Tail) + { + spr->Prev = Tail; + Tail->Next = spr; + } + else Head = spr; + Tail = spr; + if (Show) spr->Expand(); + else spr->Contract(); +} + + + + + +void QUEUE::Insert (SPRITE * spr, SPRITE * nxt) +{ + if (nxt == Head) + { + spr->Next = Head; + Head = spr; + if (! Tail) Tail = spr; + } + else + { + spr->Next = nxt; + spr->Prev = nxt->Prev; + if (spr->Prev) spr->Prev->Next = spr; + } + if (spr->Next) spr->Next->Prev = spr; + if (Show) spr->Expand(); + else spr->Contract(); +} + + + + + +void QUEUE::Insert (SPRITE * spr) +{ + SPRITE * s; + for (s = Head; s; s = s->Next) + if (s->Z > spr->Z) + break; + if (s) Insert(spr, s); + else Append(spr); + if (Show) spr->Expand(); + else spr->Contract(); +} + + + + + +SPRITE * QUEUE::Remove (SPRITE * spr) +{ + if (spr == Head) Head = spr->Next; + if (spr == Tail) Tail = spr->Prev; + if (spr->Next) spr->Next->Prev = spr->Prev; + if (spr->Prev) spr->Prev->Next = spr->Next; + spr->Prev = NULL; + spr->Next = NULL; + return spr; +} + + + + + +SPRITE * QUEUE::Locate (int ref) +{ + SPRITE * spr; + for (spr = Head; spr; spr = spr->Next) if (spr->Ref == ref) return spr; + return NULL; +} + + + + + +//-------------------------------------------------------------------------- + + + + +word VGA::StatAdr = VGAST1_; +word VGA::OldMode = 0; +word far * VGA::OldScreen = NULL; +const char * VGA::Msg = NULL; +const char * VGA::Nam = NULL; +DAC far * VGA::OldColors = NULL; +DAC far * VGA::NewColors = NULL; +Boolean VGA::SetPal = FALSE; +int VGA::Mono = 0; +QUEUE VGA::ShowQ = TRUE, VGA::SpareQ = FALSE; +byte far * VGA::Page[4] = { (byte far *) MK_FP(SCR_SEG, 0x0000), + (byte far *) MK_FP(SCR_SEG, 0x4000), + (byte far *) MK_FP(SCR_SEG, 0x8000), + (byte far *) MK_FP(SCR_SEG, 0xC000) }; + + + + +VGA::VGA (int mode) +: FrmCnt(0) +{ + extern const char Copr[]; + Boolean std = TRUE; + int i; + for (i = 10; i < 20; i ++) + { + char * txt = Text[i]; + if (txt) + { + puts(txt); + #ifndef DEBUG + std = FALSE; + #endif + } + } + if (std) puts(Copr); + SetStatAdr(); + if (StatAdr != VGAST1_) ++ Mono; + if (IsVga()) + { + OldColors = farnew(DAC, 256); + NewColors = farnew(DAC, 256); + OldScreen = SaveScreen(); + GetColors(OldColors); + Sunset(); + OldMode = SetMode(mode); + SetColors(); + Setup(VideoMode); + Clear(); + } +} + + + + + +VGA::~VGA (void) +{ + Mono = 0; + if (IsVga()) + { + Clear(); + SetMode(OldMode); + SetColors(); + RestoreScreen(OldScreen); + Sunrise(OldColors); + if (OldColors) farfree(OldColors); + if (NewColors) farfree(NewColors); + if (Msg) fputs(Msg, stderr); + if (Nam) + { + fputs(" [", stderr); + fputs(Nam, stderr); + fputc(']', stderr); + } + if (Msg || Nam) fputc('\n', stderr); + #ifdef REPORT + fputs(Report, stderr); + #endif + } +} + + + + + +void VGA::SetStatAdr (void) +{ + asm mov dx,VGAMIr_ + asm in al,dx + asm test al,1 // CGA addressing mode flag + asm mov ax,VGAST1_ // CGA addressing + asm jnz set_mode_adr + asm xor al,0x60 // MDA addressing + set_mode_adr: + StatAdr = _AX; +} + + + + + + +#pragma argsused +void VGA::WaitVR (Boolean on) +{ + _DX = StatAdr; + _AH = (on) ? 0x00 : 0x08; + + asm mov cx,2 + // wait for vertical retrace on (off) + wait: + asm in al,dx + asm xor al,ah + asm test al,0x08 + asm jnz wait + asm xor ah,0x08 + asm loop wait +} + + + + + + +void VGA::Setup (VgaRegBlk * vrb) +{ + WaitVR(); // *--LOOK!--* resets VGAATR logic + asm cld + asm mov si, vrb // take address of parameter table + asm mov dh,0x03 // higher byte of I/O address is always 3 + + s: + asm lodsw // take lower byte of I/O address and index + asm or ah,ah // 0 = end of table + asm jz xit // no more: exit + asm or al,al // indexed register? + asm js single // 7th bit set means single register + asm mov dl,ah // complete I/O address + asm out dx,al // put index into control register + asm inc dx // data register is next to control + asm in al,dx // take old data + + write: + asm mov cl,al // preserve old data + asm lodsw // take 2 masks from table + asm xor al,0xFF // invert mask bits + asm and al,cl // clear bits with "clr" mask + asm or al,ah // set bits with "set" mask + asm cmp dl,0xC1 // special case? + asm jne std2 // no: standard job, otherwise... + asm dec dx // data out reg shares address with index + std2: + asm out dx,al // write new value to register + asm jmp s + + single: // read address in al, write address in ah + asm mov dl,al // complete I/O read address + asm in al,dx // take old data + asm mov dl,ah // complete I/O write address + asm jmp write // continue standard routine + + xit: +} + + + + + + +int VGA::SetMode (int mode) +{ + Clear(); + // get current mode + asm mov ah,0x0F + Video(); // BIOS video service + asm xor ah,ah + asm push ax + + // wait for v-retrace + WaitVR(); + + // set mode + asm xor ah,ah + asm mov al,byte ptr mode + Video(); // BIOS video service + SetStatAdr(); + // return previous mode + asm pop ax + return _AX; +} + + + + + + +void VGA::GetColors (DAC far * tab) +{ + asm cld + asm les di,tab // color table + asm mov dx,0x3C7 // PEL address read mode register + asm xor al,al // start from address 0 + asm out dx,al // put address + asm mov cx,256*3 // # of colors + asm mov dl,0xC9 // PEL data register + +// asm rep insb // very fast! + + gc: // much slower: + asm in al,dx // take 1 color + asm jmp sto // little delay + sto: + asm stosb // store 1 color + asm loop gc // next one? +} + + + + +void VGA::SetColors (DAC far * tab, int lum) +{ + DAC far * des = NewColors; + asm push ds + + asm les di,des + asm lds si,tab + asm mov cx,256*3 + asm xor bx,bx + asm mov dx,lum + + copcol: + asm mov al,[si+bx] + asm mul dl + asm shr ax,6 + asm mov es:[di+bx],al + asm inc bx + asm cmp bx,cx + asm jb copcol + + asm pop ds + + if (Mono) + { + asm add cx,di + mono: + asm xor dx,dx + asm mov al,77 // 30% R + asm mul byte ptr es:[di].0 + asm add dx,ax + asm mov al,151 // 59% G + asm mul byte ptr es:[di].1 + asm add dx,ax + asm mov al,28 // 11% B + asm mul byte ptr es:[di].2 + asm add dx,ax + + asm mov es:[di].0,dh + asm mov es:[di].1,dh + asm mov es:[di].2,dh + + asm add di,3 + asm cmp di,cx + asm jb mono + } + SetPal = TRUE; +} + + + + + + +void VGA::SetColors (void) +{ + _fmemset(NewColors, 0, PAL_SIZ); + UpdateColors(); +} + + + + + + +void VGA::Sunrise (DAC far * tab) +{ + int i; + for (i = 0; i <= 64; i += FADE_STEP) + { + SetColors(tab, i); + WaitVR(); + UpdateColors(); + } +} + + + + + + +void VGA::Sunset (void) +{ + DAC tab[256]; + int i; + GetColors(tab); + for (i = 64; i >= 0; i -= FADE_STEP) + { + SetColors(tab, i); + WaitVR(); + UpdateColors(); + } +} + + + + + + + + + +void VGA::Show (void) +{ + SPRITE * spr = ShowQ.First(); + + for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Show(); + Update(); + for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Hide(); + + ++ FrmCnt; +} + + + + +void VGA::UpdateColors (void) +{ + DAC far * tab = NewColors; + + asm push ds + asm cld + asm lds si,tab // color table + asm mov dx,0x3C8 // PEL address write mode register + asm xor al,al // start from address 0 + asm out dx,al // put address + asm mov cx,256*3 // # of colors + asm mov dl,0xC9 // PEL data register + +// asm rep outsb // very fast! + + // the slower version of above: + sc: + asm lodsb // take 1/3 color + asm out dx,al // put 1/3 color + asm jmp loop // little delay + loop: + asm loop sc // next one? + + + asm pop ds +} + + + + + + + +void VGA::Update (void) +{ + byte far * p = Page[1]; + Page[1] = Page[0]; + Page[0] = p; + + asm mov dx,VGACRT_ + asm mov al,0x0D + asm mov ah,byte ptr p + asm out dx,ax + asm dec al + asm mov ah,byte ptr p+1 + asm out dx,ax + + if (! SpeedTest) WaitVR(); + + if (SetPal) + { + UpdateColors(); + SetPal = FALSE; + } +} + + + + + + + + +void VGA::Clear (byte color) +{ + byte far * a = (byte far *) MK_FP(SCR_SEG, 0); + + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // map mask register - enable all planes + asm out dx,ax + asm les di,a + asm cld + + asm mov cx,0xFFFF + asm mov al,color + asm rep stosb + asm stosb +} + + + + + + +void VGA::CopyPage (word d, word s) +{ + byte far * S = Page[s & 3], far * D = Page[d & 3]; + + asm mov dx,VGAGRA_ + asm mov al,0x05 // R/W mode + asm out dx,al + asm inc dx + asm in al,dx + asm and al,0xF4 + asm push ax + asm push dx + asm or al,0x01 + asm out dx,al + + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // map mask register - enable all planes + asm out dx,ax + + asm push ds + + asm les di,D + asm lds si,S + asm cld + asm mov cx,0x4000 + asm rep movsb + + asm pop ds + + asm pop dx + asm pop ax + asm out dx,al // end of copy mode +} + + + + + + + +void VGA::Exit (const char * txt, const char * name) +{ + Msg = txt; + Nam = name; + #ifdef REPORT + wtom(coreleft(), Report + NREP, 10, 5); + dwtom(farcoreleft(), Report + FREP, 10, 6); + #endif + exit(0); +} + + + + +void VGA::Exit (int tref, const char * name) +{ + Exit(Text[tref], name); +} + + + + +//-------------------------------------------------------------------------- + + + + +void BITMAP::XShow (int x, int y) +{ + byte rmsk = x % 4, + mask = 1 << rmsk, + far * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + byte near * m = (char *) M; + byte far * v = V; + + asm push bx + asm push si + asm push ds + + asm cld + asm les di,scr + asm lds si,v + asm mov bx,m + + + + asm mov al,0x02 // map mask register + asm mov ah,mask + + plane: + // enable output plane + asm mov dx,VGASEQ_ + asm out dx,ax + asm push ax + + // select input plane + asm mov dx,VGAGRA_ + asm mov al,0x04 // read map select register + asm mov ah,rmsk + asm out dx,ax + + asm push di + + block: + asm lodsw + asm mov cx,ax + asm and ch,0x3F + asm test ah,0xC0 + asm jz endpl + asm jns skip + asm jnp incsi // replicate? + asm add si,cx // skip over data block + asm dec si // fix it before following inc + + incsi: + asm inc si + tint: + asm mov al,es:[di] + //----------------------------------------------- + // asm xlat ss:0 // unsupported with BASM! + __emit__(0x36, 0xD7); // this stands for above! + //----------------------------------------------- + asm stosb + asm loop tint + asm jmp block + + skip: + asm add di,cx + asm jmp block + + endpl: + asm pop di + asm pop ax + asm inc rmsk + asm shl ah,1 + asm test ah,0x10 + asm jz x_chk + asm mov ah,0x01 + asm mov rmsk,0 + asm inc di + x_chk: + asm cmp ah,mask + asm jne plane + asm pop ds + asm pop si + asm pop bx +} + + + + + + +void BITMAP::Show (int x, int y) +{ + byte mask = 1 << (x & 3), + far * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); + byte far * v = V; + + asm push ds // preserve DS + + asm cld // normal direction + asm les di,scr // screen address + asm lds si,v // picture address + asm mov dx,VGASEQ_ // VGA reg + asm mov al,0x02 + asm mov ah,mask + + plane: + asm out dx,ax + asm push ax + asm push di + + block: + asm mov cx,[si] // with ADD faster then LODSW + asm add si,2 + asm test ch,0xC0 + asm jns skip // 1 (SKP) or 0 (EOI) + asm jpo repeat // 2 (REP) + + copy: // 3 (CPY) + asm and ch,0x3F + asm shr cx,1 + asm rep movsw + asm jnc block + asm movsb + asm jmp block + + repeat: + asm and ch,0x3F + asm mov al,[si] + asm inc si + asm mov ah,al + asm shr cx,1 + asm rep stosw + asm jnc block + asm mov es:[di],al + asm inc di + asm jmp block + + skip: + asm jz endpl + asm and ch,0x3F + asm add di,cx + asm jmp block + + endpl: + asm pop di + asm pop ax + asm shl ah,1 + asm test ah,0x10 + asm jz x_chk + asm mov ah,0x01 + asm inc di + x_chk: + asm cmp ah,mask + asm jne plane + asm pop ds +} + + + + + +void BITMAP::Hide (int x, int y) +{ + byte far * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + word d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); + HideDesc far * b = B; + word extra = ((x & 3) != 0); + word h = H; + +// asm push bx + asm push si + asm push ds + + asm cld + asm les di,scr + asm mov si,di + asm add si,d // take bytes from background page + asm lds bx,b + + asm mov dx,VGAGRA_ + asm mov al,0x05 // R/W mode + asm out dx,al + asm inc dx + asm in al,dx + asm and al,0xF4 + asm push ax + asm push dx + asm or al,0x01 + asm out dx,al + + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // enable all planes + asm out dx,ax + + asm mov dx,ds // save DS + + row: +// skip block + asm mov cx,[bx] + asm add si,cx + asm add di,cx + asm mov cx,[bx+2] + asm add bx,4 + asm add cx,extra + + asm push es + asm pop ds // set DS to video seg + asm rep movsb // move bytes fast + asm sub si,extra + asm sub di,extra + asm mov ds,dx // restore DS + + asm dec h + asm jnz row + + asm pop dx + asm pop ax + asm out dx,al // end of copy mode + + + asm pop ds + asm pop si +// asm pop bx +} + + + + + + + +//-------------------------------------------------------------------------- + + + -- cgit v1.2.3 From 03c540abffe39a7ea32173c2cf8f5e70d371588b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 10 Jun 2011 07:45:18 +0200 Subject: CGE: Add default header, fix some includes --- engines/cge/vga13h.cpp | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 227304668b..404b4f8bf8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1,8 +1,35 @@ -#include -#include "vga13h.h" -#include "bitmap.h" -#include "vol.h" -#include "text.h" +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "cge/general.h" +#include "cge/vga13h.h" +#include "cge/bitmap.h" +#include "cge/vol.h" +#include "cge/text.h" #include #include #include -- cgit v1.2.3 From a5c569eff2c4e2f30ef0523169ab22ed92f9894a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 10 Jun 2011 09:14:43 +0200 Subject: CGE: Remove far and near keywords --- engines/cge/vga13h.cpp | 66 +++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 404b4f8bf8..84dbd802fd 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -136,9 +136,9 @@ static void Video (void) -word far * SaveScreen (void) +word * SaveScreen (void) { - word cxy, cur, siz, far * scr = NULL, far * sav; + word cxy, cur, siz, * scr = NULL, * sav; // horizontal size of text mode screen asm mov ah,0x0F // get current video mode @@ -194,9 +194,9 @@ word far * SaveScreen (void) -void RestoreScreen (word far * &sav) +void RestoreScreen (word * &sav) { - word far * scr = NULL; + word * scr = NULL; asm mov ax,0x40 // system data segment asm mov es,ax @@ -486,7 +486,7 @@ BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) -void SPRITE::MoveShapes (byte far * buf) +void SPRITE::MoveShapes (byte * buf) { BMP_PTR * p; for (p = Ext->ShpList; *p; p ++) @@ -779,7 +779,7 @@ void SPRITE::Tick (void) -void SPRITE::MakeXlat (byte far * x) +void SPRITE::MakeXlat (byte * x) { if (Ext) { @@ -800,7 +800,7 @@ void SPRITE::KillXlat (void) if (Flags.Xlat && Ext) { BMP_PTR * b; - byte far * m = (*Ext->ShpList)->M; + byte * m = (*Ext->ShpList)->M; switch (MemType(m)) { @@ -885,7 +885,7 @@ void SPRITE::Show (void) void SPRITE::Show (word pg) { - byte far * a = VGA::Page[1]; + byte * a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; Shp()->Show(X, Y); VGA::Page[1] = a; @@ -912,13 +912,13 @@ BMP_PTR SPRITE::Ghost (void) register SPREXT * e = Ext; if (e->b1) { - BMP_PTR bmp = new BITMAP(0, 0, (byte far *)NULL); + BMP_PTR bmp = new BITMAP(0, 0, (byte *)NULL); if (bmp == NULL) VGA::Exit("No core"); bmp->W = e->b1->W; bmp->H = e->b1->H; if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) VGA::Exit("No Core"); - bmp->V = (byte far *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); - bmp->M = (byte far *) MK_FP(e->y1, e->x1); + bmp->V = (byte *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + bmp->M = (byte *) MK_FP(e->y1, e->x1); return bmp; } return NULL; @@ -1085,18 +1085,18 @@ SPRITE * QUEUE::Locate (int ref) word VGA::StatAdr = VGAST1_; word VGA::OldMode = 0; -word far * VGA::OldScreen = NULL; +word * VGA::OldScreen = NULL; const char * VGA::Msg = NULL; const char * VGA::Nam = NULL; -DAC far * VGA::OldColors = NULL; -DAC far * VGA::NewColors = NULL; +DAC * VGA::OldColors = NULL; +DAC * VGA::NewColors = NULL; Boolean VGA::SetPal = FALSE; int VGA::Mono = 0; QUEUE VGA::ShowQ = TRUE, VGA::SpareQ = FALSE; -byte far * VGA::Page[4] = { (byte far *) MK_FP(SCR_SEG, 0x0000), - (byte far *) MK_FP(SCR_SEG, 0x4000), - (byte far *) MK_FP(SCR_SEG, 0x8000), - (byte far *) MK_FP(SCR_SEG, 0xC000) }; +byte * VGA::Page[4] = { (byte *) MK_FP(SCR_SEG, 0x0000), + (byte *) MK_FP(SCR_SEG, 0x4000), + (byte *) MK_FP(SCR_SEG, 0x8000), + (byte *) MK_FP(SCR_SEG, 0xC000) }; @@ -1280,7 +1280,7 @@ int VGA::SetMode (int mode) -void VGA::GetColors (DAC far * tab) +void VGA::GetColors (DAC * tab) { asm cld asm les di,tab // color table @@ -1303,9 +1303,9 @@ void VGA::GetColors (DAC far * tab) -void VGA::SetColors (DAC far * tab, int lum) +void VGA::SetColors (DAC * tab, int lum) { - DAC far * des = NewColors; + DAC * des = NewColors; asm push ds asm les di,des @@ -1367,7 +1367,7 @@ void VGA::SetColors (void) -void VGA::Sunrise (DAC far * tab) +void VGA::Sunrise (DAC * tab) { int i; for (i = 0; i <= 64; i += FADE_STEP) @@ -1420,7 +1420,7 @@ void VGA::Show (void) void VGA::UpdateColors (void) { - DAC far * tab = NewColors; + DAC * tab = NewColors; asm push ds asm cld @@ -1453,7 +1453,7 @@ void VGA::UpdateColors (void) void VGA::Update (void) { - byte far * p = Page[1]; + byte * p = Page[1]; Page[1] = Page[0]; Page[0] = p; @@ -1483,7 +1483,7 @@ void VGA::Update (void) void VGA::Clear (byte color) { - byte far * a = (byte far *) MK_FP(SCR_SEG, 0); + byte * a = (byte *) MK_FP(SCR_SEG, 0); asm mov dx,VGASEQ_ asm mov ax,0x0F02 // map mask register - enable all planes @@ -1504,7 +1504,7 @@ void VGA::Clear (byte color) void VGA::CopyPage (word d, word s) { - byte far * S = Page[s & 3], far * D = Page[d & 3]; + byte * S = Page[s & 3], * D = Page[d & 3]; asm mov dx,VGAGRA_ asm mov al,0x05 // R/W mode @@ -1573,9 +1573,9 @@ void BITMAP::XShow (int x, int y) { byte rmsk = x % 4, mask = 1 << rmsk, - far * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - byte near * m = (char *) M; - byte far * v = V; + * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + byte * m = (char *) M; + byte * v = V; asm push bx asm push si @@ -1658,8 +1658,8 @@ void BITMAP::XShow (int x, int y) void BITMAP::Show (int x, int y) { byte mask = 1 << (x & 3), - far * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); - byte far * v = V; + * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); + byte * v = V; asm push ds // preserve DS @@ -1728,9 +1728,9 @@ void BITMAP::Show (int x, int y) void BITMAP::Hide (int x, int y) { - byte far * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + byte * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; word d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); - HideDesc far * b = B; + HideDesc * b = B; word extra = ((x & 3) != 0); word h = H; -- cgit v1.2.3 From 68f7ff111536c2d7f5a8869252ba8ad31507a380 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 10 Jun 2011 13:06:03 +0200 Subject: CGE: Replace Boolean, TRUE and FALSE by bool, true, false --- engines/cge/vga13h.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 84dbd802fd..386ccca140 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -85,7 +85,7 @@ static VgaRegBlk VideoMode[] = { { 0x00 } }; - Boolean SpeedTest = FALSE; + bool SpeedTest = false; SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; SPRITE * Sys = NULL; @@ -267,7 +267,7 @@ SPRITE * Locate (int ref) //-------------------------------------------------------------------------- -Boolean HEART::Enable = FALSE; +bool HEART::Enable = false; word * HEART::XTimer = NULL; @@ -499,7 +499,7 @@ void SPRITE::MoveShapes (byte * buf) -Boolean SPRITE::Works (SPRITE * spr) +bool SPRITE::Works (SPRITE * spr) { if (spr) if (spr->Ext) { @@ -509,10 +509,10 @@ Boolean SPRITE::Works (SPRITE * spr) c += spr->TakePtr; if (c->Ref == Ref) if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) - return TRUE; + return true; } } - return FALSE; + return false; } @@ -535,11 +535,11 @@ SEQ * SPRITE::SetSeq (SEQ * seq) -Boolean SPRITE::SeqTest (int n) +bool SPRITE::SeqTest (int n) { if (n >= 0) return (SeqPtr == n); if (Ext) return (Ext->Seq[SeqPtr].Next == SeqPtr); - return TRUE; + return true; } @@ -584,8 +584,8 @@ SPRITE * SPRITE::Expand (void) { if (! Ext) { - Boolean enbl = HEART::Enable; - HEART::Enable = FALSE; + bool enbl = HEART::Enable; + HEART::Enable = false; if ((Ext = new SPREXT) == NULL) DROP("No core", NULL); if (*File) { @@ -732,7 +732,7 @@ SPRITE * SPRITE::Contract (void) -SPRITE * SPRITE::BackShow (Boolean fast) +SPRITE * SPRITE::BackShow (bool fast) { Expand(); Show(2); @@ -787,7 +787,7 @@ void SPRITE::MakeXlat (byte * x) if (Flags.Xlat) KillXlat(); for (b = Ext->ShpList; *b; b ++) (*b)->M = x; - Flags.Xlat = TRUE; + Flags.Xlat = true; } } @@ -808,7 +808,7 @@ void SPRITE::KillXlat (void) case FAR_MEM : farfree(m); break; } for (b = Ext->ShpList; *b; b ++) (*b)->M = NULL; - Flags.Xlat = FALSE; + Flags.Xlat = false; } } @@ -953,7 +953,7 @@ SPRITE * SpriteAt (int x, int y) -QUEUE::QUEUE (Boolean show) +QUEUE::QUEUE (bool show) : Head(NULL), Tail(NULL), Show(show) { } @@ -1090,9 +1090,9 @@ const char * VGA::Msg = NULL; const char * VGA::Nam = NULL; DAC * VGA::OldColors = NULL; DAC * VGA::NewColors = NULL; -Boolean VGA::SetPal = FALSE; +bool VGA::SetPal = false; int VGA::Mono = 0; -QUEUE VGA::ShowQ = TRUE, VGA::SpareQ = FALSE; +QUEUE VGA::ShowQ = true, VGA::SpareQ = false; byte * VGA::Page[4] = { (byte *) MK_FP(SCR_SEG, 0x0000), (byte *) MK_FP(SCR_SEG, 0x4000), (byte *) MK_FP(SCR_SEG, 0x8000), @@ -1105,7 +1105,7 @@ VGA::VGA (int mode) : FrmCnt(0) { extern const char Copr[]; - Boolean std = TRUE; + bool std = true; int i; for (i = 10; i < 20; i ++) { @@ -1114,7 +1114,7 @@ VGA::VGA (int mode) { puts(txt); #ifndef DEBUG - std = FALSE; + std = false; #endif } } @@ -1187,7 +1187,7 @@ void VGA::SetStatAdr (void) #pragma argsused -void VGA::WaitVR (Boolean on) +void VGA::WaitVR (bool on) { _DX = StatAdr; _AH = (on) ? 0x00 : 0x08; @@ -1348,7 +1348,7 @@ void VGA::SetColors (DAC * tab, int lum) asm cmp di,cx asm jb mono } - SetPal = TRUE; + SetPal = true; } @@ -1470,7 +1470,7 @@ void VGA::Update (void) if (SetPal) { UpdateColors(); - SetPal = FALSE; + SetPal = false; } } -- cgit v1.2.3 From 7d88b9e4cde321ec210c5da022046639a316179b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 10 Jun 2011 19:02:13 +0200 Subject: CGE: Suppress typedef for byte, word and dword. --- engines/cge/vga13h.cpp | 96 +++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 386ccca140..e2588b74f5 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -113,7 +113,7 @@ char * NumStr (char * str, int num) static void Video (void) { - static word SP_S; + static uint16 SP_S; asm push bx asm push bp @@ -136,9 +136,9 @@ static void Video (void) -word * SaveScreen (void) +uint16 * SaveScreen (void) { - word cxy, cur, siz, * scr = NULL, * sav; + uint16 cxy, cur, siz, * scr = NULL, * sav; // horizontal size of text mode screen asm mov ah,0x0F // get current video mode @@ -179,7 +179,7 @@ word * SaveScreen (void) _AH = 0x03; Video(); // get cursor cxy = _DX; - sav = farnew(word, siz+3); // +3 extra words for size and cursor + sav = farnew(uint16, siz+3); // +3 extra uint16s for size and cursor if (sav) { sav[0] = siz; @@ -194,9 +194,9 @@ word * SaveScreen (void) -void RestoreScreen (word * &sav) +void RestoreScreen (uint16 * &sav) { - word * scr = NULL; + uint16 * scr = NULL; asm mov ax,0x40 // system data segment asm mov es,ax @@ -228,7 +228,7 @@ void RestoreScreen (word * &sav) -DAC MkDAC (byte r, byte g, byte b) +DAC MkDAC (uint8 r, uint8 g, uint8 b) { static DAC x; x.R = r; @@ -240,7 +240,7 @@ DAC MkDAC (byte r, byte g, byte b) -RGB MkRGB (byte r, byte g, byte b) +RGB MkRGB (uint8 r, uint8 g, uint8 b) { static TRGB x; x.dac.R = r; @@ -268,7 +268,7 @@ SPRITE * Locate (int ref) bool HEART::Enable = false; -word * HEART::XTimer = NULL; +uint16 * HEART::XTimer = NULL; @@ -283,16 +283,16 @@ HEART::HEART (void) extern "C" void TimerProc (void) { static SPRITE * spr; - static byte run = 0; + static uint8 run = 0; - // decrement external timer word + // decrement external timer uint16 if (HEART::XTimer) if (*HEART::XTimer) -- *HEART::XTimer; else HEART::XTimer = NULL; if (! run && HEART::Enable) // check overrun flag { - static word oldSP, oldSS; + static uint16 oldSP, oldSS; ++ run; // disable 2nd call until current lasts asm mov ax,ds @@ -319,7 +319,7 @@ extern "C" void TimerProc (void) void interrupt ENGINE::NewTimer (...) { static SPRITE * spr; - static byte run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; + static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; ___1152_Hz___: @@ -350,14 +350,14 @@ void interrupt ENGINE::NewTimer (...) my_int: //------72Hz-------// - // decrement external timer word + // decrement external timer uint16 if (HEART::XTimer) if (*HEART::XTimer) -- *HEART::XTimer; else HEART::XTimer = NULL; if (! run && HEART::Enable) // check overrun flag { - static word oldSP, oldSS; + static uint16 oldSP, oldSS; ++ run; // disable 2nd call until current lasts asm mov ax,ds @@ -383,7 +383,7 @@ void interrupt ENGINE::NewTimer (...) -void HEART::SetXTimer (word * ptr) +void HEART::SetXTimer (uint16 * ptr) { if (XTimer && ptr != XTimer) *XTimer = 0; XTimer = ptr; @@ -392,7 +392,7 @@ void HEART::SetXTimer (word * ptr) -void HEART::SetXTimer (word * ptr, word time) +void HEART::SetXTimer (uint16 * ptr, uint16 time) { SetXTimer(ptr); *ptr = time; @@ -415,7 +415,7 @@ SPRITE::SPRITE (BMP_PTR * shp) Ext(NULL), Ref(-1), Cave(0) { memset(File, 0, sizeof(File)); - *((word *)&Flags) = 0; + *((uint16 *)&Flags) = 0; SetShapeList(shp); } @@ -486,7 +486,7 @@ BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) -void SPRITE::MoveShapes (byte * buf) +void SPRITE::MoveShapes (uint8 * buf) { BMP_PTR * p; for (p = Ext->ShpList; *p; p ++) @@ -779,7 +779,7 @@ void SPRITE::Tick (void) -void SPRITE::MakeXlat (byte * x) +void SPRITE::MakeXlat (uint8 * x) { if (Ext) { @@ -800,11 +800,11 @@ void SPRITE::KillXlat (void) if (Flags.Xlat && Ext) { BMP_PTR * b; - byte * m = (*Ext->ShpList)->M; + uint8 * m = (*Ext->ShpList)->M; switch (MemType(m)) { - case NEAR_MEM : delete[] (byte *) m; break; + case NEAR_MEM : delete[] (uint8 *) m; break; case FAR_MEM : farfree(m); break; } for (b = Ext->ShpList; *b; b ++) (*b)->M = NULL; @@ -883,9 +883,9 @@ void SPRITE::Show (void) -void SPRITE::Show (word pg) +void SPRITE::Show (uint16 pg) { - byte * a = VGA::Page[1]; + uint8 * a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; Shp()->Show(X, Y); VGA::Page[1] = a; @@ -912,13 +912,13 @@ BMP_PTR SPRITE::Ghost (void) register SPREXT * e = Ext; if (e->b1) { - BMP_PTR bmp = new BITMAP(0, 0, (byte *)NULL); + BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); if (bmp == NULL) VGA::Exit("No core"); bmp->W = e->b1->W; bmp->H = e->b1->H; if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) VGA::Exit("No Core"); - bmp->V = (byte *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); - bmp->M = (byte *) MK_FP(e->y1, e->x1); + bmp->V = (uint8 *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + bmp->M = (uint8 *) MK_FP(e->y1, e->x1); return bmp; } return NULL; @@ -1083,9 +1083,9 @@ SPRITE * QUEUE::Locate (int ref) -word VGA::StatAdr = VGAST1_; -word VGA::OldMode = 0; -word * VGA::OldScreen = NULL; +uint16 VGA::StatAdr = VGAST1_; +uint16 VGA::OldMode = 0; +uint16 * VGA::OldScreen = NULL; const char * VGA::Msg = NULL; const char * VGA::Nam = NULL; DAC * VGA::OldColors = NULL; @@ -1093,10 +1093,10 @@ DAC * VGA::NewColors = NULL; bool VGA::SetPal = false; int VGA::Mono = 0; QUEUE VGA::ShowQ = true, VGA::SpareQ = false; -byte * VGA::Page[4] = { (byte *) MK_FP(SCR_SEG, 0x0000), - (byte *) MK_FP(SCR_SEG, 0x4000), - (byte *) MK_FP(SCR_SEG, 0x8000), - (byte *) MK_FP(SCR_SEG, 0xC000) }; +uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), + (uint8 *) MK_FP(SCR_SEG, 0x4000), + (uint8 *) MK_FP(SCR_SEG, 0x8000), + (uint8 *) MK_FP(SCR_SEG, 0xC000) }; @@ -1453,7 +1453,7 @@ void VGA::UpdateColors (void) void VGA::Update (void) { - byte * p = Page[1]; + uint8 * p = Page[1]; Page[1] = Page[0]; Page[0] = p; @@ -1481,9 +1481,9 @@ void VGA::Update (void) -void VGA::Clear (byte color) +void VGA::Clear (uint8 color) { - byte * a = (byte *) MK_FP(SCR_SEG, 0); + uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); asm mov dx,VGASEQ_ asm mov ax,0x0F02 // map mask register - enable all planes @@ -1502,9 +1502,9 @@ void VGA::Clear (byte color) -void VGA::CopyPage (word d, word s) +void VGA::CopyPage (uint16 d, uint16 s) { - byte * S = Page[s & 3], * D = Page[d & 3]; + uint8 * S = Page[s & 3], * D = Page[d & 3]; asm mov dx,VGAGRA_ asm mov al,0x05 // R/W mode @@ -1571,11 +1571,11 @@ void VGA::Exit (int tref, const char * name) void BITMAP::XShow (int x, int y) { - byte rmsk = x % 4, + uint8 rmsk = x % 4, mask = 1 << rmsk, * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - byte * m = (char *) M; - byte * v = V; + uint8 * m = (char *) M; + uint8 * v = V; asm push bx asm push si @@ -1657,9 +1657,9 @@ void BITMAP::XShow (int x, int y) void BITMAP::Show (int x, int y) { - byte mask = 1 << (x & 3), + uint8 mask = 1 << (x & 3), * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); - byte * v = V; + uint8 * v = V; asm push ds // preserve DS @@ -1728,11 +1728,11 @@ void BITMAP::Show (int x, int y) void BITMAP::Hide (int x, int y) { - byte * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - word d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); + uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); HideDesc * b = B; - word extra = ((x & 3) != 0); - word h = H; + uint16 extra = ((x & 3) != 0); + uint16 h = H; // asm push bx asm push si -- cgit v1.2.3 From 29065d302a9bf8bcaa18c4225e27b218bde67242 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 10 Jun 2011 22:57:09 +0200 Subject: CGE: Add namespaces --- engines/cge/vga13h.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e2588b74f5..415bff7225 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -41,6 +41,8 @@ #include #include +namespace CGE { + #ifdef DEBUG #define REPORT #endif @@ -1790,13 +1792,4 @@ void BITMAP::Hide (int x, int y) // asm pop bx } - - - - - - -//-------------------------------------------------------------------------- - - - +} // End of namespace CGE -- cgit v1.2.3 From 11264a60a7dc8e3e04b5b73f6794269f097010ff Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 11 Jun 2011 22:35:21 +0200 Subject: CGE: Stubbing and cleanup made by SylvainTV --- engines/cge/vga13h.cpp | 147 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 106 insertions(+), 41 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 415bff7225..86b04bfe0c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -30,15 +30,15 @@ #include "cge/bitmap.h" #include "cge/vol.h" #include "cge/text.h" -#include +//#include #include #include #include #include #include -#include +//#include #include -#include +//#include #include namespace CGE { @@ -112,11 +112,13 @@ char * NumStr (char * str, int num) - +// TODO Video ASM +/* static void Video (void) { static uint16 SP_S; + asm push bx asm push bp asm push si @@ -131,8 +133,9 @@ static void Video (void) asm pop si asm pop bp asm pop bx -} +} + */ @@ -140,6 +143,7 @@ static void Video (void) uint16 * SaveScreen (void) { + /* TODO ASM uint16 cxy, cur, siz, * scr = NULL, * sav; // horizontal size of text mode screen @@ -187,9 +191,11 @@ uint16 * SaveScreen (void) sav[0] = siz; sav[1] = cur; sav[2] = cxy; - _fmemcpy(sav+3, scr, siz * 2); + memcpy(sav+3, scr, siz * 2); } return sav; + */ + return 0; } @@ -198,6 +204,8 @@ uint16 * SaveScreen (void) void RestoreScreen (uint16 * &sav) { + // TODO RestoreScreen ASM + /* uint16 * scr = NULL; asm mov ax,0x40 // system data segment @@ -209,7 +217,7 @@ void RestoreScreen (uint16 * &sav) sto: // store screen address asm mov word ptr scr+2,ax - _fmemcpy(scr, sav+3, sav[0] * 2); + memcpy(scr, sav+3, sav[0] * 2); _AH = 0x0F; Video(); // active page @@ -221,8 +229,9 @@ void RestoreScreen (uint16 * &sav) _DX = sav[2]; _AH = 0x02; Video(); // set cursor - farfree(sav); + free(sav); sav = NULL; + */ } @@ -318,11 +327,12 @@ extern "C" void TimerProc (void) */ -void interrupt ENGINE::NewTimer (...) +void ENGINE::NewTimer (...) { static SPRITE * spr; static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; - + // TODO Timer ASM + /* ___1152_Hz___: SNDMIDIPlay(); @@ -379,6 +389,8 @@ void interrupt ENGINE::NewTimer (...) asm mov sp,oldSP -- run; } + + */ } @@ -591,7 +603,7 @@ SPRITE * SPRITE::Expand (void) if ((Ext = new SPREXT) == NULL) DROP("No core", NULL); if (*File) { - static char * Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; + static const char * Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[LINE_MAX], fname[MAXPATH]; BMP_PTR * shplist = new BMP_PTR [ShpCnt+1]; SEQ * seq = NULL; @@ -615,7 +627,7 @@ SPRITE * SPRITE::Expand (void) VGA::Exit("Bad SPR", fname); } - while ((len = sprf.Read(line)) != 0) + while ((len = sprf.Read((uint8*)line)) != 0) { ++ lcnt; if (len && line[len-1] == '\n') line[-- len] = '\0'; @@ -624,11 +636,16 @@ SPRITE * SPRITE::Expand (void) switch (TakeEnum(Comd, strtok(line, " =\t"))) { case 0 : // Name + { SetName(strtok(NULL, "")); break; + } case 1 : // Phase + { shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/")); break; + } case 2 : // Seq + { seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); if (seq == NULL) VGA::Exit("No core", fname); @@ -646,7 +663,9 @@ SPRITE * SPRITE::Expand (void) s->Dy = atoi(strtok(NULL, " \t,;/")); s->Dly = atoi(strtok(NULL, " \t,;/")); break; + } case 3 : // Near + { if (NearPtr != NO_PTR) { nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); @@ -661,8 +680,10 @@ SPRITE * SPRITE::Expand (void) c->Ptr = NULL; } } + } break; case 4 : // Take + { if (TakePtr != NO_PTR) { tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); @@ -678,6 +699,7 @@ SPRITE * SPRITE::Expand (void) } } break; + } } } } @@ -693,10 +715,10 @@ SPRITE * SPRITE::Expand (void) SetSeq(seq); } else SetSeq((ShpCnt == 1) ? Seq1 : Seq2); - disable(); + //disable(); // disable interupt SetShapeList(shplist); - enable(); + //enable(); // enable interupt if (nea) nea[neacnt-1].Ptr = Ext->Near = nea; else NearPtr = NO_PTR; if (tak) tak[takcnt-1].Ptr = Ext->Take = tak; else TakePtr = NO_PTR; } @@ -807,7 +829,7 @@ void SPRITE::KillXlat (void) switch (MemType(m)) { case NEAR_MEM : delete[] (uint8 *) m; break; - case FAR_MEM : farfree(m); break; + case FAR_MEM : free(m); break; } for (b = Ext->ShpList; *b; b ++) (*b)->M = NULL; Flags.Xlat = false; @@ -863,7 +885,7 @@ void SPRITE::Center (void) void SPRITE::Show (void) { register SPREXT * e; - asm cli // critic section... + // asm cli // critic section... e = Ext; e->x0 = e->x1; e->y0 = e->y1; @@ -871,7 +893,7 @@ void SPRITE::Show (void) e->x1 = X; e->y1 = Y; e->b1 = Shp(); - asm sti // ...done! +// asm sti // ...done! if (! Flags.Hide) { if (Flags.Xlat) e->b1->XShow(e->x1, e->y1); @@ -919,8 +941,9 @@ BMP_PTR SPRITE::Ghost (void) bmp->W = e->b1->W; bmp->H = e->b1->H; if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) VGA::Exit("No Core"); - bmp->V = (uint8 *) _fmemcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); - bmp->M = (uint8 *) MK_FP(e->y1, e->x1); + bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment + //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); return bmp; } return NULL; @@ -1095,11 +1118,16 @@ DAC * VGA::NewColors = NULL; bool VGA::SetPal = false; int VGA::Mono = 0; QUEUE VGA::ShowQ = true, VGA::SpareQ = false; + +// TODO: Was direct mapping to VGA buffers.. need to create scummvm surfaces for that +uint8 * VGA::Page[4] = { 0, 0, 0, 0 }; + +/* uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), (uint8 *) MK_FP(SCR_SEG, 0x4000), (uint8 *) MK_FP(SCR_SEG, 0x8000), (uint8 *) MK_FP(SCR_SEG, 0xC000) }; - +*/ @@ -1114,13 +1142,16 @@ VGA::VGA (int mode) char * txt = Text[i]; if (txt) { - puts(txt); - #ifndef DEBUG +// puts(txt); + warning(txt); + #ifndef DEBUG std = false; #endif } } - if (std) puts(Copr); + if (std) +// puts(Copr); + warning(Copr); SetStatAdr(); if (StatAdr != VGAST1_) ++ Mono; if (IsVga()) @@ -1146,33 +1177,27 @@ VGA::~VGA (void) Mono = 0; if (IsVga()) { + Common::String buffer = ""; Clear(); SetMode(OldMode); SetColors(); RestoreScreen(OldScreen); Sunrise(OldColors); - if (OldColors) farfree(OldColors); - if (NewColors) farfree(NewColors); - if (Msg) fputs(Msg, stderr); + if (OldColors) free(OldColors); + if (NewColors) free(NewColors); + if (Msg) + buffer = Common::String(Msg); if (Nam) - { - fputs(" [", stderr); - fputs(Nam, stderr); - fputc(']', stderr); - } - if (Msg || Nam) fputc('\n', stderr); - #ifdef REPORT - fputs(Report, stderr); - #endif + buffer = buffer + " [" + Nam + "]"; + + warning(buffer.c_str()); } } - - - void VGA::SetStatAdr (void) { + /* TODO SetStatADR ASM asm mov dx,VGAMIr_ asm in al,dx asm test al,1 // CGA addressing mode flag @@ -1181,6 +1206,7 @@ void VGA::SetStatAdr (void) asm xor al,0x60 // MDA addressing set_mode_adr: StatAdr = _AX; + */ } @@ -1191,6 +1217,8 @@ void VGA::SetStatAdr (void) #pragma argsused void VGA::WaitVR (bool on) { + // TODO Wait vertical retrace ASM +/* _DX = StatAdr; _AH = (on) ? 0x00 : 0x08; @@ -1203,6 +1231,7 @@ void VGA::WaitVR (bool on) asm jnz wait asm xor ah,0x08 asm loop wait + */ } @@ -1212,6 +1241,7 @@ void VGA::WaitVR (bool on) void VGA::Setup (VgaRegBlk * vrb) { +/* TODO VGA setup WaitVR(); // *--LOOK!--* resets VGAATR logic asm cld asm mov si, vrb // take address of parameter table @@ -1248,6 +1278,7 @@ void VGA::Setup (VgaRegBlk * vrb) asm jmp write // continue standard routine xit: + */ } @@ -1257,6 +1288,8 @@ void VGA::Setup (VgaRegBlk * vrb) int VGA::SetMode (int mode) { + /* TODO VGA Set Mode + Clear(); // get current mode asm mov ah,0x0F @@ -1275,6 +1308,8 @@ int VGA::SetMode (int mode) // return previous mode asm pop ax return _AX; + */ + return 0; } @@ -1284,6 +1319,7 @@ int VGA::SetMode (int mode) void VGA::GetColors (DAC * tab) { + /* TODO GetColors ASM asm cld asm les di,tab // color table asm mov dx,0x3C7 // PEL address read mode register @@ -1300,6 +1336,8 @@ void VGA::GetColors (DAC * tab) sto: asm stosb // store 1 color asm loop gc // next one? + + */ } @@ -1307,6 +1345,9 @@ void VGA::GetColors (DAC * tab) void VGA::SetColors (DAC * tab, int lum) { + + /* TODO SetColors + DAC * des = NewColors; asm push ds @@ -1350,6 +1391,7 @@ void VGA::SetColors (DAC * tab, int lum) asm cmp di,cx asm jb mono } + */ SetPal = true; } @@ -1360,7 +1402,7 @@ void VGA::SetColors (DAC * tab, int lum) void VGA::SetColors (void) { - _fmemset(NewColors, 0, PAL_SIZ); + memset(NewColors, 0, PAL_SIZ); UpdateColors(); } @@ -1422,6 +1464,7 @@ void VGA::Show (void) void VGA::UpdateColors (void) { + /* TODO UpdateColors ASM DAC * tab = NewColors; asm push ds @@ -1445,6 +1488,7 @@ void VGA::UpdateColors (void) asm pop ds + */ } @@ -1455,6 +1499,8 @@ void VGA::UpdateColors (void) void VGA::Update (void) { + // TODO VGA Update + /* uint8 * p = Page[1]; Page[1] = Page[0]; Page[0] = p; @@ -1466,7 +1512,7 @@ void VGA::Update (void) asm dec al asm mov ah,byte ptr p+1 asm out dx,ax - +*/ if (! SpeedTest) WaitVR(); if (SetPal) @@ -1485,6 +1531,7 @@ void VGA::Update (void) void VGA::Clear (uint8 color) { + /* TODO Clear ASM uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); asm mov dx,VGASEQ_ @@ -1497,6 +1544,7 @@ void VGA::Clear (uint8 color) asm mov al,color asm rep stosb asm stosb + */ } @@ -1506,6 +1554,7 @@ void VGA::Clear (uint8 color) void VGA::CopyPage (uint16 d, uint16 s) { + /* TODO CopyPage uint8 * S = Page[s & 3], * D = Page[d & 3]; asm mov dx,VGAGRA_ @@ -1536,6 +1585,7 @@ void VGA::CopyPage (uint16 d, uint16 s) asm pop dx asm pop ax asm out dx,al // end of copy mode + */ } @@ -1546,13 +1596,17 @@ void VGA::CopyPage (uint16 d, uint16 s) void VGA::Exit (const char * txt, const char * name) { + // TODO Properly exit + /* Msg = txt; Nam = name; - #ifdef REPORT + + #ifdef REPORT wtom(coreleft(), Report + NREP, 10, 5); dwtom(farcoreleft(), Report + FREP, 10, 6); #endif exit(0); + */ } @@ -1573,6 +1627,8 @@ void VGA::Exit (int tref, const char * name) void BITMAP::XShow (int x, int y) { + // TODO XShow ASM + /* uint8 rmsk = x % 4, mask = 1 << rmsk, * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; @@ -1650,6 +1706,8 @@ void BITMAP::XShow (int x, int y) asm pop ds asm pop si asm pop bx + + */ } @@ -1659,6 +1717,9 @@ void BITMAP::XShow (int x, int y) void BITMAP::Show (int x, int y) { + + // TODO Show ASM + /* uint8 mask = 1 << (x & 3), * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); uint8 * v = V; @@ -1722,6 +1783,7 @@ void BITMAP::Show (int x, int y) asm cmp ah,mask asm jne plane asm pop ds + */ } @@ -1730,6 +1792,8 @@ void BITMAP::Show (int x, int y) void BITMAP::Hide (int x, int y) { + // TODO Bitmap Hide ASM + /* uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); HideDesc * b = B; @@ -1790,6 +1854,7 @@ void BITMAP::Hide (int x, int y) asm pop ds asm pop si // asm pop bx +*/ } } // End of namespace CGE -- cgit v1.2.3 From 92076d464148d2d6ecab544076bc10718a463c7b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 11 Jun 2011 23:27:27 +0200 Subject: CGE: Remove DROP() macro --- engines/cge/vga13h.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 86b04bfe0c..d95be1d94c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -600,7 +600,8 @@ SPRITE * SPRITE::Expand (void) { bool enbl = HEART::Enable; HEART::Enable = false; - if ((Ext = new SPREXT) == NULL) DROP("No core", NULL); + if ((Ext = new SPREXT) == NULL) + error("No core"); if (*File) { static const char * Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; -- cgit v1.2.3 From 3bef49c003a888b935dc2aeaf2aa00e66249e71c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 12 Jun 2011 01:13:44 +0200 Subject: CGE: Suppress VGA::Exit, some cleanup, add one missing source --- engines/cge/vga13h.cpp | 66 ++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 48 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d95be1d94c..6e08a9790d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -585,7 +585,8 @@ void SPRITE::SetName (char * n) if (n) { if ((Ext->Name = new char[strlen(n)+1]) != NULL) strcpy(Ext->Name, n); - else VGA::Exit("No core", n); + else + error("No core [%s]", n); } } } @@ -624,9 +625,7 @@ SPRITE * SPRITE::Expand (void) { INI_FILE sprf(fname); if (! OK(sprf)) - { - VGA::Exit("Bad SPR", fname); - } + error("Bad SPR [%s]", fname); while ((len = sprf.Read((uint8*)line)) != 0) { @@ -649,7 +648,7 @@ SPRITE * SPRITE::Expand (void) { seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); if (seq == NULL) - VGA::Exit("No core", fname); + error("No core [%s]", fname); SEQ * s = &seq[seqcnt ++]; s->Now = atoi(strtok(NULL, " \t,;/")); if (s->Now > maxnow) maxnow = s->Now; @@ -670,12 +669,13 @@ SPRITE * SPRITE::Expand (void) if (NearPtr != NO_PTR) { nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); - if (nea == NULL) VGA::Exit("No core", fname); + if (nea == NULL) + error("No core [%s]", fname); else { SNAIL::COM * c = &nea[neacnt ++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - VGA::Exit(NumStr("Bad NEAR in ######", lcnt), fname); + error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); c->Ptr = NULL; @@ -688,12 +688,13 @@ SPRITE * SPRITE::Expand (void) if (TakePtr != NO_PTR) { tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); - if (tak == NULL) VGA::Exit("No core", fname); + if (tak == NULL) + error("No core [%s]", fname); else { SNAIL::COM * c = &tak[takcnt ++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - VGA::Exit(NumStr("Bad NEAR in ######", lcnt), fname); + error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); c->Ptr = NULL; @@ -711,8 +712,10 @@ SPRITE * SPRITE::Expand (void) shplist[shpcnt] = NULL; if (seq) { - if (maxnow >= shpcnt) VGA::Exit("Bad PHASE in SEQ", fname); - if (maxnxt >= seqcnt) VGA::Exit("Bad JUMP in SEQ", fname); + if (maxnow >= shpcnt) + error("Bad PHASE in SEQ [%s]", fname); + if (maxnxt >= seqcnt) + error("Bad JUMP in SEQ [%s]", fname); SetSeq(seq); } else SetSeq((ShpCnt == 1) ? Seq1 : Seq2); @@ -938,10 +941,12 @@ BMP_PTR SPRITE::Ghost (void) if (e->b1) { BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); - if (bmp == NULL) VGA::Exit("No core"); + if (bmp == NULL) + error("No core"); bmp->W = e->b1->W; bmp->H = e->b1->H; - if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) VGA::Exit("No Core"); + if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) + error("No Core"); bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); @@ -1589,43 +1594,8 @@ void VGA::CopyPage (uint16 d, uint16 s) */ } - - - - - - -void VGA::Exit (const char * txt, const char * name) -{ - // TODO Properly exit - /* - Msg = txt; - Nam = name; - - #ifdef REPORT - wtom(coreleft(), Report + NREP, 10, 5); - dwtom(farcoreleft(), Report + FREP, 10, 6); - #endif - exit(0); - */ -} - - - - -void VGA::Exit (int tref, const char * name) -{ - Exit(Text[tref], name); -} - - - - //-------------------------------------------------------------------------- - - - void BITMAP::XShow (int x, int y) { // TODO XShow ASM -- cgit v1.2.3 From b1df7ca7340ccf43817894eedcaea6d211eeb6dd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 12 Jun 2011 22:06:44 +0200 Subject: CGE: Add missing file, and STUB some missing functions in general.cpp --- engines/cge/vga13h.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6e08a9790d..f771767c7b 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1137,10 +1137,11 @@ uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), +//extern const char Copr[]; + VGA::VGA (int mode) : FrmCnt(0) { - extern const char Copr[]; bool std = true; int i; for (i = 10; i < 20; i ++) @@ -1155,9 +1156,10 @@ VGA::VGA (int mode) #endif } } - if (std) -// puts(Copr); - warning(Copr); +// if (std) +// warning(Copr); + warning("TODO: Fix Copr"); + SetStatAdr(); if (StatAdr != VGAST1_) ++ Mono; if (IsVga()) -- cgit v1.2.3 From ccd934e4bfaa2997bf2dcec6818e0c418a11624f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 13 Jun 2011 00:40:19 +0200 Subject: CGE: Add a couple of STUB warnings --- engines/cge/vga13h.cpp | 314 +++++++------------------------------------------ 1 file changed, 41 insertions(+), 273 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index f771767c7b..01441c85a3 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -30,15 +30,12 @@ #include "cge/bitmap.h" #include "cge/vol.h" #include "cge/text.h" -//#include #include #include #include #include #include -//#include #include -//#include #include namespace CGE { @@ -143,7 +140,7 @@ static void Video (void) uint16 * SaveScreen (void) { - /* TODO ASM +/* uint16 cxy, cur, siz, * scr = NULL, * sav; // horizontal size of text mode screen @@ -195,17 +192,14 @@ uint16 * SaveScreen (void) } return sav; */ + warning("STUB: SaveScreen"); return 0; } - - - void RestoreScreen (uint16 * &sav) { - // TODO RestoreScreen ASM - /* +/* uint16 * scr = NULL; asm mov ax,0x40 // system data segment @@ -232,13 +226,10 @@ void RestoreScreen (uint16 * &sav) free(sav); sav = NULL; */ + warning("STUB: RestoreScreen"); } - - - - DAC MkDAC (uint8 r, uint8 g, uint8 b) { static DAC x; @@ -249,8 +240,6 @@ DAC MkDAC (uint8 r, uint8 g, uint8 b) } - - RGB MkRGB (uint8 r, uint8 g, uint8 b) { static TRGB x; @@ -261,10 +250,6 @@ RGB MkRGB (uint8 r, uint8 g, uint8 b) } - - - - SPRITE * Locate (int ref) { SPRITE * spr = VGA::ShowQ.Locate(ref); @@ -272,18 +257,10 @@ SPRITE * Locate (int ref) } - - - -//-------------------------------------------------------------------------- - - bool HEART::Enable = false; uint16 * HEART::XTimer = NULL; - - HEART::HEART (void) : ENGINE(TMR_DIV) { @@ -327,11 +304,10 @@ extern "C" void TimerProc (void) */ -void ENGINE::NewTimer (...) +void ENGINE::NewTimer(...) { static SPRITE * spr; static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; - // TODO Timer ASM /* ___1152_Hz___: @@ -391,12 +367,10 @@ void ENGINE::NewTimer (...) } */ + warning("STUB: ENGINE::NewTimer"); } - - - void HEART::SetXTimer (uint16 * ptr) { if (XTimer && ptr != XTimer) *XTimer = 0; @@ -404,8 +378,6 @@ void HEART::SetXTimer (uint16 * ptr) } - - void HEART::SetXTimer (uint16 * ptr, uint16 time) { SetXTimer(ptr); @@ -413,16 +385,6 @@ void HEART::SetXTimer (uint16 * ptr, uint16 time) } - - -//-------------------------------------------------------------------------- - - - - - - - SPRITE::SPRITE (BMP_PTR * shp) : X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), @@ -434,18 +396,12 @@ SPRITE::SPRITE (BMP_PTR * shp) } - - - - SPRITE::~SPRITE (void) { Contract(); } - - BMP_PTR SPRITE::Shp (void) { register SPREXT * e = Ext; @@ -459,7 +415,7 @@ BMP_PTR SPRITE::Shp (void) //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); //VGA::Exit(s, File); - VGA::Exit("Invalid PHASE in SPRITE::Shp()", File); + error("Invalid PHASE in SPRITE::Shp() %s", File); } #endif return e->ShpList[i]; @@ -468,9 +424,6 @@ BMP_PTR SPRITE::Shp (void) } - - - BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) { BMP_PTR * r = (Ext) ? Ext->ShpList : NULL; @@ -497,9 +450,6 @@ BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) } - - - void SPRITE::MoveShapes (uint8 * buf) { BMP_PTR * p; @@ -510,9 +460,6 @@ void SPRITE::MoveShapes (uint8 * buf) } - - - bool SPRITE::Works (SPRITE * spr) { if (spr) if (spr->Ext) @@ -530,9 +477,6 @@ bool SPRITE::Works (SPRITE * spr) } - - - SEQ * SPRITE::SetSeq (SEQ * seq) { Expand(); @@ -545,10 +489,6 @@ SEQ * SPRITE::SetSeq (SEQ * seq) } - - - - bool SPRITE::SeqTest (int n) { if (n >= 0) return (SeqPtr == n); @@ -557,10 +497,6 @@ bool SPRITE::SeqTest (int n) } - - - - SNAIL::COM * SPRITE::SnList (SNLIST type) { register SPREXT * e = Ext; @@ -569,10 +505,6 @@ SNAIL::COM * SPRITE::SnList (SNLIST type) } - - - - void SPRITE::SetName (char * n) { if (Ext) @@ -592,9 +524,6 @@ void SPRITE::SetName (char * n) } - - - SPRITE * SPRITE::Expand (void) { if (! Ext) @@ -732,8 +661,6 @@ SPRITE * SPRITE::Expand (void) } - - SPRITE * SPRITE::Contract (void) { register SPREXT * e = Ext; @@ -756,10 +683,6 @@ SPRITE * SPRITE::Contract (void) } - - - - SPRITE * SPRITE::BackShow (bool fast) { Expand(); @@ -771,12 +694,6 @@ SPRITE * SPRITE::BackShow (bool fast) } - - - - - - void SPRITE::Step (int nr) { if (nr >= 0) SeqPtr = nr; @@ -794,19 +711,12 @@ void SPRITE::Step (int nr) } - - - - void SPRITE::Tick (void) { Step(); } - - - void SPRITE::MakeXlat (uint8 * x) { if (Ext) @@ -820,9 +730,6 @@ void SPRITE::MakeXlat (uint8 * x) } - - - void SPRITE::KillXlat (void) { if (Flags.Xlat && Ext) @@ -841,9 +748,6 @@ void SPRITE::KillXlat (void) } - - - void SPRITE::Goto (int x, int y) { int xo = X, yo = Y; @@ -864,28 +768,12 @@ void SPRITE::Goto (int x, int y) } - - - - - - - - - - void SPRITE::Center (void) { Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); } - - - - - - void SPRITE::Show (void) { register SPREXT * e; @@ -906,11 +794,6 @@ void SPRITE::Show (void) } - - - - - void SPRITE::Show (uint16 pg) { uint8 * a = VGA::Page[1]; @@ -920,12 +803,6 @@ void SPRITE::Show (uint16 pg) } - - - - - - void SPRITE::Hide (void) { register SPREXT * e = Ext; @@ -933,8 +810,6 @@ void SPRITE::Hide (void) } - - BMP_PTR SPRITE::Ghost (void) { register SPREXT * e = Ext; @@ -956,10 +831,6 @@ BMP_PTR SPRITE::Ghost (void) } - - - - SPRITE * SpriteAt (int x, int y) { SPRITE * spr = NULL, * tail = VGA::ShowQ.Last(); @@ -974,32 +845,18 @@ SPRITE * SpriteAt (int x, int y) } - - - -//-------------------------------------------------------------------------- - - - - - - QUEUE::QUEUE (bool show) : Head(NULL), Tail(NULL), Show(show) { } - - QUEUE::~QUEUE (void) { Clear(); } - - void QUEUE::Clear (void) { while (Head) @@ -1010,8 +867,6 @@ void QUEUE::Clear (void) } - - void QUEUE::ForAll (void (*fun)(SPRITE *)) { SPRITE * s = Head; @@ -1024,9 +879,6 @@ void QUEUE::ForAll (void (*fun)(SPRITE *)) } - - - void QUEUE::Append (SPRITE * spr) { if (Tail) @@ -1041,9 +893,6 @@ void QUEUE::Append (SPRITE * spr) } - - - void QUEUE::Insert (SPRITE * spr, SPRITE * nxt) { if (nxt == Head) @@ -1064,9 +913,6 @@ void QUEUE::Insert (SPRITE * spr, SPRITE * nxt) } - - - void QUEUE::Insert (SPRITE * spr) { SPRITE * s; @@ -1080,9 +926,6 @@ void QUEUE::Insert (SPRITE * spr) } - - - SPRITE * QUEUE::Remove (SPRITE * spr) { if (spr == Head) Head = spr->Next; @@ -1095,9 +938,6 @@ SPRITE * QUEUE::Remove (SPRITE * spr) } - - - SPRITE * QUEUE::Locate (int ref) { SPRITE * spr; @@ -1106,14 +946,6 @@ SPRITE * QUEUE::Locate (int ref) } - - - -//-------------------------------------------------------------------------- - - - - uint16 VGA::StatAdr = VGAST1_; uint16 VGA::OldMode = 0; uint16 * VGA::OldScreen = NULL; @@ -1177,9 +1009,6 @@ VGA::VGA (int mode) } - - - VGA::~VGA (void) { Mono = 0; @@ -1205,7 +1034,7 @@ VGA::~VGA (void) void VGA::SetStatAdr (void) { - /* TODO SetStatADR ASM + /* asm mov dx,VGAMIr_ asm in al,dx asm test al,1 // CGA addressing mode flag @@ -1215,17 +1044,13 @@ void VGA::SetStatAdr (void) set_mode_adr: StatAdr = _AX; */ + warning("STUB: VGA::SetStatADR"); } - - - - #pragma argsused void VGA::WaitVR (bool on) { - // TODO Wait vertical retrace ASM /* _DX = StatAdr; _AH = (on) ? 0x00 : 0x08; @@ -1240,16 +1065,13 @@ void VGA::WaitVR (bool on) asm xor ah,0x08 asm loop wait */ + warning("STUB: VGA::WaitVR"); } - - - - void VGA::Setup (VgaRegBlk * vrb) { -/* TODO VGA setup +/* WaitVR(); // *--LOOK!--* resets VGAATR logic asm cld asm mov si, vrb // take address of parameter table @@ -1287,17 +1109,13 @@ void VGA::Setup (VgaRegBlk * vrb) xit: */ + warning("STUB: VGA::Setup"); } - - - - -int VGA::SetMode (int mode) +int VGA::SetMode(int mode) { - /* TODO VGA Set Mode - +/* Clear(); // get current mode asm mov ah,0x0F @@ -1317,17 +1135,14 @@ int VGA::SetMode (int mode) asm pop ax return _AX; */ + warning("STUB: VGA::SetMode"); return 0; } - - - - -void VGA::GetColors (DAC * tab) +void VGA::GetColors(DAC * tab) { - /* TODO GetColors ASM +/* asm cld asm les di,tab // color table asm mov dx,0x3C7 // PEL address read mode register @@ -1344,18 +1159,14 @@ void VGA::GetColors (DAC * tab) sto: asm stosb // store 1 color asm loop gc // next one? - */ + warning("STUB: VGA::GetColors"); } - - -void VGA::SetColors (DAC * tab, int lum) +void VGA::SetColors(DAC * tab, int lum) { - - /* TODO SetColors - +/* DAC * des = NewColors; asm push ds @@ -1401,13 +1212,10 @@ void VGA::SetColors (DAC * tab, int lum) } */ SetPal = true; + warning("STUB: VGA::SetColors"); } - - - - void VGA::SetColors (void) { memset(NewColors, 0, PAL_SIZ); @@ -1415,10 +1223,6 @@ void VGA::SetColors (void) } - - - - void VGA::Sunrise (DAC * tab) { int i; @@ -1431,10 +1235,6 @@ void VGA::Sunrise (DAC * tab) } - - - - void VGA::Sunset (void) { DAC tab[256]; @@ -1449,13 +1249,6 @@ void VGA::Sunset (void) } - - - - - - - void VGA::Show (void) { SPRITE * spr = ShowQ.First(); @@ -1468,11 +1261,9 @@ void VGA::Show (void) } - - -void VGA::UpdateColors (void) +void VGA::UpdateColors(void) { - /* TODO UpdateColors ASM +/* DAC * tab = NewColors; asm push ds @@ -1497,18 +1288,13 @@ void VGA::UpdateColors (void) asm pop ds */ + warning("STUB: VGA::UpdateColors"); } - - - - - -void VGA::Update (void) +void VGA::Update(void) { - // TODO VGA Update - /* +/* uint8 * p = Page[1]; Page[1] = Page[0]; Page[0] = p; @@ -1528,18 +1314,13 @@ void VGA::Update (void) UpdateColors(); SetPal = false; } + warning("STUB: VGA::Update"); } - - - - - - -void VGA::Clear (uint8 color) +void VGA::Clear(uint8 color) { - /* TODO Clear ASM +/* uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); asm mov dx,VGASEQ_ @@ -1553,16 +1334,13 @@ void VGA::Clear (uint8 color) asm rep stosb asm stosb */ + warning("STUB: VGA::Clear"); } - - - - -void VGA::CopyPage (uint16 d, uint16 s) +void VGA::CopyPage(uint16 d, uint16 s) { - /* TODO CopyPage +/* uint8 * S = Page[s & 3], * D = Page[d & 3]; asm mov dx,VGAGRA_ @@ -1594,14 +1372,14 @@ void VGA::CopyPage (uint16 d, uint16 s) asm pop ax asm out dx,al // end of copy mode */ + warning("STUB: VGA::CopyPage"); } //-------------------------------------------------------------------------- -void BITMAP::XShow (int x, int y) +void BITMAP::XShow(int x, int y) { - // TODO XShow ASM - /* +/* uint8 rmsk = x % 4, mask = 1 << rmsk, * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; @@ -1617,8 +1395,6 @@ void BITMAP::XShow (int x, int y) asm lds si,v asm mov bx,m - - asm mov al,0x02 // map mask register asm mov ah,mask @@ -1679,19 +1455,13 @@ void BITMAP::XShow (int x, int y) asm pop ds asm pop si asm pop bx - */ + warning("STUB: BITMAP::XShow"); } - - - - -void BITMAP::Show (int x, int y) +void BITMAP::Show(int x, int y) { - - // TODO Show ASM /* uint8 mask = 1 << (x & 3), * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); @@ -1757,16 +1527,13 @@ void BITMAP::Show (int x, int y) asm jne plane asm pop ds */ + warning("STUB: BITMAP::Show"); } - - - -void BITMAP::Hide (int x, int y) +void BITMAP::Hide(int x, int y) { - // TODO Bitmap Hide ASM - /* +/* uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); HideDesc * b = B; @@ -1828,6 +1595,7 @@ void BITMAP::Hide (int x, int y) asm pop si // asm pop bx */ + warning("STUB: BITMAP::Hide"); } } // End of namespace CGE -- cgit v1.2.3 From ffc2aa4e4f41aa679d773ccafdec87bf8d7b5e85 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 13 Jun 2011 11:57:24 +0200 Subject: CGE: Format code --- engines/cge/vga13h.cpp | 2473 +++++++++++++++++++++++------------------------- 1 file changed, 1204 insertions(+), 1269 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 01441c85a3..e7ed6d0402 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -25,245 +25,219 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ -#include "cge/general.h" -#include "cge/vga13h.h" -#include "cge/bitmap.h" -#include "cge/vol.h" -#include "cge/text.h" -#include -#include -#include -#include -#include -#include -#include +#include "cge/general.h" +#include "cge/vga13h.h" +#include "cge/bitmap.h" +#include "cge/vol.h" +#include "cge/text.h" +#include +#include +#include +#include +#include +#include +#include namespace CGE { #ifdef DEBUG -#define REPORT +#define REPORT #endif -#define OK(f) ((f).Error==0) -#define FADE_STEP 2 +#define OK(f) ((f).Error==0) +#define FADE_STEP 2 -#define TMR_DIV ((0x8000/TMR_RATE)*2) +#define TMR_DIV ((0x8000/TMR_RATE)*2) //-------------------------------------------------------------------------- -#ifdef REPORT +#ifdef REPORT static char Report[] = "NearHeap=..... FarHeap=......\n"; -#define NREP 9 -#define FREP 24 +#define NREP 9 +#define FREP 24 #endif -static VgaRegBlk VideoMode[] = { +static VgaRegBlk VideoMode[] = { - { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode + { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode + { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 + { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 + { 0x06, VGAGRA, 0x02, 0x00 }, // misc + { 0x14, VGACRT, 0x40, 0x00 }, // underline + { 0x13, VGACRT, 0xFF, 0x28 }, // screen width + { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control + { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end + { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line + { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode +// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end +// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb +// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr + { 0x00 } +}; - { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 - { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 - { 0x06, VGAGRA, 0x02, 0x00 }, // misc - { 0x14, VGACRT, 0x40, 0x00 }, // underline - { 0x13, VGACRT, 0xFF, 0x28 }, // screen width - { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control +bool SpeedTest = false; +SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; +SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; +SPRITE *Sys = NULL; - { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end - { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line +extern "C" void SNDMIDIPlay(void); - { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode - -// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end -// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb -// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr - - { 0x00 } }; - - - bool SpeedTest = false; - SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; - SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; - SPRITE * Sys = NULL; - -extern "C" void SNDMIDIPlay (void); - - - - - - -char * NumStr (char * str, int num) -{ - char * p = strchr(str, '#'); - if (p) wtom(num, p, 10, 5); - return str; +char *NumStr(char *str, int num) { + char *p = strchr(str, '#'); + if (p) + wtom(num, p, 10, 5); + return str; } - - - - - -// TODO Video ASM -/* -static void Video (void) +static void Video(void) { +/* static uint16 SP_S; - - asm push bx - asm push bp - asm push si - asm push di - asm push es - asm xor bx,bx // video page #0 + asm push bx + asm push bp + asm push si + asm push di + asm push es + asm xor bx,bx // video page #0 SP_S = _SP; - asm int VIDEO + asm int VIDEO _SP = SP_S; - asm pop es - asm pop di - asm pop si - asm pop bp - asm pop bx - + asm pop es + asm pop di + asm pop si + asm pop bp + asm pop bx +*/ + warning("STUB: Video"); } - */ - - - -uint16 * SaveScreen (void) -{ -/* - uint16 cxy, cur, siz, * scr = NULL, * sav; - - // horizontal size of text mode screen - asm mov ah,0x0F // get current video mode - Video(); // BIOS video service - asm xchg ah,al // answer in ah - asm push ax // preserve width - - // vertical size of text mode screen - asm mov dl,24 // last row on std screen - asm xor bx,bx // valid request in BH - asm mov ax,0x1130 // get EGA's last row # - Video(); // BIOS video service - asm inc dl // # of rows = last+1 - - // compute screen size in words - asm pop ax // restore width - asm mul dl // width * height - - siz = _AX; - - asm mov ax,0x40 // system data segment - asm mov es,ax - asm mov ax,0B000H // Mono - asm cmp byte ptr es:[0x49],0x07 - asm je sto - asm mov ax,0B800H // Color - sto: // store screen address - asm mov word ptr scr+2,ax - - _AH = 0x0F; Video(); // active page - - // take cursor shape - _AH = 0x03; Video(); // get cursor size - cur = _CX; - - // take cursor position - _DH = 0; - _AH = 0x03; Video(); // get cursor - cxy = _DX; - - sav = farnew(uint16, siz+3); // +3 extra uint16s for size and cursor - if (sav) - { - sav[0] = siz; - sav[1] = cur; - sav[2] = cxy; - memcpy(sav+3, scr, siz * 2); - } - return sav; - */ +uint16 *SaveScreen(void) { + /* + uint16 cxy, cur, siz, * scr = NULL, * sav; + + // horizontal size of text mode screen + asm mov ah,0x0F // get current video mode + Video(); // BIOS video service + asm xchg ah,al // answer in ah + asm push ax // preserve width + + // vertical size of text mode screen + asm mov dl,24 // last row on std screen + asm xor bx,bx // valid request in BH + asm mov ax,0x1130 // get EGA's last row # + Video(); // BIOS video service + asm inc dl // # of rows = last+1 + + // compute screen size in words + asm pop ax // restore width + asm mul dl // width * height + + siz = _AX; + + asm mov ax,0x40 // system data segment + asm mov es,ax + asm mov ax,0B000H // Mono + asm cmp byte ptr es:[0x49],0x07 + asm je sto + asm mov ax,0B800H // Color + sto: // store screen address + asm mov word ptr scr+2,ax + + _AH = 0x0F; Video(); // active page + + // take cursor shape + _AH = 0x03; Video(); // get cursor size + cur = _CX; + + // take cursor position + _DH = 0; + _AH = 0x03; Video(); // get cursor + cxy = _DX; + + sav = farnew(uint16, siz+3); // +3 extra uint16s for size and cursor + if (sav) + { + sav[0] = siz; + sav[1] = cur; + sav[2] = cxy; + memcpy(sav+3, scr, siz * 2); + } + return sav; + */ warning("STUB: SaveScreen"); return 0; } -void RestoreScreen (uint16 * &sav) -{ -/* - uint16 * scr = NULL; +void RestoreScreen(uint16 * &sav) { + /* + uint16 * scr = NULL; - asm mov ax,0x40 // system data segment - asm mov es,ax - asm mov ax,0B000H // Mono - asm cmp byte ptr es:[0x49],0x07 - asm je sto - asm mov ax,0B800H // Color - sto: // store screen address - asm mov word ptr scr+2,ax + asm mov ax,0x40 // system data segment + asm mov es,ax + asm mov ax,0B000H // Mono + asm cmp byte ptr es:[0x49],0x07 + asm je sto + asm mov ax,0B800H // Color + sto: // store screen address + asm mov word ptr scr+2,ax - memcpy(scr, sav+3, sav[0] * 2); + memcpy(scr, sav+3, sav[0] * 2); - _AH = 0x0F; Video(); // active page + _AH = 0x0F; Video(); // active page - // set cursor shape - _CX = sav[1]; - _AH = 0x01; Video(); // set cursor size + // set cursor shape + _CX = sav[1]; + _AH = 0x01; Video(); // set cursor size - // set cursor position - _DX = sav[2]; - _AH = 0x02; Video(); // set cursor + // set cursor position + _DX = sav[2]; + _AH = 0x02; Video(); // set cursor - free(sav); - sav = NULL; - */ + free(sav); + sav = NULL; + */ warning("STUB: RestoreScreen"); } -DAC MkDAC (uint8 r, uint8 g, uint8 b) -{ - static DAC x; - x.R = r; - x.G = g; - x.B = b; - return x; +DAC MkDAC(uint8 r, uint8 g, uint8 b) { + static DAC x; + x.R = r; + x.G = g; + x.B = b; + return x; } -RGB MkRGB (uint8 r, uint8 g, uint8 b) -{ - static TRGB x; - x.dac.R = r; - x.dac.G = g; - x.dac.B = b; - return x.rgb; +RGB MkRGB(uint8 r, uint8 g, uint8 b) { + static TRGB x; + x.dac.R = r; + x.dac.G = g; + x.dac.B = b; + return x.rgb; } -SPRITE * Locate (int ref) -{ - SPRITE * spr = VGA::ShowQ.Locate(ref); - return (spr) ? spr : VGA::SpareQ.Locate(ref); +SPRITE *Locate(int ref) { + SPRITE *spr = VGA::ShowQ.Locate(ref); + return (spr) ? spr : VGA::SpareQ.Locate(ref); } -bool HEART::Enable = false; -uint16 * HEART::XTimer = NULL; +bool HEART::Enable = false; +uint16 *HEART::XTimer = NULL; -HEART::HEART (void) -: ENGINE(TMR_DIV) -{ +HEART::HEART(void) + : ENGINE(TMR_DIV) { } @@ -278,1323 +252,1284 @@ extern "C" void TimerProc (void) if (*HEART::XTimer) -- *HEART::XTimer; else HEART::XTimer = NULL; - if (! run && HEART::Enable) // check overrun flag + if (! run && HEART::Enable) // check overrun flag { static uint16 oldSP, oldSS; - ++ run; // disable 2nd call until current lasts - asm mov ax,ds - asm mov oldSS,ss - asm mov oldSP,sp - asm mov ss,ax - asm mov sp,0xFF80 + ++ run; // disable 2nd call until current lasts + asm mov ax,ds + asm mov oldSS,ss + asm mov oldSP,sp + asm mov ss,ax + asm mov sp,0xFF80 // system pseudo-sprite if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) - { - if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); - } - asm mov ss,oldSS - asm mov sp,oldSP + { + if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); + } + asm mov ss,oldSS + asm mov sp,oldSP -- run; } } */ -void ENGINE::NewTimer(...) -{ - static SPRITE * spr; - static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; - /* - ___1152_Hz___: +void ENGINE::NewTimer(...) { + static SPRITE *spr; + static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; + /* + ___1152_Hz___: - SNDMIDIPlay(); - asm dec cntr1 - asm jz ___72_Hz___ - asm mov al,0x20 // send... - asm out 0x020,al // ...e-o-i - return; + SNDMIDIPlay(); + asm dec cntr1 + asm jz ___72_Hz___ + asm mov al,0x20 // send... + asm out 0x020,al // ...e-o-i + return; - ___72_Hz___: + ___72_Hz___: - asm mov cntr1,TMR_RATE1 - asm dec cntr2 - asm jnz my_eoi + asm mov cntr1,TMR_RATE1 + asm dec cntr2 + asm jnz my_eoi - ___18_Hz___: + ___18_Hz___: - OldTimer(); - asm mov cntr2,TMR_RATE2 - asm jmp short my_int + OldTimer(); + asm mov cntr2,TMR_RATE2 + asm jmp short my_int - // send E-O-I - my_eoi: - asm mov al,0x20 - asm out 0x020,al - asm sti // enable interrupts + // send E-O-I + my_eoi: + asm mov al,0x20 + asm out 0x020,al + asm sti // enable interrupts - my_int: //------72Hz-------// + my_int: //------72Hz-------// - // decrement external timer uint16 - if (HEART::XTimer) - if (*HEART::XTimer) -- *HEART::XTimer; - else HEART::XTimer = NULL; + // decrement external timer uint16 + if (HEART::XTimer) + if (*HEART::XTimer) -- *HEART::XTimer; + else HEART::XTimer = NULL; - if (! run && HEART::Enable) // check overrun flag - { - static uint16 oldSP, oldSS; + if (! run && HEART::Enable) // check overrun flag + { + static uint16 oldSP, oldSS; - ++ run; // disable 2nd call until current lasts - asm mov ax,ds - asm mov oldSS,ss - asm mov oldSP,sp - asm mov ss,ax - asm mov sp,0xFF80 + ++ run; // disable 2nd call until current lasts + asm mov ax,ds + asm mov oldSS,ss + asm mov oldSP,sp + asm mov ss,ax + asm mov sp,0xFF80 - // system pseudo-sprite - if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); + // system pseudo-sprite + if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); } - asm mov ss,oldSS - asm mov sp,oldSP - -- run; - } + asm mov ss,oldSS + asm mov sp,oldSP + -- run; + } */ warning("STUB: ENGINE::NewTimer"); } -void HEART::SetXTimer (uint16 * ptr) -{ - if (XTimer && ptr != XTimer) *XTimer = 0; - XTimer = ptr; +void HEART::SetXTimer(uint16 *ptr) { + if (XTimer && ptr != XTimer) + *XTimer = 0; + XTimer = ptr; } -void HEART::SetXTimer (uint16 * ptr, uint16 time) -{ - SetXTimer(ptr); - *ptr = time; +void HEART::SetXTimer(uint16 *ptr, uint16 time) { + SetXTimer(ptr); + *ptr = time; } -SPRITE::SPRITE (BMP_PTR * shp) -: X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), - Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), - Ext(NULL), Ref(-1), Cave(0) -{ - memset(File, 0, sizeof(File)); - *((uint16 *)&Flags) = 0; - SetShapeList(shp); +SPRITE::SPRITE(BMP_PTR *shp) + : X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), + Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), + Ext(NULL), Ref(-1), Cave(0) { + memset(File, 0, sizeof(File)); + *((uint16 *)&Flags) = 0; + SetShapeList(shp); } -SPRITE::~SPRITE (void) -{ - Contract(); +SPRITE::~SPRITE(void) { + Contract(); } -BMP_PTR SPRITE::Shp (void) -{ - register SPREXT * e = Ext; - if (e) if (e->Seq) - { - int i = e->Seq[SeqPtr].Now; - #ifdef DEBUG - if (i >= ShpCnt) - { - //char s[256]; - //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", - // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); - //VGA::Exit(s, File); - error("Invalid PHASE in SPRITE::Shp() %s", File); - } - #endif - return e->ShpList[i]; - } - return NULL; +BMP_PTR SPRITE::Shp(void) { + register SPREXT *e = Ext; + if (e) + if (e->Seq) { + int i = e->Seq[SeqPtr].Now; +#ifdef DEBUG + if (i >= ShpCnt) { + //char s[256]; + //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", + // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); + //VGA::Exit(s, File); + error("Invalid PHASE in SPRITE::Shp() %s", File); + } +#endif + return e->ShpList[i]; + } + return NULL; } -BMP_PTR * SPRITE::SetShapeList (BMP_PTR * shp) -{ - BMP_PTR * r = (Ext) ? Ext->ShpList : NULL; +BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) { + BMP_PTR *r = (Ext) ? Ext->ShpList : NULL; - ShpCnt = 0; - W = 0; - H = 0; + ShpCnt = 0; + W = 0; + H = 0; - if (shp) - { - BMP_PTR * p; - for (p = shp; *p; p ++) - { - BMP_PTR b = (*p); // ->Code(); - if (b->W > W) W = b->W; - if (b->H > H) H = b->H; - ++ ShpCnt; + if (shp) { + BMP_PTR *p; + for (p = shp; *p; p++) { + BMP_PTR b = (*p); // ->Code(); + if (b->W > W) + W = b->W; + if (b->H > H) + H = b->H; + ++ShpCnt; + } + Expand(); + Ext->ShpList = shp; + if (! Ext->Seq) + SetSeq((ShpCnt < 2) ? Seq1 : Seq2); } - Expand(); - Ext->ShpList = shp; - if (! Ext->Seq) SetSeq((ShpCnt < 2) ? Seq1 : Seq2); - } - return r; -} - - -void SPRITE::MoveShapes (uint8 * buf) -{ - BMP_PTR * p; - for (p = Ext->ShpList; *p; p ++) - { - buf += (*p)->MoveVmap(buf); - } + return r; } -bool SPRITE::Works (SPRITE * spr) -{ - if (spr) if (spr->Ext) - { - SNAIL::COM * c = spr->Ext->Take; - if (c != NULL) - { - c += spr->TakePtr; - if (c->Ref == Ref) - if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) - return true; +void SPRITE::MoveShapes(uint8 *buf) { + BMP_PTR *p; + for (p = Ext->ShpList; *p; p ++) { + buf += (*p)->MoveVmap(buf); } - } - return false; } -SEQ * SPRITE::SetSeq (SEQ * seq) -{ - Expand(); - register SEQ * s = Ext->Seq; - Ext->Seq = seq; - if (SeqPtr == NO_SEQ) Step(0); - else - if (Time == 0) Step(SeqPtr); - return s; +bool SPRITE::Works(SPRITE *spr) { + if (spr) + if (spr->Ext) { + SNAIL::COM *c = spr->Ext->Take; + if (c != NULL) { + c += spr->TakePtr; + if (c->Ref == Ref) + if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) + return true; + } + } + return false; } -bool SPRITE::SeqTest (int n) -{ - if (n >= 0) return (SeqPtr == n); - if (Ext) return (Ext->Seq[SeqPtr].Next == SeqPtr); - return true; +SEQ *SPRITE::SetSeq(SEQ *seq) { + Expand(); + register SEQ *s = Ext->Seq; + Ext->Seq = seq; + if (SeqPtr == NO_SEQ) + Step(0); + else if (Time == 0) + Step(SeqPtr); + return s; } -SNAIL::COM * SPRITE::SnList (SNLIST type) -{ - register SPREXT * e = Ext; - if (e) return (type == NEAR) ? e->Near : e->Take; - return NULL; +bool SPRITE::SeqTest(int n) { + if (n >= 0) + return (SeqPtr == n); + if (Ext) + return (Ext->Seq[SeqPtr].Next == SeqPtr); + return true; } -void SPRITE::SetName (char * n) -{ - if (Ext) - { - if (Ext->Name) - { - delete[] Ext->Name; - Ext->Name = NULL; - } - if (n) - { - if ((Ext->Name = new char[strlen(n)+1]) != NULL) strcpy(Ext->Name, n); - else - error("No core [%s]", n); - } - } +SNAIL::COM *SPRITE::SnList(SNLIST type) { + register SPREXT *e = Ext; + if (e) + return (type == NEAR) ? e->Near : e->Take; + return NULL; } -SPRITE * SPRITE::Expand (void) -{ - if (! Ext) - { - bool enbl = HEART::Enable; - HEART::Enable = false; - if ((Ext = new SPREXT) == NULL) - error("No core"); - if (*File) - { - static const char * Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; - char line[LINE_MAX], fname[MAXPATH]; - BMP_PTR * shplist = new BMP_PTR [ShpCnt+1]; - SEQ * seq = NULL; - int shpcnt = 0, - seqcnt = 0, - neacnt = 0, - takcnt = 0, - maxnow = 0, - maxnxt = 0, - lcnt = 0, - len; - - SNAIL::COM * nea = NULL; - SNAIL::COM * tak = NULL; - MergeExt(fname, File, SPR_EXT); - if (INI_FILE::Exist(fname)) // sprite description file exist - { - INI_FILE sprf(fname); - if (! OK(sprf)) - error("Bad SPR [%s]", fname); - - while ((len = sprf.Read((uint8*)line)) != 0) - { - ++ lcnt; - if (len && line[len-1] == '\n') line[-- len] = '\0'; - if (len == 0 || *line == '.') continue; - - switch (TakeEnum(Comd, strtok(line, " =\t"))) - { - case 0 : // Name - { - SetName(strtok(NULL, "")); break; - } - case 1 : // Phase - { - shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/")); - break; - } - case 2 : // Seq - { - seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); - if (seq == NULL) - error("No core [%s]", fname); - SEQ * s = &seq[seqcnt ++]; - s->Now = atoi(strtok(NULL, " \t,;/")); - if (s->Now > maxnow) maxnow = s->Now; - s->Next = atoi(strtok(NULL, " \t,;/")); - switch (s->Next) - { - case 0xFF : s->Next = seqcnt; break; - case 0xFE : s->Next = seqcnt-1; break; - } - if (s->Next > maxnxt) maxnxt = s->Next; - s->Dx = atoi(strtok(NULL, " \t,;/")); - s->Dy = atoi(strtok(NULL, " \t,;/")); - s->Dly = atoi(strtok(NULL, " \t,;/")); - break; - } - case 3 : // Near - { - if (NearPtr != NO_PTR) - { - nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); - if (nea == NULL) - error("No core [%s]", fname); - else - { - SNAIL::COM * c = &nea[neacnt ++]; - if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); - c->Ref = atoi(strtok(NULL, " \t,;/")); - c->Val = atoi(strtok(NULL, " \t,;/")); - c->Ptr = NULL; - } - } - } - break; - case 4 : // Take - { - if (TakePtr != NO_PTR) - { - tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); - if (tak == NULL) - error("No core [%s]", fname); - else - { - SNAIL::COM * c = &tak[takcnt ++]; - if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); - c->Ref = atoi(strtok(NULL, " \t,;/")); - c->Val = atoi(strtok(NULL, " \t,;/")); - c->Ptr = NULL; - } - } - break; - } - } +void SPRITE::SetName(char *n) { + if (Ext) { + if (Ext->Name) { + delete[] Ext->Name; + Ext->Name = NULL; + } + if (n) { + if ((Ext->Name = new char[strlen(n) + 1]) != NULL) + strcpy(Ext->Name, n); + else + error("No core [%s]", n); } - } - else // no sprite description: try to read immediately from .BMP - { - shplist[shpcnt ++] = new BITMAP(File); - } - shplist[shpcnt] = NULL; - if (seq) - { - if (maxnow >= shpcnt) - error("Bad PHASE in SEQ [%s]", fname); - if (maxnxt >= seqcnt) - error("Bad JUMP in SEQ [%s]", fname); - SetSeq(seq); - } - else SetSeq((ShpCnt == 1) ? Seq1 : Seq2); - //disable(); // disable interupt - - SetShapeList(shplist); - //enable(); // enable interupt - if (nea) nea[neacnt-1].Ptr = Ext->Near = nea; else NearPtr = NO_PTR; - if (tak) tak[takcnt-1].Ptr = Ext->Take = tak; else TakePtr = NO_PTR; } - HEART::Enable = enbl; - } - return this; } -SPRITE * SPRITE::Contract (void) -{ - register SPREXT * e = Ext; - if (e) - { - if (e->Name) delete[] e->Name; - if (Flags.BDel && e->ShpList) - { - int i; - for (i = 0; e->ShpList[i]; i ++) delete e->ShpList[i]; - if (MemType(e->ShpList) == NEAR_MEM) delete[] e->ShpList; +SPRITE *SPRITE::Expand(void) { + if (! Ext) { + bool enbl = HEART::Enable; + HEART::Enable = false; + if ((Ext = new SPREXT) == NULL) + error("No core"); + if (*File) { + static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; + char line[LINE_MAX], fname[MAXPATH]; + BMP_PTR *shplist = new BMP_PTR [ShpCnt + 1]; + SEQ *seq = NULL; + int shpcnt = 0, + seqcnt = 0, + neacnt = 0, + takcnt = 0, + maxnow = 0, + maxnxt = 0, + lcnt = 0, + len; + + SNAIL::COM *nea = NULL; + SNAIL::COM *tak = NULL; + MergeExt(fname, File, SPR_EXT); + if (INI_FILE::Exist(fname)) { // sprite description file exist + INI_FILE sprf(fname); + if (! OK(sprf)) + error("Bad SPR [%s]", fname); + + while ((len = sprf.Read((uint8 *)line)) != 0) { + ++ lcnt; + if (len && line[len - 1] == '\n') + line[-- len] = '\0'; + if (len == 0 || *line == '.') + continue; + + switch (TakeEnum(Comd, strtok(line, " =\t"))) { + case 0 : { // Name + SetName(strtok(NULL, "")); + break; + } + case 1 : { // Phase + shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/")); + break; + } + case 2 : { // Seq + seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); + if (seq == NULL) + error("No core [%s]", fname); + SEQ *s = &seq[seqcnt ++]; + s->Now = atoi(strtok(NULL, " \t,;/")); + if (s->Now > maxnow) + maxnow = s->Now; + s->Next = atoi(strtok(NULL, " \t,;/")); + switch (s->Next) { + case 0xFF : + s->Next = seqcnt; + break; + case 0xFE : + s->Next = seqcnt - 1; + break; + } + if (s->Next > maxnxt) + maxnxt = s->Next; + s->Dx = atoi(strtok(NULL, " \t,;/")); + s->Dy = atoi(strtok(NULL, " \t,;/")); + s->Dly = atoi(strtok(NULL, " \t,;/")); + break; + } + case 3 : { // Near + if (NearPtr != NO_PTR) { + nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); + if (nea == NULL) + error("No core [%s]", fname); + else { + SNAIL::COM *c = &nea[neacnt ++]; + if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); + c->Ref = atoi(strtok(NULL, " \t,;/")); + c->Val = atoi(strtok(NULL, " \t,;/")); + c->Ptr = NULL; + } + } + } + break; + case 4 : { // Take + if (TakePtr != NO_PTR) { + tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); + if (tak == NULL) + error("No core [%s]", fname); + else { + SNAIL::COM *c = &tak[takcnt ++]; + if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); + c->Ref = atoi(strtok(NULL, " \t,;/")); + c->Val = atoi(strtok(NULL, " \t,;/")); + c->Ptr = NULL; + } + } + break; + } + } + } + } else { // no sprite description: try to read immediately from .BMP + shplist[shpcnt ++] = new BITMAP(File); + } + shplist[shpcnt] = NULL; + if (seq) { + if (maxnow >= shpcnt) + error("Bad PHASE in SEQ [%s]", fname); + if (maxnxt >= seqcnt) + error("Bad JUMP in SEQ [%s]", fname); + SetSeq(seq); + } else + SetSeq((ShpCnt == 1) ? Seq1 : Seq2); + //disable(); // disable interupt + + SetShapeList(shplist); + //enable(); // enable interupt + if (nea) + nea[neacnt - 1].Ptr = Ext->Near = nea; + else + NearPtr = NO_PTR; + if (tak) + tak[takcnt - 1].Ptr = Ext->Take = tak; + else + TakePtr = NO_PTR; + } + HEART::Enable = enbl; } - if (MemType(e->Seq) == NEAR_MEM) free(e->Seq); - if (e->Near) free(e->Near); - if (e->Take) free(e->Take); - delete e; - Ext = NULL; - } - return this; + return this; } -SPRITE * SPRITE::BackShow (bool fast) -{ - Expand(); - Show(2); - Show(1); - if (fast) Show(0); - Contract(); - return this; -} - - -void SPRITE::Step (int nr) -{ - if (nr >= 0) SeqPtr = nr; - if (Ext) - { - SEQ * seq; - if (nr < 0) SeqPtr = Ext->Seq[SeqPtr].Next; - seq = Ext->Seq + SeqPtr; - if (seq->Dly >= 0) - { - Goto(X + (seq->Dx), Y + (seq->Dy)); - Time = seq->Dly; +SPRITE *SPRITE::Contract(void) { + register SPREXT *e = Ext; + if (e) { + if (e->Name) + delete[] e->Name; + if (Flags.BDel && e->ShpList) { + int i; + for (i = 0; e->ShpList[i]; i ++) + delete e->ShpList[i]; + if (MemType(e->ShpList) == NEAR_MEM) + delete[] e->ShpList; + } + if (MemType(e->Seq) == NEAR_MEM) + free(e->Seq); + if (e->Near) + free(e->Near); + if (e->Take) + free(e->Take); + delete e; + Ext = NULL; } - } + return this; } -void SPRITE::Tick (void) -{ - Step(); -} - - -void SPRITE::MakeXlat (uint8 * x) -{ - if (Ext) - { - BMP_PTR * b; - - if (Flags.Xlat) KillXlat(); - for (b = Ext->ShpList; *b; b ++) (*b)->M = x; - Flags.Xlat = true; - } +SPRITE *SPRITE::BackShow(bool fast) { + Expand(); + Show(2); + Show(1); + if (fast) + Show(0); + Contract(); + return this; } -void SPRITE::KillXlat (void) -{ - if (Flags.Xlat && Ext) - { - BMP_PTR * b; - uint8 * m = (*Ext->ShpList)->M; - - switch (MemType(m)) - { - case NEAR_MEM : delete[] (uint8 *) m; break; - case FAR_MEM : free(m); break; +void SPRITE::Step(int nr) { + if (nr >= 0) + SeqPtr = nr; + if (Ext) { + SEQ *seq; + if (nr < 0) + SeqPtr = Ext->Seq[SeqPtr].Next; + seq = Ext->Seq + SeqPtr; + if (seq->Dly >= 0) { + Goto(X + (seq->Dx), Y + (seq->Dy)); + Time = seq->Dly; + } } - for (b = Ext->ShpList; *b; b ++) (*b)->M = NULL; - Flags.Xlat = false; - } } -void SPRITE::Goto (int x, int y) -{ - int xo = X, yo = Y; - if (W < SCR_WID) - { - if (x < 0) x = 0; - if (x + W > SCR_WID) x = (SCR_WID - W); - X = x; - } - if (H < SCR_HIG) - { - if (y < 0) y = 0; - if (y + H > SCR_HIG) y = (SCR_HIG - H); - Y = y; - } - if (Next) if (Next->Flags.Slav) Next->Goto(Next->X-xo+X, Next->Y-yo+Y); - if (Flags.Shad) Prev->Goto(Prev->X-xo+X, Prev->Y-yo+Y); +void SPRITE::Tick(void) { + Step(); } -void SPRITE::Center (void) -{ - Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); -} - +void SPRITE::MakeXlat(uint8 *x) { + if (Ext) { + BMP_PTR *b; -void SPRITE::Show (void) -{ - register SPREXT * e; - // asm cli // critic section... - e = Ext; - e->x0 = e->x1; - e->y0 = e->y1; - e->b0 = e->b1; - e->x1 = X; - e->y1 = Y; - e->b1 = Shp(); -// asm sti // ...done! - if (! Flags.Hide) - { - if (Flags.Xlat) e->b1->XShow(e->x1, e->y1); - else e->b1->Show(e->x1, e->y1); - } + if (Flags.Xlat) + KillXlat(); + for (b = Ext->ShpList; *b; b ++) + (*b)->M = x; + Flags.Xlat = true; + } } -void SPRITE::Show (uint16 pg) -{ - uint8 * a = VGA::Page[1]; - VGA::Page[1] = VGA::Page[pg & 3]; - Shp()->Show(X, Y); - VGA::Page[1] = a; -} - +void SPRITE::KillXlat(void) { + if (Flags.Xlat && Ext) { + BMP_PTR *b; + uint8 *m = (*Ext->ShpList)->M; -void SPRITE::Hide (void) -{ - register SPREXT * e = Ext; - if (e->b0) e->b0->Hide(e->x0, e->y0); + switch (MemType(m)) { + case NEAR_MEM : + delete[](uint8 *) m; + break; + case FAR_MEM : + free(m); + break; + } + for (b = Ext->ShpList; *b; b ++) + (*b)->M = NULL; + Flags.Xlat = false; + } } -BMP_PTR SPRITE::Ghost (void) -{ - register SPREXT * e = Ext; - if (e->b1) - { - BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); - if (bmp == NULL) - error("No core"); - bmp->W = e->b1->W; - bmp->H = e->b1->H; - if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) - error("No Core"); - bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); - // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment - //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); - return bmp; - } - return NULL; +void SPRITE::Goto(int x, int y) { + int xo = X, yo = Y; + if (W < SCR_WID) { + if (x < 0) + x = 0; + if (x + W > SCR_WID) + x = (SCR_WID - W); + X = x; + } + if (H < SCR_HIG) { + if (y < 0) + y = 0; + if (y + H > SCR_HIG) + y = (SCR_HIG - H); + Y = y; + } + if (Next) + if (Next->Flags.Slav) + Next->Goto(Next->X - xo + X, Next->Y - yo + Y); + if (Flags.Shad) + Prev->Goto(Prev->X - xo + X, Prev->Y - yo + Y); } -SPRITE * SpriteAt (int x, int y) -{ - SPRITE * spr = NULL, * tail = VGA::ShowQ.Last(); - if (tail) - { - for (spr = tail->Prev; spr; spr = spr->Prev) - if (! spr->Flags.Hide && ! spr->Flags.Tran) - if (spr->Shp()->SolidAt(x-spr->X, y-spr->Y)) - break; - } - return spr; +void SPRITE::Center(void) { + Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); } -QUEUE::QUEUE (bool show) -: Head(NULL), Tail(NULL), Show(show) -{ +void SPRITE::Show(void) { + register SPREXT *e; +// asm cli // critic section... + e = Ext; + e->x0 = e->x1; + e->y0 = e->y1; + e->b0 = e->b1; + e->x1 = X; + e->y1 = Y; + e->b1 = Shp(); +// asm sti // ...done! + if (! Flags.Hide) { + if (Flags.Xlat) e->b1->XShow(e->x1, e->y1); + else e->b1->Show(e->x1, e->y1); + } } -QUEUE::~QUEUE (void) -{ - Clear(); +void SPRITE::Show(uint16 pg) { + uint8 *a = VGA::Page[1]; + VGA::Page[1] = VGA::Page[pg & 3]; + Shp()->Show(X, Y); + VGA::Page[1] = a; } -void QUEUE::Clear (void) -{ - while (Head) - { - SPRITE * s = Remove(Head); - if (s->Flags.Kill) delete s; - } +void SPRITE::Hide(void) { + register SPREXT *e = Ext; + if (e->b0) + e->b0->Hide(e->x0, e->y0); } -void QUEUE::ForAll (void (*fun)(SPRITE *)) -{ - SPRITE * s = Head; - while (s) - { - SPRITE * n = s->Next; - fun(s); - s = n; - } +BMP_PTR SPRITE::Ghost(void) { + register SPREXT *e = Ext; + if (e->b1) { + BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); + if (bmp == NULL) + error("No core"); + bmp->W = e->b1->W; + bmp->H = e->b1->H; + if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) + error("No Core"); + bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment + //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); + warning("FIXME: SPRITE::Ghost"); + return bmp; + } + return NULL; } -void QUEUE::Append (SPRITE * spr) -{ - if (Tail) - { - spr->Prev = Tail; - Tail->Next = spr; - } - else Head = spr; - Tail = spr; - if (Show) spr->Expand(); - else spr->Contract(); +SPRITE *SpriteAt(int x, int y) { + SPRITE *spr = NULL, * tail = VGA::ShowQ.Last(); + if (tail) { + for (spr = tail->Prev; spr; spr = spr->Prev) + if (! spr->Flags.Hide && ! spr->Flags.Tran) + if (spr->Shp()->SolidAt(x - spr->X, y - spr->Y)) + break; + } + return spr; } -void QUEUE::Insert (SPRITE * spr, SPRITE * nxt) -{ - if (nxt == Head) - { - spr->Next = Head; - Head = spr; - if (! Tail) Tail = spr; - } - else - { - spr->Next = nxt; - spr->Prev = nxt->Prev; - if (spr->Prev) spr->Prev->Next = spr; - } - if (spr->Next) spr->Next->Prev = spr; - if (Show) spr->Expand(); - else spr->Contract(); +QUEUE::QUEUE(bool show) : Head(NULL), Tail(NULL), Show(show) { } -void QUEUE::Insert (SPRITE * spr) -{ - SPRITE * s; - for (s = Head; s; s = s->Next) - if (s->Z > spr->Z) - break; - if (s) Insert(spr, s); - else Append(spr); - if (Show) spr->Expand(); - else spr->Contract(); +QUEUE::~QUEUE(void) { + Clear(); } -SPRITE * QUEUE::Remove (SPRITE * spr) -{ - if (spr == Head) Head = spr->Next; - if (spr == Tail) Tail = spr->Prev; - if (spr->Next) spr->Next->Prev = spr->Prev; - if (spr->Prev) spr->Prev->Next = spr->Next; - spr->Prev = NULL; - spr->Next = NULL; - return spr; +void QUEUE::Clear(void) { + while (Head) { + SPRITE *s = Remove(Head); + if (s->Flags.Kill) + delete s; + } } -SPRITE * QUEUE::Locate (int ref) -{ - SPRITE * spr; - for (spr = Head; spr; spr = spr->Next) if (spr->Ref == ref) return spr; - return NULL; +void QUEUE::ForAll(void (*fun)(SPRITE *)) { + SPRITE *s = Head; + while (s) { + SPRITE *n = s->Next; + fun(s); + s = n; + } } -uint16 VGA::StatAdr = VGAST1_; -uint16 VGA::OldMode = 0; -uint16 * VGA::OldScreen = NULL; -const char * VGA::Msg = NULL; -const char * VGA::Nam = NULL; -DAC * VGA::OldColors = NULL; -DAC * VGA::NewColors = NULL; -bool VGA::SetPal = false; -int VGA::Mono = 0; -QUEUE VGA::ShowQ = true, VGA::SpareQ = false; +void QUEUE::Append(SPRITE *spr) { + if (Tail) { + spr->Prev = Tail; + Tail->Next = spr; + } else + Head = spr; + Tail = spr; + if (Show) + spr->Expand(); + else + spr->Contract(); +} + + +void QUEUE::Insert(SPRITE *spr, SPRITE *nxt) { + if (nxt == Head) { + spr->Next = Head; + Head = spr; + if (! Tail) + Tail = spr; + } else { + spr->Next = nxt; + spr->Prev = nxt->Prev; + if (spr->Prev) + spr->Prev->Next = spr; + } + if (spr->Next) + spr->Next->Prev = spr; + if (Show) + spr->Expand(); + else + spr->Contract(); +} + + +void QUEUE::Insert(SPRITE *spr) { + SPRITE *s; + for (s = Head; s; s = s->Next) + if (s->Z > spr->Z) + break; + if (s) + Insert(spr, s); + else + Append(spr); + if (Show) + spr->Expand(); + else + spr->Contract(); +} + + +SPRITE *QUEUE::Remove(SPRITE *spr) { + if (spr == Head) + Head = spr->Next; + if (spr == Tail) + Tail = spr->Prev; + if (spr->Next) + spr->Next->Prev = spr->Prev; + if (spr->Prev) + spr->Prev->Next = spr->Next; + spr->Prev = NULL; + spr->Next = NULL; + return spr; +} + + +SPRITE *QUEUE::Locate(int ref) { + SPRITE *spr; + for (spr = Head; spr; spr = spr->Next) + if (spr->Ref == ref) + return spr; + return NULL; +} + + +uint16 VGA::StatAdr = VGAST1_; +uint16 VGA::OldMode = 0; +uint16 *VGA::OldScreen = NULL; +const char *VGA::Msg = NULL; +const char *VGA::Nam = NULL; +DAC *VGA::OldColors = NULL; +DAC *VGA::NewColors = NULL; +bool VGA::SetPal = false; +int VGA::Mono = 0; +QUEUE VGA::ShowQ = true, VGA::SpareQ = false; // TODO: Was direct mapping to VGA buffers.. need to create scummvm surfaces for that -uint8 * VGA::Page[4] = { 0, 0, 0, 0 }; +uint8 *VGA::Page[4] = { 0, 0, 0, 0 }; /* -uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), - (uint8 *) MK_FP(SCR_SEG, 0x4000), - (uint8 *) MK_FP(SCR_SEG, 0x8000), - (uint8 *) MK_FP(SCR_SEG, 0xC000) }; +uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), + (uint8 *) MK_FP(SCR_SEG, 0x4000), + (uint8 *) MK_FP(SCR_SEG, 0x8000), + (uint8 *) MK_FP(SCR_SEG, 0xC000) }; */ - - //extern const char Copr[]; -VGA::VGA (int mode) -: FrmCnt(0) -{ - bool std = true; - int i; - for (i = 10; i < 20; i ++) - { - char * txt = Text[i]; - if (txt) - { +VGA::VGA(int mode) + : FrmCnt(0) { + bool std = true; + int i; + for (i = 10; i < 20; i ++) { + char *txt = Text[i]; + if (txt) { // puts(txt); - warning(txt); - #ifndef DEBUG - std = false; - #endif + warning(txt); +#ifndef DEBUG + std = false; +#endif + } } - } -// if (std) +// if (std) // warning(Copr); - warning("TODO: Fix Copr"); - - SetStatAdr(); - if (StatAdr != VGAST1_) ++ Mono; - if (IsVga()) - { - OldColors = farnew(DAC, 256); - NewColors = farnew(DAC, 256); - OldScreen = SaveScreen(); - GetColors(OldColors); - Sunset(); - OldMode = SetMode(mode); - SetColors(); - Setup(VideoMode); - Clear(); - } + warning("TODO: Fix Copr"); + + SetStatAdr(); + if (StatAdr != VGAST1_) + ++Mono; + if (IsVga()) { + OldColors = farnew(DAC, 256); + NewColors = farnew(DAC, 256); + OldScreen = SaveScreen(); + GetColors(OldColors); + Sunset(); + OldMode = SetMode(mode); + SetColors(); + Setup(VideoMode); + Clear(); + } } -VGA::~VGA (void) -{ - Mono = 0; - if (IsVga()) - { - Common::String buffer = ""; - Clear(); - SetMode(OldMode); - SetColors(); - RestoreScreen(OldScreen); - Sunrise(OldColors); - if (OldColors) free(OldColors); - if (NewColors) free(NewColors); - if (Msg) - buffer = Common::String(Msg); - if (Nam) - buffer = buffer + " [" + Nam + "]"; - - warning(buffer.c_str()); - } +VGA::~VGA(void) { + Mono = 0; + if (IsVga()) { + Common::String buffer = ""; + Clear(); + SetMode(OldMode); + SetColors(); + RestoreScreen(OldScreen); + Sunrise(OldColors); + if (OldColors) + free(OldColors); + if (NewColors) + free(NewColors); + if (Msg) + buffer = Common::String(Msg); + if (Nam) + buffer = buffer + " [" + Nam + "]"; + + warning(buffer.c_str()); + } } -void VGA::SetStatAdr (void) -{ +void VGA::SetStatAdr(void) { /* - asm mov dx,VGAMIr_ - asm in al,dx - asm test al,1 // CGA addressing mode flag - asm mov ax,VGAST1_ // CGA addressing - asm jnz set_mode_adr - asm xor al,0x60 // MDA addressing - set_mode_adr: - StatAdr = _AX; - */ + asm mov dx,VGAMIr_ + asm in al,dx + asm test al,1 // CGA addressing mode flag + asm mov ax,VGAST1_ // CGA addressing + asm jnz set_mode_adr + asm xor al,0x60 // MDA addressing + set_mode_adr: + StatAdr = _AX; + */ warning("STUB: VGA::SetStatADR"); } #pragma argsused -void VGA::WaitVR (bool on) -{ -/* - _DX = StatAdr; - _AH = (on) ? 0x00 : 0x08; - - asm mov cx,2 - // wait for vertical retrace on (off) - wait: - asm in al,dx - asm xor al,ah - asm test al,0x08 - asm jnz wait - asm xor ah,0x08 - asm loop wait - */ +void VGA::WaitVR(bool on) { + /* + _DX = StatAdr; + _AH = (on) ? 0x00 : 0x08; + + asm mov cx,2 + // wait for vertical retrace on (off) + wait: + asm in al,dx + asm xor al,ah + asm test al,0x08 + asm jnz wait + asm xor ah,0x08 + asm loop wait + */ warning("STUB: VGA::WaitVR"); } -void VGA::Setup (VgaRegBlk * vrb) -{ -/* - WaitVR(); // *--LOOK!--* resets VGAATR logic - asm cld - asm mov si, vrb // take address of parameter table - asm mov dh,0x03 // higher byte of I/O address is always 3 - - s: - asm lodsw // take lower byte of I/O address and index - asm or ah,ah // 0 = end of table - asm jz xit // no more: exit - asm or al,al // indexed register? - asm js single // 7th bit set means single register - asm mov dl,ah // complete I/O address - asm out dx,al // put index into control register - asm inc dx // data register is next to control - asm in al,dx // take old data - - write: - asm mov cl,al // preserve old data - asm lodsw // take 2 masks from table - asm xor al,0xFF // invert mask bits - asm and al,cl // clear bits with "clr" mask - asm or al,ah // set bits with "set" mask - asm cmp dl,0xC1 // special case? - asm jne std2 // no: standard job, otherwise... - asm dec dx // data out reg shares address with index - std2: - asm out dx,al // write new value to register - asm jmp s - - single: // read address in al, write address in ah - asm mov dl,al // complete I/O read address - asm in al,dx // take old data - asm mov dl,ah // complete I/O write address - asm jmp write // continue standard routine - - xit: - */ +void VGA::Setup(VgaRegBlk *vrb) { + /* + WaitVR(); // *--LOOK!--* resets VGAATR logic + asm cld + asm mov si, vrb // take address of parameter table + asm mov dh,0x03 // higher byte of I/O address is always 3 + + s: + asm lodsw // take lower byte of I/O address and index + asm or ah,ah // 0 = end of table + asm jz xit // no more: exit + asm or al,al // indexed register? + asm js single // 7th bit set means single register + asm mov dl,ah // complete I/O address + asm out dx,al // put index into control register + asm inc dx // data register is next to control + asm in al,dx // take old data + + write: + asm mov cl,al // preserve old data + asm lodsw // take 2 masks from table + asm xor al,0xFF // invert mask bits + asm and al,cl // clear bits with "clr" mask + asm or al,ah // set bits with "set" mask + asm cmp dl,0xC1 // special case? + asm jne std2 // no: standard job, otherwise... + asm dec dx // data out reg shares address with index + std2: + asm out dx,al // write new value to register + asm jmp s + + single: // read address in al, write address in ah + asm mov dl,al // complete I/O read address + asm in al,dx // take old data + asm mov dl,ah // complete I/O write address + asm jmp write // continue standard routine + + xit: + */ warning("STUB: VGA::Setup"); } -int VGA::SetMode(int mode) -{ -/* - Clear(); - // get current mode - asm mov ah,0x0F - Video(); // BIOS video service - asm xor ah,ah - asm push ax - - // wait for v-retrace - WaitVR(); - - // set mode - asm xor ah,ah - asm mov al,byte ptr mode - Video(); // BIOS video service - SetStatAdr(); - // return previous mode - asm pop ax - return _AX; - */ - warning("STUB: VGA::SetMode"); +int VGA::SetMode(int mode) { + /* + Clear(); + // get current mode + asm mov ah,0x0F + Video(); // BIOS video service + asm xor ah,ah + asm push ax + + // wait for v-retrace + WaitVR(); + + // set mode + asm xor ah,ah + asm mov al,byte ptr mode + Video(); // BIOS video service + SetStatAdr(); + // return previous mode + asm pop ax + return _AX; + */ + warning("STUB: VGA::SetMode"); return 0; } -void VGA::GetColors(DAC * tab) -{ -/* - asm cld - asm les di,tab // color table - asm mov dx,0x3C7 // PEL address read mode register - asm xor al,al // start from address 0 - asm out dx,al // put address - asm mov cx,256*3 // # of colors - asm mov dl,0xC9 // PEL data register - -// asm rep insb // very fast! - - gc: // much slower: - asm in al,dx // take 1 color - asm jmp sto // little delay - sto: - asm stosb // store 1 color - asm loop gc // next one? - */ +void VGA::GetColors(DAC *tab) { + /* + asm cld + asm les di,tab // color table + asm mov dx,0x3C7 // PEL address read mode register + asm xor al,al // start from address 0 + asm out dx,al // put address + asm mov cx,256*3 // # of colors + asm mov dl,0xC9 // PEL data register + + // asm rep insb // very fast! + + gc: // much slower: + asm in al,dx // take 1 color + asm jmp sto // little delay + sto: + asm stosb // store 1 color + asm loop gc // next one? + */ warning("STUB: VGA::GetColors"); } -void VGA::SetColors(DAC * tab, int lum) -{ -/* - DAC * des = NewColors; - asm push ds - - asm les di,des - asm lds si,tab - asm mov cx,256*3 - asm xor bx,bx - asm mov dx,lum - - copcol: - asm mov al,[si+bx] - asm mul dl - asm shr ax,6 - asm mov es:[di+bx],al - asm inc bx - asm cmp bx,cx - asm jb copcol - - asm pop ds - - if (Mono) - { - asm add cx,di - mono: - asm xor dx,dx - asm mov al,77 // 30% R - asm mul byte ptr es:[di].0 - asm add dx,ax - asm mov al,151 // 59% G - asm mul byte ptr es:[di].1 - asm add dx,ax - asm mov al,28 // 11% B - asm mul byte ptr es:[di].2 - asm add dx,ax - - asm mov es:[di].0,dh - asm mov es:[di].1,dh - asm mov es:[di].2,dh - - asm add di,3 - asm cmp di,cx - asm jb mono - } - */ - SetPal = true; - warning("STUB: VGA::SetColors"); +void VGA::SetColors(DAC *tab, int lum) { + /* + DAC * des = NewColors; + asm push ds + + asm les di,des + asm lds si,tab + asm mov cx,256*3 + asm xor bx,bx + asm mov dx,lum + + copcol: + asm mov al,[si+bx] + asm mul dl + asm shr ax,6 + asm mov es:[di+bx],al + asm inc bx + asm cmp bx,cx + asm jb copcol + + asm pop ds + + if (Mono) + { + asm add cx,di + mono: + asm xor dx,dx + asm mov al,77 // 30% R + asm mul byte ptr es:[di].0 + asm add dx,ax + asm mov al,151 // 59% G + asm mul byte ptr es:[di].1 + asm add dx,ax + asm mov al,28 // 11% B + asm mul byte ptr es:[di].2 + asm add dx,ax + + asm mov es:[di].0,dh + asm mov es:[di].1,dh + asm mov es:[di].2,dh + + asm add di,3 + asm cmp di,cx + asm jb mono + } + */ + SetPal = true; + warning("STUB: VGA::SetColors"); } -void VGA::SetColors (void) -{ - memset(NewColors, 0, PAL_SIZ); - UpdateColors(); +void VGA::SetColors(void) { + memset(NewColors, 0, PAL_SIZ); + UpdateColors(); } -void VGA::Sunrise (DAC * tab) -{ - int i; - for (i = 0; i <= 64; i += FADE_STEP) - { - SetColors(tab, i); - WaitVR(); - UpdateColors(); - } +void VGA::Sunrise(DAC *tab) { + for (int i = 0; i <= 64; i += FADE_STEP) { + SetColors(tab, i); + WaitVR(); + UpdateColors(); + } } -void VGA::Sunset (void) -{ - DAC tab[256]; - int i; - GetColors(tab); - for (i = 64; i >= 0; i -= FADE_STEP) - { - SetColors(tab, i); - WaitVR(); - UpdateColors(); - } +void VGA::Sunset(void) { + DAC tab[256]; + GetColors(tab); + for (int i = 64; i >= 0; i -= FADE_STEP) { + SetColors(tab, i); + WaitVR(); + UpdateColors(); + } } -void VGA::Show (void) -{ - SPRITE * spr = ShowQ.First(); +void VGA::Show(void) { + SPRITE *spr = ShowQ.First(); - for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Show(); - Update(); - for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Hide(); + for (spr = ShowQ.First(); spr; spr = spr->Next) + spr->Show(); + Update(); + for (spr = ShowQ.First(); spr; spr = spr->Next) + spr->Hide(); - ++ FrmCnt; + ++ FrmCnt; } -void VGA::UpdateColors(void) -{ -/* - DAC * tab = NewColors; +void VGA::UpdateColors(void) { + /* + DAC * tab = NewColors; - asm push ds - asm cld - asm lds si,tab // color table - asm mov dx,0x3C8 // PEL address write mode register - asm xor al,al // start from address 0 - asm out dx,al // put address - asm mov cx,256*3 // # of colors - asm mov dl,0xC9 // PEL data register + asm push ds + asm cld + asm lds si,tab // color table + asm mov dx,0x3C8 // PEL address write mode register + asm xor al,al // start from address 0 + asm out dx,al // put address + asm mov cx,256*3 // # of colors + asm mov dl,0xC9 // PEL data register -// asm rep outsb // very fast! + // asm rep outsb // very fast! - // the slower version of above: - sc: - asm lodsb // take 1/3 color - asm out dx,al // put 1/3 color - asm jmp loop // little delay - loop: - asm loop sc // next one? + // the slower version of above: + sc: + asm lodsb // take 1/3 color + asm out dx,al // put 1/3 color + asm jmp loop // little delay + loop: + asm loop sc // next one? - asm pop ds - */ - warning("STUB: VGA::UpdateColors"); + asm pop ds + */ + warning("STUB: VGA::UpdateColors"); } -void VGA::Update(void) -{ -/* - uint8 * p = Page[1]; - Page[1] = Page[0]; - Page[0] = p; - - asm mov dx,VGACRT_ - asm mov al,0x0D - asm mov ah,byte ptr p - asm out dx,ax - asm dec al - asm mov ah,byte ptr p+1 - asm out dx,ax -*/ - if (! SpeedTest) WaitVR(); +void VGA::Update(void) { + /* + uint8 * p = Page[1]; + Page[1] = Page[0]; + Page[0] = p; + + asm mov dx,VGACRT_ + asm mov al,0x0D + asm mov ah,byte ptr p + asm out dx,ax + asm dec al + asm mov ah,byte ptr p+1 + asm out dx,ax + */ + if (! SpeedTest) WaitVR(); - if (SetPal) - { - UpdateColors(); - SetPal = false; - } - warning("STUB: VGA::Update"); + if (SetPal) { + UpdateColors(); + SetPal = false; + } + warning("STUB: VGA::Update"); } -void VGA::Clear(uint8 color) -{ -/* - uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); +void VGA::Clear(uint8 color) { + /* + uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // map mask register - enable all planes - asm out dx,ax - asm les di,a - asm cld + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // map mask register - enable all planes + asm out dx,ax + asm les di,a + asm cld - asm mov cx,0xFFFF - asm mov al,color - asm rep stosb - asm stosb - */ - warning("STUB: VGA::Clear"); + asm mov cx,0xFFFF + asm mov al,color + asm rep stosb + asm stosb + */ + warning("STUB: VGA::Clear"); } -void VGA::CopyPage(uint16 d, uint16 s) -{ -/* - uint8 * S = Page[s & 3], * D = Page[d & 3]; +void VGA::CopyPage(uint16 d, uint16 s) { + /* + uint8 * S = Page[s & 3], * D = Page[d & 3]; - asm mov dx,VGAGRA_ - asm mov al,0x05 // R/W mode - asm out dx,al - asm inc dx - asm in al,dx - asm and al,0xF4 - asm push ax - asm push dx - asm or al,0x01 - asm out dx,al + asm mov dx,VGAGRA_ + asm mov al,0x05 // R/W mode + asm out dx,al + asm inc dx + asm in al,dx + asm and al,0xF4 + asm push ax + asm push dx + asm or al,0x01 + asm out dx,al - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // map mask register - enable all planes - asm out dx,ax + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // map mask register - enable all planes + asm out dx,ax - asm push ds + asm push ds - asm les di,D - asm lds si,S - asm cld - asm mov cx,0x4000 - asm rep movsb + asm les di,D + asm lds si,S + asm cld + asm mov cx,0x4000 + asm rep movsb - asm pop ds + asm pop ds - asm pop dx - asm pop ax - asm out dx,al // end of copy mode - */ - warning("STUB: VGA::CopyPage"); + asm pop dx + asm pop ax + asm out dx,al // end of copy mode + */ + warning("STUB: VGA::CopyPage"); } //-------------------------------------------------------------------------- -void BITMAP::XShow(int x, int y) -{ -/* - uint8 rmsk = x % 4, - mask = 1 << rmsk, - * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - uint8 * m = (char *) M; - uint8 * v = V; - - asm push bx - asm push si - asm push ds - - asm cld - asm les di,scr - asm lds si,v - asm mov bx,m - - asm mov al,0x02 // map mask register - asm mov ah,mask - - plane: - // enable output plane - asm mov dx,VGASEQ_ - asm out dx,ax - asm push ax - - // select input plane - asm mov dx,VGAGRA_ - asm mov al,0x04 // read map select register - asm mov ah,rmsk - asm out dx,ax - - asm push di - - block: - asm lodsw - asm mov cx,ax - asm and ch,0x3F - asm test ah,0xC0 - asm jz endpl - asm jns skip - asm jnp incsi // replicate? - asm add si,cx // skip over data block - asm dec si // fix it before following inc - - incsi: - asm inc si - tint: - asm mov al,es:[di] - //----------------------------------------------- - // asm xlat ss:0 // unsupported with BASM! - __emit__(0x36, 0xD7); // this stands for above! - //----------------------------------------------- - asm stosb - asm loop tint - asm jmp block - - skip: - asm add di,cx - asm jmp block - - endpl: - asm pop di - asm pop ax - asm inc rmsk - asm shl ah,1 - asm test ah,0x10 - asm jz x_chk - asm mov ah,0x01 - asm mov rmsk,0 - asm inc di - x_chk: - asm cmp ah,mask - asm jne plane - asm pop ds - asm pop si - asm pop bx - */ +void BITMAP::XShow(int x, int y) { + /* + uint8 rmsk = x % 4, + mask = 1 << rmsk, + * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + uint8 * m = (char *) M; + uint8 * v = V; + + asm push bx + asm push si + asm push ds + + asm cld + asm les di,scr + asm lds si,v + asm mov bx,m + + asm mov al,0x02 // map mask register + asm mov ah,mask + + plane: + // enable output plane + asm mov dx,VGASEQ_ + asm out dx,ax + asm push ax + + // select input plane + asm mov dx,VGAGRA_ + asm mov al,0x04 // read map select register + asm mov ah,rmsk + asm out dx,ax + + asm push di + + block: + asm lodsw + asm mov cx,ax + asm and ch,0x3F + asm test ah,0xC0 + asm jz endpl + asm jns skip + asm jnp incsi // replicate? + asm add si,cx // skip over data block + asm dec si // fix it before following inc + + incsi: + asm inc si + tint: + asm mov al,es:[di] + //----------------------------------------------- + // asm xlat ss:0 // unsupported with BASM! + __emit__(0x36, 0xD7); // this stands for above! + //----------------------------------------------- + asm stosb + asm loop tint + asm jmp block + + skip: + asm add di,cx + asm jmp block + + endpl: + asm pop di + asm pop ax + asm inc rmsk + asm shl ah,1 + asm test ah,0x10 + asm jz x_chk + asm mov ah,0x01 + asm mov rmsk,0 + asm inc di + x_chk: + asm cmp ah,mask + asm jne plane + asm pop ds + asm pop si + asm pop bx + */ warning("STUB: BITMAP::XShow"); } -void BITMAP::Show(int x, int y) -{ +void BITMAP::Show(int x, int y) { /* - uint8 mask = 1 << (x & 3), - * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); - uint8 * v = V; - - asm push ds // preserve DS - - asm cld // normal direction - asm les di,scr // screen address - asm lds si,v // picture address - asm mov dx,VGASEQ_ // VGA reg - asm mov al,0x02 - asm mov ah,mask - - plane: - asm out dx,ax - asm push ax - asm push di - - block: - asm mov cx,[si] // with ADD faster then LODSW - asm add si,2 - asm test ch,0xC0 - asm jns skip // 1 (SKP) or 0 (EOI) - asm jpo repeat // 2 (REP) - - copy: // 3 (CPY) - asm and ch,0x3F - asm shr cx,1 - asm rep movsw - asm jnc block - asm movsb - asm jmp block - - repeat: - asm and ch,0x3F - asm mov al,[si] - asm inc si - asm mov ah,al - asm shr cx,1 - asm rep stosw - asm jnc block - asm mov es:[di],al - asm inc di - asm jmp block - - skip: - asm jz endpl - asm and ch,0x3F - asm add di,cx - asm jmp block - - endpl: - asm pop di - asm pop ax - asm shl ah,1 - asm test ah,0x10 - asm jz x_chk - asm mov ah,0x01 - asm inc di - x_chk: - asm cmp ah,mask - asm jne plane - asm pop ds + uint8 mask = 1 << (x & 3), + * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); + uint8 * v = V; + + asm push ds // preserve DS + + asm cld // normal direction + asm les di,scr // screen address + asm lds si,v // picture address + asm mov dx,VGASEQ_ // VGA reg + asm mov al,0x02 + asm mov ah,mask + + plane: + asm out dx,ax + asm push ax + asm push di + + block: + asm mov cx,[si] // with ADD faster then LODSW + asm add si,2 + asm test ch,0xC0 + asm jns skip // 1 (SKP) or 0 (EOI) + asm jpo repeat // 2 (REP) + + copy: // 3 (CPY) + asm and ch,0x3F + asm shr cx,1 + asm rep movsw + asm jnc block + asm movsb + asm jmp block + + repeat: + asm and ch,0x3F + asm mov al,[si] + asm inc si + asm mov ah,al + asm shr cx,1 + asm rep stosw + asm jnc block + asm mov es:[di],al + asm inc di + asm jmp block + + skip: + asm jz endpl + asm and ch,0x3F + asm add di,cx + asm jmp block + + endpl: + asm pop di + asm pop ax + asm shl ah,1 + asm test ah,0x10 + asm jz x_chk + asm mov ah,0x01 + asm inc di + x_chk: + asm cmp ah,mask + asm jne plane + asm pop ds */ warning("STUB: BITMAP::Show"); } -void BITMAP::Hide(int x, int y) -{ -/* - uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); - HideDesc * b = B; - uint16 extra = ((x & 3) != 0); - uint16 h = H; - -// asm push bx - asm push si - asm push ds - - asm cld - asm les di,scr - asm mov si,di - asm add si,d // take bytes from background page - asm lds bx,b - - asm mov dx,VGAGRA_ - asm mov al,0x05 // R/W mode - asm out dx,al - asm inc dx - asm in al,dx - asm and al,0xF4 - asm push ax - asm push dx - asm or al,0x01 - asm out dx,al - - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // enable all planes - asm out dx,ax - - asm mov dx,ds // save DS - - row: -// skip block - asm mov cx,[bx] - asm add si,cx - asm add di,cx - asm mov cx,[bx+2] - asm add bx,4 - asm add cx,extra - - asm push es - asm pop ds // set DS to video seg - asm rep movsb // move bytes fast - asm sub si,extra - asm sub di,extra - asm mov ds,dx // restore DS - - asm dec h - asm jnz row - - asm pop dx - asm pop ax - asm out dx,al // end of copy mode - - - asm pop ds - asm pop si -// asm pop bx -*/ +void BITMAP::Hide(int x, int y) { + /* + uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); + HideDesc * b = B; + uint16 extra = ((x & 3) != 0); + uint16 h = H; + + // asm push bx + asm push si + asm push ds + + asm cld + asm les di,scr + asm mov si,di + asm add si,d // take bytes from background page + asm lds bx,b + + asm mov dx,VGAGRA_ + asm mov al,0x05 // R/W mode + asm out dx,al + asm inc dx + asm in al,dx + asm and al,0xF4 + asm push ax + asm push dx + asm or al,0x01 + asm out dx,al + + asm mov dx,VGASEQ_ + asm mov ax,0x0F02 // enable all planes + asm out dx,ax + + asm mov dx,ds // save DS + + row: + // skip block + asm mov cx,[bx] + asm add si,cx + asm add di,cx + asm mov cx,[bx+2] + asm add bx,4 + asm add cx,extra + + asm push es + asm pop ds // set DS to video seg + asm rep movsb // move bytes fast + asm sub si,extra + asm sub di,extra + asm mov ds,dx // restore DS + + asm dec h + asm jnz row + + asm pop dx + asm pop ax + asm out dx,al // end of copy mode + + + asm pop ds + asm pop si + // asm pop bx + */ warning("STUB: BITMAP::Hide"); } -- cgit v1.2.3 From 64f2ccca9bf4ba7fef87def8bee5209118d78ce8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 13 Jun 2011 13:07:45 +0200 Subject: CGE: Cleanup: remove trailing spaces --- engines/cge/vga13h.cpp | 124 ++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e7ed6d0402..3f303e7f29 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -88,7 +88,7 @@ extern "C" void SNDMIDIPlay(void); char *NumStr(char *str, int num) { char *p = strchr(str, '#'); - if (p) + if (p) wtom(num, p, 10, 5); return str; } @@ -345,7 +345,7 @@ void ENGINE::NewTimer(...) { void HEART::SetXTimer(uint16 *ptr) { - if (XTimer && ptr != XTimer) + if (XTimer && ptr != XTimer) *XTimer = 0; XTimer = ptr; } @@ -374,7 +374,7 @@ SPRITE::~SPRITE(void) { BMP_PTR SPRITE::Shp(void) { register SPREXT *e = Ext; - if (e) + if (e) if (e->Seq) { int i = e->Seq[SeqPtr].Now; #ifdef DEBUG @@ -403,15 +403,15 @@ BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) { BMP_PTR *p; for (p = shp; *p; p++) { BMP_PTR b = (*p); // ->Code(); - if (b->W > W) + if (b->W > W) W = b->W; - if (b->H > H) + if (b->H > H) H = b->H; ++ShpCnt; } Expand(); Ext->ShpList = shp; - if (! Ext->Seq) + if (! Ext->Seq) SetSeq((ShpCnt < 2) ? Seq1 : Seq2); } return r; @@ -427,7 +427,7 @@ void SPRITE::MoveShapes(uint8 *buf) { bool SPRITE::Works(SPRITE *spr) { - if (spr) + if (spr) if (spr->Ext) { SNAIL::COM *c = spr->Ext->Take; if (c != NULL) { @@ -445,18 +445,18 @@ SEQ *SPRITE::SetSeq(SEQ *seq) { Expand(); register SEQ *s = Ext->Seq; Ext->Seq = seq; - if (SeqPtr == NO_SEQ) + if (SeqPtr == NO_SEQ) Step(0); - else if (Time == 0) + else if (Time == 0) Step(SeqPtr); return s; } bool SPRITE::SeqTest(int n) { - if (n >= 0) + if (n >= 0) return (SeqPtr == n); - if (Ext) + if (Ext) return (Ext->Seq[SeqPtr].Next == SeqPtr); return true; } @@ -464,7 +464,7 @@ bool SPRITE::SeqTest(int n) { SNAIL::COM *SPRITE::SnList(SNLIST type) { register SPREXT *e = Ext; - if (e) + if (e) return (type == NEAR) ? e->Near : e->Take; return NULL; } @@ -477,7 +477,7 @@ void SPRITE::SetName(char *n) { Ext->Name = NULL; } if (n) { - if ((Ext->Name = new char[strlen(n) + 1]) != NULL) + if ((Ext->Name = new char[strlen(n) + 1]) != NULL) strcpy(Ext->Name, n); else error("No core [%s]", n); @@ -516,9 +516,9 @@ SPRITE *SPRITE::Expand(void) { while ((len = sprf.Read((uint8 *)line)) != 0) { ++ lcnt; - if (len && line[len - 1] == '\n') + if (len && line[len - 1] == '\n') line[-- len] = '\0'; - if (len == 0 || *line == '.') + if (len == 0 || *line == '.') continue; switch (TakeEnum(Comd, strtok(line, " =\t"))) { @@ -536,7 +536,7 @@ SPRITE *SPRITE::Expand(void) { error("No core [%s]", fname); SEQ *s = &seq[seqcnt ++]; s->Now = atoi(strtok(NULL, " \t,;/")); - if (s->Now > maxnow) + if (s->Now > maxnow) maxnow = s->Now; s->Next = atoi(strtok(NULL, " \t,;/")); switch (s->Next) { @@ -547,7 +547,7 @@ SPRITE *SPRITE::Expand(void) { s->Next = seqcnt - 1; break; } - if (s->Next > maxnxt) + if (s->Next > maxnxt) maxnxt = s->Next; s->Dx = atoi(strtok(NULL, " \t,;/")); s->Dy = atoi(strtok(NULL, " \t,;/")); @@ -598,19 +598,19 @@ SPRITE *SPRITE::Expand(void) { if (maxnxt >= seqcnt) error("Bad JUMP in SEQ [%s]", fname); SetSeq(seq); - } else + } else SetSeq((ShpCnt == 1) ? Seq1 : Seq2); //disable(); // disable interupt SetShapeList(shplist); //enable(); // enable interupt - if (nea) + if (nea) nea[neacnt - 1].Ptr = Ext->Near = nea; - else + else NearPtr = NO_PTR; - if (tak) + if (tak) tak[takcnt - 1].Ptr = Ext->Take = tak; - else + else TakePtr = NO_PTR; } HEART::Enable = enbl; @@ -622,20 +622,20 @@ SPRITE *SPRITE::Expand(void) { SPRITE *SPRITE::Contract(void) { register SPREXT *e = Ext; if (e) { - if (e->Name) + if (e->Name) delete[] e->Name; if (Flags.BDel && e->ShpList) { int i; - for (i = 0; e->ShpList[i]; i ++) + for (i = 0; e->ShpList[i]; i ++) delete e->ShpList[i]; - if (MemType(e->ShpList) == NEAR_MEM) + if (MemType(e->ShpList) == NEAR_MEM) delete[] e->ShpList; } - if (MemType(e->Seq) == NEAR_MEM) + if (MemType(e->Seq) == NEAR_MEM) free(e->Seq); - if (e->Near) + if (e->Near) free(e->Near); - if (e->Take) + if (e->Take) free(e->Take); delete e; Ext = NULL; @@ -648,7 +648,7 @@ SPRITE *SPRITE::BackShow(bool fast) { Expand(); Show(2); Show(1); - if (fast) + if (fast) Show(0); Contract(); return this; @@ -656,11 +656,11 @@ SPRITE *SPRITE::BackShow(bool fast) { void SPRITE::Step(int nr) { - if (nr >= 0) + if (nr >= 0) SeqPtr = nr; if (Ext) { SEQ *seq; - if (nr < 0) + if (nr < 0) SeqPtr = Ext->Seq[SeqPtr].Next; seq = Ext->Seq + SeqPtr; if (seq->Dly >= 0) { @@ -680,7 +680,7 @@ void SPRITE::MakeXlat(uint8 *x) { if (Ext) { BMP_PTR *b; - if (Flags.Xlat) + if (Flags.Xlat) KillXlat(); for (b = Ext->ShpList; *b; b ++) (*b)->M = x; @@ -712,23 +712,23 @@ void SPRITE::KillXlat(void) { void SPRITE::Goto(int x, int y) { int xo = X, yo = Y; if (W < SCR_WID) { - if (x < 0) + if (x < 0) x = 0; - if (x + W > SCR_WID) + if (x + W > SCR_WID) x = (SCR_WID - W); X = x; } if (H < SCR_HIG) { - if (y < 0) + if (y < 0) y = 0; - if (y + H > SCR_HIG) + if (y + H > SCR_HIG) y = (SCR_HIG - H); Y = y; } - if (Next) - if (Next->Flags.Slav) + if (Next) + if (Next->Flags.Slav) Next->Goto(Next->X - xo + X, Next->Y - yo + Y); - if (Flags.Shad) + if (Flags.Shad) Prev->Goto(Prev->X - xo + X, Prev->Y - yo + Y); } @@ -766,7 +766,7 @@ void SPRITE::Show(uint16 pg) { void SPRITE::Hide(void) { register SPREXT *e = Ext; - if (e->b0) + if (e->b0) e->b0->Hide(e->x0, e->y0); } @@ -815,7 +815,7 @@ QUEUE::~QUEUE(void) { void QUEUE::Clear(void) { while (Head) { SPRITE *s = Remove(Head); - if (s->Flags.Kill) + if (s->Flags.Kill) delete s; } } @@ -835,12 +835,12 @@ void QUEUE::Append(SPRITE *spr) { if (Tail) { spr->Prev = Tail; Tail->Next = spr; - } else + } else Head = spr; Tail = spr; - if (Show) + if (Show) spr->Expand(); - else + else spr->Contract(); } @@ -849,19 +849,19 @@ void QUEUE::Insert(SPRITE *spr, SPRITE *nxt) { if (nxt == Head) { spr->Next = Head; Head = spr; - if (! Tail) + if (! Tail) Tail = spr; } else { spr->Next = nxt; spr->Prev = nxt->Prev; - if (spr->Prev) + if (spr->Prev) spr->Prev->Next = spr; } - if (spr->Next) + if (spr->Next) spr->Next->Prev = spr; - if (Show) + if (Show) spr->Expand(); - else + else spr->Contract(); } @@ -871,25 +871,25 @@ void QUEUE::Insert(SPRITE *spr) { for (s = Head; s; s = s->Next) if (s->Z > spr->Z) break; - if (s) + if (s) Insert(spr, s); - else + else Append(spr); - if (Show) + if (Show) spr->Expand(); - else + else spr->Contract(); } SPRITE *QUEUE::Remove(SPRITE *spr) { - if (spr == Head) + if (spr == Head) Head = spr->Next; - if (spr == Tail) + if (spr == Tail) Tail = spr->Prev; - if (spr->Next) + if (spr->Next) spr->Next->Prev = spr->Prev; - if (spr->Prev) + if (spr->Prev) spr->Prev->Next = spr->Next; spr->Prev = NULL; spr->Next = NULL; @@ -899,8 +899,8 @@ SPRITE *QUEUE::Remove(SPRITE *spr) { SPRITE *QUEUE::Locate(int ref) { SPRITE *spr; - for (spr = Head; spr; spr = spr->Next) - if (spr->Ref == ref) + for (spr = Head; spr; spr = spr->Next) + if (spr->Ref == ref) return spr; return NULL; } @@ -948,7 +948,7 @@ VGA::VGA(int mode) warning("TODO: Fix Copr"); SetStatAdr(); - if (StatAdr != VGAST1_) + if (StatAdr != VGAST1_) ++Mono; if (IsVga()) { OldColors = farnew(DAC, 256); @@ -1194,10 +1194,10 @@ void VGA::Sunset(void) { void VGA::Show(void) { SPRITE *spr = ShowQ.First(); - for (spr = ShowQ.First(); spr; spr = spr->Next) + for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Show(); Update(); - for (spr = ShowQ.First(); spr; spr = spr->Next) + for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Hide(); ++ FrmCnt; -- cgit v1.2.3 From 9918344cdc596d211c2c03b5c31f669f06c89f0f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 13 Jun 2011 13:44:52 +0200 Subject: CGE: Fix several issues reported by CPPCHECK --- engines/cge/vga13h.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 3f303e7f29..72831e83cf 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -279,9 +279,9 @@ extern "C" void TimerProc (void) void ENGINE::NewTimer(...) { + /* static SPRITE *spr; static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; - /* ___1152_Hz___: SNDMIDIPlay(); @@ -502,9 +502,7 @@ SPRITE *SPRITE::Expand(void) { neacnt = 0, takcnt = 0, maxnow = 0, - maxnxt = 0, - lcnt = 0, - len; + maxnxt = 0; SNAIL::COM *nea = NULL; SNAIL::COM *tak = NULL; @@ -513,9 +511,9 @@ SPRITE *SPRITE::Expand(void) { INI_FILE sprf(fname); if (! OK(sprf)) error("Bad SPR [%s]", fname); - + int len = 0, lcnt = 0; while ((len = sprf.Read((uint8 *)line)) != 0) { - ++ lcnt; + ++lcnt; if (len && line[len - 1] == '\n') line[-- len] = '\0'; if (len == 0 || *line == '.') -- cgit v1.2.3 From 77d5c25472f414c2b0c49a920329a6811d271281 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 18 Jun 2011 08:54:22 +0200 Subject: CGE: Suppress some defines, fix semi-columns in template definitions --- engines/cge/vga13h.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 72831e83cf..c1587fa45a 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -40,25 +40,14 @@ namespace CGE { -#ifdef DEBUG -#define REPORT -#endif - -#define OK(f) ((f).Error==0) #define FADE_STEP 2 - #define TMR_DIV ((0x8000/TMR_RATE)*2) - //-------------------------------------------------------------------------- -#ifdef REPORT static char Report[] = "NearHeap=..... FarHeap=......\n"; #define NREP 9 #define FREP 24 -#endif - - static VgaRegBlk VideoMode[] = { @@ -377,7 +366,6 @@ BMP_PTR SPRITE::Shp(void) { if (e) if (e->Seq) { int i = e->Seq[SeqPtr].Now; -#ifdef DEBUG if (i >= ShpCnt) { //char s[256]; //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", @@ -385,7 +373,6 @@ BMP_PTR SPRITE::Shp(void) { //VGA::Exit(s, File); error("Invalid PHASE in SPRITE::Shp() %s", File); } -#endif return e->ShpList[i]; } return NULL; @@ -509,7 +496,7 @@ SPRITE *SPRITE::Expand(void) { MergeExt(fname, File, SPR_EXT); if (INI_FILE::Exist(fname)) { // sprite description file exist INI_FILE sprf(fname); - if (! OK(sprf)) + if (! (sprf.Error==0)) error("Bad SPR [%s]", fname); int len = 0, lcnt = 0; while ((len = sprf.Read((uint8 *)line)) != 0) { @@ -936,14 +923,12 @@ VGA::VGA(int mode) if (txt) { // puts(txt); warning(txt); -#ifndef DEBUG std = false; -#endif } } -// if (std) + if (std) // warning(Copr); - warning("TODO: Fix Copr"); + warning("TODO: Fix Copr"); SetStatAdr(); if (StatAdr != VGAST1_) -- cgit v1.2.3 From 3871c71f0e6f5202e935ac7119fefedde1f8e449 Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Sun, 19 Jun 2011 07:59:37 +0200 Subject: CGE: Fix compilation under GCC Unfortunately, I had to stub a few things but this all looks like code that will have to be rewritten later anyway. --- engines/cge/vga13h.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index c1587fa45a..a7dd76273d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -30,13 +30,10 @@ #include "cge/bitmap.h" #include "cge/vol.h" #include "cge/text.h" -#include #include #include #include -#include #include -#include namespace CGE { -- cgit v1.2.3 From 78e3f2a57bc0442066e00c9b625bbdde3c80ddf9 Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Sun, 19 Jun 2011 11:17:54 +0200 Subject: CGE: Get rid of some static initializing ScummVM itself (not the engine; I haven't tried that) now starts without crashing. It exits immediately, but as far as I can tell it does not crash. It still produces lots of Valgrind warnings, though... --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index a7dd76273d..52015c27f1 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -916,7 +916,7 @@ VGA::VGA(int mode) bool std = true; int i; for (i = 10; i < 20; i ++) { - char *txt = Text[i]; + char *txt = Text->getText(i); if (txt) { // puts(txt); warning(txt); -- cgit v1.2.3 From 40f95669aeb60a50c2736d71008f0e3461654f4f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 20 Jun 2011 00:13:41 +0200 Subject: CGE: As there's only one instance of VGA, suppress all the static keywords from it --- engines/cge/vga13h.cpp | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 52015c27f1..54b34105d8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -30,6 +30,7 @@ #include "cge/bitmap.h" #include "cge/vol.h" #include "cge/text.h" +#include "cge/cge_main.h" #include #include #include @@ -213,8 +214,8 @@ RGB MkRGB(uint8 r, uint8 g, uint8 b) { SPRITE *Locate(int ref) { - SPRITE *spr = VGA::ShowQ.Locate(ref); - return (spr) ? spr : VGA::SpareQ.Locate(ref); + SPRITE *spr = Vga->ShowQ->Locate(ref); + return (spr) ? spr : Vga->SpareQ->Locate(ref); } @@ -774,7 +775,7 @@ BMP_PTR SPRITE::Ghost(void) { SPRITE *SpriteAt(int x, int y) { - SPRITE *spr = NULL, * tail = VGA::ShowQ.Last(); + SPRITE *spr = NULL, * tail = Vga->ShowQ->Last(); if (tail) { for (spr = tail->Prev; spr; spr = spr->Prev) if (! spr->Flags.Hide && ! spr->Flags.Tran) @@ -888,17 +889,6 @@ SPRITE *QUEUE::Locate(int ref) { } -uint16 VGA::StatAdr = VGAST1_; -uint16 VGA::OldMode = 0; -uint16 *VGA::OldScreen = NULL; -const char *VGA::Msg = NULL; -const char *VGA::Nam = NULL; -DAC *VGA::OldColors = NULL; -DAC *VGA::NewColors = NULL; -bool VGA::SetPal = false; -int VGA::Mono = 0; -QUEUE VGA::ShowQ = true, VGA::SpareQ = false; - // TODO: Was direct mapping to VGA buffers.. need to create scummvm surfaces for that uint8 *VGA::Page[4] = { 0, 0, 0, 0 }; @@ -912,7 +902,13 @@ uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), //extern const char Copr[]; VGA::VGA(int mode) - : FrmCnt(0) { + : FrmCnt(0), OldMode(0), OldScreen(NULL), StatAdr(VGAST1_), + Msg(NULL), Nam(NULL), SetPal(false), Mono(0) { + OldColors = NULL; + NewColors = NULL; + ShowQ = new QUEUE(true); + SpareQ = new QUEUE(false); + bool std = true; int i; for (i = 10; i < 20; i ++) { @@ -939,7 +935,7 @@ VGA::VGA(int mode) OldMode = SetMode(mode); SetColors(); Setup(VideoMode); - Clear(); + Clear(0); } } @@ -948,7 +944,7 @@ VGA::~VGA(void) { Mono = 0; if (IsVga()) { Common::String buffer = ""; - Clear(); + Clear(0); SetMode(OldMode); SetColors(); RestoreScreen(OldScreen); @@ -1154,7 +1150,7 @@ void VGA::SetColors(void) { void VGA::Sunrise(DAC *tab) { for (int i = 0; i <= 64; i += FADE_STEP) { SetColors(tab, i); - WaitVR(); + WaitVR(true); UpdateColors(); } } @@ -1165,19 +1161,19 @@ void VGA::Sunset(void) { GetColors(tab); for (int i = 64; i >= 0; i -= FADE_STEP) { SetColors(tab, i); - WaitVR(); + WaitVR(true); UpdateColors(); } } void VGA::Show(void) { - SPRITE *spr = ShowQ.First(); + SPRITE *spr = ShowQ->First(); - for (spr = ShowQ.First(); spr; spr = spr->Next) + for (spr = ShowQ->First(); spr; spr = spr->Next) spr->Show(); Update(); - for (spr = ShowQ.First(); spr; spr = spr->Next) + for (spr = ShowQ->First(); spr; spr = spr->Next) spr->Hide(); ++ FrmCnt; @@ -1228,7 +1224,8 @@ void VGA::Update(void) { asm mov ah,byte ptr p+1 asm out dx,ax */ - if (! SpeedTest) WaitVR(); + if (! SpeedTest) + WaitVR(true); if (SetPal) { UpdateColors(); -- cgit v1.2.3 From 77d4dcade26a69a6e2ebcc69a4224059c450f3e4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 20 Jun 2011 00:55:47 +0200 Subject: CGE: Remove static parts of HEART --- engines/cge/vga13h.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 54b34105d8..a8a0c5faf0 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -219,12 +219,10 @@ SPRITE *Locate(int ref) { } -bool HEART::Enable = false; -uint16 *HEART::XTimer = NULL; - - HEART::HEART(void) : ENGINE(TMR_DIV) { + Enable = false; + XTimer = NULL; } @@ -235,11 +233,11 @@ extern "C" void TimerProc (void) static uint8 run = 0; // decrement external timer uint16 - if (HEART::XTimer) - if (*HEART::XTimer) -- *HEART::XTimer; - else HEART::XTimer = NULL; + if (Heart->XTimer) + if (*Heart->XTimer) -- *Heart->XTimer; + else Heart->XTimer = NULL; - if (! run && HEART::Enable) // check overrun flag + if (! run && Heart->Enable) // check overrun flag { static uint16 oldSP, oldSS; @@ -299,11 +297,11 @@ void ENGINE::NewTimer(...) { my_int: //------72Hz-------// // decrement external timer uint16 - if (HEART::XTimer) - if (*HEART::XTimer) -- *HEART::XTimer; - else HEART::XTimer = NULL; + if (Heart->XTimer) + if (*Heart->XTimer) -- *Heart->XTimer; + else Heart->XTimer = NULL; - if (! run && HEART::Enable) // check overrun flag + if (! run && Heart->Enable) // check overrun flag { static uint16 oldSP, oldSS; @@ -473,8 +471,8 @@ void SPRITE::SetName(char *n) { SPRITE *SPRITE::Expand(void) { if (! Ext) { - bool enbl = HEART::Enable; - HEART::Enable = false; + bool enbl = Heart->Enable; + Heart->Enable = false; if ((Ext = new SPREXT) == NULL) error("No core"); if (*File) { @@ -596,7 +594,7 @@ SPRITE *SPRITE::Expand(void) { else TakePtr = NO_PTR; } - HEART::Enable = enbl; + Heart->Enable = enbl; } return this; } -- cgit v1.2.3 From 6dc29e4a0489a62498653a880f38369ce05d41f8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 20 Jun 2011 23:40:22 +0200 Subject: CGE: Remove some statics --- engines/cge/vga13h.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index a8a0c5faf0..349f412ca0 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -69,7 +69,6 @@ static VgaRegBlk VideoMode[] = { bool SpeedTest = false; SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; -SPRITE *Sys = NULL; extern "C" void SNDMIDIPlay(void); -- cgit v1.2.3 From a06a75b9a41fb3ef9da2c7420ee9dee257c89cca Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 26 Jun 2011 12:07:42 +0200 Subject: CGE: Implement ForceExt and RCrypt. Little style cleanup. --- engines/cge/vga13h.cpp | 54 +++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 349f412ca0..d7c6946e87 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -233,14 +233,16 @@ extern "C" void TimerProc (void) // decrement external timer uint16 if (Heart->XTimer) - if (*Heart->XTimer) -- *Heart->XTimer; - else Heart->XTimer = NULL; + if (*Heart->XTimer) + *Heart->XTimer--; + else + Heart->XTimer = NULL; if (! run && Heart->Enable) // check overrun flag { static uint16 oldSP, oldSS; - ++ run; // disable 2nd call until current lasts + run++; // disable 2nd call until current lasts asm mov ax,ds asm mov oldSS,ss asm mov oldSP,sp @@ -256,7 +258,7 @@ extern "C" void TimerProc (void) } asm mov ss,oldSS asm mov sp,oldSP - -- run; + run--; } } */ @@ -297,14 +299,16 @@ void ENGINE::NewTimer(...) { // decrement external timer uint16 if (Heart->XTimer) - if (*Heart->XTimer) -- *Heart->XTimer; - else Heart->XTimer = NULL; + if (*Heart->XTimer) + *Heart->XTimer--; + else + Heart->XTimer = NULL; if (! run && Heart->Enable) // check overrun flag { static uint16 oldSP, oldSS; - ++ run; // disable 2nd call until current lasts + run++; // disable 2nd call until current lasts asm mov ax,ds asm mov oldSS,ss asm mov oldSP,sp @@ -320,7 +324,7 @@ void ENGINE::NewTimer(...) { } asm mov ss,oldSS asm mov sp,oldSP - -- run; + run--; } */ @@ -402,7 +406,7 @@ BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) { void SPRITE::MoveShapes(uint8 *buf) { BMP_PTR *p; - for (p = Ext->ShpList; *p; p ++) { + for (p = Ext->ShpList; *p; p++) { buf += (*p)->MoveVmap(buf); } } @@ -507,14 +511,14 @@ SPRITE *SPRITE::Expand(void) { break; } case 1 : { // Phase - shplist[shpcnt ++] = new BITMAP(strtok(NULL, " \t,;/")); + shplist[shpcnt++] = new BITMAP(strtok(NULL, " \t,;/")); break; } case 2 : { // Seq seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); if (seq == NULL) error("No core [%s]", fname); - SEQ *s = &seq[seqcnt ++]; + SEQ *s = &seq[seqcnt++]; s->Now = atoi(strtok(NULL, " \t,;/")); if (s->Now > maxnow) maxnow = s->Now; @@ -540,7 +544,7 @@ SPRITE *SPRITE::Expand(void) { if (nea == NULL) error("No core [%s]", fname); else { - SNAIL::COM *c = &nea[neacnt ++]; + SNAIL::COM *c = &nea[neacnt++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); c->Ref = atoi(strtok(NULL, " \t,;/")); @@ -556,7 +560,7 @@ SPRITE *SPRITE::Expand(void) { if (tak == NULL) error("No core [%s]", fname); else { - SNAIL::COM *c = &tak[takcnt ++]; + SNAIL::COM *c = &tak[takcnt++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); c->Ref = atoi(strtok(NULL, " \t,;/")); @@ -569,7 +573,7 @@ SPRITE *SPRITE::Expand(void) { } } } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt ++] = new BITMAP(File); + shplist[shpcnt++] = new BITMAP(File); } shplist[shpcnt] = NULL; if (seq) { @@ -606,7 +610,7 @@ SPRITE *SPRITE::Contract(void) { delete[] e->Name; if (Flags.BDel && e->ShpList) { int i; - for (i = 0; e->ShpList[i]; i ++) + for (i = 0; e->ShpList[i]; i++) delete e->ShpList[i]; if (MemType(e->ShpList) == NEAR_MEM) delete[] e->ShpList; @@ -662,7 +666,7 @@ void SPRITE::MakeXlat(uint8 *x) { if (Flags.Xlat) KillXlat(); - for (b = Ext->ShpList; *b; b ++) + for (b = Ext->ShpList; *b; b++) (*b)->M = x; Flags.Xlat = true; } @@ -682,7 +686,7 @@ void SPRITE::KillXlat(void) { free(m); break; } - for (b = Ext->ShpList; *b; b ++) + for (b = Ext->ShpList; *b; b++) (*b)->M = NULL; Flags.Xlat = false; } @@ -908,7 +912,7 @@ VGA::VGA(int mode) bool std = true; int i; - for (i = 10; i < 20; i ++) { + for (i = 10; i < 20; i++) { char *txt = Text->getText(i); if (txt) { // puts(txt); @@ -1293,9 +1297,9 @@ void BITMAP::XShow(int x, int y) { /* uint8 rmsk = x % 4, mask = 1 << rmsk, - * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - uint8 * m = (char *) M; - uint8 * v = V; + *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + uint8 *m = (char *) M; + uint8 *v = V; asm push bx asm push si @@ -1374,8 +1378,8 @@ void BITMAP::XShow(int x, int y) { void BITMAP::Show(int x, int y) { /* uint8 mask = 1 << (x & 3), - * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); - uint8 * v = V; + *scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); + uint8 *v = V; asm push ds // preserve DS @@ -1443,9 +1447,9 @@ void BITMAP::Show(int x, int y) { void BITMAP::Hide(int x, int y) { /* - uint8 * scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; + uint8 *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); - HideDesc * b = B; + HideDesc *b = B; uint16 extra = ((x & 3) != 0); uint16 h = H; -- cgit v1.2.3 From 083d6ff6122cb2faf0a4330eb480bb9f77afa255 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Jun 2011 01:03:47 +0200 Subject: CGE: remove some if(n)def DEMO by using a new flag. Added CGEEngine in several classes in order to do so. --- engines/cge/vga13h.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d7c6946e87..1038cd2631 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -35,6 +35,7 @@ #include #include #include +#include "cge/cge.h" namespace CGE { @@ -345,10 +346,10 @@ void HEART::SetXTimer(uint16 *ptr, uint16 time) { } -SPRITE::SPRITE(BMP_PTR *shp) +SPRITE::SPRITE(CGEEngine *vm, BMP_PTR *shp) : X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), - Ext(NULL), Ref(-1), Cave(0) { + Ext(NULL), Ref(-1), Cave(0), _vm(vm) { memset(File, 0, sizeof(File)); *((uint16 *)&Flags) = 0; SetShapeList(shp); -- cgit v1.2.3 From e13317baeab99f4868d49a89e110deda1d5ca5f4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 27 Jun 2011 18:57:58 +1000 Subject: CGE: Beginnings of work on graphics support --- engines/cge/vga13h.cpp | 395 ++++++++++++++++--------------------------------- 1 file changed, 128 insertions(+), 267 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 349f412ca0..f5fde14122 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -25,6 +25,8 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ +#include "common/rect.h" +#include "graphics/palette.h" #include "cge/general.h" #include "cge/vga13h.h" #include "cge/bitmap.h" @@ -737,7 +739,7 @@ void SPRITE::Show(void) { void SPRITE::Show(uint16 pg) { - uint8 *a = VGA::Page[1]; + Graphics::Surface *a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; Shp()->Show(X, Y); VGA::Page[1] = a; @@ -886,17 +888,25 @@ SPRITE *QUEUE::Locate(int ref) { } -// TODO: Was direct mapping to VGA buffers.. need to create scummvm surfaces for that -uint8 *VGA::Page[4] = { 0, 0, 0, 0 }; +//extern const char Copr[]; +Graphics::Surface *VGA::Page[4]; +DAC *VGA::SysPal; -/* -uint8 * VGA::Page[4] = { (uint8 *) MK_FP(SCR_SEG, 0x0000), - (uint8 *) MK_FP(SCR_SEG, 0x4000), - (uint8 *) MK_FP(SCR_SEG, 0x8000), - (uint8 *) MK_FP(SCR_SEG, 0xC000) }; -*/ +void VGA::init() { + for (int idx = 0; idx < 4; ++idx) { + Page[idx] = new Graphics::Surface(); + Page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); + } -//extern const char Copr[]; + SysPal = new DAC[PAL_CNT]; +} + +void VGA::deinit() { + for (int idx = 0; idx < 4; ++idx) { + delete Page[idx]; + } + delete[] SysPal; +} VGA::VGA(int mode) : FrmCnt(0), OldMode(0), OldScreen(NULL), StatAdr(VGAST1_), @@ -977,21 +987,9 @@ void VGA::SetStatAdr(void) { #pragma argsused void VGA::WaitVR(bool on) { - /* - _DX = StatAdr; - _AH = (on) ? 0x00 : 0x08; - - asm mov cx,2 - // wait for vertical retrace on (off) - wait: - asm in al,dx - asm xor al,ah - asm test al,0x08 - asm jnz wait - asm xor ah,0x08 - asm loop wait - */ - warning("STUB: VGA::WaitVR"); + // Since some of the game parts rely on using vertical sync as a delay mechanism, + // we're introducing a short delay to simulate it + g_system->delayMillis(10); } @@ -1039,102 +1037,54 @@ void VGA::Setup(VgaRegBlk *vrb) { int VGA::SetMode(int mode) { - /* - Clear(); - // get current mode - asm mov ah,0x0F - Video(); // BIOS video service - asm xor ah,ah - asm push ax - - // wait for v-retrace - WaitVR(); - - // set mode - asm xor ah,ah - asm mov al,byte ptr mode - Video(); // BIOS video service - SetStatAdr(); - // return previous mode - asm pop ax - return _AX; - */ - warning("STUB: VGA::SetMode"); + // ScummVM provides it's own vieo services return 0; } void VGA::GetColors(DAC *tab) { - /* - asm cld - asm les di,tab // color table - asm mov dx,0x3C7 // PEL address read mode register - asm xor al,al // start from address 0 - asm out dx,al // put address - asm mov cx,256*3 // # of colors - asm mov dl,0xC9 // PEL data register - - // asm rep insb // very fast! - - gc: // much slower: - asm in al,dx // take 1 color - asm jmp sto // little delay - sto: - asm stosb // store 1 color - asm loop gc // next one? - */ - warning("STUB: VGA::GetColors"); + byte palData[PAL_SIZ]; + g_system->getPaletteManager()->grabPalette(palData, 0, PAL_CNT); + pal2DAC(palData, tab); } +void VGA::pal2DAC(const byte *palData, DAC *tab) { + const byte *colP = palData; + for (int idx = 0; idx < PAL_CNT; ++idx, colP += 3) { + tab[idx].R = *colP; + tab[idx].G = *(colP + 1); + tab[idx].B = *(colP + 2); + } +} + +void VGA::DAC2pal(const DAC *tab, byte *palData) { + for (int idx = 0; idx < PAL_CNT; ++idx, palData += 3) { + *palData = tab[idx].R; + *(palData + 1) = tab[idx].G; + *(palData + 2) = tab[idx].B; + } +} void VGA::SetColors(DAC *tab, int lum) { - /* - DAC * des = NewColors; - asm push ds - - asm les di,des - asm lds si,tab - asm mov cx,256*3 - asm xor bx,bx - asm mov dx,lum - - copcol: - asm mov al,[si+bx] - asm mul dl - asm shr ax,6 - asm mov es:[di+bx],al - asm inc bx - asm cmp bx,cx - asm jb copcol - - asm pop ds - - if (Mono) - { - asm add cx,di - mono: - asm xor dx,dx - asm mov al,77 // 30% R - asm mul byte ptr es:[di].0 - asm add dx,ax - asm mov al,151 // 59% G - asm mul byte ptr es:[di].1 - asm add dx,ax - asm mov al,28 // 11% B - asm mul byte ptr es:[di].2 - asm add dx,ax - - asm mov es:[di].0,dh - asm mov es:[di].1,dh - asm mov es:[di].2,dh - - asm add di,3 - asm cmp di,cx - asm jb mono - } - */ + DAC *palP = tab; + for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { + palP->R = (palP->R * lum) >> 6; + palP->G = (palP->G * lum) >> 6; + palP->B = (palP->B * lum) >> 6; + } + + if (Mono) { + palP = tab; + for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { + // Form a greyscalce colour from 30% R, 59% G, 11% B + uint8 intensity = (palP->R * 77) + (palP->G * 151) + (palP->B * 28); + palP->R = intensity; + palP->G = intensity; + palP->B = intensity; + } + } + SetPal = true; - warning("STUB: VGA::SetColors"); } @@ -1178,113 +1128,33 @@ void VGA::Show(void) { void VGA::UpdateColors(void) { - /* - DAC * tab = NewColors; - - asm push ds - asm cld - asm lds si,tab // color table - asm mov dx,0x3C8 // PEL address write mode register - asm xor al,al // start from address 0 - asm out dx,al // put address - asm mov cx,256*3 // # of colors - asm mov dl,0xC9 // PEL data register - - // asm rep outsb // very fast! - - // the slower version of above: - sc: - asm lodsb // take 1/3 color - asm out dx,al // put 1/3 color - asm jmp loop // little delay - loop: - asm loop sc // next one? - - - asm pop ds - */ - warning("STUB: VGA::UpdateColors"); + byte palData[PAL_SIZ]; + DAC2pal(NewColors, palData); + g_system->getPaletteManager()->setPalette(palData, 0, 256); } void VGA::Update(void) { - /* - uint8 * p = Page[1]; - Page[1] = Page[0]; - Page[0] = p; - - asm mov dx,VGACRT_ - asm mov al,0x0D - asm mov ah,byte ptr p - asm out dx,ax - asm dec al - asm mov ah,byte ptr p+1 - asm out dx,ax - */ - if (! SpeedTest) - WaitVR(true); + SWAP(VGA::Page[0], VGA::Page[1]); if (SetPal) { UpdateColors(); SetPal = false; } - warning("STUB: VGA::Update"); + + g_system->copyRectToScreen((const byte *)VGA::Page[0]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); + g_system->updateScreen(); } void VGA::Clear(uint8 color) { - /* - uint8 * a = (uint8 *) MK_FP(SCR_SEG, 0); - - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // map mask register - enable all planes - asm out dx,ax - asm les di,a - asm cld - - asm mov cx,0xFFFF - asm mov al,color - asm rep stosb - asm stosb - */ - warning("STUB: VGA::Clear"); + for (int paneNum = 0; paneNum < 4; ++paneNum) + Page[paneNum]->fillRect(Common::Rect(0, 0, SCR_WID, SCR_HIG), color); } void VGA::CopyPage(uint16 d, uint16 s) { - /* - uint8 * S = Page[s & 3], * D = Page[d & 3]; - - asm mov dx,VGAGRA_ - asm mov al,0x05 // R/W mode - asm out dx,al - asm inc dx - asm in al,dx - asm and al,0xF4 - asm push ax - asm push dx - asm or al,0x01 - asm out dx,al - - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // map mask register - enable all planes - asm out dx,ax - - asm push ds - - asm les di,D - asm lds si,S - asm cld - asm mov cx,0x4000 - asm rep movsb - - asm pop ds - - asm pop dx - asm pop ax - asm out dx,al // end of copy mode - */ - warning("STUB: VGA::CopyPage"); + Page[d]->copyFrom(*Page[s]); } //-------------------------------------------------------------------------- @@ -1372,72 +1242,63 @@ void BITMAP::XShow(int x, int y) { void BITMAP::Show(int x, int y) { - /* - uint8 mask = 1 << (x & 3), - * scr = VGA::Page[1] + y * (SCR_WID >> 2) + (x >> 2); - uint8 * v = V; - - asm push ds // preserve DS - - asm cld // normal direction - asm les di,scr // screen address - asm lds si,v // picture address - asm mov dx,VGASEQ_ // VGA reg - asm mov al,0x02 - asm mov ah,mask - - plane: - asm out dx,ax - asm push ax - asm push di - - block: - asm mov cx,[si] // with ADD faster then LODSW - asm add si,2 - asm test ch,0xC0 - asm jns skip // 1 (SKP) or 0 (EOI) - asm jpo repeat // 2 (REP) - - copy: // 3 (CPY) - asm and ch,0x3F - asm shr cx,1 - asm rep movsw - asm jnc block - asm movsb - asm jmp block - - repeat: - asm and ch,0x3F - asm mov al,[si] - asm inc si - asm mov ah,al - asm shr cx,1 - asm rep stosw - asm jnc block - asm mov es:[di],al - asm inc di - asm jmp block - - skip: - asm jz endpl - asm and ch,0x3F - asm add di,cx - asm jmp block - - endpl: - asm pop di - asm pop ax - asm shl ah,1 - asm test ah,0x10 - asm jz x_chk - asm mov ah,0x01 - asm inc di - x_chk: - asm cmp ah,mask - asm jne plane - asm pop ds - */ - warning("STUB: BITMAP::Show"); + const byte *srcP = (const byte *)V; + byte *destP = (byte *)VGA::Page[1]->getBasePtr(x, y); + + int yc = 0, xc = 0; + + for (;;) { + uint16 v = READ_LE_UINT16(srcP); + srcP += 2; + int cmd = v >> 14; + int count = v & 0x3FFF; + + if (cmd == 0) + // End of image + break; + + // Handle a set of pixels + while (count-- > 0) { + // Transfer operation + switch (cmd) { + case 1: + // SKIP + break; + case 2: + // REPEAT + *destP = *srcP; + break; + case 3: + // COPY + *destP = *srcP++; + break; + } + + // Move to next dest position + ++destP; + ++xc; + if (xc == W) { + xc = 0; + ++yc; + if (yc == H) + return; + + destP = (byte *)VGA::Page[1]->getBasePtr(x, y + yc); + } + } + + if (cmd == 2) + ++srcP; + } + + // Temporary + g_system->copyRectToScreen((const byte *)VGA::Page[1]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); + byte palData[PAL_SIZ]; + VGA::DAC2pal(VGA::SysPal, palData); + g_system->getPaletteManager()->setPalette(palData, 0, PAL_CNT); + + g_system->updateScreen(); + g_system->delayMillis(5000); } -- cgit v1.2.3 From 571c3fc666ce95ce880e7a428585ea99c7c66fd2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 27 Jun 2011 21:29:18 +1000 Subject: CGE: Getting closer to properly showing bitmap images --- engines/cge/vga13h.cpp | 94 ++++++++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 42 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 1804d25aa9..32e0fd6090 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1064,9 +1064,9 @@ void VGA::pal2DAC(const byte *palData, DAC *tab) { void VGA::DAC2pal(const DAC *tab, byte *palData) { for (int idx = 0; idx < PAL_CNT; ++idx, palData += 3) { - *palData = tab[idx].R; - *(palData + 1) = tab[idx].G; - *(palData + 2) = tab[idx].B; + *palData = tab[idx].R << 2; + *(palData + 1) = tab[idx].G << 2; + *(palData + 2) = tab[idx].B << 2; } } @@ -1247,53 +1247,63 @@ void BITMAP::XShow(int x, int y) { void BITMAP::Show(int x, int y) { - const byte *srcP = (const byte *)V; - byte *destP = (byte *)VGA::Page[1]->getBasePtr(x, y); - - int yc = 0, xc = 0; - - for (;;) { - uint16 v = READ_LE_UINT16(srcP); - srcP += 2; - int cmd = v >> 14; - int count = v & 0x3FFF; - - if (cmd == 0) - // End of image - break; + // Create a temporary surface to hold the unpacked bitmap data + Graphics::Surface rawSurface; + rawSurface.create(W, H, Graphics::PixelFormat::createFormatCLUT8()); - // Handle a set of pixels - while (count-- > 0) { - // Transfer operation - switch (cmd) { - case 1: - // SKIP - break; - case 2: - // REPEAT - *destP = *srcP; - break; - case 3: - // COPY - *destP = *srcP++; + const byte *srcP = (const byte *)V; + byte *destP = (byte *)rawSurface.pixels; + byte *destEndP = destP + (W * H); + Common::set_to(destP, destEndP, 0); + + // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a + // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data + // must be decompressed and inserted into the surface + for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { + destP = (byte *)rawSurface.getBasePtr(planeCtr, 0); + + while (destP < destEndP) { + uint16 v = READ_LE_UINT16(srcP); + srcP += 2; + int cmd = v >> 14; + int count = v & 0x3FFF; + + if (cmd == 0) { + // End of image break; } - // Move to next dest position - ++destP; - ++xc; - if (xc == W) { - xc = 0; - ++yc; - if (yc == H) - return; + // Handle a set of pixels + while (count-- > 0) { + // Transfer operation + switch (cmd) { + case 1: + // SKIP + break; + case 2: + // REPEAT + *destP = *srcP; + break; + case 3: + // COPY + *destP = *srcP++; + break; + } - destP = (byte *)VGA::Page[1]->getBasePtr(x, y + yc); + // Move to next dest position + destP += 4; } + + if (cmd == 2) + ++srcP; } + } - if (cmd == 2) - ++srcP; + // Copy the decompressed buffer to the specified x/y position on Page #1 + for (int yc = 0; yc < rawSurface.h; ++yc) { + srcP = (const byte *)rawSurface.getBasePtr(0, yc); + destP = (byte *)VGA::Page[1]->getBasePtr(x, y + yc); + Common::copy(srcP, srcP + rawSurface.w, destP); } // Temporary -- cgit v1.2.3 From 2fe6061d919a84e1f2849415902b3e91403bf69d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 28 Jun 2011 21:58:03 +1000 Subject: CGE: Bitmap now shows correctly --- engines/cge/vga13h.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 32e0fd6090..21aec31e5d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1261,8 +1261,8 @@ void BITMAP::Show(int x, int y) { // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { destP = (byte *)rawSurface.getBasePtr(planeCtr, 0); - - while (destP < destEndP) { + + for (;;) { uint16 v = READ_LE_UINT16(srcP); srcP += 2; int cmd = v >> 14; @@ -1273,6 +1273,8 @@ void BITMAP::Show(int x, int y) { break; } + assert(destP < destEndP); + // Handle a set of pixels while (count-- > 0) { // Transfer operation -- cgit v1.2.3 From 04a123a4efc0ae4a76fa4ca20d8ffd692d7359ab Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 28 Jun 2011 22:36:43 +1000 Subject: CGE: Fix for displaying non full-screen bitmaps --- engines/cge/vga13h.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 21aec31e5d..b59f8e8de5 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1247,20 +1247,14 @@ void BITMAP::XShow(int x, int y) { void BITMAP::Show(int x, int y) { - // Create a temporary surface to hold the unpacked bitmap data - Graphics::Surface rawSurface; - rawSurface.create(W, H, Graphics::PixelFormat::createFormatCLUT8()); - const byte *srcP = (const byte *)V; - byte *destP = (byte *)rawSurface.pixels; - byte *destEndP = destP + (W * H); - Common::set_to(destP, destEndP, 0); + byte *destEndP = (byte *)VGA::Page[1]->pixels + (SCR_WID * SCR_HIG); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { - destP = (byte *)rawSurface.getBasePtr(planeCtr, 0); + byte *destP = (byte *)VGA::Page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -1301,13 +1295,6 @@ void BITMAP::Show(int x, int y) { } } - // Copy the decompressed buffer to the specified x/y position on Page #1 - for (int yc = 0; yc < rawSurface.h; ++yc) { - srcP = (const byte *)rawSurface.getBasePtr(0, yc); - destP = (byte *)VGA::Page[1]->getBasePtr(x, y + yc); - Common::copy(srcP, srcP + rawSurface.w, destP); - } - // Temporary g_system->copyRectToScreen((const byte *)VGA::Page[1]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); byte palData[PAL_SIZ]; -- cgit v1.2.3 From 290305ad4320a489d6dc98279433e0d3b3a7de40 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Jun 2011 00:35:21 +0200 Subject: CGE: Cleanup : Start renaming. Add BMPLoad() function --- engines/cge/vga13h.cpp | 382 ++++++++++++++++++++++++++----------------------- 1 file changed, 199 insertions(+), 183 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index b59f8e8de5..1d55af7e31 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -51,7 +51,6 @@ static char Report[] = "NearHeap=..... FarHeap=......\n"; #define FREP 24 static VgaRegBlk VideoMode[] = { - { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 @@ -69,9 +68,9 @@ static VgaRegBlk VideoMode[] = { }; -bool SpeedTest = false; -SEQ Seq1[] = { { 0, 0, 0, 0, 0 } }; -SEQ Seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; +bool SpeedTest = false; +Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; +Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; extern "C" void SNDMIDIPlay(void); @@ -83,8 +82,7 @@ char *NumStr(char *str, int num) { } -static void Video(void) -{ +static void Video() { /* static uint16 SP_S; @@ -206,7 +204,7 @@ DAC MkDAC(uint8 r, uint8 g, uint8 b) { } -RGB MkRGB(uint8 r, uint8 g, uint8 b) { +Rgb MkRGB(uint8 r, uint8 g, uint8 b) { static TRGB x; x.dac.R = r; x.dac.G = g; @@ -215,54 +213,60 @@ RGB MkRGB(uint8 r, uint8 g, uint8 b) { } -SPRITE *Locate(int ref) { - SPRITE *spr = Vga->ShowQ->Locate(ref); +Sprite *Locate(int ref) { + Sprite *spr = Vga->ShowQ->Locate(ref); return (spr) ? spr : Vga->SpareQ->Locate(ref); } -HEART::HEART(void) +Heart::Heart(void) : ENGINE(TMR_DIV) { - Enable = false; - XTimer = NULL; + _enable = false; + _xTimer = NULL; } /* -extern "C" void TimerProc (void) -{ - static SPRITE * spr; - static uint8 run = 0; - - // decrement external timer uint16 - if (Heart->XTimer) - if (*Heart->XTimer) - *Heart->XTimer--; - else - Heart->XTimer = NULL; - - if (! run && Heart->Enable) // check overrun flag - { - static uint16 oldSP, oldSS; - - run++; // disable 2nd call until current lasts - asm mov ax,ds - asm mov oldSS,ss - asm mov oldSP,sp - asm mov ss,ax - asm mov sp,0xFF80 - - // system pseudo-sprite - if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); - - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) - { - if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); - } - asm mov ss,oldSS - asm mov sp,oldSP - run--; - } +extern "C" void TimerProc() { + static SPRITE * spr; + static uint8 run = 0; + + // decrement external timer uint16 + if (_heart->_xTimer) { + if (*_heart->_xTimer) + *_heart->_xTimer--; + else + _heart->_xTimer = NULL; + } + + if (!run && _heart->_enable) { // check overrun flag + static uint16 oldSP, oldSS; + run++; // disable 2nd call until current lasts + asm mov ax,ds + asm mov oldSS,ss + asm mov oldSP,sp + asm mov ss,ax + asm mov sp,0xFF80 + + // system pseudo-sprite + if (Sys) { + if (Sys->Time) { + if (--Sys->Time == 0) + Sys->Tick(); + } + } + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { + if (spr->Time) { + if (!spr->Flags.Hide) { + if (-- spr->Time == 0) + spr->Tick(); + } + } + } + asm mov ss,oldSS + asm mov sp,oldSP + run--; + } } */ @@ -301,17 +305,17 @@ void ENGINE::NewTimer(...) { my_int: //------72Hz-------// // decrement external timer uint16 - if (Heart->XTimer) - if (*Heart->XTimer) - *Heart->XTimer--; + if (_heart->XTimer) { + if (*_heart->XTimer) + *_heart->XTimer--; else - Heart->XTimer = NULL; + _heart->XTimer = NULL; + } - if (! run && Heart->Enable) // check overrun flag - { + if (! run && _heart->Enable) { // check overrun flag static uint16 oldSP, oldSS; - run++; // disable 2nd call until current lasts + run++; // disable 2nd call until current lasts asm mov ax,ds asm mov oldSS,ss asm mov oldSP,sp @@ -319,12 +323,21 @@ void ENGINE::NewTimer(...) { asm mov sp,0xFF80 // system pseudo-sprite - if (Sys) if (Sys->Time) if (-- Sys->Time == 0) Sys->Tick(); + if (Sys) { + if (Sys->Time) { + if (--Sys->Time == 0) + Sys->Tick(); + } + } - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) - { - if (spr->Time) if (!spr->Flags.Hide) if (-- spr->Time == 0) spr->Tick(); - } + for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { + if (spr->Time) { + if (!spr->Flags.Hide) { + if (--spr->Time == 0) + spr->Tick(); + } + } + } asm mov ss,oldSS asm mov sp,oldSP run--; @@ -335,39 +348,39 @@ void ENGINE::NewTimer(...) { } -void HEART::SetXTimer(uint16 *ptr) { - if (XTimer && ptr != XTimer) - *XTimer = 0; - XTimer = ptr; +void Heart::setXTimer(uint16 *ptr) { + if (_xTimer && ptr != _xTimer) + *_xTimer = 0; + _xTimer = ptr; } -void HEART::SetXTimer(uint16 *ptr, uint16 time) { - SetXTimer(ptr); +void Heart::setXTimer(uint16 *ptr, uint16 time) { + setXTimer(ptr); *ptr = time; } -SPRITE::SPRITE(CGEEngine *vm, BMP_PTR *shp) +Sprite::Sprite(CGEEngine *vm, BMP_PTR *shp) : X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), - Ext(NULL), Ref(-1), Cave(0), _vm(vm) { + _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(File, 0, sizeof(File)); *((uint16 *)&Flags) = 0; SetShapeList(shp); } -SPRITE::~SPRITE(void) { +Sprite::~Sprite() { Contract(); } -BMP_PTR SPRITE::Shp(void) { - register SPREXT *e = Ext; +BMP_PTR Sprite::Shp() { + register SprExt *e = _ext; if (e) - if (e->Seq) { - int i = e->Seq[SeqPtr].Now; + if (e->_seq) { + int i = e->_seq[SeqPtr].Now; if (i >= ShpCnt) { //char s[256]; //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", @@ -375,14 +388,14 @@ BMP_PTR SPRITE::Shp(void) { //VGA::Exit(s, File); error("Invalid PHASE in SPRITE::Shp() %s", File); } - return e->ShpList[i]; + return e->_shpList[i]; } return NULL; } -BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) { - BMP_PTR *r = (Ext) ? Ext->ShpList : NULL; +BMP_PTR *Sprite::SetShapeList(BMP_PTR *shp) { + BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; ShpCnt = 0; W = 0; @@ -399,29 +412,29 @@ BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) { ++ShpCnt; } Expand(); - Ext->ShpList = shp; - if (! Ext->Seq) - SetSeq((ShpCnt < 2) ? Seq1 : Seq2); + _ext->_shpList = shp; + if (!_ext->_seq) + SetSeq((ShpCnt < 2) ? _seq1 : _seq2); } return r; } -void SPRITE::MoveShapes(uint8 *buf) { +void Sprite::MoveShapes(uint8 *buf) { BMP_PTR *p; - for (p = Ext->ShpList; *p; p++) { + for (p = _ext->_shpList; *p; p++) { buf += (*p)->MoveVmap(buf); } } -bool SPRITE::Works(SPRITE *spr) { +bool Sprite::Works(Sprite *spr) { if (spr) - if (spr->Ext) { - SNAIL::COM *c = spr->Ext->Take; + if (spr->_ext) { + SNAIL::COM *c = spr->_ext->_take; if (c != NULL) { c += spr->TakePtr; - if (c->Ref == Ref) + if (c->Ref == _ref) if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) return true; } @@ -430,10 +443,10 @@ bool SPRITE::Works(SPRITE *spr) { } -SEQ *SPRITE::SetSeq(SEQ *seq) { +Seq *Sprite::SetSeq(Seq *seq) { Expand(); - register SEQ *s = Ext->Seq; - Ext->Seq = seq; + register Seq *s = _ext->_seq; + _ext->_seq = seq; if (SeqPtr == NO_SEQ) Step(0); else if (Time == 0) @@ -442,32 +455,32 @@ SEQ *SPRITE::SetSeq(SEQ *seq) { } -bool SPRITE::SeqTest(int n) { +bool Sprite::SeqTest(int n) { if (n >= 0) return (SeqPtr == n); - if (Ext) - return (Ext->Seq[SeqPtr].Next == SeqPtr); + if (_ext) + return (_ext->_seq[SeqPtr].Next == SeqPtr); return true; } -SNAIL::COM *SPRITE::SnList(SNLIST type) { - register SPREXT *e = Ext; +SNAIL::COM *Sprite::SnList(SNLIST type) { + register SprExt *e = _ext; if (e) - return (type == NEAR) ? e->Near : e->Take; + return (type == NEAR) ? e->_near : e->_take; return NULL; } -void SPRITE::SetName(char *n) { - if (Ext) { - if (Ext->Name) { - delete[] Ext->Name; - Ext->Name = NULL; +void Sprite::SetName(char *n) { + if (_ext) { + if (_ext->_name) { + delete[] _ext->_name; + _ext->_name = NULL; } if (n) { - if ((Ext->Name = new char[strlen(n) + 1]) != NULL) - strcpy(Ext->Name, n); + if ((_ext->_name = new char[strlen(n) + 1]) != NULL) + strcpy(_ext->_name, n); else error("No core [%s]", n); } @@ -475,17 +488,17 @@ void SPRITE::SetName(char *n) { } -SPRITE *SPRITE::Expand(void) { - if (! Ext) { - bool enbl = Heart->Enable; - Heart->Enable = false; - if ((Ext = new SPREXT) == NULL) +Sprite *Sprite::Expand(void) { + if (!_ext) { + bool enbl = _heart->_enable; + _heart->_enable = false; + if ((_ext = new SprExt) == NULL) error("No core"); if (*File) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[LINE_MAX], fname[MAXPATH]; BMP_PTR *shplist = new BMP_PTR [ShpCnt + 1]; - SEQ *seq = NULL; + Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, neacnt = 0, @@ -518,10 +531,10 @@ SPRITE *SPRITE::Expand(void) { break; } case 2 : { // Seq - seq = (SEQ *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); + seq = (Seq *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); if (seq == NULL) error("No core [%s]", fname); - SEQ *s = &seq[seqcnt++]; + Seq *s = &seq[seqcnt++]; s->Now = atoi(strtok(NULL, " \t,;/")); if (s->Now > maxnow) maxnow = s->Now; @@ -586,52 +599,52 @@ SPRITE *SPRITE::Expand(void) { error("Bad JUMP in SEQ [%s]", fname); SetSeq(seq); } else - SetSeq((ShpCnt == 1) ? Seq1 : Seq2); + SetSeq((ShpCnt == 1) ? _seq1 : _seq2); //disable(); // disable interupt SetShapeList(shplist); //enable(); // enable interupt if (nea) - nea[neacnt - 1].Ptr = Ext->Near = nea; + nea[neacnt - 1].Ptr = _ext->_near = nea; else NearPtr = NO_PTR; if (tak) - tak[takcnt - 1].Ptr = Ext->Take = tak; + tak[takcnt - 1].Ptr = _ext->_take = tak; else TakePtr = NO_PTR; } - Heart->Enable = enbl; + _heart->_enable = enbl; } return this; } -SPRITE *SPRITE::Contract(void) { - register SPREXT *e = Ext; +Sprite *Sprite::Contract(void) { + register SprExt *e = _ext; if (e) { - if (e->Name) - delete[] e->Name; - if (Flags.BDel && e->ShpList) { + if (e->_name) + delete[] e->_name; + if (Flags.BDel && e->_shpList) { int i; - for (i = 0; e->ShpList[i]; i++) - delete e->ShpList[i]; - if (MemType(e->ShpList) == NEAR_MEM) - delete[] e->ShpList; + for (i = 0; e->_shpList[i]; i++) + delete e->_shpList[i]; + if (MemType(e->_shpList) == NEAR_MEM) + delete[] e->_shpList; } - if (MemType(e->Seq) == NEAR_MEM) - free(e->Seq); - if (e->Near) - free(e->Near); - if (e->Take) - free(e->Take); + if (MemType(e->_seq) == NEAR_MEM) + free(e->_seq); + if (e->_near) + free(e->_near); + if (e->_take) + free(e->_take); delete e; - Ext = NULL; + _ext = NULL; } return this; } -SPRITE *SPRITE::BackShow(bool fast) { +Sprite *Sprite::BackShow(bool fast) { Expand(); Show(2); Show(1); @@ -642,14 +655,14 @@ SPRITE *SPRITE::BackShow(bool fast) { } -void SPRITE::Step(int nr) { +void Sprite::Step(int nr) { if (nr >= 0) SeqPtr = nr; - if (Ext) { - SEQ *seq; + if (_ext) { + Seq *seq; if (nr < 0) - SeqPtr = Ext->Seq[SeqPtr].Next; - seq = Ext->Seq + SeqPtr; + SeqPtr = _ext->_seq[SeqPtr].Next; + seq = _ext->_seq + SeqPtr; if (seq->Dly >= 0) { Goto(X + (seq->Dx), Y + (seq->Dy)); Time = seq->Dly; @@ -658,28 +671,28 @@ void SPRITE::Step(int nr) { } -void SPRITE::Tick(void) { +void Sprite::Tick(void) { Step(); } -void SPRITE::MakeXlat(uint8 *x) { - if (Ext) { +void Sprite::MakeXlat(uint8 *x) { + if (_ext) { BMP_PTR *b; if (Flags.Xlat) KillXlat(); - for (b = Ext->ShpList; *b; b++) + for (b = _ext->_shpList; *b; b++) (*b)->M = x; Flags.Xlat = true; } } -void SPRITE::KillXlat(void) { - if (Flags.Xlat && Ext) { +void Sprite::KillXlat(void) { + if (Flags.Xlat && _ext) { BMP_PTR *b; - uint8 *m = (*Ext->ShpList)->M; + uint8 *m = (*_ext->_shpList)->M; switch (MemType(m)) { case NEAR_MEM : @@ -689,14 +702,14 @@ void SPRITE::KillXlat(void) { free(m); break; } - for (b = Ext->ShpList; *b; b++) + for (b = _ext->_shpList; *b; b++) (*b)->M = NULL; Flags.Xlat = false; } } -void SPRITE::Goto(int x, int y) { +void Sprite::Goto(int x, int y) { int xo = X, yo = Y; if (W < SCR_WID) { if (x < 0) @@ -720,30 +733,32 @@ void SPRITE::Goto(int x, int y) { } -void SPRITE::Center(void) { +void Sprite::Center(void) { Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); } -void SPRITE::Show(void) { - register SPREXT *e; +void Sprite::Show(void) { + register SprExt *e; // asm cli // critic section... - e = Ext; - e->x0 = e->x1; - e->y0 = e->y1; - e->b0 = e->b1; - e->x1 = X; - e->y1 = Y; - e->b1 = Shp(); + e = _ext; + e->_x0 = e->_x1; + e->_y0 = e->_y1; + e->_b0 = e->_b1; + e->_x1 = X; + e->_y1 = Y; + e->_b1 = Shp(); // asm sti // ...done! if (! Flags.Hide) { - if (Flags.Xlat) e->b1->XShow(e->x1, e->y1); - else e->b1->Show(e->x1, e->y1); + if (Flags.Xlat) + e->_b1->XShow(e->_x1, e->_y1); + else + e->_b1->Show(e->_x1, e->_y1); } } -void SPRITE::Show(uint16 pg) { +void Sprite::Show(uint16 pg) { Graphics::Surface *a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; Shp()->Show(X, Y); @@ -751,24 +766,24 @@ void SPRITE::Show(uint16 pg) { } -void SPRITE::Hide(void) { - register SPREXT *e = Ext; - if (e->b0) - e->b0->Hide(e->x0, e->y0); +void Sprite::Hide(void) { + register SprExt *e = _ext; + if (e->_b0) + e->_b0->Hide(e->_x0, e->_y0); } -BMP_PTR SPRITE::Ghost(void) { - register SPREXT *e = Ext; - if (e->b1) { +BMP_PTR Sprite::Ghost(void) { + register SprExt *e = _ext; + if (e->_b1) { BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); if (bmp == NULL) error("No core"); - bmp->W = e->b1->W; - bmp->H = e->b1->H; + bmp->W = e->_b1->W; + bmp->H = e->_b1->H; if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) error("No Core"); - bmp->V = (uint8 *) memcpy(bmp->B, e->b1->B, sizeof(HideDesc) * bmp->H); + bmp->V = (uint8 *) memcpy(bmp->B, e->_b1->B, sizeof(HideDesc) * bmp->H); // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); warning("FIXME: SPRITE::Ghost"); @@ -778,8 +793,8 @@ BMP_PTR SPRITE::Ghost(void) { } -SPRITE *SpriteAt(int x, int y) { - SPRITE *spr = NULL, * tail = Vga->ShowQ->Last(); +Sprite *SpriteAt(int x, int y) { + Sprite *spr = NULL, * tail = Vga->ShowQ->Last(); if (tail) { for (spr = tail->Prev; spr; spr = spr->Prev) if (! spr->Flags.Hide && ! spr->Flags.Tran) @@ -801,24 +816,24 @@ QUEUE::~QUEUE(void) { void QUEUE::Clear(void) { while (Head) { - SPRITE *s = Remove(Head); + Sprite *s = Remove(Head); if (s->Flags.Kill) delete s; } } -void QUEUE::ForAll(void (*fun)(SPRITE *)) { - SPRITE *s = Head; +void QUEUE::ForAll(void (*fun)(Sprite *)) { + Sprite *s = Head; while (s) { - SPRITE *n = s->Next; + Sprite *n = s->Next; fun(s); s = n; } } -void QUEUE::Append(SPRITE *spr) { +void QUEUE::Append(Sprite *spr) { if (Tail) { spr->Prev = Tail; Tail->Next = spr; @@ -832,7 +847,7 @@ void QUEUE::Append(SPRITE *spr) { } -void QUEUE::Insert(SPRITE *spr, SPRITE *nxt) { +void QUEUE::Insert(Sprite *spr, Sprite *nxt) { if (nxt == Head) { spr->Next = Head; Head = spr; @@ -853,8 +868,8 @@ void QUEUE::Insert(SPRITE *spr, SPRITE *nxt) { } -void QUEUE::Insert(SPRITE *spr) { - SPRITE *s; +void QUEUE::Insert(Sprite *spr) { + Sprite *s; for (s = Head; s; s = s->Next) if (s->Z > spr->Z) break; @@ -869,7 +884,7 @@ void QUEUE::Insert(SPRITE *spr) { } -SPRITE *QUEUE::Remove(SPRITE *spr) { +Sprite *QUEUE::Remove(Sprite *spr) { if (spr == Head) Head = spr->Next; if (spr == Tail) @@ -884,11 +899,12 @@ SPRITE *QUEUE::Remove(SPRITE *spr) { } -SPRITE *QUEUE::Locate(int ref) { - SPRITE *spr; - for (spr = Head; spr; spr = spr->Next) - if (spr->Ref == ref) +Sprite *QUEUE::Locate(int ref) { + Sprite *spr; + for (spr = Head; spr; spr = spr->Next) { + if (spr->_ref == ref) return spr; + } return NULL; } @@ -907,9 +923,9 @@ void VGA::init() { } void VGA::deinit() { - for (int idx = 0; idx < 4; ++idx) { + for (int idx = 0; idx < 4; ++idx) delete Page[idx]; - } + delete[] SysPal; } @@ -1120,7 +1136,7 @@ void VGA::Sunset(void) { void VGA::Show(void) { - SPRITE *spr = ShowQ->First(); + Sprite *spr = ShowQ->First(); for (spr = ShowQ->First(); spr; spr = spr->Next) spr->Show(); -- cgit v1.2.3 From e1b6bc042752f2a07a6cb0911d11bf52ed26d9a8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 29 Jun 2011 21:17:07 +1000 Subject: CGE: Removed Mouse from VGA::ShowQ to prevent crashes in the movie player --- engines/cge/vga13h.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 1d55af7e31..e642db8e7f 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1310,7 +1310,8 @@ void BITMAP::Show(int x, int y) { ++srcP; } } - +/* + DEBUG code to display image immediately // Temporary g_system->copyRectToScreen((const byte *)VGA::Page[1]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); byte palData[PAL_SIZ]; @@ -1319,6 +1320,7 @@ void BITMAP::Show(int x, int y) { g_system->updateScreen(); g_system->delayMillis(5000); +*/ } -- cgit v1.2.3 From 91dc5f424aa474001ac85d600cd22aff54e317c4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Jun 2011 09:57:16 +0200 Subject: CGE: Misc cleanup (provided by Digitall) --- engines/cge/vga13h.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e642db8e7f..56960389c8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -41,12 +41,8 @@ namespace CGE { -#define FADE_STEP 2 -#define TMR_DIV ((0x8000/TMR_RATE)*2) - -//-------------------------------------------------------------------------- - -static char Report[] = "NearHeap=..... FarHeap=......\n"; +#define FADE_STEP 2 +#define TMR_DIV ((0x8000/TMR_RATE)*2) #define NREP 9 #define FREP 24 @@ -64,10 +60,9 @@ static VgaRegBlk VideoMode[] = { // { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end // { 0x15, VGACRT, 0xFF, 0x7F }, // start vb // { 0x10, VGACRT, 0xFF, 0x94 }, // start vr - { 0x00 } + { 0x00, 0x00, 0x00, 0x00 } }; - bool SpeedTest = false; Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; @@ -82,8 +77,8 @@ char *NumStr(char *str, int num) { } -static void Video() { /* +static void Video() { static uint16 SP_S; asm push bx @@ -100,9 +95,8 @@ static void Video() { asm pop si asm pop bp asm pop bx -*/ - warning("STUB: Video"); } +*/ uint16 *SaveScreen(void) { @@ -562,7 +556,7 @@ Sprite *Sprite::Expand(void) { else { SNAIL::COM *c = &nea[neacnt++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); + error("%s [%s]", (const char*)NumStr("Bad NEAR in ######", lcnt), (const char*)fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); c->Ptr = NULL; @@ -578,7 +572,7 @@ Sprite *Sprite::Expand(void) { else { SNAIL::COM *c = &tak[takcnt++]; if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), fname); + error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), (const char *)fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); c->Ptr = NULL; @@ -701,6 +695,9 @@ void Sprite::KillXlat(void) { case FAR_MEM : free(m); break; + default: + warning("Unhandled MemType in Sprite::KillXlat()"); + break; } for (b = _ext->_shpList; *b; b++) (*b)->M = NULL; @@ -942,8 +939,7 @@ VGA::VGA(int mode) for (i = 10; i < 20; i++) { char *txt = Text->getText(i); if (txt) { -// puts(txt); - warning(txt); + warning("%s", txt); std = false; } } @@ -986,7 +982,7 @@ VGA::~VGA(void) { if (Nam) buffer = buffer + " [" + Nam + "]"; - warning(buffer.c_str()); + warning("%s", buffer.c_str()); } } -- cgit v1.2.3 From f2f3124246a77036f843dee2d83ad28084234ebc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Jun 2011 16:13:17 +0200 Subject: CGE: Some more renaming (wip) --- engines/cge/vga13h.cpp | 190 +++++++++++++++++++++++++------------------------ 1 file changed, 96 insertions(+), 94 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 56960389c8..673d6036d8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -356,11 +356,11 @@ void Heart::setXTimer(uint16 *ptr, uint16 time) { Sprite::Sprite(CGEEngine *vm, BMP_PTR *shp) - : X(0), Y(0), Z(0), NearPtr(0), TakePtr(0), - Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0), + : _x(0), _y(0), _z(0), NearPtr(0), TakePtr(0), + _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(File, 0, sizeof(File)); - *((uint16 *)&Flags) = 0; + *((uint16 *)&_flags) = 0; SetShapeList(shp); } @@ -374,8 +374,8 @@ BMP_PTR Sprite::Shp() { register SprExt *e = _ext; if (e) if (e->_seq) { - int i = e->_seq[SeqPtr].Now; - if (i >= ShpCnt) { + int i = e->_seq[_seqPtr].Now; + if (i >= _shpCnt) { //char s[256]; //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); @@ -391,24 +391,24 @@ BMP_PTR Sprite::Shp() { BMP_PTR *Sprite::SetShapeList(BMP_PTR *shp) { BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; - ShpCnt = 0; - W = 0; - H = 0; + _shpCnt = 0; + _w = 0; + _h = 0; if (shp) { BMP_PTR *p; for (p = shp; *p; p++) { BMP_PTR b = (*p); // ->Code(); - if (b->W > W) - W = b->W; - if (b->H > H) - H = b->H; - ++ShpCnt; + if (b->_w > _w) + _w = b->_w; + if (b->_h > _h) + _h = b->_h; + _shpCnt++; } Expand(); _ext->_shpList = shp; if (!_ext->_seq) - SetSeq((ShpCnt < 2) ? _seq1 : _seq2); + SetSeq((_shpCnt < 2) ? _seq1 : _seq2); } return r; } @@ -441,19 +441,19 @@ Seq *Sprite::SetSeq(Seq *seq) { Expand(); register Seq *s = _ext->_seq; _ext->_seq = seq; - if (SeqPtr == NO_SEQ) + if (_seqPtr == NO_SEQ) Step(0); - else if (Time == 0) - Step(SeqPtr); + else if (_time == 0) + Step(_seqPtr); return s; } bool Sprite::SeqTest(int n) { if (n >= 0) - return (SeqPtr == n); + return (_seqPtr == n); if (_ext) - return (_ext->_seq[SeqPtr].Next == SeqPtr); + return (_ext->_seq[_seqPtr].Next == _seqPtr); return true; } @@ -491,7 +491,7 @@ Sprite *Sprite::Expand(void) { if (*File) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[LINE_MAX], fname[MAXPATH]; - BMP_PTR *shplist = new BMP_PTR [ShpCnt + 1]; + BMP_PTR *shplist = new BMP_PTR [_shpCnt + 1]; Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, @@ -521,7 +521,7 @@ Sprite *Sprite::Expand(void) { break; } case 1 : { // Phase - shplist[shpcnt++] = new BITMAP(strtok(NULL, " \t,;/")); + shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/")); break; } case 2 : { // Seq @@ -583,7 +583,7 @@ Sprite *Sprite::Expand(void) { } } } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new BITMAP(File); + shplist[shpcnt++] = new Bitmap(File); } shplist[shpcnt] = NULL; if (seq) { @@ -593,7 +593,7 @@ Sprite *Sprite::Expand(void) { error("Bad JUMP in SEQ [%s]", fname); SetSeq(seq); } else - SetSeq((ShpCnt == 1) ? _seq1 : _seq2); + SetSeq((_shpCnt == 1) ? _seq1 : _seq2); //disable(); // disable interupt SetShapeList(shplist); @@ -618,7 +618,7 @@ Sprite *Sprite::Contract(void) { if (e) { if (e->_name) delete[] e->_name; - if (Flags.BDel && e->_shpList) { + if (_flags._bDel && e->_shpList) { int i; for (i = 0; e->_shpList[i]; i++) delete e->_shpList[i]; @@ -651,15 +651,15 @@ Sprite *Sprite::BackShow(bool fast) { void Sprite::Step(int nr) { if (nr >= 0) - SeqPtr = nr; + _seqPtr = nr; if (_ext) { Seq *seq; if (nr < 0) - SeqPtr = _ext->_seq[SeqPtr].Next; - seq = _ext->_seq + SeqPtr; + _seqPtr = _ext->_seq[_seqPtr].Next; + seq = _ext->_seq + _seqPtr; if (seq->Dly >= 0) { - Goto(X + (seq->Dx), Y + (seq->Dy)); - Time = seq->Dly; + Goto(_x + (seq->Dx), _y + (seq->Dy)); + _time = seq->Dly; } } } @@ -674,19 +674,19 @@ void Sprite::MakeXlat(uint8 *x) { if (_ext) { BMP_PTR *b; - if (Flags.Xlat) + if (_flags._xlat) KillXlat(); for (b = _ext->_shpList; *b; b++) - (*b)->M = x; - Flags.Xlat = true; + (*b)->_m = x; + _flags._xlat = true; } } void Sprite::KillXlat(void) { - if (Flags.Xlat && _ext) { + if (_flags._xlat && _ext) { BMP_PTR *b; - uint8 *m = (*_ext->_shpList)->M; + uint8 *m = (*_ext->_shpList)->_m; switch (MemType(m)) { case NEAR_MEM : @@ -700,38 +700,38 @@ void Sprite::KillXlat(void) { break; } for (b = _ext->_shpList; *b; b++) - (*b)->M = NULL; - Flags.Xlat = false; + (*b)->_m = NULL; + _flags._xlat = false; } } void Sprite::Goto(int x, int y) { - int xo = X, yo = Y; - if (W < SCR_WID) { + int xo = _x, yo = _y; + if (_x < SCR_WID) { if (x < 0) x = 0; - if (x + W > SCR_WID) - x = (SCR_WID - W); - X = x; + if (x + _w > SCR_WID) + x = (SCR_WID - _w); + _x = x; } - if (H < SCR_HIG) { + if (_h < SCR_HIG) { if (y < 0) y = 0; - if (y + H > SCR_HIG) - y = (SCR_HIG - H); - Y = y; + if (y + _h > SCR_HIG) + y = (SCR_HIG - _h); + _y = y; } - if (Next) - if (Next->Flags.Slav) - Next->Goto(Next->X - xo + X, Next->Y - yo + Y); - if (Flags.Shad) - Prev->Goto(Prev->X - xo + X, Prev->Y - yo + Y); + if (_next) + if (_next->_flags._slav) + _next->Goto(_next->_x - xo + _x, _next->_y - yo + _y); + if (_flags._shad) + _prev->Goto(_prev->_x - xo + _x, _prev->_y - yo + _y); } void Sprite::Center(void) { - Goto((SCR_WID - W) / 2, (SCR_HIG - H) / 2); + Goto((SCR_WID - _w) / 2, (SCR_HIG - _h) / 2); } @@ -742,12 +742,12 @@ void Sprite::Show(void) { e->_x0 = e->_x1; e->_y0 = e->_y1; e->_b0 = e->_b1; - e->_x1 = X; - e->_y1 = Y; + e->_x1 = _x; + e->_y1 = _y; e->_b1 = Shp(); // asm sti // ...done! - if (! Flags.Hide) { - if (Flags.Xlat) + if (!_flags._hide) { + if (_flags._xlat) e->_b1->XShow(e->_x1, e->_y1); else e->_b1->Show(e->_x1, e->_y1); @@ -758,7 +758,7 @@ void Sprite::Show(void) { void Sprite::Show(uint16 pg) { Graphics::Surface *a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; - Shp()->Show(X, Y); + Shp()->Show(_x, _y); VGA::Page[1] = a; } @@ -773,16 +773,16 @@ void Sprite::Hide(void) { BMP_PTR Sprite::Ghost(void) { register SprExt *e = _ext; if (e->_b1) { - BMP_PTR bmp = new BITMAP(0, 0, (uint8 *)NULL); + BMP_PTR bmp = new Bitmap(0, 0, (uint8 *)NULL); if (bmp == NULL) error("No core"); - bmp->W = e->_b1->W; - bmp->H = e->_b1->H; - if ((bmp->B = farnew(HideDesc, bmp->H)) == NULL) + bmp->_w = e->_b1->_w; + bmp->_h = e->_b1->_h; + if ((bmp->_b = farnew(HideDesc, bmp->_h)) == NULL) error("No Core"); - bmp->V = (uint8 *) memcpy(bmp->B, e->_b1->B, sizeof(HideDesc) * bmp->H); + bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment - //bmp->M = (uint8 *) MK_FP(e->y1, e->x1); + //bmp->_m = (uint8 *) MK_FP(e->y1, e->x1); warning("FIXME: SPRITE::Ghost"); return bmp; } @@ -793,10 +793,12 @@ BMP_PTR Sprite::Ghost(void) { Sprite *SpriteAt(int x, int y) { Sprite *spr = NULL, * tail = Vga->ShowQ->Last(); if (tail) { - for (spr = tail->Prev; spr; spr = spr->Prev) - if (! spr->Flags.Hide && ! spr->Flags.Tran) - if (spr->Shp()->SolidAt(x - spr->X, y - spr->Y)) + for (spr = tail->_prev; spr; spr = spr->_prev) { + if (! spr->_flags._hide && ! spr->_flags._tran) { + if (spr->Shp()->SolidAt(x - spr->_x, y - spr->_y)) break; + } + } } return spr; } @@ -814,7 +816,7 @@ QUEUE::~QUEUE(void) { void QUEUE::Clear(void) { while (Head) { Sprite *s = Remove(Head); - if (s->Flags.Kill) + if (s->_flags._kill) delete s; } } @@ -823,7 +825,7 @@ void QUEUE::Clear(void) { void QUEUE::ForAll(void (*fun)(Sprite *)) { Sprite *s = Head; while (s) { - Sprite *n = s->Next; + Sprite *n = s->_next; fun(s); s = n; } @@ -832,8 +834,8 @@ void QUEUE::ForAll(void (*fun)(Sprite *)) { void QUEUE::Append(Sprite *spr) { if (Tail) { - spr->Prev = Tail; - Tail->Next = spr; + spr->_prev = Tail; + Tail->_next = spr; } else Head = spr; Tail = spr; @@ -846,18 +848,18 @@ void QUEUE::Append(Sprite *spr) { void QUEUE::Insert(Sprite *spr, Sprite *nxt) { if (nxt == Head) { - spr->Next = Head; + spr->_next = Head; Head = spr; if (! Tail) Tail = spr; } else { - spr->Next = nxt; - spr->Prev = nxt->Prev; - if (spr->Prev) - spr->Prev->Next = spr; + spr->_next = nxt; + spr->_prev = nxt->_prev; + if (spr->_prev) + spr->_prev->_next = spr; } - if (spr->Next) - spr->Next->Prev = spr; + if (spr->_next) + spr->_next->_prev = spr; if (Show) spr->Expand(); else @@ -867,8 +869,8 @@ void QUEUE::Insert(Sprite *spr, Sprite *nxt) { void QUEUE::Insert(Sprite *spr) { Sprite *s; - for (s = Head; s; s = s->Next) - if (s->Z > spr->Z) + for (s = Head; s; s = s->_next) + if (s->_z > spr->_z) break; if (s) Insert(spr, s); @@ -883,22 +885,22 @@ void QUEUE::Insert(Sprite *spr) { Sprite *QUEUE::Remove(Sprite *spr) { if (spr == Head) - Head = spr->Next; + Head = spr->_next; if (spr == Tail) - Tail = spr->Prev; - if (spr->Next) - spr->Next->Prev = spr->Prev; - if (spr->Prev) - spr->Prev->Next = spr->Next; - spr->Prev = NULL; - spr->Next = NULL; + Tail = spr->_prev; + if (spr->_next) + spr->_next->_prev = spr->_prev; + if (spr->_prev) + spr->_prev->_next = spr->_next; + spr->_prev = NULL; + spr->_next = NULL; return spr; } Sprite *QUEUE::Locate(int ref) { Sprite *spr; - for (spr = Head; spr; spr = spr->Next) { + for (spr = Head; spr; spr = spr->_next) { if (spr->_ref == ref) return spr; } @@ -1134,10 +1136,10 @@ void VGA::Sunset(void) { void VGA::Show(void) { Sprite *spr = ShowQ->First(); - for (spr = ShowQ->First(); spr; spr = spr->Next) + for (spr = ShowQ->First(); spr; spr = spr->_next) spr->Show(); Update(); - for (spr = ShowQ->First(); spr; spr = spr->Next) + for (spr = ShowQ->First(); spr; spr = spr->_next) spr->Hide(); ++ FrmCnt; @@ -1176,7 +1178,7 @@ void VGA::CopyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- -void BITMAP::XShow(int x, int y) { +void Bitmap::XShow(int x, int y) { /* uint8 rmsk = x % 4, mask = 1 << rmsk, @@ -1258,8 +1260,8 @@ void BITMAP::XShow(int x, int y) { } -void BITMAP::Show(int x, int y) { - const byte *srcP = (const byte *)V; +void Bitmap::Show(int x, int y) { + const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)VGA::Page[1]->pixels + (SCR_WID * SCR_HIG); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a @@ -1320,7 +1322,7 @@ void BITMAP::Show(int x, int y) { } -void BITMAP::Hide(int x, int y) { +void Bitmap::Hide(int x, int y) { /* uint8 *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); @@ -1383,7 +1385,7 @@ void BITMAP::Hide(int x, int y) { asm pop si // asm pop bx */ - warning("STUB: BITMAP::Hide"); + warning("STUB: Bitmap::Hide"); } } // End of namespace CGE -- cgit v1.2.3 From f59c910b8f41cfa9eeda88ce5f4d5c2a18b97662 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 30 Jun 2011 08:30:23 +0200 Subject: CGE: Some more renaming (wip) --- engines/cge/vga13h.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 673d6036d8..f26d202dca 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -417,7 +417,7 @@ BMP_PTR *Sprite::SetShapeList(BMP_PTR *shp) { void Sprite::MoveShapes(uint8 *buf) { BMP_PTR *p; for (p = _ext->_shpList; *p; p++) { - buf += (*p)->MoveVmap(buf); + buf += (*p)->moveVmap(buf); } } @@ -503,12 +503,12 @@ Sprite *Sprite::Expand(void) { SNAIL::COM *nea = NULL; SNAIL::COM *tak = NULL; MergeExt(fname, File, SPR_EXT); - if (INI_FILE::Exist(fname)) { // sprite description file exist + if (INI_FILE::exist(fname)) { // sprite description file exist INI_FILE sprf(fname); if (! (sprf.Error==0)) error("Bad SPR [%s]", fname); int len = 0, lcnt = 0; - while ((len = sprf.Read((uint8 *)line)) != 0) { + while ((len = sprf.read((uint8 *)line)) != 0) { ++lcnt; if (len && line[len - 1] == '\n') line[-- len] = '\0'; @@ -521,7 +521,7 @@ Sprite *Sprite::Expand(void) { break; } case 1 : { // Phase - shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/")); + shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/"), true); break; } case 2 : { // Seq @@ -583,7 +583,7 @@ Sprite *Sprite::Expand(void) { } } } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new Bitmap(File); + shplist[shpcnt++] = new Bitmap(File, true); } shplist[shpcnt] = NULL; if (seq) { @@ -748,9 +748,9 @@ void Sprite::Show(void) { // asm sti // ...done! if (!_flags._hide) { if (_flags._xlat) - e->_b1->XShow(e->_x1, e->_y1); + e->_b1->xShow(e->_x1, e->_y1); else - e->_b1->Show(e->_x1, e->_y1); + e->_b1->show(e->_x1, e->_y1); } } @@ -758,7 +758,7 @@ void Sprite::Show(void) { void Sprite::Show(uint16 pg) { Graphics::Surface *a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; - Shp()->Show(_x, _y); + Shp()->show(_x, _y); VGA::Page[1] = a; } @@ -766,7 +766,7 @@ void Sprite::Show(uint16 pg) { void Sprite::Hide(void) { register SprExt *e = _ext; if (e->_b0) - e->_b0->Hide(e->_x0, e->_y0); + e->_b0->hide(e->_x0, e->_y0); } @@ -795,7 +795,7 @@ Sprite *SpriteAt(int x, int y) { if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { if (! spr->_flags._hide && ! spr->_flags._tran) { - if (spr->Shp()->SolidAt(x - spr->_x, y - spr->_y)) + if (spr->Shp()->solidAt(x - spr->_x, y - spr->_y)) break; } } @@ -1178,7 +1178,7 @@ void VGA::CopyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- -void Bitmap::XShow(int x, int y) { +void Bitmap::xShow(int x, int y) { /* uint8 rmsk = x % 4, mask = 1 << rmsk, @@ -1256,11 +1256,11 @@ void Bitmap::XShow(int x, int y) { asm pop si asm pop bx */ - warning("STUB: BITMAP::XShow"); + warning("STUB: BITMAP::xShow"); } -void Bitmap::Show(int x, int y) { +void Bitmap::show(int x, int y) { const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)VGA::Page[1]->pixels + (SCR_WID * SCR_HIG); @@ -1322,7 +1322,7 @@ void Bitmap::Show(int x, int y) { } -void Bitmap::Hide(int x, int y) { +void Bitmap::hide(int x, int y) { /* uint8 *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); @@ -1385,7 +1385,7 @@ void Bitmap::Hide(int x, int y) { asm pop si // asm pop bx */ - warning("STUB: Bitmap::Hide"); + warning("STUB: Bitmap::hide"); } } // End of namespace CGE -- cgit v1.2.3 From 0000a3139a7c1d3ddf993741d4e0aa0c7ac3d760 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 1 Jul 2011 08:37:40 +0200 Subject: CGE: Some more renaming (wip) --- engines/cge/vga13h.cpp | 72 +++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index f26d202dca..d12bb9596c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -189,20 +189,20 @@ void RestoreScreen(uint16 * &sav) { } -DAC MkDAC(uint8 r, uint8 g, uint8 b) { - static DAC x; - x.R = r; - x.G = g; - x.B = b; +Dac MkDAC(uint8 r, uint8 g, uint8 b) { + static Dac x; + x._r = r; + x._g = g; + x._b = b; return x; } Rgb MkRGB(uint8 r, uint8 g, uint8 b) { static TRGB x; - x.dac.R = r; - x.dac.G = g; - x.dac.B = b; + x.dac._r = r; + x.dac._g = g; + x.dac._b = b; return x.rgb; } @@ -214,7 +214,7 @@ Sprite *Locate(int ref) { Heart::Heart(void) - : ENGINE(TMR_DIV) { + : Engine_(TMR_DIV) { _enable = false; _xTimer = NULL; } @@ -265,7 +265,7 @@ extern "C" void TimerProc() { */ -void ENGINE::NewTimer(...) { +void Engine_::newTimer(...) { /* static SPRITE *spr; static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; @@ -338,7 +338,7 @@ void ENGINE::NewTimer(...) { } */ - warning("STUB: ENGINE::NewTimer"); + warning("STUB: Engine_::NewTimer"); } @@ -505,7 +505,7 @@ Sprite *Sprite::Expand(void) { MergeExt(fname, File, SPR_EXT); if (INI_FILE::exist(fname)) { // sprite description file exist INI_FILE sprf(fname); - if (! (sprf.Error==0)) + if (!(sprf._error==0)) error("Bad SPR [%s]", fname); int len = 0, lcnt = 0; while ((len = sprf.read((uint8 *)line)) != 0) { @@ -910,7 +910,7 @@ Sprite *QUEUE::Locate(int ref) { //extern const char Copr[]; Graphics::Surface *VGA::Page[4]; -DAC *VGA::SysPal; +Dac *VGA::SysPal; void VGA::init() { for (int idx = 0; idx < 4; ++idx) { @@ -918,7 +918,7 @@ void VGA::init() { Page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } - SysPal = new DAC[PAL_CNT]; + SysPal = new Dac[PAL_CNT]; } void VGA::deinit() { @@ -953,8 +953,8 @@ VGA::VGA(int mode) if (StatAdr != VGAST1_) ++Mono; if (IsVga()) { - OldColors = farnew(DAC, 256); - NewColors = farnew(DAC, 256); + OldColors = farnew(Dac, 256); + NewColors = farnew(Dac, 256); OldScreen = SaveScreen(); GetColors(OldColors); Sunset(); @@ -1061,45 +1061,45 @@ int VGA::SetMode(int mode) { } -void VGA::GetColors(DAC *tab) { +void VGA::GetColors(Dac *tab) { byte palData[PAL_SIZ]; g_system->getPaletteManager()->grabPalette(palData, 0, PAL_CNT); pal2DAC(palData, tab); } -void VGA::pal2DAC(const byte *palData, DAC *tab) { +void VGA::pal2DAC(const byte *palData, Dac *tab) { const byte *colP = palData; for (int idx = 0; idx < PAL_CNT; ++idx, colP += 3) { - tab[idx].R = *colP; - tab[idx].G = *(colP + 1); - tab[idx].B = *(colP + 2); + tab[idx]._r = *colP; + tab[idx]._g = *(colP + 1); + tab[idx]._b = *(colP + 2); } } -void VGA::DAC2pal(const DAC *tab, byte *palData) { +void VGA::DAC2pal(const Dac *tab, byte *palData) { for (int idx = 0; idx < PAL_CNT; ++idx, palData += 3) { - *palData = tab[idx].R << 2; - *(palData + 1) = tab[idx].G << 2; - *(palData + 2) = tab[idx].B << 2; + *palData = tab[idx]._r << 2; + *(palData + 1) = tab[idx]._g << 2; + *(palData + 2) = tab[idx]._b << 2; } } -void VGA::SetColors(DAC *tab, int lum) { - DAC *palP = tab; +void VGA::SetColors(Dac *tab, int lum) { + Dac *palP = tab; for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { - palP->R = (palP->R * lum) >> 6; - palP->G = (palP->G * lum) >> 6; - palP->B = (palP->B * lum) >> 6; + palP->_r = (palP->_r * lum) >> 6; + palP->_g = (palP->_g * lum) >> 6; + palP->_b = (palP->_b * lum) >> 6; } if (Mono) { palP = tab; for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { // Form a greyscalce colour from 30% R, 59% G, 11% B - uint8 intensity = (palP->R * 77) + (palP->G * 151) + (palP->B * 28); - palP->R = intensity; - palP->G = intensity; - palP->B = intensity; + uint8 intensity = (palP->_r * 77) + (palP->_g * 151) + (palP->_b * 28); + palP->_r = intensity; + palP->_g = intensity; + palP->_b = intensity; } } @@ -1113,7 +1113,7 @@ void VGA::SetColors(void) { } -void VGA::Sunrise(DAC *tab) { +void VGA::Sunrise(Dac *tab) { for (int i = 0; i <= 64; i += FADE_STEP) { SetColors(tab, i); WaitVR(true); @@ -1123,7 +1123,7 @@ void VGA::Sunrise(DAC *tab) { void VGA::Sunset(void) { - DAC tab[256]; + Dac tab[256]; GetColors(tab); for (int i = 64; i >= 0; i -= FADE_STEP) { SetColors(tab, i); -- cgit v1.2.3 From ac86efcd61aafe1ede9933f1d08b86b307de467a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 Jul 2011 18:04:21 +1000 Subject: CGE: Palette fixes so that first screen shows correctly --- engines/cge/vga13h.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d12bb9596c..e1bea9a15c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1070,9 +1070,9 @@ void VGA::GetColors(Dac *tab) { void VGA::pal2DAC(const byte *palData, Dac *tab) { const byte *colP = palData; for (int idx = 0; idx < PAL_CNT; ++idx, colP += 3) { - tab[idx]._r = *colP; - tab[idx]._g = *(colP + 1); - tab[idx]._b = *(colP + 2); + tab[idx]._r = *colP >> 2; + tab[idx]._g = *(colP + 1) >> 2; + tab[idx]._b = *(colP + 2) >> 2; } } @@ -1085,21 +1085,21 @@ void VGA::DAC2pal(const Dac *tab, byte *palData) { } void VGA::SetColors(Dac *tab, int lum) { - Dac *palP = tab; - for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { - palP->_r = (palP->_r * lum) >> 6; - palP->_g = (palP->_g * lum) >> 6; - palP->_b = (palP->_b * lum) >> 6; + Dac *palP = tab, *destP = NewColors; + for (int idx = 0; idx < PAL_CNT; ++idx, ++palP, ++destP) { + destP->_r = (palP->_r * lum) >> 6; + destP->_g = (palP->_g * lum) >> 6; + destP->_b = (palP->_b * lum) >> 6; } if (Mono) { - palP = tab; + destP = NewColors; for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { // Form a greyscalce colour from 30% R, 59% G, 11% B - uint8 intensity = (palP->_r * 77) + (palP->_g * 151) + (palP->_b * 28); - palP->_r = intensity; - palP->_g = intensity; - palP->_b = intensity; + uint8 intensity = (destP->_r * 77) + (destP->_g * 151) + (destP->_b * 28); + destP->_r = intensity; + destP->_g = intensity; + destP->_b = intensity; } } -- cgit v1.2.3 From 8e531d0da391b895a573c36c4b1bd8074571df83 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 2 Jul 2011 01:02:14 +0200 Subject: CGE: Some more renaming (WIP) --- engines/cge/vga13h.cpp | 146 ++++++++++++++++++++++++------------------------- 1 file changed, 73 insertions(+), 73 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e1bea9a15c..0e865ffd90 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -356,21 +356,21 @@ void Heart::setXTimer(uint16 *ptr, uint16 time) { Sprite::Sprite(CGEEngine *vm, BMP_PTR *shp) - : _x(0), _y(0), _z(0), NearPtr(0), TakePtr(0), + : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { - memset(File, 0, sizeof(File)); + memset(_file, 0, sizeof(_file)); *((uint16 *)&_flags) = 0; - SetShapeList(shp); + setShapeList(shp); } Sprite::~Sprite() { - Contract(); + contract(); } -BMP_PTR Sprite::Shp() { +BMP_PTR Sprite::shp() { register SprExt *e = _ext; if (e) if (e->_seq) { @@ -380,7 +380,7 @@ BMP_PTR Sprite::Shp() { //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); //VGA::Exit(s, File); - error("Invalid PHASE in SPRITE::Shp() %s", File); + error("Invalid PHASE in SPRITE::Shp() %s", _file); } return e->_shpList[i]; } @@ -388,7 +388,7 @@ BMP_PTR Sprite::Shp() { } -BMP_PTR *Sprite::SetShapeList(BMP_PTR *shp) { +BMP_PTR *Sprite::setShapeList(BMP_PTR *shp) { BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; _shpCnt = 0; @@ -405,16 +405,16 @@ BMP_PTR *Sprite::SetShapeList(BMP_PTR *shp) { _h = b->_h; _shpCnt++; } - Expand(); + expand(); _ext->_shpList = shp; if (!_ext->_seq) - SetSeq((_shpCnt < 2) ? _seq1 : _seq2); + setSeq((_shpCnt < 2) ? _seq1 : _seq2); } return r; } -void Sprite::MoveShapes(uint8 *buf) { +void Sprite::moveShapes(uint8 *buf) { BMP_PTR *p; for (p = _ext->_shpList; *p; p++) { buf += (*p)->moveVmap(buf); @@ -422,12 +422,12 @@ void Sprite::MoveShapes(uint8 *buf) { } -bool Sprite::Works(Sprite *spr) { +bool Sprite::works(Sprite *spr) { if (spr) if (spr->_ext) { SNAIL::COM *c = spr->_ext->_take; if (c != NULL) { - c += spr->TakePtr; + c += spr->_takePtr; if (c->Ref == _ref) if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) return true; @@ -437,19 +437,19 @@ bool Sprite::Works(Sprite *spr) { } -Seq *Sprite::SetSeq(Seq *seq) { - Expand(); +Seq *Sprite::setSeq(Seq *seq) { + expand(); register Seq *s = _ext->_seq; _ext->_seq = seq; if (_seqPtr == NO_SEQ) - Step(0); + step(0); else if (_time == 0) - Step(_seqPtr); + step(_seqPtr); return s; } -bool Sprite::SeqTest(int n) { +bool Sprite::seqTest(int n) { if (n >= 0) return (_seqPtr == n); if (_ext) @@ -458,7 +458,7 @@ bool Sprite::SeqTest(int n) { } -SNAIL::COM *Sprite::SnList(SNLIST type) { +SNAIL::COM *Sprite::snList(SNLIST type) { register SprExt *e = _ext; if (e) return (type == NEAR) ? e->_near : e->_take; @@ -466,7 +466,7 @@ SNAIL::COM *Sprite::SnList(SNLIST type) { } -void Sprite::SetName(char *n) { +void Sprite::setName(char *n) { if (_ext) { if (_ext->_name) { delete[] _ext->_name; @@ -482,13 +482,13 @@ void Sprite::SetName(char *n) { } -Sprite *Sprite::Expand(void) { +Sprite *Sprite::expand() { if (!_ext) { bool enbl = _heart->_enable; _heart->_enable = false; if ((_ext = new SprExt) == NULL) error("No core"); - if (*File) { + if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[LINE_MAX], fname[MAXPATH]; BMP_PTR *shplist = new BMP_PTR [_shpCnt + 1]; @@ -502,7 +502,7 @@ Sprite *Sprite::Expand(void) { SNAIL::COM *nea = NULL; SNAIL::COM *tak = NULL; - MergeExt(fname, File, SPR_EXT); + mergeExt(fname, _file, SPR_EXT); if (INI_FILE::exist(fname)) { // sprite description file exist INI_FILE sprf(fname); if (!(sprf._error==0)) @@ -515,9 +515,9 @@ Sprite *Sprite::Expand(void) { if (len == 0 || *line == '.') continue; - switch (TakeEnum(Comd, strtok(line, " =\t"))) { + switch (takeEnum(Comd, strtok(line, " =\t"))) { case 0 : { // Name - SetName(strtok(NULL, "")); + setName(strtok(NULL, "")); break; } case 1 : { // Phase @@ -549,13 +549,13 @@ Sprite *Sprite::Expand(void) { break; } case 3 : { // Near - if (NearPtr != NO_PTR) { + if (_nearPtr != NO_PTR) { nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); if (nea == NULL) error("No core [%s]", fname); else { SNAIL::COM *c = &nea[neacnt++]; - if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->Com = (SNCOM) takeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", (const char*)NumStr("Bad NEAR in ######", lcnt), (const char*)fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); @@ -565,13 +565,13 @@ Sprite *Sprite::Expand(void) { } break; case 4 : { // Take - if (TakePtr != NO_PTR) { + if (_takePtr != NO_PTR) { tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); if (tak == NULL) error("No core [%s]", fname); else { SNAIL::COM *c = &tak[takcnt++]; - if ((c->Com = (SNCOM) TakeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->Com = (SNCOM) takeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), (const char *)fname); c->Ref = atoi(strtok(NULL, " \t,;/")); c->Val = atoi(strtok(NULL, " \t,;/")); @@ -583,7 +583,7 @@ Sprite *Sprite::Expand(void) { } } } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new Bitmap(File, true); + shplist[shpcnt++] = new Bitmap(_file, true); } shplist[shpcnt] = NULL; if (seq) { @@ -591,21 +591,21 @@ Sprite *Sprite::Expand(void) { error("Bad PHASE in SEQ [%s]", fname); if (maxnxt >= seqcnt) error("Bad JUMP in SEQ [%s]", fname); - SetSeq(seq); + setSeq(seq); } else - SetSeq((_shpCnt == 1) ? _seq1 : _seq2); + setSeq((_shpCnt == 1) ? _seq1 : _seq2); //disable(); // disable interupt - SetShapeList(shplist); + setShapeList(shplist); //enable(); // enable interupt if (nea) nea[neacnt - 1].Ptr = _ext->_near = nea; else - NearPtr = NO_PTR; + _nearPtr = NO_PTR; if (tak) tak[takcnt - 1].Ptr = _ext->_take = tak; else - TakePtr = NO_PTR; + _takePtr = NO_PTR; } _heart->_enable = enbl; } @@ -613,7 +613,7 @@ Sprite *Sprite::Expand(void) { } -Sprite *Sprite::Contract(void) { +Sprite *Sprite::contract() { register SprExt *e = _ext; if (e) { if (e->_name) @@ -622,10 +622,10 @@ Sprite *Sprite::Contract(void) { int i; for (i = 0; e->_shpList[i]; i++) delete e->_shpList[i]; - if (MemType(e->_shpList) == NEAR_MEM) + if (memType(e->_shpList) == NEAR_MEM) delete[] e->_shpList; } - if (MemType(e->_seq) == NEAR_MEM) + if (memType(e->_seq) == NEAR_MEM) free(e->_seq); if (e->_near) free(e->_near); @@ -638,18 +638,18 @@ Sprite *Sprite::Contract(void) { } -Sprite *Sprite::BackShow(bool fast) { - Expand(); - Show(2); - Show(1); +Sprite *Sprite::backShow(bool fast) { + expand(); + show(2); + show(1); if (fast) - Show(0); - Contract(); + show(0); + contract(); return this; } -void Sprite::Step(int nr) { +void Sprite::step(int nr) { if (nr >= 0) _seqPtr = nr; if (_ext) { @@ -658,24 +658,24 @@ void Sprite::Step(int nr) { _seqPtr = _ext->_seq[_seqPtr].Next; seq = _ext->_seq + _seqPtr; if (seq->Dly >= 0) { - Goto(_x + (seq->Dx), _y + (seq->Dy)); + gotoxy(_x + (seq->Dx), _y + (seq->Dy)); _time = seq->Dly; } } } -void Sprite::Tick(void) { - Step(); +void Sprite::tick() { + step(); } -void Sprite::MakeXlat(uint8 *x) { +void Sprite::makeXlat(uint8 *x) { if (_ext) { BMP_PTR *b; if (_flags._xlat) - KillXlat(); + killXlat(); for (b = _ext->_shpList; *b; b++) (*b)->_m = x; _flags._xlat = true; @@ -683,12 +683,12 @@ void Sprite::MakeXlat(uint8 *x) { } -void Sprite::KillXlat(void) { +void Sprite::killXlat() { if (_flags._xlat && _ext) { BMP_PTR *b; uint8 *m = (*_ext->_shpList)->_m; - switch (MemType(m)) { + switch (memType(m)) { case NEAR_MEM : delete[](uint8 *) m; break; @@ -706,7 +706,7 @@ void Sprite::KillXlat(void) { } -void Sprite::Goto(int x, int y) { +void Sprite::gotoxy(int x, int y) { int xo = _x, yo = _y; if (_x < SCR_WID) { if (x < 0) @@ -724,18 +724,18 @@ void Sprite::Goto(int x, int y) { } if (_next) if (_next->_flags._slav) - _next->Goto(_next->_x - xo + _x, _next->_y - yo + _y); + _next->gotoxy(_next->_x - xo + _x, _next->_y - yo + _y); if (_flags._shad) - _prev->Goto(_prev->_x - xo + _x, _prev->_y - yo + _y); + _prev->gotoxy(_prev->_x - xo + _x, _prev->_y - yo + _y); } -void Sprite::Center(void) { - Goto((SCR_WID - _w) / 2, (SCR_HIG - _h) / 2); +void Sprite::center() { + gotoxy((SCR_WID - _w) / 2, (SCR_HIG - _h) / 2); } -void Sprite::Show(void) { +void Sprite::show() { register SprExt *e; // asm cli // critic section... e = _ext; @@ -744,7 +744,7 @@ void Sprite::Show(void) { e->_b0 = e->_b1; e->_x1 = _x; e->_y1 = _y; - e->_b1 = Shp(); + e->_b1 = shp(); // asm sti // ...done! if (!_flags._hide) { if (_flags._xlat) @@ -755,22 +755,22 @@ void Sprite::Show(void) { } -void Sprite::Show(uint16 pg) { +void Sprite::show(uint16 pg) { Graphics::Surface *a = VGA::Page[1]; VGA::Page[1] = VGA::Page[pg & 3]; - Shp()->show(_x, _y); + shp()->show(_x, _y); VGA::Page[1] = a; } -void Sprite::Hide(void) { +void Sprite::hide() { register SprExt *e = _ext; if (e->_b0) e->_b0->hide(e->_x0, e->_y0); } -BMP_PTR Sprite::Ghost(void) { +BMP_PTR Sprite::ghost() { register SprExt *e = _ext; if (e->_b1) { BMP_PTR bmp = new Bitmap(0, 0, (uint8 *)NULL); @@ -795,7 +795,7 @@ Sprite *SpriteAt(int x, int y) { if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { if (! spr->_flags._hide && ! spr->_flags._tran) { - if (spr->Shp()->solidAt(x - spr->_x, y - spr->_y)) + if (spr->shp()->solidAt(x - spr->_x, y - spr->_y)) break; } } @@ -840,9 +840,9 @@ void QUEUE::Append(Sprite *spr) { Head = spr; Tail = spr; if (Show) - spr->Expand(); + spr->expand(); else - spr->Contract(); + spr->contract(); } @@ -861,9 +861,9 @@ void QUEUE::Insert(Sprite *spr, Sprite *nxt) { if (spr->_next) spr->_next->_prev = spr; if (Show) - spr->Expand(); + spr->expand(); else - spr->Contract(); + spr->contract(); } @@ -877,9 +877,9 @@ void QUEUE::Insert(Sprite *spr) { else Append(spr); if (Show) - spr->Expand(); + spr->expand(); else - spr->Contract(); + spr->contract(); } @@ -952,7 +952,7 @@ VGA::VGA(int mode) SetStatAdr(); if (StatAdr != VGAST1_) ++Mono; - if (IsVga()) { + if (isVga()) { OldColors = farnew(Dac, 256); NewColors = farnew(Dac, 256); OldScreen = SaveScreen(); @@ -968,7 +968,7 @@ VGA::VGA(int mode) VGA::~VGA(void) { Mono = 0; - if (IsVga()) { + if (isVga()) { Common::String buffer = ""; Clear(0); SetMode(OldMode); @@ -1137,10 +1137,10 @@ void VGA::Show(void) { Sprite *spr = ShowQ->First(); for (spr = ShowQ->First(); spr; spr = spr->_next) - spr->Show(); + spr->show(); Update(); for (spr = ShowQ->First(); spr; spr = spr->_next) - spr->Hide(); + spr->hide(); ++ FrmCnt; } -- cgit v1.2.3 From adb27016294b995eb273663a2c33904050723f96 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jul 2011 20:38:27 +1000 Subject: CGE: Graceful exit rather than an error --- engines/cge/vga13h.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 0e865ffd90..83c89892ca 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -366,6 +366,8 @@ Sprite::Sprite(CGEEngine *vm, BMP_PTR *shp) Sprite::~Sprite() { + if (_sprite == this) + _sprite = NULL; contract(); } @@ -970,11 +972,13 @@ VGA::~VGA(void) { Mono = 0; if (isVga()) { Common::String buffer = ""; +/* Clear(0); SetMode(OldMode); SetColors(); RestoreScreen(OldScreen); Sunrise(OldColors); +*/ if (OldColors) free(OldColors); if (NewColors) -- cgit v1.2.3 From bdc213846e1c35c7b6b7f5a397f97d8fe334c1b1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 2 Jul 2011 18:20:41 +0200 Subject: CGE: Some more renaming (WIP) --- engines/cge/vga13h.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 83c89892ca..484d7118ef 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -251,7 +251,7 @@ extern "C" void TimerProc() { } for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { if (spr->Time) { - if (!spr->Flags.Hide) { + if (!spr->_flags.Hide) { if (-- spr->Time == 0) spr->Tick(); } @@ -326,7 +326,7 @@ void Engine_::newTimer(...) { for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { if (spr->Time) { - if (!spr->Flags.Hide) { + if (!spr->_flags.Hide) { if (--spr->Time == 0) spr->Tick(); } @@ -427,11 +427,11 @@ void Sprite::moveShapes(uint8 *buf) { bool Sprite::works(Sprite *spr) { if (spr) if (spr->_ext) { - SNAIL::COM *c = spr->_ext->_take; + Snail::Com *c = spr->_ext->_take; if (c != NULL) { c += spr->_takePtr; - if (c->Ref == _ref) - if (c->Com != SNLABEL || (c->Val == 0 || c->Val == Now)) + if (c->_ref == _ref) + if (c->_com != SNLABEL || (c->_val == 0 || c->_val == _now)) return true; } } @@ -460,7 +460,7 @@ bool Sprite::seqTest(int n) { } -SNAIL::COM *Sprite::snList(SNLIST type) { +Snail::Com *Sprite::snList(SNLIST type) { register SprExt *e = _ext; if (e) return (type == NEAR) ? e->_near : e->_take; @@ -493,7 +493,7 @@ Sprite *Sprite::expand() { if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[LINE_MAX], fname[MAXPATH]; - BMP_PTR *shplist = new BMP_PTR [_shpCnt + 1]; + BMP_PTR *shplist = new BMP_PTR[_shpCnt + 1]; Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, @@ -502,8 +502,8 @@ Sprite *Sprite::expand() { maxnow = 0, maxnxt = 0; - SNAIL::COM *nea = NULL; - SNAIL::COM *tak = NULL; + Snail::Com *nea = NULL; + Snail::Com *tak = NULL; mergeExt(fname, _file, SPR_EXT); if (INI_FILE::exist(fname)) { // sprite description file exist INI_FILE sprf(fname); @@ -552,32 +552,32 @@ Sprite *Sprite::expand() { } case 3 : { // Near if (_nearPtr != NO_PTR) { - nea = (SNAIL::COM *) realloc(nea, (neacnt + 1) * sizeof(*nea)); + nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); if (nea == NULL) error("No core [%s]", fname); else { - SNAIL::COM *c = &nea[neacnt++]; - if ((c->Com = (SNCOM) takeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + Snail::Com *c = &nea[neacnt++]; + if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", (const char*)NumStr("Bad NEAR in ######", lcnt), (const char*)fname); - c->Ref = atoi(strtok(NULL, " \t,;/")); - c->Val = atoi(strtok(NULL, " \t,;/")); - c->Ptr = NULL; + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; } } } break; case 4 : { // Take if (_takePtr != NO_PTR) { - tak = (SNAIL::COM *) realloc(tak, (takcnt + 1) * sizeof(*tak)); + tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); if (tak == NULL) error("No core [%s]", fname); else { - SNAIL::COM *c = &tak[takcnt++]; - if ((c->Com = (SNCOM) takeEnum(SNAIL::ComTxt, strtok(NULL, " \t,;/"))) < 0) + Snail::Com *c = &tak[takcnt++]; + if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), (const char *)fname); - c->Ref = atoi(strtok(NULL, " \t,;/")); - c->Val = atoi(strtok(NULL, " \t,;/")); - c->Ptr = NULL; + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; } } break; @@ -601,11 +601,11 @@ Sprite *Sprite::expand() { setShapeList(shplist); //enable(); // enable interupt if (nea) - nea[neacnt - 1].Ptr = _ext->_near = nea; + nea[neacnt - 1]._ptr = _ext->_near = nea; else _nearPtr = NO_PTR; if (tak) - tak[takcnt - 1].Ptr = _ext->_take = tak; + tak[takcnt - 1]._ptr = _ext->_take = tak; else _takePtr = NO_PTR; } -- cgit v1.2.3 From ada4556b9ae3b7d94ccac8ecec2ed31ba959ad55 Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Sat, 2 Jul 2011 20:25:39 +0200 Subject: CGE: Simplify error() calls This also silences a few GCC warnings. --- engines/cge/vga13h.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 484d7118ef..41d4b79469 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -558,7 +558,7 @@ Sprite *Sprite::expand() { else { Snail::Com *c = &nea[neacnt++]; if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", (const char*)NumStr("Bad NEAR in ######", lcnt), (const char*)fname); + error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); c->_ptr = NULL; @@ -574,7 +574,7 @@ Sprite *Sprite::expand() { else { Snail::Com *c = &tak[takcnt++]; if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) - error("%s [%s]", NumStr("Bad NEAR in ######", lcnt), (const char *)fname); + error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); c->_ptr = NULL; -- cgit v1.2.3 From 5f64f3ff4743b91559756a319c4a41ab36851ac1 Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Sat, 2 Jul 2011 20:28:11 +0200 Subject: CGE: Removed unused NumStr() function. It was used, until my previous commit. :-) --- engines/cge/vga13h.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 41d4b79469..a6275a3929 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -69,14 +69,6 @@ Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; extern "C" void SNDMIDIPlay(void); -char *NumStr(char *str, int num) { - char *p = strchr(str, '#'); - if (p) - wtom(num, p, 10, 5); - return str; -} - - /* static void Video() { static uint16 SP_S; -- cgit v1.2.3 From ac0caf757950b960cba058800fa42eebc7becbd8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 11:43:59 +1000 Subject: CGE: Implemented BITMAP::Hide method --- engines/cge/vga13h.cpp | 67 ++++---------------------------------------------- 1 file changed, 5 insertions(+), 62 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index a6275a3929..43de8dc9b7 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1319,69 +1319,12 @@ void Bitmap::show(int x, int y) { void Bitmap::hide(int x, int y) { - /* - uint8 *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]); - HideDesc *b = B; - uint16 extra = ((x & 3) != 0); - uint16 h = H; - - // asm push bx - asm push si - asm push ds - - asm cld - asm les di,scr - asm mov si,di - asm add si,d // take bytes from background page - asm lds bx,b - - asm mov dx,VGAGRA_ - asm mov al,0x05 // R/W mode - asm out dx,al - asm inc dx - asm in al,dx - asm and al,0xF4 - asm push ax - asm push dx - asm or al,0x01 - asm out dx,al - - asm mov dx,VGASEQ_ - asm mov ax,0x0F02 // enable all planes - asm out dx,ax + for (int yp = y; yp < y + _h; ++yp) { + const byte *srcP = (const byte *)VGA::Page[2]->getBasePtr(x, yp); + byte *destP = (byte *)VGA::Page[1]->getBasePtr(x, yp); - asm mov dx,ds // save DS - - row: - // skip block - asm mov cx,[bx] - asm add si,cx - asm add di,cx - asm mov cx,[bx+2] - asm add bx,4 - asm add cx,extra - - asm push es - asm pop ds // set DS to video seg - asm rep movsb // move bytes fast - asm sub si,extra - asm sub di,extra - asm mov ds,dx // restore DS - - asm dec h - asm jnz row - - asm pop dx - asm pop ax - asm out dx,al // end of copy mode - - - asm pop ds - asm pop si - // asm pop bx - */ - warning("STUB: Bitmap::hide"); + Common::copy(srcP, srcP + _w, destP); + } } } // End of namespace CGE -- cgit v1.2.3 From 334de9626ae6e6e5cd66582993fe799b329a0a50 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 12:30:27 +1000 Subject: CGE: Removed C standard library includes --- engines/cge/vga13h.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 43de8dc9b7..dc11ffbf6a 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -33,10 +33,6 @@ #include "cge/vol.h" #include "cge/text.h" #include "cge/cge_main.h" -#include -#include -#include -#include #include "cge/cge.h" namespace CGE { -- cgit v1.2.3 From 156c2d020fca74bb901e547a04ae2a9e2f8ec8cc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 14:55:49 +1000 Subject: CGE: Fix GCC compiler warnings --- engines/cge/vga13h.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index dc11ffbf6a..b4e9bff286 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -343,13 +343,13 @@ void Heart::setXTimer(uint16 *ptr, uint16 time) { } -Sprite::Sprite(CGEEngine *vm, BMP_PTR *shp) +Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(_file, 0, sizeof(_file)); *((uint16 *)&_flags) = 0; - setShapeList(shp); + setShapeList(shpP); } @@ -378,16 +378,16 @@ BMP_PTR Sprite::shp() { } -BMP_PTR *Sprite::setShapeList(BMP_PTR *shp) { +BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; _shpCnt = 0; _w = 0; _h = 0; - if (shp) { + if (shpP) { BMP_PTR *p; - for (p = shp; *p; p++) { + for (p = shpP; *p; p++) { BMP_PTR b = (*p); // ->Code(); if (b->_w > _w) _w = b->_w; @@ -396,7 +396,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shp) { _shpCnt++; } expand(); - _ext->_shpList = shp; + _ext->_shpList = shpP; if (!_ext->_seq) setSeq((_shpCnt < 2) ? _seq1 : _seq2); } -- cgit v1.2.3 From dff8bd5474905c924f4039ab079c20b3f145b364 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2011 17:14:47 +1000 Subject: CGE: Fix some memory leaks --- engines/cge/vga13h.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index b4e9bff286..35d9688bd3 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -912,8 +912,10 @@ void VGA::init() { } void VGA::deinit() { - for (int idx = 0; idx < 4; ++idx) + for (int idx = 0; idx < 4; ++idx) { + Page[idx]->free(); delete Page[idx]; + } delete[] SysPal; } @@ -931,7 +933,7 @@ VGA::VGA(int mode) for (i = 10; i < 20; i++) { char *txt = Text->getText(i); if (txt) { - warning("%s", txt); + debugN("%s", txt); std = false; } } @@ -976,8 +978,11 @@ VGA::~VGA(void) { if (Nam) buffer = buffer + " [" + Nam + "]"; - warning("%s", buffer.c_str()); + debugN("%s", buffer.c_str()); } + + delete ShowQ; + delete SpareQ; } -- cgit v1.2.3 From 4116189395a87959f1981ca7ebae0604aa4ca9a4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 3 Jul 2011 11:28:22 +0200 Subject: CGE: Some more renaming (WIP) --- engines/cge/vga13h.cpp | 136 ++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 35d9688bd3..36661e756e 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -187,17 +187,17 @@ Dac MkDAC(uint8 r, uint8 g, uint8 b) { Rgb MkRGB(uint8 r, uint8 g, uint8 b) { - static TRGB x; - x.dac._r = r; - x.dac._g = g; - x.dac._b = b; - return x.rgb; + static Trgb x; + x._dac._r = r; + x._dac._g = g; + x._dac._b = b; + return x._rgb; } Sprite *Locate(int ref) { - Sprite *spr = Vga->ShowQ->Locate(ref); - return (spr) ? spr : Vga->SpareQ->Locate(ref); + Sprite *spr = Vga->_showQ->locate(ref); + return (spr) ? spr : Vga->_spareQ->locate(ref); } @@ -364,7 +364,7 @@ BMP_PTR Sprite::shp() { register SprExt *e = _ext; if (e) if (e->_seq) { - int i = e->_seq[_seqPtr].Now; + int i = e->_seq[_seqPtr]._now; if (i >= _shpCnt) { //char s[256]; //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", @@ -443,7 +443,7 @@ bool Sprite::seqTest(int n) { if (n >= 0) return (_seqPtr == n); if (_ext) - return (_ext->_seq[_seqPtr].Next == _seqPtr); + return (_ext->_seq[_seqPtr]._next == _seqPtr); return true; } @@ -519,23 +519,23 @@ Sprite *Sprite::expand() { if (seq == NULL) error("No core [%s]", fname); Seq *s = &seq[seqcnt++]; - s->Now = atoi(strtok(NULL, " \t,;/")); - if (s->Now > maxnow) - maxnow = s->Now; - s->Next = atoi(strtok(NULL, " \t,;/")); - switch (s->Next) { + s->_now = atoi(strtok(NULL, " \t,;/")); + if (s->_now > maxnow) + maxnow = s->_now; + s->_next = atoi(strtok(NULL, " \t,;/")); + switch (s->_next) { case 0xFF : - s->Next = seqcnt; + s->_next = seqcnt; break; case 0xFE : - s->Next = seqcnt - 1; + s->_next = seqcnt - 1; break; } - if (s->Next > maxnxt) - maxnxt = s->Next; - s->Dx = atoi(strtok(NULL, " \t,;/")); - s->Dy = atoi(strtok(NULL, " \t,;/")); - s->Dly = atoi(strtok(NULL, " \t,;/")); + if (s->_next > maxnxt) + maxnxt = s->_next; + s->_dx = atoi(strtok(NULL, " \t,;/")); + s->_dy = atoi(strtok(NULL, " \t,;/")); + s->_dly = atoi(strtok(NULL, " \t,;/")); break; } case 3 : { // Near @@ -645,11 +645,11 @@ void Sprite::step(int nr) { if (_ext) { Seq *seq; if (nr < 0) - _seqPtr = _ext->_seq[_seqPtr].Next; + _seqPtr = _ext->_seq[_seqPtr]._next; seq = _ext->_seq + _seqPtr; - if (seq->Dly >= 0) { - gotoxy(_x + (seq->Dx), _y + (seq->Dy)); - _time = seq->Dly; + if (seq->_dly >= 0) { + gotoxy(_x + (seq->_dx), _y + (seq->_dy)); + _time = seq->_dly; } } } @@ -781,7 +781,7 @@ BMP_PTR Sprite::ghost() { Sprite *SpriteAt(int x, int y) { - Sprite *spr = NULL, * tail = Vga->ShowQ->Last(); + Sprite *spr = NULL, * tail = Vga->_showQ->last(); if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { if (! spr->_flags._hide && ! spr->_flags._tran) { @@ -794,26 +794,26 @@ Sprite *SpriteAt(int x, int y) { } -QUEUE::QUEUE(bool show) : Head(NULL), Tail(NULL), Show(show) { +Queue::Queue(bool show) : _head(NULL), _tail(NULL), _show(show) { } -QUEUE::~QUEUE(void) { - Clear(); +Queue::~Queue() { + clear(); } -void QUEUE::Clear(void) { - while (Head) { - Sprite *s = Remove(Head); +void Queue::clear() { + while (_head) { + Sprite *s = remove(_head); if (s->_flags._kill) delete s; } } -void QUEUE::ForAll(void (*fun)(Sprite *)) { - Sprite *s = Head; +void Queue::forAll(void (*fun)(Sprite *)) { + Sprite *s = _head; while (s) { Sprite *n = s->_next; fun(s); @@ -822,26 +822,26 @@ void QUEUE::ForAll(void (*fun)(Sprite *)) { } -void QUEUE::Append(Sprite *spr) { - if (Tail) { - spr->_prev = Tail; - Tail->_next = spr; +void Queue::append(Sprite *spr) { + if (_tail) { + spr->_prev = _tail; + _tail->_next = spr; } else - Head = spr; - Tail = spr; - if (Show) + _head = spr; + _tail = spr; + if (_show) spr->expand(); else spr->contract(); } -void QUEUE::Insert(Sprite *spr, Sprite *nxt) { - if (nxt == Head) { - spr->_next = Head; - Head = spr; - if (! Tail) - Tail = spr; +void Queue::insert(Sprite *spr, Sprite *nxt) { + if (nxt == _head) { + spr->_next = _head; + _head = spr; + if (!_tail) + _tail = spr; } else { spr->_next = nxt; spr->_prev = nxt->_prev; @@ -850,34 +850,34 @@ void QUEUE::Insert(Sprite *spr, Sprite *nxt) { } if (spr->_next) spr->_next->_prev = spr; - if (Show) + if (_show) spr->expand(); else spr->contract(); } -void QUEUE::Insert(Sprite *spr) { +void Queue::insert(Sprite *spr) { Sprite *s; - for (s = Head; s; s = s->_next) + for (s = _head; s; s = s->_next) if (s->_z > spr->_z) break; if (s) - Insert(spr, s); + insert(spr, s); else - Append(spr); - if (Show) + append(spr); + if (_show) spr->expand(); else spr->contract(); } -Sprite *QUEUE::Remove(Sprite *spr) { - if (spr == Head) - Head = spr->_next; - if (spr == Tail) - Tail = spr->_prev; +Sprite *Queue::remove(Sprite *spr) { + if (spr == _head) + _head = spr->_next; + if (spr == _tail) + _tail = spr->_prev; if (spr->_next) spr->_next->_prev = spr->_prev; if (spr->_prev) @@ -888,9 +888,9 @@ Sprite *QUEUE::Remove(Sprite *spr) { } -Sprite *QUEUE::Locate(int ref) { +Sprite *Queue::locate(int ref) { Sprite *spr; - for (spr = Head; spr; spr = spr->_next) { + for (spr = _head; spr; spr = spr->_next) { if (spr->_ref == ref) return spr; } @@ -925,13 +925,13 @@ VGA::VGA(int mode) Msg(NULL), Nam(NULL), SetPal(false), Mono(0) { OldColors = NULL; NewColors = NULL; - ShowQ = new QUEUE(true); - SpareQ = new QUEUE(false); + _showQ = new Queue(true); + _spareQ = new Queue(false); bool std = true; int i; for (i = 10; i < 20; i++) { - char *txt = Text->getText(i); + char *txt = _text->getText(i); if (txt) { debugN("%s", txt); std = false; @@ -981,8 +981,8 @@ VGA::~VGA(void) { debugN("%s", buffer.c_str()); } - delete ShowQ; - delete SpareQ; + delete _showQ; + delete _spareQ; } @@ -1131,12 +1131,12 @@ void VGA::Sunset(void) { void VGA::Show(void) { - Sprite *spr = ShowQ->First(); + Sprite *spr = _showQ->first(); - for (spr = ShowQ->First(); spr; spr = spr->_next) + for (spr = _showQ->first(); spr; spr = spr->_next) spr->show(); Update(); - for (spr = ShowQ->First(); spr; spr = spr->_next) + for (spr = _showQ->first(); spr; spr = spr->_next) spr->hide(); ++ FrmCnt; -- cgit v1.2.3 From c313d2cce8d647265f192400c667d72824874dbc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 3 Jul 2011 16:22:26 +0200 Subject: CGE: Even more renaming (WIP) --- engines/cge/vga13h.cpp | 198 ++++++++++++++++++++++++------------------------- 1 file changed, 99 insertions(+), 99 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 36661e756e..aa7cd8ad06 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -177,7 +177,7 @@ void RestoreScreen(uint16 * &sav) { } -Dac MkDAC(uint8 r, uint8 g, uint8 b) { +Dac mkDac(uint8 r, uint8 g, uint8 b) { static Dac x; x._r = r; x._g = g; @@ -186,7 +186,7 @@ Dac MkDAC(uint8 r, uint8 g, uint8 b) { } -Rgb MkRGB(uint8 r, uint8 g, uint8 b) { +Rgb mkRgb(uint8 r, uint8 g, uint8 b) { static Trgb x; x._dac._r = r; x._dac._g = g; @@ -195,9 +195,9 @@ Rgb MkRGB(uint8 r, uint8 g, uint8 b) { } -Sprite *Locate(int ref) { - Sprite *spr = Vga->_showQ->locate(ref); - return (spr) ? spr : Vga->_spareQ->locate(ref); +Sprite *locate(int ref) { + Sprite *spr = _vga->_showQ->locate(ref); + return (spr) ? spr : _vga->_spareQ->locate(ref); } @@ -746,10 +746,10 @@ void Sprite::show() { void Sprite::show(uint16 pg) { - Graphics::Surface *a = VGA::Page[1]; - VGA::Page[1] = VGA::Page[pg & 3]; + Graphics::Surface *a = Vga::_page[1]; + Vga::_page[1] = Vga::_page[pg & 3]; shp()->show(_x, _y); - VGA::Page[1] = a; + Vga::_page[1] = a; } @@ -780,8 +780,8 @@ BMP_PTR Sprite::ghost() { } -Sprite *SpriteAt(int x, int y) { - Sprite *spr = NULL, * tail = Vga->_showQ->last(); +Sprite *spriteAt(int x, int y) { + Sprite *spr = NULL, * tail = _vga->_showQ->last(); if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { if (! spr->_flags._hide && ! spr->_flags._tran) { @@ -899,32 +899,32 @@ Sprite *Queue::locate(int ref) { //extern const char Copr[]; -Graphics::Surface *VGA::Page[4]; -Dac *VGA::SysPal; +Graphics::Surface *Vga::_page[4]; +Dac *Vga::_sysPal; -void VGA::init() { +void Vga::init() { for (int idx = 0; idx < 4; ++idx) { - Page[idx] = new Graphics::Surface(); - Page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); + _page[idx] = new Graphics::Surface(); + _page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } - SysPal = new Dac[PAL_CNT]; + _sysPal = new Dac[PAL_CNT]; } -void VGA::deinit() { +void Vga::deinit() { for (int idx = 0; idx < 4; ++idx) { - Page[idx]->free(); - delete Page[idx]; + _page[idx]->free(); + delete _page[idx]; } - delete[] SysPal; + delete[] _sysPal; } -VGA::VGA(int mode) - : FrmCnt(0), OldMode(0), OldScreen(NULL), StatAdr(VGAST1_), - Msg(NULL), Nam(NULL), SetPal(false), Mono(0) { - OldColors = NULL; - NewColors = NULL; +Vga::Vga(int mode) + : _frmCnt(0), _oldMode(0), _oldScreen(NULL), _statAdr(VGAST1_), + _msg(NULL), _nam(NULL), _setPal(false), _mono(0) { + _oldColors = NULL; + _newColors = NULL; _showQ = new Queue(true); _spareQ = new Queue(false); @@ -941,42 +941,42 @@ VGA::VGA(int mode) // warning(Copr); warning("TODO: Fix Copr"); - SetStatAdr(); - if (StatAdr != VGAST1_) - ++Mono; + setStatAdr(); + if (_statAdr != VGAST1_) + _mono++; if (isVga()) { - OldColors = farnew(Dac, 256); - NewColors = farnew(Dac, 256); - OldScreen = SaveScreen(); - GetColors(OldColors); - Sunset(); - OldMode = SetMode(mode); - SetColors(); - Setup(VideoMode); - Clear(0); + _oldColors = farnew(Dac, 256); + _newColors = farnew(Dac, 256); + _oldScreen = SaveScreen(); + getColors(_oldColors); + sunset(); + _oldMode = setMode(mode); + setColors(); + setup(VideoMode); + clear(0); } } -VGA::~VGA(void) { - Mono = 0; +Vga::~Vga() { + _mono = 0; if (isVga()) { Common::String buffer = ""; /* - Clear(0); - SetMode(OldMode); - SetColors(); - RestoreScreen(OldScreen); - Sunrise(OldColors); + clear(0); + setMode(_oldMode); + setColors(); + restoreScreen(_oldScreen); + sunrise(_oldColors); */ - if (OldColors) - free(OldColors); - if (NewColors) - free(NewColors); - if (Msg) - buffer = Common::String(Msg); - if (Nam) - buffer = buffer + " [" + Nam + "]"; + if (_oldColors) + free(_oldColors); + if (_newColors) + free(_newColors); + if (_msg) + buffer = Common::String(_msg); + if (_nam) + buffer = buffer + " [" + _nam + "]"; debugN("%s", buffer.c_str()); } @@ -986,7 +986,7 @@ VGA::~VGA(void) { } -void VGA::SetStatAdr(void) { +void Vga::setStatAdr() { /* asm mov dx,VGAMIr_ asm in al,dx @@ -997,21 +997,21 @@ void VGA::SetStatAdr(void) { set_mode_adr: StatAdr = _AX; */ - warning("STUB: VGA::SetStatADR"); + warning("STUB: VGA::setStatADR"); } #pragma argsused -void VGA::WaitVR(bool on) { +void Vga::waitVR(bool on) { // Since some of the game parts rely on using vertical sync as a delay mechanism, // we're introducing a short delay to simulate it g_system->delayMillis(10); } -void VGA::Setup(VgaRegBlk *vrb) { +void Vga::setup(VgaRegBlk *vrb) { /* - WaitVR(); // *--LOOK!--* resets VGAATR logic + waitVR(); // *--LOOK!--* resets VGAATR logic asm cld asm mov si, vrb // take address of parameter table asm mov dh,0x03 // higher byte of I/O address is always 3 @@ -1048,23 +1048,23 @@ void VGA::Setup(VgaRegBlk *vrb) { xit: */ - warning("STUB: VGA::Setup"); + warning("STUB: VGA::setup"); } -int VGA::SetMode(int mode) { +int Vga::setMode(int mode) { // ScummVM provides it's own vieo services return 0; } -void VGA::GetColors(Dac *tab) { +void Vga::getColors(Dac *tab) { byte palData[PAL_SIZ]; g_system->getPaletteManager()->grabPalette(palData, 0, PAL_CNT); - pal2DAC(palData, tab); + palToDac(palData, tab); } -void VGA::pal2DAC(const byte *palData, Dac *tab) { +void Vga::palToDac(const byte *palData, Dac *tab) { const byte *colP = palData; for (int idx = 0; idx < PAL_CNT; ++idx, colP += 3) { tab[idx]._r = *colP >> 2; @@ -1073,7 +1073,7 @@ void VGA::pal2DAC(const byte *palData, Dac *tab) { } } -void VGA::DAC2pal(const Dac *tab, byte *palData) { +void Vga::dacToPal(const Dac *tab, byte *palData) { for (int idx = 0; idx < PAL_CNT; ++idx, palData += 3) { *palData = tab[idx]._r << 2; *(palData + 1) = tab[idx]._g << 2; @@ -1081,16 +1081,16 @@ void VGA::DAC2pal(const Dac *tab, byte *palData) { } } -void VGA::SetColors(Dac *tab, int lum) { - Dac *palP = tab, *destP = NewColors; +void Vga::setColors(Dac *tab, int lum) { + Dac *palP = tab, *destP = _newColors; for (int idx = 0; idx < PAL_CNT; ++idx, ++palP, ++destP) { destP->_r = (palP->_r * lum) >> 6; destP->_g = (palP->_g * lum) >> 6; destP->_b = (palP->_b * lum) >> 6; } - if (Mono) { - destP = NewColors; + if (_mono) { + destP = _newColors; for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { // Form a greyscalce colour from 30% R, 59% G, 11% B uint8 intensity = (destP->_r * 77) + (destP->_g * 151) + (destP->_b * 28); @@ -1100,77 +1100,77 @@ void VGA::SetColors(Dac *tab, int lum) { } } - SetPal = true; + _setPal = true; } -void VGA::SetColors(void) { - memset(NewColors, 0, PAL_SIZ); - UpdateColors(); +void Vga::setColors(void) { + memset(_newColors, 0, PAL_SIZ); + updateColors(); } -void VGA::Sunrise(Dac *tab) { +void Vga::sunrise(Dac *tab) { for (int i = 0; i <= 64; i += FADE_STEP) { - SetColors(tab, i); - WaitVR(true); - UpdateColors(); + setColors(tab, i); + waitVR(true); + updateColors(); } } -void VGA::Sunset(void) { +void Vga::sunset() { Dac tab[256]; - GetColors(tab); + getColors(tab); for (int i = 64; i >= 0; i -= FADE_STEP) { - SetColors(tab, i); - WaitVR(true); - UpdateColors(); + setColors(tab, i); + waitVR(true); + updateColors(); } } -void VGA::Show(void) { +void Vga::show() { Sprite *spr = _showQ->first(); for (spr = _showQ->first(); spr; spr = spr->_next) spr->show(); - Update(); + update(); for (spr = _showQ->first(); spr; spr = spr->_next) spr->hide(); - ++ FrmCnt; + _frmCnt++; } -void VGA::UpdateColors(void) { +void Vga::updateColors() { byte palData[PAL_SIZ]; - DAC2pal(NewColors, palData); + dacToPal(_newColors, palData); g_system->getPaletteManager()->setPalette(palData, 0, 256); } -void VGA::Update(void) { - SWAP(VGA::Page[0], VGA::Page[1]); +void Vga::update() { + SWAP(Vga::_page[0], Vga::_page[1]); - if (SetPal) { - UpdateColors(); - SetPal = false; + if (_setPal) { + updateColors(); + _setPal = false; } - g_system->copyRectToScreen((const byte *)VGA::Page[0]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); + g_system->copyRectToScreen((const byte *)Vga::_page[0]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); g_system->updateScreen(); } -void VGA::Clear(uint8 color) { +void Vga::clear(uint8 color) { for (int paneNum = 0; paneNum < 4; ++paneNum) - Page[paneNum]->fillRect(Common::Rect(0, 0, SCR_WID, SCR_HIG), color); + _page[paneNum]->fillRect(Common::Rect(0, 0, SCR_WID, SCR_HIG), color); } -void VGA::CopyPage(uint16 d, uint16 s) { - Page[d]->copyFrom(*Page[s]); +void Vga::copyPage(uint16 d, uint16 s) { + _page[d]->copyFrom(*_page[s]); } //-------------------------------------------------------------------------- @@ -1259,13 +1259,13 @@ void Bitmap::xShow(int x, int y) { void Bitmap::show(int x, int y) { const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)VGA::Page[1]->pixels + (SCR_WID * SCR_HIG); + byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { - byte *destP = (byte *)VGA::Page[1]->getBasePtr(x + planeCtr, y); + byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -1321,8 +1321,8 @@ void Bitmap::show(int x, int y) { void Bitmap::hide(int x, int y) { for (int yp = y; yp < y + _h; ++yp) { - const byte *srcP = (const byte *)VGA::Page[2]->getBasePtr(x, yp); - byte *destP = (byte *)VGA::Page[1]->getBasePtr(x, yp); + const byte *srcP = (const byte *)Vga::_page[2]->getBasePtr(x, yp); + byte *destP = (byte *)Vga::_page[1]->getBasePtr(x, yp); Common::copy(srcP, srcP + _w, destP); } -- cgit v1.2.3 From fe0ff3b2e98b8a0ec68f497925aefbdea77aeed0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Jul 2011 20:26:34 +1000 Subject: CGE: Converted loadGame to use the ScummVM serialiser --- engines/cge/vga13h.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index aa7cd8ad06..1aec1689bc 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -779,6 +779,30 @@ BMP_PTR Sprite::ghost() { return NULL; } +void Sprite::sync(Common::Serializer &s) { + uint16 unused; + + s.syncAsUint16LE(unused); + s.syncAsUint16LE(unused); // _ext + s.syncAsUint16LE(_ref); + s.syncAsByte(_cave); + s.syncBytes((byte *)&_flags, 2); + s.syncAsUint16LE(_x); + s.syncAsUint16LE(_y); + s.syncAsByte(_z); + s.syncAsUint16LE(_w); + s.syncAsUint16LE(_h); + s.syncAsUint16LE(_time); + s.syncAsByte(_nearPtr); + s.syncAsByte(_takePtr); + s.syncAsUint16LE(_seqPtr); + s.syncAsUint16LE(_shpCnt); + s.syncBytes((byte *)&_file[0], 9); + _file[8] = '\0'; + + s.syncAsUint16LE(unused); // _prev + s.syncAsUint16LE(unused); // _next +} Sprite *spriteAt(int x, int y) { Sprite *spr = NULL, * tail = _vga->_showQ->last(); -- cgit v1.2.3 From 24fa551a71453dd712b5cb0223b2ff85026a2894 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Jul 2011 21:11:59 +1000 Subject: CGE: Fix synchronising Sprite::_seqPtr to be a signed int16 --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 1aec1689bc..c349950bee 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -795,7 +795,7 @@ void Sprite::sync(Common::Serializer &s) { s.syncAsUint16LE(_time); s.syncAsByte(_nearPtr); s.syncAsByte(_takePtr); - s.syncAsUint16LE(_seqPtr); + s.syncAsSint16LE(_seqPtr); s.syncAsUint16LE(_shpCnt); s.syncBytes((byte *)&_file[0], 9); _file[8] = '\0'; -- cgit v1.2.3 From 2997db0040d4c4e7ead02f37d8e7bd2c0ce6b206 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Jul 2011 22:06:26 +1000 Subject: CGE: Minor bugfixes for game loading --- engines/cge/vga13h.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index c349950bee..6c20a78cae 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -349,6 +349,14 @@ Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(_file, 0, sizeof(_file)); *((uint16 *)&_flags) = 0; + _ref = 0; + _x = _y = 0; + _w = _h = 0; + _time = 0; + _seqPtr = 0; + _shpCnt = 0; + _prev = _next = NULL; + setShapeList(shpP); } -- cgit v1.2.3 From c86c62b288dd3c8a1a630864142f99b177e4db3a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jul 2011 23:13:12 +0200 Subject: CGE: Cleanup and renaming. Also move some static and global functions to CGEEngine. --- engines/cge/vga13h.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6c20a78cae..36ac060111 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -63,7 +63,7 @@ bool SpeedTest = false; Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; -extern "C" void SNDMIDIPlay(void); +extern "C" void SNDMIDIPlay(); /* static void Video() { @@ -87,7 +87,7 @@ static void Video() { */ -uint16 *SaveScreen(void) { +uint16 *SaveScreen() { /* uint16 cxy, cur, siz, * scr = NULL, * sav; @@ -201,7 +201,7 @@ Sprite *locate(int ref) { } -Heart::Heart(void) +Heart::Heart() : Engine_(TMR_DIV) { _enable = false; _xTimer = NULL; @@ -427,7 +427,7 @@ bool Sprite::works(Sprite *spr) { if (c != NULL) { c += spr->_takePtr; if (c->_ref == _ref) - if (c->_com != SNLABEL || (c->_val == 0 || c->_val == _now)) + if (c->_com != SNLABEL || (c->_val == 0 || c->_val == _vm->_now)) return true; } } @@ -1136,7 +1136,7 @@ void Vga::setColors(Dac *tab, int lum) { } -void Vga::setColors(void) { +void Vga::setColors() { memset(_newColors, 0, PAL_SIZ); updateColors(); } -- cgit v1.2.3 From 080d7cf7f082b5faa245da965211a099ed37fd2b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 8 Jul 2011 08:21:35 +0200 Subject: CGE: Rename Mouse class --- engines/cge/vga13h.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 36ac060111..e1309c96f0 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -234,14 +234,14 @@ extern "C" void TimerProc() { if (Sys) { if (Sys->Time) { if (--Sys->Time == 0) - Sys->Tick(); + Sys->tick(); } } for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { if (spr->Time) { if (!spr->_flags.Hide) { if (-- spr->Time == 0) - spr->Tick(); + spr->tick(); } } } @@ -308,7 +308,7 @@ void Engine_::newTimer(...) { if (Sys) { if (Sys->Time) { if (--Sys->Time == 0) - Sys->Tick(); + Sys->tick(); } } @@ -316,7 +316,7 @@ void Engine_::newTimer(...) { if (spr->Time) { if (!spr->_flags.Hide) { if (--spr->Time == 0) - spr->Tick(); + spr->tick(); } } } -- cgit v1.2.3 From 817a52ed56abc172b158d794501f2bff0ab70e94 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 09:57:19 +1000 Subject: CGE: Created a HorizLine stub class to hold the HL sprite array --- engines/cge/vga13h.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e1309c96f0..fb1c89ef5e 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1360,4 +1360,15 @@ void Bitmap::hide(int x, int y) { } } +/*--------------------------------------------------------------------------*/ + +HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { + // Set the sprite list + BMP_PTR *HL = new BMP_PTR[2]; + HL[0] = new Bitmap("HLINE", true); + HL[1] = NULL; + + setShapeList(HL); +} + } // End of namespace CGE -- cgit v1.2.3 From 622dc2d503c247e750d82fb9dea885bcf14881ed Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 10:04:41 +1000 Subject: CGE: Created a CavLight class to encapsulate the PR sprite array --- engines/cge/vga13h.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index fb1c89ef5e..1f12dd8aa9 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1371,4 +1371,13 @@ HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { setShapeList(HL); } +CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { + // Set the sprite list + BMP_PTR *PR = new BMP_PTR[2]; + PR[0] = new Bitmap("PRESS", true); + PR[1] = NULL; + + setShapeList(PR); +} + } // End of namespace CGE -- cgit v1.2.3 From 47b17cd1cec22dfaafe80ce23805587d3a6e4821 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 10:07:35 +1000 Subject: CGE: Create Spike class to encapsulate the SP spite array --- engines/cge/vga13h.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 1f12dd8aa9..ce4465a416 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1380,4 +1380,14 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { setShapeList(PR); } +Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { + // Set the sprite list + BMP_PTR *SP = new BMP_PTR[2]; + SP[0] = new Bitmap("SPK_L", true); + SP[1] = new Bitmap("SPK_R", true); + SP[2] = NULL; + + setShapeList(SP); +} + } // End of namespace CGE -- cgit v1.2.3 From 0bbefbef901e5bf5686f6fe0b49ebbdc9f89a3df Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 10:10:51 +1000 Subject: CGE: Created PocLight class to encapsulate the LI sprite array --- engines/cge/vga13h.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ce4465a416..ed87da1c82 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1390,4 +1390,16 @@ Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { setShapeList(SP); } +PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { + // Set the sprite list + BMP_PTR *LI = new BMP_PTR[5]; + LI[0] = new Bitmap("LITE0", true); + LI[1] = new Bitmap("LITE1", true); + LI[2] = new Bitmap("LITE2", true); + LI[3] = new Bitmap("LITE3", true); + LI[4] = NULL; + + setShapeList(LI); +} + } // End of namespace CGE -- cgit v1.2.3 From 319ff2ca4911a68b7d21246699c31ca26b8e59a2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 10:11:50 +1000 Subject: CGE: Changed Sprite::contract to always destroy the sprite array --- engines/cge/vga13h.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ed87da1c82..2530bf970a 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -620,8 +620,7 @@ Sprite *Sprite::contract() { int i; for (i = 0; e->_shpList[i]; i++) delete e->_shpList[i]; - if (memType(e->_shpList) == NEAR_MEM) - delete[] e->_shpList; + delete[] e->_shpList; } if (memType(e->_seq) == NEAR_MEM) free(e->_seq); -- cgit v1.2.3 From 1870f09d3131ea6b9e2646343e5191cda614b49b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 14:51:22 +1000 Subject: CGE: Fix several allocation mismatches and Valgrind issues --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 2530bf970a..6e0493695a 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -619,7 +619,7 @@ Sprite *Sprite::contract() { if (_flags._bDel && e->_shpList) { int i; for (i = 0; e->_shpList[i]; i++) - delete e->_shpList[i]; + delete e->_shpList[i]; delete[] e->_shpList; } if (memType(e->_seq) == NEAR_MEM) -- cgit v1.2.3 From 88c7b25e5b0cdf8bb0709f0f7e728f637e72b33c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 17:56:29 +1000 Subject: CGE: Fixed more free/delete[] mismatches identified by Valgrind --- engines/cge/vga13h.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6e0493695a..73a753b600 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -356,12 +356,14 @@ Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) _seqPtr = 0; _shpCnt = 0; _prev = _next = NULL; - +static int ctr = 1; +debug("create %d %x", ctr++, this); setShapeList(shpP); } Sprite::~Sprite() { +debug("destroy %x", this); if (_sprite == this) _sprite = NULL; contract(); @@ -775,7 +777,7 @@ BMP_PTR Sprite::ghost() { error("No core"); bmp->_w = e->_b1->_w; bmp->_h = e->_b1->_h; - if ((bmp->_b = farnew(HideDesc, bmp->_h)) == NULL) + if ((bmp->_b = new HideDesc[bmp->_h]) == NULL) error("No Core"); bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment @@ -903,8 +905,18 @@ void Queue::insert(Sprite *spr) { spr->contract(); } +template +inline bool contains(const Common::List &l, const T &v) { + return (Common::find(l.begin(), l.end(), v) != l.end()); +} +Common::List l; Sprite *Queue::remove(Sprite *spr) { + if (contains(l, spr)) { + debug("N"); + } + l.push_back(spr); + if (spr == _head) _head = spr->_next; if (spr == _tail) -- cgit v1.2.3 From 32c8962d62162e79f5c27fbf2b5bbc843be4ad92 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 17:58:39 +1000 Subject: CGE: Removed some accidentally added debugging statements --- engines/cge/vga13h.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 73a753b600..526faed566 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -356,14 +356,12 @@ Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) _seqPtr = 0; _shpCnt = 0; _prev = _next = NULL; -static int ctr = 1; -debug("create %d %x", ctr++, this); + setShapeList(shpP); } Sprite::~Sprite() { -debug("destroy %x", this); if (_sprite == this) _sprite = NULL; contract(); -- cgit v1.2.3 From 66c7777dfedd4ec7a251b4a47e9b581a3e7570d4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 18:17:40 +1000 Subject: CGE: Fix Valgrind identified errors --- engines/cge/vga13h.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 526faed566..9498b04e8c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -362,8 +362,6 @@ Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) Sprite::~Sprite() { - if (_sprite == this) - _sprite = NULL; contract(); } @@ -405,6 +403,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { } expand(); _ext->_shpList = shpP; + _flags._bDel = true; if (!_ext->_seq) setSeq((_shpCnt < 2) ? _seq1 : _seq2); } @@ -907,14 +906,8 @@ template inline bool contains(const Common::List &l, const T &v) { return (Common::find(l.begin(), l.end(), v) != l.end()); } -Common::List l; Sprite *Queue::remove(Sprite *spr) { - if (contains(l, spr)) { - debug("N"); - } - l.push_back(spr); - if (spr == _head) _head = spr->_next; if (spr == _tail) -- cgit v1.2.3 From f33ac85e795a0f5abba29bcca365315f3b343310 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jul 2011 20:07:45 +1000 Subject: CGE: Bugfixes for some crashes --- engines/cge/vga13h.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 9498b04e8c..d92b9e97f0 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1402,6 +1402,8 @@ PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { LI[4] = NULL; setShapeList(LI); + + _flags._kill = false; } } // End of namespace CGE -- cgit v1.2.3 From 18077762d738178795c99d38010052b95cb1cef5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jul 2011 20:37:37 +1000 Subject: CGE: Standardised Sprite::seq on always allocating/freeing data --- engines/cge/vga13h.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d92b9e97f0..ff21f5cce8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -60,8 +60,6 @@ static VgaRegBlk VideoMode[] = { }; bool SpeedTest = false; -Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; -Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; extern "C" void SNDMIDIPlay(); @@ -383,6 +381,23 @@ BMP_PTR Sprite::shp() { return NULL; } +Seq *Sprite::getConstantSeq(bool seqFlag) { + Seq seq1[] = { { 0, 0, 0, 0, 0 } }; + Seq seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; + + // Make a copy of the given seq list and return it + Seq *seq; + if (seqFlag) { + seq = (Seq *)malloc(sizeof(Seq)); + seq[0] = seq1[0]; + } else { + seq = (Seq *)malloc(2 * sizeof(Seq)); + seq[0] = seq2[0]; + seq[1] = seq2[1]; + } + + return seq; +} BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; @@ -405,7 +420,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { _ext->_shpList = shpP; _flags._bDel = true; if (!_ext->_seq) - setSeq((_shpCnt < 2) ? _seq1 : _seq2); + setSeq(getConstantSeq(_shpCnt < 2)); } return r; } @@ -590,7 +605,7 @@ Sprite *Sprite::expand() { error("Bad JUMP in SEQ [%s]", fname); setSeq(seq); } else - setSeq((_shpCnt == 1) ? _seq1 : _seq2); + setSeq(getConstantSeq(_shpCnt == 1)); //disable(); // disable interupt setShapeList(shplist); @@ -621,8 +636,8 @@ Sprite *Sprite::contract() { delete e->_shpList[i]; delete[] e->_shpList; } - if (memType(e->_seq) == NEAR_MEM) - free(e->_seq); + free(e->_seq); + if (e->_near) free(e->_near); if (e->_take) @@ -1384,7 +1399,7 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *SP = new BMP_PTR[2]; + BMP_PTR *SP = new BMP_PTR[3]; SP[0] = new Bitmap("SPK_L", true); SP[1] = new Bitmap("SPK_R", true); SP[2] = NULL; -- cgit v1.2.3 From 9ba5e2b304e6ba7ca9d0b782ad8e5dfd98317b02 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jul 2011 20:56:32 +1000 Subject: CGE: Reverted last commit due to extra memory leaks --- engines/cge/vga13h.cpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ff21f5cce8..d92b9e97f0 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -60,6 +60,8 @@ static VgaRegBlk VideoMode[] = { }; bool SpeedTest = false; +Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; +Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; extern "C" void SNDMIDIPlay(); @@ -381,23 +383,6 @@ BMP_PTR Sprite::shp() { return NULL; } -Seq *Sprite::getConstantSeq(bool seqFlag) { - Seq seq1[] = { { 0, 0, 0, 0, 0 } }; - Seq seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; - - // Make a copy of the given seq list and return it - Seq *seq; - if (seqFlag) { - seq = (Seq *)malloc(sizeof(Seq)); - seq[0] = seq1[0]; - } else { - seq = (Seq *)malloc(2 * sizeof(Seq)); - seq[0] = seq2[0]; - seq[1] = seq2[1]; - } - - return seq; -} BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; @@ -420,7 +405,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { _ext->_shpList = shpP; _flags._bDel = true; if (!_ext->_seq) - setSeq(getConstantSeq(_shpCnt < 2)); + setSeq((_shpCnt < 2) ? _seq1 : _seq2); } return r; } @@ -605,7 +590,7 @@ Sprite *Sprite::expand() { error("Bad JUMP in SEQ [%s]", fname); setSeq(seq); } else - setSeq(getConstantSeq(_shpCnt == 1)); + setSeq((_shpCnt == 1) ? _seq1 : _seq2); //disable(); // disable interupt setShapeList(shplist); @@ -636,8 +621,8 @@ Sprite *Sprite::contract() { delete e->_shpList[i]; delete[] e->_shpList; } - free(e->_seq); - + if (memType(e->_seq) == NEAR_MEM) + free(e->_seq); if (e->_near) free(e->_near); if (e->_take) @@ -1399,7 +1384,7 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *SP = new BMP_PTR[3]; + BMP_PTR *SP = new BMP_PTR[2]; SP[0] = new Bitmap("SPK_L", true); SP[1] = new Bitmap("SPK_R", true); SP[2] = NULL; -- cgit v1.2.3 From dab96401ad352512a8ffa8c1d7baeb431ade7b8c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Jul 2011 07:24:20 +0200 Subject: CGE: Implement snGhost by splitting _m field in two. Some cleanup. --- engines/cge/vga13h.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d92b9e97f0..e85e13d20c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -683,18 +683,9 @@ void Sprite::killXlat() { if (_flags._xlat && _ext) { BMP_PTR *b; uint8 *m = (*_ext->_shpList)->_m; - - switch (memType(m)) { - case NEAR_MEM : - delete[](uint8 *) m; - break; - case FAR_MEM : + if (m) free(m); - break; - default: - warning("Unhandled MemType in Sprite::KillXlat()"); - break; - } + for (b = _ext->_shpList; *b; b++) (*b)->_m = NULL; _flags._xlat = false; @@ -777,9 +768,7 @@ BMP_PTR Sprite::ghost() { if ((bmp->_b = new HideDesc[bmp->_h]) == NULL) error("No Core"); bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); - // TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment - //bmp->_m = (uint8 *) MK_FP(e->y1, e->x1); - warning("FIXME: SPRITE::Ghost"); + bmp->_map = (e->_y1 << 16) + e->_x1; return bmp; } return NULL; @@ -1209,7 +1198,7 @@ void Vga::copyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- -void Bitmap::xShow(int x, int y) { +void Bitmap::xShow(int16 x, int16 y) { /* uint8 rmsk = x % 4, mask = 1 << rmsk, @@ -1291,7 +1280,7 @@ void Bitmap::xShow(int x, int y) { } -void Bitmap::show(int x, int y) { +void Bitmap::show(int16 x, int16 y) { const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); @@ -1353,8 +1342,8 @@ void Bitmap::show(int x, int y) { } -void Bitmap::hide(int x, int y) { - for (int yp = y; yp < y + _h; ++yp) { +void Bitmap::hide(int16 x, int16 y) { + for (int yp = y; yp < y + _h; yp++) { const byte *srcP = (const byte *)Vga::_page[2]->getBasePtr(x, yp); byte *destP = (byte *)Vga::_page[1]->getBasePtr(x, yp); -- cgit v1.2.3 From a524adcaee89678ba99b294fcbc5efdf9e137c04 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Jul 2011 08:02:18 +0200 Subject: CGE: Suppress isVga() and memType() --- engines/cge/vga13h.cpp | 65 ++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 37 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e85e13d20c..4d8b5bf628 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -621,12 +621,9 @@ Sprite *Sprite::contract() { delete e->_shpList[i]; delete[] e->_shpList; } - if (memType(e->_seq) == NEAR_MEM) - free(e->_seq); - if (e->_near) - free(e->_near); - if (e->_take) - free(e->_take); +// free(e->_seq); + free(e->_near); + free(e->_take); delete e; _ext = NULL; } @@ -683,8 +680,7 @@ void Sprite::killXlat() { if (_flags._xlat && _ext) { BMP_PTR *b; uint8 *m = (*_ext->_shpList)->_m; - if (m) - free(m); + free(m); for (b = _ext->_shpList; *b; b++) (*b)->_m = NULL; @@ -967,42 +963,37 @@ Vga::Vga(int mode) setStatAdr(); if (_statAdr != VGAST1_) _mono++; - if (isVga()) { - _oldColors = farnew(Dac, 256); - _newColors = farnew(Dac, 256); - _oldScreen = SaveScreen(); - getColors(_oldColors); - sunset(); - _oldMode = setMode(mode); - setColors(); - setup(VideoMode); - clear(0); - } + _oldColors = farnew(Dac, 256); + _newColors = farnew(Dac, 256); + _oldScreen = SaveScreen(); + getColors(_oldColors); + sunset(); + _oldMode = setMode(mode); + setColors(); + setup(VideoMode); + clear(0); } Vga::~Vga() { _mono = 0; - if (isVga()) { - Common::String buffer = ""; + + Common::String buffer = ""; /* - clear(0); - setMode(_oldMode); - setColors(); - restoreScreen(_oldScreen); - sunrise(_oldColors); + clear(0); + setMode(_oldMode); + setColors(); + restoreScreen(_oldScreen); + sunrise(_oldColors); */ - if (_oldColors) - free(_oldColors); - if (_newColors) - free(_newColors); - if (_msg) - buffer = Common::String(_msg); - if (_nam) - buffer = buffer + " [" + _nam + "]"; - - debugN("%s", buffer.c_str()); - } + free(_oldColors); + free(_newColors); + if (_msg) + buffer = Common::String(_msg); + if (_nam) + buffer = buffer + " [" + _nam + "]"; + + debugN("%s", buffer.c_str()); delete _showQ; delete _spareQ; -- cgit v1.2.3 From daae033e0156f19b3bdbb46aa7b0785c40f1e094 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Jul 2011 21:16:23 +1000 Subject: CGE: Converted SprExt::_Seq to use dynamically allocated data --- engines/cge/vga13h.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 4d8b5bf628..2cdca0004f 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -60,8 +60,24 @@ static VgaRegBlk VideoMode[] = { }; bool SpeedTest = false; -Seq _seq1[] = { { 0, 0, 0, 0, 0 } }; -Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; + +Seq *getConstantSeq(bool seqFlag) { + const Seq seq1[] = { { 0, 0, 0, 0, 0 } }; + const Seq seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; + + Seq *seq; + if (seqFlag) { + seq = (Seq *)malloc(1 * sizeof(Seq)); + *seq = seq1[0]; + } else { + seq = (Seq *)malloc(2 * sizeof(Seq)); + seq[0] = seq2[0]; + seq[1] = seq2[1]; + } + + return seq; +} + extern "C" void SNDMIDIPlay(); @@ -405,7 +421,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { _ext->_shpList = shpP; _flags._bDel = true; if (!_ext->_seq) - setSeq((_shpCnt < 2) ? _seq1 : _seq2); + setSeq(getConstantSeq(_shpCnt < 2)); } return r; } @@ -590,7 +606,7 @@ Sprite *Sprite::expand() { error("Bad JUMP in SEQ [%s]", fname); setSeq(seq); } else - setSeq((_shpCnt == 1) ? _seq1 : _seq2); + setSeq(getConstantSeq(_shpCnt == 1)); //disable(); // disable interupt setShapeList(shplist); @@ -621,9 +637,11 @@ Sprite *Sprite::contract() { delete e->_shpList[i]; delete[] e->_shpList; } -// free(e->_seq); + + free(e->_seq); free(e->_near); free(e->_take); + delete e; _ext = NULL; } -- cgit v1.2.3 From b6be90326d31030ac364edeb8538aecaef51e378 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Jul 2011 21:41:11 +1000 Subject: CGE: Fixed a memory leak with Sprite::setSeq --- engines/cge/vga13h.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 2cdca0004f..96642b4540 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -451,6 +451,11 @@ bool Sprite::works(Sprite *spr) { Seq *Sprite::setSeq(Seq *seq) { + if (_ext) { + free(_ext->_seq); + _ext->_seq = NULL; + } + expand(); register Seq *s = _ext->_seq; _ext->_seq = seq; -- cgit v1.2.3 From 11c9e64885faed3c3d7ba5888e3f129548f789e8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Jul 2011 22:02:00 +1000 Subject: CGE: More bugfixes for memory leaks --- engines/cge/vga13h.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 96642b4540..5bdb50fa9e 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -612,10 +612,9 @@ Sprite *Sprite::expand() { setSeq(seq); } else setSeq(getConstantSeq(_shpCnt == 1)); - //disable(); // disable interupt setShapeList(shplist); - //enable(); // enable interupt + if (nea) nea[neacnt - 1]._ptr = _ext->_near = nea; else -- cgit v1.2.3 From 4d0f83babb923527c67157204ba0b8b678b6732a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 13 Jul 2011 08:44:58 +0200 Subject: CGE: Rename some constants --- engines/cge/vga13h.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 5bdb50fa9e..d0e267ef38 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -476,10 +476,10 @@ bool Sprite::seqTest(int n) { } -Snail::Com *Sprite::snList(SNLIST type) { +Snail::Com *Sprite::snList(SnList type) { register SprExt *e = _ext; if (e) - return (type == NEAR) ? e->_near : e->_take; + return (type == kNear) ? e->_near : e->_take; return NULL; } -- cgit v1.2.3 From 6c9719009223947572c8e81fdefe9e4cd17f717f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Jul 2011 19:18:23 +1000 Subject: CGE: Fixed initialising of _shadow that was crashing the intro sequence --- engines/cge/vga13h.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d0e267ef38..c36d747295 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -880,6 +880,7 @@ void Queue::insert(Sprite *spr, Sprite *nxt) { if (!_tail) _tail = spr; } else { + assert(nxt); spr->_next = nxt; spr->_prev = nxt->_prev; if (spr->_prev) -- cgit v1.2.3 From 9dc2cb87d98c801a773659af37dd1b84d73f4888 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Jul 2011 19:21:34 +1000 Subject: CGE: Fix array size in Spike class constructor --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index c36d747295..eab50660dd 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1387,7 +1387,7 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *SP = new BMP_PTR[2]; + BMP_PTR *SP = new BMP_PTR[3]; SP[0] = new Bitmap("SPK_L", true); SP[1] = new Bitmap("SPK_R", true); SP[2] = NULL; -- cgit v1.2.3 From c3c8032c42958f73ef4370fb0476fd0f5a7e30dd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Jul 2011 20:42:30 +1000 Subject: CGE: Implemented Bitmap::xShow method --- engines/cge/vga13h.cpp | 125 +++++++++++++++++++------------------------------ 1 file changed, 47 insertions(+), 78 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index eab50660dd..ec616a2551 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1213,84 +1213,53 @@ void Vga::copyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- void Bitmap::xShow(int16 x, int16 y) { - /* - uint8 rmsk = x % 4, - mask = 1 << rmsk, - *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4; - uint8 *m = (char *) M; - uint8 *v = V; - - asm push bx - asm push si - asm push ds - - asm cld - asm les di,scr - asm lds si,v - asm mov bx,m - - asm mov al,0x02 // map mask register - asm mov ah,mask - - plane: - // enable output plane - asm mov dx,VGASEQ_ - asm out dx,ax - asm push ax - - // select input plane - asm mov dx,VGAGRA_ - asm mov al,0x04 // read map select register - asm mov ah,rmsk - asm out dx,ax - - asm push di - - block: - asm lodsw - asm mov cx,ax - asm and ch,0x3F - asm test ah,0xC0 - asm jz endpl - asm jns skip - asm jnp incsi // replicate? - asm add si,cx // skip over data block - asm dec si // fix it before following inc - - incsi: - asm inc si - tint: - asm mov al,es:[di] - //----------------------------------------------- - // asm xlat ss:0 // unsupported with BASM! - __emit__(0x36, 0xD7); // this stands for above! - //----------------------------------------------- - asm stosb - asm loop tint - asm jmp block - - skip: - asm add di,cx - asm jmp block - - endpl: - asm pop di - asm pop ax - asm inc rmsk - asm shl ah,1 - asm test ah,0x10 - asm jz x_chk - asm mov ah,0x01 - asm mov rmsk,0 - asm inc di - x_chk: - asm cmp ah,mask - asm jne plane - asm pop ds - asm pop si - asm pop bx - */ - warning("STUB: BITMAP::xShow"); + const byte *srcP = (const byte *)_v; + byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); + byte *lookupTable = _m; + + // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a + // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data + // must be decompressed and inserted into the surface + for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { + byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); + + for (;;) { + uint16 v = READ_LE_UINT16(srcP); + srcP += 2; + int cmd = v >> 14; + int count = v & 0x3FFF; + + if (cmd == 0) { + // End of image + break; + } + + assert(destP < destEndP); + + if (cmd == 2) + ++srcP; + else if (cmd == 3) + srcP += count; + + // Handle a set of pixels + while (count-- > 0) { + // Transfer operation + switch (cmd) { + case 1: + // SKIP + break; + case 2: + case 3: + // TINT + *destP = lookupTable[*destP]; + break; + } + + // Move to next dest position + destP += 4; + } + } + } } -- cgit v1.2.3 From c3f3120194151cdeb31d9b3622c76cd4e5b7ed6a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jul 2011 15:17:18 +1000 Subject: CGE: Cleaned up room preview handling code and fixed memory leak --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ec616a2551..716a6b584d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1378,4 +1378,4 @@ PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { _flags._kill = false; } -} // End of namespace CGE +} // End of namespace CGE \ No newline at end of file -- cgit v1.2.3 From 50d313a547ae1bec050be8d6b64ccc01161da22f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jul 2011 15:44:17 +1000 Subject: CGE: Implement monochrome view mode button --- engines/cge/vga13h.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 716a6b584d..a7b9d8c080 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1128,9 +1128,9 @@ void Vga::setColors(Dac *tab, int lum) { if (_mono) { destP = _newColors; - for (int idx = 0; idx < PAL_CNT; ++idx, ++palP) { + for (int idx = 0; idx < PAL_CNT; ++idx, ++destP) { // Form a greyscalce colour from 30% R, 59% G, 11% B - uint8 intensity = (destP->_r * 77) + (destP->_g * 151) + (destP->_b * 28); + uint8 intensity = (((int)destP->_r * 77) + ((int)destP->_g * 151) + ((int)destP->_b * 28)) >> 8; destP->_r = intensity; destP->_g = intensity; destP->_b = intensity; -- cgit v1.2.3 From 8aa4f739af014303cc6a0fb90f13c22a1f77d33f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jul 2011 18:05:57 +0200 Subject: CGE: Add debug channels (WIP) --- engines/cge/vga13h.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index a7b9d8c080..ca6a9e3bdd 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1213,6 +1213,8 @@ void Vga::copyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- void Bitmap::xShow(int16 x, int16 y) { + debugC(4, kDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); + const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); byte *lookupTable = _m; @@ -1264,6 +1266,8 @@ void Bitmap::xShow(int16 x, int16 y) { void Bitmap::show(int16 x, int16 y) { + debugC(5, kDebugBitmap, "Bitmap::show(%d, %d)", x, y); + const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); @@ -1326,6 +1330,8 @@ void Bitmap::show(int16 x, int16 y) { void Bitmap::hide(int16 x, int16 y) { + debugC(5, kDebugBitmap, "Bitmap::hide(%d, %d)", x, y); + for (int yp = y; yp < y + _h; yp++) { const byte *srcP = (const byte *)Vga::_page[2]->getBasePtr(x, yp); byte *destP = (byte *)Vga::_page[1]->getBasePtr(x, yp); @@ -1378,4 +1384,4 @@ PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { _flags._kill = false; } -} // End of namespace CGE \ No newline at end of file +} // End of namespace CGE -- cgit v1.2.3 From 9a148a27cc44ba089e57ea07996a868c89c2287f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Jul 2011 08:09:16 +0200 Subject: CGE: Remove macro farnew --- engines/cge/vga13h.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ca6a9e3bdd..6fc17dc37b 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -986,8 +986,8 @@ Vga::Vga(int mode) setStatAdr(); if (_statAdr != VGAST1_) _mono++; - _oldColors = farnew(Dac, 256); - _newColors = farnew(Dac, 256); + _oldColors = (Dac *) malloc(sizeof(Dac) * PAL_CNT); + _newColors = (Dac *) malloc(sizeof(Dac) * PAL_CNT); _oldScreen = SaveScreen(); getColors(_oldColors); sunset(); -- cgit v1.2.3 From 420516b45e1822c249775c68f9c61b62aba5de0b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Jul 2011 14:22:56 +0200 Subject: CGE: Rename Debug channel constants --- engines/cge/vga13h.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6fc17dc37b..6093681292 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -1213,7 +1213,7 @@ void Vga::copyPage(uint16 d, uint16 s) { //-------------------------------------------------------------------------- void Bitmap::xShow(int16 x, int16 y) { - debugC(4, kDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); + debugC(4, kCGEDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); @@ -1266,7 +1266,7 @@ void Bitmap::xShow(int16 x, int16 y) { void Bitmap::show(int16 x, int16 y) { - debugC(5, kDebugBitmap, "Bitmap::show(%d, %d)", x, y); + debugC(5, kCGEDebugBitmap, "Bitmap::show(%d, %d)", x, y); const byte *srcP = (const byte *)_v; byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); @@ -1330,7 +1330,7 @@ void Bitmap::show(int16 x, int16 y) { void Bitmap::hide(int16 x, int16 y) { - debugC(5, kDebugBitmap, "Bitmap::hide(%d, %d)", x, y); + debugC(5, kCGEDebugBitmap, "Bitmap::hide(%d, %d)", x, y); for (int yp = y; yp < y + _h; yp++) { const byte *srcP = (const byte *)Vga::_page[2]->getBasePtr(x, yp); -- cgit v1.2.3 From 5d41ab8b5fd778f206633157ffa87efc31f643cf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 21 Jul 2011 01:56:40 +0200 Subject: CGE: Rename some more constants, remove some useless ones --- engines/cge/vga13h.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6093681292..24c83f12ee 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -508,7 +508,7 @@ Sprite *Sprite::expand() { error("No core"); if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; - char line[LINE_MAX], fname[MAXPATH]; + char line[kLineMax], fname[kPathMax]; BMP_PTR *shplist = new BMP_PTR[_shpCnt + 1]; Seq *seq = NULL; int shpcnt = 0, @@ -713,18 +713,18 @@ void Sprite::killXlat() { void Sprite::gotoxy(int x, int y) { int xo = _x, yo = _y; - if (_x < SCR_WID) { + if (_x < kScrWidth) { if (x < 0) x = 0; - if (x + _w > SCR_WID) - x = (SCR_WID - _w); + if (x + _w > kScrWidth) + x = (kScrWidth - _w); _x = x; } - if (_h < SCR_HIG) { + if (_h < kScrHeight) { if (y < 0) y = 0; - if (y + _h > SCR_HIG) - y = (SCR_HIG - _h); + if (y + _h > kScrHeight) + y = (kScrHeight - _h); _y = y; } if (_next) @@ -736,7 +736,7 @@ void Sprite::gotoxy(int x, int y) { void Sprite::center() { - gotoxy((SCR_WID - _w) / 2, (SCR_HIG - _h) / 2); + gotoxy((kScrWidth - _w) / 2, (kScrHeight - _h) / 2); } @@ -1195,14 +1195,14 @@ void Vga::update() { _setPal = false; } - g_system->copyRectToScreen((const byte *)Vga::_page[0]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); + g_system->copyRectToScreen((const byte *)Vga::_page[0]->getBasePtr(0, 0), kScrWidth, 0, 0, kScrWidth, kScrHeight); g_system->updateScreen(); } void Vga::clear(uint8 color) { for (int paneNum = 0; paneNum < 4; ++paneNum) - _page[paneNum]->fillRect(Common::Rect(0, 0, SCR_WID, SCR_HIG), color); + _page[paneNum]->fillRect(Common::Rect(0, 0, kScrWidth, kScrHeight), color); } @@ -1216,7 +1216,7 @@ void Bitmap::xShow(int16 x, int16 y) { debugC(4, kCGEDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); + byte *destEndP = (byte *)Vga::_page[1]->pixels + (kScrWidth * kScrHeight); byte *lookupTable = _m; // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a @@ -1269,7 +1269,7 @@ void Bitmap::show(int16 x, int16 y) { debugC(5, kCGEDebugBitmap, "Bitmap::show(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG); + byte *destEndP = (byte *)Vga::_page[1]->pixels + (kScrWidth * kScrHeight); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data -- cgit v1.2.3 From c728a53148d436cfebb33d58a75f3146980a39e0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2011 14:31:39 +0200 Subject: CGE: Rename IOMode and SnCom enums --- engines/cge/vga13h.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 24c83f12ee..94a4963a5e 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -442,7 +442,7 @@ bool Sprite::works(Sprite *spr) { if (c != NULL) { c += spr->_takePtr; if (c->_ref == _ref) - if (c->_com != SNLABEL || (c->_val == 0 || c->_val == _vm->_now)) + if (c->_com != kSnLabel || (c->_val == 0 || c->_val == _vm->_now)) return true; } } @@ -573,7 +573,7 @@ Sprite *Sprite::expand() { error("No core [%s]", fname); else { Snail::Com *c = &nea[neacnt++]; - if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); @@ -589,7 +589,7 @@ Sprite *Sprite::expand() { error("No core [%s]", fname); else { Snail::Com *c = &tak[takcnt++]; - if ((c->_com = (SNCOM)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); -- cgit v1.2.3 From 82adc025ea451f1fce2c0e0eed03d6e48a51e152 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 24 Jul 2011 23:42:03 +0200 Subject: CGE: Remove DrvInfo, rename some enums --- engines/cge/vga13h.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 94a4963a5e..f5a3fdd22f 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -37,11 +37,6 @@ namespace CGE { -#define FADE_STEP 2 -#define TMR_DIV ((0x8000/TMR_RATE)*2) -#define NREP 9 -#define FREP 24 - static VgaRegBlk VideoMode[] = { { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 -- cgit v1.2.3 From cf619196484d7edc11dc6908ab81ebafcb65405f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2011 16:04:45 +0200 Subject: CGE: Replace 'no core' checks by asserts --- engines/cge/vga13h.cpp | 59 +++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 34 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index f5a3fdd22f..d08f9bc8e8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -486,10 +486,9 @@ void Sprite::setName(char *n) { _ext->_name = NULL; } if (n) { - if ((_ext->_name = new char[strlen(n) + 1]) != NULL) - strcpy(_ext->_name, n); - else - error("No core [%s]", n); + _ext->_name = new char[strlen(n) + 1]; + assert(_ext->_name != NULL); + strcpy(_ext->_name, n); } } } @@ -499,8 +498,8 @@ Sprite *Sprite::expand() { if (!_ext) { bool enbl = _heart->_enable; _heart->_enable = false; - if ((_ext = new SprExt) == NULL) - error("No core"); + _ext = new SprExt; + assert(_ext != NULL); if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[kLineMax], fname[kPathMax]; @@ -522,9 +521,9 @@ Sprite *Sprite::expand() { error("Bad SPR [%s]", fname); int len = 0, lcnt = 0; while ((len = sprf.read((uint8 *)line)) != 0) { - ++lcnt; + lcnt++; if (len && line[len - 1] == '\n') - line[-- len] = '\0'; + line[--len] = '\0'; if (len == 0 || *line == '.') continue; @@ -539,8 +538,7 @@ Sprite *Sprite::expand() { } case 2 : { // Seq seq = (Seq *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); - if (seq == NULL) - error("No core [%s]", fname); + assert(seq != NULL); Seq *s = &seq[seqcnt++]; s->_now = atoi(strtok(NULL, " \t,;/")); if (s->_now > maxnow) @@ -564,32 +562,26 @@ Sprite *Sprite::expand() { case 3 : { // Near if (_nearPtr != NO_PTR) { nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); - if (nea == NULL) - error("No core [%s]", fname); - else { - Snail::Com *c = &nea[neacnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) - error("Bad NEAR in %d [%s]", lcnt, fname); - c->_ref = atoi(strtok(NULL, " \t,;/")); - c->_val = atoi(strtok(NULL, " \t,;/")); - c->_ptr = NULL; - } + assert(nea != NULL); + Snail::Com *c = &nea[neacnt++]; + if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + error("Bad NEAR in %d [%s]", lcnt, fname); + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; } } break; case 4 : { // Take if (_takePtr != NO_PTR) { tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); - if (tak == NULL) - error("No core [%s]", fname); - else { - Snail::Com *c = &tak[takcnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) - error("Bad NEAR in %d [%s]", lcnt, fname); - c->_ref = atoi(strtok(NULL, " \t,;/")); - c->_val = atoi(strtok(NULL, " \t,;/")); - c->_ptr = NULL; - } + assert(tak != NULL); + Snail::Com *c = &tak[takcnt++]; + if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + error("Bad NEAR in %d [%s]", lcnt, fname); + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; } break; } @@ -774,12 +766,11 @@ BMP_PTR Sprite::ghost() { register SprExt *e = _ext; if (e->_b1) { BMP_PTR bmp = new Bitmap(0, 0, (uint8 *)NULL); - if (bmp == NULL) - error("No core"); + assert(bmp != NULL); bmp->_w = e->_b1->_w; bmp->_h = e->_b1->_h; - if ((bmp->_b = new HideDesc[bmp->_h]) == NULL) - error("No Core"); + bmp->_b = new HideDesc[bmp->_h]; + assert(bmp->_b != NULL); bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); bmp->_map = (e->_y1 << 16) + e->_x1; return bmp; -- cgit v1.2.3 From 7d5eb1ee639bf04e8f3b2ca280e631c3f67b1e9b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 28 Jul 2011 15:35:12 +0200 Subject: CGE: Janitorial: remove trailing spaces --- engines/cge/vga13h.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d08f9bc8e8..7e1d8f9962 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -228,7 +228,7 @@ extern "C" void TimerProc() { if (_heart->_xTimer) { if (*_heart->_xTimer) *_heart->_xTimer--; - else + else _heart->_xTimer = NULL; } @@ -324,9 +324,9 @@ void Engine_::newTimer(...) { } for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { - if (spr->Time) { + if (spr->Time) { if (!spr->_flags.Hide) { - if (--spr->Time == 0) + if (--spr->Time == 0) spr->tick(); } } @@ -949,7 +949,7 @@ void Vga::deinit() { } Vga::Vga(int mode) - : _frmCnt(0), _oldMode(0), _oldScreen(NULL), _statAdr(VGAST1_), + : _frmCnt(0), _oldMode(0), _oldScreen(NULL), _statAdr(VGAST1_), _msg(NULL), _nam(NULL), _setPal(false), _mono(0) { _oldColors = NULL; _newColors = NULL; @@ -1026,7 +1026,7 @@ void Vga::setStatAdr() { #pragma argsused void Vga::waitVR(bool on) { - // Since some of the game parts rely on using vertical sync as a delay mechanism, + // Since some of the game parts rely on using vertical sync as a delay mechanism, // we're introducing a short delay to simulate it g_system->delayMillis(10); } @@ -1244,7 +1244,7 @@ void Bitmap::xShow(int16 x, int16 y) { } // Move to next dest position - destP += 4; + destP += 4; } } } @@ -1294,7 +1294,7 @@ void Bitmap::show(int16 x, int16 y) { } // Move to next dest position - destP += 4; + destP += 4; } if (cmd == 2) @@ -1302,7 +1302,7 @@ void Bitmap::show(int16 x, int16 y) { } } /* - DEBUG code to display image immediately + DEBUG code to display image immediately // Temporary g_system->copyRectToScreen((const byte *)VGA::Page[1]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); byte palData[PAL_SIZ]; -- cgit v1.2.3 From 5c7eb9a7686e6c701af083072fa944d3fc2e88fd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 30 Jul 2011 12:52:04 +0200 Subject: CGE: un-static-fy several variables, clean Heart class --- engines/cge/vga13h.cpp | 140 +------------------------------------------------ 1 file changed, 1 insertion(+), 139 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 7e1d8f9962..6e14666bd9 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -212,148 +212,10 @@ Sprite *locate(int ref) { } -Heart::Heart() - : Engine_(TMR_DIV) { +Heart::Heart() { _enable = false; - _xTimer = NULL; } - -/* -extern "C" void TimerProc() { - static SPRITE * spr; - static uint8 run = 0; - - // decrement external timer uint16 - if (_heart->_xTimer) { - if (*_heart->_xTimer) - *_heart->_xTimer--; - else - _heart->_xTimer = NULL; - } - - if (!run && _heart->_enable) { // check overrun flag - static uint16 oldSP, oldSS; - run++; // disable 2nd call until current lasts - asm mov ax,ds - asm mov oldSS,ss - asm mov oldSP,sp - asm mov ss,ax - asm mov sp,0xFF80 - - // system pseudo-sprite - if (Sys) { - if (Sys->Time) { - if (--Sys->Time == 0) - Sys->tick(); - } - } - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { - if (spr->Time) { - if (!spr->_flags.Hide) { - if (-- spr->Time == 0) - spr->tick(); - } - } - } - asm mov ss,oldSS - asm mov sp,oldSP - run--; - } -} -*/ - - -void Engine_::newTimer(...) { - /* - static SPRITE *spr; - static uint8 run = 0, cntr1 = TMR_RATE1, cntr2 = TMR_RATE2; - ___1152_Hz___: - - SNDMIDIPlay(); - asm dec cntr1 - asm jz ___72_Hz___ - asm mov al,0x20 // send... - asm out 0x020,al // ...e-o-i - return; - - ___72_Hz___: - - asm mov cntr1,TMR_RATE1 - asm dec cntr2 - asm jnz my_eoi - - ___18_Hz___: - - OldTimer(); - asm mov cntr2,TMR_RATE2 - asm jmp short my_int - - // send E-O-I - my_eoi: - asm mov al,0x20 - asm out 0x020,al - asm sti // enable interrupts - - my_int: //------72Hz-------// - - // decrement external timer uint16 - if (_heart->XTimer) { - if (*_heart->XTimer) - *_heart->XTimer--; - else - _heart->XTimer = NULL; - } - - if (! run && _heart->Enable) { // check overrun flag - static uint16 oldSP, oldSS; - - run++; // disable 2nd call until current lasts - asm mov ax,ds - asm mov oldSS,ss - asm mov oldSP,sp - asm mov ss,ax - asm mov sp,0xFF80 - - // system pseudo-sprite - if (Sys) { - if (Sys->Time) { - if (--Sys->Time == 0) - Sys->tick(); - } - } - - for (spr = VGA::ShowQ.First(); spr; spr = spr->Next) { - if (spr->Time) { - if (!spr->_flags.Hide) { - if (--spr->Time == 0) - spr->tick(); - } - } - } - asm mov ss,oldSS - asm mov sp,oldSP - run--; - } - - */ - warning("STUB: Engine_::NewTimer"); -} - - -void Heart::setXTimer(uint16 *ptr) { - if (_xTimer && ptr != _xTimer) - *_xTimer = 0; - _xTimer = ptr; -} - - -void Heart::setXTimer(uint16 *ptr, uint16 time) { - setXTimer(ptr); - *ptr = time; -} - - Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), -- cgit v1.2.3 From 8b53899ca7d5ab1599f6bf3e1d4e49746876674b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 30 Jul 2011 15:28:57 +0200 Subject: CGE: Remove Heart --- engines/cge/vga13h.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6e14666bd9..9b30e02e4d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -211,11 +211,6 @@ Sprite *locate(int ref) { return (spr) ? spr : _vga->_spareQ->locate(ref); } - -Heart::Heart() { - _enable = false; -} - Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), @@ -358,8 +353,6 @@ void Sprite::setName(char *n) { Sprite *Sprite::expand() { if (!_ext) { - bool enbl = _heart->_enable; - _heart->_enable = false; _ext = new SprExt; assert(_ext != NULL); if (*_file) { @@ -473,7 +466,6 @@ Sprite *Sprite::expand() { else _takePtr = NO_PTR; } - _heart->_enable = enbl; } return this; } -- cgit v1.2.3 From 55df4d063596c774969a8d3537c999a95b7dfcc0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 31 Jul 2011 00:52:35 +0200 Subject: CGE: Rename some class members, various clean up --- engines/cge/vga13h.cpp | 96 ++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 49 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 9b30e02e4d..cc715da03c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -211,7 +211,7 @@ Sprite *locate(int ref) { return (spr) ? spr : _vga->_spareQ->locate(ref); } -Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP) +Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { @@ -234,7 +234,7 @@ Sprite::~Sprite() { } -BMP_PTR Sprite::shp() { +BitmapPtr Sprite::shp() { register SprExt *e = _ext; if (e) if (e->_seq) { @@ -252,17 +252,17 @@ BMP_PTR Sprite::shp() { } -BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { - BMP_PTR *r = (_ext) ? _ext->_shpList : NULL; +BitmapPtr *Sprite::setShapeList(BitmapPtr *shpP) { + BitmapPtr *r = (_ext) ? _ext->_shpList : NULL; _shpCnt = 0; _w = 0; _h = 0; if (shpP) { - BMP_PTR *p; + BitmapPtr *p; for (p = shpP; *p; p++) { - BMP_PTR b = (*p); // ->Code(); + BitmapPtr b = (*p); // ->Code(); if (b->_w > _w) _w = b->_w; if (b->_h > _h) @@ -280,7 +280,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) { void Sprite::moveShapes(uint8 *buf) { - BMP_PTR *p; + BitmapPtr *p; for (p = _ext->_shpList; *p; p++) { buf += (*p)->moveVmap(buf); } @@ -336,16 +336,16 @@ Snail::Com *Sprite::snList(SnList type) { } -void Sprite::setName(char *n) { +void Sprite::setName(char *name) { if (_ext) { if (_ext->_name) { delete[] _ext->_name; _ext->_name = NULL; } - if (n) { - _ext->_name = new char[strlen(n) + 1]; + if (name) { + _ext->_name = new char[strlen(name) + 1]; assert(_ext->_name != NULL); - strcpy(_ext->_name, n); + strcpy(_ext->_name, name); } } } @@ -358,7 +358,7 @@ Sprite *Sprite::expand() { if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[kLineMax], fname[kPathMax]; - BMP_PTR *shplist = new BMP_PTR[_shpCnt + 1]; + BitmapPtr *shplist = new BitmapPtr[_shpCnt + 1]; Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, @@ -419,7 +419,7 @@ Sprite *Sprite::expand() { nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); assert(nea != NULL); Snail::Com *c = &nea[neacnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); @@ -432,7 +432,7 @@ Sprite *Sprite::expand() { tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); assert(tak != NULL); Snail::Com *c = &tak[takcnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0) + if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); @@ -528,7 +528,7 @@ void Sprite::tick() { void Sprite::makeXlat(uint8 *x) { if (_ext) { - BMP_PTR *b; + BitmapPtr *b; if (_flags._xlat) killXlat(); @@ -541,7 +541,7 @@ void Sprite::makeXlat(uint8 *x) { void Sprite::killXlat() { if (_flags._xlat && _ext) { - BMP_PTR *b; + BitmapPtr *b; uint8 *m = (*_ext->_shpList)->_m; free(m); @@ -616,10 +616,10 @@ void Sprite::hide() { } -BMP_PTR Sprite::ghost() { +BitmapPtr Sprite::ghost() { register SprExt *e = _ext; if (e->_b1) { - BMP_PTR bmp = new Bitmap(0, 0, (uint8 *)NULL); + BitmapPtr bmp = new Bitmap(0, 0, (uint8 *)NULL); assert(bmp != NULL); bmp->_w = e->_b1->_w; bmp->_h = e->_b1->_h; @@ -785,37 +785,35 @@ Graphics::Surface *Vga::_page[4]; Dac *Vga::_sysPal; void Vga::init() { - for (int idx = 0; idx < 4; ++idx) { + for (int idx = 0; idx < 4; idx++) { _page[idx] = new Graphics::Surface(); _page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } - _sysPal = new Dac[PAL_CNT]; + _sysPal = new Dac[kPalCount]; } void Vga::deinit() { - for (int idx = 0; idx < 4; ++idx) { + for (int idx = 0; idx < 4; idx++) { _page[idx]->free(); delete _page[idx]; } - delete[] _sysPal; } Vga::Vga(int mode) : _frmCnt(0), _oldMode(0), _oldScreen(NULL), _statAdr(VGAST1_), - _msg(NULL), _nam(NULL), _setPal(false), _mono(0) { + _msg(NULL), _name(NULL), _setPal(false), _mono(0) { _oldColors = NULL; _newColors = NULL; _showQ = new Queue(true); _spareQ = new Queue(false); bool std = true; - int i; - for (i = 10; i < 20; i++) { - char *txt = _text->getText(i); - if (txt) { - debugN("%s", txt); + for (int i = 10; i < 20; i++) { + char *text = _text->getText(i); + if (text) { + debugN("%s", text); std = false; } } @@ -826,8 +824,8 @@ Vga::Vga(int mode) setStatAdr(); if (_statAdr != VGAST1_) _mono++; - _oldColors = (Dac *) malloc(sizeof(Dac) * PAL_CNT); - _newColors = (Dac *) malloc(sizeof(Dac) * PAL_CNT); + _oldColors = (Dac *) malloc(sizeof(Dac) * kPalCount); + _newColors = (Dac *) malloc(sizeof(Dac) * kPalCount); _oldScreen = SaveScreen(); getColors(_oldColors); sunset(); @@ -853,8 +851,8 @@ Vga::~Vga() { free(_newColors); if (_msg) buffer = Common::String(_msg); - if (_nam) - buffer = buffer + " [" + _nam + "]"; + if (_name) + buffer = buffer + " [" + _name + "]"; debugN("%s", buffer.c_str()); @@ -936,14 +934,14 @@ int Vga::setMode(int mode) { void Vga::getColors(Dac *tab) { - byte palData[PAL_SIZ]; - g_system->getPaletteManager()->grabPalette(palData, 0, PAL_CNT); + byte palData[kPalSize]; + g_system->getPaletteManager()->grabPalette(palData, 0, kPalCount); palToDac(palData, tab); } void Vga::palToDac(const byte *palData, Dac *tab) { const byte *colP = palData; - for (int idx = 0; idx < PAL_CNT; ++idx, colP += 3) { + for (int idx = 0; idx < kPalCount; idx++, colP += 3) { tab[idx]._r = *colP >> 2; tab[idx]._g = *(colP + 1) >> 2; tab[idx]._b = *(colP + 2) >> 2; @@ -951,7 +949,7 @@ void Vga::palToDac(const byte *palData, Dac *tab) { } void Vga::dacToPal(const Dac *tab, byte *palData) { - for (int idx = 0; idx < PAL_CNT; ++idx, palData += 3) { + for (int idx = 0; idx < kPalCount; idx++, palData += 3) { *palData = tab[idx]._r << 2; *(palData + 1) = tab[idx]._g << 2; *(palData + 2) = tab[idx]._b << 2; @@ -960,7 +958,7 @@ void Vga::dacToPal(const Dac *tab, byte *palData) { void Vga::setColors(Dac *tab, int lum) { Dac *palP = tab, *destP = _newColors; - for (int idx = 0; idx < PAL_CNT; ++idx, ++palP, ++destP) { + for (int idx = 0; idx < kPalCount; idx++, palP++, destP++) { destP->_r = (palP->_r * lum) >> 6; destP->_g = (palP->_g * lum) >> 6; destP->_b = (palP->_b * lum) >> 6; @@ -968,7 +966,7 @@ void Vga::setColors(Dac *tab, int lum) { if (_mono) { destP = _newColors; - for (int idx = 0; idx < PAL_CNT; ++idx, ++destP) { + for (int idx = 0; idx < kPalCount; idx++, destP++) { // Form a greyscalce colour from 30% R, 59% G, 11% B uint8 intensity = (((int)destP->_r * 77) + ((int)destP->_g * 151) + ((int)destP->_b * 28)) >> 8; destP->_r = intensity; @@ -982,7 +980,7 @@ void Vga::setColors(Dac *tab, int lum) { void Vga::setColors() { - memset(_newColors, 0, PAL_SIZ); + memset(_newColors, 0, kPalSize); updateColors(); } @@ -1021,7 +1019,7 @@ void Vga::show() { void Vga::updateColors() { - byte palData[PAL_SIZ]; + byte palData[kPalSize]; dacToPal(_newColors, palData); g_system->getPaletteManager()->setPalette(palData, 0, 256); } @@ -1041,7 +1039,7 @@ void Vga::update() { void Vga::clear(uint8 color) { - for (int paneNum = 0; paneNum < 4; ++paneNum) + for (int paneNum = 0; paneNum < 4; paneNum++) _page[paneNum]->fillRect(Common::Rect(0, 0, kScrWidth, kScrHeight), color); } @@ -1062,7 +1060,7 @@ void Bitmap::xShow(int16 x, int16 y) { // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface - for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { + for (int planeCtr = 0; planeCtr < 4; planeCtr++) { byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); for (;;) { @@ -1079,7 +1077,7 @@ void Bitmap::xShow(int16 x, int16 y) { assert(destP < destEndP); if (cmd == 2) - ++srcP; + srcP++; else if (cmd == 3) srcP += count; @@ -1114,7 +1112,7 @@ void Bitmap::show(int16 x, int16 y) { // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface - for (int planeCtr = 0; planeCtr < 4; ++planeCtr) { + for (int planeCtr = 0; planeCtr < 4; planeCtr++) { byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); for (;;) { @@ -1152,7 +1150,7 @@ void Bitmap::show(int16 x, int16 y) { } if (cmd == 2) - ++srcP; + srcP++; } } /* @@ -1184,7 +1182,7 @@ void Bitmap::hide(int16 x, int16 y) { HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *HL = new BMP_PTR[2]; + BitmapPtr *HL = new BitmapPtr[2]; HL[0] = new Bitmap("HLINE", true); HL[1] = NULL; @@ -1193,7 +1191,7 @@ HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *PR = new BMP_PTR[2]; + BitmapPtr *PR = new BitmapPtr[2]; PR[0] = new Bitmap("PRESS", true); PR[1] = NULL; @@ -1202,7 +1200,7 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *SP = new BMP_PTR[3]; + BitmapPtr *SP = new BitmapPtr[3]; SP[0] = new Bitmap("SPK_L", true); SP[1] = new Bitmap("SPK_R", true); SP[2] = NULL; @@ -1212,7 +1210,7 @@ Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list - BMP_PTR *LI = new BMP_PTR[5]; + BitmapPtr *LI = new BitmapPtr[5]; LI[0] = new Bitmap("LITE0", true); LI[1] = new Bitmap("LITE1", true); LI[2] = new Bitmap("LITE2", true); -- cgit v1.2.3 From 7ea1f74759c2b1a5e9d497a6bc3175a414ac94a1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 3 Aug 2011 16:31:32 +0200 Subject: CGE: Fix display of info text at the beginning of the game --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index cc715da03c..8889c59b8d 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -813,7 +813,7 @@ Vga::Vga(int mode) for (int i = 10; i < 20; i++) { char *text = _text->getText(i); if (text) { - debugN("%s", text); + debugN("%s\n", text); std = false; } } -- cgit v1.2.3 From c1294b772f3f459976dacb1c06f45425cc94853b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 5 Aug 2011 22:51:32 +1000 Subject: CGE: Added an assert to test out of bounds sprite shape access The English version seems to expect a different number of shapes for some sprites, so it will need further work to determine how best to handle the differences. --- engines/cge/vga13h.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 9b30e02e4d..62b902b19c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -382,6 +382,7 @@ Sprite *Sprite::expand() { if (len == 0 || *line == '.') continue; + assert(shpcnt <= _shpCnt); switch (takeEnum(Comd, strtok(line, " =\t"))) { case 0 : { // Name setName(strtok(NULL, "")); -- cgit v1.2.3 From 388dadd56f0b0f35e0b617d1a8ce9ab47a0c14fc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 13:12:22 +1000 Subject: CGE: Changed sprite shape list loading to exceed size specified by _shpCnt This fixes the problem that was happening with the new English archive, which had a bigger shape list for one of the items in the first scene. --- engines/cge/vga13h.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index de28794f3f..f34211c360 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -25,6 +25,7 @@ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon */ +#include "common/array.h" #include "common/rect.h" #include "graphics/palette.h" #include "cge/general.h" @@ -358,7 +359,9 @@ Sprite *Sprite::expand() { if (*_file) { static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; char line[kLineMax], fname[kPathMax]; - BitmapPtr *shplist = new BitmapPtr[_shpCnt + 1]; + + Common::Array shplist; + for (int i = 0; i < _shpCnt + 1; ++i) shplist.push_back(NULL); Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, @@ -382,13 +385,18 @@ Sprite *Sprite::expand() { if (len == 0 || *line == '.') continue; - assert(shpcnt <= _shpCnt); switch (takeEnum(Comd, strtok(line, " =\t"))) { case 0 : { // Name setName(strtok(NULL, "")); break; } case 1 : { // Phase + // In case the shape index gets too high, increase the array size + while ((shpcnt + 1) >= (int)shplist.size()) { + shplist.push_back(NULL); + ++_shpCnt; + } + shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/"), true); break; } @@ -456,7 +464,12 @@ Sprite *Sprite::expand() { } else setSeq(getConstantSeq(_shpCnt == 1)); - setShapeList(shplist); + // Set the shape list + BitmapPtr *shapeList = new BitmapPtr[shplist.size()]; + for (uint i = 0; i < shplist.size(); ++i) + shapeList[i] = shplist[i]; + + setShapeList(shapeList); if (nea) nea[neacnt - 1]._ptr = _ext->_near = nea; -- cgit v1.2.3 From 0cb8b15cdf3eafbfea33ab68c6f3d43e42f11e80 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 13:30:36 +1000 Subject: CGE: Fixed warning of shadowed variable --- engines/cge/vga13h.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index f34211c360..d2ba9b1b99 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -337,16 +337,16 @@ Snail::Com *Sprite::snList(SnList type) { } -void Sprite::setName(char *name) { +void Sprite::setName(char *newName) { if (_ext) { if (_ext->_name) { delete[] _ext->_name; _ext->_name = NULL; } - if (name) { - _ext->_name = new char[strlen(name) + 1]; + if (newName) { + _ext->_name = new char[strlen(newName) + 1]; assert(_ext->_name != NULL); - strcpy(_ext->_name, name); + strcpy(_ext->_name, newName); } } } -- cgit v1.2.3 From 63d49d3e1a460e848915ee54ca85812e1129aaf8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 13:46:44 +1000 Subject: CGE: Fix uninitialised value Valgrind warnings when saving sprite data --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d2ba9b1b99..4ad4e83ad6 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -647,7 +647,7 @@ BitmapPtr Sprite::ghost() { } void Sprite::sync(Common::Serializer &s) { - uint16 unused; + uint16 unused = 0; s.syncAsUint16LE(unused); s.syncAsUint16LE(unused); // _ext -- cgit v1.2.3 From 9f8eb5a74086881f2818256b01fb6fb946c6420a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2011 16:55:39 +1000 Subject: CGE: Re-added an explicit check in Sprite destructor against _sprite variable The trouble is that the _sprite variable can currently be pointing to any registered sprite, and should only be freed in the destructor if it hasn't already been freed. Currently, this is best done by keeping track of whether the pointed to sprite has been already freed or not. --- engines/cge/vga13h.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 4ad4e83ad6..b1858c0cbe 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -231,6 +231,9 @@ Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) Sprite::~Sprite() { + if (_sprite == this) + _sprite = NULL; + contract(); } -- cgit v1.2.3 From 7ae8f8ce69ba27b4ee2c1b42dcb624d59edcdfe0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Aug 2011 18:38:06 +1000 Subject: CGE: Decrease delay amounts to give better precision for frame execution --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index b1858c0cbe..7c11653c4e 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -897,7 +897,7 @@ void Vga::setStatAdr() { void Vga::waitVR(bool on) { // Since some of the game parts rely on using vertical sync as a delay mechanism, // we're introducing a short delay to simulate it - g_system->delayMillis(10); + g_system->delayMillis(5); } -- cgit v1.2.3 From 161a39e9fe0bfdbb1d96a6bb4c88b83d3f073ad0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Aug 2011 11:04:10 +1000 Subject: CGE: Got rid of stub warnings for things that don't need to be implemented in ScummVM --- engines/cge/vga13h.cpp | 137 ++----------------------------------------------- 1 file changed, 5 insertions(+), 132 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 7c11653c4e..51be2ed1e8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -100,92 +100,13 @@ static void Video() { uint16 *SaveScreen() { - /* - uint16 cxy, cur, siz, * scr = NULL, * sav; - - // horizontal size of text mode screen - asm mov ah,0x0F // get current video mode - Video(); // BIOS video service - asm xchg ah,al // answer in ah - asm push ax // preserve width - - // vertical size of text mode screen - asm mov dl,24 // last row on std screen - asm xor bx,bx // valid request in BH - asm mov ax,0x1130 // get EGA's last row # - Video(); // BIOS video service - asm inc dl // # of rows = last+1 - - // compute screen size in words - asm pop ax // restore width - asm mul dl // width * height - - siz = _AX; - - asm mov ax,0x40 // system data segment - asm mov es,ax - asm mov ax,0B000H // Mono - asm cmp byte ptr es:[0x49],0x07 - asm je sto - asm mov ax,0B800H // Color - sto: // store screen address - asm mov word ptr scr+2,ax - - _AH = 0x0F; Video(); // active page - - // take cursor shape - _AH = 0x03; Video(); // get cursor size - cur = _CX; - - // take cursor position - _DH = 0; - _AH = 0x03; Video(); // get cursor - cxy = _DX; - - sav = farnew(uint16, siz+3); // +3 extra uint16s for size and cursor - if (sav) - { - sav[0] = siz; - sav[1] = cur; - sav[2] = cxy; - memcpy(sav+3, scr, siz * 2); - } - return sav; - */ - warning("STUB: SaveScreen"); + // In ScummVM, we don't need to worry about saving the original screen mode return 0; } void RestoreScreen(uint16 * &sav) { - /* - uint16 * scr = NULL; - - asm mov ax,0x40 // system data segment - asm mov es,ax - asm mov ax,0B000H // Mono - asm cmp byte ptr es:[0x49],0x07 - asm je sto - asm mov ax,0B800H // Color - sto: // store screen address - asm mov word ptr scr+2,ax - - memcpy(scr, sav+3, sav[0] * 2); - - _AH = 0x0F; Video(); // active page - - // set cursor shape - _CX = sav[1]; - _AH = 0x01; Video(); // set cursor size - - // set cursor position - _DX = sav[2]; - _AH = 0x02; Video(); // set cursor - - free(sav); - sav = NULL; - */ - warning("STUB: RestoreScreen"); + // In ScummVM, we don't need to restore the original text screen when the game exits } @@ -830,7 +751,7 @@ Vga::Vga(int mode) for (int i = 10; i < 20; i++) { char *text = _text->getText(i); if (text) { - debugN("%s\n", text); + debugN(1, "%s\n", text); std = false; } } @@ -879,17 +800,7 @@ Vga::~Vga() { void Vga::setStatAdr() { - /* - asm mov dx,VGAMIr_ - asm in al,dx - asm test al,1 // CGA addressing mode flag - asm mov ax,VGAST1_ // CGA addressing - asm jnz set_mode_adr - asm xor al,0x60 // MDA addressing - set_mode_adr: - StatAdr = _AX; - */ - warning("STUB: VGA::setStatADR"); + // No implementation needed for ScummVM } @@ -902,45 +813,7 @@ void Vga::waitVR(bool on) { void Vga::setup(VgaRegBlk *vrb) { - /* - waitVR(); // *--LOOK!--* resets VGAATR logic - asm cld - asm mov si, vrb // take address of parameter table - asm mov dh,0x03 // higher byte of I/O address is always 3 - - s: - asm lodsw // take lower byte of I/O address and index - asm or ah,ah // 0 = end of table - asm jz xit // no more: exit - asm or al,al // indexed register? - asm js single // 7th bit set means single register - asm mov dl,ah // complete I/O address - asm out dx,al // put index into control register - asm inc dx // data register is next to control - asm in al,dx // take old data - - write: - asm mov cl,al // preserve old data - asm lodsw // take 2 masks from table - asm xor al,0xFF // invert mask bits - asm and al,cl // clear bits with "clr" mask - asm or al,ah // set bits with "set" mask - asm cmp dl,0xC1 // special case? - asm jne std2 // no: standard job, otherwise... - asm dec dx // data out reg shares address with index - std2: - asm out dx,al // write new value to register - asm jmp s - - single: // read address in al, write address in ah - asm mov dl,al // complete I/O read address - asm in al,dx // take old data - asm mov dl,ah // complete I/O write address - asm jmp write // continue standard routine - - xit: - */ - warning("STUB: VGA::setup"); + // No direct VGA setup required, since ScummVM provides it's own graphics interface } -- cgit v1.2.3 From 23689cac23fcbe205f28434ddbb4a686feda4dea Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 17 Aug 2011 10:55:49 +0200 Subject: CGE: Remove unused Rgb/Trgb/mkRgb. --- engines/cge/vga13h.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 51be2ed1e8..9b063f0c02 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -118,16 +118,6 @@ Dac mkDac(uint8 r, uint8 g, uint8 b) { return x; } - -Rgb mkRgb(uint8 r, uint8 g, uint8 b) { - static Trgb x; - x._dac._r = r; - x._dac._g = g; - x._dac._b = b; - return x._rgb; -} - - Sprite *locate(int ref) { Sprite *spr = _vga->_showQ->locate(ref); return (spr) ? spr : _vga->_spareQ->locate(ref); -- cgit v1.2.3 From 40ea6d788bfabb9d692377fa0baf87b3e5824e0c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 19 Aug 2011 07:25:58 +0200 Subject: CGE: Suppress some dead code --- engines/cge/vga13h.cpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 9b063f0c02..ad2415caaf 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -77,28 +77,6 @@ Seq *getConstantSeq(bool seqFlag) { extern "C" void SNDMIDIPlay(); -/* -static void Video() { - static uint16 SP_S; - - asm push bx - asm push bp - asm push si - asm push di - asm push es - asm xor bx,bx // video page #0 - SP_S = _SP; - asm int VIDEO - _SP = SP_S; - asm pop es - asm pop di - asm pop si - asm pop bp - asm pop bx -} -*/ - - uint16 *SaveScreen() { // In ScummVM, we don't need to worry about saving the original screen mode return 0; @@ -125,7 +103,7 @@ Sprite *locate(int ref) { Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), - _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0), + _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(_file, 0, sizeof(_file)); *((uint16 *)&_flags) = 0; -- cgit v1.2.3 From 0d730b85e3e05829ba5ce3fbcdbf2886a9a28a94 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 19 Aug 2011 19:49:05 +1000 Subject: CGE: Changed the Sprite bit-flags into a union, to fix savegame endian issues --- engines/cge/vga13h.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ad2415caaf..6c41292712 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -164,7 +164,7 @@ BitmapPtr *Sprite::setShapeList(BitmapPtr *shpP) { } expand(); _ext->_shpList = shpP; - _flags._bDel = true; + _flags.flags._bDel = true; if (!_ext->_seq) setSeq(getConstantSeq(_shpCnt < 2)); } @@ -382,7 +382,7 @@ Sprite *Sprite::contract() { if (e) { if (e->_name) delete[] e->_name; - if (_flags._bDel && e->_shpList) { + if (_flags.flags._bDel && e->_shpList) { int i; for (i = 0; e->_shpList[i]; i++) delete e->_shpList[i]; @@ -436,24 +436,24 @@ void Sprite::makeXlat(uint8 *x) { if (_ext) { BitmapPtr *b; - if (_flags._xlat) + if (_flags.flags._xlat) killXlat(); for (b = _ext->_shpList; *b; b++) (*b)->_m = x; - _flags._xlat = true; + _flags.flags._xlat = true; } } void Sprite::killXlat() { - if (_flags._xlat && _ext) { + if (_flags.flags._xlat && _ext) { BitmapPtr *b; uint8 *m = (*_ext->_shpList)->_m; free(m); for (b = _ext->_shpList; *b; b++) (*b)->_m = NULL; - _flags._xlat = false; + _flags.flags._xlat = false; } } @@ -475,9 +475,9 @@ void Sprite::gotoxy(int x, int y) { _y = y; } if (_next) - if (_next->_flags._slav) + if (_next->_flags.flags._slav) _next->gotoxy(_next->_x - xo + _x, _next->_y - yo + _y); - if (_flags._shad) + if (_flags.flags._shad) _prev->gotoxy(_prev->_x - xo + _x, _prev->_y - yo + _y); } @@ -498,8 +498,8 @@ void Sprite::show() { e->_y1 = _y; e->_b1 = shp(); // asm sti // ...done! - if (!_flags._hide) { - if (_flags._xlat) + if (!_flags.flags._hide) { + if (_flags.flags._xlat) e->_b1->xShow(e->_x1, e->_y1); else e->_b1->show(e->_x1, e->_y1); @@ -545,7 +545,7 @@ void Sprite::sync(Common::Serializer &s) { s.syncAsUint16LE(unused); // _ext s.syncAsUint16LE(_ref); s.syncAsByte(_cave); - s.syncBytes((byte *)&_flags, 2); + s.syncAsUint16LE(_flags.flagsWord); s.syncAsUint16LE(_x); s.syncAsUint16LE(_y); s.syncAsByte(_z); @@ -567,7 +567,7 @@ Sprite *spriteAt(int x, int y) { Sprite *spr = NULL, * tail = _vga->_showQ->last(); if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { - if (! spr->_flags._hide && ! spr->_flags._tran) { + if (! spr->_flags.flags._hide && ! spr->_flags.flags._tran) { if (spr->shp()->solidAt(x - spr->_x, y - spr->_y)) break; } @@ -589,7 +589,7 @@ Queue::~Queue() { void Queue::clear() { while (_head) { Sprite *s = remove(_head); - if (s->_flags._kill) + if (s->_flags.flags._kill) delete s; } } @@ -1077,7 +1077,7 @@ PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { setShapeList(LI); - _flags._kill = false; + _flags.flags._kill = false; } } // End of namespace CGE -- cgit v1.2.3 From 372d488b3bc01f6dce06dde83d4818a010695c70 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 19 Aug 2011 20:36:43 +1000 Subject: CGE: Revert previous commit of flags synchronisation --- engines/cge/vga13h.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 6c41292712..ad2415caaf 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -164,7 +164,7 @@ BitmapPtr *Sprite::setShapeList(BitmapPtr *shpP) { } expand(); _ext->_shpList = shpP; - _flags.flags._bDel = true; + _flags._bDel = true; if (!_ext->_seq) setSeq(getConstantSeq(_shpCnt < 2)); } @@ -382,7 +382,7 @@ Sprite *Sprite::contract() { if (e) { if (e->_name) delete[] e->_name; - if (_flags.flags._bDel && e->_shpList) { + if (_flags._bDel && e->_shpList) { int i; for (i = 0; e->_shpList[i]; i++) delete e->_shpList[i]; @@ -436,24 +436,24 @@ void Sprite::makeXlat(uint8 *x) { if (_ext) { BitmapPtr *b; - if (_flags.flags._xlat) + if (_flags._xlat) killXlat(); for (b = _ext->_shpList; *b; b++) (*b)->_m = x; - _flags.flags._xlat = true; + _flags._xlat = true; } } void Sprite::killXlat() { - if (_flags.flags._xlat && _ext) { + if (_flags._xlat && _ext) { BitmapPtr *b; uint8 *m = (*_ext->_shpList)->_m; free(m); for (b = _ext->_shpList; *b; b++) (*b)->_m = NULL; - _flags.flags._xlat = false; + _flags._xlat = false; } } @@ -475,9 +475,9 @@ void Sprite::gotoxy(int x, int y) { _y = y; } if (_next) - if (_next->_flags.flags._slav) + if (_next->_flags._slav) _next->gotoxy(_next->_x - xo + _x, _next->_y - yo + _y); - if (_flags.flags._shad) + if (_flags._shad) _prev->gotoxy(_prev->_x - xo + _x, _prev->_y - yo + _y); } @@ -498,8 +498,8 @@ void Sprite::show() { e->_y1 = _y; e->_b1 = shp(); // asm sti // ...done! - if (!_flags.flags._hide) { - if (_flags.flags._xlat) + if (!_flags._hide) { + if (_flags._xlat) e->_b1->xShow(e->_x1, e->_y1); else e->_b1->show(e->_x1, e->_y1); @@ -545,7 +545,7 @@ void Sprite::sync(Common::Serializer &s) { s.syncAsUint16LE(unused); // _ext s.syncAsUint16LE(_ref); s.syncAsByte(_cave); - s.syncAsUint16LE(_flags.flagsWord); + s.syncBytes((byte *)&_flags, 2); s.syncAsUint16LE(_x); s.syncAsUint16LE(_y); s.syncAsByte(_z); @@ -567,7 +567,7 @@ Sprite *spriteAt(int x, int y) { Sprite *spr = NULL, * tail = _vga->_showQ->last(); if (tail) { for (spr = tail->_prev; spr; spr = spr->_prev) { - if (! spr->_flags.flags._hide && ! spr->_flags.flags._tran) { + if (! spr->_flags._hide && ! spr->_flags._tran) { if (spr->shp()->solidAt(x - spr->_x, y - spr->_y)) break; } @@ -589,7 +589,7 @@ Queue::~Queue() { void Queue::clear() { while (_head) { Sprite *s = remove(_head); - if (s->_flags.flags._kill) + if (s->_flags._kill) delete s; } } @@ -1077,7 +1077,7 @@ PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { setShapeList(LI); - _flags.flags._kill = false; + _flags._kill = false; } } // End of namespace CGE -- cgit v1.2.3 From 4e4062806b1b1d80e98f7935e911249a458eadc8 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 19 Aug 2011 15:55:27 +0200 Subject: CGE: Portability fix for syncing sprite flags. --- engines/cge/vga13h.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ad2415caaf..7e4daeb898 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -545,7 +545,48 @@ void Sprite::sync(Common::Serializer &s) { s.syncAsUint16LE(unused); // _ext s.syncAsUint16LE(_ref); s.syncAsByte(_cave); - s.syncBytes((byte *)&_flags, 2); + + // bitfield in-memory storage is unpredictable, so to avoid + // any issues, pack/unpack everything manually + uint16 flags = 0; + if (s.isLoading()) { + s.syncAsUint16LE(flags); + _flags._hide = flags & 0x0001 ? true : false; + _flags._near = flags & 0x0002 ? true : false; + _flags._drag = flags & 0x0004 ? true : false; + _flags._hold = flags & 0x0008 ? true : false; + _flags._____ = flags & 0x0010 ? true : false; + _flags._slav = flags & 0x0020 ? true : false; + _flags._syst = flags & 0x0040 ? true : false; + _flags._kill = flags & 0x0080 ? true : false; + _flags._xlat = flags & 0x0100 ? true : false; + _flags._port = flags & 0x0200 ? true : false; + _flags._kept = flags & 0x0400 ? true : false; + _flags._east = flags & 0x0800 ? true : false; + _flags._shad = flags & 0x1000 ? true : false; + _flags._back = flags & 0x2000 ? true : false; + _flags._bDel = flags & 0x4000 ? true : false; + _flags._tran = flags & 0x8000 ? true : false; + } else { + flags = (flags << 1) | _flags._tran; + flags = (flags << 1) | _flags._bDel; + flags = (flags << 1) | _flags._back; + flags = (flags << 1) | _flags._shad; + flags = (flags << 1) | _flags._east; + flags = (flags << 1) | _flags._kept; + flags = (flags << 1) | _flags._port; + flags = (flags << 1) | _flags._xlat; + flags = (flags << 1) | _flags._kill; + flags = (flags << 1) | _flags._syst; + flags = (flags << 1) | _flags._slav; + flags = (flags << 1) | _flags._____; + flags = (flags << 1) | _flags._hold; + flags = (flags << 1) | _flags._drag; + flags = (flags << 1) | _flags._near; + flags = (flags << 1) | _flags._hide; + s.syncAsUint16LE(flags); + } + s.syncAsUint16LE(_x); s.syncAsUint16LE(_y); s.syncAsByte(_z); -- cgit v1.2.3 From 8ff904c6b576eda37930b020e39855c1fd261b2f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 19 Aug 2011 19:48:49 +0200 Subject: CGE: clean up bitmap class. Suppress useless methods, functions, defines... --- engines/cge/vga13h.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ad2415caaf..d963622b13 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -289,7 +289,7 @@ Sprite *Sprite::expand() { ++_shpCnt; } - shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/"), true); + shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/")); break; } case 2 : { // Seq @@ -344,7 +344,7 @@ Sprite *Sprite::expand() { } } } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new Bitmap(_file, true); + shplist[shpcnt++] = new Bitmap(_file); } shplist[shpcnt] = NULL; if (seq) { @@ -1041,7 +1041,7 @@ void Bitmap::hide(int16 x, int16 y) { HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list BitmapPtr *HL = new BitmapPtr[2]; - HL[0] = new Bitmap("HLINE", true); + HL[0] = new Bitmap("HLINE"); HL[1] = NULL; setShapeList(HL); @@ -1050,7 +1050,7 @@ HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list BitmapPtr *PR = new BitmapPtr[2]; - PR[0] = new Bitmap("PRESS", true); + PR[0] = new Bitmap("PRESS"); PR[1] = NULL; setShapeList(PR); @@ -1059,8 +1059,8 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list BitmapPtr *SP = new BitmapPtr[3]; - SP[0] = new Bitmap("SPK_L", true); - SP[1] = new Bitmap("SPK_R", true); + SP[0] = new Bitmap("SPK_L"); + SP[1] = new Bitmap("SPK_R"); SP[2] = NULL; setShapeList(SP); @@ -1069,10 +1069,10 @@ Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list BitmapPtr *LI = new BitmapPtr[5]; - LI[0] = new Bitmap("LITE0", true); - LI[1] = new Bitmap("LITE1", true); - LI[2] = new Bitmap("LITE2", true); - LI[3] = new Bitmap("LITE3", true); + LI[0] = new Bitmap("LITE0"); + LI[1] = new Bitmap("LITE1"); + LI[2] = new Bitmap("LITE2"); + LI[3] = new Bitmap("LITE3"); LI[4] = NULL; setShapeList(LI); -- cgit v1.2.3 From 01b4ac72190bdfb3cd637890c5c0a88bc16163ac Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 19 Aug 2011 23:54:24 +0200 Subject: CGE: More cleanup. --- engines/cge/vga13h.cpp | 485 ++++++++++++++++++++++--------------------------- 1 file changed, 221 insertions(+), 264 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 80060bfd74..feaa005643 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -38,7 +38,7 @@ namespace CGE { -static VgaRegBlk VideoMode[] = { +static VgaRegBlk VideoMode[] = { { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 @@ -55,7 +55,7 @@ static VgaRegBlk VideoMode[] = { { 0x00, 0x00, 0x00, 0x00 } }; -bool SpeedTest = false; +bool SpeedTest = false; Seq *getConstantSeq(bool seqFlag) { const Seq seq1[] = { { 0, 0, 0, 0, 0 } }; @@ -74,20 +74,17 @@ Seq *getConstantSeq(bool seqFlag) { return seq; } - -extern "C" void SNDMIDIPlay(); +extern "C" void SNDMIDIPlay(); uint16 *SaveScreen() { // In ScummVM, we don't need to worry about saving the original screen mode return 0; } - void RestoreScreen(uint16 * &sav) { // In ScummVM, we don't need to restore the original text screen when the game exits } - Dac mkDac(uint8 r, uint8 g, uint8 b) { static Dac x; x._r = r; @@ -118,7 +115,6 @@ Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) setShapeList(shpP); } - Sprite::~Sprite() { if (_sprite == this) _sprite = NULL; @@ -126,25 +122,22 @@ Sprite::~Sprite() { contract(); } - BitmapPtr Sprite::shp() { - register SprExt *e = _ext; - if (e) - if (e->_seq) { - int i = e->_seq[_seqPtr]._now; - if (i >= _shpCnt) { - //char s[256]; - //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", - // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); - //VGA::Exit(s, File); - error("Invalid PHASE in SPRITE::Shp() %s", _file); - } - return e->_shpList[i]; - } - return NULL; + SprExt *e = _ext; + if (!e || !e->_seq) + return NULL; + + int i = e->_seq[_seqPtr]._now; + if (i >= _shpCnt) { + //char s[256]; + //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", + // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); + //VGA::Exit(s, File); + error("Invalid PHASE in SPRITE::Shp() %s", _file); + } + return e->_shpList[i]; } - BitmapPtr *Sprite::setShapeList(BitmapPtr *shpP) { BitmapPtr *r = (_ext) ? _ext->_shpList : NULL; @@ -171,7 +164,6 @@ BitmapPtr *Sprite::setShapeList(BitmapPtr *shpP) { return r; } - void Sprite::moveShapes(uint8 *buf) { BitmapPtr *p; for (p = _ext->_shpList; *p; p++) { @@ -179,22 +171,21 @@ void Sprite::moveShapes(uint8 *buf) { } } - bool Sprite::works(Sprite *spr) { - if (spr) - if (spr->_ext) { - Snail::Com *c = spr->_ext->_take; - if (c != NULL) { - c += spr->_takePtr; - if (c->_ref == _ref) - if (c->_com != kSnLabel || (c->_val == 0 || c->_val == _vm->_now)) - return true; - } - } + if (!spr || !spr->_ext) + return false; + + Snail::Com *c = spr->_ext->_take; + if (c != NULL) { + c += spr->_takePtr; + if (c->_ref == _ref) + if (c->_com != kSnLabel || (c->_val == 0 || c->_val == _vm->_now)) + return true; + } + return false; } - Seq *Sprite::setSeq(Seq *seq) { if (_ext) { free(_ext->_seq); @@ -202,7 +193,8 @@ Seq *Sprite::setSeq(Seq *seq) { } expand(); - register Seq *s = _ext->_seq; + + Seq *s = _ext->_seq; _ext->_seq = seq; if (_seqPtr == NO_SEQ) step(0); @@ -211,7 +203,6 @@ Seq *Sprite::setSeq(Seq *seq) { return s; } - bool Sprite::seqTest(int n) { if (n >= 0) return (_seqPtr == n); @@ -220,186 +211,189 @@ bool Sprite::seqTest(int n) { return true; } - Snail::Com *Sprite::snList(SnList type) { - register SprExt *e = _ext; + SprExt *e = _ext; if (e) return (type == kNear) ? e->_near : e->_take; return NULL; } - void Sprite::setName(char *newName) { - if (_ext) { - if (_ext->_name) { - delete[] _ext->_name; - _ext->_name = NULL; - } - if (newName) { - _ext->_name = new char[strlen(newName) + 1]; - assert(_ext->_name != NULL); - strcpy(_ext->_name, newName); - } + if (!_ext) + return; + + if (_ext->_name) { + delete[] _ext->_name; + _ext->_name = NULL; + } + if (newName) { + _ext->_name = new char[strlen(newName) + 1]; + assert(_ext->_name != NULL); + strcpy(_ext->_name, newName); } } - Sprite *Sprite::expand() { - if (!_ext) { - _ext = new SprExt; - assert(_ext != NULL); - if (*_file) { - static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; - char line[kLineMax], fname[kPathMax]; - - Common::Array shplist; - for (int i = 0; i < _shpCnt + 1; ++i) shplist.push_back(NULL); - Seq *seq = NULL; - int shpcnt = 0, - seqcnt = 0, - neacnt = 0, - takcnt = 0, - maxnow = 0, - maxnxt = 0; - - Snail::Com *nea = NULL; - Snail::Com *tak = NULL; - mergeExt(fname, _file, SPR_EXT); - if (INI_FILE::exist(fname)) { // sprite description file exist - INI_FILE sprf(fname); - if (!(sprf._error==0)) - error("Bad SPR [%s]", fname); - int len = 0, lcnt = 0; - while ((len = sprf.read((uint8 *)line)) != 0) { - lcnt++; - if (len && line[len - 1] == '\n') - line[--len] = '\0'; - if (len == 0 || *line == '.') - continue; - - switch (takeEnum(Comd, strtok(line, " =\t"))) { - case 0 : { // Name - setName(strtok(NULL, "")); - break; - } - case 1 : { // Phase - // In case the shape index gets too high, increase the array size - while ((shpcnt + 1) >= (int)shplist.size()) { - shplist.push_back(NULL); - ++_shpCnt; - } - - shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/")); - break; - } - case 2 : { // Seq - seq = (Seq *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); - assert(seq != NULL); - Seq *s = &seq[seqcnt++]; - s->_now = atoi(strtok(NULL, " \t,;/")); - if (s->_now > maxnow) - maxnow = s->_now; - s->_next = atoi(strtok(NULL, " \t,;/")); - switch (s->_next) { - case 0xFF : - s->_next = seqcnt; - break; - case 0xFE : - s->_next = seqcnt - 1; - break; - } - if (s->_next > maxnxt) - maxnxt = s->_next; - s->_dx = atoi(strtok(NULL, " \t,;/")); - s->_dy = atoi(strtok(NULL, " \t,;/")); - s->_dly = atoi(strtok(NULL, " \t,;/")); - break; - } - case 3 : { // Near - if (_nearPtr != NO_PTR) { - nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); - assert(nea != NULL); - Snail::Com *c = &nea[neacnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) - error("Bad NEAR in %d [%s]", lcnt, fname); - c->_ref = atoi(strtok(NULL, " \t,;/")); - c->_val = atoi(strtok(NULL, " \t,;/")); - c->_ptr = NULL; - } - } + if (_ext) + return this; + + _ext = new SprExt; + assert(_ext != NULL); + if (!*_file) + return this; + + static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; + char line[kLineMax], fname[kPathMax]; + + Common::Array shplist; + for (int i = 0; i < _shpCnt + 1; ++i) shplist.push_back(NULL); + Seq *seq = NULL; + int shpcnt = 0, + seqcnt = 0, + neacnt = 0, + takcnt = 0, + maxnow = 0, + maxnxt = 0; + + Snail::Com *nea = NULL; + Snail::Com *tak = NULL; + mergeExt(fname, _file, SPR_EXT); + if (INI_FILE::exist(fname)) { // sprite description file exist + INI_FILE sprf(fname); + if (!(sprf._error==0)) + error("Bad SPR [%s]", fname); + int len = 0, lcnt = 0; + while ((len = sprf.read((uint8 *)line)) != 0) { + lcnt++; + if (len && line[len - 1] == '\n') + line[--len] = '\0'; + if (len == 0 || *line == '.') + continue; + + Snail::Com *c; + switch (takeEnum(Comd, strtok(line, " =\t"))) { + case 0: + // Name + setName(strtok(NULL, "")); + break; + case 1: + // Phase + // In case the shape index gets too high, increase the array size + while ((shpcnt + 1) >= (int)shplist.size()) { + shplist.push_back(NULL); + ++_shpCnt; + } + shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/")); + break; + case 2: + // Seq + seq = (Seq *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); + assert(seq != NULL); + Seq *s; + s = &seq[seqcnt++]; + s->_now = atoi(strtok(NULL, " \t,;/")); + if (s->_now > maxnow) + maxnow = s->_now; + s->_next = atoi(strtok(NULL, " \t,;/")); + switch (s->_next) { + case 0xFF: + s->_next = seqcnt; + break; + case 0xFE: + s->_next = seqcnt - 1; break; - case 4 : { // Take - if (_takePtr != NO_PTR) { - tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); - assert(tak != NULL); - Snail::Com *c = &tak[takcnt++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) - error("Bad NEAR in %d [%s]", lcnt, fname); - c->_ref = atoi(strtok(NULL, " \t,;/")); - c->_val = atoi(strtok(NULL, " \t,;/")); - c->_ptr = NULL; - } - break; - } - } } - } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new Bitmap(_file); + if (s->_next > maxnxt) + maxnxt = s->_next; + s->_dx = atoi(strtok(NULL, " \t,;/")); + s->_dy = atoi(strtok(NULL, " \t,;/")); + s->_dly = atoi(strtok(NULL, " \t,;/")); + break; + case 3: + // Near + if (_nearPtr == NO_PTR) + break; + nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); + assert(nea != NULL); + c = &nea[neacnt++]; + if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) + error("Bad NEAR in %d [%s]", lcnt, fname); + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; + break; + case 4: + // Take + if (_takePtr == NO_PTR) + break; + tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); + assert(tak != NULL); + c = &tak[takcnt++]; + if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) + error("Bad NEAR in %d [%s]", lcnt, fname); + c->_ref = atoi(strtok(NULL, " \t,;/")); + c->_val = atoi(strtok(NULL, " \t,;/")); + c->_ptr = NULL; + break; } - shplist[shpcnt] = NULL; - if (seq) { - if (maxnow >= shpcnt) - error("Bad PHASE in SEQ [%s]", fname); - if (maxnxt >= seqcnt) - error("Bad JUMP in SEQ [%s]", fname); - setSeq(seq); - } else - setSeq(getConstantSeq(_shpCnt == 1)); - - // Set the shape list - BitmapPtr *shapeList = new BitmapPtr[shplist.size()]; - for (uint i = 0; i < shplist.size(); ++i) - shapeList[i] = shplist[i]; - - setShapeList(shapeList); - - if (nea) - nea[neacnt - 1]._ptr = _ext->_near = nea; - else - _nearPtr = NO_PTR; - if (tak) - tak[takcnt - 1]._ptr = _ext->_take = tak; - else - _takePtr = NO_PTR; } + } else { + // no sprite description: try to read immediately from .BMP + shplist[shpcnt++] = new Bitmap(_file); } + + shplist[shpcnt] = NULL; + if (seq) { + if (maxnow >= shpcnt) + error("Bad PHASE in SEQ [%s]", fname); + if (maxnxt >= seqcnt) + error("Bad JUMP in SEQ [%s]", fname); + setSeq(seq); + } else + setSeq(getConstantSeq(_shpCnt == 1)); + + // Set the shape list + BitmapPtr *shapeList = new BitmapPtr[shplist.size()]; + for (uint i = 0; i < shplist.size(); ++i) + shapeList[i] = shplist[i]; + + setShapeList(shapeList); + + if (nea) + nea[neacnt - 1]._ptr = _ext->_near = nea; + else + _nearPtr = NO_PTR; + if (tak) + tak[takcnt - 1]._ptr = _ext->_take = tak; + else + _takePtr = NO_PTR; + return this; } - Sprite *Sprite::contract() { - register SprExt *e = _ext; - if (e) { - if (e->_name) - delete[] e->_name; - if (_flags._bDel && e->_shpList) { - int i; - for (i = 0; e->_shpList[i]; i++) - delete e->_shpList[i]; - delete[] e->_shpList; - } + SprExt *e = _ext; + if (!e) + return this; + + if (e->_name) + delete[] e->_name; + if (_flags._bDel && e->_shpList) { + for (int i = 0; e->_shpList[i]; i++) + delete e->_shpList[i]; + delete[] e->_shpList; + } - free(e->_seq); - free(e->_near); - free(e->_take); + free(e->_seq); + free(e->_near); + free(e->_take); + + delete e; + _ext = NULL; - delete e; - _ext = NULL; - } return this; } - Sprite *Sprite::backShow(bool fast) { expand(); show(2); @@ -410,7 +404,6 @@ Sprite *Sprite::backShow(bool fast) { return this; } - void Sprite::step(int nr) { if (nr >= 0) _seqPtr = nr; @@ -426,37 +419,32 @@ void Sprite::step(int nr) { } } - void Sprite::tick() { step(); } - void Sprite::makeXlat(uint8 *x) { - if (_ext) { - BitmapPtr *b; + if (!_ext) + return; - if (_flags._xlat) - killXlat(); - for (b = _ext->_shpList; *b; b++) - (*b)->_m = x; - _flags._xlat = true; - } + if (_flags._xlat) + killXlat(); + for (BitmapPtr *b = _ext->_shpList; *b; b++) + (*b)->_m = x; + _flags._xlat = true; } - void Sprite::killXlat() { - if (_flags._xlat && _ext) { - BitmapPtr *b; - uint8 *m = (*_ext->_shpList)->_m; - free(m); - - for (b = _ext->_shpList; *b; b++) - (*b)->_m = NULL; - _flags._xlat = false; - } -} + if (!_flags._xlat || !_ext) + return; + + uint8 *m = (*_ext->_shpList)->_m; + free(m); + for (BitmapPtr *b = _ext->_shpList; *b; b++) + (*b)->_m = NULL; + _flags._xlat = false; +} void Sprite::gotoxy(int x, int y) { int xo = _x, yo = _y; @@ -481,14 +469,12 @@ void Sprite::gotoxy(int x, int y) { _prev->gotoxy(_prev->_x - xo + _x, _prev->_y - yo + _y); } - void Sprite::center() { gotoxy((kScrWidth - _w) / 2, (kScrHeight - _h) / 2); } - void Sprite::show() { - register SprExt *e; + SprExt *e; // asm cli // critic section... e = _ext; e->_x0 = e->_x1; @@ -506,7 +492,6 @@ void Sprite::show() { } } - void Sprite::show(uint16 pg) { Graphics::Surface *a = Vga::_page[1]; Vga::_page[1] = Vga::_page[pg & 3]; @@ -514,28 +499,26 @@ void Sprite::show(uint16 pg) { Vga::_page[1] = a; } - void Sprite::hide() { - register SprExt *e = _ext; + SprExt *e = _ext; if (e->_b0) e->_b0->hide(e->_x0, e->_y0); } - BitmapPtr Sprite::ghost() { - register SprExt *e = _ext; - if (e->_b1) { - BitmapPtr bmp = new Bitmap(0, 0, (uint8 *)NULL); - assert(bmp != NULL); - bmp->_w = e->_b1->_w; - bmp->_h = e->_b1->_h; - bmp->_b = new HideDesc[bmp->_h]; - assert(bmp->_b != NULL); - bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); - bmp->_map = (e->_y1 << 16) + e->_x1; - return bmp; - } - return NULL; + SprExt *e = _ext; + if (!e->_b1) + return NULL; + + BitmapPtr bmp = new Bitmap(0, 0, (uint8 *)NULL); + assert(bmp != NULL); + bmp->_w = e->_b1->_w; + bmp->_h = e->_b1->_h; + bmp->_b = new HideDesc[bmp->_h]; + assert(bmp->_b != NULL); + bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h); + bmp->_map = (e->_y1 << 16) + e->_x1; + return bmp; } void Sprite::sync(Common::Serializer &s) { @@ -617,16 +600,13 @@ Sprite *spriteAt(int x, int y) { return spr; } - Queue::Queue(bool show) : _head(NULL), _tail(NULL), _show(show) { } - Queue::~Queue() { clear(); } - void Queue::clear() { while (_head) { Sprite *s = remove(_head); @@ -635,7 +615,6 @@ void Queue::clear() { } } - void Queue::forAll(void (*fun)(Sprite *)) { Sprite *s = _head; while (s) { @@ -645,7 +624,6 @@ void Queue::forAll(void (*fun)(Sprite *)) { } } - void Queue::append(Sprite *spr) { if (_tail) { spr->_prev = _tail; @@ -659,7 +637,6 @@ void Queue::append(Sprite *spr) { spr->contract(); } - void Queue::insert(Sprite *spr, Sprite *nxt) { if (nxt == _head) { spr->_next = _head; @@ -681,7 +658,6 @@ void Queue::insert(Sprite *spr, Sprite *nxt) { spr->contract(); } - void Queue::insert(Sprite *spr) { Sprite *s; for (s = _head; s; s = s->_next) @@ -716,17 +692,14 @@ Sprite *Queue::remove(Sprite *spr) { return spr; } - Sprite *Queue::locate(int ref) { - Sprite *spr; - for (spr = _head; spr; spr = spr->_next) { + for (Sprite *spr = _head; spr; spr = spr->_next) { if (spr->_ref == ref) return spr; } return NULL; } - //extern const char Copr[]; Graphics::Surface *Vga::_page[4]; Dac *Vga::_sysPal; @@ -782,7 +755,6 @@ Vga::Vga(int mode) clear(0); } - Vga::~Vga() { _mono = 0; @@ -807,12 +779,10 @@ Vga::~Vga() { delete _spareQ; } - void Vga::setStatAdr() { // No implementation needed for ScummVM } - #pragma argsused void Vga::waitVR(bool on) { // Since some of the game parts rely on using vertical sync as a delay mechanism, @@ -820,18 +790,15 @@ void Vga::waitVR(bool on) { g_system->delayMillis(5); } - void Vga::setup(VgaRegBlk *vrb) { // No direct VGA setup required, since ScummVM provides it's own graphics interface } - int Vga::setMode(int mode) { // ScummVM provides it's own vieo services return 0; } - void Vga::getColors(Dac *tab) { byte palData[kPalSize]; g_system->getPaletteManager()->grabPalette(palData, 0, kPalCount); @@ -877,13 +844,11 @@ void Vga::setColors(Dac *tab, int lum) { _setPal = true; } - void Vga::setColors() { memset(_newColors, 0, kPalSize); updateColors(); } - void Vga::sunrise(Dac *tab) { for (int i = 0; i <= 64; i += FADE_STEP) { setColors(tab, i); @@ -892,7 +857,6 @@ void Vga::sunrise(Dac *tab) { } } - void Vga::sunset() { Dac tab[256]; getColors(tab); @@ -903,27 +867,22 @@ void Vga::sunset() { } } - void Vga::show() { - Sprite *spr = _showQ->first(); - - for (spr = _showQ->first(); spr; spr = spr->_next) + for (Sprite *spr = _showQ->first(); spr; spr = spr->_next) spr->show(); update(); - for (spr = _showQ->first(); spr; spr = spr->_next) + for (Sprite *spr = _showQ->first(); spr; spr = spr->_next) spr->hide(); _frmCnt++; } - void Vga::updateColors() { byte palData[kPalSize]; dacToPal(_newColors, palData); g_system->getPaletteManager()->setPalette(palData, 0, 256); } - void Vga::update() { SWAP(Vga::_page[0], Vga::_page[1]); @@ -936,13 +895,11 @@ void Vga::update() { g_system->updateScreen(); } - void Vga::clear(uint8 color) { for (int paneNum = 0; paneNum < 4; paneNum++) _page[paneNum]->fillRect(Common::Rect(0, 0, kScrWidth, kScrHeight), color); } - void Vga::copyPage(uint16 d, uint16 s) { _page[d]->copyFrom(*_page[s]); } -- cgit v1.2.3 From bb591b5415bcf63f554c14d5be9d74bba9e5b6cc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 21 Aug 2011 11:15:28 +0200 Subject: CGE: Some clean up in Vga class --- engines/cge/vga13h.cpp | 81 +++++++++++--------------------------------------- 1 file changed, 17 insertions(+), 64 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index feaa005643..8213a1bcf3 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -38,25 +38,6 @@ namespace CGE { -static VgaRegBlk VideoMode[] = { - { 0x04, VGASEQ, 0x08, 0x04 }, // memory mode - { 0x03, VGAGRA, 0xFF, 0x00 }, // data rotate = 0 - { 0x05, VGAGRA, 0x03, 0x00 }, // R/W mode = 0 - { 0x06, VGAGRA, 0x02, 0x00 }, // misc - { 0x14, VGACRT, 0x40, 0x00 }, // underline - { 0x13, VGACRT, 0xFF, 0x28 }, // screen width - { 0x17, VGACRT, 0xFF, 0xC3 }, // mode control - { 0x11, VGACRT, 0x80, 0x00 }, // vert retrace end - { 0x09, VGACRT, 0xEF, 0x01 }, // max scan line - { 0x30, VGAATR, 0x00, 0x20 }, // 256 color mode -// { 0x12, VGACRT, 0xFF, 0x6E }, // vert display end -// { 0x15, VGACRT, 0xFF, 0x7F }, // start vb -// { 0x10, VGACRT, 0xFF, 0x94 }, // start vr - { 0x00, 0x00, 0x00, 0x00 } -}; - -bool SpeedTest = false; - Seq *getConstantSeq(bool seqFlag) { const Seq seq1[] = { { 0, 0, 0, 0, 0 } }; const Seq seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; @@ -76,15 +57,6 @@ Seq *getConstantSeq(bool seqFlag) { extern "C" void SNDMIDIPlay(); -uint16 *SaveScreen() { - // In ScummVM, we don't need to worry about saving the original screen mode - return 0; -} - -void RestoreScreen(uint16 * &sav) { - // In ScummVM, we don't need to restore the original text screen when the game exits -} - Dac mkDac(uint8 r, uint8 g, uint8 b) { static Dac x; x._r = r; @@ -100,7 +72,7 @@ Sprite *locate(int ref) { Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), - _next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), + _next(NULL), _prev(NULL), _seqPtr(kNoSeq), _time(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(_file, 0, sizeof(_file)); *((uint16 *)&_flags) = 0; @@ -196,7 +168,7 @@ Seq *Sprite::setSeq(Seq *seq) { Seq *s = _ext->_seq; _ext->_seq = seq; - if (_seqPtr == NO_SEQ) + if (_seqPtr == kNoSeq) step(0); else if (_time == 0) step(_seqPtr); @@ -246,7 +218,9 @@ Sprite *Sprite::expand() { char line[kLineMax], fname[kPathMax]; Common::Array shplist; - for (int i = 0; i < _shpCnt + 1; ++i) shplist.push_back(NULL); + for (int i = 0; i < _shpCnt + 1; ++i) + shplist.push_back(NULL); + Seq *seq = NULL; int shpcnt = 0, seqcnt = 0, @@ -257,7 +231,7 @@ Sprite *Sprite::expand() { Snail::Com *nea = NULL; Snail::Com *tak = NULL; - mergeExt(fname, _file, SPR_EXT); + mergeExt(fname, _file, kSprExt); if (INI_FILE::exist(fname)) { // sprite description file exist INI_FILE sprf(fname); if (!(sprf._error==0)) @@ -311,7 +285,7 @@ Sprite *Sprite::expand() { break; case 3: // Near - if (_nearPtr == NO_PTR) + if (_nearPtr == kNoPtr) break; nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); assert(nea != NULL); @@ -324,7 +298,7 @@ Sprite *Sprite::expand() { break; case 4: // Take - if (_takePtr == NO_PTR) + if (_takePtr == kNoPtr) break; tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); assert(tak != NULL); @@ -362,11 +336,11 @@ Sprite *Sprite::expand() { if (nea) nea[neacnt - 1]._ptr = _ext->_near = nea; else - _nearPtr = NO_PTR; + _nearPtr = kNoPtr; if (tak) tak[takcnt - 1]._ptr = _ext->_take = tak; else - _takePtr = NO_PTR; + _takePtr = kNoPtr; return this; } @@ -721,9 +695,8 @@ void Vga::deinit() { delete[] _sysPal; } -Vga::Vga(int mode) - : _frmCnt(0), _oldMode(0), _oldScreen(NULL), _statAdr(VGAST1_), - _msg(NULL), _name(NULL), _setPal(false), _mono(0) { +Vga::Vga() + : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _mono(0) { _oldColors = NULL; _newColors = NULL; _showQ = new Queue(true); @@ -741,17 +714,11 @@ Vga::Vga(int mode) // warning(Copr); warning("TODO: Fix Copr"); - setStatAdr(); - if (_statAdr != VGAST1_) - _mono++; _oldColors = (Dac *) malloc(sizeof(Dac) * kPalCount); _newColors = (Dac *) malloc(sizeof(Dac) * kPalCount); - _oldScreen = SaveScreen(); getColors(_oldColors); sunset(); - _oldMode = setMode(mode); setColors(); - setup(VideoMode); clear(0); } @@ -779,26 +746,12 @@ Vga::~Vga() { delete _spareQ; } -void Vga::setStatAdr() { - // No implementation needed for ScummVM -} - -#pragma argsused -void Vga::waitVR(bool on) { +void Vga::waitVR() { // Since some of the game parts rely on using vertical sync as a delay mechanism, // we're introducing a short delay to simulate it g_system->delayMillis(5); } -void Vga::setup(VgaRegBlk *vrb) { - // No direct VGA setup required, since ScummVM provides it's own graphics interface -} - -int Vga::setMode(int mode) { - // ScummVM provides it's own vieo services - return 0; -} - void Vga::getColors(Dac *tab) { byte palData[kPalSize]; g_system->getPaletteManager()->grabPalette(palData, 0, kPalCount); @@ -850,9 +803,9 @@ void Vga::setColors() { } void Vga::sunrise(Dac *tab) { - for (int i = 0; i <= 64; i += FADE_STEP) { + for (int i = 0; i <= 64; i += kFadeStep) { setColors(tab, i); - waitVR(true); + waitVR(); updateColors(); } } @@ -860,9 +813,9 @@ void Vga::sunrise(Dac *tab) { void Vga::sunset() { Dac tab[256]; getColors(tab); - for (int i = 64; i >= 0; i -= FADE_STEP) { + for (int i = 64; i >= 0; i -= kFadeStep) { setColors(tab, i); - waitVR(true); + waitVR(); updateColors(); } } -- cgit v1.2.3 From 71440760307dfb99e6194929fb0c8d3bf1a0df10 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Aug 2011 09:05:32 +0200 Subject: CGE: Move IO classes to a separated source file --- engines/cge/vga13h.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 8213a1bcf3..317cb415f8 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -31,7 +31,6 @@ #include "cge/general.h" #include "cge/vga13h.h" #include "cge/bitmap.h" -#include "cge/vol.h" #include "cge/text.h" #include "cge/cge_main.h" #include "cge/cge.h" @@ -232,8 +231,8 @@ Sprite *Sprite::expand() { Snail::Com *nea = NULL; Snail::Com *tak = NULL; mergeExt(fname, _file, kSprExt); - if (INI_FILE::exist(fname)) { // sprite description file exist - INI_FILE sprf(fname); + if (VFile::exist(fname)) { // sprite description file exist + VFile sprf(fname); if (!(sprf._error==0)) error("Bad SPR [%s]", fname); int len = 0, lcnt = 0; -- cgit v1.2.3 From 4cb6c739a4cf75a0e072197845a54620db0b10b8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Aug 2011 19:09:13 +0200 Subject: CGE: Change a couple of static members to non static in Vga class --- engines/cge/vga13h.cpp | 59 ++++++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 38 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 317cb415f8..d510b98f45 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -448,7 +448,6 @@ void Sprite::center() { void Sprite::show() { SprExt *e; -// asm cli // critic section... e = _ext; e->_x0 = e->_x1; e->_y0 = e->_y1; @@ -456,7 +455,6 @@ void Sprite::show() { e->_x1 = _x; e->_y1 = _y; e->_b1 = shp(); -// asm sti // ...done! if (!_flags._hide) { if (_flags._xlat) e->_b1->xShow(e->_x1, e->_y1); @@ -466,10 +464,10 @@ void Sprite::show() { } void Sprite::show(uint16 pg) { - Graphics::Surface *a = Vga::_page[1]; - Vga::_page[1] = Vga::_page[pg & 3]; + Graphics::Surface *a = _vga->_page[1]; + _vga->_page[1] = _vga->_page[pg & 3]; shp()->show(_x, _y); - Vga::_page[1] = a; + _vga->_page[1] = a; } void Sprite::hide() { @@ -673,45 +671,24 @@ Sprite *Queue::locate(int ref) { return NULL; } -//extern const char Copr[]; -Graphics::Surface *Vga::_page[4]; -Dac *Vga::_sysPal; +Vga::Vga() : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _mono(0) { + _oldColors = NULL; + _newColors = NULL; + _showQ = new Queue(true); + _spareQ = new Queue(false); + _sysPal = new Dac[kPalCount]; -void Vga::init() { for (int idx = 0; idx < 4; idx++) { _page[idx] = new Graphics::Surface(); _page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } - _sysPal = new Dac[kPalCount]; -} - -void Vga::deinit() { - for (int idx = 0; idx < 4; idx++) { - _page[idx]->free(); - delete _page[idx]; - } - delete[] _sysPal; -} - -Vga::Vga() - : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _mono(0) { - _oldColors = NULL; - _newColors = NULL; - _showQ = new Queue(true); - _spareQ = new Queue(false); - - bool std = true; for (int i = 10; i < 20; i++) { char *text = _text->getText(i); if (text) { debugN(1, "%s\n", text); - std = false; } } - if (std) -// warning(Copr); - warning("TODO: Fix Copr"); _oldColors = (Dac *) malloc(sizeof(Dac) * kPalCount); _newColors = (Dac *) malloc(sizeof(Dac) * kPalCount); @@ -743,6 +720,12 @@ Vga::~Vga() { delete _showQ; delete _spareQ; + delete[] _sysPal; + + for (int idx = 0; idx < 4; idx++) { + _page[idx]->free(); + delete _page[idx]; + } } void Vga::waitVR() { @@ -862,14 +845,14 @@ void Bitmap::xShow(int16 x, int16 y) { debugC(4, kCGEDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)Vga::_page[1]->pixels + (kScrWidth * kScrHeight); + byte *destEndP = (byte *)_vga->_page[1]->pixels + (kScrWidth * kScrHeight); byte *lookupTable = _m; // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; planeCtr++) { - byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); + byte *destP = (byte *)_vga->_page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -915,13 +898,13 @@ void Bitmap::show(int16 x, int16 y) { debugC(5, kCGEDebugBitmap, "Bitmap::show(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)Vga::_page[1]->pixels + (kScrWidth * kScrHeight); + byte *destEndP = (byte *)_vga->_page[1]->pixels + (kScrWidth * kScrHeight); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; planeCtr++) { - byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); + byte *destP = (byte *)_vga->_page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -979,8 +962,8 @@ void Bitmap::hide(int16 x, int16 y) { debugC(5, kCGEDebugBitmap, "Bitmap::hide(%d, %d)", x, y); for (int yp = y; yp < y + _h; yp++) { - const byte *srcP = (const byte *)Vga::_page[2]->getBasePtr(x, yp); - byte *destP = (byte *)Vga::_page[1]->getBasePtr(x, yp); + const byte *srcP = (const byte *)_vga->_page[2]->getBasePtr(x, yp); + byte *destP = (byte *)_vga->_page[1]->getBasePtr(x, yp); Common::copy(srcP, srcP + _w, destP); } -- cgit v1.2.3 From 31d41731369697ca38900b3a6a89d9a6e1ac8a8c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 1 Sep 2011 00:22:20 +0200 Subject: CGE: Fix thumbnails display when a game is loaded. --- engines/cge/vga13h.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d510b98f45..3db504425f 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -99,13 +99,8 @@ BitmapPtr Sprite::shp() { return NULL; int i = e->_seq[_seqPtr]._now; - if (i >= _shpCnt) { - //char s[256]; - //sprintf(s, "Seq=%p ShpCnt=%d SeqPtr=%d Now=%d Next=%d", - // Seq, ShpCnt, SeqPtr, Seq[SeqPtr].Now, Seq[SeqPtr].Next); - //VGA::Exit(s, File); + if (i >= _shpCnt) error("Invalid PHASE in SPRITE::Shp() %s", _file); - } return e->_shpList[i]; } -- cgit v1.2.3 From 5bad1a7c7fc14caaa8af7d51addc70c94804e435 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 6 Sep 2011 00:43:40 +0200 Subject: CGE: Take into account some of LordHoto's comments --- engines/cge/vga13h.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 3db504425f..d4643a32e1 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -685,8 +685,8 @@ Vga::Vga() : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _mono(0) { } } - _oldColors = (Dac *) malloc(sizeof(Dac) * kPalCount); - _newColors = (Dac *) malloc(sizeof(Dac) * kPalCount); + _oldColors = (Dac *)malloc(sizeof(Dac) * kPalCount); + _newColors = (Dac *)malloc(sizeof(Dac) * kPalCount); getColors(_oldColors); sunset(); setColors(); -- cgit v1.2.3 From 4848683e56b1466a7dabbbecb7bb1bf7e4c857a7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 9 Sep 2011 18:24:11 +0200 Subject: CGE: Remove some static variables from fileIO --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d4643a32e1..727cc72e39 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -226,7 +226,7 @@ Sprite *Sprite::expand() { Snail::Com *nea = NULL; Snail::Com *tak = NULL; mergeExt(fname, _file, kSprExt); - if (VFile::exist(fname)) { // sprite description file exist + if (_cat->exist(fname)) { // sprite description file exist VFile sprf(fname); if (!(sprf._error==0)) error("Bad SPR [%s]", fname); -- cgit v1.2.3 From 5c256f968966ac9cb318ad12f429141eb9b46e88 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 11 Sep 2011 22:13:00 +0200 Subject: CGE: Remove some more VFiles --- engines/cge/vga13h.cpp | 71 ++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 34 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 727cc72e39..ef085359a7 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -209,37 +209,40 @@ Sprite *Sprite::expand() { return this; static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL }; - char line[kLineMax], fname[kPathMax]; + char fname[kPathMax]; Common::Array shplist; for (int i = 0; i < _shpCnt + 1; ++i) shplist.push_back(NULL); Seq *seq = NULL; - int shpcnt = 0, - seqcnt = 0, - neacnt = 0, - takcnt = 0, + int shapeCount = 0, + seqCount = 0, + nearCount = 0, + takeCount = 0, maxnow = 0, maxnxt = 0; - Snail::Com *nea = NULL; - Snail::Com *tak = NULL; + Snail::Com *near = NULL; + Snail::Com *take = NULL; mergeExt(fname, _file, kSprExt); if (_cat->exist(fname)) { // sprite description file exist - VFile sprf(fname); - if (!(sprf._error==0)) + EncryptedStream sprf(fname); + if (sprf.err()) error("Bad SPR [%s]", fname); + Common::String line; + char tmpStr[kLineMax + 1]; int len = 0, lcnt = 0; - while ((len = sprf.read((uint8 *)line)) != 0) { + + for (line = sprf.readLine(); !sprf.eos(); line = sprf.readLine()) { + len = line.size(); + strcpy(tmpStr, line.c_str()); lcnt++; - if (len && line[len - 1] == '\n') - line[--len] = '\0'; - if (len == 0 || *line == '.') + if (len == 0 || *tmpStr == '.') continue; Snail::Com *c; - switch (takeEnum(Comd, strtok(line, " =\t"))) { + switch (takeEnum(Comd, strtok(tmpStr, " =\t"))) { case 0: // Name setName(strtok(NULL, "")); @@ -247,28 +250,28 @@ Sprite *Sprite::expand() { case 1: // Phase // In case the shape index gets too high, increase the array size - while ((shpcnt + 1) >= (int)shplist.size()) { + while ((shapeCount + 1) >= (int)shplist.size()) { shplist.push_back(NULL); ++_shpCnt; } - shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/")); + shplist[shapeCount++] = new Bitmap(strtok(NULL, " \t,;/")); break; case 2: // Seq - seq = (Seq *) realloc(seq, (seqcnt + 1) * sizeof(*seq)); + seq = (Seq *)realloc(seq, (seqCount + 1) * sizeof(*seq)); assert(seq != NULL); Seq *s; - s = &seq[seqcnt++]; + s = &seq[seqCount++]; s->_now = atoi(strtok(NULL, " \t,;/")); if (s->_now > maxnow) maxnow = s->_now; s->_next = atoi(strtok(NULL, " \t,;/")); switch (s->_next) { case 0xFF: - s->_next = seqcnt; + s->_next = seqCount; break; case 0xFE: - s->_next = seqcnt - 1; + s->_next = seqCount - 1; break; } if (s->_next > maxnxt) @@ -281,9 +284,9 @@ Sprite *Sprite::expand() { // Near if (_nearPtr == kNoPtr) break; - nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea)); - assert(nea != NULL); - c = &nea[neacnt++]; + near = (Snail::Com *)realloc(near, (nearCount + 1) * sizeof(*near)); + assert(near != NULL); + c = &near[nearCount++]; if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); @@ -294,9 +297,9 @@ Sprite *Sprite::expand() { // Take if (_takePtr == kNoPtr) break; - tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak)); - assert(tak != NULL); - c = &tak[takcnt++]; + take = (Snail::Com *)realloc(take, (takeCount + 1) * sizeof(*take)); + assert(take != NULL); + c = &take[takeCount++]; if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); @@ -307,14 +310,14 @@ Sprite *Sprite::expand() { } } else { // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new Bitmap(_file); + shplist[shapeCount++] = new Bitmap(_file); } - shplist[shpcnt] = NULL; + shplist[shapeCount] = NULL; if (seq) { - if (maxnow >= shpcnt) + if (maxnow >= shapeCount) error("Bad PHASE in SEQ [%s]", fname); - if (maxnxt >= seqcnt) + if (maxnxt >= seqCount) error("Bad JUMP in SEQ [%s]", fname); setSeq(seq); } else @@ -327,12 +330,12 @@ Sprite *Sprite::expand() { setShapeList(shapeList); - if (nea) - nea[neacnt - 1]._ptr = _ext->_near = nea; + if (near) + near[nearCount - 1]._ptr = _ext->_near = near; else _nearPtr = kNoPtr; - if (tak) - tak[takcnt - 1]._ptr = _ext->_take = tak; + if (take) + take[takeCount - 1]._ptr = _ext->_take = take; else _takePtr = kNoPtr; -- cgit v1.2.3 From 85a19d61ad603becac99c1bd71cde5173b0e6241 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 12 Sep 2011 07:01:21 +0200 Subject: CGE: Remove debug messages, fix a warning --- engines/cge/vga13h.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index ef085359a7..93b729e5ec 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -681,13 +681,15 @@ Vga::Vga() : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _mono(0) { _page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } +#if 0 + // This part was used to display credits at the beginning of the game for (int i = 10; i < 20; i++) { char *text = _text->getText(i); if (text) { debugN(1, "%s\n", text); } } - +#endif _oldColors = (Dac *)malloc(sizeof(Dac) * kPalCount); _newColors = (Dac *)malloc(sizeof(Dac) * kPalCount); getColors(_oldColors); -- cgit v1.2.3 From a029bb865634bb5138e335ed4acf098997785b9f Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 12 Sep 2011 09:13:19 +0200 Subject: CGE: Build fixes for WinCE. Rename 'near' to 'nearList' (and the same for 'take' to be consistent). Also, replace a silly cast with memset to squish a warning. --- engines/cge/vga13h.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 93b729e5ec..77f51db6f6 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -74,7 +74,7 @@ Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) _next(NULL), _prev(NULL), _seqPtr(kNoSeq), _time(0), _ext(NULL), _ref(-1), _cave(0), _vm(vm) { memset(_file, 0, sizeof(_file)); - *((uint16 *)&_flags) = 0; + memset(&_flags, 0, sizeof(_flags)); _ref = 0; _x = _y = 0; _w = _h = 0; @@ -223,8 +223,8 @@ Sprite *Sprite::expand() { maxnow = 0, maxnxt = 0; - Snail::Com *near = NULL; - Snail::Com *take = NULL; + Snail::Com *nearList = NULL; + Snail::Com *takeList = NULL; mergeExt(fname, _file, kSprExt); if (_cat->exist(fname)) { // sprite description file exist EncryptedStream sprf(fname); @@ -284,9 +284,9 @@ Sprite *Sprite::expand() { // Near if (_nearPtr == kNoPtr) break; - near = (Snail::Com *)realloc(near, (nearCount + 1) * sizeof(*near)); - assert(near != NULL); - c = &near[nearCount++]; + nearList = (Snail::Com *)realloc(nearList, (nearCount + 1) * sizeof(*nearList)); + assert(nearList != NULL); + c = &nearList[nearCount++]; if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); @@ -297,9 +297,9 @@ Sprite *Sprite::expand() { // Take if (_takePtr == kNoPtr) break; - take = (Snail::Com *)realloc(take, (takeCount + 1) * sizeof(*take)); - assert(take != NULL); - c = &take[takeCount++]; + takeList = (Snail::Com *)realloc(takeList, (takeCount + 1) * sizeof(*takeList)); + assert(takeList != NULL); + c = &takeList[takeCount++]; if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); @@ -330,12 +330,12 @@ Sprite *Sprite::expand() { setShapeList(shapeList); - if (near) - near[nearCount - 1]._ptr = _ext->_near = near; + if (nearList) + nearList[nearCount - 1]._ptr = _ext->_near = nearList; else _nearPtr = kNoPtr; - if (take) - take[takeCount - 1]._ptr = _ext->_take = take; + if (takeList) + takeList[takeCount - 1]._ptr = _ext->_take = takeList; else _takePtr = kNoPtr; -- cgit v1.2.3 From 82e0b6fc4bb719e9b3e647c3fcb40cefec9fcd28 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 14 Sep 2011 00:10:59 +0200 Subject: CGE: Rewrite fileIO --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 77f51db6f6..d01a2b25fd 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -226,7 +226,7 @@ Sprite *Sprite::expand() { Snail::Com *nearList = NULL; Snail::Com *takeList = NULL; mergeExt(fname, _file, kSprExt); - if (_cat->exist(fname)) { // sprite description file exist + if (_resman->exist(fname)) { // sprite description file exist EncryptedStream sprf(fname); if (sprf.err()) error("Bad SPR [%s]", fname); -- cgit v1.2.3 From d28ac81a12958db77868fe889c0b93c902a5bdc3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 14 Sep 2011 08:15:30 +0200 Subject: CGE: Rename cave into scene --- engines/cge/vga13h.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index d01a2b25fd..9df61fa8a3 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -72,7 +72,7 @@ Sprite *locate(int ref) { Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(kNoSeq), _time(0), - _ext(NULL), _ref(-1), _cave(0), _vm(vm) { + _ext(NULL), _ref(-1), _scene(0), _vm(vm) { memset(_file, 0, sizeof(_file)); memset(&_flags, 0, sizeof(_flags)); _ref = 0; @@ -496,7 +496,7 @@ void Sprite::sync(Common::Serializer &s) { s.syncAsUint16LE(unused); s.syncAsUint16LE(unused); // _ext s.syncAsUint16LE(_ref); - s.syncAsByte(_cave); + s.syncAsByte(_scene); // bitfield in-memory storage is unpredictable, so to avoid // any issues, pack/unpack everything manually @@ -944,17 +944,6 @@ void Bitmap::show(int16 x, int16 y) { srcP++; } } -/* - DEBUG code to display image immediately - // Temporary - g_system->copyRectToScreen((const byte *)VGA::Page[1]->getBasePtr(0, 0), SCR_WID, 0, 0, SCR_WID, SCR_HIG); - byte palData[PAL_SIZ]; - VGA::DAC2pal(VGA::SysPal, palData); - g_system->getPaletteManager()->setPalette(palData, 0, PAL_CNT); - - g_system->updateScreen(); - g_system->delayMillis(5000); -*/ } @@ -980,7 +969,7 @@ HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { setShapeList(HL); } -CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) { +SceneLight::SceneLight(CGEEngine *vm): Sprite(vm, NULL) { // Set the sprite list BitmapPtr *PR = new BitmapPtr[2]; PR[0] = new Bitmap("PRESS"); -- cgit v1.2.3 From c99310820720714083b34d7d01080c54c977eb75 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 15 Sep 2011 07:58:31 +0200 Subject: CGE: Transform some static and globals into class members --- engines/cge/vga13h.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 9df61fa8a3..286fadd1ef 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -225,7 +225,7 @@ Sprite *Sprite::expand() { Snail::Com *nearList = NULL; Snail::Com *takeList = NULL; - mergeExt(fname, _file, kSprExt); + _vm->mergeExt(fname, _file, kSprExt); if (_resman->exist(fname)) { // sprite description file exist EncryptedStream sprf(fname); if (sprf.err()) @@ -242,7 +242,7 @@ Sprite *Sprite::expand() { continue; Snail::Com *c; - switch (takeEnum(Comd, strtok(tmpStr, " =\t"))) { + switch (_vm->takeEnum(Comd, strtok(tmpStr, " =\t"))) { case 0: // Name setName(strtok(NULL, "")); @@ -287,7 +287,7 @@ Sprite *Sprite::expand() { nearList = (Snail::Com *)realloc(nearList, (nearCount + 1) * sizeof(*nearList)); assert(nearList != NULL); c = &nearList[nearCount++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) + if ((c->_com = (SnCom)_vm->takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); @@ -300,7 +300,7 @@ Sprite *Sprite::expand() { takeList = (Snail::Com *)realloc(takeList, (takeCount + 1) * sizeof(*takeList)); assert(takeList != NULL); c = &takeList[takeCount++]; - if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) + if ((c->_com = (SnCom)_vm->takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); -- cgit v1.2.3 From 15bf8050b822db25c3ab4802c0e8438d0151a3cd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 16 Sep 2011 06:45:28 +0200 Subject: CGE: Move two globals functions to CGEEngine --- engines/cge/vga13h.cpp | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 286fadd1ef..f0fbd630e1 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -64,11 +64,6 @@ Dac mkDac(uint8 r, uint8 g, uint8 b) { return x; } -Sprite *locate(int ref) { - Sprite *spr = _vga->_showQ->locate(ref); - return (spr) ? spr : _vga->_spareQ->locate(ref); -} - Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(kNoSeq), _time(0), @@ -556,19 +551,6 @@ void Sprite::sync(Common::Serializer &s) { s.syncAsUint16LE(unused); // _next } -Sprite *spriteAt(int x, int y) { - Sprite *spr = NULL, * tail = _vga->_showQ->last(); - if (tail) { - for (spr = tail->_prev; spr; spr = spr->_prev) { - if (! spr->_flags._hide && ! spr->_flags._tran) { - if (spr->shp()->solidAt(x - spr->_x, y - spr->_y)) - break; - } - } - } - return spr; -} - Queue::Queue(bool show) : _head(NULL), _tail(NULL), _show(show) { } -- cgit v1.2.3 From 70c5b695df24dd9da6d7838939d3c448f602471a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 16 Sep 2011 07:55:50 +0200 Subject: CGE: move two global functions to Vga --- engines/cge/vga13h.cpp | 51 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index f0fbd630e1..3d092e755c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -54,16 +54,6 @@ Seq *getConstantSeq(bool seqFlag) { return seq; } -extern "C" void SNDMIDIPlay(); - -Dac mkDac(uint8 r, uint8 g, uint8 b) { - static Dac x; - x._r = r; - x._g = g; - x._b = b; - return x; -} - Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(kNoSeq), _time(0), @@ -722,6 +712,47 @@ void Vga::getColors(Dac *tab) { palToDac(palData, tab); } +uint8 Vga::closest(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB) { +#define f(col, lum) ((((uint16)(col)) << 8) / lum) + uint16 i, dif = 0xFFFF, found = 0; + uint16 L = colR + colG + colB; + if (!L) + L++; + uint16 R = f(colR, L), G = f(colG, L), B = f(colB, L); + for (i = 0; i < 256; i++) { + uint16 l = pal[i]._r + pal[i]._g + pal[i]._b; + if (!l) + l++; + int r = f(pal[i]._r, l), g = f(pal[i]._g, l), b = f(pal[i]._b, l); + uint16 D = ((r > R) ? (r - R) : (R - r)) + + ((g > G) ? (g - G) : (G - g)) + + ((b > B) ? (b - B) : (B - b)) + + ((l > L) ? (l - L) : (L - l)) * 10 ; + + if (D < dif) { + found = i; + dif = D; + if (D == 0) + break; // exact! + } + } + return found; +#undef f +} + +uint8 *Vga::glass(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB) { + uint8 *x = (uint8 *)malloc(256); + if (x) { + uint16 i; + for (i = 0; i < 256; i++) { + x[i] = closest(pal, ((uint16)(pal[i]._r) * colR) / 255, + ((uint16)(pal[i]._g) * colG) / 255, + ((uint16)(pal[i]._b) * colB) / 255); + } + } + return x; +} + void Vga::palToDac(const byte *palData, Dac *tab) { const byte *colP = palData; for (int idx = 0; idx < kPalCount; idx++, colP += 3) { -- cgit v1.2.3 From 0668a56f69797d26ab074d6949ed6c7870791e53 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 16 Sep 2011 23:54:08 +0200 Subject: CGE: Move _vga to CGEEngine --- engines/cge/vga13h.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 3d092e755c..84c2329b79 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -239,7 +239,7 @@ Sprite *Sprite::expand() { shplist.push_back(NULL); ++_shpCnt; } - shplist[shapeCount++] = new Bitmap(strtok(NULL, " \t,;/")); + shplist[shapeCount++] = new Bitmap(_vm, strtok(NULL, " \t,;/")); break; case 2: // Seq @@ -295,7 +295,7 @@ Sprite *Sprite::expand() { } } else { // no sprite description: try to read immediately from .BMP - shplist[shapeCount++] = new Bitmap(_file); + shplist[shapeCount++] = new Bitmap(_vm, _file); } shplist[shapeCount] = NULL; @@ -447,10 +447,10 @@ void Sprite::show() { } void Sprite::show(uint16 pg) { - Graphics::Surface *a = _vga->_page[1]; - _vga->_page[1] = _vga->_page[pg & 3]; + Graphics::Surface *a = _vm->_vga->_page[1]; + _vm->_vga->_page[1] = _vm->_vga->_page[pg & 3]; shp()->show(_x, _y); - _vga->_page[1] = a; + _vm->_vga->_page[1] = a; } void Sprite::hide() { @@ -464,7 +464,7 @@ BitmapPtr Sprite::ghost() { if (!e->_b1) return NULL; - BitmapPtr bmp = new Bitmap(0, 0, (uint8 *)NULL); + BitmapPtr bmp = new Bitmap(_vm, 0, 0, (uint8 *)NULL); assert(bmp != NULL); bmp->_w = e->_b1->_w; bmp->_h = e->_b1->_h; @@ -858,14 +858,14 @@ void Bitmap::xShow(int16 x, int16 y) { debugC(4, kCGEDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)_vga->_page[1]->pixels + (kScrWidth * kScrHeight); + byte *destEndP = (byte *)_vm->_vga->_page[1]->pixels + (kScrWidth * kScrHeight); byte *lookupTable = _m; // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; planeCtr++) { - byte *destP = (byte *)_vga->_page[1]->getBasePtr(x + planeCtr, y); + byte *destP = (byte *)_vm->_vga->_page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -911,13 +911,13 @@ void Bitmap::show(int16 x, int16 y) { debugC(5, kCGEDebugBitmap, "Bitmap::show(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)_vga->_page[1]->pixels + (kScrWidth * kScrHeight); + byte *destEndP = (byte *)_vm->_vga->_page[1]->pixels + (kScrWidth * kScrHeight); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; planeCtr++) { - byte *destP = (byte *)_vga->_page[1]->getBasePtr(x + planeCtr, y); + byte *destP = (byte *)_vm->_vga->_page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -964,8 +964,8 @@ void Bitmap::hide(int16 x, int16 y) { debugC(5, kCGEDebugBitmap, "Bitmap::hide(%d, %d)", x, y); for (int yp = y; yp < y + _h; yp++) { - const byte *srcP = (const byte *)_vga->_page[2]->getBasePtr(x, yp); - byte *destP = (byte *)_vga->_page[1]->getBasePtr(x, yp); + const byte *srcP = (const byte *)_vm->_vga->_page[2]->getBasePtr(x, yp); + byte *destP = (byte *)_vm->_vga->_page[1]->getBasePtr(x, yp); Common::copy(srcP, srcP + _w, destP); } @@ -973,41 +973,41 @@ void Bitmap::hide(int16 x, int16 y) { /*--------------------------------------------------------------------------*/ -HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) { +HorizLine::HorizLine(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { // Set the sprite list BitmapPtr *HL = new BitmapPtr[2]; - HL[0] = new Bitmap("HLINE"); + HL[0] = new Bitmap(_vm, "HLINE"); HL[1] = NULL; setShapeList(HL); } -SceneLight::SceneLight(CGEEngine *vm): Sprite(vm, NULL) { +SceneLight::SceneLight(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { // Set the sprite list BitmapPtr *PR = new BitmapPtr[2]; - PR[0] = new Bitmap("PRESS"); + PR[0] = new Bitmap(_vm, "PRESS"); PR[1] = NULL; setShapeList(PR); } -Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) { +Spike::Spike(CGEEngine *vm): Sprite(vm, NULL), _vm(vm) { // Set the sprite list BitmapPtr *SP = new BitmapPtr[3]; - SP[0] = new Bitmap("SPK_L"); - SP[1] = new Bitmap("SPK_R"); + SP[0] = new Bitmap(_vm, "SPK_L"); + SP[1] = new Bitmap(_vm, "SPK_R"); SP[2] = NULL; setShapeList(SP); } -PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) { +PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL), _vm(vm) { // Set the sprite list BitmapPtr *LI = new BitmapPtr[5]; - LI[0] = new Bitmap("LITE0"); - LI[1] = new Bitmap("LITE1"); - LI[2] = new Bitmap("LITE2"); - LI[3] = new Bitmap("LITE3"); + LI[0] = new Bitmap(_vm, "LITE0"); + LI[1] = new Bitmap(_vm, "LITE1"); + LI[2] = new Bitmap(_vm, "LITE2"); + LI[3] = new Bitmap(_vm, "LITE3"); LI[4] = NULL; setShapeList(LI); -- cgit v1.2.3 From 4778ff720c3e7c6527dde90c9eba7ccab7646cbb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 17 Sep 2011 10:54:50 +0200 Subject: CGE: Move some more globals to CGEEngine --- engines/cge/vga13h.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 84c2329b79..75c04e70eb 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -72,8 +72,8 @@ Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) } Sprite::~Sprite() { - if (_sprite == this) - _sprite = NULL; + if (_vm->_sprite == this) + _vm->_sprite = NULL; contract(); } @@ -211,8 +211,8 @@ Sprite *Sprite::expand() { Snail::Com *nearList = NULL; Snail::Com *takeList = NULL; _vm->mergeExt(fname, _file, kSprExt); - if (_resman->exist(fname)) { // sprite description file exist - EncryptedStream sprf(fname); + if (_vm->_resman->exist(fname)) { // sprite description file exist + EncryptedStream sprf(_vm, fname); if (sprf.err()) error("Bad SPR [%s]", fname); Common::String line; -- cgit v1.2.3 From 9c5415b6ae63a685abdbb523bdb091b9e8feebb0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 17 Sep 2011 19:11:40 +0200 Subject: CGE: Remove useless function Thanks fuzzie for noticing it --- engines/cge/vga13h.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 75c04e70eb..531c5f1f71 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -556,15 +556,6 @@ void Queue::clear() { } } -void Queue::forAll(void (*fun)(Sprite *)) { - Sprite *s = _head; - while (s) { - Sprite *n = s->_next; - fun(s); - s = n; - } -} - void Queue::append(Sprite *spr) { if (_tail) { spr->_prev = _tail; -- cgit v1.2.3 From 17802f8903d82cd703cc1ede8d2b91291826248e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 17 Sep 2011 23:03:37 +0200 Subject: CGE: Fix a potential bug in insertCommand(), some renaming --- engines/cge/vga13h.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 531c5f1f71..02ed4ba74c 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -126,7 +126,7 @@ bool Sprite::works(Sprite *spr) { if (!spr || !spr->_ext) return false; - Snail::Com *c = spr->_ext->_take; + Snail::Command *c = spr->_ext->_take; if (c != NULL) { c += spr->_takePtr; if (c->_ref == _ref) @@ -162,7 +162,7 @@ bool Sprite::seqTest(int n) { return true; } -Snail::Com *Sprite::snList(SnList type) { +Snail::Command *Sprite::snList(SnList type) { SprExt *e = _ext; if (e) return (type == kNear) ? e->_near : e->_take; @@ -208,8 +208,8 @@ Sprite *Sprite::expand() { maxnow = 0, maxnxt = 0; - Snail::Com *nearList = NULL; - Snail::Com *takeList = NULL; + Snail::Command *nearList = NULL; + Snail::Command *takeList = NULL; _vm->mergeExt(fname, _file, kSprExt); if (_vm->_resman->exist(fname)) { // sprite description file exist EncryptedStream sprf(_vm, fname); @@ -226,7 +226,7 @@ Sprite *Sprite::expand() { if (len == 0 || *tmpStr == '.') continue; - Snail::Com *c; + Snail::Command *c; switch (_vm->takeEnum(Comd, strtok(tmpStr, " =\t"))) { case 0: // Name @@ -269,27 +269,27 @@ Sprite *Sprite::expand() { // Near if (_nearPtr == kNoPtr) break; - nearList = (Snail::Com *)realloc(nearList, (nearCount + 1) * sizeof(*nearList)); + nearList = (Snail::Command *)realloc(nearList, (nearCount + 1) * sizeof(*nearList)); assert(nearList != NULL); c = &nearList[nearCount++]; if ((c->_com = (SnCom)_vm->takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); - c->_ptr = NULL; - break; + c->_spritePtr = NULL; + break; case 4: // Take if (_takePtr == kNoPtr) break; - takeList = (Snail::Com *)realloc(takeList, (takeCount + 1) * sizeof(*takeList)); + takeList = (Snail::Command *)realloc(takeList, (takeCount + 1) * sizeof(*takeList)); assert(takeList != NULL); c = &takeList[takeCount++]; if ((c->_com = (SnCom)_vm->takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); - c->_ptr = NULL; + c->_spritePtr = NULL; break; } } @@ -316,11 +316,11 @@ Sprite *Sprite::expand() { setShapeList(shapeList); if (nearList) - nearList[nearCount - 1]._ptr = _ext->_near = nearList; + nearList[nearCount - 1]._spritePtr = _ext->_near = nearList; else _nearPtr = kNoPtr; if (takeList) - takeList[takeCount - 1]._ptr = _ext->_take = takeList; + takeList[takeCount - 1]._spritePtr = _ext->_take = takeList; else _takePtr = kNoPtr; @@ -982,7 +982,7 @@ SceneLight::SceneLight(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { setShapeList(PR); } -Spike::Spike(CGEEngine *vm): Sprite(vm, NULL), _vm(vm) { +Speaker::Speaker(CGEEngine *vm): Sprite(vm, NULL), _vm(vm) { // Set the sprite list BitmapPtr *SP = new BitmapPtr[3]; SP[0] = new Bitmap(_vm, "SPK_L"); -- cgit v1.2.3 From 2d882fdf18f9c43fb73d669e9b4b02f65351d4a3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 18 Sep 2011 11:25:34 +0200 Subject: CGE: Rename Snail into CommandHandler, plus some associated renamings --- engines/cge/vga13h.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'engines/cge/vga13h.cpp') diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 02ed4ba74c..49cfcd3084 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -126,11 +126,11 @@ bool Sprite::works(Sprite *spr) { if (!spr || !spr->_ext) return false; - Snail::Command *c = spr->_ext->_take; + CommandHandler::Command *c = spr->_ext->_take; if (c != NULL) { c += spr->_takePtr; if (c->_ref == _ref) - if (c->_com != kSnLabel || (c->_val == 0 || c->_val == _vm->_now)) + if (c->_commandType != kCmdLabel || (c->_val == 0 || c->_val == _vm->_now)) return true; } @@ -162,7 +162,7 @@ bool Sprite::seqTest(int n) { return true; } -Snail::Command *Sprite::snList(SnList type) { +CommandHandler::Command *Sprite::snList(SnList type) { SprExt *e = _ext; if (e) return (type == kNear) ? e->_near : e->_take; @@ -208,8 +208,8 @@ Sprite *Sprite::expand() { maxnow = 0, maxnxt = 0; - Snail::Command *nearList = NULL; - Snail::Command *takeList = NULL; + CommandHandler::Command *nearList = NULL; + CommandHandler::Command *takeList = NULL; _vm->mergeExt(fname, _file, kSprExt); if (_vm->_resman->exist(fname)) { // sprite description file exist EncryptedStream sprf(_vm, fname); @@ -226,7 +226,7 @@ Sprite *Sprite::expand() { if (len == 0 || *tmpStr == '.') continue; - Snail::Command *c; + CommandHandler::Command *c; switch (_vm->takeEnum(Comd, strtok(tmpStr, " =\t"))) { case 0: // Name @@ -269,10 +269,10 @@ Sprite *Sprite::expand() { // Near if (_nearPtr == kNoPtr) break; - nearList = (Snail::Command *)realloc(nearList, (nearCount + 1) * sizeof(*nearList)); + nearList = (CommandHandler::Command *)realloc(nearList, (nearCount + 1) * sizeof(*nearList)); assert(nearList != NULL); c = &nearList[nearCount++]; - if ((c->_com = (SnCom)_vm->takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) + if ((c->_commandType = (CommandType)_vm->takeEnum(CommandHandler::_commandText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); @@ -282,10 +282,10 @@ Sprite *Sprite::expand() { // Take if (_takePtr == kNoPtr) break; - takeList = (Snail::Command *)realloc(takeList, (takeCount + 1) * sizeof(*takeList)); + takeList = (CommandHandler::Command *)realloc(takeList, (takeCount + 1) * sizeof(*takeList)); assert(takeList != NULL); c = &takeList[takeCount++]; - if ((c->_com = (SnCom)_vm->takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0) + if ((c->_commandType = (CommandType)_vm->takeEnum(CommandHandler::_commandText, strtok(NULL, " \t,;/"))) < 0) error("Bad NEAR in %d [%s]", lcnt, fname); c->_ref = atoi(strtok(NULL, " \t,;/")); c->_val = atoi(strtok(NULL, " \t,;/")); -- cgit v1.2.3