From 42f7a9b8a27ae1192b49005f5be3eba32f740d05 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 20 Sep 2009 15:27:40 +0000 Subject: Use "const char" in libtextscreen where appropriate (thanks entryway). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1679 --- textscreen/txt_sdl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'textscreen/txt_sdl.c') diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c index 367ed095..bc98a51b 100644 --- a/textscreen/txt_sdl.c +++ b/textscreen/txt_sdl.c @@ -217,7 +217,7 @@ static inline void UpdateCharacter(int x, int y) unsigned char *p; unsigned char *s, *s1; int bg, fg; - int x1, y1; + unsigned int x1, y1; p = &screendata[(y * TXT_SCREEN_W + x) * 2]; character = p[0]; @@ -458,7 +458,7 @@ signed int TXT_GetChar(void) return -1; } -static char *SpecialKeyName(int key) +static const char *SpecialKeyName(int key) { switch (key) { @@ -524,7 +524,7 @@ static char *SpecialKeyName(int key) void TXT_GetKeyDescription(int key, char *buf) { - char *keyname; + const char *keyname; keyname = SpecialKeyName(key); -- cgit v1.2.3 From 410579ec66f7df8757cb980c0a78e3161b7f20d5 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 30 Sep 2009 23:07:03 +0000 Subject: Change British English spellings to American English, for consistency. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1699 --- textscreen/txt_sdl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'textscreen/txt_sdl.c') diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c index bc98a51b..0b11aeab 100644 --- a/textscreen/txt_sdl.c +++ b/textscreen/txt_sdl.c @@ -162,7 +162,7 @@ static void ChooseFont(void) } // -// Initialise text mode screen +// Initialize text mode screen // // Returns 1 if successful, 0 if an error occurred // -- cgit v1.2.3 From 3771126689527293eb4ad658b338d7910bf79012 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 26 Oct 2009 19:28:12 +0000 Subject: Initial hacks for compiling under SDL 1.3. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1726 --- textscreen/txt_sdl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'textscreen/txt_sdl.c') diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c index 0b11aeab..4f8bc2a8 100644 --- a/textscreen/txt_sdl.c +++ b/textscreen/txt_sdl.c @@ -285,7 +285,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 +328,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 +341,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; -- cgit v1.2.3 From 9ea3cb62c94b2f293cc5dbc95518b8312434e093 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 5 Nov 2009 19:57:55 +0000 Subject: Perform bounds checking on values passed to TXT_UpdateScreenArea() to avoid crashes. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1728 --- textscreen/txt_sdl.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'textscreen/txt_sdl.c') diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c index 4f8bc2a8..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; y1w, 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) -- cgit v1.2.3