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.2
1.3 KiB55 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	0x80222DDC,
12	0x80222E10,
13}
14
15local controllers = {
16	[1] = 0x40 * 0,
17	[2] = 0x40 * 1,
18	[3] = 0x40 * 2,
19	[4] = 0x40 * 3,
20}
21
22local controller_struct = {
23	[0x0] = { type = "short",	name = "controller.%d.buttons.pressed" },
24	[0x2] = { type = "sbyte",	name = "controller.%d.joystick.x" },
25	[0x3] = { type = "sbyte",	name = "controller.%d.joystick.y" },
26	[0x4] = { type = "sbyte",	name = "controller.%d.cstick.x" },
27	[0x5] = { type = "sbyte",	name = "controller.%d.cstick.y" },
28	[0x6] = { type = "byte",	name = "controller.%d.analog.l" },
29	[0x7] = { type = "byte",	name = "controller.%d.analog.r" },
30	[0xA] = { type = "byte",	name = "controller.%d.plugged" },
31}
32
33for _, polling_addr in ipairs(polling_addresses) do
34	-- For every polling address..
35	for port, controller_addr in ipairs(controllers) do
36		-- For every controller 
37		for offset, info in pairs(controller_struct) do
38			game.memorymap[polling_addr + controller_addr + offset] = {
39				type = info.type,
40				debug = info.debug,
41				name = info.name:format(port),
42			}
43		end
44	end
45end
46
47function game.translateJoyStick(x, y)
48	x = x/100
49	y = y/100
50	return x, y
51end
52
53game.translateCStick = game.translateJoyStick
54
55return game