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 /saga/render.cpp | |
parent | b7a1956382ef349ccc3a41ac844f449de810a16c (diff) | |
download | scummvm-rg350-4b5e78b7747b0af51f4c128afcb4f81f4f320a55.tar.gz scummvm-rg350-4b5e78b7747b0af51f4c128afcb4f81f4f320a55.tar.bz2 scummvm-rg350-4b5e78b7747b0af51f4c128afcb4f81f4f320a55.zip |
indent
svn-id: r13695
Diffstat (limited to 'saga/render.cpp')
-rw-r--r-- | saga/render.cpp | 283 |
1 files changed, 61 insertions, 222 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; |