mirror of
https://github.com/irmen/prog8.git
synced 2025-01-11 13:29:45 +00:00
fix gfx2 text color, added cx16 snow example
This commit is contained in:
parent
d08451bccc
commit
2d78eaa48d
@ -918,7 +918,7 @@ _done
|
||||
y++
|
||||
%asm {{
|
||||
phx
|
||||
ldx #1
|
||||
ldx color
|
||||
lda cx16.VERA_DATA1
|
||||
sta P8ZP_SCRATCH_B1
|
||||
ldy #8
|
||||
|
@ -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
|
||||
|
82
examples/cx16/snow.p8
Normal file
82
examples/cx16/snow.p8
Normal file
@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
@ -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![]<>#$%&*()")
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user