From c37c19a8cfc04249d4b85e4d91122bd0998ca145 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 8 Jun 2008 14:59:52 +0000 Subject: pointer -> memPtr Des_RLE -> decodeRLE Des_OFF -> decodeOffset Lenght -> length Removed duplicate code for RLE decoding svn-id: r32617 --- engines/drascula/drascula.h | 6 ++-- engines/drascula/graphics.cpp | 76 +++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 50 deletions(-) (limited to 'engines/drascula') diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index fa9a036063..76814e5844 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -286,7 +286,7 @@ public: byte *screenSurface; byte *frontSurface; byte *textSurface; - byte *pointer; + byte *memPtr; byte *MiVideoSSN; byte *mSession; @@ -464,8 +464,8 @@ public: bool soundIsActive(); void waitFrameSSN(); void mixVideo(byte *OldScreen, byte *NewScreen); - void Des_RLE(byte *BufferRLE, byte *MiVideoRLE); - void Des_OFF(byte *BufferOFF, byte *MiVideoOFF, int Lenght); + void decodeRLE(byte *BufferRLE, byte *MiVideoRLE); + void decodeOffset(byte *BufferOFF, byte *MiVideoOFF, int length); byte *TryInMem(); int playFrameSSN(); diff --git a/engines/drascula/graphics.cpp b/engines/drascula/graphics.cpp index 533f7cc0c5..054e8f13aa 100644 --- a/engines/drascula/graphics.cpp +++ b/engines/drascula/graphics.cpp @@ -119,35 +119,14 @@ void DrasculaEngine::loadPic(const char *NamePcc, byte *targetSurface, int color } void DrasculaEngine::showFrame(bool firstFrame) { - bool stopProcessing = false; - byte pixel; - uint repeat, curByte = 0; - int dataSize = _arj.readSint32LE(); byte *pcxData = (byte *)malloc(dataSize); _arj.read(pcxData, dataSize); _arj.read(cPal, 768); - byte *srcPtr = pcxData; - byte *dstPtr = VGA; byte *prevFrame = (byte *)malloc(64000); memcpy(prevFrame, VGA, 64000); - while (!stopProcessing) { - pixel = *srcPtr++; - repeat = 1; - if ((pixel & 192) == 192) { - repeat = (pixel & 63); - pixel = *srcPtr++; - } - for (uint j = 0; j < repeat; j++) { - curByte++; - if (curByte > 64000) { - stopProcessing = true; - break; - } - *dstPtr++ = pixel; - } - } + decodeRLE(pcxData, VGA); free(pcxData); @@ -502,7 +481,7 @@ void DrasculaEngine::playFLI(const char *filefli, int vel) { free(MiVideoSSN); if (UsingMem) - free(pointer); + free(memPtr); else _arj.close(); } @@ -550,7 +529,7 @@ int DrasculaEngine::playFrameSSN() { memcpy(BufferSSN, mSession, Lengt); mSession += Lengt; } - Des_RLE(BufferSSN, MiVideoSSN); + decodeRLE(BufferSSN, MiVideoSSN); free(BufferSSN); waitFrameSSN(); if (FrameSSN) @@ -569,7 +548,7 @@ int DrasculaEngine::playFrameSSN() { memcpy(BufferSSN, mSession, Lengt); mSession += Lengt; } - Des_OFF(BufferSSN, MiVideoSSN, Lengt); + decodeOffset(BufferSSN, MiVideoSSN, Lengt); free(BufferSSN); waitFrameSSN(); if (FrameSSN) @@ -599,23 +578,23 @@ byte *DrasculaEngine::TryInMem() { _arj.seek(0, SEEK_END); Lengt = _arj.pos(); _arj.seek(0, SEEK_SET); - pointer = (byte *)malloc(Lengt); - if (pointer == NULL) + memPtr = (byte *)malloc(Lengt); + if (memPtr == NULL) return NULL; - _arj.read(pointer, Lengt); + _arj.read(memPtr, Lengt); UsingMem = 1; _arj.close(); - return pointer; + return memPtr; } -void DrasculaEngine::Des_OFF(byte *BufferOFF, byte *MiVideoOFF, int Lenght) { +void DrasculaEngine::decodeOffset(byte *BufferOFF, byte *MiVideoOFF, int length) { int x = 0; unsigned char Reps; int Offset; memset(MiVideoSSN, 0, 64000); - while (x < Lenght) { + while (x < length) { Offset = BufferOFF[x] + BufferOFF[x + 1] * 256; Reps = BufferOFF[x + 2]; memcpy(MiVideoOFF + Offset, &BufferOFF[x + 3], Reps); @@ -623,23 +602,26 @@ void DrasculaEngine::Des_OFF(byte *BufferOFF, byte *MiVideoOFF, int Lenght) { } } -void DrasculaEngine::Des_RLE(byte *BufferRLE, byte *MiVideoRLE) { - signed int con = 0; - unsigned int X = 0; - unsigned int fExit = 0; - char ch, rep; - while (!fExit) { - ch = *BufferRLE++; - rep = 1; - if ((ch & 192) == 192) { - rep = (ch & 63); - ch =* BufferRLE++; +void DrasculaEngine::decodeRLE(byte* srcPtr, byte* dstPtr) { + bool stopProcessing = false; + byte pixel; + uint repeat; + int curByte = 0; + + while (!stopProcessing) { + pixel = *srcPtr++; + repeat = 1; + if ((pixel & 192) == 192) { + repeat = (pixel & 63); + pixel = *srcPtr++; } - for (con = 0; con < rep; con++) { - *MiVideoRLE++ = ch; - X++; - if (X > 64000) - fExit = 1; + for (uint j = 0; j < repeat; j++) { + curByte++; + if (curByte > 64000) { + stopProcessing = true; + break; + } + *dstPtr++ = pixel; } } } -- cgit v1.2.3