aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudvig Strigeus2002-04-13 21:06:48 +0000
committerLudvig Strigeus2002-04-13 21:06:48 +0000
commit82d4f89d5353184e35ff843cfb0b0b9bca619dac (patch)
treec99f9d385af595412f9395b9b8cb68c58899f6ff
parentff6523f93fe3138d594024d1128f45ba0b44f5b3 (diff)
downloadscummvm-rg350-82d4f89d5353184e35ff843cfb0b0b9bca619dac.tar.gz
scummvm-rg350-82d4f89d5353184e35ff843cfb0b0b9bca619dac.tar.bz2
scummvm-rg350-82d4f89d5353184e35ff843cfb0b0b9bca619dac.zip
added null graphics driver (USE_NULL_DRIVER)
will make it nicer later. svn-id: r3931
-rw-r--r--gameDetector.cpp9
-rw-r--r--sdl.cpp74
-rw-r--r--simon/simon.cpp16
-rw-r--r--simon/simon.h1
-rw-r--r--system.h2
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");
diff --git a/sdl.cpp b/sdl.cpp
index 0b1e28a351..eb4460c59e 100644
--- a/sdl.cpp
+++ b/sdl.cpp
@@ -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);
diff --git a/system.h b/system.h
index b2afb8eb19..69f4a9ee49 100644
--- a/system.h
+++ b/system.h
@@ -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,
};