Routines |
Prev: E119 | Up: Map | Next: E25D |
Used by the routines at Handler_Controls, Animate_Waiting, Event_Landed, EAF6 and Controller_JumpPunch.
|
||||||||||||||||||||
First off, check if the active monster is computer controlled.
|
||||||||||||||||||||
Controls | E179 | LD A,($D252) | Jump to PlayerControlled if *Active_MonsterControlType is not set to "computer controlled". | |||||||||||||||||
E17C | AND A | |||||||||||||||||||
E17D | JR NZ,PlayerControlled | |||||||||||||||||||
Handles the monster being computer controlled.
|
||||||||||||||||||||
ComputerControlled | E17F | CALL RandomNumber | Write a random number between 00-1F (00000000-00011111 e.g. Up/ Down/ Left/ Right/ Action) to *Active_MonsterControl. | |||||||||||||||||
E182 | AND %00011111 | |||||||||||||||||||
E184 | LD ($D217),A | |||||||||||||||||||
Check if the currently active monster is jumping.
|
||||||||||||||||||||
E187 | LD A,($D248) | A=*Flag_MonsterJumping. | ||||||||||||||||||
E18A | RRCA | Rotate A right one position, setting the carry flag if bit 0 was set. | ||||||||||||||||||
E18B | JR NC,Controls_IsMonsterClimbing | Jump to Controls_IsMonsterClimbing if the monster isn't currently jumping. | ||||||||||||||||||
The active monster is jumping...
|
||||||||||||||||||||
E18D | LD A,$08 | Write 00001000 to *Active_MonsterControl. | ||||||||||||||||||
E18F | LD ($D217),A | |||||||||||||||||||
E192 | RET | Return. | ||||||||||||||||||
Check if the currently active monster is climbing.
|
||||||||||||||||||||
Controls_IsMonsterClimbing | E193 | LD A,($D246) | A=*Flag_MonsterClimbing. | |||||||||||||||||
E196 | RRCA | Rotate A right one position, setting the carry flag if bit 0 was set. | ||||||||||||||||||
E197 | JR NC,Controls_CheckBoundaries | Jump to Controls_CheckBoundaries if the monster isn't currently climbing. | ||||||||||||||||||
The active monster is climbing...
|
||||||||||||||||||||
E199 | LD A,($D217) | Jump to ComputerControlled if *Active_MonsterControl is equal to 10 (00010000 e.g. "jumping/ punching"). | ||||||||||||||||||
E19C | CP $10 | |||||||||||||||||||
E19E | JR Z,ComputerControlled | |||||||||||||||||||
E1A0 | RET | Return. | ||||||||||||||||||
Checks the screen boundaries to ensure the monster can't go off-screen.
|
||||||||||||||||||||
Controls_CheckBoundaries | E1A1 | LD A,($D24E) | A=*Active_MonsterYPosition. | |||||||||||||||||
E1A4 | CP $11 | Compare A with 11... | ||||||||||||||||||
E1A6 | LD A,($D217) | A=*Active_MonsterControl. | ||||||||||||||||||
E1A9 | RET C | Return if A was is lower than 11 on line E1A4. | ||||||||||||||||||
E1AA | CP $10 | Jump to ComputerControlled if A is equal to 10. | ||||||||||||||||||
E1AC | JR Z,ComputerControlled | |||||||||||||||||||
E1AE | LD A,($D24D) | A=*Active_MonsterXPosition. | ||||||||||||||||||
E1B1 | CP $FA | Jump to ComputerUnset_Left if A is higher than FA. | ||||||||||||||||||
E1B3 | JR NC,ComputerUnset_Left | |||||||||||||||||||
E1B5 | CP $03 | Jump to ComputerUnset_Left if A is lower than 03. | ||||||||||||||||||
E1B7 | JR C,ComputerUnset_Left | |||||||||||||||||||
E1B9 | CP $1B | Compare A with 1B... | ||||||||||||||||||
E1BB | LD A,($D217) | A=*Active_MonsterControl. | ||||||||||||||||||
E1BE | RET C | Return if A was lower 1B on line E1B9. | ||||||||||||||||||
Unsets the computer controlled monster "right" option.
|
||||||||||||||||||||
E1BF | RES 1,A | Reset bit 1 of A. | ||||||||||||||||||
E1C1 | JR ComputerUnset_JumpPunch | Jump to ComputerUnset_JumpPunch. | ||||||||||||||||||
Unsets the computer controlled monster "left" option.
|
||||||||||||||||||||
ComputerUnset_Left | E1C3 | LD A,($D217) | A=*Active_MonsterControl. | |||||||||||||||||
E1C6 | RES 0,A | Reset bit 0 of A. | ||||||||||||||||||
Unsets the computer controlled monster "jump/punch" option.
|
||||||||||||||||||||
ComputerUnset_JumpPunch | E1C8 | RES 4,A | Reset bit 4 of A. | |||||||||||||||||
E1CA | LD ($D217),A | Write A to *Active_MonsterControl. | ||||||||||||||||||
E1CD | RET | Return. | ||||||||||||||||||
The active monster is player controlled so using Active_MonsterControlType fetch the controller routine.
|
||||||||||||||||||||
PlayerControlled | E1CE | ADD A,A | Create an offset in HL using A*02. | |||||||||||||||||
E1CF | LD H,$00 | |||||||||||||||||||
E1D1 | LD L,A | |||||||||||||||||||
E1D2 | LD DE,$E24F | HL+=JumpTable_Controls. | ||||||||||||||||||
E1D5 | ADD HL,DE | |||||||||||||||||||
Load the controls address into HL and jump to it.
|
||||||||||||||||||||
E1D6 | LD A,(HL) | Load the low byte of the controls address from the jump table. | ||||||||||||||||||
E1D7 | INC HL | Increment the controls jump table pointer by one. | ||||||||||||||||||
E1D8 | LD H,(HL) | Set the high byte of the controls address from the jump table. | ||||||||||||||||||
E1D9 | LD L,A | Set low byte of the controls address from A. | ||||||||||||||||||
E1DA | JP (HL) | Jump to the address held by *HL. | ||||||||||||||||||
Controls_ComputerControlled | E1DB | XOR A | A=00. | |||||||||||||||||
E1DC | JP Controls_Return | Jump to Controls_Return. | ||||||||||||||||||
Read the controls from the Sinclair Interface 2 joystick (port 2).
|
||||||||||||||||||||
Controls_ReadSinclair2_P2 | E1DF | LD A,$F7 | Read from the keyboard;
|
|||||||||||||||||
E1E1 | IN A,($FE) | |||||||||||||||||||
E1E3 | XOR %10111111 | Flip bits 0-5 and 7. | ||||||||||||||||||
E1E5 | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
E1E7 | JP Controls_Return | Jump to Controls_Return. | ||||||||||||||||||
Read the controls from the Sinclair Interface 2 joystick (port 1).
|
||||||||||||||||||||
Controls_ReadSinclair2_P1 | E1EA | LD A,$EF | Read from the keyboard;
|
|||||||||||||||||
E1EC | IN A,($FE) | |||||||||||||||||||
Converts the input into a table address beginning at PortMappings.
|
||||||||||||||||||||
E1EE | LD B,$C6 | Create an offset using BC - where B=C6 and C=A. | ||||||||||||||||||
E1F0 | LD C,A | |||||||||||||||||||
E1F1 | LD A,(BC) | A=*BC. | ||||||||||||||||||
E1F2 | RRCA | Rotate A right three positions (bits 3 to 7 are now in positions 0 to 4). | ||||||||||||||||||
E1F3 | RRCA | |||||||||||||||||||
E1F4 | RRCA | |||||||||||||||||||
E1F5 | XOR %10111111 | Flip bits 0-5 and 7. | ||||||||||||||||||
E1F7 | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
E1F9 | JP Controls_Return | Jump to Controls_Return. | ||||||||||||||||||
Read the controls from the Kempston joystick port.
|
||||||||||||||||||||
Controls_ReadKempston | E1FC | IN A,($1F) | Read Kempston Joystick input. | |||||||||||||||||
E1FE | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
E200 | JP Z,Controls_Return | Jump to Controls_Return if the result is zero. | ||||||||||||||||||
E203 | LD B,A | B=A. | ||||||||||||||||||
E204 | AND %00000011 | Keep only bits 0-1. | ||||||||||||||||||
E206 | LD A,B | A=B. | ||||||||||||||||||
E207 | JP Z,Controls_0 | Jump to Controls_0 if A is zero. | ||||||||||||||||||
E20A | XOR %00000011 | Flip bits 0-1. | ||||||||||||||||||
Controls_0 | E20C | OR A | Set the bits from A. | |||||||||||||||||
E20D | JP Controls_Return | Jump to Controls_Return. | ||||||||||||||||||
Use user-defined keys set 1.
|
||||||||||||||||||||
Controls_Set1 | E210 | LD HL,$C850 | HL=UserDefinedKeys_Set1. | |||||||||||||||||
E213 | JR Controller_ReadKeyboard | Jump to Controller_ReadKeyboard. | ||||||||||||||||||
Use user-defined keys set 2.
|
||||||||||||||||||||
Controls_Set2 | E215 | LD HL,$C85A | HL=UserDefinedKeys_Set2. | |||||||||||||||||
E218 | JR Controller_ReadKeyboard | Jump to Controller_ReadKeyboard. | ||||||||||||||||||
Use user-defined keys set 3.
|
||||||||||||||||||||
Controls_Set3 | E21A | LD HL,$C864 | HL=UserDefinedKeys_Set3. | |||||||||||||||||
Read the keyboard set in HL.
|
||||||||||||||||||||
Controller_ReadKeyboard | E21D | LD C,$00 | C=00. | |||||||||||||||||
Has "left" been pressed?
|
||||||||||||||||||||
E21F | CALL Controls_ReadKeyboard | Call Controls_ReadKeyboard. | ||||||||||||||||||
E222 | JR NZ,Controls_ReadKeyboardRight | Jump to Controls_ReadKeyboardRight if "left" is not being pressed. | ||||||||||||||||||
E224 | SET 0,C | Set bit 0 of C if "left" is being pressed. | ||||||||||||||||||
Has "right" been pressed?
|
||||||||||||||||||||
Controls_ReadKeyboardRight | E226 | CALL Controls_ReadKeyboard | Call Controls_ReadKeyboard. | |||||||||||||||||
E229 | JR NZ,Controls_ReadKeyboardUp | Jump to Controls_ReadKeyboardUp if "right" is not being pressed. | ||||||||||||||||||
E22B | SET 1,C | Set bit 1 of C if "right" is being pressed. | ||||||||||||||||||
Has "up" been pressed?
|
||||||||||||||||||||
Controls_ReadKeyboardUp | E22D | CALL Controls_ReadKeyboard | Call Controls_ReadKeyboard. | |||||||||||||||||
E230 | JR NZ,Controls_ReadKeyboardDown | Jump to Controls_ReadKeyboardDown if "up" is not being pressed. | ||||||||||||||||||
E232 | SET 3,C | Set bit 3 of C if "up" is being pressed. | ||||||||||||||||||
Has "down" been pressed?
|
||||||||||||||||||||
Controls_ReadKeyboardDown | E234 | CALL Controls_ReadKeyboard | Call Controls_ReadKeyboard. | |||||||||||||||||
E237 | JR NZ,Controls_ReadKeyboardJumpPunch | Jump to Controls_ReadKeyboardJumpPunch if "down" is not being pressed. | ||||||||||||||||||
E239 | SET 2,C | Set bit 2 of C if "down" is being pressed. | ||||||||||||||||||
Has "jump/punch" been pressed?
|
||||||||||||||||||||
Controls_ReadKeyboardJumpPunch | E23B | CALL Controls_ReadKeyboard | Call Controls_ReadKeyboard. | |||||||||||||||||
E23E | JR NZ,Controls_ReadKeyboardSet | Jump to Controls_ReadKeyboardSet if "jump/punch" is not being pressed. | ||||||||||||||||||
E240 | SET 4,C | Set bit 4 of C if "jump/punch" is being pressed. | ||||||||||||||||||
Controls_ReadKeyboardSet | E242 | LD A,C | A=C. | |||||||||||||||||
Set the "zero" flag if no controls are being pressed.
|
||||||||||||||||||||
Controls_Return | E243 | AND A | Set flags. | |||||||||||||||||
E244 | LD ($D217),A | Write A to *Active_MonsterControl. | ||||||||||||||||||
E247 | RET | Return. | ||||||||||||||||||
Using the keyboard set in HL, read the control from the keyboard.
|
||||||||||||||||||||
Controls_ReadKeyboard | E248 | LD A,(HL) | A=*HL. | |||||||||||||||||
E249 | IN A,($FE) | Read from the entire keyboard. | ||||||||||||||||||
E24B | INC HL | Increment HL by one. | ||||||||||||||||||
E24C | AND (HL) | Merge the bits from *HL. | ||||||||||||||||||
E24D | INC HL | Increment HL by one. | ||||||||||||||||||
E24E | RET | Return. | ||||||||||||||||||
The monster control type jump table. See Active_MonsterControlType.
|
||||||||||||||||||||
JumpTable_Controls | E24F | DEFW Controls_ComputerControlled | Control type ID: 00. | |||||||||||||||||
E251 | DEFW Controls_ReadSinclair2_P2 | Control type ID: 01. | ||||||||||||||||||
E253 | DEFW Controls_ReadSinclair2_P1 | Control type ID: 02. | ||||||||||||||||||
E255 | DEFW Controls_ReadKempston | Control type ID: 03. | ||||||||||||||||||
E257 | DEFW Controls_Set1 | Control type ID: 04. | ||||||||||||||||||
E259 | DEFW Controls_Set2 | Control type ID: 05. | ||||||||||||||||||
E25B | DEFW Controls_Set3 | Control type ID: 06. |
Prev: E119 | Up: Map | Next: E25D |