Pseudorandom number generator image: Difference between revisions

no edit summary
No edit summary
Line 19:
*   Linear congruential generator [https://en.wikipedia.org/wiki/Linear_congruential_generator].
<br><br>
 
=={{header|6502 Assembly}}==
===6502js/easy6502===
The "hardware" gives us a memory-mapped port at address $00FE which contains a different random number every clock cycle. We can use this to write to video memory (there are only 16 colors so the top 4 bits of the random value are ignored.)
<lang 6502asm>define vramPtr $00
define vramPtrHi $01
main:
;we're guaranteed to start off with all registers zeroed.
STA vramPtr
LDA #$02
STA vramPtrHi
LDX #4
loop:
LDA $FE ;read a random byte from the port
STA (vramPtr),y
INY
BNE loop
INC vramPtrHi
DEX
bne loop
brk ;end program</lang>
 
Output can be seen by copying/pasting the above code [https://skilldrick.github.io/easy6502/ here.]
 
 
 
=={{header|Delphi}}==
1,489

edits