diff options
-rwxr-xr-x | devtools/tasmrecover/tasm-recover | 1 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.cpp | 38 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.h | 3 | ||||
-rw-r--r-- | engines/dreamweb/structs.h | 16 | ||||
-rw-r--r-- | engines/dreamweb/stubs.cpp | 19 | ||||
-rw-r--r-- | engines/dreamweb/stubs.h | 2 |
6 files changed, 39 insertions, 40 deletions
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 134292cc8b..fa246f5cf7 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -151,6 +151,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'delpointer', 'showblink', 'dumpblink', + 'checkcoords', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 3a819a0a6e..2b717e1966 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -15156,43 +15156,6 @@ alreadyrun: data.byte(kLastweapon) = 8; } -void DreamGenContext::checkcoords() { - STACK_CHECK; - _cmp(data.byte(kNewlocation), 255); - if (flags.z()) - goto loop048; - return; -loop048: - ax = cs.word(bx); - _cmp(ax, 0x0ffff); - if (flags.z()) - return /* (nonefound) */; - push(bx); - _cmp(data.word(kMousex), ax); - if (flags.l()) - goto over045; - ax = cs.word(bx+2); - _cmp(data.word(kMousex), ax); - if (!flags.l()) - goto over045; - ax = cs.word(bx+4); - _cmp(data.word(kMousey), ax); - if (flags.l()) - goto over045; - ax = cs.word(bx+6); - _cmp(data.word(kMousey), ax); - if (!flags.l()) - goto over045; - ax = cs.word(bx+8); - __dispatch_call(ax); - ax = pop(); - return; -over045: - bx = pop(); - _add(bx, 10); - goto loop048; -} - void DreamGenContext::identifyob() { STACK_CHECK; _cmp(data.word(kWatchingtime), 0); @@ -18257,7 +18220,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_convnum: convnum(); break; case addr_mainscreen: mainscreen(); break; case addr_madmanrun: madmanrun(); break; - case addr_checkcoords: checkcoords(); break; case addr_identifyob: identifyob(); break; case addr_checkifset: checkifset(); break; case addr_checkifex: checkifex(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index c770bbb966..300bfdd78e 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -130,7 +130,6 @@ public: static const uint16 addr_checkifex = 0xc9e0; static const uint16 addr_checkifset = 0xc9dc; static const uint16 addr_identifyob = 0xc9d4; - static const uint16 addr_checkcoords = 0xc9d0; static const uint16 addr_madmanrun = 0xc9cc; static const uint16 addr_mainscreen = 0xc9c8; static const uint16 addr_convnum = 0xc9c4; @@ -1598,7 +1597,7 @@ public: void showouterpad(); void getkeyandlogo(); void selectob(); - void checkcoords(); + //void checkcoords(); void dumpmenu(); void chewy(); void accesslighton(); diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index fe908f5857..1cb52eccea 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -54,6 +54,22 @@ struct Sprite { uint8 hidden; }; +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); } + + bool contains(uint16 x, uint16 y) const { + return (x >= xMin()) && (x < xMax()) && (y >= yMin()) && (y < yMax()); + } +}; + struct SetObject { uint8 b0; uint8 b1; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index ba47f1a945..5cbce89594 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1308,6 +1308,25 @@ void DreamGenContext::dumpblink() { multidump(44, 32, 16, 12); } +void DreamGenContext::checkcoords() { + checkcoords((const RectWithCallback *)cs.ptr(bx, 0)); +} + +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))) { + // TODO : Explicit dispatching + __dispatch_call(rectWithCallback->callback()); + return; + } + ++rectWithCallback; + } +} + bool DreamGenContext::isCD() { // The original sources has two codepaths depending if the game is 'if cd' or not // This is a hack to guess which version to use with the assumption that if we have a cd version diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 332e8a02a2..2cd22ceb29 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -181,4 +181,6 @@ void delpointer(); void showblink(); void dumpblink(); + void checkcoords(); + void checkcoords(const RectWithCallback *rectWithCallbacks); |