From edd7abdca54f0c9f7b3710f5e90818ecb5b32e82 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 3 Apr 2021 20:58:42 -0700 Subject: [PATCH] Ported examples to new audio api --- build.sh | 2 +- projects/examples/dev.mouse.usm | 12 +++++++++--- projects/examples/dev.time.usm | 17 +++++++++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/build.sh b/build.sh index 64ac7b9..586f597 100755 --- a/build.sh +++ b/build.sh @@ -28,7 +28,7 @@ else fi echo "Assembling.." -./bin/assembler projects/examples/dev.audio.usm bin/boot.rom +./bin/assembler projects/examples/dev.time.usm bin/boot.rom echo "Running.." if [ "${2}" = '--cli' ]; diff --git a/projects/examples/dev.mouse.usm b/projects/examples/dev.mouse.usm index 6112419..335cf39 100644 --- a/projects/examples/dev.mouse.usm +++ b/projects/examples/dev.mouse.usm @@ -10,9 +10,11 @@ ;pointer { x 2 y 2 } ;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 } +|0100 ;Console { pad 8 char 1 byte 1 short 2 } |0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } |0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } |0150 ;Mouse { x 2 y 2 state 1 chord 1 } +|0170 ;Audio { ch1adsr 2 ch2adsr 2 ch3adsr 2 ch4adsr 2 ch1vol 1 ch1pitch 1 ch2vol 1 ch2pitch 1 ch3vol 1 ch3pitch 1 ch4vol 1 ch4pitch 1 } |01F0 ;System { pad 8 r 2 g 2 b 2 } |0200 ^RESET JMP |0204 ,ERROR JMP2 @@ -20,8 +22,10 @@ @RESET - ( theme ) #13fd =System.r #1ef3 =System.g #1bf2 =System.b + ( theme ) #03fd =System.r #0ef3 =System.g #0bf2 =System.b + #004f =Audio.ch1adsr #33 =Audio.ch1vol + BRK @FRAME @@ -32,9 +36,11 @@ BRK ,draw-cursor JSR2 ~Mouse.state #00 EQU ^$no-touch JNZ - ~Mouse.x =circle.xc - ~Mouse.y =circle.yc + ~Mouse.x DUP2 =circle.xc + ~Mouse.y DUP2 =circle.yc #0000 =circle.r + ( play sound ) ~Screen.width #000c DIV2 ADD2 #0002 DIV2 SWP POP =Audio.ch1pitch + ( release ) #00 =Mouse.state $no-touch ( draw ) diff --git a/projects/examples/dev.time.usm b/projects/examples/dev.time.usm index 880677b..8809b13 100644 --- a/projects/examples/dev.time.usm +++ b/projects/examples/dev.time.usm @@ -17,7 +17,7 @@ |0100 ;Console { pad 8 char 1 byte 1 short 2 } |0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } |0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } -|0170 ;Audio { ch1adsr 2 ch2adsr 2 ch3adsr 2 ch4adsr 2 ch1pitch 1 ch1vol 1 ch2pitch 1 ch2vol 1 ch3pitch 1 ch3vol 1 ch4pitch 1 ch4vol 1 } +|0170 ;Audio { ch1adsr 2 ch2adsr 2 ch3adsr 2 ch4adsr 2 ch1vol 1 ch1pitch 1 ch2vol 1 ch2pitch 1 ch3vol 1 ch3pitch 1 ch4vol 1 ch4pitch 1 } |0190 ;Time { year 2 month 1 day 1 hour 1 minute 1 second 1 dow 1 doy 2 isdst 1 get 1 } |01F0 ;System { pad 8 r 2 g 2 b 2 } @@ -33,6 +33,12 @@ ( theme ) #0ff8 =System.r #0f08 =System.g #0f08 =System.b + #1000 =Audio.ch1adsr + #66 =Audio.ch1vol + + #0003 =Audio.ch2adsr + #66 =Audio.ch2vol + BRK @FRAME @@ -43,9 +49,12 @@ BRK ~Time.second ~current.second NEQ #01 JNZ BRK ~Time.second =current.second - #1444 =Audio.ch1adsr - ~Time.second #1d ADD =Audio.ch1pitch - ~Time.second #03 AND #4b MUL #0f ADD =Audio.ch1vol + ( play sounds ) + #0d =Audio.ch1pitch + + ~Time.second #0f MOD #00 NEQ ^$no-tone JNZ + #0d #02 MUL =Audio.ch2pitch + $no-tone ( clear ) #0080 SCALEX #0080 SCALEY ~needles.sx ~needles.sy #00 ,draw-line JSR2