Prev: 46687 Up: Map Next: 46736
46710: Play Random Noise
Used by the routines at HandleAttackingTool and PlayLandingSoundOnce.
Plays a burst of noise, using 16 bytes of the ROM as the pitches of beeps. The ROM address is taken from RandomSeed2 and FrameCounter.
Point at a random stretch of the ROM.
PlayRandomNoise 46710 LD A,(23301) Fetch RandomSeed2.
46713 LD L,A Use it as the low byte of a ROM address.
46714 LD A,(23298) Fetch FrameCounter.
46717 AND %00011111 Keep only bits 0 to 4.
46719 LD H,A Use them as the high byte of the address.
46720 LD E,16 Set a counter of 16 beeps.
Play a beep from each ROM byte.
PlayRandomNoise_NextBeep 46722 LD A,(HL) Fetch a byte of the ROM.
46723 INC HL Move on.
46724 AND %01111111 Keep only bits 0 to 6.
46726 LD B,A Keep the pitch in B.
46727 LD C,2 Set the number of beeps to 2.
46729 CALL PlayWaveSequence Call PlayWaveSequence.
46732 DEC E Count down the beeps.
46733 JR NZ,PlayRandomNoise_NextBeep Jump to PlayRandomNoise_NextBeep until all of them have been played.
46735 RET Return.
View the equivalent code in;
Prev: 46687 Up: Map Next: 46736