1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-23 06:32:11 +00:00
8bitworkshop/presets/vcs/ecs/random.ecs
2022-06-30 13:31:29 -05:00

36 lines
457 B
Plaintext

component Random8
seed: 0..255 default 1 // TODO: default = 1, or seed?
end
system Random
on nextrand8 do foreach [Random8]
---
lda {{<seed}}
lsr
bcc :+
eor #$d4
:
sta {{<seed}}
---
on prevrand8 do foreach [Random8]
---
lda {{<seed}}
asl
bcc :+
eor #$a9
:
sta {{<seed}}
---
/* add entropy via joystick inputs */
on preframe do foreach [Random8]
---
lda {{<seed}}
eor SWCHA
beq :+
sta {{<seed}}
:
---
end