![]() |
Routines |
| Prev: EED7 | Up: Map | Next: F104 |
|
Used by the routine at InitialiseGame.
|
||||
|
See No Pirates.
|
||||
| Handler_Pirates | F001 | LD A,($F334) | Return if *LiftsPiratesFrameSkip is a skipped frame. | |
| F004 | CP $00 | |||
| F006 | RET Z | |||
| F007 | LD HL,$8E28 | Write 8E28 to *CHARS. | ||
| F00A | LD ($5C36),HL | |||
| F00D | LD IX,($5BDE) | Point IX at *ReferencePirate. | ||
| Handler_Pirates_Loop | F011 | LD A,(IX+$00) | Return if this pirate entry is the terminator (FF). | |
| F014 | CP $FF | |||
| F016 | RET Z | |||
| F017 | LD A,$10 | Set INK from the pirate attribute. | ||
| F019 | RST $10 | |||
| F01A | LD A,(IX+$09) | |||
| F01D | RST $10 | |||
|
Advance the pirate walk frame.
|
||||
| F01E | LD A,(IX+$06) | Fetch the current pirate sprite ID. | ||
| F021 | ADD A,$06 | Add one walk frame. | ||
| F023 | LD (IX+$06),A | Write it back to the pirate sprite ID. | ||
|
Wrap the walk cycle at each facing's last frame.
|
||||
| F026 | CP $4A | Jump to Handler_Pirates_CheckSpriteFrames if the right-facing frames have not wrapped. | ||
| F028 | JR NZ,Handler_Pirates_CheckSpriteFrames | |||
| F02A | LD (IX+$06),$20 | Reset to the first right-facing pirate frame. | ||
| Handler_Pirates_CheckSpriteFrames | F02E | CP $80 | Jump to Handler_Pirates_SkipSpriteFrames if the left-facing frames have not wrapped. | |
| F030 | JR NZ,Handler_Pirates_SkipSpriteFrames | |||
| F032 | LD (IX+$06),$50 | Reset to the first left-facing pirate frame. | ||
| Handler_Pirates_SkipSpriteFrames | F036 | CALL ApplyMovementDeltas | Apply the pirate's movement deltas. | |
| F039 | LD A,C | Jump to Handler_Pirate_TurnRight if the pirate walked off the right. | ||
| F03A | CP $22 | |||
| F03C | JP Z,Handler_Pirate_TurnRight | |||
| F03F | CP $03 | Jump to Handler_Pirate_TurnLeft if the pirate walked off the left. | ||
| F041 | JP Z,Handler_Pirate_TurnLeft | |||
| F044 | PUSH DE | Stash the new position and offsets on the stack. | ||
| F045 | PUSH BC | |||
| F046 | LD A,(IX+$04) | Jump to Handler_Pirates_0 if the pirate is not moving right. | ||
| F049 | CP $FF | |||
| F04B | JR NZ,Handler_Pirates_0 | |||
| F04D | DEC C | Adjust the test column when moving right. | ||
| F04E | DEC C | |||
| Handler_Pirates_0 | F04F | CALL FindKeyAtPosition | Look for a key or locked door in this column. | |
| F052 | POP BC | Restore the new position and offsets from the stack. | ||
| F053 | POP DE | |||
| F054 | CP $FF | Jump to Pirate_TurnController if a key or locked door blocks this column. | ||
| F056 | JP NZ,Pirate_TurnController | |||
| F059 | PUSH BC | Stash the new position and offsets on the stack. | ||
| F05A | PUSH DE | |||
| F05B | DEC B | Move three rows up to the pirate's feet. | ||
| F05C | DEC B | |||
| F05D | DEC B | |||
| F05E | LD A,(IX+$04) | Jump to Handler_Pirates_1 if the pirate is not moving right. | ||
| F061 | CP $FF | |||
| F063 | JR NZ,Handler_Pirates_1 | |||
| F065 | DEC C | Adjust the test column when moving right. | ||
| F066 | DEC C | |||
| Handler_Pirates_1 | F067 | CALL ConvertCoordinateToBufferOffset | Convert that foot position into a room-buffer offset. | |
| F06A | LD HL,$A1C4 | HL=BufferRoom. | ||
| F06D | LD DE,($F330) | Add the offset from *BufferRoomPointer. | ||
| F071 | ADD HL,DE | HL+=DE. | ||
| F072 | POP DE | Restore the new position and offsets from the stack. | ||
| F073 | POP BC | |||
| F074 | LD A,(HL) | Jump to Pirate_TurnController if that buffer tile is empty space. | ||
| F075 | CP $21 | |||
| F077 | JP C,Pirate_TurnController | |||
| F07A | LD (IX+$00),C | Write the new horizontal co-ordinate back to the pirate. | ||
| F07D | LD (IX+$01),B | Write the new vertical co-ordinate back to the pirate. | ||
| F080 | LD (IX+$02),E | Write the new horizontal offset back to the pirate. | ||
| F083 | LD (IX+$03),D | Write the new vertical offset back to the pirate. | ||
| F086 | CALL EraseSpriteTrail | Erase the pirate's previous sprite. | ||
| Handler_Pirates_2 | F089 | CALL PrintShiftedSprite | Print the pirate. | |
| F08C | LD A,(IX+$00) | Copy the horizontal co-ordinate to the previous-horizontal slot. | ||
| F08F | LD (IX+$0D),A | |||
| F092 | LD A,(IX+$01) | Copy the vertical co-ordinate to the previous-vertical slot. | ||
| F095 | LD (IX+$0E),A | |||
| F098 | LD A,(IX+$02) | Copy the horizontal offset to the previous-offset slot. | ||
| F09B | LD (IX+$0B),A | |||
| F09E | LD A,(IX+$03) | Copy the vertical offset to the previous-vertical-offset slot. | ||
| F0A1 | LD (IX+$0F),A | |||
|
Test whether the pirate overlaps the player.
|
||||
| F0A4 | LD C,(IX+$00) | C=the pirate horizontal co-ordinate. | ||
| F0A7 | DEC C | Decrease C by one. | ||
| F0A8 | SLA C | Convert it to a pixel column. | ||
| F0AA | SLA C | |||
| F0AC | LD A,(IX+$02) | Add the pirate's horizontal offset. | ||
| F0AF | ADD A,C | A+=C. | ||
| F0B0 | LD C,A | C=the pirate's pixel column. | ||
| F0B1 | LD A,($F233) | B=*F233. | ||
| F0B4 | LD B,A | |||
| F0B5 | LD A,($F231) | A=*TablePlayerAttributes. | ||
| F0B8 | DEC A | Decrease A by one. | ||
| F0B9 | SLA A | Convert the player column to a pixel position. | ||
| F0BB | SLA A | |||
| F0BD | ADD A,B | Add the player's horizontal offset. | ||
| F0BE | ADD A,$07 | Add the player's pixel width. | ||
| F0C0 | SUB C | Subtract the pirate's pixel column. | ||
|
See Immune To Pirates.
|
||||
| F0C1 | CP $10 | Jump to Handler_Pirate_Next if the player is outside the pirate's horizontal span. | ||
| F0C3 | JR NC,Handler_Pirate_Next | |||
| F0C5 | LD B,(IX+$01) | B=the pirate vertical co-ordinate. | ||
| F0C8 | LD A,($F232) | A=*F232. | ||
| F0CB | ADD A,$02 | Add the player's height. | ||
| F0CD | SUB B | Subtract the pirate vertical co-ordinate. | ||
| F0CE | CP $06 | Jump to Handler_Pirate_Next if the player is outside the pirate's vertical span. | ||
| F0D0 | JP NC,Handler_Pirate_Next | |||
| F0D3 | LD A,$02 | Queue the "caught by pirate" sound at SoundFlag_General. | ||
| F0D5 | LD ($FFFE),A | |||
| F0D8 | JP LoseLife | Jump to LoseLife to lose a life. | ||
|
Move onto the next pirate.
|
||||
| Handler_Pirate_Next | F0DB | LD DE,$0010 | Move IX on to the next sixteen-byte pirate entry. | |
| F0DE | ADD IX,DE | |||
| F0E0 | JP Handler_Pirates_Loop | Jump to Handler_Pirates_Loop. | ||
|
Face and move left, then reprint.
|
||||
| Handler_Pirate_TurnLeft | F0E3 | LD (IX+$04),$01 | Set horizontal movement to the left. | |
| F0E7 | LD (IX+$06),$50 | Write the first left-facing pirate frame. | ||
| F0EB | JP Handler_Pirates_2 | Jump to Handler_Pirates_2. | ||
|
Face and move right, then reprint.
|
||||
| Handler_Pirate_TurnRight | F0EE | LD (IX+$04),$FF | Set horizontal movement to the right. | |
| F0F2 | LD (IX+$06),$20 | Write the first right-facing pirate frame. | ||
| F0F6 | JP Handler_Pirates_2 | Jump to Handler_Pirates_2. | ||
|
Turn the pirate around after a blocked step.
|
||||
| Pirate_TurnController | F0F9 | LD A,(IX+$04) | Jump to Handler_Pirate_TurnLeft if the pirate is moving right. | |
| F0FC | CP $FF | |||
| F0FE | JP Z,Handler_Pirate_TurnLeft | |||
| F101 | JP Handler_Pirate_TurnRight | Jump to Handler_Pirate_TurnRight. | ||
| Prev: EED7 | Up: Map | Next: F104 |