Prev: 29028 Up: Map Next: 29210
29118: 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 255 and the type of the bonus item is a random one of 11 12 or 13 (with 11 more likely). It goes back to the start of the main loop at MainLoop_NewPass.
SpawnBonusItem 29118 LD A,(24124) A=the state of the bonus item from State_BonusItem.
29121 AND A Test the state.
29122 JP NZ,UpdateBonusItem Jump to UpdateBonusItem if there is a bonus item.
29125 LD A,(24089) A=the random number from RandomNumber.
29128 AND A Test the random number.
29129 JP NZ,MainLoop_NewPass Jump to MainLoop_NewPass to start another pass unless it is zero.
29132 LD A,(24087) A=the game timer from GameTimer.
29135 AND %00001111 Keep only bits 0-3.
29137 CP 10 Jump to MainLoop_NewPass if it is 10 or more.
29139 JP NC,MainLoop_NewPass
29142 LD C,A C=the cubby hole number.
29143 LD B,0 B=0.
29145 LD HL,24099 HL=CubbyHoles.
29148 ADD HL,BC Add the cubby hole number.
29149 LD A,(HL) A=the contents of the cubby hole.
29150 AND A Test the contents.
29151 JP NZ,MainLoop_NewPass Jump to MainLoop_NewPass if the cubby hole is not empty.
29154 LD (HL),255 Write 255 to the cubby hole.
29156 LD IX,24124 IX=State_BonusItem (the bonus item).
29160 LD A,C A=the cubby hole number.
29161 CP 5 Jump to SpawnBonusItem_Right if the cubby hole is on the right.
29163 JR NC,SpawnBonusItem_Right
29165 LD (IX+1),8 Write 8 to the X position of the bonus item.
This entry point is used by the routine at SpawnBonusItem_Right.
SpawnBonusItem_Row 29169 RRCA Rotate the row number round so it is in bits 5-7.
29170 RRCA
29171 RRCA
29172 AND %11100000 Keep only bits 5-7.
29174 ADD A,55 Add 55.
29176 LD (IX+2),A Write it to the Y position of the bonus item.
29179 LD A,R A=the refresh register.
29181 AND %00000011 Keep only bits 0-1.
29183 CP 3 Jump to SpawnBonusItem_Type unless it is 3.
29185 JR NZ,SpawnBonusItem_Type
29187 XOR A A=0.
SpawnBonusItem_Type 29188 ADD A,11 Add 11 to give the type of the bonus item.
29190 LD (IX+4),255 Write 255 to IX+4 (the contents the cubby hole should have).
29194 LD (IX+0),A Write the type to the state of the bonus item.
29197 LD (IX+3),67 Write 67 (magenta) to the colour of the bonus item.
29201 LD (IX+5),C Write the cubby hole number to IX+5.
This entry point is used by the routine at CollectBonusItem.
SpawnBonusItem_Tone 29204 CALL PlayMidTone Play a tone using PlayMidTone.
29207 JP MainLoop_NewPass Jump to MainLoop_NewPass.
Prev: 29028 Up: Map Next: 29210