Prev: 57625 Up: Map Next: 57949
57721: Controls
Used by the routines at Handler_Controls, Animate_Waiting, Event_Landed, 60150 and 61264.
Output
A Byte representing the intended action
Controls 57721 LD A,(53842) Jump to Controls_FetchSet if *Active_MonsterControlType is not set to "computer controlled".
57724 AND A
57725 JR NZ,Controls_FetchSet
Controls_0 57727 CALL RandomNumber Write a random number between 0-31 to *53783.
57730 AND %00011111
57732 LD (53783),A
57735 LD A,(53832) A=*Flag_MonsterJumping.
57738 RRCA Rotate A right one position, setting the carry flag if bit 0 was set.
57739 JR NC,Controls_1 Jump to Controls_1 if the carry flag is not set.
57741 LD A,8 Write 8 to *53783.
57743 LD (53783),A
57746 RET Return.
Controls_1 57747 LD A,(53830) A=*Flag_MonsterClimbing.
57750 RRCA Rotate A right one position, setting the carry flag if bit 0 was set.
57751 JR NC,Controls_2 Jump to Controls_2 if the carry flag is not set.
57753 LD A,(53783) Jump to Controls_0 if *53783 is equal to 16.
57756 CP 16
57758 JR Z,Controls_0
57760 RET Return.
Controls_2 57761 LD A,(53838) A=*Active_MonsterYPosition.
57764 CP 17 Compare A with 17...
57766 LD A,(53783) A=*53783.
57769 RET C Return if A was is lower than 17 on line 57764.
57770 CP 16 Jump to Controls_0 if A is equal to 16.
57772 JR Z,Controls_0
57774 LD A,(53837) A=*Active_MonsterXPosition.
57777 CP 250 Jump to Controls_3 if A is higher than 250.
57779 JR NC,Controls_3
57781 CP 3 Jump to Controls_3 if A is lower than 3.
57783 JR C,Controls_3
57785 CP 27 Compare A with 27...
57787 LD A,(53783) A=*53783.
57790 RET C Return if A was lower 27 on line 57785.
57791 RES 1,A Reset bit 1 of A.
57793 JR Controls_4 Jump to Controls_4.
Controls_3 57795 LD A,(53783) A=*53783.
57798 RES 0,A Reset bit 0 of A.
Controls_4 57800 RES 4,A Reset bit 4 of A.
57802 LD (53783),A Write A to *53783.
57805 RET Return.
Controls_FetchSet 57806 ADD A,A A*=2.
57807 LD H,0 Create an offset using HL.
57809 LD L,A
57810 LD DE,57935 HL+=JumpTable_Controls.
57813 ADD HL,DE
Load the address into HL and jump to it.
57814 LD A,(HL) A=*HL.
57815 INC HL Increment HL by one.
57816 LD H,(HL) H=*HL.
57817 LD L,A L=A.
57818 JP (HL) Jump to the address held by *HL.
57819 XOR A A=0.
57820 JP Controls_12 Jump to Controls_12.
57823 LD A,247 A=247.
57825 IN A,(254)
57827 XOR %10111111 Flip bits 0-5 and 7.
57829 AND %00011111 Keep only bits 0-4.
57831 JP Controls_12 Jump to Controls_12.
57834 LD A,239 A=239.
57836 IN A,(254)
57838 LD B,198 B=198.
57840 LD C,A
57841 LD A,(BC) A=*BC.
57842 RRCA RRCA.
57843 RRCA
57844 RRCA
57845 XOR %10111111 Flip bits 0-5 and 7.
57847 AND %00011111 Keep only bits 0-4.
57849 JP Controls_12 Jump to Controls_12.
Controls_ReadKempston 57852 IN A,(31) Read Kempston Joystick input.
57854 AND %00011111 Keep only bits 0-4.
57856 JP Z,Controls_12 Jump to Controls_12 if the result is zero.
57859 LD B,A B=A.
57860 AND %00000011 Keep only bits 0-1.
57862 LD A,B A=B.
57863 JP Z,Controls_5 Jump to Controls_5 if A is zero.
57866 XOR %00000011 Flip bits 0-1.
Controls_5 57868 OR A Set the bits from A.
57869 JP Controls_12 Jump to Controls_12.
Use user-defined keys set 1.
Controls_Set1 57872 LD HL,51280 HL=UserDefinedKeys_Set1.
57875 JR Controls_6 Jump to Controls_6.
Use user-defined keys set 2.
Controls_Set2 57877 LD HL,51290 HL=UserDefinedKeys_Set2.
57880 JR Controls_6 Jump to Controls_6.
Use user-defined keys set 3.
Controls_Set3 57882 LD HL,51300 HL=UserDefinedKeys_Set3.
Controls_6 57885 LD C,0 C=0.
57887 CALL Controls_ReadKeyboard Call Controls_ReadKeyboard.
57890 JR NZ,Controls_7 Jump to Controls_7 if {} is not zero.
57892 SET 0,C Set bit 0 of C.
Controls_7 57894 CALL Controls_ReadKeyboard Call Controls_ReadKeyboard.
57897 JR NZ,Controls_8 Jump to Controls_8 if {} is not zero.
57899 SET 1,C Set bit 1 of C.
Controls_8 57901 CALL Controls_ReadKeyboard Call Controls_ReadKeyboard.
57904 JR NZ,Controls_9 Jump to Controls_9 if {} is not zero.
57906 SET 3,C Set bit 3 of C.
Controls_9 57908 CALL Controls_ReadKeyboard Call Controls_ReadKeyboard.
57911 JR NZ,Controls_10 Jump to Controls_10 if {} is not zero.
57913 SET 2,C Set bit 2 of C.
Controls_10 57915 CALL Controls_ReadKeyboard Call Controls_ReadKeyboard.
57918 JR NZ,Controls_11 Jump to Controls_11 if {} is not zero.
57920 SET 4,C Set bit 4 of C.
Controls_11 57922 LD A,C A=C.
Controls_12 57923 AND A Set flags.
57924 LD (53783),A Write A to *53783.
57927 RET Return.
Controls_ReadKeyboard 57928 LD A,(HL) A=*HL.
57929 IN A,(254) Read from the keyboard.
57931 INC HL Increment HL by one.
57932 AND (HL) Merge the bits from *HL.
57933 INC HL Increment HL by one.
57934 RET Return.
JumpTable_Controls 57935 DEFW 57819
57937 DEFW 57823
57939 DEFW 57834
57941 DEFW Controls_ReadKempston
57943 DEFW Controls_Set1
57945 DEFW Controls_Set2
57947 DEFW Controls_Set3
Prev: 57625 Up: Map Next: 57949