Closed bobbimanners closed 1 year ago
Fails in Crossrunner the same way it does on real hardware, so I probably need to install Crossrunner to debug this.
The file 'LANDMUS' is the same song and fails at the same place, but the code is cleaner and doesn't have the visualization and other bling.
'LANDMUS' runs on real hardware if I delete line 790, which seems to be redundant anyhow.
@jgharston Any ideas? This one is a bit of a head scratcher.
Actually I spoke too soon. It is wildly inconsistent whether it runs all the way to the end when running on a real GS (and also seems to fail the same way in Crossrunner, so I am told.)
Hmm. Well LandDemo sets up some interupt-driven machine code, but LandMus on its own just plays music and should work on its own.
Yes, LandMus is nice and straightforward in its coding, as you say. I will probably install Crossrunner (GS emulator for Windows) to try to investigate this. It is intriguing that it works on MAME flawlessly, but chokes non-deterministically on real hardware (and Crossrunner, so I am told.)
@jgharston Incidentally, I have been enjoying your arrangement of 'All Creatures Great and Small'. Has been a few years since I heard that!
'ARENAII' also plays nicely in MAME but chokes on real hardware.
I recalibrated the Ensoniq note frequency using a tuner app on my iPhone. This also calibrates the duration accurately, since it is based on a 100Hz note from the Ensoniq. After the recalibration, I was able to play 'ARENAII' on the real GS. However 'Cold Tea' is still freezing up nondeterministically. It does seem that some of this code may be sensitive to the timing of the sound engine being roughly correct.
'LANDMUS' is also choking on MAME, so I took advantage and stepped through it in the debugger. The reason it is stalled is there is a note enqueued with sequence number 1 (meaning a two note chord) but the other three audio channels have empty queues. I don't yet know why or how we ended up in this state. At least we know it is to do with sequence number / chord handling somehow.
So I replaced line 810 of 'LANDMUS' (the SOUND
statement) with a PRINT
statement. Interestingly, 'LANDMUS' does NOT use the chord synchronization function at all - it simply dispatches notes of duration 1 in round-robin to channels 1, 2, 3 repeatedly.
This strongly implies that the audio queue is getting corrupted somehow.
Also, consider that when I recalibrated the Ensoniq, which had the effect of changing the frequency at which the ISR is invoked, it changed the stability of the audio engine so that some songs that previously did not play, now do so. This strongly implies that it is an interaction of the mainline code and the ISR that has some window where the queue can get corrupted.
Will look at the code very carefully (again) tomorrow. (I thought that having interrupts disabled while I enqueue bytes in the audio queue should have done the trick.)
The JGH Music 1 programs are demo'd here, so this is what they should shound like: https://youtu.be/8kRCjG3Z0j8?t=175
-- J.G.Harston - @.*** - mdfs.net/jgh
Sounds mostly the same on the GS ... except that I have four tonal channels at the moment and no noise channel.
'LANDMUS' problem is fixed!! I was using macros ENTMAIN
and ENTAUX
when transitioning from aux->main->aux for calls to INSHND
and CNPHND
. Those calls re-enable interrupts!! Replaced them with IENTMAIN
and IENTAUX
, which do not re-enable interrupts, and now 'LANDMUS' plays without issue.
Will do some more testing before closing this.
Breaks 'ARENAII' (again). Haven't looked into how/why.
I also had to briefly enable interrupts in WORD07
when waiting for space in the queue, otherwise the ISR never runs and the queue will never drain. Now 'ARENAII' runs again.
Going to call this fixed. With the current build most stuff on the JGHMusic1 disk work and nothing seems to be choking part-way anymore.
The BASIC program 'ColdTea' which is currently on the
applecorn.po
distribution media plays nicely on Applecorn under MAME (GS ROM03) but stops unexpectedly on my GS (ROM01).