Prev: 51136 Up: Map Next: 51521
51173: Run the game
Displays the title screen and on return, sets the control method and initiates variables for a new game.
Init_Title_Screen 51173 LD HL,52148 Calls TitleScreen with HL=Copied_5B80.
51176 CALL TitleScreen
51179 LD B,0 Unused.
51181 LD A,(23728) Grab the value stored at Controller and if it is $01 then jump ahead to Set_Control_Alias which writes Controls_Keyboard to Control_Routine_Alias.
51184 LD HL,54171
51187 DEC A
51188 JR Z,Set_Control_Alias
51190 LD HL,54162 Write Controls_Joystick to Control_Routine_Alias.
Set_Control_Alias 51193 LD (52754),HL
Resets all game variables/ states ready for a new game.
51196 LD HL,52614 Clears the score (writes 0 over seven bytes from Scoredigit06).
51199 LD DE,52615
51202 LD (HL),0
51204 LD BC,6
51207 LDIR
Starting_Lives 51209 LD A,3 Initialise number of lives (Lives) to 3.
51211 LD (52313),A
51214 LD HL,257 Initialise cash deposit box position (CashboxReference_Inactive) to 257. (position 1)
51217 LD (54364),HL
51220 LD HL,0 Flag all doors as being empty.
51223 LD (52756),HL
51226 LD (52758),HL
51229 LD (52760),HL
51232 LD HL,8224 Clear day / phase text buffers at Day_ASCII and Phase_ASCII to 8224 (ASCII space-space).
51235 LD (51800),HL
51238 LD (51802),HL
51241 LD HL,52365 Clear down the deposit flags (copies 0 to each from DoorDeposited_01).
51244 LD DE,52366
51247 LD BC,13
51250 LD (HL),0
51252 LDIR
51254 XOR A Set the border to black.
51255 OUT (254),A
51257 INC A Write 1 to 52175.
51258 LD (52175),A
51261 CALL Init_Progress Set attributes to print "Day" / "Phase".
51264 CALL Set_Day_Attributes
51267 CALL Prep_Display_Day Print the current day.
51270 LD A,3 Set the default door speed multiplier in 52763 to 3. Note that this value never changes.
51272 LD (52763),A
51275 LD HL,1280 Set the default game speed at 52764 to 1280.
51278 LD (52764),HL
51281 LD A,1 Writes 1 to 53649. This indicates the reward screen should be displayed at the end of day 2.
51283 LD (53649),A
51286 LD A,(23729) Grabs the chosen starting phase in Level, if it's phase 1 then jump to Phase_01. HL points to the current phase (Phase).
51289 LD HL,51786
51292 DEC A
51293 JR Z,Phase_01
The player has chosen phase 3 or 6, so adjust the gameplay.
51295 CALL 51521 Speed the game up twice (to phase 3) and set the phase counter to 3.
51298 INC (HL)
51299 CALL 51521
51302 INC (HL)
51303 DEC A If phase 3 then move onto the appropriate logic.
51304 JR Z,Init_Title_Screen_0
The player has chosen phase 6, so adjust the gameplay.
51306 CALL 51521 Speed the game up three times (to phase 6) and set the phase counter to 6.
51309 INC (HL)
51310 CALL 51521
51313 INC (HL)
51314 CALL 51521
51317 INC (HL)
51318 JR Init_Title_Screen_1 Move forward to the appropriate logic.
The player has chosen phase 1, start with the defaults.
Phase_01 51320 LD HL,52802 Writes the character choosing routine Choose_Default_Set to Chooser_Routine_Buffer.
51323 LD (52767),HL
51326 CALL Cashboxes_Completed Run this phase.
51329 RET C Return if the game's over.
Phase 2
51330 LD HL,52847 Writes the character choosing routine Choose_Bandit_03 to Chooser_Routine_Buffer.
51333 LD (52767),HL
51336 CALL 51521 Speed the game up.
51339 CALL Cashboxes_Completed Run this phase.
51342 RET C Return if the game's over.
Phase 3
Init_Title_Screen_0 51343 LD HL,52831 Writes the character choosing routine Choose_Bandit_02 to Chooser_Routine_Buffer.
51346 LD (52767),HL
51349 CALL 51521 Speed the game up.
51352 CALL Cashboxes_Completed Run this phase.
51355 RET C Return if the game's over.
Phase 4
51356 LD HL,52821 Writes the character choosing routine Choose_Julius to Chooser_Routine_Buffer.
51359 LD (52767),HL
51362 CALL 51521 Speed the game up.
51365 CALL Cashboxes_Completed Run this phase.
51368 RET C Return if the game's over.
Phase 5
51369 LD HL,52862 Writes the character choosing routine Choose_Bandit_04 to Chooser_Routine_Buffer.
51372 LD (52767),HL
51375 CALL 51521 Speed the game up.
51378 CALL Cashboxes_Completed Run this phase.
51381 RET C Return if the game's over.
Phase 6
Init_Title_Screen_1 51382 LD HL,52877 Writes the character choosing routine Choose_Bandit_05 to Chooser_Routine_Buffer.
51385 LD (52767),HL
51388 CALL 51521 Speed the game up.
51391 CALL Cashboxes_Completed Run this phase.
51394 RET C Return if the game's over.
Phase 7
51395 LD HL,52892 Writes the character choosing routine Choose_Bandit_06 to Chooser_Routine_Buffer.
51398 LD (52767),HL
51401 CALL 51521 Speed the game up.
51404 CALL Cashboxes_Completed Run this phase.
51407 RET C Return if the game's over.
Phase 8
51408 LD HL,52892 Writes the character choosing routine Choose_Bandit_06 to Chooser_Routine_Buffer.
51411 LD (52767),HL
51414 CALL 51521 Speed the game up.
51417 CALL Set_Dusk_Attributes Change from day to dusk.
51420 CALL Cashboxes_Completed Run this phase.
51423 RET C Return if the game's over.
Phase 9
51424 LD HL,52892 Writes the character choosing routine Choose_Bandit_06 to Chooser_Routine_Buffer.
51427 LD (52767),HL
51430 CALL 51521 Speed the game up.
51433 CALL Set_Night_Attributes Change from dusk to night.
51436 CALL Cashboxes_Completed Run this phase.
51439 RET C Return if the game's over.
Day 2 / Phase 10 (loops for subsequent days)
Init_Title_Screen_2 51440 CALL Set_Day_Attributes Change from night back to day.
51443 CALL Prep_Display_Day New day (day 2).
51446 LD B,7 Seven daytime phases on day 2, all with every character.
Init_Title_Screen_3 51448 PUSH BC Remember this
51449 CALL Cashboxes_Completed Run this phase.
51452 POP BC Restore phase counter (so stack is correct for next instruction).
51453 RET C Return if the game's over.
Phase 11 - 16
51454 PUSH BC Remember counter again.
51455 CALL 51521 Speed the game up.
51458 POP BC Restore phase counter again.
51459 DJNZ Init_Title_Screen_3 Loop back if there are more phases to run.
Phase 17
51461 CALL Set_Dusk_Attributes Change from day to dusk.
51464 CALL Cashboxes_Completed Run this phase.
51467 RET C Return if the game's over.
Phase 18
51468 CALL Set_Night_Attributes Change from dusk to night.
51471 CALL Cashboxes_Completed Run this phase.
51474 RET C Return if the game's over.
Phase 19 and beyond
51475 LD HL,53649 Having got through all the phases, are we on day 2? Also reset the flag so the reward screen isn't shown for day 3 and above.
51478 LD A,(HL)
51479 LD (HL),0
51481 AND A
51482 JR Z,Init_Title_Screen_2 Jump back if we're not
51484 LD HL,52148 We have completed two days, display the reward screen.
51487 LD DE,23424
51490 LD BC,64
51493 LDIR
51495 CALL Sheriff_Star Display the reward screen.
51498 CALL Halt_Loop Wait for 1024 cycles
51501 CALL Halt_Loop
51504 CALL Halt_Loop
51507 CALL Halt_Loop
Init_Title_Screen_4 51510 XOR A Wait for a key to be pressed. Read the keyboard to bits 0-4 ... ... and turn on bits 5-7. If no key is pressed, this will set A to 0. Loop round if this is the case.
51511 IN A,(254)
51513 OR 224
51515 INC A
51516 JR Z,Init_Title_Screen_4
51518 NOP
51519 JR Init_Title_Screen_2 Loop back for another day.
Prev: 51136 Up: Map Next: 51521