![]() |
Routines |
| Prev: 43247 | Up: Map | Next: 43580 |
|
Handler for the object types 24 to 27 which are the tumbling sprites of Sabreman. The sprite id is 24 plus bits 1 and 2 of the tick counter at GameTimer, so the frames follow each other as time passes.
He tumbles after the stalactite or a creature has hit him and when he bumps into a side wall while he is falling. The routine decreases the countdown, checks for contact with the bubbles and the creatures (which push him sideways with an x velocity of 2 or 254), moves him sideways and applies gravity in the same way as Handle_Sabreman_Falling, and goes on at Handle_Sabreman_Falling_Above_Floor once the y position is less than 159.
Unlike the falling handler the y velocity here has a limit of 118.
|
||||||||
| Handle_Sabreman_Tumbling | 43301 | CALL StoreEntity | Remember the position and sprite id of Sabreman. | |||||
|
This entry point is used by the routines at Handle_Sabreman_Jumping, Handle_Sabreman_Falling and Tumble_Sabreman.
Deal with the special states in the same way as Handle_Sabreman_Walking.
|
||||||||
| Continue_Sabreman_Tumbling | 43304 | BIT 6,(IX+15) | Jump to Start_Being_Carried if Sabreman is being carried (bit 6 of the redraw flags). | |||||
| 43308 | JP NZ,Start_Being_Carried | |||||||
| 43311 | BIT 7,(IX+15) | Jump to Start_Tumbling if Sabreman is tumbling (bit 7 of the redraw flags). | ||||||
| 43315 | JP NZ,Start_Tumbling | |||||||
|
Read the world map entry and decrease the countdown unless it is zero.
|
||||||||
| 43318 | CALL Read_World_Map | Read the world map entry of the room. | ||||||
| 43321 | LD A,(IX+10) | Fetch the countdown of Sabreman. | ||||||
| 43324 | AND A | Jump to Handle_Sabreman_Tumbling_Save_Room_Flags if the countdown is zero. | ||||||
| 43325 | JR Z,Handle_Sabreman_Tumbling_Save_Room_Flags | |||||||
| 43327 | DEC (IX+10) | Decrease the countdown of Sabreman. | ||||||
| Handle_Sabreman_Tumbling_Save_Room_Flags | 43330 | LD A,E | Store the room flags in Room_Flags. | |||||
| 43331 | LD (43692),A | |||||||
|
Check for contact with the bubbles and the creatures.
|
||||||||
| 43334 | CALL Check_Bubble_Contact | Check for contact with the bubbles. | ||||||
| 43337 | BIT 2,C | Jump to Handle_Sabreman_Tumbling_Bubble_Contact if Sabreman touches a bubble (bit 2 of C is set). | ||||||
| 43339 | JR NZ,Handle_Sabreman_Tumbling_Bubble_Contact | |||||||
| 43341 | PUSH DE | Stash the world map entry on the stack. | ||||||
| 43342 | CALL Check_Decoration_Contact | Check for contact with the creatures. | ||||||
| 43345 | POP DE | Restore the world map entry from the stack. | ||||||
| 43346 | BIT 2,C | Jump to Handle_Sabreman_Tumbling_Combine_Flags if Sabreman touches no creature (bit 2 of C is not set). | ||||||
| 43348 | JR Z,Handle_Sabreman_Tumbling_Combine_Flags | |||||||
| Handle_Sabreman_Tumbling_Creature_Check_Side | 43350 | BIT 0,C | Jump to Handle_Sabreman_Tumbling_Creature_Check_Top if he is touching the middle of it (bit 0 of C is clear). | |||||
| 43352 | JR Z,Handle_Sabreman_Tumbling_Creature_Check_Top | |||||||
| 43354 | BIT 1,C | Jump to Handle_Sabreman_Tumbling_Combine_Flags if he is on top of the edge of it (bit 1 of C is set). | ||||||
| 43356 | JR NZ,Handle_Sabreman_Tumbling_Combine_Flags | |||||||
| Handle_Sabreman_Tumbling_Creature_Bounce | 43358 | BIT 7,C | Jump to Handle_Sabreman_Tumbling_Creature_Bounce_Left if he is on the left of it (bit 7 of C is clear). | |||||
| 43360 | JR Z,Handle_Sabreman_Tumbling_Creature_Bounce_Left | |||||||
| 43362 | LD B,2 | Set the new x velocity to 2 (pushed to the right). | ||||||
| 43364 | JR Handle_Sabreman_Tumbling_Set_Velocity | Jump to Handle_Sabreman_Tumbling_Set_Velocity. | ||||||
| Handle_Sabreman_Tumbling_Creature_Bounce_Left | 43366 | LD B,254 | Set the new x velocity to 254 (pushed to the left). | |||||
| 43368 | JR Handle_Sabreman_Tumbling_Set_Velocity | Jump to Handle_Sabreman_Tumbling_Set_Velocity. | ||||||
| Handle_Sabreman_Tumbling_Creature_Check_Top | 43370 | BIT 1,C | Jump to Handle_Sabreman_Tumbling_Creature_Bounce and push him away sideways if he is not on top of it (bit 1 of C is clear). | |||||
| 43372 | JR Z,Handle_Sabreman_Tumbling_Creature_Bounce | |||||||
| 43374 | LD A,B | Set the y position so that Sabreman stands on top of the creature. | ||||||
| 43375 | DEC A | |||||||
| 43376 | NEG | |||||||
| 43378 | ADD A,160 | |||||||
| 43380 | LD (IX+3),A | |||||||
| 43383 | JP Land_Sabreman | Jump to Land_Sabreman. | ||||||
| Handle_Sabreman_Tumbling_Bubble_Contact | 43386 | LD A,C | Copy the bubble contact result to A. | |||||
| 43387 | AND %00000011 | Keep only bits 0 and 1. | ||||||
| 43389 | CP 2 | Jump to Handle_Sabreman_Tumbling_Creature_Check_Side unless he is on top of the middle of the bubble (the result is 2). | ||||||
| 43391 | JR NZ,Handle_Sabreman_Tumbling_Creature_Check_Side | |||||||
| 43393 | LD (IX+9),0 | Stop him falling by setting the y velocity to 0. | ||||||
| 43397 | JR Handle_Sabreman_Tumbling_Creature_Check_Top | Jump to Handle_Sabreman_Tumbling_Creature_Check_Top. | ||||||
| Handle_Sabreman_Tumbling_Set_Velocity | 43399 | LD A,B | Copy the new x velocity to A. | |||||
| 43400 | XOR (IX+6) | Combine it with the old x velocity using XOR to find out if the direction has changed. | ||||||
| 43403 | LD (IX+6),B | Set the new x velocity of Sabreman. | ||||||
| 43406 | AND %10000000 | Keep only bit 7 (set when the direction has changed). | ||||||
| 43408 | EXX | Switch to the shadow registers to keep BC, DE and HL. | ||||||
| 43409 | CALL NZ,Play_Low_Tone | Play a low tone if the direction has changed. | ||||||
| 43412 | EXX | Switch back to the main registers. | ||||||
|
Combine the room flags with the contact flags and clear the contact flags. The sprite id is set to 24 plus bits 1 and 2 of the tick counter.
|
||||||||
| Handle_Sabreman_Tumbling_Combine_Flags | 43413 | LD A,E | Combine the contact flags of Sabreman with the contact flags of the room. | |||||
| 43414 | OR (IX+11) | |||||||
| 43417 | LD E,A | |||||||
| 43418 | XOR A | Clear the contact flags of Sabreman. | ||||||
| 43419 | LD (IX+11),A | |||||||
| 43422 | LD A,(36566) | Fetch the tick counter from GameTimer. | ||||||
| 43425 | RRA | Rotate the tick counter right, so that the frame changes every other tick. | ||||||
| 43426 | AND %00000011 | Keep only bits 0-1. | ||||||
| 43428 | ADD A,24 | Add 24 to make the sprite id of a tumbling frame. | ||||||
| 43430 | LD (IX+0),A | Set the sprite id of Sabreman. | ||||||
| 43433 | LD A,(IX+6) | Fetch the x velocity of Sabreman. | ||||||
| 43436 | AND A | Test the x velocity. | ||||||
|
Move Sabreman sideways. This is done when the x velocity is not zero or the x position is less than 128.
|
||||||||
| 43437 | LD A,(IX+1) | Fetch the x position of Sabreman. | ||||||
| 43440 | JR NZ,Handle_Sabreman_Tumbling_Move_Sideways | Jump to Handle_Sabreman_Tumbling_Move_Sideways if he is moving sideways (the x velocity is not zero). | ||||||
| 43442 | BIT 7,A | Jump to Handle_Sabreman_Tumbling_Check_Left_Edge if he is in the left half of the room (bit 7 of the x position is clear). | ||||||
| 43444 | JR Z,Handle_Sabreman_Tumbling_Check_Left_Edge | |||||||
| Handle_Sabreman_Tumbling_Move_Sideways | 43446 | ADD A,(IX+6) | Add the x velocity of Sabreman. | |||||
| 43449 | LD (IX+1),A | Store the new x position of Sabreman. | ||||||
| 43452 | BIT 7,A | Jump to Handle_Tumbling_At_Right_Edge if he is in the right half of the room (bit 7 of the x position is set). | ||||||
| 43454 | JP NZ,Handle_Tumbling_At_Right_Edge | |||||||
| Handle_Sabreman_Tumbling_Check_Left_Edge | 43457 | CP 24 | Jump to Apply_Tumbling_Gravity if he is clear of the left wall (x position 24 or more). | |||||
| 43459 | JP NC,Apply_Tumbling_Gravity | |||||||
| 43462 | BIT 6,E | Jump to Handle_Sabreman_Tumbling_No_Left_Wall if the left wall is not solid (bit 6 of E is clear). | ||||||
| 43464 | JR Z,Handle_Sabreman_Tumbling_No_Left_Wall | |||||||
| 43466 | LD A,(IX+6) | Fetch the x velocity of Sabreman. | ||||||
| 43469 | NEG | Negate the x velocity, so that he bounces off the wall. | ||||||
| 43471 | LD (IX+6),A | Store the new x velocity of Sabreman. | ||||||
| 43474 | LD (IX+1),24 | Stop him at the left wall by setting the x position to 24. | ||||||
| 43478 | JR Apply_Tumbling_Gravity | Jump to Apply_Tumbling_Gravity. | ||||||
| Handle_Sabreman_Tumbling_No_Left_Wall | 43480 | EX AF,AF' | Mark the ceiling and the floor as solid (bits 0 and 4 of the contact flags of Sabreman), as he is in the gap in the wall, keeping the new x position in AF'. | |||||
| 43481 | LD A,17 | |||||||
| 43483 | OR (IX+11) | |||||||
| 43486 | LD (IX+11),A | |||||||
| 43489 | EX AF,AF' | |||||||
| 43490 | SET 4,E | Mark the room as having a floor (bit 4 of E). | ||||||
| 43492 | CP 8 | Jump to Apply_Tumbling_Gravity if he has not left the room (x position 8 or more). | ||||||
| 43494 | JR NC,Apply_Tumbling_Gravity | |||||||
| 43496 | DEC (IX+2) | Decrease the room x, to go to the room on the left. | ||||||
| 43499 | LD (IX+1),231 | Put him at the right edge of the next room (x position 231). | ||||||
| 43503 | CALL Draw_Room | Draw the new room. | ||||||
| 43506 | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
|
This entry point is used by the routine at Handle_Tumbling_At_Right_Edge.
Apply gravity. The y velocity is increased by 2 each time up to a limit of 118 and the y position is changed by the y velocity divided by 16. A y position of 159 or more sends him to Handle_Sabreman_Falling_Reach_Floor when the room has a floor.
|
||||||||
| Apply_Tumbling_Gravity | 43509 | LD A,(IX+9) | Fetch the y velocity of Sabreman. | |||||
| 43512 | BIT 7,A | Jump to Apply_Tumbling_Gravity_Increase_Velocity if he is moving up (bit 7 of the y velocity is set). | ||||||
| 43514 | JR NZ,Apply_Tumbling_Gravity_Increase_Velocity | |||||||
| 43516 | CP 118 | Jump to Apply_Tumbling_Gravity_Move_Vertically if he is falling at full speed (the y velocity is 118 or more). | ||||||
| 43518 | JR NC,Apply_Tumbling_Gravity_Move_Vertically | |||||||
| Apply_Tumbling_Gravity_Increase_Velocity | 43520 | INC (IX+9) | Increase the y velocity (gravity pulls him down). | |||||
| 43523 | INC (IX+9) | Increase the y velocity again. | ||||||
| Apply_Tumbling_Gravity_Move_Vertically | 43526 | SRA A | Divide the y velocity by sixteen, keeping the sign. | |||||
| 43528 | SRA A | |||||||
| 43530 | SRA A | |||||||
| 43532 | SRA A | |||||||
| 43534 | ADD A,(IX+3) | Add the y position of Sabreman to get the new y position. | ||||||
| 43537 | LD (IX+3),A | Store the new y position of Sabreman. | ||||||
| 43540 | CP 159 | Jump to Handle_Sabreman_Falling_Above_Floor if he has not reached the bottom of the room (the y position is less than 159). | ||||||
| 43542 | JP C,Handle_Sabreman_Falling_Above_Floor | |||||||
| 43545 | EX AF,AF' | Mark both side walls as solid (bits 2 and 6 of the contact flags of Sabreman), keeping the new y position in AF'. | ||||||
| 43546 | LD A,68 | |||||||
| 43548 | OR (IX+11) | |||||||
| 43551 | LD (IX+11),A | |||||||
| 43554 | EX AF,AF' | |||||||
| 43555 | BIT 4,E | Jump to Apply_Tumbling_Gravity_Check_Bottom_Edge if the room has no floor (bit 4 of E is clear). | ||||||
| 43557 | JR Z,Apply_Tumbling_Gravity_Check_Bottom_Edge | |||||||
| 43559 | JP Handle_Sabreman_Falling_Reach_Floor | Jump to Handle_Sabreman_Falling_Reach_Floor to land on the floor. | ||||||
| Apply_Tumbling_Gravity_Check_Bottom_Edge | 43562 | CP 188 | Jump to Update_Object_Sprite if he has not reached the bottom of the room (the y position is less than 188). | |||||
| 43564 | JP C,Update_Object_Sprite | |||||||
| 43567 | INC (IX+4) | Increase the room y, to go to the room below. | ||||||
| 43570 | LD (IX+3),44 | Put him at the top of the room below (y position 44). | ||||||
| 43574 | CALL Draw_Room | Draw the new room. | ||||||
| 43577 | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
| Prev: 43247 | Up: Map | Next: 43580 |