fork/m-overlay

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

BkacjiosMerge pull request #197 from NicholasMoser/master6dbc289

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