1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-27 14:29:39 +00:00
8bitworkshop/test/ecs/random.ecs

36 lines
457 B
Plaintext
Raw Normal View History

2022-02-28 01:46:26 +00:00
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