Prev: 5DEC Up: Map Next: 5EFE
5E00: Move the trees
Used by the routines at 65B3, 663D, 69E3 and 6AC2.
5E00 LD A,($5DE8) Is the bike moving?
5E03 DEC A Invert flag
5E04 RET NZ Return if the bike isn't moving
5E05 LD A,($64F3) Get the next bit pattern
5E08 AND A
5E09 RRCA Shift from "all odds" <-> "all evens"
5E0A LD ($64F3),A
5E0D JR NC,$5E21 If "evens" -> "odds", don't generate trees
5E0F CALL $6491 Generate a random number, return the next item in A
5E12 LD H,$5B Get the portion of trees to copy
5E14 AND $7F Position back to the start of the line
5E16 ADD A,$20
5E18 LD L,A
5E19 LD DE,$7CBE Put the new line of trees on the back row
5E1C LD BC,$001E
5E1F LDDR
5E21 LD HL,$7F7F Shift the other lines up one so they appear closer
5E24 LD DE,$7F9F
5E27 LD BC,$02E0
5E2A LDDR
As trees get closer to the player, shunt the left out to the side, to emulate the correct perspective view
5E2C XOR A
5E2D LD B,$0D 13 rows
5E2F LD HL,$7F62 Point to next row
5E32 LD DE,$7F61
5E35 LD A,$0E 14 columns
5E37 PUSH BC
5E38 PUSH DE
5E39 LD B,$00
5E3B LD C,A
5E3C LDIR
5E3E DEC L
5E3F LD (HL),$00
5E41 POP HL
5E42 LD DE,$FFE0
5E45 ADD HL,DE
5E46 PUSH HL
5E47 INC HL
5E48 POP DE
5E49 POP BC
5E4A BIT 1,B
5E4C JR Z,$5E51
5E4E DEC A
5E4F JR Z,$5E53
5E51 DJNZ $5E37
5E53 LD B,$0D
5E55 LD HL,$7F7D
5E58 LD DE,$7F7E
5E5B LD A,$0D
5E5D PUSH BC
5E5E PUSH DE
5E5F LD B,$00
5E61 LD C,A
5E62 LDDR
5E64 INC L
5E65 LD (HL),$00
5E67 POP HL
5E68 LD DE,$FFE0
5E6B ADD HL,DE
5E6C PUSH HL
5E6D DEC HL
5E6E POP DE
5E6F POP BC
5E70 BIT 1,B
5E72 JR Z,$5E77
5E74 DEC A
5E75 JR Z,$5E79
5E77 DJNZ $5E5D
As trees get closer to the player, shunt the right out to the side, to emulate the correct perspective view
5E79 XOR A
5E7A LD B,$06
5E7C LD HL,$7CA0
5E7F LD DE,$7CA1
5E82 LD (HL),A
5E83 LD BC,$001F
5E86 LDIR
5E88 LD HL,$7F42
5E8B LD DE,$7F41
5E8E LD BC,$000E
5E91 LDIR
5E93 LD (DE),A
5E94 LD DE,$7F61
5E97 LD HL,$7F62
5E9A LD BC,$000E
5E9D LDIR
5E9F LD (DE),A
5EA0 LD HL,$7F7D
5EA3 LD DE,$7F7E
5EA6 LD BC,$000D
5EA9 LDDR
5EAB LD (DE),A Don't put two trees next to each other
5EAC LD HL,$7F40
5EAF LD BC,$0040
5EB2 LD A,$40
5EB4 CPIR
5EB6 DEC HL
5EB7 LD (HL),$00
5EB9 INC HL
5EBA LD A,B
5EBB OR C
5EBC JR NZ,$5EB2
5EBE LD HL,$7F40
5EC1 LD BC,$0040
5EC4 LD A,$20
5EC6 CPIR
5EC8 LD (HL),$40
5ECA LD A,B
5ECB OR C
5ECC JR NZ,$5EC4
5ECE XOR A
5ECF LD B,$04
5ED1 PUSH BC
5ED2 LD HL,$7F81
5ED5 LD DE,$7F80
5ED8 LD BC,$000F
5EDB LDIR
5EDD LD (DE),A
5EDE POP BC
5EDF DJNZ $5ED1
Expand out the closest trees to take up more area, as perspective view would anticipate
5EE1 LD BC,$0020
5EE4 LD A,$20
5EE6 LD HL,$7F80
5EE9 CPIR
5EEB LD (HL),$20
5EED INC HL
5EEE LD (HL),$40
5EF0 INC HL
5EF1 LD (HL),$40
5EF3 LD DE,$7F9E
5EF6 EX DE,HL
5EF7 AND A
5EF8 SBC HL,DE
5EFA EX DE,HL
5EFB JR NC,$5EE9
5EFD RET
Prev: 5DEC Up: Map Next: 5EFE