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.4 KiB59 linesraw
1-- Billy Hatcher and the Giant Egg (NTSC-U v1.0)
2
3local core = require("games.core")
4
5local game = core.newGame()
6
7local addr = 0x80279822
8local off = 0x40
9
10local controllers = {
11	[1] = addr + off * 0,
12	[2] = addr + off * 1,
13	[3] = addr + off * 2,
14	[4] = addr + off * 3,
15}
16
17local controller_struct = {
18	[0x00] = { type = "u16",	name = "controller.%d.buttons.pressed" },
19	[0x16] = { type = "u16",	name = "controller.%d.analog.r" },
20	[0x18] = { type = "u16",	name = "controller.%d.analog.l" },
21	[0x1A] = { type = "u16",	name = "controller.%d.joystick.x" },
22	[0x1C] = { type = "u16",	name = "controller.%d.joystick.y" },
23	[0x1E] = { type = "u16",	name = "controller.%d.cstick.x" },
24	[0x20] = { type = "u16",	name = "controller.%d.cstick.y" },
25	[0x32] = { type = "byte",	name = "controller.%d.plugged" },
26}
27
28for port, address in ipairs(controllers) do
29	for offset, info in pairs(controller_struct) do
30		game.memorymap[address + offset] = {
31			type = info.type,
32			debug = info.debug,
33			name = info.name:format(port),
34		}
35	end
36end
37
38local function convertAxis(a)
39	if a > 0xFF then
40		a = a - 0xFFFF - 1
41	end
42	return a
43end
44
45game.translateJoyStick = function(x, y)
46	x = convertAxis(x)
47	y = convertAxis(y)
48	return x/100, y/100
49end
50
51game.translateCStick = function(x, y)
52	x = convertAxis(x)
53	y = convertAxis(y)
54	return x/44, y/44
55end
56
57game.translateTriggers = function(l, r) return l/150, r/150 end
58
59return game