Prev: C58A Up: Map Next: C8BE
C598: Road and backdrop plotting
Used by the routine at main_loop_13.
C598 EXX Bank
C599 LD HL,$C5A1 Self modify 'JP NZ,x' @ C6AD to be C5A1
C59C LD ($C6AE),HL
C59F EXX Unbank
C5A0 EX AF,AF'
C5A1 LD A,D A = D
C5A2 DEC D D--
C5A3 AND $0F A &= 15
C5A5 JR Z,$C57C Jump if zero
This entry point is used by the routine at C57C.
C5A7 LD ($C5FA),DE Self modify 'LD DE,x' @ C5F9
C5AB LD A,L A = L
C5AC LD B,$00 B = <self modified>
C5AE EXX Bank
C5AF LD L,A L = A
C5B0 LD BC,$10F8 B = 16, C = $F8 (mask)
C5B3 LD H,$E8 Self modified
C5B5 LD A,(HL) A = *HL
C5B6 AND A Set flags
C5B7 JP Z,$C5C4 Jump if zero
C5BA LD A,$00 A = 0 (not self modified)
C5BC JP M,$C5D3 Jump if negative
C5BF LD A,$0F A = 15
C5C1 JP $C5D3 Jump
Pattern
C5C4 DEC L A = HL[-1]
C5C5 LD A,(HL)
C5C6 INC L
C5C7 AND C A &= C -- C is the mask $F8 here
C5C8 RRCA A >>= 3
C5C9 RRCA
C5CA RRCA
C5CB RRA A >>= 1
C5CC ADC A,$00 Add carry
C5CE CP B Jump if A < B
C5CF JP C,$C5D3
C5D2 DEC A A--
C5D3 LD E,A E = A
C5D4 CPL A = ~A + B
C5D5 ADD A,B
C5D6 LD ($C62D),A Self modify 'JR x' @ C62C -- jump table target
C5D9 LD H,$EC H = $EC
C5DB LD A,(HL) A = *HL
C5DC AND A Set flags
C5DD JP Z,$C5E9 Jump if zero
C5E0 LD A,$0F A = 15
C5E2 JP P,$C5F0 Jump if positive
C5E5 XOR A A = 0
C5E6 JP $C5F0 Jump
Same pattern again
C5E9 DEC L L--
C5EA LD A,(HL) A = *HL & C -- C is the mask $F8 here
C5EB AND C
C5EC RRCA A >>= 3
C5ED RRCA
C5EE RRCA
C5EF RRA A >>= 1
C5F0 LD ($C60B),A Self modify 'JR x' @ C60A -- jump table target
C5F3 CPL A = ~A + B + E
C5F4 ADD A,B
C5F5 ADD A,E
C5F6 LD ($C61C),A Self modify 'JR x' @ C61B -- jump table target
C5F9 LD DE,$0000 DE = <self modified>
C5FC LD A,E L = E + 31
C5FD ADD A,$1F
C5FF LD L,A
C600 LD H,D H = D
C601 LD SP,HL Put it in SP (so we can use PUSH for speed)
C602 EX AF,AF' Bank
C603 RLCA A <<= 1
C604 LD H,A H = A
C605 LD L,A L = A
C606 EX AF,AF' Unbank
C607 LD BC,$0000 BC = 0
C60A JR $C60A Jump table (self modified)
C60C PUSH HL
C60D PUSH HL
C60E PUSH HL
C60F PUSH HL
C610 PUSH HL
C611 PUSH HL
C612 PUSH HL
C613 PUSH HL
C614 PUSH HL
C615 PUSH HL
C616 PUSH HL
C617 PUSH HL
C618 PUSH HL
C619 PUSH HL
C61A PUSH HL
C61B JR $C61B Jump table (self modified)
C61D PUSH BC
C61E PUSH BC
C61F PUSH BC
C620 PUSH BC
C621 PUSH BC
C622 PUSH BC
C623 PUSH BC
C624 PUSH BC
C625 PUSH BC
C626 PUSH BC
C627 PUSH BC
C628 PUSH BC
C629 PUSH BC
C62A PUSH BC
C62B PUSH BC
C62C JR $C62C Jump table (self modified)
This entry point is used by the routine at main_loop_13.
C62E PUSH HL
C62F PUSH HL
C630 PUSH HL
C631 PUSH HL
C632 PUSH HL
C633 PUSH HL
C634 PUSH HL
C635 PUSH HL
C636 PUSH HL
C637 PUSH HL
C638 PUSH HL
C639 PUSH HL
C63A PUSH HL
C63B PUSH HL
C63C PUSH HL
C63D LD B,E B = E
C63E DEC C C--
C63F LD H,$E4 H = $E4
C641 EXX Bank/unbank
C642 LD H,$E8 H = <self modified>
C644 LD A,(HL) A = *HL
C645 AND A Set flags
C646 JR NZ,$C667 Jump if non-zero
C648 DEC L A = HL[-1]
C649 LD A,(HL)
C64A INC L
C64B EXX Bank/unbank
C64C LD E,A E = A
C64D AND $07 A &= 7
C64F RLCA A <<= 2
C650 RLCA
C651 ADD A,$00 A += <self modifed>
C653 LD L,A L = A
C654 LD A,E E = ((E >> 3) & 31) + B
C655 RRA
C656 RRA
C657 RRA
C658 AND $1F
C65A ADD A,B
C65B LD E,A
AND-OR masking here.
C65C LD A,(DE) A = *DE & *HL
C65D AND (HL)
C65E INC L L++
C65F OR (HL) *DE = A | *HL
C660 LD (DE),A
C661 INC L L += 2
C662 INC L
C663 INC E E++
C664 LDI *DE++ = *HL++, BC--
C666 EXX Bank/unbank
C667 INC B B++ -- counter?
C668 JR Z,$C68A Jump if zero -- exit?
C66A INC H H++
C66B LD A,(HL) A = *HL
C66C AND A Set flags
C66D JR NZ,$C667 Jump if non-zero
C66F DEC L A = HL[-1]
C670 LD A,(HL)
C671 INC L
C672 EXX Bank/unbank
C673 LD E,A E = A -- save A
C674 AND $07 L = ((A & 7) << 1) + <self modified>
C676 RLCA
C677 ADD A,$00
C679 LD L,A
C67A LD A,E E = ((E >> 3) & 31) + B
C67B RRA
C67C RRA
C67D RRA
C67E AND $1F
C680 ADD A,B
C681 LD E,A
C682 LDI *DE++ = *HL++, BC--
C684 LD A,(HL) A = *HL
C685 LD (DE),A *DE = A
C686 EXX Bank/unbank
C687 JP $C667 Jump -- looks like a loop
C68A LD H,$00 H = <self modified>
C68C LD A,(HL) A = *HL
C68D DEC L L--
C68E AND A Set flags
C68F JR NZ,$C6AB Jump if non-zero
C691 LD A,(HL) A = *HL
C692 EXX Bank/unbank
C693 LD E,A E = A -- save A
C694 AND $07 L = ((A & 7) << 2) + <self modified> -- as above but * 4
C696 RLCA
C697 RLCA
C698 ADD A,$11
C69A LD L,A
C69B LD A,E E = ((E >> 3) & 31) + B
C69C RRA
C69D RRA
C69E RRA
C69F AND $1F
C6A1 ADD A,B
C6A2 LD E,A
C6A3 LDI *DE++ = *HL++, BC--
AND-OR masking here. This affects road lines when altered.
C6A5 LD A,(DE) A = *DE & *HL
C6A6 AND (HL)
C6A7 INC L L++
C6A8 OR (HL) *DE = A | *HL
C6A9 LD (DE),A
C6AA EXX Bank/unbank
C6AB DEC L L--
C6AC DEC C C--
C6AD JP NZ,$0000 Jump to <self modified> if non-zero
C6B0 EX AF,AF' Swap
C6B1 LD B,A B = A
C6B2 LD A,$00 A = <self modified>
C6B4 XOR $01 A ^= 1
C6B6 LD ($C6B3),A Self modify above
C6B9 JP NZ,$C6D8 Jump if non-zero
C6BC LD A,$00 A = <self modified> ^ 0x55
C6BE XOR $55
C6C0 LD ($C6BD),A Self modify above
C6C3 LD B,A B = A
C6C4 LD A,($C652) Toggle bit 5 of x in 'ADD A,x' @ C651
C6C7 XOR $20
C6C9 LD ($C652),A
C6CC INC A A++
C6CD LD ($C699),A Self modify 'ADD A,x' @ C698
C6D0 LD A,($C678) Toggle <self modified> bits of 'ADD A,x' @ C677
C6D3 XOR $00
C6D5 LD ($C678),A
C6D8 LD A,$00 A = <self modified> -- self modified below
C6DA DEC A A--
C6DB LD ($C6D9),A Self modify 'LD A' @ C6D8 to be new A [above]
C6DE JP NZ,$C703 Jump if non-zero
C6E1 LD A,($C6D4) Read 'XOR x' @ C6D3
C6E4 ADD A,$10 A += 16
C6E6 JR C,$C703 Jump if carried
C6E8 LD ($C6D4),A Self modify 'XOR x' @ C6D3 to be new A
C6EB LD C,A C = A
C6EC LD A,($C678) Read 'ADD A,x' @ C677
C6EF AND A Set flags
C6F0 JR Z,$C6F6 Jump if zero
C6F2 LD A,C A = C
C6F3 LD ($C678),A Self modify 'ADD A,x' @ C677
C6F6 LD A,($C652) Read 'ADD A,x' @ C651
C6F9 ADD A,$40 A += 64
C6FB LD ($C652),A Self modify 'ADD A,x' @ C651
C6FE LD A,$05 Self modify 'LD A,x' @ C6D8 to be 5
C700 LD ($C6D9),A
C703 LD A,(IY+$00) A = IY[0]
C706 INC IY IY++
C708 INC IXl IX.low++
C70A SUB (IY+$00) A -= IY[0]
C70D JR Z,$C715 Jump if zero
C70F JP P,$C794 Jump if positive
C712 JP $C746 Jump
C715 DEC L L -= 2
C716 DEC L
C717 LD C,(IX+$00) C = IX[0]
C71A BIT 6,C Bit 6 of C set?
C71C JP Z,$C6B2 Jump if clear
C71F BIT 7,C Bit 7 of C set?
C721 JP NZ,$C6B2 Jump if set
C724 LD B,$FF B = 255
C726 BIT 2,C Bit 2 of C set?
C728 LD A,$01 A = 1
C72A JR Z,$C740 Jump if clear
C72C LD A,IYl A = IY.low
C72E LD ($C15E),A Self modify 'CP x' @ C15D [15 when tunnel is small, 6 when fills screen]
C731 LD A,$01 A = 1
C733 INC B B++
C734 BIT 4,C Bit 4 of C set?
C736 LD C,A C = A
C737 JR Z,$C73C Jump if clear
C739 DEC B B--
C73A INC A A++
C73B DEC C C--
C73C LD ($C161),A Self modify 'LD A,x' @ C160
C73F LD A,C A = C
C740 LD ($C890),A Self modify 'LD A,x' @ C88F
C743 JP $C6B2 Jump
Variation:
C746 LD C,(IX+$00) C = IX[0]
C749 BIT 6,C Bit 6 of C set?
C74B JP Z,$C774 Jump if clear
C74E BIT 7,C Bit 7 of C set?
C750 JP NZ,$C774 Jump if set
C753 EX AF,AF' Swap
C754 LD B,$FF B = 255
C756 BIT 2,C Bit 2 of C set?
C758 LD A,$01 A = 1
C75A JR Z,$C770 Jump if clear
C75C LD A,IYl A = IY.low
C75E LD ($C15E),A Self modify 'CP x' @ C15D [15 when tunnel is small, 6 when fills screen]
C761 LD A,$01 A = 1
C763 INC B B++
C764 BIT 4,C Bit 4 of C set?
C766 LD C,A C = A
C767 JR Z,$C76C Jump if clear
C769 DEC B B--
C76A INC A A++
C76B DEC C C--
C76C LD ($C161),A Self modify 'LD A,x' @ C160
C76F LD A,C A = C
C770 LD ($C890),A Self modify 'LD A,x' @ C88F
C773 EX AF,AF' Swap
C774 LD C,A C = A
C775 LD A,(IY+$00) A = IY[0]
C778 INC IY IY++
C77A INC IXl IX.low++
C77C SUB (IY+$00) A -= IY[0]
C77F CP $E0 Compare to $E0
C781 JP NC,$C788 Jump if A >= $E0
C784 CP $50 Compare to $50
C786 JR NC,$C79A Jump if A >= $50
C788 DEC L L -= 2
C789 DEC L
C78A ADD A,C A += C
C78B JR Z,$C746 Jump if zero or negative
C78D JP M,$C746
C790 LD C,A C = A
C791 JP main_loop_13_0 Jump
C794 LD C,A C = A
C795 CP $50 Compare to $50
C797 JP C,main_loop_13_0 Jump if A < $50
This entry point is used by the routines at CBA4 and CBC5.
C79A INC E E++
C79B LD HL,$C161 Address of x in 'LD A,x' @ C160
C79E LD A,($C890) Read 'LD A,x' @ C88F (TBD)
C7A1 OR (HL) A |= *HL
C7A2 RRA A >>= 1
C7A3 JP C,$C887 Jump if carry
C7A6 LD A,D A = D
C7A7 AND $0F A &= 15
C7A9 LD C,A C = A
C7AA LD A,E A = E
C7AB SRL A A >>= 1
C7AD ADD A,C A += C
C7AE CPL A = ~A
C7AF ADD A,$80 A += $80
C7B1 LD B,A B = A
C7B2 LD HL,($A171) HL = horizon_level
C7B5 LD C,$18 C = 24
C7B7 LD A,H A = H
C7B8 AND A Set flags
C7B9 JP M,$C887 Jump if negative
C7BC JR NZ,$C7CA Jump if non-zero
C7BE LD A,L A = L
C7BF SUB B A -= B
C7C0 JR NC,$C7CA Jump if A was >= B
C7C2 ADD A,C A += C
C7C3 JP NC,$C887 Jump if no carry
C7C6 JP Z,$C887 Jump if zero
C7C9 LD C,A C = A
C7CA LD A,C A = C
C7CB LD ($C80C),A Self modify xx in 'LD BC,$xxyy' @ C80A
C7CE ADD A,B A += B
C7CF JP P,$C7DB Jump if positive
C7D2 SUB $7F A -= 127
C7D4 NEG A = -A
C7D6 ADD A,C A += C
C7D7 LD ($C80C),A Self modify xx in 'LD BC,$xxyy' @ C80A
C7DA LD C,A C = A
C7DB LD A,C A = 24 - C
C7DC CPL
C7DD ADD A,$19
C7DF RLCA A <<= 1
C7E0 LD C,A C = A
C7E1 RLCA A <<= 2
C7E2 RLCA
C7E3 ADD A,C A += C
C7E4 LD C,A C = A
C7E5 LD B,$00 B = 0
C7E7 LD A,$00 A = <self modified> -- horizon shift value (ranges 0..19)
C7E9 RRA A >>= 1 -- deciding whether to use the shifted or non shifted backdrop
C7EA LD HL,$5B00 Point at first hill backdrop (shifted version)
C7ED JR NC,$C7F2 Jump if no carry
C7EF LD HL,$5C00 Point at second hill backdrop
C7F2 ADD HL,BC HL += BC
C7F3 EXX Bank/unbank
C7F4 ADD A,A A = 18 - A * 2
C7F5 CPL
C7F6 ADD A,$13
C7F8 LD ($C86D),A Self modify 'JR x' @ C86C -- jump table target
C7FB LD E,A DE = A
C7FC LD D,$00
C7FE LD HL,$86F6 Address of backdrop_shift_instrs
C801 ADD HL,DE HL += DE
C802 LD BC,$0012 BC = 18
C805 LD DE,$C82D Address in instruction stream
C808 LDIR Copy
C80A LD BC,$180A BC = $<self modified>0A
C80D EXX Bank/unbank
C80E LD A,L A = L
C80F EX AF,AF' Swap
C810 JP $C824 Jump
Scanline advance pattern.
C813 LD A,E E -= 32
C814 SUB $20
C816 LD E,A
C817 JP C,$C82A Jump if E < 32
C81A LD A,D D -= 16
C81B ADD A,$10
C81D LD D,A
C81E JP $C82A
C821 EXX Bank/unbank
C822 EX AF,AF' Swap
C823 LD E,A E = A
C824 LD A,D A = D
C825 DEC D D--
C826 AND $0F A &= 15
C828 JR Z,$C813 Jump if zero
This entry point is used by the routine at C813.
C82A LD A,E A = E
C82B EX AF,AF' Swap
C82C LD L,A L = A
C82D NOP 18 instructions/lines filled in by earlier code
C82E NOP
C82F NOP
C830 NOP
C831 NOP
C832 NOP
C833 NOP
C834 NOP
C835 NOP
C836 NOP
C837 NOP
C838 NOP
C839 NOP
C83A NOP
C83B NOP
C83C NOP
C83D NOP
C83E NOP
C83F LDI
C841 LD L,A
C842 LDI
C844 LDI
C846 LDI
C848 LDI
C84A LDI
C84C LDI
C84E LDI
C850 LDI
C852 LDI
C854 LDI
C856 LD L,A
C857 LDI
C859 LDI
C85B LDI
C85D LDI
C85F LDI
C861 LDI
C863 LDI
C865 LDI
C867 LDI
C869 LDI
C86B LD L,A
C86C JR $C86C Self modified - jump table
C86E LDI
C870 LDI
C872 LDI
C874 LDI
C876 LDI
C878 LDI
C87A LDI
C87C LDI
C87E LDI
C880 EXX
C881 ADD A,C A += C
C882 DJNZ $C821 Loop?
C884 EXX Bank/unbank
C885 EX AF,AF' Swap
C886 LD E,A E = A
This entry point is used by the routine at C598.
C887 EX DE,HL Swap
C888 LD A,L L += $1E
C889 ADD A,$1E
C88B LD L,A
C88C LD DE,$0000 Fill value for blank sky
C88F LD A,$00 A = <self modified>
C891 AND A Set flags
C892 JP Z,$C896 Jump if zero
C895 DEC DE DE-- -- $0000 -> $FFFF ?
C896 LD C,$0F C = 15
C898 LD A,H A = H
C899 DEC H H--
C89A AND C A &= C
C89B JR NZ,$C8AB Jump if non-zero -- draw blank scanline
C89D LD A,L L -= 32
C89E SUB $20
C8A0 LD L,A
C8A1 JR NC,$C8A7 Jump if no carry
C8A3 LD SP,$0000 Restore SP (self modified)
C8A6 RET Return
C8A7 LD A,H H += 16
C8A8 ADD A,$10
C8AA LD H,A
Writes DE to HL 15 times.
C8AB LD SP,HL Put it in SP (so we can use PUSH for speed)
C8AC PUSH DE Write 30 bytes
C8AD PUSH DE
C8AE PUSH DE
C8AF PUSH DE
C8B0 PUSH DE
C8B1 PUSH DE
C8B2 PUSH DE
C8B3 PUSH DE
C8B4 PUSH DE
C8B5 PUSH DE
C8B6 PUSH DE
C8B7 PUSH DE
C8B8 PUSH DE
C8B9 PUSH DE
C8BA PUSH DE
C8BB JP $C898 Loop
Prev: C58A Up: Map Next: C8BE