I'm trying to load a random background of 8x8 tiles. I first get a random number by the amount of time it takes the player to press start on the start screen by adding to the seed:
Code: Select all
Start_Controls:
LDA seed2
CLC
ADC #$01
STA seed2
LDA seed2+1
CLC
ADC #$03
STA seed2+1
LDA buttons1
AND #%00010000
BEQ Start_ControlsDone
Code: Select all
LDA #$00
STA Point+0
STA Point+1
BGTORAM:
LDA $6000
ASL
TAY
LDA bg_point+0,y
STA Point+0
LDA bg_point+1,y
STA Point+1
LDX #$04
LDY #$00
TYA
PHA
PRNG_MAP:
LDY #$08
LDA seed2+0
One:
ASL
ROL seed2+1
BCC Two
EOR #$39
Two:
DEY
BNE One
STA seed2+0
CMP #$00
LDA seed2
CMP #$0C
BCC LoadRock ; if seed2 < 12:
CMP #$AA
BCC LoadGrass ;if seed2 < 170 and is greater than 12
CMP #$FF
BCC LoadTree ;if seed2 < 255 and is greater than 170
JMP BGDone
LoadRock:
PLA
TAY
LDA #$3B ;Rock tile
STA (Point), y
JMP LoadCycle
LoadGrass:
PLA
TAY
LDA #$00 ;Grass tile
STA (Point), y
JMP LoadCycle
LoadTree:
PLA
TAY
LDA #$04 ;Tree tile
STA (Point), y
LoadCycle:
INY
TYA
PHA
CPY #$00
BNE PRNG_MAP
INC Point+1
DEX
BNE PRNG_MAP
BGDone:
Code: Select all
bg_point:
.dw $6000
Does this have to do with my "random" seed where it is getting set to 0 at some point? Or is my PRNG_MAP routine funky? Any suggestions would be great!