Skip to navigation

Elite on the BBC Micro and NES

Sound: NO3

[Acorn Electron version]

Name: NO3 [Show more] Type: Subroutine Category: Sound Summary: Make a sound from a prepared sound block
Context: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: This subroutine is called as follows: * EXNO calls NO3

Make a sound from a prepared sound block in XX16 (if sound is enabled). See routine NOS1 for details of preparing the XX16 sound block.
.NO3 LDX DNOIZ \ Set X to the DNOIZ configuration setting BNE ECMOF-1 \ If DNOIZ is non-zero, then sound is disabled, so \ return from the subroutine (as ECMOF-1 contains an \ RTS) LDA XX16 \ Set X = to bit 0 of the first SOUND parameter, so AND #&01 \ that's the channel number (as the channel is either TAX \ 0 or 1) LDY XX16+8 \ We stored the sound number (0, 8, 16 etc.) in XX16+8 \ back in NOS1, so fetch it into Y LDA SFX2,Y \ Fetch this sound's byte from SFX2 into A \ \ (This seems wrong. Y is a multiple of 8 (0, 8 ... 72) \ rather than the actual sound number (0-9), and there \ are only 10 bytes at SFX2, so this doesn't feel \ correct - surely Y should be divided by 8 before \ fetching the relevant SFX2 byte?) CMP SFXPR,X \ If the new sound's SFX2 byte is less than the current BCC ECMOF-1 \ channel's SFXPR value, return from the subroutine as \ the current sound has a higher priority than the new \ one (as ECMOF-1 contains an RTS) STA SFXPR,X \ Otherwise the new sound is a higher priority sound, so \ store the new sound's SFX2 byte as the channel's new \ SFXPR priority AND #%00001111 \ And store the low nibble of the SFX2 byte in the STA SFXDU,X \ channel's new SFXDU duration LDX #LO(XX16) \ Otherwise set (Y X) to point to the sound block in LDY #HI(XX16) \ XX16 LDA #7 \ Call OSWORD 7 to makes the sound, as described in the JMP OSWORD \ documentation for variable SFX, and return from the \ subroutine using a tail call