fork/m-overlay

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

BkacjiosAdded support for Super Monkey Ball 2 Print M'Overlay version along with other version info on startup62b54b1

settings-overhaul
1.5 KiB60 linesraw
1-- Super Monkey Ball 2 (NTSC v1.0)
2
3local core = require("games.core")
4
5local game = {
6	memorymap = {}
7}
8
9local controllers = {
10	[1] = 0x80145210 + 0x3C * 0,
11	[2] = 0x80145210 + 0x3C * 1,
12	[3] = 0x80145210 + 0x3C * 2,
13	[4] = 0x80145210 + 0x3C * 3,
14}
15
16local controller_struct = {
17	[0x0] = { type = "short",	name = "controller.%d.buttons.pressed" },
18	[0x2] = { type = "sbyte",	name = "controller.%d.joystick.x" },
19	[0x3] = { type = "sbyte",	name = "controller.%d.joystick.y" },
20	[0x4] = { type = "sbyte",	name = "controller.%d.cstick.x" },
21	[0x5] = { type = "sbyte",	name = "controller.%d.cstick.y" },
22	[0x6] = { type = "byte",	name = "controller.%d.analog.l" },
23	[0x7] = { type = "byte",	name = "controller.%d.analog.r" },
24	[0xA] = { type = "byte",	name = "controller.%d.plugged" },
25}
26
27for port, address in ipairs(controllers) do
28	for offset, info in pairs(controller_struct) do
29		game.memorymap[address + offset] = {
30			type = info.type,
31			debug = info.debug,
32			name = info.name:format(port),
33		}
34	end
35end
36
37local abs = math.abs
38
39-- These functions seem to apply to many games
40
41function game.translateAxis(x, y)
42	x = x/100
43	y = y/100
44
45	local near = 1 - (abs(abs(x) - abs(y))) * 0.100
46
47	local angle = math.atan2(x, y)
48	local mag = math.sqrt(x*x + y*y)
49
50	-- Reduce the magnitute when x,y values are headed towards a diagonal
51	return x + math.sin(angle) * mag * near * 0.25, y + math.cos(angle) * mag * near * 0.25
52end
53
54local min = math.min
55
56function game.translateTriggers(l, r)
57	return min(1, l/125), min(1, r/125)
58end
59
60return game