![]() |
Routines |
| Prev: 36292 | Up: Map | Next: 36512 |
|
The handler for the knight (sprite IDs 1 to 16) when it is the character being played. It is the same as HandlerSerf, except that the slowing is 3 on each frame and the fire button throws an axe (see ThrowAxe). The second part of this routine is used by the other characters as well: it makes creatures (see SpawnCreature), takes energy from the player every sixteen frames, and displays the character.
|
||||||||
| HandlerKnight | 36390 | LD BC,8224 | BC=8224 (the change in velocity and the top speed). | |||||
| 36393 | LD DE,771 | DE=0771 (the slowing of each velocity). | ||||||
| 36396 | LD HL,1799 | HL=1799 (this is not used by ControlPlayer). | ||||||
| 36399 | CALL ControlPlayer | Call ControlPlayer to move the knight. | ||||||
| 36402 | LD E,(IX+6) | Fetch the X velocity. | ||||||
| 36405 | LD D,(IX+7) | Fetch the Y velocity. | ||||||
| 36408 | LD A,D | Jump to HandlerKnight_Fire if the knight is not moving (both velocities are zero). | ||||||
| 36409 | OR E | |||||||
| 36410 | JR Z,HandlerKnight_Fire | |||||||
| 36412 | LD A,(23672) | Fetch FRAMES. | ||||||
| 36415 | AND %00000011 | Keep only bits 0-1. | ||||||
| 36417 | JR NZ,HandlerKnight_Fire | Jump to HandlerKnight_Fire unless this is every fourth frame. | ||||||
|
Move on to the next frame of the animation, for the left set of sprites.
|
||||||||
| 36419 | LD A,(IX+0) | Fetch the sprite ID of the knight. | ||||||
| 36422 | AND %00000011 | Keep only bits 0-1. | ||||||
| 36424 | INC A | Add 1 (the first of the sprites facing left). | ||||||
| 36425 | LD (IX+0),A | Update the sprite ID of the knight. | ||||||
|
Work out which axis the knight is moving fastest on, by comparing the sizes of the velocities.
|
||||||||
| 36428 | LD A,D | Fetch the Y velocity. | ||||||
| 36429 | AND A | Jump to HandlerKnight_CompareAxes if the Y velocity is positive. | ||||||
| 36430 | JP P,HandlerKnight_CompareAxes | |||||||
| 36433 | NEG | Make it positive. | ||||||
| HandlerKnight_CompareAxes | 36435 | LD C,A | Keep the Y speed in C. | |||||
| 36436 | LD A,E | Fetch the X velocity. | ||||||
| 36437 | AND A | Jump to HandlerKnight_Compare if the X velocity is positive. | ||||||
| 36438 | JP P,HandlerKnight_Compare | |||||||
| 36441 | NEG | Make it positive. | ||||||
| HandlerKnight_Compare | 36443 | CP C | Jump to HandlerKnight_Horizontal if the knight is moving more across than up or down. | |||||
| 36444 | JR NC,HandlerKnight_Horizontal | |||||||
|
The knight is moving up or down, so add 8 for the sprites facing up or 12 for those facing down.
|
||||||||
| 36446 | LD A,D | Fetch the Y velocity. | ||||||
| 36447 | AND A | Test the sign of the Y velocity. | ||||||
| 36448 | LD A,(IX+0) | Fetch the sprite ID of the knight. | ||||||
| 36451 | JP M,HandlerKnight_Vertical | Jump to HandlerKnight_Vertical if the knight is moving up. | ||||||
| 36454 | ADD A,4 | Add 4. | ||||||
| HandlerKnight_Vertical | 36456 | ADD A,8 | Add 8. | |||||
| HandlerKnight_SetSprite | 36458 | LD (IX+0),A | Update the sprite ID of the knight. | |||||
| 36461 | CALL SoundsWalking | Call SoundsWalking to make the sound of walking. | ||||||
|
See whether the fire button is pressed.
|
||||||||
| HandlerKnight_Fire | 36464 | CALL ReadControls | Call ReadControls to read the controls. | |||||
| 36467 | AND %00010000 | Keep only bit 4 (fire). | ||||||
| 36469 | CALL Z,ThrowAxe | Call ThrowAxe to throw an axe if the fire button is pressed. | ||||||
|
This entry point is used by the routines at HandlerWizard and HandlerSerf.
Make creatures, use up some energy and display the character. This is also where the serf and the wizard come in.
|
||||||||
| HandlerCharacter_Finish | 36472 | CALL SpawnCreature | Call SpawnCreature to make a creature, if one is due. | |||||
| 36475 | LD A,(24082) | Fetch the counter from CounterLow. | ||||||
| 36478 | AND %00001111 | Keep only bits 0-3. | ||||||
| 36480 | JR NZ,HandlerCharacter_Display | Jump to HandlerCharacter_Display unless this is every sixteenth frame. | ||||||
| 36482 | LD A,(24104) | Fetch the energy of the player from PlayerEnergy. | ||||||
| 36485 | DEC A | Decrease the energy by one. | ||||||
| 36486 | JR Z,LoseLife | Jump to LoseLife if there is no energy left. | ||||||
| 36488 | LD (24104),A | Update the energy of the player in PlayerEnergy. | ||||||
| 36491 | CALL DrawChicken | Call DrawChicken to redraw the chicken. | ||||||
|
This entry point is used by the routines at HandlerWeapon, HandlerBatlet, MoveCreature, HandlerSparkle and HandlerPop.
|
||||||||
| HandlerCharacter_Display | 36494 | CALL DisplayEntity | Call DisplayEntity to display the character. | |||||
| 36497 | JP SetEntityAttributes_Moved | Jump to SetEntityAttributes_Moved to set the attributes of the cells it covers. | ||||||
|
The knight is moving across, so add 4 for the sprites facing right.
|
||||||||
| HandlerKnight_Horizontal | 36500 | LD A,E | Fetch the X velocity. | |||||
| 36501 | AND A | Test the sign of the X velocity. | ||||||
| 36502 | LD A,(IX+0) | Fetch the sprite ID of the knight. | ||||||
| 36505 | JP M,HandlerKnight_SetSprite | Jump to HandlerKnight_SetSprite if the knight is moving left. | ||||||
| 36508 | ADD A,4 | Add 4. | ||||||
| 36510 | JR HandlerKnight_SetSprite | Jump to HandlerKnight_SetSprite to set the sprite of the knight. | ||||||
| Prev: 36292 | Up: Map | Next: 36512 |