From ca72fb45b44e0b5c6d4d4bea963be4f9aa01690f Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 23 Oct 2003 09:29:12 +0000 Subject: [PATCH] DONE, GETPALETTE and GETDEFPALETTE will no longer return errors. Use TGI_API_VERSION. git-svn-id: svn://svn.cc65.org/cc65/trunk@2568 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/c128/c128-640-200-2.s | 53 ++++++++++++++++--------------- libsrc/c128/c128-640-480-2.s | 55 +++++++++++++++++--------------- libsrc/c64/c64-320-200-2.s | 61 +++++++++++++++++++----------------- 3 files changed, 89 insertions(+), 80 deletions(-) diff --git a/libsrc/c128/c128-640-200-2.s b/libsrc/c128/c128-640-200-2.s index c43601fbc..039794b62 100644 --- a/libsrc/c128/c128-640-200-2.s +++ b/libsrc/c128/c128-640-200-2.s @@ -4,23 +4,24 @@ ; 23.12.2002 ; ; NOTES: -; For any smart monkey that will try to optimize this: PLEASE do tests on real VDC, -; not only VICE. +; For any smart monkey that will try to optimize this: PLEASE do tests on +; real VDC, not only VICE. ; -; Only DONE routine contains C128-mode specific stuff, everything else will work in -; C64-mode of C128 (C64 needs full VDC init then). +; Only DONE routine contains C128-mode specific stuff, everything else will +; work in C64-mode of C128 (C64 needs full VDC init then). ; ; With special initialization and CALC we can get 320x200 double-pixel mode. ; -; Color translation values for BROWN and GRAY3 are obviously wrong, they could -; be replaced by equiv. of ORANGE and GRAY2 but this would give only 14 of 16 colors available. +; Color translation values for BROWN and GRAY3 are obviously wrong, they +; could be replaced by equiv. of ORANGE and GRAY2 but this would give only +; 14 of 16 colors available. ; -; Register 25 ($19) is said to require different value for VDC v1, but I couldn't find what -; it should be. +; Register 25 ($19) is said to require different value for VDC v1, but I +; couldn't find what it should be. - .include "zeropage.inc" + .include "zeropage.inc" - .include "tgi-kernel.inc" + .include "tgi-kernel.inc" .include "tgi-mode.inc" .include "tgi-error.inc" @@ -53,7 +54,7 @@ VDC_DATA = 31 ; capabilities of the driver .byte $74, $67, $69 ; "tgi" - .byte $00 ; TGI version number + .byte TGI_API_VERSION ; TGI API version number xres: .word 640 ; X resolution yres: .word 200 ; Y resolution .byte 2 ; Number of drawing colors @@ -63,10 +64,7 @@ pages: .byte 1 ; Number of screens available .res 4, $00 ; Reserved for future extensions ; Next comes the jump table. Currently all entries must be valid and may point -; to an RTS for test versions (function not implemented). A future version may -; allow for emulation: In this case the vector will be zero. Emulation means -; that the graphics kernel will emulate the function by using lower level -; primitives - for example ploting a line by using calls to SETPIXEL. +; to an RTS for test versions (function not implemented). .word INSTALL .word UNINSTALL @@ -322,7 +320,7 @@ INIT: ; The graphics kernel will never call DONE when no graphics mode is active, ; so there is no need to protect against that. ; -; Must set an error code: YES +; Must set an error code: NO ; DONE: @@ -346,8 +344,7 @@ DONE: jsr VDCWriteReg ; restore color (background) lda #$47 ldx #VDC_HSCROLL - jsr VDCWriteReg ; switch to text screen -; fall through to GETERROR in order to clear ERROR status + jmp VDCWriteReg ; switch to text screen ; ------------------------------------------------------------------------ ; GETERROR: Return the error code in A and clear it. @@ -465,13 +462,17 @@ SETPALETTE: ora COLTRANS,y ldx #VDC_COLORS - jmp VDCWriteReg + jsr VDCWriteReg ; Clear error code + lda #TGI_ERR_OK + sta ERROR + rts ; ------------------------------------------------------------------------ -; GETPALETTE: Return the current palette in A/X. Must return NULL and set an -; error if palettes are not supported. +; GETPALETTE: Return the current palette in A/X. Even drivers that cannot +; set the palette should return the default palette here, so there's no +; way for this function to fail. ; -; Must set an error code: YES +; Must set an error code: NO ; GETPALETTE: @@ -480,10 +481,12 @@ GETPALETTE: rts ; ------------------------------------------------------------------------ -; GETDEFPALETTE: Return the default palette for the driver in A/X. Must -; return NULL and set an error of palettes are not supported. +; GETDEFPALETTE: Return the default palette for the driver in A/X. All +; drivers should return something reasonable here, even drivers that don't +; support palettes, otherwise the caller has no way to determine the colors +; of the (not changeable) palette. ; -; Must set an error code: YES +; Must set an error code: NO (all drivers must have a default palette) ; GETDEFPALETTE: diff --git a/libsrc/c128/c128-640-480-2.s b/libsrc/c128/c128-640-480-2.s index 1c45e8673..1cbec72db 100644 --- a/libsrc/c128/c128-640-480-2.s +++ b/libsrc/c128/c128-640-480-2.s @@ -5,23 +5,24 @@ ; 23.12.2002 ; ; NOTES: -; For any smart monkey that will try to optimize this: PLEASE do tests on real VDC, -; not only VICE. +; For any smart monkey that will try to optimize this: PLEASE do tests on +; real VDC, not only VICE. ; -; Only DONE routine contains C128-mode specific stuff, everything else will work in -; C64-mode of C128 (C64 needs full VDC init then). +; Only DONE routine contains C128-mode specific stuff, everything else will +; work in C64-mode of C128 (C64 needs full VDC init then). ; ; With special initialization and CALC we can get 320x200 double-pixel mode. ; -; Color translation values for BROWN and GRAY3 are obviously wrong, they could -; be replaced by equiv. of ORANGE and GRAY2 but this would give only 14 of 16 colors available. +; Color translation values for BROWN and GRAY3 are obviously wrong, they +; could be replaced by equiv. of ORANGE and GRAY2 but this would give only +; 14 of 16 colors available. ; -; Register 25 ($19) is said to require different value for VDC v1, but I couldn't find what -; it should be. +; Register 25 ($19) is said to require different value for VDC v1, but I +; couldn't find what it should be. - .include "zeropage.inc" + .include "zeropage.inc" - .include "tgi-kernel.inc" + .include "tgi-kernel.inc" .include "tgi-mode.inc" .include "tgi-error.inc" @@ -54,7 +55,7 @@ VDC_DATA = 31 ; capabilities of the driver .byte $74, $67, $69 ; "tgi" - .byte $00 ; TGI version number + .byte TGI_API_VERSION ; TGI version number xres: .word 640 ; X resolution yres: .word 480 ; Y resolution .byte 2 ; Number of drawing colors @@ -64,10 +65,7 @@ pages: .byte 0 ; Number of screens available .res 4, $00 ; Reserved for future extensions ; Next comes the jump table. Currently all entries must be valid and may point -; to an RTS for test versions (function not implemented). A future version may -; allow for emulation: In this case the vector will be zero. Emulation means -; that the graphics kernel will emulate the function by using lower level -; primitives - for example ploting a line by using calls to SETPIXEL. +; to an RTS for test versions (function not implemented). .word INSTALL .word UNINSTALL @@ -280,7 +278,7 @@ UNINSTALL: ; ------------------------------------------------------------------------ ; INIT: Changes an already installed device from text mode to graphics -; mode. +; mode. ; Note that INIT/DONE may be called multiple times while the driver ; is loaded, while INSTALL is only called once, so any code that is needed ; to initializes variables and so on must go here. Setting palette and @@ -331,7 +329,7 @@ INIT: ; The graphics kernel will never call DONE when no graphics mode is active, ; so there is no need to protect against that. ; -; Must set an error code: YES +; Must set an error code: NO ; DONE: @@ -355,8 +353,7 @@ DONE: jsr VDCWriteReg ; restore color (background) lda #$47 ldx #VDC_HSCROLL - jsr VDCWriteReg ; switch to text screen -; fall through to GETERROR in order to clear ERROR status + jmp VDCWriteReg ; switch to text screen ; ------------------------------------------------------------------------ ; GETERROR: Return the error code in A and clear it. @@ -463,13 +460,17 @@ SETPALETTE: ora COLTRANS,y ldx #VDC_COLORS - jmp VDCWriteReg + jsr VDCWriteReg + lda #TGI_ERR_OK ; Clear error code + sta ERROR + rts ; ------------------------------------------------------------------------ -; GETPALETTE: Return the current palette in A/X. Must return NULL and set an -; error if palettes are not supported. +; GETPALETTE: Return the current palette in A/X. Even drivers that cannot +; set the palette should return the default palette here, so there's no +; way for this function to fail. ; -; Must set an error code: YES +; Must set an error code: NO ; GETPALETTE: @@ -478,10 +479,12 @@ GETPALETTE: rts ; ------------------------------------------------------------------------ -; GETDEFPALETTE: Return the default palette for the driver in A/X. Must -; return NULL and set an error of palettes are not supported. +; GETDEFPALETTE: Return the default palette for the driver in A/X. All +; drivers should return something reasonable here, even drivers that don't +; support palettes, otherwise the caller has no way to determine the colors +; of the (not changeable) palette. ; -; Must set an error code: YES +; Must set an error code: NO (all drivers must have a default palette) ; GETDEFPALETTE: diff --git a/libsrc/c64/c64-320-200-2.s b/libsrc/c64/c64-320-200-2.s index acafb5fbd..5bed01874 100644 --- a/libsrc/c64/c64-320-200-2.s +++ b/libsrc/c64/c64-320-200-2.s @@ -23,7 +23,7 @@ ; capabilities of the driver .byte $74, $67, $69 ; "tgi" - .byte $00 ; TGI version number + .byte TGI_API_VERSION ; TGI API version number .word 320 ; X resolution .word 200 ; Y resolution .byte 2 ; Number of drawing colors @@ -66,20 +66,21 @@ ; Variables mapped to the zero page segment variables. Some of these are ; used for passing parameters to the driver. -X1 = ptr1 -Y1 = ptr2 -X2 = ptr3 -Y2 = ptr4 -RADIUS = tmp1 +X1 := ptr1 +Y1 := ptr2 +X2 := ptr3 +Y2 := ptr4 +RADIUS := tmp1 -ROW = tmp2 ; Bitmap row... -COL = tmp3 ; ...and column, both set by PLOT -TEMP = tmp4 -TEMP2 = sreg -POINT = regsave +ROW := tmp2 ; Bitmap row... +COL := tmp3 ; ...and column, both set by PLOT +TEMP := tmp4 +TEMP2 := sreg +POINT := regsave +INRANGE := regsave+2 ; PLOT variable, $00 = coordinates in range -CHUNK = X2 ; Used in the line routine -OLDCHUNK = X2+1 ; Dito +CHUNK := X2 ; Used in the line routine +OLDCHUNK := X2+1 ; Dito ; Absolute variables used in the code @@ -93,9 +94,6 @@ BITMASK: .res 1 ; $00 = clear, $FF = set pixels ; INIT/DONE OLDD018: .res 1 ; Old register value -; PLOT variables -INRANGE: .res 1 ; $00 = coordinates in range - ; Line routine stuff DX: .res 2 DY: .res 2 @@ -206,7 +204,7 @@ DONE1: sta $D011 ; The graphics kernel will never call DONE when no graphics mode is active, ; so there is no need to protect against that. ; -; Must set an error code: YES +; Must set an error code: NO ; DONE: lda $DD02 ; Set the data direction regs @@ -221,7 +219,8 @@ DONE: lda $DD02 ; Set the data direction regs lda $D011 and #<~$20 - jmp DONE1 + sta $D011 + rts ; ------------------------------------------------------------------------ ; GETERROR: Return the error code in A and clear it. @@ -367,15 +366,18 @@ SETPALETTE: sta $01 cli -; Done +; Done, reset the error code + lda #TGI_ERR_OK + sta ERROR rts ; ------------------------------------------------------------------------ -; GETPALETTE: Return the current palette in A/X. Must return NULL and set an -; error if palettes are not supported. +; GETPALETTE: Return the current palette in A/X. Even drivers that cannot +; set the palette should return the default palette here, so there's no +; way for this function to fail. ; -; Must set an error code: YES +; Must set an error code: NO ; GETPALETTE: @@ -384,10 +386,12 @@ GETPALETTE: rts ; ------------------------------------------------------------------------ -; GETDEFPALETTE: Return the default palette for the driver in A/X. Must -; return NULL and set an error of palettes are not supported. +; GETDEFPALETTE: Return the default palette for the driver in A/X. All +; drivers should return something reasonable here, even drivers that don't +; support palettes, otherwise the caller has no way to determine the colors +; of the (not changeable) palette. ; -; Must set an error code: YES +; Must set an error code: NO (all drivers must have a default palette) ; GETDEFPALETTE: @@ -769,9 +773,7 @@ FIXY: cpy #255 ;Y=255 or Y=8 @CONT1: inc ROW bne @DONE lda COL - bmi @DONE - lda #00 - sta INRANGE + bpl @CLEAR @DONE: rts @DECPTR: ;Okay, subtract 320 then @@ -790,9 +792,10 @@ FIXY: cpy #255 ;Y=255 or Y=8 bne @DONE lda COL bmi @DONE - lda #00 +@CLEAR: lda #00 sta INRANGE rts + @TOAST: pla ;Remove old return address pla jmp EXIT ;Restore interrupts, etc. -- 2.39.5