Prev: 54465 Up: Map Next: 55088
54700: 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 54700 DI Disable interrupts.
54701 LD HL,23551 SP=23551.
54704 LD SP,HL
54705 LD DE,25727 Copy 0007 bytes from Table_DefaultKeys to UserDefinedKeys.
54708 LD HL,59116
54711 LD BC,7
54714 LDIR
54716 XOR A Write 0 to:
54717 LD (25726),A
54720 LD (25724),A
54723 LD HL,45936 Write Data_TuneStream to *Pointer_TuneData.
54726 LD (25705),HL
54729 LD HL,46225 Write Data_TuneStreamCopy to *Pointer_TuneDataCopy.
54732 LD (25707),HL
54735 LD A,R Keep bit 7 of the refresh register set.
54737 SET 7,A
54739 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 54741 XOR A Write 0 to *GameActiveFlag.
54742 LD (25711),A
54745 DI Disable interrupts.
54746 XOR A Write 0 to *Active_BorderColour.
54747 LD (25629),A
54750 OUT (254),A Set the border to BLACK.
54752 LD HL,39024 Copy 6912 bytes from IntroductionScreen to 16384.
54755 LD DE,16384
54758 LD BC,6912
54761 LDIR
54763 LD BC,400 Write 400 to *PauseTimer.
54766 LD (25712),BC
54770 CALL Animate_Introduction Call Animate_Introduction.
Install IM 2. Every interrupt vector in the 253 page holds 254 so the CPU jumps to AliasInterruptRedirect, which jumps to Handler_Interrupts.
54773 LD A,195 Write 195 to *AliasInterruptRedirect.
54775 LD (65278),A
54778 DI Disable interrupts.
54779 LD HL,58476 Write Handler_Interrupts after the jump at AliasInterruptRedirect.
54782 LD (65279),HL
54785 XOR A Write 0 to *InterruptTick.
54786 LD (25710),A
54789 LD HL,0 Write 0000 to *SoundFlags.
54792 LD (25714),HL
54795 LD A,253 Set 253 as the high-order byte in I.
54797 LD I,A
54799 IM 2 Set interrupt mode 2.
54801 CALL JumpTable_InitialiseDisplay Call JumpTable_InitialiseDisplay.
54804 EI Enable interrupts.
54805 LD A,(25711) Jump to Start_Game if *GameActiveFlag is set (start a game).
54808 OR A
54809 JP NZ,Start_Game
54812 XOR A Write 0 to *Active_BorderColour.
54813 LD (25629),A
54816 OUT (254),A Set the border to BLACK.
54818 LD HL,15360 Write 15360 to *CHARS.
54821 LD (23606),HL
Draw_Menu 54824 CALL Clear_PlayArea Call Clear_PlayArea.
This entry point is used by the routine at Handler_RoomPause.
Print the introduction menu.
Print_Menu 54827 LD HL,59123 Print the messaging at Messaging_Title.
54830 CALL JumpTable_PrintMessage
54833 LD HL,59196 Print the messaging at Messaging_Menu.
54836 CALL JumpTable_PrintMessage
54839 LD A,(25726) Write BLACK to *ATTR_T when Kempston is selected.
54842 OR A
54843 JR NZ,Print_Menu_Keyboard
54845 LD A,56
54847 LD (23695),A
Print_Menu_Keyboard 54850 LD HL,59216 Print the messaging at Messaging_Keyboard.
54853 CALL JumpTable_PrintMessage
54856 LD A,(25726) Write BLACK to *ATTR_T when the keyboard is selected.
54859 OR A
54860 JR Z,Print_Menu_DefineKeys
54862 LD A,56
54864 LD (23695),A
Print_Menu_DefineKeys 54867 LD HL,59234 Print the messaging at Messaging_Kempston.
54870 CALL JumpTable_PrintMessage
54873 LD A,(25726) Jump to Menu_Keyboard_Loop if *ControlMethod is zero.
54876 OR A
54877 JR Z,Menu_Keyboard_Loop
Wait for a Kempston menu choice.
54879 LD B,255 B=255.
Menu_Kempston_Loop 54881 CALL Read_Kempston Call Read_Kempston.
54884 JR NZ,Menu_Kempston_Next Jump to Menu_Kempston_Next if the port is unstable.
54886 CP 16 Jump to Start_Game if fire was pressed.
54888 JP Z,Start_Game
Menu_Kempston_Next 54891 DEC BC Jump to Menu_Kempston_Loop until BC is zero.
54892 LD A,C
54893 OR B
54894 JR NZ,Menu_Kempston_Loop
54896 JP Select_Keyboard Jump to Select_Keyboard.
Keyboard menu. Codes are from KEY_SCAN.
Menu_Keyboard_Loop 54899 LD B,3 Call JumpTable_Delay with a pause of 3.
54901 CALL JumpTable_Delay
54904 CALL 654 Call KEY_SCAN.
54907 LD A,E A=the keypress.
54908 CP 35 Jump to Start_Game if "0" was pressed.
54910 JP Z,Start_Game
54913 CP 36 Jump to Select_Keyboard if "1" was pressed.
54915 JP Z,Select_Keyboard
54918 CP 28 Jump to Select_Kempston if "2" was pressed.
54920 JP Z,Select_Kempston
54923 CP 20 Jump to Menu_Keyboard_Loop if the key was not "3".
54925 JR NZ,Menu_Keyboard_Loop
Define the five user keys.
54927 CALL Clear_PlayArea Call Clear_PlayArea.
54930 LD HL,59123 Print the messaging at Messaging_Title.
54933 CALL JumpTable_PrintMessage
54936 LD HL,59279 Print the messaging at Messaging_DefineKeys.
54939 CALL JumpTable_PrintMessage
DefineKeys_Restart 54942 XOR A Write 0 to *ControlMethod.
54943 LD (25726),A
54946 LD B,0 B=0.
DefineKeys_Loop 54948 PUSH BC Stash the key index on the stack.
54949 LD C,27 Print at column 27 row 5+index*2.
54951 LD A,4
54953 SUB B
54954 SLA A
54956 ADD A,5
54958 LD B,A
54959 CALL JumpTable_SetPrintPosition Call JumpTable_SetPrintPosition.
54962 POP BC Restore and restash the key index.
54963 PUSH BC
54964 LD A,(25726) Highlight the current slot in BLACK.
54967 CP B
54968 JR NZ,DefineKeys_PrintSlot
54970 LD A,56
54972 LD (23695),A
DefineKeys_PrintSlot 54975 LD DE,25727 HL=UserDefinedKeys+BC.
54978 LD L,B
54979 LD H,0
54981 ADD HL,DE
54982 LD A,(HL)
54983 LD E,A
54984 LD D,0
54986 LD HL,59394 Print the glyph from Table_KeyMap for this slot.
54989 ADD HL,DE
54990 LD A,(HL)
54991 CALL JumpTable_PrintCharacter
54994 LD A,7 Write WHITE to *ATTR_T.
54996 LD (23695),A
54999 POP BC Restore the key index from the stack.
55000 INC B Increase the key index and jump to DefineKeys_Loop until five keys have been printed.
55001 LD A,B
55002 CP 5
55004 JR NZ,DefineKeys_Loop
DefineKeys_Read 55006 LD BC,20000 Call JumpTable_Delay with a pause of 20000.
55009 CALL JumpTable_Delay
55012 CALL 654 Call KEY_SCAN.
55015 LD A,E A=the keypress.
55016 CP 255 Jump to DefineKeys_Read if no key is pressed.
55018 JR Z,DefineKeys_Read
55020 CP 32 Jump to DefineKeys_CheckDuplicates if ENTER was pressed.
55022 JR Z,DefineKeys_CheckDuplicates
55024 LD BC,(25726) Write the key into the current slot at UserDefinedKeys.
55028 LD B,0
55030 LD HL,25727
55033 ADD HL,BC
55034 LD (HL),A Increase *ControlMethod by one.
55035 LD A,(25726)
55038 INC A
55039 LD (25726),A
55042 CP 5 Jump to DefineKeys_Loop if fewer than five keys are set.
55044 JR NZ,DefineKeys_Loop
Reject a set that contains any duplicate key.
DefineKeys_CheckDuplicates 55046 LD HL,25727 HL=UserDefinedKeys, DE=UserDefinedKey_Right, B=4.
55049 LD DE,25728
55052 LD B,4
DefineKeys_Compare 55054 PUSH DE Stash the compare pointers on the stack.
55055 PUSH BC
DefineKeys_CompareSlot 55056 LD A,(DE) Jump to DefineKeys_CompareNext if this pair differs.
55057 CP (HL)
55058 JR NZ,DefineKeys_CompareNext
55060 POP BC Restart define-keys if a duplicate was found.
55061 POP DE
55062 JP DefineKeys_Restart
DefineKeys_CompareNext 55065 INC DE Increase DE by one.
55066 DJNZ DefineKeys_CompareSlot Decrease the inner counter and loop back to DefineKeys_CompareSlot.
55068 POP BC Restore the compare pointers from the stack.
55069 POP DE
55070 INC HL Increase both pointers by one.
55071 INC DE
55072 DEC B Jump to DefineKeys_Compare until every pair is unique.
55073 JR NZ,DefineKeys_Compare
55075 LD HL,(25727) Copy the first two keys to *SavedKeys.
55078 LD (25732),HL
55081 XOR A Write 0 to *ControlMethod.
55082 LD (25726),A
55085 JP Draw_Menu Jump to Draw_Menu.
View the equivalent code in Booty.
Prev: 54465 Up: Map Next: 55088