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

main
1.2 KiB49 linesraw
1-- Super Monkey Ball 2 (NTSC v1.0)
2
3local core = require("games.core")
4
5local game = core.newGame()
6
7local controllers = {
8	[1] = 0x80145210 + 0x3C * 0,
9	[2] = 0x80145210 + 0x3C * 1,
10	[3] = 0x80145210 + 0x3C * 2,
11	[4] = 0x80145210 + 0x3C * 3,
12}
13
14local controller_struct = {
15	[0x0] = { type = "short",	name = "controller.%d.buttons.pressed" },
16	[0x2] = { type = "sbyte",	name = "controller.%d.joystick.x" },
17	[0x3] = { type = "sbyte",	name = "controller.%d.joystick.y" },
18	[0x4] = { type = "sbyte",	name = "controller.%d.cstick.x" },
19	[0x5] = { type = "sbyte",	name = "controller.%d.cstick.y" },
20	[0x6] = { type = "byte",	name = "controller.%d.analog.l" },
21	[0x7] = { type = "byte",	name = "controller.%d.analog.r" },
22	[0xA] = { type = "byte",	name = "controller.%d.plugged" },
23}
24
25for port, address in ipairs(controllers) do
26	for offset, info in pairs(controller_struct) do
27		game.memorymap[address + offset] = {
28			type = info.type,
29			debug = info.debug,
30			name = info.name:format(port),
31		}
32	end
33end
34
35function game.translateJoyStick(x, y)
36	x = x/100
37	y = y/100
38	return x,y
39end
40
41game.translateCStick = game.translateJoyStick
42
43local min = math.min
44
45function game.translateTriggers(l, r)
46	return min(1, l/125), min(1, r/125)
47end
48
49return game