diff options
author | Simon Howard | 2009-11-21 01:16:14 +0000 |
---|---|---|
committer | Simon Howard | 2009-11-21 01:16:14 +0000 |
commit | 3cf74a97261b1a0aceb591b495b0857781918edd (patch) | |
tree | 28caae31dc6d338310998b2cd8855ca6a16e9c3d /textscreen | |
parent | 299e1c5abf804e2e249c4f77b82fb7949a3f9d7b (diff) | |
parent | 892ad7c072a6717e8935053d7837a33974d0d824 (diff) | |
download | chocolate-doom-3cf74a97261b1a0aceb591b495b0857781918edd.tar.gz chocolate-doom-3cf74a97261b1a0aceb591b495b0857781918edd.tar.bz2 chocolate-doom-3cf74a97261b1a0aceb591b495b0857781918edd.zip |
Merge from trunk.
Subversion-branch: /branches/opl-branch
Subversion-revision: 1734
Diffstat (limited to 'textscreen')
-rw-r--r-- | textscreen/txt_sdl.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c index 0b11aeab..cd7dd77d 100644 --- a/textscreen/txt_sdl.c +++ b/textscreen/txt_sdl.c @@ -263,19 +263,44 @@ static inline void UpdateCharacter(int x, int y) } } +static int LimitToRange(int val, int min, int max) +{ + if (val < min) + { + return min; + } + else if (val > max) + { + return max; + } + else + { + return val; + } +} + void TXT_UpdateScreenArea(int x, int y, int w, int h) { int x1, y1; + int x_end; + int y_end; + + x_end = LimitToRange(x + w, 0, TXT_SCREEN_W - 1); + y_end = LimitToRange(y + h, 0, TXT_SCREEN_H - 1); + x = LimitToRange(x, 0, TXT_SCREEN_W - 1); + y = LimitToRange(y, 0, TXT_SCREEN_H - 1); - for (y1=y; y1<y+h; ++y1) + for (y1=y; y1<y_end; ++y1) { - for (x1=x; x1<x+w; ++x1) + for (x1=x; x1<x_end; ++x1) { UpdateCharacter(x1, y1); } } - SDL_UpdateRect(screen, x * font->w, y * font->h, w * font->w, h * font->h); + SDL_UpdateRect(screen, + x * font->w, y * font->h, + (x_end - x) * font->w, (y_end - y) * font->h); } void TXT_UpdateScreen(void) @@ -285,7 +310,11 @@ void TXT_UpdateScreen(void) void TXT_GetMousePosition(int *x, int *y) { +#if SDL_VERSION_ATLEAST(1, 3, 0) + SDL_GetMouseState(0, x, y); +#else SDL_GetMouseState(x, y); +#endif *x /= font->w; *y /= font->h; @@ -324,7 +353,9 @@ static int TranslateKey(SDL_keysym *sym) case SDLK_PAUSE: return KEY_PAUSE; +#if !SDL_VERSION_ATLEAST(1, 3, 0) case SDLK_EQUALS: return KEY_EQUALS; +#endif case SDLK_LSHIFT: case SDLK_RSHIFT: @@ -335,9 +366,11 @@ static int TranslateKey(SDL_keysym *sym) return KEY_RCTRL; case SDLK_LALT: - case SDLK_LMETA: case SDLK_RALT: +#if !SDL_VERSION_ATLEAST(1, 3, 0) + case SDLK_LMETA: case SDLK_RMETA: +#endif return KEY_RALT; case SDLK_CAPSLOCK: return KEY_CAPSLOCK; |