|  | Routines | 
| Prev: F446 | Up: Map | Next: F52C | 
| 
This runs the main menu. It waits for user to select an input device while waving the morale flag and playing the title tune.
 
Used by the routine at main.
 | ||||
| 
Start loop (infinite)
 | ||||
| menu_screen | F4B7 | CALL check_menu_keys | Handle menu screen keys. When the user starts the game this call will cease to return. | |
| F4BA | CALL wave_morale_flag | Wave the morale flag (on every other turn) | ||
| 
Play music.
 | ||||
| F4BD | LD HL,($F541) | Fetch and increment the music channel 0 index | ||
| F4C0 | INC HL | |||
| 
Start loop (infinite)
 | ||||
| ms_loop0 | F4C1 | LD ($F541),HL | Save the music channel 0 index | |
| F4C4 | LD DE,$F546 | Point DE at music_channel0_data | ||
| F4C7 | ADD HL,DE | Add the index | ||
| F4C8 | LD A,(HL) | Fetch a semitone | ||
| F4C9 | CP $FF | Was it the end of song marker? ($FF) | ||
| F4CB | JR NZ,ms_break0 | Jump if not | ||
| F4CD | LD HL,$0000 | Otherwise zero the index and start over | ||
| F4D0 | JR ms_loop0 | |||
| ms_break0 | F4D2 | CALL frequency_for_semitone | Get frequency for semitone | |
| F4D5 | EXX | Bank the channel 0 parameters | ||
| F4D6 | LD HL,($F543) | Fetch and increment the music channel 1 index | ||
| F4D9 | INC HL | |||
| 
Start loop (infinite)
 | ||||
| ms_loop1 | F4DA | LD ($F543),HL | Save the music channel 1 index | |
| F4DD | LD DE,$F7C7 | Point DE at music_channel1_data | ||
| F4E0 | ADD HL,DE | Add the index | ||
| F4E1 | LD A,(HL) | Fetch a semitone | ||
| F4E2 | CP $FF | Was it the end of song marker? ($FF) | ||
| F4E4 | JR NZ,ms_break1 | Jump if not | ||
| F4E6 | LD HL,$0000 | Otherwise zero the index and start over | ||
| F4E9 | JR ms_loop1 | |||
| ms_break1 | F4EB | CALL frequency_for_semitone | Get frequency for semitone | |
| 
When the second channel is silent use the first channel's frequency.
 | ||||
| F4EE | LD A,B | Get the second channel's frequency low byte (note B is low here due to endian swap) | ||
| F4EF | EXX | Unbank the channel 0 parameters | ||
| F4F0 | PUSH BC | Save channel 0's frequency | ||
| F4F1 | CP $FF | Is channel 1's frequency $xxFF? | ||
| F4F3 | JR NZ,menu_screen_0 | Jump if not | ||
| F4F5 | EXX | Otherwise swap banks to channel 1's registers | ||
| F4F6 | POP BC | Copy channel 0's frequency to channel 1 | ||
| F4F7 | LD E,C | |||
| F4F8 | LD D,B | |||
| F4F9 | EXX | Bank again | ||
| F4FA | JR menu_screen_1 | Jump | ||
| menu_screen_0 | F4FC | POP BC | Discard saved frequency | |
| 
Iterate 6,120 times (24 * 255)
 | ||||
| menu_screen_1 | F4FD | LD A,$18 | Set major tune speed (a delay: lower means faster) | |
| 
Start loop (major)
 | ||||
| menu_screen_2 | F4FF | EX AF,AF' | Bank the major counter | |
| F500 | LD H,$FF | Set minor tune speed (a delay: lower means faster) | ||
| 
Start loop (minor)
 
Play channel 0's part
 | ||||
| menu_screen_3 | F502 | DJNZ menu_screen_4 | Decrement B (low). Jump over next block unless zero | |
| F504 | DEC C | Decrement C (high) | ||
| F505 | JP NZ,menu_screen_4 | Jump over next block unless zero | ||
| 
Countdown hit zero
 | ||||
| F508 | LD A,L | Toggle the speaker bit (L is zeroed by frequency_for_semitone) | ||
| F509 | XOR $10 | |||
| F50B | LD L,A | |||
| F50C | OUT ($FE),A | |||
| F50E | LD C,E | Reset counter | ||
| F50F | LD B,D | |||
| menu_screen_4 | F510 | EXX | Swap to registers for channel 1 | |
| 
Play channel 1's part
 | ||||
| F511 | DJNZ menu_screen_5 | Decrement B (low). Jump over next block unless zero | ||
| F513 | DEC C | Decrement C (high) | ||
| F514 | JP NZ,menu_screen_5 | Jump over next block unless zero | ||
| 
Countdown hit zero
 | ||||
| F517 | LD A,L | Toggle the speaker bit (L is zeroed by frequency_for_semitone) | ||
| F518 | XOR $10 | |||
| F51A | LD L,A | |||
| F51B | OUT ($FE),A | |||
| F51D | LD C,E | Reset counter | ||
| F51E | LD B,D | |||
| menu_screen_5 | F51F | EXX | Swap to registers for channel 0 | |
| F520 | DEC H | ...loop (minor tune speed) / 255 iterations | ||
| F521 | JP NZ,menu_screen_3 | |||
| F524 | EX AF,AF' | Unbank the major counter | ||
| F525 | DEC A | ...loop (major tune speed) / 24 iterations | ||
| F526 | JP NZ,menu_screen_2 | |||
| F529 | JP menu_screen | ...loop (infinite) | ||
| Prev: F446 | Up: Map | Next: F52C |