[Scummvm-cvs-logs] CVS: scummvm/saga cvar.cpp,1.4,1.5 gfx.cpp,1.8,1.9 ihnm_introproc.cpp,1.4,1.5 reinherit.h,1.14,1.15 render.cpp,1.6,1.7 render.h,1.5,1.6 render_mod.h,1.5,1.6 saga.cpp,1.15,1.16 saga.h,1.9,1.10 sdata.cpp,1.3,1.4 sndres.cpp,1.10,1.11 sthread.cpp,1.4,1.5 sysgfx.cpp,1.6,1.7 sysgfx.h,1.4,1.5 sysinput.cpp,1.3,1.4 transitions.cpp,1.3,1.4 ys_binread.cpp,1.4,1.5 ys_binwrite.cpp,1.3,1.4

Eugene Sandulenko sev at users.sourceforge.net
Sat May 1 12:42:02 CEST 2004


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14377

Modified Files:
	cvar.cpp gfx.cpp ihnm_introproc.cpp reinherit.h render.cpp 
	render.h render_mod.h saga.cpp saga.h sdata.cpp sndres.cpp 
	sthread.cpp sysgfx.cpp sysgfx.h sysinput.cpp transitions.cpp 
	ys_binread.cpp ys_binwrite.cpp 
Log Message:
All graphics and input now is in OSystem.
Only timers left.


Index: cvar.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/cvar.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cvar.cpp	1 May 2004 06:35:06 -0000	1.4
+++ cvar.cpp	1 May 2004 19:41:47 -0000	1.5
@@ -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"

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/gfx.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- gfx.cpp	1 May 2004 09:40:47 -0000	1.8
+++ gfx.cpp	1 May 2004 19:41:47 -0000	1.9
@@ -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"

Index: ihnm_introproc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/ihnm_introproc.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ihnm_introproc.cpp	1 May 2004 09:19:35 -0000	1.4
+++ ihnm_introproc.cpp	1 May 2004 19:41:47 -0000	1.5
@@ -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"

Index: reinherit.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/reinherit.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- reinherit.h	1 May 2004 13:19:15 -0000	1.14
+++ reinherit.h	1 May 2004 19:41:47 -0000	1.15
@@ -32,7 +32,6 @@
 
 #include "base/engine.h"
 
-#define R_ENV_LINUX
 #include "sys_interface.h"
 
 namespace Saga {
@@ -111,16 +110,7 @@
 // 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_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);

Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- render.cpp	1 May 2004 09:40:47 -0000	1.6
+++ render.cpp	1 May 2004 19:41:47 -0000	1.7
@@ -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 @@
 	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 @@
 	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 @@
 		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 @@
 
 	RenderModule.r_framecount++;
 
-	screen_surface = RenderModule.r_screen_surface;
 	backbuf_surface = RenderModule.r_backbuf_surface;
 
 	// Get mouse coordinates
@@ -222,20 +208,10 @@
 	// 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;
 }
 

Index: render.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- render.h	1 May 2004 09:40:47 -0000	1.5
+++ render.h	1 May 2004 19:41:47 -0000	1.6
@@ -44,8 +44,6 @@
 	int r_softcursor;
 
 	// Module data
-	R_SURFACE *r_screen_surface;
-	R_SURFACE *r_display_surface;
 	R_SURFACE *r_backbuf_surface;
 
 	byte *r_bg_buf;

Index: render_mod.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render_mod.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- render_mod.h	1 May 2004 09:40:47 -0000	1.5
+++ render_mod.h	1 May 2004 19:41:47 -0000	1.6
@@ -47,7 +47,7 @@
 };
 
 int RENDER_Register();
-int RENDER_Init();
+int RENDER_Init(OSystem *system);
 int RENDER_DrawScene();
 unsigned int RENDER_GetFlags();
 void RENDER_SetFlag(unsigned int);

Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- saga.cpp	1 May 2004 13:19:15 -0000	1.15
+++ saga.cpp	1 May 2004 19:41:47 -0000	1.16
@@ -241,7 +241,7 @@
 	}
 
 	// Initialize graphics
