From 8ab99f6129d6f3570924020b9c703735427a3582 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 19 Jun 2022 16:20:59 +0200 Subject: [PATCH] zsound combo example --- examples/cx16/zsound/pcmplayer-0830.bin | Bin 750 -> 0 bytes examples/cx16/zsound/play-pcm.p8 | 62 ------------------ .../zsound/{play-zsm.p8 => play-zsound.p8} | 53 ++++++++++++--- examples/cx16/zsound/zsmplayer-0830.bin | Bin 1130 -> 0 bytes examples/cx16/zsound/zsound_combo-0830.bin | Bin 0 -> 1910 bytes 5 files changed, 43 insertions(+), 72 deletions(-) delete mode 100644 examples/cx16/zsound/pcmplayer-0830.bin delete mode 100644 examples/cx16/zsound/play-pcm.p8 rename examples/cx16/zsound/{play-zsm.p8 => play-zsound.p8} (60%) delete mode 100644 examples/cx16/zsound/zsmplayer-0830.bin create mode 100644 examples/cx16/zsound/zsound_combo-0830.bin diff --git a/examples/cx16/zsound/pcmplayer-0830.bin b/examples/cx16/zsound/pcmplayer-0830.bin deleted file mode 100644 index e406d433b99b80dd765123003ca6fdbc8e827a3a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 750 zcmXrw@Nwku@#63~!r}9n)8{>>!eh>r{Jqxm6WWwpR8|3bOBs4wIocQ&uy0hJDa73& z@MEn6x28d_1ov9&`I`Kk4ZITEK;`QsxfMD&&Ixh@(aQg=3<;+UO!xfbY*E=$$JL@d zN0xhzH1{H=PJs`MFFF-~1e=PUG&h^Fo-FsN3!j&&^h$9rRqmDHmPi1)Vyz(e2UY_X zph*c5D>-!4=U?Dy5LqkB-Kw%yhPzdHtu%-w1!9SETRc@>wN{M#smhAA;@mG83K#N^bpjLhuZyn@2w(z1%m>e{-7rsmeRj;`+Bz6p~iPn|wv*6g|S z7c5%5boq)^Yu2vcuxZQI?K^hu*}MP1p(96+pFDNu?0H5e7FKpnE*?I9K_L-L2N;1I zU}a-#@95;>>h9^~?W?%T}yfy>{J(jhnY_1G-?}{)2~(90R!^z}Z(Jz{fGtHAunJ&)Fx`#npuY G82|uVk{DM2 diff --git a/examples/cx16/zsound/play-pcm.p8 b/examples/cx16/zsound/play-pcm.p8 deleted file mode 100644 index ff9836ddd..000000000 --- a/examples/cx16/zsound/play-pcm.p8 +++ /dev/null @@ -1,62 +0,0 @@ -%import textio -%import cx16diskio -%import palette -%zeropage basicsafe -%zpreserved $22,$26 ; zsound lib uses this region - - -;; Proof Of Concept ZCM player using a binary blob version of zsound library by ZeroByte relocated to something usable here. - -; "issues": see play-zsm.p8 - - -main $0830 { - -zsound_lib: - ; this has to be the first statement to make sure it loads at the specified module address $0830 - %asmbinary "pcmplayer-0830.bin" - - ; note: jump table is offset by 2 from the load address (because of prg header) - romsub $0832 = pcm_init() clobbers(A) - romsub $0835 = pcm_trigger_digi(ubyte bank @A, uword song_address @XY) - romsub $0838 = pcm_play() clobbers(A, X, Y) - romsub $083b = pcm_stop() clobbers(A) - romsub $083e = pcm_set_volume(ubyte volume @A) - - const ubyte digi_bank = 1 - const uword digi_address = $a000 - const ubyte zcm_DIGITAB_size = 8 ; header size - - sub start() { - txt.print("zsound pcm digi demo program!\n") - - c64.SETMSG(%10000000) ; enable kernal status messages for load - if not cx16diskio.load_raw(8, "terminator2.zcm", digi_bank, digi_address) { - txt.print("?can't load\n") - return - } - c64.SETMSG(0) - - cx16.rambank(digi_bank) - ; initialize header pointer of the zcm to point to actual sample data - poke(digi_address+2, digi_bank) - pokew(digi_address, digi_address+zcm_DIGITAB_size) - - pcm_init() - txt.print("\nplaying digi! hit enter to stop.\n") - pcm_trigger_digi(digi_bank, digi_address) - while cx16.joystick_get2(0)==$ffff { - sys.waitvsync() - repeat 1000 { - ; artificially delay calling the play routine so we can see its raster time - %asm {{ - nop - }} - } - palette.set_color(0, $0c5) - pcm_play() - palette.set_color(0, $000) - } - pcm_stop() - } -} diff --git a/examples/cx16/zsound/play-zsm.p8 b/examples/cx16/zsound/play-zsound.p8 similarity index 60% rename from examples/cx16/zsound/play-zsm.p8 rename to examples/cx16/zsound/play-zsound.p8 index 44945683f..548439233 100644 --- a/examples/cx16/zsound/play-zsm.p8 +++ b/examples/cx16/zsound/play-zsound.p8 @@ -2,10 +2,11 @@ %import cx16diskio %import palette %zeropage basicsafe -%zpreserved $22,$28 ; zsound lib uses this region +%zpreserved $22,$2d ; zsound lib uses this region -;; Proof Of Concept ZSM player using a binary blob version of zsound library by ZeroByte relocated to something usable here. +;; Proof Of Concept Zsound player using a binary blob version of zsound library by ZeroByte relocated to something usable here. +;; Can play ZSM (music) and ZCM (pcm samples). ; "issues": ; - prog8 (or rather, 64tass) cannot "link" other assembly object files so we have to incbin a binary blob. @@ -21,7 +22,7 @@ main $0830 { zsound_lib: ; this has to be the first statement to make sure it loads at the specified module address $0830 - %asmbinary "zsmplayer-0830.bin" + %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) @@ -36,40 +37,72 @@ zsound_lib: 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 song_bank = 4 + const ubyte song_bank = 1 const uword song_address = $a000 + const ubyte digi_bank = 5 + const uword digi_address = $a000 + const ubyte zcm_DIGITAB_size = 8 ; header size sub start() { txt.print("zsound demo program!\n") + c64.SETMSG(%10000000) ; enable kernal status messages for load if not cx16diskio.load_raw(8, "colony.zsm", song_bank, song_address) { - txt.print("?can't load song\n") + txt.print("?can't load\n") return } + if not cx16diskio.load_raw(8, "terminator2.zcm", digi_bank, digi_address) { + txt.print("?can't load\n") + return + } else { + ; initialize header pointer of the zcm to point to actual sample data + ; this will be set correcly by zsound lib itself if left at zero + ; poke(digi_address+2, digi_bank) + ; pokew(digi_address, digi_address+zcm_DIGITAB_size) + } + c64.SETMSG(0) + txt.nl() cx16.rambank(song_bank) + play_music() + } + + sub play_music() { zsm_init() + pcm_init() zsm_setcallback(&end_of_song_cb) if zsm_start(song_bank, song_address)==0 { - txt.print("music speed: ") + txt.print("\nmusic speed: ") txt.print_uw(zsm_get_music_speed()) - txt.print(" hz\nplaying song! hit enter to stop.\n") + txt.print(" hz\nplaying song! hit enter to also play a digi sample!\n") ; for IRQ based playback instead: cx16.set_irq(&zsm_playIRQ, true) - while cx16.joystick_get2(0)==$ffff { + + repeat { + if cx16.joystick_get2(0)!=$ffff + pcm_trigger_digi(digi_bank, digi_address) + sys.waitvsync() - repeat 800 { + repeat 1400 { ; artificially delay calling the play routine so we can see its raster time %asm {{ nop }} } - palette.set_color(0, $0c5) + palette.set_color(0, $84c) + pcm_play() + palette.set_color(0, $f25) zsm_play() palette.set_color(0, $000) } zsm_stop() + pcm_stop() } else { txt.print("?song start error\n") } diff --git a/examples/cx16/zsound/zsmplayer-0830.bin b/examples/cx16/zsound/zsmplayer-0830.bin deleted file mode 100644 index 76042958b612d0be8cd6ce1f7d567b1c66ead860..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1130 zcmah|O=ufO6kbWIGLoK4(xjl6mTq?S=a3fBOB_+CeKDpiIR-;0EJX=5$PFbuD7Hk` zt;g7kW}_N6O<~Q7g)JG=ZG{Mh9NLB++Q_G&$L69-jgv#!rib7J;=GaD(p$yy-puTK zpT2qDw{H^jCt`j?%my)ADO04)Gimc3Fe_l51M>oyRWLtO!QS35E&k*&b{#B!+)q)REy1ecG@zPuo8T^k z`w6(8LbX&a@E9#J2Cf5c8{8FeDOmO(*10^0Me*KzSck!)crUyPg9ULRY=Sr%Hb6kQ z1cM{Jq`L%mQj1c(sjvk!N0o35s2;8ZHMH{tAAYc*vqiuac5LV}H~!8|%zg$>cEppc zHHr72xmA6|U@dUgpuG-XDZf$0SNi%^T>|V4k97VD7h!M^CAF7Rz4A9J@HGYPOj^=9 z9>_}u25Uf&V@=S`Av3OM6~G(jv+s`vHEBQ2BEy9xz*=Ov(17iU*HT?lMHaVdUD-4Ty1U!57P_5;MFg&=;hi2sbJw1iXi6|Q}-44v`Q(_Z;$m$aw6ht9M& z+A&qDitTflYG}kjUS2uoV8GLf8lXMNwPMkKp9r0*QJT!*{ zJ^N~f=0!F@wf}98{nKubSrZ?NL~Rpj-aJqGdO2F35-+9hA}VUw*O?)+y*u%C^vbpr zzkI*1-@?U+A9BT#Y0v)su=qRakG?Jo536`)mcKj856X#J2WlID9~4(=H-IZ*irc^H z;w<_M9oRqzqNFq@)&JvOMk{CBdztVWM8_)Z8XCCn|LAOjpK(5ixp6;+5Eg#SS(HMK z6ve=47Ev8JR6&BGP^}6rA(<#X=CdxBiQ2)twvA{sQ0B`4xr~ O35GfA(6yHGzrW{^H>=M8 diff --git a/examples/cx16/zsound/zsound_combo-0830.bin b/examples/cx16/zsound/zsound_combo-0830.bin new file mode 100644 index 0000000000000000000000000000000000000000..d944497256617fc93c72be4aadcc5931b035faf7 GIT binary patch literal 1910 zcmb7EYj6`)6yCgGlkDacK@AJOQb8SOa2RK}4gKNOjvo?FymM*o<(bI!e+bH4rV zIp3bCtoS7>u4lz|R_t<%-+9CekGO~vqnx;e6IXEJN=}qHaRVnNI5EtNQJ=WbcQTN* zNqR6hb2z~osgumfysT3R`X%8zPl+Vy`B_Kp7NGu|&X6OlnXi%0ST$cW1&w^jnv*ng zkTnAu*~c1erLngXqm5w_(9lexMxZ7ijlxLP`NC;7&7@dkU2-FAO(tMyXwYN*V%SI= zBqNx1D*;ju&B1sBROhLUpvs`W0O~rZF03vvY)Xi9fJ#7Z2X#HDO(4k`TjGg~Eo<*v zZmxz*z4fpegG`;Z*lYxAjM)GdXVya|r_ZIsnR#5U3#@ql(z-$2}DAcgH zjNwfIvIcO68JhysH~i%r(WkxmWWf5vFO}dul)UCZQ;@Vmd;@f}z%J$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