diff options
author | Paweł Kołodziejski | 2004-05-01 07:50:08 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2004-05-01 07:50:08 +0000 |
commit | 4b5e78b7747b0af51f4c128afcb4f81f4f320a55 (patch) | |
tree | d2a06976890113402a4c640d0d53b9ef6377a779 | |
parent | b7a1956382ef349ccc3a41ac844f449de810a16c (diff) | |
download | scummvm-rg350-4b5e78b7747b0af51f4c128afcb4f81f4f320a55.tar.gz scummvm-rg350-4b5e78b7747b0af51f4c128afcb4f81f4f320a55.tar.bz2 scummvm-rg350-4b5e78b7747b0af51f4c128afcb4f81f4f320a55.zip |
indent
svn-id: r13695
-rw-r--r-- | saga/render.cpp | 283 | ||||
-rw-r--r-- | saga/render.h | 19 | ||||
-rw-r--r-- | saga/render_mod.h | 31 |
3 files changed, 72 insertions, 261 deletions
diff --git a/saga/render.cpp b/saga/render.cpp index bae8b25360..1d9aeb8fb6 100644 --- a/saga/render.cpp +++ b/saga/render.cpp @@ -20,25 +20,16 @@ * $Header$ * */ -/* - Description: - - Main rendering loop - Notes: -*/ +// Main rendering loop #include "reinherit.h" #include "systimer.h" - #include "yslib.h" #include <SDL.h> -/* - * Uses the following modules: -\*--------------------------------------------------------------------------*/ #include "actor_mod.h" #include "console_mod.h" #include "cvar_mod.h" @@ -53,9 +44,6 @@ #include "actionmap_mod.h" #include "objectmap_mod.h" -/* - * Begin module -\*--------------------------------------------------------------------------*/ #include "render_mod.h" #include "render.h" @@ -63,70 +51,54 @@ namespace Saga { static R_RENDER_MODULE RenderModule; -const char *test_txt = "The quick brown fox jumped over the lazy dog. " - "She sells sea shells down by the sea shore."; - -int RENDER_Register(void) -{ +const char *test_txt = "The quick brown fox jumped over the lazy dog. She sells sea shells down by the sea shore."; - /* Register "r_fullscreen" cfg cvar - * \*----------------------------------------- */ +int RENDER_Register() { + // Register "r_fullscreen" cfg cvar RenderModule.r_fullscreen = R_FULLSCREEN_DEFAULT; if (CVAR_Register_I(&RenderModule.r_fullscreen, "r_fullscreen", NULL, R_CVAR_CFG, 0, 1) != R_SUCCESS) { - return R_FAILURE; } - /* Register "r_doubleres" cfg cvar - * \*----------------------------------------- */ + // Register "r_doubleres" cfg cvar RenderModule.r_doubleres = R_DOUBLERES_DEFAULT; if (CVAR_Register_I(&RenderModule.r_doubleres, "r_doubleres", NULL, R_CVAR_CFG, 0, 1) != R_SUCCESS) { - return R_FAILURE; } - /* Register "r_hicolor" cfg cvar - * \*----------------------------------------- */ + // Register "r_hicolor" cfg cvar RenderModule.r_hicolor = R_HICOLOR_DEFAULT; if (CVAR_Register_I(&RenderModule.r_hicolor, "r_hicolor", NULL, R_CVAR_CFG, 0, 1) != R_SUCCESS) { - return R_FAILURE; } - /* Register "r_softcursor" cfg cvar - * \*----------------------------------------- */ + // Register "r_softcursor" cfg cvar RenderModule.r_softcursor = R_SOFTCURSOR_DEFAULT; if (CVAR_Register_I(&RenderModule.r_softcursor, "r_softcursor", NULL, R_CVAR_CFG, 0, 1) != R_SUCCESS) { - return R_FAILURE; } return R_SUCCESS; } -int RENDER_Init(void) -{ - +int RENDER_Init() { R_GAME_DISPLAYINFO disp_info; R_SYSGFX_INIT gfx_init; - int result; - int tmp_w, tmp_h, tmp_bytepp; - /* Initialize system graphics - * \*------------------------------------------------------------- */ + // Initialize system graphics GAME_GetDisplayInfo(&disp_info); - gfx_init.backbuf_bpp = 8; /* all games are 8 bpp so far */ + 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; @@ -139,14 +111,13 @@ int RENDER_Init(void) gfx_init.screen_w = disp_info.logical_w; gfx_init.screen_h = disp_info.logical_h; - /* Don't try to double a game exceeding the resolution limit - * (640x480 would get doubled to 1280 x 960!) */ + // Don't try to double a game exceeding the resolution limit + // (640x480 would get doubled to 1280 x 960!) */ if (disp_info.logical_w > R_DOUBLE_RESLIMIT) { RenderModule.r_doubleres = 0; } if (RenderModule.r_doubleres) { - gfx_init.screen_w *= 2; gfx_init.screen_h *= 2; } @@ -154,35 +125,28 @@ int RENDER_Init(void) gfx_init.fullscreen = RenderModule.r_fullscreen; if (SYSGFX_Init(&gfx_init) != R_SUCCESS) { - return R_FAILURE; } - /* Initialize FPS timer callback - * \*------------------------------------------------------------- */ - result = SYSTIMER_CreateTimer(&RenderModule.r_fps_timer, - 1000, NULL, RENDER_FpsTimer); + // Initialize FPS timer callback + result = SYSTIMER_CreateTimer(&RenderModule.r_fps_timer, 1000, NULL, RENDER_FpsTimer); if (result != R_SUCCESS) { return R_FAILURE; } - /* Create background buffer - * \*------------------------------------------------------------- */ + // Create background buffer RenderModule.r_bg_buf_w = disp_info.logical_w; RenderModule.r_bg_buf_h = disp_info.logical_h; - - RenderModule.r_bg_buf = (byte *)calloc(disp_info.logical_w, - disp_info.logical_h); + RenderModule.r_bg_buf = (byte *)calloc(disp_info.logical_w, disp_info.logical_h); if (RenderModule.r_bg_buf == NULL) { return R_MEM; } - /* Allocate temp buffer for animation decoding, - * graphics scalers (2xSaI), etc. - \*-------------------------------------------------------------*/ + // Allocate temp buffer for animation decoding, + // graphics scalers (2xSaI), etc. tmp_w = disp_info.logical_w; - tmp_h = disp_info.logical_h + 4; /* BG unbanking requres extra rows */ + tmp_h = disp_info.logical_h + 4; // BG unbanking requres extra rows tmp_bytepp = 1; if (RenderModule.r_doubleres) { @@ -207,8 +171,7 @@ int RENDER_Init(void) RenderModule.r_screen_surface = SYSGFX_GetScreenSurface(); RenderModule.r_backbuf_surface = SYSGFX_GetBackBuffer(); - /* Initialize cursor state - * \*------------------------------------------------------------- */ + // Initialize cursor state if (RenderModule.r_softcursor) { SYSINPUT_HideMouse(); } @@ -218,25 +181,18 @@ int RENDER_Init(void) return R_SUCCESS; } -int RENDER_DrawScene(void) -{ - +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; - R_POINT bg_pt; - char txt_buf[20]; int fps_width; - R_POINT mouse_pt; int mouse_x, mouse_y; - int surface_converted = 0; if (!RenderModule.initialized) { @@ -248,8 +204,7 @@ int RENDER_DrawScene(void) screen_surface = RenderModule.r_screen_surface; backbuf_surface = RenderModule.r_backbuf_surface; - /* Get mouse coordinates - * \*------------------------------------------------------------- */ + // Get mouse coordinates SYSINPUT_GetMousePos(&mouse_x, &mouse_y); mouse_pt.x = mouse_x; @@ -265,115 +220,62 @@ int RENDER_DrawScene(void) bg_pt.x = 0; bg_pt.y = 0; - /* Display scene background - * \*--------------------------------------------------------- */ + // Display scene background SCENE_Draw(backbuf_surface); - /* Display scene maps, if applicable - * \*--------------------------------------------------------- */ + // Display scene maps, if applicable if (RENDER_GetFlags() & RF_OBJECTMAP_TEST) { - - OBJECTMAP_Draw(backbuf_surface, - &mouse_pt, SYSGFX_GetWhite(), SYSGFX_GetBlack()); - + OBJECTMAP_Draw(backbuf_surface, &mouse_pt, SYSGFX_GetWhite(), SYSGFX_GetBlack()); ACTIONMAP_Draw(backbuf_surface, SYSGFX_MatchColor(R_RGB_RED)); } - /* Draw queued actors - * \*--------------------------------------------------------- */ + // Draw queued actors ACTOR_DrawList(); - /* Draw queued text strings - * \*--------------------------------------------------------- */ + // Draw queued text strings SCENE_GetInfo(&scene_info); TEXT_DrawList(scene_info.text_list, backbuf_surface); - /* Handle user input - * \*--------------------------------------------------------- */ + // Handle user input SYSINPUT_ProcessInput(); - /* Display rendering information - * \*--------------------------------------------------------- */ + // Display rendering information if (RenderModule.r_flags & RF_SHOW_FPS) { - 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); - + 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); switch (RenderModule.r_mode) { - case RM_SCANLINES: - FONT_Draw(SMALL_FONT_ID, - backbuf_surface, - "Scanlines", - 0, - 2, 2, - SYSGFX_GetWhite(), - SYSGFX_GetBlack(), FONT_OUTLINE); + FONT_Draw(SMALL_FONT_ID, backbuf_surface, "Scanlines", 0, 2, 2, + SYSGFX_GetWhite(), SYSGFX_GetBlack(), FONT_OUTLINE); break; - case RM_2XSAI: - FONT_Draw(SMALL_FONT_ID, - backbuf_surface, - "2xSaI", - 0, - 2, 2, - SYSGFX_GetWhite(), - SYSGFX_GetBlack(), FONT_OUTLINE); + FONT_Draw(SMALL_FONT_ID, backbuf_surface, "2xSaI", 0, 2, 2, + SYSGFX_GetWhite(), SYSGFX_GetBlack(), FONT_OUTLINE); break; - case RM_SUPER2XSAI: - FONT_Draw(SMALL_FONT_ID, - backbuf_surface, - "Super2xSaI", - 0, - 2, 2, - SYSGFX_GetWhite(), - SYSGFX_GetBlack(), FONT_OUTLINE); + FONT_Draw(SMALL_FONT_ID, backbuf_surface, "Super2xSaI", 0, 2, 2, + SYSGFX_GetWhite(), SYSGFX_GetBlack(), FONT_OUTLINE); break; - case RM_SUPEREAGLE: - FONT_Draw(SMALL_FONT_ID, - backbuf_surface, - "SuperEagle", - 0, - 2, 2, - SYSGFX_GetWhite(), - SYSGFX_GetBlack(), FONT_OUTLINE); + FONT_Draw(SMALL_FONT_ID, backbuf_surface, "SuperEagle", 0, 2, 2, + SYSGFX_GetWhite(), SYSGFX_GetBlack(), FONT_OUTLINE); break; } } - /* Display "paused game" message, if applicable - * \*--------------------------------------------------------- */ + // Display "paused game" message, if applicable if (RenderModule.r_flags & RF_RENDERPAUSE) { - 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); + 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); } - /* Update user interface - * \*--------------------------------------------------------- */ + // Update user interface INTERFACE_Update(&mouse_pt, UPDATE_MOUSEMOVE); @@ -381,46 +283,29 @@ int RENDER_DrawScene(void) GFX_DrawCursor(backbuf_surface, &mouse_pt); } - /* Display text formatting test, if applicable - * \*--------------------------------------------------------- */ + // 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); + TEXT_Draw(MEDIUM_FONT_ID, backbuf_surface, test_txt, mouse_pt.x, mouse_pt.y, + SYSGFX_GetWhite(), SYSGFX_GetBlack(), FONT_OUTLINE | FONT_CENTERED); } - /* Display palette test, if applicable - * \*--------------------------------------------------------- */ + // Display palette test, if applicable if (RenderModule.r_flags & RF_PALETTE_TEST) { - GFX_DrawPalette(backbuf_surface); } - /* Draw console - * \*--------------------------------------------------------- */ + // Draw console CON_Draw(backbuf_surface); - /* Display the current frame - * \*--------------------------------------------------------- */ - + // Display the current frame if (RenderModule.r_hicolor) { - display_surface = SYSGFX_FormatToDisplay(backbuf_surface); - if (display_surface == NULL) { - R_printf(R_STDERR, - "Error: Back buffer conversion failed!\n"); - + R_printf(R_STDERR, "Error: Back buffer conversion failed!\n"); return R_FAILURE; } - surface_converted = 1; } else { - display_surface = backbuf_surface; } @@ -428,21 +313,14 @@ int RENDER_DrawScene(void) SYSGFX_LockSurface(display_surface); switch (RenderModule.r_mode) { - case RM_SCANLINES: - break; - default: - if (RenderModule.r_doubleres) { - GFX_Scale2x(screen_surface, display_surface); } else { - GFX_SimpleBlit(screen_surface, display_surface); } - break; } @@ -450,7 +328,6 @@ int RENDER_DrawScene(void) SYSGFX_UnlockSurface(screen_surface); if (surface_converted) { - SYSGFX_DestroySurface(display_surface); } @@ -460,14 +337,11 @@ int RENDER_DrawScene(void) return R_SUCCESS; } -unsigned int RENDER_GetFrameCount(void) -{ - +unsigned int RENDER_GetFrameCount() { return RenderModule.r_framecount; } -unsigned int RENDER_ResetFrameCount(void) -{ +unsigned int RENDER_ResetFrameCount() { unsigned int framecount = RenderModule.r_framecount; RenderModule.r_framecount = 0; @@ -475,8 +349,7 @@ unsigned int RENDER_ResetFrameCount(void) return framecount; } -void RENDER_FpsTimer(unsigned long interval, void *param) -{ +void RENDER_FpsTimer(unsigned long interval, void *param) { YS_IGNORE_PARAM(interval); YS_IGNORE_PARAM(param); @@ -486,8 +359,7 @@ void RENDER_FpsTimer(unsigned long interval, void *param) return; } -void RENDER_ConvertMousePt(R_POINT * mouse_pt) -{ +void RENDER_ConvertMousePt(R_POINT *mouse_pt) { assert(mouse_pt != NULL); if (RenderModule.r_doubleres) { @@ -495,75 +367,44 @@ void RENDER_ConvertMousePt(R_POINT * mouse_pt) mouse_pt->x /= 2; mouse_pt->y /= 2; } - - return; } -unsigned int RENDER_GetFlags(void) -{ +unsigned int RENDER_GetFlags() { return RenderModule.r_flags; } -void RENDER_SetFlag(unsigned int flag) -{ - +void RENDER_SetFlag(unsigned int flag) { RenderModule.r_flags |= flag; - - return; } -void RENDER_ToggleFlag(unsigned int flag) -{ - +void RENDER_ToggleFlag(unsigned int flag) { RenderModule.r_flags ^= flag; - - return; } -int RENDER_SetMode(int mode) -{ - +int RENDER_SetMode(int mode) { switch (mode) { - case RM_SCANLINES: - if (!RenderModule.r_doubleres) { - return R_FAILURE; } - break; - case RM_2XSAI: - if (!RenderModule.r_doubleres || !RenderModule.r_hicolor) { - return R_FAILURE; } - break; - case RM_SUPER2XSAI: - if (!RenderModule.r_doubleres || !RenderModule.r_hicolor) { - return R_FAILURE; } - break; - case RM_SUPEREAGLE: - if (!RenderModule.r_doubleres || !RenderModule.r_hicolor) { - return R_FAILURE; } - break; - default: break; - } RenderModule.r_mode = mode; @@ -571,9 +412,7 @@ int RENDER_SetMode(int mode) return R_SUCCESS; } -int RENDER_GetBufferInfo(R_BUFFER_INFO * r_bufinfo) -{ - +int RENDER_GetBufferInfo(R_BUFFER_INFO *r_bufinfo) { assert(r_bufinfo != NULL); r_bufinfo->r_bg_buf = RenderModule.r_bg_buf; diff --git a/saga/render.h b/saga/render.h index 4b30e14705..1288c2fbdf 100644 --- a/saga/render.h +++ b/saga/render.h @@ -20,20 +20,15 @@ * $Header$ * */ -/* - Description: - - Main rendering loop - private header - Notes: -*/ +// Main rendering loop - private header #ifndef SAGA_RENDER_H_ #define SAGA_RENDER_H_ namespace Saga { -/* Render module CVAR defaults */ +// Render module CVAR defaults #define R_FULLSCREEN_DEFAULT 0 #define R_DOUBLERES_DEFAULT 1 #define R_HICOLOR_DEFAULT 1 @@ -44,16 +39,15 @@ namespace Saga { #define R_PAUSEGAME_MSG "PAWS GAME" struct R_RENDER_MODULE { - int initialized; - /* Init cvars */ + // Init cvars int r_fullscreen; int r_doubleres; int r_hicolor; int r_softcursor; - /* Module data */ + // Module data R_SURFACE *r_screen_surface; R_SURFACE *r_display_surface; R_SURFACE *r_backbuf_surface; @@ -61,7 +55,6 @@ struct R_RENDER_MODULE { byte *r_bg_buf; int r_bg_buf_w; int r_bg_buf_h; - byte *r_tmp_buf; int r_tmp_buf_w; int r_tmp_buf_h; @@ -71,14 +64,12 @@ struct R_RENDER_MODULE { unsigned int r_fps; unsigned int r_framecount; - unsigned int r_flags; int r_mode; - }; void RENDER_FpsTimer(unsigned long interval, void *param); } // End of namespace Saga -#endif /* SAGA_RENDER_H_ */ +#endif diff --git a/saga/render_mod.h b/saga/render_mod.h index 25ca125e96..a6e4c90d41 100644 --- a/saga/render_mod.h +++ b/saga/render_mod.h @@ -20,13 +20,8 @@ * $Header$ * */ -/* - Description: - - Main rendering loop - public header - Notes: -*/ +// Main rendering loop - public header #ifndef SAGA_RENDER_MOD_H__ #define SAGA_RENDER_MOD_H__ @@ -34,7 +29,6 @@ namespace Saga { enum RENDER_FLAGS { - RF_SHOW_FPS = 0x01, RF_PALETTE_TEST = 0x02, RF_TEXT_TEST = 0x04, @@ -54,39 +48,26 @@ enum RENDER_MODES { }; struct R_BUFFER_INFO { - byte *r_bg_buf; int r_bg_buf_w; int r_bg_buf_h; - byte *r_tmp_buf; int r_tmp_buf_w; int r_tmp_buf_h; - }; -int RENDER_Register(void); - -int RENDER_Init(void); - -int RENDER_DrawScene(void); - +int RENDER_Register(); +int RENDER_Init(); +int RENDER_DrawScene(); void RENDER_ConvertMousePt(R_POINT *); - -unsigned int RENDER_GetFlags(void); - +unsigned int RENDER_GetFlags(); void RENDER_SetFlag(unsigned int); - void RENDER_ToggleFlag(unsigned int); - int RENDER_SetMode(int); - unsigned int RENDER_GetFrameCount(void); - unsigned int RENDER_ResetFrameCount(void); - int RENDER_GetBufferInfo(R_BUFFER_INFO *); } // End of namespace Saga -#endif /* SAGA_RENDER_MOD_H__ */ +#endif |