Skip to navigation

Elite on the BBC Micro

Sound: NOISE

[BBC Master version]

Name: NOISE [Show more] Type: Subroutine Category: Sound Summary: Make the sound whose number is in Y by populating the sound buffer
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: * BEEP calls NOISE * BOMBEFF2 calls NOISE * BOOP calls NOISE * DEATH calls NOISE * ELASNO calls NOISE * EXNO calls NOISE * EXNO3 calls NOISE * FRMIS calls NOISE * LASNO calls NOISE * LAUN calls NOISE * LL164 calls NOISE * Main flight loop (Part 16 of 16) calls NOISE * SFRMIS calls NOISE

The following sounds can be made by this routine. Two-part noises are made by consecutive calls to this routine with different values of Y. The routine doesn't make any sounds itself; instead, it populates the sound buffer at SOFLG with the relevant sound data, and the interrupt handler at IRQ1 calls the SOINT routine to process the data in the sound buffer and send it to the 76489 sound chip. This routine can make the following sounds depending on the value of Y: 0 Long, low beep 1 Short, high beep 3, 5 Lasers fired by us 4 We died / Collision / Our depleted shields being hit by lasers 6 We made a hit or kill / Energy bomb / Other ship exploding 7 E.C.M. on 8 Missile launched / Ship launched from station 9, 5 We're being hit by lasers 10, 11 Hyperspace drive engaged Arguments: Y The number of the sound to be made from the above table
.NOISE \ This routine appears to set up the contents of the \ SOFLG sound buffer, so the SOINT routine can then send \ the results to the 76489 sound chip. How this all \ works is a bit of a mystery, so this part needs more \ investigation LDA DNOIZ \ If DNOIZ is non-zero, then sound is disabled, so BNE SOUR1 \ return from the subroutine (as SOUR1 contains an RTS) LDA SFXBT,Y \ Fetch SFXBT+Y and shift bit 0 into the C flag LSR A CLV \ Clear the V flag LDX #0 \ If bit 0 of SFXBT+Y is set, set X = 0 and jump to BCS SOUS4 \ SOUS4 INX \ Increment X to 1 LDA SOPR+1 \ If SOPR+1 < SOPR+2, set X = 1 and jump to SOUS4 CMP SOPR+2 BCC SOUS4 INX \ SOPR+1 >= SOPR+2, so increment X to 2 \JSR SOUS4 \ These instructions are commented out in the original \BCC SOUR1 \ source \DEX \BIT SOUR1 \SEV!! \LDA SFXPR,Y \AND #&10 \BEQ SOUS9 \RTS \fall into SOUS4 since this facility not needed .SOUS4 \ By the time we get here, X is set as follows: \ \ * X = 0 if bit 0 of SFXBT+Y is set \ * X = 1 if SOPR+1 < SOPR+2 \ * X = 2 if SOPR+1 >= SOPR+2 LDA SFXPR,Y \ Set A = SFXPR+Y .SOUS9 CMP SOPR,X \ If SFXPR+Y < SOPR+X, return from the subroutine BCC SOUR1 \ (as SOUR1 contains an RTS) SEI \ Disable interrupts while we update the sound buffer \ If we get here then SFXPR+Y >= SOPR+X STA SOPR,X \ SOPR+X = A = SFXPR+Y LSR A \ Store bits 1-3 of SFXPR+Y in bits 0-2 of SOVOL+X AND #%00000111 STA SOVOL,X LDA SFXVC,Y \ Store SFXVC+Y in SOVCH+X STA SOVCH,X LDA SFXBT,Y \ Store SFXBT+Y in SOCNT+X STA SOCNT,X AND #%00001111 \ Store bits 1-3 of SFXBT+Y in bits 0-2 of SOFRCH+X LSR A STA SOFRCH,X LDA SFXFQ,Y \ Set A = SFXFQ+Y BVC P%+3 \ If the V flag is set, double the value in A ASL A STA SOFRQ,X \ Store A in SOFRQ+X LDA #%10000000 \ Set bit 7 of SOFLG+X STA SOFLG,X CLI \ Enable interrupts again SEC \ Set the C flag RTS \ Return from the subroutine