Prev: 873C Up: Map Next: 8876
87DC: Sets up the game or the level?
Input
HL Address of 14 bytes of data to be copied to $A26C+
setup_game 87DC PUSH HL Preserve data pointer
87DD LD HL,$EE00 Zero $EE00..$EEFF, and reset road_buffer_offset to $EE00
87E0 LD ($A240),HL
87E3 LD D,H
87E4 LD E,$01
87E6 LD (HL),L
87E7 LD BC,$00FF
87EA LDIR
87EC XOR A A = 0
87ED LD HL,$A13E Copy (47 bytes) at saved_game_state to var_a16d - saved game state
87F0 LD DE,$A16D
87F3 LD BC,$002F
87F6 LDIR
87F8 LD H,D Zero 208 bytes at $A19D
87F9 LD L,E
87FA INC DE
87FB LD (HL),A
87FC LD BC,$00CF
87FF LDIR
8801 POP HL Restore data pointer
8802 LD BC,$000E Copy the 14 bytes passed in to road_pos (road_pos, road_curvature_ptr, etc.)
8805 LDIR
8807 CALL pre_shift_backdrop Pre-shift the backdrop image
880A LD HL,$E34B $E34B = 8
880D LD (HL),$08
880F INC L
8810 LD (HL),A $E34C = 0
8811 INC L
8812 LD (HL),A $E34D = 0
8813 LD HL,$8F82 $8F82 = NOP (instruction)
8816 LD (HL),A
8817 INC HL
8818 LD (HL),A $8F83 = NOP (instruction)
8819 INC HL
881A LD (HL),A $8F84 = NOP (instruction)
881B LD HL,$8FA4 NOP 6 bytes [of instructions] at $8FA4
881E LD B,$06
setup_game_0 8820 LD (HL),A
8821 INC HL
8822 DJNZ setup_game_0
8824 LD ($C059),A Self modify "LD (HL),x" at C058 to x = 0
8827 LD ($B064),A Self modify "LD A,x" at move_hero_car to x = 0 car jump height
882A LD HL,($5D10) Set $A191 to the perp's car LOD
882D LD ($A191),HL
8830 LD HL,$EE00 Zero $EE00..$EEFF, and reset road_buffer_offset to $EE00 [duplicates work from earlier]
8833 LD ($A240),HL
8836 LD D,H
8837 LD E,$01
8839 LD (HL),L
883A LD BC,$00FF
883D LDIR
loop883f 883F LD B,$20 32 iterations - affects start position?
setup_game_1 8841 PUSH BC Preserve BC
8842 LD HL,$A23F Address of fast_counter
8845 CALL rm_cycle_buffer_offset Call HUGE function
8848 POP BC Restore BC
8849 DJNZ setup_game_1 Loop
884B XOR A Reset another_spawning_flag
884C LD ($A254),A
884F LD A,$F8 Transition type?
8851 CALL setup_transition Call setup_transition
8854 CALL clear_screen_set_attrs Call clear_screen_set_attrs
8857 LD HL,$5820 Point HL at left light's attributes
885A CALL clear_lights
885D LD HL,$583B Point HL at right light's attributes then FALL THROUGH
clear_lights 8860 LD C,$04 Clear the lights' BRIGHT bit
setup_game_2 8862 LD B,$05
setup_game_3 8864 RES 6,(HL)
8866 INC L
8867 DJNZ setup_game_3
8869 LD A,L
886A ADD A,$1B
886C LD L,A
886D DEC C
886E JR NZ,setup_game_2
8870 CALL silence_audio_hook Call silence_audio_hook
8873 JP update_scoreboard Exit via update_scoreboard
Prev: 873C Up: Map Next: 8876