Made the VIC-IIe TGI driver put its bitmap behind the ROMs.

This commit is contained in:
Greg King 2018-07-29 18:00:58 -04:00
parent 1981af0bbd
commit 5e67eee362
3 changed files with 116 additions and 116 deletions

View file

@ -16,6 +16,8 @@ FNAM_BANK := $C7 ; Bank for filename
KEY_COUNT := $D0 ; Number of keys in input buffer KEY_COUNT := $D0 ; Number of keys in input buffer
FKEY_COUNT := $D1 ; Characters for function key FKEY_COUNT := $D1 ; Characters for function key
MODE := $D7 ; 40-/80-column mode (bit 7: 80 columns) MODE := $D7 ; 40-/80-column mode (bit 7: 80 columns)
GRAPHM := $D8 ; Graphics mode flags (bits 5-7)
CHARDIS := $D9 ; Bit 2 shadow for location $01
CURS_X := $EC ; Cursor column CURS_X := $EC ; Cursor column
CURS_Y := $EB ; Cursor row CURS_Y := $EB ; Cursor row
SCREEN_PTR := $E0 ; Pointer to current char in text screen SCREEN_PTR := $E0 ; Pointer to current char in text screen
@ -25,22 +27,23 @@ CHARCOLOR := $F1
RVS := $F3 ; Reverse output flag RVS := $F3 ; Reverse output flag
SCROLL := $F8 ; Disable scrolling flag SCROLL := $F8 ; Disable scrolling flag
BASIC_BUF := $200 ; Location of command-line BASIC_BUF := $0200 ; Location of command-line
BASIC_BUF_LEN = 162 ; Maximum length of command-line BASIC_BUF_LEN = 162 ; Maximum length of command-line
FETCH := $2A2 ; Fetch subroutine in RAM FETCH := $02A2 ; Fetch subroutine in RAM
FETVEC := $2AA ; Vector patch location for FETCH FETVEC := $02AA ; Vector patch location for FETCH
STASH := $2AF ; Stash routine in RAM STASH := $02AF ; Stash routine in RAM
STAVEC := $2B9 ; Vector patch location for STASH STAVEC := $02B9 ; Vector patch location for STASH
IRQInd := $2FD ; JMP $0000 -- used as indirect IRQ vector IRQInd := $02FD ; JMP $0000 -- used as indirect IRQ vector
PALFLAG := $A03 ; $FF=PAL, $00=NTSC PALFLAG := $0A03 ; $FF=PAL, $00=NTSC
INIT_STATUS := $A04 ; Flags: Reset/Restore initiation status INIT_STATUS := $0A04 ; Flags: Reset/Restore initiation status
VM2 := $0A2D ; VIC-IIe shadow for $D018 -- graphics mode
FKEY_LEN := $1000 ; Function key lengths FKEY_LEN := $1000 ; Function key lengths
FKEY_TEXT := $100A ; Function key texts FKEY_TEXT := $100A ; Function key texts
KBDREPEAT := $28a KBDREPEAT := $028a
KBDREPEATRATE := $28b KBDREPEATRATE := $028b
KBDREPEATDELAY := $28c KBDREPEATDELAY := $028c
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; Kernal routines ; Kernal routines

View file

@ -141,6 +141,7 @@ extern void c128_joy_mou[];
extern void c128_inkwell_mou[]; extern void c128_inkwell_mou[];
extern void c128_pot_mou[]; extern void c128_pot_mou[];
extern void c128_swlink_ser[]; extern void c128_swlink_ser[];
extern void c128_hi_tgi[];
extern void c128_vdc_tgi[]; /* Referred to by tgi_static_stddrv[] */ extern void c128_vdc_tgi[]; /* Referred to by tgi_static_stddrv[] */
extern void c128_vdc2_tgi[]; extern void c128_vdc2_tgi[];

View file

