fork/m-overlay

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

BkacjiosMusic support for Beyond Melee (#95)2efdb91

settings-overhaul
34.7 KiB1245 linesraw
1local memory = require("memory")
2local color = require("util.color")
3
4MATCH_NO_RESULT = 0x00
5MATCH_GAME = 0x02
6MATCH_STAGE_CLEAR = 0x03
7MATCH_STAGE_FAILURE = 0x04
8MATCH_STAGE_CLEAR3 = 0x05
9MATCH_NEW_RECORD = 0x06
10MATCH_NO_CONTEST = 0x07
11MATCH_RETRY = 0x08
12MATCH_GAME_CLEAR = 0x09
13
14-- MAJOR FLAGS
15MENU_TITLE_SCREEN = 0x00
16MENU_MAIN_MENU = 0x01
17MENU_VS_MODE = 0x02
18
19	-- MINOR FLAGS
20	MENU_VS_CSS = 0x0
21	MENU_VS_SSS = 0x1
22	MENU_VS_INGAME = 0x2
23	MENU_VS_POSTGAME = 0x4
24
25MENU_CLASSIC_MODE = 0x03
26
27	MENU_CLASSIC_LEVEL_1_VS  = 0x00
28	MENU_CLASSIC_LEVEL_1 = 0x01
29	MENU_CLASSIC_LEVEL_2_VS = 0x02
30	MENU_CLASSIC_LEVEL_2 = 0x03
31	MENU_CLASSIC_LEVEL_3_VS = 0x04
32	MENU_CLASSIC_LEVEL_3 = 0x05
33	MENU_CLASSIC_LEVEL_4_VS = 0x06
34	MENU_CLASSIC_LEVEL_4 = 0x07
35	MENU_CLASSIC_LEVEL_5_VS = 0x08
36	MENU_CLASSIC_LEVEL_5 = 0x09
37	MENU_CLASSIC_LEVEL_5_VS = 0x10
38	MENU_CLASSIC_LEVEL_5 = 0x09
39
40	MENU_CLASSIC_LEVEL_16 = 0x20
41	MENU_CLASSIC_LEVEL_16_VS = 0x21
42
43	MENU_CLASSIC_LEVEL_24 = 0x30
44	MENU_CLASSIC_LEVEL_24_VS = 0x31
45
46	MENU_CLASSIC_BREAK_THE_TARGETS_INTRO = 0x16
47	MENU_CLASSIC_BREAK_THE_TARGETS = 0x17
48
49	MENU_CLASSIC_TROPHY_STAGE_INTRO = 0x28
50	MENU_CLASSIC_TROPHY_STAGE_TARGETS = 0x29
51
52	MENU_CLASSIC_RACE_TO_FINISH_INTRO = 0x40
53	MENU_CLASSIC_RACE_TO_FINISH_TARGETS = 0x41
54
55	MENU_CLASSIC_LEVEL_56 = 0x38
56	MENU_CLASSIC_LEVEL_56_VS = 0x39
57
58	MENU_CLASSIC_MASTER_HAND = 0x51
59
60	MENU_CLASSIC_CONTINUE = 0x69
61	MENU_CLASSIC_CSS = 0x70
62
63MENU_ADVENTURE_MODE = 0x04
64
65	MENU_ADVENTURE_MUSHROOM_KINGDOM_INTRO = 0x00
66	MENU_ADVENTURE_MUSHROOM_KINGDOM = 0x01
67	MENU_ADVENTURE_MUSHROOM_KINGDOM_LUIGI = 0x02
68	MENU_ADVENTURE_MUSHROOM_KINGDOM_BATTLE = 0x03
69
70	MENU_ADVENTURE_MUSHROOM_KONGO_JUNGLE_INTRO = 0x08
71	MENU_ADVENTURE_MUSHROOM_KONGO_JUNGLE_TINY_BATTLE = 0x09
72	MENU_ADVENTURE_MUSHROOM_KONGO_JUNGLE_GIANT_BATTLE = 0x0A
73
74	MENU_ADVENTURE_UNDERGROUND_MAZE_INTRO = 0x10
75	MENU_ADVENTURE_UNDERGROUND_MAZE = 0x11
76	MENU_ADVENTURE_HYRULE_TEMPLE_BATTLE = 0x12
77
78	MENU_ADVENTURE_BRINSTAR_INTRO = 0x18
79	MENU_ADVENTURE_BRINSTAR = 0x19
80
81	MENU_ADVENTURE_ESCAPE_ZEBES_INTRO = 0x1A
82	MENU_ADVENTURE_ESCAPE_ZEBES = 0x1B
83	MENU_ADVENTURE_ESCAPE_ZEBES_ESCAPE = 0x1C
84
85	MENU_ADVENTURE_GREEN_GREENS_INTRO = 0x20
86	MENU_ADVENTURE_GREEN_GREENS_KIRBY_BATTLE = 0x21
87	MENU_ADVENTURE_GREEN_GREENS_KIRBY_TEAM_INTRO = 0x22
88	MENU_ADVENTURE_GREEN_GREENS_KIRBY_TEAM_BATTLE = 0x23
89	MENU_ADVENTURE_GREEN_GREENS_GIANT_KIRBY_INTRO = 0x24
90	MENU_ADVENTURE_GREEN_GREENS_GIANT_KIRBY_BATTLE = 0x25
91
92	MENU_ADVENTURE_CORNARIA_INTRO = 0x28
93	MENU_ADVENTURE_CORNARIA_BATTLE_1 = 0x29
94	MENU_ADVENTURE_CORNARIA_RAID = 0x2A
95	MENU_ADVENTURE_CORNARIA_BATTLE_2 = 0x2B
96	MENU_ADVENTURE_CORNARIA_BATTLE_3 = 0x2C
97
98	MENU_ADVENTURE_POKEMON_STADIUM_INTRO = 0x30
99	MENU_ADVENTURE_POKEMON_STADIUM_BATTLE = 0x31
100
101	MENU_ADVENTURE_FZERO_GRAND_PRIX_CARS = 0x38
102	MENU_ADVENTURE_FZERO_GRAND_PRIX_INTRO = 0x39
103	MENU_ADVENTURE_FZERO_GRAND_PRIX_RACE = 0x3A
104	MENU_ADVENTURE_FZERO_GRAND_PRIX_BATTLE = 0x3B
105
106	MENU_ADVENTURE_ONETT_INTRO = 0x40
107	MENU_ADVENTURE_ONETT_BATTLE = 0x41
108
109	MENU_ADVENTURE_ICICLE_MOUNTAIN_INTRO = 0x48
110	MENU_ADVENTURE_ICICLE_MOUNTAIN_CLIMB = 0x49
111
112	MENU_ADVENTURE_BATTLEFIELD_INTRO = 0x50
113	MENU_ADVENTURE_BATTLEFIELD_BATTLE = 0x51
114	MENU_ADVENTURE_BATTLEFIELD_METAL_INTRO = 0x52
115	MENU_ADVENTURE_BATTLEFIELD_METAL_BATTLE = 0x53
116
117	MENU_ADVENTURE_FINAL_DESTINATION_INTRO = 0x58
118	MENU_ADVENTURE_FINAL_DESTINATION_BATTLE = 0x59
119	MENU_ADVENTURE_FINAL_DESTINATION_POSE = 0x5A
120	MENU_ADVENTURE_FINAL_DESTINATION_WINNER = 0x5B
121
122	MENU_ADVENTURE_CSS = 0x70
123
124MENU_ALL_STAR_MODE = 0x05
125	MENU_ALL_STAR_LEVEL_1 = 0x00
126	MENU_ALL_STAR_REST_AREA_1 = 0x01
127	MENU_ALL_STAR_LEVEL_2 = 0x02
128	MENU_ALL_STAR_REST_AREA_2 = 0x03
129	MENU_ALL_STAR_LEVEL_3 = 0x04
130	MENU_ALL_STAR_REST_AREA_3 = 0x05
131	MENU_ALL_STAR_LEVEL_4 = 0x06
132	MENU_ALL_STAR_REST_AREA_4 = 0x07
133	MENU_ALL_STAR_LEVEL_5 = 0x08
134	MENU_ALL_STAR_REST_AREA_5 = 0x09
135	MENU_ALL_STAR_LEVEL_6 = 0x10
136	MENU_ALL_STAR_REST_AREA_6 = 0x11
137	MENU_ALL_STAR_LEVEL_7 = 0x12
138	MENU_ALL_STAR_REST_AREA_7 = 0x13
139	MENU_ALL_STAR_LEVEL_8 = 0x14
140	MENU_ALL_STAR_REST_AREA_8 = 0x15
141	MENU_ALL_STAR_LEVEL_9 = 0x16
142	MENU_ALL_STAR_REST_AREA_9 = 0x17
143	MENU_ALL_STAR_LEVEL_10 = 0x18
144	MENU_ALL_STAR_REST_AREA_10 = 0x19
145	MENU_ALL_STAR_LEVEL_11 = 0x20
146	MENU_ALL_STAR_REST_AREA_11 = 0x21
147	MENU_ALL_STAR_LEVEL_12 = 0x22
148	MENU_ALL_STAR_REST_AREA_12 = 0x23
149	MENU_ALL_STAR_LEVEL_13 = 0x24
150	MENU_ALL_STAR_REST_AREA_13 = 0x25
151	MENU_ALL_STAR_LEVEL_14 = 0x26
152	MENU_ALL_STAR_REST_AREA_14 = 0x27
153	MENU_ALL_STAR_LEVEL_15 = 0x28
154	MENU_ALL_STAR_REST_AREA_15 = 0x29
155	MENU_ALL_STAR_LEVEL_16 = 0x30
156	MENU_ALL_STAR_REST_AREA_16 = 0x31
157	MENU_ALL_STAR_LEVEL_17 = 0x32
158	MENU_ALL_STAR_REST_AREA_17 = 0x33
159	MENU_ALL_STAR_LEVEL_18 = 0x34
160	MENU_ALL_STAR_REST_AREA_18 = 0x35
161	MENU_ALL_STAR_LEVEL_19 = 0x36
162	MENU_ALL_STAR_REST_AREA_19 = 0x37
163	MENU_ALL_STAR_LEVEL_20 = 0x38
164	MENU_ALL_STAR_REST_AREA_20 = 0x39
165	MENU_ALL_STAR_LEVEL_21 = 0x40
166	MENU_ALL_STAR_REST_AREA_21 = 0x41
167	MENU_ALL_STAR_LEVEL_22 = 0x42
168	MENU_ALL_STAR_REST_AREA_22 = 0x43
169	MENU_ALL_STAR_LEVEL_23 = 0x44
170	MENU_ALL_STAR_REST_AREA_23 = 0x45
171	MENU_ALL_STAR_LEVEL_24 = 0x46
172	MENU_ALL_STAR_REST_AREA_24 = 0x47
173	MENU_ALL_STAR_LEVEL_25 = 0x48
174	MENU_ALL_STAR_REST_AREA_25 = 0x49
175	MENU_ALL_STAR_LEVEL_26 = 0x50
176	MENU_ALL_STAR_REST_AREA_26 = 0x51
177	MENU_ALL_STAR_LEVEL_27 = 0x52
178	MENU_ALL_STAR_REST_AREA_28 = 0x53
179	MENU_ALL_STAR_LEVEL_29 = 0x54
180	MENU_ALL_STAR_REST_AREA_29 = 0x55
181	MENU_ALL_STAR_LEVEL_30 = 0x56
182	MENU_ALL_STAR_REST_AREA_30 = 0x57
183	MENU_ALL_STAR_LEVEL_31 = 0x58
184	MENU_ALL_STAR_REST_AREA_31 = 0x59
185	MENU_ALL_STAR_LEVEL_32 = 0x60
186	MENU_ALL_STAR_REST_AREA_32 = 0x61
187
188	MENU_ALL_STAR_CSS = 0x70
189
190MENU_DEBUG = 0x06
191MENU_SOUND_TEST = 0x07
192
193MENU_VS_UNKNOWN = 0x08 -- SLIPPI ONLINE
194	MENU_VS_UNKNOWN_CSS = 0x00
195	MENU_VS_UNKNOWN_SSS = 0x01
196	MENU_VS_UNKNOWN_INGAME = 0x02
197	MENU_VS_UNKNOWN_VERSUS = 0x04
198
199MENU_UNKOWN_1 = 0x09
200MENU_CAMERA_MODE = 0x0A
201MENU_TROPHY_GALLERY = 0x0B
202MENU_TROPHY_LOTTERY = 0x0C
203MENU_TROPHY_COLLECTION = 0x0D
204MENU_START_MATCH = 0x0E -- Slippi Replays
205	MENU_START_MATCH_INGAME = 0x01 -- Set when the replay is actually playing out
206	MENU_START_MATCH_UNKNOWN = 0x03 -- Seems to be set right before the match loads
207
208MENU_TARGET_TEST = 0x0F
209	MENU_TARGET_TEST_CSS = 0x00
210	MENU_TARGET_TEST_INGAME = 0x1
211
212MENU_SUPER_SUDDEN_DEATH = 0x10
213	MENU_SSD_CSS = 0x00
214	MENU_SSD_SSS = 0x01
215	MENU_SSD_INGAME = 0x02
216	MENU_SSD_POSTGAME = 0x04
217
218MENU_INVISIBLE_MELEE = 0x11
219	MENU_INVISIBLE_MELEE_CSS = 0x00
220	MENU_INVISIBLE_MELEE_SSS = 0x01
221	MENU_INVISIBLE_MELEE_INGAME = 0x02
222	MENU_INVISIBLE_MELEE_POSTGAME = 0x04
223
224MENU_SLOW_MO_MELEE = 0x12
225	MENU_SLOW_MO_MELEE_CSS = 0x00
226	MENU_SLOW_MO_MELEE_SSS = 0x01
227	MENU_SLOW_MO_MELEE_INGAME = 0x02
228	MENU_SLOW_MO_MELEE_POSTGAME = 0x04
229
230MENU_LIGHTNING_MELEE = 0x13
231	MENU_LIGHTNING_MELEE_CSS = 0x00
232	MENU_LIGHTNING_MELEE_SSS = 0x01
233	MENU_LIGHTNING_MELEE_INGAME = 0x02
234	MENU_LIGHTNING_MELEE_POSTGAME = 0x04
235
236MENU_CHARACTER_APPROACHING = 0x14
237
238MENU_CLASSIC_MODE_COMPLETE = 0x15
239	MENU_CLASSIC_MODE_TROPHY = 0x00
240	MENU_CLASSIC_MODE_CREDITS = 0x01
241	MENU_CLASSIC_MODE_CHARACTER_VIDEO = 0x02
242	MENU_CLASSIC_MODE_CONGRATS = 0x03
243
244MENU_ADVENTURE_MODE_COMPLETE = 0x16
245	MENU_ADVENTURE_MODE_TROPHY = 0x00
246	MENU_ADVENTURE_MODE_CREDITS = 0x01
247	MENU_ADVENTURE_MODE_CHARACTER_VIDEO = 0x02
248	MENU_ADVENTURE_MODE_CONGRATS = 0x03
249
250MENU_ALL_STAR_COMPLETE = 0x17
251	MENU_ALL_STAR_TROPHY = 0x00
252	MENU_ALL_STAR_CREDITS = 0x01
253	MENU_ALL_STAR_CHARACTER_VIDEO = 0x02
254	MENU_ALL_STAR_CONGRATS = 0x03
255
256MENU_TITLE_SCREEN_IDLE = 0x18
257	MENU_TITLE_SCREEN_IDLE_INTRO_VIDEO = 0x0
258	MENU_TITLE_SCREEN_IDLE_FIGHT_1 = 0x1
259	MENU_TITLE_SCREEN_IDLE_BETWEEN_FIGHTS = 0x2
260	MENU_TITLE_SCREEN_IDLE_FIGHT_2 = 0x3
261	MENU_TITLE_SCREEN_IDLE_HOW_TO_PLAY = 0x4
262
263MENU_ADVENTURE_MODE_CINEMEATIC = 0x19
264MENU_CHARACTER_UNLOCKED = 0x1A
265
266MENU_TOURNAMENT = 0x1B
267	MENU_TOURNAMENT_CSS = 0x0
268	MENU_TOURNAMENT_BRACKET = 0x1
269	MENU_TOURNAMENT_INGAME = 0x4
270	MENU_TOURNAMENT_POSTGAME = 0x6
271
272MENU_TRAINING_MODE = 0x1C
273	MENU_TRAINING_CSS = 0x0
274	MENU_TRAINING_SSS = 0x1
275	MENU_TRAINING_INGAME = 0x2
276
277MENU_TINY_MELEE = 0x1D
278	MENU_TINY_MELEE_CSS = 0x0
279	MENU_TINY_MELEE_SSS = 0x1
280	MENU_TINY_MELEE_INGAME = 0x2
281	MENU_TINY_MELEE_POSTGAME = 0x4
282
283MENU_GIANT_MELEE = 0x1E
284	MENU_GIANT_MELEE_CSS = 0x0
285	MENU_GIANT_MELEE_SSS = 0x1
286	MENU_GIANT_MELEE_INGAME = 0x2
287	MENU_GIANT_MELEE_POSTGAME = 0x4
288
289MENU_STAMINA_MODE = 0x1F
290	MENU_STAMINA_MODE_CSS = 0x0
291	MENU_STAMINA_MODE_SSS = 0x1
292	MENU_STAMINA_MODE_INGAME = 0x2
293	MENU_STAMINA_MODE_POSTGAME = 0x4
294
295MENU_HOME_RUN_CONTEST = 0x20
296	MENU_HOME_RUN_CONTEST_CSS = 0x0
297	MENU_HOME_RUN_CONTEST_INGAME = 0x1
298
299MENU_10_MAN_MELEE = 0x21
300	MENU_10_MAN_MELEE_CSS = 0x00
301	MENU_10_MAN_MELEE_INGAME = 0x01
302
303MENU_100_MAN_MELEE = 0x22
304	MENU_100_MAN_MELEE_CSS = 0x00
305	MENU_100_MAN_MELEE_INGAME = 0x01
306
307MENU_3_MINUTE_MELEE = 0x23
308	MENU_3_MINUTE_MELEE_CSS = 0x00
309	MENU_3_MINUTE_MELEE_INGAME = 0x01
310
311MENU_15_MINUTE_MELEE = 0x24
312	MENU_15_MINUTE_MELEE_CSS = 0x00
313	MENU_15_MINUTE_MELEE_INGAME = 0x01
314
315MENU_ENDLESS_MELEE = 0x25
316	MENU_ENDLESS_MELEE_CSS = 0x00
317	MENU_ENDLESS_MELEE_INGAME = 0x01
318
319MENU_CRUEL_MELEE = 0x26
320	MENU_CRUEL_MELEE_CSS = 0x00
321	MENU_CRUEL_MELEE_INGAME = 0x01
322	
323MENU_PROGRESSIVE_SCAN = 0x27
324MENU_PLAY_INTRO_VIDEO = 0x28
325MENU_MEMORY_CARD_OVERWRITE = 0x29
326
327MENU_FIXED_CAMERA_MODE = 0x2A
328	MENU_FIXED_CAMERA_MODE_CSS = 0x0
329	MENU_FIXED_CAMERA_MODE_SSS = 0x1
330	MENU_FIXED_CAMERA_MODE_INGAME = 0x2
331	MENU_FIXED_CAMERA_MODE_POSTGAME = 0x4
332
333MENU_EVENT_MATCH = 0x2B
334	MENU_EVENT_MATCH_SELECT = 0x0
335	MENU_EVENT_MATCH_INGAME = 0x1
336
337MENU_SINGLE_BUTTON_MODE = 0x2C
338
339local character_selections = {
340	[0x00] = {
341		name = "captain",
342		skin = {"original", "black", "red", "white", "green", "blue", "teal"},
343		team_skin = {3, 6, 5},
344		series = "fzero"
345	},
346	[0x01] = {
347		name = "donkey",
348		skin = {"original", "black", "red", "blue", "green", "gold"},
349		team_skin = {3, 4, 5},
350		series = "donkey_kong"
351	},
352	[0x02] = {
353		name = "fox",
354		skin = {"original", "red", "blue", "green", "gold"},
355		team_skin = {2, 3, 4},
356		series = "star_fox"
357	},
358	[0x03] = {
359		name = "gamewatch",
360		skin = {"original", "red", "blue", "green", "white"},
361		team_skin = {2, 3, 4},
362		series = "game_and_watch"
363	},
364	[0x04] = {
365		name = "kirby",
366		skin = {"original", "yellow", "blue", "red", "green", "white", "purple"},
367		team_skin = {4, 3, 5},
368		series = "kirby"
369	},
370	[0x05] = {
371		name = "koopa",
372		skin = {"green", "red", "blue", "black", "orange"},
373		team_skin = {2, 3, 1},
374		series = "mario"
375	},
376	[0x06] = {
377		name = "link",
378		skin = {"green", "red", "blue", "black", "white", "gold"},
379		team_skin = {2, 3, 1},
380		series = "zelda"
381	},
382	[0x07] = {
383		name = "luigi",
384		skin = {"green", "white", "blue", "red", "purple"},
385		team_skin = {4, 3, 1},
386		series = "mario"
387	},
388	[0x08] = {
389		name = "mario",
390		skin = {"red", "yellow", "black", "blue", "green", "teal"},
391		team_skin = {1, 4, 5},
392		series = "mario"
393	},
394	[0x09] = {
395		name = "marth",
396		skin = {"original", "red", "green", "black", "white", "gold"},
397		team_skin = {2, 1, 3},
398		series = "fire_emblem"
399	},
400	[0x10] = {
401		name = "samus",
402		skin = {"red", "pink", "black", "green", "blue", "teal"},
403		team_skin = {1, 5, 4},
404		series = "metroid"
405	},
406	[0x11] = {
407		name = "yoshi",
408		skin = {"green", "red", "blue", "yellow", "pink", "light_blue", "black"},
409		team_skin = {2, 3, 1},
410		series = "yoshi"
411	},
412	[0x12] = {
413		name = "zelda",
414		skin = {"original", "red", "blue", "green", "white", "gold"},
415		team_skin = {2, 3, 4},
416		series = "zelda"
417	},
418	[0x13] = {
419		name = "sheik",
420		skin = {"original", "red", "blue", "green", "white", "gold"},
421		team_skin = {2, 3, 4},
422		series = "zelda"
423	},
424	[0x14] = {
425		name = "falco",
426		skin = {"original", "red", "blue", "green", "pink"},
427		team_skin = {2, 3, 4},
428		series = "star_fox"
429	},
430	[0x15] = {
431		name = "younglink",
432		skin = {"green", "red", "blue", "white", "black", "purple"},
433		team_skin = {2, 3, 1},
434		series = "zelda"
435	},
436	[0x16] = {
437		name = "mariod",
438		skin = {"white", "red", "blue", "green", "black", "purple"},
439		team_skin = {2, 3, 4},
440		series = "mario"
441	},
442	[0x17] = {
443		name = "roy",
444		skin = {"original", "red", "blue", "green", "yellow", "purple"},
445		team_skin = {2, 3, 4},
446		series = "fire_emblem"
447	},
448	[0x18] = {
449		name = "pichu",
450		skin = {"original", "red", "blue", "green", "hat"},
451		team_skin = {2, 3, 4},
452		series = "pokemon"
453	},
454	[0x19] = {
455		name = "ganon",
456		skin = {"original", "red", "blue", "green", "purple", "gold"},
457		team_skin = {2, 3, 4},
458		series = "zelda"
459	},
460	[0x0A] = {
461		name = "mewtwo",
462		skin = {"original", "red", "blue", "green", "black"},
463		team_skin = {2, 3, 4},
464		series = "pokemon"
465	},
466	[0x0B] = {
467		name = "ness",
468		skin = {"original", "yellow", "blue", "green", "pink"},
469		team_skin = {1, 3, 4},
470		series = "earthbound"
471	},
472	[0x0C] = {
473		name = "peach",
474		skin = {"original", "daisy", "white", "blue", "green", "red"},
475		team_skin = {1, 4, 5},
476		series = "mario"
477	},
478	[0x0D] = {
479		name = "pikachu",
480		skin = {"original", "red", "blue", "green", "detective"},
481		team_skin = {2, 3, 4},
482		series = "pokemon"
483	},
484	[0x0E] = {
485		name = "ice_climber",
486		skin = {"original", "green", "orange", "red", "blue"},
487		team_skin = {4, 1, 2},
488		series = "ice_climbers"
489	},
490	[0x0F] = {
491		name = "purin",
492		skin = {"original", "red", "blue", "green", "crown", "pink"},
493		team_skin = {2, 3, 4},
494		series = "pokemon"
495	},
496	[0x1A] = {
497		name = "master_hand",
498		skinless = true,
499		series = "smash"
500	},
501	[0x1E] = {
502		name = "crazy_hand",
503		skinless = true,
504		series = "smash"
505	},
506	[0x1D] = {
507		name = "giga_bowser",
508		skinless = true,
509		series = "smash"
510	},
511	[0x21] = {
512		name = "wireframe",
513		skinless = true,
514		series = "smash"
515	},
516}
517
518local beyondmelee_selection = {
519	[0x00] = {
520		name = "captain",
521		skin = {"original", "black", "red", "white", "green", "blue", "maskless"},
522		team_skin = {3, 6, 5},
523		series = "fzero"
524	},
525	[0x05] = {
526		name = "koopa",
527		skin = {"green", "red", "blue", "black", "bones"},
528		team_skin = {2, 3, 1},
529		series = "mario"
530	},
531	[0x06] = {
532		name = "link",
533		skin = {"green", "red", "blue", "black", "white", "fierce"},
534		team_skin = {2, 3, 1},
535		series = "zelda"
536	},
537	[0x08] = {
538		name = "mario",
539		skin = {"red", "yellow", "black", "blue", "green", "builder"},
540		team_skin = {1, 4, 5},
541		series = "mario"
542	},
543	[0x0D] = {
544		name = "pikachu",
545		skin = {"original", "red", "blue", "green", "luchador"},
546		team_skin = {2, 3, 4},
547		series = "pokemon"
548	},
549	[0x10] = {
550		name = "samus",
551		skin = {"red", "pink", "black", "green", "blue", "white"},
552		team_skin = {1, 5, 4},
553		series = "metroid"
554	},
555	[0x16] = {
556		name = "mariod",
557		skin = {"white", "red", "blue", "green", "black", "hazmat"},
558		team_skin = {2, 3, 4},
559		series = "mario"
560	},
561	[0x18] = {
562		name = "pichu",
563		skin = {"original", "red", "blue", "green", "hat"},
564		team_skin = {2, 3, 4},
565		series = "pokemon"
566	},
567	[0x19] = {
568		name = "ganon",
569		skin = {"original", "red", "blue", "green", "purple", "spirit"},
570		team_skin = {2, 3, 4},
571		series = "zelda"
572	},
573	[0x1A] = {
574		name = "wolf",
575		skin = {"neutral", "red", "blue", "green"},
576		team_skin = {2, 3, 4},
577		series = "star_fox"
578	},
579	[0x1B] = {
580		name = "raichu",
581		skin = {"neutral", "king", "beach", "vomit", "warlock"},
582		team_skin = {2, 3, 4},
583		series = "pokemon"
584	},
585	[0x1C] = {
586		name = "shadowm2",
587		skin = {"black", "red", "blue", "green", "purple"},
588		team_skin = {2, 3, 4},
589		series = "pokemon"
590	},
591	[0x1D] = {
592		name = "fay",
593		skin = {"neutral", "red", "blue", "green"},
594		team_skin = {2, 3, 4},
595		series = "star_fox"
596	},
597	[0x1E] = {
598		name = "skullkid",
599		skin = {"neutral", "blue", "green", "black"},
600		team_skin = {1, 2, 3},
601		series = "zelda"
602	},
603}
604
605local akaneia_selection = {
606	[0x1A] = {
607		name = "wolf",
608		skin = {"neutral", "pink", "blue", "green", "brown"},
609		team_skin = {2, 3, 4},
610		series = "star_fox"
611	},
612}
613
614local textures = {
615	series = {},
616	stocks = {},
617	skinless = {}
618}
619
620local graphics = love.graphics
621local newImage = graphics.newImage
622
623local melee = {}
624
625function melee.isAkaneia()
626	return memory.romstring and memory.romstring.akaneia == "Akaneia"
627end
628
629function melee.isBeyondMelee()
630	return memory.romstring and memory.romstring.beyondmelee == "Beyond Melee"
631end
632
633do
634	local function doload(tbl)
635		for cid, info in pairs(tbl) do
636			if textures.series[cid] then textures.series[cid]:release() end
637			textures.series[cid] = newImage(("textures/series/%s.png"):format(info.series))
638
639			if textures.stocks[cid] then
640				for skin, text in pairs(textures.stocks[cid]) do
641					text:release()
642				end
643			end
644
645			textures.stocks[cid] = {}
646			textures.skinless[cid] = info.skinless
647
648			if info.skin then
649				for sid, skin in ipairs(info.skin) do
650					local stockf = ("textures/stocks/%s-%s.png"):format(info.name, skin)
651					local stockakf = ("textures/stocks/ak/%s-%s.png"):format(info.name, skin)
652					local stockbmf = ("textures/stocks/bm/%s-%s.png"):format(info.name, skin)
653
654					if melee.isAkaneia() and love.filesystem.getInfo(stockakf) then
655						-- Akaneia icon override
656						textures.stocks[cid][sid-1] = newImage(stockakf)
657					elseif melee.isBeyondMelee() and love.filesystem.getInfo(stockbmf) then
658						-- Beyond Melee icon override
659						textures.stocks[cid][sid-1] = newImage(stockbmf)
660					elseif love.filesystem.getInfo(stockf) then
661						textures.stocks[cid][sid-1] = newImage(stockf)
662					end
663				end
664			else
665				if textures.stocks[cid][1] then textures.stocks[cid][1]:release() end
666				textures.stocks[cid][1] = newImage(("textures/stocks/%s.png"):format(info.name))
667			end
668		end
669	end
670
671	function melee.loadTextures()
672		doload(character_selections)
673	end
674
675	function melee.loadRomSpecificTextures()
676		doload(character_selections)
677		if melee.isAkaneia() then
678			print("LOADED AKANEIA TEXTURES")
679			doload(akaneia_selection)
680		elseif melee.isBeyondMelee() then
681			print("LOADED BEYOND MELEE TEXTURES")
682			doload(beyondmelee_selection)
683		end
684	end
685end
686
687function melee.getPlayer(port)
688	if not memory.player then return end
689
690	if melee.isSinglePlayerGame() and not melee.isNetplayGame() and port == memory.menu.player_one_port + 1 then
691		-- Single player games in CSS screen always use PORT 1 character info no matter what port is controlling the menus
692		return memory.player[1].select
693	elseif not melee.isInGame() then
694		return memory.player[port].select
695	end
696
697	return memory.player[port]
698end
699
700function melee.getCharacterID(port)
701	if not memory.player then return end
702
703	local player = melee.getPlayer(port)
704
705	if not player then return end
706
707	local character = player.character
708
709	if melee.isInGame() then
710		local transformed = player.transformed == 256
711
712		-- Handle and detect Zelda/Sheik transformations
713		if character == 0x13 then
714			character = transformed and 0x12 or 0x13
715		elseif character == 0x12 then
716			character = transformed and 0x13 or 0x12
717		end
718	end
719
720	return character
721end
722
723function melee.getStockTexture(id, skin)
724	if textures.skinless[id] == true then
725		skin = 1
726	end
727	if not textures.stocks[id] or not textures.stocks[id][skin] then
728		return textures.stocks[id] and textures.stocks[id][0] or textures.stocks[0x21][1]
729	end
730	return textures.stocks[id][skin]
731end
732
733function melee.getSeriesTexture(id)
734	if not textures.series[id] then
735		return textures.series[0x21]
736	end
737	return textures.series[id]
738end
739
740function melee.drawSeries(port, ...)
741	local id = melee.getCharacterID(port)
742	if not id then return end
743	local series = melee.getSeriesTexture(melee.isPortEnabled(port) and id or 0x21)
744	if not series then return end
745	graphics.easyDraw(series, ...)
746end
747
748function melee.getSinglePlayerPort()
749	if melee.isSinglePlayerGame() and not melee.isNetplayGame() then
750		return 1
751	else
752		return memory.menu.player_one_port+1
753	end
754end
755
756function melee.drawStock(port, ...)
757	if not melee.isPortEnabled(port) then return end
758	local id = melee.getCharacterID(port)
759	if id == 0x21 or not memory.player then return end
760	local player = melee.getPlayer(port)
761	if not player or not id then return end
762	local stock = melee.getStockTexture(id, player.skin)
763	if not stock then return end
764	graphics.easyDraw(stock, ...)
765end
766
767local TEAM_COLORS = {
768	[0x00] = color(245, 46, 46, 255),	-- Red
769	[0x01] = color(84, 99, 255, 255),	-- Blue
770	[0x02] = color(31, 158, 64, 255),	-- Green
771	[0x04] = color(200, 200, 200, 255),	-- CPU/Disabled
772}
773
774function melee.getPlayerTeamColor(port)
775	if not melee.isPortEnabled(port) then return TEAM_COLORS[0x04] end
776	local player = melee.isInGame() and melee.getPlayer(port) or memory.player[port].card
777	if not player then return TEAM_COLORS[0x04] end
778	return TEAM_COLORS[player.team] or color_white
779end
780
781local PLAYER_COLORS = {
782	[1] = color(245, 46, 46, 255),
783	[2] = color(84, 99, 255, 255),
784	[3] = color(255, 199, 23, 255),
785	[4] = color(31, 158, 64, 255),
786}
787
788local PORT_PLAYER = 0x0
789local PORT_CPU = 0x1
790local PORT_DISABLED = 0x3
791
792function melee.isPortEnabled(port)
793	if not port then return false end
794	if melee.isInMenus() and melee.isSinglePlayerGame() and port ~= (memory.menu.player_one_port+1) then return false end
795	return memory.player[port].card.mode ~= PORT_DISABLED
796end
797
798function melee.isPortCPU(port)
799	return memory.player[port].card.mode == PORT_CPU
800end
801
802function melee.getPlayerColor(port)
803	return melee.isPortEnabled(port) and (PLAYER_COLORS[port] or color_white) or TEAM_COLORS[0x04]
804end
805
806local char_replacement_map = {
807	[0x8149] = "!", [0x8168] = "\"", [0x8194] = "#", [0x8190] = "$",
808	[0x8193] = "%", [0x8195] = "&", [0x8166] = "'", [0x8169] = "(",
809	[0x816A] = ")", [0x8196] = "*", [0x817B] = "+", [0x8143] = ",",
810	[0x817C] = "-", [0x8144] = ".", [0x815E] = "/", [0x8146] = ":",
811	[0x8147] = ";", [0x8183] = "<", [0x8181] = "=", [0x8184] = ">",
812	[0x8148] = "?", [0x8197] = "@", [0x816D] = "[", [0x815F] = "\\",
813	[0x816E] = "]", [0x814F] = "^", [0x8151] = "_", [0x814D] = "`",
814	[0x816F] = "{", [0x8162] = "|", [0x8170] = "}", [0x8160] = "~",
815}
816
817function melee.convertStr(str)
818	local niceStr = ""
819	local i = 1
820	while i <= #str do
821		local c1 = string.sub(str, i, i)
822		local b1 = string.byte(c1)
823
824		if bit.band(b1, 0x80) == 0x80 then
825			local c2 = string.sub(str, i + 1, i + 1)
826			local b2 = string.byte(c2)
827
828			local b16 = bit.bor(bit.lshift(b1, 8), bit.lshift(b2, 0))
829
830			if char_replacement_map[b16] then
831				niceStr = niceStr .. char_replacement_map[b16]
832			end
833
834			i = i + 2
835		else
836			niceStr = niceStr .. c1
837			i = i + 1
838		end
839	end
840	return niceStr
841end
842
843local STAGE_SERIES = {
844	[0x02] = "Super Mario", -- Princess Peach's Castle
845	[0x03] = "Super Mario", -- Rainbow Cruise
846	[0x04] = "Donkey Kong", -- Kongo Jungle
847	[0x05] = "Donkey Kong", -- Jungle Japes
848	[0x06] = "The Legend of Zelda", -- Great Bay
849	[0x07] = "The Legend of Zelda", -- Hyrule Temple
850	[0x08] = "Metroid", -- Brinstar
851	[0x09] = "Metroid", -- Brinstar Depths
852	[0x0A] = "Yoshi", -- Yoshi's Story
853	[0x0B] = "Yoshi", -- Yoshi's Island
854	[0x0C] = "Kirby", -- Fountain of Dreams
855	[0x0D] = "Kirby", -- Green Greens
856	[0x0E] = "Star Fox", -- Corneria
857	[0x0F] = "Star Fox", -- Venom
858	[0x10] = "Pokémon", -- Pokémon Stadium
859	[0x11] = "Pokémon", -- Poké Floats
860	[0x12] = "F-Zero", -- Mute City
861	[0x13] = "F-Zero", -- Big Blue
862	[0x14] = "Earthbound", -- Onett
863	[0x15] = "Earthbound", -- Fourside
864	[0x16] = "Ice Climbers", -- Icicle Mountain
865	[0x18] = "Super Mario", -- Mushroom Kingdom
866	[0x19] = "Super Mario", -- Mushroom Kingdom 2
867	[0x1B] = "Game & Watch", -- Flat Zone
868	[0x1C] = "Kirby", -- Dream Land N64
869	[0x1D] = "Yoshi", -- Yoshi's Island N64
870	[0x1E] = "Donkey Kong", -- Kongo Jungle N64
871	[0x24] = "Super Smash Bros", -- Battlefield
872	[0x25] = "Super Smash Bros", -- Final Destination
873	[0x26] = "Super Smash Bros", -- Trophy Collection
874
875	-- Singleplayer stages
876	[0x1F] = "Super Mario", -- Mushroom Kingdom
877	[0x20] = "The Legend of Zelda", -- Underground Maze
878	[0x21] = "Metroid", -- Escape Zebes
879	[0x22] = "F-Zero", -- F-Zero Grand Prix
880	[0x26] = "Super Smash Bros", -- Trophy Collection
881	[0x27] = "Super Smash Bros", -- Race to the Finish
882	[0x42] = "Super Smash Bros", -- All-Star Rest Area
883	[0x43] = "Super Smash Bros", -- Home-Run Contest
884	[0x44] = "Super Mario", -- Trophy Tussel - Goomba
885	[0x45] = "Pokémon", -- Trophy Tussel - Entei
886	[0x46] = "The Legend of Zelda", -- Trophy Tussel - Majora's Mask
887
888
889}
890
891local STAGE_NAMES = {
892	[0x02] = "Princess Peach's Castle",
893	[0x03] = "Rainbow Cruise",
894	[0x04] = "Kongo Jungle",
895	[0x05] = "Jungle Japes",
896	[0x06] = "Great Bay",
897	[0x07] = "Hyrule Temple",
898	[0x08] = "Brinstar",
899	[0x09] = "Brinstar Depths",
900	[0x0A] = "Yoshi's Story",
901	[0x0B] = "Yoshi's Island",
902	[0x0C] = "Fountain of Dreams",
903	[0x0D] = "Green Greens",
904	[0x0E] = "Corneria",
905	[0x0F] = "Venom",
906	[0x10] = "Pokémon Stadium",
907	[0x11] = "Poké Floats",
908	[0x12] = "Mute City",
909	[0x13] = "Big Blue",
910	[0x14] = "Onett",
911	[0x15] = "Fourside",
912	[0x16] = "Icicle Mountain",
913	[0x18] = "Mushroom Kingdom",
914	[0x19] = "Mushroom Kingdom 2",
915	[0x1B] = "Flat Zone",
916	[0x1C] = "Dream Land N64",
917	[0x1D] = "Yoshi's Island N64",
918	[0x1E] = "Kongo Jungle N64",
919	[0x24] = "Battlefield",
920	[0x25] = "Final Destination",
921}
922
923local BREAK_THE_TARGETS_STAGES = {
924	[0x28] = "Mario Target Test",
925	[0x29] = "Captain Falcon Target Test",
926	[0x2A] = "Young Link Target Test",
927	[0x2B] = "Donkey Kong Target Test",
928	[0x2C] = "Dr. Mario Target Test",
929	[0x2D] = "Falco Target Test",
930	[0x2E] = "Fox Target Test",
931	[0x2F] = "Ice Climbers Target Test",
932	[0x30] = "Kirby Target Test",
933	[0x31] = "Bowser Target Test",
934	[0x32] = "Link Target Test",
935	[0x33] = "Luigi Target Test",
936	[0x34] = "Marth Target Test",
937	[0x35] = "Mewtwo Target Test",
938	[0x36] = "Ness Target Test",
939	[0x37] = "Peach Target Test",
940	[0x38] = "Pichu Target Test",
941	[0x39] = "Pikachu Target Test",
942	[0x3A] = "Jigglypuff Target Test",
943	[0x3B] = "Samus Target Test",
944	[0x3C] = "Sheik Target Test",
945	[0x3D] = "Yoshi Target Test",
946	[0x3E] = "Zelda Target Test",
947	[0x3F] = "Mr. G&W Target Test",
948	[0x40] = "Roy Target Test",
949	[0x41] = "Ganondorf Target Test",
950
951	-- Akaneia
952	[0x4E] = "Wolf Target Test",
953}
954
955local SINGLEPLAYER_STAGES = {
956	[0x1F] = "Mushroom Kingdom",
957	[0x20] = "Underground Maze",
958	[0x21] = "Escape Zebes",
959	[0x22] = "F-Zero Grand Prix",
960	[0x26] = "Trophy Collection",
961	[0x27] = "Race to the Finish",
962	[0x42] = "All-Star Rest Area",
963	[0x43] = "Home-Run Contest",
964	[0x44] = "Trophy Tussle - Goomba",
965	[0x45] = "Trophy Tussle - Entei",
966	[0x46] = "Trophy Tussle - Majora's Mask",
967}
968
969local AKANEIA_STAGES = {
970	[0x47] = "Peach's Castle 64",
971	[0x48] = "Hyrule Castle 64",
972	[0x49] = "Saffron City 64",
973	[0x4A] = "Planet Zebes 64",
974	[0x4B] = "Mushroom Kingdom 64",
975	[0x4C] = "Metal Cavern",
976	[0x4D] = "Volleyball",
977}
978
979local AKANEIA_SERIES = {
980	[0x47] = "Super Mario",
981	[0x48] = "The Legend of Zelda",
982	[0x49] = "Pokémon",
983	[0x4A] = "Metroid",
984	[0x4B] = "Super Mario",
985	[0x4C] = "Super Mario",
986	[0x4D] = "Super Smash Bros",
987}
988
989local BEYOND_MELEE_STAGES = {
990	[0x47] = "Volleyball",
991	[0x48] = "Smashville",
992	[0x49] = "Sprout Tower",
993	[0x4A] = "Fountain of Dreams",
994	[0x4B] = "Flipper Field",
995	[0x4C] = "Brinstar Lab",
996	[0x4D] = "Metal Cavern", -- Metal Cavern? (Currently broken in BM-1.0)
997	[0x4E] = "Mute Circuit",
998	[0x4F] = "Kongo Falls",
999	[0x50] = "Town Greens",
1000	[0x51] = "Kongle Jungle 64",
1001	[0x52] = "Poké Float Stadium 2",
1002	[0x53] = "Rainbow Ride",
1003	[0x54] = "Island Zone",
1004	[0x55] = "Wasteland",
1005	[0x56] = "Baby Bowser's Castle",
1006	[0x57] = "Midnight Destination",
1007	[0x58] = "Midnight Battlefield",
1008	[0x59] = "Dual Zone",
1009	[0x5A] = "Fountain of Dreams", -- Diet (Currently broken in BM-1.0)
1010	[0x5B] = "Stadium-ville", -- Diet (Currently broken in BM-1.0)
1011	[0x5C] = "Yoshi's Story", -- Diet
1012	[0x5D] = "Treasure Hunt",
1013	[0x5E] = "Realgam Colosseum",
1014	[0x5F] = "Vapor Story",
1015	[0x60] = "Final Destination", -- Diet
1016	[0x61] = "Battlefield", -- Diet
1017	[0x62] = "Pokémon Stadium", -- Diet
1018	[0x63] = "Galacta Battleground",
1019}
1020
1021local BEYOND_MELEE_SERIES = {
1022	[0x47] = "Super Smash Bros", -- Volleyball
1023	[0x48] = "Animal Crossing", -- Smashville
1024	[0x49] = "Pokémon", -- Sprout Tower
1025	[0x4A] = "Kirby", -- Fountain of Dreams
1026	[0x4B] = "Super Smash Bros", -- Flipper Field
1027	[0x4C] = "Metroid", -- Brinstar Lab
1028	[0x4D] = "Super Mario", -- Metal Cavern? (Currently broken in BM-1.0)
1029	[0x4E] = "F-Zero", -- Mute Circuit
1030	[0x4F] = "Donkey Kong", -- Kongo Falls
1031	[0x50] = "Kirby", -- Town Greens
1032	[0x51] = "Donkey Kong", -- Kongle Jungle 64
1033	[0x52] = "Pokémon", -- Poké Float Stadium 2
1034	[0x53] = "Super Mario", -- Rainbow Ride
1035	[0x54] = "Yoshi", -- Island Zone
1036	[0x55] = "Kirby", -- Wasteland
1037	[0x56] = "Yoshi", -- Baby Bowser's Castle
1038	[0x57] = "Super Smash Bros", -- Midnight Destination
1039	[0x58] = "Super Smash Bros", -- Midnight Battlefield
1040	[0x59] = "Super Smash Bros", -- Dual Zone
1041	[0x5A] = "Kirby", -- Fountain of Dreams (Diet) (Currently broken in BM-1.0)
1042	[0x5B] = "Pokémon", -- Stadium-ville (Diet) (Currently broken in BM-1.0)
1043	[0x5C] = "Yoshi", -- Yoshi's Story (Diet)
1044	[0x5D] = "Yoshi", -- Treasure Hunt
1045	[0x5E] = "Pokémon", -- Realgam Colosseum
1046	[0x5F] = "Yoshi", -- Vapor Story
1047	[0x60] = "Super Smash Bros", -- Final Destination (Diet)
1048	[0x61] = "Super Smash Bros", -- Battlefield (Diet)
1049	[0x62] = "Pokémon", -- Pokémon Stadium (Diet)
1050	[0x63] = "Kirby", -- Galacta Battleground
1051}
1052
1053function melee.isNetplayGame()
1054	return memory.menu.major == MENU_VS_UNKNOWN and (memory.menu.minor == MENU_VS_UNKNOWN_INGAME or memory.menu.minor == MENU_VS_UNKNOWN_VERSUS)
1055end
1056
1057function melee.isTeams()
1058	if melee.isSinglePlayerGame() and not melee.isNetplayGame() then
1059		return false
1060	elseif melee.isInGame() then
1061		return memory.match.teams
1062	else
1063		return memory.menu.teams
1064	end
1065end
1066
1067function melee.isSinglePlayerGame()
1068	local major = memory.menu.major
1069	return	major == MENU_ALL_STAR_MODE or major == MENU_TRAINING_MODE or
1070			major == MENU_EVENT_MATCH or major == MENU_CLASSIC_MODE or
1071			major == MENU_ADVENTURE_MODE or major == MENU_TARGET_TEST or
1072			(major >= MENU_HOME_RUN_CONTEST and major <= MENU_CRUEL_MELEE) or
1073			major == MENU_VS_UNKNOWN
1074end
1075
1076function melee.isBTTStage(id)
1077	return BREAK_THE_TARGETS_STAGES[id] ~= nil
1078end
1079
1080function melee.isSinglePlayerStage(id)
1081	return SINGLEPLAYER_STAGES[id] ~= nil
1082end
1083
1084function melee.getSinglePlayerStages()
1085	return SINGLEPLAYER_STAGES
1086end
1087
1088function melee.getAllStages()
1089	return STAGE_NAMES
1090end
1091
1092function melee.getAkaneiaStages()
1093	return AKANEIA_STAGES
1094end
1095
1096function melee.getAkaneiaSeries()
1097	return AKANEIA_SERIES
1098end
1099
1100function melee.isAkaneiaStage(id)
1101	if melee.isAkaneia() then
1102		return AKANEIA_STAGES[id] ~= nil
1103	end
1104	return false
1105end
1106
1107function melee.getBeyondMeleeStages()
1108	return BEYOND_MELEE_STAGES
1109end
1110
1111function melee.getBeyondMeleeSeries()
1112	return BEYOND_MELEE_SERIES
1113end
1114
1115function melee.isBeyondMeleeStage(id)
1116	if melee.isBeyondMelee() then
1117		return BEYOND_MELEE_STAGES[id] ~= nil
1118	end
1119	return false
1120end
1121
1122function melee.getStageName(id)
1123	if melee.isAkaneia() and AKANEIA_STAGES[id] then
1124		return AKANEIA_STAGES[id]
1125	elseif melee.isBeyondMelee() and BEYOND_MELEE_STAGES[id] then
1126		return BEYOND_MELEE_STAGES[id]
1127	end
1128	return STAGE_NAMES[id] or SINGLEPLAYER_STAGES[id] or BREAK_THE_TARGETS_STAGES[id]
1129end
1130
1131function melee.getAllStageSeries()
1132	return STAGE_SERIES
1133end
1134
1135function melee.getStageSeries(id)
1136	if melee.isAkaneia() and AKANEIA_SERIES[id] then
1137		return AKANEIA_SERIES[id]
1138	elseif melee.isBeyondMelee() and BEYOND_MELEE_SERIES[id] then
1139		return BEYOND_MELEE_SERIES[id]
1140	end
1141	return STAGE_SERIES[id]
1142end
1143
1144function melee.matchFinsihed()
1145	return memory.match.finished == true
1146end
1147
1148function melee.isInGame()
1149	if not memory.menu then return false end
1150
1151	if memory.menu.major == MENU_ALL_STAR_MODE and memory.menu.minor < MENU_ALL_STAR_CSS then
1152		-- Even = playing the match
1153		-- Odd  = in the rest area
1154		--return memory.menu.minor % 2 == 0
1155		return true
1156	end
1157	if PANEL_SETTINGS:IsSlippiReplay() and memory.menu.major == MENU_START_MATCH then
1158		return memory.menu.minor == MENU_START_MATCH_INGAME
1159	end
1160	if memory.menu.major == MENU_VS_MODE or memory.menu.major == MENU_VS_UNKNOWN then
1161		return memory.menu.minor == MENU_VS_INGAME
1162	end
1163	if memory.menu.major >= MENU_TRAINING_MODE and memory.menu.major <= MENU_STAMINA_MODE or memory.menu.major == MENU_FIXED_CAMERA_MODE then
1164		return memory.menu.minor == MENU_TRAINING_INGAME
1165	end
1166	if memory.menu.major == MENU_EVENT_MATCH then
1167		return memory.menu.minor == MENU_EVENT_MATCH_INGAME
1168	end
1169	if memory.menu.major == MENU_CLASSIC_MODE and memory.menu.minor < MENU_CLASSIC_CONTINUE then
1170		-- Even = Verus screen
1171		-- Odd  = playing the match
1172		return memory.menu.minor % 2 == 1
1173	end
1174	if memory.menu.major == MENU_ADVENTURE_MODE then
1175		return
1176		memory.menu.minor == MENU_ADVENTURE_MUSHROOM_KINGDOM or
1177		memory.menu.minor == MENU_ADVENTURE_MUSHROOM_KINGDOM_BATTLE or
1178		memory.menu.minor == MENU_ADVENTURE_MUSHROOM_KONGO_JUNGLE_TINY_BATTLE or
1179		memory.menu.minor == MENU_ADVENTURE_MUSHROOM_KONGO_JUNGLE_GIANT_BATTLE or
1180		memory.menu.minor == MENU_ADVENTURE_UNDERGROUND_MAZE or
1181		memory.menu.minor == MENU_ADVENTURE_HYRULE_TEMPLE_BATTLE or
1182		memory.menu.minor == MENU_ADVENTURE_BRINSTAR or
1183		memory.menu.minor == MENU_ADVENTURE_ESCAPE_ZEBES or
1184		memory.menu.minor == MENU_ADVENTURE_GREEN_GREENS_KIRBY_BATTLE or
1185		memory.menu.minor == MENU_ADVENTURE_GREEN_GREENS_KIRBY_TEAM_BATTLE or
1186		memory.menu.minor == MENU_ADVENTURE_GREEN_GREENS_GIANT_KIRBY_BATTLE or
1187		memory.menu.minor == MENU_ADVENTURE_CORNARIA_BATTLE_1 or
1188		memory.menu.minor == MENU_ADVENTURE_CORNARIA_BATTLE_2 or
1189		memory.menu.minor == MENU_ADVENTURE_CORNARIA_BATTLE_3 or
1190		memory.menu.minor == MENU_ADVENTURE_POKEMON_STADIUM_BATTLE or
1191		memory.menu.minor == MENU_ADVENTURE_FZERO_GRAND_PRIX_RACE or
1192		memory.menu.minor == MENU_ADVENTURE_FZERO_GRAND_PRIX_BATTLE or
1193		memory.menu.minor == MENU_ADVENTURE_ONETT_BATTLE or
1194		memory.menu.minor == MENU_ADVENTURE_ICICLE_MOUNTAIN_CLIMB or
1195		memory.menu.minor == MENU_ADVENTURE_BATTLEFIELD_BATTLE or
1196		memory.menu.minor == MENU_ADVENTURE_BATTLEFIELD_METAL_BATTLE or
1197		memory.menu.minor == MENU_ADVENTURE_FINAL_DESTINATION_BATTLE
1198	end
1199	if memory.menu.major == MENU_TARGET_TEST then
1200		return memory.menu.minor == MENU_TARGET_TEST_INGAME
1201	end
1202	if memory.menu.major >= MENU_SUPER_SUDDEN_DEATH and memory.menu.major <= MENU_LIGHTNING_MELEE then
1203		return memory.menu.minor == MENU_SSD_INGAME
1204	end
1205	if memory.menu.major >= MENU_HOME_RUN_CONTEST and memory.menu.major <= MENU_CRUEL_MELEE then
1206		return memory.menu.minor == MENU_HOME_RUN_CONTEST_INGAME
1207	end
1208	if memory.menu.major == MENU_TITLE_SCREEN_IDLE then
1209		return memory.menu.minor == MENU_TITLE_SCREEN_IDLE_FIGHT_1 or memory.menu.minor == MENU_TITLE_SCREEN_IDLE_FIGHT_2
1210	end
1211	return false
1212end
1213
1214function melee.isInMenus()
1215	if not memory.menu then return false end
1216	
1217	if memory.menu.major == MENU_MAIN_MENU then
1218		return true
1219	end
1220	if memory.menu.major == MENU_VS_MODE or memory.menu.major == MENU_VS_UNKNOWN then
1221		return memory.menu.minor == MENU_VS_CSS or memory.menu.minor == MENU_VS_SSS
1222	end
1223	if memory.menu.major >= MENU_TRAINING_MODE and memory.menu.major <= MENU_STAMINA_MODE or memory.menu.major == MENU_FIXED_CAMERA_MODE then
1224		return memory.menu.minor == MENU_TRAINING_CSS or memory.menu.minor == MENU_TRAINING_SSS
1225	end
1226	if memory.menu.major == MENU_EVENT_MATCH then
1227		return memory.menu.minor == MENU_EVENT_MATCH_SELECT
1228	end
1229	if memory.menu.major == MENU_CLASSIC_MODE or memory.menu.major == MENU_ADVENTURE_MODE or memory.menu.major == MENU_ALL_STAR_MODE then
1230		-- All the menu_mior values all match in these three modes, so just use the MENU_CLASSIC_CSS value for simplicity
1231		return memory.menu.minor == MENU_CLASSIC_CSS
1232	end
1233	if memory.menu.major == MENU_TARGET_TEST then
1234		return memory.menu.minor == MENU_TARGET_TEST_CSS
1235	end
1236	if memory.menu.major >= MENU_SUPER_SUDDEN_DEATH and memory.menu.major <= MENU_LIGHTNING_MELEE then
1237		return memory.menu.minor == MENU_SSD_CSS or memory.menu.minor == MENU_SSD_SSS
1238	end
1239	if memory.menu.major >= MENU_HOME_RUN_CONTEST and memory.menu.major <= MENU_CRUEL_MELEE then
1240		return memory.menu.minor == MENU_HOME_RUN_CONTEST_CSS
1241	end
1242	return false
1243end
1244
1245return melee