![]() |
Routines |
| Prev: F52A | Up: Map | Next: F65C |
|
Used by the routine at CREATURE_UPDATE.
Reached from KNIGHT_UPDATE (CREATURE_UPDATE) when a key other than the action keys is down, or the joystick has moved. The way to go comes from the joystick if it is on and moved, otherwise from the keyboard. A later test wins, so there is no diagonal walking: on the keyboard Q-T beats A-G beats H-ENTER beats Y-P, and on the joystick up beats down beats left beats right.
A direction is a byte with one bit for each way, the same for every object (+13, +18, IY+$71, IY+$7C): bit 0 -- turn back when stopped (MEET_DECOY reverses the way rather than ending it); bit 1 -- rising: do not fall this pass; bit 2 -- down x; bit 3 -- up x (Y-P, joystick right); bit 4 -- up; bit 5 -- down (gravity); bit 6 -- up y (Q-T, joystick up); bit 7 -- down y. On the screen, going up x moves up and to the right, and going up y moves up and to the left. A step is two units along one axis, or one along each of x and y for a diagonal; up or down is always two.
The author's I88, with the author's own labels from the source text left at SOURCE_AND_STACK for most of its tests. INP5 then turns the knight to face the way he goes (MIMAN mirrors all his frames, and sets bits 5 and 6 of his state: FACING has which is which). Mid-jump (state 5, from CHE3D) he just walks on. Otherwise SPACE or SYMBOL SHIFT jumps: up for 8 passes of two units, going the way he walked, then down (measured: from 78 to 94 and back). His state becomes 5 for the rise, keeping the facing bits; CHE3D counts the rise off and makes him 8 again, and he falls as anything does. B, N or M, or the joystick's fire, fights: the sword is out (bit 1 of IY+$17, which is what hurts a creature he meets, OBJECTS_MEET) for three passes, standing, and then away for three while he steps forward, the two frames facing the viewer or away (SPRITE96E0 and SPRITE979A, SPRITE9854 and SPRITE990E). Otherwise he walks, through three frames of his walk (SPRITE9110 facing the viewer, SPRITE933E away).
The author's ANIM, at the end, picks a frame from a run of them. +17 holds the frame (bits 0-2), the last frame of the run (bits 3-5) and bit 7 while going back. HL is the first frame and DE the size of one; the frame shown is HL + DE times the frame. The run goes forward to the last and then back, but it goes back by jumping to frame 1: measured, a run of three goes 0, 1, 2, 1, 0, 1, 2 ..., but one of four goes 0, 1, 2, 3, 1, 0 and one of two 0, 1, 1, 0. Every run the game uses is three frames. The rest of it is at ANIMATE_AND_MOVE.
|
||||||||||||
| KNIGHT_CONTROLS | F595 | CALL IN31 | The author's I88. The joystick, if it is on; otherwise the keyboard | |||||||||
| F598 | JR Z,WALK_KEYS | |||||||||||
|
This entry point is used by the routine at CREATURE_UPDATE.
|
||||||||||||
| STICK_DIRECTION | F59A | RRA | The author's I89 (the source's I82 to I85 are the next four tests). Right: up x | |||||||||
| F59B | JR NC,KNIGHT_CONTROLS_0 | |||||||||||
| F59D | LD C,$08 | |||||||||||
| KNIGHT_CONTROLS_0 | F59F | RRA | Left: down x | |||||||||
| F5A0 | JR NC,KNIGHT_CONTROLS_1 | |||||||||||
| F5A2 | LD C,$04 | |||||||||||
| KNIGHT_CONTROLS_1 | F5A4 | RRA | Down: down y | |||||||||
| F5A5 | JR NC,KNIGHT_CONTROLS_2 | |||||||||||
| F5A7 | LD C,$80 | |||||||||||
| KNIGHT_CONTROLS_2 | F5A9 | RRA | Up: up y | |||||||||
| F5AA | JR NC,KNIGHT_CONTROLS_3 | |||||||||||
| F5AC | LD C,$40 | |||||||||||
| KNIGHT_CONTROLS_3 | F5AE | RRA | Fire: fight, at once | |||||||||
| F5AF | JR C,KNIGHT_FIGHT | |||||||||||
| F5B1 | JR KNIGHT_TURN | Walk | ||||||||||
|
This entry point is used by the routine at CREATURE_UPDATE.
|
||||||||||||
| WALK_KEYS | F5B3 | LD A,$DF | The author's I80 (INP2 to INP4 are the next three tests). Y-P: up x | |||||||||
| F5B5 | CALL INPUT | |||||||||||
| F5B8 | JR Z,KNIGHT_CONTROLS_4 | |||||||||||
| F5BA | LD C,$08 | |||||||||||
| KNIGHT_CONTROLS_4 | F5BC | LD A,$BF | H-ENTER: down x | |||||||||
| F5BE | CALL INPUT | |||||||||||
| F5C1 | JR Z,KNIGHT_CONTROLS_5 | |||||||||||
| F5C3 | LD C,$04 | |||||||||||
| KNIGHT_CONTROLS_5 | F5C5 | LD A,$FD | A-G: down y | |||||||||
| F5C7 | CALL INPUT | |||||||||||
| F5CA | JR Z,KNIGHT_CONTROLS_6 | |||||||||||
| F5CC | LD C,$80 | |||||||||||
| KNIGHT_CONTROLS_6 | F5CE | LD A,$FB | Q-T: up y | |||||||||
| F5D0 | CALL INPUT | |||||||||||
| F5D3 | JR Z,KNIGHT_TURN | |||||||||||
| F5D5 | LD C,$40 | |||||||||||
|
This entry point is used by the routine at CHE3D.
|
||||||||||||
| KNIGHT_TURN | F5D7 | CALL MIMAN | The author's INP5 (CHE3D comes here mid-jump). Turn his frames to face the way he goes; HL = his walking frames facing the viewer (SPRITE9110) | |||||||||
| F5DA | LD A,E | Facing away: the walk at SPRITE933E | ||||||||||
| F5DB | BIT 6,E | |||||||||||
| F5DD | JR NZ,KNIGHT_CONTROLS_7 | |||||||||||
| F5DF | LD HL,SPRITE933E | |||||||||||
| KNIGHT_CONTROLS_7 | F5E2 | AND $0F | Mid-jump (state 5): just walk on through the air | |||||||||
| F5E4 | CP $05 | |||||||||||
| F5E6 | JR Z,KNIGHT_CONTROLS_10 | |||||||||||
| F5E8 | LD A,$7F | None of SPACE, SYMBOL SHIFT, M, N and B: walk | ||||||||||
| F5EA | CALL INPUT | |||||||||||
| F5ED | JR Z,KNIGHT_CONTROLS_10 | |||||||||||
| F5EF | AND $03 | SPACE or SYMBOL SHIFT: jump | ||||||||||
| F5F1 | JR NZ,KNIGHT_JUMP | |||||||||||
| KNIGHT_FIGHT | F5F3 | LD HL,$0174 | The author's INP59. B, N or M, or fire: fight. The frames SPRITE96E0 facing the viewer, and 372 bytes on (SPRITE9854) facing away; C = the way he faces | |||||||||
| F5F6 | LD (AWAY_FRAMES),HL | |||||||||||
| F5F9 | LD HL,SPRITE96E0 | |||||||||||
| F5FC | CALL FACING | |||||||||||
| F5FF | BIT 1,(IY+GAME_FLAGS-V) | Is his sword out? | ||||||||||
| F603 | JR NZ,KNIGHT_CONTROLS_8 | |||||||||||
| F605 | DEC (IX+OBJ_COUNT) | Not yet: the step forward, until +15 runs out | ||||||||||
| F608 | JR NZ,KNIGHT_CONTROLS_9 | |||||||||||
| F60A | SET 1,(IY+GAME_FLAGS-V) | Out with the sword, for three passes (this pass still steps) | ||||||||||
| F60E | LD (IX+OBJ_COUNT),$03 | |||||||||||
| F612 | JR SET_SPRITE_AND_MOVE | |||||||||||
| KNIGHT_CONTROLS_8 | F614 | LD C,$00 | Sword out: stand | |||||||||
| F616 | DEC (IX+OBJ_COUNT) | For three passes | ||||||||||
| F619 | JR NZ,SET_SPRITE_AND_MOVE | |||||||||||
| F61B | LD (IX+OBJ_COUNT),$03 | Then away with it, three passes more | ||||||||||
| F61F | RES 1,(IY+GAME_FLAGS-V) | |||||||||||
| KNIGHT_CONTROLS_9 | F623 | LD DE,$00BA | The stepping frame, one on from the other | |||||||||
| F626 | ADD HL,DE | |||||||||||
| F627 | JR SET_SPRITE_AND_MOVE | |||||||||||
| KNIGHT_JUMP | F629 | SET 4,C | Jump: up, and not falling, as well as the way he walks | |||||||||
| F62B | SET 1,C | |||||||||||
| F62D | LD (IX+OBJ_COUNT),$08 | For 8 passes (+15), going this way (+18) | ||||||||||
| F631 | LD (IX+OBJ_COURSE),C | |||||||||||
| F634 | LD A,E | State 5, rising, with his facing kept; show the first frame of the walk | ||||||||||
| F635 | AND $70 | |||||||||||
| F637 | OR $05 | |||||||||||
| F639 | LD (IY+WORK_BEHAVIOUR-V),A | |||||||||||
| F63C | JR SET_SPRITE_AND_MOVE | |||||||||||
| KNIGHT_CONTROLS_10 | F63E | LD DE,$00BA | Walk: frames 186 bytes apart; the sword is not out | |||||||||
| F641 | RES 1,(IY+GAME_FLAGS-V) | |||||||||||
|
This entry point is used by the routines at CHE3D and CREATURE_UPDATE.
|
||||||||||||
| ANIM | F645 | PUSH BC | The author's ANIM. Keep the way to go | |||||||||
| F646 | LD A,(IX+OBJ_FRAME) | C = +17; B = the frame, plus one | ||||||||||
| F649 | LD C,A | |||||||||||
| F64A | AND $07 | |||||||||||
| F64C | INC A | |||||||||||
| F64D | LD B,A | |||||||||||
| F64E | BIT 7,C | Going forward: the next frame is this one plus one | ||||||||||
| F650 | JR Z,ANIMATE_AND_MOVE_0 | |||||||||||
| F652 | SUB $02 | Going back: this one less one... | ||||||||||
| F654 | JR NC,ANIMATE_AND_MOVE_0 | |||||||||||
| F656 | LD A,$01 | ...and at nought, the frame before is 1, going forward again | ||||||||||
| F658 | RES 7,C | |||||||||||
| F65A | JR ANIMATE_AND_MOVE_0 | |||||||||||
| Prev: F52A | Up: Map | Next: F65C |