prog8/examples/c64/rasterbars.p8
Irmen de Jong 08ac459a41 breaking change: sys.set_irq() and sys.set_rasterirq() no longer have useKernal parameter! The irq handler routine must return a boolean instead in the A register.
When it returns true it means run the system IRQ handler afterwards. When it returns false, the system handler is NOT ran afterwards.
2023-11-21 23:22:53 +01:00

41 lines
973 B
Lua

%import syslib
%import math
main {
sub start() {
c64.SCROLY &= %11101111 ; blank the screen
sys.set_rasterirq(&irq.irqhandler, 40) ; register exclusive raster irq handler
repeat {
; enjoy the moving bars :)
}
}
}
irq {
const ubyte barheight = 3 ; should be big enough to re-trigger the Raster irq properly.
ubyte[] colors = [6,2,4,5,15,7,1,13,3,12,8,11,9]
ubyte color = 0
ubyte yanim = 0
sub irqhandler() -> bool {
if color!=len(colors) {
c64.EXTCOL = colors[color]
c64.RASTER += barheight ; next raster Irq for next color
color++
}
else {
c64.EXTCOL = 0
color = 0
yanim += 2
c64.RASTER = math.sin8u(yanim)/2+30 ; new start of raster Irq
}
c64.SCROLY &= $7f ; set high bit of the raster pos to zero
return false
}
}