1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-21 23:30:58 +00:00
8bitworkshop/test/ecs/random.ecs
2022-02-27 19:46:33 -06: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