|  | Routines | 
| Prev: DE09 | Up: Map | Next: DFBB | 
| 
Don't reset player lives or booty count if the game has already been completed and has looped around to start again.
 | ||||
| InitialiseGame | DEA8 | LD A,($5BF0) | Jump to InitialiseGameStates if *GameState is set to "Game Looped Mode" (02). | |
| DEAB | CP $02 | |||
| DEAD | JP Z,InitialiseGameStates | |||
| 
Initialise new Game State attributes.
 | ||||
| DEB0 | LD A,$03 | Write 03 to *PlayerLives. | ||
| DEB2 | LD ($5BF1),A | |||
| DEB5 | LD BC,$0000 | Write 0000 to *PlayerBooty. | ||
| DEB8 | LD ($5BF4),BC | |||
| 
This entry point is used by the routine at AllTreasureCollected.
 | ||||
| InitialiseGameStates | DEBC | XOR A | Write 00 to *CurrentRoom. | |
| DEBD | LD ($5BD3),A | |||
| DEC0 | LD BC,$007D | Write 007D to *PlayerTreasure. | ||
| DEC3 | LD ($5BF2),BC | |||
| DEC7 | JR InitialisePlayer | Jump to InitialisePlayer. | ||
| 
This entry point is used by the routine at LoseLife.
 | ||||
| SetFirstRoom | DEC9 | LD A,$01 | Write 01 to *CurrentRoom. | |
| DECB | LD ($5BD3),A | |||
| 
Initialise Player starting attributes.
 | ||||
| InitialisePlayer | DECE | LD DE,$F231 | Copy 0014 bytes of data from TableDefaultPlayerAttributes to TablePlayerAttributes. | |
| DED1 | LD HL,$F245 | |||
| DED4 | LD BC,$0014 | |||
| DED7 | LDIR | |||
| DED9 | LD A,$00 | Write 00 to: | ||
| DEDB | LD ($F33A),A | |||
| DEDE | LD ($F33F),A | |||
| DEE1 | LD ($E479),A | |||
| DEE4 | LD A,$00 | Write 00 to *TableBombSparks. | ||
| DEE6 | LD ($F2DB),A | |||
| DEE9 | LD A,$00 | Write 00 to: | ||
| DEEB | LD ($F31C),A | |||
| DEEE | LD ($5C78),A | |||
| DEF1 | LD ($5C79),A | |||
| DEF4 | LD ($F340),A | |||
| 
This also draws the whole room.
 | ||||
| DEF7 | CALL PrintStatusBar | Call PrintStatusBar. | ||
| 
Restore the default ZX Spectrum font.
 | ||||
| DEFA | LD HL,$3C00 | Write 3C00 (CHARSET-0100) to *CHARS. | ||
| DEFD | LD ($5C36),HL | |||
| DF00 | LD A,$10 | Set INK: YELLOW (06). | ||
| DF02 | RST $10 | |||
| DF03 | LD A,$06 | |||
| DF05 | RST $10 | |||
| DF06 | LD A,$11 | Set PAPER: *Active_BorderColour. | ||
| DF08 | RST $10 | |||
| DF09 | LD A,($5BD0) | |||
| DF0C | RST $10 | |||
| DF0D | CALL PrintStatusBarIcons | Call PrintStatusBarIcons. | ||
| DF10 | CALL ResetSoundFlags | Call ResetSoundFlags. | ||
| 
This is the beginning of the game loop.
 | ||||
| Game_Loop | DF13 | LD A,$11 | Set PAPER: *ActiveRoom_PaperColour. | |
| DF15 | RST $10 | |||
| DF16 | LD A,($5BD1) | |||
| DF19 | RST $10 | |||
| DF1A | CALL Handler_Animals | Call Handler_Animals. | ||
| DF1D | CALL Handler_PortHole | Call Handler_PortHole. | ||
| DF20 | CALL Handler_Bomb | Call Handler_Bomb. | ||
| DF23 | CALL Handler_Explosion | Call Handler_Explosion. | ||
| DF26 | CALL Handler_Pirates | Call Handler_Pirates. | ||
| DF29 | CALL InGamePause | Call InGamePause. | ||
| DF2C | CALL Handler_Lifts | Call Handler_Lifts. | ||
| 
The player doesn't display during the demo mode, he can still "die" though - hence how often you hear the "lose a life" sound.
 | ||||
