|  | Routines | 
| Prev: 34426 | Up: Map | Next: 34675 | 
|  | ||||
| 34438 | LD SP,34426 | Set stack pointer | ||
| 34441 | CALL 34695 | Copy state data for all resettable complex entities into table of initial-state data | ||
| 34444 | LD A,1 | Set current level to 1... | ||
| 34446 | LD (34207),A | ... | ||
| 34449 | CALL 46830 | Display and handle main menu | ||
| 34452 | LD A,(34217) | Load current border colour into A | ||
| 34455 | OUT (254),A | Set border colour | ||
| 34457 | CALL 34864 | Copy start addresses of current level's data blocks to 34236 and clean up old data | ||
| 34460 | CALL 53887 | Paint red areas outside accessible areas of current character's current room | ||
| 34463 | CALL 47241 | Reset show-score flag and draw timer figures bar | ||
| 
Start of main loop
 | ||||
| 34466 | CALL 53723 | If Berk has been killed then reset his state, flash screen and decrease time / lives | ||
| 34469 | CALL 35689 | Update state of Berk and store current position in script data | ||
| 34472 | CALL 51739 | Update states of Drutt and worm and store current positions in script data | ||
| 34475 | LD A,(34207) | If current level is not level 1... | ||
| 34478 | CP 1 | ... | ||
| 34480 | JR NZ,34527 | ...then skip ahead to 34527 | ||
| 
Level 1
 | ||||
| 34482 | CALL 36791 | Update states of all level 1 entities | ||
| 34485 | LD IX,(34240) | Load IX with address of complex state data (current level) for Berk | ||
| 34489 | BIT 2,(IX+10) | If back-to-level-1 flag is reset... | ||
| 34493 | JR Z,34557 | ...then skip ahead to 34557 | ||
| 
Back-to-level-1 flag is set
 | ||||
| 34495 | LD A,(43612) | If y-coordinate of Boni's bottom edge is not 121... | ||
| 34498 | CP 121 | ... | ||
| 34500 | JR NZ,34557 | ...then skip ahead to 34557 | ||
| 34502 | LD A,(43677) | If y-coordinate of Drutt's bottom edge is not 121... | ||
| 34505 | CP 121 | ... | ||
| 34507 | JR NZ,34557 | ...then skip ahead to 34557 | ||
| 34509 | LD A,(43671) | If Drutt's room is not 1... | ||
| 34512 | CP 1 | ... | ||
| 34514 | JR NZ,34557 | ...then skip ahead to 34557 | ||
| 34516 | LD A,2 | Set depth of "Home Sweet Home" brickwork to 2... | ||
| 34518 | LD (43159),A | ... | ||
| 34521 | SET 3,(IX+10) | Set all-home flag | ||
| 34525 | JR 34557 | Skip ahead to 34557 | ||
| 34527 | LD A,(34207) | If current level is not level 2... | ||
| 34530 | CP 2 | ... | ||
| 34532 | JR NZ,34537 | ...then skip ahead to 34537 | ||
| 
Level 2
 | ||||
| 34534 | CALL 38009 | Update states of all level 2 entities | ||
| 34537 | LD A,(34207) | If current level is not level 3... | ||
| 34540 | CP 3 | ... | ||
| 34542 | JR NZ,34547 | ...then skip ahead to 34547 | ||
| 
Level 3
 | ||||
| 34544 | CALL 39137 | Update states of all level 3 entities | ||
| 34547 | LD A,(34207) | If current level is not level 4... | ||
| 34550 | CP 4 | ... | ||
| 34552 | JR NZ,34557 | ...then skip ahead to 34557 | ||
| 
Level 4
 | ||||
| 34554 | CALL 41211 | Update states of all level 4 entities | ||
| 
All levels
 | ||||
| 34557 | CALL 47893 | Check for control input and store at 34219 | ||
| 34560 | CALL 55525 | Move all falling entities down by distances appropriate to their current velocity factors | ||
| 34563 | CALL 34916 | If fire pressed, or character-swap-pending flag set, then swap characters | ||
| 34566 | CALL 53782 | Set each value in primary display buffer within play area to zero | ||
| 34569 | CALL 45899 | Populate primary display buffer with layout data for current character's current room | ||
| 34572 | CALL 54034 | Draw contents of primary display buffer to display | ||
| 34575 | CALL 59725 | Play and clear pending sound (index as stored at 34273) | ||
| 34578 | LD A,(34210) | Load remaining time / lives into A | ||
| 34581 | OR A | If no time / lives are left... | ||
| 34582 | JR Z,34645 | ...then jump to 34645 | ||
| 34584 | LD A,(43603) | If all-home flag is set... | ||
| 34587 | BIT 3,A | ... | ||
| 34589 | JR NZ,34658 | ...then skip ahead to 34658 | ||
| 34591 | CALL 47363 | Update eyes of a randomly selected timer figure, increase timer tick counter and process timer figure blinking | ||
| 34594 | LD HL,34208 | If update-scores-and-display flag is reset... | ||
| 34597 | BIT 5,(HL) | ... | ||
| 34599 | JR Z,34606 | ...then skip ahead to 34606 | ||
| 34601 | RES 5,(HL) | Reset update-scores-and-display flag | ||
| 34603 | CALL 47499 | Update scores and display | ||
| 34606 | LD HL,61312 | Point HL at display buffer 1 | ||
| 34609 | LD DE,63424 | Point DE at display buffer 2 | ||
| 34612 | LD A,(34271) | Invert display-buffer-2-is-primary flag... | ||
| 34615 | XOR 1 | ... | ||
| 34617 | LD (34271),A | ... | ||
| 34620 | JR Z,34623 | If display-buffer-2-is-primary flag is reset then skip ahead to 34623 (display buffer 1 is primary) | ||
| 34622 | EX DE,HL | Switch DE and HL (display buffer 1 is secondary) | ||
| 34623 | LD (34279),HL | Store address of primary display buffer at 34279 | ||
| 34626 | LD A,(34219) | Load A with control input | ||
| 34629 | BIT 6,A | If restart hasn't been pressed... | ||
| 34631 | JP Z,34466 | ...then jump to 34466 (start of main loop) | ||
| 
Restart has been pressed
 | ||||
| 34634 | LD A,1 | Set sound 1 as pending if appropriate, then play and clear pending sound... | ||
| 34636 | CALL 59722 | ... | ||
| 34639 | CALL 34751 | Reset all game data in preparation for new game | ||
| 34642 | JP 34438 | Jump back to 34438 (return to main menu) | ||
| 
No time / lives left
 | ||||
| 34645 | CALL 47499 | Update scores and display | ||
| 34648 | CALL 47185 | Print "SORRY BERK, BUT YOUR TIME IS UP" string | ||
| 34651 | LD A,1 | Set sound 1 as pending if appropriate, then play and clear pending sound... | ||
| 34653 | CALL 59722 | ... | ||
| 34656 | JR 34666 | Skip ahead to 34666 | ||
| 
All-home flag is set
 | ||||
| 34658 | CALL 47213 | Print "HOME SWEET HOME" string | ||
| 34661 | LD A,3 | Set sound 3 as pending if appropriate, then play and clear pending sound... | ||
| 34663 | CALL 59722 | ... | ||
| 34666 | CALL 47942 | Wait for current key to be released and another to be pressed, storing in A | ||
| 34669 | CALL 34751 | Reset all game data in preparation for new game | ||
| 34672 | JP 34438 | Jump back to 34438 (return to main menu) | ||
| Prev: 34426 | Up: Map | Next: 34675 |