fork/m-overlay

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

BkacjiosUpdated a bunch of joystick translations to match games x/y values between -1 and 17277dd1

v2.1.1b
1.4 KiB57 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 = core.newGame()
8
9local ptr_addr = 0x809B8F4C --> addr + 0x08 -> addr + 0x0A -> the controller structs
10local ctrl_offset = 0xB0
11
12local controllers = { -- TODO: fix port issues
13	ctrl_offset * 0,
14	ctrl_offset * 1,
15	ctrl_offset * 2,
16	ctrl_offset * 3,
17}
18
19local controller_struct = {
20	[0x00] = { type = "short",	name = "%d.buttons.pressed" },
21	[0x02] = { type = "float",	name = "%d.joystick.x" },
22	[0x06] = { type = "float",	name = "%d.joystick.y" },
23	[0x96] = { type = "float",	name = "%d.cstick.x" },
24	[0x9A] = { type = "float",	name = "%d.cstick.y" },
25	[0x8C] = { type = "byte",	name = "%d.analog.l" },
26	[0x8D] = { type = "byte",	name = "%d.analog.r" },
27	[0x90] = { type = "byte",	name = "%d.plugged" },
28}
29
30game.memorymap[ptr_addr] = {
31	type = "pointer";
32	name = "controller";
33	struct = {
34		[0x08] = {
35			type = "pointer";
36			struct = {}
37		}
38	}
39}
40
41local ptr_offset = 0x0A
42local controller_ptr = game.memorymap[ptr_addr].struct[0x08].struct
43
44for port, address in ipairs(controllers) do
45	for offset, info in pairs(controller_struct) do
46		controller_ptr[ptr_offset + address + offset] = {
47            type = info.type;
48            debug = info.debug;
49            name = info.name:format(port);
50        }
51    end
52end
53
54game.translateJoyStick = function(x, y) return x, y end
55game.translateCStick = function(x, y) return x, y end
56
57return game