From 306770331a85928e9dbd56e5352c95f977c9ba8e Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Mon, 21 Sep 2020 23:39:25 +0200 Subject: [PATCH] added cx16 txt.scroll_left --- compiler/res/prog8lib/cx16/textio.p8 | 43 +++++++++++++++------------- examples/test.p8 | 17 +++++++---- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/compiler/res/prog8lib/cx16/textio.p8 b/compiler/res/prog8lib/cx16/textio.p8 index 15cd2c765..b22ce31c7 100644 --- a/compiler/res/prog8lib/cx16/textio.p8 +++ b/compiler/res/prog8lib/cx16/textio.p8 @@ -161,34 +161,37 @@ asmsub scroll_left (ubyte dummy @ Pc) clobbers(A, Y) { phx jsr c64.SCREEN dex - stx _nextrow+1 ; number of columns to scroll + stx _lx+1 dey sty P8ZP_SCRATCH_B1 ; number of rows to scroll - stz cx16.VERA_CTRL - stz cx16.VERA_ADDR_H -_nextrow - ldx #0 ; modified +_nextline + stz cx16.VERA_CTRL ; data port 0: source column + lda #%00010000 ; auto increment 1 + sta cx16.VERA_ADDR_H + lda #2 + sta cx16.VERA_ADDR_L ; begin in column 1 + ldy P8ZP_SCRATCH_B1 + sty cx16.VERA_ADDR_M + lda #1 + sta cx16.VERA_CTRL ; data port 1: destination column + lda #%00010000 ; auto increment 1 + sta cx16.VERA_ADDR_H stz cx16.VERA_ADDR_L sty cx16.VERA_ADDR_M -- lda cx16.VERA_DATA0 ; char - inc cx16.VERA_ADDR_L - ldy cx16.VERA_DATA0 ; color - dec cx16.VERA_ADDR_L - dec cx16.VERA_ADDR_L - dec cx16.VERA_ADDR_L - sta cx16.VERA_DATA0 - inc cx16.VERA_ADDR_L - sty cx16.VERA_DATA0 - inc cx16.VERA_ADDR_L - inc cx16.VERA_ADDR_L - inc cx16.VERA_ADDR_L +_lx ldx #0 ; modified +- lda cx16.VERA_DATA0 + sta cx16.VERA_DATA1 ; copy char + lda cx16.VERA_DATA0 + sta cx16.VERA_DATA1 ; copy color dex - bpl - + bne - dec P8ZP_SCRATCH_B1 - ldy P8ZP_SCRATCH_B1 - bpl _nextrow + bpl _nextline + + lda #0 + sta cx16.VERA_CTRL plx rts }} diff --git a/examples/test.p8 b/examples/test.p8 index bd3719752..c4d979d1a 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,26 +1,31 @@ %import syslib ; %import graphics %import textio -; %zeropage basicsafe +%zeropage basicsafe main { sub start() { + ; cx16.screen_set_mode(128) + + ubyte width = txt.width() + ubyte height = txt.height() + ubyte x ubyte y - for y in 0 to txt.DEFAULT_HEIGHT-1 { - for x in 0 to txt.DEFAULT_WIDTH-1 { + for y in 0 to height-1 { + for x in 0 to width-1 { txt.setchr(x,y,x+y) } } - repeat txt.DEFAULT_WIDTH { - txt.setcc(txt.DEFAULT_WIDTH-1, rnd() % txt.DEFAULT_HEIGHT, 81, 2) + repeat width { + txt.setcc(width-1, rnd() % height, 81, 2) txt.scroll_left(true) - repeat 2000 { + repeat 1000 { x++ } }