diff --git a/gfx.cpp b/gfx.cpp index bbb5014d0fb..cede07bdac2 100644 --- a/gfx.cpp +++ b/gfx.cpp @@ -17,8 +17,13 @@ * * Change Log: * $Log$ - * Revision 1.1 2001/10/09 14:30:14 strigeus - * Initial revision + * Revision 1.2 2001/10/10 10:02:33 strigeus + * alternative mouse cursor + * basic save&load + * + * Revision 1.1.1.1 2001/10/09 14:30:14 strigeus + * + * initial revision * * */ @@ -61,6 +66,10 @@ void Scumm::initScreens(int a, int b, int w, int h) { initVirtScreen(0, b, h-b, true, true); initVirtScreen(1, 0, b, false, false); initVirtScreen(2, h, 200-h, false, false); + + _screenB = b; + _screenH = h; + } void Scumm::initVirtScreen(int slot, int top, int height, bool twobufs, bool fourextra) { @@ -107,8 +116,6 @@ void Scumm::setDirtyRange(int slot, int top, int bottom) { } void Scumm::unkVirtScreen2() { - removeMouseCursor(); - dseg_3DB6 = 1; updateDirtyScreen(2); @@ -135,7 +142,6 @@ void Scumm::unkVirtScreen2() { virtscr[0].bdirty[gdi.draw8xPos] = 0; } } - showMouseCursor(); } void Scumm::updateDirtyScreen(int slot) { @@ -217,9 +223,6 @@ void Scumm::drawStripToScreen() { blitToScreen(this, gdi.readPtr, gdi.draw8xPos*8, gdi.drawY+gdi.drawTop, gdi.drawWidth, gdi.drawBottom-gdi.drawTop); } -void Scumm::showMouseCursor() { - gdi.unk3 = 1; -} void blit(byte *dst, byte *src, int w, int h) { do { @@ -366,7 +369,7 @@ void Scumm::initBGBuffers() { itemsize = (_scrHeight + 4) * 40; size = itemsize * _numZBuffer; - memset(createResource(0xA, 9, size), 0, size); + memset(createResource(10, 9, size), 0, size); for (i=0; i<4; i++) _imgBufOffs[i] = i*itemsize; @@ -377,17 +380,18 @@ void Scumm::setPaletteFromRes() { uint32 size = READ_BE_UINT32_UNALIGNED(ptr+4); int i, r, g, b; byte *dest, *epal; + int numcolor; - _colorsInPalette = (size-8) / 3; + numcolor = (size-8) / 3; ptr += 8; - checkRange(256, 0, _colorsInPalette, "Too many colors (%d) in Palette"); + checkRange(256, 0, numcolor, "Too many colors (%d) in Palette"); dest = _currentPalette; if (_videoMode==0x13) { - for (i=0; i<_colorsInPalette; i++) { + for (i=0; ifourlinesextra) x -= _screenStartStrip; + checkHeap(); + if (x >= 40) return; @@ -673,6 +680,8 @@ void Scumm::drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr) where_draw_ptr = gdi.where_to_draw_ptr; decompressBitmap(); + checkHeap(); + if (twobufs) { gdi.where_to_draw_ptr = where_draw_ptr; if (vm.vars[VAR_DRAWFLAGS]&2) { @@ -688,6 +697,7 @@ void Scumm::drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr) clear8Col(); } } + checkHeap(); for (i=1; i<_numZBuffer; i++) { if (!zplane_list[i]) @@ -699,6 +709,7 @@ void Scumm::drawBmp(byte *ptr, int a, int b, int c, const char *str, int objnr) else decompressMaskImg(); } + checkHeap(); _drawBmpX++; a++; } while (--b); @@ -710,6 +721,8 @@ void Scumm::decompressBitmap() { 0x0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x0, }; + dseg_4E3B = 0; + byte code = *gdi.smap_ptr++; switch(code) { @@ -899,7 +912,7 @@ void Scumm::redrawBGStrip(int start, int num) { gdi.numLinesToProcess, _scrHeight); } - + drawBmp( getResourceAddress(1, _roomResource) + _IM00_offs, s, @@ -1431,7 +1444,6 @@ void Scumm::palManipulate() { } void Scumm::screenEffect(int effect) { - removeMouseCursor(); dseg_3DB6 = 1; warning("stub screenEffect(%d)",effect); /* TODO: not implemented */ @@ -1442,14 +1454,15 @@ void Scumm::resetActorBgs() { Actor *a; int i,bitpos; int top,bottom; + uint16 onlyActorFlags; for(i=0; i<40; i++) { - _onlyActorFlags = (actorDrawBits[_screenStartStrip + i]&=0x3FFF); + onlyActorFlags = (actorDrawBits[_screenStartStrip + i]&=0x3FFF); a = getFirstActor(); bitpos = 1; - while (_onlyActorFlags) { - if(_onlyActorFlags&1 && a->top!=0xFF && a->needBgReset) { + while (onlyActorFlags) { + if(onlyActorFlags&1 && a->top!=0xFF && a->needBgReset) { top = a->top; bottom = a->bottom; if (a->top < virtscr[0].tdirty[i]) @@ -1478,7 +1491,7 @@ void Scumm::resetActorBgs() { } } bitpos<<=1; - _onlyActorFlags>>=1; + onlyActorFlags>>=1; a++; } } @@ -1500,25 +1513,16 @@ void Scumm::setPalColor(int index, int r, int g, int b) { } } -void Scumm::removeMouseCursor() { - gdi.unk3 = 0; - drawMouse(); -} - void Scumm::drawMouse() { /* TODO: handle shake here */ - - GDI_removeMouse(); - if (gdi.unk3 && gdi.unk4>0) { - gdi.mouseColor = gdi.mouseColors[((++gdi.mouseColorIndex)>>2)&3]; - gdi.drawMouseX = mouse.x - gdi.hotspot_x; - gdi.drawMouseY = mouse.y - gdi.hotspot_y; - gdi.mouseMaskPtr = gdi.mouseMask + ((gdi.drawMouseX&7)<<6); - gdi.mouseClipMask1 = (gdi.drawMouseX<0) ? 0 : 0xFF; - gdi.mouseClipMask2 = (gdi.drawMouseX>=312) ? 0 : 0xFF; - gdi.mouseClipMask3 = (gdi.drawMouseX>=304) ? 0 : 0xFF; - GDI_drawMouse(); - } + + ::drawMouse(this, + mouse.x - gdi.hotspot_x, + mouse.y - gdi.hotspot_y, + gdi.mouseColors[((++gdi.mouseColorIndex)>>2)&3], + gdi.mouseMask + ((gdi.drawMouseX&7)<<6), + gdi.unk4>0 + ); } void Scumm::setCursorHotspot(int cursor, int x, int y) { @@ -1537,7 +1541,7 @@ void Scumm::setCursorImg(int cursor, int img) { // if (!offs) // return; - warning("setCursorImg: not fully implemented"); + warning("setCursorImg: not implemented"); } byte Scumm::isMaskActiveAt(int l, int t, int r, int b, byte *mem) { @@ -1559,8 +1563,8 @@ byte Scumm::isMaskActiveAt(int l, int t, int r, int b, byte *mem) { return false; } -void Scumm::GDI_drawMouse() { #if 0 +void Scumm::GDI_drawMouse() { byte *dst,*src,*dstorg; int y,h; byte color,val; @@ -1626,7 +1630,6 @@ void Scumm::GDI_drawMouse() { dstorg += 320; } while (--h); -#endif } void Scumm::GDI_removeMouse() { @@ -1643,3 +1646,4 @@ void Scumm::GDI_removeMouse() { } while (--h); } } +#endif \ No newline at end of file diff --git a/readme.txt b/readme.txt index afeb7b5d58c..d0a0e974e0c 100644 --- a/readme.txt +++ b/readme.txt @@ -12,9 +12,7 @@ You need SDL-1.2.2 (maybe older versions will work), and a supported compiler. A GCC: ---- -* Edit the makefile and replace /usr/local/include/SDL/ with the path to your SDL include files. - If your processor architecture is big endian, replace -DSCUMM_LITTLE_ENDIAN by -DSCUMM_BIG_ENDIAN -DSCUMM_NEED_ALIGNMENT -* Now type make (or gmake if that's what GNU make is called on your system) and hopefully ScummVM will compile for you. +* Type make (or gmake if that's what GNU make is called on your system) and hopefully ScummVM will compile for you. Please note that big endian support is preliminary and contains bugs. @@ -32,7 +30,6 @@ Running: -------- Before you run the engine, you need to put the game's datafiles in the same directory as the scummvm executable. The filenames must be in lowercase (monkey2.000 and monkey2.001). - Good Luck, Ludvig Strigeus diff --git a/resource.cpp b/resource.cpp index 603311b951f..1afb2351a67 100644 --- a/resource.cpp +++ b/resource.cpp @@ -17,8 +17,13 @@ * * Change Log: * $Log$ - * Revision 1.1 2001/10/09 14:30:14 strigeus - * Initial revision + * Revision 1.2 2001/10/10 10:02:33 strigeus + * alternative mouse cursor + * basic save&load + * + * Revision 1.1.1.1 2001/10/09 14:30:14 strigeus + * + * initial revision * * */ @@ -357,8 +362,6 @@ int Scumm::loadResource(int type, int index) { do { for (i=0; i<5; i++) { - _resIndexToLoad = index; - _resTypeToLoad = type; openRoom(roomNr); fileSeek(_fileHandle, fileOffs + _fileOffset, SEEK_SET); @@ -459,7 +462,7 @@ byte *Scumm::getResourceAddress(int type, int index) { if (!ptr) return NULL; - return ptr + 8; + return ptr + sizeof(ResHeader); } void Scumm::setResourceFlags(int type, int index, byte flag) { @@ -479,17 +482,21 @@ byte *Scumm::createResource(int type, int index, uint32 size) { validateResource("allocating", type, index); nukeResource(type, index); + + checkHeap(); - ptr = (byte*)alloc(size + 8); + ptr = (byte*)alloc(size + sizeof(ResHeader)); if (ptr==NULL) { error("Out of memory while allocating %d", size); } res.address[type][index] = ptr; + ((ResHeader*)ptr)->size = size; + setResourceFlags(type, index, 1); - return ptr + 8; /* skip header */ + return ptr + sizeof(ResHeader); /* skip header */ } void Scumm::validateResource(const char *str, int type, int index) { diff --git a/saveload.cpp b/saveload.cpp index c7f46504aa3..d9f530b1ac7 100644 --- a/saveload.cpp +++ b/saveload.cpp @@ -17,8 +17,13 @@ * * Change Log: * $Log$ - * Revision 1.1 2001/10/09 14:30:13 strigeus - * Initial revision + * Revision 1.2 2001/10/10 10:02:33 strigeus + * alternative mouse cursor + * basic save&load + * + * Revision 1.1.1.1 2001/10/09 14:30:13 strigeus + * + * initial revision * * */ @@ -26,30 +31,389 @@ #include "stdafx.h" #include "scumm.h" - bool Scumm::saveState(const char *filename) { FILE *out = fopen(filename,"wb"); if (out==NULL) return false; saveOrLoad(out,true); fclose(out); + debug(1,"State saved as '%s'", filename); return true; } bool Scumm::loadState(const char *filename) { FILE *out = fopen(filename,"rb"); + int i,j; + if (out==NULL) return false; + + checkHeap(); + + openRoom(-1); + memset(_inventory, 0, sizeof(_inventory)); + + /* Nuke all resources */ + for (i=1; i<16; i++) + if (!(i==13 || i==12 || i==10 || res.mode[i])) + for(j=1; jitem)) +#define SIZE(type,item) sizeof(((type*)0)->item) + +#define MKLINE(type,item,saveas) {OFFS(type,item),saveas,SIZE(type,item)} +#define MKARRAY(type,item,saveas,num) {OFFS(type,item),128|saveas,SIZE(type,item)}, {num,0,0} +#define MKEND() {0xFFFF,0xFF,0xFF} + void Scumm::saveOrLoad(FILE *inout, bool mode) { + const SaveLoadEntry objectEntries[] = { + MKLINE(ObjectData,offs_obim_to_room,sleUint32), + MKLINE(ObjectData,offs_obcd_to_room,sleUint32), + MKLINE(ObjectData,cdhd_10,sleUint16), + MKLINE(ObjectData,cdhd_12,sleUint16), + MKLINE(ObjectData,obj_nr,sleUint16), + MKLINE(ObjectData,x_pos,sleByte), + MKLINE(ObjectData,y_pos,sleByte), + MKLINE(ObjectData,numstrips,sleByte), + MKLINE(ObjectData,height,sleByte), + MKLINE(ObjectData,actordir,sleByte), + MKLINE(ObjectData,parentstate,sleByte), + MKLINE(ObjectData,parent,sleByte), + MKLINE(ObjectData,ownerstate,sleByte), + MKLINE(ObjectData,fl_object_index,sleByte), + MKLINE(ObjectData,unk_3,sleByte), + MKEND() + }; + + const SaveLoadEntry actorEntries[] = { + MKLINE(Actor,x,sleInt16), + MKLINE(Actor,y,sleInt16), + MKLINE(Actor,top,sleInt16), + MKLINE(Actor,bottom,sleInt16), + MKLINE(Actor,elevation,sleInt16), + MKLINE(Actor,width,sleUint16), + MKLINE(Actor,facing,sleByte), + MKLINE(Actor,costume,sleByte), + MKLINE(Actor,room,sleByte), + MKLINE(Actor,talkColor,sleByte), + MKLINE(Actor,scalex,sleByte), + MKLINE(Actor,scaley,sleByte), + MKLINE(Actor,charset,sleByte), + MKLINE(Actor,sound,sleByte), + MKLINE(Actor,newDirection,sleByte), + MKLINE(Actor,moving,sleByte), + MKLINE(Actor,ignoreBoxes,sleByte), + MKLINE(Actor,neverZClip,sleByte), + MKLINE(Actor,initFrame,sleByte), + MKLINE(Actor,walkFrame,sleByte), + MKLINE(Actor,standFrame,sleByte), + MKLINE(Actor,talkFrame1,sleByte), + MKLINE(Actor,talkFrame2,sleByte), + MKLINE(Actor,speedx,sleUint16), + MKLINE(Actor,speedy,sleUint16), + MKLINE(Actor,cost.animCounter1,sleUint16), + MKLINE(Actor,cost.animCounter2,sleByte), + MKARRAY(Actor,palette[0],sleByte,32), + MKLINE(Actor,mask,sleByte), + MKLINE(Actor,visible,sleByte), + MKLINE(Actor,animIndex,sleByte), + MKLINE(Actor,animSpeed,sleByte), + MKLINE(Actor,animProgress,sleByte), + MKLINE(Actor,walkbox,sleByte), + MKLINE(Actor,needRedraw,sleByte), + MKLINE(Actor,needBgReset,sleByte), + MKLINE(Actor,costumeNeedsInit,sleByte), + + MKLINE(Actor,walkdata.destx,sleInt16), + MKLINE(Actor,walkdata.desty,sleInt16), + MKLINE(Actor,walkdata.destbox,sleByte), + MKLINE(Actor,walkdata.destdir,sleByte), + MKLINE(Actor,walkdata.curbox,sleByte), + MKLINE(Actor,walkdata.field_7,sleByte), + MKLINE(Actor,walkdata.x,sleInt16), + MKLINE(Actor,walkdata.y,sleInt16), + MKLINE(Actor,walkdata.newx,sleInt16), + MKLINE(Actor,walkdata.newy,sleInt16), + MKLINE(Actor,walkdata.XYFactor,sleInt32), + MKLINE(Actor,walkdata.YXFactor,sleInt32), + MKLINE(Actor,walkdata.xfrac,sleUint16), + MKLINE(Actor,walkdata.yfrac,sleUint16), + + MKLINE(Actor,cost.hdr,sleUint16), + MKARRAY(Actor,cost.a[0],sleUint16,16), + MKARRAY(Actor,cost.b[0],sleUint16,16), + MKARRAY(Actor,cost.c[0],sleUint16,16), + MKARRAY(Actor,cost.d[0],sleUint16,16), + MKEND() + }; + + const SaveLoadEntry verbEntries[] = { + MKLINE(VerbSlot,x,sleInt16), + MKLINE(VerbSlot,y,sleInt16), + MKLINE(VerbSlot,right,sleInt16), + MKLINE(VerbSlot,bottom,sleInt16), + MKLINE(VerbSlot,oldleft,sleInt16), + MKLINE(VerbSlot,oldtop,sleInt16), + MKLINE(VerbSlot,oldright,sleInt16), + MKLINE(VerbSlot,oldbottom,sleInt16), + MKLINE(VerbSlot,verbid,sleByte), + MKLINE(VerbSlot,color,sleByte), + MKLINE(VerbSlot,hicolor,sleByte), + MKLINE(VerbSlot,dimcolor,sleByte), + MKLINE(VerbSlot,bkcolor,sleByte), + MKLINE(VerbSlot,type,sleByte), + MKLINE(VerbSlot,charset_nr,sleByte), + MKLINE(VerbSlot,curmode,sleByte), + MKLINE(VerbSlot,saveid,sleByte), + MKLINE(VerbSlot,key,sleByte), + MKLINE(VerbSlot,center,sleByte), + MKLINE(VerbSlot,field_1B,sleByte), + MKLINE(VerbSlot,imgindex,sleUint16), + MKEND() + }; + + const SaveLoadEntry mainEntries[] = { + MKLINE(Scumm,_scrWidthIn8Unit,sleUint16), + MKLINE(Scumm,_scrHeight,sleUint16), + MKLINE(Scumm,_ENCD_offs,sleUint32), + MKLINE(Scumm,_EXCD_offs,sleUint32), + MKLINE(Scumm,_IM00_offs,sleUint32), + MKLINE(Scumm,_CLUT_offs,sleUint32), + MKLINE(Scumm,_EPAL_offs,sleUint32), + MKLINE(Scumm,_currentRoom,sleByte), + MKLINE(Scumm,_roomResource,sleByte), + MKLINE(Scumm,_numObjectsInRoom,sleByte), + MKLINE(Scumm,_currentScript,sleByte), + MKARRAY(Scumm,_localScriptList[0],sleUint32,0x39), + MKARRAY(Scumm,vm.vars[0],sleUint16,801), + MKARRAY(Scumm,vm.localvar[0],sleUint16,20*17), + MKARRAY(Scumm,vm.bitvars[0],sleByte,256), + MKARRAY(Scumm,_resourceMapper[0],sleByte,128), + MKARRAY(Scumm,charset._colorMap[0],sleByte,16), + MKARRAY(Scumm,_charsetData[0][0],sleByte,10*16), + MKLINE(Scumm,_curExecScript,sleUint16), + + MKLINE(Scumm,camera._destPos,sleInt16), + MKLINE(Scumm,camera._curPos,sleInt16), + MKLINE(Scumm,camera._lastPos,sleInt16), + MKLINE(Scumm,_screenStartStrip,sleInt16), + MKLINE(Scumm,_screenEndStrip,sleInt16), + MKLINE(Scumm,_scummTimer,sleInt16), + MKLINE(Scumm,camera._mode,sleByte), + MKLINE(Scumm,camera._follows,sleByte), + MKLINE(Scumm,camera._leftTrigger,sleInt16), + MKLINE(Scumm,camera._rightTrigger,sleInt16), + MKLINE(Scumm,camera._movingToActor,sleUint16), + + MKLINE(Scumm,_actorToPrintStrFor,sleByte), + MKLINE(Scumm,_charsetColor,sleByte), + MKLINE(Scumm,charset._bufPos,sleByte), + MKLINE(Scumm,_haveMsg,sleByte), + + MKLINE(Scumm,_talkDelay,sleInt16), + MKLINE(Scumm,_defaultTalkDelay,sleInt16), + MKLINE(Scumm,_numInMsgStack,sleInt16), + 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), + MKARRAY(Scumm,vm.cutScenePtr[0],sleUint32,5), + MKARRAY(Scumm,vm.cutSceneScript[0],sleByte,5), + MKARRAY(Scumm,vm.cutSceneData[0],sleInt16,5), + MKLINE(Scumm,vm.cutSceneScriptIndex,sleInt16), + + /* nest */ + MKLINE(Scumm,_numNestedScripts,sleByte), + MKLINE(Scumm,_userPut,sleByte), + MKLINE(Scumm,_cursorState,sleByte), + MKLINE(Scumm,gdi.unk4,sleByte), + MKLINE(Scumm,gdi.currentCursor,sleByte), +// MKLINE(Scumm,gdi.unk3,sleByte), + + MKLINE(Scumm,dseg_4F8A,sleUint16), + MKLINE(Scumm,_switchRoomEffect,sleByte), + MKLINE(Scumm,_newEffect,sleByte), + MKLINE(Scumm,_switchRoomEffect2,sleByte), + MKLINE(Scumm,_BgNeedsRedraw,sleByte), + + MKARRAY(Scumm,actorDrawBits[0],sleUint16,160), + MKLINE(Scumm,gdi.transparency,sleByte), + MKARRAY(Scumm,_currentPalette[0],sleByte,768), + + /* virtscr */ + + 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), + + MKARRAY(Scumm,_imgBufOffs[0],sleUint16,4), + MKLINE(Scumm,_numZBuffer,sleUint16), + + MKLINE(Scumm,dseg_4EA0,sleUint16), + MKLINE(Scumm,dseg_4EA0,sleUint16), + + MKLINE(Scumm,_randSeed1,sleUint32), + MKLINE(Scumm,_randSeed2,sleUint32), + + MKLINE(Scumm,_shakeMode,sleInt16), + + MKLINE(Scumm,_keepText,sleByte), + + MKLINE(Scumm,_screenB,sleUint16), + MKLINE(Scumm,_screenH,sleUint16), + + MKARRAY(Scumm,_colorCycleDelays[0],sleUint16,17), + MKARRAY(Scumm,_colorCycleCounter[0],sleUint16,17), + MKARRAY(Scumm,_colorCycleFlags[0],sleUint16,17), + MKARRAY(Scumm,_colorCycleStart[0],sleByte,17), + MKARRAY(Scumm,_colorCycleEnd[0],sleByte,17), + + MKARRAY(Scumm,cost._transEffect[0],sleByte,256), + MKEND() + }; + + const SaveLoadEntry scriptSlotEntries[] = { + MKLINE(ScriptSlot,offs,sleUint32), + MKLINE(ScriptSlot,delay,sleInt32), + MKLINE(ScriptSlot,number,sleUint16), + MKLINE(ScriptSlot,status,sleByte), + MKLINE(ScriptSlot,type,sleByte), + MKLINE(ScriptSlot,unk1,sleByte), + MKLINE(ScriptSlot,unk2,sleByte), + MKLINE(ScriptSlot,freezeCount,sleByte), + MKLINE(ScriptSlot,didexec,sleByte), + MKLINE(ScriptSlot,cutsceneOverride,sleByte), + MKLINE(ScriptSlot,unk5,sleByte), + MKEND() + }; + + const SaveLoadEntry nestedScriptEntries[] = { + MKLINE(NestedScript,number,sleUint16), + MKLINE(NestedScript,type,sleByte), + MKLINE(NestedScript,slot,sleByte), + MKEND() + }; + + int i,j; + _saveLoadStream = inout; _saveOrLoad = mode; + + saveLoadEntries(this,mainEntries); + for (i=1; i<13; i++) + saveLoadEntries(&actor[i],actorEntries); + for (i=0; i<20; i++) + saveLoadEntries(&vm.slot[i],scriptSlotEntries); + for (i=0; i<184; i++) + saveLoadEntries(&objs[i],objectEntries); + for (i=0; i<102; i++) + saveLoadEntries(&verbs[i],verbEntries); + for (i=0; i<16; i++) + saveLoadEntries(&vm.nest[i],nestedScriptEntries); + + for (i=1; i<16; i++) + if (res.mode[i]==0) + for(j=1; jsize; + + saveUint32(size); + saveLoadBytes(ptr+sizeof(ResHeader),size); + + if (type==5) { + saveWord(_inventory[index]); + } + } else { + size = loadUint32(); + if (size) { + createResource(type, index, size); + saveLoadBytes(getResourceAddress(type, index), size); + if (type==5) { + _inventory[index] = loadWord(); + } + } + } +} void Scumm::saveLoadBytes(void *b, int len) { if (_saveOrLoad) @@ -57,3 +421,109 @@ void Scumm::saveLoadBytes(void *b, int len) { else fread(b, 1, len, _saveLoadStream); } + +void Scumm::saveUint32(uint32 d) { + uint32 e = FROM_LE_32(d); + saveLoadBytes(&e,4); +} + +void Scumm::saveWord(uint16 d) { + uint16 e = FROM_LE_16(d); + saveLoadBytes(&e,2); +} + +void Scumm::saveByte(byte b) { + saveLoadBytes(&b,1); +} + +uint32 Scumm::loadUint32() { + uint32 e; + saveLoadBytes(&e,4); + return FROM_LE_32(e); +} + +uint16 Scumm::loadWord() { + uint16 e; + saveLoadBytes(&e,2); + return FROM_LE_16(e); +} + +byte Scumm::loadByte() { + byte e; + saveLoadBytes(&e,1); + return e; +} + + +void Scumm::saveLoadEntries(void *d, const SaveLoadEntry *sle) { + int replen; + byte type; + byte *at; + int size; + int value; + uint32 data; + + while(sle->offs != 0xFFFF) { + at = (byte*)d + sle->offs; + size = sle->size; + type = sle->type; + replen = 1; + if (type&128) { + sle++; + replen = sle->offs; + type&=~128; + } + sle++; + + 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); + } +} + diff --git a/scumm.h b/scumm.h index 659a4fb1c57..942b77db2c0 100644 --- a/scumm.h +++ b/scumm.h @@ -17,6 +17,10 @@ * * Change Log: * $Log$ + * Revision 1.5 2001/10/10 10:02:33 strigeus + * alternative mouse cursor + * basic save&load + * * Revision 1.4 2001/10/09 19:02:28 strigeus * command line parameter support * @@ -133,7 +137,12 @@ struct NestedScript { uint8 slot; }; -struct ObjectData { +struct ResHeader { + uint32 size; +}; + +class ObjectData { +public: uint32 offs_obim_to_room; uint32 offs_obcd_to_room; uint16 cdhd_10, cdhd_12; @@ -174,6 +183,8 @@ struct ImageHeader { /* file format */ uint16 obj_id; }; +#pragma END_PACK_STRUCTS + struct PathNode { uint index; struct PathNode *left, *right; @@ -184,7 +195,19 @@ struct PathVertex { PathNode *right; }; -#pragma END_PACK_STRUCTS +struct SaveLoadEntry { + uint16 offs; + uint8 type; + uint8 size; +}; + +enum { + sleByte = 1, + sleInt16 = 2, + sleUint16 = 3, + sleInt32 = 4, + sleUint32 = 5 +}; enum ScummVars { VAR_UNK_ACTOR = 1, @@ -344,6 +367,7 @@ struct CostumeRenderer { byte _height2; int _height; int _xpos, _ypos; + int _scaleIndexXStep; int _scaleIndexYStep; byte _scaleIndexX; /* must wrap at 256*/ @@ -419,6 +443,8 @@ struct Scumm { byte _encbyte; void *_fileHandle; char *_exe_name; + + int _saveLoadSlot; bool _dynamicRoomOffsets; byte _resFilePathId; @@ -441,6 +467,8 @@ struct Scumm { uint32 _randSeed1; uint32 _randSeed2; + uint16 _screenB, _screenH; + uint16 dseg_3A76; uint16 _defaultTalkDelay; uint16 _lightsValueA,_lightsValueB; @@ -505,7 +533,6 @@ struct Scumm { int8 _userPut; int8 _cursorState; - uint16 _mouseButStat; byte _leftBtnPressed, _rightBtnPressed; @@ -516,6 +543,7 @@ struct Scumm { uint32 _ENCD_offs, _EXCD_offs; uint32 _CLUT_offs, _EPAL_offs; + uint32 _IM00_offs; int _drawObjectQueNr; byte _drawObjectQue[0xC8]; @@ -544,8 +572,6 @@ struct Scumm { struct { int16 vars[801]; byte bitvars[256]; - uint16 scriptoffs[180]; - uint16 inventory[80]; uint32 cutScenePtr[5]; byte cutSceneScript[5]; int16 cutSceneData[5]; @@ -560,7 +586,6 @@ struct Scumm { int16 x,y; } mouse; - struct { int16 x[6]; int16 y[6]; @@ -578,7 +603,6 @@ struct Scumm { uint16 drawHeight; uint16 drawWidth; uint16 draw8xPos; - uint16 unk3; int16 virtScreen; uint16 drawBottom; uint16 drawTop; @@ -610,7 +634,7 @@ struct Scumm { byte transparency; uint16 vertStripNextInc; byte *backupIsWhere; - byte mouseBackup[16*24]; +// byte mouseBackup[16*24]; } gdi; Actor actor[13]; @@ -634,11 +658,8 @@ struct Scumm { byte _resourceMapper[128]; - uint16 _resIndexToLoad, _resTypeToLoad; - byte **_lastCodePtr; - byte _dir; - + int _numSoundTags; byte *_soundTagTable; @@ -656,6 +677,7 @@ struct Scumm { byte _opcode; int _xPos, _yPos; + byte _dir; CameraData camera; @@ -694,15 +716,11 @@ struct Scumm { int16 _vararg_temp_pos[16]; - int16 _curExecScript; + uint16 _curExecScript; int _scrWidthIn8Unit; int _scrHeight; - uint32 _IM00_offs; - - int _colorsInPalette; - byte _currentPalette[0x300]; int _palDirtyMin, _palDirtyMax; @@ -734,8 +752,6 @@ struct Scumm { int16 _foundPathX; int16 _foundPathY; - uint16 _onlyActorFlags; - uint16 _lastKeyHit; int _scummStackPos; @@ -746,7 +762,6 @@ struct Scumm { int _boxPathVertexHeapIndex; int _boxMatrixItem; - /* all these can be made local */ byte *_msgPtrToAdd; void openRoom(int room); @@ -816,9 +831,6 @@ struct Scumm { void unkVirtScreen4(int a); void unkVirtScreen5(int a); - void removeMouseCursor(); - - void showMouseCursor(); void drawStripToScreen(); void restoreMouse(); void initActor(Actor *a, int mode); @@ -1207,6 +1219,19 @@ struct Scumm { bool loadState(const char *filename); void saveOrLoad(FILE *inout, bool mode); void saveLoadBytes(void *b, int len); + void saveLoadResource(int type, int index); + bool isResourceLoaded(int type, int index); + + void saveLoadEntries(void *d, const SaveLoadEntry *sle); + + void saveUint32(uint32 d); + void saveWord(uint16 d); + void saveByte(byte b); + + byte loadByte(); + uint16 loadWord(); + uint32 loadUint32(); + Actor *derefActor(int id) { return &actor[id]; } Actor *derefActorSafe(int id, const char *errmsg); @@ -1224,6 +1249,7 @@ struct Scumm { void parseCommandLine(int argc, char **argv); void showHelpAndExit(); + }; void waitForTimer(Scumm *s); @@ -1237,3 +1263,5 @@ void CDECL debug(int level, const char *s, ...); void checkHeap(); void initGraphics(Scumm *s); void updateScreen(Scumm *s); + +void drawMouse(Scumm *s, int x, int y, int color, byte *mask, bool visible); \ No newline at end of file diff --git a/scummvm.cpp b/scummvm.cpp index 3010e95f769..0f69609b3e1 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -17,6 +17,10 @@ * * Change Log: * $Log$ + * Revision 1.4 2001/10/10 10:02:33 strigeus + * alternative mouse cursor + * basic save&load + * * Revision 1.3 2001/10/09 19:02:28 strigeus * command line parameter support * @@ -83,8 +87,6 @@ void Scumm::scummInit() { memset(vm.vars, 0, sizeof(vm.vars)); memset(vm.bitvars, 0, sizeof(vm.bitvars)); - memset(vm.scriptoffs, 0, sizeof(vm.scriptoffs)); - memset(vm.inventory, 0, sizeof(vm.inventory)); _defaultTalkDelay = 60; vm.vars[37] = 4; @@ -165,7 +167,7 @@ void Scumm::scummInit() { _numInMsgStack = 0; - createResource(0xC, 6, 500); + createResource(12, 6, 500); initScummVars(); @@ -200,8 +202,6 @@ void Scumm::scummMain(int argc, char **argv) { charset._vm = this; cost._vm = this; - _exe_name = "monkey2"; - _fileHandle = NULL; _bootParam = 0; @@ -262,7 +262,14 @@ void Scumm::scummMain(int argc, char **argv) { vm.vars[VAR_DEBUGMODE] = _debugMode; if (_saveLoadFlag) { - error("Loading/saving not implemented"); + char buf[256]; + sprintf(buf, "savegame.%d", _saveLoadSlot); + if (_saveLoadFlag==1) { + saveState(buf); + } else { + loadState(buf); + } + _saveLoadFlag = 0; } if (_completeScreenRedraw) { @@ -275,9 +282,13 @@ void Scumm::scummMain(int argc, char **argv) { a->needRedraw = 1; } + checkHeap(); runAllScripts(); + checkHeap(); checkExecVerbs(); + checkHeap(); checkAndRunVar33(); + checkHeap(); if (_currentRoom==0) { gdi.unk4 = 0; @@ -288,25 +299,38 @@ void Scumm::scummMain(int argc, char **argv) { continue; } + checkHeap(); walkActors(); + checkHeap(); moveCamera(); + checkHeap(); fixObjectFlags(); + checkHeap(); CHARSET_1(); + checkHeap(); if (camera._curPos != camera._lastPos || _BgNeedsRedraw || _fullRedraw) { redrawBGAreas(); + checkHeap(); } processDrawQue(); + checkHeap(); setActorRedrawFlags(); + checkHeap(); resetActorBgs(); + checkHeap(); if (!(vm.vars[VAR_DRAWFLAGS]&2) && vm.vars[VAR_DRAWFLAGS]&4) { error("Flashlight not implemented in this version"); } processActors(); /* process actors makes the heap invalid */ + checkHeap(); clear_fullRedraw(); + checkHeap(); cyclePalette(); + checkHeap(); palManipulate(); + checkHeap(); if (dseg_4F8A) { screenEffect(_newEffect); @@ -369,7 +393,6 @@ void Scumm::startScene(int room, Actor *a, int objectNr) { checkHeap(); - removeMouseCursor(); clearMsgQueue(); unkVirtScreen4(_switchRoomEffect2); @@ -511,7 +534,7 @@ void Scumm::initRoomSubBlocks() { ptr = findResource(MKID('BOXD'), roomptr); if (ptr) { int size = READ_BE_UINT32_UNALIGNED(ptr+4); - createResource(0xE, 2, size); + createResource(14, 2, size); roomptr = getResourceAddress(1, _roomResource); ptr = findResource(MKID('BOXD'), roomptr); memcpy(getResourceAddress(0xE, 2), ptr, size); @@ -520,7 +543,7 @@ void Scumm::initRoomSubBlocks() { ptr = findResource(MKID('BOXM'), roomptr); if (ptr) { int size = READ_BE_UINT32_UNALIGNED(ptr+4); - createResource(0xE, 1, size); + createResource(14, 1, size); roomptr = getResourceAddress(1, _roomResource); ptr = findResource(MKID('BOXM'), roomptr); memcpy(getResourceAddress(0xE, 1), ptr, size); @@ -579,7 +602,7 @@ void Scumm::setScaleItem(int slot, int a, int b, int c, int d) { byte *ptr; int cur,amounttoadd,i,tmp; - ptr = createResource(0xB, slot, 200); + ptr = createResource(11, slot, 200); if (a==c) return; @@ -835,10 +858,11 @@ void CDECL debug(int level, const char *s, ...) { } void checkHeap() { -#if 0 - if (_heapchk() != _HEAPOK) { - error("Heap is invalid!"); - } +#if 1 + +//if (_heapchk() != _HEAPOK) { +// error("Heap is invalid!"); +// } #endif } diff --git a/scummvm.dsp b/scummvm.dsp index 64daceb22bf..6aa598cb934 100644 --- a/scummvm.dsp +++ b/scummvm.dsp @@ -1,175 +1,175 @@ -# Microsoft Developer Studio Project File - Name="scummvm" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=scummvm - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "scummvm.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "scummvm.mak" CFG="scummvm - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "scummvm - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "scummvm - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "scummvm - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /Zp4 /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c -# ADD BASE RSC /l 0x41d /d "NDEBUG" -# ADD RSC /l 0x41d /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "scummvm - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c -# ADD BASE RSC /l 0x41d /d "_DEBUG" -# ADD RSC /l 0x41d /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "scummvm - Win32 Release" -# Name "scummvm - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\actor.cpp -# End Source File -# Begin Source File - -SOURCE=.\boxes.cpp -# End Source File -# Begin Source File - -SOURCE=.\costume.cpp -# End Source File -# Begin Source File - -SOURCE=.\gfx.cpp -# End Source File -# Begin Source File - -SOURCE=.\object.cpp -# End Source File -# Begin Source File - -SOURCE=.\resource.cpp -# End Source File -# Begin Source File - -SOURCE=.\saveload.cpp -# End Source File -# Begin Source File - -SOURCE=.\script.cpp -# End Source File -# Begin Source File - -SOURCE=.\scummvm.cpp -# End Source File -# Begin Source File - -SOURCE=.\sdl.cpp -# End Source File -# Begin Source File - -SOURCE=.\sound.cpp -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc"stdafx.h" -# End Source File -# Begin Source File - -SOURCE=.\string.cpp -# End Source File -# Begin Source File - -SOURCE=.\sys.cpp -# End Source File -# Begin Source File - -SOURCE=.\verbs.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\scumm.h -# End Source File -# Begin Source File - -SOURCE=.\scummsys.h -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# Begin Source File - -SOURCE=.\ReadMe.txt -# End Source File -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="scummvm" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=scummvm - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "scummvm.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "scummvm.mak" CFG="scummvm - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "scummvm - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "scummvm - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "scummvm - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /Zp4 /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x41d /d "NDEBUG" +# ADD RSC /l 0x41d /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "scummvm - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD BASE RSC /l 0x41d /d "_DEBUG" +# ADD RSC /l 0x41d /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "scummvm - Win32 Release" +# Name "scummvm - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\actor.cpp +# End Source File +# Begin Source File + +SOURCE=.\boxes.cpp +# End Source File +# Begin Source File + +SOURCE=.\costume.cpp +# End Source File +# Begin Source File + +SOURCE=.\gfx.cpp +# End Source File +# Begin Source File + +SOURCE=.\object.cpp +# End Source File +# Begin Source File + +SOURCE=.\resource.cpp +# End Source File +# Begin Source File + +SOURCE=.\saveload.cpp +# End Source File +# Begin Source File + +SOURCE=.\script.cpp +# End Source File +# Begin Source File + +SOURCE=.\scummvm.cpp +# End Source File +# Begin Source File + +SOURCE=.\sdl.cpp +# End Source File +# Begin Source File + +SOURCE=.\sound.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\string.cpp +# End Source File +# Begin Source File + +SOURCE=.\sys.cpp +# End Source File +# Begin Source File + +SOURCE=.\verbs.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\scumm.h +# End Source File +# Begin Source File + +SOURCE=.\scummsys.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/sdl.cpp b/sdl.cpp index d76164de70a..5127ab86573 100644 --- a/sdl.cpp +++ b/sdl.cpp @@ -17,6 +17,10 @@ * * Change Log: * $Log$ + * Revision 1.4 2001/10/10 10:02:33 strigeus + * alternative mouse cursor + * basic save&load + * * Revision 1.3 2001/10/09 19:02:28 strigeus * command line parameter support * @@ -69,6 +73,20 @@ void waitForTimer(Scumm *s) { switch(event.type) { case SDL_KEYDOWN: s->_keyPressed = event.key.keysym.sym; + if (event.key.keysym.sym >= '0' && event.key.keysym.sym<='9') { + s->_saveLoadSlot = event.key.keysym.sym - '0'; + if (event.key.keysym.mod&KMOD_SHIFT) + s->_saveLoadFlag = 1; + else if (event.key.keysym.mod&KMOD_CTRL) + s->_saveLoadFlag = 2; + } + if (event.key.keysym.sym=='z' && event.key.keysym.mod&KMOD_CTRL) { + exit(1); + } + if (event.key.keysym.sym=='f' && event.key.keysym.mod&KMOD_CTRL) { + s->_fastMode ^= 1; + } + break; case SDL_MOUSEMOTION: #if !defined(SCALEUP_2x2) @@ -108,36 +126,13 @@ SDL_Rect dirtyRects[MAX_DIRTY_RECTS]; int numDirtyRects; bool fullRedraw; -/* Copy part of bitmap */ -void blitToScreen(Scumm *s, byte *src,int x, int y, int w, int h) { - byte *dst; +int old_mouse_x, old_mouse_y; +bool has_mouse,hide_mouse; +byte old_backup[24*16*2]; + + +void addDirtyRect(int x, int y, int w, int h) { SDL_Rect *r; - int i; - - if (SDL_LockSurface(screen)==-1) - error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - -#if !defined(SCALEUP_2x2) - dst = (byte*)screen->pixels + y*320 + x; - - if (numDirtyRects==MAX_DIRTY_RECTS) - fullRedraw = true; - else if (!fullRedraw) { - r = &dirtyRects[numDirtyRects++]; - r->x = x; - r->y = y; - r->w = w; - r->h = h; - } - - do { - memcpy(dst, src, w); - dst += 640; - src += 320; - } while (--h); -#else - dst = (byte*)screen->pixels + y*640*2 + x*2; - if (numDirtyRects==MAX_DIRTY_RECTS) fullRedraw = true; else if (!fullRedraw) { @@ -147,7 +142,40 @@ void blitToScreen(Scumm *s, byte *src,int x, int y, int w, int h) { r->w = w*2; r->h = h*2; } - +} + +void addDirtyRectClipped(int x, int y, int w, int h) { + if (x<0) { w += x; x=0; } + if (y<0) { h += y; y=0; } + if (w >= 320-x) w = 320-x; + if (h >= 200-y) h = 200-y; + addDirtyRect(x,y,w,h); +} + +/* Copy part of bitmap */ +void blitToScreen(Scumm *s, byte *src,int x, int y, int w, int h) { + byte *dst; + int i; + + hide_mouse = true; + if (has_mouse) { + s->drawMouse(); + } + + if (SDL_LockSurface(screen)==-1) + error("SDL_LockSurface failed: %s.\n", SDL_GetError()); + +#if !defined(SCALEUP_2x2) + dst = (byte*)screen->pixels + y*320 + x; + addDirtyRect(x,y,w,h); + do { + memcpy(dst, src, w); + dst += 640; + src += 320; + } while (--h); +#else + dst = (byte*)screen->pixels + y*640*2 + x*2; + addDirtyRect(x,y,w,h); do { i=0; do { @@ -164,7 +192,12 @@ void blitToScreen(Scumm *s, byte *src,int x, int y, int w, int h) { } void updateScreen(Scumm *s) { - + + if (hide_mouse) { + hide_mouse = false; + s->drawMouse(); + } + if(s->_palDirtyMax != -1) { updatePalette(s); } @@ -184,10 +217,73 @@ void updateScreen(Scumm *s) { SDL_UpdateRects(screen, numDirtyRects, dirtyRects); } - numDirtyRects = 0; } +void drawMouse(Scumm *s, int xdraw, int ydraw, int color, byte *mask, bool visible) { + int x,y; + uint32 bits; + byte *dst,*bak; + + if (hide_mouse) + visible = false; + + if (SDL_LockSurface(screen)==-1) + error("SDL_LockSurface failed: %s.\n", SDL_GetError()); + + if (has_mouse) { + dst = (byte*)screen->pixels + old_mouse_y*640*2 + old_mouse_x*2; + bak = old_backup; + + for (y=0; y<16; y++,bak+=48,dst+=640*2) { + if ( (uint)(old_mouse_y + y) < 200) { + for (x=0; x<24; x++) { + if ((uint)(old_mouse_x + x) < 320) { + dst[x*2+640] = dst[x*2] = bak[x*2]; + dst[x*2+640+1] = dst[x*2+1] = bak[x*2+1]; + } + } + } + } + } + + if (visible) { + dst = (byte*)screen->pixels + ydraw*640*2 + xdraw*2; + bak = old_backup; + + for (y=0; y<16; y++,dst+=640*2,bak+=48) { + bits = mask[3] | (mask[2]<<8) | (mask[1]<<16); + mask += 4; + if ((uint)(ydraw+y)<200) { + memcpy(bak,dst,48); + for (x=0; bits; x++,bits>>=1) { + if (bits&1 && (uint)(xdraw+x)<320) { + dst[x*2] = color; + dst[x*2+1] = color; + dst[x*2+640] = color; + dst[x*2+1+640] = color; + } + } + } + } + } + + SDL_UnlockSurface(screen); + + if (has_mouse) { + has_mouse = false; + addDirtyRectClipped(old_mouse_x, old_mouse_y, 24, 16); + } + + if (visible) { + has_mouse = true; + addDirtyRectClipped(xdraw, ydraw, 24, 16); + old_mouse_x = xdraw; + old_mouse_y = ydraw; + } + +} + void initGraphics(Scumm *s) { if (SDL_Init(SDL_INIT_VIDEO)==-1) { error("Could not initialize SDL: %s.\n", SDL_GetError()); @@ -197,20 +293,23 @@ void initGraphics(Scumm *s) { /* Clean up on exit */ atexit(SDL_Quit); + SDL_WM_SetCaption("ScummVM - Monkey Island 2: LeChuck's revenge","ScummVM - Monkey Island 2: LeChuck's revenge"); + #if !defined(SCALEUP_2x2) screen = SDL_SetVideoMode(320, 200, 8, SDL_SWSURFACE); #else screen = SDL_SetVideoMode(640, 400, 8, SDL_SWSURFACE); #endif - printf("%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 %d\n", sizeof(int8), sizeof(uint8), sizeof(int16), sizeof(uint16), sizeof(int32), sizeof(uint32), sizeof(void*), sizeof(Box), sizeof(MouseCursor),sizeof(CodeHeader), sizeof(ImageHeader), - &((CodeHeader*)0)->unk4 + &((CodeHeader*)0)->unk4, + sizeof(Scumm) ); @@ -218,6 +317,7 @@ void initGraphics(Scumm *s) { #undef main int main(int argc, char* argv[]) { + scumm._exe_name = "monkey2"; scumm._videoMode = 0x13; scumm.scummMain(argc, argv); return 0; diff --git a/sys.cpp b/sys.cpp index 5b75bbf1c4f..6d71570b571 100644 --- a/sys.cpp +++ b/sys.cpp @@ -17,8 +17,13 @@ * * Change Log: * $Log$ - * Revision 1.1 2001/10/09 14:30:13 strigeus - * Initial revision + * Revision 1.2 2001/10/10 10:02:33 strigeus + * alternative mouse cursor + * basic save&load + * + * Revision 1.1.1.1 2001/10/09 14:30:13 strigeus + * + * initial revision * * */ @@ -144,6 +149,9 @@ uint32 Scumm::fileReadDwordBE() { byte *Scumm::alloc(int size) { byte *me = (byte*)::calloc(size+4,1); + if (me==NULL) + return NULL; + *((uint32*)me) = 0xDEADBEEF; return me + 4; } diff --git a/windows.cpp b/windows.cpp index 1a961ba1c08..5daf10916d2 100644 --- a/windows.cpp +++ b/windows.cpp @@ -17,6 +17,10 @@ * * Change Log: * $Log$ + * Revision 1.3 2001/10/10 10:02:33 strigeus + * alternative mouse cursor + * basic save&load + * * Revision 1.2 2001/10/09 19:02:28 strigeus * command line parameter support * @@ -135,6 +139,17 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l case WM_CHAR: wm->_scumm->_keyPressed = wParam; break; + + case WM_KEYDOWN: + if (wParam>='0' && wParam<='9') { + wm->_scumm->_saveLoadSlot = wParam - '0'; + if (GetAsyncKeyState(VK_SHIFT)<0) + wm->_scumm->_saveLoadFlag = 1; + else if (GetAsyncKeyState(VK_CONTROL)<0) + wm->_scumm->_saveLoadFlag = 2; + } + break; + case WM_MOUSEMOVE: wm->_scumm->mouse.x = ((int16*)&lParam)[0]; wm->_scumm->mouse.y = ((int16*)&lParam)[1]; @@ -196,7 +211,6 @@ void copy_320x200_to_640x400(byte *s, byte *d) { } } - bool WndMan::allocateDIB(int w, int h) { struct { BITMAPINFOHEADER bih; @@ -783,11 +797,13 @@ void initGraphics(Scumm *s) { #undef main int main(int argc, char* argv[]) { scumm._videoMode = 0x13; + scumm._exe_name = "monkey2"; wm->init(); wm->_vgabuf = (byte*)calloc(320,200); wm->_scumm = &scumm; + scumm.scummMain(argc, argv); return 0;