| DF2F | LD A,($5BF0) | Call Handler_Player if *GameState is not set to "Demo Mode" (03). | ||
| DF32 | CP $03 | |||
| DF34 | CALL NZ,Handler_Player | |||
| DF37 | CALL Handler_Lifts2 | Call Handler_Lifts2. | ||
| DF3A | LD A,($E820) | Jump to InitialiseGame_0 if *E820 is equal to 00. | ||
| DF3D | CP $00 | |||
| DF3F | JR Z,InitialiseGame_0 | |||
| DF41 | DEC A | Decrease A by one. | ||
| DF42 | LD ($E820),A | Write A to *E820. | ||
| InitialiseGame_0 | DF45 | LD A,($5BEA) | Call PlayerControls_Kempston if *ControlMethod is set to Kempston joystick (0C). | |
| DF48 | CP $0C | |||
| DF4A | CALL Z,PlayerControls_Kempston | |||
| DF4D | LD A,($5BEA) | Call PlayerControls if *ControlMethod is not set to Kempston joystick (0C). | ||
| DF50 | CP $0C | |||
| DF52 | CALL NZ,PlayerControls | |||
| DF55 | CALL Handler_Items | Call Handler_Items. | ||
| DF58 | CALL Handler_DisappearingFloors | Call Handler_DisappearingFloors. | ||
| 
Display the currently carried key.
 
Set attributes.
 | ||||
| DF5B | LD A,$10 | Set INK: YELLOW (06). | ||
| DF5D | RST $10 | |||
| DF5E | LD A,$06 | |||
| DF60 | RST $10 | |||
| DF61 | LD A,$11 | Set PAPER: *Active_BorderColour. | ||
| DF63 | RST $10 | |||
| DF64 | LD A,($5BD0) | |||
| DF67 | RST $10 | |||
| DF68 | LD C,$1B | Set up the screen buffer location 1B/01 using CL_SET. | ||
| DF6A | LD B,$01 | |||
| DF6C | CALL $0DD9 | |||
| 
Restore the default ZX Spectrum font.
 | ||||
| DF6F | LD HL,$3C00 | Write 3C00 (CHARSET-0100) to *CHARS. | ||
| DF72 | LD ($5C36),HL | |||
| DF75 | LD IX,$F231 | IX=TablePlayerAttributes. | ||
| DF79 | LD A,(IX+$10) | A=*IX+10. | ||
| DF7C | ADD A,$30 | A+=30. | ||
| DF7E | CALL PrintColourCharacter | Call PrintColourCharacter. | ||
| DF81 | LD BC,($5BF2) | BC=*PlayerTreasure. | ||
| DF85 | LD A,C | Call AllTreasureCollected if BC is zero. | ||
| DF86 | OR B | |||
| DF87 | CALL Z,AllTreasureCollected | |||
| DF8A | LD A,($5BF0) | Jump to Game_Loop if *GameState is not set to "Demo Mode" (03). | ||
| DF8D | CP $03 | |||
| DF8F | JP NZ,Game_Loop | |||
| 
Else, this is the demo mode - so check the timer.
 | ||||
| DF92 | LD A,($5C79) | Loop back round to Game_Loop until *FRAMES+01 is equal to 03. | ||
| DF95 | CP $03 | |||
| DF97 | JP NZ,Game_Loop | |||
| DF9A | LD A,($F340) | Increment *TimerDemoMode by one. | ||
| DF9D | INC A | |||
| DF9E | LD ($F340),A | |||
| DFA1 | CP $02 | Call ED8F if *TimerDemoMode is equal to 02. | ||
| DFA3 | CALL Z,$ED8F | |||
| DFA6 | CALL GetRandomNumber | Get a random room number between 02 and 11. | ||
| DFA9 | AND %00001111 | |||
| DFAB | ADD A,$02 | |||
| DFAD | CALL ChangeRoom | Call ChangeRoom. | ||
| 
Reset the *FRAMES counter back to 0000.
 | ||||
| DFB0 | LD A,$00 | Write 00 to: | ||
| DFB2 | LD ($5C78),A | |||
| DFB5 | LD ($5C79),A | |||
| DFB8 | JP Game_Loop | Jump to Game_Loop. | ||
| Prev: DE09 | Up: Map | Next: DFBB |