From f539d8f80f7f1b9dc62d6d68ac4aa1e32b2e3164 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 1 Dec 2011 10:08:16 +0100 Subject: DREAMWEB: Mechanism to allow reel callbacks to be specified either with a ReelRoutine or es:bx as parameters --- engines/dreamweb/sprite.cpp | 47 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 8d3d76a26f..72248378ad 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -567,7 +567,7 @@ void DreamGenContext::showrain() { playchannel1(soundIndex); } -static void (DreamGenContext::*reelCallbacks[])() = { +static void (DreamGenContext::*reelCallbacks[57])() = { &DreamGenContext::gamer, &DreamGenContext::sparkydrip, &DreamGenContext::eden, &DreamGenContext::edeninbath, &DreamGenContext::sparky, &DreamGenContext::smokebloke, @@ -599,24 +599,61 @@ static void (DreamGenContext::*reelCallbacks[])() = { &DreamGenContext::carparkdrip }; +static void (DreamGenContext::*reelCallbacksCPP[57])(ReelRoutine &) = { + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL +}; 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. + // The original callbacks are called with es:bx pointing to their reelRoutine entry. + // The new callbacks take a mutable ReelRoutine parameter. es = cs; - const ReelRoutine *r = (const ReelRoutine *)cs.ptr(kReelroutines, 0); + ReelRoutine *r = (ReelRoutine *)cs.ptr(kReelroutines, 0); for (int i = 0; r[i].reallocation != 255; ++i) { bx = kReelroutines + 8*i; if (r[i].reallocation == data.byte(kReallocation) && r[i].mapX == data.byte(kMapx) && r[i].mapY == data.byte(kMapy)) { - (this->*(reelCallbacks[i]))(); + if (reelCallbacks[i]) { + assert(!reelCallbacksCPP[i]); + (this->*(reelCallbacks[i]))(); + } else { + assert(reelCallbacksCPP[i]); + (this->*(reelCallbacksCPP[i]))(r[i]); + } } } } -- cgit v1.2.3