bug fixes, code cleanup

svn-id: r3446
This commit is contained in:
Ludvig Strigeus 2001-10-26 17:34:50 +00:00
parent f9daf35824
commit 056dd5b15d
17 changed files with 1178 additions and 1110 deletions

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.7 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.6 2001/10/23 19:51:50 strigeus
* recompile not needed when switching games
* debugger skeleton implemented
@ -445,8 +448,8 @@ void Scumm::putActor(Actor *a, int x, int y, byte room) {
a->needRedraw = true;
a->needBgReset = true;
if (_vars[VAR_UNK_ACTOR]==a->number) {
dseg_3A76 = 1;
if (_vars[VAR_EGO]==a->number) {
_egoPositioned = true;
}
if (a->visible) {
@ -774,8 +777,8 @@ void Scumm::setupCostumeRenderer(CostumeRenderer *c, Actor *a) {
c->_actorX = a->x - virtscr->xstart;
c->_actorY = a->y - a->elevation;
c->_zbuf = a->mask;
if (c->_zbuf > _numZBuffer)
c->_zbuf = (byte)_numZBuffer;
if (c->_zbuf > gdi._numZBuffer)
c->_zbuf = (byte)gdi._numZBuffer;
if (a->neverZClip)
c->_zbuf = a->neverZClip;

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.6 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.5 2001/10/23 19:51:50 strigeus
* recompile not needed when switching games
* debugger skeleton implemented
@ -286,21 +289,21 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame) {
return 2;
}
_where_to_draw_ptr = _vm->getResourceAddress(0xA, 5) + _vm->virtscr[0].xstart + _ypos*320 + _xpos;
_bg_ptr = _vm->getResourceAddress(0xA, 1) + _vm->virtscr[0].xstart + _ypos*320 + _xpos;
_bgbak_ptr = _vm->getResourceAddress(0xA, 5) + _vm->virtscr[0].xstart + _ypos*320 + _xpos;
_backbuff_ptr = _vm->getResourceAddress(0xA, 1) + _vm->virtscr[0].xstart + _ypos*320 + _xpos;
charsetmask = _vm->hasCharsetMask(_left, _top + _vm->virtscr[0].topline, _right, _vm->virtscr[0].topline + _bottom);
masking = 0;
if (_zbuf) {
masking = _vm->isMaskActiveAt(_left, _top, _right, _bottom,
_vm->getResourceAddress(0xA, 9) + _vm->_imgBufOffs[_zbuf] + _vm->_screenStartStrip
_vm->getResourceAddress(0xA, 9) + _vm->gdi._imgBufOffs[_zbuf] + _vm->_screenStartStrip
);
}
if (_zbuf || charsetmask) {
_mask_ptr = _vm->getResourceAddress(0xA, 9) + _ypos*40 + _vm->_screenStartStrip;
_imgbufoffs = _vm->_imgBufOffs[_zbuf];
_imgbufoffs = _vm->gdi._imgBufOffs[_zbuf];
if (!charsetmask && _zbuf!=0)
_mask_ptr += _imgbufoffs;
_mask_ptr_dest = _mask_ptr + _xpos / 8;
@ -344,7 +347,7 @@ void CostumeRenderer::proc6() {
y = _ypos;
len = _replen;
src = _srcptr;
dst = _bg_ptr;
dst = _backbuff_ptr;
color = _repcolor;
scrheight = _vscreenheight;
width = _width2;
@ -391,7 +394,7 @@ void CostumeRenderer::proc5() {
maskbit = revBitMask[_xpos&7];
y = _ypos;
src = _srcptr;
dst = _bg_ptr;
dst = _backbuff_ptr;
len = _replen;
color = _repcolor;
scrheight = _vscreenheight;
@ -451,7 +454,7 @@ void CostumeRenderer::proc4() {
maskbit = revBitMask[_xpos&7];
y = _ypos;
src = _srcptr;
dst = _bg_ptr;
dst = _backbuff_ptr;
len = _replen;
color = _repcolor;
scrheight = _vscreenheight;
@ -508,7 +511,7 @@ void CostumeRenderer::proc3() {
uint y;
mask = _mask_ptr_dest;
dst = _bg_ptr;
dst = _backbuff_ptr;
height = _height2;
width = _width2;
len = _replen;
@ -549,9 +552,9 @@ void CostumeRenderer::proc3() {
if (_xpos >= 320)
return;
maskbit = revBitMask[_xpos&7];
_bg_ptr += _scaleIndexXStep;
_backbuff_ptr += _scaleIndexXStep;
}
dst = _bg_ptr;
dst = _backbuff_ptr;
mask = _mask_ptr + (_xpos>>3);
}
StartPos:;
@ -566,7 +569,7 @@ void CostumeRenderer::proc2() {
uint y;
mask = _mask_ptr_dest;
dst = _bg_ptr;
dst = _backbuff_ptr;
height = _height2;
width = _width2;
len = _replen;
@ -607,9 +610,9 @@ void CostumeRenderer::proc2() {
if (_xpos >= 320)
return;
maskbit = revBitMask[_xpos&7];
_bg_ptr += _scaleIndexXStep;
_backbuff_ptr += _scaleIndexXStep;
}
dst = _bg_ptr;
dst = _backbuff_ptr;
mask = _mask_ptr + (_xpos>>3);
}
StartPos:;
@ -619,28 +622,17 @@ StartPos:;
}
void CostumeRenderer::proc1() {
byte *mask,*src,*dst;
byte *mask,*src,*dst,*dstorg;
byte maskbit,len,height,pcolor,width;
uint y;
int color;
int t;
#if 0
debug(1, "proc1(): (%d %d),(%d %d %d),(%d %d %d),(%d %d,%d %d,%d %d),(%d %d)",
_xpos, _ypos,
_width2, _height2, _height,
_replen,_repcolor,_docontinue,
_scaleX, _scaleY, _scaleIndexX, _scaleIndexY,
_scaleIndexXStep, _scaleIndexYStep,
_scaleIndexYTop,_vscreenheight
);
#endif
mask = _mask_ptr = _mask_ptr_dest;
maskbit = revBitMask[_xpos&7];
y = _ypos;
dst = _bg_ptr;
dstorg = dst = _backbuff_ptr;
height = _height2;
width = _width2;
len = _replen;
@ -678,9 +670,9 @@ void CostumeRenderer::proc1() {
_xpos += _scaleIndexXStep;
if (_xpos >= 320)
return;
_bg_ptr += _scaleIndexXStep;
_backbuff_ptr += _scaleIndexXStep;
}
dst = _bg_ptr;
dst = _backbuff_ptr;
}
StartPos:;
} while (--len);

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.3 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.2 2001/10/23 19:56:57 strigeus
* fixed spelling error
*
@ -36,6 +39,8 @@ enum {
CMD_HELP,
CMD_QUIT,
CMD_GO,
CMD_ACTOR,
CMD_SCRIPTS,
};
void ScummDebugger::attach(Scumm *s) {
@ -57,7 +62,7 @@ bool ScummDebugger::do_command() {
printf("Debugger commands:\n"
"help -> display this help text\n"
"quit -> quit the debugger\n"
"step -> increase one frame\n"
"go [numframes] -> increase frame\n"
);
return true;
@ -71,7 +76,15 @@ bool ScummDebugger::do_command() {
else
_go_amount = atoi(_parameters);
return false;
case CMD_ACTOR:
if (!_parameters[0])
printActors(-1);
else
printActors(atoi(_parameters));
return true;
case CMD_SCRIPTS:
printScripts();
return true;
}
}
@ -108,6 +121,8 @@ static const DebuggerCommands debugger_commands[] = {
{ "h", 1, CMD_HELP },
{ "q", 1, CMD_QUIT },
{ "g", 1, CMD_GO },
{ "a", 1, CMD_ACTOR },
{ "s", 1, CMD_SCRIPTS },
{ 0, 0, 0 },
};
@ -143,4 +158,39 @@ int ScummDebugger::get_command() {
if (*s==32) { *s=0; break; }
printf("Invalid command '%s'. Type 'help' for a list of available commands.\n", _cmd_buffer);
} while (1);
}
void ScummDebugger::printActors(int act) {
int i;
Actor *a;
if (act==-1) {
printf("+--------------------------------------------------------------+\n");
printf("|# |room| x y |elev|cos|width|box|mov|zp|frame|scale|spd|dir|\n");
printf("+--+----+--------+----+---+-----+---+---+--+-----+-----+---+---+\n");
for(i=1; i<13; i++) {
a = &_s->actor[i];
if (a->visible)
printf("|%2d|%4d|%3d %3d|%4d|%3d|%5d|%3d|%3d|%2d|%5d|%5d|%3d|%3d|\n",
i,a->room,a->x,a->y,a->elevation,a->costume,a->width,a->walkbox,a->moving,a->neverZClip,a->animIndex,a->scalex,a->speedx,a->facing);
}
printf("+--------------------------------------------------------------+\n");
}
}
void ScummDebugger::printScripts() {
int i;
ScriptSlot *ss;
printf("+---------------------------------+\n");
printf("|# |num|sta|typ|un1|un2|fc|cut|un5|\n");
printf("+--+---+---+---+---+---+--+---+---+\n");
for(i=0; i<25; i++) {
ss = &_s->vm.slot[i];
if (ss->number) {
printf("|%2d|%3d|%3d|%3d|%3d|%3d|%2d|%3d|%3d|\n",
i, ss->number, ss->status, ss->type, ss->unk1, ss->unk2, ss->freezeCount, ss->cutsceneOverride, ss->unk5);
}
}
printf("+---------------------------------+\n");
}

975
gfx.cpp

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.7 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.6 2001/10/23 19:51:50 strigeus
* recompile not needed when switching games
* debugger skeleton implemented
@ -152,13 +155,13 @@ void Scumm::getObjectXYPos(int object) {
if (od->fl_object_index) {
ptr = getResourceAddress(0xD, od->fl_object_index);
ptr = findResource(MKID('OBIM'), ptr);
ptr = findResource(MKID('OBIM'), ptr, 0);
} else {
ptr = getResourceAddress(1, _roomResource);
ptr += od->offs_obim_to_room;
}
imhd = (ImageHeader*)findResource2(MKID('IMHD'), ptr);
imhd = (ImageHeader*)findResource(MKID('IMHD'), ptr, 0);
x = od->x_pos*8 + (int16)READ_LE_UINT16(&imhd->hotspot[state].x);
y = od->y_pos*8 + (int16)READ_LE_UINT16(&imhd->hotspot[state].y);
} else {
@ -196,7 +199,6 @@ int Scumm::getObjActToObjActDist(int a, int b) {
if (getObjectOrActorXY(b)==-1)
return 0xFF;
/* XXX: bug here? should be <= */
if (acta) {
AdjustBoxResult r = adjustXYToBeInBox(acta, _xPos, _yPos);
_xPos = r.x;
@ -281,12 +283,13 @@ void Scumm::drawObject(int obj, int arg) {
ObjectData *od;
int xpos, ypos, height, width;
byte *ptr;
int x,a,b;
int x,a,numstrip;
int tmp;
if (_BgNeedsRedraw)
arg = 0;
gdi.virtScreen = 0;
_curVirtScreen = &virtscr[0];
od = &_objs[obj];
@ -300,40 +303,39 @@ void Scumm::drawObject(int obj, int arg) {
if (od->fl_object_index) {
ptr = getResourceAddress(0xD, od->fl_object_index);
ptr = findResource(MKID('OBIM'), ptr);
ptr = findResource(MKID('OBIM'), ptr, 0);
} else {
ptr = getResourceAddress(1, _roomResource);
ptr = ptr + od->offs_obim_to_room;
}
ptr = findResource(state_tags[getState(od->obj_nr)], ptr);
ptr = findResource(state_tags[getState(od->obj_nr)], ptr, 0);
if (!ptr)
return;
x = 0xFFFF;
for (a=b=0; a<width; a++) {
_drawBmpX = xpos + a;
if (arg==1 && _screenStartStrip!=_drawBmpX)
for (a=numstrip=0; a<width; a++) {
tmp = xpos + a;
if (arg==1 && _screenStartStrip!=tmp)
continue;
if (arg==2 && _screenEndStrip!=_drawBmpX)
if (arg==2 && _screenEndStrip!=tmp)
continue;
if (_screenStartStrip > _drawBmpX || _drawBmpX > _screenEndStrip)
if (tmp < _screenStartStrip || tmp > _screenEndStrip)
continue;
actorDrawBits[_drawBmpX] |= 0x8000;
if (_drawBmpX < x)
x = _drawBmpX;
b++;
actorDrawBits[tmp] |= 0x8000;
if (tmp < x)
x = tmp;
numstrip++;
}
if (b==0)
return;
if (numstrip!=0)
gdi.drawBitmap(ptr, _curVirtScreen, x, ypos<<3, height<<3, x-xpos, numstrip, true);
_drawBmpY = ypos << 3;
gdi.numLinesToProcess = height << 3;
_drawBmpX = x;
drawBmp(ptr, x - xpos, b, 1, "Object", od->obj_nr);
// _drawBmpY = ypos << 3;
// gdi._numLinesToProcess = height << 3;
// _drawBmpX = x;
// drawBmp(ptr, x - xpos, b, 1, "Object", od->obj_nr);
}
void Scumm::loadRoomObjects() {
@ -341,7 +343,7 @@ void Scumm::loadRoomObjects() {
ObjectData *od;
byte *ptr;
uint16 obim_id;
byte *room,*tmp_room;
byte *room;
ImageHeader *imhd;
RoomHeader *roomhdr;
@ -350,7 +352,7 @@ void Scumm::loadRoomObjects() {
CHECK_HEAP
room = getResourceAddress(1, _roomResource);
roomhdr = (RoomHeader*)findResource(MKID('RMHD'), room);
roomhdr = (RoomHeader*)findResource(MKID('RMHD'), room, 0);
_numObjectsInRoom = READ_LE_UINT16(&roomhdr->numObjects);
@ -360,16 +362,14 @@ void Scumm::loadRoomObjects() {
if (_numObjectsInRoom > _numLocalObjects)
error("More than %d objects in room %d", _numLocalObjects, _roomResource);
tmp_room = room;
od = &_objs[1];
for (i=1; i<=_numObjectsInRoom; i++,od++) {
ptr = findResource(MKID('OBCD'), tmp_room);
for (i=0; i<_numObjectsInRoom; i++,od++) {
ptr = findResource(MKID('OBCD'), room, i);
if (ptr==NULL)
error("Room %d missing object code block(s)", _roomResource);
od->offs_obcd_to_room = ptr - room;
cdhd = (CodeHeader*)findResource2(MKID('CDHD'), ptr);
cdhd = (CodeHeader*)findResource(MKID('CDHD'), ptr, 0);
od->obj_nr = READ_LE_UINT16(&cdhd->obj_id);
#ifdef DUMP_SCRIPTS
@ -379,29 +379,26 @@ void Scumm::loadRoomObjects() {
dumpResource(buf, od->obj_nr, ptr);
} while (0);
#endif
tmp_room = NULL;
}
tmp_room = room;
for (i=1; i<=_numObjectsInRoom; i++) {
ptr = findResource(MKID('OBIM'), tmp_room);
for (i=0; i<_numObjectsInRoom; i++) {
ptr = findResource(MKID('OBIM'), room, i);
if (ptr==NULL)
error("Room %d missing image blocks(s)", _roomResource);
imhd = (ImageHeader*)findResource2(MKID('IMHD'), ptr);
imhd = (ImageHeader*)findResource(MKID('IMHD'), ptr, 0);
obim_id = READ_LE_UINT16(&imhd->obj_id);
for(j=1; j<=_numObjectsInRoom; j++) {
if (_objs[j].obj_nr==obim_id)
_objs[j].offs_obim_to_room = ptr - room;
}
tmp_room = NULL;
}
od = &_objs[1];
for (i=1; i<=_numObjectsInRoom; i++,od++) {
ptr = room + _objs[i].offs_obcd_to_room;
cdhd = (CodeHeader*)findResource2(MKID('CDHD'), ptr);
cdhd = (CodeHeader*)findResource(MKID('CDHD'), ptr,0);
_objs[i].obj_nr = READ_LE_UINT16(&cdhd->obj_id);
if (_majorScummVersion == 6) {
@ -482,14 +479,15 @@ void Scumm::clearOwnerOf(int obj) {
nukeResource(5, i);
_inventory[i] = 0;
}
a = &_inventory[2];
for (i=1; i < _maxInventoryItems-1; i++) {
if (!a[-1] && a[0]) {
a[-1] = a[0];
a = &_inventory[1];
for (i=1; i < _maxInventoryItems-1; i++,a++) {
if (!a[0] && a[1]) {
a[0] = a[1];
a[1] = 0;
ptr = getResourceAddress(5, i+1);
_baseInventoryItems[i] = _baseInventoryItems[i+1];
_baseInventoryItems[i+1] = 0;
/* TODO: some wacky write is done here */
error("clearOwnerOf: not fully implemented");
}
}
return;
@ -536,7 +534,7 @@ byte *Scumm::getObjOrActorName(int obj) {
if (objptr==NULL)
return (byte*)" ";
return findResource(MKID('OBNA'), objptr) + 8;
return findResource(MKID('OBNA'), objptr, 0) + 8;
}
uint32 Scumm::getOBCDOffs(int object) {
@ -579,7 +577,7 @@ void Scumm::addObjectToInventory(int obj, int room) {
byte *ptr,*obcdptr;
uint32 size,cdoffs;
int numobj;
byte *tmp_roomptr,*roomptr;
byte *roomptr;
CodeHeader *cdhd;
RoomHeader *roomhdr;
@ -601,19 +599,18 @@ void Scumm::addObjectToInventory(int obj, int room) {
}
ensureResourceLoaded(1, room);
roomptr = getResourceAddress(1, room);
roomhdr = (RoomHeader*)findResource(MKID('RMHD'), roomptr);
roomhdr = (RoomHeader*)findResource(MKID('RMHD'), roomptr, 0);
numobj = READ_LE_UINT16(&roomhdr->numObjects);
if (numobj==0)
error("addObjectToInventory: No object found in room %d", room);
if (numobj > 200)
error("addObjectToInventory: More (%d) than %d objects in room %d", numobj, 200, room);
tmp_roomptr = roomptr;
for (i=1; i<=numobj; i++) {
obcdptr = findResource(MKID('OBCD'), tmp_roomptr);
for (i=0; i<numobj; i++) {
obcdptr = findResource(MKID('OBCD'), roomptr, i);
if(obcdptr==NULL)
error("addObjectToInventory: Not enough code blocks in room %d", room);
cdhd = (CodeHeader*)findResource2(MKID('CDHD'), obcdptr);
cdhd = (CodeHeader*)findResource(MKID('CDHD'), obcdptr, 0);
if ( READ_LE_UINT16(&cdhd->obj_id) == obj) {
cdoffs = obcdptr - roomptr;
size = READ_BE_UINT32_UNALIGNED(obcdptr+4);
@ -625,7 +622,6 @@ void Scumm::addObjectToInventory(int obj, int room) {
CHECK_HEAP
return;
}
tmp_roomptr = NULL;
}
error("addObjectToInventory: Object %d not found in room %d", obj, room);

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.7 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.6 2001/10/24 20:12:52 strigeus
* fixed some bugs related to string handling
*
@ -650,20 +653,19 @@ void Scumm::unkResourceProc() {
warning("unkResourceProc: not implemented");
}
byte *findResource(uint32 tag, byte *searchin, int index) {
uint32 maxsize,curpos,totalsize,size;
byte *Scumm::findResource(uint32 tag, byte *searchin) {
uint32 size;
searchin += 4;
totalsize = READ_BE_UINT32_UNALIGNED(searchin);
curpos = 8;
searchin += 4;
if (searchin) {
searchin+=4;
_findResSize = READ_BE_UINT32_UNALIGNED(searchin);
_findResHeaderSize = 8;
_findResPos = searchin+4;
goto startScan;
}
while (curpos<totalsize) {
if (READ_UINT32_UNALIGNED(searchin)==tag && !index--)
return searchin;
do {
size = READ_BE_UINT32_UNALIGNED(_findResPos+4);
size = READ_BE_UINT32_UNALIGNED(searchin+4);
if ((int32)size <= 0) {
error("(%c%c%c%c) Not found in %d... illegal block len %d",
tag&0xFF,(tag>>8)&0xFF,(tag>>16)&0xFF,(tag>>24)&0xFF,
@ -671,53 +673,17 @@ byte *Scumm::findResource(uint32 tag, byte *searchin) {
size);
return NULL;
}
_findResHeaderSize += size;
_findResPos += size;
startScan:;
if (_findResHeaderSize >= _findResSize)
return NULL;
/* endian OK, tags are in native format */
} while (READ_UINT32_UNALIGNED(_findResPos) != tag);
return _findResPos;
}
curpos += size;
searchin += size;
}
byte *Scumm::findResource2(uint32 tag, byte *searchin) {
uint32 size;
if (searchin) {
searchin+=4;
_findResSize2 = READ_BE_UINT32_UNALIGNED(searchin);
_findResHeaderSize2 = 8;
_findResPos2 = searchin+4;
goto startScan;
}
do {
size = READ_BE_UINT32_UNALIGNED(_findResPos2+4);
if ((int32)size <= 0) {
error("(%c%c%c%c) Not found in %d... illegal block len %d",
tag&0xFF,(tag>>8)&0xFF,(tag>>16)&0xFF,(tag>>24)&0xFF,
0,
size);
return NULL;
}
_findResHeaderSize2 += size;
_findResPos2 += size;
startScan:;
if (_findResHeaderSize2 >= _findResSize2)
return NULL;
/* endian OK, tags are in native format */
} while (READ_UINT32_UNALIGNED(_findResPos2) != tag);
return _findResPos2;
return NULL;
}
void Scumm::lock(int type, int i) {
validateResource("Locking", type, i);
res.flags[type][i] |= 0x80;
}
void Scumm::unlock(int type, int i) {

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.6 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.5 2001/10/18 20:04:58 strigeus
* flags were not saved properly
*
@ -72,6 +75,7 @@ bool Scumm::loadState(const char *filename) {
FILE *out = fopen(filename,"rb");
int i,j;
SaveGameHeader hdr;
int sb,sh;
if (out==NULL)
return false;
@ -105,11 +109,20 @@ bool Scumm::loadState(const char *filename) {
saveOrLoad(out,false);
fclose(out);
initScreens(0, _screenB, 320, _screenH);
sb = _screenB;
sh = _screenH;
initScreens(0, 0, 320, 200);
_screenEffectFlag = 1;
unkVirtScreen4(129);
initScreens(0, sb, 320, sh);
_completeScreenRedraw = 1;
setDirtyColors(0,255);
_lastCodePtr = NULL;
_drawObjectQueNr = 0;
_verbMouseOver = 0;
@ -255,7 +268,7 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKLINE(Scumm,_numObjectsInRoom,sleByte),
MKLINE(Scumm,_currentScript,sleByte),
MKARRAY(Scumm,_localScriptList[0],sleUint32,0x39),
MKARRAY(Scumm,vm.localvar[0],sleUint16,20*17),
MKARRAY(Scumm,vm.localvar[0],sleUint16,NUM_SCRIPT_SLOT*17),
MKARRAY(Scumm,_resourceMapper[0],sleByte,128),
MKARRAY(Scumm,charset._colorMap[0],sleByte,16),
MKARRAY(Scumm,_charsetData[0][0],sleByte,10*16),
@ -293,29 +306,28 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKLINE(Scumm,_numNestedScripts,sleByte),
MKLINE(Scumm,_userPut,sleByte),
MKLINE(Scumm,_cursorState,sleByte),
MKLINE(Scumm,gdi.unk4,sleByte),
MKLINE(Scumm,gdi.currentCursor,sleByte),
MKLINE(Scumm,gdi._unk4,sleByte),
MKLINE(Scumm,gdi._currentCursor,sleByte),
MKLINE(Scumm,doEffect,sleByte),
MKLINE(Scumm,_doEffect,sleByte),
MKLINE(Scumm,_switchRoomEffect,sleByte),
MKLINE(Scumm,_newEffect,sleByte),
MKLINE(Scumm,_switchRoomEffect2,sleByte),
MKLINE(Scumm,_BgNeedsRedraw,sleByte),
MKARRAY(Scumm,actorDrawBits[0],sleUint16,200),
MKLINE(Scumm,gdi.transparency,sleByte),
MKLINE(Scumm,gdi._transparency,sleByte),
MKARRAY(Scumm,_currentPalette[0],sleByte,768),
/* virtscr */
MKARRAY(Scumm,charset._buffer[0],sleByte,256),
MKLINE(Scumm,dseg_3A76,sleUint16),
MKLINE(Scumm,_egoPositioned,sleByte),
MKARRAY(Scumm,_imgBufOffs[0],sleUint16,4),
MKLINE(Scumm,_numZBuffer,sleUint16),
MKARRAY(Scumm,gdi._imgBufOffs[0],sleUint16,4),
MKLINE(Scumm,gdi._numZBuffer,sleByte),
MKLINE(Scumm,dseg_4EA0,sleUint16),
MKLINE(Scumm,dseg_4EA0,sleUint16),
MKLINE(Scumm,_screenEffectFlag,sleByte),
MKLINE(Scumm,_randSeed1,sleUint32),
MKLINE(Scumm,_randSeed2,sleUint32),
@ -327,12 +339,6 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKLINE(Scumm,_screenB,sleUint16),
MKLINE(Scumm,_screenH,sleUint16),
MKARRAY(Scumm,_colorCycleDelays[0],sleUint16,17),
MKARRAY(Scumm,_colorCycleCounter[0],sleUint16,17),
MKARRAY(Scumm,_colorCycleFlags[0],sleUint16,17),
MKARRAY(Scumm,_colorCycleStart[0],sleByte,17),
MKARRAY(Scumm,_colorCycleEnd[0],sleByte,17),
MKARRAY(Scumm,cost._transEffect[0],sleByte,256),
MKEND()
};
@ -393,6 +399,14 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKEND()
};
const SaveLoadEntry colorCycleEntries[] = {
MKLINE(ColorCycle,delay,sleUint16),
MKLINE(ColorCycle,counter,sleUint16),
MKLINE(ColorCycle,flags,sleUint16),
MKLINE(ColorCycle,start,sleByte),
MKLINE(ColorCycle,end,sleByte),
};
int i,j;
_saveLoadStream = inout;
@ -401,7 +415,7 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
saveLoadEntries(this,mainEntries);
for (i=1; i<13; i++)
saveLoadEntries(&actor[i],actorEntries);
for (i=0; i<20; i++)
for (i=0; i<NUM_SCRIPT_SLOT; i++)
saveLoadEntries(&vm.slot[i],scriptSlotEntries);
for (i=0; i<_numLocalObjects; i++)
saveLoadEntries(&_objs[i],objectEntries);
@ -413,6 +427,8 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
saveLoadEntries(&sentence[i],sentenceTabEntries);
for (i=0; i<6; i++)
saveLoadEntries(&string[i],stringTabEntries);
for (i=0; i<16; i++)
saveLoadEntries(&_colorCycle,colorCycleEntries);
for (i=1; i<16; i++)
if (res.mode[i]==0)

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.5 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.4 2001/10/23 19:51:50 strigeus
* recompile not needed when switching games
* debugger skeleton implemented
@ -101,7 +104,7 @@ void Scumm::stopScriptNr(int script) {
ss = &vm.slot[1];
for (i=1; i<20; i++,ss++) {
for (i=1; i<NUM_SCRIPT_SLOT; i++,ss++) {
if (script!=ss->number || ss->type!=2 && ss->type!=3 || ss->status==0)
continue;
@ -138,7 +141,7 @@ void Scumm::stopObjectScript(int script) {
ss = &vm.slot[1];
for (i=1; i<20; i++,ss++) {
for (i=1; i<NUM_SCRIPT_SLOT; i++,ss++) {
if (script==ss->number && (ss->type==1 || ss->type==0 || ss->type==4) && ss->status!=0) {
if (ss->cutsceneOverride)
error("Object %d stopped with active cutscene/override", script);
@ -169,11 +172,11 @@ int Scumm::getScriptSlot() {
int i;
ss = &vm.slot[1];
for (i=1; i<20; i++,ss++) {
for (i=1; i<NUM_SCRIPT_SLOT; i++,ss++) {
if(ss->status==0)
return i;
}
error("Too many scripts running, %d max", 20);
error("Too many scripts running, %d max", NUM_SCRIPT_SLOT);
}
void Scumm::runScriptNested(int script) {
@ -414,12 +417,14 @@ void Scumm::setResult(int value) {
void Scumm::drawBox(int x, int y, int x2, int y2, int color) {
int top,bottom,count;
VirtScreen *vs;
byte *backbuff;
if (findVirtScreen(y)==-1)
if ((vs=findVirtScreen(y)) == NULL)
return;
top = virtscr[gdi.virtScreen].topline;
bottom = top + virtscr[gdi.virtScreen].height;
top = vs->topline;
bottom = top + vs->height;
if (x > x2)
SWAP(x,x2);
@ -436,16 +441,14 @@ void Scumm::drawBox(int x, int y, int x2, int y2, int color) {
if (x2>320) x2=320;
if (y2 > bottom) y2=bottom;
updateDirtyRect(gdi.virtScreen, x, x2, y-top, y2-top, 0);
updateDirtyRect(vs->number, x, x2, y-top, y2-top, 0);
gdi.bg_ptr = getResourceAddress(0xA, gdi.virtScreen+1)
+ virtscr[gdi.virtScreen].xstart
+ (y-top)*320 + x;
backbuff = getResourceAddress(0xA, vs->number+1) + vs->xstart + (y-top)*320 + x;
count = y2 - y;
while (count) {
memset(gdi.bg_ptr, color, x2 - x);
gdi.bg_ptr += 320;
memset(backbuff, color, x2 - x);
backbuff += 320;
count--;
}
}
@ -477,7 +480,7 @@ bool Scumm::isScriptLoaded(int script) {
int i;
ss = vm.slot;
for (i=0; i<20; i++,ss++) {
for (i=0; i<NUM_SCRIPT_SLOT; i++,ss++) {
if (ss->number == script)
return true;
}
@ -495,7 +498,7 @@ void Scumm::runHook(int i) {
void Scumm::freezeScripts(int flag) {
int i;
for(i=1; i<20; i++) {
for(i=1; i<NUM_SCRIPT_SLOT; i++) {
if (_currentScript!=i && vm.slot[i].status!=0 && (vm.slot[i].unk1==0 || flag>=0x80)) {
vm.slot[i].status |= 0x80;
vm.slot[i].freezeCount++;
@ -513,7 +516,7 @@ void Scumm::freezeScripts(int flag) {
void Scumm::unfreezeScripts() {
int i;
for (i=1; i<20; i++) {
for (i=1; i<NUM_SCRIPT_SLOT; i++) {
if (vm.slot[i].status&0x80) {
if (!--vm.slot[i].freezeCount) {
vm.slot[i].status&=0x7F;
@ -530,11 +533,11 @@ void Scumm::unfreezeScripts() {
void Scumm::runAllScripts() {
int i;
for (i=0; i<20; i++)
for (i=0; i<NUM_SCRIPT_SLOT; i++)
vm.slot[i].didexec = 0;
_currentScript = 0xFF;
for(_curExecScript = 0; _curExecScript<20; _curExecScript++) {
for(_curExecScript = 0; _curExecScript<NUM_SCRIPT_SLOT; _curExecScript++) {
if (vm.slot[_curExecScript].status == 2 &&
vm.slot[_curExecScript].didexec == 0) {
_currentScript = _curExecScript;
@ -587,7 +590,7 @@ void Scumm::killScriptsAndResources() {
ss = &vm.slot[1];
for (i=1; i<20; i++,ss++) {
for (i=1; i<NUM_SCRIPT_SLOT; i++,ss++) {
if (ss->type==1 || ss->type==4) {
if(ss->cutsceneOverride)
error("Object %d stopped with active cutscene/override in exit", ss->number);
@ -613,7 +616,7 @@ void Scumm::checkAndRunVar33() {
memset(_localParamList, 0, sizeof(_localParamList));
if (isScriptLoaded(_vars[VAR_SENTENCE_SCRIPT])) {
ss = vm.slot;
for (i=0; i<20; i++,ss++)
for (i=0; i<NUM_SCRIPT_SLOT; i++,ss++)
if (ss->number==_vars[VAR_SENTENCE_SCRIPT] && ss->status!=0 && ss->freezeCount==0)
return;
}
@ -648,7 +651,7 @@ void Scumm::runInputScript(int a, int cmd, int mode) {
void Scumm::decreaseScriptDelay(int amount) {
ScriptSlot *ss = &vm.slot[0];
int i;
for (i=0; i<20; i++,ss++) {
for (i=0; i<NUM_SCRIPT_SLOT; i++,ss++) {
if(ss->status==1) {
ss->delay -= amount;
if (ss->delay < 0){
@ -712,7 +715,7 @@ int Scumm::getVerbEntrypoint(int obj, int entry) {
objptr = getObjectAddress(obj);
verbptr = findResource(MKID('VERB'), objptr);
verbptr = findResource(MKID('VERB'), objptr, 0);
if (verbptr==NULL)
error("No verb block in object %d", obj);
@ -842,7 +845,7 @@ void Scumm::animateActor(int act, int anim) {
int Scumm::getScriptRunning(int script) {
int i;
ScriptSlot *ss = vm.slot;
for (i=0; i<20; i++,ss++)
for (i=0; i<NUM_SCRIPT_SLOT; i++,ss++)
if (ss->number==script && (ss->type==2 || ss->type==3) && ss->status)
return 1;
return 0;
@ -939,6 +942,16 @@ int Scumm::getArrayId() {
error("Out of array pointers, %d max", _numArray);
}
void Scumm::arrayop_1(int a, byte *ptr) {
ArrayHeader *ah;
int r;
int len = getStringLen(ptr);
r = defineArray(a, 4, 0, len);
ah = (ArrayHeader*)getResourceAddress(7,r);
copyString(ah->data,ptr,len);
}
void Scumm::copyString(byte *dst, byte *src, int len) {
if (!src) {
while (--len>=0)

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.4 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.3 2001/10/23 19:51:50 strigeus
* recompile not needed when switching games
* debugger skeleton implemented
@ -890,7 +893,7 @@ void Scumm::o5_getClosestObjActor() {
getResultPos();
act = getVarOrDirectWord(0x80);
obj = _vars[VAR_OBJECT_HI];
obj = _vars[VAR_V5_OBJECT_HI];
do {
dist = getObjActToObjActDist(obj,act);
@ -898,7 +901,7 @@ void Scumm::o5_getClosestObjActor() {
closnum = dist;
closobj = obj;
}
} while (--obj >= _vars[VAR_OBJECT_LO]);
} while (--obj >= _vars[VAR_V5_OBJECT_LO]);
setResult(closnum);
}
@ -1054,11 +1057,11 @@ void Scumm::o5_lights() {
a = getVarOrDirectByte(0x80);
b = fetchScriptByte();
c = fetchScriptByte();
if (c==0)
_vars[VAR_DRAWFLAGS] = a;
_vars[VAR_V5_DRAWFLAGS] = a;
else if (c==1) {
_lightsValueA = a;
_lightsValueB = b;
warning("o5_lights: lights not implemented");
}
_fullRedraw=1;
}
@ -1077,7 +1080,7 @@ void Scumm::o5_loadRoomWithEgo() {
obj = getVarOrDirectWord(0x80);
room = getVarOrDirectByte(0x40);
a = derefActorSafe(_vars[VAR_UNK_ACTOR], "o5_loadRoomWithEgo");
a = derefActorSafe(_vars[VAR_EGO], "o5_loadRoomWithEgo");
/* Warning: uses _xPos, _yPos from a previous update of those */
putActor(a, _xPos, _yPos, room);
@ -1085,7 +1088,7 @@ void Scumm::o5_loadRoomWithEgo() {
x = (int16)fetchScriptWord();
y = (int16)fetchScriptWord();
dseg_3A76 = 0;
_egoPositioned = false;
_vars[VAR_WALKTO_OBJ] = obj;
@ -1166,7 +1169,7 @@ void Scumm::o5_pickupObject() {
if (room==0)
room = _roomResource;
addObjectToInventory(obj, room);
putOwner(obj, _vars[VAR_UNK_ACTOR]);
putOwner(obj, _vars[VAR_EGO]);
putClass(obj, 32, 1);
putState(obj, 1);
removeObjectFromRoom(obj);
@ -1180,7 +1183,7 @@ void Scumm::o5_print() {
}
void Scumm::o5_printEgo() {
_actorToPrintStrFor = _vars[VAR_UNK_ACTOR];
_actorToPrintStrFor = _vars[VAR_EGO];
decodeParseString();
}
@ -1367,12 +1370,12 @@ void Scumm::o5_roomOps() {
a = getVarOrDirectByte(0x80);
b = getVarOrDirectByte(0x40);
c = getVarOrDirectByte(0x20);
unkRoomFunc2(b, c, a, a, a);
darkenPalette(b, c, a, a, a);
break;
case 9: /* ? */
_saveLoadFlag = getVarOrDirectByte(0x80);
_saveLoadData = getVarOrDirectByte(0x40);
_saveLoadData = 0; /* TODO: weird behaviour */
_saveLoadSlot = getVarOrDirectByte(0x40);
_saveLoadSlot = 99; /* use this slot */
break;
case 10: /* ? */
a = getVarOrDirectWord(0x80);
@ -1390,7 +1393,7 @@ void Scumm::o5_roomOps() {
_opcode = fetchScriptByte();
d = getVarOrDirectByte(0x80);
e = getVarOrDirectByte(0x40);
unkRoomFunc2(d, e, a, b, c);
darkenPalette(d, e, a, b, c);
break;
case 12: /* ? */
a = getVarOrDirectWord(0x80);
@ -1430,10 +1433,8 @@ void Scumm::o5_roomOps() {
case 16: /* ? */
a = getVarOrDirectByte(0x80);
b = getVarOrDirectByte(0x40);
if (b!=0)
_colorCycleDelays[a] = 0x4000 / (b*0x4C);
else
_colorCycleDelays[a] = 0;
checkRange(16, 1, a, "o5_roomOps: 16: color cycle out of range (%d)");
_colorCycle[a-1].delay = (b!=0) ? 0x4000 / (b*0x4C) : 0;
break;
}
}

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.4 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.3 2001/10/24 20:12:52 strigeus
* fixed some bugs related to string handling
*
@ -978,7 +981,7 @@ void Scumm::o6_pickupObject() {
if (room==0)
room = _roomResource;
addObjectToInventory(obj, room);
putOwner(obj, _vars[VAR_UNK_ACTOR]);
putOwner(obj, _vars[VAR_EGO]);
putClass(obj, 32, 1);
putState(obj, 1);
removeObjectFromRoom(obj);
@ -995,15 +998,16 @@ void Scumm::o6_loadRoomWithEgo() {
room = pop();
obj = pop();
a = derefActorSafe(_vars[VAR_UNK_ACTOR], "o_loadRoomWithEgo");
a = derefActorSafe(_vars[VAR_EGO], "o_loadRoomWithEgo");
putActor(a, 0, 0, room);
dseg_3A76 = 0;
_egoPositioned = false;
_vars[VAR_WALKTO_OBJ] = obj;
startScene(a->room, a, obj);
_vars[VAR_WALKTO_OBJ] = 0;
/* startScene maybe modifies VAR_UNK_ACTOR, i hope not */
/* startScene maybe modifies VAR_EGO, i hope not */
camera._destPos = camera._curPos = a->x;
setCameraFollows(a);
_fullRedraw=1;
@ -1278,11 +1282,12 @@ void Scumm::o6_roomOps() {
c = pop();
b = pop();
a = pop();
unkRoomFunc2(b,c,a,a,a);
darkenPalette(b,c,a,a,a);
break;
case 180:
_saveLoadData = pop();
_saveLoadCompatible = true;
_saveLoadSlot = pop();
_saveLoadFlag = pop();
warning("o6_roomops:180: partially unimplemented");
break;
@ -1303,7 +1308,7 @@ void Scumm::o6_roomOps() {
c = pop();
b = pop();
a = pop();
unkRoomFunc2(d, e, a, b, c);
darkenPalette(d, e, a, b, c);
break;
case 183:
@ -1334,10 +1339,8 @@ void Scumm::o6_roomOps() {
case 187: /* color cycle delay */
b = pop();
a = pop();
if (b!=0)
_colorCycleDelays[a] = 0x4000 / (b*0x4C);
else
_colorCycleDelays[a] = 0;
checkRange(16, 1, a, "o6_roomOps: 187: color cycle out of range (%d)");
_colorCycle[a-1].delay = (b!=0) ? 0x4000 / (b*0x4C) : 0;
break;
case 213: /* set palette */
@ -1863,7 +1866,7 @@ void Scumm::o6_printActor() {
}
void Scumm::o6_printEgo() {
push(_vars[VAR_UNK_ACTOR]);
push(_vars[VAR_EGO]);
decodeParseString2(0,1);
}
@ -1876,7 +1879,7 @@ void Scumm::o6_talkActor() {
}
void Scumm::o6_talkEgo() {
_actorToPrintStrFor = _vars[VAR_UNK_ACTOR];
_actorToPrintStrFor = _vars[VAR_EGO];
_messagePtr = _scriptPointer;
setStringVars(0);
actorTalk();

374
scumm.h
View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.14 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.13 2001/10/24 20:12:52 strigeus
* fixed some bugs related to string handling
*
@ -73,6 +76,8 @@ struct Actor;
typedef void (Scumm::*OpcodeProc)();
#define NUM_SCRIPT_SLOT 25
#pragma START_PACK_STRUCTS
struct Point {
@ -109,6 +114,7 @@ struct VerbSlot {
};
struct VirtScreen {
int number;
uint16 unk1;
uint16 topline;
uint16 width,height;
@ -258,80 +264,78 @@ enum {
};
enum ScummVars {
VAR_UNK_ACTOR = 1,
VAR_WALKTO_OBJ = 38,
VAR_EGO = 1,
VAR_CAMERA_CUR_POS = 2,
VAR_HAVE_MSG = 3,
VAR_ROOM = 4,
VAR_OVERRIDE = 5,
VAR_NUM_ACTOR = 8,
VAR_OBJECT_LO = 15,
VAR_OBJECT_HI = 16,
VAR_CURRENTDRIVE = 10,
VAR_TALK_ACTOR = 25,
VAR_DEBUGMODE = 39,
VAR_VERSION = 75,
VAR_FIXEDDISK = 51,
VAR_CURSORSTATE = 52,
VAR_USERPUT = 53,
VAR_SOUNDCARD = 48,
VAR_VIDEOMODE = 49,
VAR_HEAPSPACE = 40,
VAR_MOUSEPRESENT = 67,
VAR_SOUNDPARAM = 64,
VAR_SOUNDPARAM2 = 65,
VAR_SOUNDPARAM3 = 66,
VAR_GAME_LOADED = 71,
VAR_TMR_1 = 11,
VAR_TMR_2 = 12,
VAR_TMR_3 = 13,
VAR_CAMERA_MIN = 17,
VAR_CAMERA_MAX = 18,
VAR_TIMER_NEXT = 19,
VAR_VIRT_MOUSE_X = 20,
VAR_VIRT_MOUSE_Y = 21,
VAR_PERFORMANCE_1 = 68,
VAR_PERFORMANCE_2 = 69,
VAR_ROOM_FLAG = 70,
VAR_HAVE_MSG = 3,
VAR_ROOM_RESOURCE = 22,
VAR_LAST_SOUND = 23,
VAR_CUTSCENEEXIT_KEY = 24,
VAR_TALK_ACTOR = 25,
VAR_CAMERA_FAST = 26,
VAR_SCROLL_SCRIPT = 27,
VAR_ENTRY_SCRIPT = 28,
VAR_ENTRY_SCRIPT2 = 29,
VAR_EXIT_SCRIPT = 30,
VAR_EXIT_SCRIPT2 = 31,
VAR_VERB_SCRIPT = 32,
VAR_SENTENCE_SCRIPT = 33,
VAR_LAST_SOUND = 23,
VAR_HOOK_SCRIPT = 34,
VAR_CUTSCENE_START_SCRIPT = 35,
VAR_CUTSCENE_END_SCRIPT = 36,
VAR_SCROLL_SCRIPT = 27,
VAR_CAMERA_MIN = 17,
VAR_CAMERA_MAX = 18,
VAR_CAMERA_FAST = 26,
VAR_CAMERA_CUR_POS = 2,
VAR_NEW_ROOM = 72,
VAR_ROOM = 4,
VAR_ROOM_RESOURCE = 22,
VAR_MOUSE_X = 44,
VAR_MOUSE_Y = 45,
VAR_TIMER = 46,
VAR_TIMER_NEXT = 19,
VAR_TMR_1 = 11,
VAR_TMR_2 = 12,
VAR_TMR_3 = 13,
VAR_TMR_4 = 47,
VAR_DRAWFLAGS = 9,
VAR_SOUNDRESULT = 56,
VAR_PLAYBACKTIMER = 19,
VAR_TALK_STRING_Y = 54,
VAR_CHARFLAG = 60,
VAR_CHARINC = 37,
VAR_WALKTO_OBJ = 38,
VAR_DEBUGMODE = 39,
VAR_HEAPSPACE = 40,
VAR_RESTART_KEY = 42,
VAR_PAUSE_KEY = 43,
VAR_CUTSCENEEXIT_KEY = 24,
VAR_TALKSTOP_KEY = 57,
VAR_MOUSE_X = 44,
VAR_MOUSE_Y = 45,
VAR_TIMER = 46,
VAR_TMR_4 = 47,
VAR_SOUNDCARD = 48,
VAR_VIDEOMODE = 49,
VAR_SAVELOADDIALOG_KEY = 50,
VAR_FIXEDDISK = 51,
VAR_CURSORSTATE = 52,
VAR_USERPUT = 53,
VAR_SOUNDRESULT = 56,
VAR_TALKSTOP_KEY = 57,
VAR_59 = 59,
VAR_SOUNDPARAM = 64,
VAR_SOUNDPARAM2 = 65,
VAR_SOUNDPARAM3 = 66,
VAR_MOUSEPRESENT = 67,
VAR_PERFORMANCE_1 = 68,
VAR_PERFORMANCE_2 = 69,
VAR_ROOM_FLAG = 70,
VAR_GAME_LOADED = 71,
VAR_NEW_ROOM = 72,
VAR_VERSION = 75,
VAR_V5_DRAWFLAGS = 9,
VAR_V5_OBJECT_LO = 15,
VAR_V5_OBJECT_HI = 16,
VAR_V5_TALK_STRING_Y = 54,
VAR_V5_CHARFLAG = 60,
VAR_V6_SCREEN_WIDTH = 41,
VAR_V6_SCREEN_HEIGHT = 54,
VAR_V6_EMSSPACE = 76,
VAR_V6_RANDOM_NR = 118,
};
#define _maxRooms res.num[1]
@ -366,6 +370,7 @@ struct CharsetRenderer {
int _right;
byte _color;
bool _hasMask;
bool _blitAlso;
int _strLeft, _strRight, _strTop, _strBottom;
// int _mask_bottom, _mask_right, _mask_top, _mask_left;
@ -386,8 +391,9 @@ struct CharsetRenderer {
byte _ignoreCharsetMask;
byte *_bg_ptr, *_where_to_draw_ptr;
byte *_backbuff_ptr, *_bgbak_ptr;
byte *_mask_ptr;
byte *_bg_ptr2;
byte _colorMap[16];
byte _buffer[256];
@ -405,7 +411,7 @@ struct CostumeRenderer {
byte *_dataptr;
byte *_frameptr;
byte *_srcptr;
byte *_where_to_draw_ptr, *_bg_ptr, *_mask_ptr, *_mask_ptr_dest;
byte *_bgbak_ptr, *_backbuff_ptr, *_mask_ptr, *_mask_ptr_dest;
int _actorX, _actorY;
byte _zbuf;
uint _scaleX, _scaleY;
@ -519,6 +525,82 @@ struct StringTab {
int16 mask_top, mask_bottom, mask_right, mask_left;
};
struct ColorCycle {
uint16 delay;
uint16 counter;
uint16 flags;
byte start;
byte end;
};
struct Gdi {
Scumm *_vm;
byte *_readPtr;
uint _readOffs;
int8 _unk4;
int _numZBuffer;
int _imgBufOffs[4];
byte _disable_zbuffer;
byte dseg_4E3B;
byte _numLinesToProcess;
byte _tempNumLines;
byte _currentX;
byte _hotspot_x;
byte _hotspot_y;
int16 _drawMouseX;
int16 _drawMouseY;
byte _currentCursor;
byte _mouseColors[4];
byte _mouseColor;
byte _mouseClipMask1, _mouseClipMask2, _mouseClipMask3;
byte _mouseColorIndex;
byte *_mouseMaskPtr;
byte *_smap_ptr;
byte *_backbuff_ptr;
byte *_bgbak_ptr;
byte *_mask_ptr;
byte *_mask_ptr_dest;
byte *_z_plane_ptr;
byte _decomp_shr, _decomp_mask;
byte _transparency;
uint16 _vertStripNextInc;
byte *_backupIsWhere;
byte _mouseMask[0x200];
void unkDecode1();
void unkDecode2();
void unkDecode3();
void unkDecode4();
void unkDecode5();
void unkDecode6();
void unkDecode7();
void decompressBitmap();
void drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, int h, int stripnr, int numstrip, bool flag);
void clearUpperMask();
void disableZBuffer() { _disable_zbuffer++; }
void enableZBuffer() { _disable_zbuffer--; }
void draw8ColWithMasking();
void clear8ColWithMasking();
void clear8Col();
void decompressMaskImgOr();
void decompressMaskImg();
void resetBackground(byte top, byte bottom, int strip);
void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b);
void updateDirtyScreen(VirtScreen *vs);
};
enum GameId {
GID_TENTACLE = 1,
GID_MONKEY2 = 2,
@ -545,8 +627,10 @@ struct Scumm {
void *_fileHandle;
char *_exe_name;
int _saveLoadSlot;
byte _saveLoadFlag;
byte _saveLoadSlot;
bool _saveLoadCompatible;
bool _dynamicRoomOffsets;
byte _resFilePathId;
@ -571,6 +655,8 @@ struct Scumm {
int _curPalIndex;
VirtScreen *_curVirtScreen;
int _numVariables;
int _numBitVariables;
int _numLocalObjects;
@ -584,47 +670,39 @@ struct Scumm {
int _numSounds;
int _numCharsets;
int _numCostumes;
byte *_msgPtrToAdd;
uint8 *_roomFileIndexes;
byte *_objectFlagTable;
uint32 *_classData;
byte _numGlobalScripts;
uint16 _numZBuffer;
byte *_scriptPointer, *_scriptOrgPointer;
byte *_scriptPointerStart;
byte _opcode;
uint32 _randSeed1;
uint32 _randSeed2;
uint16 _screenB, _screenH;
uint16 dseg_3A76;
uint16 _defaultTalkDelay;
uint16 _lightsValueA,_lightsValueB;
byte _haveMsg;
byte _newEffect;
uint16 _fullRedraw;
uint16 dseg_3DB6;
uint16 dseg_2456; /* lastDrawnRoom */
uint16 dseg_4E8A;
uint16 _soundParam,_soundParam2,_soundParam3;
uint16 dseg_4F8C;
byte _switchRoomEffect2, _switchRoomEffect;
uint16 dseg_4AC2;
bool doEffect;
uint16 _drawBmpX;
uint16 dseg_719E;
uint16 _drawBmpY;
uint16 dseg_4174;
byte dseg_4E3C;
uint16 _lastXstart;
uint16 dseg_4EA0;
bool _egoPositioned;
bool _doEffect;
bool _screenEffectFlag;
bool _keepText;
byte _bkColor;
uint16 _lastXstart;
int16 _talkDelay;
int16 _shakeMode;
@ -639,7 +717,6 @@ struct Scumm {
byte *_messagePtr;
byte _numNestedScripts;
byte _unkTabIndex;
byte _currentScript;
byte _currentRoom;
@ -656,7 +733,7 @@ struct Scumm {
uint16 _completeScreenRedraw;
byte _saveLoadFlag;
int8 _userPut;
int8 _cursorState;
@ -666,7 +743,6 @@ struct Scumm {
int _numInMsgStack;
// VerbSlot verbs[102];
VirtScreen virtscr[4];
uint32 _ENCD_offs, _EXCD_offs;
@ -703,56 +779,15 @@ struct Scumm {
int16 cutSceneData[5];
int16 cutSceneScriptIndex;
byte cutSceneStackPointer;
ScriptSlot slot[20];
ScriptSlot slot[NUM_SCRIPT_SLOT];
NestedScript nest[15];
int16 localvar[20*17];
int16 localvar[NUM_SCRIPT_SLOT*17];
} vm;
struct {
int16 x,y;
} mouse;
struct {
byte *readPtr;
uint16 readOffs;
uint16 drawY;
uint16 drawHeight;
uint16 drawWidth;
uint16 draw8xPos;
int16 virtScreen;
uint16 drawBottom;
uint16 drawTop;
int8 unk4;
byte numLinesToProcess;
byte tempNumLines;
byte currentX;
byte hotspot_x;
byte hotspot_y;
int16 drawMouseX;
int16 drawMouseY;
byte currentCursor;
byte mouseColors[4];
byte mouseColor;
byte mouseClipMask1, mouseClipMask2, mouseClipMask3;
byte mouseColorIndex;
byte mouseMask[0x200];
byte *mouseMaskPtr;
byte *smap_ptr;
byte *bg_ptr;
byte *where_to_draw_ptr;
byte *mask_ptr;
byte *mask_ptr_dest;
byte *z_plane_ptr;
byte decomp_shr, decomp_mask;
byte transparency;
uint16 vertStripNextInc;
byte *backupIsWhere;
// byte mouseBackup[16*24];
} gdi;
Actor actor[13];
uint16 actorDrawBits[200];
@ -788,10 +823,6 @@ struct Scumm {
uint32 _whereInResToRead;
byte *_scriptPointer, *_scriptOrgPointer;
byte *_scriptPointerStart;
byte _opcode;
int _xPos, _yPos;
byte _dir;
@ -799,41 +830,13 @@ struct Scumm {
int _resultVarNumber;
uint16 _imgBufOffs[4];
byte _sentenceIndex;
SentenceTab sentence[6];
#if 0
byte _sentenceTab[6];
byte _sentenceTab2[6];
uint16 _sentenceTab3[6];
uint16 _sentenceTab4[6];
byte _sentenceTab5[6];
#endif
StringTab string[6];
#if 0
// int _stringXPos[4], _stringYPos[4];
uint16 _stringOverhead[6];
uint16 _stringCenter[6];
uint16 _stringRight[6];
uint16 _stringColor[6];
int16 _stringXpos[6];
int16 _stringYpos[6];
uint16 _stringCharset[6];
int16 _stringXpos2[6];
int16 _stringYpos2[6];
#endif
CostumeRenderer cost;
// ObjectData objs[184];
int16 _soundQuePos;
int16 _soundQue[0x100];
@ -851,22 +854,11 @@ struct Scumm {
int _palDirtyMin, _palDirtyMax;
byte _saveLoadData;
uint16 _colorCycleDelays[17];
uint16 _colorCycleCounter[17];
uint16 _colorCycleFlags[17];
byte _colorCycleStart[17];
byte _colorCycleEnd[17];
byte dseg_4E3B;
uint32 _findResSize, _findResHeaderSize;
byte *_findResPos;
uint32 _findResSize2, _findResHeaderSize2;
byte *_findResPos2;
ColorCycle _colorCycle[16];
Gdi gdi;
bool _BgNeedsRedraw;
int16 _localParamList[16];
@ -886,8 +878,6 @@ struct Scumm {
int _boxPathVertexHeapIndex;
int _boxMatrixItem;
byte *_msgPtrToAdd;
OpcodeProc getOpcode(int i) { return _opcodes[i]; }
void openRoom(int room);
@ -958,8 +948,8 @@ struct Scumm {
void updateDirtyScreen(int slot);
void unkVirtScreen4(int a);
void drawStripToScreen();
void restoreMouse();
void initActor(Actor *a, int mode);
bool checkFixedDisk();
@ -1327,8 +1317,10 @@ struct Scumm {
void initBGBuffers();
void setDirtyColors(int min, int max);
#if 0
byte *findResource(uint32 tag, byte *searchin);
byte *findResource2(uint32 tag, byte *searchin);
#endif
void setScaleItem(int slot, int a, int b, int c, int d);
@ -1341,26 +1333,13 @@ struct Scumm {
void redrawBGStrip(int start, int num);
void drawObject(int obj, int arg);
void drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr);
void decompressBitmap();
// void drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr);
int hasCharsetMask(int x, int y, int x2, int y2);
void draw8ColWithMasking();
void clear8ColWithMasking();
void clear8Col();
void decompressMaskImgOr();
void decompressMaskImg();
void GDI_UnkDecode1();
void GDI_UnkDecode2();
void GDI_UnkDecode3();
void GDI_UnkDecode4();
void GDI_UnkDecode5();
void GDI_UnkDecode6();
void GDI_UnkDecode7();
void restoreBG(int left, int top, int right, int bottom);
void updateDirtyRect(int virt, int left, int right, int top, int bottom, uint16 dirtybits);
int findVirtScreen(int y);
VirtScreen *findVirtScreen(int y);
void unkScreenEffect1();
void unkScreenEffect2();
@ -1375,7 +1354,7 @@ struct Scumm {
void decreaseScriptDelay(int amount);
void processKbd();
void clearUpperMask();
void redrawVerbs();
void checkExecVerbs();
void checkAndRunVar33();
@ -1447,7 +1426,7 @@ struct Scumm {
void unkHeapProc2(int a, int b);
void unkResProc(int a, int b);
void setPalColor(int index, int r, int g, int b);
void unkRoomFunc2(int a, int b, int c, int d, int e);
void darkenPalette(int a, int b, int c, int d, int e);
void unkRoomFunc3(int a, int b, int c, int d, int e);
void unkRoomFunc4(int a, int b, int c, int d, int e);
int getVerbSlot(int id, int mode);
@ -1484,9 +1463,6 @@ struct Scumm {
void drawMouse();
void GDI_drawMouse();
void GDI_removeMouse();
void dumpResource(char *tag, int index, byte *ptr);
FILE *_saveLoadStream;
@ -1509,7 +1485,6 @@ struct Scumm {
uint16 loadWord();
uint32 loadUint32();
Actor *derefActor(int id) { return &actor[id]; }
Actor *derefActorSafe(int id, const char *errmsg);
Actor *getFirstActor() { return actor; }
@ -1588,6 +1563,10 @@ struct Scumm {
void startManiac();
void readIndexFileV5(int i);
void grabCursor(byte *ptr, int width, int height);
byte *getPalettePtr();
};
struct ScummDebugger {
@ -1607,6 +1586,9 @@ struct ScummDebugger {
int get_command();
void attach(Scumm *s);
void detach();
void printActors(int act);
void printScripts();
};
@ -1624,3 +1606,5 @@ void initGraphics(Scumm *s);
void updateScreen(Scumm *s);
void drawMouse(Scumm *s, int x, int y, int color, byte *mask, bool visible);
void blit(byte *dst, byte *src, int w, int h);
byte *findResource(uint32 id, byte *searchin, int index);

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.13 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.12 2001/10/24 20:12:52 strigeus
* fixed some bugs related to string handling
*
@ -160,11 +163,9 @@ void Scumm::scummInit() {
virtscr[0].xstart = 0;
_vars[9] = 11;
_vars[VAR_V5_DRAWFLAGS] = 11;
_lightsValueA = _lightsValueB = 7;
_vars[59] = 3;
_vars[VAR_59] = 3;
mouse.x = 104;
mouse.y = 56;
@ -172,8 +173,8 @@ void Scumm::scummInit() {
_ENCD_offs = 0;
_EXCD_offs = 0;
_unkTabIndex = 0xFF;
_currentScript = 0xFF;
_sentenceIndex = 0xFF;
_currentRoom = 0;
_numObjectsInRoom = 0;
@ -184,7 +185,7 @@ void Scumm::scummInit() {
_screenStartStrip = 0;
_vars[25] = 0;
_vars[VAR_TALK_ACTOR] = 0;
_talkDelay = 0;
_keepText = false;
@ -212,7 +213,8 @@ void Scumm::scummInit() {
initScummVars();
_vars[54] = -0x50;
if (_majorScummVersion==5)
_vars[VAR_V5_TALK_STRING_Y] = -0x50;
getGraphicsPerformance();
}
@ -228,6 +230,8 @@ void Scumm::initScummVars() {
_vars[VAR_SOUNDPARAM] = _soundParam;
_vars[VAR_SOUNDPARAM2] = _soundParam2;
_vars[VAR_SOUNDPARAM3] = _soundParam3;
if (_majorScummVersion==6)
_vars[VAR_V6_EMSSPACE] = 10000;
}
void Scumm::checkRange(int max, int min, int no, const char *str) {
@ -242,6 +246,7 @@ void Scumm::scummMain(int argc, char **argv) {
charset._vm = this;
cost._vm = this;
gdi._vm = this;
_fileHandle = NULL;
@ -278,8 +283,8 @@ void Scumm::scummMain(int argc, char **argv) {
do {
if (_playBackFile) {
while ((_scummTimer>>2) < _vars[VAR_PLAYBACKTIMER]) {}
_scummTimer = _vars[VAR_PLAYBACKTIMER] << 2;
while ((_scummTimer>>2) < _vars[VAR_TIMER_NEXT]) {}
_scummTimer = _vars[VAR_TIMER_NEXT] << 2;
}
CHECK_HEAP
@ -323,18 +328,24 @@ void Scumm::scummMain(int argc, char **argv) {
if (_saveLoadFlag) {
char buf[256];
sprintf(buf, "savegame.%d", _saveLoadSlot);
if (_saveLoadFlag==1) {
saveState(buf);
if (_saveLoadCompatible)
_vars[VAR_GAME_LOADED] = 201;
} else {
loadState(buf);
if (_saveLoadCompatible) {
_vars[VAR_GAME_LOADED] = 203;
}
}
_saveLoadFlag = 0;
}
if (_completeScreenRedraw) {
_completeScreenRedraw = 0;
clearUpperMask();
gdi.clearUpperMask();
charset._hasMask = false;
redrawVerbs();
_fullRedraw = 1;
@ -347,7 +358,7 @@ void Scumm::scummMain(int argc, char **argv) {
checkAndRunVar33();
if (_currentRoom==0) {
gdi.unk4 = 0;
gdi._unk4 = 0;
CHARSET_1();
unkVirtScreen2();
unkSoundProc22();
@ -366,7 +377,7 @@ void Scumm::scummMain(int argc, char **argv) {
setActorRedrawFlags();
resetActorBgs();
if (!(_vars[VAR_DRAWFLAGS]&2) && _vars[VAR_DRAWFLAGS]&4) {
if (!(_vars[VAR_V5_DRAWFLAGS]&2) && _vars[VAR_V5_DRAWFLAGS]&4) {
error("Flashlight not implemented in this version");
}
@ -375,8 +386,8 @@ void Scumm::scummMain(int argc, char **argv) {
cyclePalette();
palManipulate();
if (doEffect) {
doEffect = false;
if (_doEffect) {
_doEffect = false;
screenEffect(_newEffect);
clearClickedStatus();
}
@ -385,7 +396,7 @@ void Scumm::scummMain(int argc, char **argv) {
verbMouseOver(checkMouseOver(mouse.x, mouse.y));
}
gdi.unk4 = _cursorState > 0;
gdi._unk4 = _cursorState > 0;
unkVirtScreen2();
@ -548,7 +559,12 @@ void Scumm::startScene(int room, Actor *a, int objectNr) {
camera._mode = 1;
camera._curPos = camera._destPos = 160;
if (_majorScummVersion==6) {
_vars[VAR_V6_SCREEN_WIDTH] = _scrWidthIn8Unit<<3;
_vars[VAR_V6_SCREEN_HEIGHT] = _scrHeight;
}
if (_roomResource == 0)
return;
@ -568,17 +584,16 @@ void Scumm::startScene(int room, Actor *a, int objectNr) {
}
showActors();
dseg_3A76 = 0;
_egoPositioned = false;
runEntryScript();
if (a && dseg_3A76==0) {
if (a && !_egoPositioned) {
getObjectXYPos(objectNr);
putActor(a, _xPos, _yPos, _currentRoom);
a->moving = 0;
}
doEffect = true;
_doEffect = true;
CHECK_HEAP
}
@ -601,14 +616,14 @@ void Scumm::initRoomSubBlocks() {
roomptr = getResourceAddress(1, _roomResource);
ptr = findResource(MKID('RMHD'), roomptr);
ptr = findResource(MKID('RMHD'), roomptr, 0);
_scrWidthIn8Unit = READ_LE_UINT16(&((RoomHeader*)ptr)->width) >> 3;
_scrHeight = READ_LE_UINT16(&((RoomHeader*)ptr)->height);
_IM00_offs = findResource(MKID('IM00'), findResource(MKID('RMIM'), roomptr)) -
_IM00_offs = findResource(MKID('IM00'), findResource(MKID('RMIM'), roomptr, 0), 0) -
roomptr;
ptr = findResource(MKID('EXCD'), roomptr);
ptr = findResource(MKID('EXCD'), roomptr, 0);
if (ptr) {
_EXCD_offs = ptr - roomptr;
#ifdef DUMP_SCRIPTS
@ -616,7 +631,7 @@ void Scumm::initRoomSubBlocks() {
#endif
}
ptr = findResource(MKID('ENCD'), roomptr);
ptr = findResource(MKID('ENCD'), roomptr, 0);
if (ptr) {
_ENCD_offs = ptr - roomptr;
#ifdef DUMP_SCRIPTS
@ -624,25 +639,25 @@ void Scumm::initRoomSubBlocks() {
#endif
}
ptr = findResource(MKID('BOXD'), roomptr);
ptr = findResource(MKID('BOXD'), roomptr, 0);
if (ptr) {
int size = READ_BE_UINT32_UNALIGNED(ptr+4);
createResource(14, 2, size);
roomptr = getResourceAddress(1, _roomResource);
ptr = findResource(MKID('BOXD'), roomptr);
ptr = findResource(MKID('BOXD'), roomptr, 0);
memcpy(getResourceAddress(0xE, 2), ptr, size);
}
ptr = findResource(MKID('BOXM'), roomptr);
ptr = findResource(MKID('BOXM'), roomptr, 0);
if (ptr) {
int size = READ_BE_UINT32_UNALIGNED(ptr+4);
createResource(14, 1, size);
roomptr = getResourceAddress(1, _roomResource);
ptr = findResource(MKID('BOXM'), roomptr);
ptr = findResource(MKID('BOXM'), roomptr, 0);
memcpy(getResourceAddress(0xE, 1), ptr, size);
}
ptr = findResource(MKID('SCAL'), roomptr);
ptr = findResource(MKID('SCAL'), roomptr, 0);
if (ptr) {
offs = ptr - roomptr;
for (i=1; i<_maxScaleTable; i++, offs+=8) {
@ -659,10 +674,8 @@ void Scumm::initRoomSubBlocks() {
memset(_localScriptList, 0, (0x100 - _numGlobalScripts) * 4);
roomptr = getResourceAddress(1, _roomResource);
ptr = findResource(MKID('LSCR'), roomptr);
while (ptr) {
for (i=0; ptr = findResource(MKID('LSCR'), roomptr, i++) ;) {
_localScriptList[ptr[8] - _numGlobalScripts] = ptr - roomptr;
#ifdef DUMP_SCRIPTS
do {
char buf[32];
@ -670,35 +683,34 @@ void Scumm::initRoomSubBlocks() {
dumpResource(buf, ptr[8], ptr);
} while (0);
#endif
ptr = findResource(MKID('LSCR'), NULL);
}
ptr = findResource(MKID('EPAL'), roomptr);
ptr = findResource(MKID('EPAL'), roomptr, 0);
if (ptr)
_EPAL_offs = ptr - roomptr;
ptr = findResource(MKID('CLUT'), roomptr);
ptr = findResource(MKID('CLUT'), roomptr, 0);
if (ptr) {
_CLUT_offs = ptr - roomptr;
setPaletteFromRes();
}
if (_majorScummVersion==6) {
ptr = findResource(MKID('PALS'), roomptr);
ptr = findResource(MKID('PALS'), roomptr, 0);
if (ptr) {
_PALS_offs = ptr - roomptr;
setPalette(0);
}
}
initCycl(findResource(MKID('CYCL'), roomptr) + 8);
initCycl(findResource(MKID('CYCL'), roomptr, 0) + 8);
ptr = findResource(MKID('TRNS'), roomptr);
ptr = findResource(MKID('TRNS'), roomptr, 0);
if (ptr)
gdi.transparency = ptr[8];
gdi._transparency = ptr[8];
else
gdi.transparency = 255;
gdi._transparency = 255;
initBGBuffers();
}
@ -764,64 +776,12 @@ void Scumm::unkRoomFunc3(int a, int b, int c, int d, int e) {
warning("stub unkRoomFunc3(%d,%d,%d,%d,%d)",a,b,c,d,e);
}
void Scumm::unkRoomFunc2(int a, int b, int c, int d, int e) {
byte *cptr, *cur;
int num;
byte color;
if (_videoMode==0xE) {
warning("stub unkRoomFunc2(%d,%d,%d,%d,%d)",a,b,c,d,e);
}
if (_videoMode==0x13) {
cptr = getResourceAddress(1, _roomResource);
if (_CLUT_offs) {
cptr += _CLUT_offs;
} else {
cptr = findPalInPals(cptr + _PALS_offs, _curPalIndex);
}
cptr += 8 + a*3;
cur = _currentPalette + a*3;
if (a <= b) {
num = b - a + 1;
do {
if (c != 0xFF) {
color = *cptr++ * (c>>2) / 0xFF;
} else {
color = *cptr++ >> 2;
}
if(color>63) color = 63;
*cur++=color;
if (d != 0xFF) {
color = *cptr++ * (d>>2) / 0xFF;
} else {
color = *cptr++ >> 2;
}
if(color>63) color = 63;
*cur++=color;
if (e != 0xFF) {
color = *cptr++ * (e>>2) / 0xFF;
} else {
color = *cptr++ >> 2;
}
if(color>63) color = 63;
*cur++=color;
} while (--num);
}
setDirtyColors(a,b);
}
}
void Scumm::unkRoomFunc4(int a, int b, int c, int d, int e) {
/* TODO: implement this */
warning("unkRoomFunc4: not implemented");
}
void Scumm::pauseGame(int i) {
/* TODO: implement this */
warning("pauseGame: not implemented");
@ -924,7 +884,7 @@ Actor *Scumm::derefActorSafe(int id, const char *errmsg) {
}
void Scumm::new_unk_1(int a) {
error("stub new_unk_1(%d)", a);
warning("stub new_unk_1(%d)", a);
}
void Scumm::setCursorHotspot2(int x,int y) {
@ -932,29 +892,15 @@ void Scumm::setCursorHotspot2(int x,int y) {
}
void Scumm::setStringVars(int slot) {
string[slot].xpos = string[slot].t_xpos;
string[slot].ypos = string[slot].t_ypos;
string[slot].center = string[slot].t_center;
string[slot].overhead = string[slot].t_overhead;
string[slot].new_3 = string[slot].t_new3;
string[slot].right = string[slot].t_right;
string[slot].color = string[slot].t_color;
string[slot].charset = string[slot].t_charset;
}
void Scumm::arrayop_1(int a, byte *ptr) {
ArrayHeader *ah;
int r;
int len = getStringLen(ptr);
r = defineArray(a, 4, 0, len);
ah = (ArrayHeader*)getResourceAddress(7,r);
copyString(ah->data,ptr,len);
}
void Scumm::unkMiscOp4(int a, int b, int c, int d) {
warning("stub unkMiscOp4(%d,%d,%d,%d)", a,b,c,d);
StringTab *st = &string[slot];
st->xpos = st->t_xpos;
st->ypos = st->t_ypos;
st->center = st->t_center;
st->overhead = st->t_overhead;
st->new_3 = st->t_new3;
st->right = st->t_right;
st->color = st->t_color;
st->charset = st->t_charset;
}
void Scumm::unkMiscOp9() {

View File

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Zp4 /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Zp4 /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD BASE RSC /l 0x41d /d "NDEBUG"
# ADD RSC /l 0x41d /d "NDEBUG"
BSC32=bscmake.exe
@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "CHECK_HEAP" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "DUMP_SCRIPTS" /Yu"stdafx.h" /FD /GZ /c
# SUBTRACT CPP /Fr
# ADD BASE RSC /l 0x41d /d "_DEBUG"
# ADD RSC /l 0x41d /d "_DEBUG"
@ -89,71 +89,225 @@ LINK32=link.exe
# Begin Source File
SOURCE=.\actor.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\boxes.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\costume.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\debug.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\gfx.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\object.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\resource.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\saveload.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\script.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\script_v1.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\script_v2.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\scummvm.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sound.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd /Yc"stdafx.h"
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
# ADD CPP /Yc"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\string.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sys.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\verbs.cpp
!IF "$(CFG)" == "scummvm - Win32 Release"
# ADD CPP /Gd
!ELSEIF "$(CFG)" == "scummvm - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.12 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.11 2001/10/23 19:51:50 strigeus
* recompile not needed when switching games
* debugger skeleton implemented
@ -102,6 +105,7 @@ void waitForTimer(Scumm *s) {
s->_saveLoadFlag = 1;
else if (event.key.keysym.mod&KMOD_CTRL)
s->_saveLoadFlag = 2;
s->_saveLoadCompatible = false;
}
if (event.key.keysym.sym=='z' && event.key.keysym.mod&KMOD_CTRL) {
exit(1);
@ -328,7 +332,7 @@ void initGraphics(Scumm *s) {
}
/* Clean up on exit */
atexit(SDL_Quit);
atexit(SDL_Quit);
char buf[512], *gameName;

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.5 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.4 2001/10/24 20:12:52 strigeus
* fixed some bugs related to string handling
*
@ -160,6 +163,8 @@ void Scumm::unkMessage1() {
byte buf[100];
_msgPtrToAdd = buf;
_messagePtr = addMessageToStack(_messagePtr);
// warning("unkMessage1(\"%s\")", buf);
}
void Scumm::unkMessage2() {
@ -171,7 +176,7 @@ void Scumm::unkMessage2() {
if (string[3].color==0)
string[3].color = 4;
error("unkMessage2: call to printScummMessage(%s)", buf);
warning("unkMessage2(\"%s\")", buf);
_messagePtr = tmp;
}
@ -193,11 +198,11 @@ void Scumm::CHARSET_1() {
if (_majorScummVersion==5) {
string[0].xpos = a->x - camera._curPos + 160;
if (_vars[VAR_TALK_STRING_Y] < 0) {
s = (a->scaley * (int)_vars[VAR_TALK_STRING_Y]) / 0xFF;
string[0].ypos = ((_vars[VAR_TALK_STRING_Y]-s)>>1) + s - a->elevation + a->y;
if (_vars[VAR_V5_TALK_STRING_Y] < 0) {
s = (a->scaley * (int)_vars[VAR_V5_TALK_STRING_Y]) / 0xFF;
string[0].ypos = ((_vars[VAR_V5_TALK_STRING_Y]-s)>>1) + s - a->elevation + a->y;
} else {
string[0].ypos = _vars[VAR_TALK_STRING_Y];
string[0].ypos = _vars[VAR_V5_TALK_STRING_Y];
}
if (string[0].ypos < 1)
string[0].ypos = 1;
@ -232,7 +237,7 @@ void Scumm::CHARSET_1() {
charset._center = string[0].center;
charset._right = string[0].right;
charset._color = _charsetColor;
dseg_4E3C = 0;
_bkColor = 0;
for (i=0; i<4; i++)
charset._colorMap[i] = _charsetData[charset._curId][i];
@ -303,9 +308,14 @@ newLine:;
charset._left = string[0].xpos2;
charset._top = string[0].ypos2;
if (!_vars[VAR_CHARFLAG]) {
if (_majorScummVersion==5) {
if (!_vars[VAR_V5_CHARFLAG]) {
charset.printChar(c);
}
} else {
charset.printChar(c);
}
string[0].xpos2 = charset._left;
string[0].ypos2 = charset._top;
@ -366,6 +376,7 @@ void Scumm::drawString(int a) {
byte *charsetptr,*space;
int i;
byte byte1, chr;
uint color;
_msgPtrToAdd = buf;
_messagePtr = addMessageToStack(_messagePtr);
@ -376,7 +387,7 @@ void Scumm::drawString(int a) {
charset._center = string[a].center;
charset._right = string[a].right;
charset._color = string[a].color;
dseg_4E3C = 0;
_bkColor = 0;
charset._unk12 = 1;
charset._disableOffsX = 1;
@ -420,6 +431,7 @@ void Scumm::drawString(int a) {
chr = buf[i++];
switch(chr) {
case 9:
case 10: case 13: case 14:
i += 2;
break;
case 1: case 8:
@ -428,10 +440,22 @@ void Scumm::drawString(int a) {
} else {
charset._left = charset._left2;
}
charset._top += byte1;
charset._top += byte1;
break;
case 12:
color = buf[i] + (buf[i+1]<<8);
i+=2;
if (color==0xFF)
charset._color = string[a].color;
else
charset._color = color;
break;
}
} else {
if (a==1 && _majorScummVersion==6)
charset._blitAlso = true;
charset.printChar(chr);
charset._blitAlso = false;
}
}
@ -603,11 +627,9 @@ void CharsetRenderer::printChar(int chr) {
VirtScreen *vs;
_vm->checkRange(_vm->_maxCharsets-1, 1, _curId, "Printing with bad charset %d");
if (_vm->findVirtScreen(_top)==-1)
if ((vs=_vm->findVirtScreen(_top)) == NULL)
return;
vs = &_vm->virtscr[_vm->gdi.virtScreen];
if (chr=='@')
return;
@ -678,20 +700,34 @@ void CharsetRenderer::printChar(int chr) {
_strTop = _top;
_drawTop = _top - vs->topline;
if (_drawTop<0) _drawTop = 0;
_bottom = _drawTop + _height + _offsY;
_vm->updateDirtyRect(_vm->gdi.virtScreen, _left, right, _drawTop, _bottom, 0);
_vm->updateDirtyRect(vs->number, _left, right, _drawTop, _bottom, 0);
if (_vm->gdi.virtScreen==0)
#if defined(OLD)
if (vs->number==0)
_hasMask = true;
#else
if (vs->number!=0)
_blitAlso = false;
if (vs->number==0 && _blitAlso==0)
_hasMask = true;
#endif
_bg_ptr = _vm->getResourceAddress(0xA, _vm->gdi.virtScreen+1)
+ vs->xstart + _drawTop * 320 + _left;
_where_to_draw_ptr = _vm->getResourceAddress(0xA, _vm->gdi.virtScreen+5)
_bg_ptr2 = _backbuff_ptr = _vm->getResourceAddress(0xA, vs->number+1)
+ vs->xstart + _drawTop * 320 + _left;
#if !defined(OLD)
if (_blitAlso) {
#else
if (1) {
#endif
_bg_ptr2 = _bgbak_ptr = _vm->getResourceAddress(0xA, vs->number+5)
+ vs->xstart + _drawTop * 320 + _left;
}
_mask_ptr = _vm->getResourceAddress(0xA, 9)
+ _drawTop * 40 + _left/8
+ _vm->_screenStartStrip;
@ -702,7 +738,12 @@ void CharsetRenderer::printChar(int chr) {
_charPtr += 4;
drawBits();
#if !defined(OLD)
if (_blitAlso)
blit(_backbuff_ptr, _bgbak_ptr, _width, _height);
#endif
_left += _width;
if (_left > _strRight)
_strRight = _left;
@ -722,12 +763,12 @@ void CharsetRenderer::drawBits() {
int color;
byte numbits,bits;
usemask = (_vm->gdi.virtScreen==0 && _ignoreCharsetMask==0);
usemask = (_vm->_curVirtScreen->number==0 && _ignoreCharsetMask==0);
bits = *_charPtr++;
numbits = 8;
dst = _bg_ptr;
dst = _bg_ptr2;
mask = _mask_ptr;
y = 0;
@ -754,7 +795,7 @@ void CharsetRenderer::drawBits() {
maskpos++;
}
}
dst = (_bg_ptr += 320);
dst = (_bg_ptr2 += 320);
mask += 40;
y++;
}

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.4 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.3 2001/10/16 10:01:48 strigeus
* preliminary DOTT support
*
@ -164,7 +167,7 @@ void Scumm::restoreVerbBG(int verb) {
vs = &_verbs[verb];
if (vs->oldleft != -1) {
dseg_4E3C = vs->bkcolor;
_bkColor = vs->bkcolor;
restoreBG(vs->oldleft, vs->oldtop, vs->oldright, vs->oldbottom);
vs->oldleft = -1;
}
@ -177,17 +180,16 @@ void Scumm::drawVerbBitmap(int vrb, int x, int y) {
byte twobufs, *imptr;
int ydiff, xstrip;
int imgw, imgh;
int i;
int i,tmp;
byte *IMHD_ptr;
byte *obim;
if (findVirtScreen(y) == -1)
if ((vs=findVirtScreen(y)) == NULL)
return;
_lastXstart = virtscr[0].xstart;
nozbufs = _numZBuffer;
_numZBuffer = 0;
vs = &virtscr[gdi.virtScreen];
gdi.disableZBuffer();
twobufs = vs->alloctwobuffers;
vs->alloctwobuffers = 0;
@ -195,22 +197,21 @@ void Scumm::drawVerbBitmap(int vrb, int x, int y) {
xstrip = x>>3;
ydiff = y - vs->topline;
IMHD_ptr = findResource2(MKID('IMHD'), getResourceAddress(8, vrb));
obim = getResourceAddress(8, vrb);
IMHD_ptr = findResource(MKID('IMHD'), obim, 0);
imgw = READ_LE_UINT16(IMHD_ptr+0x14) >> 3;
imgh = READ_LE_UINT16(IMHD_ptr+0x16) >> 3;
imptr = findResource2(MKID('IM01'), NULL);
imptr = findResource(MKID('IM01'), obim, 0);
if (!imptr)
error("No image for verb %d", vrb);
for (i=0; i<imgw; i++) {
_drawBmpX = xstrip + i;
if (_drawBmpX < 40) {
_drawBmpY = ydiff;
gdi.numLinesToProcess = imgh<<3;
drawBmp(imptr, i, 1, 1, "Verb", READ_LE_UINT16(IMHD_ptr+8));
}
tmp = xstrip + i;
if ((uint)tmp < 40)
gdi.drawBitmap(imptr, vs, tmp, ydiff, imgh<<3, i, 1, true);
}
vst = &_verbs[vrb];
@ -220,7 +221,8 @@ void Scumm::drawVerbBitmap(int vrb, int x, int y) {
vst->oldright = vst->right;
vst->oldtop = vst->y;
vst->oldbottom = vst->bottom;
_numZBuffer = nozbufs;
gdi.enableZBuffer();
vs->alloctwobuffers = twobufs;
}
@ -258,7 +260,7 @@ void Scumm::setVerbObject(int room, int object, int verb) {
int numobj, i;
byte *obimptr;
uint32 imoffs,size;
byte *roomptr,*tmp_roomptr;
byte *roomptr;
ImageHeader *imhd;
RoomHeader *roomhdr;
@ -267,7 +269,7 @@ void Scumm::setVerbObject(int room, int object, int verb) {
ensureResourceLoaded(1,room);
roomptr = getResourceAddress(1, room);
roomhdr = (RoomHeader*)findResource(MKID('RMHD'), roomptr);
roomhdr = (RoomHeader*)findResource(MKID('RMHD'), roomptr, 0);
numobj = READ_LE_UINT16(&roomhdr->numObjects);
if (numobj==0)
@ -275,12 +277,11 @@ void Scumm::setVerbObject(int room, int object, int verb) {
if (numobj > 200)
error("More (%d) than %d objects in room %d", numobj, 200, room);
tmp_roomptr = roomptr;
for (i=1; i<=numobj; i++) {
obimptr = findResource(MKID('OBIM'), tmp_roomptr);
for (i=0; i<numobj; i++) {
obimptr = findResource(MKID('OBIM'), roomptr, i);
if (obimptr==NULL)
error("Not enough image blocks in room %d", room);
imhd = (ImageHeader*)findResource2(MKID('IMHD'), obimptr);
imhd = (ImageHeader*)findResource(MKID('IMHD'), obimptr, 0);
if ( READ_LE_UINT16(&imhd->obj_id) == object) {
imoffs = obimptr - roomptr;
size = READ_BE_UINT32_UNALIGNED(obimptr+4);
@ -289,7 +290,6 @@ void Scumm::setVerbObject(int room, int object, int verb) {
memcpy(getResourceAddress(8, verb), obimptr, size);
return;
}
tmp_roomptr = NULL;
}
error("Image %d not found in room %d", object, room);
}

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.8 2001/10/26 17:34:50 strigeus
* bug fixes, code cleanup
*
* Revision 1.7 2001/10/23 19:51:50 strigeus
* recompile not needed when switching games
* debugger skeleton implemented
@ -133,6 +136,7 @@ void Error(const char *msg) {
int sel;
Scumm scumm;
ScummDebugger debugger;
WndMan wm[1];
byte veryFastMode;
@ -148,6 +152,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_CHAR:
wm->_scumm->_keyPressed = wParam;
break;
@ -159,6 +164,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
wm->_scumm->_saveLoadFlag = 1;
else if (GetAsyncKeyState(VK_CONTROL)<0)
wm->_scumm->_saveLoadFlag = 2;
wm->_scumm->_saveLoadCompatible = false;
}
if (wParam=='F') {
@ -169,6 +175,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
veryFastMode ^= 1;
}
if (wParam=='D') {
debugger.attach(wm->_scumm);
}
break;
case WM_MOUSEMOVE: