aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Brown2002-03-08 08:42:11 +0000
committerJames Brown2002-03-08 08:42:11 +0000
commitc161197117e3212e146083086f6f0ee581062789 (patch)
treed010a59c776f126613e110bbf80d4e64c55143ab
parent41d1864add8dd9fe227963b812c59edb83a74138 (diff)
downloadscummvm-rg350-c161197117e3212e146083086f6f0ee581062789.tar.gz
scummvm-rg350-c161197117e3212e146083086f6f0ee581062789.tar.bz2
scummvm-rg350-c161197117e3212e146083086f6f0ee581062789.zip
Yet more cleanups. Remove 'index' (reserved keyword), and remove 'res' shadowing.
svn-id: r3685
-rw-r--r--gfx.cpp20
-rw-r--r--gui.cpp4
-rw-r--r--gui.h4
-rw-r--r--insane.cpp583
-rw-r--r--object.cpp12
-rw-r--r--resource.cpp102
-rw-r--r--saveload.cpp12
-rw-r--r--script.cpp28
-rw-r--r--script_v1.cpp74
-rw-r--r--script_v2.cpp112
-rw-r--r--scummvm.cpp4
11 files changed, 764 insertions, 191 deletions
diff --git a/gfx.cpp b/gfx.cpp
index 663ec16e34..b5eeee5076 100644
--- a/gfx.cpp
+++ b/gfx.cpp
@@ -2018,11 +2018,11 @@ void Gdi::resetBackground(byte top, byte bottom, int strip) {
}
}
-void Scumm::setPalColor(int index, int r, int g, int b) {
- _currentPalette[index*3+0] = r;
- _currentPalette[index*3+1] = g;
- _currentPalette[index*3+2] = b;
- setDirtyColors(index,index);
+void Scumm::setPalColor(int idx, int r, int g, int b) {
+ _currentPalette[idx*3+0] = r;
+ _currentPalette[idx*3+1] = g;
+ _currentPalette[idx*3+2] = b;
+ setDirtyColors(idx,idx);
}
void Scumm::drawMouse() {
@@ -2088,7 +2088,7 @@ void Scumm::setPalette(int palindex) {
setPaletteFromPtr(pals);
}
-byte *Scumm::findPalInPals(byte *pal, int index) {
+byte *Scumm::findPalInPals(byte *pal, int idx) {
byte *offs;
uint32 size;
@@ -2102,10 +2102,10 @@ byte *Scumm::findPalInPals(byte *pal, int index) {
size = getResourceDataSize(offs) >> 2;
- if ((uint32)index >= (uint32)size)
+ if ((uint32)idx >= (uint32)size)
return NULL;
- return offs + READ_LE_UINT32(offs + index * sizeof(uint32));
+ return offs + READ_LE_UINT32(offs + idx * sizeof(uint32));
}
byte *Scumm::getPalettePtr() {
@@ -2252,7 +2252,7 @@ static const byte default_cursor_colors[4] = {
15,15,7,8
};
-void Scumm::decompressDefaultCursor(int index) {
+void Scumm::decompressDefaultCursor(int idx) {
int i;
byte color;
@@ -2262,7 +2262,7 @@ void Scumm::decompressDefaultCursor(int index) {
_cursorHotspotX = 8;
_cursorHotspotY = 7;
- color = default_cursor_colors[index];
+ color = default_cursor_colors[idx];
for(i=0; i<16; i++) {
_grabbedCursor[16*8+i] = color;
diff --git a/gui.cpp b/gui.cpp
index e3e2b3a65d..8adc342c54 100644
--- a/gui.cpp
+++ b/gui.cpp
@@ -269,12 +269,12 @@ const GuiWidget save_load_dialog[] = {
{GUI_TEXT,0x04,GWF_BUTTON,200,45,54,16,8,9}, /* Ok */
{GUI_TEXT,0x04,GWF_BUTTON,200,65,54,16,7,7}, /* Cancel */
- {0}
+ {0,0,0,0,0,0,0,0,0}
};
const GuiWidget pause_dialog[] = {
{GUI_TEXT,0x01,GWF_DEFAULT,50,80,220,16,0,10},
- {0},
+ {0,0,0,0,0,0,0,0,0}
};
diff --git a/gui.h b/gui.h
index e4d1d63bd2..f49e828244 100644
--- a/gui.h
+++ b/gui.h
@@ -5,7 +5,7 @@ enum {
GUI_NONE = 0,
GUI_TEXT = 1,
GUI_IMAGE = 2,
- GUI_STAT = 3,
+ GUI_STAT = 3
};
enum {
@@ -14,7 +14,7 @@ enum {
GWF_PARENT = 4,
GWF_DELAY = 8,
GWF_DEFAULT = GWF_BORDER|GWF_CLEARBG,
- GWF_BUTTON = GWF_BORDER|GWF_CLEARBG|GWF_DELAY,
+ GWF_BUTTON = GWF_BORDER|GWF_CLEARBG|GWF_DELAY
};
diff --git a/insane.cpp b/insane.cpp
index d1d18763d3..45da4aae50 100644
--- a/insane.cpp
+++ b/insane.cpp
@@ -1,573 +1,1146 @@
// insane.cpp : Defines the entry point for the console application.
+
//
+
+
#define NEED_SDL_HEADERS
+
+
#include "stdafx.h"
+
#include "scumm.h"
+
+
#define SWAP2(a) ((((a)>>24)&0xFF) | (((a)>>8)&0xFF00) | (((a)<<8)&0xFF0000) | (((a)<<24)&0xFF000000))
+
+
void invalidblock(uint32 tag) {
+
error("Encountered invalid block %c%c%c%c", tag>>24, tag>>16, tag>>8, tag);
+
}
+
+
uint32 SmushPlayer::nextBE32() {
+
uint32 a = *((uint32*)_cur);
+
_cur += sizeof(uint32);
+
return SWAP2(a);
+
}
+
+
void SmushPlayer::fileRead(void *mem, int len) {
+
if (fread(mem, len,1, _in) != 1)
+
error("EOF while reading");
+
}
+
+
uint32 SmushPlayer::fileReadBE32() {
+
uint32 number;
+
fileRead(&number, sizeof(number));
+
return SWAP2(number);
+
}
+
+
uint32 SmushPlayer::fileReadLE32() {
+
uint32 number;
+
fileRead(&number, sizeof(number));
+
return number;
+
}
+
+
void SmushPlayer::openFile(byte* fileName) {
+
byte buf[100];
+
sprintf((char*)buf,"%s%s%s",(char*)sm->_gameDataPath,(char*)sm->_videoPath,(char*)fileName);
+
_in = fopen((char*)buf, "rb");
+
}
+
+
void SmushPlayer::nextBlock() {
+
_blockTag = fileReadBE32();
+
_blockSize = fileReadBE32();
+
+
if (_block != NULL)
+
free(_block);
+
+
_block = (byte*)malloc(_blockSize);
+
if (_block==NULL)
+
error("cannot allocate memory");
+
+
fileRead(_block, _blockSize);
+
}
+
+
bool SmushPlayer::parseTag() {
+
switch(nextBlock(), _blockTag) {
+
case 'AHDR':
+
parseAHDR();
+
break;
+
case 'FRME':
+
parseFRME();
+
break;
+
default:
+
invalidblock(_blockTag);
+
}
+
return true;
+
}
+
+
void SmushPlayer::parseAHDR() {
+
// memcpy(_fluPalette, _block, 0x300);
+
_paletteChanged = true;
+
+
printf("parse AHDR\n");
+
}
+
+
void SmushPlayer::parseNPAL() {
+
memcpy(_fluPalette, _cur, 0x300);
+
_paletteChanged = true;
+
}
+
+
void codec1(CodecData *cd) {
+
uint y = cd->y;
+
byte *src = cd->src;
+
byte *dest= cd->out;
+
uint h = cd->h;
+
+
if (!h || !cd->w)
+
return;
+
+
dest += cd->y * cd->pitch;
+
+
do {
+
byte color;
+
uint len, num;
+
uint x;
+
if ((uint)y >= (uint)cd->outheight) {
+
src += *(uint16*)(src) + 2;
+
continue;
+
}
+
len = cd->w;
+
x = cd->x;
+
+
src += 2;
+
do {
+
byte code = *src++;
+
num = (code>>1)+1;
+
if (num>len) num=len;
+
len -= num;
+
if (code&1) {
+
color = *src++;
+
// if ((color = *src++)!=0) {
+
do {
+
if ((uint)x < (uint)cd->outwidth)
+
dest[x] = color;
+
} while (++x,--num);
+
// } else {
+
// x += num;
+
// }
+
} else {
+
do {
+
color = *src++;
+
if (/*(color=*src++) != 0 &&*/ (uint)x < (uint)cd->outwidth)
+
dest[x] = color;
+
} while (++x,--num);
+
}
+
} while (len);
+
} while (dest += cd->pitch,y++,--h);
+
}
+
+
void codec37_bompdepack(byte *dst, byte *src, int len) {
+
byte code;
+
byte color;
+
int num;
+
+
do {
+
code = *src++;
+
if (code & 1) {
+
num = (code>>1) + 1;
+
color = *src++;
+
memset(dst, color, num);
+
dst += num;
+
} else {
+
num = (code>>1) + 1;
+
memcpy(dst,src,num);
+
dst += num;
+
src += num;
+
}
+
} while (len -= num);
+
}
+
+
void codec37_proc5(byte *dst, byte *src, int next_offs, int bw, int bh, int pitch, int16 *table) {
+
byte code, *tmp;
+
int i;
+
+
if (pitch != 320)
+
{
+
warning("invalid pitch");
+
return;
+
}
+
+
do {
+
i = bw;
+
do {
+
code = *src++;
+
if (code==0xFF) {
+
*(uint32*)(dst+0) = ((uint32*)src)[0];
+
*(uint32*)(dst+320) = ((uint32*)src)[1];
+
*(uint32*)(dst+320*2) = ((uint32*)src)[2];
+
*(uint32*)(dst+320*3) = ((uint32*)src)[3];
+
src += 16;
+
dst += 4;
+
} else {
+
tmp = dst + table[code] + next_offs;
+
*(uint32*)(dst+0) = *(uint32*)(tmp);
+
*(uint32*)(dst+320) = *(uint32*)(tmp+320);
+
*(uint32*)(dst+320*2) = *(uint32*)(tmp+320*2);
+
*(uint32*)(dst+320*3) = *(uint32*)(tmp+320*3);
+
dst += 4;
+
}
+
} while(--i);
+
dst += 320*4 - 320;
+
} while (--bh);
+
}
+
+
static const int8 maketable_bytes[] = {
+
0, 0, 1, 0, 2, 0, 3, 0, 5, 0, 8, 0, 13, 0, 21, 0,
+
-1, 0, -2, 0, -3, 0, -5, 0, -8, 0, -13, 0, -17, 0, -21, 0,
+
0, 1, 1, 1, 2, 1, 3, 1, 5, 1, 8, 1, 13, 1, 21, 1,
+
-1, 1, -2, 1, -3, 1, -5, 1, -8, 1, -13, 1, -17, 1, -21, 1,
+
0, 2, 1, 2, 2, 2, 3, 2, 5, 2, 8, 2, 13, 2, 21, 2,
+
-1, 2, -2, 2, -3, 2, -5, 2, -8, 2, -13, 2, -17, 2, -21, 2,
+
0, 3, 1, 3, 2, 3, 3, 3, 5, 3, 8, 3, 13, 3, 21, 3,
+
-1, 3, -2, 3, -3, 3, -5, 3, -8, 3, -13, 3, -17, 3, -21, 3,
+
0, 5, 1, 5, 2, 5, 3, 5, 5, 5, 8, 5, 13, 5, 21, 5,
+
-1, 5, -2, 5, -3, 5, -5, 5, -8, 5, -13, 5, -17, 5, -21, 5,
+
0, 8, 1, 8, 2, 8, 3, 8, 5, 8, 8, 8, 13, 8, 21, 8,
+
-1, 8, -2, 8, -3, 8, -5, 8, -8, 8, -13, 8, -17, 8, -21, 8,
+
0, 13, 1, 13, 2, 13, 3, 13, 5, 13, 8, 13, 13, 13, 21, 13,
+
-1, 13, -2, 13, -3, 13, -5, 13, -8, 13, -13, 13, -17, 13, -21, 13,
+
0, 21, 1, 21, 2, 21, 3, 21, 5, 21, 8, 21, 13, 21, 21, 21,
+
-1, 21, -2, 21, -3, 21, -5, 21, -8, 21, -13, 21, -17, 21, -21, 21,
+
0, -1, 1, -1, 2, -1, 3, -1, 5, -1, 8, -1, 13, -1, 21, -1,
+
-1, -1, -2, -1, -3, -1, -5, -1, -8, -1, -13, -1, -17, -1, -21, -1,
+
0, -2, 1, -2, 2, -2, 3, -2, 5, -2, 8, -2, 13, -2, 21, -2,
+
-1, -2, -2, -2, -3, -2, -5, -2, -8, -2, -13, -2, -17, -2, -21, -2,
+
0, -3, 1, -3, 2, -3, 3, -3, 5, -3, 8, -3, 13, -3, 21, -3,
+
-1, -3, -2, -3, -3, -3, -5, -3, -8, -3, -13, -3, -17, -3, -21, -3,
+
0, -5, 1, -5, 2, -5, 3, -5, 5, -5, 8, -5, 13, -5, 21, -5,
+
-1, -5, -2, -5, -3, -5, -5, -5, -8, -5, -13, -5, -17, -5, -21, -5,
+
0, -8, 1, -8, 2, -8, 3, -8, 5, -8, 8, -8, 13, -8, 21, -8,
+
-1, -8, -2, -8, -3, -8, -5, -8, -8, -8, -13, -8, -17, -8, -21, -8,
+
0, -13, 1, -13, 2, -13, 3, -13, 5, -13, 8, -13, 13, -13, 21, -13,
+
-1, -13, -2, -13, -3, -13, -5, -13, -8, -13, -13, -13, -17, -13, -21, -13,
+
0, -17, 1, -17, 2, -17, 3, -17, 5, -17, 8, -17, 13, -17, 21, -17,
+
-1, -17, -2, -17, -3, -17, -5, -17, -8, -17, -13, -17, -17, -17, -21, -17,
+
0, -21, 1, -21, 2, -21, 3, -21, 5, -21, 8, -21, 13, -21, 21, -21,
+
-1, -21, -2, -21, -3, -21, -5, -21, -8, -21, -13, -21, -17, -21, 0, 0,
+
-8, -29, 8, -29, -18, -25, 17, -25, 0, -23, -6, -22, 6, -22, -13, -19,
+
12, -19, 0, -18, 25, -18, -25, -17, -5, -17, 5, -17, -10, -15, 10, -15,
+
0, -14, -4, -13, 4, -13, 19, -13, -19, -12, -8, -11, -2, -11, 0, -11,
+
2, -11, 8, -11, -15, -10, -4, -10, 4, -10, 15, -10, -6, -9, -1, -9,
+
1, -9, 6, -9, -29, -8, -11, -8, -8, -8, -3, -8, 3, -8, 8, -8,
+
11, -8, 29, -8, -5, -7, -2, -7, 0, -7, 2, -7, 5, -7, -22, -6,
+
-9, -6, -6, -6, -3, -6, -1, -6, 1, -6, 3, -6, 6, -6, 9, -6,
+
22, -6, -17, -5, -7, -5, -4, -5, -2, -5, 0, -5, 2, -5, 4, -5,
+
7, -5, 17, -5, -13, -4, -10, -4, -5, -4, -3, -4, -1, -4, 0, -4,
+
1, -4, 3, -4, 5, -4, 10, -4, 13, -4, -8, -3, -6, -3, -4, -3,
+
-3, -3, -2, -3, -1, -3, 0, -3, 1, -3, 2, -3, 4, -3, 6, -3,
+
8, -3, -11, -2, -7, -2, -5, -2, -3, -2, -2, -2, -1, -2, 0, -2,
+
1, -2, 2, -2, 3, -2, 5, -2, 7, -2, 11, -2, -9, -1, -6, -1,
+
-4, -1, -3, -1, -2, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1,
+
4, -1, 6, -1, 9, -1, -31, 0, -23, 0, -18, 0, -14, 0, -11, 0,
+
-7, 0, -5, 0, -4, 0, -3, 0, -2, 0, -1, 0, 0, -31, 1, 0,
+
2, 0, 3, 0, 4, 0, 5, 0, 7, 0, 11, 0, 14, 0, 18, 0,
+
23, 0, 31, 0, -9, 1, -6, 1, -4, 1, -3, 1, -2, 1, -1, 1,
+
0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 6, 1, 9, 1, -11, 2,
+
-7, 2, -5, 2, -3, 2, -2, 2, -1, 2, 0, 2, 1, 2, 2, 2,
+
3, 2, 5, 2, 7, 2, 11, 2, -8, 3, -6, 3, -4, 3, -2, 3,
+
-1, 3, 0, 3, 1, 3, 2, 3, 3, 3, 4, 3, 6, 3, 8, 3,
+
-13, 4, -10, 4, -5, 4, -3, 4, -1, 4, 0, 4, 1, 4, 3, 4,
+
5, 4, 10, 4, 13, 4, -17, 5, -7, 5, -4, 5, -2, 5, 0, 5,
+
2, 5, 4, 5, 7, 5, 17, 5, -22, 6, -9, 6, -6, 6, -3, 6,
+
-1, 6, 1, 6, 3, 6, 6, 6, 9, 6, 22, 6, -5, 7, -2, 7,
+
0, 7, 2, 7, 5, 7, -29, 8, -11, 8, -8, 8, -3, 8, 3, 8,
+
8, 8, 11, 8, 29, 8, -6, 9, -1, 9, 1, 9, 6, 9, -15, 10,
+
-4, 10, 4, 10, 15, 10, -8, 11, -2, 11, 0, 11, 2, 11, 8, 11,
+
19, 12, -19, 13, -4, 13, 4, 13, 0, 14, -10, 15, 10, 15, -5, 17,
+
5, 17, 25, 17, -25, 18, 0, 18, -12, 19, 13, 19, -6, 22, 6, 22,
+
0, 23, -17, 25, 18, 25, -8, 29, 8, 29, 0, 31, 0, 0, -6, -22,
+
6, -22, -13, -19, 12, -19, 0, -18, -5, -17, 5, -17, -10, -15, 10, -15,
+
0, -14, -4, -13, 4, -13, 19, -13, -19, -12, -8, -11, -2, -11, 0, -11,
+
2, -11, 8, -11, -15, -10, -4, -10, 4, -10, 15, -10, -6, -9, -1, -9,
+
1, -9, 6, -9, -11, -8, -8, -8, -3, -8, 0, -8, 3, -8, 8, -8,
+
11, -8, -5, -7, -2, -7, 0, -7, 2, -7, 5, -7, -22, -6, -9, -6,
+
-6, -6, -3, -6, -1, -6, 1, -6, 3, -6, 6, -6, 9, -6, 22, -6,
+
-17, -5, -7, -5, -4, -5, -2, -5, -1, -5, 0, -5, 1, -5, 2, -5,
+
4, -5, 7, -5, 17, -5, -13, -4, -10, -4, -5, -4, -3, -4, -2, -4,
+
-1, -4, 0, -4, 1, -4, 2, -4, 3, -4, 5, -4, 10, -4, 13, -4,
+
-8, -3, -6, -3, -4, -3, -3, -3, -2, -3, -1, -3, 0, -3, 1, -3,
+
2, -3, 3, -3, 4, -3, 6, -3, 8, -3, -11, -2, -7, -2, -5, -2,
+
-4, -2, -3, -2, -2, -2, -1, -2, 0, -2, 1, -2, 2, -2, 3, -2,
+
4, -2, 5, -2, 7, -2, 11, -2, -9, -1, -6, -1, -5, -1, -4, -1,
+
-3, -1, -2, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1,
+
5, -1, 6, -1, 9, -1, -23, 0, -18, 0, -14, 0, -11, 0, -7, 0,
+
-5, 0, -4, 0, -3, 0, -2, 0, -1, 0, 0, -23, 1, 0, 2, 0,
+
3, 0, 4, 0, 5, 0, 7, 0, 11, 0, 14, 0, 18, 0, 23, 0,
+
-9, 1, -6, 1, -5, 1, -4, 1, -3, 1, -2, 1, -1, 1, 0, 1,
+
1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 9, 1, -11, 2,
+
-7, 2, -5, 2, -4, 2, -3, 2, -2, 2, -1, 2, 0, 2, 1, 2,
+
2, 2, 3, 2, 4, 2, 5, 2, 7, 2, 11, 2, -8, 3, -6, 3,
+
-4, 3, -3, 3, -2, 3, -1, 3, 0, 3, 1, 3, 2, 3, 3, 3,
+
4, 3, 6, 3, 8, 3, -13, 4, -10, 4, -5, 4, -3, 4, -2, 4,
+
-1, 4, 0, 4, 1, 4, 2, 4, 3, 4, 5, 4, 10, 4, 13, 4,
+
-17, 5, -7, 5, -4, 5, -2, 5, -1, 5, 0, 5, 1, 5, 2, 5,
+
4, 5, 7, 5, 17, 5, -22, 6, -9, 6, -6, 6, -3, 6, -1, 6,
+
1, 6, 3, 6, 6, 6, 9, 6, 22, 6, -5, 7, -2, 7, 0, 7,
+
2, 7, 5, 7, -11, 8, -8, 8, -3, 8, 0, 8, 3, 8, 8, 8,
+
11, 8, -6, 9, -1, 9, 1, 9, 6, 9, -15, 10, -4, 10, 4, 10,
+
15, 10, -8, 11, -2, 11, 0, 11, 2, 11, 8, 11, 19, 12, -19, 13,
+
-4, 13, 4, 13, 0, 14, -10, 15, 10, 15, -5, 17, 5, 17, 0, 18,
+
-12, 19, 13, 19, -6, 22, 6, 22, 0, 23,
+
};
-void codec37_maketable(PersistentCodecData37 *pcd, int pitch, byte index) {
+
+
+
+void codec37_maketable(PersistentCodecData37 *pcd, int pitch, byte idx) {
+
int i,j;
- if (pcd->table_last_pitch==pitch && pcd->table_last_flags==index)
+
+
+ if (pcd->table_last_pitch==pitch && pcd->table_last_flags==idx)
+
return;
+
pcd->table_last_pitch = pitch;
- pcd->table_last_flags = index;
- assert(index*255 + 254 < sizeof(maketable_bytes)/2);
+ pcd->table_last_flags = idx;
+
+
+
+ assert(idx*255 + 254 < sizeof(maketable_bytes)/2);
+
+
for(i=0; i<255; i++) {
- j = i + index*255;
+
+ j = i + idx*255;
+
pcd->table1[i] = maketable_bytes[j*2+1] * pitch + maketable_bytes[j*2];
+
}
+
+
}
+
+
void codec37(CodecData *cd, PersistentCodecData37 *pcd) {
+
int width_in_blocks, height_in_blocks;
+
int src_pitch;
+
byte *src = cd->src, *curbuf;
+
uint size;
+
bool result = false;
+
+
width_in_blocks = (cd->w + 3) >> 2;
+
height_in_blocks = (cd->h + 3) >> 2;
+
src_pitch = width_in_blocks * 4;
+
+
codec37_maketable(pcd, src_pitch, cd->src[1]);
+
+
switch(cd->src[0]) {
+
case 0: {
+
curbuf = pcd->deltaBufs[pcd->curtable];
+
memset(pcd->deltaBuf, 0, curbuf - pcd->deltaBuf);
+
size = *(uint32*)(cd->src + 4);
+
memset(curbuf + size, 0, pcd->deltaBuf + pcd->deltaSize - curbuf - size);
+
memcpy(curbuf, cd->src + 16, size);
+
break;
+
}
+
case 2: {
+
size = *(uint32*)(cd->src + 4);
+
curbuf = pcd->deltaBufs[pcd->curtable];
+
if(size==64000)
+
codec37_bompdepack(curbuf, cd->src+16, size);
+
else
+
return;
+
memset(pcd->deltaBuf, 0, curbuf - pcd->deltaBuf);
+
memset(curbuf + size, 0, pcd->deltaBuf + pcd->deltaSize - curbuf - size);
+
break;
+
}
+
case 3: {
+
uint16 number = *(uint16*)(cd->src + 2);
+
if ( number && pcd->flags+1 != number)
+
break;
+
+
if (number&1 && cd->src[12]&1 && cd->flags&0x10) {
+
result=true;
+
break;
+
}
+
+
if ((number&1) || !(cd->src[12]&1)) {
+
pcd->curtable ^= 1;
+
}
+
+
codec37_proc5(pcd->deltaBufs[pcd->curtable], cd->src+16,
+
pcd->deltaBufs[pcd->curtable^1] - pcd->deltaBufs[pcd->curtable],
+
width_in_blocks, height_in_blocks, src_pitch,
+
pcd->table1);
+
break;
+
}
+
+
case 1:
+
case 4:
+
printf("code %d", cd->src[0]);
+
return;
+
default:
+
error("codec37 default case");
+
}
+
+
+
pcd->flags = *(uint16*)(cd->src + 2);
+
+
if (result) {
+
pcd->curtable ^= 1;
+
} else {
+
memcpy(cd->out, pcd->deltaBufs[pcd->curtable], 320*200);
+
}
+
+
}
+
+
+
void codec37_init(PersistentCodecData37 *pcd, int width, int height) {
+
pcd->width = width;
+
pcd->height = height;
+
pcd->deltaSize = width*height*2+0x3E00+0xBA00;
+
pcd->deltaBuf = (byte*)calloc(pcd->deltaSize, 1);
+
pcd->deltaBufs[0] = pcd->deltaBuf + 0x3E00;
+
pcd->deltaBufs[1] = pcd->deltaBuf + width * height + 0xBA00;
+
pcd->curtable = 0;
+
pcd->table1 = (int16*)calloc(255,sizeof(uint16));
+
}
+
+
void SmushPlayer::parseFOBJ() {
+
byte codec;
+
CodecData cd;
+
+
cd.out = _renderBitmap;
+
cd.pitch = cd.outwidth = 320;
+
cd.outheight = 200;
+
cd.y = 0;
+
cd.x = 0;
+
cd.src = _cur + 0xE;
+
cd.w = *(uint16*)(_cur + 6);
+
cd.h = *(uint16*)(_cur + 8);
+
+
codec = _cur[0];
+
+
switch(codec) {
+
case 1:
+
codec1(&cd);
+
break;
+
case 37:
+
codec37(&cd, &pcd37);
+
break;
+
default:
+
error("invalid codec %d", codec);
+
}
+
+
+
}
+
+
void SmushPlayer::parsePSAD() {
+
//printf("parse PSAD\n");
+
}
+
+
void SmushPlayer::parseTRES() {
+
// printf("parse TRES\n");
+
}
+
+
void SmushPlayer::parseXPAL() {
+
int num;
+
int i;
+
+
num = *(uint16*)(_cur + 2);
+
+
if (num==0 || num==0x200) {
+
if (num==0x200)
+
memcpy(_fluPalette, _cur + 0x604, 0x300);
+
+
for(i=0; i<0x300; i++) {
+
_fluPalMul129[i] = _fluPalette[i] * 129;
+
_fluPalWords[i] = *(uint16*)(_cur + 4 + i*2);
+
}
+
return;
+
}
+
+
for(i=0; i<0x300; i++) {
+
_fluPalMul129[i] += _fluPalWords[i];
+
_fluPalette[i] = _fluPalMul129[i]>>7;
+
}
+
+
_paletteChanged = true;
+
}
+
+
void SmushPlayer::parseFRME() {
+
_cur = _block;
+
+
do {
+
_frmeTag = nextBE32();
+
_frmeSize = nextBE32();
+
+
switch(_frmeTag) {
+
case 'NPAL':
+
parseNPAL();
+
break;
+
case 'FOBJ':
+
parseFOBJ();
+
break;
+
case 'PSAD':
+
parsePSAD();
+
break;
+
case 'TRES':
+
parseTRES();
+
break;
+
case 'XPAL':
+
parseXPAL();
+
break;
+
case 'IACT':
+
parseTRES();
+
break;
+
default:
+
invalidblock(_frmeTag);
+
}
+
+
_cur += (_frmeSize + 1) & ~1;
+
+
} while (_cur + 4 < _block + _blockSize);
+
}
+
+
void SmushPlayer::init() {
+
_renderBitmap = (byte*)malloc(320*200);
+
codec37_init(&pcd37, 320, 200);
+
}
+
+
void SmushPlayer::go() {
+
while (parseTag()) {}
+
}
+
+
+
void SmushPlayer::setPalette() {
+
int i;
+
+
for(i=0;i<768;i++)
+
sm->_currentPalette[i]=_fluPalette[i];
+
}
+
+
void SmushPlayer::startVideo(short int arg, byte* videoFile)
+
{
+
int frameIndex=0;
+
+
_in=NULL;
+
_paletteChanged=0;
+
_block=NULL;
+
_blockTag=0;
+
_blockSize=0;
+
_cur=NULL;
+
_renderBitmap=NULL;
+
_frameSize=0;
+
_frmeTag=0;
+
_frmeSize=0;
+
_deltaBuf=NULL;
+
_deltaBufSize=0;
+
+
pcd37.deltaBuf=NULL;
+
pcd37.deltaBufs[0]=NULL;
+
pcd37.deltaBufs[1]=NULL;
+
pcd37.deltaSize=0;
+
pcd37.width=0;
+
pcd37.height=0;
+
pcd37.curtable=0;
+
pcd37.unk2=0;
+
pcd37.unk3=0;
+
pcd37.flags=0;
+
pcd37.table1=NULL;
+
pcd37.table_last_pitch=0;
+
pcd37.table_last_flags=0;
+
+
+
+
init();
+
openFile(videoFile);
+
+
if(_in==NULL)
+
return;
+
+
if (fileReadBE32() != 'ANIM')
+
error("file is not an anim");
+
+
fileSize=fileReadBE32();
+
+
+
do {
+
if(ftell(_in)>=fileSize )
+
return;
+
+
parseTag();
+
frameIndex++;
+
+
if (_paletteChanged) {
+
_paletteChanged = false;
+
setPalette();
+
sm->setDirtyColors(0, 255);
+
}
+
+
blitToScreen(sm,_renderBitmap, 0, 0, 320 ,200);
+
+
updateScreen(sm);
+
+
waitForTimer(sm,20);
+
+
if(sm->_keyPressed == sm->_vars[sm->VAR_CUTSCENEEXIT_KEY])
+
return;
+
+
} while (1);
+
}
+
+
diff --git a/object.cpp b/object.cpp
index caa3bb877f..7db7a6e823 100644
--- a/object.cpp
+++ b/object.cpp
@@ -943,11 +943,11 @@ int Scumm::getObjNewDir(int obj) {
}
}
-int Scumm::findInventory(int owner, int index) {
+int Scumm::findInventory(int owner, int idx) {
int count = 1, i, obj;
for (i=0; i!=_maxInventoryItems; i++) {
obj = _inventory[i];
- if (obj && getOwner(obj)==owner && count++ == index)
+ if (obj && getOwner(obj)==owner && count++ == idx)
return obj;
}
return 0;
@@ -1130,7 +1130,7 @@ void Scumm::drawEnqueuedObject(EnqueuedObject *eo) {
VirtScreen *vs;
byte *roomptr,*bomp;
byte *ptr;
- int index;
+ int idx;
ObjectData *od;
BompDrawData bdd;
@@ -1141,9 +1141,9 @@ void Scumm::drawEnqueuedObject(EnqueuedObject *eo) {
if (eo->l==0) {
roomptr = getResourceAddress(1, _roomResource);
- index = getObjectIndex(eo->a);
- assert(index != -1);
- ptr = roomptr + _objs[index].offs_obim_to_room;
+ idx = getObjectIndex(eo->a);
+ assert(idx != -1);
+ ptr = roomptr + _objs[idx].offs_obim_to_room;
} else if (eo->a!=0) {
od = &_objs[getObjectIndex(eo->a)];
ptr = getResourceAddress(rtFlObject, od->fl_object_index);
diff --git a/resource.cpp b/resource.cpp
index d0e3cd900c..ec84d8360b 100644
--- a/resource.cpp
+++ b/resource.cpp
@@ -569,28 +569,28 @@ void Scumm::ensureResourceLoaded(int type, int i) {
_vars[VAR_ROOM_FLAG] = 1;
}
-int Scumm::loadResource(int type, int index) {
+int Scumm::loadResource(int type, int idx) {
int roomNr, i;
uint32 fileOffs;
uint32 size, tag;
-// debug(1, "loadResource(%d,%d)", type,index);
+// debug(1, "loadResource(%d,%d)", type,idx);
if(type == rtCharset && (_features & GF_SMALL_HEADER)){
- loadCharset(index);
+ loadCharset(idx);
return(1);
}
- roomNr = getResourceRoomNr(type, index);
- if (roomNr == 0 || index >= res.num[type]) {
+ roomNr = getResourceRoomNr(type, idx);
+ if (roomNr == 0 || idx >= res.num[type]) {
error("%s %d undefined",
- res.name[type],index);
+ res.name[type],idx);
}
if (type==rtRoom) {
fileOffs = 0;
} else {
- fileOffs = res.roomoffs[type][index];
+ fileOffs = res.roomoffs[type][idx];
if (fileOffs==0xFFFFFFFF)
return 0;
}
@@ -611,7 +611,7 @@ int Scumm::loadResource(int type, int index) {
if (type==rtSound) {
fileReadDwordLE();
fileReadDwordLE();
- return readSoundResource(type, index);
+ return readSoundResource(type, idx);
}
tag = fileReadDword();
@@ -624,12 +624,12 @@ int Scumm::loadResource(int type, int index) {
size = fileReadDwordBE();
fileSeek(_fileHandle, -8, SEEK_CUR);
}
- fileRead(_fileHandle, createResource(type, index, size), size);
+ fileRead(_fileHandle, createResource(type, idx, size), size);
/* dump the resource */
#ifdef DUMP_SCRIPTS
if(type==rtScript) {
- dumpResource("script-", index, getResourceAddress(rtScript, index));
+ dumpResource("script-", idx, getResourceAddress(rtScript, idx));
}
#endif
@@ -637,19 +637,19 @@ int Scumm::loadResource(int type, int index) {
return 1;
}
- nukeResource(type, index);
+ nukeResource(type, idx);
}
error("Cannot read resource");
} while(1);
}
-int Scumm::readSoundResource(int type, int index) {
+int Scumm::readSoundResource(int type, int idx) {
uint32 pos, total_size, size, tag,basetag;
int pri, best_pri;
uint32 best_size, best_offs;
- debug(9, "readSoundResource(%d,%d)", type, index);
+ debug(9, "readSoundResource(%d,%d)", type, idx);
pos = 0;
@@ -659,7 +659,7 @@ int Scumm::readSoundResource(int type, int index) {
if (_gameId==GID_SAMNMAX || _features & GF_AFTER_V7) {
if (basetag == MKID('MIDI')) {
fileSeek(_fileHandle, -8, SEEK_CUR);
- fileRead(_fileHandle,createResource(type, index, total_size+8), total_size+8);
+ fileRead(_fileHandle,createResource(type, idx, total_size+8), total_size+8);
return 1;
}
} else {
@@ -690,39 +690,39 @@ int Scumm::readSoundResource(int type, int index) {
if (best_pri != -1) {
fileSeek(_fileHandle, best_offs - 8, SEEK_SET);
- fileRead(_fileHandle,createResource(type, index, best_size), best_size);
+ fileRead(_fileHandle,createResource(type, idx, best_size), best_size);
return 1;
}
}
- res.roomoffs[type][index] = 0xFFFFFFFF;
+ res.roomoffs[type][idx] = 0xFFFFFFFF;
return 0;
}
-int Scumm::getResourceRoomNr(int type, int index) {
+int Scumm::getResourceRoomNr(int type, int idx) {
if (type==rtRoom)
- return index;
- return res.roomno[type][index];
+ return idx;
+ return res.roomno[type][idx];
}
-byte *Scumm::getResourceAddress(int type, int index) {
+byte *Scumm::getResourceAddress(int type, int idx) {
byte *ptr;
- debug(9, "getResourceAddress(%d,%d)", type, index);
+ debug(9, "getResourceAddress(%d,%d)", type, idx);
CHECK_HEAP
- validateResource("getResourceAddress", type, index);
+ validateResource("getResourceAddress", type, idx);
- if (res.mode[type] && !res.address[type][index]) {
- ensureResourceLoaded(type, index);
+ if (res.mode[type] && !res.address[type][idx]) {
+ ensureResourceLoaded(type, idx);
}
- ptr=(byte*)res.address[type][index];
+ ptr=(byte*)res.address[type][idx];
if (!ptr)
return NULL;
- setResourceCounter(type, index, 1);
+ setResourceCounter(type, idx, 1);
return ptr + sizeof(MemBlkHeader);
}
@@ -737,26 +737,26 @@ byte *Scumm::getStringAddress(int i) {
return b;
}
-void Scumm::setResourceCounter(int type, int index, byte flag) {
- res.flags[type][index] &= ~RF_USAGE;
- res.flags[type][index] |= flag;
+void Scumm::setResourceCounter(int type, int idx, byte flag) {
+ res.flags[type][idx] &= ~RF_USAGE;
+ res.flags[type][idx] |= flag;
}
/* 2 bytes safety area to make "precaching" of bytes in the gdi drawer easier */
#define SAFETY_AREA 2
-byte *Scumm::createResource(int type, int index, uint32 size) {
+byte *Scumm::createResource(int type, int idx, uint32 size) {
byte *ptr;
CHECK_HEAP
- debug(9, "createResource(%d,%d,%d)", type, index,size);
+ debug(9, "createResource(%d,%d,%d)", type, idx,size);
if (size > 65536*4+37856)
warning("Probably invalid size allocating %d", size);
- validateResource("allocating", type, index);
- nukeResource(type, index);
+ validateResource("allocating", type, idx);
+ nukeResource(type, idx);
expireResources(size);
@@ -769,30 +769,30 @@ byte *Scumm::createResource(int type, int index, uint32 size) {
_allocatedSize += size;
- res.address[type][index] = ptr;
+ res.address[type][idx] = ptr;
((MemBlkHeader*)ptr)->size = size;
- setResourceCounter(type, index, 1);
+ setResourceCounter(type, idx, 1);
return ptr + sizeof(MemBlkHeader); /* skip header */
}
-void Scumm::validateResource(const char *str, int type, int index) {
- if (type<rtFirst || type>rtLast || (uint)index >= (uint)res.num[type]) {
- error("%s Illegal Glob type %d num %d", str, type, index);
+void Scumm::validateResource(const char *str, int type, int idx) {
+ if (type<rtFirst || type>rtLast || (uint)idx >= (uint)res.num[type]) {
+ error("%s Illegal Glob type %d num %d", str, type, idx);
}
}
-void Scumm::nukeResource(int type, int index) {
+void Scumm::nukeResource(int type, int idx) {
byte *ptr;
- debug(9, "nukeResource(%d,%d)", type, index);
+ debug(9, "nukeResource(%d,%d)", type, idx);
CHECK_HEAP
assert( res.address[type] );
- assert( index>=0 && index < res.num[type]);
+ assert( idx>=0 && idx < res.num[type]);
- if ((ptr = res.address[type][index]) != NULL) {
- res.address[type][index] = 0;
- res.flags[type][index] = 0;
+ if ((ptr = res.address[type][idx]) != NULL) {
+ res.address[type][idx] = 0;
+ res.flags[type][idx] = 0;
_allocatedSize -= ((MemBlkHeader*)ptr)->size;
free(ptr);
}
@@ -887,7 +887,7 @@ StartScan:
return f->ptr;
}
-byte *findResource(uint32 tag, byte *searchin, int index) {
+byte *findResource(uint32 tag, byte *searchin, int idx) {
uint32 curpos,totalsize,size;
assert(searchin);
@@ -898,7 +898,7 @@ byte *findResource(uint32 tag, byte *searchin, int index) {
searchin += 4;
while (curpos<totalsize) {
- if (READ_UINT32_UNALIGNED(searchin)==tag && !index--)
+ if (READ_UINT32_UNALIGNED(searchin)==tag && !idx--)
return searchin;
size = READ_BE_UINT32_UNALIGNED(searchin+4);
@@ -917,7 +917,7 @@ byte *findResource(uint32 tag, byte *searchin, int index) {
return NULL;
}
-byte *findResourceSmall(uint32 tag, byte *searchin, int index) {
+byte *findResourceSmall(uint32 tag, byte *searchin, int idx) {
uint32 curpos,totalsize,size;
uint16 smallTag;
@@ -932,7 +932,7 @@ byte *findResourceSmall(uint32 tag, byte *searchin, int index) {
while (curpos<totalsize) {
size = READ_LE_UINT32(searchin);
- if (READ_LE_UINT16(searchin+4)==smallTag && !index--)
+ if (READ_LE_UINT16(searchin+4)==smallTag && !idx--)
return searchin;
if ((int32)size <= 0) {
@@ -1076,9 +1076,9 @@ void Scumm::loadPtrToResource(int type, int resindex, byte *source) {
}
}
-bool Scumm::isResourceLoaded(int type, int index) {
- validateResource("isLoaded", type, index);
- return res.address[type][index] != NULL;
+bool Scumm::isResourceLoaded(int type, int idx) {
+ validateResource("isLoaded", type, idx);
+ return res.address[type][idx] != NULL;
}
void Scumm::resourceStats() {
diff --git a/saveload.cpp b/saveload.cpp
index aa96b129fe..ea8afd5073 100644
--- a/saveload.cpp
+++ b/saveload.cpp
@@ -524,7 +524,7 @@ void Scumm::saveOrLoad(Serializer *s) {
}
-void Scumm::saveLoadResource(Serializer *ser, int type, int index) {
+void Scumm::saveLoadResource(Serializer *ser, int type, int idx) {
byte *ptr;
uint32 size;
@@ -533,7 +533,7 @@ void Scumm::saveLoadResource(Serializer *ser, int type, int index) {
return;
if (ser->isSaving()) {
- ptr = res.address[type][index];
+ ptr = res.address[type][idx];
if (ptr==NULL) {
ser->saveUint32(0);
return;
@@ -545,15 +545,15 @@ void Scumm::saveLoadResource(Serializer *ser, int type, int index) {
ser->saveLoadBytes(ptr+sizeof(MemBlkHeader),size);
if (type==rtInventory) {
- ser->saveWord(_inventory[index]);
+ ser->saveWord(_inventory[idx]);
}
} else {
size = ser->loadUint32();
if (size) {
- createResource(type, index, size);
- ser->saveLoadBytes(getResourceAddress(type, index), size);
+ createResource(type, idx, size);
+ ser->saveLoadBytes(getResourceAddress(type, idx), size);
if (type==rtInventory) {
- _inventory[index] = ser->loadWord();
+ _inventory[idx] = ser->loadWord();
}
}
}
diff --git a/script.cpp b/script.cpp
index 26e0cf95da..4cb858f490 100644
--- a/script.cpp
+++ b/script.cpp
@@ -207,7 +207,7 @@ void Scumm::updateScriptPtr() {
void Scumm::getScriptBaseAddress() {
ScriptSlot *ss;
- int index;
+ int idx;
if (_currentScript == 0xFF)
return;
@@ -215,9 +215,9 @@ void Scumm::getScriptBaseAddress() {
ss = &vm.slot[_currentScript];
switch(ss->where) {
case WIO_INVENTORY: /* inventory script **/
- index = getObjectIndex(ss->number);
- _scriptOrgPointer = getResourceAddress(rtInventory, index);
- _lastCodePtr = &_baseInventoryItems[index];
+ idx = getObjectIndex(ss->number);
+ _scriptOrgPointer = getResourceAddress(rtInventory, idx);
+ _lastCodePtr = &_baseInventoryItems[idx];
break;
case 3:
@@ -232,8 +232,8 @@ void Scumm::getScriptBaseAddress() {
break;
case WIO_FLOBJECT: /* flobject script */
- index = getObjectIndex(ss->number);
- _scriptOrgPointer = getResourceAddress(rtFlObject,_objs[index].fl_object_index);
+ idx = getObjectIndex(ss->number);
+ _scriptOrgPointer = getResourceAddress(rtFlObject,_objs[idx].fl_object_index);
_lastCodePtr = &_baseFLObject[ss->number];
break;
default:
@@ -881,16 +881,16 @@ bool Scumm::isRoomScriptRunning(int script) {
void Scumm::beginOverride() {
- int index;
+ int idx;
uint32 *ptr;
- index = vm.cutSceneStackPointer;
- ptr = &vm.cutScenePtr[index];
+ idx = vm.cutSceneStackPointer;
+ ptr = &vm.cutScenePtr[idx];
if (!*ptr) {
vm.slot[_currentScript].cutsceneOverride++;
}
*ptr = _scriptPointer - _scriptOrgPointer;
- vm.cutSceneScript[index] = _currentScript;
+ vm.cutSceneScript[idx] = _currentScript;
fetchScriptByte();
fetchScriptWord();
@@ -898,16 +898,16 @@ void Scumm::beginOverride() {
}
void Scumm::endOverride() {
- int index;
+ int idx;
uint32 *ptr;
- index = vm.cutSceneStackPointer;
- ptr = &vm.cutScenePtr[index];
+ idx = vm.cutSceneStackPointer;
+ ptr = &vm.cutScenePtr[idx];
if (*ptr) {
vm.slot[_currentScript].cutsceneOverride--;
}
*ptr = 0;
- vm.cutSceneScript[index] = 0;
+ vm.cutSceneScript[idx] = 0;
_vars[VAR_OVERRIDE] = 0;
}
diff --git a/script_v1.cpp b/script_v1.cpp
index 5ccf707a73..5edf101c8b 100644
--- a/script_v1.cpp
+++ b/script_v1.cpp
@@ -1024,7 +1024,7 @@ void Scumm::o5_drawBox() {
}
void Scumm::o5_drawObject() {
- int state,obj,index,i;
+ int state,obj,idx,i;
ObjectData *od;
uint16 x,y,w,h;
int xpos, ypos;
@@ -1037,10 +1037,10 @@ void Scumm::o5_drawObject() {
int temp = getVarOrDirectWord(0x40);
int room = getVarOrDirectWord(0x20);
- index = getObjectIndex(obj);
- if(index==-1)
+ idx = getObjectIndex(obj);
+ if(idx==-1)
return;
- od = &_objs[index];
+ od = &_objs[idx];
xpos = ypos = 255;
if (temp!=0xFF) {
od->walk_x += (xpos<<3) - od->x_pos;
@@ -1048,7 +1048,7 @@ void Scumm::o5_drawObject() {
od->walk_y += (ypos<<3) - od->y_pos;
od->y_pos = ypos<<3;
}
- addObjectToDrawQue(index);
+ addObjectToDrawQue(idx);
x = od->x_pos;
y = od->y_pos;
@@ -1079,17 +1079,17 @@ void Scumm::o5_drawObject() {
error("o5_drawObject: default case");
}
- index = getObjectIndex(obj);
- if (index==-1)
+ idx = getObjectIndex(obj);
+ if (idx==-1)
return;
- od = &_objs[index];
+ od = &_objs[idx];
if (xpos!=0xFF) {
od->walk_x += (xpos<<3) - od->x_pos;
od->x_pos = xpos<<3;
od->walk_y += (ypos<<3) - od->y_pos;
od->y_pos = ypos<<3;
}
- addObjectToDrawQue(index);
+ addObjectToDrawQue(idx);
x = od->x_pos;
y = od->y_pos;
@@ -1629,85 +1629,85 @@ void Scumm::o5_quitPauseRestart() {
}
void Scumm::o5_resourceRoutines() {
- int res;
+ int resid;
_opcode = fetchScriptByte();
if (_opcode != 17)
- res = getVarOrDirectByte(0x80);
+ resid = getVarOrDirectByte(0x80);
if(_features & GF_OLD256) /*FIXME: find a better way to implement this */
_opcode&=0x3F;
switch(_opcode&0x1F) {
case 1: /* load script */
- ensureResourceLoaded(rtScript, res);
+ ensureResourceLoaded(rtScript, resid);
break;
case 2: /* load sound */
- ensureResourceLoaded(rtSound, res);
+ ensureResourceLoaded(rtSound, resid);
break;
case 3: /* load costume */
- ensureResourceLoaded(rtCostume, res);
+ ensureResourceLoaded(rtCostume, resid);
break;
case 4: /* load room */
if(_features & GF_OLD256)
- ensureResourceLoaded(rtScript, res & 0x7F); /*FIXME: missing stuff...*/
+ ensureResourceLoaded(rtScript, resid & 0x7F); /*FIXME: missing stuff...*/
else
- ensureResourceLoaded(rtRoom, res);
+ ensureResourceLoaded(rtRoom, resid);
break;
case 5: /* nuke script */
- setResourceCounter(rtScript, res, 0x7F);
+ setResourceCounter(rtScript, resid, 0x7F);
break;
case 6: /* nuke sound */
- setResourceCounter(rtSound, res, 0x7F);
+ setResourceCounter(rtSound, resid, 0x7F);
break;
case 7: /* nuke costume */
- setResourceCounter(rtCostume, res, 0x7F);
+ setResourceCounter(rtCostume, resid, 0x7F);
break;
case 8: /* nuke room */
- setResourceCounter(rtRoom, res, 0x7F);
+ setResourceCounter(rtRoom, resid, 0x7F);
break;
case 9: /* lock script */
- if (res >= _numGlobalScripts)
+ if (resid >= _numGlobalScripts)
break;
- lock(rtScript,res);
+ lock(rtScript,resid);
break;
case 10:/* lock sound */
- lock(rtSound,res);
+ lock(rtSound,resid);
break;
case 11:/* lock costume */
- lock(rtCostume,res);
+ lock(rtCostume,resid);
break;
case 12:/* lock room */
- if (res > 0x7F)
- res = _resourceMapper[res&0x7F];
- lock(rtRoom,res);
+ if (resid > 0x7F)
+ resid = _resourceMapper[resid&0x7F];
+ lock(rtRoom,resid);
break;
case 13:/* unlock script */
- if (res >= _numGlobalScripts)
+ if (resid >= _numGlobalScripts)
break;
- unlock(rtScript,res);
+ unlock(rtScript,resid);
break;
case 14:/* unlock sound */
- unlock(rtSound,res);
+ unlock(rtSound,resid);
break;
case 15:/* unlock costume */
- unlock(rtCostume,res);
+ unlock(rtCostume,resid);
break;
case 16:/* unlock room */
- if (res > 0x7F)
- res = _resourceMapper[res&0x7F];
- unlock(rtRoom,res);
+ if (resid > 0x7F)
+ resid = _resourceMapper[resid&0x7F];
+ unlock(rtRoom,resid);
break;
case 17:/* clear heap */
heapClear(0);
unkHeapProc2(0,0);
break;
case 18:/* load charset */
- loadCharset(res);
+ loadCharset(resid);
break;
case 19:/* nuke charset */
- nukeCharset(res);
+ nukeCharset(resid);
break;
case 20:/* load fl object */
- loadFlObject(getVarOrDirectWord(0x40), res);
+ loadFlObject(getVarOrDirectWord(0x40), resid);
break;
default:
warning("Unknown o5_resourcesroutine: %d", _opcode&0x1F);
diff --git a/script_v2.cpp b/script_v2.cpp
index c0006d1653..f1d85977ff 100644
--- a/script_v2.cpp
+++ b/script_v2.cpp
@@ -700,14 +700,14 @@ int Scumm::popRoomAndObj(int *room) {
}
-int Scumm::readArray(int array, int index, int base) {
+int Scumm::readArray(int array, int idx, int base) {
ArrayHeader *ah = (ArrayHeader*)getResourceAddress(rtString, readVar(array));
if (ah==NULL) {
error("readArray: invalid array %d (%d)", array, readVar(array));
}
- base += index*ah->dim1_size;
+ base += idx*ah->dim1_size;
assert(base>=0 && base < ah->dim1_size*ah->dim2_size);
@@ -718,10 +718,10 @@ int Scumm::readArray(int array, int index, int base) {
}
}
-void Scumm::writeArray(int array, int index, int base, int value) {
+void Scumm::writeArray(int array, int idx, int base, int value) {
ArrayHeader *ah = (ArrayHeader*)getResourceAddress(rtString, readVar(array));
assert(ah);
- base += index*ah->dim1_size;
+ base += idx*ah->dim1_size;
assert(base>=0 && base < ah->dim1_size*ah->dim2_size);
@@ -783,14 +783,14 @@ void Scumm::o6_wordArrayRead() {
void Scumm::o6_byteArrayIndexedRead() {
int base = pop();
- int index = pop();
- push(readArray(fetchScriptByte(), index, base));
+ int idx = pop();
+ push(readArray(fetchScriptByte(), idx, base));
}
void Scumm::o6_wordArrayIndexedRead() {
int base = pop();
- int index = pop();
- push(readArray(fetchScriptWord(), index, base));
+ int idx = pop();
+ push(readArray(fetchScriptWord(), idx, base));
}
void Scumm::o6_dup() {
@@ -1463,9 +1463,9 @@ void Scumm::o6_getActorCostume() {
}
void Scumm::o6_findInventory() {
- int index = pop();
+ int idx = pop();
int owner = pop();
- push(findInventory(owner,index));
+ push(findInventory(owner,idx));
}
void Scumm::o6_getInventoryCount() {
@@ -1543,100 +1543,100 @@ void Scumm::o6_createBoxMatrix() {
}
void Scumm::o6_resourceRoutines() {
- int res;
+ int resid;
switch(fetchScriptByte()) {
case 100: /* load script */
- res = pop();
+ resid = pop();
if(_features & GF_AFTER_V7)
- if (res >= _numGlobalScripts)
+ if (resid >= _numGlobalScripts)
break;
- ensureResourceLoaded(rtScript, res);
+ ensureResourceLoaded(rtScript, resid);
break;
case 101: /* load sound */
- res = pop();
- ensureResourceLoaded(rtSound, res);
+ resid = pop();
+ ensureResourceLoaded(rtSound, resid);
break;
case 102: /* load costume */
- res = pop();
- ensureResourceLoaded(rtCostume, res);
+ resid = pop();
+ ensureResourceLoaded(rtCostume, resid);
break;
case 103: /* load room */
- res = pop();
- ensureResourceLoaded(rtRoom, res);
+ resid = pop();
+ ensureResourceLoaded(rtRoom, resid);
break;
case 104: /* nuke script */
- res = pop();
+ resid = pop();
if(_features & GF_AFTER_V7)
- if (res >= _numGlobalScripts)
+ if (resid >= _numGlobalScripts)
break;
- setResourceCounter(rtScript, res, 0x7F);
- debug(5, "nuke script %d", res);
+ setResourceCounter(rtScript, resid, 0x7F);
+ debug(5, "nuke script %d", resid);
break;
case 105: /* nuke sound */
- res = pop();
- setResourceCounter(rtSound, res, 0x7F);
+ resid = pop();
+ setResourceCounter(rtSound, resid, 0x7F);
break;
case 106: /* nuke costume */
- res = pop();
- setResourceCounter(rtCostume, res, 0x7F);
+ resid = pop();
+ setResourceCounter(rtCostume, resid, 0x7F);
break;
case 107: /* nuke room */
- res = pop();
- setResourceCounter(rtRoom, res, 0x7F);
+ resid = pop();
+ setResourceCounter(rtRoom, resid, 0x7F);
break;
case 108: /* lock script */
- res = pop();
- if (res >= _numGlobalScripts)
+ resid = pop();
+ if (resid >= _numGlobalScripts)
break;
- lock(rtScript,res);
+ lock(rtScript,resid);
break;
case 109:/* lock sound */
- res = pop();
- lock(rtSound,res);
+ resid = pop();
+ lock(rtSound,resid);
break;
case 110:/* lock costume */
- res = pop();
- lock(rtCostume,res);
+ resid = pop();
+ lock(rtCostume,resid);
break;
case 111:/* lock room */
- res = pop();
- if (res > 0x7F)
- res = _resourceMapper[res&0x7F];
- lock(rtRoom,res);
+ resid = pop();
+ if (resid > 0x7F)
+ resid = _resourceMapper[resid&0x7F];
+ lock(rtRoom,resid);
break;
case 112:/* unlock script */
- res = pop();
- if (res >= _numGlobalScripts)
+ resid = pop();
+ if (resid >= _numGlobalScripts)
break;
- unlock(rtScript,res);
+ unlock(rtScript,resid);
break;
case 113:/* unlock sound */
- res = pop();
- unlock(rtSound,res);
+ resid = pop();
+ unlock(rtSound,resid);
break;
case 114:/* unlock costume */
- res = pop();
- unlock(rtCostume,res);
+ resid = pop();
+ unlock(rtCostume,resid);
break;
case 115:/* unlock room */
- res = pop();
- if (res > 0x7F)
- res = _resourceMapper[res&0x7F];
- unlock(rtRoom,res);
+ resid = pop();
+ if (resid > 0x7F)
+ resid = _resourceMapper[resid&0x7F];
+ unlock(rtRoom,resid);
break;
case 116:/* clear heap */
/* this is actually a scumm message */
error("clear heap not working yet");
break;
case 117:/* load charset */
- res = pop();
- loadCharset(res);
+ resid = pop();
+ loadCharset(resid);
break;
case 118:/* nuke charset */
warning("popping extra argument in nukeCharset");
- res = pop();
- nukeCharset(res);
+ resid = pop();
+ nukeCharset(resid);
break;
case 119: {/* load fl object */
int room,obj = popRoomAndObj(&room);
diff --git a/scummvm.cpp b/scummvm.cpp
index 39552332cd..66c53efb39 100644
--- a/scummvm.cpp
+++ b/scummvm.cpp
@@ -943,7 +943,7 @@ void Scumm::setScaleItem(int slot, int a, int b, int c, int d) {
}
}
-void Scumm::dumpResource(char *tag, int index, byte *ptr) {
+void Scumm::dumpResource(char *tag, int idx, byte *ptr) {
char buf[256];
FILE *out;
@@ -953,7 +953,7 @@ void Scumm::dumpResource(char *tag, int index, byte *ptr) {
else
size = READ_BE_UINT32_UNALIGNED(ptr+4);
- sprintf(buf, "dumps/%s%d.dmp", tag,index);
+ sprintf(buf, "dumps/%s%d.dmp", tag,idx);
out = fopen(buf,"rb");
if (!out) {