preliminary DOTT support

svn-id: r3433
This commit is contained in:
Ludvig Strigeus 2001-10-16 10:01:48 +00:00
parent 862192dbeb
commit 794163c1a3
19 changed files with 6207 additions and 2811 deletions

View file

@ -10,7 +10,7 @@ INCS = scumm.h scummsys.h stdafx.h
OBJS = actor.o boxes.o costume.o gfx.o object.o resource.o \ OBJS = actor.o boxes.o costume.o gfx.o object.o resource.o \
saveload.o script.o scummvm.o sound.o string.o \ saveload.o script.o scummvm.o sound.o string.o \
sys.o verbs.o sdl.o sys.o verbs.o sdl.o script_v1.o script_v2.o
DISTFILES=actor.cpp boxes.cpp costume.cpp gfx.cpp object.cpp resource.cpp \ DISTFILES=actor.cpp boxes.cpp costume.cpp gfx.cpp object.cpp resource.cpp \
saveload.cpp script.cpp scummvm.cpp sound.cpp string.cpp \ saveload.cpp script.cpp scummvm.cpp sound.cpp string.cpp \

View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.5 2001/10/16 10:01:44 strigeus
* preliminary DOTT support
*
* Revision 1.4 2001/10/10 17:18:33 strigeus * Revision 1.4 2001/10/10 17:18:33 strigeus
* fixed swapped parameters in o_walkActorToActor * fixed swapped parameters in o_walkActorToActor
* *
@ -38,26 +41,43 @@
#include "scumm.h" #include "scumm.h"
void Scumm::initActor(Actor *a, int mode) { void Scumm::initActor(Actor *a, int mode) {
if (mode) { if (mode==1) {
a->facing = 2;
a->costume = 0; a->costume = 0;
a->room = 0; a->room = 0;
a->x = 0; a->x = 0;
a->y = 0; a->y = 0;
a->facing = 2;
} else if (mode==2) {
a->facing = 2;
} }
a->elevation = 0; a->elevation = 0;
a->width = 0x18; a->width = 0x18;
a->talkColor = 0xF; a->talkColor = 0xF;
#if defined(DOTT)
a->new_2 = 0;
a->new_1 = -80;
#endif
a->scaley = a->scalex = 0xFF; a->scaley = a->scalex = 0xFF;
a->charset = 0; a->charset = 0;
a->sound = 0; a->sound[0] = 0;
a->sound[1] = 0;
a->sound[2] = 0;
a->sound[3] = 0;
a->sound[4] = 0;
a->sound[5] = 0;
a->sound[6] = 0;
a->sound[7] = 0;
a->newDirection = 0;
a->moving = 0; a->moving = 0;
setActorWalkSpeed(a, 8, 2); setActorWalkSpeed(a, 8, 2);
a->ignoreBoxes = 0; a->ignoreBoxes = 0;
a->neverZClip = 0; a->neverZClip = 0;
#if defined(DOTT)
a->new_3 = 0;
#endif
a->initFrame = 1; a->initFrame = 1;
a->walkFrame = 2; a->walkFrame = 2;
a->standFrame = 3; a->standFrame = 3;
@ -415,7 +435,7 @@ void Scumm::decodeCostData(Actor *a, int frame, uint usemask) {
} }
void Scumm::putActor(Actor *a, int x, int y, byte room) { void Scumm::putActor(Actor *a, int x, int y, byte room) {
if (a->visible && _currentRoom!=room && vm.vars[VAR_TALK_ACTOR]==a->number) { if (a->visible && _currentRoom!=room && _vars[VAR_TALK_ACTOR]==a->number) {
clearMsgQueue(); clearMsgQueue();
} }
@ -425,7 +445,7 @@ void Scumm::putActor(Actor *a, int x, int y, byte room) {
a->needRedraw = true; a->needRedraw = true;
a->needBgReset = true; a->needBgReset = true;
if (vm.vars[VAR_UNK_ACTOR]==a->number) { if (_vars[VAR_UNK_ACTOR]==a->number) {
dseg_3A76 = 1; dseg_3A76 = 1;
} }
@ -589,13 +609,13 @@ void Scumm::stopTalk() {
_haveMsg = 0; _haveMsg = 0;
_talkDelay = 0; _talkDelay = 0;
act = vm.vars[VAR_TALK_ACTOR]; act = _vars[VAR_TALK_ACTOR];
if (act && act<0x80) { if (act && act<0x80) {
Actor *a = derefActorSafe(act, "stopTalk"); Actor *a = derefActorSafe(act, "stopTalk");
if (_currentRoom == a->room) { if (_currentRoom == a->room) {
startAnimActor(a, a->talkFrame2, a->facing); startAnimActor(a, a->talkFrame2, a->facing);
} }
vm.vars[VAR_TALK_ACTOR] = 0xFF; _vars[VAR_TALK_ACTOR] = 0xFF;
} }
_keepText = false; _keepText = false;
restoreCharsetBg(); restoreCharsetBg();
@ -616,6 +636,7 @@ void Scumm::walkActors() {
} }
} }
#if !defined(DOTT)
void Scumm::playActorSounds() { void Scumm::playActorSounds() {
int i; int i;
Actor *a; Actor *a;
@ -624,7 +645,7 @@ void Scumm::playActorSounds() {
a = derefActor(i); a = derefActor(i);
if (a->cost.animCounter2 && a->room==_currentRoom && a->sound) { if (a->cost.animCounter2 && a->room==_currentRoom && a->sound) {
_currentScript = 0xFF; _currentScript = 0xFF;
addSoundToQueue(a->sound); addSoundToQueue(a->sound[0]);
for (i=1; i<13; i++) { for (i=1; i<13; i++) {
a = derefActor(i); a = derefActor(i);
a->cost.animCounter2 = 0; a->cost.animCounter2 = 0;
@ -633,6 +654,7 @@ void Scumm::playActorSounds() {
} }
} }
} }
#endif
void Scumm::walkActor(Actor *a) { void Scumm::walkActor(Actor *a) {
int j; int j;
@ -741,9 +763,9 @@ void Scumm::processActors() {
setupActorScale(a); setupActorScale(a);
setupCostumeRenderer(&cost, a); setupCostumeRenderer(&cost, a);
setActorCostPalette(a); setActorCostPalette(a);
checkHeap(); CHECK_HEAP
drawActorCostume(a); drawActorCostume(a);
checkHeap(); CHECK_HEAP
actorAnimate(a); actorAnimate(a);
} }
} while (ac++,--cnt); } while (ac++,--cnt);
@ -851,7 +873,7 @@ void Scumm::actorTalk() {
if (_actorToPrintStrFor==0xFF) { if (_actorToPrintStrFor==0xFF) {
if (!_keepText) if (!_keepText)
stopTalk(); stopTalk();
vm.vars[VAR_TALK_ACTOR] = 0xFF; _vars[VAR_TALK_ACTOR] = 0xFF;
oldact = 0; oldact = 0;
} else { } else {
a = derefActorSafe(_actorToPrintStrFor, "actorTalk"); a = derefActorSafe(_actorToPrintStrFor, "actorTalk");
@ -860,24 +882,24 @@ void Scumm::actorTalk() {
} else { } else {
if (!_keepText) if (!_keepText)
stopTalk(); stopTalk();
vm.vars[VAR_TALK_ACTOR] = a->number; _vars[VAR_TALK_ACTOR] = a->number;
startAnimActor(a,a->talkFrame1,a->facing); startAnimActor(a,a->talkFrame1,a->facing);
oldact = vm.vars[VAR_TALK_ACTOR]; oldact = _vars[VAR_TALK_ACTOR];
} }
} }
if (oldact>=0x80) if (oldact>=0x80)
return; return;
if (vm.vars[VAR_TALK_ACTOR]>0x7F) { if (_vars[VAR_TALK_ACTOR]>0x7F) {
_charsetColor = (byte)_stringColor[0]; _charsetColor = (byte)string[0].color;
} else { } else {
a = derefActorSafe(vm.vars[VAR_TALK_ACTOR], "actorTalk(2)"); a = derefActorSafe(_vars[VAR_TALK_ACTOR], "actorTalk(2)");
_charsetColor = a->talkColor; _charsetColor = a->talkColor;
} }
charset._bufPos = 0; charset._bufPos = 0;
_talkDelay = 0; _talkDelay = 0;
_haveMsg = 0xFF; _haveMsg = 0xFF;
vm.vars[VAR_HAVE_MSG] = 0xFF; _vars[VAR_HAVE_MSG] = 0xFF;
CHARSET_1(); CHARSET_1();
} }

View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.3 2001/10/16 10:01:45 strigeus
* preliminary DOTT support
*
* Revision 1.2 2001/10/09 18:35:02 strigeus * Revision 1.2 2001/10/09 18:35:02 strigeus
* fixed object parent bug * fixed object parent bug
* fixed some signed/unsigned comparisons * fixed some signed/unsigned comparisons
@ -85,8 +88,9 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame) {
byte scaling; byte scaling;
byte charsetmask, masking; byte charsetmask, masking;
byte unk19; byte unk19;
int ex1,ex2;
checkHeap(); CHECK_HEAP
_maskval = 0xF; _maskval = 0xF;
_shrval = 4; _shrval = 4;
@ -105,6 +109,19 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame) {
_ymove -= (int16)READ_LE_UINT16(_srcptr+10); _ymove -= (int16)READ_LE_UINT16(_srcptr+10);
_srcptr += 12; _srcptr += 12;
#if defined(DOTT)
switch(_ptr[7]&0x7F) {
case 0x60: case 0x61:
ex1 = _srcptr[0];
ex2 = _srcptr[1];
_srcptr += 2;
if (ex1!=0xFF || ex2!=0xFF) {
ex1=READ_LE_UINT16(_ptr + _numColors + 10 + ex1*2);
_srcptr = _ptr + READ_LE_UINT16(_ptr + ex1 + ex2*2) + 14;
}
}
#endif
_xpos = _actorX; _xpos = _actorX;
_ypos = _actorY; _ypos = _actorY;
@ -200,10 +217,8 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame) {
_vscreenheight = _vm->virtscr[0].height; _vscreenheight = _vm->virtscr[0].height;
_vm->updateDirtyRect(0, _left, _right+1,_top,_bottom,1<<a->number); _vm->updateDirtyRect(0, _left, _right+1,_top,_bottom,1<<a->number);
if (_top >= (int)_vscreenheight || _bottom <= 0) { if (_top >= (int)_vscreenheight || _bottom <= 0)
checkHeap();
return 0; return 0;
}
_ypitch = _height * 320; _ypitch = _height * 320;
_docontinue = 0; _docontinue = 0;
@ -246,7 +261,10 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame) {
} }
} }
if ((uint)_top > (uint)_vscreenheight || _top < 0) if (_width2==0)
return 0;
if ((uint)_top > (uint)_vscreenheight)
_top = 0; _top = 0;
if ((uint)_bottom > _vscreenheight) if ((uint)_bottom > _vscreenheight)
@ -259,7 +277,7 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame) {
a->bottom = _bottom; a->bottom = _bottom;
if (_height2 + _top >= 256) { if (_height2 + _top >= 256) {
checkHeap(); CHECK_HEAP
return 2; return 2;
} }
@ -283,7 +301,7 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame) {
_mask_ptr_dest = _mask_ptr + _xpos / 8; _mask_ptr_dest = _mask_ptr + _xpos / 8;
} }
checkHeap(); CHECK_HEAP
switch ((scaling<<2)|(masking<<1)|charsetmask) { switch ((scaling<<2)|(masking<<1)|charsetmask) {
case 0: case 0:
@ -306,7 +324,7 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame) {
break; break;
} }
checkHeap(); CHECK_HEAP
return b; return b;
} }
@ -611,7 +629,12 @@ StartPos:;
} }
void CostumeRenderer::loadCostume(int id) { void CostumeRenderer::loadCostume(int id) {
_ptr = _vm->getResourceAddress(3, id) + 2; _ptr = _vm->getResourceAddress(3, id)
#if defined(DOTT)
+ 8;
#else
+ 2;
#endif
switch(_ptr[7]&0x7F) { switch(_ptr[7]&0x7F) {
case 0x58: case 0x58:
_numColors = 16; _numColors = 16;
@ -619,6 +642,14 @@ void CostumeRenderer::loadCostume(int id) {
case 0x59: case 0x59:
_numColors = 32; _numColors = 32;
break; break;
#if defined(DOTT)
case 0x60:
_numColors = 16;
break;
case 0x61:
_numColors = 32;
break;
#endif
default: default:
error("Costume %d is invalid", id); error("Costume %d is invalid", id);
} }
@ -649,6 +680,7 @@ byte CostumeRenderer::drawOneSlot(Actor *a, int slot) {
byte CostumeRenderer::drawCostume(Actor *a) { byte CostumeRenderer::drawCostume(Actor *a) {
int i; int i;
byte r = 0; byte r = 0;
_xmove = _ymove = 0; _xmove = _ymove = 0;
for (i=0; i<16; i++) for (i=0; i<16; i++)
r|=drawOneSlot(a, i); r|=drawOneSlot(a, i);

316
gfx.cpp
View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.4 2001/10/16 10:01:47 strigeus
* preliminary DOTT support
*
* Revision 1.3 2001/10/10 12:52:21 strigeus * Revision 1.3 2001/10/10 12:52:21 strigeus
* fixed bug in GDI_UnkDecode7() * fixed bug in GDI_UnkDecode7()
* *
@ -42,7 +45,7 @@ void Scumm::getGraphicsPerformance() {
initScreens(0, 0, 320, 200); initScreens(0, 0, 320, 200);
} }
vm.vars[VAR_PERFORMANCE_1] = _scummTimer; _vars[VAR_PERFORMANCE_1] = _scummTimer;
_scummTimer = 0; _scummTimer = 0;
for (i=10; i!=0; i--) { for (i=10; i!=0; i--) {
@ -50,7 +53,7 @@ void Scumm::getGraphicsPerformance() {
unkVirtScreen2(); unkVirtScreen2();
} }
vm.vars[VAR_PERFORMANCE_2] = _scummTimer; _vars[VAR_PERFORMANCE_2] = _scummTimer;
initScreens(0, 16, 320, 144); initScreens(0, 16, 320, 144);
} }
@ -314,15 +317,15 @@ void Scumm::setCameraAt(int dest) {
} }
cd->_destPos = dest; cd->_destPos = dest;
t = vm.vars[VAR_CAMERA_MIN]; t = _vars[VAR_CAMERA_MIN];
if (cd->_curPos < t) cd->_curPos = t; if (cd->_curPos < t) cd->_curPos = t;
t = vm.vars[VAR_CAMERA_MAX]; t = _vars[VAR_CAMERA_MAX];
if (cd->_curPos > t) cd->_curPos = t; if (cd->_curPos > t) cd->_curPos = t;
if (vm.vars[VAR_SCROLL_SCRIPT]) { if (_vars[VAR_SCROLL_SCRIPT]) {
vm.vars[VAR_CAMERA_CUR_POS] = cd->_curPos; _vars[VAR_CAMERA_CUR_POS] = cd->_curPos;
runScript(vm.vars[VAR_SCROLL_SCRIPT], 0, 0, 0); runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0);
} }
if (cd->_curPos != cd->_lastPos && charset._hasMask) if (cd->_curPos != cd->_lastPos && charset._hasMask)
@ -378,8 +381,7 @@ void Scumm::initBGBuffers() {
_imgBufOffs[i] = i*itemsize; _imgBufOffs[i] = i*itemsize;
} }
void Scumm::setPaletteFromRes() { void Scumm::setPaletteFromPtr(byte *ptr) {
byte *ptr = getResourceAddress(1, _roomResource) + _CLUT_offs;
uint32 size = READ_BE_UINT32_UNALIGNED(ptr+4); uint32 size = READ_BE_UINT32_UNALIGNED(ptr+4);
int i, r, g, b; int i, r, g, b;
byte *dest, *epal; byte *dest, *epal;
@ -419,6 +421,12 @@ void Scumm::setPaletteFromRes() {
setDirtyColors(0, numcolor-1); setDirtyColors(0, numcolor-1);
} }
void Scumm::setPaletteFromRes() {
byte *ptr;
ptr = getResourceAddress(1, _roomResource) + _CLUT_offs;
setPaletteFromPtr(ptr);
}
void Scumm::setDirtyColors(int min, int max) { void Scumm::setDirtyColors(int min, int max) {
if (_palDirtyMin > min) if (_palDirtyMin > min)
@ -465,9 +473,9 @@ void Scumm::cyclePalette() {
if(_videoMode != 0x13) if(_videoMode != 0x13)
return; return;
valueToAdd = vm.vars[VAR_TIMER]; valueToAdd = _vars[VAR_TIMER];
if (valueToAdd < vm.vars[VAR_TIMER_NEXT]) if (valueToAdd < _vars[VAR_TIMER_NEXT])
valueToAdd = vm.vars[VAR_TIMER_NEXT]; valueToAdd = _vars[VAR_TIMER_NEXT];
for (i=1; i<=16; i++) { for (i=1; i<=16; i++) {
if (_colorCycleDelays[i] && if (_colorCycleDelays[i] &&
@ -571,6 +579,8 @@ void Scumm::unkVirtScreen4(int a) {
case 135: case 135:
unkScreenEffect5(1); unkScreenEffect5(1);
break; break;
default:
error("unkVirtScreen4: default case %d", a);
} }
} }
@ -615,7 +625,6 @@ const uint32 zplane_tags[] = {
MKID('ZP03') MKID('ZP03')
}; };
void Scumm::drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr) { void Scumm::drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr) {
byte *smap_ptr; byte *smap_ptr;
int i; int i;
@ -626,14 +635,10 @@ void Scumm::drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr)
int x; int x;
byte *where_draw_ptr; byte *where_draw_ptr;
checkHeap(); CHECK_HEAP
smap_ptr = findResource(MKID('SMAP'), ptr); smap_ptr = findResource(MKID('SMAP'), ptr);
if (objnr==209) {
warning("tst");
}
for(i=1; i<_numZBuffer; i++) { for(i=1; i<_numZBuffer; i++) {
zplane_list[i] = findResource(zplane_tags[i], ptr); zplane_list[i] = findResource(zplane_tags[i], ptr);
} }
@ -662,7 +667,7 @@ void Scumm::drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr)
if (vs->fourlinesextra) if (vs->fourlinesextra)
x -= _screenStartStrip; x -= _screenStartStrip;
checkHeap(); CHECK_HEAP
if (x >= 40) if (x >= 40)
return; return;
@ -683,11 +688,11 @@ void Scumm::drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr)
where_draw_ptr = gdi.where_to_draw_ptr; where_draw_ptr = gdi.where_to_draw_ptr;
decompressBitmap(); decompressBitmap();
checkHeap(); CHECK_HEAP
if (twobufs) { if (twobufs) {
gdi.where_to_draw_ptr = where_draw_ptr; gdi.where_to_draw_ptr = where_draw_ptr;
if (vm.vars[VAR_DRAWFLAGS]&2) { if (_vars[VAR_DRAWFLAGS]&2) {
if (hasCharsetMask(x<<3, _drawBmpY, (x+1)<<3, t)) if (hasCharsetMask(x<<3, _drawBmpY, (x+1)<<3, t))
draw8ColWithMasking(); draw8ColWithMasking();
else { else {
@ -700,7 +705,7 @@ void Scumm::drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr)
clear8Col(); clear8Col();
} }
} }
checkHeap(); CHECK_HEAP
for (i=1; i<_numZBuffer; i++) { for (i=1; i<_numZBuffer; i++) {
if (!zplane_list[i]) if (!zplane_list[i])
@ -712,7 +717,7 @@ void Scumm::drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr)
else else
decompressMaskImg(); decompressMaskImg();
} }
checkHeap(); CHECK_HEAP
_drawBmpX++; _drawBmpX++;
a++; a++;
} while (--b); } while (--b);
@ -728,6 +733,8 @@ void Scumm::decompressBitmap() {
byte code = *gdi.smap_ptr++; byte code = *gdi.smap_ptr++;
assert(gdi.numLinesToProcess);
switch(code) { switch(code) {
case 1: case 1:
GDI_UnkDecode7(); GDI_UnkDecode7();
@ -747,7 +754,7 @@ void Scumm::decompressBitmap() {
case 34: case 35: case 36: case 37: case 38: case 34: case 35: case 36: case 37: case 38:
dseg_4E3B = 1; dseg_4E3B = 1;
gdi.decomp_shr = code - 30; gdi.decomp_shr = code - 30;
gdi.decomp_mask = decompress_table[code - 30]; gdi.decomp_mask = decompress_table[code - 30 ];
GDI_UnkDecode4(); GDI_UnkDecode4();
break; break;
@ -770,12 +777,30 @@ void Scumm::decompressBitmap() {
gdi.decomp_mask = decompress_table[code - 80]; gdi.decomp_mask = decompress_table[code - 80];
GDI_UnkDecode3(); GDI_UnkDecode3();
break; break;
#if defined(DOTT)
case 104: case 105: case 106: case 107: case 108:
gdi.decomp_shr = code - 100;
gdi.decomp_mask = decompress_table[code - 100];
GDI_UnkDecode1();
break;
case 124: case 125: case 126: case 127: case 128:
dseg_4E3B = 1;
gdi.decomp_shr = code - 120;
gdi.decomp_mask = decompress_table[code - 120];
GDI_UnkDecode3();
break;
#endif
default:
error("decompressBitmap: default case %d", code);
} }
} }
int Scumm::hasCharsetMask(int x, int y, int x2, int y2) { int Scumm::hasCharsetMask(int x, int y, int x2, int y2) {
if (!charset._hasMask || y > charset._mask_bottom || x > charset._mask_right || if (!charset._hasMask || y > string[0].mask_bottom || x > string[0].mask_right ||
y2 < charset._mask_top || x2 < charset._mask_left ) y2 < string[0].mask_top || x2 < string[0].mask_left )
return 0; return 0;
return 1; return 1;
} }
@ -928,6 +953,59 @@ void Scumm::redrawBGStrip(int start, int num) {
#define READ_BIT (cl--,bit = bits&1, bits>>=1,bit) #define READ_BIT (cl--,bit = bits&1, bits>>=1,bit)
#define FILL_BITS if (cl <= 8) { bits |= (*src++ << cl); cl += 8;} #define FILL_BITS if (cl <= 8) { bits |= (*src++ << cl); cl += 8;}
#if defined(DOTT)
void Scumm::GDI_UnkDecode1() {
byte *src = gdi.smap_ptr;
byte *dst = gdi.where_to_draw_ptr;
byte color = *src++;
uint bits = *src++;
byte cl = 8;
byte bit;
byte incm,reps;
gdi.tempNumLines = gdi.numLinesToProcess;
do {
gdi.currentX = 8;
do {
FILL_BITS
*dst++=color;
againPos:;
if (!READ_BIT) {}
else if (READ_BIT) {
incm = (bits&7)-4;
cl-=3;
bits>>=3;
if (!incm) {
FILL_BITS
reps = bits&0xFF;
do {
if (!--gdi.currentX) {
gdi.currentX = 8;
dst += 312;
if (!--gdi.tempNumLines)
return;
}
*dst++=color;
} while (--reps);
bits>>=8;
bits |= (*src++)<<(cl-8);
goto againPos;
} else {
color += incm;
}
} else {
FILL_BITS
color = bits&gdi.decomp_mask;
cl -= gdi.decomp_shr;
bits >>= gdi.decomp_shr;
}
} while (--gdi.currentX);
dst += 312;
} while (--gdi.tempNumLines);
}
#else
void Scumm::GDI_UnkDecode1() { void Scumm::GDI_UnkDecode1() {
byte *src = gdi.smap_ptr; byte *src = gdi.smap_ptr;
byte *dst = gdi.where_to_draw_ptr; byte *dst = gdi.where_to_draw_ptr;
@ -957,8 +1035,8 @@ void Scumm::GDI_UnkDecode1() {
} while (--gdi.currentX); } while (--gdi.currentX);
dst += 312; dst += 312;
} while (--gdi.tempNumLines); } while (--gdi.tempNumLines);
} }
#endif
void Scumm::GDI_UnkDecode2() { void Scumm::GDI_UnkDecode2() {
byte *src = gdi.smap_ptr; byte *src = gdi.smap_ptr;
@ -996,6 +1074,74 @@ void Scumm::GDI_UnkDecode2() {
} while (--gdi.tempNumLines); } while (--gdi.tempNumLines);
} }
#if defined(DOTT)
void Scumm::GDI_UnkDecode3() {
byte *src = gdi.smap_ptr;
byte *dst = gdi.where_to_draw_ptr;
byte color = *src++;
uint bits = *src++;
byte cl = 8;
byte bit;
byte incm,reps;
gdi.tempNumLines = gdi.numLinesToProcess;
do {
gdi.currentX = 8;
do {
FILL_BITS
if (color!=gdi.transparency) *dst=color;
dst++;
againPos:;
if (!READ_BIT) {}
else if (READ_BIT) {
incm = (bits&7)-4;
cl-=3;
bits>>=3;
if (incm) {
color += incm;
} else {
FILL_BITS
reps = bits&0xFF;
if (color==gdi.transparency) {
do {
if (!--gdi.currentX) {
gdi.currentX = 8;
dst += 312;
if (!--gdi.tempNumLines)
return;
}
dst++;
} while (--reps);
} else {
do {
if (!--gdi.currentX) {
gdi.currentX = 8;
dst += 312;
if (!--gdi.tempNumLines)
return;
}
*dst++=color;
} while (--reps);
}
bits>>=8;
bits |= (*src++)<<(cl-8);
goto againPos;
}
} else {
FILL_BITS
color = bits&gdi.decomp_mask;
cl -= gdi.decomp_shr;
bits >>= gdi.decomp_shr;
}
} while (--gdi.currentX);
dst += 312;
} while (--gdi.tempNumLines);
}
#else
void Scumm::GDI_UnkDecode3() { void Scumm::GDI_UnkDecode3() {
byte *src = gdi.smap_ptr; byte *src = gdi.smap_ptr;
byte *dst = gdi.where_to_draw_ptr; byte *dst = gdi.where_to_draw_ptr;
@ -1028,6 +1174,8 @@ void Scumm::GDI_UnkDecode3() {
dst += 312; dst += 312;
} while (--gdi.tempNumLines); } while (--gdi.tempNumLines);
} }
#endif
void Scumm::GDI_UnkDecode4() { void Scumm::GDI_UnkDecode4() {
byte *src = gdi.smap_ptr; byte *src = gdi.smap_ptr;
@ -1154,13 +1302,18 @@ void Scumm::GDI_UnkDecode7() {
void Scumm::restoreCharsetBg() { void Scumm::restoreCharsetBg() {
dseg_4E3C = 0; dseg_4E3C = 0;
if (charset._mask_left != -1) { if (string[0].mask_left != -1) {
restoreBG(charset._mask_left, charset._mask_top, charset._mask_right, charset._mask_bottom); restoreBG(string[0].mask_left, string[0].mask_top, string[0].mask_right, string[0].mask_bottom);
charset._hasMask = false; charset._hasMask = false;
charset._mask_left = -1; string[0].mask_left = -1;
#if defined(DOTT)
charset._strLeft = -1;
charset._left = -1;
#endif
} }
_stringXpos2[0] = _stringXPos[0];
_stringYpos2[0] = _stringYPos[0]; string[0].xpos2 = string[0].xpos;
string[0].ypos2 = string[0].ypos;
} }
void Scumm::restoreBG(int left, int top, int right, int bottom) { void Scumm::restoreBG(int left, int top, int right, int bottom) {
@ -1209,7 +1362,7 @@ void Scumm::restoreBG(int left, int top, int right, int bottom) {
width = right - left; width = right - left;
widthmod = (width >> 2) + 2; widthmod = (width >> 2) + 2;
if (vs->alloctwobuffers && _currentRoom!=0 && vm.vars[VAR_DRAWFLAGS]&2) { if (vs->alloctwobuffers && _currentRoom!=0 && _vars[VAR_DRAWFLAGS]&2) {
blit(gdi.bg_ptr, gdi.where_to_draw_ptr, width, height); blit(gdi.bg_ptr, gdi.where_to_draw_ptr, width, height);
if (gdi.virtScreen==0 && charset._hasMask && height) { if (gdi.virtScreen==0 && charset._hasMask && height) {
do { do {
@ -1245,8 +1398,8 @@ void Scumm::updateDirtyRect(int virt, int left, int right, int top, int bottom,
rp = (right >> 3) + _screenStartStrip; rp = (right >> 3) + _screenStartStrip;
lp = (left >> 3) + _screenStartStrip; lp = (left >> 3) + _screenStartStrip;
if (lp<0) lp=0; if (lp<0) lp=0;
if (rp >= 160) if (rp >= 200)
rp = 159; rp = 200;
if (lp <= rp) { if (lp <= rp) {
num = rp - lp + 1; num = rp - lp + 1;
sp = &actorDrawBits[lp]; sp = &actorDrawBits[lp];
@ -1328,18 +1481,18 @@ void Scumm::moveCamera() {
cd->_curPos &= 0xFFF8; cd->_curPos &= 0xFFF8;
if (cd->_curPos < vm.vars[VAR_CAMERA_MIN]) { if (cd->_curPos < _vars[VAR_CAMERA_MIN]) {
if (vm.vars[VAR_CAMERA_FAST]) if (_vars[VAR_CAMERA_FAST])
cd->_curPos = vm.vars[VAR_CAMERA_MIN]; cd->_curPos = _vars[VAR_CAMERA_MIN];
else else
cd->_curPos += 8; cd->_curPos += 8;
cameraMoved(); cameraMoved();
return; return;
} }
if (cd->_curPos > vm.vars[VAR_CAMERA_MAX]) { if (cd->_curPos > _vars[VAR_CAMERA_MAX]) {
if (vm.vars[VAR_CAMERA_FAST]) if (_vars[VAR_CAMERA_FAST])
cd->_curPos = vm.vars[VAR_CAMERA_MAX]; cd->_curPos = _vars[VAR_CAMERA_MAX];
else else
cd->_curPos-=8; cd->_curPos-=8;
cameraMoved(); cameraMoved();
@ -1353,7 +1506,7 @@ void Scumm::moveCamera() {
t = (actorx>>3) - _screenStartStrip; t = (actorx>>3) - _screenStartStrip;
if (t < cd->_leftTrigger || t > cd->_rightTrigger) { if (t < cd->_leftTrigger || t > cd->_rightTrigger) {
if (vm.vars[VAR_CAMERA_FAST]) { if (_vars[VAR_CAMERA_FAST]) {
if (t > 35) if (t > 35)
cd->_destPos = actorx + 80; cd->_destPos = actorx + 80;
if (t < 5) if (t < 5)
@ -1368,13 +1521,13 @@ void Scumm::moveCamera() {
cd->_destPos = a->x; cd->_destPos = a->x;
} }
if (cd->_destPos < vm.vars[VAR_CAMERA_MIN]) if (cd->_destPos < _vars[VAR_CAMERA_MIN])
cd->_destPos = vm.vars[VAR_CAMERA_MIN]; cd->_destPos = _vars[VAR_CAMERA_MIN];
if (cd->_destPos > vm.vars[VAR_CAMERA_MAX]) if (cd->_destPos > _vars[VAR_CAMERA_MAX])
cd->_destPos = vm.vars[VAR_CAMERA_MAX]; cd->_destPos = _vars[VAR_CAMERA_MAX];
if (vm.vars[VAR_CAMERA_FAST]) { if (_vars[VAR_CAMERA_FAST]) {
cd->_curPos = cd->_destPos; cd->_curPos = cd->_destPos;
} else { } else {
if (cd->_curPos < cd->_destPos) if (cd->_curPos < cd->_destPos)
@ -1390,9 +1543,9 @@ void Scumm::moveCamera() {
cameraMoved(); cameraMoved();
if (pos != cd->_curPos && vm.vars[VAR_SCROLL_SCRIPT]) { if (pos != cd->_curPos && _vars[VAR_SCROLL_SCRIPT]) {
vm.vars[VAR_CAMERA_CUR_POS] = cd->_curPos; _vars[VAR_CAMERA_CUR_POS] = cd->_curPos;
runScript(vm.vars[VAR_SCROLL_SCRIPT], 0, 0, 0); runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0);
} }
} }
@ -1410,6 +1563,31 @@ void Scumm::cameraMoved() {
virtscr[0].xstart = _screenStartStrip << 3; virtscr[0].xstart = _screenStartStrip << 3;
} }
void Scumm::panCameraTo(int x) {
CameraData *cd = &camera;
cd->_destPos = x;
cd->_mode = 3;
cd->_movingToActor = 0;
}
void Scumm::actorFollowCamera(int act) {
int old = camera._follows;
setCameraFollows(derefActorSafe(act, "actorFollowCamera"));
if (camera._follows != old)
runHook(0);
camera._movingToActor = 0;
}
void Scumm::setCameraAtEx(int at) {
CameraData *cd = &camera;
cd->_mode = 1;
cd->_curPos = at;
setCameraAt(at);
cd->_movingToActor = 0;
}
void Scumm::palManipulate() { void Scumm::palManipulate() {
byte *srcptr, *destptr; byte *srcptr, *destptr;
byte *pal; byte *pal;
@ -1484,7 +1662,7 @@ void Scumm::resetActorBgs() {
+ (top * 40 + _screenStartStrip + i); + (top * 40 + _screenStartStrip + i);
gdi.numLinesToProcess = bottom - top; gdi.numLinesToProcess = bottom - top;
if (gdi.numLinesToProcess) { if (gdi.numLinesToProcess) {
if (vm.vars[VAR_DRAWFLAGS]&2) { if (_vars[VAR_DRAWFLAGS]&2) {
if(hasCharsetMask(i<<3, top, (i+1)<<3, bottom)) if(hasCharsetMask(i<<3, top, (i+1)<<3, bottom))
draw8ColWithMasking(); draw8ColWithMasking();
else else
@ -1510,6 +1688,7 @@ void Scumm::setPalColor(int index, int r, int g, int b) {
_currentPalette[index*3+0] = r>>2; _currentPalette[index*3+0] = r>>2;
_currentPalette[index*3+1] = g>>2; _currentPalette[index*3+1] = g>>2;
_currentPalette[index*3+2] = b>>2; _currentPalette[index*3+2] = b>>2;
setDirtyColors(index,index);
} }
if (_videoMode==0xE) { if (_videoMode==0xE) {
/* TODO: implement this */ /* TODO: implement this */
@ -1567,6 +1746,41 @@ byte Scumm::isMaskActiveAt(int l, int t, int r, int b, byte *mem) {
return false; return false;
} }
byte *Scumm::findPalInPals(byte *pal, int index) {
byte *offs;
uint32 size;
pal = findResource(MKID('WRAP'), pal);
if (pal==NULL)
return NULL;
offs = findResource(MKID('OFFS'),pal);
if (offs==NULL)
return NULL;
size = (READ_BE_UINT32_UNALIGNED(offs+4)-8) >> 2;
if ((uint32)index >= (uint32)size)
return NULL;
return offs + READ_LE_UINT32(offs + 8 + index * sizeof(uint32));
}
void Scumm::setPalette(int palindex) {
byte *pals;
_curPalIndex = palindex;
pals = getResourceAddress(1, _roomResource) + _PALS_offs;
pals = findPalInPals(pals, palindex);
if (pals==NULL)
error("invalid palette %d", palindex);
setPaletteFromPtr(pals);
}
#if 0 #if 0
void Scumm::GDI_drawMouse() { void Scumm::GDI_drawMouse() {
byte *dst,*src,*dstorg; byte *dst,*src,*dstorg;

View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.3 2001/10/16 10:01:47 strigeus
* preliminary DOTT support
*
* Revision 1.2 2001/10/09 18:35:02 strigeus * Revision 1.2 2001/10/09 18:35:02 strigeus
* fixed object parent bug * fixed object parent bug
* fixed some signed/unsigned comparisons * fixed some signed/unsigned comparisons
@ -32,7 +35,7 @@
#include "scumm.h" #include "scumm.h"
bool Scumm::getClass(int obj, int cls) { bool Scumm::getClass(int obj, int cls) {
checkRange(_maxNrObjects-1, 0, obj, "Object %d out of range in getClass"); checkRange(_numGlobalObjects-1, 0, obj, "Object %d out of range in getClass");
cls &= 0x7F; cls &= 0x7F;
checkRange(32,1,cls,"Class %d out of range in getClass"); checkRange(32,1,cls,"Class %d out of range in getClass");
@ -41,7 +44,7 @@ bool Scumm::getClass(int obj, int cls) {
} }
void Scumm::putClass(int obj, int cls, bool set) { void Scumm::putClass(int obj, int cls, bool set) {
checkRange(_maxNrObjects-1, 0, obj, "Object %d out of range in getClass"); checkRange(_numGlobalObjects-1, 0, obj, "Object %d out of range in getClass");
cls &= 0x7F; cls &= 0x7F;
checkRange(32,1,cls,"Class %d out of range in getClass"); checkRange(32,1,cls,"Class %d out of range in getClass");
@ -53,23 +56,23 @@ void Scumm::putClass(int obj, int cls, bool set) {
} }
int Scumm::getOwner(int obj) { int Scumm::getOwner(int obj) {
checkRange(_maxNrObjects-1, 0, obj, "Object %d out of range in getOwner"); checkRange(_numGlobalObjects-1, 0, obj, "Object %d out of range in getOwner");
return _objectFlagTable[obj]&0xF; return _objectFlagTable[obj]&0xF;
} }
void Scumm::putOwner(int act, int owner) { void Scumm::putOwner(int act, int owner) {
checkRange(_maxNrObjects-1, 0, act, "Object %d out of range in putOwner"); checkRange(_numGlobalObjects-1, 0, act, "Object %d out of range in putOwner");
checkRange(15, 0, owner, "Owner %d out of range in putOwner"); checkRange(15, 0, owner, "Owner %d out of range in putOwner");
_objectFlagTable[act] = (_objectFlagTable[act]&0xF0) | owner; _objectFlagTable[act] = (_objectFlagTable[act]&0xF0) | owner;
} }
int Scumm::getState(int act) { int Scumm::getState(int act) {
checkRange(_maxNrObjects-1, 0, act, "Object %d out of range in getState"); checkRange(_numGlobalObjects-1, 0, act, "Object %d out of range in getState");
return _objectFlagTable[act]>>4; return _objectFlagTable[act]>>4;
} }
void Scumm::putState(int act, int state) { void Scumm::putState(int act, int state) {
checkRange(_maxNrObjects-1, 0, act, "Object %d out of range in putState"); checkRange(_numGlobalObjects-1, 0, act, "Object %d out of range in putState");
checkRange(15, 0, state, "State %d out of range in putState"); checkRange(15, 0, state, "State %d out of range in putState");
_objectFlagTable[act] = (_objectFlagTable[act]&0x0F) | (state<<4); _objectFlagTable[act] = (_objectFlagTable[act]&0x0F) | (state<<4);
} }
@ -84,7 +87,7 @@ int Scumm::getObjectIndex(int object) {
return -1; return -1;
} else { } else {
for (i=_numObjectsInRoom; i>0; i--) { for (i=_numObjectsInRoom; i>0; i--) {
if (objs[i].obj_nr==object) if (_objs[i].obj_nr==object)
return i; return i;
} }
return -1; return -1;
@ -102,8 +105,8 @@ int Scumm::whereIsObject(int object) {
} }
for (i=_numObjectsInRoom; i>0; i--) for (i=_numObjectsInRoom; i>0; i--)
if (objs[i].obj_nr == object) { if (_objs[i].obj_nr == object) {
if (objs[i].fl_object_index) if (_objs[i].fl_object_index)
return 4; return 4;
return 1; return 1;
} }
@ -111,7 +114,7 @@ int Scumm::whereIsObject(int object) {
} }
int Scumm::getObjectOrActorXY(int object) { int Scumm::getObjectOrActorXY(int object) {
if (object <= vm.vars[VAR_NUM_ACTOR]) { if (object <= _vars[VAR_NUM_ACTOR]) {
return getActorXYPos(derefActorSafe(object, "getObjectOrActorXY")); return getActorXYPos(derefActorSafe(object, "getObjectOrActorXY"));
} }
switch(whereIsObject(object)) { switch(whereIsObject(object)) {
@ -124,24 +127,56 @@ int Scumm::getObjectOrActorXY(int object) {
return 0; return 0;
} }
#if defined(DOTT)
void Scumm::getObjectXYPos(int object) { void Scumm::getObjectXYPos(int object) {
ObjectData *od = &objs[getObjectIndex(object)]; ObjectData *od = &_objs[getObjectIndex(object)];
int state;
byte *ptr;
ImageHeader *imhd;
int x,y;
AdjustBoxResult abr;
state = getState(object)-1;
if (state<0)
state = 0;
if (od->fl_object_index) {
ptr = getResourceAddress(0xD, od->fl_object_index);
ptr = findResource(MKID('OBIM'), ptr);
} else {
ptr = getResourceAddress(1, _roomResource);
ptr += od->offs_obim_to_room;
}
imhd = (ImageHeader*)findResource2(MKID('IMHD'), ptr);
x = od->x_pos*8 + imhd->hotspot[state].x;
y = od->y_pos*8 + imhd->hotspot[state].y;
abr = adjustXYToBeInBox(0, x, y);
_xPos = abr.x;
_yPos = abr.y;
_dir = od->actordir&3;
}
#else
void Scumm::getObjectXYPos(int object) {
ObjectData *od = &_objs[getObjectIndex(object)];
AdjustBoxResult abr; AdjustBoxResult abr;
abr = adjustXYToBeInBox(0, od->cdhd_10, od->cdhd_12); abr = adjustXYToBeInBox(0, od->cdhd_10, od->cdhd_12);
_xPos = abr.x; _xPos = abr.x;
_yPos = abr.y; _yPos = abr.y;
_dir = od->actordir&3; _dir = od->actordir&3;
} }
#endif
int Scumm::getObjActToObjActDist(int a, int b) { int Scumm::getObjActToObjActDist(int a, int b) {
int x,y; int x,y;
Actor *acta = NULL; Actor *acta = NULL;
Actor *actb = NULL; Actor *actb = NULL;
if (a<=vm.vars[VAR_NUM_ACTOR]) if (a<=_vars[VAR_NUM_ACTOR])
acta = derefActorSafe(a, "getObjActToObjActDist"); acta = derefActorSafe(a, "getObjActToObjActDist");
if (b<=vm.vars[VAR_NUM_ACTOR]) if (b<=_vars[VAR_NUM_ACTOR])
actb = derefActorSafe(b, "getObjActToObjActDist(2)"); actb = derefActorSafe(b, "getObjActToObjActDist(2)");
if (acta && actb && acta->room==actb->room && acta->room && if (acta && actb && acta->room==actb->room && acta->room &&
@ -175,21 +210,21 @@ int Scumm::findObject(int x, int y) {
int i,a,b; int i,a,b;
for (i=1; i<=_numObjectsInRoom; i++) { for (i=1; i<=_numObjectsInRoom; i++) {
if (!objs[i].obj_nr || getClass(objs[i].obj_nr, 32)) if (!_objs[i].obj_nr || getClass(_objs[i].obj_nr, 32))
continue; continue;
b = i; b = i;
do { do {
a = objs[b].parentstate; a = _objs[b].parentstate;
b = objs[b].parent; b = _objs[b].parent;
if (b==0) { if (b==0) {
if (objs[i].x_pos <= (x>>3) && if (_objs[i].x_pos <= (x>>3) &&
objs[i].numstrips + objs[i].x_pos > (x>>3) && _objs[i].numstrips + _objs[i].x_pos > (x>>3) &&
objs[i].y_pos <= (y>>3) && _objs[i].y_pos <= (y>>3) &&
objs[i].height + objs[i].y_pos > (y>>3)) _objs[i].height + _objs[i].y_pos > (y>>3))
return objs[i].obj_nr; return _objs[i].obj_nr;
break; break;
} }
} while ( (objs[b].ownerstate&0xF0) == a); } while ( (_objs[b].ownerstate&0xF0) == a);
} }
return 0; return 0;
} }
@ -203,7 +238,7 @@ void Scumm::drawRoomObjects(int arg) {
return; return;
do { do {
od = &objs[num]; od = &_objs[num];
if (!od->obj_nr || !(od->ownerstate&0xF0)) if (!od->obj_nr || !(od->ownerstate&0xF0))
continue; continue;
@ -213,7 +248,7 @@ void Scumm::drawRoomObjects(int arg) {
drawObject(num, arg); drawObject(num, arg);
break; break;
} }
od = &objs[od->parent]; od = &_objs[od->parent];
} while ((od->ownerstate & 0xF0)==a); } while ((od->ownerstate & 0xF0)==a);
} while (--num); } while (--num);
@ -249,7 +284,7 @@ void Scumm::drawObject(int obj, int arg) {
gdi.virtScreen = 0; gdi.virtScreen = 0;
od = &objs[obj]; od = &_objs[obj];
xpos = od->x_pos; xpos = od->x_pos;
ypos = od->y_pos; ypos = od->y_pos;
@ -308,7 +343,7 @@ void Scumm::loadRoomObjects() {
CodeHeader *cdhd; CodeHeader *cdhd;
checkHeap(); CHECK_HEAP
room = getResourceAddress(1, _roomResource); room = getResourceAddress(1, _roomResource);
roomhdr = (RoomHeader*)findResource(MKID('RMHD'), room); roomhdr = (RoomHeader*)findResource(MKID('RMHD'), room);
@ -318,12 +353,12 @@ void Scumm::loadRoomObjects() {
if (_numObjectsInRoom == 0) if (_numObjectsInRoom == 0)
return; return;
if (_numObjectsInRoom > 200) if (_numObjectsInRoom > _numLocalObjects)
error("More than %d objects in room %d", 200, _roomResource); error("More than %d objects in room %d", _numLocalObjects, _roomResource);
tmp_room = room; tmp_room = room;
od = &objs[1]; od = &_objs[1];
for (i=1; i<=_numObjectsInRoom; i++,od++) { for (i=1; i<=_numObjectsInRoom; i++,od++) {
ptr = findResource(MKID('OBCD'), tmp_room); ptr = findResource(MKID('OBCD'), tmp_room);
if (ptr==NULL) if (ptr==NULL)
@ -353,40 +388,49 @@ void Scumm::loadRoomObjects() {
obim_id = READ_LE_UINT16(&imhd->obj_id); obim_id = READ_LE_UINT16(&imhd->obj_id);
for(j=1; j<=_numObjectsInRoom; j++) { for(j=1; j<=_numObjectsInRoom; j++) {
if (objs[j].obj_nr==obim_id) if (_objs[j].obj_nr==obim_id)
objs[j].offs_obim_to_room = ptr - room; _objs[j].offs_obim_to_room = ptr - room;
} }
tmp_room = NULL; tmp_room = NULL;
} }
od = &objs[1]; od = &_objs[1];
for (i=1; i<=_numObjectsInRoom; i++,od++) { for (i=1; i<=_numObjectsInRoom; i++,od++) {
ptr = room + objs[i].offs_obcd_to_room; ptr = room + _objs[i].offs_obcd_to_room;
cdhd = (CodeHeader*)findResource2(MKID('CDHD'), ptr); cdhd = (CodeHeader*)findResource2(MKID('CDHD'), ptr);
objs[i].obj_nr = READ_LE_UINT16(&cdhd->obj_id); _objs[i].obj_nr = READ_LE_UINT16(&cdhd->obj_id);
objs[i].numstrips = cdhd->w;
objs[i].height = cdhd->h;
objs[i].x_pos = cdhd->x;
objs[i].y_pos = cdhd->y;
#if defined(DOTT)
_objs[i].numstrips = cdhd->w>>3;
_objs[i].height = cdhd->h>>3;
_objs[i].x_pos = cdhd->x>>3;
_objs[i].y_pos = cdhd->y>>3;
#else
_objs[i].numstrips = cdhd->w;
_objs[i].height = cdhd->h;
_objs[i].x_pos = cdhd->x;
_objs[i].y_pos = cdhd->y;
#endif
if (cdhd->flags == 0x80) { if (cdhd->flags == 0x80) {
objs[i].parentstate = 1<<4; _objs[i].parentstate = 1<<4;
} else { } else {
objs[i].parentstate = (cdhd->flags&0xF)<<4; _objs[i].parentstate = (cdhd->flags&0xF)<<4;
} }
objs[i].parent = cdhd->unk1; _objs[i].parent = cdhd->parent;
objs[i].cdhd_10 = READ_LE_UINT16(&cdhd->unk2); #if !defined(DOTT)
objs[i].cdhd_12 = READ_LE_UINT16(&cdhd->unk3); _objs[i].cdhd_10 = READ_LE_UINT16(&cdhd->unk2);
objs[i].actordir = cdhd->unk4; _objs[i].cdhd_12 = READ_LE_UINT16(&cdhd->unk3);
objs[i].fl_object_index = 0; #endif
_objs[i].actordir = cdhd->actordir;
_objs[i].fl_object_index = 0;
} }
checkHeap(); CHECK_HEAP
} }
void Scumm::fixObjectFlags() { void Scumm::fixObjectFlags() {
int i; int i;
ObjectData *od = &objs[1]; ObjectData *od = &_objs[1];
for (i=1; i<=_numObjectsInRoom; i++,od++) { for (i=1; i<=_numObjectsInRoom; i++,od++) {
od->ownerstate = _objectFlagTable[od->obj_nr]; od->ownerstate = _objectFlagTable[od->obj_nr];
} }
@ -412,12 +456,12 @@ void Scumm::clearOwnerOf(int obj) {
if (getOwner(obj)==0xF) { if (getOwner(obj)==0xF) {
i = 0; i = 0;
do { do {
if (objs[i].obj_nr==obj) { if (_objs[i].obj_nr==obj) {
if (!objs[i].fl_object_index) if (!_objs[i].fl_object_index)
return; return;
nukeResource(0xD, objs[i].fl_object_index); nukeResource(0xD, _objs[i].fl_object_index);
objs[i].obj_nr = 0; _objs[i].obj_nr = 0;
objs[i].fl_object_index = 0; _objs[i].fl_object_index = 0;
} }
} while(++i <= _numObjectsInRoom); } while(++i <= _numObjectsInRoom);
return; return;
@ -449,10 +493,10 @@ void Scumm::removeObjectFromRoom(int obj) {
uint16 *ptr; uint16 *ptr;
for(i=1; i<=_numObjectsInRoom; i++) { for(i=1; i<=_numObjectsInRoom; i++) {
if (objs[i].obj_nr==obj) { if (_objs[i].obj_nr==obj) {
if (objs[i].numstrips != 0) { if (_objs[i].numstrips != 0) {
ptr = &actorDrawBits[objs[i].x_pos]; ptr = &actorDrawBits[_objs[i].x_pos];
cnt = objs[i].numstrips; cnt = _objs[i].numstrips;
do { do {
*ptr++ |= 0x8000; *ptr++ |= 0x8000;
} while (--cnt); } while (--cnt);
@ -476,7 +520,7 @@ void Scumm::clearDrawObjectQueue() {
byte *Scumm::getObjOrActorName(int obj) { byte *Scumm::getObjOrActorName(int obj) {
byte *objptr; byte *objptr;
if (obj <= vm.vars[VAR_NUM_ACTOR]) if (obj <= _vars[VAR_NUM_ACTOR])
return getActorName(derefActorSafe(obj, "getObjOrActorName")); return getActorName(derefActorSafe(obj, "getObjOrActorName"));
objptr = getObjectAddress(obj); objptr = getObjectAddress(obj);
@ -492,10 +536,10 @@ uint32 Scumm::getOBCDOffs(int object) {
if ((_objectFlagTable[object]&0xF)!=0xF) if ((_objectFlagTable[object]&0xF)!=0xF)
return 0; return 0;
for (i=_numObjectsInRoom; i>0; i--) { for (i=_numObjectsInRoom; i>0; i--) {
if (objs[i].obj_nr == object) { if (_objs[i].obj_nr == object) {
if (objs[i].fl_object_index!=0) if (_objs[i].fl_object_index!=0)
return 8; return 8;
return objs[i].offs_obcd_to_room; return _objs[i].offs_obcd_to_room;
} }
} }
return 0; return 0;
@ -511,10 +555,10 @@ byte *Scumm::getObjectAddress(int obj) {
} }
} else { } else {
for(i=_numObjectsInRoom; i>0; --i) { for(i=_numObjectsInRoom; i>0; --i) {
if (objs[i].obj_nr==obj) { if (_objs[i].obj_nr==obj) {
if (objs[i].fl_object_index) if (_objs[i].fl_object_index)
return getResourceAddress(0xD, objs[i].fl_object_index)+8; return getResourceAddress(0xD, _objs[i].fl_object_index)+8;
return getResourceAddress(1, _roomResource) + objs[i].offs_obcd_to_room; return getResourceAddress(1, _roomResource) + _objs[i].offs_obcd_to_room;
} }
} }
} }
@ -532,18 +576,18 @@ void Scumm::addObjectToInventory(int obj, int room) {
debug(1,"Adding object %d from room %d into inventory", obj, room); debug(1,"Adding object %d from room %d into inventory", obj, room);
checkHeap(); CHECK_HEAP
if (whereIsObject(obj)==4) { if (whereIsObject(obj)==4) {
i = getObjectIndex(obj); i = getObjectIndex(obj);
ptr = getResourceAddress(0xD, objs[i].fl_object_index) + 64; ptr = getResourceAddress(0xD, _objs[i].fl_object_index) + 64;
size = READ_BE_UINT32_UNALIGNED(ptr+4); size = READ_BE_UINT32_UNALIGNED(ptr+4);
slot = getInventorySlot(); slot = getInventorySlot();
_inventory[slot] = obj; _inventory[slot] = obj;
createResource(5, slot, size); createResource(5, slot, size);
ptr = getResourceAddress(0xD, objs[i].fl_object_index) + 64; ptr = getResourceAddress(0xD, _objs[i].fl_object_index) + 64;
memcpy(getResourceAddress(5, slot), ptr, size); memcpy(getResourceAddress(5, slot), ptr, size);
checkHeap(); CHECK_HEAP
return; return;
} }
ensureResourceLoaded(1, room); ensureResourceLoaded(1, room);
@ -569,7 +613,7 @@ void Scumm::addObjectToInventory(int obj, int room) {
createResource(5, slot, size); createResource(5, slot, size);
obcdptr = getResourceAddress(1, room) + cdoffs; obcdptr = getResourceAddress(1, room) + cdoffs;
memcpy(getResourceAddress(5,slot),obcdptr,size); memcpy(getResourceAddress(5,slot),obcdptr,size);
checkHeap(); CHECK_HEAP
return; return;
} }
tmp_roomptr = NULL; tmp_roomptr = NULL;
@ -587,3 +631,131 @@ int Scumm::getInventorySlot() {
error("Inventory full, %d max items", _maxInventoryItems); error("Inventory full, %d max items", _maxInventoryItems);
} }
void Scumm::setOwnerOf(int obj, int owner) {
ScriptSlot *ss;
if (owner==0) {
clearOwnerOf(obj);
ss = &vm.slot[_currentScript];
if (ss->type==0 && _inventory[ss->number]==obj) {
putOwner(obj, 0);
runHook(0);
stopObjectCode();
return;
}
}
putOwner(obj, owner);
runHook(0);
}
int Scumm::getObjX(int obj) {
if (obj <= _vars[VAR_NUM_ACTOR]) {
return derefActorSafe(obj,"getObjX")->x;
} else {
if (whereIsObject(obj)==-1)
return -1;
getObjectOrActorXY(obj);
return _xPos;
}
}
int Scumm::getObjY(int obj) {
if (obj <= _vars[VAR_NUM_ACTOR]) {
return derefActorSafe(obj,"getObjY")->y;
} else {
if (whereIsObject(obj)==-1)
return -1;
getObjectOrActorXY(obj);
return _yPos;
}
}
int Scumm::getObjDir(int obj) {
if (obj <= _vars[VAR_NUM_ACTOR]) {
return derefActorSafe(obj,"getObjDir")->facing;
} else {
getObjectXYPos(obj);
return _dir;
}
}
int Scumm::findInventory(int owner, int index) {
int count = 1, i, obj;
for (i=0; i!=_maxInventoryItems; i++) {
obj = _inventory[i];
if (obj && getOwner(obj)==owner && count++ == index)
return obj;
}
return 0;
}
int Scumm::getInventoryCount(int owner) {
int i,obj;
int count = 0;
for (i=0; i!=_maxInventoryItems; i++) {
obj = _inventory[i];
if (obj && getOwner(obj) == owner)
count++;
}
return count;
}
#if defined(DOTT)
void Scumm::setObjectState(int obj, int state, int x, int y) {
int i;
i = getObjectIndex(obj);
if (i==-1)
return;
if (x != -1) {
_objs[i].x_pos = x;
_objs[i].x_pos = y;
}
addObjectToDrawQue(i);
putState(obj, state);
}
static int getDist(int x, int y, int x2, int y2) {
int a = abs(y-y2);
int b = abs(x-x2);
if (a>b)
return a;
return b;
}
int Scumm::getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e, int f) {
int i,j;
int x,y;
int x2,y2;
j = i = 0xFF;
if (is_obj_1) {
if (getObjectOrActorXY(b)==-1)
return -1;
if (b < _vars[VAR_NUM_ACTOR])
i = derefActorSafe(b, "unkObjProc1")->scalex;
x = _xPos;
y = _yPos;
} else {
x = b;
y = c;
}
if (is_obj_2) {
if (getObjectOrActorXY(e)==-1)
return -1;
if (e < _vars[VAR_NUM_ACTOR])
j = derefActorSafe(e, "unkObjProc1(2)")->scalex;
x2 = _xPos;
y2 = _yPos;
} else {
x2 = e;
y2 = f;
}
return getDist(x,y,x2,y2) * 0xFF / ((i + j)>>1);
}
#endif

View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.3 2001/10/16 10:01:47 strigeus
* preliminary DOTT support
*
* Revision 1.2 2001/10/10 10:02:33 strigeus * Revision 1.2 2001/10/10 10:02:33 strigeus
* alternative mouse cursor * alternative mouse cursor
* basic save&load * basic save&load
@ -164,6 +167,7 @@ void Scumm::askForDisk() {
error("askForDisk: not yet implemented"); error("askForDisk: not yet implemented");
} }
#if !defined(DOTT)
void Scumm::readIndexFile(int mode) { void Scumm::readIndexFile(int mode) {
uint32 blocktype,itemsize; uint32 blocktype,itemsize;
@ -192,18 +196,18 @@ void Scumm::readIndexFile(int mode) {
break; break;
case MKID('DOBJ'): case MKID('DOBJ'):
_maxNrObjects = fileReadWordLE(); _numGlobalObjects = fileReadWordLE();
_objectFlagTable = (byte*)alloc(_maxNrObjects); _objectFlagTable = (byte*)alloc(_numGlobalObjects);
if (mode==1) { if (mode==1) {
fileSeek(_fileHandle, itemsize - 10, 1); fileSeek(_fileHandle, itemsize - 10, 1);
break; break;
} }
_classData = (uint32*)alloc(_maxNrObjects * sizeof(uint32)); _classData = (uint32*)alloc(_numGlobalObjects * sizeof(uint32));
fileRead(_fileHandle, _objectFlagTable, _maxNrObjects); fileRead(_fileHandle, _objectFlagTable, _numGlobalObjects);
fileRead(_fileHandle, _classData, _maxNrObjects * sizeof(uint32)); fileRead(_fileHandle, _classData, _numGlobalObjects * sizeof(uint32));
#if defined(SCUMM_BIG_ENDIAN) #if defined(SCUMM_BIG_ENDIAN)
for (i=0; i<_maxNrObjects; i++) for (i=0; i<_numGlobalObjects; i++)
_classData[i] = FROM_LE_32(_classData[i]); _classData[i] = FROM_LE_32(_classData[i]);
#endif #endif
break; break;
@ -239,7 +243,7 @@ void Scumm::readIndexFile(int mode) {
case MKID('DSOU'): case MKID('DSOU'):
readResTypeList(4,MKID('SOUN'),"sound"); readResTypeList(4,MKID('SOUN'),"sound");
break; break;
default: default:
error("Bad ID %c%c%c%c found in directory!", blocktype&0xFF, blocktype>>8, blocktype>>16, blocktype>>24); error("Bad ID %c%c%c%c found in directory!", blocktype&0xFF, blocktype>>8, blocktype>>16, blocktype>>24);
return; return;
@ -253,27 +257,147 @@ void Scumm::readIndexFile(int mode) {
openRoom(-1); openRoom(-1);
_numGlobalScriptsUsed = _maxScripts; _numGlobalScripts = _maxScripts;
_dynamicRoomOffsets = true; _dynamicRoomOffsets = true;
} }
#else
void Scumm::readIndexFile() {
uint32 blocktype,itemsize;
int numblock = 0;
int num;
debug(9, "readIndexFile()");
openRoom(-1);
openRoom(0);
while (1) {
blocktype = fileReadDword();
if (fileReadFailed(_fileHandle))
break;
itemsize = fileReadDwordBE();
numblock++;
switch(blocktype) {
case MKID('DCHR'):
readResTypeList(6,MKID('CHAR'),"charset");
break;
case MKID('DOBJ'):
num = fileReadWordLE();
assert(num == _numGlobalObjects);
fileRead(_fileHandle, _objectFlagTable, num);
fileRead(_fileHandle, _classData, num * sizeof(uint32));
#if defined(SCUMM_BIG_ENDIAN)
for (i=0; i<_numGlobalObjects; i++)
_classData[i] = FROM_LE_32(_classData[i]);
#endif
break;
case MKID('RNAM'):
fileSeek(_fileHandle, itemsize-8,1);
break;
case MKID('DROO'):
readResTypeList(1,MKID('ROOM'),"room");
break;
case MKID('DSCR'):
readResTypeList(2,MKID('SCRP'),"script");
break;
case MKID('DCOS'):
readResTypeList(3,MKID('COST'),"costume");
break;
case MKID('MAXS'):
readMAXS();
break;
case MKID('DSOU'):
readResTypeList(4,MKID('SOUN'),"sound");
break;
case MKID('AARY'):
readArrayFromIndexFile();
break;
default:
error("Bad ID %c%c%c%c found in directory!", blocktype&0xFF, blocktype>>8, blocktype>>16, blocktype>>24);
return;
}
}
clearFileReadFailed(_fileHandle);
if (numblock!=9)
error("Not enough blocks read from directory");
openRoom(-1);
}
#endif
#if defined(DOTT)
void Scumm::readArrayFromIndexFile() {
int num;
int a,b,c;
while ((num = fileReadWordLE()) != 0) {
a = fileReadWordLE();
b = fileReadWordLE();
c = fileReadWordLE();
if (c==1)
defineArray(num, 1, a, b);
else
defineArray(num, 5, a, b);
}
}
#endif
#if defined(DOTT)
void Scumm::readResTypeList(int id, uint32 tag, const char *name) {
int num,i;
debug(9, "readResTypeList(%d,%x,%s)",id,FROM_LE_32(tag),name);
num = fileReadWordLE();
assert(num == res.num[id]);
fileRead(_fileHandle, res.roomno[id], num*sizeof(uint8));
fileRead(_fileHandle, res.roomoffs[id], num*sizeof(uint32));
#if defined(SCUMM_BIG_ENDIAN)
for (i=0; i<num; i++)
res.roomoffs[id][i] = FROM_LE_32(res.roomoffs[id][i]);
#endif
}
#else
void Scumm::readResTypeList(int id, uint32 tag, const char *name) { void Scumm::readResTypeList(int id, uint32 tag, const char *name) {
int num; int num;
#if defined(SCUMM_BIG_ENDIAN)
int i; int i;
#endif
debug(9, "readResTypeList(%d,%x,%s)",id,FROM_LE_32(tag),name); debug(9, "readResTypeList(%d,%x,%s)",id,FROM_LE_32(tag),name);
num = fileReadWordLE(); num = fileReadWordLE();
if (num>0xFF) { if (num>=0xFF) {
error("Too many %ss (%d) in directory", name, num); error("Too many %ss (%d) in directory", name, num);
} }
allocResTypeData(id, tag, num, name, 1); allocResTypeData(id, tag, num, name, 1);
fileRead(_fileHandle, res.roomno[id], num); fileRead(_fileHandle, res.roomno[id], num*sizeof(uint8));
fileRead(_fileHandle, res.roomoffs[id], num*sizeof(uint32)); fileRead(_fileHandle, res.roomoffs[id], num*sizeof(uint32));
#if defined(SCUMM_BIG_ENDIAN) #if defined(SCUMM_BIG_ENDIAN)
@ -282,8 +406,16 @@ void Scumm::readResTypeList(int id, uint32 tag, const char *name) {
#endif #endif
} }
#endif
void Scumm::allocResTypeData(int id, uint32 tag, int num, const char *name, int mode) { void Scumm::allocResTypeData(int id, uint32 tag, int num, const char *name, int mode) {
debug(9, "allocResTypeData(%d,%x,%d,%s,%d)",id,FROM_LE_32(tag),num,name,mode); debug(9, "allocResTypeData(%d,%x,%d,%s,%d)",id,FROM_LE_32(tag),num,name,mode);
assert(id>=0 && id<sizeof(res.mode)/sizeof(res.mode[0]));
if (num>=512) {
error("Too many %ss (%d) in directory", name, num);
}
res.mode[id] = mode; res.mode[id] = mode;
res.num[id] = num; res.num[id] = num;
res.tags[id] = tag; res.tags[id] = tag;
@ -336,7 +468,7 @@ void Scumm::ensureResourceLoaded(int type, int i) {
loadResource(type, i); loadResource(type, i);
if (type==1 && i==_roomResource) if (type==1 && i==_roomResource)
vm.vars[VAR_ROOM_FLAG] = 1; _vars[VAR_ROOM_FLAG] = 1;
} }
int Scumm::loadResource(int type, int index) { int Scumm::loadResource(int type, int index) {
@ -436,7 +568,6 @@ int Scumm::readSoundResource(int type, int index) {
return 0; return 0;
} }
int Scumm::getResourceRoomNr(int type, int index) { int Scumm::getResourceRoomNr(int type, int index) {
if (type==1) if (type==1)
return index; return index;
@ -448,7 +579,7 @@ byte *Scumm::getResourceAddress(int type, int index) {
debug(9, "getResourceAddress(%d,%d)", type, index); debug(9, "getResourceAddress(%d,%d)", type, index);
checkHeap(); CHECK_HEAP
validateResource("getResourceAddress", type, index); validateResource("getResourceAddress", type, index);
@ -473,7 +604,7 @@ void Scumm::setResourceFlags(int type, int index, byte flag) {
byte *Scumm::createResource(int type, int index, uint32 size) { byte *Scumm::createResource(int type, int index, uint32 size) {
byte *ptr; byte *ptr;
checkHeap(); CHECK_HEAP
debug(9, "createResource(%d,%d,%d)", type, index,size); debug(9, "createResource(%d,%d,%d)", type, index,size);
@ -483,7 +614,7 @@ byte *Scumm::createResource(int type, int index, uint32 size) {
validateResource("allocating", type, index); validateResource("allocating", type, index);
nukeResource(type, index); nukeResource(type, index);
checkHeap(); CHECK_HEAP
ptr = (byte*)alloc(size + sizeof(ResHeader)); ptr = (byte*)alloc(size + sizeof(ResHeader));
if (ptr==NULL) { if (ptr==NULL) {
@ -509,7 +640,7 @@ void Scumm::nukeResource(int type, int index) {
debug(9, "nukeResource(%d,%d)", type, index); debug(9, "nukeResource(%d,%d)", type, index);
checkHeap(); CHECK_HEAP
assert( res.address[type] ); assert( res.address[type] );
assert( index>=0 && index < res.num[type]); assert( index>=0 && index < res.num[type]);
@ -607,22 +738,10 @@ void Scumm::loadPtrToResource(int type, int resindex, byte *source) {
int i,len; int i,len;
nukeResource(type, resindex); nukeResource(type, resindex);
if (!source) {
ptr = _scriptPointer;
} else {
ptr = source;
}
len = 0; len = getStringLen(source);
do {
i = *ptr++;
if (!i) break;
len++;
if (i==0xFF)
ptr += 3, len += 3;
} while (1);
if (++len <= 1) if (len <= 1)
return; return;
alloced = createResource(type, resindex, len); alloced = createResource(type, resindex, len);
@ -648,7 +767,57 @@ void Scumm::unkHeapProc2(int a, int b) {
} }
void Scumm::unkResProc(int a, int b) { void Scumm::unkResProc(int a, int b) {
error("unkResProc:not implemented"); warning("unkResProc:not implemented");
} }
#if defined(DOTT)
void Scumm::readMAXS() {
_numVariables = fileReadWordLE();
fileReadWordLE();
_numBitVariables = fileReadWordLE();
_numLocalObjects = fileReadWordLE();
_numArray = fileReadWordLE();
fileReadWordLE();
_numVerbs = fileReadWordLE();
_numFlObject = fileReadWordLE();
_numInventory = fileReadWordLE();
_numRooms = fileReadWordLE();
_numScripts = fileReadWordLE();
_numSounds = fileReadWordLE();
_numCharsets = fileReadWordLE();
_numCostumes = fileReadWordLE();
_numGlobalObjects = fileReadWordLE();
allocResTypeData(3, MKID('COST'), _numCostumes, "costume", 1);
allocResTypeData(1, MKID('ROOM'), _numRooms, "room", 1);
allocResTypeData(4, MKID('SOUN'), _numSounds, "sound", 1);
allocResTypeData(2, MKID('SCRP'), _numScripts, "script", 1);
allocResTypeData(6, MKID('CHAR'), _numCharsets, "charset", 1);
allocResTypeData(5, MKID('NONE'), _numInventory, "inventory", 0);
allocResTypeData(8, MKID('NONE'), _numVerbs,"verb", 0);
allocResTypeData(7, MKID('NONE'), _numArray,"array", 0);
allocResTypeData(13, MKID('NONE'),_numFlObject,"flobject", 0);
allocResTypeData(12,MKID('NONE'),10, "temp", 0);
allocResTypeData(11,MKID('NONE'),5, "scale table", 0);
allocResTypeData(9, MKID('NONE'),13,"actor name", 0);
allocResTypeData(10, MKID('NONE'),10,"buffer", 0);
allocResTypeData(14, MKID('NONE'),10,"boxes", 0);
allocResTypeData(16, MKID('NONE'),50,"new name", 0);
_objectFlagTable = (byte*)alloc(_numGlobalObjects);
_inventory = (uint16*)alloc(_numInventory * sizeof(uint16));
_arrays = (byte*)alloc(_numArray);
_verbs = (VerbSlot*)alloc(_numVerbs * sizeof(VerbSlot));
_objs = (ObjectData*)alloc(_numLocalObjects * sizeof(ObjectData));
_vars = (int16*)alloc(_numVariables * sizeof(int16));
_bitVars = (byte*)alloc(_numBitVariables >> 3);
_newNames = (uint16*)alloc(50 * sizeof(uint16));
_classData = (uint32*)alloc(_numGlobalObjects * sizeof(uint32));
_numGlobalScripts = 200;
_dynamicRoomOffsets = 1;
}
#endif

View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.3 2001/10/16 10:01:47 strigeus
* preliminary DOTT support
*
* Revision 1.2 2001/10/10 10:02:33 strigeus * Revision 1.2 2001/10/10 10:02:33 strigeus
* alternative mouse cursor * alternative mouse cursor
* basic save&load * basic save&load
@ -31,10 +34,25 @@
#include "stdafx.h" #include "stdafx.h"
#include "scumm.h" #include "scumm.h"
struct SaveGameHeader {
uint32 type;
uint32 size;
uint32 ver;
};
bool Scumm::saveState(const char *filename) { bool Scumm::saveState(const char *filename) {
FILE *out = fopen(filename,"wb"); FILE *out = fopen(filename,"wb");
SaveGameHeader hdr;
if (out==NULL) if (out==NULL)
return false; return false;
hdr.type = MKID('SCVM');
hdr.size = 0;
hdr.ver = 1;
fwrite(&hdr, sizeof(hdr), 1, out);
saveOrLoad(out,true); saveOrLoad(out,true);
fclose(out); fclose(out);
debug(1,"State saved as '%s'", filename); debug(1,"State saved as '%s'", filename);
@ -44,11 +62,25 @@ bool Scumm::saveState(const char *filename) {
bool Scumm::loadState(const char *filename) { bool Scumm::loadState(const char *filename) {
FILE *out = fopen(filename,"rb"); FILE *out = fopen(filename,"rb");
int i,j; int i,j;
SaveGameHeader hdr;
if (out==NULL) if (out==NULL)
return false; return false;
fread(&hdr, sizeof(hdr), 1, out);
if (hdr.type != MKID('SCVM')) {
warning("Invalid savegame '%s'", filename);
fclose(out);
return false;
}
if (hdr.ver != 1) {
warning("Invalid version of '%s'", filename);
fclose(out);
return false;
}
checkHeap(); CHECK_HEAP
openRoom(-1); openRoom(-1);
memset(_inventory, 0, sizeof(_inventory)); memset(_inventory, 0, sizeof(_inventory));
@ -74,7 +106,7 @@ bool Scumm::loadState(const char *filename) {
initBGBuffers(); initBGBuffers();
checkHeap(); CHECK_HEAP
debug(1,"State loaded from '%s'", filename); debug(1,"State loaded from '%s'", filename);
@ -95,10 +127,10 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKLINE(ObjectData,cdhd_10,sleUint16), MKLINE(ObjectData,cdhd_10,sleUint16),
MKLINE(ObjectData,cdhd_12,sleUint16), MKLINE(ObjectData,cdhd_12,sleUint16),
MKLINE(ObjectData,obj_nr,sleUint16), MKLINE(ObjectData,obj_nr,sleUint16),
MKLINE(ObjectData,x_pos,sleByte), MKLINE(ObjectData,x_pos,sleInt16),
MKLINE(ObjectData,y_pos,sleByte), MKLINE(ObjectData,y_pos,sleInt16),
MKLINE(ObjectData,numstrips,sleByte), MKLINE(ObjectData,numstrips,sleUint16),
MKLINE(ObjectData,height,sleByte), MKLINE(ObjectData,height,sleUint16),
MKLINE(ObjectData,actordir,sleByte), MKLINE(ObjectData,actordir,sleByte),
MKLINE(ObjectData,parentstate,sleByte), MKLINE(ObjectData,parentstate,sleByte),
MKLINE(ObjectData,parent,sleByte), MKLINE(ObjectData,parent,sleByte),
@ -116,13 +148,13 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKLINE(Actor,elevation,sleInt16), MKLINE(Actor,elevation,sleInt16),
MKLINE(Actor,width,sleUint16), MKLINE(Actor,width,sleUint16),
MKLINE(Actor,facing,sleByte), MKLINE(Actor,facing,sleByte),
MKLINE(Actor,costume,sleByte), MKLINE(Actor,costume,sleUint16),
MKLINE(Actor,room,sleByte), MKLINE(Actor,room,sleByte),
MKLINE(Actor,talkColor,sleByte), MKLINE(Actor,talkColor,sleByte),
MKLINE(Actor,scalex,sleByte), MKLINE(Actor,scalex,sleByte),
MKLINE(Actor,scaley,sleByte), MKLINE(Actor,scaley,sleByte),
MKLINE(Actor,charset,sleByte), MKLINE(Actor,charset,sleByte),
MKLINE(Actor,sound,sleByte), MKARRAY(Actor,sound[0],sleByte, 8),
MKLINE(Actor,newDirection,sleByte), MKLINE(Actor,newDirection,sleByte),
MKLINE(Actor,moving,sleByte), MKLINE(Actor,moving,sleByte),
MKLINE(Actor,ignoreBoxes,sleByte), MKLINE(Actor,ignoreBoxes,sleByte),
@ -147,6 +179,10 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKLINE(Actor,needBgReset,sleByte), MKLINE(Actor,needBgReset,sleByte),
MKLINE(Actor,costumeNeedsInit,sleByte), MKLINE(Actor,costumeNeedsInit,sleByte),
MKLINE(Actor,new_1,sleInt16),
MKLINE(Actor,new_2,sleInt16),
MKLINE(Actor,new_3,sleByte),
MKLINE(Actor,walkdata.destx,sleInt16), MKLINE(Actor,walkdata.destx,sleInt16),
MKLINE(Actor,walkdata.desty,sleInt16), MKLINE(Actor,walkdata.desty,sleInt16),
MKLINE(Actor,walkdata.destbox,sleByte), MKLINE(Actor,walkdata.destbox,sleByte),
@ -203,14 +239,14 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKLINE(Scumm,_IM00_offs,sleUint32), MKLINE(Scumm,_IM00_offs,sleUint32),
MKLINE(Scumm,_CLUT_offs,sleUint32), MKLINE(Scumm,_CLUT_offs,sleUint32),
MKLINE(Scumm,_EPAL_offs,sleUint32), MKLINE(Scumm,_EPAL_offs,sleUint32),
MKLINE(Scumm,_PALS_offs,sleUint32),
MKLINE(Scumm,_curPalIndex,sleByte),
MKLINE(Scumm,_currentRoom,sleByte), MKLINE(Scumm,_currentRoom,sleByte),
MKLINE(Scumm,_roomResource,sleByte), MKLINE(Scumm,_roomResource,sleByte),
MKLINE(Scumm,_numObjectsInRoom,sleByte), MKLINE(Scumm,_numObjectsInRoom,sleByte),
MKLINE(Scumm,_currentScript,sleByte), MKLINE(Scumm,_currentScript,sleByte),
MKARRAY(Scumm,_localScriptList[0],sleUint32,0x39), MKARRAY(Scumm,_localScriptList[0],sleUint32,0x39),
MKARRAY(Scumm,vm.vars[0],sleUint16,801),
MKARRAY(Scumm,vm.localvar[0],sleUint16,20*17), MKARRAY(Scumm,vm.localvar[0],sleUint16,20*17),
MKARRAY(Scumm,vm.bitvars[0],sleByte,256),
MKARRAY(Scumm,_resourceMapper[0],sleByte,128), MKARRAY(Scumm,_resourceMapper[0],sleByte,128),
MKARRAY(Scumm,charset._colorMap[0],sleByte,16), MKARRAY(Scumm,charset._colorMap[0],sleByte,16),
MKARRAY(Scumm,_charsetData[0][0],sleByte,10*16), MKARRAY(Scumm,_charsetData[0][0],sleByte,10*16),
@ -238,12 +274,6 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKLINE(Scumm,_numInMsgStack,sleInt16), MKLINE(Scumm,_numInMsgStack,sleInt16),
MKLINE(Scumm,_sentenceIndex,sleByte), MKLINE(Scumm,_sentenceIndex,sleByte),
MKARRAY(Scumm,_sentenceTab[0],sleByte,6),
MKARRAY(Scumm,_sentenceTab2[0],sleByte,6),
MKARRAY(Scumm,_sentenceTab3[0],sleUint16,6),
MKARRAY(Scumm,_sentenceTab4[0],sleUint16,6),
MKARRAY(Scumm,_sentenceTab5[0],sleByte,6),
MKLINE(Scumm,vm.cutSceneStackPointer,sleByte), MKLINE(Scumm,vm.cutSceneStackPointer,sleByte),
MKARRAY(Scumm,vm.cutScenePtr[0],sleUint32,5), MKARRAY(Scumm,vm.cutScenePtr[0],sleUint32,5),
MKARRAY(Scumm,vm.cutSceneScript[0],sleByte,5), MKARRAY(Scumm,vm.cutSceneScript[0],sleByte,5),
@ -256,7 +286,6 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKLINE(Scumm,_cursorState,sleByte), MKLINE(Scumm,_cursorState,sleByte),
MKLINE(Scumm,gdi.unk4,sleByte), MKLINE(Scumm,gdi.unk4,sleByte),
MKLINE(Scumm,gdi.currentCursor,sleByte), MKLINE(Scumm,gdi.currentCursor,sleByte),
// MKLINE(Scumm,gdi.unk3,sleByte),
MKLINE(Scumm,dseg_4F8A,sleUint16), MKLINE(Scumm,dseg_4F8A,sleUint16),
MKLINE(Scumm,_switchRoomEffect,sleByte), MKLINE(Scumm,_switchRoomEffect,sleByte),
@ -264,37 +293,13 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKLINE(Scumm,_switchRoomEffect2,sleByte), MKLINE(Scumm,_switchRoomEffect2,sleByte),
MKLINE(Scumm,_BgNeedsRedraw,sleByte), MKLINE(Scumm,_BgNeedsRedraw,sleByte),
MKARRAY(Scumm,actorDrawBits[0],sleUint16,160), MKARRAY(Scumm,actorDrawBits[0],sleUint16,200),
MKLINE(Scumm,gdi.transparency,sleByte), MKLINE(Scumm,gdi.transparency,sleByte),
MKARRAY(Scumm,_currentPalette[0],sleByte,768), MKARRAY(Scumm,_currentPalette[0],sleByte,768),
/* virtscr */ /* virtscr */
MKARRAY(Scumm,charset._buffer[0],sleByte,256), MKARRAY(Scumm,charset._buffer[0],sleByte,256),
MKARRAY(Scumm,textslot.x[0],sleInt16,6),
MKARRAY(Scumm,textslot.y[0],sleInt16,6),
MKARRAY(Scumm,textslot.center[0],sleInt16,6),
MKARRAY(Scumm,textslot.overhead[0],sleInt16,6),
MKARRAY(Scumm,textslot.right[0],sleInt16,6),
MKARRAY(Scumm,textslot.color[0],sleInt16,6),
MKARRAY(Scumm,textslot.charset[0],sleInt16,6),
MKARRAY(Scumm,_stringXpos[0],sleInt16,6),
MKARRAY(Scumm,_stringYpos[0],sleInt16,6),
MKARRAY(Scumm,_stringXpos2[0],sleInt16,6),
MKARRAY(Scumm,_stringYpos2[0],sleInt16,6),
MKARRAY(Scumm,_stringCenter[0],sleInt16,6),
MKARRAY(Scumm,_stringOverhead[0],sleUint16,6),
MKARRAY(Scumm,_stringRight[0],sleUint16,6),
MKARRAY(Scumm,_stringColor[0],sleUint16,6),
MKARRAY(Scumm,_stringCharset[0],sleUint16,6),
MKLINE(Scumm,charset._mask_left,sleInt16),
MKLINE(Scumm,charset._mask_top,sleInt16),
MKLINE(Scumm,charset._mask_right,sleInt16),
MKLINE(Scumm,charset._mask_bottom,sleInt16),
MKLINE(Scumm,dseg_3A76,sleUint16), MKLINE(Scumm,dseg_3A76,sleUint16),
MKARRAY(Scumm,_imgBufOffs[0],sleUint16,4), MKARRAY(Scumm,_imgBufOffs[0],sleUint16,4),
@ -327,6 +332,7 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKLINE(ScriptSlot,offs,sleUint32), MKLINE(ScriptSlot,offs,sleUint32),
MKLINE(ScriptSlot,delay,sleInt32), MKLINE(ScriptSlot,delay,sleInt32),
MKLINE(ScriptSlot,number,sleUint16), MKLINE(ScriptSlot,number,sleUint16),
MKLINE(ScriptSlot,newfield,sleUint16),
MKLINE(ScriptSlot,status,sleByte), MKLINE(ScriptSlot,status,sleByte),
MKLINE(ScriptSlot,type,sleByte), MKLINE(ScriptSlot,type,sleByte),
MKLINE(ScriptSlot,unk1,sleByte), MKLINE(ScriptSlot,unk1,sleByte),
@ -345,6 +351,39 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
MKEND() MKEND()
}; };
const SaveLoadEntry sentenceTabEntries[] = {
MKLINE(SentenceTab,unk5,sleUint8),
MKLINE(SentenceTab,unk2,sleUint8),
MKLINE(SentenceTab,unk4,sleUint16),
MKLINE(SentenceTab,unk3,sleUint16),
MKLINE(SentenceTab,unk,sleUint8),
MKEND()
};
const SaveLoadEntry stringTabEntries[] = {
MKLINE(StringTab,t_xpos,sleInt16),
MKLINE(StringTab,t_ypos,sleInt16),
MKLINE(StringTab,t_center,sleInt16),
MKLINE(StringTab,t_overhead,sleInt16),
MKLINE(StringTab,t_new3,sleInt16),
MKLINE(StringTab,t_right,sleInt16),
MKLINE(StringTab,t_color,sleInt16),
MKLINE(StringTab,t_charset,sleInt16),
MKLINE(StringTab,xpos,sleInt16),
MKLINE(StringTab,ypos,sleInt16),
MKLINE(StringTab,xpos2,sleInt16),
MKLINE(StringTab,ypos2,sleInt16),
MKLINE(StringTab,center,sleInt16),
MKLINE(StringTab,overhead,sleInt16),
MKLINE(StringTab,new_3,sleInt16),
MKLINE(StringTab,right,sleInt16),
MKLINE(StringTab,mask_top,sleInt16),
MKLINE(StringTab,mask_bottom,sleInt16),
MKLINE(StringTab,mask_right,sleInt16),
MKLINE(StringTab,mask_left,sleInt16),
MKEND()
};
int i,j; int i,j;
_saveLoadStream = inout; _saveLoadStream = inout;
@ -355,29 +394,26 @@ void Scumm::saveOrLoad(FILE *inout, bool mode) {
saveLoadEntries(&actor[i],actorEntries); saveLoadEntries(&actor[i],actorEntries);
for (i=0; i<20; i++) for (i=0; i<20; i++)
saveLoadEntries(&vm.slot[i],scriptSlotEntries); saveLoadEntries(&vm.slot[i],scriptSlotEntries);
for (i=0; i<184; i++) for (i=0; i<_numLocalObjects; i++)
saveLoadEntries(&objs[i],objectEntries); saveLoadEntries(&_objs[i],objectEntries);
for (i=0; i<102; i++) for (i=0; i<_numVerbs; i++)
saveLoadEntries(&verbs[i],verbEntries); saveLoadEntries(&_verbs[i],verbEntries);
for (i=0; i<16; i++) for (i=0; i<16; i++)
saveLoadEntries(&vm.nest[i],nestedScriptEntries); saveLoadEntries(&vm.nest[i],nestedScriptEntries);
for (i=0; i<6; i++)
saveLoadEntries(&sentence[i],sentenceTabEntries);
for (i=0; i<6; i++)
saveLoadEntries(&string[i],stringTabEntries);
for (i=1; i<16; i++) for (i=1; i<16; i++)
if (res.mode[i]==0) if (res.mode[i]==0)
for(j=1; j<res.num[i]; j++) for(j=1; j<res.num[i]; j++)
saveLoadResource(i,j); saveLoadResource(i,j);
if (_saveOrLoad) { saveLoadArrayOf(_objectFlagTable, _numGlobalObjects, sizeof(_objectFlagTable[0]), sleByte);
for (i=0; i<_maxNrObjects; i++) { saveLoadArrayOf(_classData, _numGlobalObjects, sizeof(_classData[0]), sleUint32);
saveByte(_objectFlagTable[i]); saveLoadArrayOf(_vars, _numVariables, sizeof(_vars[0]), sleInt16);
saveUint32(_classData[i]); saveLoadArrayOf(_bitVars, _numBitVariables>>8, 1, sleByte);
}
} else {
for (i=0; i<_maxNrObjects; i++) {
_objectFlagTable[i] = loadByte();
_classData[i] = loadUint32();
}
}
} }
void Scumm::saveLoadResource(int type, int index) { void Scumm::saveLoadResource(int type, int index) {
@ -454,6 +490,61 @@ byte Scumm::loadByte() {
return e; return e;
} }
void Scumm::saveLoadArrayOf(void *b, int len, int datasize, byte filetype) {
byte *at = (byte*)b;
uint32 data;
while (--len>=0) {
if (_saveOrLoad) {
/* saving */
if (datasize==1) {
data = *(byte*)at;
at += 1;
} else if (datasize==2) {
data = *(uint16*)at;
at += 2;
} else if (datasize==4) {
data = *(uint32*)at;
at += 4;
} else {
error("saveLoadArrayOf: invalid size %d", datasize);
}
switch(filetype) {
case sleByte: saveByte(data); break;
case sleUint16:
case sleInt16:saveWord(data); break;
case sleInt32:
case sleUint32:saveUint32(data); break;
default:
error("saveLoadArrayOf: invalid filetype %d", filetype);
}
} else {
/* loading */
switch(filetype) {
case sleByte: data = loadByte(); break;
case sleUint16: data = loadWord(); break;
case sleInt16: data = (int16)loadWord(); break;
case sleUint32: data = loadUint32(); break;
case sleInt32: data = (int32)loadUint32(); break;
default:
error("saveLoadArrayOf: invalid filetype %d", filetype);
}
if (datasize==1) {
*(byte*)at = data;
at += 1;
} else if (datasize==2) {
*(uint16*)at = data;
at += 2;
} else if (datasize==4) {
*(uint32*)at = data;
at += 4;
} else {
error("saveLoadArrayOf: invalid size %d", datasize);
}
}
}
}
void Scumm::saveLoadEntries(void *d, const SaveLoadEntry *sle) { void Scumm::saveLoadEntries(void *d, const SaveLoadEntry *sle) {
int replen; int replen;
@ -461,7 +552,6 @@ void Scumm::saveLoadEntries(void *d, const SaveLoadEntry *sle) {
byte *at; byte *at;
int size; int size;
int value; int value;
uint32 data;
while(sle->offs != 0xFFFF) { while(sle->offs != 0xFFFF) {
at = (byte*)d + sle->offs; at = (byte*)d + sle->offs;
@ -474,56 +564,7 @@ void Scumm::saveLoadEntries(void *d, const SaveLoadEntry *sle) {
type&=~128; type&=~128;
} }
sle++; sle++;
saveLoadArrayOf(at, replen, size, type);
do {
if (_saveOrLoad) {
/* saving */
if (size==1) {
data = *(byte*)at;
at += 1;
} else if (size==2) {
data = *(uint16*)at;
at += 2;
} else if (size==4) {
data = *(uint32*)at;
at += 4;
} else {
warning("invalid size %d", size);
}
switch(type) {
case sleByte: saveByte(data); break;
case sleUint16:
case sleInt16:saveWord(data); break;
case sleInt32:
case sleUint32:saveUint32(data); break;
default:
warning("invalid type %d", type);
}
} else {
/* loading */
switch(type) {
case sleByte: data = loadByte(); break;
case sleUint16: data = loadWord(); break;
case sleInt16: data = (int16)loadWord(); break;
case sleUint32: data = loadUint32(); break;
case sleInt32: data = (int32)loadUint32(); break;
default:
warning("invalid type %d", type);
}
if (size==1) {
*(byte*)at = data;
at += 1;
} else if (size==2) {
*(uint16*)at = data;
at += 2;
} else if (size==4) {
*(uint32*)at = data;
at += 4;
} else {
warning("invalid size %d", size);
}
}
} while (--replen);
} }
} }

2584
script.cpp

File diff suppressed because it is too large Load diff

1986
script_v1.cpp Normal file

File diff suppressed because it is too large Load diff

2124
script_v2.cpp Normal file

File diff suppressed because it is too large Load diff

403
scumm.h
View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.8 2001/10/16 10:01:47 strigeus
* preliminary DOTT support
*
* Revision 1.7 2001/10/11 12:07:35 strigeus * Revision 1.7 2001/10/11 12:07:35 strigeus
* Determine caption from file name. * Determine caption from file name.
* *
@ -129,6 +132,7 @@ struct ScriptSlot {
uint32 offs; uint32 offs;
int32 delay; int32 delay;
uint16 number; uint16 number;
uint16 newfield;
byte status; byte status;
byte type; byte type;
byte unk1,unk2,freezeCount,didexec; byte unk1,unk2,freezeCount,didexec;
@ -146,6 +150,25 @@ struct ResHeader {
uint32 size; uint32 size;
}; };
#if defined(DOTT)
class ObjectData {
public:
uint32 offs_obim_to_room;
uint32 offs_obcd_to_room;
uint16 cdhd_10, cdhd_12;
uint16 obj_nr;
int16 x_pos;
int16 y_pos;
uint16 numstrips;
uint16 height;
byte actordir;
byte parent;
byte parentstate;
byte ownerstate;
byte fl_object_index;
byte unk_3;
};
#else
class ObjectData { class ObjectData {
public: public:
uint32 offs_obim_to_room; uint32 offs_obim_to_room;
@ -154,15 +177,16 @@ public:
uint16 obj_nr; uint16 obj_nr;
byte x_pos; byte x_pos;
byte y_pos; byte y_pos;
byte numstrips; uint16 numstrips;
byte height; uint16 height;
byte actordir; byte actordir;
byte parentstate;
byte parent; byte parent;
byte parentstate;
byte ownerstate; byte ownerstate;
byte fl_object_index; byte fl_object_index;
byte unk_3; byte unk_3;
}; };
#endif
struct RoomHeader { struct RoomHeader {
uint32 tag, size; uint32 tag, size;
@ -170,22 +194,43 @@ struct RoomHeader {
uint16 numObjects; uint16 numObjects;
}; };
#if !defined(DOTT)
struct CodeHeader { /* file format */ struct CodeHeader { /* file format */
uint32 id; uint32 id;
uint32 size; uint32 size;
uint16 obj_id; uint16 obj_id;
byte x,y,w,h; byte x,y,w,h;
byte flags; byte flags;
byte unk1; byte parent;
uint16 unk2; uint16 unk2;
uint16 unk3; uint16 unk3;
byte unk4; byte actordir;
}; };
#else
struct CodeHeader { /* file format */
uint32 id;
uint32 size;
uint16 obj_id;
int16 x, y;
uint16 w,h;
byte flags, parent;
uint16 unk2;
uint16 unk3;
byte actordir;
};
#endif
struct ImageHeader { /* file format */ struct ImageHeader { /* file format */
uint32 id; uint32 id;
uint32 size; uint32 size;
uint16 obj_id; uint16 obj_id;
uint16 unk[5];
uint16 img_w;
uint16 img_h;
uint16 unk_2;
struct {
int16 x,y;
} hotspot[15];
}; };
#pragma END_PACK_STRUCTS #pragma END_PACK_STRUCTS
@ -208,6 +253,7 @@ struct SaveLoadEntry {
enum { enum {
sleByte = 1, sleByte = 1,
sleUint8 = 1,
sleInt16 = 2, sleInt16 = 2,
sleUint16 = 3, sleUint16 = 3,
sleInt32 = 4, sleInt32 = 4,
@ -287,6 +333,10 @@ enum ScummVars {
VAR_CUTSCENEEXIT_KEY = 24, VAR_CUTSCENEEXIT_KEY = 24,
VAR_TALKSTOP_KEY = 57, VAR_TALKSTOP_KEY = 57,
VAR_SAVELOADDIALOG_KEY = 50, VAR_SAVELOADDIALOG_KEY = 50,
#if defined(DOTT)
VAR_RANDOM_NR = 118,
#endif
}; };
#define _maxRooms res.num[1] #define _maxRooms res.num[1]
@ -308,6 +358,7 @@ enum ScummVars {
#define _baseScripts res.address[2] #define _baseScripts res.address[2]
#define _baseInventoryItems res.address[5] #define _baseInventoryItems res.address[5]
#define _baseFLObject res.address[13] #define _baseFLObject res.address[13]
#define _baseArrays res.address[7]
#define _roomFileOffsets res.roomoffs[1] #define _roomFileOffsets res.roomoffs[1]
@ -322,7 +373,7 @@ struct CharsetRenderer {
bool _hasMask; bool _hasMask;
int _strLeft, _strRight, _strTop, _strBottom; int _strLeft, _strRight, _strTop, _strBottom;
int _mask_bottom, _mask_right, _mask_top, _mask_left; // int _mask_bottom, _mask_right, _mask_top, _mask_left;
byte _curId; byte _curId;
byte _bufPos; byte _bufPos;
@ -413,11 +464,11 @@ struct Actor {
uint width; uint width;
byte number; byte number;
byte facing; byte facing;
byte costume; uint16 costume;
byte room; byte room;
byte talkColor; byte talkColor;
byte scalex,scaley; byte scalex,scaley;
byte charset,sound; byte charset;
byte newDirection; byte newDirection;
byte moving; byte moving;
byte ignoreBoxes; byte ignoreBoxes;
@ -430,6 +481,9 @@ struct Actor {
byte walkbox; byte walkbox;
byte mask; byte mask;
byte animProgress, animSpeed; byte animProgress, animSpeed;
int16 new_1,new_2;
byte new_3;
byte sound[8];
ActorWalkData walkdata; ActorWalkData walkdata;
CostumeData cost; CostumeData cost;
byte palette[32]; byte palette[32];
@ -442,6 +496,34 @@ struct CameraData {
uint16 _movingToActor; uint16 _movingToActor;
}; };
#define ARRAY_HDR_SIZE 6
struct ArrayHeader {
int16 dim1_size;
int16 type;
int16 dim2_size;
byte data[1];
};
struct SentenceTab {
byte unk5;
byte unk2;
uint16 unk4;
uint16 unk3;
byte unk;
byte pad;
};
struct StringTab {
int16 t_xpos, t_ypos, t_center, t_overhead;
int16 t_new3, t_right, t_color, t_charset;
int16 xpos, ypos;
int16 xpos2,ypos2;
int16 center, overhead;
int16 new_3, right;
int16 color,charset;
int16 mask_top, mask_bottom, mask_right, mask_left;
};
struct Scumm { struct Scumm {
int _lastLoadedRoom; int _lastLoadedRoom;
int _roomResource; int _roomResource;
@ -459,13 +541,41 @@ struct Scumm {
int _keyPressed; int _keyPressed;
uint16 *_inventory;
byte *_arrays;
VerbSlot *_verbs;
ObjectData *_objs;
uint16 *_newNames;
int16 *_vars;
byte *_bitVars;
const OpcodeProc *_opcodes;
byte _curActor;
int _curVerb;
int _curVerbSlot;
int _curPalIndex;
int _numVariables;
int _numBitVariables;
int _numLocalObjects;
int _numGlobalObjects;
int _numArray;
int _numVerbs;
int _numFlObject;
int _numInventory;
int _numRooms;
int _numScripts;
int _numSounds;
int _numCharsets;
int _numCostumes;
uint8 *_roomFileIndexes; uint8 *_roomFileIndexes;
byte *_objectFlagTable; byte *_objectFlagTable;
uint32 *_classData; uint32 *_classData;
byte _numGlobalScriptsUsed; byte _numGlobalScripts;
uint16 _maxNrObjects;
uint16 _numZBuffer; uint16 _numZBuffer;
@ -509,8 +619,6 @@ struct Scumm {
uint32 _localScriptList[0x39]; uint32 _localScriptList[0x39];
uint16 _inventory[0x50];
uint16 _debugMode; uint16 _debugMode;
byte *_messagePtr; byte *_messagePtr;
@ -543,12 +651,13 @@ struct Scumm {
int _numInMsgStack; int _numInMsgStack;
VerbSlot verbs[102]; // VerbSlot verbs[102];
VirtScreen virtscr[4]; VirtScreen virtscr[4];
uint32 _ENCD_offs, _EXCD_offs; uint32 _ENCD_offs, _EXCD_offs;
uint32 _CLUT_offs, _EPAL_offs; uint32 _CLUT_offs, _EPAL_offs;
uint32 _IM00_offs; uint32 _IM00_offs;
uint32 _PALS_offs;
int _drawObjectQueNr; int _drawObjectQueNr;
byte _drawObjectQue[0xC8]; byte _drawObjectQue[0xC8];
@ -556,7 +665,6 @@ struct Scumm {
uint16 _currentDrive; uint16 _currentDrive;
uint16 _soundCardType; uint16 _soundCardType;
uint16 _videoMode; uint16 _videoMode;
uint16 _heapSpace;
byte _mousePresent; byte _mousePresent;
int16 _palManipStart; int16 _palManipStart;
@ -564,19 +672,17 @@ struct Scumm {
int16 _palManipCounter; int16 _palManipCounter;
struct { struct {
byte mode[16]; byte mode[17];
uint16 num[16]; uint16 num[17];
uint32 tags[16]; uint32 tags[17];
const char *name[16]; const char *name[17];
byte **address[16]; byte **address[17];
byte *flags[16]; byte *flags[17];
byte *roomno[16]; byte *roomno[17];
uint32 *roomoffs[16]; uint32 *roomoffs[17];
} res; } res;
struct { struct {
int16 vars[801];
byte bitvars[256];
uint32 cutScenePtr[5]; uint32 cutScenePtr[5];
byte cutSceneScript[5]; byte cutSceneScript[5];
int16 cutSceneData[5]; int16 cutSceneData[5];
@ -591,16 +697,6 @@ struct Scumm {
int16 x,y; int16 x,y;
} mouse; } mouse;
struct {
int16 x[6];
int16 y[6];
int16 center[6];
int16 overhead[6];
int16 right[6];
int16 color[6];
int16 charset[6];
} textslot;
struct { struct {
byte *readPtr; byte *readPtr;
uint16 readOffs; uint16 readOffs;
@ -644,7 +740,7 @@ struct Scumm {
Actor actor[13]; Actor actor[13];
uint16 actorDrawBits[160]; uint16 actorDrawBits[200];
struct { struct {
int upperLeftX; int upperLeftX;
@ -691,12 +787,21 @@ struct Scumm {
uint16 _imgBufOffs[4]; uint16 _imgBufOffs[4];
byte _sentenceIndex; byte _sentenceIndex;
SentenceTab sentence[6];
#if 0
byte _sentenceTab[6]; byte _sentenceTab[6];
byte _sentenceTab2[6]; byte _sentenceTab2[6];
uint16 _sentenceTab3[6]; uint16 _sentenceTab3[6];
uint16 _sentenceTab4[6]; uint16 _sentenceTab4[6];
byte _sentenceTab5[6]; byte _sentenceTab5[6];
#endif
StringTab string[6];
#if 0
// int _stringXPos[4], _stringYPos[4];
uint16 _stringOverhead[6]; uint16 _stringOverhead[6];
uint16 _stringCenter[6]; uint16 _stringCenter[6];
uint16 _stringRight[6]; uint16 _stringRight[6];
@ -708,10 +813,11 @@ struct Scumm {
int16 _stringXpos2[6]; int16 _stringXpos2[6];
int16 _stringYpos2[6]; int16 _stringYpos2[6];
#endif
CostumeRenderer cost; CostumeRenderer cost;
ObjectData objs[184]; // ObjectData objs[184];
int16 _soundQuePos; int16 _soundQuePos;
int16 _soundQue[0x100]; int16 _soundQue[0x100];
@ -748,7 +854,7 @@ struct Scumm {
bool _BgNeedsRedraw; bool _BgNeedsRedraw;
int _stringXPos[4], _stringYPos[4];
int16 _localParamList[16]; int16 _localParamList[16];
@ -760,7 +866,7 @@ struct Scumm {
uint16 _lastKeyHit; uint16 _lastKeyHit;
int _scummStackPos; int _scummStackPos;
int16 _scummStack[0x15]; int16 _scummStack[100];
int _maxBoxVertexHeap; int _maxBoxVertexHeap;
byte *_boxMatrixPtr4, *_boxMatrixPtr1, *_boxMatrixPtr3; byte *_boxMatrixPtr4, *_boxMatrixPtr1, *_boxMatrixPtr3;
@ -769,12 +875,14 @@ struct Scumm {
byte *_msgPtrToAdd; byte *_msgPtrToAdd;
OpcodeProc getOpcode(int i) { return _opcodes[i]; }
void openRoom(int room); void openRoom(int room);
void deleteRoomOffsets(); void deleteRoomOffsets();
void readRoomsOffsets(); void readRoomsOffsets();
void askForDisk(); void askForDisk();
void readIndexFile(int i);
bool openResourceFile(const char *filename); bool openResourceFile(const char *filename);
void fileClose(void *file); void fileClose(void *file);
@ -897,6 +1005,7 @@ struct Scumm {
int getVarOrDirectWord(byte mask); int getVarOrDirectWord(byte mask);
int getVarOrDirectByte(byte mask); int getVarOrDirectByte(byte mask);
int readVar(uint var); int readVar(uint var);
void writeVar(uint var, int value);
void getResultPos(); void getResultPos();
void setResult(int result); void setResult(int result);
@ -1004,6 +1113,150 @@ struct Scumm {
void o_walkActorToActor(); void o_walkActorToActor();
void o_walkActorToObject(); void o_walkActorToObject();
void o2_pushByte();
void o2_pushWord();
void o2_pushByteVar();
void o2_pushWordVar();
void o2_invalid();
void o2_byteArrayRead();
void o2_wordArrayRead();
void o2_byteArrayIndexedRead();
void o2_wordArrayIndexedRead();
void o2_dup();
void o2_zero();
void o2_eq();
void o2_neq();
void o2_gt();
void o2_lt();
void o2_le();
void o2_ge();
void o2_add();
void o2_sub();
void o2_mul();
void o2_div();
void o2_land();
void o2_lor();
void o2_kill();
void o2_writeByteVar();
void o2_writeWordVar();
void o2_byteArrayWrite();
void o2_wordArrayWrite();
void o2_byteArrayIndexedWrite();
void o2_wordArrayIndexedWrite();
void o2_byteVarInc();
void o2_wordVarInc();
void o2_byteArrayInc();
void o2_wordArrayInc();
void o2_byteVarDec();
void o2_wordVarDec();
void o2_byteArrayDec();
void o2_wordArrayDec();
void o2_jumpTrue();
void o2_jumpFalse();
void o2_jump();
void o2_startScriptEx();
void o2_startScript();
void o2_startObject();
void o2_setObjectState();
void o2_setObjectXY();
void o2_stopObjectCode();
void o2_endCutscene();
void o2_cutScene();
void o2_stopMusic();
void o2_freezeUnfreeze();
void o2_cursorCommand();
void o2_breakHere();
void o2_ifClassOfIs();
void o2_setClass();
void o2_getState();
void o2_setState();
void o2_setOwner();
void o2_getOwner();
void o2_startSound();
void o2_stopSound();
void o2_startMusic();
void o2_stopObjectScript();
void o2_panCameraTo();
void o2_actorFollowCamera();
void o2_setCameraAt();
void o2_loadRoom();
void o2_stopScript();
void o2_walkActorToObj();
void o2_walkActorTo();
void o2_putActorInRoom();
void o2_putActorAtObject();
void o2_faceActor();
void o2_animateActor();
void o2_doSentence();
void o2_pickupObject();
void o2_loadRoomWithEgo();
void o2_getRandomNumber();
void o2_getRandomNumberRange();
void o2_getActorMoving();
void o2_getScriptRunning();
void o2_getActorRoom();
void o2_getObjectX();
void o2_getObjectY();
void o2_getObjectDir();
void o2_getActorWalkBox();
void o2_getActorCostume();
void o2_findInventory();
void o2_getInventoryCount();
void o2_getVerbFromXY();
void o2_beginOverride();
void o2_endOverride();
void o2_setObjectName();
void o2_isSoundRunning();
void o2_setBoxFlags();
void o2_createBoxMatrix();
void o2_resourceRoutines();
void o2_roomOps();
void o2_actorSet();
void o2_verbOps();
void o2_getActorFromXY();
void o2_findObject();
void o2_pseudoRoom();
void o2_getActorElevation();
void o2_getVerbEntrypoint();
void o2_arrayOps();
void o2_saveRestoreVerbs();
void o2_drawBox();
void o2_getActorWidth();
void o2_wait();
void o2_getActorScaleX();
void o2_getActorAnimCounter1();
void o2_soundKludge();
void o2_isAnyOf();
void o2_quitPauseRestart();
void o2_isActorInBox();
void o2_delay();
void o2_delayLonger();
void o2_delayVeryLong();
void o2_stopSentence();
void o2_print_0();
void o2_print_1();
void o2_print_2();
void o2_print_3();
void o2_printActor();
void o2_printEgo();
void o2_talkActor();
void o2_talkEgo();
void o2_dim();
void o2_runVerbCodeQuick();
void o2_runScriptQuick();
void o2_dim2();
void o2_abs();
void o2_distObjectObject();
void o2_distObjectPt();
void o2_distPtPt();
void o2_dummy_stacklist();
void o2_miscOps();
void o2_breakMaybe();
void o2_pickOneOf();
void o2_pickOneOfDefault();
void soundKludge(int16 *list);
void stopObjectCode(); void stopObjectCode();
void stopObjectScript(int script); void stopObjectScript(int script);
void putActor(Actor *a, int x, int y, byte room); void putActor(Actor *a, int x, int y, byte room);
@ -1148,8 +1401,8 @@ struct Scumm {
void setActorCostume(Actor *a, int c); void setActorCostume(Actor *a, int c);
void loadPtrToResource(int type, int i, byte *ptr); void loadPtrToResource(int type, int i, byte *ptr);
void stackPush(int a); void push(int a);
int stackPop(); int pop();
void walkActorTo(Actor *a, int x, int y, int direction); void walkActorTo(Actor *a, int x, int y, int direction);
@ -1182,7 +1435,7 @@ struct Scumm {
byte *getObjectAddress(int obj); byte *getObjectAddress(int obj);
byte *getObjOrActorName(int obj); byte *getObjOrActorName(int obj);
void clearOwnerOf(int obj); void clearOwnerOf(int obj);
void runVERBCode(int script, int entry, int a, int b, int16 *vars); void runVerbCode(int script, int entry, int a, int b, int16 *vars);
void unkSoundProc1(int a); void unkSoundProc1(int a);
void setVerbObject(int room, int object, int verb); void setVerbObject(int room, int object, int verb);
void unkMessage1(); void unkMessage1();
@ -1207,8 +1460,6 @@ struct Scumm {
int getKeyInput(int a); int getKeyInput(int a);
void convertKeysToClicks(); void convertKeysToClicks();
OpcodeProc getOpcode(int i);
void drawBox(int x, int y, int x2, int y2, int color); void drawBox(int x, int y, int x2, int y2, int color);
void drawMouse(); void drawMouse();
@ -1226,6 +1477,7 @@ struct Scumm {
void saveLoadBytes(void *b, int len); void saveLoadBytes(void *b, int len);
void saveLoadResource(int type, int index); void saveLoadResource(int type, int index);
bool isResourceLoaded(int type, int index); bool isResourceLoaded(int type, int index);
void saveLoadArrayOf(void *b, int len, int datasize, byte filetype);
void saveLoadEntries(void *d, const SaveLoadEntry *sle); void saveLoadEntries(void *d, const SaveLoadEntry *sle);
@ -1256,6 +1508,67 @@ struct Scumm {
void showHelpAndExit(); void showHelpAndExit();
char *getGameName(); char *getGameName();
void setupOpcodes();
void setupOpcodes2();
void endCutscene();
void cutscene(int16 *args);
void setOwnerOf(int obj, int owner);
void panCameraTo(int x);
void actorFollowCamera(int act);
void setCameraAtEx(int at);
void setCursorHotspot2(int x,int y);
void new_unk_1(int a);
void faceActorToObj(int act, int obj);
void animateActor(int act, int anim);
int getScriptRunning(int script);
int getObjX(int obj);
int getObjY(int obj);
int getObjDir(int obj);
int findInventory(int owner, int index);
int getInventoryCount(int owner);
void beginOverride();
void endOverride();
void setPalette(int pal);
void setPaletteFromPtr(byte *ptr);
byte *findPalInPals(byte *pal, int index);
int getStringLen(byte *ptr);
#if defined(DOTT)
void readArrayFromIndexFile();
void readMAXS();
void readIndexFile();
int readArray(int array, int index, int base);
void writeArray(int array, int index, int base, int value);
int getStackList(int16 *args, uint maxnum);
void setObjectState(int obj, int state, int x, int y);
void setStringVars(int i);
void decodeParseString2(int a, int b);
void arrayop_1(int a, byte *ptr);
void copyString(byte *dst, byte *src, int len);
int getArrayId();
void nukeArray(int a);
int defineArray(int a, int b, int c, int d);
int getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e, int f);
void unkMiscOp4(int a, int b, int c, int d);
void unkMiscOp9();
void startManiac();
#else
void readIndexFile(int i);
#endif
}; };
void waitForTimer(Scumm *s); void waitForTimer(Scumm *s);

View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.4 2001/10/16 10:01:47 strigeus
* preliminary DOTT support
*
* Revision 1.3 2001/10/09 18:35:02 strigeus * Revision 1.3 2001/10/09 18:35:02 strigeus
* fixed object parent bug * fixed object parent bug
* fixed some signed/unsigned comparisons * fixed some signed/unsigned comparisons
@ -36,6 +39,13 @@
#pragma warning (disable: 4101) #pragma warning (disable: 4101)
#if defined(CHECK_HEAP)
#undef CHECK_HEAP
#define CHECK_HEAP checkHeap();
#else
#define CHECK_HEAP
#endif
#define SCUMM_LITTLE_ENDIAN #define SCUMM_LITTLE_ENDIAN
#define FORCEINLINE __forceinline #define FORCEINLINE __forceinline
@ -55,8 +65,9 @@ typedef signed long int32;
#elif defined(UNIX) #elif defined(UNIX)
/* need this for the SDL_BYTEORDER define */ #define CHECK_HEAP
/* need this for the SDL_BYTEORDER define */
#include <SDL_byteorder.h> #include <SDL_byteorder.h>
#if SDL_BYTEORDER == SDL_LIL_ENDIAN #if SDL_BYTEORDER == SDL_LIL_ENDIAN
@ -122,6 +133,9 @@ uint32 FORCEINLINE READ_BE_UINT32(void *ptr) {
#define FROM_LE_32(__a__) __a__ #define FROM_LE_32(__a__) __a__
#define FROM_LE_16(__a__) __a__ #define FROM_LE_16(__a__) __a__
#define TO_LE_32(__a__) __a__
#define TO_LE_16(__a__) __a__
#define TO_BE_32(a) ((((a)>>24)&0xFF) | (((a)>>8)&0xFF00) | (((a)<<8)&0xFF0000) | (((a)<<24)&0xFF000000)) #define TO_BE_32(a) ((((a)>>24)&0xFF) | (((a)>>8)&0xFF00) | (((a)<<8)&0xFF0000) | (((a)<<24)&0xFF000000))
#elif defined(SCUMM_BIG_ENDIAN) #elif defined(SCUMM_BIG_ENDIAN)
@ -136,6 +150,9 @@ uint16 FORCEINLINE FROM_LE_16(uint16 a) {
return ((a>>8)&0xFF) + ((a<<8)&0xFF00); return ((a>>8)&0xFF) + ((a<<8)&0xFF00);
} }
#define TO_LE_32 FROM_LE_32
#define TO_LE_16 FROM_LE_16
uint32 FORCEINLINE READ_LE_UINT32(void *ptr) { uint32 FORCEINLINE READ_LE_UINT32(void *ptr) {
byte *b = (byte*)ptr; byte *b = (byte*)ptr;
return (b[3]<<24)+(b[2]<<16)+(b[1]<<8)+(b[0]); return (b[3]<<24)+(b[2]<<16)+(b[1]<<8)+(b[0]);
@ -158,7 +175,6 @@ int FORCEINLINE READ_BE_UINT16_UNALIGNED(void *ptr) {
return (((byte*)ptr)[0]<<8)|((byte*)ptr)[1]; return (((byte*)ptr)[0]<<8)|((byte*)ptr)[1];
} }
uint32 FORCEINLINE READ_BE_UINT32_UNALIGNED(void *ptr) { uint32 FORCEINLINE READ_BE_UINT32_UNALIGNED(void *ptr) {
byte *b = (byte*)ptr; byte *b = (byte*)ptr;
return (b[0]<<24)+(b[1]<<16)+(b[2]<<8)+(b[3]); return (b[0]<<24)+(b[1]<<16)+(b[2]<<8)+(b[3]);

View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.7 2001/10/16 10:01:48 strigeus
* preliminary DOTT support
*
* Revision 1.6 2001/10/11 11:49:51 strigeus * Revision 1.6 2001/10/11 11:49:51 strigeus
* Determine caption from file name. * Determine caption from file name.
* *
@ -44,9 +47,20 @@
#include "stdafx.h" #include "stdafx.h"
#include "scumm.h" #include "scumm.h"
#if !defined(DOTT)
void Scumm::initThings() { void Scumm::initThings() {
readIndexFile(1); readIndexFile(1);
_numVariables = 800;
_numBitVariables = 2048;
_numLocalObjects = 200;
_inventory = (uint16*)alloc(0x50 * sizeof(uint16));
_verbs = (VerbSlot*)alloc(102 * sizeof(VerbSlot));
_objs = (ObjectData*)alloc(200 * sizeof(ObjectData));
_vars = (int16*)alloc(800 * sizeof(int16));
_bitVars = (byte*)alloc(2048 >> 3);
allocResTypeData(5, MKID('NONE'), 0x50, "inventory", 0); allocResTypeData(5, MKID('NONE'), 0x50, "inventory", 0);
allocResTypeData(12,MKID('NONE'),10, "temp", 0); allocResTypeData(12,MKID('NONE'),10, "temp", 0);
allocResTypeData(11,MKID('NONE'),5, "scale table", 0); allocResTypeData(11,MKID('NONE'),5, "scale table", 0);
@ -56,11 +70,19 @@ void Scumm::initThings() {
allocResTypeData(7, MKID('NONE'),0x32,"string", 0); allocResTypeData(7, MKID('NONE'),0x32,"string", 0);
allocResTypeData(13, MKID('NONE'),0x32,"flobject", 0); allocResTypeData(13, MKID('NONE'),0x32,"flobject", 0);
allocResTypeData(14, MKID('NONE'),10,"boxes", 0); allocResTypeData(14, MKID('NONE'),10,"boxes", 0);
readIndexFile(2); readIndexFile(2);
initRandSeeds(); initRandSeeds();
setupOpcodes();
}
#else
void Scumm::initThings() {
setupOpcodes2();
readIndexFile();
} }
#endif
void Scumm::initRandSeeds() { void Scumm::initRandSeeds() {
_randSeed1 = 0xA943DE35; _randSeed1 = 0xA943DE35;
@ -71,7 +93,7 @@ uint Scumm::getRandomNumber(uint max) {
/* TODO: my own random number generator */ /* TODO: my own random number generator */
_randSeed1 = 0xDEADBEEF * (_randSeed1 + 1); _randSeed1 = 0xDEADBEEF * (_randSeed1 + 1);
_randSeed1 = (_randSeed1>>13) | (_randSeed1<<19); _randSeed1 = (_randSeed1>>13) | (_randSeed1<<19);
return _randSeed1%(max+1); return _randSeed1%max;
} }
void Scumm::scummInit() { void Scumm::scummInit() {
@ -79,7 +101,7 @@ void Scumm::scummInit() {
Actor *a; Actor *a;
debug(9, "scummInit"); debug(9, "scummInit");
readIndexFile(3); // readIndexFile(3);
loadCharset(1); loadCharset(1);
initScreens(0, 16, 320, 144); initScreens(0, 16, 320, 144);
@ -91,11 +113,11 @@ void Scumm::scummInit() {
initActor(a, 1); initActor(a, 1);
} }
memset(vm.vars, 0, sizeof(vm.vars)); // memset(vm.vars, 0, sizeof(vm.vars));
memset(vm.bitvars, 0, sizeof(vm.bitvars)); // memset(vm.bitvars, 0, sizeof(vm.bitvars));
_defaultTalkDelay = 60; _defaultTalkDelay = 60;
vm.vars[37] = 4; _vars[VAR_CHARINC] = 4;
_numNestedScripts = 0; _numNestedScripts = 0;
vm.cutSceneStackPointer = 0; vm.cutSceneStackPointer = 0;
@ -104,17 +126,17 @@ void Scumm::scummInit() {
memset(vm.cutSceneData, 0, sizeof(vm.cutSceneData)); memset(vm.cutSceneData, 0, sizeof(vm.cutSceneData));
for (i=0; i<_maxVerbs; i++) { for (i=0; i<_maxVerbs; i++) {
verbs[i].verbid = 0; _verbs[i].verbid = 0;
verbs[i].right = 319; _verbs[i].right = 319;
verbs[i].oldleft = -1; _verbs[i].oldleft = -1;
verbs[i].type = 0; _verbs[i].type = 0;
verbs[i].color = 2; _verbs[i].color = 2;
verbs[i].hicolor = 0; _verbs[i].hicolor = 0;
verbs[i].charset_nr = 1; _verbs[i].charset_nr = 1;
verbs[i].curmode = 0; _verbs[i].curmode = 0;
verbs[i].saveid = 0; _verbs[i].saveid = 0;
verbs[i].center=0; _verbs[i].center=0;
verbs[i].key = 0; _verbs[i].key = 0;
} }
camera._leftTrigger = 10; camera._leftTrigger = 10;
@ -122,14 +144,13 @@ void Scumm::scummInit() {
camera._mode = 0; camera._mode = 0;
camera._follows = 0; camera._follows = 0;
virtscr[0].xstart = 0; virtscr[0].xstart = 0;
vm.vars[9] = 11; _vars[9] = 11;
_lightsValueA = _lightsValueB = 7; _lightsValueA = _lightsValueB = 7;
vm.vars[59] = 3; _vars[59] = 3;
mouse.x = 104; mouse.x = 104;
mouse.y = 56; mouse.y = 56;
@ -149,7 +170,7 @@ void Scumm::scummInit() {
_screenStartStrip = 0; _screenStartStrip = 0;
vm.vars[25] = 0; _vars[25] = 0;
_talkDelay = 0; _talkDelay = 0;
_keepText = false; _keepText = false;
@ -163,12 +184,12 @@ void Scumm::scummInit() {
clearDrawObjectQueue(); clearDrawObjectQueue();
for (i=0; i<6; i++) { for (i=0; i<6; i++) {
textslot.x[i] = 2; string[i].t_xpos = 2;
textslot.y[i] = 5; string[i].t_ypos = 5;
textslot.right[i] = 319; string[i].t_right = 319;
textslot.color[i] = 0xF; string[i].t_color = 0xF;
textslot.center[i] = 0; string[i].t_center = 0;
textslot.charset[i] = 0; string[i].t_charset = 0;
} }
_numInMsgStack = 0; _numInMsgStack = 0;
@ -177,22 +198,22 @@ void Scumm::scummInit() {
initScummVars(); initScummVars();
vm.vars[54] = -0x50; _vars[54] = -0x50;
getGraphicsPerformance(); getGraphicsPerformance();
} }
void Scumm::initScummVars() { void Scumm::initScummVars() {
vm.vars[VAR_CURRENTDRIVE] = _currentDrive; _vars[VAR_CURRENTDRIVE] = _currentDrive;
vm.vars[VAR_FIXEDDISK] = checkFixedDisk(); _vars[VAR_FIXEDDISK] = checkFixedDisk();
vm.vars[VAR_SOUNDCARD] = _soundCardType; _vars[VAR_SOUNDCARD] = _soundCardType;
vm.vars[VAR_VIDEOMODE] = _videoMode; _vars[VAR_VIDEOMODE] = _videoMode;
vm.vars[VAR_HEAPSPACE] = _heapSpace; _vars[VAR_HEAPSPACE] = 600;
vm.vars[VAR_MOUSEPRESENT] = _mousePresent; _vars[VAR_MOUSEPRESENT] = _mousePresent;
vm.vars[VAR_SOUNDPARAM] = _soundParam; _vars[VAR_SOUNDPARAM] = _soundParam;
vm.vars[VAR_SOUNDPARAM2] = _soundParam2; _vars[VAR_SOUNDPARAM2] = _soundParam2;
vm.vars[VAR_SOUNDPARAM3] = _soundParam3; _vars[VAR_SOUNDPARAM3] = _soundParam3;
} }
void Scumm::checkRange(int max, int min, int no, const char *str) { void Scumm::checkRange(int max, int min, int no, const char *str) {
@ -220,33 +241,34 @@ void Scumm::scummMain(int argc, char **argv) {
initThings(); initThings();
scummInit(); scummInit();
vm.vars[VAR_VERSION] = 21; _vars[VAR_VERSION] = 21;
vm.vars[VAR_DEBUGMODE] = _debugMode; _vars[VAR_DEBUGMODE] = _debugMode;
runScript(1,0,0,&_bootParam); runScript(1,0,0,&_bootParam);
_scummTimer = 0; _scummTimer = 0;
do { do {
if (_playBackFile) { if (_playBackFile) {
while ((_scummTimer>>2) < vm.vars[VAR_PLAYBACKTIMER]) {} while ((_scummTimer>>2) < _vars[VAR_PLAYBACKTIMER]) {}
_scummTimer = vm.vars[VAR_PLAYBACKTIMER] << 2; _scummTimer = _vars[VAR_PLAYBACKTIMER] << 2;
} }
CHECK_HEAP
updateScreen(this); updateScreen(this);
vm.vars[VAR_TIMER] = _scummTimer >> 2; _vars[VAR_TIMER] = _scummTimer >> 2;
do { do {
waitForTimer(this); waitForTimer(this);
tmr = _scummTimer >> 2; tmr = _scummTimer >> 2;
if (_fastMode) if (_fastMode)
tmr += 15; tmr += 15;
} while (tmr < vm.vars[VAR_TIMER_NEXT]); } while (tmr < _vars[VAR_TIMER_NEXT]);
_scummTimer = 0; _scummTimer = 0;
vm.vars[VAR_TMR_1] += tmr; _vars[VAR_TMR_1] += tmr;
vm.vars[VAR_TMR_2] += tmr; _vars[VAR_TMR_2] += tmr;
vm.vars[VAR_TMR_3] += tmr; _vars[VAR_TMR_3] += tmr;
vm.vars[VAR_TMR_4] += tmr; _vars[VAR_TMR_4] += tmr;
if (tmr > 15) if (tmr > 15)
tmr = 15; tmr = 15;
@ -259,13 +281,13 @@ void Scumm::scummMain(int argc, char **argv) {
processKbd(); processKbd();
/* XXX: memory low check skipped */ /* XXX: memory low check skipped */
vm.vars[VAR_CAMERA_CUR_POS] = camera._curPos; _vars[VAR_CAMERA_CUR_POS] = camera._curPos;
vm.vars[VAR_HAVE_MSG] = _haveMsg; _vars[VAR_HAVE_MSG] = _haveMsg;
vm.vars[VAR_VIRT_MOUSE_X] = _virtual_mouse_x; _vars[VAR_VIRT_MOUSE_X] = _virtual_mouse_x;
vm.vars[VAR_VIRT_MOUSE_Y] = _virtual_mouse_y; _vars[VAR_VIRT_MOUSE_Y] = _virtual_mouse_y;
vm.vars[VAR_MOUSE_X] = mouse.x; _vars[VAR_MOUSE_X] = mouse.x;
vm.vars[VAR_MOUSE_Y] = mouse.y; _vars[VAR_MOUSE_Y] = mouse.y;
vm.vars[VAR_DEBUGMODE] = _debugMode; _vars[VAR_DEBUGMODE] = _debugMode;
if (_saveLoadFlag) { if (_saveLoadFlag) {
char buf[256]; char buf[256];
@ -288,13 +310,9 @@ void Scumm::scummMain(int argc, char **argv) {
a->needRedraw = 1; a->needRedraw = 1;
} }
checkHeap();
runAllScripts(); runAllScripts();
checkHeap();
checkExecVerbs(); checkExecVerbs();
checkHeap();
checkAndRunVar33(); checkAndRunVar33();
checkHeap();
if (_currentRoom==0) { if (_currentRoom==0) {
gdi.unk4 = 0; gdi.unk4 = 0;
@ -305,38 +323,25 @@ void Scumm::scummMain(int argc, char **argv) {
continue; continue;
} }
checkHeap();
walkActors(); walkActors();
checkHeap();
moveCamera(); moveCamera();
checkHeap();
fixObjectFlags(); fixObjectFlags();
checkHeap();
CHARSET_1(); CHARSET_1();
checkHeap();
if (camera._curPos != camera._lastPos || _BgNeedsRedraw || _fullRedraw) { if (camera._curPos != camera._lastPos || _BgNeedsRedraw || _fullRedraw) {
redrawBGAreas(); redrawBGAreas();
checkHeap();
} }
processDrawQue(); processDrawQue();
checkHeap();
setActorRedrawFlags(); setActorRedrawFlags();
checkHeap();
resetActorBgs(); resetActorBgs();
checkHeap();
if (!(vm.vars[VAR_DRAWFLAGS]&2) && vm.vars[VAR_DRAWFLAGS]&4) { if (!(_vars[VAR_DRAWFLAGS]&2) && _vars[VAR_DRAWFLAGS]&4) {
error("Flashlight not implemented in this version"); error("Flashlight not implemented in this version");
} }
processActors(); /* process actors makes the heap invalid */ processActors(); /* process actors makes the heap invalid */
checkHeap();
clear_fullRedraw(); clear_fullRedraw();
checkHeap();
cyclePalette(); cyclePalette();
checkHeap();
palManipulate(); palManipulate();
checkHeap();
if (dseg_4F8A) { if (dseg_4F8A) {
screenEffect(_newEffect); screenEffect(_newEffect);
@ -352,7 +357,9 @@ void Scumm::scummMain(int argc, char **argv) {
unkVirtScreen2(); unkVirtScreen2();
#if !defined(DOTT)
playActorSounds(); playActorSounds();
#endif
unkSoundProc22(); unkSoundProc22();
camera._lastPos = camera._curPos; camera._lastPos = camera._curPos;
} while (1); } while (1);
@ -420,7 +427,7 @@ void Scumm::startScene(int room, Actor *a, int objectNr) {
int i; int i;
Actor *at; Actor *at;
checkHeap(); CHECK_HEAP
clearMsgQueue(); clearMsgQueue();
@ -439,7 +446,7 @@ void Scumm::startScene(int room, Actor *a, int objectNr) {
} }
} }
vm.vars[VAR_NEW_ROOM] = room; _vars[VAR_NEW_ROOM] = room;
runExitScript(); runExitScript();
killScriptsAndResources(); killScriptsAndResources();
stopCycle(0); stopCycle(0);
@ -454,7 +461,7 @@ void Scumm::startScene(int room, Actor *a, int objectNr) {
clearDrawObjectQueue(); clearDrawObjectQueue();
vm.vars[VAR_ROOM] = room; _vars[VAR_ROOM] = room;
_fullRedraw = 1; _fullRedraw = 1;
_roomResource = _currentRoom = 0xFF; _roomResource = _currentRoom = 0xFF;
@ -462,14 +469,14 @@ void Scumm::startScene(int room, Actor *a, int objectNr) {
unkResourceProc(); unkResourceProc();
_currentRoom = room; _currentRoom = room;
vm.vars[VAR_ROOM] = room; _vars[VAR_ROOM] = room;
if (room >= 0x80) if (room >= 0x80)
_roomResource = _resourceMapper[room&0x7F]; _roomResource = _resourceMapper[room&0x7F];
else else
_roomResource = room; _roomResource = room;
vm.vars[VAR_ROOM_RESOURCE] = _roomResource; _vars[VAR_ROOM_RESOURCE] = _roomResource;
if (room!=0) if (room!=0)
ensureResourceLoaded(1, room); ensureResourceLoaded(1, room);
@ -490,8 +497,8 @@ void Scumm::startScene(int room, Actor *a, int objectNr) {
if (_roomResource == 0) if (_roomResource == 0)
return; return;
vm.vars[VAR_CAMERA_MAX] = (_scrWidthIn8Unit<<3) - 160; _vars[VAR_CAMERA_MAX] = (_scrWidthIn8Unit<<3) - 160;
vm.vars[VAR_CAMERA_MIN] = 160; _vars[VAR_CAMERA_MIN] = 160;
memset(actorDrawBits, 0, sizeof(actorDrawBits)); memset(actorDrawBits, 0, sizeof(actorDrawBits));
@ -518,7 +525,7 @@ void Scumm::startScene(int room, Actor *a, int objectNr) {
dseg_4F8A = 1; dseg_4F8A = 1;
checkHeap(); CHECK_HEAP
} }
void Scumm::initRoomSubBlocks() { void Scumm::initRoomSubBlocks() {
@ -528,6 +535,8 @@ void Scumm::initRoomSubBlocks() {
_ENCD_offs = 0; _ENCD_offs = 0;
_EXCD_offs = 0; _EXCD_offs = 0;
_CLUT_offs = 0;
_PALS_offs = 0;
nukeResource(0xE, 1); nukeResource(0xE, 1);
nukeResource(0xE, 2); nukeResource(0xE, 2);
@ -592,12 +601,12 @@ void Scumm::initRoomSubBlocks() {
} }
} }
} }
memset(_localScriptList, 0, (0x100 - _numGlobalScriptsUsed) * 4); memset(_localScriptList, 0, (0x100 - _numGlobalScripts) * 4);
roomptr = getResourceAddress(1, _roomResource); roomptr = getResourceAddress(1, _roomResource);
ptr = findResource(MKID('LSCR'), roomptr); ptr = findResource(MKID('LSCR'), roomptr);
while (ptr) { while (ptr) {
_localScriptList[ptr[8] - _numGlobalScriptsUsed] = ptr - roomptr; _localScriptList[ptr[8] - _numGlobalScripts] = ptr - roomptr;
#ifdef DUMP_SCRIPTS #ifdef DUMP_SCRIPTS
do { do {
@ -610,12 +619,24 @@ void Scumm::initRoomSubBlocks() {
ptr = findResource(MKID('LSCR'), NULL); ptr = findResource(MKID('LSCR'), NULL);
} }
_CLUT_offs = findResource(MKID('CLUT'), roomptr) - roomptr;
ptr = findResource(MKID('EPAL'), roomptr); ptr = findResource(MKID('EPAL'), roomptr);
if (ptr) if (ptr)
_EPAL_offs = ptr - roomptr; _EPAL_offs = ptr - roomptr;
ptr = findResource(MKID('CLUT'), roomptr);
if (ptr) {
_CLUT_offs = ptr - roomptr;
setPaletteFromRes();
}
setPaletteFromRes(); #if defined(DOTT)
ptr = findResource(MKID('PALS'), roomptr);
if (ptr) {
_PALS_offs = ptr - roomptr;
setPalette(0);
}
#endif
initCycl(findResource(MKID('CYCL'), roomptr) + 8); initCycl(findResource(MKID('CYCL'), roomptr) + 8);
ptr = findResource(MKID('TRNS'), roomptr); ptr = findResource(MKID('TRNS'), roomptr);
@ -651,11 +672,10 @@ 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 index, byte *ptr) {
char buf[256]; char buf[256];
FILE *out; FILE *out;
uint32 size = READ_BE_UINT32_UNALIGNED(ptr+4); uint32 size = READ_BE_UINT32_UNALIGNED(ptr+4);
sprintf(buf, "f:\\descumm\\%s%d.dmp", tag,index); sprintf(buf, "dumps\\%s%d.dmp", tag,index);
out = fopen(buf,"rb"); out = fopen(buf,"rb");
if (!out) { if (!out) {
@ -699,7 +719,13 @@ void Scumm::unkRoomFunc2(int a, int b, int c, int d, int e) {
} }
if (_videoMode==0x13) { if (_videoMode==0x13) {
cptr = getResourceAddress(1, _roomResource) + _CLUT_offs + 8 + a*3; 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; cur = _currentPalette + a*3;
if (a <= b) { if (a <= b) {
num = b - a + 1; num = b - a + 1;
@ -764,19 +790,19 @@ void Scumm::processKbd() {
if (!_lastKeyHit) if (!_lastKeyHit)
return; return;
if (_lastKeyHit==vm.vars[VAR_RESTART_KEY]) { if (_lastKeyHit==_vars[VAR_RESTART_KEY]) {
warning("Restart not implemented"); warning("Restart not implemented");
pauseGame(1); pauseGame(1);
return; return;
} }
if (_lastKeyHit==vm.vars[VAR_PAUSE_KEY]) { if (_lastKeyHit==_vars[VAR_PAUSE_KEY]) {
warning("Pause not implemented"); warning("Pause not implemented");
/* pause */ /* pause */
return; return;
} }
if (_lastKeyHit==vm.vars[VAR_CUTSCENEEXIT_KEY]) { if (_lastKeyHit==_vars[VAR_CUTSCENEEXIT_KEY]) {
uint32 offs = vm.cutScenePtr[vm.cutSceneStackPointer]; uint32 offs = vm.cutScenePtr[vm.cutSceneStackPointer];
if (offs) { if (offs) {
ScriptSlot *ss = &vm.slot[vm.cutSceneScript[vm.cutSceneStackPointer]]; ScriptSlot *ss = &vm.slot[vm.cutSceneScript[vm.cutSceneStackPointer]];
@ -784,12 +810,12 @@ void Scumm::processKbd() {
ss->status = 2; ss->status = 2;
ss->freezeCount = 0; ss->freezeCount = 0;
ss->cutsceneOverride--; ss->cutsceneOverride--;
vm.vars[VAR_OVERRIDE] = 1; _vars[VAR_OVERRIDE] = 1;
vm.cutScenePtr[vm.cutSceneStackPointer] = 0; vm.cutScenePtr[vm.cutSceneStackPointer] = 0;
} }
} }
if (_lastKeyHit==vm.vars[VAR_TALKSTOP_KEY]) { if (_lastKeyHit==_vars[VAR_TALKSTOP_KEY]) {
_talkDelay = 0; _talkDelay = 0;
return; return;
} }
@ -811,7 +837,7 @@ int Scumm::getKeyInput(int a) {
if (_leftBtnPressed&1 && _rightBtnPressed&1) { if (_leftBtnPressed&1 && _rightBtnPressed&1) {
_mouseButStat = 0; _mouseButStat = 0;
_lastKeyHit = vm.vars[VAR_CUTSCENEEXIT_KEY]; _lastKeyHit = _vars[VAR_CUTSCENEEXIT_KEY];
} else if (_leftBtnPressed&1) { } else if (_leftBtnPressed&1) {
_mouseButStat = 0x8000; _mouseButStat = 0x8000;
} else if (_rightBtnPressed&1) { } else if (_rightBtnPressed&1) {
@ -842,6 +868,51 @@ Actor *Scumm::derefActorSafe(int id, const char *errmsg) {
return derefActor(id); return derefActor(id);
} }
#if defined(DOTT)
void Scumm::new_unk_1(int a) {
error("stub new_unk_1(%d)", a);
}
void Scumm::setCursorHotspot2(int x,int y) {
warning("stub setCursorHotspot2(%d,%d)", x,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);
}
void Scumm::unkMiscOp9() {
warning("stub unkMiscOp9()");
}
void Scumm::startManiac() {
warning("stub startManiac()");
}
#endif
extern Scumm scumm; extern Scumm scumm;
void NORETURN CDECL error(const char *s, ...) { void NORETURN CDECL error(const char *s, ...) {
@ -886,11 +957,8 @@ void CDECL debug(int level, const char *s, ...) {
} }
void checkHeap() { void checkHeap() {
#if 1 if (_heapchk() != _HEAPOK) {
error("Heap is invalid!");
//if (_heapchk() != _HEAPOK) { }
// error("Heap is invalid!");
// }
#endif
} }

View file

@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 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" /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 BASE RSC /l 0x41d /d "_DEBUG" # ADD BASE RSC /l 0x41d /d "_DEBUG"
# ADD RSC /l 0x41d /d "_DEBUG" # ADD RSC /l 0x41d /d "_DEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
@ -119,6 +119,14 @@ SOURCE=.\script.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\script_v1.cpp
# End Source File
# Begin Source File
SOURCE=.\script_v2.cpp
# End Source File
# Begin Source File
SOURCE=.\scummvm.cpp SOURCE=.\scummvm.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.8 2001/10/16 10:01:48 strigeus
* preliminary DOTT support
*
* Revision 1.7 2001/10/11 11:49:51 strigeus * Revision 1.7 2001/10/11 11:49:51 strigeus
* Determine caption from file name. * Determine caption from file name.
* *
@ -328,14 +331,13 @@ void initGraphics(Scumm *s) {
screen = SDL_SetVideoMode(640, 400, 8, SDL_SWSURFACE); screen = SDL_SetVideoMode(640, 400, 8, SDL_SWSURFACE);
#endif #endif
printf("%d %d, %d %d, %d %d %d, %d %d %d %d %d %d\n", printf("%d %d, %d %d, %d %d %d, %d %d %d %d %d\n",
sizeof(int8), sizeof(uint8), sizeof(int8), sizeof(uint8),
sizeof(int16), sizeof(uint16), sizeof(int16), sizeof(uint16),
sizeof(int32), sizeof(uint32), sizeof(int32), sizeof(uint32),
sizeof(void*), sizeof(void*),
sizeof(Box), sizeof(MouseCursor),sizeof(CodeHeader), sizeof(Box), sizeof(MouseCursor),sizeof(CodeHeader),
sizeof(ImageHeader), sizeof(ImageHeader),
&((CodeHeader*)0)->unk4,
sizeof(Scumm) sizeof(Scumm)
); );

View file

@ -17,8 +17,12 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.1 2001/10/09 14:30:13 strigeus * Revision 1.2 2001/10/16 10:01:48 strigeus
* Initial revision * preliminary DOTT support
*
* Revision 1.1.1.1 2001/10/09 14:30:13 strigeus
*
* initial revision
* *
* *
*/ */
@ -27,7 +31,7 @@
#include "scumm.h" #include "scumm.h"
void Scumm::addSoundToQueue(int sound) { void Scumm::addSoundToQueue(int sound) {
vm.vars[VAR_LAST_SOUND] = sound; _vars[VAR_LAST_SOUND] = sound;
ensureResourceLoaded(4, sound); ensureResourceLoaded(4, sound);
addSoundToQueue2(sound); addSoundToQueue2(sound);
} }
@ -71,16 +75,35 @@ void Scumm::unkSoundProc22() {
void Scumm::playSound(int sound) { void Scumm::playSound(int sound) {
getResourceAddress(4, sound); getResourceAddress(4, sound);
/* XXX: not implemented */ /* XXX: not implemented */
warning("stub playSound(%d)", sound); // warning("stub playSound(%d)", sound);
} }
int Scumm::unkSoundProc23(int a) { int Scumm::unkSoundProc23(int a) {
/* TODO: implement this */ /* TODO: implement this */
warning("unkSoundProc23: not implemented"); // warning("unkSoundProc23: not implemented");
return 0; return 0;
} }
void Scumm::unkSoundProc1(int a) { void Scumm::unkSoundProc1(int a) {
/* TODO: implement this */ /* TODO: implement this */
warning("unkSoundProc: not implemented"); // warning("unkSoundProc: not implemented");
} }
void Scumm::soundKludge(int16 *list) {
int16 *ptr;
int i;
if (list[0]==-1) {
unkSoundProc22();
return;
}
_soundQue[_soundQuePos++] = 8;
ptr = _soundQue + _soundQuePos;
_soundQuePos += 8;
for (i=0; i<8; i++)
*ptr++ = list[i];
if (_soundQuePos > 0x100)
error("Sound que buffer overflow");
}

View file

@ -17,8 +17,12 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.1 2001/10/09 14:30:13 strigeus * Revision 1.2 2001/10/16 10:01:48 strigeus
* Initial revision * preliminary DOTT support
*
* Revision 1.1.1.1 2001/10/09 14:30:13 strigeus
*
* initial revision
* *
* *
*/ */
@ -51,8 +55,18 @@ int CharsetRenderer::getStringWidth(int arg, byte *text, int pos) {
text[pos++] = '@'; text[pos++] = '@';
continue; continue;
} }
if (chr==1 || chr==2) if (chr==10 || chr==21 || chr==12 || chr==13) {
pos += 2;
continue;
}
if (chr==9 || chr==1 || chr==2)
break; break;
if (chr==14) {
int set = text[pos] | (text[pos+1]<<8);
pos+=2;
ptr = _vm->getResourceAddress(6, set) + 29;
continue;
}
} }
offs = READ_LE_UINT32(ptr + chr*4 + 4); offs = READ_LE_UINT32(ptr + chr*4 + 4);
@ -94,12 +108,22 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
} }
continue; continue;
} }
if (chr==10 || chr==21 || chr==12 || chr==13) {
pos += 2;
continue;
}
if (chr==1) { if (chr==1) {
curw = 1; curw = 1;
continue; continue;
} }
if (chr==2) if (chr==2)
break; break;
if (chr==14) {
int set = str[pos] | (str[pos+1]<<8);
pos+=2;
ptr = _vm->getResourceAddress(6, set) + 29;
continue;
}
} }
if (chr==' ') if (chr==' ')
@ -137,11 +161,10 @@ void Scumm::unkMessage2() {
_msgPtrToAdd = buf; _msgPtrToAdd = buf;
tmp = _messagePtr = addMessageToStack(_messagePtr); tmp = _messagePtr = addMessageToStack(_messagePtr);
if (_stringColor[3]==0) if (string[3].color==0)
_stringColor[3] = 4; string[3].color = 4;
error("unkMessage2: call to printScummMessage(%s)", buf); error("unkMessage2: call to printScummMessage(%s)", buf);
vm.vars[0] = 0;
_messagePtr = tmp; _messagePtr = tmp;
} }
@ -156,37 +179,52 @@ void Scumm::CHARSET_1() {
) return; ) return;
a = NULL; a = NULL;
if (vm.vars[VAR_TALK_ACTOR] != 0xFF) if (_vars[VAR_TALK_ACTOR] != 0xFF)
a = derefActorSafe(vm.vars[VAR_TALK_ACTOR], "CHARSET_1"); a = derefActorSafe(_vars[VAR_TALK_ACTOR], "CHARSET_1");
if (a && _stringOverhead[0]!=0) { #if !defined(DOTT)
_stringXpos[0] = a->x - camera._curPos + 160; if (a && string[0].overhead!=0) {
string[0].xpos = a->x - camera._curPos + 160;
if (vm.vars[VAR_TALK_STRING_Y] < 0) { if (_vars[VAR_TALK_STRING_Y] < 0) {
s = (a->scaley * (int)vm.vars[VAR_TALK_STRING_Y]) / 0xFF; s = (a->scaley * (int)_vars[VAR_TALK_STRING_Y]) / 0xFF;
_stringYpos[0] = ((vm.vars[VAR_TALK_STRING_Y]-s)>>1) + s - a->elevation + a->y; string[0].ypos = ((_vars[VAR_TALK_STRING_Y]-s)>>1) + s - a->elevation + a->y;
} else { } else {
_stringYpos[0] = vm.vars[VAR_TALK_STRING_Y]; string[0].ypos = _vars[VAR_TALK_STRING_Y];
} }
if (_stringYpos[0] < 1) if (string[0].ypos < 1)
_stringYpos[0] = 1; string[0].ypos = 1;
if (_stringXpos[0] < 80) if (string[0].xpos < 80)
_stringXpos[0] = 80; string[0].xpos = 80;
if (_stringXpos[0] > 240) if (string[0].xpos > 240)
_stringXpos[0] = 240; string[0].xpos = 240;
} }
#else
charset._top = _stringYpos[0]; if (a && string[0].overhead!=0) {
charset._left = _stringXpos[0]; s = a->scaley * a->new_1 / 0xFF;
charset._left2 = _stringXpos[0]; string[0].ypos = ((a->new_1 - s)>>1) + s - a->elevation + a->y;
charset._curId = _stringCharset[0]; if (string[0].ypos<1)
string[0].ypos = 1;
s = a->scalex * a->new_2 / 0xFF;
string[0].xpos = ((a->new_2 - s)>>1) + s + a->x - camera._curPos + 160;
if (string[0].xpos < 80)
string[0].xpos = 80;
if (string[0].xpos > 240)
string[0].xpos = 240;
}
#endif
charset._top = string[0].ypos;
charset._left = string[0].xpos;
charset._left2 = string[0].xpos;
charset._curId = string[0].charset;
if (a && a->charset) if (a && a->charset)
charset._curId = a->charset; charset._curId = a->charset;
charset._center = _stringCenter[0]; charset._center = string[0].center;
charset._right = _stringRight[0]; charset._right = string[0].right;
charset._color = _charsetColor; charset._color = _charsetColor;
dseg_4E3C = 0; dseg_4E3C = 0;
@ -194,10 +232,10 @@ void Scumm::CHARSET_1() {
charset._colorMap[i] = _charsetData[charset._curId][i]; charset._colorMap[i] = _charsetData[charset._curId][i];
if (_keepText) { if (_keepText) {
charset._strLeft = charset._mask_left; charset._strLeft = string[0].mask_left;
charset._strRight = charset._mask_right; charset._strRight = string[0].mask_right;
charset._strTop = charset._mask_top; charset._strTop = string[0].mask_top;
charset._strBottom = charset._mask_bottom; charset._strBottom = string[0].mask_bottom;
} }
if (!_haveMsg || _talkDelay) if (!_haveMsg || _talkDelay)
@ -216,21 +254,21 @@ void Scumm::CHARSET_1() {
if (!_keepText) { if (!_keepText) {
restoreCharsetBg(); restoreCharsetBg();
_stringXpos2[0] = _stringXpos[0]; string[0].xpos2 = string[0].xpos;
_stringYpos2[0] = _stringYpos[0]; string[0].ypos2 = string[0].ypos;
} }
t = charset._right - _stringXpos2[0] - 1; t = charset._right - string[0].xpos - 1;
if (charset._center) { if (charset._center) {
if (t > _stringXpos2[0]) if (t > string[0].xpos2)
t = _stringXpos2[0]; t = string[0].xpos2;
t <<= 1; t <<= 1;
} }
charset.addLinebreaks(0, charset._buffer, charset._bufPos, t); charset.addLinebreaks(0, charset._buffer, charset._bufPos, t);
_lastXstart = virtscr[0].xstart; _lastXstart = virtscr[0].xstart;
if (charset._center) { if (charset._center) {
_stringXpos2[0] -= charset.getStringWidth(0, charset._buffer, charset._bufPos) >> 1; string[0].xpos2 -= charset.getStringWidth(0, charset._buffer, charset._bufPos) >> 1;
} }
charset._disableOffsX = charset._unk12 = !_keepText; charset._disableOffsX = charset._unk12 = !_keepText;
@ -242,58 +280,79 @@ void Scumm::CHARSET_1() {
_keepText = false; _keepText = false;
break; break;
} }
if (c != 13) { if (c == 13) {
if (c==0xFE) newLine:;
c=0xFF; string[0].xpos2 = string[0].xpos;
if (charset._center) {
if (c!=0xFF) { string[0].xpos2 -= charset.getStringWidth(0, charset._buffer, charset._bufPos)>>1;
PrintChar:;
charset._left = _stringXpos2[0];
charset._top = _stringYpos2[0];
if (!vm.vars[VAR_CHARFLAG]) {
charset.printChar(c);
}
_stringXpos2[0] = charset._left;
_stringYpos2[0] = charset._top;
_talkDelay += vm.vars[VAR_CHARINC];
continue;
}
c = charset._buffer[charset._bufPos++];
if (c==3) {
_haveMsg = 0xFF;
_keepText = false;
break;
}
if (c!=1) {
if (c==2) {
_haveMsg = 0;
_keepText = true;
break;
}
if (c==9) {
frme = charset._buffer[charset._bufPos++];
frme |= charset._buffer[charset._bufPos++]<<8;
if (a)
startAnimActor(a, frme, a->facing);
}
goto PrintChar;
} }
string[0].ypos2 += getResourceAddress(6,charset._curId)[30];
charset._disableOffsX = 1;
continue;
} }
_stringXpos2[0] = _stringXpos[0];
if (charset._center) { if (c==0xFE) c=0xFF;
_stringXpos2[0] -= charset.getStringWidth(0, charset._buffer, charset._bufPos)>>1;
if (c!=0xFF) {
charset._left = string[0].xpos2;
charset._top = string[0].ypos2;
if (!_vars[VAR_CHARFLAG]) {
charset.printChar(c);
}
string[0].xpos2 = charset._left;
string[0].ypos2 = charset._top;
_talkDelay += _vars[VAR_CHARINC];
continue;
}
c = charset._buffer[charset._bufPos++];
if (c==3) {
_haveMsg = 0xFF;
_keepText = false;
break;
} else if (c==1) {
goto newLine;
} else if (c==2) {
_haveMsg = 0;
_keepText = true;
break;
} else if (c==9) {
frme = charset._buffer[charset._bufPos++];
frme |= charset._buffer[charset._bufPos++]<<8;
if (a)
startAnimActor(a, frme, a->facing);
} else if (c==10) {
warning("CHARSET_1: code 10 unimplemented");
charset._bufPos += 14;
} else if (c==14) {
int oldy = getResourceAddress(6,charset._curId)[30];
charset._curId = charset._buffer[charset._bufPos];
charset._bufPos += 2;
for (i=0; i<4; i++)
charset._colorMap[i] = _charsetData[charset._curId][i];
string[0].ypos2 -= getResourceAddress(6,charset._curId)[30] - oldy;
} else if (c==12) {
int color;
color = charset._buffer[charset._bufPos++];
color |= charset._buffer[charset._bufPos++]<<8;
if (color==0xFF)
charset._color = _charsetColor;
else
charset._color = color;
} else if (c==13) {
charset._bufPos += 2;
} else {
warning("CHARSET_1: invalid code %d", c);
} }
_stringYpos2[0] += getResourceAddress(6,charset._curId)[30];
charset._disableOffsX = 1;
} while (1); } while (1);
charset._mask_left = charset._strLeft; string[0].mask_left = charset._strLeft;
charset._mask_right = charset._strRight; string[0].mask_right = charset._strRight;
charset._mask_top = charset._strTop; string[0].mask_top = charset._strTop;
charset._mask_bottom = charset._strBottom; string[0].mask_bottom = charset._strBottom;
} }
void Scumm::drawString(int a) { void Scumm::drawString(int a) {
@ -305,12 +364,12 @@ void Scumm::drawString(int a) {
_msgPtrToAdd = buf; _msgPtrToAdd = buf;
_messagePtr = addMessageToStack(_messagePtr); _messagePtr = addMessageToStack(_messagePtr);
charset._left2 = charset._left = _stringXpos[a]; charset._left2 = charset._left = string[a].xpos;
charset._top = _stringYpos[a]; charset._top = string[a].ypos;
charset._curId = _stringCharset[a]; charset._curId = string[a].charset;
charset._center = _stringCenter[a]; charset._center = string[a].center;
charset._right = _stringRight[a]; charset._right = string[a].right;
charset._color = _stringColor[a]; charset._color = string[a].color;
dseg_4E3C = 0; dseg_4E3C = 0;
charset._unk12 = 1; charset._unk12 = 1;
charset._disableOffsX = 1; charset._disableOffsX = 1;
@ -371,8 +430,8 @@ void Scumm::drawString(int a) {
} }
charset._ignoreCharsetMask = 0; charset._ignoreCharsetMask = 0;
_stringXpos2[a] = charset._left; string[a].xpos2 = charset._left;
_stringYpos2[a] = charset._top; string[a].ypos2 = charset._top;
} }
byte *Scumm::addMessageToStack(byte *msg) { byte *Scumm::addMessageToStack(byte *msg) {
@ -394,7 +453,7 @@ byte *Scumm::addMessageToStack(byte *msg) {
if (chr==255) { if (chr==255) {
ptr[num++] = chr = *msg++; ptr[num++] = chr = *msg++;
if (chr==0 || chr!=2 && chr!=3 && chr!=8) { if (chr!=1 && chr!=2 && chr!=3 && chr!=8) {
ptr[num++] = chr = *msg++; ptr[num++] = chr = *msg++;
ptr[num++] = chr = *msg++; ptr[num++] = chr = *msg++;
} }
@ -411,38 +470,32 @@ byte *Scumm::addMessageToStack(byte *msg) {
if (chr == 0) if (chr == 0)
break; break;
if (chr == 0xFF) { if (chr == 0xFF) {
ptr = getResourceAddress(0xC, 6);
chr = ptr[num++]; chr = ptr[num++];
switch(chr) { switch(chr) {
case 4: case 4:
unkAddMsgToStack2( unkAddMsgToStack2(READ_LE_UINT16(ptr + num));
READ_LE_UINT16(getResourceAddress(0xC, 6)+ num)
);
num+=2; num+=2;
break; break;
case 5: case 5:
unkAddMsgToStack3( unkAddMsgToStack3(READ_LE_UINT16(ptr + num));
READ_LE_UINT16(getResourceAddress(0xC, 6)+ num)
);
num+=2; num+=2;
break; break;
case 6: case 6:
unkAddMsgToStack4( unkAddMsgToStack4(READ_LE_UINT16(ptr + num));
READ_LE_UINT16(getResourceAddress(0xC, 6)+ num)
);
num+=2; num+=2;
break; break;
case 7: case 7:
unkAddMsgToStack5( unkAddMsgToStack5(READ_LE_UINT16(ptr + num));
READ_LE_UINT16(getResourceAddress(0xC, 6)+num)
);
num+=2; num+=2;
break; break;
case 9: case 9:
#if defined(DOTT)
case 10: case 12: case 13: case 14:
#endif
*_msgPtrToAdd++ = 0xFF; *_msgPtrToAdd++ = 0xFF;
*_msgPtrToAdd++ = chr; *_msgPtrToAdd++ = chr;
*_msgPtrToAdd++ = getResourceAddress(0xC, 6)[num++]; *_msgPtrToAdd++ = ptr[num++];
*_msgPtrToAdd++ = getResourceAddress(0xC, 6)[num++]; *_msgPtrToAdd++ = ptr[num++];
break; break;
default: default:
*_msgPtrToAdd++ = 0xFF; *_msgPtrToAdd++ = 0xFF;
@ -489,7 +542,7 @@ void Scumm::unkAddMsgToStack3(int var) {
num = readVar(var); num = readVar(var);
if (num) { if (num) {
for (i=1; i<_maxVerbs; i++) { for (i=1; i<_maxVerbs; i++) {
if (num==verbs[i].verbid && !verbs[i].type && !verbs[i].saveid) { if (num==_verbs[i].verbid && !_verbs[i].type && !_verbs[i].saveid) {
addMessageToStack(getResourceAddress(8, i)); addMessageToStack(getResourceAddress(8, i));
break; break;
} }
@ -528,8 +581,8 @@ void Scumm::initCharset(int charsetno) {
if (!getResourceAddress(6, charsetno)) if (!getResourceAddress(6, charsetno))
loadCharset(charsetno); loadCharset(charsetno);
textslot.charset[0] = charsetno; string[0].t_charset = charsetno;
textslot.charset[1] = charsetno; string[1].t_charset = charsetno;
for (i=0; i<0x10; i++) for (i=0; i<0x10; i++)
charset._colorMap[i] = _charsetData[charsetno][i]; charset._colorMap[i] = _charsetData[charsetno][i];
@ -615,6 +668,7 @@ void CharsetRenderer::printChar(int chr) {
_strTop = _top; _strTop = _top;
_drawTop = _top - vs->topline; _drawTop = _top - vs->topline;
_bottom = _drawTop + _height + _offsY; _bottom = _drawTop + _height + _offsY;
_vm->updateDirtyRect(_vm->gdi.virtScreen, _left, right, _drawTop, _bottom, 0); _vm->updateDirtyRect(_vm->gdi.virtScreen, _left, right, _drawTop, _bottom, 0);

View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.3 2001/10/16 10:01:48 strigeus
* preliminary DOTT support
*
* Revision 1.2 2001/10/09 19:02:28 strigeus * Revision 1.2 2001/10/09 19:02:28 strigeus
* command line parameter support * command line parameter support
* *
@ -46,7 +49,7 @@ void Scumm::checkExecVerbs() {
if (_mouseButStat < 0x200) { if (_mouseButStat < 0x200) {
/* Check keypresses */ /* Check keypresses */
vs = &verbs[1]; vs = &_verbs[1];
for (i=1; i<_maxVerbs; i++,vs++) { for (i=1; i<_maxVerbs; i++,vs++) {
if (vs->verbid && vs->saveid && vs->curmode==1) { if (vs->verbid && vs->saveid && vs->curmode==1) {
if (_mouseButStat == vs->key) { if (_mouseButStat == vs->key) {
@ -61,13 +64,13 @@ void Scumm::checkExecVerbs() {
if (mouse.y >= virtscr[0].topline && mouse.y < virtscr[0].topline + virtscr[0].height) { if (mouse.y >= virtscr[0].topline && mouse.y < virtscr[0].topline + virtscr[0].height) {
over = checkMouseOver(mouse.x, mouse.y); over = checkMouseOver(mouse.x, mouse.y);
if (over != 0) { if (over != 0) {
runInputScript(1,verbs[over].verbid,code); runInputScript(1,_verbs[over].verbid,code);
return; return;
} }
runInputScript(2, 0, code); runInputScript(2, 0, code);
} else { } else {
over=checkMouseOver(mouse.x, mouse.y); over=checkMouseOver(mouse.x, mouse.y);
runInputScript(1, over!=0 ? verbs[over].verbid : 0, code); runInputScript(1, over!=0 ? _verbs[over].verbid : 0, code);
} }
} }
} }
@ -76,12 +79,12 @@ void Scumm::verbMouseOver(int verb) {
if (_verbMouseOver==verb) if (_verbMouseOver==verb)
return; return;
if (verbs[_verbMouseOver].type!=1) { if (_verbs[_verbMouseOver].type!=1) {
drawVerb(_verbMouseOver, 0); drawVerb(_verbMouseOver, 0);
_verbMouseOver = verb; _verbMouseOver = verb;
} }
if (verbs[verb].type!=1 && verbs[verb].hicolor) { if (_verbs[verb].type!=1 && _verbs[verb].hicolor) {
drawVerb(verb, 1); drawVerb(verb, 1);
_verbMouseOver = verb; _verbMouseOver = verb;
} }
@ -89,9 +92,9 @@ void Scumm::verbMouseOver(int verb) {
int Scumm::checkMouseOver(int x, int y) { int Scumm::checkMouseOver(int x, int y) {
VerbSlot *vs; VerbSlot *vs;
int i = _maxVerbs; int i = _maxVerbs-1;
vs = &verbs[i]; vs = &_verbs[i];
do { do {
if (vs->curmode!=1 || !vs->verbid || vs->saveid || if (vs->curmode!=1 || !vs->verbid || vs->saveid ||
y < vs->y || y >= vs->bottom) y < vs->y || y >= vs->bottom)
@ -104,7 +107,7 @@ int Scumm::checkMouseOver(int x, int y) {
continue; continue;
} }
return i; return i;
} while (--vs, i--); } while (--vs,--i);
return 0; return 0;
} }
@ -116,7 +119,7 @@ void Scumm::drawVerb(int vrb, int mode) {
if (!vrb) if (!vrb)
return; return;
vs = &verbs[vrb]; vs = &_verbs[vrb];
if (!vs->saveid && vs->curmode && vs->verbid) { if (!vs->saveid && vs->curmode && vs->verbid) {
if (vs->type==1) { if (vs->type==1) {
@ -125,18 +128,18 @@ void Scumm::drawVerb(int vrb, int mode) {
} }
restoreVerbBG(vrb); restoreVerbBG(vrb);
_stringCharset[4] = vs->charset_nr; string[4].charset = vs->charset_nr;
_stringXpos[4] = vs->x; string[4].xpos = vs->x;
_stringYpos[4] = vs->y; string[4].ypos = vs->y;
_stringRight[4] = 319; string[4].right = 319;
_stringCenter[4] = vs->center; string[4].center = vs->center;
if (mode && vs->hicolor) if (mode && vs->hicolor)
color = vs->hicolor; color = vs->hicolor;
else else
color = vs->color; color = vs->color;
_stringColor[4] = color; string[4].color = color;
if (vs->curmode==2) if (vs->curmode==2)
_stringColor[4] = vs->dimcolor; string[4].color = vs->dimcolor;
_messagePtr = getResourceAddress(8, vrb); _messagePtr = getResourceAddress(8, vrb);
assert(_messagePtr); assert(_messagePtr);
tmp = charset._center; tmp = charset._center;
@ -158,7 +161,7 @@ void Scumm::drawVerb(int vrb, int mode) {
void Scumm::restoreVerbBG(int verb) { void Scumm::restoreVerbBG(int verb) {
VerbSlot *vs; VerbSlot *vs;
vs = &verbs[verb]; vs = &_verbs[verb];
if (vs->oldleft != -1) { if (vs->oldleft != -1) {
dseg_4E3C = vs->bkcolor; dseg_4E3C = vs->bkcolor;
@ -210,7 +213,7 @@ void Scumm::drawVerbBitmap(int vrb, int x, int y) {
} }
} }
vst = &verbs[vrb]; vst = &_verbs[vrb];
vst->right = vst->x + imgw*8; vst->right = vst->x + imgw*8;
vst->bottom = vst->y + imgh*8; vst->bottom = vst->y + imgh*8;
vst->oldleft = vst->x; vst->oldleft = vst->x;
@ -225,7 +228,7 @@ void Scumm::drawVerbBitmap(int vrb, int x, int y) {
int Scumm::getVerbSlot(int id, int mode) { int Scumm::getVerbSlot(int id, int mode) {
int i; int i;
for (i=1; i<_maxVerbs; i++) { for (i=1; i<_maxVerbs; i++) {
if (verbs[i].verbid == id && verbs[i].saveid == mode) { if (_verbs[i].verbid == id && _verbs[i].saveid == mode) {
return i; return i;
} }
} }
@ -238,7 +241,7 @@ void Scumm::killVerb(int slot) {
if (slot==0) if (slot==0)
return; return;
vs = &verbs[slot]; vs = &_verbs[slot];
vs->verbid = 0; vs->verbid = 0;
vs->curmode = 0; vs->curmode = 0;

View file

@ -17,6 +17,9 @@
* *
* Change Log: * Change Log:
* $Log$ * $Log$
* Revision 1.5 2001/10/16 10:01:48 strigeus
* preliminary DOTT support
*
* Revision 1.4 2001/10/12 07:24:06 strigeus * Revision 1.4 2001/10/12 07:24:06 strigeus
* fast mode support * fast mode support
* *
@ -124,8 +127,7 @@ void Error(const char *msg) {
int sel; int sel;
Scumm scumm; Scumm scumm;
WndMan wm[1]; WndMan wm[1];
byte veryFastMode;
void modifyslot(int sel, int what); void modifyslot(int sel, int what);
@ -156,6 +158,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
wm->_scumm->_fastMode ^= 1; wm->_scumm->_fastMode ^= 1;
} }
if (wParam=='G') {
veryFastMode ^= 1;
}
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
@ -711,7 +717,6 @@ int _declspec(naked) endpentiumtest() {
#ifdef _DEBUG
void decompressMask(byte *d, byte *s) { void decompressMask(byte *d, byte *s) {
int x,y; int x,y;
@ -732,12 +737,19 @@ void decompressMask(byte *d, byte *s) {
void outputdisplay2(Scumm *s, int disp) { void outputdisplay2(Scumm *s, int disp) {
byte *old = wm->_vgabuf; byte *old = wm->_vgabuf;
byte buf[64000];
switch(disp) { switch(disp) {
case 0: case 0:
wm->_vgabuf = s->getResourceAddress(0xA, 5); wm->_vgabuf = buf;
memcpy(buf, wm->_vgabuf, 64000);
memcpy(buf+320*144,s->getResourceAddress(0xA, 7),320*56);
break; break;
case 1: case 1:
wm->_vgabuf = s->getResourceAddress(0xA, 1); wm->_vgabuf = buf;
memcpy(buf, wm->_vgabuf, 64000);
memcpy(buf+320*144,s->getResourceAddress(0xA, 3),320*56);
break; break;
case 2: case 2:
wm->_vgabuf = NULL; wm->_vgabuf = NULL;
@ -759,7 +771,7 @@ void outputdisplay2(Scumm *s, int disp) {
wm->writeToScreen(); wm->writeToScreen();
wm->_vgabuf = old; wm->_vgabuf = old;
} }
#endif
#if 0 #if 0
void outputdisplay(Scumm *s) { void outputdisplay(Scumm *s) {
@ -783,6 +795,8 @@ void blitToScreen(Scumm *s, byte *src,int x, int y, int w, int h) {
} }
int clock;
void updateScreen(Scumm *s) { void updateScreen(Scumm *s) {
if (s->_palDirtyMax != -1) { if (s->_palDirtyMax != -1) {
wm->setPalette(s->_currentPalette, 0, 256); wm->setPalette(s->_currentPalette, 0, 256);
@ -792,8 +806,12 @@ void updateScreen(Scumm *s) {
wm->writeToScreen(); wm->writeToScreen();
} }
void waitForTimer(Scumm *s) { void waitForTimer(Scumm *s) {
Sleep(10); if (!veryFastMode) {
Sleep(5);
}
s->_scummTimer+=2; s->_scummTimer+=2;
wm->handleMessage(); wm->handleMessage();
} }
@ -808,7 +826,12 @@ void drawMouse(Scumm *s, int, int, int, byte*, bool) {
#undef main #undef main
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
scumm._videoMode = 0x13; scumm._videoMode = 0x13;
#if defined(DOTT)
scumm._exe_name = "tentacle";
#else
scumm._exe_name = "monkey2"; scumm._exe_name = "monkey2";
#endif
wm->init(); wm->init();
wm->_vgabuf = (byte*)calloc(320,200); wm->_vgabuf = (byte*)calloc(320,200);