aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2004-05-02 00:00:39 +0000
committerEugene Sandulenko2004-05-02 00:00:39 +0000
commit90a876798ae05b865c25a8ee98f20d1695315984 (patch)
treec5d887ad0bf229caa16503624ec9d91372bd1b7b
parent0765b272aef169411df8fc1a17d4a5f28f76bf8a (diff)
downloadscummvm-rg350-90a876798ae05b865c25a8ee98f20d1695315984.tar.gz
scummvm-rg350-90a876798ae05b865c25a8ee98f20d1695315984.tar.bz2
scummvm-rg350-90a876798ae05b865c25a8ee98f20d1695315984.zip
Merged sysgfx.cpp and gfx.cpp to gfx.cpp
svn-id: r13726
-rw-r--r--saga/actor.cpp2
-rw-r--r--saga/console.cpp10
-rw-r--r--saga/events.cpp12
-rw-r--r--saga/gfx.cpp264
-rw-r--r--saga/gfx.h13
-rw-r--r--saga/ihnm_introproc.cpp4
-rw-r--r--saga/interface.cpp4
-rw-r--r--saga/ite_introproc.cpp2
-rw-r--r--saga/module.mk1
-rw-r--r--saga/objectmap.cpp2
-rw-r--r--saga/palanim.cpp6
-rw-r--r--saga/reinherit.h25
-rw-r--r--saga/render.cpp14
-rw-r--r--saga/saga.cpp5
-rw-r--r--saga/sceneproc.cpp2
-rw-r--r--saga/sysgfx.cpp303
-rw-r--r--saga/sysgfx.h45
17 files changed, 316 insertions, 398 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp
index 339c14fe2d..688bd2f8f9 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -221,7 +221,7 @@ int ACTOR_DrawList() {
R_SURFACE *back_buf;
- back_buf = SYSGFX_GetBackBuffer();
+ back_buf = GFX_GetBackBuffer();
for (walk_p = ys_dll_head(ActorModule.list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
actor = (R_ACTOR *)ys_dll_get_data(walk_p);
diff --git a/saga/console.cpp b/saga/console.cpp
index d001846664..b1cf724f6b 100644
--- a/saga/console.cpp
+++ b/saga/console.cpp
@@ -216,9 +216,9 @@ int CON_Draw(R_SURFACE *ds) {
fill_rect.bottom = ConInfo.y_pos;
fill_rect.right = ds->buf_w - 1;
- GFX_DrawRect(ds, &fill_rect, SYSGFX_MatchColor(R_CONSOLE_BGCOLOR));
- txt_fgcolor = SYSGFX_MatchColor(R_CONSOLE_TXTCOLOR);
- txt_shcolor = SYSGFX_MatchColor(R_CONSOLE_TXTSHADOW);
+ GFX_DrawRect(ds, &fill_rect, GFX_MatchColor(R_CONSOLE_BGCOLOR));
+ txt_fgcolor = GFX_MatchColor(R_CONSOLE_TXTCOLOR);
+ txt_shcolor = GFX_MatchColor(R_CONSOLE_TXTSHADOW);
FONT_Draw(SMALL_FONT_ID, ds, ">", 1, 2, ConInfo.y_pos - 10, txt_fgcolor, txt_shcolor, FONT_SHADOW);
FONT_Draw(SMALL_FONT_ID, ds, ConInfo.input_buf, strlen(ConInfo.input_buf),
@@ -354,7 +354,7 @@ int CON_DropConsole(double percent) {
percent = 1.0;
}
- back_buf = SYSGFX_GetBackBuffer();
+ back_buf = GFX_GetBackBuffer();
CON_SetDropPos(percent);
CON_Draw(back_buf);
@@ -369,7 +369,7 @@ int CON_RaiseConsole(double percent) {
ConInfo.active = 0;
}
- back_buf = SYSGFX_GetBackBuffer();
+ back_buf = GFX_GetBackBuffer();
CON_SetDropPos(1.0 - percent);
CON_Draw(back_buf);
diff --git a/saga/events.cpp b/saga/events.cpp
index 5cc1b5e072..aff450b37f 100644
--- a/saga/events.cpp
+++ b/saga/events.cpp
@@ -159,13 +159,13 @@ int HandleContinuous(R_EVENT *event) {
case R_PAL_EVENT:
switch (event->op) {
case EVENT_BLACKTOPAL:
- back_buf = SYSGFX_GetBackBuffer();
- SYSGFX_BlackToPal(back_buf, (PALENTRY *)event->data, event_pc);
+ back_buf = GFX_GetBackBuffer();
+ GFX_BlackToPal(back_buf, (PALENTRY *)event->data, event_pc);
break;
case EVENT_PALTOBLACK:
- back_buf = SYSGFX_GetBackBuffer();
- SYSGFX_PalToBlack(back_buf, (PALENTRY *)event->data, event_pc);
+ back_buf = GFX_GetBackBuffer();
+ GFX_PalToBlack(back_buf, (PALENTRY *)event->data, event_pc);
break;
default:
break;
@@ -249,7 +249,7 @@ static int HandleOneShot(R_EVENT *event) {
if (SCENE_GetMode() == R_SCENE_MODE_NORMAL) {
- back_buf = SYSGFX_GetBackBuffer();
+ back_buf = GFX_GetBackBuffer();
RENDER_GetBufferInfo(&rbuf_info);
SCENE_GetBGInfo(&bginfo);
@@ -262,7 +262,7 @@ static int HandleOneShot(R_EVENT *event) {
if (event->param == SET_PALETTE) {
PALENTRY *pal_p;
SCENE_GetBGPal(&pal_p);
- SYSGFX_SetPalette(back_buf, pal_p);
+ GFX_SetPalette(back_buf, pal_p);
}
}
}
diff --git a/saga/gfx.cpp b/saga/gfx.cpp
index df60ff34b0..6ee2e95c34 100644
--- a/saga/gfx.cpp
+++ b/saga/gfx.cpp
@@ -37,6 +37,42 @@
namespace Saga {
+static R_GFX_MODULE GfxModule;
+static OSystem *_system;
+
+static byte cur_pal[R_PAL_ENTRIES * 4];
+
+int GFX_Init(OSystem *system, int width, int height) {
+ R_SURFACE r_back_buf;
+
+ _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 *)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.clip_rect.left = 0;
+ r_back_buf.clip_rect.top = 0;
+ r_back_buf.clip_rect.right = width - 1;
+ r_back_buf.clip_rect.bottom = height - 1;
+
+ // Set module data
+ GfxModule.r_back_buf = r_back_buf;
+ GfxModule.init = 1;
+
+ return R_SUCCESS;
+}
+
+/*
+~Gfx() {
+ free(GfxModule.r_back_buf->buf);
+}
+ */
+
int GFX_DrawPalette(R_SURFACE *dst_s) {
int x;
int y;
@@ -843,4 +879,232 @@ void GFX_DrawLine(R_SURFACE *ds, R_POINT *p1, R_POINT *p2, int color) {
return;
}
+R_SURFACE *GFX_GetBackBuffer() {
+ return &GfxModule.r_back_buf;
+}
+
+int GFX_GetWhite(void) {
+ return GfxModule.white_index;
+}
+
+int GFX_GetBlack(void) {
+ return GfxModule.black_index;
+}
+
+int GFX_MatchColor(unsigned long colormask) {
+ int i;
+ int red = (colormask & 0x0FF0000UL) >> 16;
+ int green = (colormask & 0x000FF00UL) >> 8;
+ int blue = colormask & 0x00000FFUL;
+ int dr;
+ int dg;
+ int db;
+ long color_delta;
+ long best_delta = LONG_MAX;
+ int best_index = 0;
+ byte *ppal;
+
+ for (i = 0, ppal = cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) {
+ dr = ppal[0] - red;
+ dr = ABS(dr);
+ dg = ppal[1] - green;
+ dg = ABS(dg);
+ db = ppal[2] - blue;
+ db = ABS(db);
+ ppal[3] = 0;
+
+ color_delta = (long)(dr * R_RED_WEIGHT + dg * R_GREEN_WEIGHT + db * R_BLUE_WEIGHT);
+
+ if (color_delta == 0) {
+ return i;
+ }
+
+ if (color_delta < best_delta) {
+ best_delta = color_delta;
+ best_index = i;
+ }
+ }
+
+ return best_index;
+}
+
+int GFX_SetPalette(R_SURFACE *surface, PALENTRY *pal) {
+ byte red;
+ byte green;
+ byte blue;
+ int color_delta;
+ int best_wdelta = 0;
+ int best_windex = 0;
+ int best_bindex = 0;
+ int best_bdelta = 1000;
+ int i;
+ byte *ppal;
+
+ for (i = 0, ppal = cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) {
+ red = pal[i].red;
+ ppal[0] = red;
+ color_delta = red;
+ green = pal[i].green;
+ ppal[1] = green;
+ color_delta += green;
+ blue = pal[i].blue;
+ ppal[2] = blue;
+ color_delta += blue;
+ ppal[3] = 0;
+
+ if (color_delta < best_bdelta) {
+ best_bindex = i;
+ best_bdelta = color_delta;
+ }
+
+ if (color_delta > best_wdelta) {
+ best_windex = i;
+ best_wdelta = color_delta;
+ }
+ }
+
+ // Set whitest and blackest color indices
+ GfxModule.white_index = best_windex;
+ GfxModule.black_index = best_bindex;
+
+ _system->setPalette(cur_pal, 0, R_PAL_ENTRIES);
+
+ return R_SUCCESS;
+}
+
+int GFX_GetCurrentPal(PALENTRY *src_pal) {
+ int i;
+ byte *ppal;
+
+ 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;
+}
+
+int GFX_PalToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent) {
+ int i;
+ //int fade_max = 255;
+ int new_entry;
+ byte *ppal;
+
+ double fpercent;
+
+ if (percent > 1.0) {
+ percent = 1.0;
+ }
+
+ // Exponential fade
+ fpercent = percent * percent;
+
+ fpercent = 1.0 - fpercent;
+
+ // Use the correct percentage change per frame for each palette entry
+ 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) {
+ ppal[0] = 0;
+ } else {
+ ppal[0] = (byte) new_entry;
+ }
+
+ new_entry = (int)(src_pal[i].green * fpercent);
+
+ if (new_entry < 0) {
+ ppal[1] = 0;
+ } else {
+ ppal[1] = (byte) new_entry;
+ }
+
+ new_entry = (int)(src_pal[i].blue * fpercent);
+
+ if (new_entry < 0) {
+ ppal[2] = 0;
+ } else {
+ ppal[2] = (byte) new_entry;
+ }
+ ppal[3] = 0;
+ }
+
+ _system->setPalette(cur_pal, 0, R_PAL_ENTRIES);
+
+ return R_SUCCESS;
+}
+
+int GFX_BlackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) {
+ int new_entry;
+ double fpercent;
+ int color_delta;
+ int best_wdelta = 0;
+ int best_windex = 0;
+ int best_bindex = 0;
+ int best_bdelta = 1000;
+ byte *ppal;
+ int i;
+
+ if (percent > 1.0) {
+ percent = 1.0;
+ }
+
+ // Exponential fade
+ fpercent = percent * percent;
+
+ fpercent = 1.0 - fpercent;
+
+ // Use the correct percentage change per frame for each palette entry
+ 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) {
+ ppal[0] = 0;
+ } else {
+ ppal[0] = (byte) new_entry;
+ }
+
+ new_entry = (int)(src_pal[i].green - src_pal[i].green * fpercent);
+
+ if (new_entry < 0) {
+ ppal[1] = 0;
+ } else {
+ ppal[1] = (byte) new_entry;
+ }
+
+ new_entry = (int)(src_pal[i].blue - src_pal[i].blue * fpercent);
+
+ if (new_entry < 0) {
+ ppal[2] = 0;
+ } else {
+ ppal[2] = (byte) new_entry;
+ }
+ ppal[3] = 0;
+ }
+
+ // Find the best white and black color indices again
+ if (percent >= 1.0) {
+ 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;
+ best_bdelta = color_delta;
+ }
+
+ if (color_delta > best_wdelta) {
+ best_windex = i;
+ best_wdelta = color_delta;
+ }
+ }
+ }
+
+ _system->setPalette(cur_pal, 0, R_PAL_ENTRIES);
+
+ return R_SUCCESS;
+}
+
} // End of namespace Saga
diff --git a/saga/gfx.h b/saga/gfx.h
index 2a72f157e3..dd088d89f0 100644
--- a/saga/gfx.h
+++ b/saga/gfx.h
@@ -34,6 +34,19 @@ namespace Saga {
#define R_CURSOR_ORIGIN_X 4
#define R_CURSOR_ORIGIN_Y 4
+#define R_RED_WEIGHT 0.299
+#define R_GREEN_WEIGHT 0.587
+#define R_BLUE_WEIGHT 0.114
+
+struct R_GFX_MODULE {
+ int init;
+
+ R_SURFACE r_back_buf;
+
+ int white_index;
+ int black_index;
+};
+
} // End of namespace Saga
#endif
diff --git a/saga/ihnm_introproc.cpp b/saga/ihnm_introproc.cpp
index d6c1c598f6..53daa9c1ef 100644
--- a/saga/ihnm_introproc.cpp
+++ b/saga/ihnm_introproc.cpp
@@ -142,7 +142,7 @@ int IHNM_IntroMovieProc2(int param, R_SCENE_INFO *scene_info) {
case SCENE_BEGIN:
// Fade to black out of the intro CyberDreams logo anim
- SYSGFX_GetCurrentPal(current_pal);
+ GFX_GetCurrentPal(current_pal);
event.type = R_CONTINUOUS_EVENT;
event.code = R_PAL_EVENT;
@@ -203,7 +203,7 @@ int IHNM_IntroMovieProc3(int param, R_SCENE_INFO *scene_info) {
switch (param) {
case SCENE_BEGIN:
// Fade to black out of the intro DG logo anim
- SYSGFX_GetCurrentPal(current_pal);
+ GFX_GetCurrentPal(current_pal);
event.type = R_CONTINUOUS_EVENT;
event.code = R_PAL_EVENT;
diff --git a/saga/interface.cpp b/saga/interface.cpp
index 6644796566..1c03c285fb 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -254,7 +254,7 @@ int INTERFACE_Draw() {
R_RECT rect;
R_POINT origin;
- back_buf = SYSGFX_GetBackBuffer();
+ back_buf = GFX_GetBackBuffer();
if (!IfModule.active) {
return R_SUCCESS;
@@ -318,7 +318,7 @@ int INTERFACE_Update(R_POINT *imouse_pt, int update_flag) {
imouse_x = imouse_pt->x;
imouse_y = imouse_pt->y;
- back_buf = SYSGFX_GetBackBuffer();
+ back_buf = GFX_GetBackBuffer();
// Get game display info
GAME_GetDisplayInfo(&g_di);
diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp
index ccf6d74fb4..c4e00ce6b7 100644
--- a/saga/ite_introproc.cpp
+++ b/saga/ite_introproc.cpp
@@ -242,7 +242,7 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) {
switch (param) {
case SCENE_BEGIN:
// Fade to black out of the intro DG/NWC logo animation
- SYSGFX_GetCurrentPal(current_pal);
+ GFX_GetCurrentPal(current_pal);
event.type = R_CONTINUOUS_EVENT;
event.code = R_PAL_EVENT;
event.op = EVENT_PALTOBLACK;
diff --git a/saga/module.mk b/saga/module.mk
index 7fde955894..acbf5daa2f 100644
--- a/saga/module.mk
+++ b/saga/module.mk
@@ -38,7 +38,6 @@ MODULE_OBJS = \
saga/ys_binread.o \
saga/ys_binwrite.o \
saga/ys_dl_list.o \
- saga/sysgfx.o \
saga/input.o \
saga/timer.o \
saga/music.o \
diff --git a/saga/objectmap.cpp b/saga/objectmap.cpp
index 7fce03bd96..3a428fa309 100644
--- a/saga/objectmap.cpp
+++ b/saga/objectmap.cpp
@@ -365,7 +365,7 @@ int OBJECTMAP_Draw(R_SURFACE *ds, R_POINT *imouse_pt, int color, int color2) {
}
if (draw_txt) {
- FONT_Draw(SMALL_FONT_ID, ds, txt_buf, 0, 2, 2, SYSGFX_GetWhite(), SYSGFX_GetBlack(), FONT_OUTLINE);
+ FONT_Draw(SMALL_FONT_ID, ds, txt_buf, 0, 2, 2, GFX_GetWhite(), GFX_GetBlack(), FONT_OUTLINE);
}
return R_SUCCESS;
diff --git a/saga/palanim.cpp b/saga/palanim.cpp
index 4c3aef330f..e1759c4790 100644
--- a/saga/palanim.cpp
+++ b/saga/palanim.cpp
@@ -153,8 +153,8 @@ int PALANIM_CycleStep(int vectortime) {
return R_FAILURE;
}
- SYSGFX_GetCurrentPal(pal);
- back_buf = SYSGFX_GetBackBuffer();
+ GFX_GetCurrentPal(pal);
+ back_buf = GFX_GetBackBuffer();
for (i = 0; i < PAnimData.entry_count; i++) {
cycle = PAnimData.entries[i].cycle;
@@ -174,7 +174,7 @@ int PALANIM_CycleStep(int vectortime) {
}
}
- SYSGFX_SetPalette(back_buf, pal);
+ GFX_SetPalette(back_buf, pal);
event.type = R_ONESHOT_EVENT;
event.code = R_PALANIM_EVENT;
diff --git a/saga/reinherit.h b/saga/reinherit.h
index 36dcea552a..7a45b558c3 100644
--- a/saga/reinherit.h
+++ b/saga/reinherit.h
@@ -109,18 +109,16 @@ int TRANSITION_Dissolve(byte *dst_img, int dst_w, int dst_h,
// System : Graphics
#define R_PAL_ENTRIES 256
-int SYSGFX_Init(OSystem *system, int width, int height);
-R_SURFACE *SYSGFX_GetScreenSurface();
-R_SURFACE *SYSGFX_GetBackBuffer();
-int SYSGFX_LockSurface(R_SURFACE *surface);
-int SYSGFX_UnlockSurface(R_SURFACE *surface);
-int SYSGFX_GetWhite();
-int SYSGFX_GetBlack();
-int SYSGFX_MatchColor(unsigned long colormask);
-int SYSGFX_SetPalette(R_SURFACE *surface, PALENTRY *pal);
-int SYSGFX_GetCurrentPal(PALENTRY *src_pal);
-int SYSGFX_PalToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent);
-int SYSGFX_BlackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent);
+int GFX_Init(OSystem *system, int width, int height);
+R_SURFACE *GFX_GetScreenSurface();
+R_SURFACE *GFX_GetBackBuffer();
+int GFX_GetWhite();
+int GFX_GetBlack();
+int GFX_MatchColor(unsigned long colormask);
+int GFX_SetPalette(R_SURFACE *surface, PALENTRY *pal);
+int GFX_GetCurrentPal(PALENTRY *src_pal);
+int GFX_PalToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent);
+int GFX_BlackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent);
// System : Input
int SYSINPUT_Init();
@@ -129,9 +127,6 @@ int SYSINPUT_GetMousePos(int *mouse_x, int *mouse_y);
int SYSINPUT_HideMouse(void);
int SYSINPUT_ShowMouse(void);
-// sys_signal.c
-int ITESYS_CheckSignal(void);
-
} // End of namespace Saga
#endif
diff --git a/saga/render.cpp b/saga/render.cpp
index 50cfd0f652..86d1db2240 100644
--- a/saga/render.cpp
+++ b/saga/render.cpp
@@ -72,7 +72,7 @@ int RENDER_Init(OSystem *system) {
// Initialize system graphics
GAME_GetDisplayInfo(&disp_info);
- if (SYSGFX_Init(system, disp_info.logical_w, disp_info.logical_h) != R_SUCCESS) {
+ if (GFX_Init(system, disp_info.logical_w, disp_info.logical_h) != R_SUCCESS) {
return R_FAILURE;
}
@@ -107,7 +107,7 @@ int RENDER_Init(OSystem *system) {
RenderModule.r_tmp_buf_w = tmp_w;
RenderModule.r_tmp_buf_h = tmp_h;
- RenderModule.r_backbuf_surface = SYSGFX_GetBackBuffer();
+ RenderModule.r_backbuf_surface = GFX_GetBackBuffer();
// Initialize cursor state
if (RenderModule.r_softcursor) {
@@ -155,8 +155,8 @@ int RENDER_DrawScene() {
// Display scene maps, if applicable
if (RENDER_GetFlags() & RF_OBJECTMAP_TEST) {
- OBJECTMAP_Draw(backbuf_surface, &mouse_pt, SYSGFX_GetWhite(), SYSGFX_GetBlack());
- ACTIONMAP_Draw(backbuf_surface, SYSGFX_MatchColor(R_RGB_RED));
+ OBJECTMAP_Draw(backbuf_surface, &mouse_pt, GFX_GetWhite(), GFX_GetBlack());
+ ACTIONMAP_Draw(backbuf_surface, GFX_MatchColor(R_RGB_RED));
}
// Draw queued actors
@@ -175,7 +175,7 @@ int RENDER_DrawScene() {
sprintf(txt_buf, "%d", RenderModule.r_fps);
fps_width = FONT_GetStringWidth(SMALL_FONT_ID, txt_buf, 0, FONT_NORMAL);
FONT_Draw(SMALL_FONT_ID, backbuf_surface, txt_buf, 0, backbuf_surface->buf_w - fps_width, 2,
- SYSGFX_GetWhite(), SYSGFX_GetBlack(), FONT_OUTLINE);
+ GFX_GetWhite(), GFX_GetBlack(), FONT_OUTLINE);
}
// Display "paused game" message, if applicable
@@ -183,7 +183,7 @@ int RENDER_DrawScene() {
int msg_len = strlen(R_PAUSEGAME_MSG);
int msg_w = FONT_GetStringWidth(BIG_FONT_ID, R_PAUSEGAME_MSG, msg_len, FONT_OUTLINE);
FONT_Draw(BIG_FONT_ID, backbuf_surface, R_PAUSEGAME_MSG, msg_len,
- (backbuf_surface->buf_w - msg_w) / 2, 90, SYSGFX_GetWhite(), SYSGFX_GetBlack(), FONT_OUTLINE);
+ (backbuf_surface->buf_w - msg_w) / 2, 90, GFX_GetWhite(), GFX_GetBlack(), FONT_OUTLINE);
}
// Update user interface
@@ -197,7 +197,7 @@ int RENDER_DrawScene() {
// Display text formatting test, if applicable
if (RenderModule.r_flags & RF_TEXT_TEST) {
TEXT_Draw(MEDIUM_FONT_ID, backbuf_surface, test_txt, mouse_pt.x, mouse_pt.y,
- SYSGFX_GetWhite(), SYSGFX_GetBlack(), FONT_OUTLINE | FONT_CENTERED);
+ GFX_GetWhite(), GFX_GetBlack(), FONT_OUTLINE | FONT_CENTERED);
}
// Display palette test, if applicable
diff --git a/saga/saga.cpp b/saga/saga.cpp
index c8a360506b..c6f6abd79a 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -215,11 +215,6 @@ void SagaEngine::go() {
SCENE_Start();
for (;;) {
-#ifdef R_USE_CUSTOM_WININIT
- if (ITESYS_CheckSignal()) {
- break;
- }
-#endif
if (RENDER_GetFlags() & RF_RENDERPAUSE) {
// Freeze time while paused
SYSTIMER_ResetMSCounter();
diff --git a/saga/sceneproc.cpp b/saga/sceneproc.cpp
index 937b997ef2..fb0dae1243 100644
--- a/saga/sceneproc.cpp
+++ b/saga/sceneproc.cpp
@@ -55,7 +55,7 @@ int InitialSceneProc(int param, R_SCENE_INFO *scene_info) {
_vm->_sound->stopVoice();
// Fade palette to black from intro scene
- SYSGFX_GetCurrentPal(current_pal);
+ GFX_GetCurrentPal(current_pal);
event.type = R_CONTINUOUS_EVENT;
event.code = R_PAL_EVENT;
diff --git a/saga/sysgfx.cpp b/saga/sysgfx.cpp
deleted file mode 100644
index 1f81d58707..0000000000
--- a/saga/sysgfx.cpp
+++ /dev/null
@@ -1,303 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2004 The ScummVM project
- *
- * The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
- *
- * 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$
- *
- */
-#include "saga.h"
-#include "reinherit.h"
-
-#include "sysgfx.h"
-
-namespace Saga {
-
-static R_SYSGFX_MODULE SGfxModule;
-static OSystem *_system;
-
-static byte cur_pal[R_PAL_ENTRIES * 4];
-
-int SYSGFX_Init(OSystem *system, int width, int height) {
- R_SURFACE r_back_buf;
-
- _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 *)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.clip_rect.left = 0;
- r_back_buf.clip_rect.top = 0;
- r_back_buf.clip_rect.right = width - 1;
- r_back_buf.clip_rect.bottom = height - 1;
-
- // Set module data
- SGfxModule.r_back_buf = r_back_buf;
- SGfxModule.init = 1;
-
- return R_SUCCESS;
-}
-
-/*
-~SysGfx() {
- free(SGfxModule.r_back_buf->buf);
-}
- */
-
-R_SURFACE *SYSGFX_GetBackBuffer() {
- return &SGfxModule.r_back_buf;
-}
-
-int SYSGFX_LockSurface(R_SURFACE *surface) {
- return 0;
-}
-
-int SYSGFX_UnlockSurface(R_SURFACE *surface) {
- return 0;
-}
-
-int SYSGFX_GetWhite(void) {
- return SGfxModule.white_index;
-}
-
-int SYSGFX_GetBlack(void) {
- return SGfxModule.black_index;
-}
-
-int SYSGFX_MatchColor(unsigned long colormask) {
- int i;
- int red = (colormask & 0x0FF0000UL) >> 16;
- int green = (colormask & 0x000FF00UL) >> 8;
- int blue = colormask & 0x00000FFUL;
- int dr;
- int dg;
- int db;
- long color_delta;
- long best_delta = LONG_MAX;
- int best_index = 0;
- byte *ppal;
-
- for (i = 0, ppal = cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) {
- dr = ppal[0] - red;
- dr = ABS(dr);
- dg = ppal[1] - green;
- dg = ABS(dg);
- db = ppal[2] - blue;
- db = ABS(db);
- ppal[3] = 0;
-
- color_delta = (long)(dr * R_RED_WEIGHT + dg * R_GREEN_WEIGHT + db * R_BLUE_WEIGHT);
-
- if (color_delta == 0) {
- return i;
- }
-
- if (color_delta < best_delta) {
- best_delta = color_delta;
- best_index = i;
- }
- }
-
- return best_index;
-}
-
-int SYSGFX_SetPalette(R_SURFACE *surface, PALENTRY *pal) {
- byte red;
- byte green;
- byte blue;
- int color_delta;
- int best_wdelta = 0;
- int best_windex = 0;
- int best_bindex = 0;
- int best_bdelta = 1000;
- int i;
- byte *ppal;
-
- for (i = 0, ppal = cur_pal; i < R_PAL_ENTRIES; i++, ppal += 4) {
- red = pal[i].red;
- ppal[0] = red;
- color_delta = red;
- green = pal[i].green;
- ppal[1] = green;
- color_delta += green;
- blue = pal[i].blue;
- ppal[2] = blue;
- color_delta += blue;
- ppal[3] = 0;
-
- if (color_delta < best_bdelta) {
- best_bindex = i;
- best_bdelta = color_delta;
- }
-
- if (color_delta > best_wdelta) {
- best_windex = i;
- best_wdelta = color_delta;
- }
- }
-
- // Set whitest and blackest color indices
- SGfxModule.white_index = best_windex;
- SGfxModule.black_index = best_bindex;
-
- _system->setPalette(cur_pal, 0, R_PAL_ENTRIES);
-
- return R_SUCCESS;
-}
-
-int SYSGFX_GetCurrentPal(PALENTRY *src_pal) {
- int i;
- byte *ppal;
-
- 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;
-}
-
-int SYSGFX_PalToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent) {
- int i;
- //int fade_max = 255;
- int new_entry;
- byte *ppal;
-
- double fpercent;
-
- if (percent > 1.0) {
- percent = 1.0;
- }
-
- // Exponential fade
- fpercent = percent * percent;
-
- fpercent = 1.0 - fpercent;
-
- // Use the correct percentage change per frame for each palette entry
- 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) {
- ppal[0] = 0;
- } else {
- ppal[0] = (byte) new_entry;
- }
-
- new_entry = (int)(src_pal[i].green * fpercent);
-
- if (new_entry < 0) {
- ppal[1] = 0;
- } else {
- ppal[1] = (byte) new_entry;
- }
-
- new_entry = (int)(src_pal[i].blue * fpercent);
-
- if (new_entry < 0) {
- ppal[2] = 0;
- } else {
- ppal[2] = (byte) new_entry;
- }
- ppal[3] = 0;
- }
-
- _system->setPalette(cur_pal, 0, R_PAL_ENTRIES);
-
- return R_SUCCESS;
-}
-
-int SYSGFX_BlackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) {
- int new_entry;
- double fpercent;
- int color_delta;
- int best_wdelta = 0;
- int best_windex = 0;
- int best_bindex = 0;
- int best_bdelta = 1000;
- byte *ppal;
- int i;
-
- if (percent > 1.0) {
- percent = 1.0;
- }
-
- // Exponential fade
- fpercent = percent * percent;
-
- fpercent = 1.0 - fpercent;
-
- // Use the correct percentage change per frame for each palette entry
- 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) {
- ppal[0] = 0;
- } else {
- ppal[0] = (byte) new_entry;
- }
-
- new_entry = (int)(src_pal[i].green - src_pal[i].green * fpercent);
-
- if (new_entry < 0) {
- ppal[1] = 0;
- } else {
- ppal[1] = (byte) new_entry;
- }
-
- new_entry = (int)(src_pal[i].blue - src_pal[i].blue * fpercent);
-
- if (new_entry < 0) {
- ppal[2] = 0;
- } else {
- ppal[2] = (byte) new_entry;
- }
- ppal[3] = 0;
- }
-
- // Find the best white and black color indices again
- if (percent >= 1.0) {
- 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;
- best_bdelta = color_delta;
- }
-
- if (color_delta > best_wdelta) {
- best_windex = i;
- best_wdelta = color_delta;
- }
- }
- }
-
- _system->setPalette(cur_pal, 0, R_PAL_ENTRIES);
-
- return R_SUCCESS;
-}
-
-} // End of namespace Saga
-
diff --git a/saga/sysgfx.h b/saga/sysgfx.h
deleted file mode 100644
index f530b8d1a0..0000000000
--- a/saga/sysgfx.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2004 The ScummVM project
- *
- * The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
- *
- * 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 SYSGFX_H_
-#define SYSGFX_H_
-
-namespace Saga {
-
-#define R_COLORSEARCH_SQUARE 0
-
-#define R_RED_WEIGHT 0.299
-#define R_GREEN_WEIGHT 0.587
-#define R_BLUE_WEIGHT 0.114
-
-struct R_SYSGFX_MODULE {
- int init;
-
- R_SURFACE r_back_buf;
-
- int white_index;
- int black_index;
-};
-
-} // End of namespace Saga
-
-#endif