![]() |
Routines |
| Prev: E12A | Up: Map | Next: E30B |
|
Used by the routine at InitialiseGame.
Moves, animates and collides the live animal at TableAnimalAttributes. If the slot is empty, AnimalsEventTiming may spawn one.
|
||||
| Handler_Animals | E22D | LD IX,$F31C | Point IX at TableAnimalAttributes. | |
| E231 | LD A,(IX+$00) | Jump to AnimalsEventTiming if no animal is active. | ||
| E234 | CP $00 | |||
| E236 | JP Z,AnimalsEventTiming | |||
|
Point the UDG graphics at the animal frames.
|
||||
| E239 | LD HL,$934C | Write 934C to *CHARS. | ||
| E23C | LD ($5C36),HL | |||
| E23F | CALL ApplyMovementDeltas | Apply the animal's movement deltas. | ||
| E242 | LD (IX+$00),C | Write the new horizontal co-ordinate back to the slot. | ||
| E245 | LD (IX+$01),B | Write the new vertical co-ordinate back to the slot. | ||
| E248 | LD (IX+$02),E | Write the new horizontal offset back to the slot. | ||
| E24B | LD (IX+$03),D | Write the new vertical offset back to the slot. | ||
|
Erase the previous animal when it crosses a character boundary.
|
||||
| E24E | LD A,E | Jump to Handler_Animals_TestLeaveOrHit if the horizontal offset is not 03. | ||
| E24F | CP $03 | |||
| E251 | JR NZ,Handler_Animals_TestLeaveOrHit | |||
| E253 | LD A,(IX+$04) | Jump to Handler_Animals_MoveRight if the animal is moving right. | ||
| E256 | CP $FF | |||
| E258 | JR Z,Handler_Animals_MoveRight | |||
| E25A | LD A,C | A=the new horizontal co-ordinate. | ||
| E25B | SUB (IX+$07) | Subtract the animal width. | ||
| E25E | CP $02 | Jump to Handler_Animals_TestLeaveOrHit if that column is off the left of the play area. | ||
| E260 | JR C,Handler_Animals_TestLeaveOrHit | |||
| E262 | CP $22 | Jump to Handler_Animals_TestLeaveOrHit if that column is off the right of the play area. | ||
| E264 | JR NC,Handler_Animals_TestLeaveOrHit | |||
| E266 | LD C,A | C=the trail column to erase. | ||
| E267 | LD E,$01 | E=01 (one character wide). | ||
| E269 | LD D,(IX+$08) | D=the animal height. | ||
| E26C | CALL PrintSpriteUpdateBuffer | Erase the previous animal from the room buffer. | ||
| E26F | JR Handler_Animals_TestLeaveOrHit | Jump to Handler_Animals_TestLeaveOrHit. | ||
| Handler_Animals_MoveRight | E271 | INC C | Step the trail column one to the right. | |
| E272 | LD A,C | Jump to Handler_Animals_TestLeaveOrHit if that column is off the right of the play area. | ||
| E273 | CP $22 | |||
| E275 | JR NC,Handler_Animals_TestLeaveOrHit | |||
| E277 | CP $02 | Jump to Handler_Animals_TestLeaveOrHit if that column is off the left of the play area. | ||
| E279 | JR C,Handler_Animals_TestLeaveOrHit | |||
| E27B | LD E,$01 | E=01 (one character wide). | ||
| E27D | LD D,(IX+$08) | D=the animal height. | ||
| E280 | CALL PrintSpriteUpdateBuffer | Erase the previous animal from the room buffer. | ||
|
Leave the screen, or animate and test a hit on the player.
|
||||
| Handler_Animals_TestLeaveOrHit | E283 | LD A,(IX+$00) | Jump to Handler_Animals_ClearSlot if the animal has walked off the right. | |
| E286 | CP $26 | |||
| E288 | JP Z,Handler_Animals_ClearSlot | |||
| E28B | CP $01 | Jump to Handler_Animals_ClearSlot if the animal has walked off the left. | ||
| E28D | JP Z,Handler_Animals_ClearSlot | |||
| E290 | LD A,(IX+$06) | Jump to Handler_Animals_StoreFrame if this is still a rat frame (below 25). | ||
| E293 | CP $25 | |||
| E295 | JR C,Handler_Animals_StoreFrame | |||
| E297 | ADD A,$08 | Advance the bird animation by one frame. | ||
| E299 | CP $47 | Jump to Handler_Animals_StoreFrame if the bird frames have not wrapped. | ||
| E29B | JR C,Handler_Animals_StoreFrame | |||
| E29D | SUB $20 | Wrap back to the first bird frame. | ||
| Handler_Animals_StoreFrame | E29F | LD (IX+$06),A | Write the new frame ID back to the slot. | |
| E2A2 | CALL PrintShiftedSprite | Print the animal. | ||
| E2A5 | LD A,(IX+$00) | Copy the horizontal co-ordinate to the previous-horizontal slot. | ||
| E2A8 | LD (IX+$0D),A | |||
| E2AB | LD A,(IX+$01) | Copy the vertical co-ordinate to the previous-vertical slot. | ||
| E2AE | LD (IX+$0E),A | |||
| E2B1 | LD A,(IX+$02) | Copy the horizontal offset to the previous-offset slot. | ||
| E2B4 | LD (IX+$0B),A | |||
| E2B7 | LD A,(IX+$03) | Copy the vertical offset to the previous-vertical-offset slot. | ||
| E2BA | LD (IX+$0F),A | |||
|
Test whether the animal overlaps the player.
|
||||
| E2BD | LD A,(IX+$08) | A=the animal height. | ||
| E2C0 | ADD A,$03 | Add 03 for the player's height. | ||
| E2C2 | LD C,A | C=the combined height. | ||
| E2C3 | LD B,(IX+$01) | B=the animal vertical co-ordinate. | ||
| E2C6 | LD A,($F232) | A=the player's vertical co-ordinate. | ||
| E2C9 | DEC A | Decrease A by one. | ||
| E2CA | ADD A,(IX+$08) | Add the animal height. | ||
| E2CD | SUB B | Subtract the animal vertical co-ordinate. | ||
| E2CE | CP C | Return if the player is outside the animal's vertical span. | ||
| E2CF | RET NC | |||
| E2D0 | LD A,(IX+$07) | A=the animal width. | ||
| E2D3 | ADD A,$02 | Add 02. | ||
| E2D5 | SLA A | Convert that width into a pixel span. | ||
| E2D7 | SLA A | |||
| E2D9 | LD B,A | B=the pixel width to test. | ||
| E2DA | LD C,(IX+$00) | C=the animal horizontal co-ordinate. | ||
| E2DD | LD A,($F233) | D=the player's horizontal offset. | ||
| E2E0 | LD D,A | |||
| E2E1 | LD A,C | A=the animal horizontal co-ordinate. | ||
| E2E2 | SLA A | Convert it to a pixel column. | ||
| E2E4 | SLA A | |||
| E2E6 | ADD A,(IX+$02) | Add the animal's horizontal offset. | ||
| E2E9 | LD C,A | |||
| E2EA | LD A,($F231) | A=the player's horizontal co-ordinate. | ||
| E2ED | ADD A,(IX+$07) | Add the animal width. | ||
| E2F0 | SLA A | Shift A left (with carry). | ||
| E2F2 | SLA A | Shift A left (with carry). | ||
| E2F4 | ADD A,D | Add the player's horizontal offset. | ||
| E2F5 | DEC A | Decrease A by one. | ||
| E2F6 | SUB C | Subtract the animal's pixel column. | ||
| E2F7 | CP B | Return if the player is outside the animal's horizontal span. | ||
| E2F8 | RET NC | |||
| E2F9 | LD A,$01 | Queue the "touched by animal" sound at SoundFlag_General. | ||
| E2FB | LD ($FFFE),A | |||
| E2FE | JP LoseLife | Jump to LoseLife to lose a life. | ||
|
The animal has left the room; clear the slot.
|
||||
| Handler_Animals_ClearSlot | E301 | LD (IX+$00),$00 | Clear *TableAnimalAttributes; no animal is active. | |
| E305 | LD A,$00 | Stop the animal sound at SoundFlag_Animal. | ||
| E307 | LD ($FFFF),A | |||
| E30A | RET | Return. | ||
| Prev: E12A | Up: Map | Next: E30B |