From 9dc5fe2a1dc4196d5785b484bfb1a96d33d732e8 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 28 Sep 2002 16:19:28 +0000 Subject: cleaned up various variable names in the SDL backend & NewGui; also fixed a small buglet that could cause garbage to appear behind the mouse cursor when closing NewGui while inside a game svn-id: r5029 --- backends/sdl/sdl-common.cpp | 208 +++++++++++++++++++++---------------------- backends/sdl/sdl-common.h | 65 +++++++------- backends/sdl/sdl.cpp | 211 +++++++++++++++++++++----------------------- backends/sdl/sdl_gl.cpp | 44 ++++----- gui/newgui.cpp | 41 +++++---- gui/newgui.h | 5 +- 6 files changed, 284 insertions(+), 290 deletions(-) diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index 45c25acdd0..d77d63c091 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -70,33 +70,33 @@ void OSystem_SDL_Common::set_timer(int timer, int (*callback)(int)) { } OSystem_SDL_Common::OSystem_SDL_Common() - : sdl_screen(0), cdrom(0), SCREEN_WIDTH(0), SCREEN_HEIGHT(0), - _dirty_checksums(0), _current_shake_pos(0), _new_shake_pos(0) + : _screen(0), _screenWidth(0), _screenHeight(0), _cdrom(0), + _dirty_checksums(0), _currentShakePos(0), _newShakePos(0) { // allocate palette storage - _cur_pal = (SDL_Color*)calloc(sizeof(SDL_Color), 256); + _currentPalette = (SDL_Color*)calloc(sizeof(SDL_Color), 256); // allocate the dirty rect storage - _mouse_backup = (byte*)malloc(MAX_MOUSE_W * MAX_MOUSE_H * MAX_SCALING * 2); + _mouseBackup = (byte*)malloc(MAX_MOUSE_W * MAX_MOUSE_H * MAX_SCALING * 2); } OSystem_SDL_Common::~OSystem_SDL_Common() { if (_dirty_checksums) free(_dirty_checksums); - free(_cur_pal); - free(_mouse_backup); + free(_currentPalette); + free(_mouseBackup); } void OSystem_SDL_Common::init_size(uint w, uint h) { // Avoid redundant res changes - if ((int)w == SCREEN_WIDTH && (int)h == SCREEN_HEIGHT) + if ((int)w == _screenWidth && (int)h == _screenHeight) return; - SCREEN_WIDTH = w; - SCREEN_HEIGHT = h; - CKSUM_NUM = (SCREEN_WIDTH*SCREEN_HEIGHT/(8*8)); + _screenWidth = w; + _screenHeight = h; + CKSUM_NUM = (_screenWidth*_screenHeight/(8*8)); if (_dirty_checksums) free(_dirty_checksums); _dirty_checksums = (uint32*)calloc(CKSUM_NUM*2, sizeof(uint32)); @@ -113,10 +113,10 @@ void OSystem_SDL_Common::init_size(uint w, uint h) { } void OSystem_SDL_Common::copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) { - if (sdl_screen == NULL) + if (_screen == NULL) return; - if (pitch == SCREEN_WIDTH && x==0 && y==0 && w==SCREEN_WIDTH && h==SCREEN_HEIGHT && _mode_flags&DF_WANT_RECT_OPTIM) { + if (pitch == _screenWidth && x==0 && y==0 && w==_screenWidth && h==_screenHeight && _mode_flags&DF_WANT_RECT_OPTIM) { /* Special, optimized case for full screen updates. * It tries to determine what areas were actually changed, * and just updates those, on the actual display. */ @@ -125,8 +125,8 @@ void OSystem_SDL_Common::copy_rect(const byte *buf, int pitch, int x, int y, int /* Clip the coordinates */ if (x < 0) { w+=x; buf-=x; x = 0; } if (y < 0) { h+=y; buf-=y*pitch; y = 0; } - if (w > SCREEN_WIDTH-x) { w = SCREEN_WIDTH - x; } - if (h > SCREEN_HEIGHT-y) { h = SCREEN_HEIGHT - y; } + if (w > _screenWidth-x) { w = _screenWidth - x; } + if (h > _screenHeight-y) { h = _screenHeight - y; } if (w <= 0 || h <= 0) return; @@ -136,20 +136,20 @@ void OSystem_SDL_Common::copy_rect(const byte *buf, int pitch, int x, int y, int } /* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */ - if (_mouse_drawn) + if (_mouseDrawn) undraw_mouse(); - if (SDL_LockSurface(sdl_screen) == -1) + if (SDL_LockSurface(_screen) == -1) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - byte *dst = (byte *)sdl_screen->pixels + y * SCREEN_WIDTH + x; + byte *dst = (byte *)_screen->pixels + y * _screenWidth + x; do { memcpy(dst, buf, w); - dst += SCREEN_WIDTH; + dst += _screenWidth; buf += pitch; } while (--h); - SDL_UnlockSurface(sdl_screen); + SDL_UnlockSurface(_screen); } @@ -164,25 +164,25 @@ void OSystem_SDL_Common::move_screen(int dx, int dy, int height) { // move down // copy from bottom to top for (int y = height - 1; y >= dy; y--) - copy_rect((byte *)sdl_screen->pixels + SCREEN_WIDTH * (y - dy), SCREEN_WIDTH, 0, y, SCREEN_WIDTH, 1); + copy_rect((byte *)_screen->pixels + _screenWidth * (y - dy), _screenWidth, 0, y, _screenWidth, 1); } else { // move up // copy from top to bottom for (int y = 0; y < height + dx; y++) - copy_rect((byte *)sdl_screen->pixels + SCREEN_WIDTH * (y - dy), SCREEN_WIDTH, 0, y, SCREEN_WIDTH, 1); + copy_rect((byte *)_screen->pixels + _screenWidth * (y - dy), _screenWidth, 0, y, _screenWidth, 1); } } else if (dy == 0) { // horizontal movement if (dx > 0) { // move right // copy from right to left - for (int x = SCREEN_WIDTH - 1; x >= dx; x--) - copy_rect((byte *)sdl_screen->pixels + x - dx, SCREEN_WIDTH, x, 0, 1, height); + for (int x = _screenWidth - 1; x >= dx; x--) + copy_rect((byte *)_screen->pixels + x - dx, _screenWidth, x, 0, 1, height); } else { // move left // copy from left to right - for (int x = 0; x < SCREEN_WIDTH; x++) - copy_rect((byte *)sdl_screen->pixels + x - dx, SCREEN_WIDTH, x, 0, 1, height); + for (int x = 0; x < _screenWidth; x++) + copy_rect((byte *)_screen->pixels + x - dx, _screenWidth, x, 0, 1, height); } } else { // free movement @@ -191,16 +191,16 @@ void OSystem_SDL_Common::move_screen(int dx, int dy, int height) { } void OSystem_SDL_Common::add_dirty_rect(int x, int y, int w, int h) { - if (force_full) + if (_forceFull) return; - if (num_dirty_rects == NUM_DIRTY_RECT) - force_full = true; + if (_num_dirty_rects == NUM_DIRTY_RECT) + _forceFull = true; else { - SDL_Rect *r = &_dirty_rect_list[num_dirty_rects++]; + SDL_Rect *r = &_dirty_rect_list[_num_dirty_rects++]; - /* Update the dirty region by 1 pixel for graphics drivers - * that "smear" the screen */ + // Extend the dirty region by 1 pixel for scalers + // that "smear" the screen, e.g. 2xSAI if (_mode_flags & DF_UPDATE_EXPAND_1_PIXEL) { x--; y--; @@ -208,11 +208,11 @@ void OSystem_SDL_Common::add_dirty_rect(int x, int y, int w, int h) { h+=2; } - /* clip */ + // clip if (x < 0) { w+=x; x=0; } if (y < 0) { h+=y; y=0; } - if (w > SCREEN_WIDTH-x) { w = SCREEN_WIDTH - x; } - if (h > SCREEN_HEIGHT-y) { h = SCREEN_HEIGHT - y; } + if (w > _screenWidth-x) { w = _screenWidth - x; } + if (h > _screenHeight-y) { h = _screenHeight - y; } r->x = x; r->y = y; @@ -222,16 +222,16 @@ void OSystem_SDL_Common::add_dirty_rect(int x, int y, int w, int h) { } #define ROL(a,n) a = (a<<(n)) | (a>>(32-(n))) -#define DOLINE(x) a ^= ((uint32*)buf)[0+(x)*(SCREEN_WIDTH/4)]; b ^= ((uint32*)buf)[1+(x)*(SCREEN_WIDTH/4)] +#define DOLINE(x) a ^= ((uint32*)buf)[0+(x)*(_screenWidth/4)]; b ^= ((uint32*)buf)[1+(x)*(_screenWidth/4)] void OSystem_SDL_Common::mk_checksums(const byte *buf) { uint32 *sums = _dirty_checksums; uint x,y; - const uint last_x = (uint)SCREEN_WIDTH/8; - const uint last_y = (uint)SCREEN_HEIGHT/8; + const uint last_x = (uint)_screenWidth/8; + const uint last_y = (uint)_screenHeight/8; /* the 8x8 blocks in buf are enumerated starting in the top left corner and * reading each line at a time from left to right */ - for(y=0; y != last_y; y++, buf+=SCREEN_WIDTH*(8-1)) + for(y=0; y != last_y; y++, buf+=_screenWidth*(8-1)) for(x=0; x != last_x; x++, buf+=8) { uint32 a = x; uint32 b = y; @@ -264,19 +264,19 @@ void OSystem_SDL_Common::add_dirty_rgn_auto(const byte *buf) { mk_checksums(buf); if (!cksum_valid) { - force_full = true; + _forceFull = true; cksum_valid = true; } /* go through the checksum list, compare it with the previous checksums, and add all dirty rectangles to a list. try to combine small rectangles into bigger ones in a simple way */ - if (!force_full) { + if (!_forceFull) { int x,y,w; uint32 *ck = _dirty_checksums; - for(y=0; y!=SCREEN_HEIGHT/8; y++) { - for(x=0; x!=SCREEN_WIDTH/8; x++,ck++) { + for(y=0; y!=_screenHeight/8; y++) { + for(x=0; x!=_screenWidth/8; x++,ck++) { if (ck[0] != ck[CKSUM_NUM]) { /* found a dirty 8x8 block, now go as far to the right as possible, and at the same time, unmark the dirty status by setting old to new. */ @@ -284,11 +284,11 @@ void OSystem_SDL_Common::add_dirty_rgn_auto(const byte *buf) { do { ck[w+CKSUM_NUM] = ck[w]; w++; - } while (x+w != SCREEN_WIDTH/8 && ck[w] != ck[w+CKSUM_NUM]); + } while (x+w != _screenWidth/8 && ck[w] != ck[w+CKSUM_NUM]); add_dirty_rect(x*8, y*8, w*8, 8); - if (force_full) + if (_forceFull) goto get_out; } } @@ -370,11 +370,11 @@ void OSystem_SDL_Common::kbd_mouse() { } bool OSystem_SDL_Common::show_mouse(bool visible) { - if (_mouse_visible == visible) + if (_mouseVisible == visible) return visible; - bool last = _mouse_visible; - _mouse_visible = visible; + bool last = _mouseVisible; + _mouseVisible = visible; if (visible) draw_mouse(); @@ -396,16 +396,16 @@ void OSystem_SDL_Common::set_mouse_cursor(const byte *buf, uint w, uint h, int h _mouse_cur_state.w = w; _mouse_cur_state.h = h; - _mouse_hotspot_x = hotspot_x; - _mouse_hotspot_y = hotspot_y; + _mouseHotspotX = hotspot_x; + _mouseHotspotY = hotspot_y; - _mouse_data = (byte*)buf; + _mouseData = (byte*)buf; undraw_mouse(); } void OSystem_SDL_Common::set_shake_pos(int shake_pos) { - _new_shake_pos = shake_pos; + _newShakePos = shake_pos; } uint32 OSystem_SDL_Common::get_msecs() { @@ -581,8 +581,8 @@ bool OSystem_SDL_Common::poll_event(Event *event) { km.x = event->mouse.x = ev.motion.x; km.y = event->mouse.y = ev.motion.y; - event->mouse.x /= scaling; - event->mouse.y /= scaling; + event->mouse.x /= _scaleFactor; + event->mouse.y /= _scaleFactor; return true; @@ -595,8 +595,8 @@ bool OSystem_SDL_Common::poll_event(Event *event) { break; km.x = event->mouse.x = ev.motion.x; km.y = event->mouse.y = ev.motion.y; - event->mouse.x /= scaling; - event->mouse.y /= scaling; + event->mouse.x /= _scaleFactor; + event->mouse.y /= _scaleFactor; return true; @@ -609,8 +609,8 @@ bool OSystem_SDL_Common::poll_event(Event *event) { break; event->mouse.x = ev.button.x; event->mouse.y = ev.button.y; - event->mouse.x /= scaling; - event->mouse.y /= scaling; + event->mouse.x /= _scaleFactor; + event->mouse.y /= _scaleFactor; return true; case SDL_QUIT: @@ -643,12 +643,12 @@ void OSystem_SDL_Common::get_320x200_image(byte *buf) { /* make sure the mouse is gone */ undraw_mouse(); - if (SDL_LockSurface(sdl_screen) == -1) + if (SDL_LockSurface(_screen) == -1) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - memcpy(buf, sdl_screen->pixels, SCREEN_WIDTH*SCREEN_HEIGHT); + memcpy(buf, _screen->pixels, _screenWidth*_screenHeight); - SDL_UnlockSurface(sdl_screen); + SDL_UnlockSurface(_screen); } uint32 OSystem_SDL_Common::property(int param, Property *value) { @@ -663,11 +663,11 @@ uint32 OSystem_SDL_Common::property(int param, Property *value) { case PROP_OPEN_CD: if (SDL_InitSubSystem(SDL_INIT_CDROM) == -1) - cdrom = NULL; + _cdrom = NULL; else { - cdrom = SDL_CDOpen(value->cd_num); - /* Did if open? Check if cdrom is NULL */ - if (!cdrom) { + _cdrom = SDL_CDOpen(value->cd_num); + /* Did if open? Check if _cdrom is NULL */ + if (!_cdrom) { warning("Couldn't open drive: %s\n", SDL_GetError()); } } @@ -694,25 +694,25 @@ uint32 OSystem_SDL_Common::property(int param, Property *value) { } void OSystem_SDL_Common::quit() { - if(cdrom) { - SDL_CDStop(cdrom); - SDL_CDClose(cdrom); + if(_cdrom) { + SDL_CDStop(_cdrom); + SDL_CDClose(_cdrom); } unload_gfx_mode(); exit(0); } void OSystem_SDL_Common::draw_mouse() { - if (_mouse_drawn || !_mouse_visible) + if (_mouseDrawn || !_mouseVisible) return; - int x = _mouse_cur_state.x - _mouse_hotspot_x; - int y = _mouse_cur_state.y - _mouse_hotspot_y; + int x = _mouse_cur_state.x - _mouseHotspotX; + int y = _mouse_cur_state.y - _mouseHotspotY; int w = _mouse_cur_state.w; int h = _mouse_cur_state.h; byte color; - byte *src = _mouse_data; // Image representing the mouse - byte *bak = _mouse_backup; // Surface used to backup the area obscured by the mouse + byte *src = _mouseData; // Image representing the mouse + byte *bak = _mouseBackup; // Surface used to backup the area obscured by the mouse byte *dst; // Surface we are drawing into // clip the mouse rect, and addjust the src pointer accordingly @@ -726,10 +726,14 @@ void OSystem_SDL_Common::draw_mouse() { src -= y * _mouse_cur_state.w; y = 0; } - if (w > SCREEN_WIDTH - x) - w = SCREEN_WIDTH - x; - if (h > SCREEN_HEIGHT - y) - h = SCREEN_HEIGHT - y; + if (w > _screenWidth - x) + w = _screenWidth - x; + if (h > _screenHeight - y) + h = _screenHeight - y; + + // Quick check to see if anything has to be drawn at all + if (w <= 0 || h <= 0) + return; // Store the bounding box so that undraw mouse can restore the area the // mouse currently covers to its original content. @@ -738,16 +742,12 @@ void OSystem_SDL_Common::draw_mouse() { _mouse_old_state.w = w; _mouse_old_state.h = h; - // Quick check to see if anything has to be drawn at all - if (w <= 0 || h <= 0) - return; - // Draw the mouse cursor; backup the covered area in "bak" - if (SDL_LockSurface(sdl_screen) == -1) + if (SDL_LockSurface(_screen) == -1) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - dst = (byte *)sdl_screen->pixels + y * SCREEN_WIDTH + x; + dst = (byte *)_screen->pixels + y * _screenWidth + x; while (h > 0) { int width = w; while (width > 0) { @@ -760,38 +760,38 @@ void OSystem_SDL_Common::draw_mouse() { } src += _mouse_cur_state.w - w; bak += MAX_MOUSE_W - w; - dst += SCREEN_WIDTH - w; + dst += _screenWidth - w; h--; } - SDL_UnlockSurface(sdl_screen); + SDL_UnlockSurface(_screen); // Mark as dirty add_dirty_rect(x, y, w, h); // Finally, set the flag to indicate the mouse has been drawn - _mouse_drawn = true; + _mouseDrawn = true; } void OSystem_SDL_Common::undraw_mouse() { - if (!_mouse_drawn) + if (!_mouseDrawn) return; - _mouse_drawn = false; + _mouseDrawn = false; - if (SDL_LockSurface(sdl_screen) == -1) + if (SDL_LockSurface(_screen) == -1) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - byte *dst, *bak = _mouse_backup; + byte *dst, *bak = _mouseBackup; const int old_mouse_x = _mouse_old_state.x; const int old_mouse_y = _mouse_old_state.y; const int old_mouse_w = _mouse_old_state.w; const int old_mouse_h = _mouse_old_state.h; - int x,y; + int x, y; // No need to do clipping here, since draw_mouse() did that already - dst = (byte *)sdl_screen->pixels + old_mouse_y * SCREEN_WIDTH + old_mouse_x; - for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += SCREEN_WIDTH) { + dst = (byte *)_screen->pixels + old_mouse_y * _screenWidth + old_mouse_x; + for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _screenWidth) { for (x = 0; x < old_mouse_w; ++x) { dst[x] = bak[x]; } @@ -799,7 +799,7 @@ void OSystem_SDL_Common::undraw_mouse() { add_dirty_rect(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h); - SDL_UnlockSurface(sdl_screen); + SDL_UnlockSurface(_screen); } void OSystem_SDL_Common::stop_cdrom() { /* Stop CD Audio in 1/10th of a second */ @@ -812,7 +812,7 @@ void OSystem_SDL_Common::play_cdrom(int track, int num_loops, int start_frame, i if (!num_loops && !start_frame) return; - if (!cdrom) + if (!_cdrom) return; if (end_frame > 0) @@ -822,26 +822,26 @@ void OSystem_SDL_Common::play_cdrom(int track, int num_loops, int start_frame, i cd_num_loops = num_loops; cd_start_frame = start_frame; - SDL_CDStatus(cdrom); - SDL_CDPlayTracks(cdrom, track, start_frame, 0, end_frame); + SDL_CDStatus(_cdrom); + SDL_CDPlayTracks(_cdrom, track, start_frame, 0, end_frame); cd_end_frame = end_frame; cd_stop_time = 0; - cd_end_time = SDL_GetTicks() + cdrom->track[track].length * 1000 / CD_FPS; + cd_end_time = SDL_GetTicks() + _cdrom->track[track].length * 1000 / CD_FPS; } bool OSystem_SDL_Common::poll_cdrom() { - if (!cdrom) + if (!_cdrom) return false; - return (cd_num_loops != 0 && (SDL_GetTicks() < cd_end_time || SDL_CDStatus(cdrom) != CD_STOPPED)); + return (cd_num_loops != 0 && (SDL_GetTicks() < cd_end_time || SDL_CDStatus(_cdrom) != CD_STOPPED)); } void OSystem_SDL_Common::update_cdrom() { - if (!cdrom) + if (!_cdrom) return; if (cd_stop_time != 0 && SDL_GetTicks() >= cd_stop_time) { - SDL_CDStop(cdrom); + SDL_CDStop(_cdrom); cd_num_loops = 0; cd_stop_time = 0; return; @@ -850,7 +850,7 @@ void OSystem_SDL_Common::update_cdrom() { if (cd_num_loops == 0 || SDL_GetTicks() < cd_end_time) return; - if (cd_num_loops != 1 && SDL_CDStatus(cdrom) != CD_STOPPED) { + if (cd_num_loops != 1 && SDL_CDStatus(_cdrom) != CD_STOPPED) { // Wait another second for it to be done cd_end_time += 1000; return; @@ -860,8 +860,8 @@ void OSystem_SDL_Common::update_cdrom() { cd_num_loops--; if (cd_num_loops != 0) { - SDL_CDPlayTracks(cdrom, cd_track, cd_start_frame, 0, cd_end_frame); - cd_end_time = SDL_GetTicks() + cdrom->track[cd_track].length * 1000 / CD_FPS; + SDL_CDPlayTracks(_cdrom, cd_track, cd_start_frame, 0, cd_end_frame); + cd_end_time = SDL_GetTicks() + _cdrom->track[cd_track].length * 1000 / CD_FPS; } } diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index b6d0463359..5712c2f84a 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -75,17 +75,17 @@ public: // Set function that generates samples bool set_sound_proc(void *param, SoundProc *proc, byte sound); - // Poll cdrom status + // Poll CD status // Returns true if cd audio is playing bool poll_cdrom(); - // Play cdrom audio track + // Play CD audio track void play_cdrom(int track, int num_loops, int start_frame, int end_frame); - // Stop cdrom audio track + // Stop CD audio track void stop_cdrom(); - // Update cdrom audio status + // Update CD audio status void update_cdrom(); // Quit @@ -107,23 +107,29 @@ public: protected: - SDL_Surface *sdl_screen; // unseen game screen - SDL_CD *cdrom; + OSystem_SDL_Common(); + virtual ~OSystem_SDL_Common(); + + // unseen game screen + SDL_Surface *_screen; + int _screenWidth, _screenHeight; + + // CD Audio + SDL_CD *_cdrom; + int cd_track, cd_num_loops, cd_start_frame, cd_end_frame; + Uint32 cd_end_time, cd_stop_time, cd_next_second; enum { DF_WANT_RECT_OPTIM = 1 << 0, DF_UPDATE_EXPAND_1_PIXEL = 1 << 3 }; + bool _forceFull; // Force full redraw on next update_screen + int _scaleFactor; int _mode; bool _full_screen; - bool _mouse_visible; - bool _mouse_drawn; uint32 _mode_flags; - bool force_full; //Force full redraw on next update_screen - bool cksum_valid; - enum { NUM_DIRTY_RECT = 100, @@ -132,18 +138,14 @@ protected: MAX_SCALING = 3 }; - int SCREEN_WIDTH, SCREEN_HEIGHT, CKSUM_NUM; + // Dirty rect managment SDL_Rect _dirty_rect_list[100]; - int num_dirty_rects; + int _num_dirty_rects; uint32 *_dirty_checksums; + bool cksum_valid; + int CKSUM_NUM; - int scaling; - - /* CD Audio */ - int cd_track, cd_num_loops, cd_start_frame, cd_end_frame; - Uint32 cd_end_time, cd_stop_time, cd_next_second; - - /* Keyboard mouse emulation */ + // Keyboard mouse emulation struct KbdMouse { int16 x, y, x_vel, y_vel, x_max, y_max, x_down_count, y_down_count; uint32 last_time, delay_time, x_down_time, y_down_time; @@ -153,20 +155,23 @@ protected: int16 x, y, w, h; }; - byte *_mouse_data; - byte *_mouse_backup; + bool _mouseVisible; + bool _mouseDrawn; + byte *_mouseData; + byte *_mouseBackup; MousePos _mouse_cur_state; MousePos _mouse_old_state; - int16 _mouse_hotspot_x; - int16 _mouse_hotspot_y; - int _current_shake_pos; - int _new_shake_pos; - SDL_Color *_cur_pal; + int16 _mouseHotspotX; + int16 _mouseHotspotY; - uint _palette_changed_first, _palette_changed_last; + // Shake mode + int _currentShakePos; + int _newShakePos; + + // Palette data + SDL_Color *_currentPalette; + uint _paletteDirtyStart, _paletteDirtyEnd; - OSystem_SDL_Common(); - virtual ~OSystem_SDL_Common(); void add_dirty_rgn_auto(const byte *buf); void mk_checksums(const byte *buf); diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp index 2b2ae1d115..8bdd5301e4 100644 --- a/backends/sdl/sdl.cpp +++ b/backends/sdl/sdl.cpp @@ -72,7 +72,7 @@ OSystem_SDL_Common *OSystem_SDL_Common::create() { void OSystem_SDL_Normal::set_palette(const byte *colors, uint start, uint num) { const byte *b = colors; uint i; - SDL_Color *base = _cur_pal + start; + SDL_Color *base = _currentPalette + start; for(i = 0; i < num; i++) { base[i].r = b[0]; base[i].g = b[1]; @@ -80,11 +80,11 @@ void OSystem_SDL_Normal::set_palette(const byte *colors, uint start, uint num) { b += 4; } - if (start < _palette_changed_first) - _palette_changed_first = start; + if (start < _paletteDirtyStart) + _paletteDirtyStart = start; - if (start + num > _palette_changed_last) - _palette_changed_last = start + num; + if (start + num > _paletteDirtyEnd) + _paletteDirtyEnd = start + num; } void OSystem_SDL_Normal::draw_mouse() { @@ -92,17 +92,16 @@ void OSystem_SDL_Normal::draw_mouse() { OSystem_SDL_Common::draw_mouse(); } - - if (_mouse_drawn || !_mouse_visible) + if (_mouseDrawn || !_mouseVisible) return; - int x = _mouse_cur_state.x - _mouse_hotspot_x; - int y = _mouse_cur_state.y - _mouse_hotspot_y; + int x = _mouse_cur_state.x - _mouseHotspotX; + int y = _mouse_cur_state.y - _mouseHotspotY; int w = _mouse_cur_state.w; int h = _mouse_cur_state.h; byte color; - byte *src = _mouse_data; // Image representing the mouse - uint16 *bak = (uint16*)_mouse_backup; // Surface used to backup the area obscured by the mouse + byte *src = _mouseData; // Image representing the mouse + uint16 *bak = (uint16*)_mouseBackup; // Surface used to backup the area obscured by the mouse uint16 *dst; // Surface we are drawing into // clip the mouse rect, and addjust the src pointer accordingly @@ -116,14 +115,15 @@ void OSystem_SDL_Normal::draw_mouse() { src -= y * _mouse_cur_state.w; y = 0; } - if (w > SCREEN_WIDTH - x) - w = SCREEN_WIDTH - x; - if (h > SCREEN_HEIGHT - y) - h = SCREEN_HEIGHT - y; - // Adjust for tmp_screen offset - x++; - y++; + // Quick check to see if anything has to be drawn at all + if (w <= 0 || h <= 0) + return; + + if (w > _screenWidth - x) + w = _screenWidth - x; + if (h > _screenHeight - y) + h = _screenHeight - y; // Store the bounding box so that undraw mouse can restore the area the // mouse currently covers to its original content. @@ -132,23 +132,19 @@ void OSystem_SDL_Normal::draw_mouse() { _mouse_old_state.w = w; _mouse_old_state.h = h; - // Quick check to see if anything has to be drawn at all - if (w <= 0 || h <= 0) - return; - // Draw the mouse cursor; backup the covered area in "bak" if (SDL_LockSurface(sdl_tmpscreen) == -1) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - dst = (uint16 *)sdl_tmpscreen->pixels + y * TMP_SCREEN_WIDTH + x; + dst = (uint16 *)sdl_tmpscreen->pixels + (y+1) * TMP_SCREEN_WIDTH + (x+1); while (h > 0) { int width = w; while (width > 0) { *bak++ = *dst; color = *src++; if (color != 0xFF) // 0xFF = transparent, don't draw - *dst = RGB_TO_16(_cur_pal[color].r, _cur_pal[color].g, _cur_pal[color].b); + *dst = RGB_TO_16(_currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b); dst++; width--; } @@ -161,10 +157,10 @@ void OSystem_SDL_Normal::draw_mouse() { SDL_UnlockSurface(sdl_tmpscreen); // Mark as dirty - add_dirty_rect(x-1, y-1, w, h); + add_dirty_rect(x, y, w, h); // Finally, set the flag to indicate the mouse has been drawn - _mouse_drawn = true; + _mouseDrawn = true; } void OSystem_SDL_Normal::undraw_mouse() { @@ -172,65 +168,64 @@ void OSystem_SDL_Normal::undraw_mouse() { OSystem_SDL_Common::undraw_mouse(); } - - if (!_mouse_drawn) + if (!_mouseDrawn) return; - _mouse_drawn = false; + _mouseDrawn = false; - uint16 *dst, *bak = (uint16 *)_mouse_backup; + if (SDL_LockSurface(sdl_tmpscreen) == -1) + error("SDL_LockSurface failed: %s.\n", SDL_GetError()); + + uint16 *dst, *bak = (uint16 *)_mouseBackup; const int old_mouse_x = _mouse_old_state.x; const int old_mouse_y = _mouse_old_state.y; const int old_mouse_w = _mouse_old_state.w; const int old_mouse_h = _mouse_old_state.h; - int x,y; - - if (SDL_LockSurface(sdl_tmpscreen) == -1) - error("SDL_LockSurface failed: %s.\n", SDL_GetError()); + int x, y; // No need to do clipping here, since draw_mouse() did that already - dst = (uint16 *)sdl_tmpscreen->pixels + old_mouse_y * TMP_SCREEN_WIDTH + old_mouse_x; + dst = (uint16 *)sdl_tmpscreen->pixels + (old_mouse_y+1) * TMP_SCREEN_WIDTH + (old_mouse_x+1); for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += TMP_SCREEN_WIDTH) { for (x = 0; x < old_mouse_w; ++x) { dst[x] = bak[x]; } } - add_dirty_rect(old_mouse_x-1, old_mouse_y-1, old_mouse_w, old_mouse_h); + add_dirty_rect(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h); SDL_UnlockSurface(sdl_tmpscreen); } void OSystem_SDL_Normal::load_gfx_mode() { - force_full = true; - scaling = 1; + _forceFull = true; + _scaleFactor = 1; _mode_flags = 0; _overlay_visible = false; _scaler_proc = NULL; sdl_tmpscreen = NULL; - TMP_SCREEN_WIDTH = (SCREEN_WIDTH + 3); + TMP_SCREEN_WIDTH = (_screenWidth + 3); switch(_mode) { case GFX_2XSAI: - scaling = 2; + _scaleFactor = 2; _scaler_proc = _2xSaI; break; case GFX_SUPER2XSAI: - scaling = 2; + _scaleFactor = 2; _scaler_proc = Super2xSaI; break; case GFX_SUPEREAGLE: - scaling = 2; + _scaleFactor = 2; _scaler_proc = SuperEagle; break; case GFX_ADVMAME2X: - scaling = 2; + _scaleFactor = 2; _scaler_proc = AdvMame2x; break; case GFX_DOUBLESIZE: - scaling = 2; + _scaleFactor = 2; _scaler_proc = Normal2x; break; @@ -239,25 +234,25 @@ void OSystem_SDL_Normal::load_gfx_mode() { warning("full screen in useless in triplesize mode, reverting to normal mode"); goto normal_mode; } - scaling = 3; + _scaleFactor = 3; _scaler_proc = Normal3x; break; case GFX_NORMAL: normal_mode:; - scaling = 1; + _scaleFactor = 1; _scaler_proc = Normal1x; break; } - sdl_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN_WIDTH, SCREEN_HEIGHT, 8, 0, 0, 0, 0); - if (sdl_screen == NULL) - error("sdl_screen failed failed"); + _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth, _screenHeight, 8, 0, 0, 0, 0); + if (_screen == NULL) + error("_screen failed failed"); - uint16 *tmp_screen = (uint16*)calloc(TMP_SCREEN_WIDTH*(SCREEN_HEIGHT+3),sizeof(uint16)); + uint16 *tmp_screen = (uint16*)calloc(TMP_SCREEN_WIDTH*(_screenHeight+3),sizeof(uint16)); _mode_flags = DF_WANT_RECT_OPTIM | DF_UPDATE_EXPAND_1_PIXEL; - sdl_hwscreen = SDL_SetVideoMode(SCREEN_WIDTH * scaling, SCREEN_HEIGHT * scaling, 16, + sdl_hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, _screenHeight * _scaleFactor, 16, _full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE ); if (sdl_hwscreen == NULL) @@ -269,7 +264,7 @@ normal_mode:; else Init_2xSaI(565); sdl_tmpscreen = SDL_CreateRGBSurfaceFrom(tmp_screen, - TMP_SCREEN_WIDTH, SCREEN_HEIGHT + 3, 16, TMP_SCREEN_WIDTH*2, + TMP_SCREEN_WIDTH, _screenHeight + 3, 16, TMP_SCREEN_WIDTH*2, sdl_hwscreen->format->Rmask, sdl_hwscreen->format->Gmask, sdl_hwscreen->format->Bmask, @@ -279,17 +274,17 @@ normal_mode:; error("sdl_tmpscreen failed"); // keyboard cursor control, some other better place for it? - km.x_max = SCREEN_WIDTH * scaling - 1; - km.y_max = SCREEN_HEIGHT * scaling - 1; + km.x_max = _screenWidth * _scaleFactor - 1; + km.y_max = _screenHeight * _scaleFactor - 1; km.delay_time = 25; km.last_time = 0; } void OSystem_SDL_Normal::unload_gfx_mode() { - if (sdl_screen) { - SDL_FreeSurface(sdl_screen); - sdl_screen = NULL; + if (_screen) { + SDL_FreeSurface(_screen); + _screen = NULL; } if (sdl_hwscreen) { @@ -314,52 +309,52 @@ void OSystem_SDL_Normal::update_screen() { // Check whether the palette was changed in the meantime and update the // screen surface accordingly. - if (_palette_changed_last != 0) { - SDL_SetColors(sdl_screen, _cur_pal + _palette_changed_first, - _palette_changed_first, - _palette_changed_last - _palette_changed_first); + if (_paletteDirtyEnd != 0) { + SDL_SetColors(_screen, _currentPalette + _paletteDirtyStart, + _paletteDirtyStart, + _paletteDirtyEnd - _paletteDirtyStart); - _palette_changed_last = 0; + _paletteDirtyEnd = 0; - force_full = true; + _forceFull = true; } /* If the shake position changed, fill the dirty area with blackness */ - if (_current_shake_pos != _new_shake_pos) { - SDL_Rect blackrect = {0, 0, SCREEN_WIDTH*scaling, _new_shake_pos*scaling}; + if (_currentShakePos != _newShakePos) { + SDL_Rect blackrect = {0, 0, _screenWidth*_scaleFactor, _newShakePos*_scaleFactor}; SDL_FillRect(sdl_hwscreen, &blackrect, 0); - _current_shake_pos = _new_shake_pos; + _currentShakePos = _newShakePos; - force_full = true; + _forceFull = true; } // Force a full redraw if requested - if (force_full) { - num_dirty_rects = 1; + if (_forceFull) { + _num_dirty_rects = 1; _dirty_rect_list[0].x = 0; _dirty_rect_list[0].y = 0; - _dirty_rect_list[0].w = SCREEN_WIDTH; - _dirty_rect_list[0].h = SCREEN_HEIGHT; + _dirty_rect_list[0].w = _screenWidth; + _dirty_rect_list[0].h = _screenHeight; } // Only draw anything if necessary - if (num_dirty_rects > 0) { + if (_num_dirty_rects > 0) { SDL_Rect *r; uint32 srcPitch, dstPitch; - SDL_Rect *last_rect = _dirty_rect_list + num_dirty_rects; + SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects; // Convert appropriate parts of the 8bpp image into 16bpp if (!_overlay_visible) { SDL_Rect dst; - for(r=_dirty_rect_list; r!=last_rect; ++r) { + for(r = _dirty_rect_list; r != last_rect; ++r) { dst = *r; dst.x++; // Shift rect by one since 2xSai needs to acces the data around dst.y++; // any pixel to scale it, and we want to avoid mem access crashes. - if (SDL_BlitSurface(sdl_screen, r, sdl_tmpscreen, &dst) != 0) + if (SDL_BlitSurface(_screen, r, sdl_tmpscreen, &dst) != 0) error("SDL_BlitSurface failed: %s", SDL_GetError()); } } @@ -370,42 +365,35 @@ void OSystem_SDL_Normal::update_screen() { srcPitch = sdl_tmpscreen->pitch; dstPitch = sdl_hwscreen->pitch; - for(r=_dirty_rect_list; r!=last_rect; ++r) { - register int dst_y = r->y + _current_shake_pos; + for(r = _dirty_rect_list; r != last_rect; ++r) { + register int dst_y = r->y + _currentShakePos; register int dst_h = 0; - if (dst_y < SCREEN_HEIGHT) { + if (dst_y < _screenHeight) { dst_h = r->h; - if (dst_h > SCREEN_HEIGHT - dst_y) - dst_h = SCREEN_HEIGHT - dst_y; + if (dst_h > _screenHeight - dst_y) + dst_h = _screenHeight - dst_y; - dst_y *= scaling; + dst_y *= _scaleFactor; _scaler_proc((byte*)sdl_tmpscreen->pixels + (r->x*2+2) + (r->y+1)*srcPitch, srcPitch, NULL, - (byte*)sdl_hwscreen->pixels + r->x*2*scaling + dst_y*dstPitch, dstPitch, r->w, dst_h); + (byte*)sdl_hwscreen->pixels + r->x*2*_scaleFactor + dst_y*dstPitch, dstPitch, r->w, dst_h); } - r->x *= scaling; + r->x *= _scaleFactor; r->y = dst_y; - r->w *= scaling; - r->h = dst_h * scaling; - } - - if (force_full) { - _dirty_rect_list[0].y = 0; - _dirty_rect_list[0].h = SCREEN_HEIGHT * scaling; + r->w *= _scaleFactor; + r->h = dst_h * _scaleFactor; } SDL_UnlockSurface(sdl_tmpscreen); SDL_UnlockSurface(sdl_hwscreen); - } - - if (num_dirty_rects > 0) { - /* Finally, blit all our changes to the screen */ - SDL_UpdateRects(sdl_hwscreen, num_dirty_rects, _dirty_rect_list); + + // Finally, blit all our changes to the screen + SDL_UpdateRects(sdl_hwscreen, _num_dirty_rects, _dirty_rect_list); } - num_dirty_rects = 0; - force_full = false; + _num_dirty_rects = 0; + _forceFull = false; } void OSystem_SDL_Normal::hotswap_gfx_mode() { @@ -414,20 +402,20 @@ void OSystem_SDL_Normal::hotswap_gfx_mode() { * then draw that to the new screen right after it's setup. */ - byte *bak_mem = (byte*)malloc(SCREEN_WIDTH*SCREEN_HEIGHT); + byte *bak_mem = (byte*)malloc(_screenWidth*_screenHeight); get_320x200_image(bak_mem); unload_gfx_mode(); load_gfx_mode(); - force_full = true; + _forceFull = true; // reset palette - SDL_SetColors(sdl_screen, _cur_pal, 0, 256); + SDL_SetColors(_screen, _currentPalette, 0, 256); // blit image - OSystem_SDL_Normal::copy_rect(bak_mem, SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + OSystem_SDL_Normal::copy_rect(bak_mem, _screenWidth, 0, 0, _screenWidth, _screenHeight); free(bak_mem); OSystem_SDL_Normal::update_screen(); @@ -460,8 +448,11 @@ void OSystem_SDL_Normal::show_overlay() void OSystem_SDL_Normal::hide_overlay() { + // hide the mouse + undraw_mouse(); + _overlay_visible = false; - force_full = true; + _forceFull = true; } void OSystem_SDL_Normal::clear_overlay() @@ -476,12 +467,12 @@ void OSystem_SDL_Normal::clear_overlay() SDL_Rect src, dst; src.x = src.y = 0; dst.x = dst.y = 1; - src.w = dst.w = SCREEN_WIDTH; - src.h = dst.h = SCREEN_HEIGHT; - if (SDL_BlitSurface(sdl_screen, &src, sdl_tmpscreen, &dst) != 0) + src.w = dst.w = _screenWidth; + src.h = dst.h = _screenHeight; + if (SDL_BlitSurface(_screen, &src, sdl_tmpscreen, &dst) != 0) error("SDL_BlitSurface failed: %s", SDL_GetError()); - force_full = true; + _forceFull = true; } void OSystem_SDL_Normal::grab_overlay(int16 *buf, int pitch) @@ -499,9 +490,9 @@ void OSystem_SDL_Normal::grab_overlay(int16 *buf, int pitch) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); int16 *src = (int16 *)sdl_tmpscreen->pixels + TMP_SCREEN_WIDTH + 1; - int h = SCREEN_HEIGHT; + int h = _screenHeight; do { - memcpy(buf, src, SCREEN_WIDTH*2); + memcpy(buf, src, _screenWidth*2); src += TMP_SCREEN_WIDTH; buf += pitch; } while (--h); @@ -520,8 +511,8 @@ void OSystem_SDL_Normal::copy_rect_overlay(const int16 *buf, int pitch, int x, i // Clip the coordinates if (x < 0) { w+=x; buf-=x; x = 0; } if (y < 0) { h+=y; buf-=y*pitch; y = 0; } - if (w > SCREEN_WIDTH-x) { w = SCREEN_WIDTH - x; } - if (h > SCREEN_HEIGHT-y) { h = SCREEN_HEIGHT - y; } + if (w > _screenWidth-x) { w = _screenWidth - x; } + if (h > _screenHeight-y) { h = _screenHeight - y; } if (w <= 0 || h <= 0) return; diff --git a/backends/sdl/sdl_gl.cpp b/backends/sdl/sdl_gl.cpp index 9e6e0f8e72..67626a7ea0 100644 --- a/backends/sdl/sdl_gl.cpp +++ b/backends/sdl/sdl_gl.cpp @@ -75,22 +75,22 @@ void OSystem_SDL_GL::set_palette(const byte *colors, uint start, uint num) { b += 4; } - if (start < _palette_changed_first) - _palette_changed_first = start; + if (start < _paletteDirtyStart) + _paletteDirtyStart = start; - if (start + num > _palette_changed_last) - _palette_changed_last = start + num; + if (start + num > _paletteDirtyEnd) + _paletteDirtyEnd = start + num; } void OSystem_SDL_GL::load_gfx_mode() { int gl_flags = FB2GL_320 | FB2GL_PITCH; - force_full = true; - scaling = 2; + _forceFull = true; + _scaleFactor = 2; _mode_flags = 0; - sdl_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN_WIDTH, SCREEN_HEIGHT, 8, 0, 0, 0, 0); - if (sdl_screen == NULL) - error("sdl_screen failed failed"); + _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth, _screenHeight, 8, 0, 0, 0, 0); + if (_screen == NULL) + error("_screen failed failed"); _mode_flags = DF_WANT_RECT_OPTIM; @@ -111,9 +111,9 @@ void OSystem_SDL_GL::load_gfx_mode() { } void OSystem_SDL_GL::unload_gfx_mode() { - if (sdl_screen) { - SDL_FreeSurface(sdl_screen); - sdl_screen = NULL; + if (_screen) { + SDL_FreeSurface(_screen); + _screen = NULL; } } @@ -123,9 +123,9 @@ void OSystem_SDL_GL::update_screen() { draw_mouse(); /* If the shake position changed, fill the dirty area with blackness */ - if (_current_shake_pos != _new_shake_pos) { + if (_currentShakePos != _newShakePos) { - _current_shake_pos = _new_shake_pos; + _currentShakePos = _newShakePos; } @@ -134,15 +134,15 @@ void OSystem_SDL_GL::update_screen() { * "real" 8bit mode, palatte changes may be visible immediatly, * and we want to avoid any ugly effects. */ - if (_palette_changed_last != 0) { - fb2gl.setPalette(_palette_changed_first, - _palette_changed_last - _palette_changed_first); + if (_paletteDirtyEnd != 0) { + fb2gl.setPalette(_paletteDirtyStart, + _paletteDirtyEnd - _paletteDirtyStart); - _palette_changed_last = 0; + _paletteDirtyEnd = 0; } // FIXME - this seems to be tied to 320x200 - what about Zak256 which needs 320x240 ? - fb2gl.update(sdl_screen->pixels,320,200,320,0,_current_shake_pos); + fb2gl.update(_screen->pixels,320,200,320,0,_currentShakePos); } @@ -152,7 +152,7 @@ void OSystem_SDL_GL::hotswap_gfx_mode() { * then draw that to the new screen right after it's setup. */ - byte *bak_mem = (byte*)malloc(SCREEN_WIDTH*SCREEN_HEIGHT); + byte *bak_mem = (byte*)malloc(_screenWidth*_screenHeight); get_320x200_image(bak_mem); @@ -160,10 +160,10 @@ void OSystem_SDL_GL::hotswap_gfx_mode() { load_gfx_mode(); fb2gl.setPalette(0,256); - fb2gl.update(sdl_screen->pixels,320,200,320,0,_current_shake_pos); + fb2gl.update(_screen->pixels,320,200,320,0,_currentShakePos); /* blit image */ - copy_rect(bak_mem, SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + copy_rect(bak_mem, _screenWidth, 0, 0, _screenWidth, _screenHeight); free(bak_mem); update_screen(); diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 15a4ef1afd..8b82e5b8a5 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -75,8 +75,7 @@ static byte guifont[] = { }; // Constructor -NewGui::NewGui(OSystem *system) : _system(system), _screen(0), - _use_alpha_blending(true), _need_redraw(false), +NewGui::NewGui(OSystem *system) : _system(system), _screen(0), _needRedraw(false), _currentKeyDown(0), _cursorAnimateCounter(0), _cursorAnimateTimer(0) { // Setup some default GUI colors. @@ -113,14 +112,14 @@ void NewGui::runLoop() activeDialog->handleTickle(); - if (_need_redraw) { + if (_needRedraw) { // Restore the overlay to its initial state, then draw all dialogs. // This is necessary to get the blending right. _system->clear_overlay(); - _system->grab_overlay(_screen, _screen_pitch); + _system->grab_overlay(_screen, _screenPitch); for (i = 0; i < _dialogStack.size(); i++) _dialogStack[i]->draw(); - _need_redraw = false; + _needRedraw = false; } animateCursor(); @@ -205,10 +204,10 @@ void NewGui::saveState() _system->show_overlay(); // TODO - add getHeight & getWidth methods to OSystem. _screen = new int16[320 * 240]; - _screen_pitch = 320; + _screenPitch = 320; // _screen = new int16[_system->get_width() * _system->get_height()]; -// _screen_pitch = _system->get_width(); - _system->grab_overlay(_screen, _screen_pitch); +// _screenPitch = _system->get_width(); + _system->grab_overlay(_screen, _screenPitch); } void NewGui::restoreState() @@ -227,7 +226,7 @@ void NewGui::restoreState() void NewGui::openDialog(Dialog *dialog) { _dialogStack.push(dialog); - _need_redraw = true; + _needRedraw = true; } void NewGui::closeTopDialog() @@ -238,7 +237,7 @@ void NewGui::closeTopDialog() // Remove the dialog from the stack _dialogStack.pop(); - _need_redraw = true; + _needRedraw = true; } @@ -247,7 +246,7 @@ void NewGui::closeTopDialog() int16 *NewGui::getBasePtr(int x, int y) { - return _screen + x + y * _screen_pitch; + return _screen + x + y * _screenPitch; } void NewGui::box(int x, int y, int width, int height) @@ -282,7 +281,7 @@ void NewGui::line(int x, int y, int x2, int y2, int16 color) /* vertical line */ while (y++ <= y2) { *ptr = color; - ptr += _screen_pitch; + ptr += _screenPitch; } } else if (y == y2) { /* horizontal line */ @@ -307,7 +306,7 @@ void NewGui::blendRect(int x, int y, int w, int h, int16 color) (GREEN_FROM_16(ptr[i])+g)/4, (BLUE_FROM_16(ptr[i])+b)/4); } - ptr += _screen_pitch; + ptr += _screenPitch; } } @@ -322,7 +321,7 @@ void NewGui::fillRect(int x, int y, int w, int h, int16 color) for (i = 0; i < w; i++) { ptr[i] = color; } - ptr += _screen_pitch; + ptr += _screenPitch; } } @@ -338,7 +337,7 @@ void NewGui::checkerRect(int x, int y, int w, int h, int16 color) if ((h ^ i) & 1) ptr[i] = color; } - ptr += _screen_pitch; + ptr += _screenPitch; } } @@ -353,12 +352,12 @@ void NewGui::frameRect(int x, int y, int w, int h, int16 color) for (i = 0; i < w; i++, ptr++) *ptr = color; ptr--; - for (i = 0; i < h; i++, ptr += _screen_pitch) + for (i = 0; i < h; i++, ptr += _screenPitch) *ptr = color; ptr = basePtr; - for (i = 0; i < h; i++, ptr += _screen_pitch) + for (i = 0; i < h; i++, ptr += _screenPitch) *ptr = color; - ptr -= _screen_pitch; + ptr -= _screenPitch; for (i = 0; i < w; i++, ptr++) *ptr = color; } @@ -369,7 +368,7 @@ void NewGui::addDirtyRect(int x, int y, int w, int h) // blit the affected area directly to the overlay. At least for our current // GUI/widget/dialog code that is just fine. int16 *buf = getBasePtr(x, y); - _system->copy_rect_overlay(buf, _screen_pitch, x, y, w, h); + _system->copy_rect_overlay(buf, _screenPitch, x, y, w, h); } void NewGui::drawChar(const char chr, int xx, int yy, int16 color) @@ -394,7 +393,7 @@ void NewGui::drawChar(const char chr, int xx, int yy, int16 color) if (c) ptr[x] = color; } - ptr += _screen_pitch; + ptr += _screenPitch; } } @@ -442,7 +441,7 @@ void NewGui::drawBitmap(uint32 bitmap[8], int x, int y, int16 color) ptr[x2] = color; mask >>= 4; } - ptr += _screen_pitch; + ptr += _screenPitch; } } diff --git a/gui/newgui.h b/gui/newgui.h index 455904026d..1667a0d5b8 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -81,10 +81,9 @@ public: protected: OSystem *_system; int16 *_screen; - int _screen_pitch; + int _screenPitch; - bool _use_alpha_blending; - bool _need_redraw; + bool _needRedraw; DialogStack _dialogStack; // for continuous events (keyDown) -- cgit v1.2.3