Prev: B4EA Up: Map Next: B57E
B506: Configure weapon sound and check for weapon free slot
Configure Rex weapon sound. Used by the routines at B372, B456 and B64E.
Output
IY Address pointer into projectile configuration for new projectile
B506 XOR A Set A07B to playing sound for Rex weapon
B507 LD ($A07B),A
B50A LD IY,$5B60 Set IY to the address for the rex projectile configuration
B50E LD E,$1E Set E to the max number of projectiles
B510 LD A,($A013) Set A to the in use Rex weapon
B513 OR A is basic laser?
B514 JP Z,$B51F Jump forward if so
B517 CP $01 is double fire?
B519 JP Z,$B51F Jump forward if so
B51C JP $B528 Jump to play sound
B51F LD A,($A014) Set E to max number of Rex projectile based on weapon energy level max num. projectiles = weapon energy level * 4
B522 SLA A
B524 SLA A
B526 INC A
B527 LD E,A
Check if there is a free slot for projectile and configure sound
B528 DEC E Set B to the number of projectiles to check for sound play
B529 LD B,E
B52A LD A,(IY+$06) Set A to the projectile state
B52D OR A is projectile slot free?
B52E JP Z,$B53D Jump to play sound
B531 LD DE,$000F Point IY to the next projectile
B534 ADD IY,DE
B536 DJNZ $B52A Jump until all projectiles handled
B538 LD IY,$03E8 No slot available, point IY to rom address
B53C RET
Configure sound
B53D PUSH HL Save HL
B53E LD A,($A07B) playing sound for enemy weapon?
B541 OR A
B542 JP NZ,$B562 Jump if so
B545 LD DE,$D763 Set DE to the address sound data for basic laser, double fire and multiple
B548 LD A,($A013) weapon in use is laser?
B54B CP $02
B54D CALL Z,$B55A Configure address for his sound data
B550 CP $04 weapon in use is spray?
B552 CALL Z,$B55E Configure address for his sound data
B555 CALL $D5E7 Configure sound channel and mixer register
B558 POP HL Restore HL
B559 RET
Configure address for laser sound data
B55A LD DE,$D775
B55D RET
Configure address for spray sound data
B55E LD DE,$D77E
B561 RET
Configure address for enemy sound data
B562 POP HL Restore HL
B563 LD A,($D842) sound channel 3 in use?
B566 CP $FF
B568 RET NZ Return if so
B569 LD DE,$D76C Configure address for enemy sound data
B56C CALL $D5E7 Configure sound channel and mixer register
B56F RET
Check for slot to create a new projectile and play weapon sound if so Used by the routines at BA5C, BCDD and C03A.
B570 LD A,$01 Set A07B to playing enemy sound data
B572 LD ($A07B),A
B575 LD IY,$5D22 Set IY to the address for the enemy projectile configuration
B579 LD E,$14 Set E to the max number of projectiles
B57B JP $B528 Jump back and check if sound need to be played
Prev: B4EA Up: Map Next: B57E