Code: Select all
GENERATERANDOM:
LDX RANDOMSEED
LDA COLOR,X
AND #240
CLC
ROR
ROR
ROR
ROR
STA TEMP1
LDA COLOR+256,X
AND #240
ORA TEMP1
INC RANDOMSEED
RTS
RANDOMSEED is another memory location that is always being INCremented by 1 when the program waits for you to press a key so because of the unpredictability of when a player presses the key, it is always a value between 0 to 255.
I've noticed that the upper nibble of the SCREEN COLOR memory map generates a sequence of fairly random numbers. So that, in combination with a randomized position from RANDOMSEED should produce stuff that is fairly 'random' right?
Right now I'm writing the code to create characters.
I'll probably use a Linear feedback shift register when I want to generate mazes.