diff options
-rw-r--r-- | gameDetector.cpp | 9 | ||||
-rw-r--r-- | sdl.cpp | 74 | ||||
-rw-r--r-- | simon/simon.cpp | 16 | ||||
-rw-r--r-- | simon/simon.h | 1 | ||||
-rw-r--r-- | system.h | 2 |
5 files changed, 100 insertions, 2 deletions
diff --git a/gameDetector.cpp b/gameDetector.cpp index f6ecaa2bad..d74143ef86 100644 --- a/gameDetector.cpp +++ b/gameDetector.cpp @@ -341,6 +341,12 @@ int GameDetector::detectMain(int argc, char **argv) _gfx_mode = GFX_DOUBLESIZE; + _gfx_driver = GD_AUTO; + +#ifdef USE_NULL_DRIVER + _gfx_driver = GD_NULL; +#endif + _gameDataPath = NULL; _gameTempo = 0; _soundCardType = 3; @@ -392,6 +398,9 @@ OSystem *GameDetector::createSystem() { case GD_X: /* not implemented yet */ break; + + case GD_NULL: + return OSystem_NULL_create(); } error("Invalid graphics driver"); @@ -1020,6 +1020,80 @@ void OSystem_SDL::undraw_mouse() { SDL_UnlockSurface(sdl_screen); } + +#ifdef USE_NULL_DRIVER + +/* NULL video driver */ +class OSystem_NULL : public OSystem { +public: + void set_palette(const byte *colors, uint start, uint num) {} + void init_size(uint w, uint h, byte sound); + void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) {} + void update_screen() {} + bool show_mouse(bool visible) { return false; } + void set_mouse_pos(int x, int y) {} + void set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) {} + void set_shake_pos(int shake_pos) {} + uint32 get_msecs(); + void delay_msecs(uint msecs); + void *create_thread(ThreadProc *proc, void *param) { return NULL; } + bool poll_event(Event *event) { return false; } + void set_sound_proc(void *param, SoundProc *proc) {} + void quit() { exit(1); } + uint32 set_param(int param, uint32 value) { return 0; } + static OSystem *create(int gfx_mode, bool full_screen); +private: + + uint msec_start; + + uint32 get_ticks(); +}; + +void OSystem_NULL::init_size(uint w, uint h, byte sound) { + msec_start = get_ticks(); +} + +uint32 OSystem_NULL::get_ticks() { + uint a = 0; +#ifdef WIN32 + a = GetTickCount(); +#endif + +#ifdef UNIX + struct timeval tv; + gettimeofday(&tv, NULL); + a = tv.tv_sec * 1000 + tv.tv_usec/1000; +#endif + + return a; +} + +void OSystem_NULL::delay_msecs(uint msecs) { +#ifdef WIN32 + Sleep(msecs); +#endif +#ifdef UNIX + usleep(msecs*1000); +#endif +} + +uint32 OSystem_NULL::get_msecs() { + return get_ticks() - msec_start; +} + +OSystem *OSystem_NULL_create() { + return new OSystem_NULL(); +} +#else /* USE_NULL_DRIVER */ + +OSystem *OSystem_NULL_create() { + return NULL; +} + +#endif + + + void cd_stop() { } diff --git a/simon/simon.cpp b/simon/simon.cpp index f995b8a7f1..0a1aeb2aba 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -131,7 +131,7 @@ FILE *fopen_maybe_lowercase(const char *filename) { byte *SimonState::allocateItem(uint size) { byte *org = _itemheap_ptr; - size = (size + 1) & ~1; + size = (size + 3) & ~3; _itemheap_ptr += size; _itemheap_curpos += size; @@ -142,8 +142,16 @@ byte *SimonState::allocateItem(uint size) { return org; } +void SimonState::alignTableMem() { + if ((uint32)_tablesheap_ptr & 3) { + _tablesheap_ptr += 2; + _tablesheap_curpos += 2; + } +} + byte *SimonState::allocateTable(uint size) { byte *org = _tablesheap_ptr; + size = (size + 1) & ~1; _tablesheap_ptr += size; @@ -527,7 +535,11 @@ void SimonState::readSubroutine(FILE *in, Subroutine *sub) { } Subroutine *SimonState::createSubroutine(uint id) { - Subroutine *sub = (Subroutine*)allocateTable(sizeof(Subroutine)); + Subroutine *sub; + + alignTableMem(); + + sub = (Subroutine*)allocateTable(sizeof(Subroutine)); sub->id = id; sub->first = 0; sub->next = _subroutine_list; diff --git a/simon/simon.h b/simon/simon.h index 6e98eee821..8fbcf4d346 100644 --- a/simon/simon.h +++ b/simon/simon.h @@ -592,6 +592,7 @@ public: byte *allocateItem(uint size); byte *allocateTable(uint size); + void alignTableMem(); Child *findChildOfType(Item *i, uint child); Child *allocateChildBlock(Item *i, uint type, uint size); @@ -102,6 +102,7 @@ public: /* OSystem_SDL */ OSystem *OSystem_SDL_create(int gfx_driver, bool full_screen); +OSystem *OSystem_NULL_create(); enum { GFX_NORMAL = 0, @@ -119,6 +120,7 @@ enum { GD_SDL = 1, GD_WIN32 = 2, GD_X = 3, + GD_NULL = 4, }; |