prog8/examples/cx16/rasterbars.p8

58 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-02-22 00:44:07 +00:00
%import textio
2021-02-23 23:01:27 +00:00
%import palette
2021-02-22 00:44:07 +00:00
2021-03-03 00:09:18 +00:00
; horizontal raster bars
; also see: kefrenbars.p8
2021-02-22 00:44:07 +00:00
main {
sub start() {
2021-12-29 23:58:33 +00:00
void cx16.screen_set_mode(0)
2021-02-22 00:44:07 +00:00
txt.plot(14,14)
txt.print("raster bars!")
cx16.set_rasterirq(&irq.irqhandler, 0)
2021-02-22 00:44:07 +00:00
repeat {
; don't exit
}
}
}
irq {
uword[32] colors = [
2021-02-23 23:01:27 +00:00
$011, $112, $213, $214,
$315, $316, $417, $418,
$519, $51a, $62b, $62c,
$73d, $73e, $84f, $94f,
$93e, $83d, $82c, $72b,
$71a, $619, $618, $517,
$516, $415, $414, $313,
$312, $211, $100, $000
2021-02-22 00:44:07 +00:00
]
uword next_irq_line = 0
ubyte color_idx = 0
ubyte yanim = 0
const ubyte barheight = 4
sub irqhandler() {
2021-02-22 00:44:07 +00:00
uword c = colors[color_idx]
color_idx++
color_idx &= 31
if color_idx==0 {
yanim++
next_irq_line = $0030 + sin8u(yanim)
} else {
next_irq_line += barheight
}
2021-02-23 23:01:27 +00:00
palette.set_color(0, c)
2021-02-22 00:44:07 +00:00
cx16.set_rasterline(next_irq_line)
}
}