mirror of
https://github.com/irmen/prog8.git
synced 2024-07-30 01:29:08 +00:00
zsound stream test
This commit is contained in:
parent
69f3106062
commit
eb53e44cb0
@ -3,6 +3,8 @@ TODO
|
|||||||
|
|
||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
|
- bug: 2 repeats in same subroutine -> duplicate label error? see repeat_bug.p8
|
||||||
|
- bug: f_read() can't deal with running out of banked ram?
|
||||||
- add McCarthy evaluation to shortcircuit and/or expressions. Both conditional expressions and assignments!
|
- add McCarthy evaluation to shortcircuit and/or expressions. Both conditional expressions and assignments!
|
||||||
- add some more optimizations in vmPeepholeOptimizer
|
- add some more optimizations in vmPeepholeOptimizer
|
||||||
- vm Instruction needs to know what the read-registers/memory are, and what the write-register/memory is.
|
- vm Instruction needs to know what the read-registers/memory are, and what the write-register/memory is.
|
||||||
|
89
examples/cx16/zsound/stream-test-zcm.p8
Normal file
89
examples/cx16/zsound/stream-test-zcm.p8
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
%import textio
|
||||||
|
%import diskio
|
||||||
|
%import cx16diskio
|
||||||
|
%zpreserved $22,$2d ; zsound lib uses this region
|
||||||
|
|
||||||
|
|
||||||
|
main $0830 {
|
||||||
|
|
||||||
|
zsound_lib:
|
||||||
|
; this has to be the first statement to make sure it loads at the specified module address $0830
|
||||||
|
%asmbinary "zsound_combo-0830.bin"
|
||||||
|
|
||||||
|
; note: jump table is offset by 2 from the load address (because of prg header)
|
||||||
|
romsub $0832 = zsm_init() clobbers(A)
|
||||||
|
romsub $0835 = zsm_play() clobbers(A, X, Y)
|
||||||
|
romsub $0838 = zsm_playIRQ() clobbers(A, X, Y)
|
||||||
|
romsub $083b = zsm_start(ubyte bank @A, uword song_address @XY) clobbers(A, X, Y) -> ubyte @Pc
|
||||||
|
romsub $083e = zsm_stop()
|
||||||
|
romsub $0841 = zsm_setspeed(uword hz @XY) clobbers(A, X, Y)
|
||||||
|
romsub $0844 = zsm_setloop(ubyte count @A)
|
||||||
|
romsub $0847 = zsm_forceloop(ubyte count @A)
|
||||||
|
romsub $084a = zsm_noloop()
|
||||||
|
romsub $084d = zsm_setcallback(uword address @XY)
|
||||||
|
romsub $0850 = zsm_clearcallback() clobbers(A)
|
||||||
|
romsub $0853 = zsm_get_music_speed() clobbers(A) -> uword @XY
|
||||||
|
romsub $0856 = pcm_init() clobbers(A)
|
||||||
|
romsub $0859 = pcm_trigger_digi(ubyte bank @A, uword song_address @XY)
|
||||||
|
romsub $085c = pcm_play() clobbers(A, X, Y)
|
||||||
|
romsub $085f = pcm_stop() clobbers(A)
|
||||||
|
romsub $0862 = pcm_set_volume(ubyte volume @A)
|
||||||
|
|
||||||
|
const ubyte digi_bank = 1
|
||||||
|
const uword digi_address = $a000
|
||||||
|
const ubyte zcm_DIGITAB_size = 8 ; header size
|
||||||
|
const uword ram_bank_size = $2000
|
||||||
|
|
||||||
|
ubyte load_ok = false
|
||||||
|
|
||||||
|
sub prebuffer() {
|
||||||
|
txt.print("prebuffering...")
|
||||||
|
repeat 4 {
|
||||||
|
void cx16diskio.f_read(digi_address, ram_bank_size)
|
||||||
|
txt.print_ub(cx16.getrambank())
|
||||||
|
txt.spc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub start() {
|
||||||
|
txt.print("\nzsound digi streaming!\n")
|
||||||
|
|
||||||
|
if not diskio.f_open(8, "thriller.zcm") {
|
||||||
|
txt.print("?no file\n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cx16.rambank(digi_bank)
|
||||||
|
prebuffer()
|
||||||
|
|
||||||
|
pcm_init()
|
||||||
|
pcm_trigger_digi(digi_bank, digi_address)
|
||||||
|
irq_zsound_rambank_cache = digi_bank
|
||||||
|
cx16.set_irq(&zsm_playroutine, true)
|
||||||
|
|
||||||
|
txt.print("\nstreaming from file, playback in irq!\n")
|
||||||
|
uword size = 1
|
||||||
|
while size {
|
||||||
|
size = cx16diskio.f_read(digi_address, ram_bank_size) ; load next bank
|
||||||
|
txt.print_ub(cx16.getrambank())
|
||||||
|
txt.spc()
|
||||||
|
}
|
||||||
|
|
||||||
|
txt.print("file end.\n")
|
||||||
|
diskio.f_close()
|
||||||
|
|
||||||
|
repeat {
|
||||||
|
}
|
||||||
|
|
||||||
|
pcm_stop() ;unreached
|
||||||
|
}
|
||||||
|
|
||||||
|
ubyte irq_zsound_rambank_cache
|
||||||
|
sub zsm_playroutine() {
|
||||||
|
ubyte old_rambank = cx16.getrambank()
|
||||||
|
cx16.rambank(irq_zsound_rambank_cache)
|
||||||
|
pcm_play()
|
||||||
|
irq_zsound_rambank_cache = cx16.getrambank()
|
||||||
|
cx16.rambank(old_rambank)
|
||||||
|
}
|
||||||
|
}
|
@ -5,29 +5,6 @@
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
; sub ands(ubyte arg, ubyte b1, ubyte b2, ubyte b3, ubyte b4) -> ubyte {
|
|
||||||
; return arg>b1 and arg>b2 and arg>b3 and arg>b4
|
|
||||||
; }
|
|
||||||
;
|
|
||||||
; sub ors(ubyte arg, ubyte b1, ubyte b2, ubyte b3, ubyte b4) -> ubyte {
|
|
||||||
; return arg==b1 or arg==b2 or arg==b3 or arg==b4
|
|
||||||
; }
|
|
||||||
|
|
||||||
; sub mcCarthy() {
|
|
||||||
; ubyte @shared a
|
|
||||||
; ubyte @shared b
|
|
||||||
;
|
|
||||||
; txt.print_ub(ands(10, 2,3,4,5))
|
|
||||||
; txt.spc()
|
|
||||||
; txt.print_ub(ands(10, 20,3,4,5))
|
|
||||||
; txt.spc()
|
|
||||||
; txt.print_ub(ors(10, 2,3,40,5))
|
|
||||||
; txt.spc()
|
|
||||||
; txt.print_ub(ors(10, 1,10,40,5))
|
|
||||||
; txt.spc()
|
|
||||||
; }
|
|
||||||
|
|
||||||
|
|
||||||
sub funcFalse() -> ubyte {
|
sub funcFalse() -> ubyte {
|
||||||
txt.print("false() ")
|
txt.print("false() ")
|
||||||
return false
|
return false
|
||||||
@ -69,14 +46,13 @@ main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
; mcCarthy()
|
|
||||||
ubyte value
|
ubyte value
|
||||||
uword wvalue
|
uword wvalue
|
||||||
|
|
||||||
; txt.print("short and with false (word): ")
|
txt.print("short and with false (word): ")
|
||||||
; wvalue = funcw() and funcFalseWord() and funcw() and funcw()
|
wvalue = funcw() and funcFalseWord() and funcw() and funcw()
|
||||||
; txt.print_uw(wvalue)
|
txt.print_uw(wvalue)
|
||||||
; txt.nl()
|
txt.nl()
|
||||||
|
|
||||||
txt.print("short and with false: ")
|
txt.print("short and with false: ")
|
||||||
value = func1(25) and funcFalse()
|
value = func1(25) and funcFalse()
|
||||||
|
Loading…
Reference in New Issue
Block a user