-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsns_boost.c
1398 lines (1170 loc) · 42.1 KB
/
sns_boost.c
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
/* Copyright (c) 2024 Diego A.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
static const char proj[] = "PROJECT SNES BOOSTER";
const char name[] = "Diego A.";
const char noise[] = "MISAKA NETWORK";
const char atk[] = "CHAOS CONTROL";
const char def[] = "IMAGINE BREAKER";
const char quote1[] = "The time-space rift is expanding... There's no more time, I need to hurry.";
const char quote2[] = "Sounds good but you should know only the Power Rangers can control the Mega Voyger.";
const char spell1[] = "Zaker";
const char spell2[] = "Rashield";
const char spell3[] = "Jikerdor";
const char spell4[] = "Bao Zakeruga";
const char rando0[] = "Sparkling Wide Pressure";
const char end1[] = "You foolish man, I am a Jito-Ryo master. Allow me to reunite you with your ancestors.";
const char end2[] = "Jump on panel number one, it will take you to panels two and three.";
static const char decIntro[] = "Wii Remote Support for SNES VC\n\n";
//"\n";
// 2C000000 41820020 38600001 48 = HOME Menu aspect ratio
// ROM header check, used in later releases like Ignition Factor
//90a63698
//4BFC92dd // noop to skip header check
//3c7f000e
//8883159d
// RomHeader check, SFII Alpha
//94 21 FF E0 7C 08 02 A6 88 A4 00 2F
// opera.arc checks, used on later releases
// corresponds to the ignition factor
// 2C190000 40800010 7F23 CB78 4BFF EE0D 480000DC 3B 40 00 03
// part2
// 2C190000 40800010 7F23 CB78 4BFF EDC1 48000090 3B 40 00 03 8081 0008 7F65DB78
// opera.arc megaman x2
// 2C 14 00 00 40 80 00 10 7E 83 A3 78 4B FF EB E1 48 00 00 DC 3A
// 2C 14 00 00 40 80 00 10 7E 83 A3 78 4B FF EB 95 48 00 00 90 3A
//hbmse ignition
// 2C190000 40800010 7f23cb78 4BFF EF5D 480000DC //at 0x4A6C
// 2C190000 40800010 7f23cb78 4BFF EF11 48000090 //at 0x4AB8
//hbmse megaman x2
// 2C14 0000 40 80 00 10 7E 83 A3 78 4BFFED31 4800 00DC 3A
// 2C14 0000 40 80 00 10 7E 83 A3 78 4BFFECE5 4800 0090 3A
// types of ROM header checks, Ignition Factor
const uint8_t romheader_patch_1[5] = {
0x90, 0xA6, 0x36, 0x98, 0x4B
};
// SFII Alpha
const uint8_t romheader_patch_2[5] = {
0x90, 0xA6, 0x36, 0xA0, 0x4B
//0x94, 0x21, 0xFF, 0xE0, 0x7C, 0x08, 0x02, 0xA6, 0x88, 0xA4, 0x00, 0x2F
};
// FFIII
const uint8_t romheader_patch_3[5] = {
0x90, 0xA6, 0x37, 0x18, 0x4B
};
// Better romheader skips that maintain SRAM saving support
const uint8_t romheader_simple_ignition[5] = {
0x3C, 0x9F, 0x00, 0x0E, 0x3C
};
const uint8_t romheader_simple_ffiii[5] = {
0x3F, 0x7A, 0x00, 0x2E, 0x3F
};
// opera.arc, ignition factor
const uint8_t opera_patch_ignition_p1[21] = {
0x2C, 0x19, 0x00, 0x00, 0x40, 0x80, 0x00, 0x10, 0x7F, 0x23, 0xCB, 0x78, 0x4B, 0xFF, 0xEE, 0x0D,
0x48, 0x00, 0x00, 0xDC, 0x3B
};
const uint8_t opera_patch_ignition_p2[21] = {
0x2C, 0x19, 0x00, 0x00, 0x40, 0x80, 0x00, 0x10, 0x7F, 0x23, 0xCB, 0x78, 0x4B, 0xFF, 0xED, 0xC1,
0x48, 0x00, 0x00, 0x90, 0x3B
};
// opera.arc, Megaman X2, FFIII
const uint8_t opera_patch_megamanx2_p1[21] = {
0x2C, 0x14, 0x00, 0x00, 0x40, 0x80, 0x00, 0x10, 0x7E, 0x83, 0xA3, 0x78, 0x4B, 0xFF, 0xEB, 0xE1,
0x48, 0x00, 0x00, 0xDC, 0x3A
};
const uint8_t opera_patch_megamanx2_p2[21] = {
0x2C, 0x14, 0x00, 0x00, 0x40, 0x80, 0x00, 0x10, 0x7E, 0x83, 0xA3, 0x78, 0x4B, 0xFF, 0xEB, 0x95,
0x48, 0x00, 0x00, 0x90, 0x3A
};
// HBMSE.arc, Megaman X2, FFIII
const uint8_t hbmse_patch_megamanx2_p1[21] = {
0x2C, 0x14, 0x00, 0x00, 0x40, 0x80, 0x00, 0x10, 0x7E, 0x83, 0xA3, 0x78, 0x4B, 0xFF, 0xED, 0x31,
0x48, 0x00, 0x00, 0xDC, 0x3A
};
const uint8_t hbmse_patch_megamanx2_p2[21] = {
0x2C, 0x14, 0x00, 0x00, 0x40, 0x80, 0x00, 0x10, 0x7E, 0x83, 0xA3, 0x78, 0x4B, 0xFF, 0xEC, 0xE5,
0x48, 0x00, 0x00, 0x90, 0x3A
};
// HBMSE.arc, Ignition Factor
const uint8_t hbmse_patch_ignition_p1[20] = {
0x2C, 0x19, 0x00, 0x00, 0x40, 0x80, 0x00, 0x10, 0x7f, 0x23, 0xcb, 0x78, 0x4B, 0xFF, 0xEF, 0x5D,
0x48, 0x00, 0x00, 0xDC
};
const uint8_t hbmse_patch_ignition_p2[20] = {
0x2C, 0x19, 0x00, 0x00, 0x40, 0x80, 0x00, 0x10, 0x7f, 0x23, 0xcb, 0x78, 0x4B, 0xFF, 0xEF, 0x11,
0x48, 0x00, 0x00, 0x90
};
// Correct opera.arc removal
const uint8_t opera_patch[0xD] = {
0x7F, 0xA3, 0xEB, 0x78, 0x38, 0x80, 0x00, 0x30, 0x38, 0xA0, 0x00, 0x00, 0x48
};
// Try to catch both hbmse.arc and opera.arc (hbmse cause dolphin errors)
const uint8_t tmp_skip[8] = {
0x2C, 0x00, 0x00, 0x00, 0x40, 0x82, 0x02, 0xEC
};
// Widescreen correction, varies depending on release
const uint8_t widescreenHomeMenu_find[0xD] = {
0x38, 0x00, 0x00, 0x00, 0x98, 0x0D, 0x86, 0xE8, 0x98, 0x0D, 0x86, 0xE9, 0x4B
};
const uint8_t widescreenHomeMenu_patch[0x10] = {
0x60, 0x00, 0x00, 0x00, 0x48, 0x08, 0xC3, 0x19, 0x98, 0x6D, 0x86, 0xE8, 0x98, 0x6D, 0x86, 0xE9
};
// Alt for kirby super star
const uint8_t widescreenHomeMenu_patch_alt[0x10] = {
0x60, 0x00, 0x00, 0x00, 0x48, 0x4C, 0x4A, 0x25, 0x98, 0x6D, 0x87, 0x88, 0x98, 0x6D, 0x87, 0x89
};
// Generic read sysconf aspect ratio value
const uint8_t conf_aspect[0xD] = {
0x94, 0x21, 0xFF, 0xF0, 0x7C, 0x08, 0x02, 0xA6, 0x38, 0x80, 0x00, 0x01, 0x90
};
const uint8_t pixel_scale_1[9] = {
0x38, 0x60, 0x02, 0x00, 0x38, 0x00, 0x01, 0x2C, 0xB0
};
const uint8_t pixel_scale_patch[9] = {
0x38, 0x60, 0x02, 0x00, 0x38, 0x00, 0x01, 0x2C, 0xB0
};
// Original emulator volume
const uint8_t volume[4] = {
0x38, 0x00, 0x00, 0xF8
};
// Dark filter Kirby Super Star
const uint8_t dark_kby[8] = {
0xB3, 0xB3, 0xB3, 0xFF, 0x43, 0xD0, 0x00, 0x00
};
// Dark filter Final Fantasy II, Super Mario All-Stars, Secret of Mana
const uint8_t dark_ff[4] = {
0x38, 0x00, 0x00, 0xE0
};
// Max white
const uint8_t max_white[4] = {
0xFF, 0xFF, 0xFF, 0xFF
};
// Kirby's Dream Course is the first SNES title to use filter, but it randomly changes
const uint8_t dark_kbydc[0x14] = {
0x88, 0xA1, 0x00, 0x12, 0x38, 0x60, 0x00, 0x02, 0x98, 0xE1, 0x00, 0x08, 0x98, 0xC1, 0x00, 0x09,
0x98, 0xA1, 0x00, 0x0A
};
// Forces Kirby's Dream Course to always write 0xFFFFFFFF to the display code that sets the dark filter
const uint8_t kbydc_white[0xC] = {
0x9B, 0x81, 0x00, 0x08, 0x9B, 0x81, 0x00, 0x09, 0x9B, 0x81, 0x00, 0x0A
};
// CC advertisement
const uint8_t cc_advertise[0x1D] = {
0x54, 0x60, 0x04, 0x3E, 0x70, 0x00, 0x01, 0x10, 0x40, 0x82, 0x00, 0x18, 0x38, 0x60, 0x00, 0x02,
0x38, 0x80, 0x00, 0x01, 0x38, 0xA0, 0x00, 0x01, 0x38, 0xC0, 0x00, 0x00, 0x4B
};
// Original / direct GC mappings (SMW / Super Metroid)
const uint8_t gc_map_1[0x5C] = {
0x54, 0x60, 0x05, 0xef, 0x38, 0x80, 0x00, 0x00, 0x41, 0x82, 0x00, 0x08, 0x60, 0x84, 0x00, 0x80,
0x54, 0x60, 0x05, 0x6b, 0x41, 0x82, 0x00, 0x0c, 0x60, 0x80, 0x00, 0x40, 0x54, 0x04, 0x06, 0x3e,
0x54, 0x60, 0x06, 0x73, 0x41, 0x82, 0x00, 0x0c, 0x60, 0x80, 0x00, 0x20, 0x54, 0x04, 0x06, 0x3e,
0x54, 0x60, 0x06, 0xb5, 0x41, 0x82, 0x00, 0x0c, 0x60, 0x80, 0x00, 0x10, 0x54, 0x04, 0x06, 0x3e,
0x7c, 0x83, 0x23, 0x78, 0x4e, 0x80, 0x00, 0x20, 0x54, 0x60, 0x05, 0xad, 0x38, 0x80, 0x00, 0x00,
0x41, 0x82, 0x00, 0x08, 0x60, 0x84, 0x00, 0x80, 0x54, 0x60, 0x05, 0x29
};
// Altered GC mappings
const uint8_t gc_map_1_alt[0x5C] = {
0x54, 0x60, 0x05, 0x6b, 0x38, 0x80, 0x00, 0x00, 0x41, 0x82, 0x00, 0x08, 0x60, 0x84, 0x00, 0x80,
0x54, 0x60, 0x05, 0x29, 0x41, 0x82, 0x00, 0x0c, 0x60, 0x80, 0x00, 0x40, 0x54, 0x04, 0x06, 0x3e,
0x54, 0x60, 0x06, 0x73, 0x41, 0x82, 0x00, 0x0c, 0x60, 0x80, 0x00, 0x20, 0x54, 0x04, 0x06, 0x3e,
0x54, 0x60, 0x06, 0xb5, 0x41, 0x82, 0x00, 0x0c, 0x60, 0x80, 0x00, 0x10, 0x54, 0x04, 0x06, 0x3e,
0x7c, 0x83, 0x23, 0x78, 0x4e, 0x80, 0x00, 0x20, 0x54, 0x60, 0x05, 0xef, 0x38, 0x80, 0x00, 0x00,
0x41, 0x82, 0x00, 0x08, 0x60, 0x84, 0x00, 0x80, 0x54, 0x60, 0x05, 0xad
};
// Original GC mappings type 2 part1
const uint8_t gc_map_2[0x1C] = {
0x54, 0x80, 0x05, 0xef, 0x41, 0x82, 0x00, 0x08, 0x60, 0xa5, 0x00, 0x80, 0x54, 0x80, 0x05, 0x6b,
0x41, 0x82, 0x00, 0x0c, 0x60, 0xa0, 0x00, 0x40, 0x54, 0x05, 0x06, 0x3e
};
// Altered GC mappings type 2 part1
const uint8_t gc_map_2_alt[0x10] = {
0x54, 0x80, 0x05, 0x6b, 0x41, 0x82, 0x00, 0x08, 0x60, 0xa5, 0x00, 0x80, 0x54, 0x80, 0x05, 0x29
};
// Original GC mappings type 2 part2
const uint8_t gc_map_2_p2[0x24] = {
0x60, 0x84, 0x00, 0x80, 0x54, 0x60, 0x05, 0x29, 0x41, 0x82, 0x00, 0x0c, 0x60, 0x80, 0x00, 0x40,
0x54, 0x04, 0x06, 0x3e, 0x54, 0x60, 0x04, 0x63, 0x41, 0x82, 0x00, 0x0c, 0x60, 0x80, 0x00, 0x20,
0x54, 0x04, 0x06, 0x3e
};
// Altered GC mappings type 2 part 2
const uint8_t gc_map_2_p2_alt[0x10] = {
0x60, 0x84, 0x00, 0x40, 0x54, 0x60, 0x05, 0xEF, 0x41, 0x82, 0x00, 0x0C, 0x60, 0x80, 0x00, 0x80
};
const uint8_t wiimote_native[8] = {
0x28, 0x00, 0x00, 0x01, 0x40, 0x82, 0x01, 0x2C //0x28 in others
};
// These wiimote hooks are for building a C2 code for wiimote support,
// Wii Remote hook type 1
const uint8_t wiimoteHook[0x18] = {
0x38, 0x04, 0x00, 0x04, 0x7C, 0x05, 0x00, 0x00, 0x40, 0x82, 0x00, 0x18, 0x3C, 0x7F, 0x00, 0x06,
0x88, 0x9F, 0x00, 0x51, 0x38, 0x63, 0xF7, 0xEC
};
// Wii Remote hook type 2
const uint8_t wiimoteHook2[0x18] = {
0x38, 0x04, 0x00, 0x04, 0x7C, 0x05, 0x00, 0x00, 0x40, 0x82, 0x00, 0x18, 0x3C, 0x7F, 0x00, 0x09,
0x88, 0x9F, 0x00, 0x51, 0x38, 0x63, 0xC0, 0xD0
};
// Wii Remote hook type 3 - Used in FFII
const uint8_t wiimoteHook3[0x18] = {
0x38, 0x05, 0x00, 0x04, 0x7C, 0x06, 0x00, 0x00, 0x40, 0x82, 0x00, 0x18, 0x3C, 0x63, 0x00, 0x06,
0x88, 0x9F, 0x00, 0x51, 0x38, 0x63, 0xF7, 0xF0
};
uint16_t getSNS_native(const char* snesPad)
{
uint16_t val = 0;
if(strncasecmp(snesPad, "A", 1) == 0)
val = 0x400;
else if(strncasecmp(snesPad, "B", 1) == 0)
val = 0x100;
else if(strncasecmp(snesPad, "X", 1) == 0)
val = 0x800;
else if(strncasecmp(snesPad, "Y", 1) == 0)
val = 0x200;
else if(strncasecmp(snesPad, "Up", 2) == 0)
val = 0x8;
else if(strncasecmp(snesPad, "Down", 4) == 0)
val = 0x4;
else if(strncasecmp(snesPad, "Left", 4) == 0)
val = 0x1;
else if(strncasecmp(snesPad, "Right", 5) == 0)
val = 0x2;
else if(strncasecmp(snesPad, "Start", 5) == 0)
val = 0x1000;
else if(strncasecmp(snesPad, "Select", 6) == 0)
val = 0x4000;
else if(strncasecmp(snesPad, "L", 1) == 0)
val = 0x40;
else if(strncasecmp(snesPad, "R", 1) == 0)
val = 0x20;
return val;
}
uint16_t getSNS(const char* snesPad)
{
uint16_t val = 0;
if(strncasecmp(snesPad, "A", 1) == 0)
val = 0x80;
else if(strncasecmp(snesPad, "B", 1) == 0)
val = 0x8000;
else if(strncasecmp(snesPad, "X", 1) == 0)
val = 0x40;
else if(strncasecmp(snesPad, "Y", 1) == 0)
val = 0x4000;
else if(strncasecmp(snesPad, "Up", 2) == 0)
val = 0x800;
else if(strncasecmp(snesPad, "Down", 4) == 0)
val = 0x400;
else if(strncasecmp(snesPad, "Left", 4) == 0)
val = 0x200;
else if(strncasecmp(snesPad, "Right", 5) == 0)
val = 0x100;
else if(strncasecmp(snesPad, "Start", 5) == 0)
val = 0x1000;
else if(strncasecmp(snesPad, "Select", 6) == 0)
val = 0x2000;
else if(strncasecmp(snesPad, "L", 1) == 0)
val = 0x20;
else if(strncasecmp(snesPad, "R", 1) == 0)
val = 0x10;
return val;
}
int main (int argc, char *argv[])
{
int i = 0;
int x = 0;
int fullLimit = 0;
int halfLimit = 0;
int halfLimit1 = 0; //for recording game string len
int fullLimit1 = 0;
bool lineBroke = false;
int checksum = 0;
printf("\n\n");
printf("~ SNES VC Booster ~ by %s\n\n\n", name);
int d = 0;
int fileSz = 0;
int txtSz = 0;
// setting vars
int boost_volume = 0;
int no_dark = 0;
int no_ccAd = 0;
int gc_remap = 0;
int wiimote = 0;
int wiimoteNative = 0;
int no_opera = 0;
int no_hbmse = 0;
int no_save = 0;
int no_qsave = 0;
int no_check = 0;
int wideWant = 0;
int pixel_perf = 0;
bool verbose = false;
bool useType3 = false; //for wiimote emu
int workType = 1;
FILE *fd = NULL;
if(argc > 1) {
for(i = 1; i < (argc); i++) {
//need to handle special characters or commands
if(strcmp(argv[i], "-i") == 0) {
fd = fopen(argv[i+1], "rb");
if(fd == NULL) {
printf("Failed to open file!\nAre you sure this is correct?\n\n");
break;
} else {
printf("Opened file for reading: %s\n\n", argv[i+1]);
++workType;
}
}
if(strcmp(argv[i], "--volume") == 0) {
boost_volume = 1;
printf("Game volume will increase...\n");
++workType;
}
if(strcmp(argv[i], "--no-dark") == 0) {
no_dark = 1;
printf("Game dark filter will be removed...\n");
++workType;
}
if(strcmp(argv[i], "--no-cc") == 0) {
no_ccAd = 1;
printf("\"You will need the Classic Controller.\" message will be removed...\n");
++workType;
}
if(strcmp(argv[i], "--gc-remap") == 0) {
gc_remap = 1;
printf("GameCube Controller's direct mapping changed to A=B, B=Y, Y=X, X=A...\n");
++workType;
}
if(strcmp(argv[i], "--wiimote-emu") == 0) {
wiimote = 1;
printf("Wii Remote will be used as controller...\n");
printf("Wii Remote support requires inserting code,\n");
printf("this requires an additional effort to find the correct addresses,\n");
printf("therefore, this option will output a C2 code that can be applied to the DOL.\n");
printf("Edit wii.txt to customize mapping.\n");
++workType;
}
if(strcmp(argv[i], "--wiimote-native") == 0) {
wiimoteNative = 1;
printf("Wii Remote will be used as controller...\n");
++workType;
}
if(strcmp(argv[i], "--no-opera") == 0) {
no_opera = 1;
printf("opera.arc will no longer be written...\n");
//printf("This is useful when there is no e-manual.\n");
++workType;
}
if(strcmp(argv[i], "--no-hbmse") == 0) {
no_hbmse = 1;
printf("HBMSE.arc will no longer be written...\n");
//printf("This prevents writing HBMSE.arc to /tmp every time the game is started.\n");
++workType;
}
if(strcmp(argv[i], "--no-header-check-all") == 0) {
no_check = 1;
printf("ROM header check will be patched for all checks, SRAM will stop working.\n");
//printf("This allows more games to work on newer, LZH8 supporting builds.\n");
++workType;
}
if(strcmp(argv[i], "--no-header-check-simple") == 0) {
no_check = 2;
printf("ROM header check will be patched...\n");
//printf("This allows more games to work on newer, LZH8 supporting builds.\n");
++workType;
}
if(strcmp(argv[i], "--wide") == 0) {
wideWant = 1;
printf("Forcing game to recognize widescreen setting...\n");
//printf("This is useful when ya want widescreen Home Menu and no VI scaling in-game.\n");
++workType;
}
if(strcmp(argv[i], "--pixel-perfect") == 0 || strcmp(argv[i], "--pp") == 0) {
pixel_perf = 1;
printf("Forcing game to display 1:1...\n");
++workType;
}
if(strcmp(argv[i], "--no-save") == 0) {
no_save = 1;
printf("savedata.bin will no longer be written...\n");
// printf("This is useful when the base uses savedata but not the replaced game.\n");
// printf("Otherwise it creates an empty file, causing Data Management to allow copying.\n");
++workType;
}
if(strcmp(argv[i], "--no-qsave") == 0 || strcmp(argv[i], "--no-suspend") == 0) {
no_qsave = 1;
printf("qsave.bin will no longer be written...\n");
++workType;
}
if(strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) {
verbose = true;
printf("Verbosity set...\n");
++workType;
}
if(strcmp(argv[i], "/help") == 0) //print all commands and instructions
{
++i; //skip arg
x = 0; //reset parse
//printf("\n");
printf("USAGE INSTRUCTIONS:\n");
printf("sns_boost.exe -i 01.app --volume --no-dark --no-cc --gc-remap --wiimote-native\n\n");
printf("This tool modifies SNES VC DOL files\n");
printf("to increase volume, remove dark filter, remove opera.arc, savedata.bin, qsdata.bin writing,\n");
printf("rotate the GC controller's ABXY and adding custom Wii Remote support.\n\n");
printf("\"--volume\" = Maximize volume of the game.\n");
printf("\"--no-dark\" = Tries to find a dark filter setting and remove it. (May break stuff!)\n");
printf("\"--no-cc\" = Removes requirement of a GameCube or Classic Controller to start. ");
printf("Also makes loading games faster.\n");
printf("\"--gc-remap\" = Rotates the direct button mapping on GC controllers ");
printf("to make Super Mario World truly playable.\n");
printf("\"--wiimote-emu\" = Opens wii.txt to build a C2 code that allows playing with JUST a Wii Remote.\n");
printf("\"--wiimote-native\" = Enables native Wii Remote support.\n");
printf("\"--wide\" = Restores widescreen detection for the HOME Menu.\n");
printf("\"--no-opera\" = Prevents writing opera.arc to NAND, for games that have no e-manuals.\n");
printf("\"--no-hbmse\" = Prevents writing HBMSE.arc to NAND.\n");
printf("\"--no-save\" = Prevents writing savedata.bin, for custom games that have no save.\n");
printf("\"--no-suspend\" = Prevents writing qsdata.bin, games will always start fresh.\n");
printf("\"--no-header-check\" = Allows using later releases as base with ROM compression.\n\n");
printf("NOTE: \"--no-save\", \"--no-suspend\" may only work on earlier titles.\n\n");
//printf("\n");
break;
}
if(workType > 2 && (i > (argc-2))) {
// get file size
fseek(fd, 0, SEEK_END);
fileSz = ftell(fd);
// read the file into mem
fseek(fd, 0, SEEK_SET);
uint8_t* datBuf = malloc(fileSz);
fread(datBuf, 1, fileSz, fd);
fclose(fd);
// Verify app is not compressed
if(datBuf[0] == 0x11 || datBuf[0] == 0x10) {
printf("This DOL is compressed! Decompress it first!\n\n");
free(datBuf);
break;
}
printf("DOL size: 0x%X\n\n", fileSz);
//printf("WHAT\n");
// Kirby's dark filter is baked into the display list at the end of the dol
bool isKirbySS = false;
if(fileSz > 0x56601F) {
if(strcmp((const char*)datBuf+0x4F101E, "Kirby Super Star") == 0)
isKirbySS = true;
}
if(isKirbySS) {
datBuf[0x8E68] = 0x48; // patch the nand block check, geez
datBuf[0x8E69] = 0x00;
datBuf[0x8E6A] = 0x00;
datBuf[0x8E6B] = 0x3C;
printf("Removed NAND block size check.\n");
// SRAM patch
}
// Handle regular patches
int qsave = 0;
int p = 0;
for(p = 0; p < fileSz; ++p) {
// Begin the magic
if(boost_volume && memcmp(&datBuf[p], volume, 4) == 0) {
boost_volume = 0;
datBuf[p+2] = 2;
if(verbose)
printf("Adjusted volume to maximum! 0x%X\n", p);
else
printf("Adjusted volume to maximum!\n");
}
else if(no_dark && memcmp(&datBuf[p], dark_kby, 8) == 0) {
no_dark = 0;
memcpy(&datBuf[p], max_white, 4);
printf("Removed dark filter! Type: 30%% black, 0xB3B3B3 whites - Kirby Super Star ");
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if(!isKirbySS && no_dark && memcmp(&datBuf[p], dark_ff, 4) == 0) {
no_dark = 0;
datBuf[p+3] = 0xFF;
printf("Removed dark filter! Type: 12%% black, 0xE0E0E0 whites - Final Fantasy II, Secret of Mana, ");
printf("Super Mario All-Stars ");
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if(no_dark && memcmp(&datBuf[p], dark_kbydc, 0x14) == 0) {
no_dark = 0;
// TODO: test search on JPN/PAL/KOR, instead of hardcoding address to 0x6618 (NTSC-U only)
memcpy(&datBuf[p+8], kbydc_white, 0xC);
printf("Removed dark filter! Type: dynamic, Kirby's Dream Course ");
if(verbose)
printf("0x%X\n", p+8);
else
printf("\n");
}
else if(no_ccAd && memcmp(&datBuf[p], cc_advertise, 0x1D) == 0) {
no_ccAd = 0;
// "Press the A Button to return to the Wii Menu." screen removal
datBuf[p+0x1C] = 0x60;
datBuf[p+0x1D] = 0x00;
datBuf[p+0x1E] = 0x00;
datBuf[p+0x1F] = 0x00;
// "You will need the Classic Controller." artificial delay removal
datBuf[p-0x14] = 0x60;
datBuf[p-0x13] = 0x00;
datBuf[p-0x12] = 0x00;
datBuf[p-0x11] = 0x00;
printf("Removed CC advertisement! ");
if(verbose)
printf("0x%X, 0x%X\n", p+0x1C, p-0x14);
else
printf("\n");
}
else if(gc_remap && memcmp(&datBuf[p], gc_map_1, 0x5C) == 0) {
gc_remap = 0;
memcpy(&datBuf[p], gc_map_1_alt, 0x5C);
printf("Found GC mappings type 1 (Super Mario World, Super Metroid) affects P1 and P2.\n");
printf("Adjusted GC mappings. ");
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if(gc_remap && memcmp(&datBuf[p], gc_map_2, 0x1C) == 0) {
// Remove this line to apply multiple times
//gc_remap = 0;
//--gc_remap;
memcpy(&datBuf[p], gc_map_2_alt, 0x10);
//printf("Found GC mappings type 2 (FFII, Chrono Trigger)\n");
printf("Adjusted GC mappings. 2/2 ");
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if(gc_remap && memcmp(&datBuf[p], gc_map_2_p2, 0x24) == 0) {
gc_remap = 5; // apply 5 times, for patch 2/2 no idea why it's 5 instead of 4
memcpy(&datBuf[p], gc_map_2_p2_alt, 0x10);
printf("Found GC mappings type 2 (FFII, Chrono Trigger)\n");
printf("Adjusted GC mappings. 1/2 ");
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if((no_check == 1) && memcmp(&datBuf[p], romheader_patch_1, 0x5) == 0) {
no_check = 0;
datBuf[p+4] = 0x60;
datBuf[p+5] = 0x00;
datBuf[p+6] = 0x00;
datBuf[p+7] = 0x00;
printf("Found and removed ROM header check. Type 1, Ignition Factor ");
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if((no_check == 1) && memcmp(&datBuf[p], romheader_patch_2, 0x5) == 0) {
no_check = 0;
datBuf[p+4] = 0x60;
datBuf[p+5] = 0x00;
datBuf[p+6] = 0x00;
datBuf[p+7] = 0x00;
printf("Found and removed ROM header check. Type 2, SFII Alpha ");
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if((no_check == 1) && memcmp(&datBuf[p], romheader_patch_3, 0x5) == 0) {
no_check = 0;
datBuf[p+4] = 0x60;
datBuf[p+5] = 0x00;
datBuf[p+6] = 0x00;
datBuf[p+7] = 0x00;
printf("Found and removed ROM header check. Type 3, FFIII ");
// At 0xA760 there is a loop that needs to be removed for the game to start
if(datBuf[0xA760] == 0x48 && datBuf[0xA763] == 0)
datBuf[0xA760] = 0x60;
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if((no_check == 2) && memcmp(&datBuf[p], romheader_simple_ignition, 5) == 0) {
// Confirm it
//printf("Found simple header check...\n");
// Verify
if(datBuf[p-4] == 0x4B) {
// Loop to find blr
uint16_t b = 0;
for(b = 0; b < 0x500; b+=4) {
if(datBuf[p+b] == 0x4E && datBuf[p+b+3] == 0x20) {
b -= 0x10;
datBuf[p] = 0x48;
datBuf[p+1] = 0x00;
datBuf[p+2] = b >> 8;
datBuf[p+3] = b;
no_check = 0;
//printf("Show me: 0x%X %X,, ", b >> 8, (uint8_t)b);
break;
}
}
printf("Found and removed ROM header check. Type SRAM: Ignition Factor ");
}
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if((no_check == 2) && memcmp(&datBuf[p], romheader_simple_ffiii, 5) == 0) {
// Confirm it
//printf("Found simple header check...\n");
// Verify
if(datBuf[p-4] == 0x4B) {
// Loop to find blr
uint16_t b = 0;
for(b = 0; b < 0x500; b+=4) {
if(datBuf[p+b] == 0x4E && datBuf[p+b+3] == 0x20) {
b -= 0x10;
datBuf[p] = 0x48;
datBuf[p+1] = 0x00;
datBuf[p+2] = b >> 8;
datBuf[p+3] = b;
no_check = 0;
//printf("Show me: 0x%X %X,, ", b >> 8, (uint8_t)b);
break;
}
}
printf("Found and removed ROM header check. Type SRAM: FFIII ");
}
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if(no_opera && memcmp(&datBuf[p], opera_patch_ignition_p1, 21) == 0) {
// no_opera = 0;
datBuf[p+0xC] = 0x60;
datBuf[p+0xD] = 0x00;
datBuf[p+0xE] = 0x00;
datBuf[p+0xF] = 0x00;
printf("Found and removed opera.arc check 1 ");
if(memcmp(&datBuf[p+0x4C], opera_patch_ignition_p2, 21) == 0) {
datBuf[p+0x4C+0xC] = 0x60;
datBuf[p+0x4C+0xD] = 0x00;
datBuf[p+0x4C+0xE] = 0x00;
datBuf[p+0x4C+0xF] = 0x00;
printf("and check 2 ");
}
printf("of type 1, Ignition Factor ");
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if(no_opera && memcmp(&datBuf[p], opera_patch_megamanx2_p1, 21) == 0) {
// no_opera = 0;
datBuf[p+0xC] = 0x60;
datBuf[p+0xD] = 0x00;
datBuf[p+0xE] = 0x00;
datBuf[p+0xF] = 0x00;
printf("Found and removed opera.arc check 1 ");
if(memcmp(&datBuf[p+0x4C], opera_patch_megamanx2_p2, 21) == 0) { // higher than 14 fails
datBuf[p+0x4C+0xC] = 0x60;
datBuf[p+0x4C+0xD] = 0x00;
datBuf[p+0x4C+0xE] = 0x00;
datBuf[p+0x4C+0xF] = 0x00;
printf("and check 2 ");
}
printf("of type 2, MegaMan X2, FFIII ");
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if(no_hbmse && memcmp(&datBuf[p], hbmse_patch_megamanx2_p1, 21) == 0) {
// no_hbmse = 0;
datBuf[p+0xC] = 0x60;
datBuf[p+0xD] = 0x00;
datBuf[p+0xE] = 0x00;
datBuf[p+0xF] = 0x00;
printf("Found and removed HBMSE.arc check 1 ");
if(memcmp(&datBuf[p+0x4C], hbmse_patch_megamanx2_p2, 21) == 0) {
datBuf[p+0x4C+0xC] = 0x60;
datBuf[p+0x4C+0xD] = 0x00;
datBuf[p+0x4C+0xE] = 0x00;
datBuf[p+0x4C+0xF] = 0x00;
printf("and check 2 ");
}
printf("of type 2, MegaMan X2, FFIII ");
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if(no_hbmse && memcmp(&datBuf[p], hbmse_patch_ignition_p1, 20) == 0) {
// no_hbmse = 0;
datBuf[p+0xC] = 0x60;
datBuf[p+0xD] = 0x00;
datBuf[p+0xE] = 0x00;
datBuf[p+0xF] = 0x00;
printf("Found and removed HBMSE.arc check 1 ");
if(memcmp(&datBuf[p+0x4C], hbmse_patch_ignition_p2, 20) == 0) {
datBuf[p+0x4C+0xC] = 0x60;
datBuf[p+0x4C+0xD] = 0x00;
datBuf[p+0x4C+0xE] = 0x00;
datBuf[p+0x4C+0xF] = 0x00;
printf("and check 2 ");
}
printf("of type 2, Ignition Factor ");
if(verbose)
printf("0x%X\n", p);
else
printf("\n");
}
else if(no_opera && memcmp(&datBuf[p], opera_patch, 0xD) == 0) {
no_opera = 0;
datBuf[p] = 0x48;
datBuf[p+1] = 0x00;
datBuf[p+2] = 0x01;
datBuf[p+3] = 0x20;
printf("Removed opera.arc!\n");
}
else if(wideWant && memcmp(&datBuf[p], widescreenHomeMenu_find, 6) == 0) {
// wideWant = 0;
if(datBuf[p-4] == 0x48 && datBuf[p+8] == 0x98 && (datBuf[p+6] == 0x86 || datBuf[p+6] == 0x87)) {
// copy the bl
unsigned bakBL = 0;
memcpy(&bakBL, &datBuf[p-4], 4);
uint8_t bakSTB_bot = datBuf[p+7];
uint8_t bakSTB_top = datBuf[p+5];
// Correct to BE
bakBL = ((bakBL>>24)&0xff) | // move byte 3 to byte 0
((bakBL<<8) &0xff0000) | // move byte 1 to byte 2
((bakBL>>8) &0xff00) | // move byte 2 to byte 1
((bakBL<<24)&0xff000000); // byte 0 to byte 3
if(datBuf[p+6] == 0x87)
memcpy(&datBuf[p-4], widescreenHomeMenu_patch_alt, 0x10);
else
memcpy(&datBuf[p-4], widescreenHomeMenu_patch, 0x10);
// Since a li has been no-op'd move the bl closer
bakBL -= 4;
// Restore LE
bakBL = ((bakBL>>24)&0xff) | // move byte 3 to byte 0
((bakBL<<8) &0xff0000) | // move byte 1 to byte 2
((bakBL>>8) &0xff00) | // move byte 2 to byte 1
((bakBL<<24)&0xff000000); // byte 0 to byte 3
memcpy(&datBuf[p], &bakBL, 4);
//printf("Show me: 0x%X\n", bakBL);
// adjust r13
datBuf[p+0x7] = bakSTB_bot;
datBuf[p+0xB] = bakSTB_bot+1;
datBuf[p+0x5] = bakSTB_top;
datBuf[p+0x9] = bakSTB_top;
printf("Applied widescreen checking! Type 1 HOME Menu, Ignition Factor, FFIII ");
if(verbose)
printf("0x%X\n", p-4);
else
printf("\n");
}
}
#if 0
else if(wideWant && memcmp(&datBuf[p], conf_aspect, sizeof(conf_aspect)) == 0) {
// wideWant = 0;
// memcpy(&datBuf[p], ???, sizeof());
// TODO
if(datBuf[p+0x3C] == 0x98) {
// branch, OG instr 98010008
printf("Found widescreen checking function! Injected new code.\n");
}
}
#endif
#if 0 // obvious trouble doing this: can't inject ASM easily
else if(pixel_perf && memcmp(&datBuf[p], pixel_scale_1, sizeof(pixel_scale_1)) == 0) {
// pixel_perf = 0;
memcpy(&datBuf[p], pixel_scale_patch, sizeof(pixel_scale_patch));
printf("Applied pixel-perfect patch! Type 1 HOME Menu, Ignition Factor\n");
}
#endif
#if 0
else if(pixel_perf && memcmp(&datBuf[p], find_video, sizeof(find_video)) == 0) {
if(datBuf[p-0x2C] == 0 && datBuf[p-0x26] == 0x28 && datBuf[p-0x22] == 0x80) {
datBuf[p-0x26] = 0x68;
datBuf[p-0x22] = 0x00;
printf("Applied pixel-perfect patch! Type 1, Ignition Factor\n");
}
// pixel_perf = 0;
}
#endif
#if 0 // apparently crashes on real hardware
else if(no_opera && strcmp((const char*)datBuf+p, "/tmp/opera.arc") == 0) {
no_opera = 0;
datBuf[p+5] = 0;
printf("Removed opera.arc!\n");
}
#endif
#if 1
else if(no_hbmse && strcmp((const char*)datBuf+p, "/tmp/HBMSE.arc") == 0) {
no_hbmse = 0;
datBuf[p+5] = 0;
printf("Removed HBMSE.arc path!\n");
}
#endif
else if(no_save && strcmp((const char*)datBuf+p, "/tmp/savedata.bin") == 0) {
no_save = 0;
datBuf[p+5] = 0;
printf("Removed SRAM creation!\n");
}
else if(no_qsave && strcmp((const char*)datBuf+p, "nocopy/qsdata.bin") == 0) {
qsave = 1;
datBuf[p+7] = 0;
}
else if((qsave == 1) && strcmp((const char*)datBuf+p, "nocopy/dummy") == 0) {
qsave = 2;
no_qsave = 0;
datBuf[p+7] = 0;
printf("Removed suspend feature!\n");