Re Game Over.
In JSW their are a multitude of sound effects.
The title tune and in game tune plays their notes in a differing method to all the other sound FX's.
Both the title tune and in game tune attempt to play the note over a fixed period of time.
Your simple demo routine plays the tune, were each notes length is dictated by its pitch. The overall length of each note is the product of a fixed length and a pitch variable. This has several repercussions. The obvious visual one is the speed change in the boot as it descends. The obvious audio effect would be shifting tempo.
Your routine might benefit from using a routine more similar to the in game tune routine. Whereby the length of each note is fixed (sort of).
;in game tune
;Pitch of note held in D which should be copied to E before playing
8B60 LD BC,$0003 ;length of the note overall
8B63 OUT ($FE),A
8B65 DEC E
8B66 JR NZ,$8B6B
8B68 LD E,D
8B69 XOR $18
8B6B DJNZ $8B63
8B6D DEC C
8B6E JR NZ,$8B63
I think I've figured out the reason behind the "sort of" comment highlighted in bold in the above quote from Norman Sword.
My first attempt at the Funeral March caused a fixed number of oscillations of the speaker diaphragm. That meant that the higher the pitch, the shorter the delay between each oscillation and therefore the shorter the overall duration of the note.
As Norman said, the tune routines play each note for a fixed period, in an attempt to make each note of equal duration. However, there is a slight over-compensation involved, because in reality each execution of the Z80 operation which causes the speaker to oscillate (i.e. each XOR #18) takes a short but finite
amount of time (i.e. a certain number of T-States).
This is usually insignificant in terms of the overall length of the notes, but when you have an extremely high pitch note, it can start to cause a perceptible increase in the duration of the note.
In the previous test file which I uploaded a while ago - 'Game Over Test 3' - I used data bytes with value #01 in the table of Funeral March notes, in order to punctuate the tune. This means that the tune routine attempts to oscillate the diaphragm during each and every pass through the inner loop
controlled by the B register via a DJNZ command (that's 256 times per pass through the outer loop, controlled via the C register). The cumulative effect is that those notes are sustained for slightly longer, and the descending foot perceptively slows down at those moments in the tune when the 'silent notes' are being played.
I have now created a further test file - 'Game Over Test 4' - in which data bytes holding the value #00 are used to punctuate the Funeral March, instead of #01. The oscillation of the diaphragm now only occurs once for every 256 passes through the inner loop, which is only once during each pass through the outer loop
(i.e. 256 times less often than before), so the cumulative impact of the T-States of time spent executing XOR #18 commands becomes insignificant. As a result, the 'silent notes' are of roughly the same duration as the notes of intermediate pitch, and therefore the foot descends much more smoothly (at an even pace) down the Game Over screen.
I have attached to this post both of the files referred to above, for convenient comparing and contrasting of the Game Over sequence.
Edited by IRF, 04 October 2018 - 06:00 PM.