diff options
-rw-r--r-- | scumm/charset.cpp | 81 | ||||
-rw-r--r-- | scumm/resource_v2.cpp | 9 | ||||
-rw-r--r-- | scumm/script_v2.cpp | 18 | ||||
-rw-r--r-- | scumm/util.cpp | 51 | ||||
-rw-r--r-- | scumm/util.h | 5 |
5 files changed, 73 insertions, 91 deletions
diff --git a/scumm/charset.cpp b/scumm/charset.cpp index 09e167d422..76613f01dd 100644 --- a/scumm/charset.cpp +++ b/scumm/charset.cpp @@ -1681,82 +1681,9 @@ void CharsetRendererNut::printChar(int chr) { _str.bottom = shadow.bottom; } -static byte trNESEnglishTable[] = { - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x0a, 0x07, 0x00, - 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, - 0x13, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, - 0x00, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, - 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, - 0x2c, 0x2d, 0x2e, 0x00, 0x00, 0x00, 0x2f, 0x00, - 0x03, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, - 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, - 0x2c, 0x2d, 0x2e, 0x00, 0x00, 0x00, 0x05, 0x08, - 0x20, 0x20, 0x21, 0x60, 0x27, 0x7e, 0x2c, 0x2e, - 0x7f, 0x3f, 0x2d, 0x30, 0x31, 0x32, 0x33, 0x34, - 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, - 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, - 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, - 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5e -}; - -static byte trNESFrenchTable[] = { - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x64, 0x04, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x0a, 0x07, 0x00, - 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, - 0x13, 0x14, 0x00, 0x00, 0x15, 0x15, 0x64, 0x09, - 0x00, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, - 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, - 0x2c, 0x2d, 0x2e, 0x19, 0x19, 0x19, 0x2f, 0x29, - 0x03, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, - 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, - 0x2c, 0x2d, 0x2e, 0x1d, 0x23, 0x29, 0x05, 0x08, - 0x20, 0x20, 0x21, 0x60, 0x27, 0x7e, 0x2c, 0x2e, - 0x7f, 0x3f, 0x2d, 0x30, 0x31, 0x32, 0x33, 0x34, - 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, - 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, - 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, - 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5e -}; - -static byte trNESSwedishTable[] = { - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x0a, 0x07, 0x00, - 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, - 0x13, 0x14, 0x00, 0x00, 0x61, 0x00, 0x64, 0x09, - 0x00, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, - 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, - 0x2c, 0x2d, 0x2e, 0x62, 0x63, 0x00, 0x2f, 0x00, - 0x03, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, - 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, - 0x2c, 0x2d, 0x2e, 0x63, 0x64, 0x61, 0x05, 0x08, - 0x20, 0x20, 0x21, 0x60, 0x27, 0x7e, 0x2c, 0x2e, - 0x7f, 0x3f, 0x2d, 0x30, 0x31, 0x32, 0x33, 0x34, - 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, - 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, - 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, - 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5e -}; - CharsetRendererNES::CharsetRendererNES(ScummEngine *vm, Common::Language language) : CharsetRendererCommon(vm) { - switch (language) { - case Common::FR_FRA: - _trTable = trNESFrenchTable; - break; - case Common::SE_SWE: - _trTable = trNESSwedishTable; - break; - default: - _trTable = trNESEnglishTable; - break; - } + _trTable = NULL; // can't init it here, since resources aren't yet loaded! } void CharsetRendererNES::printChar(int chr) { @@ -1764,6 +1691,9 @@ void CharsetRendererNES::printChar(int chr) { VirtScreen *vs; byte *charPtr, *dst; + if (!_trTable) // have to init it here instead + _trTable = _vm->getResourceAddress(rtCostume, 77) + 2; + // HACK: how to set it properly? if (_top == 0) _top = 16; @@ -1825,6 +1755,9 @@ void CharsetRendererNES::drawChar(int chr, const Graphics::Surface &s, int x, in byte *charPtr, *dst; int width, height; + if (!_trTable) + _trTable = _vm->getResourceAddress(rtCostume, 77) + 2; + charPtr = _vm->_NESPatTable[1] + _trTable[chr - 32] * 16; width = getCharWidth(chr); height = 8; diff --git a/scumm/resource_v2.cpp b/scumm/resource_v2.cpp index 1e968d6b00..fb8dddc807 100644 --- a/scumm/resource_v2.cpp +++ b/scumm/resource_v2.cpp @@ -38,9 +38,12 @@ void ScummEngine_v2::readClassicIndexFile() { _numRooms = 55; if (_features & GF_NES) - // costumes 25-37 are special. see v1MMNEScostTables[] in costume.cpp - // costumes 38-77 are room graphics resources, to be referenced in - _numCostumes = 77; + // costumes 25-36 are special. see v1MMNEScostTables[] in costume.cpp + // costumes 37-76 are room graphics resources + // costume 77 is a character set translation table + // costume 78 is a preposition list + // costume 79 is unused but allocated, so the total is a nice even number :) + _numCostumes = 80; else _numCostumes = 35; diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp index 8696a355be..3313c39497 100644 --- a/scumm/script_v2.cpp +++ b/scumm/script_v2.cpp @@ -413,7 +413,10 @@ void ScummEngine_v2::decodeParseString() { int textSlot = 0; _string[textSlot].xpos = 0; _string[textSlot].ypos = 0; - _string[textSlot].right = 320; + if (_features & GF_NES) + _string[textSlot].right = 256; + else + _string[textSlot].right = 320; _string[textSlot].center = false; _string[textSlot].overhead = false; @@ -1022,7 +1025,10 @@ void ScummEngine_v2::o2_drawSentence() { { " ", " in", " with", " on", " to" } // Korean }; int lang = (_language <= 8) ? _language : 0; // Default to english - strcat(sentence, prepositions[lang][VAR(VAR_SENTENCE_PREPOSITION)]); + if (_features & GF_NES) { + strcat(sentence, (const char *)(getResourceAddress(rtCostume, 78) + VAR(VAR_SENTENCE_PREPOSITION) * 8 + 2)); + } else + strcat(sentence, prepositions[lang][VAR(VAR_SENTENCE_PREPOSITION)]); } if (VAR(VAR_SENTENCE_OBJECT2) > 0) { @@ -1058,12 +1064,14 @@ void ScummEngine_v2::o2_drawSentence() { ptr++; } - sentenceline.top = virtscr[2].topline; - sentenceline.bottom = virtscr[2].topline + 8; - if (_features & GF_NES) { + if (_features & GF_NES) { // TODO - get multiline sentences working + sentenceline.top = virtscr[2].topline; + sentenceline.bottom = virtscr[2].topline + 16; sentenceline.left = 16; sentenceline.right = 255; } else { + sentenceline.top = virtscr[2].topline; + sentenceline.bottom = virtscr[2].topline + 8; sentenceline.left = 0; sentenceline.right = 319; } diff --git a/scumm/util.cpp b/scumm/util.cpp index 9a7a1d21f2..a4e0f614da 100644 --- a/scumm/util.cpp +++ b/scumm/util.cpp @@ -715,13 +715,18 @@ static ScummNESFile::t_resource res_sproffs[2] = { { {0x0BFEA,0x0BEF3,0x0BF4C,0x07F32}, {0x000C,0x000C,0x000C,0x000C}, NES_SPROFFS } }; - // sprite data sets (packed NES sprite data) static ScummNESFile::t_resource res_sprdata[2] = { { {0x2CE11,0x2CE11,0x2C401,0x2CA28}, {0x2BE0,0x2BE0,0x2BE0,0x2BE0}, NES_SPRDATA }, { {0x07F6B,0x0BE28,0x0FE6B,0x07E48}, {0x008A,0x008A,0x008A,0x008A}, NES_SPRDATA } }; +static ScummNESFile::t_resource res_charset = + { {0x3F6EE,0x3F724,0x3F739,0x3F739}, {0x0090,0x0090,0x0090,0x0090}, NES_CHARSET }; + +static ScummNESFile::t_resource res_preplist = + { {0x3FB5A,0x3FB90,0x3FBA9,0x3FBAF}, {0x000E,0x000E,0x000E,0x0010}, NES_PREPLIST }; + uint16 write_byte(Common::MemoryWriteStream *out, byte val) { val ^= 0xFF; if (out != 0) @@ -822,6 +827,14 @@ uint16 ScummNESFile::extractResource(Common::MemoryWriteStream *output, p_resour reslen += write_word(output, len); reslen += write_byte(output, val); reslen += write_byte(output, cnt); + + cnt = FileReadByte(); + reslen += write_byte(output, cnt); + for (i = 0; i < cnt; i++) + reslen += write_byte(output, FileReadByte()); + for (i = 0; i < cnt; i++) + reslen += write_byte(output, FileReadByte()); + while (1) { reslen += write_byte(output, val = FileReadByte()); if (val >= 0xFE) @@ -860,6 +873,7 @@ uint16 ScummNESFile::extractResource(Common::MemoryWriteStream *output, p_resour case NES_SPRLENS: case NES_SPROFFS: case NES_SPRDATA: + case NES_CHARSET: len = resLength(res); reslen += write_word(output, (uint16)(len + 2)); @@ -868,6 +882,24 @@ uint16 ScummNESFile::extractResource(Common::MemoryWriteStream *output, p_resour break; + case NES_PREPLIST: + len = resLength(res); + reslen += write_word(output, 0x002A); + + reslen += write_byte(output, ' '); + for (i = 1; i < 8; i++) + reslen += write_byte(output, 0); + + for (j = 0; j < 4; j++) + { + reslen += write_byte(output,' '); + for (i = 1; val = FileReadByte(); i++) + reslen += write_byte(output, val); + for (; i < 8; i++) + reslen += write_byte(output, 0); + } + break; + default: error("extract_resource - unknown resource type %d specified!", res->type); } @@ -933,7 +965,7 @@ static ScummNESFile::p_resource lfl_52[] = { &res_rooms[52], NULL }; /* remaining 'standard' resources (not used by any of the original LFL files) */ static ScummNESFile::p_resource lfl_53[] = { &res_rooms[53], &res_scripts[177], &res_scripts[178], &res_sounds[70], &res_sounds[71], &res_sounds[72], &res_sounds[73], &res_sounds[74], &res_sounds[75], &res_sounds[76], &res_sounds[77], &res_sounds[78], &res_sounds[79], &res_sounds[80], &res_sounds[81], NULL }; /* all 'non-standard' resources (the costume-related stuff) */ -static ScummNESFile::p_resource lfl_54[] = { &res_rooms[54], &res_sprdesc[0], &res_sprdesc[1], &res_sprlens[0], &res_sprlens[1], &res_sproffs[0], &res_sproffs[1], &res_sprdata[0], &res_sprdata[1], &res_costumegfx[0], &res_costumegfx[1], &res_sprpals[0], &res_sprpals[1], NULL }; +static ScummNESFile::p_resource lfl_54[] = { &res_rooms[54], &res_sprdesc[0], &res_sprdesc[1], &res_sprlens[0], &res_sprlens[1], &res_sproffs[0], &res_sproffs[1], &res_sprdata[0], &res_sprdata[1], &res_costumegfx[0], &res_costumegfx[1], &res_sprpals[0], &res_sprpals[1], &res_charset, &res_preplist, NULL }; typedef struct _lfl { int num; @@ -1002,8 +1034,8 @@ t_lfl lfls[] = { struct _lfl_index { byte room_lfl[55]; uint16 room_addr[55]; - byte costume_lfl[77]; - uint16 costume_addr[77]; + byte costume_lfl[80]; + uint16 costume_addr[80]; byte script_lfl[200]; uint16 script_addr[200]; byte sound_lfl[100]; @@ -1095,6 +1127,14 @@ bool ScummNESFile::generateIndex() { lfl_index.sound_lfl[entry - res_sounds] = lfl->num; lfl_index.sound_addr[entry - res_sounds] = TO_LE_16(respos); break; + case NES_CHARSET: + lfl_index.costume_lfl[77] = lfl->num; + lfl_index.costume_addr[77] = TO_LE_16(respos); + break; + case NES_PREPLIST: + lfl_index.costume_lfl[78] = lfl->num; + lfl_index.costume_addr[78] = TO_LE_16(respos); + break; default: error("Unindexed entry found!"); break; @@ -1118,9 +1158,6 @@ bool ScummNESFile::generateIndex() { extractResource(&out, &res_globdata); - for (i = res_globdata.length[_ROMset]; i < 775; i++) - write_byte(&out, 0); - for (i = 0; i < (int)sizeof(lfl_index); i++) write_byte(&out, ((byte *)&lfl_index)[i]); diff --git a/scumm/util.h b/scumm/util.h index 873966eca7..5863a47587 100644 --- a/scumm/util.h +++ b/scumm/util.h @@ -65,7 +65,6 @@ public: uint32 write(const void *ptr, uint32 size); }; - typedef enum _res_type { NES_UNKNOWN, NES_GLOBDATA, @@ -79,7 +78,9 @@ typedef enum _res_type { NES_SPRDESC, NES_SPRLENS, NES_SPROFFS, - NES_SPRDATA + NES_SPRDATA, + NES_CHARSET, + NES_PREPLIST } res_type; class ScummNESFile : public BaseScummFile { |