diff options
author | Vincent Hamm | 2007-12-24 01:05:36 +0000 |
---|---|---|
committer | Vincent Hamm | 2007-12-24 01:05:36 +0000 |
commit | 2d9d0f1b1ff9c76aedb587b89bc4e87d81f87ae2 (patch) | |
tree | 5f385232e38f9c13c31659a2413163a8d45ea80c | |
parent | 15469b47b5c9883636e775a31e44e6b4bc43dccb (diff) | |
download | scummvm-rg350-2d9d0f1b1ff9c76aedb587b89bc4e87d81f87ae2.tar.gz scummvm-rg350-2d9d0f1b1ff9c76aedb587b89bc4e87d81f87ae2.tar.bz2 scummvm-rg350-2d9d0f1b1ff9c76aedb587b89bc4e87d81f87ae2.zip |
-Fade in/fade out
-Implement background mode 5
svn-id: r29968
-rw-r--r-- | engines/cruise/background.cpp | 115 | ||||
-rw-r--r-- | engines/cruise/cruise.cpp | 2 | ||||
-rw-r--r-- | engines/cruise/cruise_main.cpp | 22 | ||||
-rw-r--r-- | engines/cruise/dataLoader.cpp | 3 | ||||
-rw-r--r-- | engines/cruise/function.cpp | 18 | ||||
-rw-r--r-- | engines/cruise/gfxModule.cpp | 61 | ||||
-rw-r--r-- | engines/cruise/gfxModule.h | 12 | ||||
-rw-r--r-- | engines/cruise/mainDraw.cpp | 50 | ||||
-rw-r--r-- | engines/cruise/mainDraw.h | 1 | ||||
-rw-r--r-- | engines/cruise/saveload.cpp | 14 | ||||
-rw-r--r-- | engines/cruise/various.cpp | 2 | ||||
-rw-r--r-- | engines/cruise/various.h | 2 | ||||
-rw-r--r-- | engines/cruise/vars.cpp | 11 | ||||
-rw-r--r-- | engines/cruise/vars.h | 14 |
14 files changed, 223 insertions, 104 deletions
diff --git a/engines/cruise/background.cpp b/engines/cruise/background.cpp index c346512ab2..11d70c06de 100644 --- a/engines/cruise/background.cpp +++ b/engines/cruise/background.cpp @@ -93,14 +93,7 @@ int loadBackground(const char *name, int idx) { printf("Loading BG: %s\n", name); if (!backgroundPtrtable[idx]) { - //if (!gfxModuleData.useEGA && !gfxModuleData.useVGA) - { - backgroundPtrtable[idx] = - (uint8 *) mallocAndZero(320 * 200 /*64000 */ ); - } -/* else { - backgroundPtrtable[idx] = hwMemAddr[idx]; - } */ + backgroundPtrtable[idx] = (uint8 *)mallocAndZero(320 * 200); } if (!backgroundPtrtable[idx]) { @@ -126,63 +119,83 @@ int loadBackground(const char *name, int idx) { ptr2 = ptrToFree; if (!strcmp(name, "LOGO.PI1")) { - bgVar3 = bgVar2; - bgVar1 = 1; - bgVar2 = 1; - } else { - if (bgVar1) { - bgVar2 = bgVar3; - bgVar1 = 0; - } + oldSpeedGame = speedGame; + flagSpeed = 1; + speedGame = 1; + } else if (flagSpeed) { + speedGame = oldSpeedGame; + flagSpeed = 0; } if (!strcmp((char*)ptr, "PAL")) { printf("Pal loading unsupported !\n"); - exit(1); + ASSERT(0); } else { - if (!colorMode || ptr2[1] == 5) { - ptr2 += 2; + int mode = ptr2[1]; + ptr2 += 2; + // read palette + switch(mode) + { + case 4: // color on 3 bit + { + uint16 oldPalette[32]; + + memcpy(oldPalette, ptr2, 0x20); + ptr2 += 0x20; + flipGen(oldPalette, 0x20); + + for(unsigned long int i=0; i<32; i++) + { + gfxModuleData_convertOldPalColor(oldPalette[i], &palScreen[idx][i*3]); + } + ptr2 += 32000; + break; + } + case 5: // color on 4 bit + { + for(unsigned long int i=0; i<32; i++) + { + uint8* inPtr = ptr2 + i * 2; + uint8* outPtr = palScreen[idx] +i * 3; + + outPtr[2] = ((inPtr[1])&0x0F) << 4; + outPtr[1] = (((inPtr[1])&0xF0) >> 4) << 4; + outPtr[0] = ((inPtr[0])&0x0F) << 4; + } + ptr2 += 2*32; + break; + } + case 8: + memcpy(palScreen[idx], ptr2, 256*3); + ptr2 += 256*3; + break; - memcpy(palette, ptr2, 0x20); - ptr2 += 0x20; - flipGen(palette, 0x20); - ptr2 += 0x7D00; + default: + ASSERT(0); + } - loadMEN(&ptr2); - loadCVT(&ptr2); + gfxModuleData_setPal256(palScreen[idx]); - gfxModuleData_gfxClearFrameBuffer(backgroundPtrtable - [idx]); - gfxModuleData_field_60((char *)ptrToFree + 34, 20, 200, - (char *)backgroundPtrtable[idx], 0, 0); + loadMEN(&ptr2); + loadCVT(&ptr2); - gfxModuleData_setPal((uint8 *) (palette + (idx << 6))); - } else if (ptr2[1] == 8) { - int i; - ptr2 += 2; - - for (i = 0; i < 256 * 3; i++) { - palette[i] = ptr2[i]; - } - //memcpy(palette,ptr2,256*3); - ptr2 += 256 * 3; + // read image data + gfxModuleData_gfxClearFrameBuffer(backgroundPtrtable[idx]); + switch(mode) + { + case 4: + convertGfxFromMode4(ptr2, 320, 200, backgroundPtrtable[idx]); + break; + case 5: + convertGfxFromMode5(ptr2, 320, 200, backgroundPtrtable[idx]); + break; + case 8: memcpy(backgroundPtrtable[idx], ptr2, 320 * 200); - - gfxModuleData_setPal256(palette); + break; } } - //if (ptrToFree != gfxModuleData.pPage10) - // free(ptrToFree); - - if (gfxModuleData.useEGA || gfxModuleData.useTandy) { - ASSERT(0); - } - - if (gfxModuleData.useEGA || gfxModuleData.useTandy) { - ASSERT(0); - } strcpy(backgroundTable[idx].name, name); diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp index 8d6c04968e..0e840c8ca3 100644 --- a/engines/cruise/cruise.cpp +++ b/engines/cruise/cruise.cpp @@ -97,7 +97,7 @@ int CruiseEngine::go() { void CruiseEngine::initialize() { - fadeVar = 0; + PCFadeFlag = 0; ptr_something = (ctpVar19Struct *) mallocAndZero(sizeof(ctpVar19Struct) * 0x200); diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index 2d7695b7b6..14cc4e9baa 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -372,8 +372,7 @@ int loadFileSub1(uint8 **ptr, const char *name, uint8 *ptr2) { if (fileIdx < 0) return (-18); - unpackedSize = loadFileVar1 = - volumePtrToFileDescriptor[fileIdx].extSize + 2; + unpackedSize = loadFileVar1 = volumePtrToFileDescriptor[fileIdx].extSize + 2; // TODO: here, can unpack in gfx module buffer unpackedBuffer = (uint8 *) mallocAndZero(unpackedSize); @@ -385,9 +384,7 @@ int loadFileSub1(uint8 **ptr, const char *name, uint8 *ptr2) { lastFileSize = unpackedSize; if (volumePtrToFileDescriptor[fileIdx].size + 2 != unpackedSize) { - uint8 *pakedBuffer = - (uint8 *) mallocAndZero(volumePtrToFileDescriptor[fileIdx]. - size + 2); + uint8 *pakedBuffer = (uint8 *) mallocAndZero(volumePtrToFileDescriptor[fileIdx].size + 2); loadPakedFileToMem(fileIdx, pakedBuffer); @@ -1798,15 +1795,12 @@ void mainLoop(void) { if (displayOn) { if (doFade) - fadeVar = 0; + PCFadeFlag = 0; - /*if (fadeVar) - * { - * // TODO! - * } */ - - mainDraw(0); - flipScreen(); + if (!PCFadeFlag) { + mainDraw(0); + flipScreen(); + } if (userEnabled && !userWait && !autoTrack) { if (currentActiveMenu == -1) { @@ -1919,7 +1913,7 @@ int oldmain(int argc, char *argv[]) { // initBuffer(scaledScreen,640,400); - fadeVar = 0; + PCFadeFlag = 0; //lowLevelInit(); diff --git a/engines/cruise/dataLoader.cpp b/engines/cruise/dataLoader.cpp index bc13810364..c7833fe150 100644 --- a/engines/cruise/dataLoader.cpp +++ b/engines/cruise/dataLoader.cpp @@ -92,8 +92,7 @@ void decodeGfxFormat4(dataFileEntry *pCurrentFileEntry) { /* decode planes */ for (c = 0; c < 16; c++) { - buffer[x + c] = - ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8); + buffer[x + c] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8); p0 <<= 1; p1 <<= 1; diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index 38d5c966b2..87dd78e0cf 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -535,7 +535,23 @@ int16 Op_GetlowMemory(void) { } int16 Op_FadeOut(void) { - printf("Op_FadeOut dummy\n"); + for(long int i=0; i< 256; i+=32) { + for(long int j=0; j<256; j++) { + int offsetTable[3]; + offsetTable[0] = -i; + offsetTable[1] = -i; + offsetTable[2] = -i; + calcRGB(&workpal[3*j], &workpal[3*j], offsetTable); + } + gfxModuleData_setPal256(workpal); + gfxModuleData_flipScreen(); + } + + //gfxModuleData_gfxClearFrameBuffer(backgroundPtrtable[currentActiveBackgroundPlane]); + + fadeFlag = 1; + PCFadeFlag = 1; + return 0; } diff --git a/engines/cruise/gfxModule.cpp b/engines/cruise/gfxModule.cpp index dbb7614245..8a990c778e 100644 --- a/engines/cruise/gfxModule.cpp +++ b/engines/cruise/gfxModule.cpp @@ -62,9 +62,9 @@ void outputBit(char *buffer, int bitPlaneNumber, uint8 data) { *(buffer + (8000 * bitPlaneNumber)) = data; } -void gfxModuleData_field_60(char *sourcePtr, int width, int height, char *destPtr, int x_, int y_) { +void convertGfxFromMode4(uint8 *sourcePtr, int width, int height, uint8 *destPtr) { - for (int y = 0; y < height; ++y) { + for (int y = 0; y < (height/16); ++y) { for (int x = 0; x < width; ++x) { for (int bit = 0; bit < 16; ++bit) { uint8 color = 0; @@ -80,6 +80,30 @@ void gfxModuleData_field_60(char *sourcePtr, int width, int height, char *destPt } } +void convertGfxFromMode5(uint8 *sourcePtr, int width, int height, uint8 *destPtr) { + int range = (width/8) * height; + + for(int line = 0; line < 200; line++) { + uint8 p0; + uint8 p1; + uint8 p2; + uint8 p3; + uint8 p4; + + for(int col = 0; col < 40; col++) { + for(int bit = 0; bit <8; bit++ ) { + p0 = (sourcePtr[line*40 + col + range * 0] >> bit) & 1; + p1 = (sourcePtr[line*40 + col + range * 1] >> bit) & 1; + p2 = (sourcePtr[line*40 + col + range * 2] >> bit) & 1; + p3 = (sourcePtr[line*40 + col + range * 3] >> bit) & 1; + p4 = (sourcePtr[line*40 + col + range * 4] >> bit) & 1; + + destPtr[line * width + col * 8 + (7-bit)] = p0 | (p1 << 1) | (p2 << 2) | (p3 << 3) | (p4 << 4); + } + } + } +} + void gfxModuleData_setDirtyColors(int min, int max) { if (min < palDirtyMin) palDirtyMin = min; @@ -94,7 +118,7 @@ void gfxModuleData_setPalColor(int idx, int r, int g, int b) { gfxModuleData_setDirtyColors(idx, idx); } -void gfxModuleData_setPal256(int16 *ptr) { +void gfxModuleData_setPal256(uint8 *ptr) { int R; int G; int B; @@ -114,17 +138,17 @@ void gfxModuleData_setPal256(int16 *ptr) { gfxModuleData_setDirtyColors(0, 255); } -void gfxModuleData_setPal(uint8 *ptr) { +/*void gfxModuleData_setPal(uint8 *ptr) { int i; int R; int G; int B; - for (i = 0; i < 16; i++) { + for (i = 0; i < 256; i++) { #define convertRatio 36.571428571428571428571428571429 - short int atariColor = *(int16 *) ptr; + uint16 atariColor = *ptr; //flipShort(&atariColor); - ptr += 2; + ptr ++; R = (int)(convertRatio * ((atariColor & 0x700) >> 8)); G = (int)(convertRatio * ((atariColor & 0x070) >> 4)); @@ -144,6 +168,29 @@ void gfxModuleData_setPal(uint8 *ptr) { } gfxModuleData_setDirtyColors(0, 16); +}*/ + +void gfxModuleData_convertOldPalColor(uint16 oldColor, uint8* pOutput) { + int R; + int G; + int B; + +#define convertRatio 36.571428571428571428571428571429 + + R = (int)(convertRatio * ((oldColor & 0x700) >> 8)); + G = (int)(convertRatio * ((oldColor & 0x070) >> 4)); + B = (int)(convertRatio * ((oldColor & 0x007))); + + if (R > 0xFF) + R = 0xFF; + if (G > 0xFF) + G = 0xFF; + if (B > 0xFF) + B = 0xFF; + + *(pOutput++) = R; + *(pOutput++) = G; + *(pOutput++) = B; } void gfxModuleData_field_90(void) { diff --git a/engines/cruise/gfxModule.h b/engines/cruise/gfxModule.h index bd0dbbfd6f..e8fa0a6799 100644 --- a/engines/cruise/gfxModule.h +++ b/engines/cruise/gfxModule.h @@ -50,17 +50,17 @@ extern gfxModuleDataStruct gfxModuleData; void gfxModuleData_gfxClearFrameBuffer(uint8 * ptr); void gfxModuleData_setDirtyColors(int min, int max); void gfxModuleData_setPalColor(int idx, int r, int g, int b); -void gfxModuleData_setPal(uint8 * ptr); void gfxModuleData_field_90(void); void gfxModuleData_gfxWaitVSync(void); void gfxModuleData_flip(void); -void gfxModuleData_field_64(char *sourceBuffer, int width, int height, - char *dest, int x, int y, int color); +void gfxModuleData_field_64(char *sourceBuffer, int width, int height, char *dest, int x, int y, int color); void gfxModuleData_gfxCopyScreen(char *sourcePtr, char *destPtr); -void gfxModuleData_field_60(char *sourcePtr, int width, int height, - char *destPtr, int x, int y); +void convertGfxFromMode4(uint8 *sourcePtr, int width, int height, uint8 *destPtr); +void convertGfxFromMode5(uint8 *sourcePtr, int width, int height, uint8 *destPtr); void gfxModuleData_flipScreen(void); -void gfxModuleData_setPal256(int16 * ptr); +//void gfxModuleData_setPal(uint8 * ptr); +void gfxModuleData_convertOldPalColor(uint16 oldColor, uint8* pOutput); +void gfxModuleData_setPal256(uint8 * ptr); void flip(void); } // End of namespace Cruise diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp index f2d2e7f3b0..5898b032b4 100644 --- a/engines/cruise/mainDraw.cpp +++ b/engines/cruise/mainDraw.cpp @@ -81,13 +81,57 @@ void freeAutoCell(void) { } } +void calcRGB(uint8* pColorSrc, uint8* pColorDst, int* offsetTable) { + for(unsigned long int i=0; i<3; i++) { + int color = *(pColorSrc++); + int offset = offsetTable[i]; + + color += offset; + if(color < 0) + color = 0; + if(color > 0xFF) + color = 0xFF; + + *(pColorDst++) = (uint8)color; + } +} + +void fadeIn() { + for(long int i=256; i>=0; i-=32) { + for(long int j=0; j<256; j++) { + int offsetTable[3]; + offsetTable[0] = -i; + offsetTable[1] = -i; + offsetTable[2] = -i; + calcRGB(&palScreen[currentActiveBackgroundPlane][3*j], &workpal[3*j], offsetTable); + } + gfxModuleData_setPal256(workpal); + gfxModuleData_flipScreen(); + } + + for(long int j=0; j<256; j++) { + int offsetTable[3]; + offsetTable[0] = 0; + offsetTable[1] = 0; + offsetTable[2] = 0; + calcRGB(&palScreen[currentActiveBackgroundPlane][3*j], &workpal[3*j], offsetTable); + } + + gfxModuleData_setPal256(workpal); + + fadeFlag = 0; + PCFadeFlag = 0; +} + void flipScreen(void) { SWAP(gfxModuleData.pPage00, gfxModuleData.pPage10); gfxModuleData_flipScreen(); - /*memcpy(globalAtariScreen, gfxModuleData.pPage00, 16000); - * convertAtariToRaw(gfxModuleData.pPage00,globalScreen,200,320); */ + if(doFade) { + fadeIn(); + doFade = 0; + } } int spriteX1; @@ -1344,7 +1388,7 @@ void mainDraw(int16 param) { int16 objZ2 = 0; int16 spriteHeight; - if (fadeVar) { + if (PCFadeFlag) { return; } diff --git a/engines/cruise/mainDraw.h b/engines/cruise/mainDraw.h index 5e35e70220..0f51565129 100644 --- a/engines/cruise/mainDraw.h +++ b/engines/cruise/mainDraw.h @@ -44,6 +44,7 @@ void flipPoly(int fileId, int16 *dataPtr, int scale, char** newFrame, int X, int void getPolySize(int positionX, int positionY, int scale, int sizeTable[4], unsigned char *dataPtr); bool findPoly(char* dataPtr, int x, int y, int zoom, int mouseX, int mouseY); unsigned char *drawPolyMode2(unsigned char *dataPointer, int linesToDraw); +void calcRGB(uint8* pColorSrc, uint8* pColorDst, int* offsetTable); } // End of namespace Cruise #endif diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp index fa7aa56525..31721f440f 100644 --- a/engines/cruise/saveload.cpp +++ b/engines/cruise/saveload.cpp @@ -184,7 +184,7 @@ void initVars(void) buttonDown = 0; var41 = 0; entrerMenuJoueur = 0; - fadeVar = 0; + PCFadeFlag = 0; } void saveOverlay(Common::OutSaveFile& currentSaveFile) { @@ -560,8 +560,8 @@ int saveSavegameData(int saveGameIdx) { currentSaveFile->writeSint16LE(var41); currentSaveFile->writeSint16LE(entrerMenuJoueur); - currentSaveFile->write(var50, 64); - currentSaveFile->write(var50, 64); // Hu ? why 2 times ? + currentSaveFile->write(newPal, sizeof(int16) * NBCOLORS); + currentSaveFile->write(workpal, sizeof(int16) * NBCOLORS); currentSaveFile->write(musicName, 15); @@ -577,7 +577,7 @@ int saveSavegameData(int saveGameIdx) { currentSaveFile->write(backgroundTable[i].extention, 6); } - currentSaveFile->write(palette, 256*2); + currentSaveFile->write(palScreen, sizeof(int16) * NBCOLORS * NBSCREENS); currentSaveFile->write(initVar5, 24); currentSaveFile->write(globalVars, stateID * 2); // ok for(int i=0; i<257; i++) @@ -737,8 +737,8 @@ int loadSavegameData(int saveGameIdx) { var41 = currentSaveFile->readSint16LE(); entrerMenuJoueur = currentSaveFile->readSint16LE(); - currentSaveFile->read(var50, 64); - currentSaveFile->read(var50, 64); // Hu ? why 2 times ? + currentSaveFile->read(newPal, sizeof(int16) * NBCOLORS); + currentSaveFile->read(newPal, sizeof(int16) * NBCOLORS); // here code seems bogus... this should read music name and it may be a buffer overrun currentSaveFile->skip(21); @@ -752,7 +752,7 @@ int loadSavegameData(int saveGameIdx) { currentSaveFile->read(backgroundTable[i].extention, 6); } - currentSaveFile->read(palette, 256*2); + currentSaveFile->read(palScreen, sizeof(int16) * NBCOLORS * NBSCREENS); currentSaveFile->read(initVar5, 24); currentSaveFile->read(globalVars, stateID * 2); // ok for(int i=0; i<257; i++) diff --git a/engines/cruise/various.cpp b/engines/cruise/various.cpp index cf52fdb4ec..4b704dbf67 100644 --- a/engines/cruise/various.cpp +++ b/engines/cruise/various.cpp @@ -28,7 +28,7 @@ namespace Cruise { uint16 remdo = 0; -uint16 fadeVar; +uint16 PCFadeFlag; int16 readB16(void *ptr) { int16 temp; diff --git a/engines/cruise/various.h b/engines/cruise/various.h index 99b16f8c66..0bdaab305c 100644 --- a/engines/cruise/various.h +++ b/engines/cruise/various.h @@ -31,7 +31,7 @@ namespace Cruise { extern uint16 remdo; -extern uint16 fadeVar; +extern uint16 PCFadeFlag; int16 readB16(void *ptr); diff --git a/engines/cruise/vars.cpp b/engines/cruise/vars.cpp index 6a7dcd073f..bcc9ac825d 100644 --- a/engines/cruise/vars.cpp +++ b/engines/cruise/vars.cpp @@ -143,8 +143,9 @@ int16 var47; int16 var48; int16 flagCt; -int8 var50[64]; -int16 palette[256 * 3]; +uint8 newPal[NBCOLORS*3]; +uint8 workpal[NBCOLORS*3]; +uint8 palScreen[NBSCREENS][NBCOLORS*3]; //systemStringsStruct systemStrings; @@ -172,9 +173,9 @@ int16 ctpVar8[200]; int16 ctpVar14; -int16 bgVar1; -int16 bgVar2; -int16 bgVar3; +int16 flagSpeed; +int16 speedGame; +int16 oldSpeedGame; uint8 globalScreen[320 * 200]; uint8 scaledScreen[640 * 400]; diff --git a/engines/cruise/vars.h b/engines/cruise/vars.h index 2a320c268c..44945da1ed 100644 --- a/engines/cruise/vars.h +++ b/engines/cruise/vars.h @@ -30,6 +30,9 @@ namespace Cruise { +#define NBCOLORS 256 +#define NBSCREENS 8 + struct menuElementSubStruct { struct menuElementSubStruct *pNext; int16 ovlIdx; @@ -235,8 +238,9 @@ extern int16 var47; extern int16 var48; extern int16 flagCt; -extern int8 var50[64]; -extern int16 palette[256 * 3]; +extern uint8 newPal[NBCOLORS*3]; +extern uint8 workpal[NBCOLORS*3]; +extern uint8 palScreen[NBSCREENS][NBCOLORS*3]; //extern systemStringsStruct systemStrings; @@ -282,9 +286,9 @@ extern int16 ctpVar8[200]; extern int16 ctpVar14; -extern int16 bgVar1; -extern int16 bgVar2; -extern int16 bgVar3; +extern int16 flagSpeed; +extern int16 speedGame; +extern int16 oldSpeedGame; extern uint8 globalScreen[320 * 200]; extern uint8 scaledScreen[640 * 400]; |