diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index 34845c4ab..6b9539b43 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -217,10 +217,12 @@ _done cx16.VERA_ADDR_H = (cx16.VERA_ADDR_H & %00000111) | (14<<4) %asm {{ ldy height + beq + lda color - sta cx16.VERA_DATA0 dey bne - ++ }} return } @@ -228,6 +230,10 @@ _done ; note for the 1 bpp modes we can't use vera's auto increment mode because we have to 'or' the pixel data in place. cx16.VERA_ADDR_H = (cx16.VERA_ADDR_H & %00000111) ; no auto advance cx16.r15 = gfx2.plot.bits[x as ubyte & 7] ; bitmask + if active_mode>=128 + cx16.r14 = 640/8 + else + cx16.r14 = 320/8 if color { if monochrome_dont_stipple_flag { repeat height { @@ -237,7 +243,7 @@ _done sta cx16.VERA_DATA0 lda cx16.VERA_ADDR_L clc - adc #640/8 ; advance vera data ptr to go to the next line + adc cx16.r14 ; advance vera ptr to go to the next line sta cx16.VERA_ADDR_L lda cx16.VERA_ADDR_M adc #0 @@ -248,7 +254,8 @@ _done }} } } else { - ; stippling + ; stippling. + height = (height+1)/2 %asm {{ lda x eor y @@ -256,21 +263,21 @@ _done bne + lda cx16.VERA_ADDR_L clc - adc #<640/8*1 ; advance vera data ptr to go to the next line, for correct stipple pattern + adc cx16.r14 ; advance vera ptr to go to the next line for correct stipple pattern sta cx16.VERA_ADDR_L lda cx16.VERA_ADDR_M adc #0 sta cx16.VERA_ADDR_M + - lsr height+1 - ror height + asl cx16.r14 ldy height + beq + - lda cx16.VERA_DATA0 ora cx16.r15 sta cx16.VERA_DATA0 lda cx16.VERA_ADDR_L clc - adc #<640/8*2 ; advance vera data ptr to go to the next-next line + adc cx16.r14 ; advance vera data ptr to go to the next-next line sta cx16.VERA_ADDR_L lda cx16.VERA_ADDR_M adc #0 @@ -280,6 +287,7 @@ _done ; sta cx16.VERA_ADDR_H dey bne - ++ }} } } else { @@ -291,7 +299,7 @@ _done sta cx16.VERA_DATA0 lda cx16.VERA_ADDR_L clc - adc #640/8 ; advance vera data ptr to go to the next line + adc cx16.r14 ; advance vera data ptr to go to the next line sta cx16.VERA_ADDR_L lda cx16.VERA_ADDR_M adc #0 diff --git a/examples/cx16/testgfx2.p8 b/examples/cx16/testgfx2.p8 index 10b72b869..3eab462c7 100644 --- a/examples/cx16/testgfx2.p8 +++ b/examples/cx16/testgfx2.p8 @@ -11,7 +11,7 @@ main { uword pixels = memory("pixels", 320) uword yy = 10 - uword xx = gfx2.width/2 + uword xx uword pp uword cnt pp=pixels @@ -24,17 +24,14 @@ main { for xx in 0 to 639 { gfx2.vertical_line(xx, 0, 480, 0) } - cx16.wait(200) - gfx2.screen_mode(255) - txt.print("done!\n") - return - for cnt in 0 to 319 { @(pp) = 255 pp++ } + xx=gfx2.width/2 + yy=10 gfx2.monochrome_stipple(false) linesy() linesx() @@ -42,6 +39,8 @@ main { linesy() linesx() + + sub linesx() { repeat 8 { gfx2.horizontal_line(10,yy,300,3) @@ -126,7 +125,7 @@ main { xx+=4 } - ; cx16.wait(3*60) + cx16.wait(3*60) gfx2.screen_mode(255) txt.print("done!\n") diff --git a/examples/test.p8 b/examples/test.p8 index fecd67e8a..e413c6eb8 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -9,14 +9,23 @@ main { sub start () { - ; differences between: -; @(pp) = cnt as ubyte -; @(pp) = lsb(cnt) -; @(pp) = msb(cnt) -; repeat w as ubyte / repeat lsb(w) + uword cnt + ubyte ub -; stack based evaluation for this function call even when it's inlined: -; gfx2.next_pixel((cnt as ubyte) + 30) + + ; TODO differences between: + + repeat cnt as ubyte { ; TODO this goes via stack + ub++ + } + + repeat lsb(cnt) { ; TODO this doesnt + ub++ + } + + + ; TODO stack based evaluation for this function call even when it's inlined: + next_pixel((cnt as ubyte) + 30) test_stack.test() @@ -24,4 +33,11 @@ main { } + inline asmsub next_pixel(ubyte color @A) { + %asm {{ + nop + }} + } + + }