Routines |
Prev: A921 | Up: Map | Next: AA30 |
Used by the routine at 81AE.
|
||||||||
A92C | PUSH IY | Store IY | ||||||
A92E | LD A,(IY+$0F) | Get the room for the current character in A. | ||||||
A931 | LD ($B951),A | Store this. (B951) | ||||||
A934 | LD IY,$BC67 | Point IY at the first character. | ||||||
A938 | LD A,($B55F) | Get the "computer controlled" player flag. | ||||||
A93B | ADD A,$04 | Add 4 to give either 4 (normal) or 5 (demo) characters to move. | ||||||
A93D | LD B,A | Set this in B to loop through the characters. | ||||||
A93E | PUSH BC | Remember the character count. | ||||||
A93F | LD A,($B55F) | Is this player computer controlled? | ||||||
A942 | OR A | |||||||
A943 | JR NZ,$A94C | Jump forward if so. | ||||||
This character is being controlled by the player, so nothing to do
|
||||||||
A945 | CALL $A921 | Check this character is player-controlled. | ||||||
A948 | JR NZ,$A94C | Jump forward if not. (Should never get here). | ||||||
A94A | INC IY | Otherwise jump to the next character. | ||||||
This is a computer controlled character, so move them.
|
||||||||
A94C | LD A,(IY+$0F) | Get the room for the current character. | ||||||
A94F | CP (IY+$5A) | Does it equal the target room? | ||||||
A952 | JR NZ,$A95B | Jump forward if it doesn't. | ||||||
A954 | LD A,(IY-$14) | Is the character in the room it wants to get to? (BC53) | ||||||
A957 | OR A | |||||||
A958 | JP NZ,$A991 | Jump forward if not. | ||||||
A95B | CALL $AFC4 | If the character is in mid-air, drop them to the ground or a platform. | ||||||
A95E | LD A,(IY+$46) | Is the character in mid-jump? | ||||||
A961 | OR A | |||||||
A962 | JR Z,$A96A | If not, move forward to handle movement. | ||||||
A964 | CALL $B1B9 | Otherwise finish off the jump. | ||||||
A967 | JP $A989 | |||||||
A96A | LD A,(IY+$37) | Is the character falling? | ||||||
A96D | OR A | |||||||
A96E | JR Z,$A975 | If not, move forward to handle movement. | ||||||
A970 | CALL $B197 | Otherwise, finish off the fall. | ||||||
A973 | JR $A989 | |||||||
The computer character can move, so do so.
|
||||||||
A975 | LD A,(IY+$64) | Get the computer character's next movement table. (BCCB) | ||||||
A978 | ADD A,A | Double it to get a word offset. | ||||||
A979 | LD E,A | Put the value in DE. | ||||||
A97A | LD D,$00 | |||||||
A97C | LD HL,$AAA0 | Add the base address for the movement tables. (AAA0) | ||||||
A97F | ADD HL,DE | |||||||
A980 | LD E,(HL) | Put the address found in DE. | ||||||
A981 | INC HL | |||||||
A982 | LD D,(HL) | |||||||
A983 | EX DE,HL | Swap DE and HL. | ||||||
A984 | LD DE,$A989 | Set A989 as a return address. | ||||||
A987 | PUSH DE | |||||||
A988 | JP (HL) | Execute the routine. | ||||||
Control returns from the routine to this point.
|
||||||||
A989 | POP BC | Restore the character count. | ||||||
A98A | INC IY | Move to the next character. | ||||||
A98C | DJNZ $A93E | Loop until all the characters have moved. | ||||||
A98E | POP IY | Restore IY and return. | ||||||
A990 | RET | |||||||
A991 | CALL $AFC4 | If the character is in mid-air, drop them to the ground or a platform. | ||||||
A994 | LD A,(IY+$46) | Is the character in mid-jump? | ||||||
A997 | OR A | |||||||
A998 | JR Z,$A9A0 | If not, move forward to handle movement. | ||||||
A99A | CALL $B1B9 | Otherwise finish off the jump. | ||||||
A99D | JP $A989 | |||||||
A9A0 | LD A,(IY+$37) | Is the character falling? | ||||||
A9A3 | OR A | |||||||
A9A4 | JR Z,$A9AC | If not, move forward to handle movement. | ||||||
A9A6 | CALL $B197 | Otherwise, finish off the fall. | ||||||
A9A9 | JP $A989 | |||||||
The character can move, so do so.
|
||||||||
A9AC | LD A,(IY+$0A) | Get the Y position. | ||||||
A9AF | CP $98 | Is it on the ground? | ||||||
A9B1 | JR Z,$A9CA | Jump forward if it is. | ||||||
A9B3 | LD A,(IY+$05) | Get the X position. | ||||||
A9B6 | CP $78 | Is it less than 78? | ||||||
A9B8 | JR NC,$A9C4 | Jump forward if it is. | ||||||
A9BA | LD (IY+$3C),$01 | Set the character as mid-air. | ||||||
A9BE | CALL $B288 | Move a character. | ||||||
A9C1 | JP $A989 | Jump back to finish off the routine. | ||||||
The character is standing next to the wall, and can be built (?)
|
||||||||
A9C4 | LD (IY+$3C),$FF | |||||||
A9C8 | JR $A9BE | |||||||
The character is standing in a room with an item, move them towards sawpping it.
|
||||||||
A9CA | LD B,(IY-$0F) | Get the room object index for this character. (BC58) | ||||||
A9CD | CALL $AA8C | Get the address of the room object. | ||||||
A9D0 | INC HL | Move to the next position. | ||||||
A9D1 | LD A,(HL) | Get the X co-ordinate. | ||||||
A9D2 | PUSH AF | Store AF. | ||||||
A9D3 | LD A,(IY+$05) | Get the X co-ordinate. | ||||||
A9D6 | CP (HL) | Does it match that of the item? | ||||||
A9D7 | JR NC,$A9DF | Jump if it's less. | ||||||
A9D9 | LD (IY+$3C),$01 | Set the character to go right. | ||||||
A9DD | JR $A9E3 | |||||||
A9DF | LD (IY+$3C),$FF | Otherwise set them to go left. | ||||||
A9E3 | CALL $B288 | Move the character. | ||||||
A9E6 | POP AF | Restore A. | ||||||
A9E7 | CP (IY+$05) | Is the character's X co-ordinate now the same as the item's. | ||||||
A9EA | JP NZ,$A989 | Jump back if it isn't. | ||||||
A9ED | LD B,(IY-$0F) | Otherwise get the ID of the object to swap with. | ||||||
A9F0 | CALL $AA30 | Swap an item. | ||||||
A9F3 | LD (IY-$14),$00 | Mark the character as not in the target room. (BC53) | ||||||
A9F7 | LD E,(IY+$78) | Put the address of the character's swap buffer in DE. | ||||||
A9FA | LD D,(IY+$7D) | |||||||
A9FD | LD H,$00 | Set H to 0. | ||||||
A9FF | INC (IY-$05) | Move to the next index in the buffer. | ||||||
AA02 | LD L,(IY-$05) | Put the index in L. | ||||||
AA05 | ADD HL,DE | Add the value in HL to the start of the buffer to get the right address. | ||||||
AA06 | LD A,(HL) | Get the next swap item. | ||||||
AA07 | CP $FF | Is it an end marker? | ||||||
AA09 | JR NZ,$AA10 | Jump forward if it isn't. | ||||||
AA0B | EX DE,HL | Otherwise, set the index back to 0. | ||||||
AA0C | LD (IY-$05),$00 | |||||||
AA10 | LD E,(HL) | Get the object ID in the buffer. | ||||||
AA11 | CALL $AE8A | Get the address of the object in HL. | ||||||
AA14 | LD A,B | Is the object index 0? | ||||||
AA15 | OR A | |||||||
AA16 | JR NZ,$AA24 | If so, jump forward. | ||||||
@labe | l=Update_Characters_16 | |||||||
AA18 | CALL $AED7 | Return the next room that the character should swap in. | ||||||
AA1B | LD C,$00 | |||||||
AA1D | LD D,A | Put this in D. | ||||||
AA1E | LD A,D | Is the next room the current one? | ||||||
AA1F | CP (IY+$0F) | |||||||
AA22 | JR Z,$AA18 | Jump back until it isn't. | ||||||
@labe | l=Update_Characters_17 | |||||||
AA24 | LD (IY+$5A),D | Set the next target room. (BCC1) | ||||||
AA27 | LD (IY-$0F),C | Set the room object index. (0?) | ||||||
AA2A | CALL $ADBA | Update the character. | ||||||
AA2D | JP $A989 | Jump back to finish off the routine. |
Prev: A921 | Up: Map | Next: AA30 |