Skip to navigation

Maths (Arithmetic): GetNextSeed0To22

Name: GetNextSeed0To22 [Show more] Type: Subroutine Category: Maths (Arithmetic) Summary: Set A to the next number from the landscape's sequence of seed numbers, converted to the range 0 to 22
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * GenerateLandscape calls GetNextSeed0To22 * SpawnTrees calls GetNextSeed0To22
.GetNextSeed0To22 JSR GetNextSeedNumber \ Set A to the next number from the landscape's sequence \ of seed numbers PHA \ Set T to bits 0-2 of A AND #%00000111 \ STA T \ So T is a number in the range 0 to 7 PLA LSR A \ Set A to bits 3-6 of A and clear the C flag LSR A \ AND #%00011110 \ So T is a number in the range 0 to 15 LSR A ADC T \ Set A = A + T \ \ So A is a number in the range 0 to 22 RTS \ Return from the subroutine