diff --git a/saga/actionmap.cpp b/saga/actionmap.cpp index 6237d4eb038..b0b0818d30c 100644 --- a/saga/actionmap.cpp +++ b/saga/actionmap.cpp @@ -25,7 +25,7 @@ #include "saga.h" #include "cvar_mod.h" -#include "gfx_mod.h" +#include "gfx.h" #include "console_mod.h" #include "actionmap.h" @@ -159,11 +159,11 @@ int ActionMap::draw(R_SURFACE * ds, int color) { for (i = 0; i < _n_exits; i++) { if (_exits_tbl[i].pt_count == 2) { - GFX_DrawFrame(ds, + _vm->_gfx->drawFrame(ds, &_exits_tbl[i].pt_tbl[0], &_exits_tbl[i].pt_tbl[1], color); } else if (_exits_tbl[i].pt_count > 2) { - GFX_DrawPolyLine(ds, _exits_tbl[i].pt_tbl, + _vm->_gfx->drawPolyLine(ds, _exits_tbl[i].pt_tbl, _exits_tbl[i].pt_count, color); } } diff --git a/saga/actor.cpp b/saga/actor.cpp index 6646caeaef9..e7c3d20c241 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -23,7 +23,7 @@ #include "saga.h" #include "yslib.h" -#include "gfx_mod.h" +#include "gfx.h" #include "game_mod.h" #include "cvar_mod.h" @@ -220,7 +220,7 @@ int ACTOR_DrawList() { R_SURFACE *back_buf; - back_buf = GFX_GetBackBuffer(); + back_buf = _vm->_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/animation.cpp b/saga/animation.cpp index 50189e09ba5..ba29a8882d7 100644 --- a/saga/animation.cpp +++ b/saga/animation.cpp @@ -23,7 +23,7 @@ // Background animation management module #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "cvar_mod.h" #include "console_mod.h" diff --git a/saga/console.cpp b/saga/console.cpp index 34fae3a4940..488d50aa636 100644 --- a/saga/console.cpp +++ b/saga/console.cpp @@ -24,11 +24,10 @@ // Console module #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "font_mod.h" #include "cvar_mod.h" #include "events_mod.h" -#include "gfx_mod.h" #include "console_mod.h" #include "console.h" @@ -216,9 +215,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, GFX_MatchColor(R_CONSOLE_BGCOLOR)); - txt_fgcolor = GFX_MatchColor(R_CONSOLE_TXTCOLOR); - txt_shcolor = GFX_MatchColor(R_CONSOLE_TXTSHADOW); + _vm->_gfx->drawRect(ds, &fill_rect, _vm->_gfx->matchColor(R_CONSOLE_BGCOLOR)); + txt_fgcolor = _vm->_gfx->matchColor(R_CONSOLE_TXTCOLOR); + txt_shcolor = _vm->_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), @@ -353,7 +352,7 @@ int CON_DropConsole(double percent) { percent = 1.0; } - back_buf = GFX_GetBackBuffer(); + back_buf = _vm->_gfx->getBackBuffer(); CON_SetDropPos(percent); CON_Draw(back_buf); @@ -368,7 +367,7 @@ int CON_RaiseConsole(double percent) { ConInfo.active = 0; } - back_buf = GFX_GetBackBuffer(); + back_buf = _vm->_gfx->getBackBuffer(); CON_SetDropPos(1.0 - percent); CON_Draw(back_buf); diff --git a/saga/cvar.cpp b/saga/cvar.cpp index f16dc95716c..a943c5eeccd 100644 --- a/saga/cvar.cpp +++ b/saga/cvar.cpp @@ -23,7 +23,7 @@ // Configuration Variable Module #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "console_mod.h" diff --git a/saga/events.cpp b/saga/events.cpp index 1f91aa69ff4..d9fae5e385d 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -25,14 +25,13 @@ #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "yslib.h" #include "animation.h" #include "console_mod.h" #include "scene_mod.h" -#include "gfx_mod.h" #include "interface_mod.h" #include "text_mod.h" #include "palanim_mod.h" @@ -159,13 +158,13 @@ int HandleContinuous(R_EVENT *event) { case R_PAL_EVENT: switch (event->op) { case EVENT_BLACKTOPAL: - back_buf = GFX_GetBackBuffer(); - GFX_BlackToPal(back_buf, (PALENTRY *)event->data, event_pc); + back_buf = _vm->_gfx->getBackBuffer(); + _vm->_gfx->blackToPal(back_buf, (PALENTRY *)event->data, event_pc); break; case EVENT_PALTOBLACK: - back_buf = GFX_GetBackBuffer(); - GFX_PalToBlack(back_buf, (PALENTRY *)event->data, event_pc); + back_buf = _vm->_gfx->getBackBuffer(); + _vm->_gfx->palToBlack(back_buf, (PALENTRY *)event->data, event_pc); break; default: break; @@ -249,7 +248,7 @@ static int HandleOneShot(R_EVENT *event) { if (SCENE_GetMode() == R_SCENE_MODE_NORMAL) { - back_buf = GFX_GetBackBuffer(); + back_buf = _vm->_gfx->getBackBuffer(); _vm->_render->getBufferInfo(&rbuf_info); SCENE_GetBGInfo(&bginfo); @@ -257,12 +256,12 @@ static int HandleOneShot(R_EVENT *event) { bg_pt.x = bginfo.bg_x; bg_pt.y = bginfo.bg_y; - GFX_BufToBuffer(rbuf_info.r_bg_buf, rbuf_info.r_bg_buf_w, rbuf_info.r_bg_buf_h, + _vm->_gfx->bufToBuffer(rbuf_info.r_bg_buf, rbuf_info.r_bg_buf_w, rbuf_info.r_bg_buf_h, bginfo.bg_buf, bginfo.bg_w, bginfo.bg_h, NULL, &bg_pt); if (event->param == SET_PALETTE) { PALENTRY *pal_p; SCENE_GetBGPal(&pal_p); - GFX_SetPalette(back_buf, pal_p); + _vm->_gfx->setPalette(back_buf, pal_p); } } } diff --git a/saga/font.cpp b/saga/font.cpp index 02e1a819732..fdbe54f0681 100644 --- a/saga/font.cpp +++ b/saga/font.cpp @@ -23,7 +23,7 @@ // Font management and font drawing module #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "rscfile_mod.h" #include "game_mod.h" diff --git a/saga/gfx.cpp b/saga/gfx.cpp index fe638d9b100..02dc871d8ac 100644 --- a/saga/gfx.cpp +++ b/saga/gfx.cpp @@ -28,7 +28,6 @@ // Coriolis Group Books, 1997 #include "saga/saga.h" -#include "saga/gfx_mod.h" #include "saga/gfx.h" #include "common/system.h" @@ -41,7 +40,7 @@ static OSystem *_system; static byte cur_pal[R_PAL_ENTRIES * 4]; -int GFX_Init(OSystem *system, int width, int height) { +Gfx::Gfx(OSystem *system, int width, int height) { R_SURFACE r_back_buf; _system = system; @@ -66,10 +65,8 @@ int GFX_Init(OSystem *system, int width, int height) { GfxModule.black_index = -1; // For now, always show the mouse cursor. - GFX_SetCursor(1); + setCursor(1); g_system->showMouse(true); - - return R_SUCCESS; } /* @@ -78,7 +75,7 @@ int GFX_Init(OSystem *system, int width, int height) { } */ -int GFX_DrawPalette(R_SURFACE *dst_s) { +int Gfx::drawPalette(R_SURFACE *dst_s) { int x; int y; int color = 0; @@ -93,7 +90,7 @@ int GFX_DrawPalette(R_SURFACE *dst_s) { pal_rect.left = (x * 8) + 4; pal_rect.right = pal_rect.left + 8; - GFX_DrawRect(dst_s, &pal_rect, color); + drawRect(dst_s, &pal_rect, color); color++; } } @@ -101,7 +98,7 @@ int GFX_DrawPalette(R_SURFACE *dst_s) { return 0; } -int GFX_SimpleBlit(R_SURFACE *dst_s, R_SURFACE *src_s) { +int Gfx::simpleBlit(R_SURFACE *dst_s, R_SURFACE *src_s) { byte *src_p; byte *dst_p; int y, w, p; @@ -135,7 +132,7 @@ int GFX_SimpleBlit(R_SURFACE *dst_s, R_SURFACE *src_s) { // - If src_rect is NULL, the entire buffer is copied./ // - The surface must match the logical dimensions of the buffer exactly. // - Returns R_FAILURE on error -int GFX_BufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, +int Gfx::bufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, R_RECT *src_rect, R_POINT *dst_pt) { const byte *read_p; byte *write_p; @@ -261,7 +258,7 @@ int GFX_BufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, return R_SUCCESS; } -int GFX_BufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src, +int Gfx::bufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src, int src_w, int src_h, R_RECT *src_rect, R_POINT *dst_pt) { const byte *read_p; byte *write_p; @@ -383,7 +380,7 @@ int GFX_BufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src, // Fills a rectangle in the surface ds from point 'p1' to point 'p2' using // the specified color. -int GFX_DrawRect(R_SURFACE *ds, R_RECT *dst_rect, int color) { +int Gfx::drawRect(R_SURFACE *ds, R_RECT *dst_rect, int color) { byte *write_p; int w; @@ -423,7 +420,7 @@ int GFX_DrawRect(R_SURFACE *ds, R_RECT *dst_rect, int color) { return R_SUCCESS; } -int GFX_DrawFrame(R_SURFACE *ds, R_POINT *p1, R_POINT *p2, int color) { +int Gfx::drawFrame(R_SURFACE *ds, R_POINT *p1, R_POINT *p2, int color) { int left, top, right, bottom; int min_x; @@ -457,15 +454,15 @@ int GFX_DrawFrame(R_SURFACE *ds, R_POINT *p1, R_POINT *p2, int color) { n_p4.x = min_x; n_p4.y = max_y; - GFX_DrawLine(ds, &n_p1, &n_p2, color); - GFX_DrawLine(ds, &n_p2, &n_p3, color); - GFX_DrawLine(ds, &n_p3, &n_p4, color); - GFX_DrawLine(ds, &n_p4, &n_p1, color); + drawLine(ds, &n_p1, &n_p2, color); + drawLine(ds, &n_p2, &n_p3, color); + drawLine(ds, &n_p3, &n_p4, color); + drawLine(ds, &n_p4, &n_p1, color); return R_SUCCESS; } -int GFX_DrawPolyLine(R_SURFACE *ds, R_POINT *pts, int pt_ct, int draw_color) { +int Gfx::drawPolyLine(R_SURFACE *ds, R_POINT *pts, int pt_ct, int draw_color) { R_POINT *first_pt = pts; int last_i = 1; int i; @@ -477,16 +474,16 @@ int GFX_DrawPolyLine(R_SURFACE *ds, R_POINT *pts, int pt_ct, int draw_color) { } for (i = 1; i < pt_ct; i++) { - GFX_DrawLine(ds, &pts[i], &pts[i - 1], draw_color); + drawLine(ds, &pts[i], &pts[i - 1], draw_color); last_i = i; } - GFX_DrawLine(ds, &pts[last_i], first_pt, draw_color); + drawLine(ds, &pts[last_i], first_pt, draw_color); return R_SUCCESS; } -int GFX_GetClipInfo(R_CLIPINFO *clipinfo) { +int Gfx::getClipInfo(R_CLIPINFO *clipinfo) { Common::Rect s; int d_x, d_y; @@ -570,7 +567,7 @@ int GFX_GetClipInfo(R_CLIPINFO *clipinfo) { return R_SUCCESS; } -int GFX_ClipLine(R_SURFACE *ds, const R_POINT *src_p1, const R_POINT *src_p2, +int Gfx::clipLine(R_SURFACE *ds, const R_POINT *src_p1, const R_POINT *src_p2, R_POINT *dst_p1, R_POINT *dst_p2) { const R_POINT *n_p1; const R_POINT *n_p2; @@ -642,7 +639,7 @@ int GFX_ClipLine(R_SURFACE *ds, const R_POINT *src_p1, const R_POINT *src_p2, // Coriolis Group Books, 1997 // // Performs no clipping -void GFX_DrawLine(R_SURFACE *ds, R_POINT *p1, R_POINT *p2, int color) { +void Gfx::drawLine(R_SURFACE *ds, R_POINT *p1, R_POINT *p2, int color) { byte *write_p; int clip_result; int temp; @@ -658,7 +655,7 @@ void GFX_DrawLine(R_SURFACE *ds, R_POINT *p1, R_POINT *p2, int color) { int left, top, right, bottom; int i, k; - clip_result = GFX_ClipLine(ds, p1, p2, &clip_p1, &clip_p2); + clip_result = clipLine(ds, p1, p2, &clip_p1, &clip_p2); if (clip_result < 0) { // Line not visible return; @@ -817,19 +814,19 @@ void GFX_DrawLine(R_SURFACE *ds, R_POINT *p1, R_POINT *p2, int color) { return; } -R_SURFACE *GFX_GetBackBuffer() { +R_SURFACE *Gfx::getBackBuffer() { return &GfxModule.r_back_buf; } -int GFX_GetWhite(void) { +int Gfx::getWhite(void) { return GfxModule.white_index; } -int GFX_GetBlack(void) { +int Gfx::getBlack(void) { return GfxModule.black_index; } -int GFX_MatchColor(unsigned long colormask) { +int Gfx::matchColor(unsigned long colormask) { int i; int red = (colormask & 0x0FF0000UL) >> 16; int green = (colormask & 0x000FF00UL) >> 8; @@ -866,7 +863,7 @@ int GFX_MatchColor(unsigned long colormask) { return best_index; } -int GFX_SetPalette(R_SURFACE *surface, PALENTRY *pal) { +int Gfx::setPalette(R_SURFACE *surface, PALENTRY *pal) { byte red; byte green; byte blue; @@ -905,7 +902,7 @@ int GFX_SetPalette(R_SURFACE *surface, PALENTRY *pal) { // correct. We may have to reconsider this code later, but for now // there is only one cursor image. if (GfxModule.white_index != best_windex) { - GFX_SetCursor(best_windex); + setCursor(best_windex); } // Set whitest and blackest color indices @@ -917,7 +914,7 @@ int GFX_SetPalette(R_SURFACE *surface, PALENTRY *pal) { return R_SUCCESS; } -int GFX_GetCurrentPal(PALENTRY *src_pal) { +int Gfx::getCurrentPal(PALENTRY *src_pal) { int i; byte *ppal; @@ -930,7 +927,7 @@ int GFX_GetCurrentPal(PALENTRY *src_pal) { return R_SUCCESS; } -int GFX_PalToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent) { +int Gfx::palToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent) { int i; //int fade_max = 255; int new_entry; @@ -980,7 +977,7 @@ int GFX_PalToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent) { return R_SUCCESS; } -int GFX_BlackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) { +int Gfx::blackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) { int new_entry; double fpercent; int color_delta; @@ -1051,7 +1048,7 @@ int GFX_BlackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) { // correct. We may have to reconsider this code later, but for now // there is only one cursor image. if (GfxModule.white_index != best_windex) { - GFX_SetCursor(best_windex); + setCursor(best_windex); } _system->setPalette(cur_pal, 0, R_PAL_ENTRIES); @@ -1059,7 +1056,7 @@ int GFX_BlackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent) { return R_SUCCESS; } -void GFX_SetCursor(int best_white) { +void Gfx::setCursor(int best_white) { int i; byte keycolor = (best_white == 0) ? 1 : 0; diff --git a/saga/gfx.h b/saga/gfx.h index a24385874ad..489c9e92dec 100644 --- a/saga/gfx.h +++ b/saga/gfx.h @@ -28,6 +28,49 @@ namespace Saga { +struct R_CLIPINFO { + // input members + const R_RECT *src_rect; + const R_RECT *dst_rect; + const R_POINT *dst_pt; + + // output members + int nodraw; + int src_draw_x; + int src_draw_y; + int dst_draw_x; + int dst_draw_y; + int draw_w; + int draw_h; +}; + +struct PALENTRY { + byte red; + byte green; + byte blue; +}; + +struct R_COLOR { + int red; + int green; + int blue; + int alpha; +}; + +struct R_SURFACE { + byte *buf; + int buf_w; + int buf_h; + int buf_pitch; + R_RECT clip_rect; +}; + +#define R_PAL_ENTRIES 256 + +#define R_RGB_RED 0x00FF0000UL +#define R_RGB_GREEN 0x0000FF00UL +#define R_RGB_BLUE 0x000000FFUL + #define R_CURSOR_W 7 #define R_CURSOR_H 7 @@ -47,7 +90,32 @@ struct R_GFX_MODULE { int black_index; }; -void GFX_SetCursor(int best_white); +class Gfx { +public: + int simpleBlit(R_SURFACE *dst_s, R_SURFACE *src_s); + int drawPalette(R_SURFACE *dst_s); + int bufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, R_RECT *src_rect, R_POINT *dst_pt); + int bufToBuffer(byte * dst_buf, int dst_w, int dst_h, const byte *src, + int src_w, int src_h, R_RECT *src_rect, R_POINT *dst_pt); + int drawRect(R_SURFACE *ds, R_RECT *dst_rect, int color); + int drawFrame(R_SURFACE *ds, R_POINT *p1, R_POINT *p2, int color); + int drawPolyLine(R_SURFACE *ds, R_POINT *pts, int pt_ct, int draw_color); + int getClipInfo(R_CLIPINFO *clipinfo); + int clipLine(R_SURFACE *ds, const R_POINT *src_p1, const R_POINT *src_p2, R_POINT *dst_p1, R_POINT *dst_p2); + void drawLine(R_SURFACE * ds, R_POINT *p1, R_POINT *p2, int color); + + Gfx(OSystem *system, int width, int height); + R_SURFACE *getBackBuffer(); + int getWhite(); + int getBlack(); + int matchColor(unsigned long colormask); + int setPalette(R_SURFACE *surface, PALENTRY *pal); + int getCurrentPal(PALENTRY *src_pal); + int palToBlack(R_SURFACE *surface, PALENTRY *src_pal, double percent); + int blackToPal(R_SURFACE *surface, PALENTRY *src_pal, double percent); +private: + void setCursor(int best_white); +}; } // End of namespace Saga diff --git a/saga/gfx_mod.h b/saga/gfx_mod.h deleted file mode 100644 index d335ccb7c93..00000000000 --- a/saga/gfx_mod.h +++ /dev/null @@ -1,99 +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$ - * - */ -// Graphics manipulation routines - module header file - -#ifndef SAGA_GFX_MOD_H_ -#define SAGA_GFX_MOD_H_ - -namespace Saga { - -struct R_CLIPINFO { - // input members - const R_RECT *src_rect; - const R_RECT *dst_rect; - const R_POINT *dst_pt; - - // output members - int nodraw; - int src_draw_x; - int src_draw_y; - int dst_draw_x; - int dst_draw_y; - int draw_w; - int draw_h; - -}; - -struct PALENTRY { - byte red; - byte green; - byte blue; -}; - -struct R_COLOR { - int red; - int green; - int blue; - int alpha; -}; - -struct R_SURFACE { - byte *buf; - int buf_w; - int buf_h; - int buf_pitch; - R_RECT clip_rect; -}; - -#define R_PAL_ENTRIES 256 - -#define R_RGB_RED 0x00FF0000UL -#define R_RGB_GREEN 0x0000FF00UL -#define R_RGB_BLUE 0x000000FFUL - -int GFX_SimpleBlit(R_SURFACE *dst_s, R_SURFACE *src_s); -int GFX_DrawPalette(R_SURFACE *dst_s); -int GFX_BufToSurface(R_SURFACE *ds, const byte *src, int src_w, int src_h, R_RECT *src_rect, R_POINT *dst_pt); -int GFX_BufToBuffer(byte * dst_buf, int dst_w, int dst_h, const byte *src, - int src_w, int src_h, R_RECT *src_rect, R_POINT *dst_pt); -int GFX_DrawRect(R_SURFACE *ds, R_RECT *dst_rect, int color); -int GFX_DrawFrame(R_SURFACE *ds, R_POINT *p1, R_POINT *p2, int color); -int GFX_DrawPolyLine(R_SURFACE *ds, R_POINT *pts, int pt_ct, int draw_color); -int GFX_GetClipInfo(R_CLIPINFO *clipinfo); -int GFX_ClipLine(R_SURFACE *ds, const R_POINT *src_p1, const R_POINT *src_p2, R_POINT *dst_p1, R_POINT *dst_p2); -void GFX_DrawLine(R_SURFACE * ds, R_POINT *p1, R_POINT *p2, int color); - -int GFX_Init(OSystem *system, int width, int height); -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); - - -} // End of namespace Saga - -#endif diff --git a/saga/ihnm_introproc.cpp b/saga/ihnm_introproc.cpp index dd9f5c500c8..c1518e6876e 100644 --- a/saga/ihnm_introproc.cpp +++ b/saga/ihnm_introproc.cpp @@ -25,7 +25,7 @@ #include "saga.h" #include "yslib.h" -#include "gfx_mod.h" +#include "gfx.h" #include "animation.h" #include "cvar_mod.h" @@ -139,7 +139,7 @@ int IHNM_IntroMovieProc2(int param, R_SCENE_INFO *scene_info) { case SCENE_BEGIN: // Fade to black out of the intro CyberDreams logo anim - GFX_GetCurrentPal(current_pal); + _vm->_gfx->getCurrentPal(current_pal); event.type = R_CONTINUOUS_EVENT; event.code = R_PAL_EVENT; @@ -199,7 +199,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 - GFX_GetCurrentPal(current_pal); + _vm->_gfx->getCurrentPal(current_pal); event.type = R_CONTINUOUS_EVENT; event.code = R_PAL_EVENT; diff --git a/saga/input.cpp b/saga/input.cpp index 0f7d7388c4d..1b8aace8bf5 100644 --- a/saga/input.cpp +++ b/saga/input.cpp @@ -22,7 +22,7 @@ */ #include "saga/saga.h" -#include "saga/gfx_mod.h" +#include "saga/gfx.h" #include "saga/actor_mod.h" #include "saga/console_mod.h" #include "saga/interface_mod.h" diff --git a/saga/interface.cpp b/saga/interface.cpp index 5c7191d8b02..380e9be04b9 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -24,7 +24,7 @@ // Game interface module #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "game_mod.h" #include "cvar_mod.h" #include "actor_mod.h" @@ -250,7 +250,7 @@ int INTERFACE_Draw() { R_RECT rect; R_POINT origin; - back_buf = GFX_GetBackBuffer(); + back_buf = _vm->_gfx->getBackBuffer(); if (!IfModule.active) { return R_SUCCESS; @@ -266,7 +266,7 @@ int INTERFACE_Draw() { rect.right = g_di.logical_w - 1; rect.bottom = IfModule.i_desc.status_y; - GFX_DrawRect(back_buf, &rect, IfModule.i_desc.status_bgcol); + _vm->_gfx->drawRect(back_buf, &rect, IfModule.i_desc.status_bgcol); // Draw command panel background if (IfModule.panel_mode == PANEL_COMMAND) { @@ -276,7 +276,7 @@ int INTERFACE_Draw() { origin.x = 0; origin.y = g_di.logical_h - IfModule.c_panel.img_h; - GFX_BufToSurface(back_buf, IfModule.c_panel.img, IfModule.c_panel.img_w, + _vm->_gfx->bufToSurface(back_buf, IfModule.c_panel.img, IfModule.c_panel.img_w, IfModule.c_panel.img_h, NULL, &origin); } else { xbase = IfModule.d_panel.x; @@ -285,7 +285,7 @@ int INTERFACE_Draw() { origin.x = 0; origin.y = g_di.logical_h - IfModule.c_panel.img_h; - GFX_BufToSurface(back_buf, IfModule.d_panel.img, IfModule.d_panel.img_w, + _vm->_gfx->bufToSurface(back_buf, IfModule.d_panel.img, IfModule.d_panel.img_w, IfModule.d_panel.img_h, NULL, &origin); } @@ -314,7 +314,7 @@ int INTERFACE_Update(R_POINT *imouse_pt, int update_flag) { imouse_x = imouse_pt->x; imouse_y = imouse_pt->y; - back_buf = GFX_GetBackBuffer(); + back_buf = _vm->_gfx->getBackBuffer(); // Get game display info GAME_GetDisplayInfo(&g_di); @@ -356,7 +356,7 @@ int DrawStatusBar(R_SURFACE *ds) { rect.right = g_di.logical_w - 1; rect.bottom = IfModule.i_desc.status_y + IfModule.i_desc.status_h - 1; - GFX_DrawRect(ds, &rect, IfModule.i_desc.status_bgcol); + _vm->_gfx->drawRect(ds, &rect, IfModule.i_desc.status_bgcol); string_w = FONT_GetStringWidth(SMALL_FONT_ID, IfModule.status_txt, 0, 0); diff --git a/saga/isomap.cpp b/saga/isomap.cpp index 65f7b96e1e6..c3c7af94c81 100644 --- a/saga/isomap.cpp +++ b/saga/isomap.cpp @@ -25,7 +25,7 @@ #include "saga.h" #include "game_mod.h" -#include "gfx_mod.h" +#include "gfx.h" #include "isomap_mod.h" #include "isomap.h" @@ -138,7 +138,7 @@ int ISOMAP_Draw(R_SURFACE *dst_s) { R_GAME_DISPLAYINFO disp_info; GAME_GetDisplayInfo(&disp_info); R_RECT iso_rect(disp_info.logical_w - 1, disp_info.scene_h - 1); - GFX_DrawRect(dst_s, &iso_rect, 0); + _vm->_gfx->drawRect(dst_s, &iso_rect, 0); ISOMAP_DrawMetamap(dst_s, -1000, -500); return R_SUCCESS; diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp index 2055b19a502..b6783bbe388 100644 --- a/saga/ite_introproc.cpp +++ b/saga/ite_introproc.cpp @@ -25,7 +25,7 @@ // Intro sequence scene procedures #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "yslib.h" #include "animation.h" @@ -240,7 +240,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 - GFX_GetCurrentPal(current_pal); + _vm->_gfx->getCurrentPal(current_pal); event.type = R_CONTINUOUS_EVENT; event.code = R_PAL_EVENT; event.op = EVENT_PALTOBLACK; diff --git a/saga/objectmap.cpp b/saga/objectmap.cpp index dacb23af681..254c11a649e 100644 --- a/saga/objectmap.cpp +++ b/saga/objectmap.cpp @@ -28,7 +28,7 @@ // p. 24-46, code: p. 34-45 #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "cvar_mod.h" #include "console_mod.h" #include "font_mod.h" @@ -291,7 +291,7 @@ int OBJECTMAP_GetEPNum(int object, int *ep_num) { return R_FAILURE; } -// Uses GFX_DrawLine to display all clickareas for each object in the +// Uses Gfx::drawLine to display all clickareas for each object in the // currently loaded object map resource. int OBJECTMAP_Draw(R_SURFACE *ds, R_POINT *imouse_pt, int color, int color2) { R_OBJECTMAP_ENTRY *object_map; @@ -338,16 +338,17 @@ int OBJECTMAP_Draw(R_SURFACE *ds, R_POINT *imouse_pt, int color, int color2) { pointcount = 0; if (clickarea->n_points == 2) { // 2 points represent a box - GFX_DrawFrame(ds, &clickarea->points[0], &clickarea->points[1], draw_color); + _vm->_gfx->drawFrame(ds, &clickarea->points[0], &clickarea->points[1], draw_color); } else if (clickarea->n_points > 2) { // Otherwise draw a polyline - GFX_DrawPolyLine(ds, clickarea->points, clickarea->n_points, draw_color); + _vm->_gfx->drawPolyLine(ds, clickarea->points, clickarea->n_points, draw_color); } } } if (draw_txt) { - FONT_Draw(SMALL_FONT_ID, ds, txt_buf, 0, 2, 2, GFX_GetWhite(), GFX_GetBlack(), FONT_OUTLINE); + FONT_Draw(SMALL_FONT_ID, ds, txt_buf, 0, 2, 2, + _vm->_gfx->getWhite(), _vm->_gfx->getBlack(), FONT_OUTLINE); } return R_SUCCESS; diff --git a/saga/palanim.cpp b/saga/palanim.cpp index 085730d92c4..6cd8ee89e55 100644 --- a/saga/palanim.cpp +++ b/saga/palanim.cpp @@ -23,7 +23,7 @@ // Palette animation module #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "events_mod.h" #include "game_mod.h" @@ -146,8 +146,8 @@ int PALANIM_CycleStep(int vectortime) { return R_FAILURE; } - GFX_GetCurrentPal(pal); - back_buf = GFX_GetBackBuffer(); + _vm->_gfx->getCurrentPal(pal); + back_buf = _vm->_gfx->getBackBuffer(); for (i = 0; i < PAnimData.entry_count; i++) { cycle = PAnimData.entries[i].cycle; @@ -167,7 +167,7 @@ int PALANIM_CycleStep(int vectortime) { } } - GFX_SetPalette(back_buf, pal); + _vm->_gfx->setPalette(back_buf, pal); event.type = R_ONESHOT_EVENT; event.code = R_PALANIM_EVENT; diff --git a/saga/render.cpp b/saga/render.cpp index a1a2b76343e..6e67305667b 100644 --- a/saga/render.cpp +++ b/saga/render.cpp @@ -24,7 +24,7 @@ // Main rendering loop #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "timer.h" #include "actor_mod.h" #include "console_mod.h" @@ -56,9 +56,8 @@ Render::Render(SagaEngine *vm, OSystem *system) : _vm(vm), _system(system), _ini // Initialize system graphics GAME_GetDisplayInfo(&disp_info); - if (GFX_Init(system, disp_info.logical_w, disp_info.logical_h) != R_SUCCESS) { - return; - } + _vm->_gfx = new Gfx(system, disp_info.logical_w, disp_info.logical_h); + _gfx = _vm->_gfx; // Initialize FPS timer callback g_timer->installTimerProc(&fpsTimerCallback, 1000000, this); @@ -87,7 +86,7 @@ Render::Render(SagaEngine *vm, OSystem *system) : _vm(vm), _system(system), _ini _tmp_buf_w = tmp_w; _tmp_buf_h = tmp_h; - _backbuf_surface = GFX_GetBackBuffer(); + _backbuf_surface = _gfx->getBackBuffer(); _flags = 0; _initialized = true; @@ -135,8 +134,8 @@ int Render::drawScene() { // Display scene maps, if applicable if (getFlags() & RF_OBJECTMAP_TEST) { - OBJECTMAP_Draw(backbuf_surface, &mouse_pt, GFX_GetWhite(), GFX_GetBlack()); - _vm->_actionMap->draw(backbuf_surface, GFX_MatchColor(R_RGB_RED)); + OBJECTMAP_Draw(backbuf_surface, &mouse_pt, _gfx->getWhite(), _gfx->getBlack()); + _vm->_actionMap->draw(backbuf_surface, _gfx->matchColor(R_RGB_RED)); } // Draw queued actors @@ -155,7 +154,7 @@ int Render::drawScene() { sprintf(txt_buf, "%d", _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, - GFX_GetWhite(), GFX_GetBlack(), FONT_OUTLINE); + _gfx->getWhite(), _gfx->getBlack(), FONT_OUTLINE); } // Display "paused game" message, if applicable @@ -163,7 +162,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, GFX_GetWhite(), GFX_GetBlack(), FONT_OUTLINE); + (backbuf_surface->buf_w - msg_w) / 2, 90, _gfx->getWhite(), _gfx->getBlack(), FONT_OUTLINE); } // Update user interface @@ -173,12 +172,12 @@ int Render::drawScene() { // Display text formatting test, if applicable if (_flags & RF_TEXT_TEST) { TEXT_Draw(MEDIUM_FONT_ID, backbuf_surface, test_txt, mouse_pt.x, mouse_pt.y, - GFX_GetWhite(), GFX_GetBlack(), FONT_OUTLINE | FONT_CENTERED); + _gfx->getWhite(), _gfx->getBlack(), FONT_OUTLINE | FONT_CENTERED); } // Display palette test, if applicable if (_flags & RF_PALETTE_TEST) { - GFX_DrawPalette(backbuf_surface); + _gfx->drawPalette(backbuf_surface); } // Draw console diff --git a/saga/render.h b/saga/render.h index 8a6c78880a8..f3c37600659 100644 --- a/saga/render.h +++ b/saga/render.h @@ -70,6 +70,7 @@ private: SagaEngine *_vm; OSystem *_system; bool _initialized; + Gfx *_gfx; // Module data R_SURFACE *_backbuf_surface; diff --git a/saga/saga.h b/saga/saga.h index 1485f46ee16..f93edeabcfd 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -43,6 +43,7 @@ class Music; class Anim; class Render; class ActionMap; +class Gfx; using Common::MemoryReadStream; @@ -91,6 +92,7 @@ public: Anim *_anim; Render *_render; ActionMap *_actionMap; + Gfx *_gfx; private: int decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len); diff --git a/saga/scene.cpp b/saga/scene.cpp index 0e00aa9264b..55a40a0028e 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -25,7 +25,7 @@ #include "saga.h" #include "yslib.h" -#include "gfx_mod.h" +#include "gfx.h" #include "game_mod.h" #include "animation.h" #include "console_mod.h" @@ -731,7 +731,7 @@ int SCENE_Draw(R_SURFACE *dst_s) { switch (SceneModule.scene_mode) { case R_SCENE_MODE_NORMAL: - GFX_BufToSurface(dst_s, buf_info.r_bg_buf, disp_info.logical_w, + _vm->_gfx->bufToSurface(dst_s, buf_info.r_bg_buf, disp_info.logical_w, MAX(disp_info.scene_h, SceneModule.bg.h), NULL, &bg_pt); break; case R_SCENE_MODE_ISO: @@ -855,7 +855,7 @@ int initialScene(int param, R_SCENE_INFO *scene_info) { _vm->_sound->stopVoice(); // Fade palette to black from intro scene - GFX_GetCurrentPal(current_pal); + _vm->_gfx->getCurrentPal(current_pal); event.type = R_CONTINUOUS_EVENT; event.code = R_PAL_EVENT; diff --git a/saga/script.cpp b/saga/script.cpp index ba92d905c09..3f268771f04 100644 --- a/saga/script.cpp +++ b/saga/script.cpp @@ -25,7 +25,7 @@ #include "saga.h" #include "yslib.h" -#include "gfx_mod.h" +#include "gfx.h" #include "rscfile_mod.h" #include "game_mod.h" #include "text_mod.h" diff --git a/saga/sdata.cpp b/saga/sdata.cpp index 57a0595c146..3374c398bbb 100644 --- a/saga/sdata.cpp +++ b/saga/sdata.cpp @@ -23,7 +23,7 @@ // Type SDataWord_T must be unpadded #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "text_mod.h" #include "script_mod.h" #include "script.h" diff --git a/saga/sdebug.cpp b/saga/sdebug.cpp index 848d178b69f..c7d09fc7861 100644 --- a/saga/sdebug.cpp +++ b/saga/sdebug.cpp @@ -24,7 +24,7 @@ // Scripting module simple thread debugging support #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "actor_mod.h" #include "console_mod.h" #include "text_mod.h" diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp index fa592b32728..46a70974ada 100644 --- a/saga/sfuncs.cpp +++ b/saga/sfuncs.cpp @@ -25,7 +25,7 @@ #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "actor_mod.h" #include "animation.h" #include "console_mod.h" diff --git a/saga/sprite.cpp b/saga/sprite.cpp index db7e47e5fdf..4bb600de0b6 100644 --- a/saga/sprite.cpp +++ b/saga/sprite.cpp @@ -25,7 +25,7 @@ #include "saga.h" #include "game_mod.h" -#include "gfx_mod.h" +#include "gfx.h" #include "scene_mod.h" #include "rscfile_mod.h" @@ -360,7 +360,7 @@ int SPRITE_DrawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num ci.src_rect = &spr_src_rect; ci.dst_pt = &spr_pt; - GFX_GetClipInfo(&ci); + _vm->_gfx->getClipInfo(&ci); if (ci.nodraw) { return R_SUCCESS; diff --git a/saga/sstack.cpp b/saga/sstack.cpp index 4d83340d035..aa8c04474b8 100644 --- a/saga/sstack.cpp +++ b/saga/sstack.cpp @@ -25,7 +25,7 @@ #include "saga.h" -#include "gfx_mod.h" +#include "gfx.h" #include "console_mod.h" #include "text_mod.h" diff --git a/saga/sthread.cpp b/saga/sthread.cpp index c7ff22d91f5..fdd633589b8 100644 --- a/saga/sthread.cpp +++ b/saga/sthread.cpp @@ -26,7 +26,7 @@ #include "yslib.h" -#include "gfx_mod.h" +#include "gfx.h" #include "actor_mod.h" #include "console_mod.h" #include "text_mod.h" diff --git a/saga/text.cpp b/saga/text.cpp index 415a325692f..7131463d3f6 100644 --- a/saga/text.cpp +++ b/saga/text.cpp @@ -26,7 +26,7 @@ #include "saga.h" #include "yslib.h" -#include "gfx_mod.h" +#include "gfx.h" #include "font_mod.h" #include "text_mod.h"