added cx16 rasterbars example

This commit is contained in:
Irmen de Jong 2021-02-22 01:44:07 +01:00
parent 334f86480a
commit e65c5402d7
3 changed files with 77 additions and 44 deletions

View File

@ -614,13 +614,8 @@ asmsub set_rasterirq(uword handler @AY, uword rasterpos @R0) clobbers(A) {
ora #%00000010 ; enable the line (raster) irq
sta cx16.VERA_IEN
lda cx16.r0
sta cx16.VERA_IRQ_LINE_L
lda cx16.r0+1
lsr a
ror a
and #%10000000
ora cx16.VERA_IEN
sta cx16.VERA_IEN ; high bit of the raster line
ldy cx16.r0+1
jsr set_rasterline
lda #<_raster_irq_handler
sta cx16.CINV
lda #>_raster_irq_handler
@ -643,6 +638,22 @@ _modified jsr $ffff ; modified
}}
}
asmsub set_rasterline(uword line @AY) {
%asm {{
sta cx16.VERA_IRQ_LINE_L
lda cx16.VERA_IEN
and #%01111111
sta cx16.VERA_IEN
tya
lsr a
ror a
and #%10000000
ora cx16.VERA_IEN
sta cx16.VERA_IEN
rts
}}
}
}

View File

@ -0,0 +1,53 @@
%import textio
main {
sub start() {
cx16.screen_set_mode(0)
txt.plot(14,14)
txt.print("raster bars!")
cx16.set_rasterirq(&irq.irq, 0)
repeat {
; don't exit
}
}
}
irq {
uword[32] colors = [
$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
]
uword next_irq_line = 0
ubyte color_idx = 0
ubyte yanim = 0
const ubyte barheight = 4
sub irq() {
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
}
; set new screen background color
cx16.vpoke(1, $fa00, lsb(c))
cx16.vpoke(1, $fa01, msb(c))
cx16.set_rasterline(next_irq_line)
}
}

View File

@ -1,47 +1,16 @@
%import textio
%zeropage dontuse
%option no_sysinit
main {
; $1F9C0 - $1F9FF PSG registers
sub start() {
cx16.set_rasterirq(&irq.irq, 100)
;cx16.set_irq(&irq.irq, true)
sys.wait(100)
cx16.restore_irq()
txt.print("tone")
; uword freq = 1181
; cx16.vpoke(1, $f9c0, lsb(freq))
; cx16.vpoke(1, $f9c1, msb(freq))
; cx16.vpoke(1, $f9c2, %11111111) ; volume
; cx16.vpoke(1, $f9c3, %11000000) ; triangle waveform
}
}
irq {
%option force_output
uword counter = 0
sub irq() {
cx16.vpoke(1, $fa00+6*2, lsb(counter))
cx16.vpoke(1, $fa01+6*2, msb(counter))
repeat 20 {
uword xx
repeat 16 {
xx++
}
cx16.vpoke(1, $fa00+6*2, 0)
cx16.vpoke(1, $fa01+6*2, 255)
repeat 16 {
xx++
}
cx16.vpoke(1, $fa00+6*2, 0)
cx16.vpoke(1, $fa01+6*2, 0)
}
counter++
uword freq = 1181
cx16.vpoke(1, $f9c0, lsb(freq))
cx16.vpoke(1, $f9c1, msb(freq))
cx16.vpoke(1, $f9c2, %11111111) ; volume
cx16.vpoke(1, $f9c3, %11000000) ; triangle waveform
}
}