![]() |
Routines |
| Prev: 26906 | Up: Map | Next: 27030 |
|
The handler for the cheese (IDs 18 and 19), which bounces up and down the screen like a ball. Byte 5 of the actor is the vertical speed; it is increased by one every eight frames (up to a maximum of 8), and half of it is added to the vertical co-ordinate. When the cheese reaches the top of the play area its vertical speed is reversed, and when it reaches the bottom it is thrown back up with a random speed, and a random horizontal speed. The horizontal movement is done by MoveBouncingActor_Horizontal.
While the cheese is still entering from the right of the screen (a horizontal co-ordinate of 196 or more) it only moves horizontally.
|
||||||||
| HandleCheese | 26928 | CALL StoreEntity | Record the position of the sprite using StoreEntity. | |||||
| 26931 | LD HL,24347 | Point HL at ActorsInPlay. | ||||||
| 26934 | INC (HL) | Increase the number of actors in play by one. | ||||||
| 26935 | LD A,(IX+1) | Fetch the horizontal co-ordinate. | ||||||
| 26938 | CP 196 | Jump to HandleCheese_Horizontal if the cheese is still entering from the right. | ||||||
| 26940 | JR NC,HandleCheese_Horizontal | |||||||
| 26942 | CALL TestCharlieCollision | Test whether the cheese has hit Charlie using TestCharlieCollision. | ||||||
| 26945 | DEC E | Has Charlie been hit (is E now zero)? | ||||||
| 26946 | JP Z,LoseHat | Jump to LoseHat if Charlie has been hit. | ||||||
| 26949 | CALL TestFlourCollision | Test whether a flour shot has hit the cheese using TestFlourCollision. | ||||||
| 26952 | BIT 7,(IX+0) | Jump to HandleHitActor if the cheese has been hit. | ||||||
| 26956 | JP NZ,HandleHitActor | |||||||
|
Every eight frames, increase the vertical speed (up to a maximum of 8).
|
||||||||
| 26959 | LD A,(IX+7) | Fetch the frame counter (byte 7 of the actor). | ||||||
| 26962 | AND %00000111 | Keep only bits 0-2. | ||||||
| 26964 | JR NZ,HandleCheese_Vertical | Jump to HandleCheese_Vertical if the counter is not a multiple of 8. | ||||||
| 26966 | LD A,(IX+5) | Fetch the vertical speed. | ||||||
| 26969 | CP 8 | Jump to HandleCheese_Vertical if the vertical speed is already at the maximum. | ||||||
| 26971 | JR Z,HandleCheese_Vertical | |||||||
| 26973 | INC (IX+5) | Increase the vertical speed by one. | ||||||
| HandleCheese_Vertical | 26976 | LD A,(IX+5) | Fetch the vertical speed. | |||||
| 26979 | LD (IX+3),70 | Set the actor colour to 70 (yellow). | ||||||
| 26983 | SRA A | Halve the vertical speed. | ||||||
| 26985 | ADD A,(IX+2) | Add the vertical co-ordinate. | ||||||
| 26988 | CP 32 | Jump to HandleCheese_Top if the cheese has reached the top. | ||||||
| 26990 | JR C,HandleCheese_Top | |||||||
| 26992 | CP 160 | Jump to HandleCheese_Bottom if the cheese has reached the bottom. | ||||||
| 26994 | JR NC,HandleCheese_Bottom | |||||||
| 26996 | LD (IX+2),A | Update the vertical co-ordinate. | ||||||
| HandleCheese_Horizontal | 26999 | JP MoveBouncingActor_Horizontal | Move the actor horizontally using MoveBouncingActor_Horizontal. | |||||
|
The cheese has reached the top, so reverse the vertical speed.
|
||||||||
| HandleCheese_Top | 27002 | LD (IX+2),32 | Put the cheese at the top of the play area (32). | |||||
| 27006 | LD A,(IX+5) | Fetch the vertical speed. | ||||||
| 27009 | NEG | Reverse the direction by negating the vertical speed. | ||||||
| HandleCheese_SetSpeed | 27011 | LD (IX+5),A | Update the vertical speed. | |||||
| 27014 | JR HandleCheese_Horizontal | Jump to HandleCheese_Horizontal. | ||||||
|
The cheese has reached the bottom, so throw it back up.
|
||||||||
| HandleCheese_Bottom | 27016 | LD (IX+2),160 | Put the cheese on the floor (160). | |||||
| 27020 | CALL SetRandomSpeeds | Set random horizontal and vertical speeds using SetRandomSpeeds. | ||||||
| 27023 | LD A,R | Fetch a random number. | ||||||
| 27025 | AND %00000111 | Keep only bits 0-2. | ||||||
| 27027 | CPL | Invert A, so it is in the range 248 to 255 (-8 to -1). | ||||||
| 27028 | JR HandleCheese_SetSpeed | Jump to HandleCheese_SetSpeed. | ||||||
| Prev: 26906 | Up: Map | Next: 27030 |