![]() |
Routines |
| Prev: B41A | Up: Map | Next: B79C |
|
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 | B440 | BIT 0,(IX+$03) | Is Berk script-locked (bit 00 of IX+03)? If so, advance the current script at AdvanceScriptInstruction. | |||||
| B444 | JP NZ,AdvanceScriptInstruction | |||||||
| B447 | BIT 4,(IX+$03) | Is Berk carrying / mid put-down (bit 04)? If not, read the controls at Berk_ReadControls_Dispatch. | ||||||
| B44B | JR Z,Berk_ReadControls_Dispatch | |||||||
| B44D | LD IY,($72AC) | Point IY at the held entity (Pointer_CurrentEntity). | ||||||
| B451 | BIT 3,(IY+$02) | Is that held entity still marked "held" (bit 03)? If not, read the controls at Berk_ReadControls_Dispatch. | ||||||
| B455 | JR Z,Berk_ReadControls_Dispatch | |||||||
| B457 | LD HL,$BA31 | Point HL at Berk's "still holding" interaction script (BA31). | ||||||
| B45A | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Read the control input bitmap (ControlInputBitmap) and branch on direction / fire.
|
||||||||
| Berk_ReadControls_Dispatch | B45D | LD A,($F5F8) | Fetch the control input bitmap from ControlInputBitmap. | |||||
| B460 | BIT 0,A | Has right been pressed? If so, jump to Berk_WalkRight to walk Berk right. | ||||||
| B462 | JP NZ,Berk_WalkRight | |||||||
| B465 | BIT 1,A | Has left been pressed? If so, jump to Berk_WalkLeft to walk Berk left. | ||||||
| B467 | JP NZ,Berk_WalkLeft | |||||||
| B46A | BIT 2,A | Has down (forward) been pressed? If so, jump to Berk_ReadControls_Down to move Berk forward. | ||||||
| B46C | JP NZ,Berk_ReadControls_Down | |||||||
| B46F | BIT 3,A | Has up (back) been pressed? If so, jump to Berk_ReadControls_Up to move Berk back / up. | ||||||
| B471 | JP NZ,Berk_ReadControls_Up | |||||||
| B474 | BIT 4,A | Has fire been pressed? If so, jump to Berk_ReadControls_OfferOrPutDown to pick up, put down or offer to the trap. | ||||||
| B476 | JP NZ,Berk_ReadControls_OfferOrPutDown | |||||||
| B479 | BIT 5,A | Has the secondary action key been pressed? If so, jump to Berk_ReadControls_SecondaryFire for the alternate fire path. | ||||||
| B47B | 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 | B47E | RES 3,(IX+$03) | Reset bit 03 of flags byte 3 (IX+03). | |||||
| B482 | BIT 1,(IX+$03) | Is Berk facing left (bit 01)? If not, use the right-facing idle script at Berk_ReadControls_IdleFaceRight. | ||||||
| B486 | JR Z,Berk_ReadControls_IdleFaceRight | |||||||
| B488 | BIT 2,(IX+$03) | Test the mid-interaction latch (bit 02). Clear that latch. If it was set, still use the right-facing idle script at Berk_ReadControls_IdleFaceRight. | ||||||
| B48C | RES 2,(IX+$03) | |||||||
| B490 | JR NZ,Berk_ReadControls_IdleFaceRight | |||||||
| B492 | BIT 3,(IX+$09) | Is Berk's direction byte already "face left" bit 03? If not, continue the current script at AdvanceScriptInstruction. | ||||||
| B496 | JP Z,AdvanceScriptInstruction | |||||||
| B499 | LD HL,$B9CD | Point HL at Berk's left-facing idle script (B9CD). | ||||||
| B49C | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Idle facing right: run Berk's right-facing idle script at B9AD via ScriptInstruction.
|
||||||||
| Berk_ReadControls_IdleFaceRight | B49F | LD HL,$B9AD | Point HL at Berk's right-facing idle script (B9AD). | |||||
| B4A2 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Handle fire: pick up, put down or offer an item to the trap door.
|
||||||||
| Berk_ReadControls_OfferOrPutDown | B4A5 | BIT 4,(IX+$03) | Is bit 04 of flags byte 3 (IX+03) set? If not, fall back to idle at Berk_ReadControls_Idle. | |||||
| B4A9 | JP Z,Berk_ReadControls_Idle | |||||||
| B4AC | LD A,(IX+$06) | Load Berk's y-extent. | ||||||
| B4AF | CP $1B | Is Berk standing on the trap door row (y-extent 1B)? If so, handle the offer at Berk_ReadControls_OfferOrPutDownOfferTrap. | ||||||
| B4B1 | JR Z,Berk_ReadControls_OfferOrPutDownOfferTrap | |||||||
| B4B3 | CP $23 | Is he still below the offer band (y-extent < 23)? If so, idle at Berk_ReadControls_Idle. | ||||||
| B4B5 | JP C,Berk_ReadControls_Idle | |||||||
|
Facing-left trap offer: test the held entity with Adjust_CameraY, then offer or put down.
|
||||||||
| Berk_ReadControls_OfferOrPutDownOfferTrap | B4B8 | BIT 1,(IX+$03) | Is Berk facing left? If not, try the right-facing offer path at Berk_ReadControls_OfferOrPutDownFaceRight. | |||||
| B4BC | JR Z,Berk_ReadControls_OfferOrPutDownFaceRight | |||||||
| B4BE | PUSH IX | Stash IX on the stack. | ||||||
| B4C0 | LD IX,($72AC) | Switch IX to the held entity (Pointer_CurrentEntity). | ||||||
| B4C4 | CALL Adjust_CameraY | Call Adjust_CameraY to test whether that entity can be offered to the trap. | ||||||
| B4C7 | POP IX | Restore IX from the stack. | ||||||
| B4C9 | JR C,Berk_ReadControls_OfferOrPutDownOfferScript | If the offer was rejected, skip ahead to the reject script at Berk_ReadControls_OfferOrPutDownOfferScript. | ||||||
| B4CB | CP $3D | Is Berk's y-extent exactly the trap mouth (3D)? If not, use the put-down script at Berk_ReadControls_OfferOrPutDownPutDown. | ||||||
| B4CD | JR NZ,Berk_ReadControls_OfferOrPutDownPutDown | |||||||
| B4CF | LD A,($72B3) | Fetch the game event flags (GameEventFlags). | ||||||
| B4D2 | BIT 3,A | Has an object already been offered to the trap (bit 03)? If so, just put down at Berk_ReadControls_OfferOrPutDownPutDown. | ||||||
| B4D4 | JR NZ,Berk_ReadControls_OfferOrPutDownPutDown | |||||||
| B4D6 | SET 3,A | Mark "object offered to the trap" (set bit 03). | ||||||
| B4D8 | LD ($72B3),A | Write the updated game event flags back to GameEventFlags. | ||||||
| B4DB | LD IY,($72AC) | Point IY at the held entity (Pointer_CurrentEntity). | ||||||
| B4DF | SET 6,(IY+$01) | Set that entity's can-fall latch (bit 06). | ||||||
| B4E3 | LD ($8D89),IY | Remember it as the trap door entity pointer slot (8D89). | ||||||
| B4E7 | LD A,(IY+$00) | Load the held entity's type. | ||||||
| B4EA | CP $01 | Is it type 01 (Berk's own slot)? If not, run the offer script at Berk_ReadControls_OfferOrPutDownOfferScript. | ||||||
| B4EC | JR NZ,Berk_ReadControls_OfferOrPutDownOfferScript | |||||||
| B4EE | LD A,$08 | Load the Bad Tempered Thing "object offered" state (08). | ||||||
| B4F0 | LD ($72C7),A | Store it at BadTemperedThingState. | ||||||
|
Run Berk's trap-offer script (BA3F) after accepting or rejecting the offer.
|
||||||||
| Berk_ReadControls_OfferOrPutDownOfferScript | B4F3 | LD HL,$BA3F | Point HL at Berk's trap-offer script (BA3F). | |||||
| B4F6 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Put the held item down with Berk's standard put-down script (Data_BerkPutDownScripts).
|
||||||||
| Berk_ReadControls_OfferOrPutDownPutDown | B4F9 | LD HL,$B9A5 | Point HL at Berk's standard put-down script (Data_BerkPutDownScripts). | |||||
| B4FC | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Right-facing fire path: test a trap offer or fall back to idle / hold.
|
||||||||
| Berk_ReadControls_OfferOrPutDownFaceRight | B4FF | LD A,(IX+$06) | Load Berk's y-extent. | |||||
| B502 | PUSH IX | Stash IX on the stack. | ||||||
| B504 | LD IX,($72AC) | Switch IX to the held entity (Pointer_CurrentEntity). | ||||||
| B508 | CP $1B | Is Berk on the trap door row (y-extent 1B)? If so, handle that offer at Berk_ReadControls_OfferOrPutDownTrapRow. | ||||||
| B50A | JR Z,Berk_ReadControls_OfferOrPutDownTrapRow | |||||||
| B50C | CALL Test_EntityOverlap | Call Test_EntityOverlap to test a right-facing trap offer. | ||||||
| B50F | POP IX | Restore IX from the stack. | ||||||
| B511 | JR C,Berk_ReadControls_OfferOrPutDownHoldScript | If the offer was accepted, run the holding script at Berk_ReadControls_OfferOrPutDownHoldScript. | ||||||
| B513 | CP $32 | Is Berk still below the mid-room band (y-extent < 32)? If so, idle at Berk_ReadControls_Idle. | ||||||
| B515 | JP C,Berk_ReadControls_Idle | |||||||
|
Keep holding: run Berk's "still holding" script (BA31).
|
||||||||
| Berk_ReadControls_OfferOrPutDownHoldScript | B518 | LD HL,$BA31 | Point HL at Berk's "still holding" script (BA31). | |||||
| B51B | 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 | B51E | CALL Test_EntityOverlap | Call Test_EntityOverlap to test the trap-row offer. | |||||
| B521 | POP IX | Restore IX from the stack. | ||||||
| B523 | CP $35 | Is Berk's y-extent exactly 35? If so, idle at Berk_ReadControls_Idle. | ||||||
| B525 | JP Z,Berk_ReadControls_Idle | |||||||
| B528 | LD HL,$BA67 | Point HL at Berk's trap-row interaction script (BA67). | ||||||
| B52B | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Handle secondary fire: put down when carrying, otherwise idle.
|
||||||||
| Berk_ReadControls_SecondaryFire | B52E | BIT 4,(IX+$03) | Is bit 04 of flags byte 3 (IX+03) set? If not, idle at Berk_ReadControls_Idle. | |||||
| B532 | JP Z,Berk_ReadControls_Idle | |||||||
| B535 | BIT 1,(IX+$03) | Is Berk facing left? If not, try the right-facing secondary path at Berk_ReadControls_SecondaryFireRight. | ||||||
| B539 | JR Z,Berk_ReadControls_SecondaryFireRight | |||||||
| B53B | LD HL,$B9A5 | Point HL at Berk's standard put-down script (Data_BerkPutDownScripts). | ||||||
| B53E | 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 | B541 | PUSH IX | Stash IX on the stack. | |||||
| B543 | LD IX,($72AC) | Switch IX to the held entity (Pointer_CurrentEntity). | ||||||
| B547 | LD A,(IX+$02) | Load the held entity's flags byte 2. | ||||||
| B54A | AND %01000010 | Keep only bits 06 and 01 (can-fall / facing-left). | ||||||
| B54C | JR Z,Berk_ReadControls_SecondaryFireAbort | If neither bit is set, abandon the secondary action at Berk_ReadControls_SecondaryFireAbort. | ||||||
| B54E | CALL Test_EntityOverlap | Call Test_EntityOverlap to validate the put-down. | ||||||
| B551 | JR NC,Berk_ReadControls_SecondaryFireAbort | If validation failed, abandon at Berk_ReadControls_SecondaryFireAbort. | ||||||
| B553 | POP IX | Restore IX from the stack. | ||||||
| B555 | LD HL,$BBA1 | Point HL at Berk's alternate put-down script (BBA1). | ||||||
| B558 | JP ScriptInstruction | Run that script via ScriptInstruction. | ||||||
|
Abort secondary fire and return Berk to idle at Berk_ReadControls_Idle.
|
||||||||
| Berk_ReadControls_SecondaryFireAbort | B55B | POP IX | Restore IX from the stack. | |||||
| B55D | 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 | B560 | BIT 1,(IX+$03) | Is Berk already facing left? If so, continue the up-walk at Berk_ReadControls_UpWalk. | |||||
| B564 | JP NZ,Berk_ReadControls_UpWalk | |||||||
| B567 | LD HL,$B9C5 | Point HL at Berk's turn-to-face-back script (B9C5). | ||||||
| B56A | 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 | B56D | DEC (IX+$05) | Probe one character above Berk's current y. | |||||
| B570 | CALL Clamp_CameraPosition | Call Clamp_CameraPosition to clamp Camera Position. | ||||||
| B573 | INC (IX+$05) | Restore Berk's y after the camera clamp probe. | ||||||
| B576 | JP C,Update_Berk_Movement_And_Script_PartA | If a hit/borrow was signaled, jump to Update_Berk_Movement_And_Script_PartA. | ||||||
| B579 | CP $64 | Is A less than 64? If not, jump to Update_Berk_Movement_And_Script_PartB. | ||||||
| B57B | JP NC,Update_Berk_Movement_And_Script_PartB | |||||||
| B57E | CP $41 | Is A equal to 41? If so, jump to Update_Berk_Movement_And_Script_PartL. | ||||||
| B580 | JP Z,Update_Berk_Movement_And_Script_PartL | |||||||
| B583 | CP $32 | Is A less than 32? If not, jump to Berk_ReadControls_UpInteract. | ||||||
| B585 | JR NC,Berk_ReadControls_UpInteract | |||||||
| B587 | CP $1E | Is A less than 1E? If not, jump to Berk_Put_Down_Entity_PublishScriptPos. | ||||||
| B589 | 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 | B58C | BIT 4,(IX+$03) | Is bit 04 of flags byte 3 (IX+03) set? If so, jump to Update_Berk_Movement_And_Script_PartI. | |||||
| B590 | JP NZ,Update_Berk_Movement_And_Script_PartI | |||||||
| B593 | LD IY,($72AA) | Load IY with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| B597 | LD A,(IY+$00) | Load A with the referenced entity's entity type. | ||||||
| B59A | CP $0F | Is referenced entity's entity type equal to 0F? If so, jump to Update_Berk_Movement_And_Script_PartD. | ||||||
| B59C | JP Z,Update_Berk_Movement_And_Script_PartD | |||||||
| B59F | BIT 4,(IY+$01) | Is bit 04 of the referenced entity's flags byte 1 set? If so, jump to Update_Berk_Movement_And_Script_PartD. | ||||||
| B5A3 | JP NZ,Update_Berk_Movement_And_Script_PartD | |||||||
| B5A6 | BIT 3,(IY+$01) | Is bit 03 of the referenced entity's flags byte 1 set? If not, jump to Berk_ReadControls_UpPutDownScript. | ||||||
| B5AA | JR Z,Berk_ReadControls_UpPutDownScript | |||||||
| B5AC | 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. | ||||||
| B5AF | JP C,Berk_ReadControls_DownBitTest | |||||||
| B5B2 | JP NZ,Berk_ReadControls_DownPartT | |||||||
| B5B5 | PUSH IX | Stash IX on the stack. | ||||||
| B5B7 | LD IX,($72AA) | Load IX with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| B5BB | LD A,(IX+$04) | Load A with the current entity's room index. | ||||||
| B5BE | OR A | Is the current entity's room index zero? If so, jump to Berk_ReadControls_UpRestore. | ||||||
| B5BF | JR Z,Berk_ReadControls_UpRestore | |||||||
| B5C1 | CP $01 | Is the current entity's room index equal to 01? If not, jump to Berk_ReadControls_UpRoomCheck. | ||||||
| B5C3 | JR NZ,Berk_ReadControls_UpRoomCheck | |||||||
| B5C5 | LD ($8D89),IX | Store IX in the trap door entity pointer (8D89). | ||||||
| B5C9 | SET 6,(IX+$01) | Set bit 06 of the current entity's flags byte 1. | ||||||
| B5CD | LD HL,$72B3 | Point HL at the game event flags (GameEventFlags). | ||||||
| B5D0 | SET 3,(HL) | Set "object has been offered to the trap" (bit 03 of GameEventFlags). | ||||||
| B5D2 | JR Berk_ReadControls_UpGrabEntity | Jump to Berk_ReadControls_UpGrabEntity to store Berk's extra state. | ||||||
|
Room-specific up checks: camera tweak, trap mouth (3D), or special X band (68).
|
||||||||
| Berk_ReadControls_UpRoomCheck | B5D4 | CALL Adjust_CameraX | Call Adjust_CameraX to adjust Camera X? If so, jump to Berk_ReadControls_UpGrabEntity. | |||||
| B5D7 | JR C,Berk_ReadControls_UpGrabEntity | |||||||
| B5D9 | CP $3D | Is the current entity's room index equal to 3D? If so, jump to Berk_ReadControls_UpGrabEntity. | ||||||
| B5DB | JR Z,Berk_ReadControls_UpGrabEntity | |||||||
| B5DD | CP $68 | Is the current entity's room index equal to 68? If not, jump to Berk_ReadControls_UpRestore. | ||||||
| B5DF | JR NZ,Berk_ReadControls_UpRestore | |||||||
| B5E1 | LD A,($72B3) | Load A with the game event flags (GameEventFlags). | ||||||
| B5E4 | BIT 3,A | Is bit 03 of game event flags set? If so, jump to Berk_ReadControls_UpRestore. | ||||||
| B5E6 | JR NZ,Berk_ReadControls_UpRestore | |||||||
| B5E8 | LD A,(IX+$07) | Load A with the current entity's x-coordinate. | ||||||
| B5EB | CP $98 | Is the current entity's x-coordinate less than 98? If so, jump to Berk_ReadControls_UpRestore. | ||||||
| B5ED | JR C,Berk_ReadControls_UpRestore | |||||||
| B5EF | LD A,$9D | Load A with 9D. | ||||||
| B5F1 | CP (IX+$08) | Does A match this entity's x-extent? If not, jump to Berk_ReadControls_UpGrabEntity. | ||||||
| B5F4 | JR NC,Berk_ReadControls_UpGrabEntity | |||||||
|
Failed up-path grab: restore Berk's entity pointer and fall into the put-down script.
|
||||||||
| Berk_ReadControls_UpRestore | B5F6 | POP IX | Restore IX from the stack. | |||||
|
Run a left-facing idle/put-down fragment (B9CD) when the up grab is rejected.
|
||||||||
| Berk_ReadControls_UpPutDownScript | B5F8 | LD HL,$B9CD | Point HL at a Berk put-down script fragment (B9CD). | |||||
| B5FB | 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 | B5FE | PUSH IX | Stash IX on the stack. | |||||
| B600 | POP BC | Restore BC and IX from the stack. | ||||||
| B601 | POP IX | |||||||
| B603 | LD (IX+$0C),C | Store C in the current entity's extra state. | ||||||
| B606 | LD (IX+$0D),B | Store B in the current entity's extra state. | ||||||
| B609 | SET 3,(IX+$03) | Set bit 03 of the current entity's flags byte 3. | ||||||
| B60D | RES 2,(IX+$03) | Reset bit 02 of the current entity's flags byte 3. | ||||||
| B611 | LD HL,$BABB | Point HL at Berk control/put-down script data (BerkPutDownScript_Bit3Set). | ||||||
| B614 | 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 | B617 | BIT 3,(IX+$09) | Is bit 03 of the current entity's direction / state set? If so, jump to AdvanceScriptInstruction. | |||||
| B61B | JP NZ,AdvanceScriptInstruction | |||||||
| B61E | LD HL,$BA8F | Point HL at Berk control/put-down script data (BerkPutDownScript_Drop). | ||||||
| B621 | 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 | B624 | 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. | |||||
| B627 | JR Z,Update_Berk_Movement_And_Script_PartC | |||||||
| B629 | JP NC,Berk_ReadControls_DownPartT | |||||||
| B62C | 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 | B62F | LD A,C | Copy the saved count/flag from C into A. | |||||
| B630 | CP $66 | Is 9D equal to 66? If not, jump to Update_Berk_Movement_And_Script_PartA. | ||||||
| B632 | JR NZ,Update_Berk_Movement_And_Script_PartA | |||||||
| B634 | PUSH HL | Stash HL on the stack. | ||||||
| B635 | LD HL,$B63D | Point HL at Berk movement script data (B63D). | ||||||
| B638 | LD A,$A0 | Load A with A0. | ||||||
| B63A | JP Berk_ReadControls_DownCameraCopy | Jump to Berk_ReadControls_DownCameraCopy to refresh the camera room origin. | ||||||
| B63D | INC B | Advance the layout-table index in B. | ||||||
| B63E | LD HL,$A227 | Point HL at graphic layout/table A227. | ||||||
| B641 | AND A | Test whether A0 is zero (clear carry). | ||||||
|
Plant-pot / type-0F up interact: retarget layout GraphicLayout_EyeballPlantLevel4 and update plant pots.
|
||||||||
| Update_Berk_Movement_And_Script_PartD | B642 | 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. | |||||
| B645 | JP C,Berk_ReadControls_DownBitTest | |||||||
| B648 | JP NZ,Berk_ReadControls_DownPartT | |||||||
| B64B | LD B,(IX+$06) | Load B with the current entity's y-extent. | ||||||
| B64E | DEC B | Step the loop counter in B back by one. | ||||||
| B64F | LD IY,($72AA) | Load IY with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| B653 | LD A,(IY+$00) | Load A with the referenced entity's entity type. | ||||||
| B656 | CP $0F | Is referenced entity's entity type equal to 0F? If not, jump to Update_Berk_Movement_And_Script_PartE. | ||||||
| B658 | JR NZ,Update_Berk_Movement_And_Script_PartE | |||||||
| B65A | LD A,(IY+$09) | Load A with the referenced entity's direction / state. | ||||||
| B65D | CP $07 | Is referenced entity's direction / state equal to 07? If not, jump to Berk_ReadControls_UpPutDownScript. | ||||||
| B65F | JP NZ,Berk_ReadControls_UpPutDownScript | |||||||
| B662 | LD (IY+$09),$0B | Write 0B to the referenced entity's direction / state. | ||||||
| B666 | LD BC,$A0B5 | Load BC with graphic layout address GraphicLayout_EyeballPlantLevel4. | ||||||
| B669 | LD (IY+$0A),C | Set the low byte of the referenced entity's graphic layout address from C. | ||||||
| B66C | LD (IY+$0B),B | Set the high byte of the referenced entity's graphic layout address from B. | ||||||
| B66F | PUSH IX | Stash IX on the stack. | ||||||
| B671 | LD IX,($72AA) | Load IX with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| B675 | LD C,$06 | Load C with 06 as an entity/loop count. | ||||||
| B677 | CALL Update_Plant_Pots | Call Update_Plant_Pots to update Plant Pots. | ||||||
| B67A | 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 | B67C | LD ($72AC),IY | Store IY in the current-entity pointer (Pointer_CurrentEntity). | |||||
| B680 | BIT 6,(IY+$01) | Is bit 06 of the referenced entity's flags byte 1 set? If not, jump to Update_Berk_Movement_And_Script_PartF. | ||||||
| B684 | JR Z,Update_Berk_Movement_And_Script_PartF | |||||||
| B686 | RES 6,(IY+$01) | Reset bit 06 of the referenced entity's flags byte 1. | ||||||
| B68A | LD HL,$72B3 | Point HL at the game event flags (GameEventFlags). | ||||||
| B68D | RES 3,(HL) | Clear "object has been offered to the trap" (bit 03 of GameEventFlags). | ||||||
|
Choose a pick-up/put-down script from the collided entity's y-extent vs Berk.
|
||||||||
| Update_Berk_Movement_And_Script_PartF | B68F | LD A,(IY+$06) | Load A with the referenced entity's y-extent. | |||||
| B692 | CP (IX+$05) | Does A match this entity's y-coordinate? If so, jump to Update_Berk_Movement_And_Script_PartH. | ||||||
| B695 | JR C,Update_Berk_Movement_And_Script_PartH | |||||||
| B697 | CP B | Does the referenced entity's y-extent equal B? If so, jump to Update_Berk_Movement_And_Script_PartG. | ||||||
| B698 | JR Z,Update_Berk_Movement_And_Script_PartG | |||||||
| B69A | LD HL,$BA07 | Point HL at Berk control/put-down script data (BA07). | ||||||
| B69D | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Run put-down script B9EB when y-extents match the stepped collision band.
|
||||||||
| Update_Berk_Movement_And_Script_PartG | B6A0 | LD HL,$B9EB | Point HL at Berk control/put-down script data (B9EB). | |||||
| B6A3 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Run put-down script B9F9 when the collided entity sits on Berk's own y.
|
||||||||
| Update_Berk_Movement_And_Script_PartH | B6A6 | LD HL,$B9F9 | Point HL at Berk control/put-down script data (B9F9). | |||||
| B6A9 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Carrying-flag up path: require a latch-set collidee, with a type-15 special case.
|
||||||||
| Update_Berk_Movement_And_Script_PartI | B6AC | LD IY,($72AA) | Load IY with the last-collided entity pointer (Pointer_LastCollidedEntity). | |||||
| B6B0 | LD A,(IY+$00) | Load A with the referenced entity's entity type. | ||||||
| B6B3 | BIT 2,(IY+$02) | Is bit 02 of the referenced entity's flags byte 2 set? If not, jump to Berk_ReadControls_UpPutDownScript. | ||||||
| B6B7 | JP Z,Berk_ReadControls_UpPutDownScript | |||||||
| B6BA | CP $15 | Is referenced entity's entity type equal to 15? If not, jump to Update_Berk_Movement_And_Script_PartJ. | ||||||
| B6BC | JR NZ,Update_Berk_Movement_And_Script_PartJ | |||||||
| B6BE | LD BC,($72AC) | Load BC with the current-entity pointer (Pointer_CurrentEntity). | ||||||
| B6C2 | LD A,(BC) | Fetch a byte through the pointer in BC. | ||||||
| B6C3 | CP $04 | Is referenced entity's entity type equal to 04? If not, jump to Berk_ReadControls_UpPutDownScript. | ||||||
| B6C5 | JP NZ,Berk_ReadControls_UpPutDownScript | |||||||
|
|
||||||||
| Update_Berk_Movement_And_Script_PartJ | B6C8 | 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. | |||||
| B6CB | JP C,Berk_ReadControls_DownBitTest | |||||||
| B6CE | JP NZ,Berk_ReadControls_DownPartT | |||||||
| B6D1 | LD C,(IX+$05) | Load C with the current entity's y-coordinate. | ||||||
| B6D4 | LD A,(IY+$05) | Load A with the referenced entity's y-coordinate. | ||||||
| B6D7 | DEC A | Step referenced entity's y-coordinate back by one. | ||||||
| B6D8 | LD ($72E9),A | Set held-entity y-extent (HeldEntityYExtent). | ||||||
| B6DB | CP C | Does the referenced entity's y equal C? If so, jump to Update_Berk_Movement_And_Script_PartK. | ||||||
| B6DC | JR C,Update_Berk_Movement_And_Script_PartK | |||||||
| B6DE | LD HL,$BA5B | Point HL at Berk control/put-down script data (BA5B). | ||||||
| B6E1 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Run put-down script BA4D once the held entity's y matches Berk.
|
||||||||
| Update_Berk_Movement_And_Script_PartK | B6E4 | LD HL,$BA4D | Point HL at Berk control/put-down script data (BA4D). | |||||
| B6E7 | JP ScriptInstruction | Jump to ScriptInstruction to execute the script instruction at HL. | ||||||
|
Flags-41 up interact: hand off to Berk_Interact_With_Entity, then run script BB4F.
|
||||||||
| Update_Berk_Movement_And_Script_PartL | B6EA | 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. | |||||
| B6ED | JP C,Berk_ReadControls_DownBitTest | |||||||
| B6F0 | JP NZ,Berk_ReadControls_DownPartT | |||||||
| B6F3 | LD HL,$BB4F | Point HL at Berk control/put-down script data (BB4F). | ||||||
| B6F6 | 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 | B6F9 | BIT 1,(IX+$03) | Is the current entity facing left (bit 01 of IX+03)? If not, jump to Berk_ReadControls_DownWalk. | |||||
| B6FD | JP Z,Berk_ReadControls_DownWalk | |||||||
| B700 | LD HL,$B9A5 | Point HL at Berk put-down script data (Data_BerkPutDownScripts). | ||||||
| B703 | 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 | B706 | CALL Test_EntityOverlap_AtDepth | Call Test_EntityOverlap_AtDepth to test Entity Overlap At Depth? If so, jump to Berk_ReadControls_DownScript. | |||||
| B709 | JR C,Berk_ReadControls_DownScript | |||||||
| B70B | CP $64 | Is referenced entity's y-coordinate less than 64? If not, jump to Berk_ReadControls_DownInteract. | ||||||
| B70D | JP NC,Berk_ReadControls_DownInteract | |||||||
| B710 | CP $41 | Is referenced entity's y-coordinate equal to 41? If so, jump to Berk_ReadControls_DownPartW. | ||||||
| B712 | JP Z,Berk_ReadControls_DownPartW | |||||||
| B715 | CP $32 | Is referenced entity's y-coordinate less than 32? If not, jump to Berk_ReadControls_Idle. | ||||||
| B717 | JP NC,Berk_ReadControls_Idle | |||||||
| B71A | CP $1E | Is referenced entity's y-coordinate less than 1E? If not, jump to Berk_Put_Down_Entity_PublishScriptPos. | ||||||
| B71C | JP NC,Berk_Put_Down_Entity_PublishScriptPos | |||||||
| B71F | BIT 4,(IX+$03) | Is bit 04 of flags byte 3 (IX+03) set? If so, jump to Berk_ReadControls_Idle. | ||||||
| B723 | JP NZ,Berk_ReadControls_Idle | |||||||
| B726 | LD BC,($72AA) | Load BC with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| B72A | INC BC | Advance the counter/pointer in BC by one. | ||||||
| B72B | LD A,(BC) | Fetch a byte through the pointer in BC. | ||||||
| B72C | BIT 4,A | Is bit 04 of referenced entity's y-coordinate set? If so, jump to Berk_ReadControls_DownPartU. | ||||||
| B72E | JP NZ,Berk_ReadControls_DownPartU | |||||||
| B731 | BIT 3,A | Is bit 03 of referenced entity's y-coordinate set? If not, jump to Berk_ReadControls_Idle. | ||||||
| B733 | JP Z,Berk_ReadControls_Idle | |||||||
| B736 | 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. | ||||||
| B739 | JR C,Berk_ReadControls_DownBitTest | |||||||
| B73B | JP NZ,Berk_ReadControls_DownPartT | |||||||
| B73E | PUSH IX | Stash IX on the stack. | ||||||
| B740 | LD IX,($72AA) | Load IX with the last-collided entity pointer (Pointer_LastCollidedEntity). | ||||||
| B744 | LD A,(IX+$04) | Load A with the current entity's room index. | ||||||
| B747 | CP $04 | Is the current entity's room index less than 04? If not, jump to Berk_ReadControls_DownAbort. | ||||||
| B749 | JR NC,Berk_ReadControls_DownAbort | |||||||
| B74B | CALL Test_EntityOverlap_AtDepth | Call Test_EntityOverlap_AtDepth to test Entity Overlap At Depth? If so, jump to Berk_ReadControls_DownGrab. | ||||||
| B74E | JR C,Berk_ReadControls_DownGrab | |||||||
|
Abort the down-path grab and return Berk to idle at Berk_ReadControls_Idle.
|
||||||||
| Berk_ReadControls_DownAbort | B750 | POP IX | Restore IX from the stack. | |||||
| B752 | 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 | B755 | PUSH IX | Stash IX on the stack. | |||||
| B757 | POP BC | Restore BC and IX from the stack. | ||||||
| B758 | POP IX | |||||||
| B75A | LD (IX+$0C),C | Store C in the current entity's extra state. | ||||||
| B75D | LD (IX+$0D),B | Store B in the current entity's extra state. | ||||||
| B760 | SET 3,(IX+$03) | Set bit 03 of the current entity's flags byte 3. | ||||||
|
Down put-down: continue the active script, or launch BerkPutDownScript_DownControl.
|
||||||||
| Berk_ReadControls_DownScript | B764 | BIT 2,(IX+$09) | Is bit 02 of the current entity's direction / state set? If so, jump to AdvanceScriptInstruction. | |||||
| B768 | JP NZ,AdvanceScriptInstruction | |||||||
| B76B | LD HL,$BAA5 | Point HL at Berk control/put-down script data (BerkPutDownScript_DownControl). | ||||||
| B76E | 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 | B771 | CALL Berk_Interact_With_Entity | Call Berk_Interact_With_Entity to let Berk interact with an entity? If not, jump to Berk_ReadControls_DownBranch. | |||||
| B774 | JR NZ,Berk_ReadControls_DownBranch | |||||||
| B776 | LD A,C | Copy the saved count/flag from C into A. | ||||||
| B777 | CP $65 | Is the current entity's room index equal to 65? If not, jump to Berk_ReadControls_DownScript. | ||||||
| B779 | JR NZ,Berk_ReadControls_DownScript | |||||||
| B77B | PUSH HL | Stash HL on the stack. | ||||||
| B77C | LD HL,$B79C | Point HL at Berk movement script data (Data_BerkMovementScripts). | ||||||
| B77F | LD A,$E0 | Load A with E0. | ||||||
|
Publish a new camera room-origin and copy follow fields, then resume idle.
|
||||||||
| Berk_ReadControls_DownCameraCopy | B781 | LD E,A | Keep E0 in E for later. | |||||
| B782 | ADD A,$1F | Add 1F to A (step down one screen row in the attribute map). | ||||||
| B784 | LD D,A | Keep E0 in D for later. | ||||||
| B785 | LD ($72FB),DE | Store DE in the camera room-origin pointer (Pointer_CameraRoomOrigin). | ||||||
| B789 | LD DE,$909F | Point DE at camera-follow entity fields (909F). | ||||||
| B78C | LD BC,$0005 | Load BC with 0005 as a short copy length. | ||||||
| B78F | LDIR | Copy the block at HL to DE. | ||||||
| B791 | POP HL | Restore HL from the stack. | ||||||
| B792 | BIT 4,(IX+$03) | Is bit 04 of flags byte 3 (IX+03) set? If so, call ScriptRoutine_PutDownCarried_PlaceHeldFromBerk. | ||||||
| B796 | CALL NZ,ScriptRoutine_PutDownCarried_PlaceHeldFromBerk | |||||||
| B799 | JP Berk_ReadControls_Idle | Jump to Berk_ReadControls_Idle to resume Berk's controller. | ||||||
| Prev: B41A | Up: Map | Next: B79C |