From e74ed31936abc27ba0304c8e10d07b11a8abcc3f Mon Sep 17 00:00:00 2001 From: uz Date: Fri, 13 Nov 2009 12:57:10 +0000 Subject: [PATCH] Fixed TGI error codes and messages. Removed the Atari specific ones. tgi_load_vectorfont will now return TGI_ERR_NO_MEM and clear the error code if the load was successful. git-svn-id: svn://svn.cc65.org/cc65/trunk@4466 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- asminc/tgi-error.inc | 6 +----- include/tgi/tgi-error.h | 1 + libsrc/tgi/tgi_geterrormsg.s | 6 ++++-- libsrc/tgi/tgi_load_vectorfont.c | 8 +++++++- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/asminc/tgi-error.inc b/asminc/tgi-error.inc index 99eb6ee4a..52bb57727 100644 --- a/asminc/tgi-error.inc +++ b/asminc/tgi-error.inc @@ -37,16 +37,12 @@ .enum TGI_ERR_OK ; No error TGI_ERR_NO_DRIVER ; No driver available - TGI_ERR_LOAD_ERROR ; Error loading driver + TGI_ERR_CANNOT_LOAD ; Error loading driver or font TGI_ERR_INV_DRIVER ; Invalid driver TGI_ERR_INV_MODE ; Mode not supported by driver TGI_ERR_INV_ARG ; Invalid function argument TGI_ERR_INV_FUNC ; Function not supported TGI_ERR_INV_FONT ; Font file is invalid - - ; Atari specific error codes - - TGI_ERR_NO_IOCB ; No free IOCB to open the screen device TGI_ERR_NO_MEM ; Not enough memory TGI_ERR_UNKNOWN ; Unknown error diff --git a/include/tgi/tgi-error.h b/include/tgi/tgi-error.h index 30b809a0a..f1dd7c8ff 100644 --- a/include/tgi/tgi-error.h +++ b/include/tgi/tgi-error.h @@ -52,6 +52,7 @@ #define TGI_ERR_INV_ARG 5 /* Invalid function argument */ #define TGI_ERR_INV_FUNC 6 /* Function not supported */ #define TGI_ERR_INV_FONT 7 /* Font file is invalid */ +#define TGI_ERR_NO_MEM 8 /* Out of memory */ diff --git a/libsrc/tgi/tgi_geterrormsg.s b/libsrc/tgi/tgi_geterrormsg.s index c2288fd05..c31033cb0 100644 --- a/libsrc/tgi/tgi_geterrormsg.s +++ b/libsrc/tgi/tgi_geterrormsg.s @@ -1,4 +1,4 @@ -; +; ; Ullrich von Bassewitz, 2004-06-15 ; ; const char* __fastcall__ tgi_geterrormsg (unsigned char code); @@ -40,6 +40,7 @@ offs: .byte <(msg0-msgtab) .byte <(msg6-msgtab) .byte <(msg7-msgtab) .byte <(msg8-msgtab) + .byte <(msg9-msgtab) msgtab: msg0: .asciiz "No error" @@ -50,5 +51,6 @@ msg4: .asciiz "Mode not supported by driver" msg5: .asciiz "Invalid function argument" msg6: .asciiz "Function not supported" msg7: .asciiz "Invalid font file" -msg8: .asciiz "Unknown error" +msg8: .asciiz "Out of memory" +msg9: .asciiz "Unknown error" diff --git a/libsrc/tgi/tgi_load_vectorfont.c b/libsrc/tgi/tgi_load_vectorfont.c index ad141d098..280f9f47e 100644 --- a/libsrc/tgi/tgi_load_vectorfont.c +++ b/libsrc/tgi/tgi_load_vectorfont.c @@ -67,6 +67,9 @@ const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name) unsigned char I; + /* Assume we have an error loading the font */ + tgi_error = TGI_ERR_CANNOT_LOAD; + /* Open the file */ F = open (name, O_RDONLY); if (F < 0) { @@ -90,6 +93,7 @@ const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name) Font = malloc (H.size); if (Font == 0) { /* Out of memory */ + tgi_error = TGI_ERR_NO_MEM; goto LoadError; } @@ -113,6 +117,9 @@ const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name) Font->chars[I] += V; } + /* Clear the error */ + tgi_error = TGI_ERR_OK; + /* Return the vector font loaded */ return Font; @@ -123,7 +130,6 @@ LoadError: if (F >= 0) { close (F); } - tgi_error = TGI_ERR_CANNOT_LOAD; return 0; } -- 2.39.5