fork/m-overlay

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

BkacjiosMerge pull request #185 from MORImementos/mainlined568a79

main
1.5 KiB48 linesraw
1-- Mario Superstar Baseball (NTSC-U v1.0)
2
3local core = require("games.core")
4
5local game = core.newGame()
6
7-- local controllers = {
8-- 	[1] = 0x8026BB60 + 0x10 * 0,
9-- 	[2] = 0x8026BB60 + 0x10 * 1,
10-- 	[3] = 0x8026BB60 + 0x10 * 2,
11-- 	[4] = 0x8026BB60 + 0x10 * 3,
12-- }
13
14local controllers = {
15	[1] = 0x803C77B8 + 0x20 * 0,
16	[2] = 0x803C77B8 + 0x20 * 1,
17	[3] = 0x803C77B8 + 0x20 * 2,
18	[4] = 0x803C77B8 + 0x20 * 3,
19}
20
21local controller_struct = {
22	[0x00] = { type = "u16",	name = "controller.%d.buttons.pressed" },
23	[0x02] = { type = "u16",	name = "controller.%d.buttons.instant" },
24	[0x04] = { type = "u16",	name = "controller.%d.buttons.pressed_previous" },
25	[0x08] = { type = "u8",		name = "controller.%d.plugged" },
26	[0x10] = { type = "sbyte",	name = "controller.%d.joystick.x" },
27	[0x11] = { type = "sbyte",	name = "controller.%d.joystick.y" },
28	[0x12] = { type = "sbyte",	name = "controller.%d.cstick.x" },
29	[0x13] = { type = "sbyte",	name = "controller.%d.cstick.y" },
30	[0x14] = { type = "u8",		name = "controller.%d.analog.l" },
31	[0x15] = { type = "u8",		name = "controller.%d.analog.r" },
32}
33
34for port, address in ipairs(controllers) do
35	for offset, info in pairs(controller_struct) do
36		game.memorymap[address + offset] = {
37			type = info.type,
38			debug = info.debug,
39			name = info.name:format(port),
40		}
41	end
42end
43
44game.translateJoyStick = function(x, y) return x/72, y/72 end
45game.translateCStick = function(x, y) return x/59, y/59 end
46game.translateTriggers = function(l, r) return l/150, r/150 end
47
48return game