Prev: 7164 Up: Map Next: 721A
71BE: Spawn Bonus Item
Used by the routines at SpawnBug and CreateBug.
Updates the bonus item if there is one. Otherwise, it puts a new bonus item into a cubby hole, with a chance of one in two hundred and fifty-six. The hole is chosen using the game timer, from the first ten, and has to be empty. The hole is marked with FF and the type of the bonus item is a random one of 0B 0C or 0D (with 0B more likely). It goes back to the start of the main loop at MainLoop_NewPass.
SpawnBonusItem 71BE LD A,($5E3C) A=the state of the bonus item from State_BonusItem.
71C1 AND A Test the state.
71C2 JP NZ,UpdateBonusItem Jump to UpdateBonusItem if there is a bonus item.
71C5 LD A,($5E19) A=the random number from RandomNumber.
71C8 AND A Test the random number.
71C9 JP NZ,MainLoop_NewPass Jump to MainLoop_NewPass to start another pass unless it is zero.
71CC LD A,($5E17) A=the game timer from GameTimer.
71CF AND %00001111 Keep only bits 0-3.
71D1 CP $0A Jump to MainLoop_NewPass if it is 0A or more.
71D3 JP NC,MainLoop_NewPass
71D6 LD C,A C=the cubby hole number.
71D7 LD B,$00 B=00.
71D9 LD HL,$5E23 HL=CubbyHoles.
71DC ADD HL,BC Add the cubby hole number.
71DD LD A,(HL) A=the contents of the cubby hole.
71DE AND A Test the contents.
71DF JP NZ,MainLoop_NewPass Jump to MainLoop_NewPass if the cubby hole is not empty.
71E2 LD (HL),$FF Write FF to the cubby hole.
71E4 LD IX,$5E3C IX=State_BonusItem (the bonus item).
71E8 LD A,C A=the cubby hole number.
71E9 CP $05 Jump to SpawnBonusItem_Right if the cubby hole is on the right.
71EB JR NC,SpawnBonusItem_Right
71ED LD (IX+$01),$08 Write 08 to the X position of the bonus item.
This entry point is used by the routine at SpawnBonusItem_Right.
SpawnBonusItem_Row 71F1 RRCA Rotate the row number round so it is in bits 5-7.
71F2 RRCA
71F3 RRCA
71F4 AND %11100000 Keep only bits 5-7.
71F6 ADD A,$37 Add 37.
71F8 LD (IX+$02),A Write it to the Y position of the bonus item.
71FB LD A,R A=the refresh register.
71FD AND %00000011 Keep only bits 0-1.
71FF CP $03 Jump to SpawnBonusItem_Type unless it is 03.
7201 JR NZ,SpawnBonusItem_Type
7203 XOR A A=00.
SpawnBonusItem_Type 7204 ADD A,$0B Add 0B to give the type of the bonus item.
7206 LD (IX+$04),$FF Write FF to IX+04 (the contents the cubby hole should have).
720A LD (IX+$00),A Write the type to the state of the bonus item.
720D LD (IX+$03),$43 Write 43 (magenta) to the colour of the bonus item.
7211 LD (IX+$05),C Write the cubby hole number to IX+05.
This entry point is used by the routine at CollectBonusItem.
SpawnBonusItem_Tone 7214 CALL PlayMidTone Play a tone using PlayMidTone.
7217 JP MainLoop_NewPass Jump to MainLoop_NewPass.
Prev: 7164 Up: Map Next: 721A