@ -3,15 +3,16 @@
; ;
; Based on Stephen L. Judd's GRLIB code. ; Based on Stephen L. Judd's GRLIB code.
; ;
; 2017-01-13, Greg King
; 2018-03-13, Sven Klose ; 2018-03-13, Sven Klose
; 2018-07-22, Scott Hutter ; 2018-07-22, Scott Hutter
; 2018-07-28, Greg King
; ;
.include "zeropage.inc" .include "zeropage.inc"
.include "tgi-kernel.inc" .include "tgi-kernel.inc"
.include "tgi-error.inc" .include "tgi-error.inc"
.include "c128.inc"
.macpack generic .macpack generic
.macpack module .macpack module
@ -77,7 +78,7 @@ TEMP2 := sreg
POINT := regsave POINT := regsave
CHUNK := X2 ; Used in the line routine CHUNK := X2 ; Used in the line routine
OLDCHUNK := X2+1 ; Dito OLDCHUNK := X2+1 ; Ditto
; Absolute variables used in the code ; Absolute variables used in the code
@ -88,18 +89,15 @@ PALETTE: .res 2 ; The current palette
BITMASK: .res 1 ; $00 = clear, $FF = set pixels BITMASK: .res 1 ; $00 = clear, $FF = set pixels
; INIT/DONE
OLDD018: .res 1 ; Old register value
; Line routine stuff ; Line routine stuff
DX: .res 2 DX: .res 2
DY: .res 2 DY: .res 2
; BAR variables ; BAR variables
X1SAVE: .res 2 X1SAVE: .res 2
Y1SAVE: .res 2 Y1SAVE: .res 1
X2SAVE: .res 2 X2SAVE: .res 2
Y2SAVE: .res 2 Y2SAVE: .res 1
; Text output stuff ; Text output stuff
TEXTMAGX: .res 1 TEXTMAGX: .res 1
@ -116,15 +114,10 @@ PALETTESIZE = * - DEFPALETTE
BITTAB: .byte $80,$40,$20,$10,$08,$04,$02,$01 BITTAB: .byte $80,$40,$20,$10,$08,$04,$02,$01
BITCHUNK: .byte $FF,$7F,$3F,$1F,$0F,$07,$03,$01 BITCHUNK: .byte $FF,$7F,$3F,$1F,$0F,$07,$03,$01
CHARROM := $D000 ; Character rom base address CHARROM := $D000 ; Character ROM base address
CBASE := $5C00 ; Color memory base address
VBASE := $6000 ; Video memory base address
; BASE + $4000 for each bank above VIC bank 0
; $2000 = VIC bank 0 (base)
; $6000 = VIC bank 1
; $A000 = VIC bank 2
; $E000 = VIC bank 3
VBASE := $C000 ; Video memory base address
CBASE := $E000 ; Color memory base address
.code .code
@ -166,28 +159,38 @@ UNINSTALL:
; ;
INIT: INIT:
; Initialize variables
ldx #$FF ; Initialize variables.
ldx #$FF ; Foreground color
stx BITMASK stx BITMASK
; Switch into graphics mode ; Switch into graphics mode.
; select video bank ; Select a video bank:
; bank 0=3 ($0-$3FFF) (default) ; bank 0 = $03 ($0000-$3FFF) (default)
; bank 1=2 ($4000-$7FFF) * ; bank 1 = $02 ($4000-$7FFF)
; bank 2=1 ($8000-$BFFF) ; bank 2 = $01 ($8000-$BFFF)
; bank 3=0 ($C000-$FFFF) ; bank 3 = $00 ($C000-$FFFF) (TGI)
lda $DD00
and #$FC
ora #$02 ; bank number 1 ($4000)
sta $DD00
; Switch to bitmap mode lda CIA2_PRA
lda $D8 and #<~$03 ; Bank 3
ora #$20 sta CIA2_PRA
sta $D8
DONE1: lda #TGI_ERR_OK lda #$80 ; color-map at $E000, bitmap at $C000
sta VM2
; Make the VIC-IIe read RAM instead of the font ROM.
lda #%00000100
sta CHARDIS
; Switch to bitmap mode.
lda #%00100000
sta GRAPHM
lda #TGI_ERR_OK
sta ERROR sta ERROR
rts rts
@ -199,19 +202,26 @@ DONE1: lda #TGI_ERR_OK
; Must set an error code: NO ; Must set an error code: NO
; ;
DONE: ; select video bank DONE:
lda $DD00
and #$FC
ora #$03 ; bank 0=3 ($0-$3FFF), 1=2 ($4000-$7FFF), 2=1 ($8000-$BFFF), 3=0 ($C000-$FFFF)
sta $DD00
lda $0A2D ; change screen ram location ; Select the text video bank.
AND #$0F
ORA #$10 ; $0400
STA $0A2D
LDA #$00 ; switch back to text mode lda CIA2_PRA
STA $D8 ora #$03 ; Bank 0
sta CIA2_PRA
; Make the VIC-IIe read the font ROM instead of RAM.
lda #%00000000
sta CHARDIS
;lda #%00000000 ; Switch back to text mode
sta GRAPHM
; Restore a value that's needed by BASIC's GRAPHIC 1 statement.
lda #$78 ; color-map at $1C00, bitmap at $2000
sta VM2
rts rts
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@ -241,8 +251,11 @@ CONTROL:
; ;
CLEAR: CLEAR:
ldy #$00 ldy #$00
tya tya
ldx #MMU_CFG_RAM0
sei
stx MMU_CR
@L1: sta VBASE+$0000,y @L1: sta VBASE+$0000,y
sta VBASE+$0100,y sta VBASE+$0100,y
sta VBASE+$0200,y sta VBASE+$0200,y
@ -274,9 +287,12 @@ CLEAR:
sta VBASE+$1C00,y sta VBASE+$1C00,y
sta VBASE+$1D00,y sta VBASE+$1D00,y
sta VBASE+$1E00,y sta VBASE+$1E00,y
sta VBASE+$1E40,y ; preserve vectors sta VBASE+$1F00,y
iny iny
bne @L1 bne @L1
ldx #MMU_CFG_CC65
stx MMU_CR
cli
rts rts
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@ -337,26 +353,22 @@ SETPALETTE:
asl a asl a
asl a asl a
ora PALETTE ; Background color ora PALETTE ; Background color
tax
; Initialize the color map with the new color settings (it is below the ; Initialize the color map with the new color settings (it is below the
; I/O area) ; Kernal ROM).
ldy #$00 ldy #$00
ldx #MMU_CFG_RAM0
sei sei
lda $01 ; Get ROM config stx MMU_CR
pha ; Save it
and #%11111100 ; Clear bit 0 and 1
sta $01
txa ; Load color code
@L2: sta CBASE+$0000,y @L2: sta CBASE+$0000,y
sta CBASE+$0100,y sta CBASE+$0100,y
sta CBASE+$0200,y sta CBASE+$0200,y
sta CBASE+$02e8,y sta CBASE+$02e8,y
iny iny
bne @L2 bne @L2
pla ldx #MMU_CFG_CC65
sta $01 stx MMU_CR
cli cli
; Done, reset the error code ; Done, reset the error code
@ -403,11 +415,9 @@ GETDEFPALETTE:
SETPIXEL: SETPIXEL:
jsr CALC ; Calculate coordinates jsr CALC ; Calculate coordinates
sei ; Get underneath ROM lda #MMU_CFG_RAM0 ; Work behind ROMs
lda $01 sei
pha sta MMU_CR
lda #$34
sta $01
lda (POINT),Y lda (POINT),Y
eor BITMASK eor BITMASK
@ -415,11 +425,11 @@ SETPIXEL:
eor (POINT),Y eor (POINT),Y
sta (POINT),Y sta (POINT),Y
pla ldx #MMU_CFG_CC65
sta $01 stx MMU_CR
cli cli
@L9: rts rts
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; GETPIXEL: Read the color value of a pixel and return it in A/X. The ; GETPIXEL: Read the color value of a pixel and return it in A/X. The
@ -430,23 +440,18 @@ SETPIXEL:
GETPIXEL: GETPIXEL:
jsr CALC ; Calculate coordinates jsr CALC ; Calculate coordinates
sei ; Get underneath ROM lda #MMU_CFG_RAM0 ; Work behind ROMs
lda $01 sei
pha sta MMU_CR
lda #$34
sta $01
lda (POINT),Y lda (POINT),Y
ldy #$00
and BITTAB,X and BITTAB,X
beq @L1 beq @L1
iny lda #$01 ; Foreground color
@L1: pla @L1: ldy #MMU_CFG_CC65
sta $01 sty MMU_CR
cli cli
tya ; Get color value into A
ldx #$00 ; Clear high byte ldx #$00 ; Clear high byte
rts rts
@ -513,9 +518,9 @@ LINE:
sta OLDCHUNK sta OLDCHUNK
sta CHUNK sta CHUNK
sei ; Get underneath ROM lda #MMU_CFG_RAM0 ; Work behind ROMs
lda #$34 sei
sta $01 sta MMU_CR
ldx DY ldx DY
cpx DX ;Who's bigger: dy or dx? cpx DX ;Who's bigger: dy or dx?
@ -571,8 +576,8 @@ YCONT2: lda (POINT),y ;Plot endpoint
and CHUNK and CHUNK
eor (POINT),y eor (POINT),y
sta (POINT),y sta (POINT),y
lda #$36 ldx #MMU_CFG_CC65
sta $01 stx MMU_CR
cli cli
rts rts
@ -628,8 +633,8 @@ XCONT2: dex
lsr CHUNK ;Advance to last point lsr CHUNK ;Advance to last point
jsr LINEPLOT ;Plot the last chunk jsr LINEPLOT ;Plot the last chunk
lda #$36 ldx #MMU_CFG_CC65
sta $01 stx MMU_CR
cli cli
rts rts
; ;
@ -737,47 +742,35 @@ FIXY: cpy #255 ;Y=255 or Y=8
; the original C wrapper and could be written much smaller (besides that, ; the original C wrapper and could be written much smaller (besides that,
; calling LINE is not a good idea either). ; calling LINE is not a good idea either).
BAR: lda Y2 BAR:
sta Y2SAVE
lda Y2+1
sta Y2SAVE+1
lda X2 lda X2
sta X2SAVE sta X2SAVE
lda X2+1 lda X2+1
sta X2SAVE+1 sta X2SAVE+1
lda Y1 lda Y2
sta Y1SAVE sta Y2SAVE
lda Y1+1
sta Y1SAVE+1
lda X1 lda X1
sta X1SAVE sta X1SAVE
lda X1+1 lda X1+1
sta X1SAVE+1 sta X1SAVE+1
@L1: lda Y1 lda Y1
sta Y2 sta Y1SAVE
lda Y1+1
@L1: sta Y2
lda #>200
sta Y1+1
sta Y2+1 sta Y2+1
jsr LINE jsr LINE
lda Y1SAVE
cmp Y2SAVE
bne @L2
lda Y1SAVE lda Y1SAVE
cmp Y2SAVE cmp Y2SAVE
beq @L4 beq @L4
@L2: inc Y1SAVE inc Y1SAVE
bne @L3
inc Y1SAVE+1
@L3: lda Y1SAVE
sta Y1
lda Y1SAVE+1
sta Y1+1
lda X1SAVE lda X1SAVE
sta X1 sta X1
@ -788,6 +781,9 @@ BAR: lda Y2
sta X2 sta X2
lda X2SAVE+1 lda X2SAVE+1
sta X2+1 sta X2+1
lda Y1SAVE
sta Y1
jmp @L1 jmp @L1
@L4: rts @L4: rts