![]() |
Routines |
| Prev: 60013 | Up: Map | Next: 60130 |
|
Used by the routines at Update_Drutt, Berk_Put_Down_Entity, ScriptRoutine_ThingUpstairsFillAttributes, ScriptRoutine_TaskThreeBerkRightWindow and ScriptRoutine_TaskFourBerkOverlap.
Clear the attribute file via Clear_AttributeFile, then randomly reposition the camera-follow entity (StateData_Berk) and store a Berk script pointer at Pointer_BerkScriptPosition.
|
||||
| Reposition_CameraFollowEntity | 60019 | LD A,4 | Load A with 4. | |
| 60021 | LD (29450),A | Set the camera-follow delay (CameraFollowDelay). | ||
| 60024 | LD A,127 | Load A with 127. | ||
| 60026 | CALL Clear_AttributeFile | Call Clear_AttributeFile to clear the attribute file (and play sound). | ||
| 60029 | EXX | Switch to the shadow registers. | ||
| 60030 | PUSH IX | Stash IX on the stack. | ||
| 60032 | LD IX,37019 | Point IX at the camera-follow entity (StateData_Berk). | ||
| 60036 | LD A,(IX+7) | Load A with the current entity's x-coordinate. | ||
| 60039 | LD B,5 | Load B with 5. | ||
|
Divide the follow entity's X by 32 to pick a room-band seed.
|
||||
| Reposition_CameraFollow_ShiftX | 60041 | SRL A | Shift A right logical. | |
| 60043 | DJNZ Reposition_CameraFollow_ShiftX | Decrease the loop counter in B and jump to Reposition_CameraFollow_ShiftX if more iterations remain. | ||
| 60045 | LD C,A | Keep the fill attribute in C. | ||
|
Pick a random X band that differs from the previous one.
|
||||
| Reposition_CameraFollow_WriteX | 60046 | LD A,5 | Load A with 5. | |
| 60048 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||
| 60051 | INC A | Step the fill-row counter on by one. | ||
| 60052 | CP C | Does A match C? If so, jump to Reposition_CameraFollow_WriteX. | ||
| 60053 | JR Z,Reposition_CameraFollow_WriteX | |||
| 60055 | PUSH AF | Stash AF on the stack. | ||
| 60056 | LD B,5 | Load B with 5. | ||
|
Scale the band into a world X and add a random offset for the follow entity.
|
||||
| Reposition_CameraFollow_RandomY | 60058 | ADD A,A | Double A to form a word index into the table. | |
| 60059 | DJNZ Reposition_CameraFollow_RandomY | Decrease the loop counter in B and jump to Reposition_CameraFollow_RandomY if more iterations remain. | ||
| 60061 | LD B,A | Keep a copy of A in B. | ||
| 60062 | LD A,20 | Load A with 20. | ||
| 60064 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||
| 60067 | ADD A,2 | A+=2. | ||
| 60069 | ADD A,B | A+=B. | ||
| 60070 | LD (IX+7),A | Set the current entity's x-coordinate. | ||
| 60073 | ADD A,5 | A+=5. | ||
| 60075 | LD (IX+8),A | Set the current entity's x-extent. | ||
| 60078 | POP AF | Restore AF from the stack. | ||
| 60079 | CP 3 | Is A equal to 3? If so, jump to Reposition_CameraFollow_WriteScript. | ||
| 60081 | JR Z,Reposition_CameraFollow_WriteScript | |||
| 60083 | LD A,3 | Load A with 3. | ||
| 60085 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||
| 60088 | INC A | Step the fill-row counter on by two. | ||
|
Write the follow entity's room, Y, extents, and facing after the random place.
|
||||
| Reposition_CameraFollow_WriteScript | 60089 | INC A | ||
| 60090 | LD (IX+4),A | Set the current entity's room index. | ||
| 60093 | ADD A,29 | A+=29. | ||
| 60095 | LD (IX+5),A | Set the current entity's y-coordinate. | ||
| 60098 | ADD A,6 | A+=6. | ||
| 60100 | LD (IX+6),A | Set the current entity's y-extent. | ||
| 60103 | LD (IX+9),0 | Write 0 to the current entity's direction / state. | ||
| 60107 | SET 0,(IX+3) | Set bit 0 of the current entity's flags byte 3. | ||
| 60111 | LD BC,48061 | Load BC with 48061. | ||
| 60114 | BIT 4,(IX+3) | Is bit 4 of flags byte 3 (IX+3) set? If so, jump to Reposition_CameraFollow_PickScript. | ||
| 60118 | JR NZ,Reposition_CameraFollow_PickScript | |||
| 60120 | INC BC | Advance the script address in BC by two bytes. | ||
| 60121 | INC BC | |||
|
Store the chosen Berk script pointer at Pointer_BerkScriptPosition and return.
|
||||
| Reposition_CameraFollow_PickScript | 60122 | LD (29361),BC | Store BC in Pointer: Berk Script Position (Pointer_BerkScriptPosition). | |
| 60126 | POP IX | Restore IX from the stack. | ||
| 60128 | EXX | Switch to the shadow registers. | ||
| 60129 | RET | Return. | ||
| Prev: 60013 | Up: Map | Next: 60130 |