-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathScriptHawk.lua
2607 lines (2263 loc) · 96.2 KB
/
ScriptHawk.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-------------------
-- Version Check --
-------------------
degree_symbol = string.char(0xB0);
-- 1.11.5 (Feb 2016)
if emu.setislagged == nil then
print("This version of BizHawk is not supported by ScriptHawk");
print("Please upgrade to a newer version of BizHawk");
print("http://tasvideos.org/Bizhawk.html");
return false;
end
-- 2.2.2 (March 2018)
if emu.getluacore == nil then
function emu.getluacore()
return "NLua";
end
end
-- 2.9 (April 2023)
if math.atan2 == nil then
degree_symbol = "°";
-- Stop the console spam for deprecated ops
emu.getluacore = client.get_lua_engine;
bit = require "lib.pngLua.numberlua";
bit.check = function(value, _bit)
return (bit.band(value, bit.lshift(1, _bit))) ~= 0;
end
bit.set = function(value, _bit)
return (bit.bor(value, bit.lshift(1, _bit)));
end
bit.clear = function(value, _bit)
return (bit.band(value, bit.bnot(bit.lshift(1, _bit))));
end
-- atan2 polyfill
math.atan2 = function(y, x)
if x == 0 then
if y == 0 then
return 0;
end
if y < 0 then
return -(math.pi / 2);
else
return (math.pi / 2);
end
end
local r = math.atan(y/x);
if x > 0 then
return r;
end
if y < 0 then
r = r - math.pi;
else
r = r + math.pi;
end
local tau = math.pi * 2;
return r - math.floor(r / tau + 0.5) * tau;
end
end
---------------
-- Libraries --
---------------
require "lib.pngLua.png";
require "lib.LibScriptHawk";
Stats = require "lib.Stats";
lips = require "lips.init";
------------------------
-- Global object init --
------------------------
ScriptHawk = {
warnings = false, -- Useful for debugging but annoying for end users, so default to false
ui_test = false, -- Open all possible module options forms, useful for testing global UI changes
force_module = {
enabled = false,
name = "games.lots", -- The name of the module to load for all opened ROMs
version = 1, -- The Game.version value to force
selfContained = false, -- Whether the forced module is self contained
},
mode = "Position",
update_delta_on_lag = false,
smooth_moving_angle = true,
UI = {
form_controls = {},
form_padding = 8,
form_width = 17,
form_height = 10,
label_offset = 5,
dropdown_offset = 1,
long_label_width = 140,
button_height = 23,
},
modifyOSDUI = {
isOpen = false,
form_controls = {},
form_padding = 8,
form_width = 10,
form_height = 10,
label_offset = 5,
dropdown_offset = 1,
long_label_width = 140,
button_height = 23,
},
hitboxModeWH = 0,
hitboxModeWHCentered = 1,
hitboxModeX2Y2 = 2,
hitboxDefaultColor = 0xFFFFFFFF, -- White
hitboxDefaultBGColor = 0x33000000, -- Translucent black
hitboxListPosition = {
x = 2,
y = 2,
},
hitboxListAnchor = "bottomright",
hitboxListShowCount = false,
overscan_compensation = {
x = 0,
y = 0,
},
isSMS = emu.getsystemid() == "SMS",
isNES = emu.getsystemid() == "NES",
bufferWidth = client.bufferwidth(),
bufferHeight = client.bufferheight(),
isFileIOSafe = emu.getluacore() == "LuaInterface",
};
ScriptHawk.hitboxDefaultMode = ScriptHawk.hitboxModeWH;
ScriptHawk.hitboxDefaultShowList = true;
ScriptHawk.hitboxDefaultShowHitboxes = true;
function ScriptHawk.biz222Notice()
print("Due to a bug between BizHawk release 1.13.0 and 2.2.1");
print("The save & clear preferenes function cannot run on any");
print("pre-2.2.2 release of BizHawk. Sorry");
print("--------");
end
function ScriptHawk.UI:controlsOverlap(control1, control2)
local x1 = tonumber(forms.getproperty(control1, "Left"));
local y1 = tonumber(forms.getproperty(control1, "Top"));
local w1 = tonumber(forms.getproperty(control1, "Width"));
local h1 = tonumber(forms.getproperty(control1, "Height"));
local x2 = tonumber(forms.getproperty(control2, "Left"));
local y2 = tonumber(forms.getproperty(control2, "Top"));
local w2 = tonumber(forms.getproperty(control2, "Width"));
local h2 = tonumber(forms.getproperty(control2, "Height"));
--gui.drawRectangle(x1, y1, w1, h1);
--gui.drawRectangle(x2, y2, w2, h2);
return x1 < x2 + w2 and x2 < x1 + w1 and y1 < y2 + h2 and y2 < y1 + h1;
end
function ScriptHawk.UI:checkControls()
for k, v in pairs(self.form_controls) do
--local x = forms.getproperty(v, "Left");
--local y = forms.getproperty(v, "Top");
--local w = forms.getproperty(v, "Width")
--local h = forms.getproperty(v, "Height");
--dprint(k.." ("..v.."): Position: "..x..", "..y.." Size: "..w..", "..h);
for l, u in pairs(self.form_controls) do
if v ~= u and self:controlsOverlap(v, u) then
dprint('Warning: Controls "'..k..'" and "'..l..'" may be overlapping!');
end
end
end
print_deferred();
end
-----------------------
-- Keybind framework --
-----------------------
local mouse_state = {
previous = {},
current = {},
};
local input_pressed = {};
local joypad_pressed = {};
local lbutton_pressed = false;
local dpad_pressed = {
up = false,
down = false,
left = false,
right = false,
};
ScriptHawk.keybindsFrame = {};
ScriptHawk.keybindsRealtime = {};
ScriptHawk.joypadBindsFrame = {};
ScriptHawk.joypadBindsRealtime = {};
ScriptHawk.mouseBinds = {};
function ScriptHawk.bind(keybindArray, key, callback, preventHold)
if type(keybindArray) == "table" and type(key) == "string" and type(callback) == "function" then
if type(preventHold) ~= 'boolean' then
preventHold = true;
end
table.insert(keybindArray, {key = key, callback = callback, pressed = false, preventHold = preventHold});
end
end
function ScriptHawk.bindKeyRealtime(key, callback, preventHold)
ScriptHawk.bind(ScriptHawk.keybindsRealtime, key, callback, preventHold);
end
function ScriptHawk.bindKeyFrame(key, callback, preventHold)
ScriptHawk.bind(ScriptHawk.keybindsFrame, key, callback, preventHold);
end
function ScriptHawk.bindJoypadFrame(key, callback, preventHold)
ScriptHawk.bind(ScriptHawk.joypadBindsFrame, key, callback, preventHold);
end
function ScriptHawk.bindJoypadRealtime(key, callback, preventHold)
ScriptHawk.bind(ScriptHawk.joypadBindsRealtime, key, callback, preventHold);
end
function ScriptHawk.bindMouse(key, callback)
ScriptHawk.bind(ScriptHawk.mouseBinds, key, callback);
end
function ScriptHawk.unbind(keybinds, key)
if type(key) == "string" then
for i, keybind in ipairs(keybinds) do
if key == keybind.key then
table.remove(keybinds, i);
end
end
end
end
function ScriptHawk.processKeybinds(keybinds)
local input_table = input.get();
for i, keybind in ipairs(keybinds) do
if not input_table[keybind.key] then
keybind.pressed = false;
end
if input_table[keybind.key] and (not keybind.preventHold or not keybind.pressed) then
keybind.callback();
keybind.pressed = true;
end
end
end
function ScriptHawk.processJoypadBinds(joypadBinds)
local input_table = joypad.getimmediate();
for i, joypadBind in ipairs(joypadBinds) do
if not input_table[joypadBind.key] then
joypadBind.pressed = false;
end
if input_table[joypadBind.key] and (not joypadBind.preventHold or not joypadBind.pressed) then
joypadBind.callback();
joypadBind.pressed = true;
end
end
end
function ScriptHawk.processMouseBinds(mouseBinds)
mouse_state.current = input.getmouse();
if type(mouse_state.current.Wheel) == "number" and type(mouse_state.previous.Wheel) == "number" then
if mouse_state.current.Wheel > mouse_state.previous.Wheel then
mouse_state.current.mousewheelup = true;
mouse_state.current.mousewheeldown = false;
elseif mouse_state.current.Wheel < mouse_state.previous.Wheel then
mouse_state.current.mousewheelup = false;
mouse_state.current.mousewheeldown = true;
end
else
mouse_state.current.mousewheelup = false;
mouse_state.current.mousewheeldown = false;
end
for i = 1, #mouseBinds do
if mouse_state.current[mouseBinds[i].key] then
mouseBinds[i].callback();
end
end
mouse_state.previous = mouse_state.current;
end
-- Default to N64 binds
ScriptHawk.dpad = {
joypad = {
up = "P1 DPad U",
down = "P1 DPad D",
left = "P1 DPad L",
right = "P1 DPad R",
enabled = true,
},
key = {
up = "W",
down = "S",
left = "A",
right = "D",
enabled = true,
},
};
ScriptHawk.lbutton = {
joypad = "P1 L",
key = "E",
};
-- PSX Joypad binds
if emu.getsystemid() == "PSX" then
ScriptHawk.dpad.joypad = {
up = "P1 Up",
down = "P1 Down",
left = "P1 Left",
right = "P1 Right",
enabled = false,
};
ScriptHawk.lbutton.joypad = "P1 L1";
end
----------------------------
-- Intervals and Timeouts --
----------------------------
ScriptHawk.intervals = {};
ScriptHawk.timeouts = {};
function ScriptHawk.setInterval(callback, interval, label, offset)
local intervalData = {
label = label or '',
callback = callback or function(calledCount) if ScriptHawk.warnings then print("Warning: ScriptHawk.setInterval() called without a callback function present."); end end,
createdAt = emu.framecount(),
interval = interval or 1,
offset = offset or 0,
calledCount = 0, -- Incremented every time the callback is called, passed into the callback
};
table.insert(ScriptHawk.intervals, intervalData);
end
function ScriptHawk.setTimeout(callback, timeout, label)
local timeoutData = {
label = label or '',
callback = callback or function() if ScriptHawk.warnings then print("Warning: ScriptHawk.setTimeout() called without a callback function present."); end end,
createdAt = emu.framecount(),
timeout = timeout or 1,
};
table.insert(ScriptHawk.timeouts, timeoutData);
end
function ScriptHawk.clearInterval(label)
if type(label) == "string" then
for i, interval in ipairs(ScriptHawk.intervals) do
if label == interval.label then
table.remove(ScriptHawk.intervals, i);
end
end
end
end
function ScriptHawk.clearTimeout(label)
if type(label) == "string" then
for i, timeout in ipairs(ScriptHawk.timeouts) do
if label == timeout.label then
table.remove(ScriptHawk.timeouts, i);
end
end
end
end
function ScriptHawk.processIntervals(intervals)
local currentFrame = emu.framecount();
for i, interval in ipairs(intervals) do
if ((currentFrame - interval.createdAt) + interval.offset) % interval.interval == 0 then
interval.calledCount = interval.calledCount + 1;
interval.callback(interval.calledCount);
end
end
end
function ScriptHawk.processTimeouts(timeouts)
local currentFrame = emu.framecount();
for i, timeout in ipairs(timeouts) do
if currentFrame >= (timeout.createdAt + timeout.timeout) then
timeout.callback();
table.remove(timeouts, i);
end
end
end
----------------
-- ASM Loader --
----------------
function outputGamesharkCode(bytes, skipZeroes)
skipZeroes = skipZeroes or false;
local skippedZeroes = 0;
if type(bytes) == "table" and #bytes > 0 then
local nextByteHandled = false;
for i = 1, #bytes do
if not nextByteHandled then
if i < #bytes and bytes[i][1] == (bytes[i + 1][1] - 1) then
if not (skipZeroes and bytes[i][2] == 0x00 and bytes[i + 1] == 0x00) then
dprint(toHexString(bytes[i][1], 6, " - 81")..toHexString(bytes[i][2], 2, " ")..toHexString(bytes[i + 1][2], 2, ""));
else
skippedZeroes = skippedZeroes + 2;
end
nextByteHandled = true;
else
if not (skipZeroes and bytes[i][2] == 0x00) then
dprint(toHexString(bytes[i][1], 6, " - 80")..toHexString(bytes[i][2], 2, " 00"));
else
skippedZeroes = skippedZeroes + 1;
end
end
else
nextByteHandled = false;
end
end
end
return skippedZeroes;
end
local code = {};
function codeWriter(pos, b)
if isPointer(pos) then
table.insert(code, {pos - RDRAMBase, b});
else
print("Warning: "..toHexString(pos).." isn't a pointer to RDRAM on the System Bus. Writing outside RDRAM isn't currently supported.");
end
end
function loadASMPatch(code_filename, suppress_print)
if not fileExists(code_filename) then
code_filename = forms.openfile(nil, nil, "R4300i Assembly Code|*.asm|All Files (*.*)|*.*");
if not fileExists(code_filename) then
if not suppress_print then
print("No code loaded, aborting mission...");
end
return false;
end
end
-- Open the file and assemble the code
code = {};
local result = lips(code_filename, codeWriter);
if #code == 0 then
if not suppress_print then
print(result);
print("The code did not compile correctly, check for errors in your source.");
end
return false;
end
-- Patch the code
for i = 1, #code do
mainmemory.writebyte(code[i][1], code[i][2]);
end
-- Hacky, yes, but if we're using dynarec the patched code pages don't get marked as dirty
-- Quickest and easiest way around this is to save and reload a state
local ss_fn = 'lips/temp.state';
savestate.save(ss_fn);
savestate.load(ss_fn);
if not suppress_print then
outputGamesharkCode(code, false);
dprint("Patched code ("..#code.." bytes)");
dprint("Done!");
print_deferred();
end
return true;
end
-----------------
-- Game checks --
-----------------
local supportedGames = {
-- Alex Kidd in Miracle World
["6E8E702E1D8A893EE698B93F5807972A"] = {moduleName="games.miracle_world", friendlyName="Alex Kidd in Miracle World (J)"},
["3D9A8D5C2D6D3F8FF63A8F7C77FFA983"] = {moduleName="games.miracle_world", friendlyName="Alex Kidd in Miracle World (UE)"},
["F43E74FFEC58DDF62F0B8667D31F22C0"] = {moduleName="games.miracle_world", friendlyName="Alex Kidd in Miracle World (UE) (Rev 1)"},
-- Alex Kidd in Shinobi World
["D62B631506913712A2103F54912458A5"] = {moduleName="games.shinobi_world", friendlyName="Alex Kidd in Shinobi World (UE)"},
-- Balloon Fight
["3F597CE54843187CCA85ADAA7E26F46FAE4992B5"] = {moduleName="games.balloon_fight", friendlyName="Balloon Fight"},
["BE2C30D69B1EBA76EAF1CC259DFA41F0F29B0FB2"] = {moduleName="games.balloon_fight", friendlyName="Balloon Fight"},
["F7E96381736E679C1E996283C2BE718025A02C0D"] = {moduleName="games.balloon_fight", friendlyName="Balloon Fight (PC10)"},
-- Banjo-Kazooie
["90726D7E7CD5BF6CDFD38F45C9ACBF4D45BD9FD8"] = {moduleName="games.bk", friendlyName="Banjo to Kazooie no Daibouken (Japan)", version=2, romIdentifier="NBKJ"},
["BB359A75941DF74BF7290212C89FBC6E2C5601FE"] = {moduleName="games.bk", friendlyName="Banjo-Kazooie (Europe) (En,Fr,De)", version=1, romIdentifier="NBKP"},
["DED6EE166E740AD1BC810FD678A84B48E245AB80"] = {moduleName="games.bk", friendlyName="Banjo-Kazooie (USA) (Rev A)", version=3}, -- NOTE: Same romIdentifier as the US 1.0 ROM, but 1.0 is the base for almost all ROM hacks, so we'll leave this one out
["1FE1632098865F639E22C11B9A81EE8F29C75D7A"] = {moduleName="games.bk", friendlyName="Banjo-Kazooie (USA)", version=4, romIdentifier="NBKE"},
--
["6A81FE9C1C9059275A2C5E64D608BAA91F22C14C"] = {moduleName="games.bk", friendlyName="Banjo-Dreamie", version=4},
["7BCA8A32E83823F9230A92DA14F26E74744B0CEC"] = {moduleName="games.bk", friendlyName="BK Hidden Lair", version=4},
["4B5CEA82AE7BD0951E02BFBE6D1665626A03BA20"] = {moduleName="games.bk", friendlyName="Banjo-Kazooie Worlds Collide", version=4},
["3D1C4371EFA16E325E981C35CF56A91D37B4BC25"] = {moduleName="games.bk", friendlyName="BK Legend of the Crystal Jiggy", version=4},
["EB3863AE260CC6B248AA3F69DC4F5D712799E09E"] = {moduleName="games.bk", friendlyName="BK Nightbear Before Christmas", version=4},
["19D2B030BD1E7D91D1A25614C330638007660235"] = {moduleName="games.bk", friendlyName="Banjo-Kazooie Fort Fun v5", version=4},
["7C50845E42C9B7B2BE48BDDC89D8D70BE95C5324"] = {moduleName="games.bk", friendlyName="Banjo Kazooie: How The Gruntch stole Christmas (1.2)", version=4},
-- Banjo-Tooie
["5A5172383037D171F121790959962703BE1F373C"] = {moduleName="games.bt", friendlyName="Banjo to Kazooie no Daibouken 2 (Japan)", version=3, romIdentifier="NB7J"},
["4CA2D332F6E6B018777AFC6A8B7880B38B6DFB79"] = {moduleName="games.bt", friendlyName="Banjo-Tooie (Australia)", version=1, romIdentifier="NB7U"},
["93BF2FAC1387320AD07251CB4B64FD36BAC1D7A6"] = {moduleName="games.bt", friendlyName="Banjo-Tooie (Europe) (En,Fr,De,Es)", version=2, romIdentifier="NB7P"},
["AF1A89E12B638B8D82CC4C085C8E01D4CBA03FB3"] = {moduleName="games.bt", friendlyName="Banjo-Tooie (USA)", version=4, romIdentifier="NB7E"},
-- Brother Bear (GBA)
["89E6903500F62E11483402B76C1454AF788646C0"] = {moduleName="games.GBA_brother_bear", friendlyName="Brother Bear (USA)", version=1},
-- Bomberman 64
["8A7648D8105AC4FC1AD942291B2EF89AECA921C9"] = {moduleName="games.bomberman64", friendlyName="Bomberman 64 (USA)", version=1, romIdentifier="NBME"},
["4813B147D552F72FDB0B306469BF9AA0F820FD5B"] = {moduleName="games.bomberman64", friendlyName="Baku Bomberman (Japan)", version=2, romIdentifier="NBMJ"},
-- Conker's Bad Fur Day
["EE7BC6656FD1E1D9FFB3D19ADD759F28B88DF710"] = {moduleName="games.cbfd", friendlyName="Conker's Bad Fur Day (Europe)", version=1, romIdentifier="NFUP"},
["4CBADD3C4E0729DEC46AF64AD018050EADA4F47A"] = {moduleName="games.cbfd", friendlyName="Conker's Bad Fur Day (USA)", version=2, romIdentifier="NFUE"},
-- Crash Bandicoot
["41B5F211"] = {moduleName="games.crash1", friendlyName="Crash Bandicoot (USA)", version=1},
["249FC147"] = {moduleName="games.crash1", friendlyName="Crash Bandicoot (USA)", version=1},
["D6172125"] = {moduleName="games.crash1", friendlyName="Crash Bandicoot (Europe) (EDC)", version=2},
["2033243A"] = {moduleName="games.crash1", friendlyName="Crash Bandicoot (Europe) (EDC)", version=2},
["FD11EB1E"] = {moduleName="games.crash1", friendlyName="Crash Bandicoot (Europe) (No EDC)", version=2},
["0B9EB02B"] = {moduleName="games.crash1", friendlyName="Crash Bandicoot (Europe) (No EDC)", version=2},
["D9BA797E"] = {moduleName="games.crash1", friendlyName="Crash Bandicoot (Japan)", version=3},
["F5B95131"] = {moduleName="games.crash1", friendlyName="Crash Bandicoot (Japan)", version=3},
-- Crash Bandicoot 2: Cortex Strikes Back
["149A203B"] = {moduleName="games.crash2", friendlyName="Crash Bandicoot 2 - Cortex Strikes Back (USA)", version=1},
["395C0916"] = {moduleName="games.crash2", friendlyName="Crash Bandicoot 2 - Cortex Strikes Back (USA)", version=1},
["5F65CF0F"] = {moduleName="games.crash2", friendlyName="Crash Bandicoot 2 - Cortex Strikes Back (Europe) (En,Fr,De,Es,It) (No EDC)", version=2},
["F5E2EC49"] = {moduleName="games.crash2", friendlyName="Crash Bandicoot 2 - Cortex Strikes Back (Europe) (En,Fr,De,Es,It) (No EDC)", version=2},
["97395614"] = {moduleName="games.crash2", friendlyName="Crash Bandicoot 2 - Cortex Strikes Back (Europe) (En,Fr,De,Es,It) (EDC)", version=2},
["74C85B1E"] = {moduleName="games.crash2", friendlyName="Crash Bandicoot 2 - Cortex Strikes Back (Europe) (En,Fr,De,Es,It) (EDC)", version=2},
["B0A92BAF"] = {moduleName="games.crash2", friendlyName="Crash Bandicoot 2 - Cortex no Gyakushuu! (Japan)", version=3},
["14591AE9"] = {moduleName="games.crash2", friendlyName="Crash Bandicoot 2 - Cortex no Gyakushuu! (Japan)", version=3},
-- Crash Bandicoot 3: Warped
["05E3012B"] = {moduleName="games.crash3", friendlyName="Crash Bandicoot - Warped (USA)", version=1},
["9BF37B2C"] = {moduleName="games.crash3", friendlyName="Crash Bandicoot - Warped (USA)", version=1},
["39B868A1"] = {moduleName="games.crash3", friendlyName="Crash Bandicoot 3 - Warped (Europe) (En,Fr,De,Es,It)", version=2},
["A91BEA0E"] = {moduleName="games.crash3", friendlyName="Crash Bandicoot 3 - Warped (Europe) (En,Fr,De,Es,It)", version=2},
["7E59A4CE"] = {moduleName="games.crash3", friendlyName="Crash Bandicoot 3 - Buttobi! Sekai Isshuu (Japan)", version=3},
["A2E93AEC"] = {moduleName="games.crash3", friendlyName="Crash Bandicoot 3 - Buttobi! Sekai Isshuu (Japan)", version=3},
-- Crash Bash
["C829C610"] = {moduleName="games.crash_bash", friendlyName="Crash Bash (USA)", version=1},
["69A6CD83"] = {moduleName="games.crash_bash", friendlyName="Crash Bash (USA)", version=1},
["D9D78CC9"] = {moduleName="games.crash_bash", friendlyName="Crash Bash (Europe)", version=2},
["2FA7F930"] = {moduleName="games.crash_bash", friendlyName="Crash Bash (Europe)", version=2},
-- Day Dreamin' Davey
["4C88391318E3BD79C14BFF6724A377688E47261B"] = {moduleName="games.day_dreamin_davey", friendlyName="Day Dreamin' Davey"},
-- Diddy Kong Racing
["B7F628073237B3D211D40406AA0884FF8FDD70D5"] = {moduleName="games.dkr", friendlyName="Diddy Kong Racing (Europe) (En,Fr,De) (Rev A)", version=1}, -- Same romIdentifier as 1.0
["DD5D64DD140CB7AA28404FA35ABDCABA33C29260"] = {moduleName="games.dkr", friendlyName="Diddy Kong Racing (Europe) (En,Fr,De)", version=2, romIdentifier="NDYP"},
["23BA3D302025153D111416E751027CEF11213A19"] = {moduleName="games.dkr", friendlyName="Diddy Kong Racing (Japan)", version=3, romIdentifier="NDYJ"},
["6D96743D46F8C0CD0EDB0EC5600B003C89B93755"] = {moduleName="games.dkr", friendlyName="Diddy Kong Racing (USA) (En,Fr) (Rev A)", version=4}, -- Same romIdentifier as 1.0
["0CB115D8716DBBC2922FDA38E533B9FE63BB9670"] = {moduleName="games.dkr", friendlyName="Diddy Kong Racing (USA) (En,Fr)", version=5, romIdentifier="NDYE"},
-- Donald Land
["C5BBA353871E438C387FD13891580A2A139694AD"] = {moduleName="games.donald_land", friendlyName="Donald Land"},
-- Donkey Kong 64
["F96AF883845308106600D84E0618C1A066DC6676"] = {moduleName="games.dk64", friendlyName="Donkey Kong 64 (Europe) (En,Fr,De,Es)", version=2, romIdentifier="NDOP"},
["F0AD2B2BBF04D574ED7AFBB1BB6A4F0511DCD87D"] = {moduleName="games.dk64", friendlyName="Donkey Kong 64 (Japan)", version=3, romIdentifier="NDOJ"},
["B4717E602F07CA9BE0D4822813C658CD8B99F993"] = {moduleName="games.dk64", friendlyName="Donkey Kong 64 (USA) (Demo) (Kiosk)", version=4, romIdentifier="NDPE"},
["CF806FF2603640A748FCA5026DED28802F1F4A50"] = {moduleName="games.dk64", friendlyName="Donkey Kong 64 (USA)", version=1, romIdentifier="NDOE"},
["F39476827CCF7F03707DE5D79949559A4DAC390B"] = {moduleName="games.dk64", friendlyName="Donkey Kong 64 (LodgeNet)", version=5, romIdentifier="NDOG"},
-- Donkey Kong Country 1 (GBA)
["FCC62356A3B7157CA7DDA1398C9BF1AF1DD31265"] = {moduleName="games.GBA_dkc1", friendlyName="Donkey Kong Country (USA)", version=1},
-- Donkey Kong Country 2 (GBA)
["B0A4D59447C8D7C321BEA4DC7253B0F581129EDE"] = {moduleName="games.GBA_dkc2", friendlyName="Donkey Kong Country 2 (USA)", version=1},
-- Drill Dozer
["C1058CC2482B91204100CC8515DA99AEB06773F5"] = {moduleName="games.GBA_DrillDozer", friendlyName="Drill Dozer (USA)", version=1},
["84AFA7108E4D604E7B1A6D105DF5760869A247FA"] = {moduleName="games.GBA_DrillDozer", friendlyName="Screw Breaker Goushin Dorirurero (Japan)", version=2},
-- Duck Dodgers
["2C840E2991D6A2AF63C4EFE830240FC49D93FC9A"] = {moduleName="games.duck_dodgers", friendlyName="Duck Dodgers Starring Daffy Duck (USA) (En,Fr,Es)", romIdentifier="NDUE"},
-- Earthworm Jim 3D
["EAB14F23640CD6148D4888902CDCC00DD6111BF9"] = {moduleName="games.ej3d", friendlyName="Earthworm Jim 3D (USA)", version=1, romIdentifier="NJME"},
["F02C1AFD18C1CBE309472CBE5B3B3F04B22DB7EE"] = {moduleName="games.ej3d", friendlyName="Earthworm Jim 3D (Europe) (En,Fr,De,Es,It)", version=2, romIdentifier="NJMP"},
-- Elmo
["97777CA06F4E8AFF8F1E95033CC8D3833BE40F76"] = {moduleName="games.elmo", friendlyName="Elmo's Letter Adventure (USA)", verison=2, romIdentifier="NENE"},
["7195EA96D9FE5DE065AF61F70D55C92C8EE905E6"] = {moduleName="games.elmo", friendlyName="Elmo's Number Journey (USA)", verison=1, romIdentifier="NELE"},
-- Galahad
["536E5A1FFB50D33632A9978B35DB5DF6"] = {moduleName="games.galahad", friendlyName="Legend of Galahad, The (UE) [!]"},
["FA7A34B92D06013625C2FE155A9DB5A8"] = {moduleName="games.galahad", friendlyName="Legend of Galahad, The (UE) [t1+C]"},
["3F183BD8A7360E3BE3CF65AE8FF9810C"] = {moduleName="games.galahad", friendlyName="Legend of Galahad, The (UE) [t1]"},
-- Golden Axe Warrior
["D46E40BBB729BA233F171AD7BF6169F5"] = {moduleName="games.golden_axe_warrior", friendlyName="Golden Axe Warrior (UE)"},
-- Golvellius
["2101295C258CB6B845BDB72BE617691D"] = {moduleName="games.golvellius", friendlyName="Golvellius (UE)"},
["6BD9879AF39E248D149761014EBF5639"] = {moduleName="games.golvellius", friendlyName="Golvellius (J)"},
-- Gran Turismo 2
["D2C9B4EE"] = {moduleName="games.gran_turismo_2", friendlyName="Gran Turismo 2 (USA 1.0)", version=1},
["B5A363A3"] = {moduleName="games.gran_turismo_2", friendlyName="Gran Turismo 2 (USA 1.1)", version=2},
["E3672E95"] = {moduleName="games.gran_turismo_2", friendlyName="Gran Turismo 2 (USA 1.2)", version=3},
["20FB91D3"] = {moduleName="games.gran_turismo_2", friendlyName="Gran Turismo 2 (Japan 1.0)", version=4},
["7E74A4F0"] = {moduleName="games.gran_turismo_2", friendlyName="Gran Turismo 2 (Japan 1.1)", version=5},
["AFCCF4DC"] = {moduleName="games.gran_turismo_2", friendlyName="Gran Turismo 2 (Europe)", version=6},
-- Impossible Mission
["D883F28E77E575EDCA6DCB1C4CD1F2B1F11393B2"] = {moduleName="games.impossible_mission", friendlyName="Impossible Mission (E)"},
["AF51AB03A173DEC28C9241532227CD64"] = {moduleName="games.impossible_mission", friendlyName="Impossible Mission (E)"},
["9C6C28610603D05664D9AE44B62B5C1AC47F829C"] = {moduleName="games.impossible_mission", friendlyName="Impossible Mission (E) (Beta)"},
["A26D40B6B7646C22D1F2DB7F746F0391"] = {moduleName="games.impossible_mission", friendlyName="Impossible Mission (E) (Beta)"},
-- Klonoa: Empire of Dreams
["A0A298D9DBA1BA15D04A42FC2EB35893D1A9569B"] = {moduleName="games.GBA_klonoa", friendlyName="Klonoa - Empire of Dreams (USA)"},
-- Knight Shift (SMS)
["FF98E8166221C5657E1A205150D0CE7202C6B8A3"] = {moduleName="games.knight_shift", friendlyName="Knight Shift (Demo Version 1)"},
["F228111C062222E61AFCF224232EB855"] = {moduleName="games.knight_shift", friendlyName="Knight Shift (Demo Version 1)"},
-- Land of Illusion
["07FAC1D61BC20CF6EB298F66EC2FFE49"] = {moduleName="games.land_of_illusion", friendlyName="Land of Illusion Starring Mickey Mouse (E)"},
-- Lord of the Sword
["6A08D913FD92A213B1ECF5AA7C5630362CCCC6B4"] = {moduleName="games.lots", friendlyName="Lord of the Sword (J)"},
["A5736126ED7E8569A189065EC20ADF72"] = {moduleName="games.lots", friendlyName="Lord of the Sword (J)"},
["A5326A0029F7C3101ADD3335A599A01CCD7634C5"] = {moduleName="games.lots", friendlyName="Lord of the Sword (UE)"},
["B80F87887881343E5705FF3CCE93C5F1"] = {moduleName="games.lots", friendlyName="Lord of the Sword (UE)"},
-- Majora's Mask
["B38B71D2961DFFB523020A67F4807A4B704E347A"] = {moduleName="games.mm", friendlyName="Legend of Zelda, The - Majora's Mask (Europe) (En,Fr,De,Es) (Beta)"},
["BB4E4757D10727C7584C59C1F2E5F44196E9C293"] = {moduleName="games.mm", friendlyName="Legend of Zelda, The - Majora's Mask (Europe) (En,Fr,De,Es) (Rev A)"},
["C04599CDAFEE1C84A7AF9A71DF68F139179ADA84"] = {moduleName="games.mm", friendlyName="Legend of Zelda, The - Majora's Mask (Europe) (En,Fr,De,Es)", romIdentifier="NZSP"},
["2F0744F2422B0421697A74B305CB1EF27041AB11"] = {moduleName="games.mm", friendlyName="Legend of Zelda, The - Majora's Mask (USA) (Demo)"},
["D6133ACE5AFAA0882CF214CF88DABA39E266C078"] = {moduleName="games.mm", friendlyName="Legend of Zelda, The - Majora's Mask (USA)", romIdentifier="NZSE"},
["41FDB879AB422EC158B4EAFEA69087F255EA8589"] = {moduleName="games.mm", friendlyName="Zelda no Densetsu - Mujura no Kamen (Japan) (Rev A)"},
["5FB2301AACBF85278AF30DCA3E4194AD48599E36"] = {moduleName="games.mm", friendlyName="Zelda no Densetsu - Mujura no Kamen (Japan)", romIdentifier="NZSJ"},
-- Mercs
["7D5696C3DA0DBED04B35543F7BDBEF40"] = {moduleName="games.mercs_sms", friendlyName="Mercs (E)"},
-- Metroid
["166A5B1344B17F98B6B18794094F745F8A7435B8"] = {moduleName="games.metroid", friendlyName="Metroid (U)"},
["FDBFC7871962F72A1EF57E5A7E456164FB93430B"] = {moduleName="games.metroid", friendlyName="Metroid (U)"},
["B2D2D9ED68B3E5E0D29053EA525BD37C"] = {moduleName="games.metroid", friendlyName="Metroid (U)"},
-- Mr. Driller
["E7009DD8418303343C4AAC2558538B8CAA28B694"] = {moduleName="beta.Drillbot", selfContained=true, friendlyName="Mr. Driller 2 (USA)"},
-- Ocarina of Time
["CFBB98D392E4A9D39DA8285D10CBEF3974C2F012"] = {moduleName="games.oot", friendlyName="Legend of Zelda, The - Ocarina of Time (Europe) (En,Fr,De) (Rev A)"},
["328A1F1BEBA30CE5E178F031662019EB32C5F3B5"] = {moduleName="games.oot", friendlyName="Legend of Zelda, The - Ocarina of Time (Europe) (En,Fr,De)", romIdentifier="NZLP"},
["D3ECB253776CD847A5AA63D859D8C89A2F37B364"] = {moduleName="games.oot", friendlyName="Legend of Zelda, The - Ocarina of Time (USA) (Rev A)"},
["41B3BDC48D98C48529219919015A1AF22F5057C2"] = {moduleName="games.oot", friendlyName="Legend of Zelda, The - Ocarina of Time (USA) (Rev B)"},
["AD69C91157F6705E8AB06C79FE08AAD47BB57BA7"] = {moduleName="games.oot", friendlyName="Legend of Zelda, The - Ocarina of Time (USA)", romIdentifier="CZLE"},
["50BEBEDAD9E0F10746A52B07239E47FA6C284D03"] = {moduleName="games.oot", friendlyName="Legend of Zelda, The - Ocarina of Time - Master Quest (USA) (Debug Edition)"},
["8B5D13AAC69BFBF989861CFDC50B1D840945FC1D"] = {moduleName="games.oot", friendlyName="Legend of Zelda, The - Ocarina of Time - Master Quest (USA) (GC)"},
["DBFC81F655187DC6FEFD93FA6798FACE770D579D"] = {moduleName="games.oot", friendlyName="Zelda no Densetsu - Toki no Ocarina (Japan) (Rev A)"},
["FA5F5942B27480D60243C2D52C0E93E26B9E6B86"] = {moduleName="games.oot", friendlyName="Zelda no Densetsu - Toki no Ocarina (Japan) (Rev B)"},
["C892BBDA3993E66BD0D56A10ECD30B1EE612210F"] = {moduleName="games.oot", friendlyName="Zelda no Densetsu - Toki no Ocarina (Japan)", romIdentifier="CZLJ"},
["DD14E143C4275861FE93EA79D0C02E36AE8C6C2F"] = {moduleName="games.oot", friendlyName="Zelda no Densetsu - Toki no Ocarina (Japan) (GC)"},
-- Penguin Land
["8762239C339A084DFB8443CC38515301476BDE28"] = {moduleName="games.penguin_land", friendlyName="Penguin Land (UE)"},
["8DDEC589F72CDCF2CD4CAAFB075EC8E4"] = {moduleName="games.penguin_land", friendlyName="Penguin Land (UE)"},
["C01CF44EEE335D509DC20A165ADD8514E7FBB7C4"] = {moduleName="games.penguin_land", friendlyName="Doki Doki Penguin Land - Uchuu Daibouken (J)"},
["FF7502DD8A717DB5ADB42C711DDBC9F5"] = {moduleName="games.penguin_land", friendlyName="Doki Doki Penguin Land - Uchuu Daibouken (J)"},
-- Phantasy Star (SMS)
["DFEBC48DFE8165202B7F002D8BAC477B"] = {moduleName="games.phantasy_star_1", friendlyName="Phantasy Star (J)"},
["14C59604768B33175362CC592CB75EAD"] = {moduleName="games.phantasy_star_1", friendlyName="Phantasy Star (J)"}, -- From Saturn Collection CD
["1B69716F9F4053E1533F654C091AE410"] = {moduleName="games.phantasy_star_1", friendlyName="Phantasy Star (B)"},
["F853B7DDCA63864735C03001C9AC477B"] = {moduleName="games.phantasy_star_1", friendlyName="Phantasy Star (K)"},
["5BA9114EDEA5DEB5282FD9AD7D4B2D62"] = {moduleName="games.phantasy_star_1", friendlyName="Phantasy Star (UE) (Rev 2)"},
["1110938DF80F4E44C8213D7F85CFB5E6"] = {moduleName="games.phantasy_star_1", friendlyName="Phantasy Star (UE) (Rev 3)"},
-- Psycho Fox
["278CC3853905626138E83B6CFA39C26BA8E4F632"] = {moduleName="games.psycho_fox", friendlyName="Psycho Fox (UE)"},
["A9C2FACF9EF536D095414CE2E7CE2F4F"] = {moduleName="games.psycho_fox", friendlyName="Psycho Fox (UE)"},
-- Rats!
["5E423DFAB8221B69A641D2E535EBFE1E3759A2E4"] = {moduleName="games.rats", friendlyName="Rats! (USA) (En,Es)"},
-- Rayman 2
["619AB27EA1645399439AD324566361D3E7FF020E"] = {moduleName="games.rayman_2", friendlyName="Rayman 2 - The Great Escape (Europe) (En,Fr,De,Es,It)", version=1, romIdentifier="NY2P"},
["50558356B059AD3FBAF5FE95380512B9DCEAAF52"] = {moduleName="games.rayman_2", friendlyName="Rayman 2 - The Great Escape (USA) (En,Fr,De,Es,It)", version=2, romIdentifier="NY2E"},
-- San Francisco Rush 2049
["3F99351D7BB61656614BDB2AA1A90CFE55D1922C"] = {moduleName="games.rush_2049", friendlyName="San Francisco Rush 2049 (USA)", version=1, romIdentifier="NRUE"},
["61373D4758ECA3FA831BEAC27B4D4C250845F80C"] = {moduleName="games.rush_2049", friendlyName="San Francisco Rush 2049 (Europe) (En,Fr,De,Es,It,Nl)", version=2, romIdentifier="NRUP"},
-- Super Mario 64
["4AC5721683D0E0B6BBB561B58A71740845DCEEA9"] = {moduleName="games.sm64", friendlyName="Super Mario 64 (Europe) (En,Fr,De)", version=2, romIdentifier="NSMP"},
["3F319AE697533A255A1003D09202379D78D5A2E0"] = {moduleName="games.sm64", friendlyName="Super Mario 64 (Japan) (Rev A) (Shindou Edition)", version=3}, -- romIdentifier same as Shindou
["8A20A5C83D6CEB0F0506CFC9FA20D8F438CAFE51"] = {moduleName="games.sm64", friendlyName="Super Mario 64 (Japan)", version=4, romIdentifier="NSMJ"},
["9BEF1128717F958171A4AFAC3ED78EE2BB4E86CE"] = {moduleName="games.sm64", friendlyName="Super Mario 64 (USA)", version=1, romIdentifier="NSME"},
-- Smash 64
["4B71F0E01878696733EEFA9C80D11C147ECB4984"] = {moduleName="games.smash64", friendlyName="Nintendo All-Star! Dairantou Smash Brothers (Japan)", version=1, romIdentifier="NALJ"},
["A9BF83FE73361E8D042C33ED48B3851D7D46712C"] = {moduleName="games.smash64", friendlyName="Super Smash Bros. (Australia)", version=2, romIdentifier="NALU"},
["6EE8A41FEF66280CE3E3F0984D00B96079442FB9"] = {moduleName="games.smash64", friendlyName="Super Smash Bros. (Europe) (En,Fr,De)", version=3, romIdentifier="NALP"},
["E2929E10FCCC0AA84E5776227E798ABC07CEDABF"] = {moduleName="games.smash64", friendlyName="Super Smash Bros. (USA)", version=4, romIdentifier="NALE"},
["88C8FED5ECD5ED901CB5FC4B5BBEFFA3EA022DF7"] = {moduleName="games.smash64", friendlyName="19XXTE 0.11", version=4}, -- Based on US ROM
["1095F94D70216AC916A9DD8A9FD65DB13E7F9F17"] = {moduleName="games.smash64", friendlyName="19XXGE", version=4}, -- Based on US ROM
["926DFAD9DAEDE0DDD088D3006BBD1D02CA6222A4"] = {moduleName="games.smash64", friendlyName="Super Smash Bros. (iQue)", version=5},
-- Sonic & SEGA All-Stars Racing
["3E4990287DA39F067BB56A1609B2FE5D"] = {moduleName="games.sonic_all_stars_racing", friendlyName="Sonic & SEGA All-Stars Racing (USA)", version=1},
-- Sonic The Hedgehog (GG)
["8A95B36139206A5BA13A38BB626AEE25"] = {moduleName="games.sonic1_sms", friendlyName="Sonic The Hedgehog (J)", version=2},
["05D0E3897CB2B6E08C2952730D2C80C1"] = {moduleName="games.sonic1_sms", friendlyName="Sonic The Hedgehog (W) (Proto)", version=1}, -- Same addresses as SMS version, interestingly
["B1DE7027824C434CE8DE59782705F5C9"] = {moduleName="games.sonic1_sms", friendlyName="Sonic The Hedgehog (W) (Rev 1)", version=3},
-- Sonic The Hedgehog (SMS)
["6B9677E4A9ABB37765D6DB4658F4324251807E07"] = {moduleName="games.sonic1_sms", friendlyName="Sonic The Hedgehog (UE)", version=1},
["6ACA0E3DFFE461BA1CB11A86CD4CAF5B97E1B8DF"] = {moduleName="games.sonic1_sms", friendlyName="Sonic The Hedgehog (E) (BIOS)", version=1},
["DC13A61EAFE75C13C15B5ECE419AC57B"] = {moduleName="games.sonic1_sms", friendlyName="Sonic The Hedgehog (UE)", version=1},
["4187D96BEAF36385E681A3CF3BD1663D"] = {moduleName="games.sonic1_sms", friendlyName="Sonic The Hedgehog (E) (BIOS)", version=1},
-- Sonic The Hedgehog 2 (SMS)
["BF3B7A41E7DA9DE23416473A33C6AC2B"] = {moduleName="games.sonic2_sms", friendlyName="Sonic The Hedgehog 2 (E)"},
["0AC157B6B7E839953FC8EBA7538FB74A"] = {moduleName="games.sonic2_sms", friendlyName="Sonic The Hedgehog 2 (E) (Rev 1)"},
-- Space Station Silicon Valley
["E5E09205AA743A9E5043A42DF72ADC379C746B0B"] = {moduleName="games.sssv", friendlyName="Space Station Silicon Valley (USA)", version=1, romIdentifier="NSVE"},
["23710541BB3394072740B0F0236A7CB1A7D41531"] = {moduleName="games.sssv", friendlyName="Space Station Silicon Valley (Europe) (En,Fr,De)", version=2, romIdentifier="NSVP"},
-- Taz-Mania (SMS)
["AC98F23DDC24609CB77BB13102E0386F8C2A4A76"] = {moduleName="games.taz", friendlyName="Taz-Mania (E)"},
["CFC878F0163933FCFCC89E134FBEB31F"] = {moduleName="games.taz", friendlyName="Taz-Mania (E)"},
-- Tetris Attack
-- TODO: Support more versions of this game
["EAD855D774C9943F7FFB5B4F429B2DD07FB6F606"] = {moduleName="Tetris Attack Bot", selfContained=true, friendlyName="Panel de Pon (Japan)"}, -- SNES
["B59061561A3AEAC13E46735582F29826E7310141"] = {moduleName="Tetris Attack Bot", selfContained=true, friendlyName="Panel de Pon - Event '98 (Japan) (BS)"}, -- SNES
["08E01F9AD5B6148E1A4355C80E2B23D8B2463443"] = {moduleName="Tetris Attack Bot", selfContained=true, friendlyName="Tetris Attack (Europe) (En,Ja)"}, -- SNES
["2DC56EAB3E70C0910AE47119D8B69F494E6000DF"] = {moduleName="Tetris Attack Bot", selfContained=true, friendlyName="Tetris Attack (USA) (En,Ja)"}, -- SNES
-- The Ninja (SMS)
["76396A25902700E18ADF6BC5C8668E2A8BDF03A9"] = {moduleName="games.the_ninja", friendlyName="The Ninja (UE)"},
["E9ACDAE112A898F7DB090FC0B8F1CE9B86637234"] = {moduleName="games.the_ninja", friendlyName="The Ninja (J)"},
["2C620BA64FCAAC940B4B1566733037B3"] = {moduleName="games.the_ninja", friendlyName="The Ninja (UE)"},
["41E20AFE05C2FBE45AC5F3A9C8111047"] = {moduleName="games.the_ninja", friendlyName="The Ninja (J)"},
-- Toy Story 2
["A9F97E22391313095D2C2FBAF81FB33BFA2BA7C6"] = {moduleName="games.ts2", friendlyName="Toy Story 2 - Buzz l'Eclair a la Rescousse! (France)", version=1, romIdentifier="NTHF"},
["92015E5254CBBAD1BC668ECB13A4B568E5F55052"] = {moduleName="games.ts2", friendlyName="Toy Story 2 - Buzz Lightyear to the Rescue! (Europe)", version=2, romIdentifier="NTHP"},
["982AD2E1E44C6662C88A77367BC5DF91C51531BF"] = {moduleName="games.ts2", friendlyName="Toy Story 2 - Buzz Lightyear to the Rescue! (USA)", version=3, romIdentifier="NTHE"},
["EAE83C07E2E777D8E71A5BE6120AED03D7E67782"] = {moduleName="games.ts2", friendlyName="Toy Story 2 - Captain Buzz Lightyear auf Rettungsmission! (Germany) (Rev A)", version=4}, -- romIdentifier same as 1.0
["F8FBB100227015BE8629243F53D70F29A2A14315"] = {moduleName="games.ts2", friendlyName="Toy Story 2 - Captain Buzz Lightyear auf Rettungsmission! (Germany)", version=5, romIdentifier="NTHD"},
-- Ty the Tasmanian Tiger 2: Bush Rescue (GBA)
["84267CE3D86100688048A8D4F166FA1B2D50E6D5"] = {moduleName="games.GBA_Ty2", friendlyName="Ty the Tasmanian Tiger 2 - Bush Rescue (USA,Europe) (En,Fr,De)"},
-- Ty the Tasmanian Tiger 3: Night of the Quinkan (GBA)
["07FAFA1C96CC039A1788D6526D52F7D3EC0BA3C3"] = {moduleName="games.GBA_Ty3", friendlyName="Ty the Tasmanian Tiger 3 - Night of the Quinkan (USA)"},
-- Tyrants - Fight Through Time (Mega Lo Mania)
["B090D74241CD56820B568C319799412B"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [!]"},
["1F7DD4DCB076E7AF7E43F01795504C4A"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [!]"}, -- Bad dump?
["8EBE079DB90BEC1AE3E5CBBBDDF0EC4F3164B191"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [!]"}, -- Bad dump?
["692F7BF5446415B1B64AAA32E4F652E6"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [b1]"},
["C98AD9D36B1A43B7C6E687C197487C05"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [b2]"},
["11AA8E16CB988BFE63A18E81976DDD3E"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [b3]"},
["2E132458425BB780A3563611811E33E4"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [f1]"},
["080686B870B124F89E47AC9C83A94A73"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [hI+1C]"},
["21901EE9D49825953454DF458230D673"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [hI+2C]"},
["A5D23A84E3320CB5A0DDA78B1A435083"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [hI]"},
["E622BC3C4A61AACC2EFC1FE4C580987F"] = {moduleName="games.tftt", friendlyName="Mega Lo Mania (E) (REV00) [c][!]"},
["B26A3CE67638A9A02E0CFEA97A31A2DE"] = {moduleName="games.tftt", friendlyName="Mega Lo Mania (E) (REV01) [hI+C]"},
["EFF87FFE2421EF0F5A5965F3B9D3F573"] = {moduleName="games.tftt", friendlyName="Mega Lo Mania (E) (REV01) [hI]"},
["A4561B736011C91E43C18AA8971CDEAD"] = {moduleName="games.tftt", friendlyName="Mega Lo Mania (E) (REV01)"},
["6D294B1A2C901AE61774754F6F533A34"] = {moduleName="games.tftt", friendlyName="Mega Lo Mania (J) [!]"},
["1FCFC9EE3BFFC25388735782B0CDB829A7E40507"] = {moduleName="games.tftt", friendlyName="Mega Lo Mania (F) [!]"},
-- Wonder Boy
["917C3E4F4C50D6506E64E2F05B945D9C"] = {moduleName="games.wonder_boy_sms", friendlyName="Wonder Boy (J)", version=2}, -- Game Gear
["03ADBEA26158137DE3F18D82E119C520"] = {moduleName="games.wonder_boy_sms", friendlyName="Wonder Boy (E)", version=2}, -- Game Gear
["A4E48850BF8799CFAC74B1D33F5900B5"] = {moduleName="games.wonder_boy_sms", friendlyName="Wonder Boy (JE)", version=1},
["7E805AA51BFB5F206C950A32EBCDAB7C"] = {moduleName="games.wonder_boy_sms", friendlyName="Wonder Boy (UE)", version=1},
-- Wonder Boy III
["E7F86C049E4BD8B26844FF62BD067D57"] = {moduleName="games.wonder_boy_iii", friendlyName="Wonder Boy III - The Dragon's Trap (UE)"},
-- Wonder Boy in Monster World (SMS)
["DA0ACDB1B9E806AA67A0216A675CB02ED24ABF8B"] = {moduleName="games.wonder_boy_monster_world", friendlyName="Wonder Boy in Monster World (E)"},
["5837764C172C8C43C8C7B21F2144CF27"] = {moduleName="games.wonder_boy_monster_world", friendlyName="Wonder Boy in Monster World (E)"},
};
local romName = gameinfo.getromname();
local romHash = gameinfo.getromhash();
Game = nil;
if not ScriptHawk.ui_test then
if not ScriptHawk.force_module.enabled then
for k, v in pairs(supportedGames) do
if romHash == k then
Game = require (v.moduleName);
ScriptHawk.moduleName = v.moduleName;
ScriptHawk.gamePrefName = string.gsub(ScriptHawk.moduleName, "games.", "");
if type(v.version) == "number" then
Game.version = v.version;
end
if v.selfContained then -- Self contained modules that do not require ScriptHawk's functionality and merely use ScriptHawk.lua as a convenient loader
return true;
end
end
end
if type(Game) ~= "table" then
-- If game has not been found, check list of games to see whether the ROM Name matches anything and use that instead
if emu.getsystemid() == "N64" then
local rom_id = "";
for i = 0, 3 do
rom_id = rom_id..string.char(memory.read_u8(0x3B + i, "ROM"));
end
for k, v in pairs(supportedGames) do
if rom_id == v.romIdentifier then
print("ROM Hash doesn't match, but this is the best match we determined.");
print("We cannot guarantee that this will work as desired, but we'll give it a shot anyways.");
print("Good luck!");
Game = require (v.moduleName);
ScriptHawk.moduleName = v.moduleName;
ScriptHawk.gamePrefName = string.gsub(ScriptHawk.moduleName, "games.", "");
if type(v.version) == "number" then
Game.version = v.version;
end
if v.selfContained then -- Self contained modules that do not require ScriptHawk's functionality and merely use ScriptHawk.lua as a convenient loader
return true;
end
break;
end
end
end
end
else
-- Force a particular module to load, see ScriptHawk.force_module for details
print("ScriptHawk is forcing a particular module to load.");
print("We cannot guarantee that this will work as desired, but we'll give it a shot anyways.");
print("Good luck!");
Game = require (ScriptHawk.force_module.name);
ScriptHawk.moduleName = ScriptHawk.force_module.name;
ScriptHawk.gamePrefName = string.gsub(ScriptHawk.moduleName, "games.", "");
if type(ScriptHawk.force_module.version) == "number" then
Game.version = ScriptHawk.force_module.version;
end
if ScriptHawk.force_module.selfContained then -- Self contained modules that do not require ScriptHawk's functionality and merely use ScriptHawk.lua as a convenient loader
return true;
end
end
if type(Game) ~= "table" then
print("This game is not currently supported.");
return false;
end
if Game.squish_memory_table and type(Game.version) == "number" then
-- Squish Game.Memory tables down to a single address for the relevant version
for k, v in pairs(Game.Memory) do
Game.Memory[k] = v[Game.version];
end
end
if type(Game.detectVersion) == "function" then
if not Game.detectVersion(romName, romHash) then
if not ScriptHawk.force_module.enabled then
print("This version of the game is not currently supported.");
return false;
end
end
end
else
Game = {};
end
currentPreferences = {};
function loadPreferences()
-- Load preferences from disk
require "default_preferences";
require "user_preferences";
-- Copy defaultPreferences into currentPreferences
currentPreferences = {};
for moduleName, defaultPreference in pairs(defaultPreferences) do
currentPreferences[moduleName] = {};
if userPreferences[moduleName] == nil then
userPreferences[moduleName] = {};
end
for OSDType, preference in pairs(defaultPreference) do
currentPreferences[moduleName][OSDType] = preference;
end
end
-- Override defaults with userPreferences in currentPreferences
for moduleName, userPreference in pairs(userPreferences) do
for OSDType, preference in pairs(userPreference) do
if type(preference) == "boolean" then
currentPreferences[moduleName][OSDType] = preference;
end
end
end
-- Update checkboxes if the modifyOSD() form is open
if ScriptHawk.modifyOSDUI.isOpen then
for OSDType, preference in pairs(currentPreferences[ScriptHawk.gamePrefName]) do
local checkboxID = OSDType.."Checkbox";
if preference then
forms.setproperty(ScriptHawk.modifyOSDUI.form_controls[checkboxID], "Checked", true);
else
forms.setproperty(ScriptHawk.modifyOSDUI.form_controls[checkboxID], "Checked", false);
end
end
end
end
loadPreferences();
-----------
-- State --
-----------
ScriptHawk.override_lag_detection = type(Game.isPhysicsFrame) == "function"; -- Default to true if the game implements custom lag detection
local rotation_units = "Degrees";
local current_frame = emu.framecount(); -- TODO: Move this to ScriptHawk table to give access for game modules?
local previous_frame = current_frame - 1; -- TODO: Move this to ScriptHawk table to give access for game modules?
local previous_map = "";
local previous_map_value = 0;
local x = 0.0;
local y = 0.0;
local z = 0.0;
local dx = 0.0;
local dy = 0.0;
local dz = 0.0;
local d = 0.0;
local odometer = 0.0;
local prev_x = 0.0;
local prev_y = 0.0;
local prev_z = 0.0;
local max_dx = 0.0;
local max_dy = 0.0;
local max_dz = 0.0;
local max_d = 0.0;
function ScriptHawk.getDX()
return dx;
end
function ScriptHawk.getDY()
return dy;
end
function ScriptHawk.getDZ()
return dz;
end
-- Rounding precision
precision = 3;
function ScriptHawk.decreasePrecision()
precision = math.max(0, precision - 1);
forms.settext(ScriptHawk.UI.form_controls["Precision Value Label"], precision);
end
function ScriptHawk.increasePrecision()
precision = math.min(12, precision + 1);
forms.settext(ScriptHawk.UI.form_controls["Precision Value Label"], precision);
end
function ScriptHawk.decreaseSpeed()
Game.speedy_index = math.max(1, Game.speedy_index - 1);
forms.settext(ScriptHawk.UI.form_controls["Speed Value Label"], Game.speedy_speeds[Game.speedy_index]);
end
function ScriptHawk.increaseSpeed()