diff options
-rw-r--r-- | simon/midi.h | 113 | ||||
-rw-r--r-- | simon/simon.cpp | 194 | ||||
-rw-r--r-- | simon/simon.h | 365 | ||||
-rw-r--r-- | simon/simondebug.cpp | 1 | ||||
-rw-r--r-- | simon/simonintern.h | 171 | ||||
-rw-r--r-- | simon/simonitems.cpp | 3 | ||||
-rw-r--r-- | simon/simonres.cpp | 1 | ||||
-rw-r--r-- | simon/simonsys.cpp | 8 | ||||
-rw-r--r-- | simon/simonverb.cpp | 3 | ||||
-rw-r--r-- | simon/simonvga.cpp | 1 | ||||
-rw-r--r-- | wince/pocketpc.cpp | 2 |
11 files changed, 466 insertions, 396 deletions
diff --git a/simon/midi.h b/simon/midi.h new file mode 100644 index 0000000000..6ef61a866c --- /dev/null +++ b/simon/midi.h @@ -0,0 +1,113 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001/2002 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ + +#ifndef SIMON_MIDI_H +#define SIMON_MIDI_H + +class MidiDriver; +struct MidiEvent; + +class MidiPlayer { +public: + void read_all_songs(FILE *in); + void read_all_songs_old(FILE *in); + void initialize(); + void shutdown(); + void play(); + void set_driver(MidiDriver *md); + +private: + struct Track { + uint32 a; + uint32 data_size; + uint32 data_cur_size; + byte *data_ptr; + byte *data_cur_ptr; + uint32 delay; + byte last_cmd; + }; + + struct Song { + uint ppqn; + uint midi_format; + uint num_tracks; + Track *tracks; + }; + + struct NoteRec { + uint32 delay; + byte cmd; + byte param_1; + byte param_2; + uint cmd_length; + byte *sysex_data; + }; + + MidiDriver *_md; + + FILE *_input; + + uint _midi_var10, _midi_5; + bool _midi_var9; + byte _midi_var1; + bool _shutting_down; + uint _midi_var8; + + uint _midi_var11; + + uint32 _midi_tempo; + + Track *_midi_tick_track_ptr; + Track *_midi_track_ptr; + int16 _midi_song_id; + int16 _midi_song_id_2; + int16 _midi_var2; + + Song *_midi_cur_song_ptr; + + uint32 _midi_volume_table[16]; + + Song _midi_songs[8]; + + void read_mthd(Song *s, bool old); + + void read_from_file(void *dst, uint size); + void read_one_song(Song *s); + byte read_byte_from_file(); + uint32 read_uint32_from_file(); + uint16 read_uint16_from_file(); + + static uint32 track_read_gamma(Track *t); + static byte track_read_byte(Track *t); + + int fill(MidiEvent *me, int num_event); + bool fill_helper(NoteRec *nr, MidiEvent *me); + + void reset_tracks(); + void read_next_note(Track *t, NoteRec *nr); + + void unload(); + + static int on_fill(void *param, MidiEvent *ev, int num); + +}; + +#endif diff --git a/simon/simon.cpp b/simon/simon.cpp index 645aec9092..23c07aba65 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -21,16 +21,9 @@ #include "stdafx.h" #include "simon.h" +#include "simonintern.h" #include <errno.h> -int sdl_mouse_x, sdl_mouse_y; - -byte *sdl_buf_3; -byte *sdl_buf; -byte *sdl_buf_attached; - -SimonState *g_simon; - #ifdef _WIN32_WCE extern bool toolbar_drawn; @@ -39,6 +32,101 @@ extern bool draw_keyboard; #endif +static const GameSpecificSettings simon1_settings = { + 1, /* VGA_DELAY_BASE */ + 1576 / 4, /* TABLE_INDEX_BASE */ + 1460 / 4, /* TEXT_INDEX_BASE */ + 1700 / 4, /* NUM_GAME_OFFSETS */ + 64, /* NUM_VIDEO_OP_CODES */ + 1000000, /* VGA_MEM_SIZE */ + 50000, /* TABLES_MEM_SIZE */ + 3624, /* NUM_VOICE_RESOURCES */ + 141, /* NUM_EFFECT_RESOURCES */ + 1316 / 4, /* MUSIC_INDEX_BASE */ + 0, /* SOUND_INDEX_BASE */ + "SIMON.GME", /* gme_filename */ + "SIMON.WAV", /* wav_filename */ + "SIMON.VOC", /* wav_filename2 */ + "EFFECTS.VOC", /* effects_filename */ + "GAMEPC", /* gamepc_filename */ +}; + +static const GameSpecificSettings simon2_settings = { + 5, /* VGA_DELAY_BASE */ + 1580 / 4, /* TABLE_INDEX_BASE */ + 1500 / 4, /* TEXT_INDEX_BASE */ + 2116 / 4, /* NUM_GAME_OFFSETS */ + 75, /* NUM_VIDEO_OP_CODES */ + 2000000, /* VGA_MEM_SIZE */ + 100000, /* TABLES_MEM_SIZE */ + 12256, /* NUM_VOICE_RESOURCES */ + 0, + 1128 / 4, /* MUSIC_INDEX_BASE */ + 1660 / 4, /* SOUND_INDEX_BASE */ + "SIMON2.GME", /* gme_filename */ + "SIMON2.WAV", /* wav_filename */ + NULL, + "", + "GSPTR30", /* gamepc_filename */ +}; + +static const GameSpecificSettings simon2win_settings = { + 5, /* VGA_DELAY_BASE */ + 1580 / 4, /* TABLE_INDEX_BASE */ + 1500 / 4, /* TEXT_INDEX_BASE */ + 2116 / 4, /* NUM_GAME_OFFSETS */ + 75, /* NUM_VIDEO_OP_CODES */ + 2000000, /* VGA_MEM_SIZE */ + 100000, /* TABLES_MEM_SIZE */ + 12256, /* NUM_VOICE_RESOURCES */ + 0, + 1128 / 4, /* MUSIC_INDEX_BASE */ + 1660 / 4, /* SOUND_INDEX_BASE */ + "SIMON2.GME", /* gme_filename */ + "SIMON2.WAV", /* wav_filename */ + NULL, + "", + "GSPTR30", /* gamepc_filename */ +}; + +static const GameSpecificSettings simon2dos_settings = { + 5, /* VGA_DELAY_BASE */ + 1580 / 4, /* TABLE_INDEX_BASE */ + 1500 / 4, /* TEXT_INDEX_BASE */ + 2116 / 4, /* NUM_GAME_OFFSETS */ + 75, /* NUM_VIDEO_OP_CODES */ + 2000000, /* VGA_MEM_SIZE */ + 100000, /* TABLES_MEM_SIZE */ + 12256, /* NUM_VOICE_RESOURCES */ + 0, + 1128 / 4, /* MUSIC_INDEX_BASE */ + 1660 / 4, /* SOUND_INDEX_BASE */ + "SIMON2.GME", /* gme_filename */ + "SIMON2.WAV", /* wav_filename */ + NULL, + "", + "GAME32", /* gamepc_filename */ +}; + + +SimonState::SimonState() +{ + _dummy_item_1 = new Item(); + _dummy_item_2 = new Item(); + _dummy_item_3 = new Item(); + + _fcs_list = new FillOrCopyStruct[16]; +} + +SimonState::~SimonState() +{ + delete _dummy_item_1; + delete _dummy_item_2; + delete _dummy_item_3; + + delete [] _fcs_list; +} + SimonState *SimonState::create(OSystem *syst, MidiDriver *driver) { SimonState *s = new SimonState; @@ -440,11 +528,11 @@ Item *SimonState::getNextItemPtrStrange() case -3: return _object_item; case -5: - return &_dummy_item_2; + return _dummy_item_2; case -7: return NULL; case -9: - return &_dummy_item_3; + return _dummy_item_3; default: return derefItem(a); } @@ -474,7 +562,7 @@ Item *SimonState::getItem1Ptr() { if (_item_1_ptr) return _item_1_ptr; - return &_dummy_item_1; + return _dummy_item_1; } Item *SimonState::getItemPtrB() @@ -482,7 +570,7 @@ Item *SimonState::getItemPtrB() error("getItemPtrB: is this code ever used?"); if (_item_ptr_B) return _item_ptr_B; - return &_dummy_item_1; + return _dummy_item_1; } uint SimonState::getNextVarContents() @@ -967,10 +1055,10 @@ void SimonState::o_setup_cond_c() _item_1_ptr = item; _object_item = _hitarea_object_item; - if (_object_item == &_dummy_item_2) + if (_object_item == _dummy_item_2) _object_item = getItem1Ptr(); - if (_object_item == &_dummy_item_3) + if (_object_item == _dummy_item_3) _object_item = derefItem(getItem1Ptr()->parent); if (_object_item != NULL) { @@ -1007,7 +1095,11 @@ void SimonState::setup_cond_c_helper() _left_button_down = 0; do { +#ifdef WIN32 if (GetAsyncKeyState(VK_F5) != 0 && _bit_array[0] & 0x200) { +#else + if (_bit_array[0] & 0x200) { +#endif startSubroutine170(); goto out_of_here; } @@ -1071,7 +1163,9 @@ void SimonState::unlock() if (_lock_counter != 0) { if (_lock_counter == 1) { +#ifdef WIN32 GetAsyncKeyState(VK_LBUTTON); +#endif } _lock_counter--; } @@ -1550,8 +1644,8 @@ void SimonState::showmessage_helper_3(uint a, uint b) void SimonState::pollMouseXY() { - _mouse_x = sdl_mouse_x; - _mouse_y = sdl_mouse_y; + _mouse_x = _sdl_mouse_x; + _mouse_y = _sdl_mouse_y; } void SimonState::handle_verb_clicked(uint verb) @@ -1562,18 +1656,18 @@ void SimonState::handle_verb_clicked(uint verb) _item_1_ptr = _item_1; _object_item = _hitarea_object_item; - if (_object_item == &_dummy_item_2) { + if (_object_item == _dummy_item_2) { _object_item = getItem1Ptr(); } - if (_object_item == &_dummy_item_3) { + if (_object_item == _dummy_item_3) { _object_item = derefItem(getItem1Ptr()->parent); } _subject_item = _hitarea_subject_item; - if (_subject_item == &_dummy_item_2) { + if (_subject_item == _dummy_item_2) { _subject_item = getItem1Ptr(); } - if (_subject_item == &_dummy_item_3) { + if (_subject_item == _dummy_item_3) { _subject_item = derefItem(getItem1Ptr()->parent); } @@ -2487,7 +2581,7 @@ void SimonState::timer_vga_sprites() } #ifdef DRAW_IMAGES_DEBUG - memset(sdl_buf_attached, 0, 320 * 200); + memset(_sdl_buf_attached, 0, 320 * 200); #endif _video_var_8++; _vc_ptr = vc_ptr_org; @@ -2517,7 +2611,7 @@ void SimonState::timer_vga_sprites_helper() dx_unlock_2(); - memcpy(sdl_buf_attached, sdl_buf, 320 * 200); + memcpy(_sdl_buf_attached, _sdl_buf, 320 * 200); dx_copy_from_attached_to_3(_vga_var5); @@ -4111,7 +4205,7 @@ void SimonState::dx_copy_rgn_from_3_to_2(uint b, uint r, uint y, uint x) uint i; dst = dx_lock_2(); - src = sdl_buf_3; + src = _sdl_buf_3; dst += y * _dx_surface_pitch; src += y * _dx_surface_pitch; @@ -4129,26 +4223,26 @@ void SimonState::dx_copy_rgn_from_3_to_2(uint b, uint r, uint y, uint x) void SimonState::dx_clear_surfaces(uint num_lines) { - memset(sdl_buf_attached, 0, num_lines * 320); + memset(_sdl_buf_attached, 0, num_lines * 320); - _system->copy_rect(sdl_buf_attached, 320, 0, 0, 320, 200); + _system->copy_rect(_sdl_buf_attached, 320, 0, 0, 320, 200); if (_dx_use_3_or_4_for_lock) { - memset(sdl_buf, 0, num_lines * 320); - memset(sdl_buf_3, 0, num_lines * 320); + memset(_sdl_buf, 0, num_lines * 320); + memset(_sdl_buf_3, 0, num_lines * 320); } } void SimonState::dx_clear_attached_from_top(uint lines) { - memset(sdl_buf_attached, 0, lines * 320); + memset(_sdl_buf_attached, 0, lines * 320); } void SimonState::dx_copy_from_attached_to_2(uint x, uint y, uint w, uint h) { uint offs = x + y * 320; - byte *s = sdl_buf_attached + offs; - byte *d = sdl_buf + offs; + byte *s = _sdl_buf_attached + offs; + byte *d = _sdl_buf + offs; do { memcpy(d, s, w); @@ -4160,8 +4254,8 @@ void SimonState::dx_copy_from_attached_to_2(uint x, uint y, uint w, uint h) void SimonState::dx_copy_from_2_to_attached(uint x, uint y, uint w, uint h) { uint offs = x + y * 320; - byte *s = sdl_buf + offs; - byte *d = sdl_buf_attached + offs; + byte *s = _sdl_buf + offs; + byte *d = _sdl_buf_attached + offs; do { memcpy(d, s, w); @@ -4174,7 +4268,7 @@ void SimonState::dx_copy_from_2_to_attached(uint x, uint y, uint w, uint h) void SimonState::dx_copy_from_attached_to_3(uint lines) { - memcpy(sdl_buf_3, sdl_buf_attached, lines * 320); + memcpy(_sdl_buf_3, _sdl_buf_attached, lines * 320); } void SimonState::dx_update_screen_and_palette() @@ -4193,13 +4287,13 @@ void SimonState::dx_update_screen_and_palette() if (_mouse_pos_changed) { _mouse_pos_changed = false; - _system->set_mouse_pos(sdl_mouse_x, sdl_mouse_y); + _system->set_mouse_pos(_sdl_mouse_x, _sdl_mouse_y); } - _system->copy_rect(sdl_buf_attached, 320, 0, 0, 320, 200); + _system->copy_rect(_sdl_buf_attached, 320, 0, 0, 320, 200); _system->update_screen(); } - memcpy(sdl_buf_attached, sdl_buf, 320 * 200); + memcpy(_sdl_buf_attached, _sdl_buf, 320 * 200); if (_palette_color_count != 0) { if (!(_game & GAME_SIMON2) && _use_palette_delay) { @@ -4233,9 +4327,9 @@ void SimonState::go() _dump_file = stdout; /* allocate buffers */ - sdl_buf_3 = (byte *)calloc(320 * 200, 1); - sdl_buf = (byte *)calloc(320 * 200, 1); - sdl_buf_attached = (byte *)calloc(320 * 200, 1); + _sdl_buf_3 = (byte *)calloc(320 * 200, 1); + _sdl_buf = (byte *)calloc(320 * 200, 1); + _sdl_buf_attached = (byte *)calloc(320 * 200, 1); if (_game == GAME_SIMON2WIN) { gss = &simon2win_settings; @@ -4304,7 +4398,8 @@ void SimonState::delay(uint delay) while (_system->poll_event(&event)) { switch (event.event_code) { - case OSystem::EVENT_KEYDOWN:if (event.kbd.keycode == 't') { + case OSystem::EVENT_KEYDOWN: + if (event.kbd.keycode == 't') { _vk_t_toggle ^= 1; } else if (event.kbd.flags == OSystem::KBD_CTRL) { if (event.kbd.keycode == 'f') { @@ -4313,19 +4408,22 @@ void SimonState::delay(uint delay) } _key_pressed = (byte)event.kbd.ascii; break; - case OSystem::EVENT_MOUSEMOVE:sdl_mouse_x = event.mouse.x; - sdl_mouse_y = event.mouse.y; + case OSystem::EVENT_MOUSEMOVE: + _sdl_mouse_x = event.mouse.x; + _sdl_mouse_y = event.mouse.y; _mouse_pos_changed = true; break; - case OSystem::EVENT_LBUTTONDOWN:_left_button_down++; + case OSystem::EVENT_LBUTTONDOWN: + _left_button_down++; #ifdef _WIN32_WCE - sdl_mouse_x = event.mouse.x; - sdl_mouse_y = event.mouse.y; + _sdl_mouse_x = event.mouse.x; + _sdl_mouse_y = event.mouse.y; #endif break; - case OSystem::EVENT_RBUTTONDOWN:_exit_cutscene = true; + case OSystem::EVENT_RBUTTONDOWN: + _exit_cutscene = true; break; } } @@ -4824,7 +4922,7 @@ void SimonState::playMusic(uint music) byte *SimonState::dx_lock_2() { _dx_surface_pitch = 320; - return sdl_buf; + return _sdl_buf; } void SimonState::dx_unlock_2() @@ -4834,7 +4932,7 @@ void SimonState::dx_unlock_2() byte *SimonState::dx_lock_attached() { _dx_surface_pitch = 320; - return _dx_use_3_or_4_for_lock ? sdl_buf_3 : sdl_buf_attached; + return _dx_use_3_or_4_for_lock ? _sdl_buf_3 : _sdl_buf_attached; } void SimonState::dx_unlock_attached() diff --git a/simon/simon.h b/simon/simon.h index 1ce7ee452a..aed088aca3 100644 --- a/simon/simon.h +++ b/simon/simon.h @@ -19,9 +19,13 @@ * */ +#ifndef SIMON_H +#define SIMON_H + #include <time.h> #include <sys/stat.h> #include "engine.h" +#include "simon/midi.h" /* Various other settings */ //#define DUMP_CONTINOUS_MAINSCRIPT @@ -48,111 +52,21 @@ uint fileReadItemID(FILE *in); #define CHECK_BOUNDS(x,y) assert((uint)(x)<ARRAYSIZE(y)) #define NUM_PALETTE_FADEOUT 32 -struct Child { - Child *next; - uint16 type; -}; - -struct Child2 { - Child hdr; - - uint16 string_id; - uint32 avail_props; - int16 array[1]; -}; - -struct Child1 { - Child hdr; +struct Child; +struct Child1; +struct Child2; +struct Child3; - uint16 subroutine_id; - uint16 fr2; - uint16 array[1]; -}; - -struct Child9 { - Child hdr; - - uint16 array[4]; -}; - -struct Child3 { - Child hdr; -}; +struct Item; +struct FillOrCopyStruct; +struct Subroutine; +struct SubroutineLine; +struct TimeEvent; struct ThreeValues { int16 a, b, c; }; -enum { - CHILD1_SIZE = sizeof(Child1) - sizeof(uint16), - CHILD2_SIZE = sizeof(Child2) - sizeof(int16) -}; - -struct Item { - uint16 parent; - uint16 child; - uint16 sibling; - int16 unk1; - int16 unk2; - int16 unk3; /* signed int */ - uint16 unk4; - uint16 xxx_1; /* unused? */ - Child *children; -}; - -struct Subroutine { - uint16 id; /* subroutine ID */ - uint16 first; /* offset from subroutine start to first subroutine line */ - Subroutine *next; /* next subroutine in linked list */ -}; - -struct FillOrCopyDataEntry { - Item *item; - uint16 hit_area; - uint16 xxx_1; -}; - -struct FillOrCopyData { - int16 unk1; - Item *item_ptr; - FillOrCopyDataEntry e[64]; - int16 unk3, unk4; - uint16 unk2; -}; - -struct FillOrCopyStruct { - byte mode; - byte flags; - uint16 x, y; - uint16 width, height; - uint16 textColumn, textRow; - uint8 textColumnOffset, textLength, textMaxLength; - uint8 fill_color, text_color, unk5; - FillOrCopyData *fcs_data; -}; -// note on text offset: -// the actual x-coordinate is: textColumn * 8 + textColumnOffset -// the actual y-coordinate is: textRow * 8 - - -enum { - SUBROUTINE_LINE_SMALL_SIZE = 2, - SUBROUTINE_LINE_BIG_SIZE = 8, -}; - -struct SubroutineLine { - uint16 next; - int16 cond_a; - int16 cond_b; - int16 cond_c; -}; - -struct TimeEvent { - uint32 time; - uint16 subroutine_id; - TimeEvent *next; -}; - struct HitArea { uint16 x, y; uint16 width, height; @@ -192,165 +106,7 @@ struct VgaTimerEntry { uint16 cur_vga_file; }; -struct VgaFile1Header { - uint16 x_1, x_2; - uint16 hdr2_start; - uint16 x_3, x_4; -}; - -struct VgaFile1Header2 { - uint16 x_1; - uint16 unk1; - uint16 x_2; - uint16 id_count; - uint16 x_3; - uint16 unk2_offs; - uint16 x_4; - uint16 id_table; - uint16 x_5; -}; - -struct VgaFile1Struct0x8 { - uint16 id; - uint16 x_1; - uint16 x_2; - uint16 script_offs; -}; - -struct VgaFile1Struct0x6 { - uint16 id; - uint16 x_2; - uint16 script_offs; -}; - -/* dummy typedefs to make it compile in *nix */ -#if defined(UNIX) || defined(__MORPHOS__) || defined(__DC__) || defined(macintosh) -typedef void *HMIDISTRM; -typedef void *HMIDIOUT; -typedef uint32 UINT; -typedef void *MIDIHDR; -typedef uint32 MMRESULT; -#define CALLBACK -typedef uint32 DWORD; - -enum { - VK_F5 = 1, - VK_LBUTTON = 2, - VK_SHIFT = 3, - -}; - -int GetAsyncKeyState(int key); -#endif - -class MidiDriver; -struct MidiEvent; - -class MidiPlayer { -public: - void read_all_songs(FILE *in); - void read_all_songs_old(FILE *in); - void initialize(); - void shutdown(); - void play(); - void set_driver(MidiDriver *md); - -private: - struct Track { - uint32 a; - uint32 data_size; - uint32 data_cur_size; - byte *data_ptr; - byte *data_cur_ptr; - uint32 delay; - byte last_cmd; - }; - - struct Song { - uint ppqn; - uint midi_format; - uint num_tracks; - Track *tracks; - }; - - struct NoteRec { - uint32 delay; - byte cmd; - byte param_1; - byte param_2; - uint cmd_length; - byte *sysex_data; - }; - - MidiDriver *_md; - - FILE *_input; - - uint _midi_var10, _midi_5; - bool _midi_var9; - byte _midi_var1; - bool _shutting_down; - uint _midi_var8; - - uint _midi_var11; - - uint32 _midi_tempo; - - Track *_midi_tick_track_ptr; - Track *_midi_track_ptr; - int16 _midi_song_id; - int16 _midi_song_id_2; - int16 _midi_var2; - - Song *_midi_cur_song_ptr; - - uint32 _midi_volume_table[16]; - - Song _midi_songs[8]; - - void read_mthd(Song *s, bool old); - - void read_from_file(void *dst, uint size); - void read_one_song(Song *s); - byte read_byte_from_file(); - uint32 read_uint32_from_file(); - uint16 read_uint16_from_file(); - - static uint32 track_read_gamma(Track *t); - static byte track_read_byte(Track *t); - - int fill(MidiEvent *me, int num_event); - bool fill_helper(NoteRec *nr, MidiEvent *me); - - void reset_tracks(); - void read_next_note(Track *t, NoteRec *nr); - - void unload(); - - static int on_fill(void *param, MidiEvent *ev, int num); - -}; - - -struct GameSpecificSettings { - uint VGA_DELAY_BASE; - uint TABLE_INDEX_BASE; - uint TEXT_INDEX_BASE; - uint NUM_GAME_OFFSETS; - uint NUM_VIDEO_OP_CODES; - uint VGA_MEM_SIZE; - uint TABLES_MEM_SIZE; - uint NUM_VOICE_RESOURCES; - uint NUM_EFFECTS_RESOURCES; - uint MUSIC_INDEX_BASE; - uint SOUND_INDEX_BASE; - const char *gme_filename; - const char *wav_filename; - const char *wav_filename2; - const char *effects_filename; - const char *gamepc_filename; -}; - +struct GameSpecificSettings; class SimonState : public Engine { public: @@ -487,9 +243,9 @@ public: uint _mouse_x, _mouse_y; uint _mouse_x_old, _mouse_y_old; - Item _dummy_item_1; - Item _dummy_item_2; - Item _dummy_item_3; + Item *_dummy_item_1; + Item *_dummy_item_2; + Item *_dummy_item_3; uint16 _lock_word; uint16 _scroll_up_hit_area; @@ -569,7 +325,7 @@ public: VgaTimerEntry _vga_timer_list[95]; - FillOrCopyStruct _fcs_list[16]; + FillOrCopyStruct *_fcs_list; byte _letters_to_print_buf[80]; @@ -594,6 +350,15 @@ public: bool _save_or_load; bool _saveload_flag; + int _sdl_mouse_x, _sdl_mouse_y; + + byte *_sdl_buf_3; + byte *_sdl_buf; + byte *_sdl_buf_attached; + + SimonState(); + virtual ~SimonState(); + int allocGamePcVars(FILE *in); Item *allocItem1(); void loginPlayerHelper(Item *item, int a, int b); @@ -1064,78 +829,4 @@ void initializeHardware(); void dx_set_palette(uint32 *colors, uint num); void palette_fadeout(uint32 *pal_values, uint num); -static const GameSpecificSettings simon1_settings = { - 1, /* VGA_DELAY_BASE */ - 1576 / 4, /* TABLE_INDEX_BASE */ - 1460 / 4, /* TEXT_INDEX_BASE */ - 1700 / 4, /* NUM_GAME_OFFSETS */ - 64, /* NUM_VIDEO_OP_CODES */ - 1000000, /* VGA_MEM_SIZE */ - 50000, /* TABLES_MEM_SIZE */ - 3624, /* NUM_VOICE_RESOURCES */ - 141, /* NUM_EFFECT_RESOURCES */ - 1316 / 4, /* MUSIC_INDEX_BASE */ - 0, /* SOUND_INDEX_BASE */ - "SIMON.GME", /* gme_filename */ - "SIMON.WAV", /* wav_filename */ - "SIMON.VOC", /* wav_filename2 */ - "EFFECTS.VOC", /* effects_filename */ - "GAMEPC", /* gamepc_filename */ -}; - -static const GameSpecificSettings simon2_settings = { - 5, /* VGA_DELAY_BASE */ - 1580 / 4, /* TABLE_INDEX_BASE */ - 1500 / 4, /* TEXT_INDEX_BASE */ - 2116 / 4, /* NUM_GAME_OFFSETS */ - 75, /* NUM_VIDEO_OP_CODES */ - 2000000, /* VGA_MEM_SIZE */ - 100000, /* TABLES_MEM_SIZE */ - 12256, /* NUM_VOICE_RESOURCES */ - 0, - 1128 / 4, /* MUSIC_INDEX_BASE */ - 1660 / 4, /* SOUND_INDEX_BASE */ - "SIMON2.GME", /* gme_filename */ - "SIMON2.WAV", /* wav_filename */ - NULL, - "", - "GSPTR30", /* gamepc_filename */ -}; - -static const GameSpecificSettings simon2win_settings = { - 5, /* VGA_DELAY_BASE */ - 1580 / 4, /* TABLE_INDEX_BASE */ - 1500 / 4, /* TEXT_INDEX_BASE */ - 2116 / 4, /* NUM_GAME_OFFSETS */ - 75, /* NUM_VIDEO_OP_CODES */ - 2000000, /* VGA_MEM_SIZE */ - 100000, /* TABLES_MEM_SIZE */ - 12256, /* NUM_VOICE_RESOURCES */ - 0, - 1128 / 4, /* MUSIC_INDEX_BASE */ - 1660 / 4, /* SOUND_INDEX_BASE */ - "SIMON2.GME", /* gme_filename */ - "SIMON2.WAV", /* wav_filename */ - NULL, - "", - "GSPTR30", /* gamepc_filename */ -}; - -static const GameSpecificSettings simon2dos_settings = { - 5, /* VGA_DELAY_BASE */ - 1580 / 4, /* TABLE_INDEX_BASE */ - 1500 / 4, /* TEXT_INDEX_BASE */ - 2116 / 4, /* NUM_GAME_OFFSETS */ - 75, /* NUM_VIDEO_OP_CODES */ - 2000000, /* VGA_MEM_SIZE */ - 100000, /* TABLES_MEM_SIZE */ - 12256, /* NUM_VOICE_RESOURCES */ - 0, - 1128 / 4, /* MUSIC_INDEX_BASE */ - 1660 / 4, /* SOUND_INDEX_BASE */ - "SIMON2.GME", /* gme_filename */ - "SIMON2.WAV", /* wav_filename */ - NULL, - "", - "GAME32", /* gamepc_filename */ -}; +#endif diff --git a/simon/simondebug.cpp b/simon/simondebug.cpp index a4aa8cba78..ed7febe739 100644 --- a/simon/simondebug.cpp +++ b/simon/simondebug.cpp @@ -22,6 +22,7 @@ // Simon debug functions #include "stdafx.h" #include "simon.h" +#include "simonintern.h" #ifdef SIMONDEBUG #define SIMON2 diff --git a/simon/simonintern.h b/simon/simonintern.h new file mode 100644 index 0000000000..2536534844 --- /dev/null +++ b/simon/simonintern.h @@ -0,0 +1,171 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001/2002 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ + +#ifndef SIMON_INTERN_H +#define SIMON_INTERN_H + +struct Child { + Child *next; + uint16 type; +}; + +struct Child1 : Child { + uint16 subroutine_id; + uint16 fr2; + uint16 array[1]; +}; + +struct Child2 : Child { + uint16 string_id; + uint32 avail_props; + int16 array[1]; +}; + +struct Child3 : Child { +}; + +struct Child9 : Child { + uint16 array[4]; +}; + +enum { + CHILD1_SIZE = sizeof(Child1) - sizeof(uint16), + CHILD2_SIZE = sizeof(Child2) - sizeof(int16) +}; + + +struct Item { + uint16 parent; + uint16 child; + uint16 sibling; + int16 unk1; + int16 unk2; + int16 unk3; /* signed int */ + uint16 unk4; + uint16 xxx_1; /* unused? */ + Child *children; +}; + +struct Subroutine { + uint16 id; /* subroutine ID */ + uint16 first; /* offset from subroutine start to first subroutine line */ + Subroutine *next; /* next subroutine in linked list */ +}; + +struct FillOrCopyDataEntry { + Item *item; + uint16 hit_area; + uint16 xxx_1; +}; + +struct FillOrCopyData { + int16 unk1; + Item *item_ptr; + FillOrCopyDataEntry e[64]; + int16 unk3, unk4; + uint16 unk2; +}; + +struct FillOrCopyStruct { + byte mode; + byte flags; + uint16 x, y; + uint16 width, height; + uint16 textColumn, textRow; + uint8 textColumnOffset, textLength, textMaxLength; + uint8 fill_color, text_color, unk5; + FillOrCopyData *fcs_data; +}; +// note on text offset: +// the actual x-coordinate is: textColumn * 8 + textColumnOffset +// the actual y-coordinate is: textRow * 8 + + +enum { + SUBROUTINE_LINE_SMALL_SIZE = 2, + SUBROUTINE_LINE_BIG_SIZE = 8, +}; + +struct SubroutineLine { + uint16 next; + int16 cond_a; + int16 cond_b; + int16 cond_c; +}; + +struct TimeEvent { + uint32 time; + uint16 subroutine_id; + TimeEvent *next; +}; + +struct VgaFile1Header { + uint16 x_1, x_2; + uint16 hdr2_start; + uint16 x_3, x_4; +}; + +struct VgaFile1Header2 { + uint16 x_1; + uint16 unk1; + uint16 x_2; + uint16 id_count; + uint16 x_3; + uint16 unk2_offs; + uint16 x_4; + uint16 id_table; + uint16 x_5; +}; + +struct VgaFile1Struct0x8 { + uint16 id; + uint16 x_1; + uint16 x_2; + uint16 script_offs; +}; + +struct VgaFile1Struct0x6 { + uint16 id; + uint16 x_2; + uint16 script_offs; +}; + + +struct GameSpecificSettings { + uint VGA_DELAY_BASE; + uint TABLE_INDEX_BASE; + uint TEXT_INDEX_BASE; + uint NUM_GAME_OFFSETS; + uint NUM_VIDEO_OP_CODES; + uint VGA_MEM_SIZE; + uint TABLES_MEM_SIZE; + uint NUM_VOICE_RESOURCES; + uint NUM_EFFECTS_RESOURCES; + uint MUSIC_INDEX_BASE; + uint SOUND_INDEX_BASE; + const char *gme_filename; + const char *wav_filename; + const char *wav_filename2; + const char *effects_filename; + const char *gamepc_filename; +}; + +#endif diff --git a/simon/simonitems.cpp b/simon/simonitems.cpp index 90c0c7b0ee..39e95d3a70 100644 --- a/simon/simonitems.cpp +++ b/simon/simonitems.cpp @@ -22,6 +22,7 @@ // Item script opcodes for Simon1/Simon2 #include "stdafx.h" #include "simon.h" +#include "simonintern.h" #ifdef _WIN32_WCE @@ -372,7 +373,7 @@ int SimonState::runScript() int h = getVarOrWord(); int number = getVarOrByte(); if (number < 20) - addNewHitArea(id, x, y, w, h, (number << 8) + 129, 0xD0, &_dummy_item_2); + addNewHitArea(id, x, y, w, h, (number << 8) + 129, 0xD0, _dummy_item_2); } break; diff --git a/simon/simonres.cpp b/simon/simonres.cpp index f0537e1d1b..3ee30ae90e 100644 --- a/simon/simonres.cpp +++ b/simon/simonres.cpp @@ -22,6 +22,7 @@ // Resource file routines for Simon1/Simon2 #include "stdafx.h" #include "simon.h" +#include "simonintern.h" // Script opcodes to load into memory static const char *const opcode_arg_table_simon1win[256] = { diff --git a/simon/simonsys.cpp b/simon/simonsys.cpp index 14a5585553..0bef256764 100644 --- a/simon/simonsys.cpp +++ b/simon/simonsys.cpp @@ -69,11 +69,3 @@ void fileWriteBE16(FILE *in, uint16 value) value = TO_BE_16(value); fwrite(&value, sizeof(value), 1, in); } - -#ifndef WIN32 -/* GetAsyncKeyState for unix */ -int GetAsyncKeyState(int key) -{ - return 0; -} -#endif diff --git a/simon/simonverb.cpp b/simon/simonverb.cpp index 77065f7a9c..662237cd68 100644 --- a/simon/simonverb.cpp +++ b/simon/simonverb.cpp @@ -22,6 +22,7 @@ // Verb and hitarea handling #include "stdafx.h" #include "simon.h" +#include "simonintern.h" void SimonState::defocusHitarea() { @@ -430,7 +431,7 @@ bool SimonState::hitarea_proc_3(Item *item) uint x; const byte *string_ptr; - if (item == 0 || item == &_dummy_item_2 || item == &_dummy_item_3) + if (item == 0 || item == _dummy_item_2 || item == _dummy_item_3) return false; child2 = findChildOfType2(item); diff --git a/simon/simonvga.cpp b/simon/simonvga.cpp index dc9eb639d8..1c56d5295d 100644 --- a/simon/simonvga.cpp +++ b/simon/simonvga.cpp @@ -22,6 +22,7 @@ // Video script opcodes for Simon1/Simon2 #include "stdafx.h" #include "simon.h" +#include "simonintern.h" typedef void (SimonState::*VgaOpcodeProc) (); static const uint16 vc_get_out_of_code = 0; diff --git a/wince/pocketpc.cpp b/wince/pocketpc.cpp index f2a9629adb..407c984e4f 100644 --- a/wince/pocketpc.cpp +++ b/wince/pocketpc.cpp @@ -59,7 +59,7 @@ typedef void SoundProc(void *param, byte *buf, int len); GameDetector detector; Gui gui; Scumm *g_scumm; -extern SimonState *g_simon; +SimonState *g_simon; OSystem *g_system; SoundMixer *g_mixer; Config *scummcfg; |