[Scummvm-cvs-logs] CVS: scummvm/scumm charset.cpp,2.126,2.127 charset.h,2.37,2.38 costume.cpp,1.163,1.164 gfx.cpp,2.406,2.407 gfx.h,1.103,1.104 script_v2.cpp,2.260,2.261 scumm.cpp,1.369,1.370 scumm.h,1.542,1.543
Eugene Sandulenko
sev at users.sourceforge.net
Tue Mar 15 19:22:10 CET 2005
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14299
Modified Files:
charset.cpp charset.h costume.cpp gfx.cpp gfx.h script_v2.cpp
scumm.cpp scumm.h
Log Message:
Preliminary support for NES charsets. Colors are wrong and we get glitches
caused by too narrow screen. Also text clearing doesn't work.
Index: charset.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.cpp,v
retrieving revision 2.126
retrieving revision 2.127
diff -u -d -r2.126 -r2.127
--- charset.cpp 2 Mar 2005 21:46:45 -0000 2.126
+++ charset.cpp 16 Mar 2005 03:20:27 -0000 2.127
@@ -1669,6 +1669,159 @@
_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;
+ }
+}
+
+void CharsetRendererNES::printChar(int chr) {
+ int width, height, origWidth, origHeight;
+ VirtScreen *vs;
+ byte *charPtr, *dst;
+
+ if ((vs = _vm->findVirtScreen(_top)) == NULL)
+ return;
+
+ if (chr == '@')
+ return;
+
+ charPtr = _vm->_NESPatTable + _trTable[chr - 32] * 16;
+ width = getCharWidth(chr);
+ height = 8;
+
+ origWidth = width;
+ origHeight = height;
+
+ if (_firstChar) {
+ _str.left = _left;
+ _str.top = _top;
+ _str.right = _left;
+ _str.bottom = _top;
+ _firstChar = false;
+ }
+
+ int drawTop = _top - vs->topline;
+
+ _vm->markRectAsDirty(vs->number, _left, _left + width, drawTop, drawTop + height);
+
+ if (!_ignoreCharsetMask) {
+ _hasMask = true;
+ _textScreenID = vs->number;
+ }
+ dst = (byte *)_vm->gdi._textSurface.pixels + _top * _vm->gdi._textSurface.pitch + _left;
+ drawBits1(_vm->gdi._textSurface, dst, charPtr, drawTop, origWidth, origHeight);
+
+ if (_str.left > _left)
+ _str.left = _left;
+
+ _left += origWidth;
+
+ if (_str.right < _left) {
+ _str.right = _left;
+ if (_dropShadow)
+ _str.right++;
+ }
+
+ if (_str.bottom < _top + height)
+ _str.bottom = _top + height;
+}
+
+void CharsetRendererNES::drawChar(int chr, const Graphics::Surface &s, int x, int y) {
+ byte *charPtr, *dst;
+ int width, height;
+
+ charPtr = _vm->_NESPatTable + _trTable[chr - 32] * 16;
+ width = getCharWidth(chr);
+ height = 8;
+
+ dst = (byte *)s.pixels + y * s.pitch + x;
+ drawBits1(s, dst, charPtr, y, width, height);
+}
+
+void CharsetRendererNES::drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height) {
+ for (int i = 0; i < 8; i++) {
+ byte c0 = src[i];
+ byte c1 = src[i + 8];
+ for (int j = 0; j < 8; j++)
+ dst[j] = _vm->_NESPalette[((c0 >> (7 - j)) & 1) | (((c1 >> (7 - j)) & 1) << 1)] | _color;
+ dst += s.pitch;
+ }
+}
+
} // End of namespace Scumm
#ifdef __PALM_OS__
Index: charset.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.h,v
retrieving revision 2.37
retrieving revision 2.38
diff -u -d -r2.37 -r2.38
--- charset.h 20 Feb 2005 00:17:22 -0000 2.37
+++ charset.h 16 Mar 2005 03:20:28 -0000 2.38
@@ -130,6 +130,23 @@
int getCharWidth(byte chr);
};
+class CharsetRendererNES : public CharsetRendererCommon {
+protected:
+ byte *_trTable;
+
+ void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height);
+
+public:
+ CharsetRendererNES(ScummEngine *vm, Common::Language language);
+
+ void setCurID(byte id) {}
+ void printChar(int chr);
+ void drawChar(int chr, const Graphics::Surface &s, int x, int y);
+
+ int getFontHeight() { return 8; }
+ int getCharWidth(byte chr) { return 8; }
+};
+
class CharsetRendererV3 : public CharsetRendererCommon {
protected:
int _numChars;
Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/costume.cpp,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -d -r1.163 -r1.164
--- costume.cpp 16 Mar 2005 02:14:31 -0000 1.163
+++ costume.cpp 16 Mar 2005 03:20:28 -0000 1.164
@@ -598,7 +598,7 @@
offset = src[(frameset * 4 + framenum) * 2];
// Lookup & desc
- table = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][0]);
+ table = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_NESCostumeSet][0]);
offset = READ_LE_UINT16(table + v1MMNESLookup[_id] * 2 + 2);
if (v1MMNESLookup[_id] * 2 >= READ_LE_UINT16(table)) {
@@ -686,17 +686,17 @@
bool flipped = (newDirToOldDir(a->getFacing()) == 1);
// Lookup & desc
- table = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][0]) + 2;
+ table = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_NESCostumeSet][0]) + 2;
offset = READ_LE_UINT16(table + v1MMNESLookup[_loaded._id] * 2);
// lens
- numSpritesTab = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][1]) + 2 + offset;
+ numSpritesTab = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_NESCostumeSet][1]) + 2 + offset;
// offs
- spritesOffsetTab = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][2]) + 2 + offset*2;
+ spritesOffsetTab = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_NESCostumeSet][2]) + 2 + offset*2;
// data
- spritesDefs = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][3]) + 2;
+ spritesDefs = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_NESCostumeSet][3]) + 2;
// data
- spritesPal = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][5]) + 2;
+ spritesPal = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_NESCostumeSet][5]) + 2;
ptr = spritesDefs + READ_LE_UINT16(spritesOffsetTab + frame*2);
numSprites = numSpritesTab[frame] + 1;
@@ -717,8 +717,8 @@
}
for (int ty = 0; ty < 8; ty++) {
- byte c1 = _vm->_v1MMNESCostumeGfx[_vm->_v1MMNESCostumeSet][tile * 16 + ty];
- byte c2 = _vm->_v1MMNESCostumeGfx[_vm->_v1MMNESCostumeSet][tile * 16 + ty + 8];
+ byte c1 = _vm->_NESCostumeGfx[_vm->_NESCostumeSet][tile * 16 + ty];
+ byte c2 = _vm->_NESCostumeGfx[_vm->_NESCostumeSet][tile * 16 + ty + 8];
for (int tx = 0; tx < 8; tx++) {
unsigned char c = ((c1 & mask) ? 1 : 0) | ((c2 & mask) ? 2 : 0) | palette;
if (mask == 0x01) {
@@ -816,8 +816,8 @@
int maxSprites = patTable[2];
if (maxSprites == 0)
maxSprites = 256;
- _v1MMNESCostumeGfx[n] = (byte *)calloc(maxSprites * 16, 1);
- decodeNESTileData(patTable,_v1MMNESCostumeGfx[n]);
+ _NESCostumeGfx[n] = (byte *)calloc(maxSprites * 16, 1);
+ decodeNESTileData(patTable,_NESCostumeGfx[n]);
// We will not need it anymore
nukeResource(rtCostume, v1MMNEScostTables[n][4]);
}
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.406
retrieving revision 2.407
diff -u -d -r2.406 -r2.407
--- gfx.cpp 16 Mar 2005 02:14:32 -0000 2.406
+++ gfx.cpp 16 Mar 2005 03:20:29 -0000 2.407
@@ -184,8 +184,6 @@
_roomPalette = vm->_roomPalette;
if ((vm->_features & GF_AMIGA) && (vm->_version >= 4))
_roomPalette += 16;
- if (vm->_features & GF_NES)
- _NESBaseTiles = 0;
_compositeBuf = 0;
_textSurface.pixels = 0;
@@ -1830,21 +1828,22 @@
}
}
+void ScummEngine::decodeNESBaseTiles() {
+ byte *basetiles = getResourceAddress(rtCostume, 37);
+ _NESBaseTiles = basetiles[2];
+ decodeNESTileData(basetiles, _NESPatTable);
+}
+
void Gdi::decodeNESGfx(const byte *room) {
- if (_NESBaseTiles == 0) {
- byte *basetiles = _vm->getResourceAddress(rtCostume,37);
- _NESBaseTiles = basetiles[2];
- decodeNESTileData(basetiles,_NESPatTable);
- }
const byte *gdata = room + READ_LE_UINT16(room + 0x0A);
int tileset = *gdata++;
int width = READ_LE_UINT16(room + 0x04);
// int height = READ_LE_UINT16(room + 0x06);
int i, j, n;
- decodeNESTileData(_vm->getResourceAddress(rtCostume, 37 + tileset), _NESPatTable + _NESBaseTiles * 16);
+ decodeNESTileData(_vm->getResourceAddress(rtCostume, 37 + tileset), _vm->_NESPatTable + _vm->_NESBaseTiles * 16);
for (i = 0; i < 16; i++)
- _NESPalette[i] = *gdata++;
+ _vm->_NESPalette[i] = *gdata++;
for (i = 0; i < 16; i++) {
_NESNametable[i][0] = _NESNametable[i][1] = 0;
n = 0;
@@ -1908,10 +1907,10 @@
int tile = isObject ? _NESNametableObj[y][x] : _NESNametable[y][x];
for (int i = 0; i < 8; i++) {
- byte c0 = _NESPatTable[tile * 16 + i];
- byte c1 = _NESPatTable[tile * 16 + i + 8];
+ byte c0 = _vm->_NESPatTable[tile * 16 + i];
+ byte c1 = _vm->_NESPatTable[tile * 16 + i + 8];
for (int j = 0; j < 8; j++)
- dst[j] = _NESPalette[((c0 >> (7 - j)) & 1) | (((c1 >> (7 - j)) & 1) << 1) | (palette << 2)];
+ dst[j] = _vm->_NESPalette[((c0 >> (7 - j)) & 1) | (((c1 >> (7 - j)) & 1) << 1) | (palette << 2)];
dst += dstPitch;
}
}
Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- gfx.h 16 Mar 2005 02:14:34 -0000 1.103
+++ gfx.h 16 Mar 2005 03:20:30 -0000 1.104
@@ -229,7 +229,7 @@
byte _C64MaskMap[4096], _C64MaskChar[4096];
bool _C64ObjectMode;
- byte _NESPatTable[4096], _NESNametable[16][64], _NESAttributes[64], _NESPalette[16];
+ byte _NESNametable[16][64], _NESAttributes[64];
byte _NESBaseTiles;
byte _NESNametableObj[16][64];
int _NESObj_x;
Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.260
retrieving revision 2.261
diff -u -d -r2.260 -r2.261
--- script_v2.cpp 15 Mar 2005 21:15:37 -0000 2.260
+++ script_v2.cpp 16 Mar 2005 03:20:30 -0000 2.261
@@ -1538,7 +1538,7 @@
// NES version of maniac uses this to switch between the two
// groups of costumes it has
if (_features & GF_NES)
- _v1MMNESCostumeSet = fetchScriptByte();
+ _NESCostumeSet = fetchScriptByte();
else
o2_dummy();
}
Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.369
retrieving revision 1.370
diff -u -d -r1.369 -r1.370
--- scumm.cpp 15 Mar 2005 18:46:35 -0000 1.369
+++ scumm.cpp 16 Mar 2005 03:20:31 -0000 1.370
@@ -1232,7 +1232,9 @@
loadCJKFont();
// Create the charset renderer
- if (_version <= 2)
+ if (_features & GF_NES)
+ _charset = new CharsetRendererNES(this, _language);
+ else if (_version <= 2)
_charset = new CharsetRendererV2(this, _language);
else if (_version == 3)
_charset = new CharsetRendererV3(this);
@@ -1500,8 +1502,10 @@
clearDrawObjectQueue();
- if (_features & GF_NES)
+ if (_features & GF_NES) {
+ decodeNESBaseTiles();
cost_decodeNESCostumeGfx();
+ }
for (i = 0; i < 6; i++) {
if (_version == 3) { // FIXME - what is this?
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.542
retrieving revision 1.543
diff -u -d -r1.542 -r1.543
--- scumm.h 15 Mar 2005 21:48:06 -0000 1.542
+++ scumm.h 16 Mar 2005 03:20:32 -0000 1.543
@@ -471,8 +471,12 @@
BaseCostumeRenderer* _costumeRenderer;
- int _v1MMNESCostumeSet;
- byte *_v1MMNESCostumeGfx[2];
+ int _NESCostumeSet;
+ byte *_NESCostumeGfx[2];
+
+ byte _NESPatTable[4096];
+ byte _NESPalette[16];
+ byte _NESBaseTiles;
char *_audioNames;
int32 _numAudioNames;
@@ -916,6 +920,8 @@
void initBGBuffers(int height);
void initCycl(const byte *ptr); // Color cycle
+ void decodeNESBaseTiles();
+
void drawObject(int obj, int arg);
void drawRoomObjects(int arg);
void drawRoomObject(int i, int arg);
More information about the Scummvm-git-logs
mailing list