![]() |
Routines |
| Prev: F1C8 | Up: Map | Next: F2F7 |
|
Used by the routines at ANIMATE_AND_MOVE and MAIN_LOOP.
The author's CHE3D (Krumlinde's Sub_F1E0). The main loop (MAIN_LOOP) calls it once a pass for every record from the knight's on, and the movement code comes back to it at once for an object whose carried-along movement has just stopped (ANIMATE_AND_MOVE). Nothing is done for an object without a sprite, a door (type 1 in +$0C, dealt with where it is met, BUMPED), anything taken out of the room (bit 5 of +$10) or scenery (bits 0-4 of +$10 clear). The labels inside are the author's own.
Otherwise the record's first 19 bytes are copied to IY+$64 on and its address kept at IY+$7D; its state byte, +$0E, is also kept at IY+$67, for the movement code to see bit 7 of it as it was when the pass began. In the first pass after a room is entered (bit 2 of IY+$17) the object is only drawn where it stands (NOG, ANIMATE_AND_MOVE). An object carried along by a movement already under way (bit 7 of +$0E) carries on in the direction kept in +$12 (NOPROP). Otherwise the low four bits of +$0E, its state, say what it does. The states dealt with here:
State 0, at rest: it falls if it can -- the movement code adds the fall -- except that with bit 4 of +$0E, which is cleared as it is read, it makes its last movement (+$0D) once more instead: a thing just dropped (CREATURE_UPDATE) or knocked (OBJECTS_MEET). The pass also notes two kinds of thing as it meets them: the first thing of type 8 (+$0C) is kept at IY+$0F with bit 0 of IY+$11 set, and the creatures in state 9 go for it rather than for the knight (ZOOMIN, ZOOMIN), and destroy it when they reach it (MEET_DECOY); a thing of kind 11 sets bit 1 of IY+$11, which wakes the creature in state 15 (CREATURE_UPDATE). Both are forgotten when a room is entered, a thing is picked up, or the kind-8 thing is destroyed.
State 3 bounces about: it keeps moving along its last movement, $45 (a diagonal) when it has none, and the movement code turns it round when it is blocked. State 4 strikes at the knight when he is in its reach -- its own box moved 12 towards lower +6, towards the viewer -- taking three from LIFE each pass and showing its striking frames (TYPE48_FRAMES); otherwise it is left alone. State 5 is the knight in a jump (KNIGHT_CONTROLS starts one): eight passes going up in the direction he was walking, without the fall, then back to state 8 to come down. State 9 is a creature that rises out of the floor: after a wait it grows through four frames (SPRITEA4B8 to SPRITEA2E4) as +$11 counts up, and then walks after the knight like state 6. Every other state, the knight's 8 among them, goes on to CREATURE_UPDATE.
Bit 7 of IY+$17 is set when the thing of type 5 is used (MAIN_LOOP), and lasts until a room is entered. While it is set every state but the knight's 8 and his jump's 5 is dealt with as state 0: the creatures stand where they are and only fall. Release 1 excepts only state 8 -- at offset 131 it has JR I00 where Release 2 has CP 5 and JR NZ -- and there a knight who jumps while the freeze lasts stays in state 5 for good, since nothing counts his jump down: he never walks again. Played in the simulator in both releases (the type-5 thing in room 24 picked up and used, then SPACE, then Q): Release 1's knight stayed in state 5 and did not move; Release 2's landed after eight passes and walked.
|
||||||||
| CHE3D | F1E0 | PUSH HL | No sprite: nothing to do | |||||
| F1E1 | POP IX | |||||||
| F1E3 | LD A,(IX+OBJ_SPRITE) | |||||||
| F1E6 | OR (IX+OBJ_SPRITE+$01) | |||||||
| F1E9 | RET Z | |||||||
| F1EA | LD A,(IX+OBJ_KIND) | A door: dealt with where it is met | ||||||
| F1ED | AND $0F | |||||||
| F1EF | CP $01 | |||||||
| F1F1 | RET Z | |||||||
| F1F2 | LD A,(IX+OBJ_WEIGHT) | Taken out of the room, or scenery | ||||||
| F1F5 | BIT 5,A | |||||||
| F1F7 | RET NZ | |||||||
| F1F8 | AND $1F | |||||||
| F1FA | RET Z | |||||||
| F1FB | LD DE,POINT | The record's first 19 bytes to IY+$64 on, its address to IY+$7D | ||||||
| F1FE | LD (WORK_RECORD),HL | |||||||
| F201 | LD BC,$0013 | |||||||
| F204 | LDIR | |||||||
| F206 | LD A,(WORK_BEHAVIOUR) | The state byte as the pass found it, over the height's copy | ||||||
| F209 | LD (SECOND_POINT_ROW),A | |||||||
| F20C | BIT 2,(IY+GAME_FLAGS-V) | The first pass in a new room: only draw it | ||||||
| F210 | JP NZ,SKIP_GRAVITY | |||||||
| F213 | BIT 7,A | Carried along: on in the direction in +$12 | ||||||
| F215 | JR Z,I0 | |||||||
| F217 | LD A,(IX+OBJ_COURSE) | |||||||
| F21A | JP ADD_GRAVITY | |||||||
| I0 | F21D | LD C,(IY+WORK_DIRECTION-V) | I0: C its last movement (+$0D), HL its sprite; bit 4 cleared in the copy of +$0E; state 0? | |||||
| F220 | LD HL,(WORK_SPRITE) | |||||||
| F223 | RES 4,(IY+WORK_BEHAVIOUR-V) | |||||||
| F227 | LD E,A | |||||||
| F228 | AND $0F | |||||||
| F22A | JR NZ,I3 | |||||||
| I00 | F22C | BIT 0,(IY+THINGS_NOTED-V) | I00: the first kind-8 thing, kept while none is | |||||
| F230 | JR NZ,I01 | |||||||
| F232 | LD A,(WORK_KIND) | |||||||
| F235 | AND $0F | |||||||
| F237 | CP $08 | |||||||
| F239 | JR NZ,I01 | |||||||
| F23B | SET 0,(IY+THINGS_NOTED-V) | |||||||
| F23F | LD (DECOY),IX | |||||||
| F243 | JR I02 | |||||||
| I01 | F245 | CP $0B | I01: a kind-11 thing. Once a kind-8 thing is known this compares the state instead of the kind, so a kind-11 thing met later goes unnoticed, and a frozen creature in state 11 counts as one | |||||
| F247 | JR NZ,I02 | |||||||
| F249 | SET 1,(IY+THINGS_NOTED-V) | |||||||
| I02 | F24D | LD A,C | I02: with bit 4, its last movement once more; otherwise only bit 0 of it, and the movement code adds the fall | |||||
| F24E | BIT 4,E | |||||||
| F250 | JP NZ,ADD_GRAVITY | |||||||
| F253 | AND $01 | |||||||
| F255 | JP ADD_GRAVITY | |||||||
| I3 | F258 | BIT 7,(IY+GAME_FLAGS-V) | I3: the freeze: the knight to his controls, his jump on, everything else as state 0 | |||||
| F25C | JR Z,I30 | |||||||
| F25E | CP $08 | |||||||
| F260 | JP Z,KNIGHT_UPDATE | |||||||
| F263 | CP $05 | |||||||
| F265 | JR NZ,I00 | |||||||
| I30 | F267 | CP $03 | I30: state 3: its last movement, or $45 if it has no direction | |||||
| F269 | JR NZ,I4 | |||||||
| F26B | LD A,C | |||||||
| F26C | AND $CC | |||||||
| F26E | JR NZ,I31 | |||||||
| F270 | LD C,$45 | |||||||
| I31 | F272 | JP MOVE_IN_DIRECTION | I31: move (KON6) | |||||
| I4 | F275 | CP $04 | I4: state 4: is the knight in its box moved 12 along +6? | |||||
| F277 | JR NZ,I5 | |||||||
| F279 | CALL WORKING_POSITION | |||||||
| F27C | CALL WORKING_SIZES | |||||||
| F27F | LD A,B | |||||||
| F280 | SUB $0C | |||||||
| F282 | LD B,A | |||||||
| F283 | LD IX,KNIGHT | |||||||
| F287 | CALL BOX_OVERLAP | |||||||
| F28A | RET NC | |||||||
| F28B | LD A,$03 | Never run in the build's sessions: three from LIFE, and its striking frames, 144 bytes each, without moving (ANIM) | ||||||
| F28D | CALL DECLIF | |||||||
| F290 | LD IX,(WORK_RECORD) | |||||||
| F294 | LD C,$00 | |||||||
| F296 | LD HL,SPRITE5C84 | |||||||
| F299 | LD DE,$0090 | |||||||
| F29C | JP ANIM | |||||||
| I5 | F29F | CP $05 | I5: state 5, the jump: when +$0F has counted down, back to state 8, and only the fall | |||||
| F2A1 | JR NZ,I9 | |||||||
| F2A3 | DEC (IX+OBJ_COUNT) | |||||||
| F2A6 | JR NZ,I50 | |||||||
| F2A8 | LD A,E | |||||||
| F2A9 | AND $F0 | |||||||
| F2AB | OR $08 | |||||||
| F2AD | LD (WORK_BEHAVIOUR),A | |||||||
| F2B0 | LD C,$01 | |||||||
| F2B2 | JP MOVE_IN_DIRECTION | |||||||
| I50 | F2B5 | LD A,(WORK_HEADING) | I50: up (bit 4) without the fall (bit 1) along +$12, in the knight's poses (INP5, KNIGHT_CONTROLS) | |||||
| F2B8 | OR $12 | |||||||
| F2BA | LD C,A | |||||||
| F2BB | JP KNIGHT_TURN | |||||||
| I9 | F2BE | CP $09 | I9: other states go on | |||||
| F2C0 | JR NZ,CREATURE_UPDATE | |||||||
| F2C2 | LD A,(WORK_ANIMATION) | State 9: risen already (bit 6 of +$11)? | ||||||
| F2C5 | BIT 6,A | |||||||
| F2C7 | JR NZ,I91 | |||||||
| F2C9 | INC A | Rising: +$11 counts up; it stands still | ||||||
| F2CA | LD (IX+OBJ_FRAME),A | |||||||
| F2CD | CP $40 | |||||||
| F2CF | JR NC,I92 | |||||||
| F2D1 | LD C,$01 | |||||||
| F2D3 | LD HL,SPRITEA4B8 | Its frame by the count: below $37, $3A, $3D and $40 | ||||||
| F2D6 | CP $37 | |||||||
| F2D8 | JR C,I95 | |||||||
| F2DA | LD HL,SPRITEA41C | |||||||
| F2DD | CP $3A | |||||||
| F2DF | JR C,I95 | |||||||
| F2E1 | LD HL,SPRITEA380 | |||||||
| F2E4 | CP $3D | |||||||
| F2E6 | JR C,I95 | |||||||
| F2E8 | LD HL,SPRITEA2E4 | |||||||
| I95 | F2EB | JP SET_SPRITE_AND_MOVE | I95: into +4 and +5 (INPE) | |||||
| I92 | F2EE | LD (IX+OBJ_FRAME),$51 | I92: risen: +$11 to $51 | |||||
| I91 | F2F2 | CALL STEER | I91: turn after the knight now and then (ZZ1), and walk with state 6's sprites (I600) | |||||
| F2F5 | JR GUARD_FRAMES | |||||||
|
Continued at CREATURE_UPDATE.
|
||||||||
| Prev: F1C8 | Up: Map | Next: F2F7 |