Prev: D4C1 Up: Map Next: D730
D5AC: Initialise Game
Used by the routine at Decrypt_Game.
Sets up the stack, copies the default keys, shows the introduction screen and installs the interrupt handler.
Initialise_Game D5AC DI Disable interrupts.
D5AD LD HL,$5BFF SP=5BFF.
D5B0 LD SP,HL
D5B1 LD DE,$647F Copy 0007 bytes from Table_DefaultKeys to UserDefinedKeys.
D5B4 LD HL,$E6EC
D5B7 LD BC,$0007
D5BA LDIR
D5BC XOR A Write 00 to:
D5BD LD ($647E),A
D5C0 LD ($647C),A
D5C3 LD HL,$B370 Write Data_TuneStream to *Pointer_TuneData.
D5C6 LD ($6469),HL
D5C9 LD HL,$B491 Write Data_TuneStreamCopy to *Pointer_TuneDataCopy.
D5CC LD ($646B),HL
D5CF LD A,R Keep bit 7 of the refresh register set.
D5D1 SET 7,A
D5D3 LD R,A
This entry point is used by the routines at Game_Loop, Handler_Enemies and Handler_Combination.
Reset the introduction / demo state.
Reset_Introduction D5D5 XOR A Write 00 to *GameActiveFlag.
D5D6 LD ($646F),A
D5D9 DI Disable interrupts.
D5DA XOR A Write 00 to *Active_BorderColour.
D5DB LD ($641D),A
D5DE OUT ($FE),A Set the border to BLACK.
D5E0 LD HL,$9870 Copy 1B00 bytes from IntroductionScreen to 4000.
D5E3 LD DE,$4000
D5E6 LD BC,$1B00
D5E9 LDIR
D5EB LD BC,$0190 Write 0190 to *PauseTimer.
D5EE LD ($6470),BC
D5F2 CALL Animate_Introduction Call Animate_Introduction.
Install IM 02. Every interrupt vector in the FD page holds FE so the CPU jumps to AliasInterruptRedirect, which jumps to Handler_Interrupts.
D5F5 LD A,$C3 Write C3 to *AliasInterruptRedirect.
D5F7 LD ($FEFE),A
D5FA DI Disable interrupts.
D5FB LD HL,$E46C Write Handler_Interrupts after the jump at AliasInterruptRedirect.
D5FE LD ($FEFF),HL
D601 XOR A Write 00 to *InterruptTick.
D602 LD ($646E),A
D605 LD HL,$0000 Write 0000 to *SoundFlags.
D608 LD ($6472),HL
D60B LD A,$FD Set FD as the high-order byte in I.
D60D LD I,A
D60F IM 2 Set interrupt mode 02.
D611 CALL JumpTable_InitialiseDisplay Call JumpTable_InitialiseDisplay.
D614 EI Enable interrupts.
D615 LD A,($646F) Jump to Start_Game if *GameActiveFlag is set (start a game).
D618 OR A
D619 JP NZ,Start_Game
D61C XOR A Write 00 to *Active_BorderColour.
D61D LD ($641D),A
D620 OUT ($FE),A Set the border to BLACK.
D622 LD HL,$3C00 Write 3C00 to *CHARS.
D625 LD ($5C36),HL
Draw_Menu D628 CALL Clear_PlayArea Call Clear_PlayArea.
This entry point is used by the routine at Handler_RoomPause.
Print the introduction menu.
Print_Menu D62B LD HL,$E6F3 Print the messaging at Messaging_Title.
D62E CALL JumpTable_PrintMessage
D631 LD HL,$E73C Print the messaging at Messaging_Menu.
D634 CALL JumpTable_PrintMessage
D637 LD A,($647E) Write BLACK to *ATTR_T when Kempston is selected.
D63A OR A
D63B JR NZ,Print_Menu_Keyboard
D63D LD A,$38
D63F LD ($5C8F),A
Print_Menu_Keyboard D642 LD HL,$E750 Print the messaging at Messaging_Keyboard.
D645 CALL JumpTable_PrintMessage
D648 LD A,($647E) Write BLACK to *ATTR_T when the keyboard is selected.
D64B OR A
D64C JR Z,Print_Menu_DefineKeys
D64E LD A,$38
D650 LD ($5C8F),A
Print_Menu_DefineKeys D653 LD HL,$E762 Print the messaging at Messaging_Kempston.
D656 CALL JumpTable_PrintMessage
D659 LD A,($647E) Jump to Menu_Keyboard_Loop if *ControlMethod is zero.
D65C OR A
D65D JR Z,Menu_Keyboard_Loop
Wait for a Kempston menu choice.
D65F LD B,$FF B=FF.
Menu_Kempston_Loop D661 CALL Read_Kempston Call Read_Kempston.
D664 JR NZ,Menu_Kempston_Next Jump to Menu_Kempston_Next if the port is unstable.
D666 CP $10 Jump to Start_Game if fire was pressed.
D668 JP Z,Start_Game
Menu_Kempston_Next D66B DEC BC Jump to Menu_Kempston_Loop until BC is zero.
D66C LD A,C
D66D OR B
D66E JR NZ,Menu_Kempston_Loop
D670 JP Select_Keyboard Jump to Select_Keyboard.
Keyboard menu. Codes are from KEY_SCAN.
Menu_Keyboard_Loop D673 LD B,$03 Call JumpTable_Delay with a pause of 03.
D675 CALL JumpTable_Delay
D678 CALL $028E Call KEY_SCAN.
D67B LD A,E A=the keypress.
D67C CP $23 Jump to Start_Game if "0" was pressed.
D67E JP Z,Start_Game
D681 CP $24 Jump to Select_Keyboard if "1" was pressed.
D683 JP Z,Select_Keyboard
D686 CP $1C Jump to Select_Kempston if "2" was pressed.
D688 JP Z,Select_Kempston
D68B CP $14 Jump to Menu_Keyboard_Loop if the key was not "3".
D68D JR NZ,Menu_Keyboard_Loop
Define the five user keys.
D68F CALL Clear_PlayArea Call Clear_PlayArea.
D692 LD HL,$E6F3 Print the messaging at Messaging_Title.
D695 CALL JumpTable_PrintMessage
D698 LD HL,$E78F Print the messaging at Messaging_DefineKeys.
D69B CALL JumpTable_PrintMessage
DefineKeys_Restart D69E XOR A Write 00 to *ControlMethod.
D69F LD ($647E),A
D6A2 LD B,$00 B=00.
DefineKeys_Loop D6A4 PUSH BC Stash the key index on the stack.
D6A5 LD C,$1B Print at column 1B row 05+index*02.
D6A7 LD A,$04
D6A9 SUB B
D6AA SLA A
D6AC ADD A,$05
D6AE LD B,A
D6AF CALL JumpTable_SetPrintPosition Call JumpTable_SetPrintPosition.
D6B2 POP BC Restore and restash the key index.
D6B3 PUSH BC
D6B4 LD A,($647E) Highlight the current slot in BLACK.
D6B7 CP B
D6B8 JR NZ,DefineKeys_PrintSlot
D6BA LD A,$38
D6BC LD ($5C8F),A
DefineKeys_PrintSlot D6BF LD DE,$647F HL=UserDefinedKeys+BC.
D6C2 LD L,B
D6C3 LD H,$00
D6C5 ADD HL,DE
D6C6 LD A,(HL)
D6C7 LD E,A
D6C8 LD D,$00
D6CA LD HL,$E802 Print the glyph from Table_KeyMap for this slot.
D6CD ADD HL,DE
D6CE LD A,(HL)
D6CF CALL JumpTable_PrintCharacter
D6D2 LD A,$07 Write WHITE to *ATTR_T.
D6D4 LD ($5C8F),A
D6D7 POP BC Restore the key index from the stack.
D6D8 INC B Increase the key index and jump to DefineKeys_Loop until five keys have been printed.
D6D9 LD A,B
D6DA CP $05
D6DC JR NZ,DefineKeys_Loop
DefineKeys_Read D6DE LD BC,$4E20 Call JumpTable_Delay with a pause of 4E20.
D6E1 CALL JumpTable_Delay
D6E4 CALL $028E Call KEY_SCAN.
D6E7 LD A,E A=the keypress.
D6E8 CP $FF Jump to DefineKeys_Read if no key is pressed.
D6EA JR Z,DefineKeys_Read
D6EC CP $20 Jump to DefineKeys_CheckDuplicates if ENTER was pressed.
D6EE JR Z,DefineKeys_CheckDuplicates
D6F0 LD BC,($647E) Write the key into the current slot at UserDefinedKeys.
D6F4 LD B,$00
D6F6 LD HL,$647F
D6F9 ADD HL,BC
D6FA LD (HL),A Increase *ControlMethod by one.
D6FB LD A,($647E)
D6FE INC A
D6FF LD ($647E),A
D702 CP $05 Jump to DefineKeys_Loop if fewer than five keys are set.
D704 JR NZ,DefineKeys_Loop
Reject a set that contains any duplicate key.
DefineKeys_CheckDuplicates D706 LD HL,$647F HL=UserDefinedKeys, DE=UserDefinedKey_Right, B=04.
D709 LD DE,$6480
D70C LD B,$04
DefineKeys_Compare D70E PUSH DE Stash the compare pointers on the stack.
D70F PUSH BC
DefineKeys_CompareSlot D710 LD A,(DE) Jump to DefineKeys_CompareNext if this pair differs.
D711 CP (HL)
D712 JR NZ,DefineKeys_CompareNext
D714 POP BC Restart define-keys if a duplicate was found.
D715 POP DE
D716 JP DefineKeys_Restart
DefineKeys_CompareNext D719 INC DE Increase DE by one.
D71A DJNZ DefineKeys_CompareSlot Decrease the inner counter and loop back to DefineKeys_CompareSlot.
D71C POP BC Restore the compare pointers from the stack.
D71D POP DE
D71E INC HL Increase both pointers by one.
D71F INC DE
D720 DEC B Jump to DefineKeys_Compare until every pair is unique.
D721 JR NZ,DefineKeys_Compare
D723 LD HL,($647F) Copy the first two keys to *SavedKeys.
D726 LD ($6484),HL
D729 XOR A Write 00 to *ControlMethod.
D72A LD ($647E),A
D72D JP Draw_Menu Jump to Draw_Menu.
View the equivalent code in Booty.
Prev: D4C1 Up: Map Next: D730