![]() |
Routines |
| Prev: 46106 | Up: Map | Next: 47004 |
|
Used by the routine at Update_Berk_Controller.
Drive Berk from the control input bitmap at ControlInputBitmap: walk, turn, fire (pick up / put down / trap door offer) or idle scripts.
|
||||||||
|
Script lock and held-entity gate: ignore controls while a script is already running.
|
||||||||
| Update_Berk_ReadControls | 46144 | BIT 0,(IX+3) | Is Berk script-locked (bit 0 of IX+3)? If so, advance the current script at AdvanceScriptInstruction. | |||||
| 46148 | JP NZ,AdvanceScriptInstruction | |||||||
| 46151 | BIT 4,(IX+3) | Is Berk carrying / mid put-down (bit 4)? If not, read the controls at Berk_ReadControls_Dispatch. | ||||||
| 46155 | JR Z,Berk_ReadControls_Dispatch | |||||||
| 46157 | LD IY,(29356) | Point IY at the held entity (Pointer_CurrentEntity). | ||||||
| 46161 | BIT 3,(IY+2) | Is that held entity still marked "held" (bit 3)? If not, read the controls at Berk_ReadControls_Dispatch. | ||||||
| 46165 | JR Z,Berk_ReadControls_Dispatch | |||||||
| 46167 | LD HL,47665 | Point HL at Berk's "still holding" interaction script (47665). | ||||||
| 46170 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Read the control input bitmap (ControlInputBitmap) and branch on direction / fire.
|
||||||||
| Berk_ReadControls_Dispatch | 46173 | LD A,(62968) | Fetch the control input bitmap from ControlInputBitmap. | |||||
| 46176 | BIT 0,A | Has right been pressed? If so, jump to Berk_WalkRight to walk Berk right. | ||||||
| 46178 | JP NZ,Berk_WalkRight | |||||||
| 46181 | BIT 1,A | Has left been pressed? If so, jump to Berk_WalkLeft to walk Berk left. | ||||||
| 46183 | JP NZ,Berk_WalkLeft | |||||||
| 46186 | BIT 2,A | Has down (forward) been pressed? If so, jump to Berk_ReadControls_Down to move Berk forward. | ||||||
| 46188 | JP NZ,Berk_ReadControls_Down | |||||||
| 46191 | BIT 3,A | Has up (back) been pressed? If so, jump to Berk_ReadControls_Up to move Berk back / up. | ||||||
| 46193 | JP NZ,Berk_ReadControls_Up | |||||||
| 46196 | BIT 4,A | Has fire been pressed? If so, jump to Berk_ReadControls_OfferOrPutDown to pick up, put down or offer to the trap. | ||||||
| 46198 | JP NZ,Berk_ReadControls_OfferOrPutDown | |||||||
| 46201 | BIT 5,A | Has the secondary action key been pressed? If so, jump to Berk_ReadControls_SecondaryFire for the alternate fire path. | ||||||
| 46203 | JP NZ,Berk_ReadControls_SecondaryFire | |||||||
|
This entry point is used by the routines at Berk_Interact_With_Entity, Berk_Pick_Up_Entity and Berk_Put_Down_Entity.
Handle idle: clear the holding lock and pick a facing script.
|
||||||||
| Berk_ReadControls_Idle | 46206 | RES 3,(IX+3) | Reset bit 3 of flags byte 3 (IX+3). | |||||
| 46210 | BIT 1,(IX+3) | Is Berk facing left (bit 1)? If not, use the right-facing idle script at Berk_ReadControls_IdleFaceRight. | ||||||
| 46214 | JR Z,Berk_ReadControls_IdleFaceRight | |||||||
| 46216 | BIT 2,(IX+3) | Test the mid-interaction latch (bit 2). Clear that latch. If it was set, still use the right-facing idle script at Berk_ReadControls_IdleFaceRight. | ||||||
| 46220 | RES 2,(IX+3) | |||||||
| 46224 | JR NZ,Berk_ReadControls_IdleFaceRight | |||||||
| 46226 | BIT 3,(IX+9) | Is Berk's direction byte already "face left" bit 3? If not, continue the current script at AdvanceScriptInstruction. | ||||||
| 46230 | JP Z,AdvanceScriptInstruction | |||||||
| 46233 | LD HL,47565 | Point HL at Berk's left-facing idle script (47565). | ||||||
| 46236 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Idle facing right: run Berk's right-facing idle script at 47533 via ScriptInstruction.
|
||||||||
| Berk_ReadControls_IdleFaceRight | 46239 | LD HL,47533 | Point HL at Berk's right-facing idle script (47533). | |||||
| 46242 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Handle fire: pick up, put down or offer an item to the trap door.
|
||||||||
| Berk_ReadControls_OfferOrPutDown | 46245 | BIT 4,(IX+3) | Is bit 4 of flags byte 3 (IX+3) set? If not, fall back to idle at Berk_ReadControls_Idle. | |||||
| 46249 | JP Z,Berk_ReadControls_Idle | |||||||
| 46252 | LD A,(IX+6) | Load Berk's y-extent. | ||||||
| 46255 | CP 27 | Is Berk standing on the trap door row (y-extent 27)? If so, handle the offer at Berk_ReadControls_OfferOrPutDownOfferTrap. | ||||||
| 46257 | JR Z,Berk_ReadControls_OfferOrPutDownOfferTrap | |||||||
| 46259 | CP 35 | Is he still below the offer band (y-extent < 35)? If so, idle at Berk_ReadControls_Idle. | ||||||
| 46261 | JP C,Berk_ReadControls_Idle | |||||||
|
Facing-left trap offer: test the held entity with Adjust_CameraY, then offer or put down.
|
||||||||
| Berk_ReadControls_OfferOrPutDownOfferTrap | 46264 | BIT 1,(IX+3) | Is Berk facing left? If not, try the right-facing offer path at Berk_ReadControls_OfferOrPutDownFaceRight. | |||||
| 46268 | JR Z,Berk_ReadControls_OfferOrPutDownFaceRight | |||||||
| 46270 | PUSH IX | Stash IX on the stack. | ||||||
| 46272 | LD IX,(29356) | Switch IX to the held entity (Pointer_CurrentEntity). | ||||||
| 46276 | CALL Adjust_CameraY | Call Adjust_CameraY to test whether that entity can be offered to the trap. | ||||||
| 46279 | POP IX | Restore IX from the stack. | ||||||
| 46281 | JR C,Berk_ReadControls_OfferOrPutDownOfferScript | If the offer was rejected, skip ahead to the reject script at Berk_ReadControls_OfferOrPutDownOfferScript. | ||||||
| 46283 | CP 61 | Is Berk's y-extent exactly the trap mouth (61)? If not, use the put-down script at Berk_ReadControls_OfferOrPutDownPutDown. | ||||||
| 46285 | JR NZ,Berk_ReadControls_OfferOrPutDownPutDown | |||||||
| 46287 | LD A,(29363) | Fetch the game event flags (GameEventFlags). | ||||||
| 46290 | BIT 3,A | Has an object already been offered to the trap (bit 3)? If so, just put down at Berk_ReadControls_OfferOrPutDownPutDown. | ||||||
| 46292 | JR NZ,Berk_ReadControls_OfferOrPutDownPutDown | |||||||
| 46294 | SET 3,A | Mark "object offered to the trap" (set bit 3). | ||||||
| 46296 | LD (29363),A | Write the updated game event flags back to GameEventFlags. | ||||||
| 46299 | LD IY,(29356) | Point IY at the held entity (Pointer_CurrentEntity). | ||||||
| 46303 | SET 6,(IY+1) | Set that entity's can-fall latch (bit 6). | ||||||
| 46307 | LD (36233),IY | Remember it as the trap door entity pointer slot (36233). | ||||||
| 46311 | LD A,(IY+0) | Load the held entity's type. | ||||||
| 46314 | CP 1 | Is it type 1 (Berk's own slot)? If not, run the offer script at Berk_ReadControls_OfferOrPutDownOfferScript. | ||||||
| 46316 | JR NZ,Berk_ReadControls_OfferOrPutDownOfferScript | |||||||
| 46318 | LD A,8 | Load the Bad Tempered Thing "object offered" state (8). | ||||||
| 46320 | LD (29383),A | Store it at BadTemperedThingState. | ||||||
|
Run Berk's trap-offer script (47679) after accepting or rejecting the offer.
|
||||||||
| Berk_ReadControls_OfferOrPutDownOfferScript | 46323 | LD HL,47679 | Point HL at Berk's trap-offer script (47679). | |||||
| 46326 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Put the held item down with Berk's standard put-down script (Data_BerkPutDownScripts).
|
||||||||
| Berk_ReadControls_OfferOrPutDownPutDown | 46329 | LD HL,47525 | Point HL at Berk's standard put-down script (Data_BerkPutDownScripts). | |||||
| 46332 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Right-facing fire path: test a trap offer or fall back to idle / hold.
|
||||||||
| Berk_ReadControls_OfferOrPutDownFaceRight | 46335 | LD A,(IX+6) | Load Berk's y-extent. | |||||
| 46338 | PUSH IX | Stash IX on the stack. | ||||||
| 46340 | LD IX,(29356) | Switch IX to the held entity (Pointer_CurrentEntity). | ||||||
| 46344 | CP 27 | Is Berk on the trap door row (y-extent 27)? If so, handle that offer at Berk_ReadControls_OfferOrPutDownTrapRow. | ||||||
| 46346 | JR Z,Berk_ReadControls_OfferOrPutDownTrapRow | |||||||
| 46348 | CALL Test_EntityOverlap | Call Test_EntityOverlap to test a right-facing trap offer. | ||||||
| 46351 | POP IX | Restore IX from the stack. | ||||||
| 46353 | JR C,Berk_ReadControls_OfferOrPutDownHoldScript | If the offer was accepted, run the holding script at Berk_ReadControls_OfferOrPutDownHoldScript. | ||||||
| 46355 | CP 50 | Is Berk still below the mid-room band (y-extent < 50)? If so, idle at Berk_ReadControls_Idle. | ||||||
| 46357 | JP C,Berk_ReadControls_Idle | |||||||
|
Keep holding: run Berk's "still holding" script (47665).
|
||||||||
| Berk_ReadControls_OfferOrPutDownHoldScript | 46360 | LD HL,47665 | Point HL at Berk's "still holding" script (47665). | |||||
| 46363 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
On the trap door row facing right: validate the offer, then run the trap-row script.
|
||||||||
| Berk_ReadControls_OfferOrPutDownTrapRow | 46366 | CALL Test_EntityOverlap | Call Test_EntityOverlap to test the trap-row offer. | |||||
| 46369 | POP IX | Restore IX from the stack. | ||||||
| 46371 | CP 53 | Is Berk's y-extent exactly 53? If so, idle at Berk_ReadControls_Idle. | ||||||
| 46373 | JP Z,Berk_ReadControls_Idle | |||||||
| 46376 | LD HL,47719 | Point HL at Berk's trap-row interaction script (47719). | ||||||
| 46379 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Handle secondary fire: put down when carrying, otherwise idle.
|
||||||||
| Berk_ReadControls_SecondaryFire | 46382 | BIT 4,(IX+3) | Is bit 4 of flags byte 3 (IX+3) set? If not, idle at Berk_ReadControls_Idle. | |||||
| 46386 | JP Z,Berk_ReadControls_Idle | |||||||
| 46389 | BIT 1,(IX+3) | Is Berk facing left? If not, try the right-facing secondary path at Berk_ReadControls_SecondaryFireRight. | ||||||
| 46393 | JR Z,Berk_ReadControls_SecondaryFireRight | |||||||
| 46395 | LD HL,47525 | Point HL at Berk's standard put-down script (Data_BerkPutDownScripts). | ||||||
| 46398 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Right-facing secondary fire: validate the held entity with Test_EntityOverlap, then put it down.
|
||||||||
| Berk_ReadControls_SecondaryFireRight | 46401 | PUSH IX | Stash IX on the stack. | |||||
| 46403 | LD IX,(29356) | Switch IX to the held entity (Pointer_CurrentEntity). | ||||||
| 46407 | LD A,(IX+2) | Load the held entity's flags byte 2. | ||||||
| 46410 | AND %01000010 | Keep only bits 6 and 1 (can-fall / facing-left). | ||||||
| 46412 | JR Z,Berk_ReadControls_SecondaryFireAbort | If neither bit is set, abandon the secondary action at Berk_ReadControls_SecondaryFireAbort. | ||||||
| 46414 | CALL Test_EntityOverlap | Call Test_EntityOverlap to validate the put-down. | ||||||
| 46417 | JR NC,Berk_ReadControls_SecondaryFireAbort | If validation failed, abandon at Berk_ReadControls_SecondaryFireAbort. | ||||||
| 46419 | POP IX | Restore IX from the stack. | ||||||
| 46421 | LD HL,48033 | Point HL at Berk's alternate put-down script (48033). | ||||||
| 46424 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Abort secondary fire and return Berk to idle at Berk_ReadControls_Idle.
|
||||||||
| Berk_ReadControls_SecondaryFireAbort | 46427 | POP IX | Restore IX from the stack. | |||||
| 46429 | JP Berk_ReadControls_Idle | Idle at Berk_ReadControls_Idle. | ||||||
|
Handle up / back: turn or walk Berk toward the back of the room.
|
||||||||
| Berk_ReadControls_Up | 46432 | BIT 1,(IX+3) | Is Berk already facing left? If so, continue the up-walk at Berk_ReadControls_UpWalk. | |||||
| 46436 | JP NZ,Berk_ReadControls_UpWalk | |||||||
| 46439 | LD HL,47557 | Point HL at Berk's turn-to-face-back script (47557). | ||||||
| 46442 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Walk Berk back/up: probe the row above, clamp the camera, then branch on collision height.
|
||||||||
| Berk_ReadControls_UpWalk | 46445 | DEC (IX+5) | Probe one character above Berk's current y. | |||||
| 46448 | CALL Clamp_CameraPosition | Call Clamp_CameraPosition to clamp Camera Position. | ||||||
| 46451 | INC (IX+5) | Restore Berk's y after the camera clamp probe. | ||||||
| 46454 | JP C,Update_Berk_Movement_And_Script_PartA | If a hit/borrow was signaled, jump to Update_Berk_Movement_And_Script_PartA. | ||||||
| 46457 | CP 100 | Is A less than 100? If not, jump to Update_Berk_Movement_And_Script_PartB. | ||||||
| 46459 | JP NC,Update_Berk_Movement_And_Script_PartB | |||||||
| 46462 | CP 65 | Is A equal to 65? If so, jump to Update_Berk_Movement_And_Script_PartL. | ||||||
| 46464 | JP Z,Update_Berk_Movement_And_Script_PartL | |||||||
| 46467 | CP 50 | Is A less than 50? If not, jump to Berk_ReadControls_UpInteract. | ||||||
| 46469 | JR NC,Berk_ReadControls_UpInteract | |||||||
| 46471 | CP 30 | Is A less than 30? If not, jump to Berk_Put_Down_Entity_PublishScriptPos. | ||||||
| 46473 | JP NC,Berk_Put_Down_Entity_PublishScriptPos | |||||||
|
Up-path interact: offer to the trap, grab scenery, or hand off to Berk_Interact_With_Entity.
|
||||||||
| Berk_ReadControls_UpInteract | 46476 | BIT 4,(IX+3) | Is bit 4 of flags byte 3 (IX+3) set? If so, jump to Update_Berk_Movement_And_Script_PartI. | |||||
| 46480 | JP NZ,Update_Berk_Movement_And_Script_PartI | |||||||
| 46483 | LD IY,(29354) | Load IY with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| 46487 | LD A,(IY+0) | Load A with the referenced entity's entity type. | ||||||
| 46490 | CP 15 | Is referenced entity's entity type equal to 15? If so, jump to Update_Berk_Movement_And_Script_PartD. | ||||||
| 46492 | JP Z,Update_Berk_Movement_And_Script_PartD | |||||||
| 46495 | BIT 4,(IY+1) | Is bit 4 of the referenced entity's flags byte 1 set? If so, jump to Update_Berk_Movement_And_Script_PartD. | ||||||
| 46499 | JP NZ,Update_Berk_Movement_And_Script_PartD | |||||||
| 46502 | BIT 3,(IY+1) | Is bit 3 of the referenced entity's flags byte 1 set? If not, jump to Berk_ReadControls_UpPutDownScript. | ||||||
| 46506 | JR Z,Berk_ReadControls_UpPutDownScript | |||||||
| 46508 | CALL Berk_Interact_With_Entity | Call Berk_Interact_With_Entity to let Berk interact with an entity? If so, jump to Berk_ReadControls_DownBitTest? If not, jump to Berk_ReadControls_DownPartT. | ||||||
| 46511 | JP C,Berk_ReadControls_DownBitTest | |||||||
| 46514 | JP NZ,Berk_ReadControls_DownPartT | |||||||
| 46517 | PUSH IX | Stash IX on the stack. | ||||||
| 46519 | LD IX,(29354) | Load IX with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| 46523 | LD A,(IX+4) | Load A with the current entity's room index. | ||||||
| 46526 | OR A | Is the current entity's room index zero? If so, jump to Berk_ReadControls_UpRestore. | ||||||
| 46527 | JR Z,Berk_ReadControls_UpRestore | |||||||
| 46529 | CP 1 | Is the current entity's room index equal to 1? If not, jump to Berk_ReadControls_UpRoomCheck. | ||||||
| 46531 | JR NZ,Berk_ReadControls_UpRoomCheck | |||||||
| 46533 | LD (36233),IX | Store IX in the trap door entity pointer (36233). | ||||||
| 46537 | SET 6,(IX+1) | Set bit 6 of the current entity's flags byte 1. | ||||||
| 46541 | LD HL,29363 | Point HL at the game event flags (GameEventFlags). | ||||||
| 46544 | SET 3,(HL) | Set "object has been offered to the trap" (bit 3 of GameEventFlags). | ||||||
| 46546 | JR Berk_ReadControls_UpGrabEntity | Jump to Berk_ReadControls_UpGrabEntity to store Berk's extra state. | ||||||
|
Room-specific up checks: camera tweak, trap mouth (61), or special X band (104).
|
||||||||
| Berk_ReadControls_UpRoomCheck | 46548 | CALL Adjust_CameraX | Call Adjust_CameraX to adjust Camera X? If so, jump to Berk_ReadControls_UpGrabEntity. | |||||
| 46551 | JR C,Berk_ReadControls_UpGrabEntity | |||||||
| 46553 | CP 61 | Is the current entity's room index equal to 61? If so, jump to Berk_ReadControls_UpGrabEntity. | ||||||
| 46555 | JR Z,Berk_ReadControls_UpGrabEntity | |||||||
| 46557 | CP 104 | Is the current entity's room index equal to 104? If not, jump to Berk_ReadControls_UpRestore. | ||||||
| 46559 | JR NZ,Berk_ReadControls_UpRestore | |||||||
| 46561 | LD A,(29363) | Load A with the game event flags (GameEventFlags). | ||||||
| 46564 | BIT 3,A | Is bit 3 of game event flags set? If so, jump to Berk_ReadControls_UpRestore. | ||||||
| 46566 | JR NZ,Berk_ReadControls_UpRestore | |||||||
| 46568 | LD A,(IX+7) | Load A with the current entity's x-coordinate. | ||||||
| 46571 | CP 152 | Is the current entity's x-coordinate less than 152? If so, jump to Berk_ReadControls_UpRestore. | ||||||
| 46573 | JR C,Berk_ReadControls_UpRestore | |||||||
| 46575 | LD A,157 | Load A with 157. | ||||||
| 46577 | CP (IX+8) | Does A match this entity's x-extent? If not, jump to Berk_ReadControls_UpGrabEntity. | ||||||
| 46580 | JR NC,Berk_ReadControls_UpGrabEntity | |||||||
|
Failed up-path grab: restore Berk's entity pointer and fall into the put-down script.
|
||||||||
| Berk_ReadControls_UpRestore | 46582 | POP IX | Restore IX from the stack. | |||||
|
Run a left-facing idle/put-down fragment (47565) when the up grab is rejected.
|
||||||||
| Berk_ReadControls_UpPutDownScript | 46584 | LD HL,47565 | Point HL at a Berk put-down script fragment (47565). | |||||
| 46587 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Commit the grabbed entity into Berk's held state and launch script BerkPutDownScript_Bit3Set.
|
||||||||
| Berk_ReadControls_UpGrabEntity | 46590 | PUSH IX | Stash IX on the stack. | |||||
| 46592 | POP BC | Restore BC and IX from the stack. | ||||||
| 46593 | POP IX | |||||||
| 46595 | LD (IX+12),C | Store C in the current entity's extra state. | ||||||
| 46598 | LD (IX+13),B | Store B in the current entity's extra state. | ||||||
| 46601 | SET 3,(IX+3) | Set bit 3 of the current entity's flags byte 3. | ||||||
| 46605 | RES 2,(IX+3) | Reset bit 2 of the current entity's flags byte 3. | ||||||
| 46609 | LD HL,47803 | Point HL at Berk control/put-down script data (BerkPutDownScript_Bit3Set). | ||||||
| 46612 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Camera-clamp hit on up: drop/control put-down via BerkPutDownScript_Drop, or keep the current script.
|
||||||||
| Update_Berk_Movement_And_Script_PartA | 46615 | BIT 3,(IX+9) | Is bit 3 of the current entity's direction / state set? If so, jump to AdvanceScriptInstruction. | |||||
| 46619 | JP NZ,AdvanceScriptInstruction | |||||||
| 46622 | LD HL,47759 | Point HL at Berk control/put-down script data (BerkPutDownScript_Drop). | ||||||
| 46625 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Up-path collision: let Berk_Interact_With_Entity decide interact vs the shared down-branch at Berk_ReadControls_DownPartT.
|
||||||||
| Update_Berk_Movement_And_Script_PartB | 46628 | CALL Berk_Interact_With_Entity | Call Berk_Interact_With_Entity to let Berk interact with an entity? If so, jump to Update_Berk_Movement_And_Script_PartC? If not, jump to Berk_ReadControls_DownPartT. | |||||
| 46631 | JR Z,Update_Berk_Movement_And_Script_PartC | |||||||
| 46633 | JP NC,Berk_ReadControls_DownPartT | |||||||
| 46636 | JP Berk_ReadControls_DownBitTest | Jump to Berk_ReadControls_DownBitTest. | ||||||
|
Special room interact: refresh the camera origin from Berk movement data and resume.
|
||||||||
| Update_Berk_Movement_And_Script_PartC | 46639 | LD A,C | Copy the saved count/flag from C into A. | |||||
| 46640 | CP 102 | Is 157 equal to 102? If not, jump to Update_Berk_Movement_And_Script_PartA. | ||||||
| 46642 | JR NZ,Update_Berk_Movement_And_Script_PartA | |||||||
| 46644 | PUSH HL | Stash HL on the stack. | ||||||
| 46645 | LD HL,46653 | Point HL at Berk movement script data (46653). | ||||||
| 46648 | LD A,160 | Load A with 160. | ||||||
| 46650 | JP Berk_ReadControls_DownCameraCopy | Jump to Berk_ReadControls_DownCameraCopy to refresh the camera room origin. | ||||||
| 46653 | INC B | Advance the layout-table index in B. | ||||||
| 46654 | LD HL,41511 | Point HL at graphic layout/table 41511. | ||||||
| 46657 | AND A | Test whether 160 is zero (clear carry). | ||||||
|
Plant-pot / type-15 up interact: retarget layout GraphicLayout_EyeballPlantLevel4 and update plant pots.
|
||||||||
| Update_Berk_Movement_And_Script_PartD | 46658 | CALL Berk_Interact_With_Entity | Call Berk_Interact_With_Entity to let Berk interact with an entity? If so, jump to Berk_ReadControls_DownBitTest? If not, jump to Berk_ReadControls_DownPartT. | |||||
| 46661 | JP C,Berk_ReadControls_DownBitTest | |||||||
| 46664 | JP NZ,Berk_ReadControls_DownPartT | |||||||
| 46667 | LD B,(IX+6) | Load B with the current entity's y-extent. | ||||||
| 46670 | DEC B | Step the loop counter in B back by one. | ||||||
| 46671 | LD IY,(29354) | Load IY with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| 46675 | LD A,(IY+0) | Load A with the referenced entity's entity type. | ||||||
| 46678 | CP 15 | Is referenced entity's entity type equal to 15? If not, jump to Update_Berk_Movement_And_Script_PartE. | ||||||
| 46680 | JR NZ,Update_Berk_Movement_And_Script_PartE | |||||||
| 46682 | LD A,(IY+9) | Load A with the referenced entity's direction / state. | ||||||
| 46685 | CP 7 | Is referenced entity's direction / state equal to 7? If not, jump to Berk_ReadControls_UpPutDownScript. | ||||||
| 46687 | JP NZ,Berk_ReadControls_UpPutDownScript | |||||||
| 46690 | LD (IY+9),11 | Write 11 to the referenced entity's direction / state. | ||||||
| 46694 | LD BC,41141 | Load BC with graphic layout address GraphicLayout_EyeballPlantLevel4. | ||||||
| 46697 | LD (IY+10),C | Set the low byte of the referenced entity's graphic layout address from C. | ||||||
| 46700 | LD (IY+11),B | Set the high byte of the referenced entity's graphic layout address from B. | ||||||
| 46703 | PUSH IX | Stash IX on the stack. | ||||||
| 46705 | LD IX,(29354) | Load IX with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| 46709 | LD C,6 | Load C with 6 as an entity/loop count. | ||||||
| 46711 | CALL Update_Plant_Pots | Call Update_Plant_Pots to update Plant Pots. | ||||||
| 46714 | POP IX | Restore IX from the stack. | ||||||
|
Adopt the collided entity as held and clear any pending trap-offer flag.
|
||||||||
| Update_Berk_Movement_And_Script_PartE | 46716 | LD (29356),IY | Store IY in the current-entity pointer (Pointer_CurrentEntity). | |||||
| 46720 | BIT 6,(IY+1) | Is bit 6 of the referenced entity's flags byte 1 set? If not, jump to Update_Berk_Movement_And_Script_PartF. | ||||||
| 46724 | JR Z,Update_Berk_Movement_And_Script_PartF | |||||||
| 46726 | RES 6,(IY+1) | Reset bit 6 of the referenced entity's flags byte 1. | ||||||
| 46730 | LD HL,29363 | Point HL at the game event flags (GameEventFlags). | ||||||
| 46733 | RES 3,(HL) | Clear "object has been offered to the trap" (bit 3 of GameEventFlags). | ||||||
|
Choose a pick-up/put-down script from the collided entity's y-extent vs Berk.
|
||||||||
| Update_Berk_Movement_And_Script_PartF | 46735 | LD A,(IY+6) | Load A with the referenced entity's y-extent. | |||||
| 46738 | CP (IX+5) | Does A match this entity's y-coordinate? If so, jump to Update_Berk_Movement_And_Script_PartH. | ||||||
| 46741 | JR C,Update_Berk_Movement_And_Script_PartH | |||||||
| 46743 | CP B | Does the referenced entity's y-extent equal B? If so, jump to Update_Berk_Movement_And_Script_PartG. | ||||||
| 46744 | JR Z,Update_Berk_Movement_And_Script_PartG | |||||||
| 46746 | LD HL,47623 | Point HL at Berk control/put-down script data (47623). | ||||||
| 46749 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Run put-down script 47595 when y-extents match the stepped collision band.
|
||||||||
| Update_Berk_Movement_And_Script_PartG | 46752 | LD HL,47595 | Point HL at Berk control/put-down script data (47595). | |||||
| 46755 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Run put-down script 47609 when the collided entity sits on Berk's own y.
|
||||||||
| Update_Berk_Movement_And_Script_PartH | 46758 | LD HL,47609 | Point HL at Berk control/put-down script data (47609). | |||||
| 46761 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Carrying-flag up path: require a latch-set collidee, with a type-21 special case.
|
||||||||
| Update_Berk_Movement_And_Script_PartI | 46764 | LD IY,(29354) | Load IY with the last-collided entity pointer (Pointer_LastCollidedEntity). | |||||
| 46768 | LD A,(IY+0) | Load A with the referenced entity's entity type. | ||||||
| 46771 | BIT 2,(IY+2) | Is bit 2 of the referenced entity's flags byte 2 set? If not, jump to Berk_ReadControls_UpPutDownScript. | ||||||
| 46775 | JP Z,Berk_ReadControls_UpPutDownScript | |||||||
| 46778 | CP 21 | Is referenced entity's entity type equal to 21? If not, jump to Update_Berk_Movement_And_Script_PartJ. | ||||||
| 46780 | JR NZ,Update_Berk_Movement_And_Script_PartJ | |||||||
| 46782 | LD BC,(29356) | Load BC with the current-entity pointer (Pointer_CurrentEntity). | ||||||
| 46786 | LD A,(BC) | Fetch a byte through the pointer in BC. | ||||||
| 46787 | CP 4 | Is referenced entity's entity type equal to 4? If not, jump to Berk_ReadControls_UpPutDownScript. | ||||||
| 46789 | JP NZ,Berk_ReadControls_UpPutDownScript | |||||||
|
|
||||||||
| Update_Berk_Movement_And_Script_PartJ | 46792 | CALL Berk_Interact_With_Entity | Call Berk_Interact_With_Entity to let Berk interact with an entity? If so, jump to Berk_ReadControls_DownBitTest? If not, jump to Berk_ReadControls_DownPartT. | |||||
| 46795 | JP C,Berk_ReadControls_DownBitTest | |||||||
| 46798 | JP NZ,Berk_ReadControls_DownPartT | |||||||
| 46801 | LD C,(IX+5) | Load C with the current entity's y-coordinate. | ||||||
| 46804 | LD A,(IY+5) | Load A with the referenced entity's y-coordinate. | ||||||
| 46807 | DEC A | Step referenced entity's y-coordinate back by one. | ||||||
| 46808 | LD (29417),A | Set held-entity y-extent (HeldEntityYExtent). | ||||||
| 46811 | CP C | Does the referenced entity's y equal C? If so, jump to Update_Berk_Movement_And_Script_PartK. | ||||||
| 46812 | JR C,Update_Berk_Movement_And_Script_PartK | |||||||
| 46814 | LD HL,47707 | Point HL at Berk control/put-down script data (47707). | ||||||
| 46817 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Run put-down script 47693 once the held entity's y matches Berk.
|
||||||||
| Update_Berk_Movement_And_Script_PartK | 46820 | LD HL,47693 | Point HL at Berk control/put-down script data (47693). | |||||
| 46823 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Flags-65 up interact: hand off to Berk_Interact_With_Entity, then run script 47951.
|
||||||||
| Update_Berk_Movement_And_Script_PartL | 46826 | CALL Berk_Interact_With_Entity | Call Berk_Interact_With_Entity to let Berk interact with an entity? If so, jump to Berk_ReadControls_DownBitTest? If not, jump to Berk_ReadControls_DownPartT. | |||||
| 46829 | JP C,Berk_ReadControls_DownBitTest | |||||||
| 46832 | JP NZ,Berk_ReadControls_DownPartT | |||||||
| 46835 | LD HL,47951 | Point HL at Berk control/put-down script data (47951). | ||||||
| 46838 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Handle down / forward: turn or walk Berk toward the front of the room.
|
||||||||
| Berk_ReadControls_Down | 46841 | BIT 1,(IX+3) | Is the current entity facing left (bit 1 of IX+3)? If not, jump to Berk_ReadControls_DownWalk. | |||||
| 46845 | JP Z,Berk_ReadControls_DownWalk | |||||||
| 46848 | LD HL,47525 | Point HL at Berk put-down script data (Data_BerkPutDownScripts). | ||||||
| 46851 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Walk Berk forward/down: depth-overlap test, then branch on collidee height and flags.
|
||||||||
| Berk_ReadControls_DownWalk | 46854 | CALL Test_EntityOverlap_AtDepth | Call Test_EntityOverlap_AtDepth to test Entity Overlap At Depth? If so, jump to Berk_ReadControls_DownScript. | |||||
| 46857 | JR C,Berk_ReadControls_DownScript | |||||||
| 46859 | CP 100 | Is referenced entity's y-coordinate less than 100? If not, jump to Berk_ReadControls_DownInteract. | ||||||
| 46861 | JP NC,Berk_ReadControls_DownInteract | |||||||
| 46864 | CP 65 | Is referenced entity's y-coordinate equal to 65? If so, jump to Berk_ReadControls_DownPartW. | ||||||
| 46866 | JP Z,Berk_ReadControls_DownPartW | |||||||
| 46869 | CP 50 | Is referenced entity's y-coordinate less than 50? If not, jump to Berk_ReadControls_Idle. | ||||||
| 46871 | JP NC,Berk_ReadControls_Idle | |||||||
| 46874 | CP 30 | Is referenced entity's y-coordinate less than 30? If not, jump to Berk_Put_Down_Entity_PublishScriptPos. | ||||||
| 46876 | JP NC,Berk_Put_Down_Entity_PublishScriptPos | |||||||
| 46879 | BIT 4,(IX+3) | Is bit 4 of flags byte 3 (IX+3) set? If so, jump to Berk_ReadControls_Idle. | ||||||
| 46883 | JP NZ,Berk_ReadControls_Idle | |||||||
| 46886 | LD BC,(29354) | Load BC with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| 46890 | INC BC | Advance the counter/pointer in BC by one. | ||||||
| 46891 | LD A,(BC) | Fetch a byte through the pointer in BC. | ||||||
| 46892 | BIT 4,A | Is bit 4 of referenced entity's y-coordinate set? If so, jump to Berk_ReadControls_DownPartU. | ||||||
| 46894 | JP NZ,Berk_ReadControls_DownPartU | |||||||
| 46897 | BIT 3,A | Is bit 3 of referenced entity's y-coordinate set? If not, jump to Berk_ReadControls_Idle. | ||||||
| 46899 | JP Z,Berk_ReadControls_Idle | |||||||
| 46902 | CALL Berk_Interact_With_Entity | Call Berk_Interact_With_Entity to let Berk interact with an entity? If so, jump to Berk_ReadControls_DownBitTest? If not, jump to Berk_ReadControls_DownPartT. | ||||||
| 46905 | JR C,Berk_ReadControls_DownBitTest | |||||||
| 46907 | JP NZ,Berk_ReadControls_DownPartT | |||||||
| 46910 | PUSH IX | Stash IX on the stack. | ||||||
| 46912 | LD IX,(29354) | Load IX with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| 46916 | LD A,(IX+4) | Load A with the current entity's room index. | ||||||
| 46919 | CP 4 | Is the current entity's room index less than 4? If not, jump to Berk_ReadControls_DownAbort. | ||||||
| 46921 | JR NC,Berk_ReadControls_DownAbort | |||||||
| 46923 | CALL Test_EntityOverlap_AtDepth | Call Test_EntityOverlap_AtDepth to test Entity Overlap At Depth? If so, jump to Berk_ReadControls_DownGrab. | ||||||
| 46926 | JR C,Berk_ReadControls_DownGrab | |||||||
|
Abort the down-path grab and return Berk to idle at Berk_ReadControls_Idle.
|
||||||||
| Berk_ReadControls_DownAbort | 46928 | POP IX | Restore IX from the stack. | |||||
| 46930 | JP Berk_ReadControls_Idle | Jump to Berk_ReadControls_Idle to resume Berk's controller. | ||||||
|
Mark the collided entity held and fall into the down put-down script.
|
||||||||
| Berk_ReadControls_DownGrab | 46933 | PUSH IX | Stash IX on the stack. | |||||
| 46935 | POP BC | Restore BC and IX from the stack. | ||||||
| 46936 | POP IX | |||||||
| 46938 | LD (IX+12),C | Store C in the current entity's extra state. | ||||||
| 46941 | LD (IX+13),B | Store B in the current entity's extra state. | ||||||
| 46944 | SET 3,(IX+3) | Set bit 3 of the current entity's flags byte 3. | ||||||
|
Down put-down: continue the active script, or launch BerkPutDownScript_DownControl.
|
||||||||
| Berk_ReadControls_DownScript | 46948 | BIT 2,(IX+9) | Is bit 2 of the current entity's direction / state set? If so, jump to AdvanceScriptInstruction. | |||||
| 46952 | JP NZ,AdvanceScriptInstruction | |||||||
| 46955 | LD HL,47781 | Point HL at Berk control/put-down script data (BerkPutDownScript_DownControl). | ||||||
| 46958 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Deep down-interact: call Berk_Interact_With_Entity, then maybe retarget the camera room origin.
|
||||||||
| Berk_ReadControls_DownInteract | 46961 | CALL Berk_Interact_With_Entity | Call Berk_Interact_With_Entity to let Berk interact with an entity? If not, jump to Berk_ReadControls_DownBranch. | |||||
| 46964 | JR NZ,Berk_ReadControls_DownBranch | |||||||
| 46966 | LD A,C | Copy the saved count/flag from C into A. | ||||||
| 46967 | CP 101 | Is the current entity's room index equal to 101? If not, jump to Berk_ReadControls_DownScript. | ||||||
| 46969 | JR NZ,Berk_ReadControls_DownScript | |||||||
| 46971 | PUSH HL | Stash HL on the stack. | ||||||
| 46972 | LD HL,47004 | Point HL at Berk movement script data (Data_BerkMovementScripts). | ||||||
| 46975 | LD A,224 | Load A with 224. | ||||||
|
Publish a new camera room-origin and copy follow fields, then resume idle.
|
||||||||
| Berk_ReadControls_DownCameraCopy | 46977 | LD E,A | Keep 224 in E for later. | |||||
| 46978 | ADD A,31 | Add 31 to A (step down one screen row in the attribute map). | ||||||
| 46980 | LD D,A | Keep 224 in D for later. | ||||||
| 46981 | LD (29435),DE | Store DE in the camera room-origin pointer (Pointer_CameraRoomOrigin). | ||||||
| 46985 | LD DE,37023 | Point DE at camera-follow entity fields (37023). | ||||||
| 46988 | LD BC,5 | Load BC with 0005 as a short copy length. | ||||||
| 46991 | LDIR | Copy the block at HL to DE. | ||||||
| 46993 | POP HL | Restore HL from the stack. | ||||||
| 46994 | BIT 4,(IX+3) | Is bit 4 of flags byte 3 (IX+3) set? If so, call ScriptRoutine_PutDownCarried_PlaceHeldFromBerk. | ||||||
| 46998 | CALL NZ,ScriptRoutine_PutDownCarried_PlaceHeldFromBerk | |||||||
| 47001 | JP Berk_ReadControls_Idle | Jump to Berk_ReadControls_Idle to resume Berk's controller. | ||||||
| Prev: 46106 | Up: Map | Next: 47004 |