diff options
author | Eugene Sandulenko | 2004-05-01 19:41:47 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2004-05-01 19:41:47 +0000 |
commit | c0772498b6d2351ed2f3c2ba308d0bbda84b7cb0 (patch) | |
tree | af908b45a373cf37214320e68ab3c15280368773 | |
parent | 78f2d348253c69180f00221caad0566a09d69345 (diff) | |
download | scummvm-rg350-c0772498b6d2351ed2f3c2ba308d0bbda84b7cb0.tar.gz scummvm-rg350-c0772498b6d2351ed2f3c2ba308d0bbda84b7cb0.tar.bz2 scummvm-rg350-c0772498b6d2351ed2f3c2ba308d0bbda84b7cb0.zip |
All graphics and input now is in OSystem.
Only timers left.
svn-id: r13723
-rw-r--r-- | saga/cvar.cpp | 6 | ||||
-rw-r--r-- | saga/gfx.cpp | 6 | ||||
-rw-r--r-- | saga/ihnm_introproc.cpp | 5 | ||||
-rw-r--r-- | saga/reinherit.h | 14 | ||||
-rw-r--r-- | saga/render.cpp | 40 | ||||
-rw-r--r-- | saga/render.h | 2 | ||||
-rw-r--r-- | saga/render_mod.h | 2 | ||||
-rw-r--r-- | saga/saga.cpp | 2 | ||||
-rw-r--r-- | saga/saga.h | 3 | ||||
-rw-r--r-- | saga/sdata.cpp | 4 | ||||
-rw-r--r-- | saga/sndres.cpp | 2 | ||||
-rw-r--r-- | saga/sthread.cpp | 4 | ||||
-rw-r--r-- | saga/sysgfx.cpp | 208 | ||||
-rw-r--r-- | saga/sysgfx.h | 4 | ||||
-rw-r--r-- | saga/sysinput.cpp | 101 | ||||
-rw-r--r-- | saga/transitions.cpp | 5 | ||||
-rw-r--r-- | saga/ys_binread.cpp | 2 | ||||
-rw-r--r-- | saga/ys_binwrite.cpp | 3 |
18 files changed, 133 insertions, 280 deletions
diff --git a/saga/cvar.cpp b/saga/cvar.cpp index 6e7a4a2df0..048b5b1985 100644 --- a/saga/cvar.cpp +++ b/saga/cvar.cpp @@ -22,13 +22,9 @@ */ // Configuration Variable Module - - +#include "saga.h" #include "reinherit.h" -#include <limits.h> -#include <stddef.h> - #include "console_mod.h" #include "cvar_mod.h" diff --git a/saga/gfx.cpp b/saga/gfx.cpp index 5d9472945e..6ca6ae2ab3 100644 --- a/saga/gfx.cpp +++ b/saga/gfx.cpp @@ -27,11 +27,7 @@ // described in "Michael Abrash's Graphics Programming Black Book", // Coriolis Group Books, 1997 -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <assert.h> - +#include "saga.h" #include "yslib.h" #include "reinherit.h" diff --git a/saga/ihnm_introproc.cpp b/saga/ihnm_introproc.cpp index a21b7ad8ab..d6c1c598f6 100644 --- a/saga/ihnm_introproc.cpp +++ b/saga/ihnm_introproc.cpp @@ -23,10 +23,7 @@ // "I Have No Mouth" Intro sequence scene procedures -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - +#include "saga.h" #include "yslib.h" #include "reinherit.h" diff --git a/saga/reinherit.h b/saga/reinherit.h index be8903832c..06afa6a918 100644 --- a/saga/reinherit.h +++ b/saga/reinherit.h @@ -32,7 +32,6 @@ #include "base/engine.h" -#define R_ENV_LINUX #include "sys_interface.h" namespace Saga { @@ -111,16 +110,7 @@ int TRANSITION_Dissolve(byte *dst_img, int dst_w, int dst_h, // System : Graphics #define R_PAL_ENTRIES 256 -struct R_SYSGFX_INIT { - int backbuf_w; - int backbuf_h; - int backbuf_bpp; - int screen_w; - int screen_h; - int screen_bpp; -}; - -int SYSGFX_Init(R_SYSGFX_INIT *); +int SYSGFX_Init(OSystem *system, int width, int height); R_SURFACE *SYSGFX_GetScreenSurface(); R_SURFACE *SYSGFX_GetBackBuffer(); int SYSGFX_LockSurface(R_SURFACE *surface); @@ -134,7 +124,7 @@ int SYSGFX_PalToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent); int SYSGFX_BlackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent); // System : Input -int SYSINPUT_Init(void); +int SYSINPUT_Init(); int SYSINPUT_ProcessInput(void); int SYSINPUT_GetMousePos(int *mouse_x, int *mouse_y); int SYSINPUT_HideMouse(void); diff --git a/saga/render.cpp b/saga/render.cpp index f881d90b96..6cc49f9b4f 100644 --- a/saga/render.cpp +++ b/saga/render.cpp @@ -22,14 +22,12 @@ */ // Main rendering loop - +#include "saga.h" #include "reinherit.h" #include "systimer.h" #include "yslib.h" -#include <SDL.h> - #include "actor_mod.h" #include "console_mod.h" #include "cvar_mod.h" @@ -50,6 +48,7 @@ namespace Saga { static R_RENDER_MODULE RenderModule; +static OSystem *_system; const char *test_txt = "The quick brown fox jumped over the lazy dog. She sells sea shells down by the sea shore."; @@ -65,25 +64,15 @@ int RENDER_Register() { return R_SUCCESS; } -int RENDER_Init() { +int RENDER_Init(OSystem *system) { R_GAME_DISPLAYINFO disp_info; - R_SYSGFX_INIT gfx_init; int result; int tmp_w, tmp_h, tmp_bytepp; // Initialize system graphics GAME_GetDisplayInfo(&disp_info); - gfx_init.backbuf_bpp = 8; // all games are 8 bpp so far - gfx_init.backbuf_w = disp_info.logical_w; - gfx_init.backbuf_h = disp_info.logical_h; - - gfx_init.screen_bpp = 8; - - gfx_init.screen_w = disp_info.logical_w; - gfx_init.screen_h = disp_info.logical_h; - - if (SYSGFX_Init(&gfx_init) != R_SUCCESS) { + if (SYSGFX_Init(system, disp_info.logical_w, disp_info.logical_h) != R_SUCCESS) { return R_FAILURE; } @@ -118,7 +107,6 @@ int RENDER_Init() { RenderModule.r_tmp_buf_w = tmp_w; RenderModule.r_tmp_buf_h = tmp_h; - RenderModule.r_screen_surface = SYSGFX_GetScreenSurface(); RenderModule.r_backbuf_surface = SYSGFX_GetBackBuffer(); // Initialize cursor state @@ -126,15 +114,14 @@ int RENDER_Init() { SYSINPUT_HideMouse(); } + _system = system; RenderModule.initialized = 1; return R_SUCCESS; } int RENDER_DrawScene() { - R_SURFACE *screen_surface; R_SURFACE *backbuf_surface; - R_SURFACE *display_surface; R_GAME_DISPLAYINFO disp_info; R_SCENE_INFO scene_info; SCENE_BGINFO bg_info; @@ -150,7 +137,6 @@ int RENDER_DrawScene() { RenderModule.r_framecount++; - screen_surface = RenderModule.r_screen_surface; backbuf_surface = RenderModule.r_backbuf_surface; // Get mouse coordinates @@ -222,20 +208,10 @@ int RENDER_DrawScene() { // Draw console CON_Draw(backbuf_surface); - // Display the current frame - display_surface = backbuf_surface; - - SYSGFX_LockSurface(screen_surface); - SYSGFX_LockSurface(display_surface); - - GFX_SimpleBlit(screen_surface, display_surface); - - SYSGFX_UnlockSurface(display_surface); - SYSGFX_UnlockSurface(screen_surface); - - // FIXME - SDL_UpdateRect((SDL_Surface *)screen_surface->impl_src, 0, 0, 0, 0); + _system->copyRectToScreen(backbuf_surface->buf, backbuf_surface->buf_w, 0, 0, + backbuf_surface->buf_w, backbuf_surface->buf_h); + _system->updateScreen(); return R_SUCCESS; } diff --git a/saga/render.h b/saga/render.h index ad74c27fe9..0e7a4d9b88 100644 --- a/saga/render.h +++ b/saga/render.h @@ -44,8 +44,6 @@ struct R_RENDER_MODULE { int r_softcursor; // Module data - R_SURFACE *r_screen_surface; - R_SURFACE *r_display_surface; R_SURFACE *r_backbuf_surface; byte *r_bg_buf; diff --git a/saga/render_mod.h b/saga/render_mod.h index c9986df317..49e5c03091 100644 --- a/saga/render_mod.h +++ b/saga/render_mod.h @@ -47,7 +47,7 @@ struct R_BUFFER_INFO { }; int RENDER_Register(); -int RENDER_Init(); +int RENDER_Init(OSystem *system); int RENDER_DrawScene(); unsigned int RENDER_GetFlags(); void RENDER_SetFlag(unsigned int); diff --git a/saga/saga.cpp b/saga/saga.cpp index 101d3a07ad..d27a6f3850 100644 --- a/saga/saga.cpp +++ b/saga/saga.cpp @@ -241,7 +241,7 @@ void SagaEngine::go() { } // Initialize graphics - if (RENDER_Init() != R_SUCCESS) { + if (RENDER_Init(_system) != R_SUCCESS) { return; } diff --git a/saga/saga.h b/saga/saga.h index 7343ff3c06..a049d120c2 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -30,6 +30,9 @@ #include "base/gameDetector.h" #include "common/util.h" +#include <limits.h> +#include <stddef.h> + //#include "gamedesc.h" namespace Saga { diff --git a/saga/sdata.cpp b/saga/sdata.cpp index 0994d4d7aa..542a7c8169 100644 --- a/saga/sdata.cpp +++ b/saga/sdata.cpp @@ -21,13 +21,11 @@ * */ // Type SDataWord_T must be unpadded - +#include "saga.h" #include "reinherit.h" #include "yslib.h" -#include <limits.h> - #include "text_mod.h" #include "script_mod.h" diff --git a/saga/sndres.cpp b/saga/sndres.cpp index 6fc98017c7..abb1d4c1b2 100644 --- a/saga/sndres.cpp +++ b/saga/sndres.cpp @@ -28,8 +28,6 @@ #include "yslib.h" -#include <limits.h> - #include "game_mod.h" #include "rscfile_mod.h" diff --git a/saga/sthread.cpp b/saga/sthread.cpp index e4b52272e7..03ae108f20 100644 --- a/saga/sthread.cpp +++ b/saga/sthread.cpp @@ -22,13 +22,11 @@ */ // Scripting module thread management component - +#include "saga.h" #include "reinherit.h" #include "yslib.h" -#include <limits.h> - #include "actor_mod.h" #include "console_mod.h" #include "text_mod.h" diff --git a/saga/sysgfx.cpp b/saga/sysgfx.cpp index 8cffa6dd87..6c8ad4d8ac 100644 --- a/saga/sysgfx.cpp +++ b/saga/sysgfx.cpp @@ -20,125 +20,60 @@ * $Header$ * */ - +#include "saga.h" #include "reinherit.h" -#include <SDL.h> -#include <limits.h> - #include "sysgfx.h" namespace Saga { -R_SYSGFX_MODULE SGfxModule; +static R_SYSGFX_MODULE SGfxModule; +static OSystem *_system; -static SDL_Color cur_pal[R_PAL_ENTRIES]; +static byte cur_pal[R_PAL_ENTRIES * 4]; -int SYSGFX_Init(R_SYSGFX_INIT *gfx_init) { - SDL_Surface *sdl_screen; - R_SURFACE r_screen; - SDL_Surface *sdl_back_buf; +int SYSGFX_Init(OSystem *system, int width, int height) { R_SURFACE r_back_buf; - int result; - Uint32 flags; - - assert(gfx_init != NULL); - - flags = SDL_HWPALETTE; - - // Test video mode availability */ - result = SDL_VideoModeOK(gfx_init->screen_w, gfx_init->screen_h, gfx_init->screen_bpp, flags); - if (result == 0) { - R_printf(R_STDERR, "Requested video mode (%d x %d @ %d bpp) is unavailable.\n", gfx_init->screen_w, - gfx_init->screen_h, gfx_init->screen_bpp); - return R_FAILURE; - } - - // Set the video mode - sdl_screen = SDL_SetVideoMode(gfx_init->screen_w, gfx_init->screen_h, gfx_init->screen_bpp, flags); - if (sdl_screen == NULL) { - R_printf(R_STDERR, "Unable to set video mode (%d x %d @ %d bpp).\n", gfx_init->screen_w, - gfx_init->screen_h, gfx_init->screen_bpp); - R_printf(R_STDERR, "SDL reports: %s\n", SDL_GetError()); - return R_FAILURE; - } - - R_printf(R_STDOUT, "Set video mode: (%d x %d @ %d bpp)\n", sdl_screen->w, sdl_screen->h, - sdl_screen->format->BitsPerPixel); - - // Convert sdl surface data to R surface data - r_screen.buf = (byte *)sdl_screen->pixels; - r_screen.buf_w = sdl_screen->w; - r_screen.buf_h = sdl_screen->h; - r_screen.buf_pitch = sdl_screen->pitch; - r_screen.bpp = gfx_init->screen_bpp; - - r_screen.clip_rect.left = 0; - r_screen.clip_rect.top = 0; - r_screen.clip_rect.right = sdl_screen->w - 1; - r_screen.clip_rect.bottom = sdl_screen->h - 1; - - r_screen.impl_src = sdl_screen; - - // Create the back buffer - sdl_back_buf = SDL_CreateRGBSurface(SDL_SWSURFACE, gfx_init->backbuf_w, - gfx_init->backbuf_h, gfx_init->backbuf_bpp, 0, 0, 0, 0); - if (sdl_back_buf == NULL) { - R_printf(R_STDERR, "Unable to create back buffer (%d x %d @ %d bpp).\n", gfx_init->backbuf_w, - gfx_init->backbuf_h, gfx_init->backbuf_bpp); - R_printf(R_STDERR, "SDL reports: %s.\n", SDL_GetError()); - return R_FAILURE; - } + _system = system; + _system->initSize(width, height); + debug(0, "Init screen %dx%d", width, height); // Convert sdl surface data to R surface data - r_back_buf.buf = (byte *)sdl_back_buf->pixels; - r_back_buf.buf_w = sdl_back_buf->w; - r_back_buf.buf_h = sdl_back_buf->h; - r_back_buf.buf_pitch = sdl_back_buf->pitch; - r_back_buf.bpp = gfx_init->backbuf_bpp; + r_back_buf.buf = (byte *)calloc(1, width * height); + r_back_buf.buf_w = width; + r_back_buf.buf_h = height; + r_back_buf.buf_pitch = width; + r_back_buf.bpp = 8; r_back_buf.clip_rect.left = 0; r_back_buf.clip_rect.top = 0; - r_back_buf.clip_rect.right = sdl_back_buf->w - 1; - r_back_buf.clip_rect.bottom = sdl_back_buf->h - 1; - - r_back_buf.impl_src = sdl_back_buf; + r_back_buf.clip_rect.right = width - 1; + r_back_buf.clip_rect.bottom = height - 1; // Set module data - SGfxModule.sdl_screen = sdl_screen; - SGfxModule.r_screen = r_screen; - SGfxModule.sdl_back_buf = sdl_back_buf; SGfxModule.r_back_buf = r_back_buf; SGfxModule.init = 1; return R_SUCCESS; } -R_SURFACE *SYSGFX_GetScreenSurface() { - return &SGfxModule.r_screen; +/* +~SysGfx() { + free(SGfxModule.r_back_buf->buf); } + */ R_SURFACE *SYSGFX_GetBackBuffer() { return &SGfxModule.r_back_buf; } int SYSGFX_LockSurface(R_SURFACE *surface) { - int result; - - assert(surface != NULL); - - result = SDL_LockSurface((SDL_Surface *) surface->impl_src); - - return (result == 0) ? R_SUCCESS : R_FAILURE; + return 0; } int SYSGFX_UnlockSurface(R_SURFACE *surface) { - assert(surface != NULL); - - SDL_UnlockSurface((SDL_Surface *) surface->impl_src); - - return R_SUCCESS; + return 0; } int SYSGFX_GetWhite(void) { @@ -160,20 +95,19 @@ int SYSGFX_MatchColor(unsigned long colormask) { long color_delta; long best_delta = LONG_MAX; int best_index = 0; + byte *ppal; - for (i = 0; i < R_PAL_ENTRIES; i++) { - dr = cur_pal[i].r - red; + for (i = 0, ppal = cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { + dr = ppal[0] - red; dr = ABS(dr); - dg = cur_pal[i].g - green; + dg = ppal[1] - green; dg = ABS(dg); - db = cur_pal[i].b - blue; + db = ppal[2] - blue; db = ABS(db); + ppal[3] = 0; -#if R_COLORSEARCH_SQUARE - color_delta = (long)((dr * dr) * R_RED_WEIGHT + (dg * dg) * R_GREEN_WEIGHT + (db * db) * R_BLUE_WEIGHT); -#else color_delta = (long)(dr * R_RED_WEIGHT + dg * R_GREEN_WEIGHT + db * R_BLUE_WEIGHT); -#endif + if (color_delta == 0) { return i; } @@ -197,17 +131,19 @@ int SYSGFX_SetPalette(R_SURFACE *surface, PALENTRY *pal) { int best_bindex = 0; int best_bdelta = 1000; int i; + byte *ppal; - for (i = 0; i < R_PAL_ENTRIES; i++) { + for (i = 0, ppal = cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { red = pal[i].red; - cur_pal[i].r = red; + ppal[0] = red; color_delta = red; green = pal[i].green; - cur_pal[i].g = green; + ppal[1] = green; color_delta += green; blue = pal[i].blue; - cur_pal[i].b = blue; + ppal[2] = blue; color_delta += blue; + ppal[3] = 0; if (color_delta < best_bdelta) { best_bindex = i; @@ -224,25 +160,19 @@ int SYSGFX_SetPalette(R_SURFACE *surface, PALENTRY *pal) { SGfxModule.white_index = best_windex; SGfxModule.black_index = best_bindex; - // If the screen surface is palettized, set the screen palette. - // If the screen surface is not palettized, set the palette of - // the surface parameter - if (SGfxModule.r_screen.bpp < 16) { - SDL_SetColors(SGfxModule.sdl_screen, cur_pal, 0, R_PAL_ENTRIES); - } else { - SDL_SetColors((SDL_Surface *) surface->impl_src, cur_pal, 0, R_PAL_ENTRIES); - } + _system->setPalette(cur_pal, 0, R_PAL_ENTRIES); return R_SUCCESS; } int SYSGFX_GetCurrentPal(PALENTRY *src_pal) { int i; + byte *ppal; - for (i = 0; i < R_PAL_ENTRIES; i++) { - src_pal[i].red = cur_pal[i].r; - src_pal[i].green = cur_pal[i].g; - src_pal[i].blue = cur_pal[i].b; + for (i = 0, ppal = cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { + src_pal[i].red = ppal[0]; + src_pal[i].green = ppal[1]; + src_pal[i].blue = ppal[2]; } return R_SUCCESS; @@ -252,6 +182,7 @@ int SYSGFX_PalToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent) { int i; //int fade_max = 255; int new_entry; + byte *ppal; double fpercent; @@ -265,40 +196,34 @@ int SYSGFX_PalToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent) { fpercent = 1.0 - fpercent; // Use the correct percentage change per frame for each palette entry - for (i = 0; i < R_PAL_ENTRIES; i++) { + for (i = 0, ppal = cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { new_entry = (int)(src_pal[i].red * fpercent); if (new_entry < 0) { - cur_pal[i].r = 0; + ppal[0] = 0; } else { - cur_pal[i].r = (byte) new_entry; + ppal[0] = (byte) new_entry; } new_entry = (int)(src_pal[i].green * fpercent); if (new_entry < 0) { - cur_pal[i].g = 0; + ppal[1] = 0; } else { - cur_pal[i].g = (byte) new_entry; + ppal[1] = (byte) new_entry; } new_entry = (int)(src_pal[i].blue * fpercent); if (new_entry < 0) { - cur_pal[i].b = 0; + ppal[2] = 0; } else { - cur_pal[i].b = (byte) new_entry; + ppal[2] = (byte) new_entry; } + ppal[3] = 0; } - // If the screen surface is palettized, set the screen palette. - // If the screen surface is not palettized, set the palette of - // the surface parameter - if (SGfxModule.r_screen.bpp < 16) { - SDL_SetColors(SGfxModule.sdl_screen, cur_pal, 0, R_PAL_ENTRIES); - } else { - SDL_SetColors((SDL_Surface *) surface->impl_src, cur_pal, 0, R_PAL_ENTRIES); - } + _system->setPalette(cur_pal, 0, R_PAL_ENTRIES); return R_SUCCESS; } @@ -311,6 +236,7 @@ int SYSGFX_BlackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) { int best_windex = 0; int best_bindex = 0; int best_bdelta = 1000; + byte *ppal; int i; if (percent > 1.0) { @@ -323,38 +249,39 @@ int SYSGFX_BlackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) { fpercent = 1.0 - fpercent; // Use the correct percentage change per frame for each palette entry - for (i = 0; i < R_PAL_ENTRIES; i++) { + for (i = 0, ppal = cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { new_entry = (int)(src_pal[i].red - src_pal[i].red * fpercent); if (new_entry < 0) { - cur_pal[i].r = 0; + ppal[0] = 0; } else { - cur_pal[i].r = (byte) new_entry; + ppal[0] = (byte) new_entry; } new_entry = (int)(src_pal[i].green - src_pal[i].green * fpercent); if (new_entry < 0) { - cur_pal[i].g = 0; + ppal[1] = 0; } else { - cur_pal[i].g = (byte) new_entry; + ppal[1] = (byte) new_entry; } new_entry = (int)(src_pal[i].blue - src_pal[i].blue * fpercent); if (new_entry < 0) { - cur_pal[i].b = 0; + ppal[2] = 0; } else { - cur_pal[i].b = (byte) new_entry; + ppal[2] = (byte) new_entry; } + ppal[3] = 0; } // Find the best white and black color indices again if (percent >= 1.0) { - for (i = 0; i < R_PAL_ENTRIES; i++) { - color_delta = cur_pal[i].r; - color_delta += cur_pal[i].g; - color_delta += cur_pal[i].b; + for (i = 0, ppal = cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) { + color_delta = ppal[0]; + color_delta += ppal[1]; + color_delta += ppal[2]; if (color_delta < best_bdelta) { best_bindex = i; @@ -368,14 +295,7 @@ int SYSGFX_BlackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) { } } - // If the screen surface is palettized, set the screen palette. - // If the screen surface is not palettized, set the palette of - // the surface parameter - if (SGfxModule.r_screen.bpp < 16) { - SDL_SetColors(SGfxModule.sdl_screen, cur_pal, 0, R_PAL_ENTRIES); - } else { - SDL_SetColors((SDL_Surface *) surface->impl_src, cur_pal, 0, R_PAL_ENTRIES); - } + _system->setPalette(cur_pal, 0, R_PAL_ENTRIES); return R_SUCCESS; } diff --git a/saga/sysgfx.h b/saga/sysgfx.h index b69b2766f1..f530b8d1a0 100644 --- a/saga/sysgfx.h +++ b/saga/sysgfx.h @@ -34,10 +34,6 @@ namespace Saga { struct R_SYSGFX_MODULE { int init; - SDL_Surface *sdl_screen; // Screen surface - R_SURFACE r_screen; - - SDL_Surface *sdl_back_buf; // Double buffer surface R_SURFACE r_back_buf; int white_index; diff --git a/saga/sysinput.cpp b/saga/sysinput.cpp index 772a8352e0..b6f4f97f46 100644 --- a/saga/sysinput.cpp +++ b/saga/sysinput.cpp @@ -20,10 +20,9 @@ * $Header$ * */ - +#include "saga.h" #include "reinherit.h" -#include <SDL.h> #include "actor_mod.h" #include "console_mod.h" #include "interface_mod.h" @@ -33,99 +32,83 @@ namespace Saga { -int SYSINPUT_Init() { - SDL_EnableUNICODE(1); - SDL_EnableKeyRepeat(200, 30); +static int _mouse_x, _mouse_y; +int SYSINPUT_Init() { return R_SUCCESS; } int SYSINPUT_ProcessInput() { - SDL_Event sdl_event; + OSystem::Event event; - int mouse_x, mouse_y; R_POINT imouse_pt; - SYSINPUT_GetMousePos(&mouse_x, &mouse_y); - - imouse_pt.x = mouse_x; - imouse_pt.y = mouse_y; - - while (SDL_PollEvent(&sdl_event)) { + while (g_system->poll_event(&event)) { int in_char; - switch (sdl_event.type) { - case SDL_KEYDOWN: + switch (event.event_code) { + case OSystem::EVENT_KEYDOWN: if (CON_IsActive()) { - in_char = sdl_event.key.keysym.sym; - switch (sdl_event.key.keysym.sym) { - case SDLK_BACKQUOTE: + in_char = event.kbd.ascii; + switch (event.kbd.keycode) { + case 96: // backquote CON_Deactivate(); break; - case SDLK_PAGEUP: + case 280: // page up CON_PageUp(); break; - case SDLK_PAGEDOWN: + case 281: // page down CON_PageDown(); break; - case SDLK_UP: - case SDLK_KP8: + case 273: // up + case 264: // keypad up CON_CmdUp(); break; - case SDLK_DOWN: - case SDLK_KP2: + case 274: // down + case 258: // keypad down CON_CmdDown(); break; default: - if ((sdl_event.key.keysym. - unicode & 0xFF80) == 0) { - in_char = sdl_event.key.keysym. unicode & 0x7F; - if (in_char) { - CON_Type(in_char); - } - } else { - R_printf(R_STDOUT, "Ignored UNICODE character.\n"); + if (in_char) { + CON_Type(in_char); } break; } break; } - switch (sdl_event.key.keysym.sym) { - case SDLK_BACKQUOTE: + switch (event.kbd.keycode) { + case 96: // back quote CON_Activate(); break; - case SDLK_q: - R_printf(R_STDOUT, "Quit key pressed.\n"); - //goto done; - break; - case SDLK_r: + case 114: // r INTERFACE_Draw(); break; - case SDLK_F1: + case 282: // F1 RENDER_ToggleFlag(RF_SHOW_FPS); break; - case SDLK_F2: + case 283: // F2 RENDER_ToggleFlag(RF_PALETTE_TEST); break; - case SDLK_F3: + case 284: // F3 RENDER_ToggleFlag(RF_TEXT_TEST); break; - case SDLK_F4: + case 285: // F4 RENDER_ToggleFlag(RF_OBJECTMAP_TEST); break; - case SDLK_TAB: + case 9: // Tab STHREAD_DebugStep(); break; - // Actual game keys - case SDLK_SPACE: + + // Actual game keys + case 32: // space ACTOR_SkipDialogue(); break; - case SDLK_PAUSE: - case SDLK_p: + case 19: // pause + case 112: // p RENDER_ToggleFlag(RF_RENDERPAUSE); break; - case SDLK_ESCAPE: + case 27: // Esc // Skip to next scene skip target SCENE_Skip(); break; @@ -133,11 +116,18 @@ int SYSINPUT_ProcessInput() { break; } break; - case SDL_KEYUP: - break; - case SDL_MOUSEBUTTONDOWN: + case OSystem::EVENT_LBUTTONDOWN: INTERFACE_Update(&imouse_pt, UPDATE_MOUSECLICK); break; + case OSystem::EVENT_MOUSEMOVE: + _mouse_x = event.mouse.x; + _mouse_y = event.mouse.y; + imouse_pt.x = _mouse_x; + imouse_pt.y = _mouse_y; + break; + case OSystem::EVENT_QUIT: + g_system->quit(); + break; default: break; } @@ -147,19 +137,20 @@ int SYSINPUT_ProcessInput() { } int SYSINPUT_GetMousePos(int *mouse_x, int *mouse_y) { - SDL_GetMouseState(mouse_x, mouse_y); + *mouse_x = _mouse_x; + *mouse_y = _mouse_y; return R_SUCCESS; } int SYSINPUT_HideMouse() { - SDL_ShowCursor(SDL_DISABLE); + g_system->showMouse(false); return R_SUCCESS; } int SYSINPUT_ShowMouse() { - SDL_ShowCursor(SDL_ENABLE); + g_system->showMouse(true); return R_SUCCESS; } diff --git a/saga/transitions.cpp b/saga/transitions.cpp index c97b3a46fa..5e3091d7f6 100644 --- a/saga/transitions.cpp +++ b/saga/transitions.cpp @@ -22,10 +22,7 @@ */ //Background transition routines - -#include <stdio.h> -#include <stdlib.h> - +#include "saga.h" #include "yslib.h" #include "reinherit.h" diff --git a/saga/ys_binread.cpp b/saga/ys_binread.cpp index 021a0a8436..4eba5acb2c 100644 --- a/saga/ys_binread.cpp +++ b/saga/ys_binread.cpp @@ -21,7 +21,7 @@ * */ -#include <stdio.h> +#include "saga.h" #include "yslib.h" namespace Saga { diff --git a/saga/ys_binwrite.cpp b/saga/ys_binwrite.cpp index 4ea81d7d11..10ca28fa85 100644 --- a/saga/ys_binwrite.cpp +++ b/saga/ys_binwrite.cpp @@ -20,8 +20,7 @@ * $Header$ * */ - -#include <stddef.h> +#include "saga.h" namespace Saga { |