Prev: EFE7 Up: Map Next: F09A
EFF4: Room Event : Ghost
Used by the routine at Update_Room00.
Input
Output
Handler_Ghosts EFF4 LD A,(Flag_BaddyInit) See if ghosts are initialised.
EFF7 OR A
EFF8 JR NZ,Handler_Ghosts_0
Initialise
EFFA LD A,$01 If not then set as initialised.
EFFC LD (Flag_BaddyInit),A
EFFF LD HL,$A064 See the position of each ghost and draw them.
F002 LD (Ghost1),HL
F005 LD (BitmapX),HL
F008 LD A,(Ghost_Bitmap)
F00B CALL Bitmap16Draw
F00E LD HL,$50DC
F011 LD (Ghost2),HL
F014 LD (BitmapX),HL
F017 CALL Bitmap16Draw
F01A LD HL,$3A30
F01D LD (Ghost3),HL
F020 LD (BitmapX),HL
F023 CALL Bitmap16Draw
F026 RET
Update
Handler_Ghosts_0 F027 LD A,(Ghost_Bitmap) Update the bitmap by increasing its value.
F02A INC A
F02B CP $BF
F02D JR NZ,Handler_Ghosts_1
F02F LD A,$BB Check for animation loop.
Handler_Ghosts_1 F031 LD C,A Store animation rame.
F032 LD IX,Ghost1 Use pointer to update each ghost.
F036 LD B,$03 Number of ghosts to display.
Handler_Ghosts_2 F038 LD L,(IX+$00) Get data on next ghost (X, Y, DirX, Dir Y)
F03B LD H,(IX+$01)
F03E LD E,(IX+$02)
F041 LD D,(IX+$03)
F044 INC IX Point to next ghost ready.
F046 INC IX
F048 INC IX
F04A INC IX
F04C LD A,L
F04D CP $08 See if X position is on the left wall.
F04F JR NZ,Handler_Ghosts_4
Handler_Ghosts_3 F051 LD A,E If it is change direction.
F052 NEG
F054 LD E,A
F055 JR Handler_Ghosts_5
Handler_Ghosts_4 F057 CP $E8 See if X position is on the right hand wall.
F059 JR Z,Handler_Ghosts_3 Change direction if so.
Handler_Ghosts_5 F05B LD A,H See if Y position is at the top.
F05C CP $30
F05E JR NZ,Handler_Ghosts_7
Handler_Ghosts_6 F060 LD A,D Change direction if so.
F061 NEG
F063 LD D,A
F064 JR Handler_Ghosts_8
Handler_Ghosts_7 F066 CP $A8 See if Y position is at the bottom.
F068 JR Z,Handler_Ghosts_6 Change direction if so.
Handler_Ghosts_8 F06A LD (BitmapX),HL Erase image at current position.
F06D LD A,(Ghost_Bitmap)
F070 CALL Bitmap16Draw
F073 LD A,L Update X and Y positions based on directions.
F074 ADD A,E
F075 LD L,A
F076 LD A,H
F077 ADD A,D
F078 LD H,A
F079 LD (BitmapX),HL Draw at new position.
F07C LD A,C
F07D CALL Bitmap16Draw
F080 LD (IX-$01),D Store new position and directions.
F083 LD (IX-$02),E
F086 LD (IX-$03),H
F089 LD (IX-$04),L
F08C PUSH BC Check to see if hit wally, using 1 hit point if so.
F08D LD B,$01
F08F CALL Wally_HitTest
F092 POP BC Next ghost.
F093 DJNZ Handler_Ghosts_2
F095 LD A,C
F096 LD (Ghost_Bitmap),A
F099 RET
Prev: EFE7 Up: Map Next: F09A