![]() |
Routines |
| Prev: C117 | Up: Map | Next: C1D2 |
|
Used by the routine at PLAYER_LEGS.
Two ways of steering. Rotational control -- the keyboard's always, and a joystick's unless directional control is chosen -- turns a quarter at a time on the two turn controls: bit 0 of C left, bit 1 right. Directional control, a joystick with bit 3 of CONTROL set (key 5 on the menu), treats the controls as four points of the compass instead: pushing one turns the robot towards it and, once he faces it, walks him that way.
Facings, as GET_SPRITE_DIR gives them: bit 2 of the graphic and bit 6 of the flags, the mirror bit, make a number 0 to 3 (the mirror bit the high bit); a left turn goes 0, 3, 1, 2 and round, a right turn the other way. Directional control reads up (bit 2) -- which faces 2 -- unless left is also held, then right (1), down (bit 4; 3) and left (0), and goes the short way round, or two turns for an about-face.
A turn is not made at once, as in Knight Lore and Pentagram. The legs become one of four part-way graphics, 24 to 27, from TURN_RIGHT_VIEWS for a right turn or TURN_LEFT_VIEWS for a left one, by the facing; bit 0 of +$0D records which way, and bits 1-2 a count of one. Their update routine (TURNING_LEGS) holds that frame for two turns and then puts in the new facing's standing graphic (17 or 21, with its mirror bit), so a quarter turn takes three turns (measured: holding a turn key, the legs' graphic at the end of each turn went 26, 26, then 17 mirrored, and so on round). The top follows the legs' graphic, 16 higher (TOP_FOLLOWS_LEGS). No turn is started during the walk into a room, or in a jump; directional control also waits until he stands on something.
|
||||||||||||||
| HANDLE_LEFT_RIGHT | C13C | LD HL,CONTROL | bits 1-2 of CONTROL: 0, the keyboard, always turns rotationally | |||||||||||
| C13F | LD A,(HL) | |||||||||||||
| C140 | AND $06 | |||||||||||||
| C142 | JR Z,ROTATIONAL_TURN | |||||||||||||
| C144 | BIT 3,(HL) | directional control not chosen | ||||||||||||
| C146 | JR Z,ROTATIONAL_TURN | |||||||||||||
| C148 | LD A,(IX+$0C) | directional: nothing during the walk into a room (the count in bits 4-7 of +$0C)... | ||||||||||||
| C14B | AND $F0 | |||||||||||||
| C14D | RET NZ | |||||||||||||
| C14E | BIT 2,(IX+$0C) | ...nor in the air: bit 2 of +$0C, standing on something | ||||||||||||
| C152 | RET Z | |||||||||||||
| C153 | BIT 0,C | left held: skip up; up held: face 2 | ||||||||||||
| C155 | JR NZ,DIRECTIONAL_NOT_UP | |||||||||||||
| C157 | BIT 2,C | |||||||||||||
| C159 | JR NZ,DIRECTIONAL_UP | |||||||||||||
| DIRECTIONAL_NOT_UP | C15B | BIT 1,C | right: face 1; down: face 3; left: face 0 | |||||||||||
| C15D | JR NZ,DIRECTIONAL_RIGHT | |||||||||||||
| C15F | BIT 4,C | |||||||||||||
| C161 | JR NZ,DIRECTIONAL_DOWN | |||||||||||||
| C163 | BIT 0,C | |||||||||||||
| C165 | JR NZ,DIRECTIONAL_LEFT | |||||||||||||
| C167 | RES 2,C | nothing pushed: no walking | ||||||||||||
| C169 | RET | |||||||||||||
| DIRECTIONAL_UP | C16A | CALL GET_SPRITE_DIR | up: facing 2 already? | |||||||||||
| C16D | CP $02 | |||||||||||||
| HANDLE_LEFT_RIGHT_0 | C16F | JR Z,FACING_THAT_WAY | yes: walk; otherwise invert the facing, so that its bit 0 set means a right turn is the short way | |||||||||||
| C171 | CPL | |||||||||||||
| TURN_BY_PARITY | C172 | AND $01 | the facing's bit 0 picks the turn | |||||||||||
| C174 | JR HANDLE_LEFT_RIGHT_2 | |||||||||||||
| DIRECTIONAL_RIGHT | C176 | CALL GET_SPRITE_DIR | right: facing 1 already? The same test as up | |||||||||||
| C179 | CP $01 | |||||||||||||
| C17B | JR HANDLE_LEFT_RIGHT_0 | |||||||||||||
| DIRECTIONAL_DOWN | C17D | CALL GET_SPRITE_DIR | down: facing 3 already? Walk if so; otherwise the facing's own bit 0 picks the turn | |||||||||||
| C180 | CP $03 | |||||||||||||
| HANDLE_LEFT_RIGHT_1 | C182 | JR Z,FACING_THAT_WAY | ||||||||||||
| C184 | JR TURN_BY_PARITY | |||||||||||||
| DIRECTIONAL_LEFT | C186 | CALL GET_SPRITE_DIR | left: facing 0 already? The same test as down | |||||||||||
| C189 | AND A | |||||||||||||
| C18A | JR HANDLE_LEFT_RIGHT_1 | |||||||||||||
| FACING_THAT_WAY | C18C | SET 2,C | facing the way pushed: walk | |||||||||||
| C18E | RET | |||||||||||||
| ROTATIONAL_TURN | C18F | LD A,C | rotational: neither turn control held | |||||||||||
| C190 | AND $03 | |||||||||||||
| C192 | RET Z | |||||||||||||
| C193 | LD A,(IX+$0C) | not during the walk into a room | ||||||||||||
| C196 | AND $F0 | |||||||||||||
| C198 | RET NZ | |||||||||||||
| C199 | BIT 3,(IX+$0C) | not in the middle of a jump | ||||||||||||
| C19D | RET NZ | |||||||||||||
| C19E | BIT 1,C | bit 1: right | ||||||||||||
| HANDLE_LEFT_RIGHT_2 | C1A0 | JR NZ,START_TURN_RIGHT | NZ for a right turn, Z for a left | |||||||||||
| START_TURN_LEFT | C1A2 | RES 0,(IX+$0D) | left: bit 0 of +$0D clear, and the left turn's part-way graphics | |||||||||||
| C1A6 | LD HL,TURN_LEFT_VIEWS | |||||||||||||
| C1A9 | JR START_TURN | |||||||||||||
| START_TURN_RIGHT | C1AB | SET 0,(IX+$0D) | right: bit 0 of +$0D set, and the right turn's | |||||||||||
| C1AF | LD HL,TURN_RIGHT_VIEWS | |||||||||||||
| START_TURN | C1B2 | LD A,(IX+$0D) | a count of one in bits 1-2 of +$0D, for TURNING_LEGS | |||||||||||
| C1B5 | OR $02 | |||||||||||||
| C1B7 | LD (IX+$0D),A | |||||||||||||
| C1BA | CALL GET_SPRITE_DIR | A = the facing | ||||||||||||
|
This entry point is used by the routine at TURNING_LEGS.
Set the graphic and the mirror bit from the pair A selects in the table at HL, A taken modulo 4. Also used by TURNING_LEGS, with the part-way graphic as A.
|
||||||||||||||
| SET_TURN_GRAPHIC | C1BD | RLCA | HL = the pair: A times 2 | |||||||||||
| C1BE | AND $06 | |||||||||||||
| C1C0 | CALL ADD_HL_A | |||||||||||||
| C1C3 | LD A,(HL) | the graphic | ||||||||||||
| C1C4 | INC HL | |||||||||||||
| C1C5 | LD (IX+$00),A | |||||||||||||
| C1C8 | LD A,(IX+$07) | the mirror bit (bit 6 of +7) from the pair's second byte | ||||||||||||
| C1CB | AND $BF | |||||||||||||
| C1CD | OR (HL) | |||||||||||||
| C1CE | LD (IX+$07),A | |||||||||||||
| C1D1 | RET | |||||||||||||
| Prev: C117 | Up: Map | Next: C1D2 |