Prev: 35689 Up: Map Next: 36008
35735: Update state of Berk depending upon currently selected character, control input and currently active power
Used by the routine at 35689.
Input
IX Address of complex state data (current level) for Berk
35735 BIT 7,(IX+9) If Berk's moving-upwards flag (floating power) is set...
35739 JP NZ,36542 ...then jump to 36542 (update state of Berk, floating power active)
35742 BIT 0,(IX+9) If Berk's must-process-current-script-data flag is set...
35746 JP NZ,48096 ...then jump to 48096 (advance HL to next script instruction and execute)
35749 LD A,(34208) If Drutt-mode flag is set...
35752 BIT 0,A ...
35754 JP NZ,35577 ...then jump to 35577 (change direction Berk is facing depending upon relative position of Drutt)
Drutt-mode flag is reset (i.e. Berk mode)
35757 LD A,(34219) Load A with control input
35760 BIT 0,A If right has been pressed...
35762 JP NZ,36214 ...then skip ahead to 36214 (move Berk right if appropriate)
35765 BIT 1,A If left has been pressed...
35767 JP NZ,36137 ...then skip ahead to 36137 (move Berk left if appropriate)
35770 CALL 54283 Move Berk into new room (left or right) if he is at the edge of his current room
35773 LD A,(34219) Load A with control input
35776 BIT 2,A If forward has been pressed...
35778 JP NZ,36036 ...then skip ahead to 36036 (update state of Berk, forward pressed)
35781 BIT 3,A If back has been pressed...
35783 JP NZ,35827 ...then skip ahead to 35827
This entry point is used by the routines at 35577, 36036 and 36116.
At this point, no control has been pressed.
35786 BIT 6,(IX+9) If Berk is not flying...
35790 JR Z,35802 ...then skip ahead to 35802
Berk is flying
35792 RES 6,(IX+9) Reset Berk's is-flying flag
35796 LD HL,35359 Point HL at script data for Berk starting to fall downwards...
35799 JP 48098 ...and execute
No control pressed and Berk not flying
35802 BIT 1,(IX+9) If Berk's facing-into-screen flag is reset...
35806 JR Z,35821 ...then skip ahead to 35821
No control pressed, Berk not flying and Berk's facing-into-screen flag is set
35808 BIT 3,(IX+11) If Berk's unused-(11,3) flag is reset...
35812 JP Z,48096 ...then jump to 48096 (advance HL to next script instruction and execute)
This entry point is used by the routine at 35577.
No control pressed, Berk not flying, Berk's facing-into-screen and unused-(11,3) flags are set
35815 LD HL,35113 Point HL at script data for Berk facing into screen, ready to respond to control input...
35818 JP 48098 ...and execute
This entry point is used by the routine at 35577.
No control pressed, Berk not flying and Berk's facing-into-screen flag is reset
35821 LD HL,35081 Point HL at script data for Berk facing out of screen, ready to respond to control input...
35824 JP 48098 ...and execute
Back pressed
35827 BIT 6,(IX+9) If Berk is flying...
35831 JP NZ,48096 ...then jump to 48096 (advance HL to next script instruction and execute)
35834 CALL 36008 If Berk is holding an edible entity them make him eat it, process appropriate script data and return to calling routine
35837 DEC (IX+4) Temporarily decrease y-coordinate of Berk's top edge
35840 CALL 54890 Check entity at IX for collision with another entity (in reverse order) at next depth level into screen whose interaction-(11,7) flag is set
35843 PUSH AF Store AF
35844 INC (IX+4) Restore y-coordinate of Berk's top edge
35847 POP AF Restore AF
35848 JR C,35953 If no collision occurred, then skip ahead to 35953
35850 CP 33 If collision was not with an entity of class 33 (door)...
35852 JR NZ,35870 ...then skip ahead 35870
Collision with door
35854 CALL 36116 If Berk is not horizontally aligned with door then move him closer and exit this routine
Berk is now horizontally aligned with door
35857 CALL 36367 If Berk is neither facing into the screen nor walking then exit this routine and have Berk turn into screen
35860 LD (34256),IY Store address of complex state data for door at 34256
35864 LD HL,35017 Point HL at script data for Berk interacting with a door behind him...
35867 JP 48098 ...and execute
Collision with something other than door
35870 CP 22 If collision was with an entity of class of 22 or greater (can't be picked up)...
35872 JR NC,35924 ...then skip ahead to 35924
Collision with entity that can be picked up
35874 BIT 4,(IX+9) If Berk is already carrying something...
35878 JP NZ,35953 ...then skip ahead to 35953
35881 CALL 36116 If Berk is not horizontally aligned with entity then move him closer and exit this routine
Berk is now horizontally aligned with entity pointed to by IY
35884 CALL 36367 If Berk is neither facing into the screen nor walking then exit this routine and have Berk turn into screen
35887 LD (34256),IY Store address of complex state data for entity at 34256
35891 LD B,(IX+6) Load B with y-coordinate of Berk's bottom edge...
35894 DEC B ...minus 1 (to take into account different depth)
35895 LD A,(IY+6) Load A with y-coordinate of entity's bottom edge...
35898 CP (IX+4) ...and if this is less than the y-coordinate of Berk's top edge...
35901 JR C,35918 ...then skip ahead to 35918
Entity is not above Berk
35903 CP B If entity's bottom edge is level with Berk's (taking into account different depth)...
35904 JR Z,35912 ...then skip ahead to 35912
Entity is above floor and below Berk's top edge
35906 LD HL,35163 Point HL at script data for Berk picking up an entity that is above floor and below Berk's top edge and behind him...
35909 JP 48098 ...and execute
Entity is on floor behind Berk
35912 LD HL,35135 Point HL at script data for Berk picking up an entity on floor behind him...
35915 JP 48098 ...and execute
Entity is above Berk
35918 LD HL,35149 Point HL at script data for Berk picking up an entity above and behind him...
35921 JP 48098 ...and execute
Collision with something that can't be picked up
35924 CP 32 If collision was not with entity of class 32 (coloured creatures' slots, level 3)...
35926 JR NZ,35953 ...then skip ahead to 35953
Collision with a coloured creature slot
35928 BIT 4,(IX+9) If Berk is not carrying anything...
35932 JR Z,35953 ...then skip ahead to 35953
Berk is carrying something
35934 CALL 36116 If Berk is not horizontally aligned with coloured creature slot then move him closer and exit this routine
Berk is now horizontally aligned with coloured creature slot and carrying something
35937 CALL 36367 If Berk is neither facing into the screen nor walking then exit this routine and have Berk turn into screen
35940 LD A,(IY+4) Load A with y-coordinate of top edge of coloured creature slot... (see trivia)
35943 DEC A ...minus 1...
35944 LD (34222),A ...and store at 34222
35947 LD HL,35235 Point HL at script data for Berk putting an entity down above floor behind him...
35950 JP 48098 ...and execute
No collision, collision with non-interactive entity or interaction conditions not met
35953 LD A,(34220) If Berk has no current power...
35956 OR A ...
35957 JR Z,35969 ...then skip ahead to 35969
35959 CP 4 If Berk's current power is 1-3 (jumping)...
35961 JP C,35995 ...then skip ahead to 35995
35964 CP 9 If Berk's current power is 4-8 (flying)...
35966 JP C,35985 ...then skip ahead to 35985
Berk has neither jumping nor flying power
35969 BIT 4,(IX+9) If Berk is not carrying anything...
35973 JP Z,35786 ...then jump to 35786 (terminate Berk's flight, or have him (turn to) face out of screen as appropriate)
Berk is carrying something
35976 CALL 36367 If Berk is neither facing into the screen nor walking then exit this routine and have Berk turn into screen
35979 LD HL,35219 Point HL at script data for Berk putting an entity down on floor behind him...
35982 JP 48098 ...and execute
Berk's current power is flying
35985 SET 6,(IX+9) Set Berk's is-flying flag
35989 LD HL,35417 Point HL at script data for Berk starting to fly...
35992 JP 48098 ...and execute
Berk's current power is jumping
35995 CALL 36296 Make Berk drop the entity he is holding and load IY with its complex state data address
35998 LD (IX+12),129 Set Berk's is-jumping flag and set initial jump velocity to 1
36002 LD HL,35441 Point HL at script data for Berk starting to jump straight up...
36005 JP 48098 ...and execute
Prev: 35689 Up: Map Next: 36008