From 14ee367e565bf51977a9660c5b295fbff02e44ec Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Tue, 18 Mar 2025 09:00:38 -0700 Subject: [PATCH] Simplify music sequence parameters --- src/dhgr.tk/demos/darthgr/DARTHGR.REL | Bin 593 -> 390 bytes src/dhgr.tk/demos/darthgr/darthgr.pla | 20 ++------------ src/inc/sndseq.plh | 3 ++- src/libsrc/apple/sndseq.pla | 36 +++++++++++++++++++++----- 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/dhgr.tk/demos/darthgr/DARTHGR.REL b/src/dhgr.tk/demos/darthgr/DARTHGR.REL index 40d08183aba9ef975800184fd49531b9816f78d6..6d0911a10031509c181472d40e30fa24afa3e41f 100644 GIT binary patch literal 390 zcmXX>O-lk%6g{KjS>h#3_7LKhmEe>4O9>W@t{p0vS>fdJq5<%m*%Aqdahi-%Bou_T4)5v; zo$jd`7=(@9`9M*7@|iGHuDBAowj=LmK=1o0a=kj~r%C)aHi_nCGC^xHc+jFX6sUx} zb_CESa#{<}jyZ2bq(cuE@Ao%veG4_cV%APNg>_2nakI!tsPI93zbL<38*1`_y$V5UZ6$c} zvfx3m7jJ?f2%-lMvSz30>Shymw^9#+7cZW?310NgMjU3|_r2eHZy1=9sdT%6Dy31Q z{?LuSsJ<5n)d>gcf#(aa>K+b4-@7E`DE53c3fxFs#s8IC)6Bif^yRv?qj#?FVoN!_ zXKJnX#S6-fyW0(bcYd}+EZqg_&Qk)EQ!O6Tm6m?flnqL@b7!Y*cC_2dZu_2*L-YP3 z>5H^pmhI<}>dE;fiHs$A7ssA)2F-3UVT5L$(VL>INhin7(QGxz&&uSHF;BhpzOg{L zhnfA!i}HEdJ}m>b(p7?e4J)>WlGO%m9YyOFU~RKEQLrDNVn4==^@Q0|X3s$ObL6ZS zoWJDrirH&qt+%Z2xbHo)59|f|kL-u+$C$EW)?;i~Us=DQW`D<=^@Hm_`TSz`8_V_| zWb6~E0tO;pr3?;*GafqO70M>o@%_;%-4w-2Nc!kNi=c z<{&?DIC9HWNN^O_Y5AWE#c?cxSfyeD4n{$PN??gY;jGaLqJAhukR%lhk0P%>_MJ`I Nn0S8XC$UL2;4f#$;XVKW diff --git a/src/dhgr.tk/demos/darthgr/darthgr.pla b/src/dhgr.tk/demos/darthgr/darthgr.pla index 8a63181..59d4da8 100644 --- a/src/dhgr.tk/demos/darthgr/darthgr.pla +++ b/src/dhgr.tk/demos/darthgr/darthgr.pla @@ -1,6 +1,4 @@ include "inc/cmdsys.plh" -include "inc/lines.plh" -include "inc/args.plh" include "inc/fileio.plh" include "dhgr.tk/inc/dhgrlib.plh" include "dhgr.tk/inc/dhgrutils.plh" @@ -9,27 +7,13 @@ include "inc/sndseq.plh" sysflags resxtxt1|reshgr1|resxhgr1 var strWidth, strHeight -byte ref -var seq, len char darthstr = "DartH GRaphics" - -def backgroundProc#0 - return -end - dcgrFont(fontRead("trade54.fon")) strWidth, strHeight = dcgrStrExtents(@darthstr) dhgrMode(DHGR_COLOR_MODE) screenRead("darth.dhgr") -ref = fileio:open("imperial.seq") -if ref - seq = heapalloc(heapavail - 256) - len = fileio:read(ref, seq, heapmark - seq) - fileio:close(ref) - heaprelease(seq + len) - musicPlay(seq, FALSE) - musicGetKey(16, @backgroundProc) // Yield every 16/16 second -fin +musicPlay(musicRead("imperial.seq"), FALSE) +musicGetKey(16, NULL) // Yield every 16/16 second dcgrColor(CLR_WHITE) dcgrStr((140 - strWidth) / 2, (strHeight * 7) / 8, @darthstr) getc diff --git a/src/inc/sndseq.plh b/src/inc/sndseq.plh index b20a464..e5530ea 100644 --- a/src/inc/sndseq.plh +++ b/src/inc/sndseq.plh @@ -2,5 +2,6 @@ import sndseq word musicSequence // musicSequence(yield, backgroundProc)#0 word spkrTone // spkrTone(pitch, duration)#0 word spkrPWM // spkrPWM(sample, speed, len)#0 - predef musicPlay(track, rept)#0, musicStop#0, musicGetKey(yield, backgroundProc)#1 + predef musicPlay(track, rept)#0, musicStop#0 + predef musicGetKey(yield, backgroundProc)#1, musicRead(filename)#1 end diff --git a/src/libsrc/apple/sndseq.pla b/src/libsrc/apple/sndseq.pla index 5539fd7..0a1d62e 100755 --- a/src/libsrc/apple/sndseq.pla +++ b/src/libsrc/apple/sndseq.pla @@ -366,6 +366,8 @@ asm a2keypressed DEY + STY ESTKL,X STY ESTKH,X +end +asm nopBackground#0 RTS end def a3keypressed @@ -833,15 +835,35 @@ export def musicGetKey(yield, backgroundProc)#1 char key key = 0 - repeat - musicSequence(yield, backgroundProc)#0 // Call background proc every half second - if keypressed() - key = getc - seqRepeat = FALSE - fin - until not seqRepeat + if backgroundProc == NULL; backgroundProc = @nopBackground; fin + if seqTrack + repeat + musicSequence(yield, backgroundProc)#0 // Call background proc every half second + if keypressed() + key = getc + seqRepeat = FALSE + fin + until not seqRepeat + fin return key end +// +// Read sequence onto heap +// +export def musicRead(filename)#1 + byte ref + word seq, len + + seq = NULL + ref = fileio:open(filename) + if ref + seq = heapalloc(heapavail - 256) + len = fileio:read(ref, seq, heapmark - seq) + fileio:close(ref) + heaprelease(seq + len) + fin + return seq +end when MACHID & MACHID_MODEL is MACHID_III