Prev: B828 Up: Map Next: B8D2
B848: Routine at B848
Used by the routines at main_loop, cpu_driver and escape_scene.
scroll_horizon B848 LD HL,($A24A) Return if speed is zero
B84B LD A,H
B84C OR L
B84D RET Z
B84E LD A,($A25C) A = horizon_scroll
B851 AND A Set flags
B852 JR Z,scroll_horizon_3 Jump if zero
B854 EX AF,AF' Bank
B855 RR H RR H -- shift out carry?
B857 RLA A <<= 1
B858 RLA A <<= 1
B859 RLA A <<= 1
B85A AND $06 A &= 6
B85C LD C,A C = A + var_a25d
B85D LD A,($A25D)
B860 ADD A,C
B861 LD C,A
B862 LD B,$00 B = 0
B864 LD HL,$B828 16 word table at table_b828
B867 ADD HL,BC HL += BC
B868 LD B,(HL) BC = wordat(HL)
B869 INC HL
B86A LD C,(HL)
B86B LD HL,$A25E HL = &var_a25e
B86E DEC (HL) *HL--
B86F JR NZ,scroll_horizon_3 Jump if non-zero
B871 LD (HL),B *HL = B
B872 EX AF,AF' Bank
B873 LD A,C A = C
B874 JP P,scroll_horizon_0 Jump if positive
B877 NEG A = -A
scroll_horizon_0 B879 LD HL,$C7E8 Address of operand in 'LD A,x' @ C7E7
B87C ADD A,(HL) A += *HL
B87D JP P,scroll_horizon_1 Jump if positive
B880 ADD A,$14 A += 20
scroll_horizon_1 B882 CP $14 Jump if A < 20
B884 JR C,scroll_horizon_2
B886 SUB $14 A -= 20
scroll_horizon_2 B888 LD (HL),A *HL = A
scroll_horizon_3 B889 XOR A A = 0
B88A LD B,A B = 0
B88B LD E,A E = 0
B88C EX AF,AF' Bank
B88D LD A,($A258) Return if var_a258 is zero
B890 OR A
B891 RET Z
B892 JP P,scroll_horizon_4 Jump if positive
B895 INC E E = -(E + 1)
B896 NEG
scroll_horizon_4 B898 LD HL,$B827 32-byte table at table_b828
B89B LD C,A C = A
B89C ADD HL,BC HL += BC
B89D LD A,($A25B) C = var_a25b
B8A0 LD C,A
B8A1 LD A,($A23F) A = fast_counter - C
B8A4 SUB C
B8A5 AND A Set flags
B8A6 RET Z Return if non-zero
B8A7 LD C,(HL) C = *HL
scroll_horizon_5 B8A8 SUB C A -= C
B8A9 JR C,scroll_horizon_6 Jump if carry
B8AB INC B B++
B8AC EX AF,AF' Bank
B8AD ADD A,C A += C
B8AE EX AF,AF' Bank
B8AF JR scroll_horizon_5 Jump
scroll_horizon_6 B8B1 LD A,B A = B
B8B2 AND A Set flags
B8B3 RET Z Return if zero
B8B4 LD HL,$A25A HL = &var_a25a
B8B7 ADD A,(HL) A += *HL
B8B8 LD (HL),A *HL = A
B8B9 LD A,B A = B
B8BA RR E
B8BC LD B,$00 B = 0
B8BE JR NC,scroll_horizon_7 Jump if no carry
B8C0 DEC B B--
B8C1 NEG A = -A
scroll_horizon_7 B8C3 LD HL,($A171) HL = horizon_level
B8C6 LD C,A C = A
B8C7 ADD HL,BC HL += BC
B8C8 LD ($A171),HL write it back
B8CB EX AF,AF' Bank
B8CC LD HL,$A25B var_a25b += A
B8CF ADD A,(HL)
B8D0 LD (HL),A
B8D1 RET Return
Prev: B828 Up: Map Next: B8D2