fork/m-overlay

git clone https://git.julia.blue/fork/m-overlay

BkacjiosMerge pull request #144 from UltiNaruto/masterd80c92c

v2.1.1a
984 B39 linesraw
1-- Metroid Prime (NTSC v1.1)
2
3local core = require("games.core")
4
5local game = core.newGame()
6
7-- Pointer to a struct that contains the controller data
8local game_data_loc = 0x804578DC
9
10local controller_struct = {
11	[0x0] = { type = "short",	name = "%d.buttons.pressed" },
12	[0x2] = { type = "sbyte",	name = "%d.joystick.x" },
13	[0x3] = { type = "sbyte",	name = "%d.joystick.y" },
14	[0x4] = { type = "sbyte",	name = "%d.cstick.x" },
15	[0x5] = { type = "sbyte",	name = "%d.cstick.y" },
16	[0x6] = { type = "byte",	name = "%d.analog.l" },
17	[0x7] = { type = "byte",	name = "%d.analog.r" },
18	[0xA] = { type = "byte",	name = "%d.plugged" },
19}
20
21local controller_ptr = {
22	type = "pointer",
23	name = "controller",
24	struct = {}
25}
26
27for i=1,4 do
28	for offset, info in pairs(controller_struct) do
29		controller_ptr.struct[0x04 + (0xC * (i-1)) + offset] = {
30			type = info.type,
31			debug = info.debug,
32			name = info.name:format(i),
33		}
34	end
35end
36
37game.memorymap[game_data_loc] = controller_ptr
38
39return game