diff options
Diffstat (limited to 'engines/dreamweb')
-rw-r--r-- | engines/dreamweb/dreamgen.cpp | 554 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.h | 49 | ||||
-rw-r--r-- | engines/dreamweb/module.mk | 1 | ||||
-rw-r--r-- | engines/dreamweb/object.cpp | 154 | ||||
-rw-r--r-- | engines/dreamweb/saveload.cpp | 21 | ||||
-rw-r--r-- | engines/dreamweb/sprite.cpp | 155 | ||||
-rw-r--r-- | engines/dreamweb/structs.h | 12 | ||||
-rw-r--r-- | engines/dreamweb/stubs.cpp | 433 | ||||
-rw-r--r-- | engines/dreamweb/stubs.h | 15 | ||||
-rw-r--r-- | engines/dreamweb/talk.cpp | 40 |
10 files changed, 640 insertions, 794 deletions
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 8f4b4cea21..73ed6f121d 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2262,129 +2262,6 @@ forgotone: setuptimeduse(); } -void DreamGenContext::initrain() { - STACK_CHECK; - es = data.word(kBuffers); - di = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80)+(250*4)+(256*30)); - bx = offset_rainlocations; -checkmorerain: - al = cs.byte(bx); - _cmp(al, 255); - if (flags.z()) - goto finishinitrain; - _cmp(al, data.byte(kReallocation)); - if (!flags.z()) - goto checkrain; - al = cs.byte(bx+1); - _cmp(al, data.byte(kMapx)); - if (!flags.z()) - goto checkrain; - al = cs.byte(bx+2); - _cmp(al, data.byte(kMapy)); - if (!flags.z()) - goto checkrain; - al = cs.byte(bx+3); - data.byte(kRainspace) = al; - goto dorain; -checkrain: - _add(bx, 4); - goto checkmorerain; -dorain: - cx = 4; -initraintop: - randomnumber(); - _and(al, 31); - _add(al, 3); - _cmp(al, data.byte(kRainspace)); - if (!flags.c()) - goto initraintop; - _add(cl, al); - _cmp(cl, data.byte(kMapxsize)); - if (!flags.c()) - goto initrainside; - push(cx); - splitintolines(); - cx = pop(); - goto initraintop; -initrainside: - cl = data.byte(kMapxsize); - _dec(cl); -initrainside2: - randomnumber(); - _and(al, 31); - _add(al, 3); - _cmp(al, data.byte(kRainspace)); - if (!flags.c()) - goto initrainside2; - _add(ch, al); - _cmp(ch, data.byte(kMapysize)); - if (!flags.c()) - goto finishinitrain; - push(cx); - splitintolines(); - cx = pop(); - goto initrainside2; -finishinitrain: - al = 255; - _stosb(); -} - -void DreamGenContext::splitintolines() { - STACK_CHECK; -lookforlinestart: - getblockofpixel(); - _cmp(al, 0); - if (!flags.z()) - goto foundlinestart; - _dec(cl); - _inc(ch); - _cmp(cl, 0); - if (flags.z()) - return /* (endofthisline) */; - _cmp(ch, data.byte(kMapysize)); - if (!flags.c()) - return /* (endofthisline) */; - goto lookforlinestart; -foundlinestart: - es.word(di) = cx; - bh = 1; -lookforlineend: - getblockofpixel(); - _cmp(al, 0); - if (flags.z()) - goto foundlineend; - _dec(cl); - _inc(ch); - _cmp(cl, 0); - if (flags.z()) - goto foundlineend; - _cmp(ch, data.byte(kMapysize)); - if (!flags.c()) - goto foundlineend; - _inc(bh); - goto lookforlineend; -foundlineend: - push(cx); - es.byte(di+2) = bh; - randomnumber(); - es.byte(di+3) = al; - randomnumber(); - es.byte(di+4) = al; - randomnumber(); - _and(al, 3); - _add(al, 4); - es.byte(di+5) = al; - _add(di, 6); - cx = pop(); - _cmp(cl, 0); - if (flags.z()) - return /* (endofthisline) */; - _cmp(ch, data.byte(kMapysize)); - if (!flags.c()) - return /* (endofthisline) */; - goto lookforlinestart; -} - void DreamGenContext::liftnoise() { STACK_CHECK; _cmp(data.byte(kReallocation), 5); @@ -3851,81 +3728,6 @@ findopen2a: goto findopen1a; } -void DreamGenContext::examineob() { - STACK_CHECK; - data.byte(kPointermode) = 0; - data.word(kTimecount) = 0; -examineagain: - data.byte(kInmaparea) = 0; - data.byte(kExamagain) = 0; - data.byte(kOpenedob) = 255; - data.byte(kOpenedtype) = 255; - data.byte(kInvopen) = 0; - al = data.byte(kCommandtype); - data.byte(kObjecttype) = al; - data.byte(kItemframe) = 0; - data.byte(kPointerframe) = 0; - createpanel(); - showpanel(); - showman(); - showexit(); - obicons(); - obpicture(); - describeob(); - undertextline(); - data.byte(kCommandtype) = 255; - readmouse(); - showpointer(); - worktoscreen(); - delpointer(); -waitexam: - readmouse(); - showpointer(); - vsync(); - dumppointer(); - dumptextline(); - delpointer(); - data.byte(kGetback) = 0; - bx = offset_examlist; - _cmp(data.byte(kInvopen), 0); - if (flags.z()) - goto notuseinv; - bx = offset_invlist1; - _cmp(data.byte(kInvopen), 1); - if (flags.z()) - goto notuseinv; - bx = offset_withlist1; -notuseinv: - checkcoords(); - _cmp(data.byte(kQuitrequested), 0); - if (!flags.z()) - goto stopwaiting; - _cmp(data.byte(kExamagain), 0); - if (flags.z()) - goto norex; - goto examineagain; -norex: - _cmp(data.byte(kGetback), 0); - if (flags.z()) - goto waitexam; -stopwaiting: - data.byte(kPickup) = 0; - _cmp(data.word(kWatchingtime), 0); - if (!flags.z()) - goto iswatching; - _cmp(data.byte(kNewlocation), 255); - if (!flags.z()) - goto justgetback; -iswatching: - makemainscreen(); - data.byte(kInvopen) = 0; - data.byte(kOpenedob) = 255; - return; -justgetback: - data.byte(kInvopen) = 0; - data.byte(kOpenedob) = 255; -} - void DreamGenContext::makemainscreen() { STACK_CHECK; createpanel(); @@ -4233,126 +4035,6 @@ foundmatch: bx = pop(); } -void DreamGenContext::inventory() { - STACK_CHECK; - _cmp(data.byte(kMandead), 1); - if (flags.z()) - goto iswatchinv; - _cmp(data.word(kWatchingtime), 0); - if (flags.z()) - goto notwatchinv; -iswatchinv: - blank(); - return; -notwatchinv: - _cmp(data.byte(kCommandtype), 239); - if (flags.z()) - goto alreadyopinv; - data.byte(kCommandtype) = 239; - al = 32; - commandonly(); -alreadyopinv: - ax = data.word(kMousebutton); - _cmp(ax, data.word(kOldbutton)); - if (flags.z()) - return /* (cantopinv) */; - _and(ax, 1); - if (!flags.z()) - goto doopeninv; - return; -doopeninv: - data.word(kTimecount) = 0; - data.byte(kPointermode) = 0; - data.byte(kInmaparea) = 0; - animpointer(); - createpanel(); - showpanel(); - examicon(); - showman(); - showexit(); - undertextline(); - data.byte(kPickup) = 0; - data.byte(kInvopen) = 2; - openinv(); - readmouse(); - showpointer(); - worktoscreen(); - delpointer(); - data.byte(kOpenedob) = 255; - goto waitexam; - return; -/*continuing to unbounded code: examineagain from examineob:3-69*/ -examineagain: - data.byte(kInmaparea) = 0; - data.byte(kExamagain) = 0; - data.byte(kOpenedob) = 255; - data.byte(kOpenedtype) = 255; - data.byte(kInvopen) = 0; - al = data.byte(kCommandtype); - data.byte(kObjecttype) = al; - data.byte(kItemframe) = 0; - data.byte(kPointerframe) = 0; - createpanel(); - showpanel(); - showman(); - showexit(); - obicons(); - obpicture(); - describeob(); - undertextline(); - data.byte(kCommandtype) = 255; - readmouse(); - showpointer(); - worktoscreen(); - delpointer(); -waitexam: - readmouse(); - showpointer(); - vsync(); - dumppointer(); - dumptextline(); - delpointer(); - data.byte(kGetback) = 0; - bx = offset_examlist; - _cmp(data.byte(kInvopen), 0); - if (flags.z()) - goto notuseinv; - bx = offset_invlist1; - _cmp(data.byte(kInvopen), 1); - if (flags.z()) - goto notuseinv; - bx = offset_withlist1; -notuseinv: - checkcoords(); - _cmp(data.byte(kQuitrequested), 0); - if (!flags.z()) - goto stopwaiting; - _cmp(data.byte(kExamagain), 0); - if (flags.z()) - goto norex; - goto examineagain; -norex: - _cmp(data.byte(kGetback), 0); - if (flags.z()) - goto waitexam; -stopwaiting: - data.byte(kPickup) = 0; - _cmp(data.word(kWatchingtime), 0); - if (!flags.z()) - goto iswatching; - _cmp(data.byte(kNewlocation), 255); - if (!flags.z()) - goto justgetback; -iswatching: - makemainscreen(); - data.byte(kInvopen) = 0; - data.byte(kOpenedob) = 255; - return; -justgetback: - data.byte(kInvopen) = 0; - data.byte(kOpenedob) = 255; -} - void DreamGenContext::setpickup() { STACK_CHECK; _cmp(data.byte(kObjecttype), 1); @@ -5479,35 +5161,6 @@ void DreamGenContext::transfercontoex() { ds.byte(si+2) = 255; } -void DreamGenContext::transfertext() { - STACK_CHECK; - es = data.word(kExtras); - al = data.byte(kExpos); - ah = 0; - _add(ax, ax); - bx = (0+2080+30000+(16*114)); - _add(bx, ax); - di = data.word(kExtextpos); - es.word(bx) = di; - _add(di, (0+2080+30000+(16*114)+((114+2)*2))); - al = data.byte(kItemtotran); - ah = 0; - _add(ax, ax); - ds = data.word(kFreedesc); - bx = (0); - _add(bx, ax); - si = (0+(82*2)); - ax = ds.word(bx); - _add(si, ax); -moretext: - _lodsb(); - _stosb(); - _inc(data.word(kExtextpos)); - _cmp(al, 0); - if (!flags.z()) - goto moretext; -} - void DreamGenContext::purgealocation() { STACK_CHECK; push(ax); @@ -5950,31 +5603,6 @@ notnexttalk: data.byte(kVolumeto) = 0; } -void DreamGenContext::convicons() { - STACK_CHECK; - al = data.byte(kCharacter); - _and(al, 127); - getpersframe(); - di = 234; - bx = 2; - data.word(kCurrentframe) = ax; - findsource(); - ax = data.word(kCurrentframe); - _sub(ax, data.word(kTakeoff)); - ah = 0; - showframe(); -} - -void DreamGenContext::getpersframe() { - STACK_CHECK; - ah = 0; - _add(ax, ax); - bx = ax; - es = data.word(kPeople); - _add(bx, (0)); - ax = es.word(bx); -} - void DreamGenContext::starttalk() { STACK_CHECK; data.byte(kTalkmode) = 0; @@ -6377,23 +6005,6 @@ quittravel: deallocatemem(); } -void DreamGenContext::showcity() { - STACK_CHECK; - clearwork(); - ds = data.word(kTempgraphics); - di = 57; - bx = 32; - al = 0; - ah = 0; - showframe(); - ds = data.word(kTempgraphics); - di = 120+57; - bx = 32; - al = 1; - ah = 0; - showframe(); -} - void DreamGenContext::lookatplace() { STACK_CHECK; _cmp(data.byte(kCommandtype), 224); @@ -13682,16 +13293,6 @@ void DreamGenContext::checkforemm() { STACK_CHECK; } -void DreamGenContext::checkbasemem() { - STACK_CHECK; - bx = data.word(kHowmuchalloc); - _cmp(bx, 0x9360); - if (!flags.c()) - return /* (enoughmem) */; - data.byte(kGameerror) = 5; - { quickquit(); return; }; -} - void DreamGenContext::allocatebuffers() { STACK_CHECK; bx = (0+2080+30000+(16*114)+((114+2)*2)+18000)/16; @@ -13880,6 +13481,9 @@ void DreamGenContext::screenupdate() { STACK_CHECK; newplace(); mainscreen(); + _cmp(data.byte(kQuitrequested), 0); + if (!flags.z()) + return /* (finishearly) */; animpointer(); showpointer(); _cmp(data.word(kWatchingtime), 0); @@ -14245,22 +13849,6 @@ notzeronum: ch = 1; } -void DreamGenContext::mainscreen() { - STACK_CHECK; - data.byte(kInmaparea) = 0; - bx = offset_mainlist; - _cmp(data.byte(kWatchon), 1); - if (flags.z()) - goto checkmain; - bx = offset_mainlist2; -checkmain: - checkcoords(); - _cmp(data.byte(kWalkandexam), 0); - if (flags.z()) - return /* (finishmain) */; - walkandexamine(); -} - void DreamGenContext::madmanrun() { STACK_CHECK; _cmp(data.byte(kLocation), 14); @@ -14750,57 +14338,6 @@ success: data.byte(kTurndirection) = 0; } -void DreamGenContext::showicon() { - STACK_CHECK; - _cmp(data.byte(kReallocation), 50); - if (!flags.c()) - goto isdream1; - showpanel(); - showman(); - roomname(); - panelicons1(); - zoomicon(); - return; -isdream1: - ds = data.word(kTempsprites); - di = 72; - bx = 2; - al = 45; - ah = 0; - showframe(); - ds = data.word(kTempsprites); - di = 72+47; - bx = 2; - al = 46; - ah = 0; - showframe(); - ds = data.word(kTempsprites); - di = 69-10; - bx = 21; - al = 49; - ah = 0; - showframe(); - ds = data.word(kTempsprites); - di = 160+88; - bx = 2; - al = 45; - ah = 4; - showframe(); - ds = data.word(kTempsprites); - di = 160+43; - bx = 2; - al = 46; - ah = 4; - showframe(); - ds = data.word(kTempsprites); - di = 160+101; - bx = 21; - al = 49; - ah = 4; - showframe(); - middlepanel(); -} - void DreamGenContext::middlepanel() { STACK_CHECK; ds = data.word(kTempsprites); @@ -14854,42 +14391,6 @@ void DreamGenContext::showman() { showframe(); } -void DreamGenContext::roomname() { - STACK_CHECK; - di = 88; - bx = 18; - al = 53; - dl = 240; - printmessage(); - bl = data.byte(kRoomnum); - _cmp(bl, 32); - if (flags.c()) - goto notover32; - _sub(bl, 32); -notover32: - bh = 0; - _add(bx, bx); - es = data.word(kRoomdesc); - _add(bx, (0)); - ax = es.word(bx); - _add(ax, (0+(38*2))); - si = ax; - data.word(kLinespacing) = 7; - di = 88; - bx = 25; - dl = 120; - _cmp(data.byte(kWatchon), 1); - if (flags.z()) - goto gotpl; - dl = 160; -gotpl: - al = 0; - ah = 0; - printdirect(); - data.word(kLinespacing) = 10; - usecharset1(); -} - void DreamGenContext::usecharset1() { STACK_CHECK; ax = data.word(kCharset1); @@ -14943,20 +14444,6 @@ zoomisoff: showwatch(); } -void DreamGenContext::showwatch() { - STACK_CHECK; - _cmp(data.byte(kWatchon), 0); - if (flags.z()) - return /* (nowristwatch) */; - ds = data.word(kIcons1); - di = 250; - bx = 1; - al = 6; - ah = 0; - showframe(); - showtime(); -} - void DreamGenContext::zoomicon() { STACK_CHECK; _cmp(data.byte(kZoomon), 0); @@ -15374,29 +14861,6 @@ void DreamGenContext::restoreall() { setallchanges(); } -void DreamGenContext::sortoutmap() { - STACK_CHECK; - push(es); - push(di); - ds = data.word(kWorkspace); - si = 0; - es = data.word(kMapdata); - di = 0; - cx = (60); -blimey: - push(cx); - push(si); - cx = (66); - _movsb(cx, true); - si = pop(); - cx = pop(); - _add(si, 132); - if (--cx) - goto blimey; - di = pop(); - es = pop(); -} - void DreamGenContext::disablepath() { STACK_CHECK; push(cx); @@ -16747,8 +16211,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_adjustleft: adjustleft(); break; case addr_adjustright: adjustright(); break; case addr_reminders: reminders(); break; - case addr_initrain: initrain(); break; - case addr_splitintolines: splitintolines(); break; case addr_backobject: backobject(); break; case addr_liftnoise: liftnoise(); break; case addr_random: random(); break; @@ -16814,7 +16276,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_monprint: monprint(); break; case addr_fillopen: fillopen(); break; case addr_findallopen: findallopen(); break; - case addr_examineob: examineob(); break; case addr_makemainscreen: makemainscreen(); break; case addr_getbackfromob: getbackfromob(); break; case addr_incryanpage: incryanpage(); break; @@ -16858,7 +16319,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_transfertoex: transfertoex(); break; case addr_pickupconts: pickupconts(); break; case addr_transfercontoex: transfercontoex(); break; - case addr_transfertext: transfertext(); break; case addr_purgealocation: purgealocation(); break; case addr_emergencypurge: emergencypurge(); break; case addr_purgeanitem: purgeanitem(); break; @@ -16873,8 +16333,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_redrawmainscrn: redrawmainscrn(); break; case addr_getback1: getback1(); break; case addr_talk: talk(); break; - case addr_convicons: convicons(); break; - case addr_getpersframe: getpersframe(); break; case addr_starttalk: starttalk(); break; case addr_getpersontext: getpersontext(); break; case addr_moretalk: moretalk(); break; @@ -16883,7 +16341,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_redes: redes(); break; case addr_newplace: newplace(); break; case addr_selectlocation: selectlocation(); break; - case addr_showcity: showcity(); break; case addr_lookatplace: lookatplace(); break; case addr_getundercentre: getundercentre(); break; case addr_putundercentre: putundercentre(); break; @@ -17165,7 +16622,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_setupemm: setupemm(); break; case addr_removeemm: removeemm(); break; case addr_checkforemm: checkforemm(); break; - case addr_checkbasemem: checkbasemem(); break; case addr_allocatebuffers: allocatebuffers(); break; case addr_clearbuffers: clearbuffers(); break; case addr_clearchanges: clearchanges(); break; @@ -17199,15 +16655,12 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_printmessage2: printmessage2(); break; case addr_setwalk: setwalk(); break; case addr_workoutframes: workoutframes(); break; - case addr_showicon: showicon(); break; case addr_middlepanel: middlepanel(); break; case addr_showman: showman(); break; - case addr_roomname: roomname(); break; case addr_usecharset1: usecharset1(); break; case addr_usetempcharset: usetempcharset(); break; case addr_showexit: showexit(); break; case addr_panelicons1: panelicons1(); break; - case addr_showwatch: showwatch(); break; case addr_gettime: gettime(); break; case addr_zoomicon: zoomicon(); break; case addr_worktoscreenm: worktoscreenm(); break; @@ -17237,7 +16690,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_getridofall: getridofall(); break; case addr_restorereels: restorereels(); break; case addr_restoreall: restoreall(); break; - case addr_sortoutmap: sortoutmap(); break; case addr_disablepath: disablepath(); break; case addr_findroominloc: findroominloc(); break; case addr_dontloadseg: dontloadseg(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index f3a763fbd8..20ef2f9818 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -60,7 +60,6 @@ public: static const uint16 addr_dontloadseg = 0xcb64; static const uint16 addr_findroominloc = 0xcb58; static const uint16 addr_disablepath = 0xcb50; - static const uint16 addr_sortoutmap = 0xcb48; static const uint16 addr_restoreall = 0xcb44; static const uint16 addr_restorereels = 0xcb40; static const uint16 addr_getridofall = 0xcb3c; @@ -90,15 +89,12 @@ public: static const uint16 addr_worktoscreenm = 0xca9c; static const uint16 addr_zoomicon = 0xca90; static const uint16 addr_gettime = 0xca8c; - static const uint16 addr_showwatch = 0xca88; static const uint16 addr_panelicons1 = 0xca84; static const uint16 addr_showexit = 0xca80; static const uint16 addr_usetempcharset = 0xca7c; static const uint16 addr_usecharset1 = 0xca78; - static const uint16 addr_roomname = 0xca74; static const uint16 addr_showman = 0xca6c; static const uint16 addr_middlepanel = 0xca68; - static const uint16 addr_showicon = 0xca64; static const uint16 addr_workoutframes = 0xca54; static const uint16 addr_setwalk = 0xca44; static const uint16 addr_printmessage2 = 0xca30; @@ -132,7 +128,6 @@ public: static const uint16 addr_clearchanges = 0xc974; static const uint16 addr_clearbuffers = 0xc970; static const uint16 addr_allocatebuffers = 0xc96c; - static const uint16 addr_checkbasemem = 0xc968; static const uint16 addr_checkforemm = 0xc964; static const uint16 addr_removeemm = 0xc960; static const uint16 addr_setupemm = 0xc95c; @@ -415,7 +410,6 @@ public: static const uint16 addr_putundercentre = 0xc4b8; static const uint16 addr_getundercentre = 0xc4b4; static const uint16 addr_lookatplace = 0xc4b0; - static const uint16 addr_showcity = 0xc4ac; static const uint16 addr_selectlocation = 0xc4a8; static const uint16 addr_newplace = 0xc4a4; static const uint16 addr_redes = 0xc4a0; @@ -424,8 +418,6 @@ public: static const uint16 addr_moretalk = 0xc494; static const uint16 addr_getpersontext = 0xc490; static const uint16 addr_starttalk = 0xc48c; - static const uint16 addr_getpersframe = 0xc488; - static const uint16 addr_convicons = 0xc484; static const uint16 addr_talk = 0xc480; static const uint16 addr_getback1 = 0xc47c; static const uint16 addr_redrawmainscrn = 0xc478; @@ -440,7 +432,6 @@ public: static const uint16 addr_purgeanitem = 0xc414; static const uint16 addr_emergencypurge = 0xc410; static const uint16 addr_purgealocation = 0xc40c; - static const uint16 addr_transfertext = 0xc404; static const uint16 addr_transfercontoex = 0xc400; static const uint16 addr_pickupconts = 0xc3fc; static const uint16 addr_transfertoex = 0xc3f8; @@ -484,7 +475,6 @@ public: static const uint16 addr_incryanpage = 0xc348; static const uint16 addr_getbackfromob = 0xc344; static const uint16 addr_makemainscreen = 0xc340; - static const uint16 addr_examineob = 0xc33c; static const uint16 addr_findallopen = 0xc32c; static const uint16 addr_fillopen = 0xc324; static const uint16 addr_monprint = 0xc314; @@ -550,8 +540,6 @@ public: static const uint16 addr_random = 0xc17c; static const uint16 addr_liftnoise = 0xc178; static const uint16 addr_backobject = 0xc170; - static const uint16 addr_splitintolines = 0xc164; - static const uint16 addr_initrain = 0xc160; static const uint16 addr_reminders = 0xc15c; static const uint16 addr_adjustright = 0xc158; static const uint16 addr_adjustleft = 0xc154; @@ -660,12 +648,11 @@ public: static const uint16 offset_speechfilename = 0x13eb; static const uint16 offset_rootdir = 0x0b8c; static const uint16 offset_gameerror3 = 0x1003; - static const uint16 offset_rainlocations = 0x0459; + static const uint16 offset_facelist = 0x0451; static const uint16 offset_diarylist = 0x0e9c; static const uint16 offset_decidelist = 0x13c1; static const uint16 offset_symbollist = 0x0e5e; static const uint16 offset_folderlist = 0x0e34; - static const uint16 offset_facelist = 0x0451; static const uint16 offset_operand1 = 0x0b7e; static const uint16 offset_keypadlist = 0x0d9a; static const uint16 kStartvars = 0; @@ -1268,7 +1255,7 @@ public: //void frameoutbh(); void getobtextstart(); void loadfolder(); - void decide(); + void dumpdiarykeys(); //void dumppointer(); void reelsonscreen(); void getridofreels(); @@ -1347,7 +1334,7 @@ public: //void deltextline(); void entercode(); void getopenedsize(); - void getpersframe(); + //void getpersframe(); void doshake(); void resetkeyboard(); //void showpanel(); @@ -1369,7 +1356,7 @@ public: void watchcount(); void fadedownmon(); void loadcart(); - //void calcfrframe(); + //void splitintolines(); void bartender(); void eden(); void showdiary(); @@ -1426,7 +1413,7 @@ public: void getridoftemp2(); void usebalcony(); void runendseq(); - void dumpdiarykeys(); + void decide(); void disablesoundint(); void priesttext(); //void showallex(); @@ -1522,7 +1509,7 @@ public: void placefreeobject(); void allpalette(); //void loopchannel0(); - void initrain(); + //void initrain(); void showleftpage(); void rockstar(); void adjustright(); @@ -1538,9 +1525,10 @@ public: void dumpsymbox(); void loadgame(); void getridoftemp(); - void showcity(); + //void showcity(); void dumpsymbol(); void disablepath(); + //void convicons(); void buttonsix(); void intro2text(); void showouterpad(); @@ -1607,16 +1595,14 @@ public: void mainman(); void mansatstill(); void channel1only(); - void checkbasemem(); + //void checkbasemem(); void lastfolder(); void transfermap(); - //void showreelframe(); void showmonk(); void diarykeyn(); void set16colpalette(); - void convicons(); - void interviewer(); void sparky(); + void interviewer(); void purgeanitem(); void madman(); void createpanel(); @@ -1656,7 +1642,7 @@ public: void startup(); void savegame(); void startpaltoend(); - void showicon(); + //void showicon(); void findopenpos(); void describeob(); void deleteexframe(); @@ -1666,7 +1652,7 @@ public: void actualsave(); void autolook(); void playguitar(); - void transfertext(); + //void showreelframe(); void searchforsame(); void showmainops(); void getback1(); @@ -1685,7 +1671,7 @@ public: void openinv(); void lookatplace(); void useaxe(); - void examineob(); + //void examineob(); void buttonnought(); void useelvdoor(); void putbackobstuff(); @@ -1769,7 +1755,7 @@ public: //void madmode(); void intro3text(); void allocatemem(); - void sortoutmap(); + //void sortoutmap(); //void showrain(); void useopened(); void inventory(); @@ -1796,6 +1782,7 @@ public: //void plotreel(); void swapwithopen(); //void makesprite(); + //void transfertext(); void dreamweb(); void droperror(); void edenscdplayer(); @@ -1803,7 +1790,7 @@ public: void checkinside(); void gates(); void newgame(); - void showwatch(); + //void showwatch(); //void turnanypathon(); void restorereels(); void setwalk(); @@ -1880,7 +1867,7 @@ public: void clearrest(); //void getreelframeax(); void barwoman(); - void roomname(); + //void roomname(); void credits(); void madmanrun(); void randomnum1(); @@ -1891,7 +1878,7 @@ public: void closefile(); void delcurs(); void randomaccess(); - void splitintolines(); + //void calcfrframe(); //void checkifex(); //void findobname(); void initialmoncols(); diff --git a/engines/dreamweb/module.mk b/engines/dreamweb/module.mk index 21429dc960..d38d4db0db 100644 --- a/engines/dreamweb/module.mk +++ b/engines/dreamweb/module.mk @@ -12,6 +12,7 @@ MODULE_OBJS := \ saveload.o \ sprite.o \ stubs.o \ + talk.o \ use.o \ vgagrafx.o diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp index e2da902465..d887f1c564 100644 --- a/engines/dreamweb/object.cpp +++ b/engines/dreamweb/object.cpp @@ -103,12 +103,160 @@ void DreamGenContext::obpicture() { void DreamGenContext::obicons() { uint8 value1, value2; getanyad(&value1, &value2); - if (value1 == 0xff) { - showframe((Frame *)segRef(data.word(kIcons2)).ptr(0, 0), 260, 1, 1, 0); - } else { + if (value1 != 0xff) { + // can open it showframe((Frame *)segRef(data.word(kIcons2)).ptr(0, 0), 210, 1, 4, 0); } + + showframe((Frame *)segRef(data.word(kIcons2)).ptr(0, 0), 260, 1, 1, 0); +} + +void DreamGenContext::examineob(bool examineAgain) { + data.byte(kPointermode) = 0; + data.word(kTimecount) = 0; + while (true) { + if (examineAgain) { + data.byte(kInmaparea) = 0; + data.byte(kExamagain) = 0; + data.byte(kOpenedob) = 255; + data.byte(kOpenedtype) = 255; + data.byte(kInvopen) = 0; + al = data.byte(kCommandtype); + data.byte(kObjecttype) = al; + data.byte(kItemframe) = 0; + data.byte(kPointerframe) = 0; + createpanel(); + showpanel(); + showman(); + showexit(); + obicons(); + obpicture(); + describeob(); + undertextline(); + data.byte(kCommandtype) = 255; + readmouse(); + showpointer(); + worktoscreen(); + delpointer(); + examineAgain = false; + } + + readmouse(); + showpointer(); + vsync(); + dumppointer(); + dumptextline(); + delpointer(); + data.byte(kGetback) = 0; + switch (data.byte(kInvopen)) { + case 0: { + RectWithCallback examlist[] = { + { 273,320,157,198,&DreamGenContext::getbackfromob }, + { 260,300,0,44,&DreamGenContext::useobject }, + { 210,254,0,44,&DreamGenContext::selectopenob }, + { 144,176,64,96,&DreamGenContext::setpickup }, + { 0,50,50,200,&DreamGenContext::examinventory }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(examlist); + break; + } + case 1: { + // NB: This table contains the non-constant openchangesize! + RectWithCallback invlist1[] = { + { 273,320,157,198,&DreamGenContext::getbackfromob }, + { 255,294,0,24,&DreamGenContext::dropobject }, + { kInventx+167,kInventx+167+(18*3),kInventy-18,kInventy-2,&DreamGenContext::incryanpage }, + { kInventx, cs.word(offset_openchangesize),kInventy+100,kInventy+100+kItempicsize,&DreamGenContext::useopened }, + { kInventx,kInventx+(5*kItempicsize), kInventy,kInventy+(2*kItempicsize),&DreamGenContext::intoinv }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(invlist1); + break; + } + default: { + RectWithCallback withlist1[] = { + { 273,320,157,198,&DreamGenContext::getbackfromob }, + { kInventx+167,kInventx+167+(18*3),kInventy-18,kInventy-2,&DreamGenContext::incryanpage }, + { kInventx,kInventx+(5*kItempicsize), kInventy,kInventy+(2*kItempicsize),&DreamGenContext::selectob }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(withlist1); + break; + } + } + if (data.byte(kQuitrequested) != 0) + break; + if (data.byte(kExamagain) != 0) + examineAgain = true; + else if (data.byte(kGetback) != 0) + break; + } + + data.byte(kPickup) = 0; + if (data.word(kWatchingtime) != 0 || data.byte(kNewlocation) == 255) { + // iswatching + makemainscreen(); + } + + data.byte(kInvopen) = 0; + data.byte(kOpenedob) = 255; +} + +void DreamGenContext::inventory() { + if (data.byte(kMandead) == 1 || data.word(kWatchingtime) != 0) { + blank(); + return; + } + + if (data.byte(kCommandtype) != 239) { + data.byte(kCommandtype) = 239; + al = 32; + commandonly(); + } + + if (data.word(kMousebutton) == data.word(kOldbutton)) + return; + if (!(data.word(kMousebutton) & 1)) // only on left mouse button + return; + + + data.word(kTimecount) = 0; + data.byte(kPointermode) = 0; + data.byte(kInmaparea) = 0; + animpointer(); + createpanel(); + showpanel(); + examicon(); + showman(); + showexit(); + undertextline(); + data.byte(kPickup) = 0; + data.byte(kInvopen) = 2; + openinv(); + readmouse(); + showpointer(); + worktoscreen(); + delpointer(); + data.byte(kOpenedob) = 255; + examineob(false); } +void DreamGenContext::transfertext() { + segRef(data.word(kExtras)).word(kExtextdat + data.byte(kExpos) * 2) = data.word(kExtextpos); + uint16 freeTextOffset = data.byte(kItemtotran) * 2; + uint16 srcOffset = segRef(data.word(kFreedesc)).word(kFreetextdat + freeTextOffset); + const char *src = (const char *)segRef(data.word(kFreedesc)).ptr(kFreetext + srcOffset, 0); + char *dst = (char *)segRef(data.word(kExtras)).ptr(kExtext + data.word(kExtextpos), 0); + + size_t len = strlen(src); + memcpy(dst, src, len + 1); + data.word(kExtextpos) += len + 1; +} + + } /*namespace dreamgen */ diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp index 636182dc83..f68ec86ddf 100644 --- a/engines/dreamweb/saveload.cpp +++ b/engines/dreamweb/saveload.cpp @@ -72,8 +72,14 @@ void DreamGenContext::doload() { vsync(); dumppointer(); dumptextline(); - bx = offset_loadlist; - checkcoords(); + RectWithCallback loadlist[] = { + { kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamGenContext::getbacktoops }, + { kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamGenContext::actualload }, + { kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamGenContext::selectslot }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(loadlist); if (data.byte(kGetback) == 1) break; if (data.byte(kGetback) == 2) @@ -213,8 +219,15 @@ void DreamGenContext::savegame() { vsync(); dumppointer(); dumptextline(); - bx = offset_savelist; - checkcoords(); + + RectWithCallback savelist[] = { + { kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamGenContext::getbacktoops }, + { kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamGenContext::actualsave }, + { kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamGenContext::selectslot }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(savelist); _cmp(data.byte(kGetback), 0); if (flags.z()) continue; diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 3b67bfbd72..34b0729535 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -494,43 +494,30 @@ void DreamGenContext::facerightway() { data.byte(kLeavedirection) = dir; } -void DreamGenContext::findsource() { +Frame *DreamGenContext::findsource() { uint16 currentFrame = data.word(kCurrentframe); if (currentFrame < 160) { - ds = data.word(kReel1); data.word(kTakeoff) = 0; + return (Frame *)segRef(data.word(kReel1)).ptr(0, 0); } else if (currentFrame < 320) { - ds = data.word(kReel2); data.word(kTakeoff) = 160; + return (Frame *)segRef(data.word(kReel2)).ptr(0, 0); } else { - ds = data.word(kReel3); data.word(kTakeoff) = 320; + return (Frame *)segRef(data.word(kReel3)).ptr(0, 0); } } -Frame *DreamGenContext::findsourceCPP() { - push(ds); - findsource(); - Frame *result = (Frame *)ds.ptr(0, 0); - ds = pop(); - return result; -} - Reel *DreamGenContext::getreelstart() { Reel *reel = (Reel *)segRef(data.word(kReels)).ptr(kReellist + data.word(kReelpointer) * sizeof(Reel) * 8, sizeof(Reel)); return reel; } -void DreamGenContext::showreelframe() { - Reel *reel = (Reel *)es.ptr(si, sizeof(Reel)); - showreelframe(reel); -} - void DreamGenContext::showreelframe(Reel *reel) { uint16 x = reel->x + data.word(kMapadx); uint16 y = reel->y + data.word(kMapady); data.word(kCurrentframe) = reel->frame(); - Frame *source = findsourceCPP(); + Frame *source = findsource(); uint16 frame = data.word(kCurrentframe) - data.word(kTakeoff); showframe(source, x, y, frame, 8); } @@ -550,7 +537,7 @@ void DreamGenContext::showgamereel(ReelRoutine *routine) { const Frame *DreamGenContext::getreelframeax(uint16 frame) { data.word(kCurrentframe) = frame; - Frame *source = findsourceCPP(); + Frame *source = findsource(); uint16 offset = data.word(kCurrentframe) - data.word(kTakeoff); return source + offset; } @@ -602,6 +589,10 @@ void DreamGenContext::updatepeople() { data.word(kListpos) = kPeoplelist; memset(segRef(data.word(kBuffers)).ptr(kPeoplelist, 12 * sizeof(People)), 0xff, 12 * sizeof(People)); ++data.word(kMaintimer); + + // The callbacks are called with es:bx pointing to their reelRoutine entry. + // They use some of the fields in it to store state. + es = cs; bx = kReelroutines; const ReelRoutine *reelRoutine = (const ReelRoutine *)cs.ptr(bx, 0); @@ -903,5 +894,131 @@ void DreamGenContext::addtopeoplelist(ReelRoutine *routine) { data.word(kListpos) += sizeof(People); } +Rain *DreamGenContext::splitintolines(uint8 x, uint8 y, Rain *rain) { + do { + // Look for line start + while (!getblockofpixel(x, y)) { + --x; + ++y; + if (x == 0 || y >= data.byte(kMapysize)) + return rain; + } + + rain->x = x; + rain->y = y; + + uint8 length = 1; + + // Look for line end + while (getblockofpixel(x, y)) { + --x; + ++y; + if (x == 0 || y >= data.byte(kMapysize)) + break; + ++length; + } + + rain->size = length; + rain->w3_lo = engine->randomNumber(); + rain->w3_hi = engine->randomNumber(); + rain->b5 = (engine->randomNumber() & 3) + 4; + ++rain; + } while (x > 0 && y < data.byte(kMapysize)); + + return rain; +} + +struct RainLocation { + uint8 location; + uint8 x, y; + uint8 rainSpacing; +}; + +static const RainLocation rainLocationList[] = { + { 1,44,10,16 }, + { 4,11,30,14 }, + { 4,22,30,14 }, + { 3,33,10,14 }, + { 10,33,30,14 }, + { 10,22,30,24 }, + { 9,22,10,14 }, + { 2,33,0,14 }, + { 2,22,0,14 }, + { 6,11,30,14 }, + { 7,11,20,18 }, + { 7,0,20,18 }, + { 7,0,30,18 }, + { 55,44,0,14 }, + { 5,22,30,14 }, + + { 8,0,10,18 }, + { 8,11,10,18 }, + { 8,22,10,18 }, + { 8,33,10,18 }, + { 8,33,20,18 }, + { 8,33,30,18 }, + { 8,33,40,18 }, + { 8,22,40,18 }, + { 8,11,40,18 }, + + { 21,44,20,18 }, + { 255,0,0,0 } +}; + +void DreamGenContext::initrain() { + const RainLocation *r = rainLocationList; + Rain *rainList = (Rain *)segRef(data.word(kBuffers)).ptr(kRainlist, 0); + Rain *rain = rainList; + + uint8 rainSpacing = 0; + + // look up location in rainLocationList to determine rainSpacing + for (r = rainLocationList; r->location != 0xff; ++r) { + if (r->location == data.byte(kReallocation) && + r->x == data.byte(kMapx) && r->y == data.byte(kMapy)) { + rainSpacing = r->rainSpacing; + break; + } + } + + if (rainSpacing == 0) { + // location not found in rainLocationList: no rain + rain->x = 0xff; + return; + } + + // start lines of rain from top of screen + uint8 x = 4; + do { + uint8 delta; + do { + delta = (engine->randomNumber() & 31) + 3; + } while (delta >= rainSpacing); + + x += delta; + if (x >= data.byte(kMapxsize)) + break; + + rain = splitintolines(x, 0, rain); + } while (true); + + // start lines of rain from side of screen + uint8 y = 0; + do { + uint8 delta; + do { + delta = (engine->randomNumber() & 31) + 3; + } while (delta >= rainSpacing); + + y += delta; + if (y >= data.byte(kMapysize)) + break; + + rain = splitintolines(data.byte(kMapxsize) - 1, y, rain); + } while (true); + + rain->x = 0xff; +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 0d7bbb6cbf..ceb30e3a4f 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -54,19 +54,15 @@ struct Sprite { uint8 hidden; }; +class DreamGenContext; + struct RectWithCallback { uint16 _xMin, _xMax; uint16 _yMin, _yMax; - uint16 _callback; - - uint16 xMin() const { return READ_LE_UINT16(&_xMin); } - uint16 xMax() const { return READ_LE_UINT16(&_xMax); } - uint16 yMin() const { return READ_LE_UINT16(&_yMin); } - uint16 yMax() const { return READ_LE_UINT16(&_yMax); } - uint16 callback() const { return READ_LE_UINT16(&_callback); } + void (DreamGenContext::*_callback)(); bool contains(uint16 x, uint16 y) const { - return (x >= xMin()) && (x < xMax()) && (y >= yMin()) && (y < yMax()); + return (x >= _xMin) && (x < _xMax) && (y >= _yMin) && (y < _yMax); } }; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 7f8a511cde..a01949edfb 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -28,8 +28,19 @@ namespace DreamGen { void DreamGenContext::dreamweb() { STACK_CHECK; + + switch(engine->getLanguage()) { + case Common::EN_ANY: + case Common::EN_GRB: + case Common::EN_USA: + // Implicit data.byte(kForeignrelease) = 0 + break; + default: + data.byte(kForeignrelease) = 1; + break; + } + seecommandtail(); - checkbasemem(); soundstartup(); setkeyboardint(); setupemm(); @@ -140,6 +151,9 @@ void DreamGenContext::dreamweb() { screenupdate(); + if (data.byte(kQuitrequested)) + return; // exit game + if (data.byte(kWongame) != 0) { // "endofgame" clearbeforeload(); @@ -190,12 +204,8 @@ void DreamGenContext::dreamweb() { } static Common::String getFilename(Context &context) { - uint16 name_ptr = context.dx; - Common::String name; - uint8 c; - while((c = context.cs.byte(name_ptr++)) != 0) - name += (char)c; - return name; + const char *name = (const char *)context.cs.ptr(context.dx, 0); + return Common::String(name); } void DreamGenContext::seecommandtail() { @@ -502,15 +512,6 @@ void DreamGenContext::removeemm() { } void DreamGenContext::setupemm() { - //good place for early initialization - switch(engine->getLanguage()) { - case Common::EN_ANY: - case Common::EN_GRB: - case Common::EN_USA: - return; - default: - data.byte(kForeignrelease) = 1; - } } void DreamGenContext::pitinterupt() { @@ -669,7 +670,7 @@ void DreamGenContext::eraseoldobs() { return; Sprite *sprites = spritetable(); - for (size_t i=0; i < 16; ++i) { + for (size_t i = 0; i < 16; ++i) { Sprite &sprite = sprites[i]; if (sprite.objData() != 0xffff) { memset(&sprite, 0xff, sizeof(Sprite)); @@ -917,11 +918,7 @@ void DreamGenContext::dealwithspecial(uint8 firstParam, uint8 secondParam) { void DreamGenContext::plotreel() { Reel *reel = getreelstart(); - while (true) { - if (reel->x < 220) - break; - if (reel->x == 255) - break; + while (reel->x >= 220 && reel->x != 255) { dealwithspecial(reel->x, reel->y); ++data.word(kReelpointer); reel += 8; @@ -1144,29 +1141,24 @@ void DreamGenContext::findormake() { void DreamGenContext::findormake(uint8 index, uint8 value, uint8 type) { Change *change = (Change *)segRef(data.word(kBuffers)).ptr(kListofchanges, sizeof(Change)); - while (true) { - if (change->index == 0xff) { - change->index = index; - change->location = data.byte(kReallocation); - change->value = value; - change->type = type; - return; - } - if ((index == change->index) && (data.byte(kReallocation) == change->location) && (type == change->type)) { + for (; change->index != 0xff; ++change) { + if (index == change->index && data.byte(kReallocation) == change->location && type == change->type) { change->value = value; return; } - ++change; } + + change->index = index; + change->location = data.byte(kReallocation); + change->value = value; + change->type = type; } void DreamGenContext::setallchanges() { Change *change = (Change *)segRef(data.word(kBuffers)).ptr(kListofchanges, sizeof(Change)); - while (change->index != 0xff) { + for (; change->index != 0xff; ++change) if (change->location == data.byte(kReallocation)) dochange(change->index, change->value, change->type); - ++change; - } } DynObject *DreamGenContext::getfreead(uint8 index) { @@ -1301,7 +1293,7 @@ void DreamGenContext::getflagunderp(uint8 *flag, uint8 *flagEx) { } void DreamGenContext::walkandexamine() { - if (! finishedwalkingCPP()) + if (!finishedwalkingCPP()) return; data.byte(kCommandtype) = data.byte(kWalkexamtype); data.byte(kCommand) = data.byte(kWalkexamnum); @@ -1434,156 +1426,160 @@ void DreamGenContext::dumppointer() { } void DreamGenContext::checkcoords() { - checkcoords((const RectWithCallback *)cs.ptr(bx, 0)); + + // FIXME: Move all these lists to the callers + + switch ((uint16)bx) { + case offset_talklist: { + RectWithCallback talklist[] = { + { 273,320,157,198,&DreamGenContext::getback1 }, + { 240,290,2,44,&DreamGenContext::moretalk }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(talklist); + break; + } + case offset_quitlist: { + RectWithCallback quitlist[] = { + { 273,320,157,198,&DreamGenContext::getback1 }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(quitlist); + break; + } + case offset_destlist: { + RectWithCallback destlist[] = { + { 238,258,4,44,&DreamGenContext::nextdest }, + { 104,124,4,44,&DreamGenContext::lastdest }, + { 280,308,4,44,&DreamGenContext::lookatplace }, + { 104,216,138,192,&DreamGenContext::destselect }, + { 273,320,157,198,&DreamGenContext::getback1 }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(destlist); + break; + } + case offset_keypadlist: { + RectWithCallback keypadlist[] = { + { kKeypadx+9,kKeypadx+30,kKeypady+9,kKeypady+22,&DreamGenContext::buttonone }, + { kKeypadx+31,kKeypadx+52,kKeypady+9,kKeypady+22,&DreamGenContext::buttontwo }, + { kKeypadx+53,kKeypadx+74,kKeypady+9,kKeypady+22,&DreamGenContext::buttonthree }, + { kKeypadx+9,kKeypadx+30,kKeypady+23,kKeypady+40,&DreamGenContext::buttonfour }, + { kKeypadx+31,kKeypadx+52,kKeypady+23,kKeypady+40,&DreamGenContext::buttonfive }, + { kKeypadx+53,kKeypadx+74,kKeypady+23,kKeypady+40,&DreamGenContext::buttonsix }, + { kKeypadx+9,kKeypadx+30,kKeypady+41,kKeypady+58,&DreamGenContext::buttonseven }, + { kKeypadx+31,kKeypadx+52,kKeypady+41,kKeypady+58,&DreamGenContext::buttoneight }, + { kKeypadx+53,kKeypadx+74,kKeypady+41,kKeypady+58,&DreamGenContext::buttonnine }, + { kKeypadx+9,kKeypadx+30,kKeypady+59,kKeypady+73,&DreamGenContext::buttonnought }, + { kKeypadx+31,kKeypadx+74,kKeypady+59,kKeypady+73,&DreamGenContext::buttonenter }, + { kKeypadx+72,kKeypadx+86,kKeypady+80,kKeypady+94,&DreamGenContext::quitkey }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(keypadlist); + break; + } + case offset_menulist: { + RectWithCallback menulist[] = { + { kMenux+54,kMenux+68,kMenuy+72,kMenuy+88,&DreamGenContext::quitkey }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(menulist); + break; + } + case offset_folderlist: { + RectWithCallback folderlist[] = { + { 280,320,160,200,&DreamGenContext::quitkey }, + { 143,300,6,194,&DreamGenContext::nextfolder }, + { 0,143,6,194,&DreamGenContext::lastfolder }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(folderlist); + break; + } + case offset_symbollist: { + RectWithCallback symbollist[] = { + { kSymbolx+40,kSymbolx+64,kSymboly+2,kSymboly+16,&DreamGenContext::quitsymbol }, + { kSymbolx,kSymbolx+52,kSymboly+20,kSymboly+50,&DreamGenContext::settopleft }, + { kSymbolx+52,kSymbolx+104,kSymboly+20,kSymboly+50,&DreamGenContext::settopright }, + { kSymbolx,kSymbolx+52,kSymboly+50,kSymboly+80,&DreamGenContext::setbotleft }, + { kSymbolx+52,kSymbolx+104,kSymboly+50,kSymboly+80,&DreamGenContext::setbotright }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(symbollist); + + break; + } + case offset_diarylist: { + RectWithCallback diarylist[] = { + { kDiaryx+94,kDiaryx+110,kDiaryy+97,kDiaryy+113,&DreamGenContext::diarykeyn }, + { kDiaryx+151,kDiaryx+167,kDiaryy+71,kDiaryy+87,&DreamGenContext::diarykeyp }, + { kDiaryx+176,kDiaryx+192,kDiaryy+108,kDiaryy+124,&DreamGenContext::quitkey }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(diarylist); + break; + } + case offset_opslist: { + RectWithCallback opslist[] = { + { kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamGenContext::getbackfromops }, + { kOpsx+10,kOpsx+77,kOpsy+10,kOpsy+59,&DreamGenContext::dosreturn }, + { kOpsx+128,kOpsx+190,kOpsy+16,kOpsy+100,&DreamGenContext::discops }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(opslist); + break; + } + case offset_discopslist: { + RectWithCallback discopslist[] = { + { kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamGenContext::loadgame }, + { kOpsx+10,kOpsx+79,kOpsy+10,kOpsy+59,&DreamGenContext::savegame }, + { kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamGenContext::getbacktoops }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(discopslist); + break; + } + case offset_decidelist: { + RectWithCallback decidelist[] = { + { kOpsx+69,kOpsx+124,kOpsy+30,kOpsy+76,&DreamGenContext::newgame }, + { kOpsx+20,kOpsx+87,kOpsy+10,kOpsy+59,&DreamGenContext::dosreturn }, + { kOpsx+123,kOpsx+190,kOpsy+10,kOpsy+59,&DreamGenContext::loadold }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(decidelist); + break; + } + default: + ::error("Unimplemented checkcoords() call"); + } } + void DreamGenContext::checkcoords(const RectWithCallback *rectWithCallbacks) { if (data.byte(kNewlocation) != 0xff) return; - const RectWithCallback *rectWithCallback = rectWithCallbacks; - while (rectWithCallback->xMin() != 0xffff) { - if (rectWithCallback->contains(data.word(kMousex), data.word(kMousey))) { - uint16 callback = rectWithCallback->callback(); - - // common - if(callback == addr_blank) - blank(); - else if(callback == addr_getbackfromob) - getbackfromob(); - else if(callback == addr_incryanpage) - incryanpage(); - else if(callback == addr_getback1) - getback1(); - else if(callback == addr_quitkey) - quitkey(); - else if(callback == addr_dosreturn) - dosreturn(); - else if(callback == addr_getbacktoops) - getbacktoops(); - else if(callback == addr_selectslot) - selectslot(); - // examlist - else if(callback == addr_useobject) - useobject(); - else if(callback == addr_selectopenob) - selectopenob(); - else if(callback == addr_setpickup) - setpickup(); - else if(callback == addr_examinventory) - examinventory(); - // invlist1 - else if(callback == addr_dropobject) - dropobject(); - else if(callback == addr_useopened) - useopened(); - else if(callback == addr_intoinv) - intoinv(); - // withlist1 - else if(callback == addr_selectob) - selectob(); - // talklist - else if(callback == addr_moretalk) - moretalk(); - // quitlist - // destlist - else if(callback == addr_nextdest) - nextdest(); - else if(callback == addr_lastdest) - lastdest(); - else if(callback == addr_lookatplace) - lookatplace(); - else if(callback == addr_destselect) - destselect(); - // keypadlist - else if(callback == addr_buttonone) - buttonone(); - else if(callback == addr_buttontwo) - buttontwo(); - else if(callback == addr_buttonthree) - buttonthree(); - else if(callback == addr_buttonfour) - buttonfour(); - else if(callback == addr_buttonfive) - buttonfive(); - else if(callback == addr_buttonsix) - buttonsix(); - else if(callback == addr_buttonseven) - buttonseven(); - else if(callback == addr_buttoneight) - buttoneight(); - else if(callback == addr_buttonnine) - buttonnine(); - else if(callback == addr_buttonnought) - buttonnought(); - else if(callback == addr_buttonenter) - buttonenter(); - // menulist - // folderlist - else if(callback == addr_nextfolder) - nextfolder(); - else if(callback == addr_lastfolder) - lastfolder(); - // symbollist - else if(callback == addr_quitsymbol) - quitsymbol(); - else if(callback == addr_settopleft) - settopleft(); - else if(callback == addr_settopright) - settopright(); - else if(callback == addr_setbotleft) - setbotleft(); - else if(callback == addr_setbotright) - setbotright(); - // diarylist - else if(callback == addr_diarykeyn) - diarykeyn(); - else if(callback == addr_diarykeyp) - diarykeyp(); - // opslist - else if(callback == addr_getbackfromops) - getbackfromops(); - else if(callback == addr_discops) - discops(); - // discopslist - else if(callback == addr_loadgame) - loadgame(); - else if(callback == addr_savegame) - savegame(); - // mainlist, mainlist2 - else if(callback == addr_look) - look(); - else if(callback == addr_inventory) - inventory(); - else if(callback == addr_zoomonoff) - zoomonoff(); - else if(callback == addr_saveload) - saveload(); - else if(callback == addr_madmanrun) - madmanrun(); - else if(callback == addr_identifyob) - identifyob(); - // decidelist - else if(callback == addr_newgame) - newgame(); - else if(callback == addr_loadold) - loadold(); - // loadlist - else if(callback == addr_actualload) - actualload(); - // savelist - else if(callback == addr_actualsave) - actualsave(); - else { - debug("__dispatch_call remaining in checkcoords! %d", (int)callback); - __dispatch_call(callback); - } + const RectWithCallback *r; + for (r = rectWithCallbacks; r->_xMin != 0xffff; ++r) { + if (r->contains(data.word(kMousex), data.word(kMousey))) { + (this->*(r->_callback))(); return; } - ++rectWithCallback; } } + void DreamGenContext::showpointer() { showblink(); const Frame *icons1 = ((const Frame *)segRef(data.word(kIcons1)).ptr(0, 0)); @@ -1721,6 +1717,25 @@ bool DreamGenContext::isCD() { return (data.byte(kSpeechloaded) == 1); } +void DreamGenContext::showicon() { + if (data.byte(kReallocation) < 50) { + showpanel(); + showman(); + roomname(); + panelicons1(); + zoomicon(); + } else { + Frame *tempSprites = (Frame *)segRef(data.word(kTempsprites)).ptr(0, 0); + showframe(tempSprites, 72, 2, 45, 0); + showframe(tempSprites, 72+47, 2, 46, 0); + showframe(tempSprites, 69-10, 21, 49, 0); + showframe(tempSprites, 160+88, 2, 45, 4 & 0xfe); + showframe(tempSprites, 160+43, 2, 46, 4 & 0xfe); + showframe(tempSprites, 160+101, 21, 49, 4 & 0xfe); + middlepanel(); + } +} + void DreamGenContext::checkifset() { flags._z = !checkifset(al, ah); } @@ -1882,5 +1897,73 @@ void DreamGenContext::zoomonoff() { worktoscreenm(); } +void DreamGenContext::sortoutmap() { + const uint8 *src = (const uint8 *)segRef(data.word(kWorkspace)).ptr(0, 0); + uint8 *dst = (uint8 *)segRef(data.word(kMapdata)).ptr(0, 0); + for (uint16 y = 0; y < kMaplength; ++y) { + memcpy(dst, src, kMapwidth); + dst += kMapwidth; + src += 132; + } +} + +void DreamGenContext::showcity() { + clearwork(); + Frame *tempGraphics = (Frame *)segRef(data.word(kTempgraphics)).ptr(0, 0); + showframe(tempGraphics, 57, 32, 0, 0); + showframe(tempGraphics, 120+57, 32, 1, 0); +} + +void DreamGenContext::mainscreen() { + data.byte(kInmaparea) = 0; + if (data.byte(kWatchon) == 1) { + RectWithCallback mainlist[] = { + { 44,70,32,46,&DreamGenContext::look }, + { 0,50,0,180,&DreamGenContext::inventory }, + { 226,244,10,26,&DreamGenContext::zoomonoff }, + { 226,244,26,40,&DreamGenContext::saveload }, + { 240,260,100,124,&DreamGenContext::madmanrun }, + { 0,320,0,200,&DreamGenContext::identifyob }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(mainlist); + } else { + RectWithCallback mainlist2[] = { + { 44,70,32,46,&DreamGenContext::look }, + { 0,50,0,180,&DreamGenContext::inventory }, + { 226+48,244+48,10,26,&DreamGenContext::zoomonoff }, + { 226+48,244+48,26,40,&DreamGenContext::saveload }, + { 240,260,100,124,&DreamGenContext::madmanrun }, + { 0,320,0,200,&DreamGenContext::identifyob }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(mainlist2); + } + + if (data.byte(kWalkandexam) != 0) + walkandexamine(); +} + +void DreamGenContext::showwatch() { + if (data.byte(kWatchon)) { + showframe((Frame *)segRef(data.word(kIcons1)).ptr(0, 0), 250, 1, 6, 0); + showtime(); + } +} + +void DreamGenContext::roomname() { + printmessage(88, 18, 53, 240, false); + uint16 textIndex = data.byte(kRoomnum); + if (textIndex >= 32) + textIndex -= 32; + data.word(kLinespacing) = 7; + uint8 maxWidth = (data.byte(kWatchon) == 1) ? 120 : 160; + uint16 descOffset = segRef(data.word(kRoomdesc)).word(kIntextdat + textIndex * 2); + const uint8 *string = segRef(data.word(kRoomdesc)).ptr(kIntext + descOffset, 0); + printdirect(string, 88, 25, maxWidth, false); + data.word(kLinespacing) = 10; + usecharset1(); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index ac7e1a5b91..da21d415f5 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -96,11 +96,9 @@ void widedoor(Sprite *sprite, SetObject *objData); void lockeddoorway(Sprite *sprite, SetObject *objData); void liftsprite(Sprite *sprite, SetObject *objData); - void findsource(); - Frame *findsourceCPP(); + Frame *findsource(); void showgamereel(); void showgamereel(ReelRoutine *routine); - void showreelframe(); void showreelframe(Reel *reel); const Frame *getreelframeax(uint16 frame); void turnpathon(uint8 param); @@ -237,6 +235,7 @@ void hangon(uint16 frameCount); void hangonp(); void hangonp(uint16 count); + void showicon(); uint8 findnextcolon(uint8 **string); void findnextcolon(); uint8 *getobtextstartCPP(); @@ -246,4 +245,14 @@ uint8 getblockofpixel(uint8 x, uint8 y); void bresenhams(); void examineobtext(); + void sortoutmap(); + void showcity(); + uint16 getpersframe(uint8 index); + void convicons(); + void examineob(bool examineAgain = true); + void showwatch(); + void roomname(); + void transfertext(); + void initrain(); + Rain *splitintolines(uint8 x, uint8 y, Rain *rain); diff --git a/engines/dreamweb/talk.cpp b/engines/dreamweb/talk.cpp new file mode 100644 index 0000000000..78b296afe6 --- /dev/null +++ b/engines/dreamweb/talk.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "dreamweb/dreamweb.h" + +namespace DreamGen { + +uint16 DreamGenContext::getpersframe(uint8 index) { + return segRef(data.word(kPeople)).word(kPersonframes + index * 2); +} + +void DreamGenContext::convicons() { + uint8 index = data.byte(kCharacter) & 127; + data.word(kCurrentframe) = getpersframe(index); + Frame *frame = findsource(); + uint16 frameNumber = (data.word(kCurrentframe) - data.word(kTakeoff)) & 0xff; + showframe(frame, 234, 2, frameNumber, 0); +} + +} /*namespace dreamgen */ + |