First Spear Posted March 2, 2017 Share Posted March 2, 2017 Hey gurus. Can you take a look at this and recommend a way to make this code more compact? The sound plays as I want, but I am sure the calling code could be more efficient. Rather than "programming the PSG", I am just blasting words at it to get the sound to play. Thanks. Include "Constants.bas" Wait Mode 0 , 0,0,0,0 Wait CLS LoopMain: Gosub PlayDis For #spinWait = 0 to 120 Wait Next #spinWait Wait Goto LoopMain SoundResetAll: Procedure SOUND 0,1,0 SOUND 1,1,0 SOUND 2,1,0 SOUND 4,,$38 RETURN END PlayDis: Procedure Print At 200 Color CS_DARKGREEN , "Sound Begin" GoSub SoundResetAll #seekAddr = 40960 #valTemp = 1 #sndCounter = 0 #soundVol = 15 Sound 2 ,1 , 0 While PEEK(#seekAddr) <> $FFFF #toneTemp = Peek(#seekAddr) If #toneTemp = $1000 Then Wait #seekAddr = #seekAddr + 1 ElseIf #toneTemp = $0 Then Sound 2 , 1 , 0 Wait #seekAddr = #seekAddr + 1 ElseIf #toneTemp <> $FFFF Then #seekAddr = #seekAddr + 1 #soundVol = Peek(#seekAddr) Sound 2 , #toneTemp , #soundVol Wait #seekAddr = #seekAddr + 1 End If Wend Sound 2 ,1 , 0 For #spinWait = 0 to 30 Wait Next #spinWait Print At 200 Color CS_WHITE , "Sound End " For #spinWait = 0 to 50 Wait Next #spinWait CLS Return End ASM ORG $A000 Guuooiiii: Data $0c1, $d , $0b1, $d , $0a1, $d , $091, $d , $081, $d , $071, $d , $061, $d , $051, $d , $041, $d , $031, $d , $021, $d , $011, $d , $001, $d , $FFFF PlayDis0.bas Quote Link to comment Share on other sites More sharing options...
mmarrero Posted March 2, 2017 Share Posted March 2, 2017 Hi! I posted a while ago a Sound demo. My unused sound routine is compact enough, although I use odd values to lower volume instead of reading volume data. http://atariage.com/forums/topic/261295-tron-sounds-and-music/ I rewrote your sound loop (sorry for the gotos), I eliminated the $1000 check, just repeat sound/volume values in your data. SoundLoop: #toneTemp = Peek(#seekAddr) If #toneTemp = $0 Then Sound 2 , 1 , 0 ElseIf #toneTemp = $FFFF Then GOTO SoundEnd ELSE #seekAddr = #seekAddr + 1 #soundVol = Peek(#seekAddr) Sound 2 , #toneTemp , #soundVol End If WAIT #seekAddr = #seekAddr + 1 GOTO SoundLoop SoundEnd: Quote Link to comment Share on other sites More sharing options...
First Spear Posted March 2, 2017 Author Share Posted March 2, 2017 Thanks for the idea. I do use the $1000 in some sounds to add an additional wait to make the PSG play a little longer but you have me something more to think about here. Thank you! Quote Link to comment Share on other sites More sharing options...
mmarrero Posted October 9, 2017 Share Posted October 9, 2017 I made an interactive PSG sound envelope utility that also displays the Sound commands to use. I included binary and source. Usage: Up/down to select option, right/left to pick digit, then up/down to change it. B1/B2 is faster, B0 to replay. Any keypad starts input. Red numbers numbers means it's GUI value, PSG value is displayed next to them. Sound statements are shown hex, GUI values are in Dec. I recommend experimenting with tones, using cycle/triangle envelopes with low envelope frequency values for interesting sounds (motor-like). If there's any error compiling, please use the newest version of IntyBasic, and fix 2 "bugs" in constants.bas. (comments ends with line continuation "\", my fix is "...") CONST PSG_ENVELOPE_CYCLE_RAMP_DOWN_SAWTOOTH =$08 '\\\\\\\... CONST PSG_ENVELOPE_CYCLE_RAMP_DOWN_TRIANGLE =$0A '\/\/\/\... psg(source).zip PSG.rom 4 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.