Fix addressing issue in font routine and data-overwrite bug; Render no longer crashes!

This commit is contained in:
Lucas Scharenbroich 2021-07-10 17:15:35 -05:00
parent ab9a2682db
commit e4d480d2be
5 changed files with 80 additions and 14 deletions

View File

@ -36,6 +36,7 @@ VBL_STATE_REG equ $E0C019
SHADOW_SCREEN equ $012000
SHR_SCREEN equ $E12000
SHR_SCB equ $E19D00
SHR_PALETTES equ $E19E00
; External references
tiledata ext
@ -84,12 +85,9 @@ tiledata ext
jsr BlitInit ; Initialize the memory
jsr GrafInit ; Initialize the graphics screen
ldx #9 ; Special debug size
ldx #6 ; Gameboy Advance size
jsr SetScreenMode
; ldx #6 ; Gameboy Advance size
; jsr SetScreenMode
; Load a picture and copy it into Bank $E1. Then turn on the screen.
jsr AllocOneBank ; Alloc 64KB for Load/Unpack
@ -360,14 +358,23 @@ BlitInit
; Graphic screen initialization
GrafInit lda #$8888
GrafInit
jsr ShadowOn
jsr GrafOn
lda #$8888
jsr ClearToColor
lda #0000
jsr SetSCBs
jsr GrafOn
jsr ShadowOn
ldx #DefaultPalette
lda #0
jsr SetPalette
rts
DefaultPalette dw $0000,$007F,$0090,$0FF0
dw $000F,$0080,$0f70,$0FFF
dw $0fa9,$0ff0,$00e0,$04DF
dw $0d00,$078f,$0ccc,$0FFF
; Return the current border color ($0 - $F) in the accumulator
GetBorderColor lda #0000
sep #$20
@ -393,6 +400,26 @@ ClearToColor ldx #$7D00 ;start at top of pixel data
bne :clearloop ;loop until we've worked our way down to 0
rts
; Set a palette values
; A = palette number, X = palette address
SetPalette
and #$000F ; palette values are 0 - 15 and each palette is 32 bytes
asl
asl
asl
asl
asl
txy
tax
]idx equ 0
lup 16
lda: $0000+]idx,y
stal SHR_PALETTES+]idx,x
]idx equ ]idx+2
--^
rts
; Initialize the SCB
SetSCBs ldx #$0100 ;set all $100 scbs to A
:scbloop dex
@ -628,6 +655,20 @@ qtRec adrl $0000

View File

@ -93,10 +93,10 @@ DumpBanks
bne :loop
pld ; restore the direct page
tcs ; restore the stack pointer
tsc ; restore the stack pointer
clc
adc #8
tsc
tcs
rts
WordBuff str '0000'
@ -141,5 +141,6 @@ Addr3Buff str '000000' ; str adds leading length byte

View File

@ -206,6 +206,7 @@ ScreenAddr lup 200
; so that code can pick an offset and copy values without needing to check for a wrap-around. If the
; playfield is less than 200 lines tall, then any values after 2 * PLAYFIELD_HEIGHT are undefine.
RTable ds 400
ds 400
; Array of addresses for the banks that hold the blitter.
BlitBuff ds 4*13
@ -216,3 +217,5 @@ BlitBuff ds 4*13
BTableHigh ds 208*2*2
BTableLow ds 208*2*2

View File

@ -131,7 +131,7 @@ FillScreen lda #0
lsr
tay
lda #$FFFF
:xloop stal SHR_SCREEN,x
:xloop stal $E10000,x ; X is the absolute address
inx
inx
dey
@ -931,5 +931,6 @@ top

View File

@ -16,11 +16,17 @@
]F_Length ds 2 ;length of string (only one byte currently used)
]F_CharIdx ds 2 ;index of current character
]F_CurrentPos ds 2 ;current top left char position
]F_StrPtr equ $00 ;pointer to string (including length byte) / DP
]F_StrClr equ $02
]F_StrPtr equ $01 ;pointer to string (including length byte) / DP
]F_StrClr equ $03
DrawString
sta ]F_StrPtr ;store at dp 0 ($00) for indirect loads
pha ; local variable space
pha
tsc
phd
tcd
; sta ]F_StrPtr ; (done in pha init above) store at dp 0 ($00) for indirect loads
stx ]F_CurrentPos
sty ]F_StrClr
stz ]F_CharIdx
@ -31,11 +37,14 @@ DrawString
NextChar lda ]F_CharIdx
cmp ]F_Length
bne :notDone
pld
pla
pla
rts ;DONE! Return to caller
:notDone inc ]F_CharIdx
ldy ]F_CharIdx
lda ($00),y ;get next char!
lda (]F_StrPtr),y ;get next char!
and #$00FF ;mask high byte
sec
sbc #' ' ;our table starts with space ' '
@ -636,6 +645,17 @@ s_Template hex 00000000