Prev: 51378 Up: Map Next: 51529
51402: Game Selection Menu
Used by the routine at StartGame.
Shows the game selection menu, plays a tune, and waits for the options for the controls to be chosen. The game starts when the "0" key is pressed.
The control method is held in bits 1 and 2 of GameOptions, and bit 3 is set when directional control has been chosen.
game-selection-menu
Prepare the menu.
GameMenu 51402 XOR A Write 0 to *MenuFrameDrawnFlag.
51403 LD (48063),A
51406 LD HL,51554 Point HL at MenuLineAttributes.
51409 LD B,8 Set the number of lines to 8.
GameMenu_Unflash 51411 RES 7,(HL) Stop the line flashing.
51413 INC HL Move on to the next line.
51414 DJNZ GameMenu_Unflash Jump to GameMenu_Unflash until all of the lines are done.
51416 CALL ClearScreenBuffer Call ClearScreenBuffer.
51419 CALL DisplayMenu Call DisplayMenu.
51422 CALL FlashMenuOptions Call FlashMenuOptions.
Read the keys that choose the control method.
GameMenu_Loop 51425 CALL DisplayMenu Call DisplayMenu.
51428 LD DE,51056 Point DE at Tune_Menu.
51431 CALL PlayMusicOnce Call PlayMusicOnce.
Read the keys "1" to "5".
51434 LD A,247 Read from the keyboard;
Port Number Bit
0 1 2 3 4
247 1 2 3 4 5
51436 CALL ReadKeyboardPort
51439 LD E,A Keep the keys that are pressed in E.
51440 LD A,(48048) Fetch GameOptions.
51443 LD (48049),A Set PreviousGameOptions.
51446 BIT 0,E Jump to GameMenu_Key2 if "1" is not pressed.
51448 JR Z,GameMenu_Key2
51450 AND %11111001 Choose the keyboard.
Choose a joystick if one of those keys is pressed.
GameMenu_Key2 51452 BIT 1,E Jump to GameMenu_Key3 if "2" is not pressed.
51454 JR Z,GameMenu_Key3
51456 AND %11111001 Clear bits 1 and 2.
51458 OR %00000010 Choose the Kempston joystick.
GameMenu_Key3 51460 BIT 2,E Jump to GameMenu_Key4 if "3" is not pressed.
51462 JR Z,GameMenu_Key4
51464 AND %11111001 Clear bits 1 and 2.
51466 OR %00000100 Choose the cursor joystick.
GameMenu_Key4 51468 BIT 3,E Jump to GameMenu_SetMethod if "4" is not pressed.
51470 JR Z,GameMenu_SetMethod
51472 OR %00000110 Choose Interface II.
GameMenu_SetMethod 51474 LD (48048),A Set GameOptions.
Toggle directional control once for each press of "5".
51477 LD HL,48061 Point HL at KeyHeldFlag.
51480 BIT 4,E Jump to GameMenu_Key5Released if "5" is not pressed.
51482 JR Z,GameMenu_Key5Released
51484 BIT 0,(HL) Jump to GameMenu_Check if "5" was pressed last time as well.
51486 JR NZ,GameMenu_Check
51488 SET 0,(HL) Set bit 0 of KeyHeldFlag.
51490 LD A,(48048) Fetch GameOptions.
51493 XOR %00001000 Toggle directional control.
51495 LD (48048),A Set GameOptions.
Start the game if "0" is pressed.
GameMenu_Check 51498 LD HL,48049 Point HL at PreviousGameOptions.
51501 CP (HL) Compare with the previous options.
51502 LD DE,51188 Point DE at Tune_MenuSelection.
51505 CALL NZ,PlayMusic Call PlayMusic if the control method has changed.
51508 LD A,239 Read from the keyboard;
Port Number Bit
0 1 2 3 4
239 0 9 8 7 6
51510 CALL ReadKeyboardPort
51513 BIT 0,A Return if "0" is pressed.
51515 RET NZ
51516 CALL IncrementFrameCounter Call IncrementFrameCounter.
51519 CALL FlashMenuOptions Call FlashMenuOptions.
51522 JP GameMenu_Loop Jump to GameMenu_Loop.
"5" has been released.
GameMenu_Key5Released 51525 RES 0,(HL) Reset bit 0 of KeyHeldFlag.
51527 JR GameMenu_Check Jump to GameMenu_Check.
View the equivalent code in;
Prev: 51378 Up: Map Next: 51529