diff --git a/compiler/res/prog8lib/c64/textio.p8 b/compiler/res/prog8lib/c64/textio.p8 index 40fe856e6..a2d3f901b 100644 --- a/compiler/res/prog8lib/c64/textio.p8 +++ b/compiler/res/prog8lib/c64/textio.p8 @@ -38,13 +38,13 @@ asmsub clear_screenchars (ubyte char @ A) clobbers(Y) { ; ---- clear the character screen with the given fill character (leaves colors) ; (assumes screen matrix is at the default address) %asm {{ - ldy #0 -_loop sta c64.Screen,y - sta c64.Screen+$0100,y - sta c64.Screen+$0200,y - sta c64.Screen+$02e8,y - iny - bne _loop + ldy #250 +- sta c64.Screen+250*0-1,y + sta c64.Screen+250*1-1,y + sta c64.Screen+250*2-1,y + sta c64.Screen+250*3-1,y + dey + bne - rts }} } @@ -53,13 +53,13 @@ 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 {{ - ldy #0 -_loop sta c64.Colors,y - sta c64.Colors+$0100,y - sta c64.Colors+$0200,y - sta c64.Colors+$02e8,y - iny - bne _loop + ldy #250 +- sta c64.Colors+250*0-1,y + sta c64.Colors+250*1-1,y + sta c64.Colors+250*2-1,y + sta c64.Colors+250*3-1,y + dey + bne - rts }} } @@ -83,29 +83,31 @@ asmsub scroll_left (ubyte alsocolors @ Pc) clobbers(A, Y) { %asm {{ stx P8ZP_SCRATCH_REG - bcs + - jmp _scroll_screen + bcc _scroll_screen -+ ; scroll the color memory ++ ; scroll the screen and the color memory ldx #0 ldy #38 - - .for row=0, row<=24, row+=1 - lda c64.Colors + 40*row + 1,x - sta c64.Colors + 40*row,x - .next + .for row=0, row<=24, row+=1 + lda c64.Screen + 40*row + 1,x + sta c64.Screen + 40*row + 0,x + lda c64.Colors + 40*row + 1,x + sta c64.Colors + 40*row + 0,x + .next inx dey bpl - + rts -_scroll_screen ; scroll the screen memory +_scroll_screen ; scroll only the screen memory ldx #0 ldy #38 - - .for row=0, row<=24, row+=1 - lda c64.Screen + 40*row + 1,x - sta c64.Screen + 40*row,x - .next + .for row=0, row<=24, row+=1 + lda c64.Screen + 40*row + 1,x + sta c64.Screen + 40*row + 0,x + .next inx dey bpl - @@ -121,26 +123,28 @@ asmsub scroll_right (ubyte alsocolors @ Pc) clobbers(A) { ; Carry flag determines if screen color data must be scrolled too %asm {{ stx P8ZP_SCRATCH_REG - bcs + - jmp _scroll_screen + bcc _scroll_screen -+ ; scroll the color memory ++ ; scroll the screen and the color memory ldx #38 - - .for row=0, row<=24, row+=1 - lda c64.Colors + 40*row + 0,x - sta c64.Colors + 40*row + 1,x - .next + .for row=0, row<=24, row+=1 + lda c64.Screen + 40*row + 0,x + sta c64.Screen + 40*row + 1,x + lda c64.Colors + 40*row + 0,x + sta c64.Colors + 40*row + 1,x + .next dex bpl - + rts -_scroll_screen ; scroll the screen memory +_scroll_screen ; scroll only the screen memory ldx #38 - - .for row=0, row<=24, row+=1 - lda c64.Screen + 40*row + 0,x - sta c64.Screen + 40*row + 1,x - .next + .for row=0, row<=24, row+=1 + lda c64.Screen + 40*row + 0,x + sta c64.Screen + 40*row + 1,x + .next dex bpl - @@ -155,26 +159,28 @@ asmsub scroll_up (ubyte alsocolors @ Pc) clobbers(A) { ; Carry flag determines if screen color data must be scrolled too %asm {{ stx P8ZP_SCRATCH_REG - bcs + - jmp _scroll_screen + bcc _scroll_screen -+ ; scroll the color memory ++ ; scroll the screen and the color memory ldx #39 - - .for row=1, row<=24, row+=1 - lda c64.Colors + 40*row,x - sta c64.Colors + 40*(row-1),x - .next + .for row=1, row<=24, row+=1 + lda c64.Screen + 40*row,x + sta c64.Screen + 40*(row-1),x + lda c64.Colors + 40*row,x + sta c64.Colors + 40*(row-1),x + .next dex bpl - + rts -_scroll_screen ; scroll the screen memory +_scroll_screen ; scroll only the screen memory ldx #39 - - .for row=1, row<=24, row+=1 - lda c64.Screen + 40*row,x - sta c64.Screen + 40*(row-1),x - .next + .for row=1, row<=24, row+=1 + lda c64.Screen + 40*row,x + sta c64.Screen + 40*(row-1),x + .next dex bpl - @@ -189,26 +195,28 @@ asmsub scroll_down (ubyte alsocolors @ Pc) clobbers(A) { ; Carry flag determines if screen color data must be scrolled too %asm {{ stx P8ZP_SCRATCH_REG - bcs + - jmp _scroll_screen + bcc _scroll_screen -+ ; scroll the color memory ++ ; scroll the screen and the color memory ldx #39 - - .for row=23, row>=0, row-=1 - lda c64.Colors + 40*row,x - sta c64.Colors + 40*(row+1),x - .next + .for row=23, row>=0, row-=1 + lda c64.Colors + 40*row,x + sta c64.Colors + 40*(row+1),x + lda c64.Screen + 40*row,x + sta c64.Screen + 40*(row+1),x + .next dex bpl - + rts -_scroll_screen ; scroll the screen memory +_scroll_screen ; scroll only the screen memory ldx #39 - - .for row=23, row>=0, row-=1 - lda c64.Screen + 40*row,x - sta c64.Screen + 40*(row+1),x - .next + .for row=23, row>=0, row-=1 + lda c64.Screen + 40*row,x + sta c64.Screen + 40*(row+1),x + .next dex bpl - diff --git a/examples/balloonflight.p8 b/examples/balloonflight.p8 index ccc7abcb6..42a43b914 100644 --- a/examples/balloonflight.p8 +++ b/examples/balloonflight.p8 @@ -17,7 +17,7 @@ main { c64.SCROLX &= %11110111 ; 38 column mode - c64.set_rasterirq(1) ; enable animation + c64.set_rasterirq(40) ; enable animation ubyte target_height = 10 ubyte active_height = 24 diff --git a/examples/line-circle-txt.p8 b/examples/line-circle-txt.p8 index 64f3cc8db..81b284127 100644 --- a/examples/line-circle-txt.p8 +++ b/examples/line-circle-txt.p8 @@ -41,7 +41,7 @@ main { rect(10, 10, 10, 10, false) rect(6, 0, 16, 20, true) - ; test_stack.test() + test_stack.test() sub rect(ubyte x1, ubyte y1, ubyte x2, ubyte y2, ubyte fill) { @@ -140,21 +140,17 @@ main { ubyte xx while x>=y { - for xx in cx to cx+x { - txt.setcc(xx, cy + y as ubyte, 81, 1) - txt.setcc(xx, cy - y as ubyte, 81, 2) + xx = cx-x + repeat 2*x+1 { + txt.setcc(xx, cy + y as ubyte, 81, 11) + txt.setcc(xx, cy - y as ubyte, 81, 12) + xx++ } - for xx in cx-x to cx-1 { - txt.setcc(xx, cy + y as ubyte, 81, 3) - txt.setcc(xx, cy - y as ubyte, 81, 4) - } - for xx in cx to cx+y { - txt.setcc(xx, cy + x as ubyte, 81, 5) - txt.setcc(xx, cy - x as ubyte, 81, 6) - } - for xx in cx-y to cx { - txt.setcc(xx, cy + x as ubyte, 81, 7) - txt.setcc(xx, cy - x as ubyte, 81, 8) + xx = cx-y + repeat 2*y+1 { + txt.setcc(xx, cy + x as ubyte, 81, 13) + txt.setcc(xx, cy - x as ubyte, 81, 14) + xx++ } y++ if decisionOver2<=0 diff --git a/examples/test.p8 b/examples/test.p8 index 24e3159b4..681dc6c4d 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -7,27 +7,13 @@ main { sub start() { txt.fill_screen('.',2) - ubyte xx - ubyte yy = 0 - for xx in 0 to txt.DEFAULT_WIDTH-1 { - txt.setcc(xx, 0, xx, 1) - txt.setcc(xx, txt.DEFAULT_HEIGHT-1, xx, 1) - } - for yy in 0 to txt.DEFAULT_HEIGHT-1 { - txt.setcc(0, yy, yy,1) - txt.setcc(txt.DEFAULT_WIDTH-1, yy, yy, 1) - } - repeat { - delay() - txt.scroll_left(false) } } - sub delay () { ubyte tt - repeat 255 { + repeat 55 { repeat 255 { tt++ }