fork/m-overlay

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

BlazinZzettiAdd Support for Shadow the Hedgehog + Rom Hacks1f39dd3

master
1.3 KiB56 linesraw
1--Shadow The Hedgehog (NTSC-U)
2
3local core = require("games.core")
4
5local game = core.newGame(0x805A5810)
6
7local controllers = {
8	[1] = 0x805A5810,
9}
10
11local controller_struct = {
12		[0x0] = { type = "u16",		name = "controller.%d.buttons.pressed" },
13		[0x2] = { type = "sbyte",	name = "controller.%d.joystick.x" },
14		[0x3] = { type = "sbyte",	name = "controller.%d.joystick.y" },
15		[0x4] = { type = "sbyte",	name = "controller.%d.cstick.x" },
16		[0x5] = { type = "sbyte",	name = "controller.%d.cstick.y" },
17		[0x6] = { type = "byte",	name = "controller.%d.analog.l" },
18		[0x7] = { type = "byte",	name = "controller.%d.analog.r" },
19	}
20
21function game.translateJoyStick(x, y)
22	--Left = 25 <- 127
23	--Neutral = -128
24	--Right = -127 -> -25
25	if x > 0 
26		then
27			x = (math.abs(x)-127)/102
28			x = math.min(x, 1)
29		else 
30			x = -(math.abs(x)-127)/102
31			x = math.max(x,-1) 
32	end
33	if y > 0 
34		then 
35			y = (math.abs(y)-127)/102
36			y = math.min(y, 1)
37		else 
38			y = -(math.abs(y)-127)/102
39			y = math.max(y,-1) 
40	end
41	return x, y
42end
43 
44game.translateCStick = game.translateJoyStick
45 
46for port, address in ipairs(controllers) do
47	for offset, info in pairs(controller_struct) do
48		game.memorymap[address + offset] = {
49			type = info.type,
50			debug = info.debug,
51			name = info.name:format(port),
52		}
53	end
54end
55
56return game