Routines
Address
Description
34438
Display main menu and handle main game loop
34675
Pause
34695
Copy state data for all resettable complex entities into table of initial-state data for complex entities
34751
Reset all game data in preparation for new game
34864
Copy start addresses of current level's data blocks and clean up old data
34916
If fire pressed, or character-swap-pending flag set, then swap characters
35577
Change direction Berk is facing depending upon relative position of Drutt
35689
Update state of Berk and store current position in script data
35735
Update state of Berk depending upon currently selected character, control input and currently active power
36008
Make Berk eat the entity he is holding, if edible, and exit calling routine
36036
Update state of Berk (forward pressed)
36116
If Berk is not horizontally aligned with entity at
IY
then move Berk closer and exit calling routine
36296
Make Berk drop the entity he is holding and load
IY
with its complex state data address
36367
If Berk is neither facing into the screen nor walking then exit calling routine and have Berk turn into screen
36385
Script routine: (59) Have Berk interact appropriately with a door behind him
36390
Script routine: (58) Have Berk interact appropriately with a door in front of him
36471
Script routine: (56) Give Berk power corresponding to entity eaten
36542
Update state of Berk (floating power active)
36610
Script routine: (57) Cycle attributes (full-screen), clear display buffers and paint red areas outside current room
36616
Cycle attributes (full-screen), clear display buffers and paint red areas outside current room
36638
Advance to next level and if back to level 1 then exit calling routine and make Berk start falling
36753
Set Berk's horizontal position to match level 1's entry door
36778
Initialise script data positions for flying skeleton creature and bat (level 1)
36791
Update states of all level 1 entities
36887
Execute script data for Boni's kidnap and handle Trap Door opening and closing
36921
Open Trap Door if Berk is near the left side of the Trap Door room
36947
Advance
HL
to next script instruction and start executing
36950
Script routine: (36) Remove Boni from level 1
36957
Script routine: (37) Remove flying skeleton creature from level 1, and terminate script processing
36966
Close the Trap Door if Berk is not in room 1 and Drutt is in room 4 (level 1)
36984
Script routine: (38) Close the Trap Door
36990
Script routine: (39) Open the Trap Door
36996
Close the Trap Door
37004
Open the Trap Door
37062
Update state of bat (level 1) and store current position in script data
37085
Update state of bat (level 1)
37586
Update the states of the spiders (level 1) and store current positions in script data
37639
Update the state of a spider (level 1)
37718
Script routine: (41) Move spider up one character and, if home, reset its timer and make it wait
37753
Script routine: (42) Decrease remaining time until spider next descends and if zero, start descent
37778
Script routine: (40) Move spider down one character, and if at bottom, advance it to bounce / climb up mode
38009
Update states of all level 2 entities
38054
Update state of Bubo (level 2) and store current position in script data
38074
Update state of Bubo
38165
Script routine: (61) Fire Bubo's projectile
38219
Update state of Bubo's projectile
38377
Start level 2 key falling if Bubo's projectile is in place below it
38468
Reset current positions in ape-beasts' script data to initial values
38480
Update states of ape-beasts (level 2) and store current positions in script data
38540
Update state of an ape-beast
38554
Script routine: (60) Check position of ape-beast and turn if appropriate
38592
Update states of stalactites (level 2)
38756
Move entity at
IX
down one character
39137
Update states of all level 3 entities
39151
Update state of hatch (level 3)
39278
Update state of clawed foot (level 3)
39601
Update states of coloured creatures
39699
Count coloured creatures in slots and return if all are home
39760
Present reward for getting coloured creatures home
39776
Update state of large yellow creature (level 3)
39934
Set large yellow creature's mode to "returning home", and set Berk-has-been-killed flag
39944
Set graphic layout data address for entity at
IY
to
BC
39951
Move entity at
IY
down two characters
39961
Move entity at
IY
up two characters
39971
Move entity
IY
such that its left edge is up to two characters closer to entity
IX
's
39998
Set large yellow creature's mode to "returning home", move one step closer to home and return
40008
Move entity at
IY
one step closer to home position
41211
Update states of all level 4 entities
41354
Reset skeleton to initial state
41381
Update state of skeleton (level 4) and store current position in script data
41424
Update state of skeleton (dying)
41498
Kill Berk if he collides with skeleton
41550
Script routine: (63) Have skeleton advance or retreat based upon positions of Berk and yellow skull
41617
Script routine: (64) Set random (1 to 10) number of iterations in following loop script instruction
41633
Update state of ghost
41767
Update state of cannon and projectile
41961
Update state of cannon's projectile
42064
Update states of drips (level 4)
42251
Set a drip's (level 4) stage to
A
42266
Update state of flying skeleton creature (level 4)
42381
Update state of snake (level 4)
42486
Open snake's mouth and set Berk-has-been-killed flag if snake and Berk have collided
42505
Move entity at
IX
right one character
42512
Set graphic layout data address for entity at
IX
to
BC
45899
Populate primary display buffer with layout data for current character's current room
45965
Populate primary display buffer with graphic layout data for entity whose simple / complex state data is at address in
IX
45999
Advance graphic layout data pointer by two bytes, and process data
46218
Jump to appropriate graphic layout routine
46284
Graphic layout routine: (237) Set new pending sound
46295
Graphic layout routine: (242) Set current attribute
46306
Graphic layout routine: (244) Set current graphic set index
46317
Graphic layout routine: (236) Set graphic index in next instruction to value randomly selected from list
46347
Graphic layout routine: (245) Decrease timer value, and if zero, reset and write random graphic index from list into next instruction
46363
Graphic layout routine: (246) Decrease timer value, and if zero, reset and write random attribute from list into next instruction
46385
Reset timer to initial value then load
E
with random value from sequence (in graphic layout data)
46418
Graphic layout routine: (255) Load
HL
with stored coordinates and return from drawing
46427
Graphic layout routine: (250) Adjust x- and y-coordinates for drawing without storing
46442
Graphic layout routine: (254) Adjust x- and y-coordinates for drawing and set as new base coordinates
46460
Graphic layout routine: (251) Process graphic layout data at following address and return when complete
46481
Graphic layout routine: (248) Jump to graphic layout data address
46495
Graphic layout routine: (249) Jump to time-weighted, randomly selected graphic layout data address in list
46559
Graphic layout routine: (243) Increment index, n, and jump to n-th address in following list
46577
Graphic layout routine: (247) Jump to randomly selected graphic layout data address from list
46594
Graphic layout routine: (253) Jump to graphic layout data address selected from list, based upon width of Berk's carried entity
46611
Graphic layout routine: (238) Start loop (1 / 2)
46628
Graphic layout routine: (239) End loop (1 / 2)
46647
Graphic layout routine: (240) Start loop (2 / 2)
46664
Graphic layout routine: (241) End loop (2 / 2)
46830
Display and handle main menu
46946
Draw joystick "J" (main menu) in colour depending upon joystick mode
46968
If "K" pressed then redefine controls
47043
Set carry flag if Kempston interface not present, or Kempston joystick moved / fire pressed
47060
Set zero flag if key whose index is in
A
matches a direction, or the Berk / Drutt key
47071
Set attribute and location and print double-height character in
E
47084
Print keyboard controls on main menu
47140
Print "THROUGH the TRAPDOOR" string
47185
Print "SORRY BERK, BUT YOUR TIME IS UP" string
47213
Print "HOME SWEET HOME" string
47241
Reset show-score flag and draw timer figures bar
47302
If show-score flag reset then draw pair of timer figure eyes (closed) at attribute file address
IX
and advance
IX
by two bytes
47315
If show-score flag reset then draw pair of timer figure eyes (open, random frame) at attribute file address
IX
and advance
IX
by two bytes
47323
Draw a timer figure's eye (random frame) at attribute file address in
IX
and advance
IX
by one byte
47355
If show-score flag is reset then return to calling routine, else return to routine that called calling routine
47363
Update eyes of a randomly selected timer figure, increase timer tick counter and process timer figure blinking
47431
Select a remaining timer figure at random and update its eyes to a random (open-eyed) frame
47468
Increase timer tick counter and reduce remaining time if counter > 767
47499
Update scores and display
47628
Print score / total / high score string in current character's colours
47682
Print a double-height text character
47709
Print half of a double-height text character
47741
Convert number in
HL
to string at
IY
47772
Convert a digit of numeric data to its string equivalent
47788
Read keyboard and load pressed key character into
A
47893
Check for control key press and store
47930
If joystick mode is on, then read joystick input
47942
Wait for current key to be released and another to be pressed, storing in
A
47955
Wait for key-press, store pressed key code in
A
and play main menu sound
48096
Advance
HL
to next script instruction and execute
48133
Script routine: (04) If current character and target entity are in the same room then set pending sound
48142
Script routine: (62) Move entity at
IX
into room to the left, if appropriate
48148
Script routine: (16) Have Berk hold an entity, and position it appropriately between his hands
48154
Script routine: (17) Have Berk put down an entity in front of him, if appropriate
48158
Script routine: (18) Have Berk put down an entity behind him, if appropriate
48212
Script routine: (10) Reset walking-left and walking-right flags
48216
Script routine: (12) Reset walking-left flag and set walking-right flag
48220
Script routine: (11) Set walking-left flag and reset walking-right flag
48234
Script routine: (07) Reset Berk's facing-into-screen, facing-left and facing-right flags
48238
Script routine: (06) Set Berk's facing-into-screen flag, and reset his facing-left and facing-right flags
48242
Script routine: (13) Set Berk's facing-left flag, and reset his facing-into-screen and facing-right flags
48246
Script routine: (14) Set Berk's facing-right flag, and reset his facing-into-screen and facing-left flags
48260
Script routine: (09) Reset must-process-current-script-data flag for entity at
IX
48267
Script routine: (08) Set must-process-current-script-data flag for entity at
IX
48274
Script routine: (15) Jump to new address if Berk is carrying something
48285
Script routine: (01) Load
HL
(script data pointer) with new address
48295
Script routine: (23) Start loop (1 / 3)
48307
Script routine: (24) End loop (1 / 3)
48324
Script routine: (25) Start loop (2 / 3)
48336
Script routine: (26) End loop (2 / 3)
48353
Script routine: (27) Start loop (3 / 3)
48365
Script routine: (28) End loop (3 / 3)
48382
Load
A
with script instruction parameter then advance
HL
to next instruction
48388
Decrease remaining time for current power and if zero, exit calling routine and run script data for removal of power
48417
Remove Berk's current power and reset sweet / mushroom / edible eyes / sausage to its original position
48487
Script routine: (32) Update Berk's position and state (flying) depending upon control input
48567
Script routine: (35) Move entity at
IX
(and any carried entities) down one character
48593
Move entity right one character, and into new room if appropriate
48641
Move entity left one character, and into new room if appropriate
48686
Script routine: (22) Move carried entity behind Berk as he faces into screen
48692
Script routine: (21) Move carried entity in front of Berk as he faces out of screen
48698
Script routine: (19) Move carried entity to Berk's left as he faces left
48704
Script routine: (20) Move carried entity to Berk's right as he faces right
48710
Move carried entity in front of Berk as he faces out of screen
48715
Move carried entity behind Berk as he faces into screen
48727
Move carried entity to Berk's right as he faces right
48738
Move carried entity to Berk's left as he faces left
48760
Load
A
,
D
and
E
with positional data for a carried entity or return
48850
Have Berk hold an entity, and position it appropriately between his hands
48920
Script routine: (29) Make Berk start falling, and drop his carried entity if appropriate
48934
Script routine: (30) Check Berk's fall velocity, and react to landing
49010
Script routine: (33) Advance Berk's jump and select next phase if current phase complete
51732
Reset Drutt to initial state
51739
Update states of Drutt and worm and store current positions in script data
51765
Update state of Drutt
51779
Script routine: (43) Select next action for Drutt depending upon control input
51904
Randomly select script data for rightward hop of size three or four, and execute
51924
Randomly select script data for leftward hop of size three or four, and execute
51944
Start Drutt jumping
51954
Point
HL
at script data for Drutt swapping depth levels and execute
51960
Move Drutt closer to the worm and eat it if close enough
52029
Script routine: (44) Move entity up one character
52038
Script routine: (45) Move entity down one character
52047
Script routine: (46) Move Drutt, or entity he is pushing left one character and start pushed entity falling if appropriate
52053
Move Drutt, or entity he is pushing left one character and start pushed entity falling if appropriate
52098
Advance position of entity pushed left by Drutt
52142
Script routine: (47) Move Drutt, or entity he is pushing right one character and start pushed entity falling if appropriate
52148
Move Drutt, or entity he is pushing right one character and start pushed entity falling if appropriate
52193
Advance position of entity pushed right by Drutt
52243
Script routine: (50) Advance Drutt's jump and select next phase if current phase complete
52309
Script routine: (51) Swap Drutt's current depth level if possible
52315
Swap Drutt's current depth level if possible
52837
Update state of worm and store current position in script data
52860
Update state of worm
52870
Script routine: (53) Move worm left if possible, otherwise choose new direction
52889
Script routine: (54) Move worm right if possible, otherwise choose new direction
52908
Execute script data for worm choosing next direction
52914
Script routine: (55) Choose new direction and start crawling (worm)
52967
Script routine: (52) Increase worm's age and decrease time until direction change, or react to Drutt's presence
53057
Increase worm's age and set its depth to zero if it has expired
53083
Attempt to spawn a new worm
53194
Load
A
with value indicating which direction room
A
lies relative to room in state data at
IX
53309
Add entry to pathfinding data table for room
B
in direction
A
53317
Set zero flag if room
B
has an entry in pathfinding data table, otherwise reset
53333
Load
A
with direction index in pathfinding data table entry at address in
IX
, restore registers and return
53577
Cycle attributes (long, full-screen) and clear display buffers
53581
Cycle attributes (short, full-screen) and clear display buffers
53649
Fill top 22 rows of attribute file with attribute value in
A
53667
Set Berk-has-been-killed flag
53723
If Berk has been killed then reset his position and state, flash screen and decrease time / lives
53782
Set each value in primary display buffer within play area to zero
53814
Advance
DE
by 2 ×
A
bytes and load word at this location into
DE
53825
Copy room dimension data entry for current character / entity's current room to temporary store location
53887
Paint red areas outside accessible areas of current character's current room
53968
Print red cell to current attribute file position (outside play area) and mark as unused in display buffers
53987
Reset complex state data for first entity of class
A
to that stored in initial-state table
54019
Point
IY
at first entry in current level's complex state data that has class
A
54034
Draw contents of primary display buffer to display
54144
Draw a graphic character block to display
54222
Load
A
with a pseudo-random number between 0 and the higher of 2 and
A
(input)
54283
Move entity at
IX
into new room (left or right) if it is at the edge of its current room
54313
Move entity at
IX
into room to the right, if appropriate
54348
Move entity at
IX
into room to the left, if appropriate
54383
Move entity at
IX
into room to right of its current room and update position of carried entity if moving entity is Berk
54398
Set entity's position to be left-hand side of new room to right
54419
Move entity at
IX
into room to left of its current room and update position of carried entity if moving entity is Berk
54434
Set entity's position to be right-hand side of new room to left
54456
Paint red areas outside current character's room if
IX
points to current character's complex state data
54480
Set room of entity at
IX
to
B
, store room size data for new room and load
E
with entity's width minus one
54505
Load
B
with index of room to right of an entity's current room
54539
Load
B
with index of room to left of an entity's current room
54569
Check entity at
IX
for collision with another (impassable / pushable) entity immediately to the right
54666
Check entity at
IX
for collision with another (impassable / pushable) entity immediately to the left
54764
Check entity at
IX
for collision with another entity at next depth level out of screen whose interaction-(11,6) flag is set
54768
Check entity at
IX
for collision with another entity at same depth whose interaction-(11,6) flag is set
54878
Check entity at
IX
for collision with another entity (only those defined before, and in reverse order) at same depth level whose interaction-(11,7) flag is set
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
55023
Handle Drutt's jump, and load
E
with jump state index as appropriate
55041
Handle Berk's jump, and load
E
with jump state index as appropriate
55187
Set character-swap-pending flag
55196
Handle vertical component of character's jump, and load
E
with jump state index as appropriate
55421
Increase current velocity of character's jump if less than 7
55433
Change entity's room up one if appropriate
55516
Set can-fall flag and set initial velocity factor of 2 for entity defined at address in
IX
55525
Move all falling entities down by distances appropriate to their current velocity factors
55616
Change entity's room down one if appropriate
59601
If current character is in same room as target entity at
IX
then set pending sound to
A
59722
Set sound of index
A
as pending if appropriate, then play and clear pending sound