-	if (RENDER_Init() != R_SUCCESS) {
+	if (RENDER_Init(_system) != R_SUCCESS) {
 		return;
 	}
 

Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- saga.h	1 May 2004 13:19:15 -0000	1.9
+++ saga.h	1 May 2004 19:41:47 -0000	1.10
@@ -30,6 +30,9 @@
 #include "base/gameDetector.h"
 #include "common/util.h"
 
+#include <limits.h>
+#include <stddef.h>
+
 //#include "gamedesc.h"
 
 namespace Saga {

Index: sdata.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sdata.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sdata.cpp	1 May 2004 14:34:00 -0000	1.3
+++ sdata.cpp	1 May 2004 19:41:47 -0000	1.4
@@ -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"

Index: sndres.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sndres.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- sndres.cpp	1 May 2004 16:15:54 -0000	1.10
+++ sndres.cpp	1 May 2004 19:41:47 -0000	1.11
@@ -28,8 +28,6 @@
 
 #include "yslib.h"
 
-#include <limits.h>
-
 #include "game_mod.h"
 #include "rscfile_mod.h"
 

Index: sthread.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sthread.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sthread.cpp	1 May 2004 16:15:55 -0000	1.4
+++ sthread.cpp	1 May 2004 19:41:47 -0000	1.5
@@ -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"

Index: sysgfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sysgfx.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- sysgfx.cpp	1 May 2004 09:40:47 -0000	1.6
+++ sysgfx.cpp	1 May 2004 19:41:47 -0000	1.7
@@ -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 @@
 	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 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 @@
 	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 i;
 	//int fade_max = 255;
 	int new_entry;
+	byte *ppal;
 
 	double fpercent;
 
@@ -265,40 +196,34 @@
 	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 best_windex = 0;
 	int best_bindex = 0;
 	int best_bdelta = 1000;
+	byte *ppal;
 	int i;
 
 	if (percent > 1.0) {
@@ -323,38 +249,39 @@
 	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 @@
 		}
 	}
 
-	// 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;
 }

Index: sysgfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sysgfx.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sysgfx.h	1 May 2004 07:39:39 -0000	1.4
+++ sysgfx.h	1 May 2004 19:41:47 -0000	1.5
@@ -34,10 +34,6 @@
 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;

Index: sysinput.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sysinput.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sysinput.cpp	1 May 2004 16:15:55 -0000	1.3
+++ sysinput.cpp	1 May 2004 19:41:47 -0000	1.4
@@ -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 @@
 				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_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;
 }

Index: transitions.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/transitions.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- transitions.cpp	1 May 2004 16:15:55 -0000	1.3
+++ transitions.cpp	1 May 2004 19:41:47 -0000	1.4
@@ -22,10 +22,7 @@
  */
 
 //Background transition routines
-
-#include <stdio.h>
-#include <stdlib.h>
-
+#include "saga.h"
 #include "yslib.h"
 
 #include "reinherit.h"

Index: ys_binread.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/ys_binread.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ys_binread.cpp	1 May 2004 16:15:55 -0000	1.4
+++ ys_binread.cpp	1 May 2004 19:41:47 -0000	1.5
@@ -21,7 +21,7 @@
  *
  */
 
-#include <stdio.h>
+#include "saga.h"
 #include "yslib.h"
 
 namespace Saga {

Index: ys_binwrite.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/ys_binwrite.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ys_binwrite.cpp	1 May 2004 16:15:55 -0000	1.3
+++ ys_binwrite.cpp	1 May 2004 19:41:47 -0000	1.4
@@ -20,8 +20,7 @@
  * $Header$
  *
  */
-
-#include <stddef.h>
+#include "saga.h"
 
 namespace Saga {
 





More information about the Scummvm-git-logs mailing list