![]() |
Routines |
| Prev: 41990 | Up: Map | Next: 42481 |
|
Handler for the object types 9 to 16 which are the walking sprites of Sabreman (9 to 12 when he walks to the left and 13 to 16 when he walks to the right). It is also the state that he is in when he is standing still.
Each time it saves the object state, handles being carried off (bit 6 of the redraw flags), tumbling (bit 7) and the special state at Tumble_Sabreman (bit 3), checks for contact with the bubbles, the stalactite and the creatures, reads the controls, moves him sideways, and finally keeps him inside the room, moving him to the next room when he walks off the edge.
|
||||||||
|
Clear the countdown and the contact flags. In the top part of the room (y position less than 72) the contact flags are set to 68 which marks both side walls as solid.
|
||||||||
| Handle_Sabreman_Walking | 42035 | CALL StoreEntity | Remember the position and sprite id of Sabreman (see StoreEntity). | |||||
| 42038 | LD A,(IX+15) | Fetch the redraw flags of Sabreman. | ||||||
| 42041 | AND %01000000 | Keep only bit 6 (being carried). | ||||||
| 42043 | JP NZ,Start_Being_Carried | Jump to Start_Being_Carried if Sabreman is being carried by an eagle (bit 6 of the redraw flags is set). | ||||||
| 42046 | LD (IX+10),0 | Clear the countdown of Sabreman. | ||||||
| 42050 | LD (IX+11),0 | Clear the contact flags of Sabreman. | ||||||
| 42054 | LD A,(IX+3) | Fetch the y position of Sabreman. | ||||||
| 42057 | CP 72 | Jump to Handle_Sabreman_Walking_Check_Special_States if Sabreman is in the lower part of the room (y position 72 or more). | ||||||
| 42059 | JR NC,Handle_Sabreman_Walking_Check_Special_States | |||||||
| 42061 | LD (IX+11),68 | Mark the walls on both sides as solid by setting the contact flags to 68 as he is in the upper part of the room. | ||||||
|
Check the special states.
|
||||||||
| Handle_Sabreman_Walking_Check_Special_States | 42065 | BIT 7,(IX+15) | Jump to Start_Tumbling if bit 7 of the redraw flags is set (Sabreman starts to tumble). | |||||
| 42069 | JR NZ,Start_Tumbling | |||||||
| 42071 | BIT 3,(IX+15) | Jump to Tumble_Sabreman if bit 3 of the redraw flags is set. | ||||||
| 42075 | JP NZ,Tumble_Sabreman | |||||||
|
Check for contact with the bubbles, the stalactite and the creatures. The result of the bubble contact check is kept in byte 14 of the record of Sabreman.
|
||||||||
| 42078 | CALL Read_World_Map | Read the world map entry of the room (the room flags are returned in E). | ||||||
| 42081 | CALL Check_Bubble_Contact | Check for contact with the bubbles. | ||||||
| 42084 | LD (IX+14),C | Store the bubble contact result in byte 14 of the record of Sabreman. | ||||||
| 42087 | CALL Check_Stalactite_Contact | Check for contact with the falling stalactite. | ||||||
| 42090 | BIT 2,C | Jump to Handle_Sabreman_Walking_Check_Creatures if the stalactite does not touch him (bit 2 of C is clear). | ||||||
| 42092 | JR Z,Handle_Sabreman_Walking_Check_Creatures | |||||||
| 42094 | BIT 2,(IX+14) | Jump to Knock_Sabreman_Down to knock Sabreman down if the stalactite hit him while he was touching a bubble. | ||||||
| 42098 | JP NZ,Knock_Sabreman_Down | |||||||
| 42101 | JP Handle_Stalactite_Hit | Jump to Handle_Stalactite_Hit to handle the stalactite hit. | ||||||
| Handle_Sabreman_Walking_Check_Creatures | 42104 | BIT 2,(IX+14) | Jump to Handle_Sabreman_Walking_Read_Controls if he is touching a bubble, as the creatures are only checked when he is not. | |||||
| 42108 | JR NZ,Handle_Sabreman_Walking_Read_Controls | |||||||
| 42110 | CALL Check_Decoration_Contact | Check for contact with the creatures. | ||||||
| 42113 | LD A,C | Copy the creature contact result to A. | ||||||
| 42114 | AND %01111111 | Keep only bits 0 to 6 (ignore which side the creature is on). | ||||||
| 42116 | CP 4 | Jump to Start_Tumbling_Downwards to start tumbling downwards if a creature is touching him from the side (the contact result is 4). | ||||||
| 42118 | JP Z,Start_Tumbling_Downwards | |||||||
| 42121 | LD (IX+14),C | Store the creature contact result in byte 14 of the record of Sabreman. | ||||||
|
Read the controls. A clear fire bit throws a weapon, and a set fire bit sets the flag for the released fire key. Then bit 3 of the controls (clear) starts a jump, bit 0 (clear) moves him to the right and bit 1 (clear) moves him to the left.
|
||||||||
| Handle_Sabreman_Walking_Read_Controls | 42124 | CALL ReadControls | Read the controls. | |||||
| 42127 | BIT 4,A | Jump to Handle_Sabreman_Walking_Fire_Released if bit 4 of the controls is set (the fire key is not pressed). | ||||||
| 42129 | JR NZ,Handle_Sabreman_Walking_Fire_Released | |||||||
| 42131 | EX AF,AF' | Keep the controls in AF' while the weapon is thrown. | ||||||
| 42132 | CALL Throw_Weapon | Throw a weapon (see Throw_Weapon). | ||||||
| 42135 | JR Handle_Sabreman_Walking_Check_Movement | Jump to Handle_Sabreman_Walking_Check_Movement. | ||||||
| Handle_Sabreman_Walking_Fire_Released | 42137 | EX AF,AF' | Keep the controls in AF'. | |||||
| 42138 | LD A,255 | Set the flag for the released fire key (Fire_Key_Flag) to 255. | ||||||
| 42140 | LD (43691),A | |||||||
| Handle_Sabreman_Walking_Check_Movement | 42143 | EX AF,AF' | Fetch the controls again from AF'. | |||||
| 42144 | BIT 3,A | Jump to Handle_Sabreman_Walking_Jump to start a jump if the up control is used (bit 3 of the controls is clear). | ||||||
| 42146 | JP Z,Handle_Sabreman_Walking_Jump | |||||||
| 42149 | BIT 0,A | Jump to Handle_Sabreman_Walking_Right to walk to the right if the right control is used (bit 0 of the controls is clear). | ||||||
| 42151 | JP Z,Handle_Sabreman_Walking_Right | |||||||
| 42154 | BIT 1,A | Jump to Handle_Sabreman_Walking_Left to walk to the left if the left control is used (bit 1 of the controls is clear). | ||||||
| 42156 | JP Z,Handle_Sabreman_Walking_Left | |||||||
| 42159 | LD (IX+6),0 | Set the x velocity to 0 as he is standing still. | ||||||
|
Move Sabreman sideways by the x velocity, unless the contact bits of the bubble or creature that he touches (bits 0 to 2) are all set, in which case the routine goes to Handle_Sabreman_Walking_Jump_Straight_Up, which starts a jump with a y velocity of zero.
|
||||||||
| Handle_Sabreman_Walking_Move_Sideways | 42163 | LD A,(IX+14) | Fetch the bubble or creature contact result of Sabreman (byte 14). | |||||
| 42166 | AND %00000111 | Keep only bits 0 to 2 (touching, on top and at the edge). | ||||||
| 42168 | CP 7 | Jump to Handle_Sabreman_Walking_Jump_Straight_Up if all three are set (he is standing on the edge of a bubble or a creature). | ||||||
| 42170 | JP Z,Handle_Sabreman_Walking_Jump_Straight_Up | |||||||
| 42173 | LD A,(IX+1) | Fetch the x position of Sabreman. | ||||||
| 42176 | ADD A,(IX+6) | Add the x velocity of Sabreman. | ||||||
| 42179 | LD (IX+1),A | Store the new x position of Sabreman. | ||||||
| 42182 | CALL Read_World_Map | Read the world map entry of the room. | ||||||
| 42185 | LD A,E | Copy the room flags to A. | ||||||
| 42186 | LD (43692),A | Store the room flags in Room_Flags. | ||||||
| 42189 | OR (IX+11) | Combine the room flags with the contact flags of Sabreman. | ||||||
| 42192 | LD E,A | Keep the combined flags in E. | ||||||
| 42193 | LD A,(IX+1) | Fetch the x position of Sabreman. | ||||||
| 42196 | CP 16 | Jump to Handle_Sabreman_Walking_On_Ground if Sabreman is at the left edge of the room (x position less than 16). | ||||||
| 42198 | JR C,Handle_Sabreman_Walking_On_Ground | |||||||
| 42200 | CP 232 | Jump to Handle_Sabreman_Walking_On_Ground if Sabreman is at the right edge of the room (x position 232 or more). | ||||||
| 42202 | JR NC,Handle_Sabreman_Walking_On_Ground | |||||||
| 42204 | EX AF,AF' | Keep the controls in AF' while the room redrawn flag is fetched. | ||||||
| 42205 | LD A,(36592) | Fetch the room redrawn flag from Room_Redrawn_Flag. | ||||||
| 42208 | LD D,A | Copy the flag to D. | ||||||
| 42209 | EX AF,AF' | Fetch the controls again from AF'. | ||||||
| 42210 | BIT 0,D | Jump to Handle_Sabreman_Walking_On_Ground if the room has just been drawn (bit 0 of the flag is set). | ||||||
| 42212 | JR NZ,Handle_Sabreman_Walking_On_Ground | |||||||
| 42214 | BIT 4,E | Jump to Handle_Sabreman_Walking_No_Floor if there is no floor under him (bit 4 of E is clear), as he walks off the ledge. | ||||||
| 42216 | JP Z,Handle_Sabreman_Walking_No_Floor | |||||||
|
Sabreman is on the ground, so the y velocity is cleared. Then the x position is kept inside the room. Bit 2 of the sprite id less one tells which way he is facing (set for the right).
|
||||||||
| Handle_Sabreman_Walking_On_Ground | 42219 | LD (IX+9),0 | Set the y velocity to 0 as he is standing on the floor. | |||||
| 42223 | LD B,(IX+0) | Fetch the sprite id of Sabreman. | ||||||
| 42226 | DEC B | Decrease it so that bit 2 tells which way he is facing. | ||||||
| 42227 | BIT 2,B | Jump to Handle_Sabreman_Walking_Facing_Right if he is facing right (bit 2 is set). | ||||||
| 42229 | JR NZ,Handle_Sabreman_Walking_Facing_Right | |||||||
| 42231 | BIT 7,(IX+1) | Jump to Update_Object_Sprite if he is in the right half of the room (bit 7 of the x position is set), as he is far from the left wall. | ||||||
| 42235 | JP NZ,Update_Object_Sprite | |||||||
| 42238 | CP 24 | Jump to Update_Object_Sprite if he has not reached the left wall (x position 24 or more). | ||||||
| 42240 | JP NC,Update_Object_Sprite | |||||||
| 42243 | BIT 6,E | Jump to Handle_Sabreman_Walking_Left_Room_Edge if the left wall is not solid (bit 6 of E is clear). | ||||||
| 42245 | JR Z,Handle_Sabreman_Walking_Left_Room_Edge | |||||||
| 42247 | LD (IX+1),24 | Stop him at the left wall by setting the x position to 24. | ||||||
| 42251 | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
| Handle_Sabreman_Walking_Left_Room_Edge | 42254 | CP 8 | Jump to Update_Object_Sprite if he has not left the room (x position 8 or more). | |||||
| 42256 | JP NC,Update_Object_Sprite | |||||||
| 42259 | LD (IX+1),240 | Put him at the right edge of the next room (x position 240). | ||||||
| 42263 | DEC (IX+2) | Decrease the room x, to go to the room on the left. | ||||||
| 42266 | CALL Draw_Room | Draw the new room. | ||||||
| 42269 | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
| Handle_Sabreman_Walking_Facing_Right | 42272 | BIT 7,(IX+1) | Jump to Update_Object_Sprite if he is in the left half of the room (bit 7 of the x position is clear), as he is far from the right wall. | |||||
| 42276 | JP Z,Update_Object_Sprite | |||||||
| 42279 | CP 216 | Jump to Update_Object_Sprite if he has not reached the right wall (x position less than 216). | ||||||
| 42281 | JP C,Update_Object_Sprite | |||||||
| 42284 | BIT 2,E | Jump to Handle_Sabreman_Walking_Right_Room_Edge if the right wall is not solid (bit 2 of E is clear). | ||||||
| 42286 | JP Z,Handle_Sabreman_Walking_Right_Room_Edge | |||||||
| 42289 | LD (IX+1),216 | Stop him at the right wall by setting the x position to 216. | ||||||
| 42293 | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
| Handle_Sabreman_Walking_Right_Room_Edge | 42296 | CP 241 | Jump to Update_Object_Sprite if he has not left the room (x position less than 241). | |||||
| 42298 | JP C,Update_Object_Sprite | |||||||
| 42301 | LD (IX+1),8 | Put him at the left edge of the next room (x position 8). | ||||||
| 42305 | INC (IX+2) | Increase the room x, to go to the room on the right. | ||||||
| 42308 | CALL Draw_Room | Draw the new room. | ||||||
| 42311 | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
|
Walk to the right. If the contact bits of the bubble or creature that he touches (bits 1, 2 and 7) are exactly 4 he is blocked and stands still. Otherwise the x velocity is 2 and the sprite id is 13 plus bits 1 and 2 of the animation counter.
|
||||||||
| Handle_Sabreman_Walking_Right | 42314 | LD A,(IX+14) | Fetch the bubble or creature contact result of Sabreman (byte 14). | |||||
| 42317 | AND %10000110 | Keep only bits 1, 2 and 7 (on top, touching and the side). | ||||||
| 42319 | CP 4 | Jump to Handle_Sabreman_Walking_Right_Free if he is not blocked on the right (the result is not 4). | ||||||
| 42321 | JR NZ,Handle_Sabreman_Walking_Right_Free | |||||||
| 42323 | LD (IX+6),0 | Set the x velocity to 0 as he is blocked. | ||||||
| 42327 | JP Handle_Sabreman_Walking_Move_Sideways | Jump to Handle_Sabreman_Walking_Move_Sideways. | ||||||
| Handle_Sabreman_Walking_Right_Free | 42330 | LD (IX+6),2 | Set the x velocity to 2 (walking right). | |||||
| 42334 | INC (IX+8) | Increase the animation counter of Sabreman. | ||||||
| 42337 | LD A,(IX+8) | Fetch the animation counter. | ||||||
| 42340 | RRA | Halve the animation counter so that the frame changes every other pass. | ||||||
| 42341 | AND %00000011 | Keep only the two low bits (one of four frames). | ||||||
| 42343 | ADD A,13 | Add 13 to make the sprite id (the frames for walking right). | ||||||
| 42345 | LD (IX+0),A | Set the sprite id. | ||||||
| 42348 | JR Handle_Sabreman_Walking_Play_Tone | Jump to Handle_Sabreman_Walking_Play_Tone to play the footstep sound. | ||||||
|
Walk to the left. If the contact bits of the bubble or creature that he touches (bits 1, 2 and 7) are exactly 132 he is blocked and stands still. Otherwise the x velocity is 254 and the sprite id is 9 plus bits 1 and 2 of the animation counter.
|
||||||||
| Handle_Sabreman_Walking_Left | 42350 | LD A,(IX+14) | Fetch the bubble or creature contact result of Sabreman (byte 14). | |||||
| 42353 | AND %10000110 | Keep only bits 1, 2 and 7 (on top, touching and the side). | ||||||
| 42355 | CP 132 | Jump to Handle_Sabreman_Walking_Left_Free if he is not blocked on the left (the result is not 132). | ||||||
| 42357 | JR NZ,Handle_Sabreman_Walking_Left_Free | |||||||
| 42359 | LD (IX+6),0 | Set the x velocity to 0 as he is blocked. | ||||||
| 42363 | JP Handle_Sabreman_Walking_Move_Sideways | Jump to Handle_Sabreman_Walking_Move_Sideways. | ||||||
| Handle_Sabreman_Walking_Left_Free | 42366 | LD (IX+6),254 | Set the x velocity to 254 (walking left). | |||||
| 42370 | INC (IX+8) | Increase the animation counter of Sabreman. | ||||||
| 42373 | LD A,(IX+8) | Fetch the animation counter. | ||||||
| 42376 | RRA | Halve the animation counter so that the frame changes every other pass. | ||||||
| 42377 | AND %00000011 | Keep only the two low bits (one of four frames). | ||||||
| 42379 | ADD A,9 | Add 9 to make the sprite id (the frames for walking left). | ||||||
| 42381 | LD (IX+0),A | Set the sprite id. | ||||||
| Handle_Sabreman_Walking_Play_Tone | 42384 | CALL Play_Alternating_Tone | Play the footstep sound (see Play_Alternating_Tone). | |||||
| 42387 | JP Handle_Sabreman_Walking_Move_Sideways | Jump to Handle_Sabreman_Walking_Move_Sideways. | ||||||
|
Jump. The y velocity is set to 208 the countdown to 8 and the sprite id becomes 17 (facing left) or 19 (facing right), according to the direction of the x velocity or, when he is not moving sideways, to the way that he faced.
|
||||||||
| Handle_Sabreman_Walking_Jump | 42390 | LD (IX+9),208 | Set the y velocity to 208 (up) to start the jump. | |||||
| Handle_Sabreman_Walking_Jump_Set_Countdown | 42394 | LD (IX+10),8 | Set the jump countdown to 8. | |||||
| 42398 | LD A,(IX+0) | Fetch the sprite id of Sabreman. | ||||||
| 42401 | DEC A | Decrease it so that bit 2 tells which way he is facing. | ||||||
| 42402 | AND %00000100 | Keep only bit 2 (set when he faces right). | ||||||
| 42404 | SRL A | Shift it right to make 0 (left) or 2 (right). | ||||||
| 42406 | ADD A,17 | Add 17 to make the jumping sprite id. | ||||||
| 42408 | LD (IX+0),A | Set the sprite id. | ||||||
| 42411 | LD A,(IX+6) | Fetch the x velocity of Sabreman. | ||||||
| 42414 | AND A | Jump to Update_Object_Sprite if he is not moving sideways. | ||||||
| 42415 | JP Z,Update_Object_Sprite | |||||||
| 42418 | JP M,Handle_Sabreman_Walking_Jump_Left | Jump to Handle_Sabreman_Walking_Jump_Left if he is moving to the left. | ||||||
| 42421 | LD (IX+0),19 | Set the sprite id to 19 (jumping right). | ||||||
| 42425 | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
| Handle_Sabreman_Walking_Jump_Left | 42428 | LD (IX+0),17 | Set the sprite id to 17 (jumping left). | |||||
| 42432 | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
|
The room has no floor at this position. Sabreman jumps with a y velocity of 192 and an x velocity of 2 (when his x position is below 128) or 254.
|
||||||||
| Handle_Sabreman_Walking_No_Floor | 42435 | LD (IX+9),192 | Set the y velocity to 192 (up), as he steps off the ledge. | |||||
| 42439 | BIT 7,(IX+1) | Jump to Handle_Sabreman_Walking_No_Floor_Left if bit 7 of the x position is set. | ||||||
| 42443 | JR NZ,Handle_Sabreman_Walking_No_Floor_Left | |||||||
| 42445 | LD (IX+6),2 | Set the x velocity to 2. | ||||||
| 42449 | LD (IX+10),8 | Set the countdown to 8. | ||||||
| 42453 | LD (IX+0),19 | Set the sprite id to 19 (jumping right). | ||||||
| 42457 | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
| Handle_Sabreman_Walking_No_Floor_Left | 42460 | LD (IX+6),254 | Set the x velocity to 254. | |||||
| 42464 | LD (IX+10),8 | Set the countdown to 8. | ||||||
| 42468 | LD (IX+0),17 | Set the sprite id to 17 (jumping left). | ||||||
| 42472 | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
| Handle_Sabreman_Walking_Jump_Straight_Up | 42475 | LD (IX+9),0 | Set the y velocity to 0 so that the jump has no height. | |||||
| 42479 | JR Handle_Sabreman_Walking_Jump_Set_Countdown | Jump to Handle_Sabreman_Walking_Jump_Set_Countdown. | ||||||
| Prev: 41990 | Up: Map | Next: 42481 |