Prev: 64B3 Up: Map Next: 64F4
64B7: Recalculate new tree density based on sector
Used by the routines at 65B3 and 69E3.
64B7 XOR A Clear $5B00 - $5BFF
64B8 LD H,$5B
64BA LD L,A
64BB LD B,A
64BC LD (HL),A
64BD INC L
64BE DJNZ $64BC
64C0 LD A,($5DD1) Get the sector number
64C3 LD HL,$64AB Point to the tree density buffer at 64AB
64C6 DEC A Move to the right entry
64C7 JR Z,$64CC
64C9 INC HL
64CA JR $64C6
64CC LD B,(HL) Store it in B
64CD CALL $6491 Get a random location
64D0 LD L,A
64D1 LD H,$5B
64D3 LD (HL),$20 Put a tree in it
64D5 DJNZ $64CD Return for however many more trees we need
64D7 LD HL,$5B00 Go to the start of the buffer
64DA LD B,$00
64DC PUSH BC
64DD PUSH HL
64DE LD B,$03
64E0 LD A,(HL) Get current buffer position
64E1 CP $20 Is there a tree here?
64E3 JR NZ,$64ED Move on if not
64E5 INC L Is there a tree next to it?
64E6 CP (HL)
64E7 JR NZ,$64EB Move on if not
64E9 LD (HL),$00 Don't put trees next to each other
64EB DJNZ $64E5
64ED POP HL
64EE POP BC
64EF INC HL
64F0 DJNZ $64DC
64F2 RET
Prev: 64B3 Up: Map Next: 64F4