added cx16 txt.scroll_up

This commit is contained in:
Irmen de Jong 2020-09-21 21:39:36 +02:00
parent ba3dce0b4c
commit 2dbf849c82
4 changed files with 131 additions and 24 deletions

View File

@ -4,7 +4,6 @@
;
; indent format: TABS, size=8
%target c64
%import syslib
%import conv
@ -20,7 +19,7 @@ sub clear_screen() {
clear_screenchars(' ')
}
asmsub fill_screen (ubyte char @ A, ubyte charcolor @ Y) clobbers(A) {
asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
; ---- fill the character screen with the given fill character and character color.
; (assumes screen and color matrix are at their default addresses)
@ -50,7 +49,7 @@ _loop sta c64.Screen,y
}}
}
asmsub clear_screencolors (ubyte scrcolor @ A) clobbers(Y) {
asmsub clear_screencolors (ubyte color @ A) clobbers(Y) {
; ---- clear the character screen colors with the given color (leaves characters).
; (assumes color matrix is at the default address)
%asm {{
@ -77,7 +76,7 @@ sub uppercase() {
c64.VMCSB &= ~2
}
asmsub scroll_left_full (ubyte alsocolors @ Pc) clobbers(A, Y) {
asmsub scroll_left (ubyte alsocolors @ Pc) clobbers(A, Y) {
; ---- scroll the whole screen 1 character to the left
; contents of the rightmost column are unchanged, you should clear/refill this yourself
; Carry flag determines if screen color data must be scrolled too
@ -116,7 +115,7 @@ _scroll_screen ; scroll the screen memory
}}
}
asmsub scroll_right_full (ubyte alsocolors @ Pc) clobbers(A) {
asmsub scroll_right (ubyte alsocolors @ Pc) clobbers(A) {
; ---- scroll the whole screen 1 character to the right
; contents of the leftmost column are unchanged, you should clear/refill this yourself
; Carry flag determines if screen color data must be scrolled too
@ -150,7 +149,7 @@ _scroll_screen ; scroll the screen memory
}}
}
asmsub scroll_up_full (ubyte alsocolors @ Pc) clobbers(A) {
asmsub scroll_up (ubyte alsocolors @ Pc) clobbers(A) {
; ---- scroll the whole screen 1 character up
; contents of the bottom row are unchanged, you should refill/clear this yourself
; Carry flag determines if screen color data must be scrolled too
@ -184,7 +183,7 @@ _scroll_screen ; scroll the screen memory
}}
}
asmsub scroll_down_full (ubyte alsocolors @ Pc) clobbers(A) {
asmsub scroll_down (ubyte alsocolors @ Pc) clobbers(A) {
; ---- scroll the whole screen 1 character down
; contents of the top row are unchanged, you should refill/clear this yourself
; Carry flag determines if screen color data must be scrolled too

View File

@ -19,7 +19,7 @@ sub clear_screen() {
clear_screenchars(' ')
}
asmsub fill_screen (ubyte char @ A, ubyte txtcolor @ Y) clobbers(A) {
asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
; ---- fill the character screen with the given fill character and character color.
%asm {{
sty _ly+1
@ -92,7 +92,7 @@ _lx ldx #0 ; modified
}}
}
asmsub clear_screencolors (ubyte scrcolor @ A) clobbers(Y) {
asmsub clear_screencolors (ubyte color @ A) clobbers(Y) {
; ---- clear the character screen colors with the given color (leaves characters).
; (assumes color matrix is at the default address)
%asm {{
@ -148,7 +148,116 @@ sub uppercase() {
cx16.screen_set_charset(2, 0) ; uppercase charset
}
; TODO implement the "missing" txtio scroll subroutines: scroll_left_full, (also right, up, down)
; TODO implement the "missing" txtio scroll subroutines: scroll_left, scroll_right, scroll_down
asmsub scroll_left (ubyte dummy @ Pc) clobbers(A, Y) {
; ---- scroll the whole screen 1 character to the left
; contents of the rightmost column are unchanged, you should clear/refill this yourself
; Carry flag is a dummy on the cx16
}
asmsub scroll_right (ubyte dummy @ Pc) clobbers(A) {
; ---- scroll the whole screen 1 character to the right
; contents of the leftmost column are unchanged, you should clear/refill this yourself
; Carry flag is a dummy on the cx16
}
asmsub scroll_up (ubyte dummy @ Pc) clobbers(A) {
; ---- scroll the whole screen 1 character up
; contents of the bottom row are unchanged, you should refill/clear this yourself
; Carry flag is a dummy on the cx16
%asm {{
phx
jsr c64.SCREEN
txa
lsr a
lsr a
sta P8ZP_SCRATCH_REG ; number of columns / 4 due to loop unroll
dey
sty P8ZP_SCRATCH_B1 ; number of lines to scroll up
lda #%00010000
sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0.
lda #1
sta cx16.VERA_ADDR_M ; start at (0, 1)
_scrolline ldy #0
stz cx16.VERA_ADDR_L
ldx P8ZP_SCRATCH_REG
- lda cx16.VERA_DATA0
sta _scrollbuffer,y
iny
lda cx16.VERA_DATA0
sta _scrollbuffer,y
iny
lda cx16.VERA_DATA0
sta _scrollbuffer,y
iny
lda cx16.VERA_DATA0
sta _scrollbuffer,y
iny
lda cx16.VERA_DATA0
sta _scrollbuffer,y
iny
lda cx16.VERA_DATA0
sta _scrollbuffer,y
iny
lda cx16.VERA_DATA0
sta _scrollbuffer,y
iny
lda cx16.VERA_DATA0
sta _scrollbuffer,y
iny
dex
bpl -
; now copy the linebuffer back to the line above this one
stz cx16.VERA_ADDR_L
dec cx16.VERA_ADDR_M
ldy #0
ldx P8ZP_SCRATCH_REG
- lda _scrollbuffer,y
sta cx16.VERA_DATA0
iny
lda _scrollbuffer,y
sta cx16.VERA_DATA0
iny
lda _scrollbuffer,y
sta cx16.VERA_DATA0
iny
lda _scrollbuffer,y
sta cx16.VERA_DATA0
iny
lda _scrollbuffer,y
sta cx16.VERA_DATA0
iny
lda _scrollbuffer,y
sta cx16.VERA_DATA0
iny
lda _scrollbuffer,y
sta cx16.VERA_DATA0
iny
lda _scrollbuffer,y
sta cx16.VERA_DATA0
iny
dex
bpl -
inc cx16.VERA_ADDR_M
inc cx16.VERA_ADDR_M ; next line to copy
dec P8ZP_SCRATCH_B1
bne _scrolline
plx
rts
_scrollbuffer .fill 160, 0
}}
}
asmsub scroll_down (ubyte dummy @ Pc) clobbers(A) {
; ---- scroll the whole screen 1 character down
; contents of the top row are unchanged, you should refill/clear this yourself
; Carry flag is a dummy on the cx16
}
romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use c64.CHROUT directly ofcourse.

View File

@ -44,7 +44,7 @@ main {
}
perform_scroll = false
txt.scroll_left_full(true)
txt.scroll_left(true)
if c64.RASTER & 1
c64.SPXY[1] ++
else

View File

@ -8,21 +8,20 @@ main {
sub start() {
; 40 x 25
; 80 x 60
txt.fill_screen('*', 8)
ubyte x
ubyte y
for y in 0 to txt.DEFAULT_HEIGHT-1 {
for x in 0 to txt.DEFAULT_WIDTH-1 {
txt.setchr(x,y,x+y)
}
}
txt.clear_screen()
repeat 60 {
txt.scroll_up(true)
txt.print_ub(txt.width())
txt.chrout('\n')
txt.print_ub(txt.height())
txt.chrout('\n')
ubyte i
repeat {
txt.clear_screencolors(i)
i++
repeat 5000 {
x++
}
}
}
}