![]() |
Routines |
| Prev: 40257 | Up: Map | Next: 40452 |
|
Handles a flame (sprite IDs 52-55) which has been started by SpawnFlame. A flame which is not in the player's room is counted off by ExpireActor. In the player's room it burns for a limited time, drifting around in a random direction (which is changed by ChooseFlameDirection whenever its timer runs out or it is blocked) and bouncing off the edges of the screen. It flickers by changing sprite and colour every time it is handled, and it plays a crackling sound. If it touches the player (while the player is coloured INK:WHITE, PAPER:BLACK (BRIGHT)) the player is hit. When its time is up, or the player is dead, the flame is blown up.
|
||||||||
|
Count off the flame if it is not in the same room as the player.
|
||||||||
| HandlerFlame | 40337 | LD A,(38659) | Fetch the room of the player from 38659. | |||||
| 40340 | CP (IX+1) | Jump to ExpireActor if the flame is in a different room to the player. | ||||||
| 40343 | JP NZ,ExpireActor | |||||||
| 40346 | LD A,23 | Write 23 to Actor_Width (the width of the flame). | ||||||
| 40348 | LD (38573),A | |||||||
| 40351 | CALL StoreEntity | Remember the previous position of the flame. | ||||||
|
Explode the flame if the player is not alive.
|
||||||||
| 40354 | LD A,(38658) | Fetch the sprite ID of the player. | ||||||
| 40357 | SUB 16 | Subtract 16 (the first Sabreman sprite ID). | ||||||
| 40359 | CP 32 | Jump to BlowUpActor if the player is not alive. | ||||||
| 40361 | JP NC,BlowUpActor | |||||||
|
Explode the flame when its lifetime runs out.
|
||||||||
| 40364 | DEC (IX+8) | Decrease the lifetime of the flame by one and jump to BlowUpFlame if it has run out. | ||||||
| 40367 | JP Z,BlowUpFlame | |||||||
|
Choose a new direction when the direction timer has run out.
|
||||||||
| 40370 | DEC (IX+2) | Decrease the direction timer by one and choose a new direction if it has run out. | ||||||
| 40373 | CALL Z,ChooseFlameDirection | |||||||
|
Work out the new position of the flame and bounce off the edges of the screen.
|
||||||||
| 40376 | CALL CalculateNewPosition | Work out the new position of the flame. | ||||||
| 40379 | BIT 0,B | Jump to BounceFlameHorizontally if the flame has hit the left or right edge of the screen. | ||||||
| 40381 | JR NZ,BounceFlameHorizontally | |||||||
| 40383 | BIT 1,B | Jump to BounceFlameVertically if the flame has hit the top or bottom edge of the screen. | ||||||
| 40385 | JR NZ,BounceFlameVertically | |||||||
|
This entry point is used by the routines at BounceFlameHorizontally and BounceFlameVertically.
Stop the flame moving through objects in the room. If it did not manage to move then choose a new direction.
|
||||||||
| HandlerFlame_Move | 40387 | LD BC,5903 | Set the height of the flame in B to 23 and the width in C to 15. | |||||
| 40390 | CALL SlideActorPastObjects | Stop the flame passing through objects in the room. | ||||||
| 40393 | CALL TestPositionUnchanged | Test whether the flame has stayed where it was. | ||||||
| 40396 | CALL Z,ChooseFlameDirection | Choose a new direction if the flame has stayed where it was. | ||||||
|
Flicker the flame by choosing one of the four flame sprites and a colour at random.
|
||||||||
| 40399 | LD A,(38549) | Fetch the random seed from RandomNumber. | ||||||
| 40402 | AND %00000011 | Keep only bits 0-1. | ||||||
| 40404 | OR %00110100 | Set bits 2, 4-5. | ||||||
| 40406 | LD (IX+0),A | Set the sprite ID of the flame. | ||||||
| 40409 | CALL ChooseFlameColour | Choose a colour for the flame. | ||||||
| 40412 | LD (IX+5),A | Set the colour of the flame. | ||||||
|
Store the new position.
|
||||||||
| 40415 | LD (IX+3),E | Set the X position of the flame. | ||||||
| 40418 | LD (IX+4),D | Set the Y position of the flame. | ||||||
|
Hit the player if the flame touches the player, but only if the player is coloured INK:WHITE, PAPER:BLACK (BRIGHT).
|
||||||||
| 40421 | LD A,(38663) | Fetch the colour of the player from 38663. | ||||||
| 40424 | CP 71 | Jump to HandlerFlame_Draw if the player is not coloured INK:WHITE, PAPER:BLACK (BRIGHT). | ||||||
| 40426 | JR NZ,HandlerFlame_Draw | |||||||
| 40428 | LD BC,4879 | Set the height of the flame in B to 19 and the width in C to 15. | ||||||
| 40431 | CALL TestPlayerTouchingActor | Test whether the flame is touching the player. | ||||||
| 40434 | JR NC,HandlerFlame_Draw | Jump to HandlerFlame_Draw if the flame is not touching the player. | ||||||
| 40436 | LD A,(38661) | Fetch the X position of the player from 38661. | ||||||
| 40439 | RLCA | Rotate bit 7 (which half of the screen the player is in) into bit 0. | ||||||
| 40440 | AND %00000001 | Keep only bit 0. | ||||||
| 40442 | INC A | Add one, so the hit direction is 1 or 2. | ||||||
| 40443 | LD (38660),A | Store the hit direction in 38660 (the player's state). | ||||||
|
Draw the flame and make the crackling sound.
|
||||||||
| HandlerFlame_Draw | 40446 | CALL DisplayActor | Display the flame. | |||||
| 40449 | JP PlayFlameSound | Jump to PlayFlameSound to play the flame sound. | ||||||
| Prev: 40257 | Up: Map | Next: 40452 |