From: cuz Date: Tue, 11 Feb 2003 12:37:46 +0000 (+0000) Subject: Renamed ..._deinstall -> ..._uninstall. X-Git-Tag: V2.12.0~1722 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8ecdf9d6b7c7d84642d5784c74b98649395b7e61;p=cc65 Renamed ..._deinstall -> ..._uninstall. Rename tgi_setup to tgi_install. Make tgi_install and tgi_deinstall user callable. More cosmetic changes. git-svn-id: svn://svn.cc65.org/cc65/trunk@1966 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/asminc/tgi-kernel.inc b/asminc/tgi-kernel.inc index fb6939c9b..a299d921a 100644 --- a/asminc/tgi-kernel.inc +++ b/asminc/tgi-kernel.inc @@ -6,10 +6,10 @@ ;* */ ;* */ ;* */ -;* (C) 2002 Ullrich von Bassewitz */ -;* Wacholderweg 14 */ -;* D-70597 Stuttgart */ -;* EMail: uz@musoftware.de */ +;* (C) 2002-2003 Ullrich von Bassewitz */ +;* Römerstrasse 52 */ +;* D-70794 Filderstadt */ +;* EMail: uz@cc65.org */ ;* */ ;* */ ;* This software is provided 'as-is', without any expressed or implied */ @@ -48,7 +48,7 @@ TGI_HDR_RES = 12 ; Reserved for extensions TGI_HDR_JUMPTAB = 16 TGI_HDR_INSTALL = TGI_HDR_JUMPTAB+0 ; INSTALL routine -TGI_HDR_DEINSTALL = TGI_HDR_JUMPTAB+2 ; DEINSTALL routine +TGI_HDR_UNINSTALL = TGI_HDR_JUMPTAB+2 ; UNINSTALL routine TGI_HDR_INIT = TGI_HDR_JUMPTAB+4 ; INIT routine TGI_HDR_DONE = TGI_HDR_JUMPTAB+6 ; DONE routine TGI_HDR_GETERROR = TGI_HDR_JUMPTAB+8 ; GETERROR routine @@ -100,7 +100,7 @@ TGI_TEXT_VERTICAL = 1 ; Driver entry points .global tgi_install - .global tgi_deinstall + .global tgi_uninstall .global tgi_init .global tgi_done .global tgi_geterror @@ -127,10 +127,51 @@ TGI_TEXT_VERTICAL = 1 .global tgi_emu_bar .global tgi_getset .global tgi_inv_arg + .global tgi_inv_drv .global tgi_linepop .global tgi_set_ptr .global tgi_popxy .global tgi_popxy2 .global tgi_curtoxy +;------------------------------------------------------------------------------ +; C callable functions + + .global _tgi_load + .global _tgi_load_driver + .global _tgi_unload + .global _tgi_install + .global _tgi_uninstall + .global _tgi_init + .global _tgi_done + .global _tgi_geterror + .global _tgi_clear + .global _tgi_getpagecount + .global _tgi_setviewpage + .global _tgi_setdrawpage + .global _tgi_getcolorcount + .global _tgi_getmaxcolor + .global _tgi_setcolor + .global _tgi_getcolor + .global _tgi_setpalette + .global _tgi_getpalette + .global _tgi_getdefpalette + .global _tgi_getxres + .global _tgi_getmaxx + .global _tgi_getyres + .global _tgi_getmaxy + .global _tgi_getpixel + .global _tgi_setpixel + .global _tgi_gotoxy + .global _tgi_line + .global _tgi_lineto + .global _tgi_circle + .global _tgi_bar + .global _tgi_textstyle + .global _tgi_textwidth + .global _tgi_textheight + .global _tgi_outtext + .global _tgi_outtextxy + + diff --git a/include/tgi.h b/include/tgi.h index b30286e3d..bb4a95644 100644 --- a/include/tgi.h +++ b/include/tgi.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2002-2003 Ullrich von Bassewitz */ +/* Römerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -66,24 +66,38 @@ void __fastcall__ tgi_load (unsigned char mode); -/* Install the matching driver for the given mode. Will just load the driver - * and check if loading was successul. Will not switch to gaphics mode. +/* Load and install the matching driver for the given mode. Will just load + * the driver and check if loading was successul. Will not switch to gaphics + * mode. */ void __fastcall__ tgi_load_driver (const char* name); -/* Install the given driver. This function is identical to tgi_load with the - * only difference that the name of the driver is specified explicitly. You - * should NOT use this function in most cases, use tgi_load() instead. +/* Load and install the given driver. This function is identical to tgi_load + * with the only difference that the name of the driver is specified + * explicitly. You should NOT use this function in most cases, use tgi_load() + * instead. */ void __fastcall__ tgi_unload (void); -/* Unload the currently loaded driver. Will call tgi_done if necessary. */ +/* Uninstall, then unload the currently loaded driver. Will call tgi_done if + * necessary. + */ + +void __fastcall__ tgi_install (void* driver); +/* Install an already loaded driver. */ + +void __fastcall__ tgi_uninstall (void); +/* Uninstall the currently loaded driver but do not unload it. Will call + * tgi_done if necessary. + */ void __fastcall__ tgi_init (void); -/* Initialize the already loaded graphics driver */ +/* Initialize the already loaded graphics driver. */ void __fastcall__ tgi_done (void); -/* End graphics mode, switch back to text mode. Will NOT unload the driver! */ +/* End graphics mode, switch back to text mode. Will NOT uninstall or unload + * the driver! + */ unsigned char __fastcall__ tgi_geterror (void); /* Return the error code for the last operation. This will also clear the diff --git a/include/tgi/tgi-kernel.h b/include/tgi/tgi-kernel.h index d2e23f40d..e8982d199 100644 --- a/include/tgi/tgi-kernel.h +++ b/include/tgi/tgi-kernel.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2002-2003 Ullrich von Bassewitz */ +/* Römerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -46,7 +46,7 @@ /* A structure that describes the header of a graphics driver loaded into * memory. - */ + */ typedef struct { /* Data that describes the capabilities of the driver */ @@ -60,7 +60,7 @@ typedef struct { /* Jump vectors. Note that these are not C callable */ void* install; /* INSTALL routine */ - void* deinstall; /* DEINSTALL routine */ + void* uninstall; /* UNINSTALL routine */ void* init; /* INIT routine */ void* done; /* DONE routine */ void* geterror; /* GETERROR routine */ @@ -106,9 +106,6 @@ extern unsigned char tgi_pagecount; /* Number of available screens */ const char* __fastcall__ tgi_map_mode (unsigned char mode); /* Map a tgi mode to a driver name. Returns NULL if no driver available. */ -void __fastcall__ tgi_setup (void); -/* Setup the driver and graphics kernel once the driver is loaded */ - /* End of tgi-kernel.h */ diff --git a/libsrc/tgi/tgi-kernel.s b/libsrc/tgi/tgi-kernel.s index dbb5a5c0e..0fce818b1 100644 --- a/libsrc/tgi/tgi-kernel.s +++ b/libsrc/tgi/tgi-kernel.s @@ -7,7 +7,7 @@ .include "tgi-kernel.inc" .include "tgi-error.inc" - .export _tgi_setup + .export tgi_clear_ptr .importzp ptr1 @@ -42,7 +42,7 @@ tgi_driver_var_size = * - tgi_driver_vars ; Jump table for the driver functions. tgi_install: jmp $0000 -tgi_deinstall: jmp $0000 +tgi_uninstall: jmp $0000 tgi_init: jmp $0000 tgi_done: jmp $0000 tgi_geterror: jmp $0000 @@ -63,21 +63,31 @@ tgi_circle: jmp $0000 tgi_textstyle: jmp $0000 tgi_outtext: jmp $0000 +; Driver header signature +.rodata +tgi_sig: .byte $74, $67, $69, $00 ; "tgi", version +tgi_sig_len = * - tgi_sig + ;---------------------------------------------------------------------------- -; void __fastcall__ tgi_setup (void); -; /* Setup the driver and graphics kernel once the driver is loaded */ +; void __fastcall__ tgi_install (void* driver); +; /* Install an already loaded driver. */ -copy: lda (ptr1),y - sta tgi_install,x - iny - inx - rts +_tgi_install: + sta _tgi_drv + sta ptr1 + stx _tgi_drv+1 + stx ptr1+1 +; Check the driver signature -_tgi_setup: - jsr tgi_set_ptr ; load _tgi_drv into ptr1 + ldy #tgi_sig_len-1 +@L0: lda (ptr1),y + cmp tgi_sig,y + bne tgi_inv_drv + dey + bpl @L0 ; Copy the jump vectors @@ -125,14 +135,12 @@ _tgi_setup: rts -;---------------------------------------------------------------------------- -; Load the pointer to the tgi driver into ptr1. +; Copy one byte from the jump vectors -tgi_set_ptr: - lda _tgi_drv - sta ptr1 - lda _tgi_drv+1 - sta ptr1+1 +copy: lda (ptr1),y + sta tgi_install,x + iny + inx rts ;---------------------------------------------------------------------------- @@ -143,3 +151,42 @@ tgi_inv_arg: sta _tgi_error rts +;---------------------------------------------------------------------------- +; Set an invalid driver error + +tgi_inv_drv: + lda #TGI_ERR_INV_DRIVER + sta _tgi_error + rts + +;---------------------------------------------------------------------------- +; Load the pointer to the tgi driver into ptr1. + +tgi_set_ptr: + lda _tgi_drv + sta ptr1 + lda _tgi_drv+1 + sta ptr1+1 + rts + +;---------------------------------------------------------------------------- +; void __fastcall__ tgi_uninstall (void); +; /* Uninstall the currently loaded driver but do not unload it. Will call +; * tgi_done if necessary. +; */ + +_tgi_uninstall: + jsr _tgi_done ; Switch off graphics + jsr tgi_uninstall ; Allow the driver to clean up + +; Clear driver pointer and error code + +tgi_clear_ptr: ; External entry point + lda #$00 + sta _tgi_drv + sta _tgi_drv+1 + sta _tgi_error + + rts + + diff --git a/libsrc/tgi/tgi_bar.s b/libsrc/tgi/tgi_bar.s index 1b6ffb0e7..476f9d7a4 100644 --- a/libsrc/tgi/tgi_bar.s +++ b/libsrc/tgi/tgi_bar.s @@ -9,10 +9,10 @@ .importzp ptr1, ptr2, ptr3, ptr4 .import popax - .import _tgi_getmaxx, _tgi_getmaxy - .export _tgi_bar -_tgi_bar: + +.proc _tgi_bar + sta ptr4 ; Y2 stx ptr4+1 @@ -130,4 +130,4 @@ _tgi_bar: @L9: rts - +.endproc diff --git a/libsrc/tgi/tgi_circle.s b/libsrc/tgi/tgi_circle.s index 4908000c9..ab79a1d2b 100644 --- a/libsrc/tgi/tgi_circle.s +++ b/libsrc/tgi/tgi_circle.s @@ -8,12 +8,12 @@ .import popax .importzp tmp1 - .export _tgi_circle -_tgi_circle: +.proc _tgi_circle + sta tmp1 ; Get the coordinates jsr popax jsr tgi_popxy ; Pop X/Y into ptr1/ptr2 jmp tgi_circle ; Call the driver - +.endproc diff --git a/libsrc/tgi/tgi_clear.s b/libsrc/tgi/tgi_clear.s index 558f4ca09..65fe4b341 100644 --- a/libsrc/tgi/tgi_clear.s +++ b/libsrc/tgi/tgi_clear.s @@ -6,8 +6,6 @@ .include "tgi-kernel.inc" - .export _tgi_clear - _tgi_clear = tgi_clear ; Call the driver diff --git a/libsrc/tgi/tgi_done.s b/libsrc/tgi/tgi_done.s index 816567341..e3d37b373 100644 --- a/libsrc/tgi/tgi_done.s +++ b/libsrc/tgi/tgi_done.s @@ -7,9 +7,8 @@ .include "tgi-kernel.inc" .include "tgi-error.inc" - .export _tgi_done +.proc _tgi_done -_tgi_done: lda _tgi_gmode ; Is a graphics mode active? beq @L1 ; Jump if not jsr tgi_done ; Call the driver routine @@ -20,5 +19,5 @@ _tgi_done: sta _tgi_gmode ; Reset the graph mode flag (A = 0) @L1: rts - +.endproc diff --git a/libsrc/tgi/tgi_emu_bar.s b/libsrc/tgi/tgi_emu_bar.s index 048f10bee..e8a06a1ed 100644 --- a/libsrc/tgi/tgi_emu_bar.s +++ b/libsrc/tgi/tgi_emu_bar.s @@ -7,9 +7,9 @@ .include "tgi-kernel.inc" .importzp ptr1, ptr2, ptr3, ptr4 - .export tgi_emu_bar -tgi_emu_bar: +.proc tgi_emu_bar + lda ptr4 sta Y2 lda ptr4+1 @@ -63,6 +63,8 @@ tgi_emu_bar: @L4: rts +.endproc + ;----------------------------------------------------------------------------- ; Data diff --git a/libsrc/tgi/tgi_getcolor.s b/libsrc/tgi/tgi_getcolor.s index 32efd5511..9169b5423 100644 --- a/libsrc/tgi/tgi_getcolor.s +++ b/libsrc/tgi/tgi_getcolor.s @@ -6,10 +6,11 @@ .include "tgi-kernel.inc" - .export _tgi_getcolor -_tgi_getcolor: +.proc _tgi_getcolor + lda _tgi_color ; Get the current drawing color ldx #0 ; Clear high byte rts +.endproc diff --git a/libsrc/tgi/tgi_getcolorcount.s b/libsrc/tgi/tgi_getcolorcount.s index 0661a43f0..ae34220fd 100644 --- a/libsrc/tgi/tgi_getcolorcount.s +++ b/libsrc/tgi/tgi_getcolorcount.s @@ -5,11 +5,12 @@ ; /* Get the number of available colors */ .include "tgi-kernel.inc" - .export _tgi_getcolorcount +.proc _tgi_getcolorcount -_tgi_getcolorcount: lda _tgi_colorcount ldx #0 rts +.endproc + diff --git a/libsrc/tgi/tgi_getdefpalette.s b/libsrc/tgi/tgi_getdefpalette.s index f1bf1c999..8b0325728 100644 --- a/libsrc/tgi/tgi_getdefpalette.s +++ b/libsrc/tgi/tgi_getdefpalette.s @@ -8,7 +8,6 @@ ; .include "tgi-kernel.inc" - .export _tgi_getdefpalette _tgi_getdefpalette = tgi_getdefpalette ; Call the driver diff --git a/libsrc/tgi/tgi_geterror.s b/libsrc/tgi/tgi_geterror.s index 569d6c276..c2426158b 100644 --- a/libsrc/tgi/tgi_geterror.s +++ b/libsrc/tgi/tgi_geterror.s @@ -8,9 +8,8 @@ .include "tgi-kernel.inc" - .export _tgi_geterror +.proc _tgi_geterror -_tgi_geterror: lda _tgi_drv ; Check if we have a driver ora _tgi_drv+1 beq @L1 @@ -22,3 +21,5 @@ _tgi_geterror: stx _tgi_error ; Clear high level error code @L2: rts +.endproc + diff --git a/libsrc/tgi/tgi_getmaxcolor.s b/libsrc/tgi/tgi_getmaxcolor.s index 679311920..2e2b2ad0e 100644 --- a/libsrc/tgi/tgi_getmaxcolor.s +++ b/libsrc/tgi/tgi_getmaxcolor.s @@ -4,19 +4,18 @@ ; unsigned char __fastcall__ tgi_getmaxcolor (void); ; /* Return the maximum supported color number (the number of colors would ; * then be getmaxcolor()+1). -; */ +; */ ; .include "tgi-kernel.inc" - .export _tgi_getmaxcolor +.proc _tgi_getmaxcolor -_tgi_getmaxcolor: ldx _tgi_colorcount dex txa ldx #0 rts - +.endproc diff --git a/libsrc/tgi/tgi_getmaxx.s b/libsrc/tgi/tgi_getmaxx.s index bbfa3d638..7762993e8 100644 --- a/libsrc/tgi/tgi_getmaxx.s +++ b/libsrc/tgi/tgi_getmaxx.s @@ -7,14 +7,15 @@ ; */ .include "tgi-kernel.inc" - .export _tgi_getmaxx - .import _tgi_getxres + .import decax1 -_tgi_getmaxx: +.proc _tgi_getmaxx + jsr _tgi_getxres jmp decax1 +.endproc diff --git a/libsrc/tgi/tgi_getmaxy.s b/libsrc/tgi/tgi_getmaxy.s index 56e186b18..d54675ff5 100644 --- a/libsrc/tgi/tgi_getmaxy.s +++ b/libsrc/tgi/tgi_getmaxy.s @@ -7,13 +7,12 @@ ; */ .include "tgi-kernel.inc" - .export _tgi_getmaxy - .import _tgi_getyres .import decax1 +.proc _tgi_getmaxy -_tgi_getmaxy: jsr _tgi_getyres jmp decax1 +.endproc diff --git a/libsrc/tgi/tgi_getpagecount.s b/libsrc/tgi/tgi_getpagecount.s index de59e9b58..7c8f480b8 100644 --- a/libsrc/tgi/tgi_getpagecount.s +++ b/libsrc/tgi/tgi_getpagecount.s @@ -6,11 +6,12 @@ ; .include "tgi-kernel.inc" - .export _tgi_getpagecount +.proc _tgi_getpagecount -_tgi_getpagecount: lda _tgi_pagecount ldx #0 rts +.endproc + diff --git a/libsrc/tgi/tgi_getpalette.s b/libsrc/tgi/tgi_getpalette.s index 46eaa30d9..ec64ffbc4 100644 --- a/libsrc/tgi/tgi_getpalette.s +++ b/libsrc/tgi/tgi_getpalette.s @@ -8,10 +8,7 @@ ; .include "tgi-kernel.inc" - .export _tgi_getpalette - _tgi_getpalette = tgi_getpalette ; Call the driver - diff --git a/libsrc/tgi/tgi_getpixel.s b/libsrc/tgi/tgi_getpixel.s index 1806d9c16..770757a74 100644 --- a/libsrc/tgi/tgi_getpixel.s +++ b/libsrc/tgi/tgi_getpixel.s @@ -6,13 +6,15 @@ .include "tgi-kernel.inc" - + .import return0 - .export _tgi_getpixel -_tgi_getpixel: +.proc _tgi_getpixel + jsr tgi_getset ; Pop args, check range bcs @L9 jmp tgi_getpixel ; Call the driver @L9: jmp return0 ; Assume bg color +.endproc + diff --git a/libsrc/tgi/tgi_getset.s b/libsrc/tgi/tgi_getset.s index 4ebabaa96..aded19d71 100644 --- a/libsrc/tgi/tgi_getset.s +++ b/libsrc/tgi/tgi_getset.s @@ -11,7 +11,8 @@ .importzp ptr1, ptr2 -tgi_getset: +.proc tgi_getset + jsr tgi_popxy ; Pop X/Y into ptr1/ptr2 ; Are the coordinates out of range? First check if any coord is negative. @@ -36,4 +37,5 @@ tgi_getset: sbc _tgi_yres+1 @L9: rts +.endproc diff --git a/libsrc/tgi/tgi_getxres.s b/libsrc/tgi/tgi_getxres.s index 2a85205c8..62f828c60 100644 --- a/libsrc/tgi/tgi_getxres.s +++ b/libsrc/tgi/tgi_getxres.s @@ -6,12 +6,12 @@ .include "tgi-kernel.inc" - .export _tgi_getxres +.proc _tgi_getxres -_tgi_getxres: lda _tgi_xres ldx _tgi_xres+1 rts +.endproc diff --git a/libsrc/tgi/tgi_getyres.s b/libsrc/tgi/tgi_getyres.s index 172d64f12..d018a3928 100644 --- a/libsrc/tgi/tgi_getyres.s +++ b/libsrc/tgi/tgi_getyres.s @@ -6,13 +6,12 @@ .include "tgi-kernel.inc" - .export _tgi_getyres - .import ldaxidx +.proc _tgi_getyres -_tgi_getyres: lda _tgi_yres ldx _tgi_yres+1 rts +.endproc diff --git a/libsrc/tgi/tgi_gotoxy.s b/libsrc/tgi/tgi_gotoxy.s index c36324285..d02f0ab3d 100644 --- a/libsrc/tgi/tgi_gotoxy.s +++ b/libsrc/tgi/tgi_gotoxy.s @@ -8,9 +8,9 @@ .include "tgi-kernel.inc" .import popax - .export _tgi_gotoxy -_tgi_gotoxy: +.proc _tgi_gotoxy + sta _tgi_cury ; Y stx _tgi_cury+1 jsr popax @@ -18,5 +18,5 @@ _tgi_gotoxy: stx _tgi_curx+1 rts +.endproc - diff --git a/libsrc/tgi/tgi_init.s b/libsrc/tgi/tgi_init.s index 81f784bce..4c521afba 100644 --- a/libsrc/tgi/tgi_init.s +++ b/libsrc/tgi/tgi_init.s @@ -9,11 +9,9 @@ .include "tgi-error.inc" .importzp ptr1 - .import _tgi_done - .import _tgi_setcolor - .export _tgi_init -_tgi_init: +.proc _tgi_init + jsr _tgi_done ; Switch off graphics if needed jsr tgi_init ; Go into graphics mode jsr tgi_geterror ; Get the error code @@ -57,3 +55,6 @@ _tgi_init: @L9: rts +.endproc + + diff --git a/libsrc/tgi/tgi_line.s b/libsrc/tgi/tgi_line.s index 24295eed2..d895dc533 100644 --- a/libsrc/tgi/tgi_line.s +++ b/libsrc/tgi/tgi_line.s @@ -8,12 +8,14 @@ .include "tgi-kernel.inc" .import popax - .export _tgi_line -_tgi_line: +.proc _tgi_line + jsr tgi_linepop ; Pop/store Y2/X2 jsr popax jsr tgi_popxy ; Pop/store X1/Y1 into ptr1/ptr2 jmp tgi_line ; Call the driver +.endproc + diff --git a/libsrc/tgi/tgi_linepop.s b/libsrc/tgi/tgi_linepop.s index 8871f9c36..8cc3dff89 100644 --- a/libsrc/tgi/tgi_linepop.s +++ b/libsrc/tgi/tgi_linepop.s @@ -9,7 +9,8 @@ .import popax .importzp ptr3, ptr4 -tgi_linepop: +.proc tgi_linepop + sta ptr4 ; Y2 stx ptr4+1 sta _tgi_cury @@ -21,4 +22,5 @@ tgi_linepop: stx _tgi_curx+1 rts +.endproc diff --git a/libsrc/tgi/tgi_lineto.s b/libsrc/tgi/tgi_lineto.s index 4799d793a..2cf4a9a1d 100644 --- a/libsrc/tgi/tgi_lineto.s +++ b/libsrc/tgi/tgi_lineto.s @@ -9,11 +9,12 @@ .include "tgi-kernel.inc" .import popax - .export _tgi_lineto -_tgi_lineto: +.proc _tgi_lineto + jsr tgi_curtoxy ; Copy curx/cury into ptr1/ptr2 jsr tgi_linepop ; Pop x2/y2 into ptr3/ptr4 and curx/cury jmp tgi_line ; Call the driver +.endproc diff --git a/libsrc/tgi/tgi_load.c b/libsrc/tgi/tgi_load.c index d11084b2b..17a8de02e 100644 --- a/libsrc/tgi/tgi_load.c +++ b/libsrc/tgi/tgi_load.c @@ -64,8 +64,6 @@ void __fastcall__ tgi_load_driver (const char* name) * should NOT use this function in most cases, use tgi_load() instead. */ { - static const unsigned char marker[4] = { 0x74, 0x67, 0x69, 0x00 }; - static struct mod_ctrl ctrl = { read /* Read from disk */ }; @@ -78,38 +76,24 @@ void __fastcall__ tgi_load_driver (const char* name) /* Now open the file */ ctrl.callerdata = open (name, O_RDONLY); - if (ctrl.callerdata < 0) { - tgi_error = TGI_ERR_CANNOT_LOAD; - return; - } + if (ctrl.callerdata >= 0) { - /* Load the module */ - Res = mod_load (&ctrl); + /* Load the module */ + Res = mod_load (&ctrl); - /* Close the input file */ - close (ctrl.callerdata); + /* Close the input file */ + close (ctrl.callerdata); - /* Check the return code */ - if (Res == MLOAD_OK) { + /* Check the return code */ + if (Res == MLOAD_OK) { - /* Get a pointer to the loaded driver */ - tgi_drv = (tgi_drv_header*) ctrl.module; + /* Check the driver signature, install the driver */ + tgi_install (ctrl.module); + return; - /* Check the header */ - if (memcmp (tgi_drv, marker, sizeof (marker)) != 0) { - /* Invalid driver */ - mod_free (tgi_drv); - tgi_drv = 0; - tgi_error = TGI_ERR_INV_DRIVER; - } else { - /* Driver is ok do setup */ - tgi_setup (); } - - } else { - - /* Error loading the driver */ - tgi_error = TGI_ERR_CANNOT_LOAD; - } + + /* Error loading the driver */ + tgi_error = TGI_ERR_CANNOT_LOAD; } diff --git a/libsrc/tgi/tgi_map_mode.s b/libsrc/tgi/tgi_map_mode.s index 11af5f622..d6a5f64dc 100644 --- a/libsrc/tgi/tgi_map_mode.s +++ b/libsrc/tgi/tgi_map_mode.s @@ -16,7 +16,8 @@ .code -_tgi_map_mode: +.proc _tgi_map_mode + sta tmp1 ; Save mode ldy #$00 @@ -48,4 +49,6 @@ Found: tya inx @L1: rts - +.endproc + + diff --git a/libsrc/tgi/tgi_outtext.s b/libsrc/tgi/tgi_outtext.s index 4c087bc95..f66cc0086 100644 --- a/libsrc/tgi/tgi_outtext.s +++ b/libsrc/tgi/tgi_outtext.s @@ -9,12 +9,13 @@ .import popax .importzp ptr3 - .export _tgi_outtext -_tgi_outtext: +.proc _tgi_outtext + sta ptr3 stx ptr3+1 ; Save s jsr tgi_curtoxy ; Copy curx/cury into ptr1/ptr2 jmp tgi_outtext ; Call the driver +.endproc diff --git a/libsrc/tgi/tgi_outtextxy.s b/libsrc/tgi/tgi_outtextxy.s index c9b209261..efc3e80d5 100644 --- a/libsrc/tgi/tgi_outtextxy.s +++ b/libsrc/tgi/tgi_outtextxy.s @@ -9,13 +9,14 @@ .import popax .importzp ptr3 - .export _tgi_outtextxy -_tgi_outtextxy: +.proc _tgi_outtextxy + sta ptr3 stx ptr3+1 ; Save s jsr popax ; get y from stack jsr tgi_popxy ; Pop x/y into ptr1/ptr2 jmp tgi_outtext ; Call the driver +.endproc diff --git a/libsrc/tgi/tgi_popxy.s b/libsrc/tgi/tgi_popxy.s index 3e2900328..55b259dab 100644 --- a/libsrc/tgi/tgi_popxy.s +++ b/libsrc/tgi/tgi_popxy.s @@ -9,7 +9,8 @@ .import popax .importzp ptr1, ptr2 -tgi_popxy: +.proc tgi_popxy + sta ptr2 ; Y stx ptr2+1 jsr popax @@ -17,4 +18,5 @@ tgi_popxy: stx ptr1+1 rts +.endproc diff --git a/libsrc/tgi/tgi_popxy2.s b/libsrc/tgi/tgi_popxy2.s index d74c8e9ba..8ef17f92b 100644 --- a/libsrc/tgi/tgi_popxy2.s +++ b/libsrc/tgi/tgi_popxy2.s @@ -9,7 +9,8 @@ .import popax .importzp ptr3, ptr4 -tgi_popxy2: +.proc tgi_popxy2 + sta ptr4 ; Y stx ptr4+1 jsr popax @@ -17,3 +18,6 @@ tgi_popxy2: stx ptr3+1 rts +.endproc + + diff --git a/libsrc/tgi/tgi_setcolor.s b/libsrc/tgi/tgi_setcolor.s index 242f07826..8e6fdc555 100644 --- a/libsrc/tgi/tgi_setcolor.s +++ b/libsrc/tgi/tgi_setcolor.s @@ -6,13 +6,14 @@ .include "tgi-kernel.inc" - .export _tgi_setcolor -_tgi_setcolor: +.proc _tgi_setcolor + cmp _tgi_colorcount ; Compare to available colors bcs @L1 sta _tgi_color ; Remember the drawing color jmp tgi_setcolor ; Call the driver @L1: jmp tgi_inv_arg ; Invalid argument +.endproc diff --git a/libsrc/tgi/tgi_setdrawpage.s b/libsrc/tgi/tgi_setdrawpage.s index 90522580e..b1568ff16 100644 --- a/libsrc/tgi/tgi_setdrawpage.s +++ b/libsrc/tgi/tgi_setdrawpage.s @@ -6,13 +6,13 @@ .include "tgi-kernel.inc" - .export _tgi_setdrawpage -_tgi_setdrawpage: +.proc _tgi_setdrawpage + cmp _tgi_pagecount ; Compare to available pages bcs @L1 jmp tgi_setdrawpage ; Call the driver @L1: jmp tgi_inv_arg ; Invalid argument - +.endproc diff --git a/libsrc/tgi/tgi_setpalette.s b/libsrc/tgi/tgi_setpalette.s index baa572b21..b8f269b9e 100644 --- a/libsrc/tgi/tgi_setpalette.s +++ b/libsrc/tgi/tgi_setpalette.s @@ -10,12 +10,12 @@ .include "tgi-kernel.inc" .importzp ptr1 - .export _tgi_setpalette +.proc _tgi_setpalette -_tgi_setpalette: sta ptr1 stx ptr1+1 jmp tgi_setpalette ; Call the driver +.endproc diff --git a/libsrc/tgi/tgi_setpixel.s b/libsrc/tgi/tgi_setpixel.s index d72c05dfc..cd2df6891 100644 --- a/libsrc/tgi/tgi_setpixel.s +++ b/libsrc/tgi/tgi_setpixel.s @@ -7,13 +7,13 @@ .include "tgi-kernel.inc" - .export _tgi_setpixel +.proc _tgi_setpixel -_tgi_setpixel: jsr tgi_getset ; Pop args, check range bcs @L9 jmp tgi_setpixel ; Call the driver @L9: rts +.endproc diff --git a/libsrc/tgi/tgi_setviewpage.s b/libsrc/tgi/tgi_setviewpage.s index d8fdb54ba..a287344ca 100644 --- a/libsrc/tgi/tgi_setviewpage.s +++ b/libsrc/tgi/tgi_setviewpage.s @@ -7,12 +7,13 @@ .include "tgi-kernel.inc" - .export _tgi_setviewpage -_tgi_setviewpage: +.proc _tgi_setviewpage + cmp _tgi_pagecount ; Compare to available pages bcs @L1 jmp tgi_setviewpage ; Call the driver @L1: jmp tgi_inv_arg ; Invalid argument +.endproc diff --git a/libsrc/tgi/tgi_textsize.s b/libsrc/tgi/tgi_textsize.s index 1ed4d225c..24c0d4a75 100644 --- a/libsrc/tgi/tgi_textsize.s +++ b/libsrc/tgi/tgi_textsize.s @@ -1,4 +1,4 @@ -; +; ; Ullrich von Bassewitz, 22.06.2002 ; @@ -6,8 +6,6 @@ .include "tgi-kernel.inc" .import _strlen, pushax, tosumulax - .export _tgi_textwidth - .export _tgi_textheight ;----------------------------------------------------------------------------- ; unsigned __fastcall__ tgi_textwidth (const char* s); @@ -17,6 +15,7 @@ _tgi_textwidth: + ldy _tgi_textdir ; Get text direction bne height diff --git a/libsrc/tgi/tgi_textstyle.s b/libsrc/tgi/tgi_textstyle.s index ddb1aa698..2f7c2bcfa 100644 --- a/libsrc/tgi/tgi_textstyle.s +++ b/libsrc/tgi/tgi_textstyle.s @@ -9,9 +9,9 @@ .include "tgi-kernel.inc" .import popax, incsp2 - .export _tgi_textstyle -_tgi_textstyle: +.proc _tgi_textstyle + pha jsr popax ; Get magx/magy in one call tay @@ -39,3 +39,5 @@ DirOk: cpy #$00 jmp tgi_textstyle +.endproc + diff --git a/libsrc/tgi/tgi_unload.s b/libsrc/tgi/tgi_unload.s index fba835ed1..69171de32 100644 --- a/libsrc/tgi/tgi_unload.s +++ b/libsrc/tgi/tgi_unload.s @@ -8,25 +8,18 @@ .include "tgi-kernel.inc" .include "modload.inc" - .import _tgi_done - .export _tgi_unload + .import tgi_clear_ptr +.proc _tgi_unload -_tgi_unload: jsr _tgi_done ; Switch off graphics - jsr tgi_deinstall ; Allow the driver to clean up + jsr tgi_uninstall ; Allow the driver to clean up lda _tgi_drv ldx _tgi_drv+1 jsr _mod_free ; Free the driver -; Clear variables - - lda #$00 - sta _tgi_drv - sta _tgi_drv+1 - sta _tgi_error - - rts + jmp tgi_clear_ptr ; Clear the driver pointer and exit +.endproc