fork/m-overlay

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

BkacjiosMerge pull request #197 from NicholasMoser/master6dbc289

main
1.3 KiB52 linesraw
1-- Naruto - Clash of Ninja Revolution 3 (PAL v1.0)
2
3local core = require("games.core")
4
5local game = core.newGame()
6
7local polling_addresses = {
8	0x803BE480,
9	0x803BE4B0,
10}
11
12local controllers = {
13	[1] = 0xC * 0,
14	[2] = 0xC * 1,
15	[3] = 0xC * 2,
16	[4] = 0xC * 3,
17}
18
19local controller_struct = {
20	[0x0] = { type = "short",	name = "controller.%d.buttons.pressed" },
21	[0x2] = { type = "sbyte",	name = "controller.%d.joystick.x" },
22	[0x3] = { type = "sbyte",	name = "controller.%d.joystick.y" },
23	[0x4] = { type = "sbyte",	name = "controller.%d.cstick.x" },
24	[0x5] = { type = "sbyte",	name = "controller.%d.cstick.y" },
25	[0x6] = { type = "byte",	name = "controller.%d.analog.l" },
26	[0x7] = { type = "byte",	name = "controller.%d.analog.r" },
27	[0xA] = { type = "byte",	name = "controller.%d.plugged" },
28}
29
30for _, polling_addr in ipairs(polling_addresses) do
31	-- For every polling address..
32	for port, controller_addr in ipairs(controllers) do
33		-- For every controller 
34		for offset, info in pairs(controller_struct) do
35			game.memorymap[polling_addr + controller_addr + offset] = {
36				type = info.type,
37				debug = info.debug,
38				name = info.name:format(port),
39			}
40		end
41	end
42end
43
44function game.translateJoyStick(x, y)
45	x = x/100
46	y = y/100
47	return x, y
48end
49
50game.translateCStick = game.translateJoyStick
51
52return game