fork/m-overlay

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

BkacjiosMerge branch 'master' of https://github.com/bkacjios/m-overlay0b8a1a7

settings-overhaul
1.4 KiB59 linesraw
1-- Mario Kart Wii (NTSC-U, v1.0) (Issue #17)
2
3-- Code based on RSBE01-2.lua
4
5local core = require("games.core")
6
7local game = {
8	memorymap = {}
9}
10
11local ptr_addr = 0x809B8F4C --> addr + 0x08 -> addr + 0x0A -> the controller structs
12local ctrl_offset = 0xB0
13
14local controllers = { -- TODO: fix port issues
15	ctrl_offset * 0,
16	ctrl_offset * 1,
17	ctrl_offset * 2,
18	ctrl_offset * 3,
19}
20
21local controller_struct = {
22	[0x00] = { type = "short",	name = "%d.buttons.pressed" },
23	[0x02] = { type = "float",	name = "%d.joystick.x" },
24	[0x06] = { type = "float",	name = "%d.joystick.y" },
25	[0x96] = { type = "float",	name = "%d.cstick.x" },
26	[0x9A] = { type = "float",	name = "%d.cstick.y" },
27	[0x8C] = { type = "byte",	name = "%d.analog.l" },
28	[0x8D] = { type = "byte",	name = "%d.analog.r" },
29	[0x90] = { type = "byte",	name = "%d.plugged" },
30}
31
32game.memorymap[ptr_addr] = {
33	type = "pointer";
34	name = "controller";
35	struct = {
36		[0x08] = {
37			type = "pointer";
38			struct = {}
39		}
40	}
41}
42
43local ptr_offset = 0x0A
44local controller_ptr = game.memorymap[ptr_addr].struct[0x08].struct
45
46for port, address in ipairs(controllers) do
47	for offset, info in pairs(controller_struct) do
48		controller_ptr[ptr_offset + address + offset] = {
49            type = info.type;
50            debug = info.debug;
51            name = info.name:format(port);
52        }
53    end
54end
55
56game.translateAxis = function(x, y) return x, y end
57game.translateTriggers = core.translateTriggers
58
59return game