Routines |
Prev: 50852 | Up: Map | Next: 51032 |
Check and log game control inputs
|
||||
50870 | LD A,(48921) | Game flag - 0 = New/current game, 1 = Loaded game | ||
50873 | CP 0 | If not a new/current game... | ||
50875 | JP NZ,51043 | ...Launch the pause game (with music) routine | ||
50878 | LD A,(60087) | Get room number | ||
50881 | CP 224 | If <= 224, skip next two instructions | ||
50883 | JR C,50890 | |||
50885 | LD A,1 | If room number >= 224, it's a tunnel room - set Maroc's vertical facing direction to 1 (up) | ||
50887 | LD (60076),A | |||
Read keyboard/joystick input
Kempston controls dealt with separately at 50930.
|
||||
50890 | LD HL,(60166) | Address of the control values to check, e.g. keyboard, cursor, Kempston | ||
50893 | LD DE,60206 | Store for which keys/buttons are being pressed | ||
50896 | LD A,(48920) | Control option 1 = Kempston, 2 = AGF (Cursor), 3 = Sinclair, 4 = Keyboard | ||
50899 | CP 1 | Check if Kempston joystick selected | ||
50901 | JR Z,50930 | |||
50903 | LD C,(HL) | Get port value of control method to check - store in BC register pair | ||
50904 | INC HL | |||
50905 | LD B,(HL) | |||
50906 | INC HL | |||
50907 | IN A,(C) | Check if relevant control key pressed (up/down/left/right/fire) | ||
50909 | OR (HL) | |||
50910 | CP 255 | |||
50912 | JR Z,50918 | |||
50914 | LD A,1 | Key pressed - store 1 for this input | ||
50916 | JR 50920 | |||
50918 | LD A,0 | Key not pressed - store 0 for this input | ||
50920 | LD (DE),A | |||
50921 | INC DE | Move on to next control key/button | ||
50922 | INC HL | |||
50923 | LD A,0 | Check if we've reached the end of the controls (0 = end-of-data byte) | ||
50925 | CP (HL) | |||
50926 | JR NZ,50903 | If not, continue to read control directions until all 5 have been checked | ||
50928 | JR 50952 | |||
Read Kempston joystick input
|
||||
50930 | LD BC,31 | Kempston joystick port | ||
50933 | IN A,(C) | Read control port | ||
50935 | LD B,A | |||
50936 | LD A,(HL) | Check if direction/button being pressed | ||
50937 | AND B | |||
50938 | LD A,0 | Store 0 (default) if button/control not being pressed | ||
50940 | JR Z,50944 | |||
50942 | LD A,1 | Store 1 if button/control being pressed | ||
50944 | LD (DE),A | |||
50945 | INC DE | Move on to next control/button | ||
50946 | INC HL | |||
50947 | LD A,(HL) | |||
50948 | CP 0 | Check if we've reached the end of the controls (0 = end-of-data byte) | ||
50950 | JR NZ,50930 | If not, continue to read control directions until all 5 have been checked | ||
Evaluate control direction values
Horizontal movement control:
|
||||
50952 | LD A,(60209) | Check movement control - right | ||
50955 | LD C,A | Store in C register (1 = right pressed, 0 = right not pressed) | ||
50956 | LD A,(60208) | Check movement control - left | ||
50959 | SUB C | Calculate left minus right (0 = both/neither pressed, 1 = right pressed, -1 (255) = left pressed) | ||
50960 | LD C,A | Store left/right calculated value in C | ||
50961 | LD A,(60075) | Maroc's facing direction - 0, 254 (facing right), or 2 (facing left), depending on which door he's entered a room from. When Maroc enters a new room, he's set to 'moving' so he doesn't just sit in the doorway |
||
50964 | ADD A,C | Add to control value | ||
50965 | LD (60157),A | ...And store... | ||
Vertical movement control:
|
||||
50968 | LD A,(60207) | Check movement control - down | ||
50971 | LD C,A | Store in C register (1 = down pressed, 0 = down not pressed) | ||
50972 | LD A,(60206) | Check movement control - up | ||
50975 | SUB C | Calculate up minus down (0 = both/neither pressed, 1 = up pressed, -1 (255) = down pressed) | ||
50976 | LD C,A | Store up/down calculated value in C register | ||
50977 | LD A,(60076) | Maroc's facing direction (1 = facing up, 255 = facing down) | ||
50980 | ADD A,C | Add to control value | ||
50981 | LD (60158),A | ...And store... | ||
The FIRE button flag is stored at 60210. Unlike other control directions, the byte at 60102 is used to ensure that the control button is released after pressing, to prevent action auto-cancel if the fire control is held for too long.
This ensures that the player has to let go of the fire control button/key, before pressing it again to activate something.
|
||||
50984 | LD A,(60210) | Check FIRE control | ||
50987 | CP 0 | |||
50989 | LD A,(60102) | Get the 'fire release' flag ready to check | ||
50992 | JR Z,51027 | If fire hasn't been pressed, skip the next routine | ||
FIRE pressed
|
||||
50994 | CP 0 | Has the fire key been released from being pressed earlier? | ||
50996 | JR Z,51005 | |||
50998 | LD A,0 | Set FIRE control to zero | ||
51000 | LD (60210),A | |||
51003 | JR 51032 | |||
Fire control has been pressed so set the fire control release byte at 60102 to 1.
|
||||
51005 | LD A,1 | |||
51007 | LD (60102),A | |||
Play high pitched beep
|
||||
51010 | LD A,16 | 16 = speaker bit (bit 4) | ||
51012 | LD C,32 | Outer loop counter - affects duration/sound effect | ||
51014 | OUT (254),A | Play speaker | ||
51016 | XOR 16 | Toggle speaker bit | ||
51018 | LD B,48 | Inner loop counter - affects pitch of beep sound | ||
51020 | DJNZ 51020 | Decrement inner loop counter until zero for short pause | ||
51022 | DEC C | Outer loop pause | ||
51023 | JR NZ,51014 | |||
51025 | JR 51032 | |||
Fire not pressed
|
||||
51027 | LD A,0 | Set the 'fire control release' control flag to 0, as no fire controls are being pressed | ||
51029 | LD (60102),A |
Prev: 50852 | Up: Map | Next: 51032 |