diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index 32092b9e5..37f222cca 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -918,7 +918,7 @@ _done y++ %asm {{ phx - ldx #1 + ldx color lda cx16.VERA_DATA1 sta P8ZP_SCRATCH_B1 ldy #8 diff --git a/docs/source/todo.rst b/docs/source/todo.rst index b7e24ddf4..8668342a1 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,6 +3,14 @@ TODO For next release ^^^^^^^^^^^^^^^^ +- fix compiler error about containment + if xx[idx]==0 or xx[idx]==319 { + ; nothing here, if a call is here the error doesn't trigger !?? + ; gfx2.plot(xx[idx], yy[idx], PILED_SNOW_COLOR) + } else { + ... + } + - 6502 codegen: make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as ``p8v_``? Or not worth it (most 3 letter opcodes as variables are nonsensical anyway) then we can get rid of the instruction lists in the machinedefinitions as well. This is already no problem at all in the IR codegen. - create BSS section in output program and put StStaticVariables in there with bss=true. Don't forget to add init code to zero out everything that was put in bss. If array in bss->only zero ONCE! So requires self-modifying code diff --git a/examples/cx16/snow.p8 b/examples/cx16/snow.p8 new file mode 100644 index 000000000..afb9b298b --- /dev/null +++ b/examples/cx16/snow.p8 @@ -0,0 +1,82 @@ +%import math +%import gfx2 + +main { + sub start() { + gfx2.screen_mode(4) + + uword[128] xx + uword[128] yy + + ubyte @zp idx + for idx in 0 to 127 { + xx[idx] = math.rndw() % 320 + yy[idx] = math.rndw() % 240 + } + + gfx2.text(96, 90, 2, sc:"**************") + gfx2.text(104, 100, 5, sc:"let it snow!") + gfx2.text(96, 110, 2, sc:"**************") + + const ubyte FALLING_SNOW_COLOR = 1 + const ubyte PILED_SNOW_COLOR = 15 + + repeat { + sys.waitvsync() + for idx in 0 to 127 { + gfx2.plot(xx[idx], yy[idx], FALLING_SNOW_COLOR) + } + sys.waitvsync() + for idx in 0 to 127 { + if yy[idx]==239 { + ; reached the floor + gfx2.plot(xx[idx], yy[idx], PILED_SNOW_COLOR) + yy[idx] = 0 + xx[idx] = math.rndw() % 320 + } else if gfx2.pget(xx[idx], yy[idx]+1)==PILED_SNOW_COLOR { + ; pile up + uword @zp snowx = xx[idx] + if snowx!=0 and snowx!=319 { ; check to avoid x coordinate under/overflow + uword pilex1 + uword pilex2 + if math.rnd() & 1 { + pilex1 = snowx-1 + pilex2 = snowx+1 + } else { + pilex1 = snowx+1 + pilex2 = snowx-1 + } + if gfx2.pget(pilex1, yy[idx]+1)==0 { + gfx2.plot(snowx, yy[idx], 0) + gfx2.plot(pilex1, yy[idx]+1, PILED_SNOW_COLOR) + } else if gfx2.pget(pilex2, yy[idx]+1)==0 { + gfx2.plot(snowx, yy[idx], 0) + gfx2.plot(pilex2, yy[idx]+1, PILED_SNOW_COLOR) + } else { + gfx2.plot(snowx, yy[idx], PILED_SNOW_COLOR) + } + } + yy[idx] = 0 + xx[idx] = math.rndw() % 320 + } else { + ; fall + gfx2.plot(xx[idx], yy[idx], 0) + yy[idx]++ + when math.rnd() & 3 { + 1 -> { + if xx[idx] + xx[idx]-- + } + 2 -> { + if xx[idx] < 319 + xx[idx]++ + } + } + } + } + } + + repeat { + } + } +} diff --git a/examples/cx16/testgfx2.p8 b/examples/cx16/testgfx2.p8 index 1cbf523a0..24773f1e0 100644 --- a/examples/cx16/testgfx2.p8 +++ b/examples/cx16/testgfx2.p8 @@ -192,7 +192,7 @@ main { ubyte tp for tp in 0 to 15 { - gfx2.text(19+tp,20+tp*11, 5, sc:"ScreenCODE text! 1234![]<>#$%&*()") + gfx2.text(19+tp,20+tp*11, 7, sc:"ScreenCODE text! 1234![]<>#$%&*()") } }