fork/m-overlay

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

BkacjiosFinal small changes7342549

main
13.5 KiB388 linesraw
1-- Super Smash Bros. Melee (NTSC v1.2) / Dairantou Smash Brothers DX (Japan v1.2)
2
3local core = require("games.core")
4
5local game = core.newGame()
6
7-- Controls/Saves the volume levels of the game
8game.memorymap[0x8045C384] = { type = "s8", name = "volume.slider" } -- Scale is (-100 to 100)
9
10-- You can change these values in real time to change the volume, but when opening the sound menu, it will readjust to the slider value above
11game.memorymap[0x804D3887] = { type = "u8", name = "volume.music" } -- Scale is (0-127)
12game.memorymap[0x804D388F] = { type = "u8", name = "volume.ui" } -- Scale is (0-127)
13
14game.memorymap[0x80479D60] = { type = "u32", name = "frame" }
15
16game.memorymap[0x80479D30] = { type = "u8", name = "scene.major", debug = true }
17game.memorymap[0x80479D31] = { type = "u8", name = "scene.major2" }
18game.memorymap[0x80479D32] = { type = "u8", name = "scene.major_prev" }
19game.memorymap[0x80479D33] = { type = "u8", name = "scene.minor", debug = true }
20game.memorymap[0x80479D34] = { type = "u8", name = "scene.minor_prev" }
21
22game.memorymap[0x804D6598] = { type = "u8", name = "menu.player_one_port" } -- What port is currently acting as "Player 1" in single player games
23game.memorymap[0x804807C8] = { type = "bool", name = "menu.teams" }
24
25game.memorymap[0x804A04F0] = { type = "u8", name = "menu.id" }
26game.memorymap[0x804A04F1] = { type = "u8", name = "menu.id_prev" }
27game.memorymap[0x804A04F3] = { type = "u8", name = "menu.selection" }
28game.memorymap[0x804A04F4] = { type = "u8", name = "menu.value" }
29
30game.memorymap[0x804D5F90] = { type = "u32", name = "rng.seed" }
31
32local controllers = {
33	[1] = 0x804C1FAC + 0x44 * 0,
34	[2] = 0x804C1FAC + 0x44 * 1,
35	[3] = 0x804C1FAC + 0x44 * 2,
36	[4] = 0x804C1FAC + 0x44 * 3,
37}
38
39local controller_struct = {
40	[0x00] = { type = "u32",	name = "controller.%d.buttons.pressed" },
41	[0x04] = { type = "u32",	name = "controller.%d.buttons.pressed_previous" },
42	[0x08] = { type = "u32",	name = "controller.%d.buttons.instant" },
43	[0x10] = { type = "u32",	name = "controller.%d.buttons.released" },
44	[0x1C] = { type = "u8",		name = "controller.%d.analog.byte.l" },
45	[0x1D] = { type = "u8",		name = "controller.%d.analog.byte.r" },
46	[0x20] = { type = "float",	name = "controller.%d.joystick.x" },
47	[0x24] = { type = "float",	name = "controller.%d.joystick.y" },
48	[0x28] = { type = "float",	name = "controller.%d.cstick.x" },
49	[0x2C] = { type = "float",	name = "controller.%d.cstick.y" },
50	[0x30] = { type = "float",	name = "controller.%d.analog.l" },
51	[0x34] = { type = "float",	name = "controller.%d.analog.r" },
52	[0x41] = { type = "u8",		name = "controller.%d.plugged" },
53}
54
55for port, address in ipairs(controllers) do
56	for offset, info in pairs(controller_struct) do
57		game.memorymap[address + offset] = {
58			type = info.type,
59			debug = info.debug,
60			name = info.name:format(port),
61		}
62	end
63end
64
65local player_static_addresses = {
66	0x80453080, -- Player 1
67	0x80453F10, -- Player 2
68	0x80454DA0, -- Player 3
69	0x80455C30, -- Player 4
70	0x80456AC0, -- Player 5
71	0x80457950, -- Player 6
72}
73
74local entity_pointer_offsets = {
75	[0xB0] = "entity",
76	[0xB4] = "partner", -- Partner entity (For sheik/zelda/iceclimbers)
77}
78
79local player_static_struct = {
80	[0x004] = { type = "u32", name = "character" },
81	[0x008] = { type = "u32", name = "mode" },
82	[0x00C] = { type = "u16", name = "transformed" },
83	[0x044] = { type = "u8", name = "skin" },
84	--[0x045] = { type = "u8", name = "port" },
85	[0x046] = { type = "u8", name = "color" },
86	[0x047] = { type = "u8", name = "team" },
87	--[0x048] = { type = "u8", name = "index" },
88	[0x049] = { type = "u8", name = "cpu_level" },
89	[0x04A] = { type = "u8", name = "cpu_type" }, -- 4 = 20XX, 22 = normalish, 19 = Alt Normal
90}
91
92for id, address in ipairs(player_static_addresses) do
93	for offset, info in pairs(player_static_struct) do
94		game.memorymap[address + offset] = {
95			type = info.type,
96			debug = info.debug,
97			name = ("player.%i.%s"):format(id, info.name),
98		}
99	end
100
101	for offset, name in pairs(entity_pointer_offsets) do
102		game.memorymap[address + offset] = {
103			type = "pointer",
104			name = ("player.%i.%s"):format(id, name),
105			struct = {
106				[0x60 + 0x0004] = { type = "u32", name = "character" },
107				--[0x60 + 0x000C] = { type = "u8", name = "port" },
108				--[0x60 + 0x0618] = { type = "u8", name = "index" },
109				[0x60 + 0x0619] = { type = "u8", name = "skin" },
110				[0x60 + 0x061A] = { type = "u8", name = "color" },
111				[0x60 + 0x061B] = { type = "u8", name = "team" },
112
113				[0x60 + 0x0620] = { type = "float", name = "controller.joystick.x" },
114				[0x60 + 0x0624] = { type = "float", name = "controller.joystick.y" },
115				[0x60 + 0x0638] = { type = "float", name = "controller.cstick.x" },
116				[0x60 + 0x063C] = { type = "float", name = "controller.cstick.y" },
117				[0x60 + 0x0650] = { type = "float", name = "controller.analog.float" },
118				[0x60 + 0x065C] = { type = "u32",	name = "controller.buttons.pressed" },
119				[0x60 + 0x0660] = { type = "u32",	name = "controller.buttons.pressed_previous" },
120
121				--[[
122				[0x60 + 0x1A94] = { type = "u32", name = "cpu_type" },
123				[0x60 + 0x1A98] = { type = "u32", name = "cpu_level" },
124				]]
125			},
126		}
127	end
128end
129
130-- https://github.com/project-slippi/slippi-ssbm-asm/blob/9c36ffc5e4787c6caadfb12727c5fcff07d64642/Online/Online.s#L29
131local CSSDT_BUF_ADDR = 0x80005614
132
133game.memorymap[CSSDT_BUF_ADDR] = {
134	type = "pointer",
135	name = "slippi",
136	debug = true,
137	struct = {
138		-- https://github.com/project-slippi/slippi-ssbm-asm/blob/9c36ffc5e4787c6caadfb12727c5fcff07d64642/Online/Online.s#L253
139		[0x000] = {
140			type = "pointer",
141			--name = "slippi_ptr",
142			debug = true,
143			struct = {
144				[0x00] = { type = "u8", name = "connection_state" },					-- 1
145				[0x01] = { type = "bool", name = "local_player.ready" },				-- 1
146				[0x02] = { type = "bool", name = "remote_player.ready" },				-- 1
147				[0x03] = { type = "u8", name = "local_player.index", debug = true },	-- 1
148				[0x04] = { type = "u8", name = "remote_player.index" },					-- 1
149				[0x05] = { type = "u32", name = "rng_offset" },							-- 4
150				[0x09] = { type = "u8", name = "delay_frames" },						-- 1
151				[0x0A] = { type = "u8", name = "local_player.chatmsg_id" },				-- 1
152				[0x0B] = { type = "u8", name = "opponent.chatmsg_id" },					-- 1
153				[0x0C] = { type = "u8", name = "chatmsg.index" },						-- 1
154				[0x0D] = { type = "u32", name = "vs.left_names" },						-- 4
155				[0x11] = { type = "u32", name = "vs.right_names" },						-- 4
156				-- [0x15] = { type = "string-jis", len = 31, name = "local_player.name" },	-- 31
157				-- [0x34] = { type = "string-jis", len = 31, name = "players.1.name" },	-- 31
158				-- [0x53] = { type = "string-jis", len = 31, name = "players.2.name" },	-- 31
159				-- [0x72] = { type = "string-jis", len = 31, name = "players.3.name" },	-- 31
160				-- [0x91] = { type = "string-jis", len = 31, name = "players.4.name" },	-- 31
161				-- [0xB0] = { type = "string-jis", len = 31, name = "opponent.name" },		-- 31
162				-- [0xCF] = { type = "string-jis", len = 10, name = "players.1.code" },	-- 10
163				-- [0xD9] = { type = "string-jis", len = 10, name = "players.2.code" },	-- 10
164				-- [0xE3] = { type = "string-jis", len = 10, name = "players.3.code" },	-- 10
165				-- [0xED] = { type = "string-jis", len = 10, name = "players.4.code" },	-- 10
166				-- [0xF7] = { type = "string", len = 29, name = "players.1.uuid", debug = true },		-- 29
167				-- [0x114] = { type = "string", len = 29, name = "players.2.uuid", debug = true },		-- 29
168				-- [0x131] = { type = "string", len = 29, name = "players.3.uuid", debug = true },		-- 29
169				-- [0x14E] = { type = "string", len = 29, name = "players.4.uuid", debug = true },		-- 29
170				-- [0x16B] = { type = "string", len = 241, name = "error_msg", debug = true },			-- 241
171				-- [0x25C] = { type = "data", len = 241, name = "game_info", debug = true },				-- 241
172				-- [0x34D] = { type = "data", len = 51, name = "match_id", debug = true },				-- 51
173			}
174		},
175	}
176}
177
178-- https://github.com/project-slippi/slippi-ssbm-asm/blob/9c36ffc5e4787c6caadfb12727c5fcff07d64642/Online/Online.s#L10
179local ONLINE_BUF_ADDR = 0x804D6CBC
180
181game.memorymap[ONLINE_BUF_ADDR] = {
182	type = "pointer",
183	name = "online",
184	debug = true,
185	struct = {
186		-- https://github.com/project-slippi/slippi-ssbm-asm/blob/9c36ffc5e4787c6caadfb12727c5fcff07d64642/Online/Online.s#L182-L225
187		[0x07] = { type = "u32", name = "rng_offset" }
188	}
189}
190
191-- Where character ID's are stored in the CSS menu
192local player_select_external_addresses = {
193	0x8043208B,
194	0x80432093,
195	0x8043209B,
196	0x804320A3,
197}
198
199local player_select_external = {
200	[0x04] = "character",
201	[0x05] = "skin",
202}
203
204for id, address in ipairs(player_select_external_addresses) do
205	for offset, name in pairs(player_select_external) do
206		game.memorymap[address + offset] = {
207			debug = true,
208			type = "u8",
209			name = ("player.%i.select.%s"):format(id, name),
210		}
211	end
212end
213
214local player_card_addresses = {
215	0x803F0E06,
216	0x803F0E2A,
217	0x803F0E4E,
218	0x803F0E72,
219}
220
221local player_card = {
222	[0x00] = "team",
223	[0x01] = "mode",
224	--[0x02] = "mode2", -- Duplicate?
225	[0x03] = "skin",
226	[0x04] = "character",
227	[0x05] = "hovered",
228}
229
230for id, address in ipairs(player_card_addresses) do
231	for offset, name in pairs(player_card) do
232		game.memorymap[address + offset] = {
233			type = "byte",
234			name = ("player.%i.card.%s"):format(id, name),
235		}
236	end
237end
238
239-- 0x80480530 = Only for VS matches?
240-- 0x80480590 = PlayerDATA
241
242-- MATCH = 8046b6a0
243
244local match_info = 0x8046B6A0
245local match_info_struct = {
246	[0x00] = { type = "u8", name = "match.info.state" },
247	[0x01] = { type = "u8", name = "match.info.pauser" },
248	[0x05] = { type = "bool", name = "match.info.playing", debug = true },
249	[0x08] = { type = "u8", name = "match.info.result", debug = true },
250	[0x0E] = { type = "bool", name = "match.info.finished", debug = true },
251	[0x24] = { type = "u32", name = "match.info.timer.frames" },
252	[0x28] = { type = "u32", name = "match.info.timer.seconds" },
253	[0x2C] = { type = "u16", name = "match.info.timer.millis" },
254}
255
256for offset, info in pairs(match_info_struct) do
257	game.memorymap[match_info + offset] = info
258end
259
260local match_init_addr = 0x24C8
261local match_init_struct = {
262	[0x00] = { type = "u8", name = "match.settings.flags.1" },
263	--[[
264		TIMER = bit.band(flags, 3)
265
266		0: TIMER_FROZEN
267		1: TIMER_HIDDEN
268		2: TIMER_COUNT_DOWN
269		3: TIMER_COUNT_UP
270
271		HUDPOS = bit.band(bit.rshift(flags, 2), 7)
272
273		0: MATCH_HUDPOS_NONE
274		1: MATCH_HUDPOS_ONE
275		2: MATCH_HUDPOS_TWO
276		3: MATCH_HUDPOS_THREE
277		4: MATCH_HUDPOS_FOUR
278		5: MATCH_HUDPOS_SIX
279		6: MATCH_HUDPOS_UNK
280		7: MATCH_HUDPOS_FOURCOMPACT
281
282		MATCH = bit.band(bit.rshift(flags, 5), 7)
283
284		0: MODE_TIME
285		1: MODE_STOCK
286		2: MODE_COIN
287		3: MODE_BONUS
288	]]
289	[0x01] = { type = "u8", name = "match.settings.flags.2" },
290	--[[
291		0x01: UNKNOWN_2
292		0x02: TIMER_UNKOWN
293		0x04: UNKNOWN_3
294		0x08: DISABLE_MUSIC
295		0x10: HIDE_GO
296		0x20: HIDE_READY
297		0x40: UNKNOWN_4
298		0x80: TIMER_UNKNOWN
299	]]
300	[0x02] = { type = "u8", name = "match.settings.flags.3" },
301	--[[
302		0x01: UNKNOWN_5
303		0x02: CREATE_HUD
304		0x04: UNKNOWN_7
305		0x08: DISABLE_PAUSE
306		0x10: SINGLE_BUTTON
307		0x20: UNKNOWN_8
308		0x40: DISABLE_OFFSCREEN_DAMAGE
309		0x80: UNKNOWN_9
310	]]
311	[0x03] = { type = "u8", name = "match.settings.flags.4" },
312	--[[
313		0x01: TIMER_RUN_ON_PAUSE
314		0x02: TIMER_HIDE_ON_PAUSE
315		0x04: SHOW_LRAS
316		0x08: CHECK_LRAS
317		0x10: SHOW_RETRY
318		0x20: CHECK_RETRY
319		0x40: SHOW_ANALOG_STICK
320		0x80: SHOW_SCORE
321	]]
322	[0x04] = { type = "u8", name = "match.settings.flags.5" },
323	--[[
324		0x01 - 0x10: UNKNOWN_10
325		0x20: RUN_STOCK_LOGIC
326		0x40: CHECK_STOCK_STEAL
327		0x80: UNKNOWN_11
328	]]
329	[0x05] = { type = "u8", name = "match.settings.flags.6" },
330	--[[
331		0x01 - 0x10: UNKNOWN_12
332		0x20: NO_HIT
333		0x40: SKIP_UKNONWN_STOCK_CHECK
334		0x80: NO_CHECK_END
335	]]
336	[0x06] = { type = "bool", name = "match.settings.bombrain" },
337	[0x08] = { type = "bool", name = "match.settings.teams" },
338	[0x0B] = { type = "s8", name = "match.settings.item_frequency" },
339	[0x0C] = { type = "s8", name = "match.settings.self_destruct" },
340	[0x0E] = { type = "short", name = "match.settings.stage" },
341	[0x10] = { type = "u32", name = "match.settings.timer.seconds" },
342	[0x14] = { type = "u8", name = "match.settings.timer.millis" },
343
344	[0x28] = { type = "float", name = "match.settings.quake_multiplier" },
345	[0x2C] = { type = "float", name = "match.settings.damage_ratio" },
346	[0x30] = { type = "float", name = "match.settings.match_speed" },
347}
348
349for offset, info in pairs(match_init_struct) do
350	game.memorymap[match_info + match_init_addr + offset] = info
351end
352
353game.memorymap[0x804D640F] = { type = "bool", name = "match.info.paused" }
354
355local stage_info_addr = 0x8049E6C8
356local stage_info_struct = {
357	[0x0088] = { type = "int", name = "stage.id", debug = true },
358	[0x06D4] = { type = "short", name = "stage.targets" },
359	[0x06E0] = { type = "float", name = "stage.homerun_distance" },
360}
361for offset, info in pairs(stage_info_struct) do
362	game.memorymap[stage_info_addr + offset] = info
363end
364
365local player_cursors_pointers = {
366	0x804A0BC0,
367	0x804A0BC4,
368	0x804A0BC8,
369	0x804A0BCC,
370}
371
372local player_cursor_struct = {
373	--[0x00] = { type = "u32", name = "unknown_ptr" },
374	[0x05] = { type = "u8", name = "state" }, -- The state of the pointer (0 = in the bottom area, 1 = holding coin, 2 = empty hand)
375	[0x0B] = { type = "u8", name = "b_frame_counter" }, -- How many frames the player is holding B for (At 32, it will forcibly exit back to the menus)
376	[0x0C] = { type = "float", name = "position.x" },
377	[0x10] = { type = "float", name = "position.y" },
378}
379
380for port, addr in pairs(player_cursors_pointers) do
381	game.memorymap[addr] = { type = "pointer", name = ("player.%i.cursor"):format(port), struct = player_cursor_struct }
382end
383
384game.translateJoyStick = function(x, y) return x, y end
385game.translateCStick = function(x, y) return x, y end
386game.translateTriggers = function(l, r) return l, r end
387
388return game