diff --git a/src/dhgr.tk/demos/darthgr/DARTHGR.REL b/src/dhgr.tk/demos/darthgr/DARTHGR.REL index 40d0818..6d0911a 100644 Binary files a/src/dhgr.tk/demos/darthgr/DARTHGR.REL and b/src/dhgr.tk/demos/darthgr/DARTHGR.REL differ 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