aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2004-12-18 02:08:32 +0000
committerMax Horn2004-12-18 02:08:32 +0000
commit06315c1ce1cc8fbf2d05637603d27f6dbc6c0cf2 (patch)
tree0a94215e7653e477dc4758a8e6882cb2d63f0806
parent0ceb634fd4f0ccac5012ed7db61f131b814b7a3b (diff)
downloadscummvm-rg350-06315c1ce1cc8fbf2d05637603d27f6dbc6c0cf2.tar.gz
scummvm-rg350-06315c1ce1cc8fbf2d05637603d27f6dbc6c0cf2.tar.bz2
scummvm-rg350-06315c1ce1cc8fbf2d05637603d27f6dbc6c0cf2.zip
A little more cleanup (the Simon code really is a big mess :-)
svn-id: r16107
-rw-r--r--simon/debug.cpp4
-rw-r--r--simon/items.cpp2
-rw-r--r--simon/simon.cpp69
-rw-r--r--simon/simon.h6
-rw-r--r--simon/vga.cpp8
5 files changed, 52 insertions, 37 deletions
diff --git a/simon/debug.cpp b/simon/debug.cpp
index 071146aa30..70aa8042b1 100644
--- a/simon/debug.cpp
+++ b/simon/debug.cpp
@@ -30,7 +30,7 @@
namespace Simon {
-byte *SimonEngine::dumpOpcode(byte *p) {
+const byte *SimonEngine::dumpOpcode(const byte *p) {
byte opcode;
const char *s, *st;
@@ -133,7 +133,7 @@ byte *SimonEngine::dumpOpcode(byte *p) {
}
void SimonEngine::dumpSubroutineLine(SubroutineLine *sl, Subroutine *sub) {
- byte *p;
+ const byte *p;
printf("; ****\n");
diff --git a/simon/items.cpp b/simon/items.cpp
index 5e67881576..589be615c7 100644
--- a/simon/items.cpp
+++ b/simon/items.cpp
@@ -1085,7 +1085,7 @@ int SimonEngine::runScript() {
int SimonEngine::startSubroutine(Subroutine *sub) {
int result = -1;
SubroutineLine *sl;
- byte *old_code_ptr;
+ const byte *old_code_ptr;
if (_start_mainscript)
dumpSubroutine(sub);
diff --git a/simon/simon.cpp b/simon/simon.cpp
index f6f6cd3da2..f547010f63 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -495,8 +495,8 @@ SimonEngine::SimonEngine(GameDetector *detector, OSystem *syst)
_x_scroll = 0;
_vga_var1 = 0;
_vga_var2 = 0;
- _vga_var3 = 0;
- _vga_var5 = 0;
+ _xscroll_step = 0;
+ _sprite_height = 0;
_vga_var7 = 0;
_vga_var8 = 0;
@@ -727,6 +727,18 @@ int SimonEngine::init(GameDetector &detector) {
}
SimonEngine::~SimonEngine() {
+ delete _game_file;
+
+ midi.close();
+
+ free(_stringtab_ptr);
+ free(_itemarray_ptr);
+ free(_itemheap_ptr - _itemheap_curpos);
+ free(_tablesheap_ptr - _tablesheap_curpos);
+ free(_tbl_list);
+ free(_icon_file_ptr);
+ free(_game_offsets_ptr);
+
delete _dummy_item_1;
delete _dummy_item_2;
delete _dummy_item_3;
@@ -1018,8 +1030,9 @@ void SimonEngine::setItemUnk3(Item *item, int value) {
}
int SimonEngine::getNextWord() {
+ int16 a = (int16)READ_BE_UINT16(_code_ptr);
_code_ptr += 2;
- return (int16)((_code_ptr[-2] << 8) | _code_ptr[-1]);
+ return a;
}
uint SimonEngine::getNextStringID() {
@@ -1034,7 +1047,7 @@ uint SimonEngine::getVarOrByte() {
}
uint SimonEngine::getVarOrWord() {
- uint a = (_code_ptr[0] << 8) | _code_ptr[1];
+ uint a = READ_BE_UINT16(_code_ptr);
_code_ptr += 2;
if (a >= 30000 && a < 30512)
return readVariable(a - 30000);
@@ -1348,7 +1361,7 @@ void SimonEngine::loadTablesIntoMem(uint subr_id) {
}
}
- debug(1,"loadTablesIntoMem: didn't find %d", subr_id);
+ debug(1,"loadTablesIntoMem: didn't find %d", subr_id);
}
void SimonEngine::playSting(uint a) {
@@ -1718,10 +1731,10 @@ void SimonEngine::handle_mouse_moved() {
if (_vga_var2 == 0) {
if (_mouse_x >= 631 / 2) {
if (_x_scroll != _vga_var1)
- _vga_var3 = 1;
+ _xscroll_step = 1;
} else if (_mouse_x < 8) {
if (_x_scroll != 0)
- _vga_var3 = -1;
+ _xscroll_step = -1;
}
}
} else {
@@ -2469,8 +2482,8 @@ void SimonEngine::set_video_mode_internal(uint mode, uint vga_res_id) {
_x_scroll = 0;
_vga_var1 = 0;
_vga_var2 = 0;
- _vga_var3 = 0;
- _vga_var5 = 134;
+ _xscroll_step = 0;
+ _sprite_height = 134;
if (_variableArray[34] != -1)
_variableArray[251] = 0;
}
@@ -2586,14 +2599,14 @@ void SimonEngine::scroll_timeout() {
return;
if (_vga_var2 < 0) {
- if (_vga_var3 != -1) {
- _vga_var3 = -1;
+ if (_xscroll_step != -1) {
+ _xscroll_step = -1;
if (++_vga_var2 == 0)
return;
}
} else {
- if (_vga_var3 != 1) {
- _vga_var3 = 1;
+ if (_xscroll_step != 1) {
+ _xscroll_step = 1;
if (--_vga_var2 == 0)
return;
}
@@ -2718,7 +2731,7 @@ void SimonEngine::timer_vga_sprites() {
if (_video_var_9 == 2)
_video_var_9 = 1;
- if (_game & GF_SIMON2 && _vga_var3) {
+ if (_game & GF_SIMON2 && _xscroll_step) {
timer_vga_sprites_helper();
}
@@ -2762,34 +2775,34 @@ void SimonEngine::timer_vga_sprites_helper() {
const byte *src;
uint x;
- if (_vga_var3 < 0) {
- memmove(dst + 8, dst, 320 * _vga_var5 - 8);
+ if (_xscroll_step < 0) {
+ memmove(dst + 8, dst, 320 * _sprite_height - 8);
} else {
- memmove(dst, dst + 8, 320 * _vga_var5 - 8);
+ memmove(dst, dst + 8, 320 * _sprite_height - 8);
}
x = _x_scroll - 1;
- if (_vga_var3 > 0) {
+ if (_xscroll_step > 0) {
dst += 320 - 8;
x += 41;
}
src = _vga_var7 + x * 4;
- decodeStripA(dst, src + READ_BE_UINT32(src), _vga_var5);
+ decodeStripA(dst, src + READ_BE_UINT32(src), _sprite_height);
dx_unlock_2();
memcpy(_sdl_buf_attached, _sdl_buf, 320 * 200);
- dx_copy_from_attached_to_3(_vga_var5);
+ dx_copy_from_attached_to_3(_sprite_height);
- _x_scroll += _vga_var3;
+ _x_scroll += _xscroll_step;
vc_write_var(0xfB, _x_scroll);
- _vga_var3 = 0;
+ _xscroll_step = 0;
}
void SimonEngine::timer_vga_sprites_2() {
@@ -4018,16 +4031,18 @@ int SimonEngine::go() {
}
void SimonEngine::shutdown() {
- if (_game_file) {
- delete _game_file;
- _game_file = NULL;
- }
+ delete _game_file;
+
+ midi.close();
free(_stringtab_ptr);
free(_itemarray_ptr);
free(_itemheap_ptr - _itemheap_curpos);
free(_tablesheap_ptr - _tablesheap_curpos);
- midi.close();
+ free(_tbl_list);
+ free(_icon_file_ptr);
+ free(_game_offsets_ptr);
+
_system->quit();
}
diff --git a/simon/simon.h b/simon/simon.h
index 14f6731f82..48c8bcded1 100644
--- a/simon/simon.h
+++ b/simon/simon.h
@@ -157,7 +157,7 @@ protected:
byte *_tbl_list;
- byte *_code_ptr;
+ const byte *_code_ptr;
byte **_local_stringtable;
@@ -212,7 +212,7 @@ protected:
bool _vga_var9;
int16 _script_unk_1;
bool _vga_var6;
- int _x_scroll, _vga_var1, _vga_var2, _vga_var3, _vga_var5;
+ int _x_scroll, _vga_var1, _vga_var2, _xscroll_step, _sprite_height;
const byte *_vga_var7;
byte _vga_var8;
@@ -415,7 +415,7 @@ protected:
void dumpSubroutines();
void dumpSubroutine(Subroutine *sub);
void dumpSubroutineLine(SubroutineLine *sl, Subroutine *sub);
- byte *dumpOpcode(byte *p);
+ const byte *dumpOpcode(const byte *p);
int startSubroutine(Subroutine *sub);
int startSubroutineEx(Subroutine *sub);
diff --git a/simon/vga.cpp b/simon/vga.cpp
index 5dbb3f934c..6630153186 100644
--- a/simon/vga.cpp
+++ b/simon/vga.cpp
@@ -648,7 +648,7 @@ void SimonEngine::vc_10_draw() {
_vga_var1 = width * 2 - 40;
_vga_var7 = state.depack_src;
- _vga_var5 = height;
+ _sprite_height = height;
if (_variableArray[34] == -1)
state.x = _variableArray[251];
@@ -1099,7 +1099,7 @@ void SimonEngine::vc_19_chain_to_script() {
/* helper routines */
void SimonEngine::vc_20_set_code_word() {
- /* FIXME: This pücode is somewhat strange: it first reads a BE word from
+ /* FIXME: This opcode is somewhat strange: it first reads a BE word from
* the script (advancing the script pointer in doing so); then it writes
* back the same word, this time as LE, into the script.
*/
@@ -1400,7 +1400,7 @@ void SimonEngine::vc_40_var_add() {
goto no_scroll;
_vga_var2 = 0;
} else {
- if (_vga_var3 != 0)
+ if (_xscroll_step != 0)
goto no_scroll;
}
@@ -1429,7 +1429,7 @@ void SimonEngine::vc_41_var_sub() {
goto no_scroll;
_vga_var2 = 0;
} else {
- if (_vga_var3 != 0)
+ if (_xscroll_step != 0)
goto no_scroll;
}