Prev: ACE2 Up: Map Next: AD7B
ACF6: Handle Menu Bullet
The routine for state 04 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 01. If the game has been started, the title screen returns to the caller.
HandleMenuBullet ACF6 LD A,(IX+$01) Fetch the horizontal position of the bullet.
ACF9 ADD A,$02 Move it two pixels to the right.
ACFB LD (IX+$01),A Store the new horizontal position of the bullet.
ACFE CP $F8 Jump to HandleMenuBullet_Finished to finish with the bullet if it has reached the edge.
AD00 JP NC,HandleMenuBullet_Finished
AD03 CALL DrawMenuSprite Draw the bullet.
AD06 CALL PlayBulletSound Make a click.
AD09 LD A,($A20E) Fetch the number of the entry.
AD0C DEC A Subtract one.
AD0D JR Z,HandleMenuBullet_Players Jump to HandleMenuBullet_Players if this is the first entry.
AD0F DEC A Subtract one.
AD10 JR Z,HandleMenuBullet_Controls Jump to HandleMenuBullet_Controls if this is the second entry.
This is the third entry, which always says "START GAME".
AD12 LD A,$47 Set the attribute to INK:WHITE, PAPER:BLACK (BRIGHT).
AD14 EX AF,AF' Keep it in the alternate accumulator.
AD15 LD HL,$ADD9 Point HL at ControlsTexts_StartGame.
AD18 JR HandleMenuBullet_Print Jump to HandleMenuBullet_Print.
The first entry says "ONE PLAYER GAME" or "TWO PLAYER GAME".
HandleMenuBullet_Players AD1A LD A,$42 Set the attribute to INK:RED, PAPER:BLACK (BRIGHT).
AD1C EX AF,AF' Keep it in the alternate accumulator.
AD1D LD A,($A21C) Fetch the options.
AD20 AND %00000001 Keep the number of players.
AD22 LD BC,$AD7B Point BC at NumberOfPlayersTexts.
HandleMenuBullet_ChooseText AD25 CALL GetTableEntry Point HL at the text.
Print the next character of the text when the bullet is at the right place.
HandleMenuBullet_Print AD28 LD A,(IX+$01) Fetch the horizontal position of the bullet.
AD2B SUB $08 Move eight pixels to the left to find the position of the character.
AD2D LD E,A Keep the horizontal position of the character in E.
AD2E LD A,(IX+$02) Fetch the vertical position of the bullet.
AD31 ADD A,$0F Move it up to the top of the text.
AD33 LD D,A Keep the vertical position of the text in D.
AD34 BIT 7,(IX+$03) Test whether the text is complete.
AD38 RET NZ Return if it is.
AD39 LD A,E Fetch the horizontal position of the character.
AD3A AND %00000110 Keep bits 1 and 2.
AD3C RET NZ Return unless the character is on a character boundary.
AD3D LD A,E Fetch the horizontal position of the character.
AD3E SUB $58 Subtract the position of the start of the text.
AD40 RET C Return if the bullet has not yet reached the start of the text.
AD41 RRCA Divide the offset by eight.
AD42 RRCA
AD43 RRCA
AD44 AND %00011111 Keep five bits.
AD46 CALL AddAToHL Point HL at the character in the text.
AD49 EX DE,HL Swap the position of the character into HL and its address into DE.
AD4A CALL CalculateScreenAddress Work out the screen address.
AD4D LD A,(DE) Fetch the character.
AD4E BIT 7,A Jump to HandleMenuBullet_DrawCharacter unless the character is the last one of the text.
AD50 JR Z,HandleMenuBullet_DrawCharacter
AD52 AND %01111111 Remove the flag from the character.
AD54 SET 7,(IX+$03) Note that the text is complete.
HandleMenuBullet_DrawCharacter AD58 CALL ConvertCharacter Convert the character to the number of its tile.
AD5B LD BC,$8EA8 Point BC at Font.
AD5E JP DrawCharacter Jump to DrawCharacter.
The second entry says which controls are used.
HandleMenuBullet_Controls AD61 LD A,$43 Set the attribute to INK:MAGENTA, PAPER:BLACK (BRIGHT).
AD63 EX AF,AF' Keep it in the alternate accumulator.
AD64 LD A,($A21C) Fetch the options.
AD67 RRCA Move the type of controls into bits 0 and 1.
AD68 AND %00000011 Keep the type of controls.
AD6A LD BC,$AD9D Point BC at ControlsTexts.
AD6D JR HandleMenuBullet_ChooseText Choose the text.
The bullet has reached the edge of the screen.
HandleMenuBullet_Finished AD6F LD (IX+$00),$01 Set the state of the entry to complete.
AD73 LD A,($A241) Fetch the flag which starts the game.
AD76 AND A Return if the game has not been started.
AD77 RET Z
AD78 INC SP Drop the return address, so that the title screen returns to its caller.
AD79 INC SP
AD7A RET Return.
Prev: ACE2 Up: Map Next: AD7B