sms/vdp: clear 2 lines forward when doing LF

It allows to see much more easily where the action happens on the screen.
This commit is contained in:
Virgil Dupras 2019-07-22 11:03:44 -04:00
parent 87d794d426
commit 518f12b07f
1 changed files with 46 additions and 6 deletions

View File

@ -9,6 +9,8 @@
; bottom of the screen, but for now, when the end of the screen is reached, we ; bottom of the screen, but for now, when the end of the screen is reached, we
; wrap up to the top. ; wrap up to the top.
; ;
; When reaching a new line, we clear that line and the next to help readability.
;
; *** Consts *** ; *** Consts ***
; ;
.equ VDP_CTLPORT 0xbf .equ VDP_CTLPORT 0xbf
@ -92,6 +94,9 @@ vdpSpitC:
ld b, 0 ; we push rotated bits from VDP_LINE into B so ld b, 0 ; we push rotated bits from VDP_LINE into B so
; that we'll already have our low bits from the ; that we'll already have our low bits from the
; second byte we'll send right after. ; second byte we'll send right after.
; Here, we're fitting a 5-bit line, and a 5-bit column on 16-bit, right
; aligned. On top of that, our righmost bit is taken because our target
; cell is 2-bytes wide and our final number is a VRAM address.
ld a, (VDP_LINE) ld a, (VDP_LINE)
sla a ; should always push 0, so no pushing in B sla a ; should always push 0, so no pushing in B
sla a ; same sla a ; same
@ -172,15 +177,23 @@ vdpLF:
; clear the first char of the line. ; clear the first char of the line.
push af push af
ld a, (VDP_LINE) ld a, (VDP_LINE)
inc a call .incA
cp 24 call vdpClrLine
jr nz, .norollover ; Also clear the line after this one
; bottom reached, roll over to top of screen push af ; --> lvl 1
xor a call .incA
.norollover: call vdpClrLine
pop af ; <-- lvl 1
ld (VDP_LINE), a ld (VDP_LINE), a
pop af pop af
ret ret
.incA:
inc a
cp 24
ret nz ; no rollover
; bottom reached, roll over to top of screen
xor a
ret
vdpBS: vdpBS:
call vdpClrPos call vdpClrPos
@ -216,6 +229,33 @@ vdpClrPos:
pop af pop af
ret ret
; Clear line number A
vdpClrLine:
; see comments in vdpSpitC for VRAM details.
push af
; first, get the two LSB at MSB pos.
rrca \ rrca
push af ; --> lvl 1
and 0b11000000
; That's our first address byte
out (VDP_CTLPORT), a
pop af ; <-- lvl 1
; Then, get those 3 other bits at LSB pos. Our popped A has already
; done 2 RRCA, which means that everything is in place.
and 0b00000111
or 0x78
out (VDP_CTLPORT), a
; We're at the right place. Let's just spit 32*2 null bytes
xor a
push bc ; --> lvl 1
ld b, 64
.loop:
out (VDP_DATAPORT), a
djnz .loop
pop bc ; <-- lvl 1
pop af
ret
; Convert ASCII char in A into a tile index corresponding to that character. ; Convert ASCII char in A into a tile index corresponding to that character.
; When a character is unknown, returns 0x5e (a '~' char). ; When a character is unknown, returns 0x5e (a '~' char).
vdpConv: vdpConv: