Routines |
Prev: F076 | Up: Map | Next: F1E0 |
This is where the game starts.
Used by the routine at jump_to_main.
|
||||
main | F163 | DI | Disable interrupts | |
Q: Why is the stack pointer set to $FFFE here when squash_stack_goto_main sets it to $FFFF?
|
||||
F164 | LD SP,$FFFE | Point the stack pointer at the end of RAM | ||
Clear the screen.
|
||||
F167 | CALL wipe_full_screen_and_attributes | Clear the full screen and attributes and set the screen border to black | ||
Set the morale flag to green.
|
||||
F16A | LD A,$44 | Set A to attribute_BRIGHT_GREEN_OVER_BLACK | ||
F16C | CALL set_morale_flag_screen_attributes | Set the screen attributes of the morale flag | ||
Draw everything else.
Bug: This passes in index $44 to set_menu_item_attributes in A, but it ought to be zero.
|
||||
F16F | LD E,$46 | Set E to attribute_BRIGHT_YELLOW_OVER_BLACK | ||
F171 | CALL set_menu_item_attributes | Set the screen attributes of the specified menu item | ||
F174 | CALL plot_statics_and_menu_text | Plot all static graphics and menu text | ||
F177 | CALL plot_score | Draw the current score to screen | ||
Run the menu screen.
We'll be in here for some time until the user selects their input method. When we return we'll continue setting up the things required for the game, then jump into the main loop.
|
||||
F17A | CALL menu_screen | Runs the menu screen | ||
Construct a table of 256 bit-reversed bytes at $7F00.
|
||||
F17D | LD HL,$7F00 | Point HL at $7F00 | ||
Start loop
|
||||
main_0 | F180 | LD A,L | Shuffle | |
F181 | LD C,$00 | Zero C (Commentary: Could have used XOR C) | ||
Reverse a byte
|
||||
F183 | LD B,$08 | Set B for eight iterations | ||
Start loop
|
||||
main_1 | F185 | RRA | Shift out lowest bit from A into carry | |
F186 | RL C | Shift carry into C | ||
F188 | DJNZ main_1 | ...loop until the byte is completed | ||
F18A | LD (HL),C | Store the reversed byte | ||
F18B | INC L | |||
F18C | JP NZ,main_0 | ...loop until L becomes zero | ||
F18F | INC H | Advance HL to $8000 | ||
Initialise visible characters (HL is $8000).
|
||||
F190 | LD DE,$F1C9 | Point DE at vischar_initial | ||
F193 | LD B,$08 | Set B for eight iterations | ||
Start loop
|
||||
main_2 | F195 | PUSH BC | Preserve loop counter | |
F196 | PUSH DE | Preserve vischar_initial | ||
F197 | PUSH HL | Preserve vischar pointer | ||
F198 | LD BC,$0017 | Populate the vischar slot with vischar_initial's data | ||
F19B | EX DE,HL | |||
F19C | LDIR | |||
F19E | POP HL | Restore vischar pointer | ||
F19F | LD A,$20 | Advance HL to the next vischar (assumes no overflow) | ||
F1A1 | ADD A,L | |||
F1A2 | LD L,A | |||
F1A3 | POP DE | Restore vischar_initial | ||
F1A4 | POP BC | ...loop until the vischars are populated | ||
F1A5 | DJNZ main_2 | |||
Write $FF $FF at $8020 and every 32 bytes after. (Commentary: It could be easier to do the inverse and clear those bytes at $8000).
|
||||
F1A7 | LD B,$07 | Set B for seven iterations | ||
Iterate over non-player visible characters.
|
||||
F1A9 | LD HL,$8020 | Start at the second visible character | ||
F1AC | LD DE,$001F | Prepare the vischar stride, minus a byte | ||
F1AF | LD A,$FF | Prepare the index / flags initialiser | ||
Start loop
|
||||
main_3 | F1B1 | LD (HL),A | Set the vischar's character index to $FF | |
F1B2 | INC L | Advance HL to the flags field | ||
F1B3 | LD (HL),A | Set the vischar's flags to $FF | ||
F1B4 | ADD HL,DE | Advance the vischar pointer | ||
F1B5 | DJNZ main_3 | ...loop until the vischar flags are set | ||
Zero $118 bytes at HL ($8100 is mask_buffer) onwards.
This wipes everything up until the start of tiles ($8218).
|
||||
F1B7 | LD BC,$0118 | Set B to $118 | ||
Start loop
|
||||
main_4 | F1BA | LD (HL),$00 | Zero and advance | |
F1BC | INC HL | |||
F1BD | DEC BC | ...loop until cleared | ||
F1BE | LD A,C | |||
F1BF | OR B | |||
F1C0 | JP NZ,main_4 | |||
F1C3 | CALL reset_game | Reset the game | ||
F1C6 | JP main_loop_setup | Jump to main_loop_setup | ||
Initial state of a visible character.
|
||||
vischar_initial | F1C9 | DEFB $00 | character | |
F1CA | DEFB $00 | flags | ||
F1CB | DEFW $012C | route | ||
F1CD | DEFB $2E,$2E,$18 | target | ||
F1D0 | DEFB $00 | counter_and_flags | ||
F1D1 | DEFW animations | animbase | ||
F1D3 | DEFW anim_wait_tl | anim | ||
F1D5 | DEFB $00 | animindex | ||
F1D6 | DEFB $00 | input | ||
F1D7 | DEFB $00 | direction | ||
F1D8 | DEFW $0000,$0000,$0018 | mi.pos | ||
F1DE | DEFW sprite_prisoner | mi.sprite |
Prev: F076 | Up: Map | Next: F1E0 |