![]() |
Routines |
| Prev: 6681 | Up: Map | Next: 6735 |
|
The handler for the orange peel (IDs 14 and 15). It wanders about in a wavy path. Byte 06 of the actor holds the direction (bit 0 is set for right, bit 1 is set for down) and which byte of each pair in the table at WanderSpeeds is used for which direction (bit 2). Byte 07 is a counter, which chooses the speeds to use from the table, and changes the sprite frame.
While the peel is entering from the right of the screen (a horizontal co-ordinate of C4 or more) it can't hit Charlie or be hit.
|
||||||||
| HandlePeel | 669B | CALL StoreEntity | Record the position of the sprite using StoreEntity. | |||||
| 669E | LD HL,$5F1B | Increase ActorsInPlay by one. | ||||||
| 66A1 | INC (HL) | |||||||
| 66A2 | LD A,(IX+$01) | Fetch the horizontal co-ordinate. | ||||||
| 66A5 | CP $C4 | Jump to HandlePeel_Horizontal if the peel is still entering from the right. | ||||||
| 66A7 | JR NC,HandlePeel_Horizontal | |||||||
| 66A9 | CALL TestCharlieCollision | Test whether the peel has hit Charlie using TestCharlieCollision. | ||||||
| 66AC | DEC E | Has the peel hit Charlie (is E now zero)? | ||||||
| 66AD | JP Z,LoseHat | Jump to LoseHat if Charlie has been hit. | ||||||
| 66B0 | CALL TestFlourCollision | Test whether a flour shot has hit the peel using TestFlourCollision. | ||||||
| 66B3 | BIT 7,(IX+$00) | Jump to HandleHitActor if the peel has been hit. | ||||||
| 66B7 | JP NZ,HandleHitActor | |||||||
|
Every 10 frames pick a new random direction.
|
||||||||
| 66BA | LD A,(IX+$07) | Fetch the direction counter. | ||||||
| 66BD | INC A | Increase the direction counter by one. | ||||||
| 66BE | AND %00001111 | Keep only bits 0-3. | ||||||
| 66C0 | LD (IX+$07),A | Update the direction counter. | ||||||
| 66C3 | JR NZ,HandlePeel_Vertical | Jump to HandlePeel_Vertical if the counter is not zero. | ||||||
| 66C5 | LD A,R | Fetch a random number. | ||||||
| 66C7 | AND %00000111 | Keep only bits 0-2. | ||||||
| 66C9 | LD (IX+$06),A | Write the random number to the direction of the peel (byte 06 of the actor). | ||||||
|
Move vertically.
|
||||||||
| HandlePeel_Vertical | 66CC | CALL FindWanderSpeeds | Find the speeds for the counter using FindWanderSpeeds. | |||||
| 66CF | LD (IX+$03),$43 | Set the colour to 43. | ||||||
| 66D3 | JR NZ,HandlePeel_VerticalSpeed | Jump to HandlePeel_VerticalSpeed if bit 2 of the actor state is set. | ||||||
| 66D5 | INC HL | Use the second byte of the pair. | ||||||
| HandlePeel_VerticalSpeed | 66D6 | LD A,(HL) | Fetch the speed. | |||||
| 66D7 | BIT 1,(IX+$06) | Jump to HandlePeel_VerticalMove if the peel is moving down. | ||||||
| 66DB | JR NZ,HandlePeel_VerticalMove | |||||||
| 66DD | NEG | Make the speed negative. | ||||||
| HandlePeel_VerticalMove | 66DF | ADD A,(IX+$02) | Add the speed to the vertical co-ordinate. | |||||
| 66E2 | CP $A0 | Jump to HandlePeel_Bottom if the peel has reached the bottom. | ||||||
| 66E4 | JR NC,HandlePeel_Bottom | |||||||
| 66E6 | CP $20 | Jump to HandlePeel_Top if the peel has reached the top. | ||||||
| 66E8 | JR C,HandlePeel_Top | |||||||
| 66EA | LD (IX+$02),A | Update the vertical co-ordinate. | ||||||
|
Move horizontally.
|
||||||||
| HandlePeel_Horizontal | 66ED | CALL FindWanderSpeeds | Find the speeds for the counter using FindWanderSpeeds. | |||||
| 66F0 | JR Z,HandlePeel_HorizontalSpeed | Jump to HandlePeel_HorizontalSpeed if bit 2 of the actor state is not set. | ||||||
| 66F2 | INC HL | Use the second byte of the pair. | ||||||
| HandlePeel_HorizontalSpeed | 66F3 | LD A,(HL) | Fetch the speed. | |||||
| 66F4 | BIT 0,(IX+$06) | Jump to HandlePeel_HorizontalMove if the peel is moving right. | ||||||
| 66F8 | JR NZ,HandlePeel_HorizontalMove | |||||||
| 66FA | NEG | Make the speed negative. | ||||||
| HandlePeel_HorizontalMove | 66FC | ADD A,(IX+$01) | Add the speed to the horizontal co-ordinate. | |||||
| 66FF | CP $04 | Jump to HandlePeel_LeftEdge if the peel has reached the left edge. | ||||||
| 6701 | JR C,HandlePeel_LeftEdge | |||||||
| 6703 | CP $C0 | Jump to HandlePeel_RightEdge if the peel has reached the right edge. | ||||||
| 6705 | JR NC,HandlePeel_RightEdge | |||||||
| HandlePeel_Animate | 6707 | LD (IX+$01),A | Update the horizontal co-ordinate. | |||||
| 670A | LD A,(IX+$07) | Fetch the direction counter. | ||||||
| 670D | RRA | Shift the counter right by one. | ||||||
| 670E | AND %00000001 | Keep only bit 0. | ||||||
| 6710 | XOR (IX+$00) | Flip the bit 0 of the actor ID, when bit 1 of the counter is set. | ||||||
| 6713 | LD (IX+$00),A | Update the actor ID. | ||||||
| 6716 | JP MoveBouncingActor_Draw | Jump to MoveBouncingActor_Draw to move and colour the sprite. | ||||||
|
The peel has reached the bottom, so move it up.
|
||||||||
| HandlePeel_Bottom | 6719 | LD (IX+$02),$A0 | Write A0 to the vertical co-ordinate. | |||||
| 671D | RES 1,(IX+$06) | Reset bit 1 of the actor state. | ||||||
| 6721 | JR HandlePeel_Horizontal | Jump to HandlePeel_Horizontal. | ||||||
|
The peel has reached the top, so move it down.
|
||||||||
| HandlePeel_Top | 6723 | SET 1,(IX+$06) | Set bit 1 of the actor state. | |||||
| 6727 | JR HandlePeel_Horizontal | Jump to HandlePeel_Horizontal. | ||||||
|
The peel has reached the left edge, so move it right.
|
||||||||
| HandlePeel_LeftEdge | 6729 | SET 0,(IX+$06) | Set bit 0 of the actor state. | |||||
| 672D | JR HandlePeel_Animate | Jump to HandlePeel_Animate. | ||||||
|
The peel has reached the right edge, so move it left.
|
||||||||
| HandlePeel_RightEdge | 672F | RES 0,(IX+$06) | Reset bit 0 of the actor state. | |||||
| 6733 | JR HandlePeel_Animate | Jump to HandlePeel_Animate. | ||||||
| Prev: 6681 | Up: Map | Next: 6735 |