Prev: 44258 Up: Map Next: 44411
44278: Handle Menu Bullet
The routine for state 4 of a menu entry: a bullet flying across the screen. It moves the bullet right two pixels, draws it and makes a click. Every eight pixels once it is past the left of the text, it prints the next character of the line of text in the bullet's wake. When the bullet reaches the edge of the screen the entry goes back to state 1. If the game has been started, the title screen returns to the caller.
HandleMenuBullet 44278 LD A,(IX+1) Fetch the horizontal position of the bullet.
44281 ADD A,2 Move it two pixels to the right.
44283 LD (IX+1),A Store the new horizontal position of the bullet.
44286 CP 248 Jump to HandleMenuBullet_Finished to finish with the bullet if it has reached the edge.
44288 JP NC,HandleMenuBullet_Finished
44291 CALL DrawMenuSprite Draw the bullet.
44294 CALL PlayBulletSound Make a click.
44297 LD A,(41486) Fetch the number of the entry.
44300 DEC A Subtract one.
44301 JR Z,HandleMenuBullet_Players Jump to HandleMenuBullet_Players if this is the first entry.
44303 DEC A Subtract one.
44304 JR Z,HandleMenuBullet_Controls Jump to HandleMenuBullet_Controls if this is the second entry.
This is the third entry, which always says "START GAME".
44306 LD A,71 Set the attribute to INK:WHITE, PAPER:BLACK (BRIGHT).
44308 EX AF,AF' Keep it in the alternate accumulator.
44309 LD HL,44505 Point HL at ControlsTexts_StartGame.
44312 JR HandleMenuBullet_Print Jump to HandleMenuBullet_Print.
The first entry says "ONE PLAYER GAME" or "TWO PLAYER GAME".
HandleMenuBullet_Players 44314 LD A,66 Set the attribute to INK:RED, PAPER:BLACK (BRIGHT).
44316 EX AF,AF' Keep it in the alternate accumulator.
44317 LD A,(41500) Fetch the options.
44320 AND %00000001 Keep the number of players.
44322 LD BC,44411 Point BC at NumberOfPlayersTexts.
HandleMenuBullet_ChooseText 44325 CALL GetTableEntry Point HL at the text.
Print the next character of the text when the bullet is at the right place.
HandleMenuBullet_Print 44328 LD A,(IX+1) Fetch the horizontal position of the bullet.
44331 SUB 8 Move eight pixels to the left to find the position of the character.
44333 LD E,A Keep the horizontal position of the character in E.
44334 LD A,(IX+2) Fetch the vertical position of the bullet.
44337 ADD A,15 Move it up to the top of the text.
44339 LD D,A Keep the vertical position of the text in D.
44340 BIT 7,(IX+3) Test whether the text is complete.
44344 RET NZ Return if it is.
44345 LD A,E Fetch the horizontal position of the character.
44346 AND %00000110 Keep bits 1 and 2.
44348 RET NZ Return unless the character is on a character boundary.
44349 LD A,E Fetch the horizontal position of the character.
44350 SUB 88 Subtract the position of the start of the text.
44352 RET C Return if the bullet has not yet reached the start of the text.
44353 RRCA Divide the offset by eight.
44354 RRCA
44355 RRCA
44356 AND %00011111 Keep five bits.
44358 CALL AddAToHL Point HL at the character in the text.
44361 EX DE,HL Swap the position of the character into HL and its address into DE.
44362 CALL CalculateScreenAddress Work out the screen address.
44365 LD A,(DE) Fetch the character.
44366 BIT 7,A Jump to HandleMenuBullet_DrawCharacter unless the character is the last one of the text.
44368 JR Z,HandleMenuBullet_DrawCharacter
44370 AND %01111111 Remove the flag from the character.
44372 SET 7,(IX+3) Note that the text is complete.
HandleMenuBullet_DrawCharacter 44376 CALL ConvertCharacter Convert the character to the number of its tile.
44379 LD BC,36520 Point BC at Font.
44382 JP DrawCharacter Jump to DrawCharacter.
The second entry says which controls are used.
HandleMenuBullet_Controls 44385 LD A,67 Set the attribute to INK:MAGENTA, PAPER:BLACK (BRIGHT).
44387 EX AF,AF' Keep it in the alternate accumulator.
44388 LD A,(41500) Fetch the options.
44391 RRCA Move the type of controls into bits 0 and 1.
44392 AND %00000011 Keep the type of controls.
44394 LD BC,44445 Point BC at ControlsTexts.
44397 JR HandleMenuBullet_ChooseText Choose the text.
The bullet has reached the edge of the screen.
HandleMenuBullet_Finished 44399 LD (IX+0),1 Set the state of the entry to complete.
44403 LD A,(41537) Fetch the flag which starts the game.
44406 AND A Return if the game has not been started.
44407 RET Z
44408 INC SP Drop the return address, so that the title screen returns to its caller.
44409 INC SP
44410 RET Return.
Prev: 44258 Up: Map Next: 44411