mirror of
https://github.com/cc65/cc65.git
synced 2025-01-06 06:33:34 +00:00
Added check that hi-bytes of the screen and charset addresses are in the same vic bank
This commit is contained in:
parent
5e530526ba
commit
34e063a2a0
@ -17,23 +17,36 @@
|
||||
.code
|
||||
|
||||
.proc _set_viewport
|
||||
lsr
|
||||
lsr
|
||||
sta tmp1 ; chr_hi
|
||||
lda #0
|
||||
sta tmp2 ; bank
|
||||
jsr popa ; scr_hi
|
||||
asl
|
||||
rol tmp2
|
||||
asl
|
||||
rol tmp2
|
||||
ora tmp1
|
||||
sta VIC_ADDR
|
||||
sta tmp1 ; chr_hi
|
||||
ldy #0
|
||||
eor (sp), y ; eor scr_hi with chr_hi to determine VIC bank compliance
|
||||
sec
|
||||
bne @return ; If the upper two bits do not coincide, then the screen and char would be in different VIC banks
|
||||
|
||||
sty tmp2 ; store bank bits temporarily, here
|
||||
lsr tmp1 ; lsr hi-byte into correct bit position for VIC_ADDR (0x08 -> 0x02, 0x10 -> 0x04 ...)
|
||||
lsr tmp1 ; The vic bank check prevents doing this directly in an effective manner, beforehand
|
||||
|
||||
lda CIA2_pra
|
||||
ora #$03
|
||||
eor tmp2
|
||||
sta CIA2_pra
|
||||
lda (sp), y ; scr_hi
|
||||
asl ; rol hi-byte into correct bit position for VIC_ADDR (0x04 -> 0x10, 0x08 -> 0x20 ...)
|
||||
rol tmp2 ; rol hi-bits into bank bits
|
||||
asl
|
||||
rol tmp2 ; rol's 0 into carry
|
||||
ora tmp1 ; combine scr and char bits to the final register value
|
||||
sta VIC_ADDR
|
||||
|
||||
lda CIA2_pra
|
||||
ora #$03 ; prepare for eor
|
||||
eor tmp2 ; EOR bank bits, because in the register the bits are reversed
|
||||
sta CIA2_pra
|
||||
@return:
|
||||
jsr incsp1 ; does not influence carry
|
||||
; return EXIT_SUCCESS, if clc
|
||||
; return EXIT_FAILURE, if sec
|
||||
lda #0
|
||||
tax
|
||||
bcc :+
|
||||
adc #0
|
||||
:
|
||||
rts
|
||||
.endproc
|
||||
|
Loading…
Reference in New Issue
Block a user