diff options
author | Gregory Montoir | 2006-02-24 22:34:22 +0000 |
---|---|---|
committer | Gregory Montoir | 2006-02-24 22:34:22 +0000 |
commit | 481094ada0537162e11bb4ffcc2c8cbaa4f4fcea (patch) | |
tree | 9cdf38c060ebacd6da59f1282c8826ce585229bf /engines/cine | |
parent | ca504aca4fc270b277297973a2ce459c998192c5 (diff) | |
download | scummvm-rg350-481094ada0537162e11bb4ffcc2c8cbaa4f4fcea.tar.gz scummvm-rg350-481094ada0537162e11bb4ffcc2c8cbaa4f4fcea.tar.bz2 scummvm-rg350-481094ada0537162e11bb4ffcc2c8cbaa4f4fcea.zip |
cleanup
svn-id: r20846
Diffstat (limited to 'engines/cine')
-rw-r--r-- | engines/cine/anim.cpp | 16 | ||||
-rw-r--r-- | engines/cine/bg_list.cpp | 2 | ||||
-rw-r--r-- | engines/cine/cine.cpp | 9 | ||||
-rw-r--r-- | engines/cine/cine.h | 7 | ||||
-rw-r--r-- | engines/cine/flip_support.cpp | 15 | ||||
-rw-r--r-- | engines/cine/flip_support.h | 3 | ||||
-rw-r--r-- | engines/cine/gfx.cpp | 120 | ||||
-rw-r--r-- | engines/cine/main_loop.cpp | 8 | ||||
-rw-r--r-- | engines/cine/part.h | 4 | ||||
-rw-r--r-- | engines/cine/rel.cpp | 50 | ||||
-rw-r--r-- | engines/cine/rel.h | 16 | ||||
-rw-r--r-- | engines/cine/script.cpp | 2 | ||||
-rw-r--r-- | engines/cine/sfx_player.cpp | 2 | ||||
-rw-r--r-- | engines/cine/sound_driver.cpp | 48 | ||||
-rw-r--r-- | engines/cine/texte.cpp | 7 | ||||
-rw-r--r-- | engines/cine/various.cpp | 102 |
16 files changed, 160 insertions, 251 deletions
diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp index 65ef6f3891..c38c2ae90e 100644 --- a/engines/cine/anim.cpp +++ b/engines/cine/anim.cpp @@ -211,8 +211,8 @@ int16 allocFrame(uint16 width, uint16 height, int8 isMask) { animDataTable[i].width = width; animDataTable[i].var1 = width >> 3; - animDataTable[i].field_4 = 4; - animDataTable[i].var2 = height; + animDataTable[i].bpp = 4; + animDataTable[i].height = height; animDataTable[i].fileIdx = -1; animDataTable[i].frameIdx = -1; @@ -225,8 +225,8 @@ int16 allocFrame(uint16 width, uint16 height, int8 isMask) { animDataTable[i].width = width; animDataTable[i].var1 = width >> 3; - animDataTable[i].field_4 = 4; - animDataTable[i].var2 = height; + animDataTable[i].bpp = 4; + animDataTable[i].height = height; animDataTable[i].fileIdx = -1; animDataTable[i].frameIdx = -1; @@ -275,9 +275,9 @@ int16 allocFrame2(uint16 width, uint16 height, uint16 type) { animDataTable[i].var1 = width / 16; } - animDataTable[i].field_4 = type; // bbp ? + animDataTable[i].bpp = type; - animDataTable[i].var2 = height; + animDataTable[i].height = height; animDataTable[i].fileIdx = -1; animDataTable[i].frameIdx = -1; @@ -319,9 +319,9 @@ int16 reserveFrame(uint16 width, uint16 height, uint16 type, uint16 idx) { animDataTable[i].var1 = width / 16; } - animDataTable[i].field_4 = type; // bbp ? + animDataTable[i].bpp = type; - animDataTable[i].var2 = height; + animDataTable[i].height = height; animDataTable[i].fileIdx = -1; animDataTable[i].frameIdx = -1; diff --git a/engines/cine/bg_list.cpp b/engines/cine/bg_list.cpp index b102ca33fd..4671983997 100644 --- a/engines/cine/bg_list.cpp +++ b/engines/cine/bg_list.cpp @@ -36,7 +36,7 @@ void addSpriteFilledToBGList(int16 idx) { y = objectTable[idx].y; width = animDataTable[objectTable[idx].frame].width; - height = animDataTable[objectTable[idx].frame].var2; + height = animDataTable[objectTable[idx].frame].height; if (animDataTable[objectTable[idx].frame].ptr1) { gfxFillSprite(animDataTable[objectTable[idx].frame].ptr1, width / 2, height, page2Raw, x, y); diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index 4d3bd94b96..edfd5dd8a4 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -217,10 +217,11 @@ static void initialize() { } for (i = 0; i < NUM_MAX_REL; i++) { - relTable[i].ptr0 = NULL; - relTable[i].var4 = 0; - relTable[i].var6 = 0; - relTable[i].var8 = 0; + relTable[i].data = NULL; + relTable[i].size = 0; + relTable[i].obj1Param1 = 0; + relTable[i].obj1Param2 = 0; + relTable[i].obj2Param = 0; } for (i = 0; i < NUM_MAX_PARTDATA; i++) { diff --git a/engines/cine/cine.h b/engines/cine/cine.h index 54656f7934..6273708dbe 100644 --- a/engines/cine/cine.h +++ b/engines/cine/cine.h @@ -96,6 +96,13 @@ extern char *savePath; #include "cine/sfx_player.h" #include "cine/sound_driver.h" +enum { + VAR_MOUSE_X_MODE = 253, + VAR_MOUSE_X_POS = 249, + VAR_MOUSE_Y_MODE = 251, + VAR_MOUSE_Y_POS = 250 +}; + extern AdlibMusic *g_cine_adlib; #endif diff --git a/engines/cine/flip_support.cpp b/engines/cine/flip_support.cpp index 27d6a9d985..f67095179b 100644 --- a/engines/cine/flip_support.cpp +++ b/engines/cine/flip_support.cpp @@ -40,18 +40,3 @@ void flipU32(uint32 * pVar) { *pVar = (part2) | ((uint32) part1 << 16); } - -uint16 readU16LE(const void *ptr) { - const uint8 *b = (const uint8 *)ptr; - return (b[1] << 8) | b[0]; -} - -uint16 readU16BE(const void *ptr) { - const uint8 *b = (const uint8 *)ptr; - return (b[0] << 8) | b[1]; -} - -uint32 readU32BE(const void *ptr) { - const uint8 *b = (const uint8 *)ptr; - return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; -} diff --git a/engines/cine/flip_support.h b/engines/cine/flip_support.h index 536e31f66b..122b743294 100644 --- a/engines/cine/flip_support.h +++ b/engines/cine/flip_support.h @@ -27,8 +27,5 @@ void flipU16(uint16 *); void flipU32(uint32 *); -uint16 readU16LE(const void *ptr); -uint16 readU16BE(const void *ptr); -uint32 readU32BE(const void *ptr); #endif diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp index cb3e45debc..d17152a950 100644 --- a/engines/cine/gfx.cpp +++ b/engines/cine/gfx.cpp @@ -58,20 +58,17 @@ uint16 transformColor(uint16 baseColor, int8 r, int8 g, int8 b) { if (oriR < 0) oriR = 0; - - if (oriR > 7) + else if (oriR > 7) oriR = 7; if (oriG < 0) oriG = 0; - - if (oriG > 7) + else if (oriG > 7) oriG = 7; if (oriB < 0) oriB = 0; - - if (oriB > 7) + else if (oriB > 7) oriB = 7; return (oriR | (oriG << 4) | (oriB << 8)); @@ -111,12 +108,9 @@ void gfxFillSprite(uint8 *spritePtr, uint16 width, uint16 height, uint8 *page, i } void gfxDrawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint8 color, uint8 *page) { - int16 t; if (x1 == x2) { if (y1 > y2) { - t = y1; - y1 = y2; - y2 = t; + SWAP(y1, y2); } while (y1 <= y2) { *(page + (y1 * 320 + x1)) = color; @@ -124,9 +118,7 @@ void gfxDrawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint8 color, uint8 *pag } } else { if (x1 > x2) { - t = x1; - x1 = x2; - x2 = t; + SWAP(x1, x2); } while (x1 <= x2) { *(page + (y1 * 320 + x1)) = color; @@ -140,15 +132,11 @@ void gfxDrawPlainBoxRaw(int16 x1, int16 y1, int16 x2, int16 y2, uint8 color, uin int16 t; if (x1 > x2) { - t = x1; - x1 = x2; - x2 = t; + SWAP(x1, x2); } if (y1 > y2) { - t = y1; - y1 = y2; - y2 = t; + SWAP(y1, y2); } t = x1; @@ -180,78 +168,32 @@ void gfxResetRawPage(uint8 *pageRaw) { memset(pageRaw, 0, 320 * 200); } -void gfxConvertSpriteToRaw(uint8 *dest, uint8 *source, uint16 width, uint16 height) { - int x, y; - uint8 b1, b2, b3, b4, b5, b6, b7, b8, d1a, d1b, d2a, d2b, d3a, d3b, d4a, d4b; +void gfxConvertSpriteToRaw(uint8 *dst, uint8 *src, uint16 width, uint16 height) { + int x, y, d, bit, plane; + width >>= 3; for (y = 0; y < height; y++) { - for (x = 0; x < (width >> 3); x++) { - b4 = *(source++); - b8 = *(source++); - b3 = *(source++); - b7 = *(source++); - b2 = *(source++); - b6 = *(source++); - b1 = *(source++); - b5 = *(source++); - - d1a = d1b = d2a = d2b = d3a = d3b = d4a = d4b = 0; - - d1a |= (((b4 & 1) >> 0) | ((b3 & 1) << 1) | ((b2 & 1) << 2) | ((b1 & 1) << 3)) << 0; - d1b |= (((b4 & 2) >> 1) | ((b3 & 2) >> 0) | ((b2 & 2) << 1) | ((b1 & 2) << 2)) << 0; - d2a |= (((b4 & 4) >> 2) | ((b3 & 4) >> 1) | ((b2 & 4) >> 0) | ((b1 & 4) << 1)) << 0; - d2b |= (((b4 & 8) >> 3) | ((b3 & 8) >> 2) | ((b2 & 8) >> 1) | ((b1 & 8) >> 0)) << 0; - - b1 >>= 4; - b2 >>= 4; - b3 >>= 4; - b4 >>= 4; - - d3a |= (((b4 & 1) >> 0) | ((b3 & 1) << 1) | ((b2 & 1) << 2) | ((b1 & 1) << 3)) << 0; - d3b |= (((b4 & 2) >> 1) | ((b3 & 2) >> 0) | ((b2 & 2) << 1) | ((b1 & 2) << 2)) << 0; - d4a |= (((b4 & 4) >> 2) | ((b3 & 4) >> 1) | ((b2 & 4) >> 0) | ((b1 & 4) << 1)) << 0; - d4b |= (((b4 & 8) >> 3) | ((b3 & 8) >> 2) | ((b2 & 8) >> 1) | ((b1 & 8) >> 0)) << 0; - - *(dest++) = d4b; - *(dest++) = d4a; - *(dest++) = d3b; - *(dest++) = d3a; - *(dest++) = d2b; - *(dest++) = d2a; - *(dest++) = d1b; - *(dest++) = d1a; - - b1 = b5; - b2 = b6; - b3 = b7; - b4 = b8; - - d1a = d1b = d2a = d2b = d3a = d3b = d4a = d4b = 0; - - d1a |= (((b4 & 1) >> 0) | ((b3 & 1) << 1) | ((b2 & 1) << 2) | ((b1 & 1) << 3)) << 0; - d1b |= (((b4 & 2) >> 1) | ((b3 & 2) >> 0) | ((b2 & 2) << 1) | ((b1 & 2) << 2)) << 0; - d2a |= (((b4 & 4) >> 2) | ((b3 & 4) >> 1) | ((b2 & 4) >> 0) | ((b1 & 4) << 1)) << 0; - d2b |= (((b4 & 8) >> 3) | ((b3 & 8) >> 2) | ((b2 & 8) >> 1) | ((b1 & 8) >> 0)) << 0; - - b1 >>= 4; - b2 >>= 4; - b3 >>= 4; - b4 >>= 4; - - d3a |= (((b4 & 1) >> 0) | ((b3 & 1) << 1) | ((b2 & 1) << 2) | ((b1 & 1) << 3)) << 0; - d3b |= (((b4 & 2) >> 1) | ((b3 & 2) >> 0) | ((b2 & 2) << 1) | ((b1 & 2) << 2)) << 0; - d4a |= (((b4 & 4) >> 2) | ((b3 & 4) >> 1) | ((b2 & 4) >> 0) | ((b1 & 4) << 1)) << 0; - d4b |= (((b4 & 8) >> 3) | ((b3 & 8) >> 2) | ((b2 & 8) >> 1) | ((b1 & 8) >> 0)) << 0; - - *(dest++) = d4b; - *(dest++) = d4a; - *(dest++) = d3b; - *(dest++) = d3a; - *(dest++) = d2b; - *(dest++) = d2a; - *(dest++) = d1b; - *(dest++) = d1a; - + for (x = 0; x < width; x++) { + uint8 data[2][4]; + data[0][0] = *src++; + data[1][0] = *src++; + data[0][1] = *src++; + data[1][1] = *src++; + data[0][2] = *src++; + data[1][2] = *src++; + data[0][3] = *src++; + data[1][3] = *src++; + for (d = 0; d < 2; ++d) { + for (bit = 0; bit < 8; ++bit) { + uint8 color = 0; + for (plane = 0; plane < 4; ++plane) { + if (data[d][plane] & (1 << (7 - bit))) { + color |= 1 << plane; + } + } + *dst++ = color; + } + } } } } diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp index 72a4e2cc46..7898ac456b 100644 --- a/engines/cine/main_loop.cpp +++ b/engines/cine/main_loop.cpp @@ -79,7 +79,7 @@ void getMouseData(uint16 param, uint16 *pButton, uint16 *pX, uint16 *pY) { void mainLoop(int bootScriptIdx) { uint16 var_6; - uint16 var_2; + uint16 quitFlag; uint16 i; char *di; uint16 mouseButton; @@ -105,7 +105,7 @@ void mainLoop(int bootScriptIdx) { gfxFuncGen2(); - var_2 = 0; + quitFlag = 0; allowPlayerInput = 0; checkForPendingDataLoadSwitch = 0; @@ -210,13 +210,13 @@ void mainLoop(int bootScriptIdx) { if (di) { if (!strcmp(di, "quit")) { - var_2 = 1; + quitFlag = 1; } } manageEvents(); - } while (!exitEngine && !var_2 && var21 != 7); + } while (!exitEngine && !quitFlag && var21 != 7); hideMouse(); stopSample(); diff --git a/engines/cine/part.h b/engines/cine/part.h index 67a869b10c..11fc4b3d47 100644 --- a/engines/cine/part.h +++ b/engines/cine/part.h @@ -37,8 +37,8 @@ typedef struct { typedef struct { uint16 width; uint16 var1; - uint16 field_4; - uint16 var2; + uint16 bpp; + uint16 height; uint8 *ptr1; uint8 *ptr2; diff --git a/engines/cine/rel.cpp b/engines/cine/rel.cpp index ed4ef67bbc..c9edef6efc 100644 --- a/engines/cine/rel.cpp +++ b/engines/cine/rel.cpp @@ -24,7 +24,7 @@ #include "cine/cine.h" -relStruct relTable[NUM_MAX_REL]; +RelObjectScript relTable[NUM_MAX_REL]; void resetObjectScriptHead(void) { objScriptList.next = NULL; @@ -57,14 +57,10 @@ void loadRel(char *pRelName) { checkDataDisk(-1); for (i = 0; i < NUM_MAX_REL; i++) { - if (relTable[i].ptr0) { - ASSERT_PTR(relTable[i].ptr0); - - free(relTable[i].ptr0); - - relTable[i].ptr0 = NULL; - - relTable[i].var4 = 0; + if (relTable[i].data) { + free(relTable[i].data); + relTable[i].data = NULL; + relTable[i].size = 0; } } @@ -72,38 +68,25 @@ void loadRel(char *pRelName) { processPendingUpdates(1); - numEntry = *(uint16 *) ptr; - ptr += 2; - flipU16(&numEntry); + numEntry = READ_BE_UINT16(ptr); ptr += 2; ASSERT(numEntry <= NUM_MAX_REL); for (i = 0; i < numEntry; i++) { - relTable[i].var4 = *(uint16 *)ptr; - ptr += 2; - flipU16(&relTable[i].var4); - - relTable[i].var6 = *(uint16 *)ptr; - ptr += 2; - flipU16(&relTable[i].var6); - - relTable[i].var8 = *(uint16 *)ptr; - ptr += 2; - flipU16(&relTable[i].var8); - - relTable[i].varA = *(uint16 *)ptr; - ptr += 2; - flipU16(&relTable[i].varA); + relTable[i].size = READ_BE_UINT16(ptr); ptr += 2; + relTable[i].obj1Param1 = READ_BE_UINT16(ptr); ptr += 2; + relTable[i].obj1Param2 = READ_BE_UINT16(ptr); ptr += 2; + relTable[i].obj2Param = READ_BE_UINT16(ptr); ptr += 2; } for (i = 0; i < numEntry; i++) { - if (relTable[i].var4) { - relTable[i].ptr0 = (char *)malloc(relTable[i].var4); + if (relTable[i].size) { + relTable[i].data = (char *)malloc(relTable[i].size); - ASSERT_PTR(relTable[i].ptr0); + ASSERT_PTR(relTable[i].data); - memcpy(relTable[i].ptr0, ptr, relTable[i].var4); - ptr += relTable[i].var4; + memcpy(relTable[i].data, ptr, relTable[i].size); + ptr += relTable[i].size; } } @@ -117,8 +100,7 @@ void loadRel(char *pRelName) { if (relTable[i].var4) { sprintf(buffer, "%s_%03d.txt", pRelName, i); - decompileScript(relTable[i].ptr0, NULL, - relTable[i].var4, i); + decompileScript(relTable[i].data, NULL, relTable[i].size, i); dumpScript(buffer); } } diff --git a/engines/cine/rel.h b/engines/cine/rel.h index e2c155af3e..f19a621e68 100644 --- a/engines/cine/rel.h +++ b/engines/cine/rel.h @@ -25,17 +25,17 @@ #ifndef CINE_REL_H_ #define CINE_REL_H_ -typedef struct relData { - char *ptr0; - uint16 var4; - uint16 var6; - uint16 var8; - uint16 varA; -} relStruct; +struct RelObjectScript { + char *data; + uint16 size; + uint16 obj1Param1; + uint16 obj1Param2; + uint16 obj2Param; +}; #define NUM_MAX_REL 255 -extern relStruct relTable[NUM_MAX_REL]; +extern RelObjectScript relTable[NUM_MAX_REL]; void releaseObjectScripts(void); void resetObjectScriptHead(void); diff --git a/engines/cine/script.cpp b/engines/cine/script.cpp index 8ac0fed56b..e92d545a1e 100644 --- a/engines/cine/script.cpp +++ b/engines/cine/script.cpp @@ -112,7 +112,7 @@ void addToBGList(int16 objIdx) { y = objectTable[objIdx].y; width = animDataTable[objectTable[objIdx].frame].var1; - height = animDataTable[objectTable[objIdx].frame].var2; + height = animDataTable[objectTable[objIdx].frame].height; part = objectTable[objIdx].part; diff --git a/engines/cine/sfx_player.cpp b/engines/cine/sfx_player.cpp index 0612d3fe5d..45dcfa9c18 100644 --- a/engines/cine/sfx_player.cpp +++ b/engines/cine/sfx_player.cpp @@ -258,7 +258,7 @@ void snd_handlePattern(int channelNum, const uint8 *patternData) { if (snd_mute != 0) (*snd_driver.stopChannel)(channelNum); else { - int16 freq = (int16)readU16BE(patternData); + int16 freq = (int16)READ_BE_UINT16(patternData); if (freq > 0) { (*snd_driver.stopChannel)(channelNum); (*snd_driver.setChannelFrequency)(channelNum, freq); diff --git a/engines/cine/sound_driver.cpp b/engines/cine/sound_driver.cpp index c66e377b14..cb8ff0d3d0 100644 --- a/engines/cine/sound_driver.cpp +++ b/engines/cine/sound_driver.cpp @@ -94,44 +94,44 @@ static void snd_adlibDriverSetupInstrument(const uint8 *instrumentData, int chan if (fl == 0 || ch == 6) { // vibrato tmp = 0; - if (readU16LE(instrumentData + 18) != 0) + if (READ_LE_UINT16(instrumentData + 18) != 0) tmp |= 0x80; - if (readU16LE(instrumentData + 20) != 0) + if (READ_LE_UINT16(instrumentData + 20) != 0) tmp |= 0x40; - if (readU16LE(instrumentData + 10) != 0) + if (READ_LE_UINT16(instrumentData + 10) != 0) tmp |= 0x20; - if (readU16LE(instrumentData + 22) != 0) + if (READ_LE_UINT16(instrumentData + 22) != 0) tmp |= 0x10; - tmp |= (readU16LE(instrumentData + 2) & 0xF); + tmp |= (READ_LE_UINT16(instrumentData + 2) & 0xF); snd_adlibWriteData(ADLIB_REG_AM_VIBRATO_EG_KS + adlibOp1, tmp); // key scaling - tmp = 0x3F - (readU16LE(instrumentData + 16) & 0x3F); + tmp = 0x3F - (READ_LE_UINT16(instrumentData + 16) & 0x3F); tmp = snd_adlibChannelVolume[channelNum] * tmp; tmp += tmp + 0x7F; tmp = 0x3F - (tmp / 0xFE); - if (readU16LE(instrumentData + 24) != 0) - tmp = readU16LE(instrumentData + 16) & 0x3F; - tmp |= readU16LE(instrumentData) << 6; + if (READ_LE_UINT16(instrumentData + 24) != 0) + tmp = READ_LE_UINT16(instrumentData + 16) & 0x3F; + tmp |= READ_LE_UINT16(instrumentData) << 6; snd_adlibWriteData(ADLIB_REG_KEY_SCALING_OPERATOR_OUTPUT + adlibOp1, tmp); // attack/decay rates - tmp = (readU16LE(instrumentData + 6) << 4) | (readU16LE(instrumentData + 12) & 0xF); + tmp = (READ_LE_UINT16(instrumentData + 6) << 4) | (READ_LE_UINT16(instrumentData + 12) & 0xF); snd_adlibWriteData(ADLIB_REG_ATTACK_RATE_DECAY_RATE + adlibOp1, tmp); // sustain/release rates - tmp = (readU16LE(instrumentData + 8) << 4) | (readU16LE(instrumentData + 14) & 0xF); + tmp = (READ_LE_UINT16(instrumentData + 8) << 4) | (READ_LE_UINT16(instrumentData + 14) & 0xF); snd_adlibWriteData(ADLIB_REG_SUSTAIN_LEVEL_RELEASE_RATE_0 + adlibOp1, tmp); if (fl != 0) { - tmp = readU16LE(instrumentData + 4) * 2; - if (readU16LE(instrumentData + 24) == 0) + tmp = READ_LE_UINT16(instrumentData + 4) * 2; + if (READ_LE_UINT16(instrumentData + 24) == 0) tmp |= 1; snd_adlibWriteData(ADLIB_REG_FEEDBACK_STRENGTH_CONNECTION_TYPE + ch, tmp); } else { - tmp = readU16LE(instrumentData + 4) * 2; - if (readU16LE(instrumentData + 24) == 0) + tmp = READ_LE_UINT16(instrumentData + 4) * 2; + if (READ_LE_UINT16(instrumentData + 24) == 0) tmp |= 1; snd_adlibWriteData(ADLIB_REG_FEEDBACK_STRENGTH_CONNECTION_TYPE + channelNum, tmp); @@ -142,31 +142,31 @@ static void snd_adlibDriverSetupInstrument(const uint8 *instrumentData, int chan // vibrato tmp = 0; - if (readU16LE(instrumentData + 18) != 0) + if (READ_LE_UINT16(instrumentData + 18) != 0) tmp |= 0x80; - if (readU16LE(instrumentData + 20) != 0) + if (READ_LE_UINT16(instrumentData + 20) != 0) tmp |= 0x40; - if (readU16LE(instrumentData + 10) != 0) + if (READ_LE_UINT16(instrumentData + 10) != 0) tmp |= 0x20; - if (readU16LE(instrumentData + 22) != 0) + if (READ_LE_UINT16(instrumentData + 22) != 0) tmp |= 0x10; - tmp |= (readU16LE(instrumentData + 2) & 0xF); + tmp |= (READ_LE_UINT16(instrumentData + 2) & 0xF); snd_adlibWriteData(ADLIB_REG_AM_VIBRATO_EG_KS + adlibOp2, tmp); // key scaling - tmp = 0x3F - (readU16LE(instrumentData + 16) & 0x3F); + tmp = 0x3F - (READ_LE_UINT16(instrumentData + 16) & 0x3F); tmp = snd_adlibChannelVolume[channelNum] * tmp; tmp += tmp + 0x7F; tmp = 0x3F - (tmp / 0xFE); - tmp |= readU16LE(instrumentData) << 6; + tmp |= READ_LE_UINT16(instrumentData) << 6; snd_adlibWriteData(ADLIB_REG_KEY_SCALING_OPERATOR_OUTPUT + adlibOp2, tmp); // attack/decay rates */ - tmp =(readU16LE(instrumentData + 6) << 4) | (readU16LE(instrumentData + 12) & 0xF); + tmp =(READ_LE_UINT16(instrumentData + 6) << 4) | (READ_LE_UINT16(instrumentData + 12) & 0xF); snd_adlibWriteData(ADLIB_REG_ATTACK_RATE_DECAY_RATE + adlibOp2, tmp); // sustain/release rates */ - tmp = (readU16LE(instrumentData + 8) << 4) | (readU16LE(instrumentData + 14) & 0xF); + tmp = (READ_LE_UINT16(instrumentData + 8) << 4) | (READ_LE_UINT16(instrumentData + 14) & 0xF); snd_adlibWriteData(ADLIB_REG_SUSTAIN_LEVEL_RELEASE_RATE_0 + adlibOp2, tmp); snd_adlibWriteData(ADLIB_REG_WAVE_SELECT + adlibOp2, waveSelect2); } diff --git a/engines/cine/texte.cpp b/engines/cine/texte.cpp index 3d87870068..277aeb07a8 100644 --- a/engines/cine/texte.cpp +++ b/engines/cine/texte.cpp @@ -45,11 +45,8 @@ void loadTextData(const char *pFileName, uint8 *pDestinationBuffer) { assert(pFileHandle.isOpen()); - pFileHandle.read(&entrySize, 2); - flipU16(&entrySize); - - pFileHandle.read(&numEntry, 2); - flipU16(&numEntry); + entrySize = pFileHandle.readUint16BE(); + numEntry = pFileHandle.readUint16BE(); dataSize = numEntry * entrySize; pFileHandle.read(pDestinationBuffer, numEntry * entrySize); diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index 7eee420d04..7895661e6b 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -206,10 +206,10 @@ void runObjectScript(int16 entryIdx) { pNewElement->compareResult = 0; pNewElement->scriptPosition = 0; - pNewElement->scriptPtr = (byte *)relTable[entryIdx].ptr0; + pNewElement->scriptPtr = (byte *)relTable[entryIdx].data; pNewElement->scriptIdx = entryIdx; - computeScriptStack(pNewElement->scriptPtr, pNewElement->stack, relTable[entryIdx].var4); + computeScriptStack(pNewElement->scriptPtr, pNewElement->stack, relTable[entryIdx].size); } int16 getRelEntryForObject(uint16 param1, uint16 param2, @@ -218,11 +218,11 @@ int16 getRelEntryForObject(uint16 param1, uint16 param2, int16 di = -1; for (i = 0; i < NUM_MAX_REL; i++) { - if (relTable[i].ptr0 && relTable[i].var6 == param1 && relTable[i].var8 == pSelectedObject->idx) { + if (relTable[i].data && relTable[i].obj1Param1 == param1 && relTable[i].obj1Param2 == pSelectedObject->idx) { if (param2 == 1) { di = i; } else if (param2 == 2) { - if (relTable[i].varA == pSelectedObject->param) { + if (relTable[i].obj2Param == pSelectedObject->param) { di = i; } } @@ -263,7 +263,7 @@ int16 getObjectUnderCursor(uint16 x, uint16 y) { treshold = animDataTable[frame].width / 2; } - height = animDataTable[frame].var2; + height = animDataTable[frame].height; xdif = x - objX; ydif = y - objY; @@ -368,7 +368,7 @@ void loadObjectScritpFromSave(Common::File *fHandle) { fHandle->read(&newElement->scriptIdx, 2); flipU16((uint16 *)&newElement->scriptIdx); - newElement->scriptPtr = (byte *)relTable[newElement->scriptIdx].ptr0; + newElement->scriptPtr = (byte *)relTable[newElement->scriptIdx].data; } void loadGlobalScritpFromSave(Common::File *fHandle) { @@ -461,7 +461,7 @@ void setupObjectScriptList(void) { prcLinkedListStruct *currentHead = objScriptList.next; while (currentHead) { - currentHead->scriptPtr = (byte *)relTable[currentHead->scriptIdx].ptr0; + currentHead->scriptPtr = (byte *)relTable[currentHead->scriptIdx].data; currentHead = currentHead->next; } } @@ -490,13 +490,13 @@ int16 makeLoad(char *saveName) { closePart(); for (i = 0; i < NUM_MAX_REL; i++) { - if (relTable[i].ptr0) { - free(relTable[i].ptr0); - relTable[i].ptr0 = NULL; - relTable[i].var4 = 0; - relTable[i].var6 = 0; - relTable[i].var8 = 0; - relTable[i].varA = 0; + if (relTable[i].data) { + free(relTable[i].data); + relTable[i].data = NULL; + relTable[i].size = 0; + relTable[i].obj1Param1 = 0; + relTable[i].obj1Param2 = 0; + relTable[i].obj2Param = 0; } } @@ -548,8 +548,8 @@ int16 makeLoad(char *saveName) { strcpy(commandBuffer, ""); - globalVars[249] = 0; - globalVars[250] = 0; + globalVars[VAR_MOUSE_X_POS] = 0; + globalVars[VAR_MOUSE_Y_POS] = 0; fadeRequired = 0; @@ -659,8 +659,8 @@ int16 makeLoad(char *saveName) { for (i = 0; i < NUM_MAX_ANIMDATA; i++) { flipU16(&animDataTable[i].width); flipU16(&animDataTable[i].var1); - flipU16(&animDataTable[i].field_4); - flipU16(&animDataTable[i].var2); + flipU16(&animDataTable[i].bpp); + flipU16(&animDataTable[i].height); flipU16((uint16 *)&animDataTable[i].fileIdx); flipU16((uint16 *)&animDataTable[i].frameIdx); } @@ -812,8 +812,8 @@ void makeSave(char *saveFileName) { for (i = 0; i < NUM_MAX_ANIMDATA; i++) { flipU16(&animDataTable[i].width); flipU16(&animDataTable[i].var1); - flipU16(&animDataTable[i].field_4); - flipU16(&animDataTable[i].var2); + flipU16(&animDataTable[i].bpp); + flipU16(&animDataTable[i].height); flipU16((uint16 *)&animDataTable[i].fileIdx); flipU16((uint16 *)&animDataTable[i].frameIdx); @@ -821,8 +821,8 @@ void makeSave(char *saveFileName) { flipU16(&animDataTable[i].width); flipU16(&animDataTable[i].var1); - flipU16(&animDataTable[i].field_4); - flipU16(&animDataTable[i].var2); + flipU16(&animDataTable[i].bpp); + flipU16(&animDataTable[i].height); flipU16((uint16 *)&animDataTable[i].fileIdx); flipU16((uint16 *)&animDataTable[i].frameIdx); } @@ -1887,8 +1887,8 @@ uint16 executePlayerInput(void) { strcpy(commandBuffer, ""); } } else { - globalVars[249] = mouseX; - globalVars[250] = mouseY; + globalVars[VAR_MOUSE_X_POS] = mouseX; + globalVars[VAR_MOUSE_Y_POS] = mouseY; } } } else { @@ -1955,12 +1955,12 @@ uint16 executePlayerInput(void) { int16 objIdx; int16 relEntry; - globalVars[249] = mouseX; + globalVars[VAR_MOUSE_X_POS] = mouseX; if (!mouseX) { - globalVars[249]++; + globalVars[VAR_MOUSE_X_POS]++; } - globalVars[250] = mouseY; + globalVars[VAR_MOUSE_Y_POS] = mouseY; objIdx = getObjectUnderCursor(mouseX, mouseY); @@ -2017,7 +2017,7 @@ uint16 executePlayerInput(void) { if (inputVar1 && allowPlayerInput) { // use keyboard inputVar1 = 0; - switch (globalVars[253]) { + switch (globalVars[VAR_MOUSE_X_MODE]) { case 1: { mouseX = objectTable[1].x + 12; @@ -2030,12 +2030,12 @@ uint16 executePlayerInput(void) { } default: { - mouseX = globalVars[249]; + mouseX = globalVars[VAR_MOUSE_X_POS]; break; } } - switch (globalVars[251]) { + switch (globalVars[VAR_MOUSE_Y_MODE]) { case 1: { mouseY = objectTable[1].y + 34; @@ -2048,7 +2048,7 @@ uint16 executePlayerInput(void) { } default: { - mouseX = globalVars[250]; + mouseY = globalVars[VAR_MOUSE_Y_POS]; break; } } @@ -2056,27 +2056,27 @@ uint16 executePlayerInput(void) { if (var_5E == bgVar0) { var_5E = 0; - globalVars[249] = mouseX; - globalVars[250] = mouseY; + globalVars[VAR_MOUSE_X_POS] = mouseX; + globalVars[VAR_MOUSE_Y_POS] = mouseY; } else { if (inputVar2) { if (inputVar2 == 2) { - globalVars[249] = 1; + globalVars[VAR_MOUSE_X_POS] = 1; } else { - globalVars[249] = 320; + globalVars[VAR_MOUSE_X_POS] = 320; } } else { - globalVars[249] = mouseX; + globalVars[VAR_MOUSE_X_POS] = mouseX; } if (inputVar3) { if (inputVar3 == 2) { - globalVars[250] = 1; + globalVars[VAR_MOUSE_Y_POS] = 1; } else { - globalVars[250] = 200; + globalVars[VAR_MOUSE_Y_POS] = 200; } } else { - globalVars[250] = mouseY; + globalVars[VAR_MOUSE_Y_POS] = mouseY; } } @@ -2184,7 +2184,7 @@ void drawSprite(overlayHeadElement *currentOverlay, uint8 *spritePtr, maskSpriteIdx = objectTable[pCurrentOverlay->objIdx].frame; maskWidth = animDataTable[maskSpriteIdx].width / 2; - maskHeight = animDataTable[maskSpriteIdx].var2; + maskHeight = animDataTable[maskSpriteIdx].height; gfxSpriteFunc2(spritePtr, width, height, animDataTable[maskSpriteIdx].ptr1, maskWidth, maskHeight, ptr, maskX - x,maskY - y, i++); } @@ -2429,7 +2429,7 @@ void drawOverlays(void) { pPart = &animDataTable[objPtr->frame]; partVar1 = pPart->var1; - partVar2 = pPart->var2; + partVar2 = pPart->height; if (pPart->ptr1) { drawSprite(currentOverlay, pPart->ptr1, pPart->ptr1, partVar1, partVar2, page1Raw, x, y); @@ -2445,7 +2445,7 @@ void drawOverlays(void) { pPart = &animDataTable[objPtr->frame]; partVar1 = pPart->var1; - partVar2 = pPart->var2; + partVar2 = pPart->height; if (pPart->ptr1) { drawSprite(currentOverlay, pPart->ptr1, pPart->ptr2, partVar1, partVar2, page1Raw, x, y); @@ -2511,7 +2511,7 @@ void drawOverlays(void) { pPart = &animDataTable[objPtr->frame]; partVar1 = pPart->width / 2; - partVar2 = pPart->var2; + partVar2 = pPart->height; if (pPart->ptr1) { gfxFillSprite(pPart->ptr1, partVar1, partVar2, page1Raw, x, y); @@ -2537,14 +2537,12 @@ void drawOverlays(void) { if (objPtr->frame >= 0) { if (var5 <= 8) { if (additionalBgTable[var5]) { - if (animDataTable - [objPtr->frame]. - field_4 == 1) { + if (animDataTable[objPtr->frame].bpp == 1) { int16 x2; int16 y2; x2 = animDataTable[objPtr->frame].width / 2; - y2 = animDataTable[objPtr->frame].var2; + y2 = animDataTable[objPtr->frame].height; if (animDataTable[objPtr->frame].ptr1) { // drawSpriteRaw(animDataTable[objPtr->frame].ptr1, animDataTable[objPtr->frame].ptr1, x2, y2, @@ -2898,8 +2896,8 @@ void processUnkListElement(unkListElementStruct *element) { param2 = ptr1[2]; if (element->varC == 255) { - if (globalVars[249] || globalVars[250]) { - computeMove1(element, ptr1[4] + x, ptr1[5] + y, param1, param2, globalVars[249], globalVars[250]); + if (globalVars[VAR_MOUSE_X_POS] || globalVars[VAR_MOUSE_Y_POS]) { + computeMove1(element, ptr1[4] + x, ptr1[5] + y, param1, param2, globalVars[VAR_MOUSE_X_POS], globalVars[VAR_MOUSE_Y_POS]); } else { element->var16 = 0; element->var14 = 0; @@ -2921,14 +2919,14 @@ void processUnkListElement(unkListElementStruct *element) { && !addAni(3, element->var6, ptr1, element, 0, &var_4)) || (element->var16 == 2 && !addAni(2, element->var6, ptr1, element, 0, &var_4))) { if (element->varC == 255) { - globalVars[250] = 0; + globalVars[VAR_MOUSE_Y_POS] = 0; } } if ((element->var14 == 1 && !addAni(0, element->var6, ptr1, element, 1, &var_2))) { if (element->varC == 255) { - globalVars[249] = 0; + globalVars[VAR_MOUSE_X_POS] = 0; if (var_4 != -1) { objectTable[element->var6].costume = var_4; @@ -2938,7 +2936,7 @@ void processUnkListElement(unkListElementStruct *element) { if ((element->var14 == 2 && !addAni(1, element->var6, ptr1, element, 1, &var_2))) { if (element->varC == 255) { - globalVars[249] = 0; + globalVars[VAR_MOUSE_X_POS] = 0; if (var_4 != -1) { objectTable[element->var6].costume = var_4; |