-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrng.lua
48 lines (41 loc) · 1.3 KB
/
rng.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- if the emulator is at a path like: path/to/dtemu.exe
-- then put this in a path like: path/to/modules/rng.lua
-- interrupt values
local INT_GENERATE = 0;
local INT_SEED = 1;
function interrupt(cpu)
-- cpu is a table that lets you do things to the CPU.
if (cpu.registers.A == INT_GENERATE) then
cpu.registers.B = math.random(0x0, 0xFFFF);
elseif (cpu.registers.A == INT_SEED) then
math.randomseed(cpu.registers.B);
end
end
function cycle(cpu)
-- cpu is a table that lets you do things to the CPU.
-- according to hardware standards, this is not called
-- until the first interrupt has been received and handled,
-- however at the moment the toolchain ignores this
-- requirement and it's called anyway :P
--[[print(string.format("0x%X", cpu.ram[0x0]))
print(cpu.registers.Z)
print(cpu.registers.PC)
cpu.registers.Z = math.random(0x0, 0xFFFF);
cpu.ram[0x0] = 0x0;]]--
end
function write(cpu, pos)
-- cpu is a table that lets you do things to the CPU.
-- pos is the memory address that was written to.
end
MODULE = {
Type = "Hardware",
Name = "RNG Hardware",
Version = "1.0",
SDescription = "The random number generator device",
URL = "http://dcputoolcha.in/docs/modules/list/rng.html"
};
HARDWARE = {
ID = 0x739df773,
Version = 0x0001,
Manufacturer = 0x93765997
};