From 4cdc9c9f8e883bdb4864e6b2c0ef127bf0824e9a Mon Sep 17 00:00:00 2001 From: Vladimir Menshakov Date: Sat, 18 Jun 2011 12:59:55 +0400 Subject: DREAMWEB: implemented clean exit --- devtools/tasmrecover/dreamweb/dreamweb.asm | 6 ++++++ engines/dreamweb/dreamgen.cpp | 7 ++++++- engines/dreamweb/dreamgen.h | 3 ++- engines/dreamweb/dreamweb.cpp | 6 ++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/devtools/tasmrecover/dreamweb/dreamweb.asm b/devtools/tasmrecover/dreamweb/dreamweb.asm index ea61338ae3..275d8208b0 100644 --- a/devtools/tasmrecover/dreamweb/dreamweb.asm +++ b/devtools/tasmrecover/dreamweb/dreamweb.asm @@ -195,6 +195,10 @@ alreadyloaded: mov newlocation,255 mov commandtype,255 mainloop: call screenupdate + cmp quitrequested, 0 + jz $1 + ret +$1: cmp wongame,0 jnz endofgame cmp mandead,1 @@ -6219,6 +6223,8 @@ savefiles db "DREAMWEB.D00",0 Recname db "DREAMWEB.DEM",0 +Quitrequested db 0 + ;-------------------------------------------------------End of code segment---- diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index a87f65bcb3..92901b0627 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -21359,6 +21359,11 @@ loadnew: data.byte(kCommandtype) = 255; mainloop: screenupdate(); + _cmp(data.byte(kQuitrequested), 0); + if (flags.z()) + goto _tmp1; + return; +_tmp1: _cmp(data.byte(kWongame), 0); if (!flags.z()) goto endofgame; @@ -21972,7 +21977,7 @@ void DreamGenContext::__start() { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, }; + 0x00, 0x00, 0x00, }; ds.assign(src, src + sizeof(src)); dreamweb(); } diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index a70f06d496..d7cf4677e3 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -486,7 +486,8 @@ public: const static uint16 kSavenames = 8579; const static uint16 kSavefiles = 8698; const static uint16 kRecname = 8789; - const static uint16 kStak = 8802; + const static uint16 kQuitrequested = 8802; + const static uint16 kStak = 8803; const static uint16 kBlocktextdat = (0); const static uint16 kPersonframes = (0); const static uint16 kDebuglevel1 = (0); diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp index cb66dda26b..4f39671b85 100644 --- a/engines/dreamweb/dreamweb.cpp +++ b/engines/dreamweb/dreamweb.cpp @@ -100,8 +100,9 @@ void DreamWebEngine::waitForVSync() { } void DreamWebEngine::quit() { - warning("Engine should quit gracefully (but doesn't yet)"); - g_system->quit(); + _context.data.byte(DreamGen::DreamGenContext::kQuitrequested) = 1; + _context.data.byte(DreamGen::DreamGenContext::kLasthardkey) = 1; + _context.data.byte(DreamGen::DreamGenContext::kGetback) = 4; } void DreamWebEngine::processEvents() { @@ -208,6 +209,7 @@ Common::Error DreamWebEngine::run() { //http://martin.hinner.info/vga/timing.html _context.__start(); + _context.data.byte(DreamGen::DreamGenContext::kQuitrequested) = 0; getTimerManager()->removeTimerProc(vSyncInterrupt); -- cgit v1.2.3