From 9d8e5c0df49a6a6d52f71c31f3ab0b406ad84ede Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 15 Aug 2011 17:11:11 +0200 Subject: [PATCH] DREAMWEB: 'updatepeople' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 38 -------- engines/dreamweb/dreamgen.h | 3 +- engines/dreamweb/sprite.cpp | 145 ++++++++++++++++++++++++++++++ engines/dreamweb/structs.h | 11 +++ engines/dreamweb/stubs.h | 2 +- 6 files changed, 159 insertions(+), 41 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 9bc5ff7030bd..cc678b711b1c 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -111,6 +111,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'copyname', 'commandwithob', 'showpanel', + 'updatepeople', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 8b8b6227be34..8c3719b6d6e9 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2651,43 +2651,6 @@ void DreamGenContext::widedoor() { dodoor(); } -void DreamGenContext::updatepeople() { - 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)); - data.word(kListpos) = di; - cx = 12*5; - al = 255; - _stosb(cx, true); - _inc(data.word(kMaintimer)); - es = cs; - bx = 534; - di = 991; -updateloop: - al = es.byte(bx); - _cmp(al, 255); - if (flags.z()) - return /* (endupdate) */; - _cmp(al, data.byte(kReallocation)); - if (!flags.z()) - goto notinthisroom; - cx = es.word(bx+1); - _cmp(cl, data.byte(kMapx)); - if (!flags.z()) - goto notinthisroom; - _cmp(ch, data.byte(kMapy)); - if (!flags.z()) - goto notinthisroom; - push(di); - ax = cs.word(di); - __dispatch_call(ax); - di = pop(); -notinthisroom: - _add(bx, 8); - _add(di, 2); - goto updateloop; -} - void DreamGenContext::reelsonscreen() { STACK_CHECK; reconstruct(); @@ -19234,7 +19197,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_constant: constant(); break; case addr_doorway: doorway(); break; case addr_widedoor: widedoor(); break; - case addr_updatepeople: updatepeople(); break; case addr_reelsonscreen: reelsonscreen(); break; case addr_soundonreels: soundonreels(); break; case addr_reconstruct: reconstruct(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 16b23db749b9..851c87d00c32 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -625,7 +625,6 @@ class DreamGenContext : public Context { static const uint16 addr_reconstruct = 0xc1ac; static const uint16 addr_soundonreels = 0xc1a8; static const uint16 addr_reelsonscreen = 0xc1a0; - static const uint16 addr_updatepeople = 0xc198; static const uint16 addr_widedoor = 0xc18c; static const uint16 addr_doorway = 0xc188; static const uint16 addr_constant = 0xc184; @@ -1416,7 +1415,7 @@ class DreamGenContext : public Context { void eden(); void showdiary(); void purgealocation(); - void updatepeople(); + //void updatepeople(); void slabdoorf(); void addtopeoplelist(); void hangoncurs(); diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 9735ad01b6ec..59ca0cbc0b4f 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -619,5 +619,150 @@ void DreamGenContext::showrain() { } } +void DreamGenContext::updatepeople() { + data.word(kListpos) = kPeoplelist; + memset(segRef(data.word(kBuffers)).ptr(kPeoplelist, 12 * sizeof(People)), 0xff, 12 * sizeof(People)); + ++data.word(kMaintimer); + es = cs; + bx = kReelroutines; + const ReelRoutine *reelRoutine = (const ReelRoutine *)cs.ptr(bx, 0); + const uint16 *callbacks = (const uint16 *)cs.ptr(kReelcalls, 0); + while (true) { + uint8 realLocation = reelRoutine->reallocation; + if (realLocation == 255) + return; + if ((realLocation == data.byte(kReallocation)) && + (reelRoutine->mapX == data.byte(kMapx)) && + (reelRoutine->mapY == data.byte(kMapy))) { + uint16 callback = READ_LE_UINT16(callbacks); + //dw gamer,sparkydrip,eden,edeninbath,sparky,smokebloke + if (callback == addr_gamer) + gamer(); + else if (callback == addr_sparkydrip) + sparkydrip(); + else if (callback == addr_eden) + eden(); + else if (callback == addr_edeninbath) + edeninbath(); + else if (callback == addr_sparky) + sparky(); + else if (callback == addr_smokebloke) + smokebloke(); + //dw manasleep,drunk,receptionist,malefan,femalefan + else if (callback == addr_manasleep) + manasleep(); + else if (callback == addr_drunk) + drunk(); + else if (callback == addr_receptionist) + receptionist(); + else if (callback == addr_malefan) + malefan(); + else if (callback == addr_femalefan) + femalefan(); + //dw louis,louischair,soldier1,bossman,interviewer + else if (callback == addr_louis) + louis(); + else if (callback == addr_louischair) + louischair(); + else if (callback == addr_soldier1) + soldier1(); + else if (callback == addr_bossman) + bossman(); + else if (callback == addr_interviewer) + interviewer(); + //dw heavy,manasleep2,mansatstill,drinker,bartender + else if (callback == addr_heavy) + heavy(); + else if (callback == addr_manasleep2) + manasleep2(); + else if (callback == addr_mansatstill) + mansatstill(); + else if (callback == addr_drinker) + drinker(); + else if (callback == addr_bartender) + bartender(); + //dw othersmoker,tattooman,attendant,keeper,candles1 + else if (callback == addr_othersmoker) + othersmoker(); + else if (callback == addr_tattooman) + tattooman(); + else if (callback == addr_attendant) + attendant(); + else if (callback == addr_keeper) + keeper(); + else if (callback == addr_candles1) + candles1(); + //dw smallcandle,security,copper,poolguard,rockstar + else if (callback == addr_smallcandle) + smallcandle(); + else if (callback == addr_security) + security(); + else if (callback == addr_copper) + copper(); + else if (callback == addr_poolguard) + poolguard(); + else if (callback == addr_rockstar) + rockstar(); + //dw businessman,train,aide,mugger,helicopter + else if (callback == addr_businessman) + businessman(); + else if (callback == addr_train) + train(); + else if (callback == addr_aide) + aide(); + else if (callback == addr_mugger) + mugger(); + else if (callback == addr_helicopter) + helicopter(); + //dw intromagic1,intromusic,intromagic2,candles2,gates + else if (callback == addr_intromagic1) + intromagic1(); + else if (callback == addr_intromusic) + intromusic(); + else if (callback == addr_intromagic2) + intromagic2(); + else if (callback == addr_candles2) + candles2(); + else if (callback == addr_gates) + gates(); + //dw intromagic3,intromonks1,candles,intromonks2 + else if (callback == addr_intromagic3) + intromagic3(); + else if (callback == addr_intromonks1) + intromonks1(); + else if (callback == addr_candles) + candles(); + else if (callback == addr_intromonks2) + intromonks2(); + //dw handclap,monkandryan,endgameseq,priest,madman + else if (callback == addr_handclap) + handclap(); + else if (callback == addr_monkandryan) + monkandryan(); + else if (callback == addr_endgameseq) + endgameseq(); + else if (callback == addr_priest) + priest(); + else if (callback == addr_madman) + madman(); + //dw madmanstelly,alleybarksound,foghornsound + else if (callback == addr_madmanstelly) + madmanstelly(); + else if (callback == addr_alleybarksound) + alleybarksound(); + else if (callback == addr_foghornsound) + foghornsound(); + //dw carparkdrip,carparkdrip,carparkdrip,carparkdrip + else if (callback == addr_carparkdrip) + carparkdrip(); + else + assert(false); // Oops I forgot something in the dispatch table + } + bx += 8; + ++reelRoutine; + ++callbacks; + } +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 775466ad18e6..685e4cffe1ce 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -96,6 +96,17 @@ struct Reel { uint8 b4; }; +struct ReelRoutine { + uint8 reallocation; + uint8 mapX; + uint8 mapY; + uint8 b3; + uint8 b4; + uint8 b5; + uint8 b6; + uint8 b7; +}; + struct People { uint8 b0; uint8 b1; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 1f14faf404e1..94580b3a6894 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -127,5 +127,5 @@ void commandwithob(); void commandwithob(uint8 command, uint8 type, uint8 index); void showpanel(); - + void updatepeople();