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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
|
#include "menu.h"
#include "theme.h"
#include "config.h"
#include "screenshot.h"
#include "graphics.h"
#include "png.h"
#define MENU_AREA_Y_START 50
#define MENU_AREA_Y_END 227
#define PPU_IGNORE_FIXEDCOLCHANGES (1<<0)
#define PPU_IGNORE_WINDOW (1<<1)
#define PPU_IGNORE_ADDSUB (1<<2)
#define PPU_IGNORE_PALWRITE (1<<3)
#define GFX_IGNORE_OBJ (1<<4)
#define GFX_IGNORE_BG0 (1<<5)
#define GFX_IGNORE_BG1 (1<<6)
#define GFX_IGNORE_BG2 (1<<7)
#define GFX_IGNORE_BG3 (1<<8)
char romDir[MAX_PATH+1];
char snesRomDir[MAX_PATH+1];
#define ROM_SELECTOR_DEFAULT_FOCUS 3
DIRDATA dir;
#if defined (__GP2X__)
unsigned short cpuSpeedLookup[46]={
10,20, 30, 40, 50,
60,70, 80, 90,100,
110,120,130,144,150,
160,170,180,190,200,
210,220,230,240,250,
255,260,265,270,275,
280,285,290,295,300,
305,310,315,320,325,
330,335,340,345,350,
355};
#endif
#if defined (__WIZ__)
unsigned short cpuSpeedLookup[46]={
200,250, 300, 350, 400,
450,500, 520, 540,560,
580,590,600,610,620,
630,640,650,660,670,
680,690,700,710,720,
730,740,750,760,770,
780,790,800,810,820,
830,840,850,860,870,
875,880,885,890,895,
900};
#endif
extern volatile int timer;
static int menutileXscroll=0;
static int menutileYscroll=0;
static int headerDone[4]; // variable that records if header graphics have been rendered or not
int quickSavePresent=0;
struct ROM_LIST_RECORD
{
char filename[MAX_PATH+1];
char type;
};
static struct ROM_LIST_RECORD romList[MAX_ROMS];
struct SNES_MENU_OPTIONS snesMenuOptions;
static int romCount;
char currentRomFilename[MAX_PATH+1]="";
int currFB=0;
int prevFB=0;
int currentEmuMode=EMU_MODE_SNES;
char currentWorkingDir[MAX_PATH+1];
char snesOptionsDir[MAX_PATH+1];
char snesSramDir[MAX_PATH+1];
char snesSaveStateDir[MAX_PATH+1];
#if defined(__WIZ__)
float soundRates[3]={22050.0,32000.0,44100.0};
#else
float soundRates[5]={8000.0,11025.0,16000.0,22050.0,44100.0};
#endif
char menutext[256][50];
struct SAVE_STATE saveState[10]; // holds the filenames for the savestate and "inuse" flags
char saveStateName[MAX_PATH+MAX_PATH+2]; // holds the last filename to be scanned for save states
// a few vars for persistent file selector
int lastSelected = -1;
int defaultDir;
unsigned char gammaConv[32*29]={ 0, 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,
0, 2, 3, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 24, 25, 26, 27, 28, 29, 29, 30, 31,
0, 3, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 16, 17, 18, 19, 20, 21, 22, 22, 23, 24, 25, 25, 26, 27, 28, 28, 29, 30, 30, 31,
0, 4, 6, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23, 23, 24, 25, 25, 26, 27, 27, 28, 29, 29, 30, 30, 31,
0, 6, 8, 10, 11, 12, 14, 15, 16, 17, 18, 18, 19, 20, 21, 22, 22, 23, 24, 24, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31,
0, 7, 9, 11, 12, 14, 15, 16, 17, 18, 19, 20, 20, 21, 22, 22, 23, 24, 24, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31,
0, 8, 10, 12, 14, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 28, 29, 29, 30, 30, 31, 31,
0, 9, 11, 13, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 29, 30, 30, 31, 31,
0, 10, 12, 14, 16, 17, 18, 19, 20, 21, 21, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 28, 29, 29, 30, 30, 30, 31, 31,
0, 11, 13, 15, 17, 18, 19, 20, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31,
0, 12, 14, 16, 17, 18, 19, 20, 21, 22, 22, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31,
0, 12, 15, 17, 18, 19, 20, 21, 22, 22, 23, 24, 24, 25, 25, 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 30, 31, 31,
0, 13, 16, 17, 19, 20, 21, 21, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 30, 31, 31,
0, 14, 16, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 31, 31, 31,
0, 14, 17, 18, 20, 21, 22, 22, 23, 24, 24, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31,
0, 15, 17, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31,
0, 16, 18, 19, 21, 22, 22, 23, 24, 24, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31,
0, 16, 18, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 30, 31, 31, 31,
0, 17, 19, 20, 21, 22, 23, 24, 24, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 30, 31, 31, 31,
0, 17, 19, 21, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 30, 31, 31, 31,
0, 17, 20, 21, 22, 23, 24, 24, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 31, 31, 31,
0, 18, 20, 21, 22, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 31, 31, 31,
0, 18, 20, 22, 23, 23, 24, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 31, 31, 31, 31,
0, 19, 21, 22, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 31, 31, 31, 31,
0, 19, 21, 22, 23, 24, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31,
0, 19, 21, 22, 23, 24, 25, 25, 26, 26, 27, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31,
0, 20, 22, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31,
0, 20, 22, 23, 24, 24, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31,
0, 20, 22, 23, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31};
void InitMenu(void) {
}
void UpdateMenuGraphicsGamma(void)
{
unsigned int currPix=0;
unsigned short pixel=0;
unsigned char R,G,B;
for(currPix=0;currPix<15360;currPix++)
{
// md 0000 bbb0 ggg0 rrr0
// gp rrrr rggg ggbb bbbi
pixel=menuHeaderOrig[currPix];
R=(pixel>>11)&0x1F; // 0000 0RRR - 3 bits Red
G=(pixel>>6)&0x1F;
B=(pixel>>1)&0x1F;
// Do gamma correction
R=gammaConv[R+(0<<5)];
G=gammaConv[G+(0<<5)];
B=gammaConv[B+(0<<5)];
pixel=MENU_RGB(R,G,B);
menuHeader[currPix]=pixel;
}
for(currPix=0;currPix<5120;currPix++)
{
// md 0000 bbb0 ggg0 rrr0
// gp rrrr rggg ggbb bbbi
pixel=highLightBarOrig[currPix];
R=(pixel>>11)&0x1F; // 0000 0RRR - 3 bits Red
G=(pixel>>6)&0x1F;
B=(pixel>>1)&0x1F;
// Do gamma correction
R=gammaConv[R+(0<<5)];
G=gammaConv[G+(0<<5)];
B=gammaConv[B+(0<<5)];
pixel=MENU_RGB(R,G,B);
highLightBar[currPix]=pixel;
}
for(currPix=0;currPix<(MENU_TILE_WIDTH*MENU_TILE_HEIGHT);currPix++)
{
// md 0000 bbb0 ggg0 rrr0
// gp rrrr rggg ggbb bbbi
pixel=menuTileOrig[currPix];
R=(pixel>>11)&0x1F; // 0000 0RRR - 3 bits Red
G=(pixel>>6)&0x1F;
B=(pixel>>1)&0x1F;
// Do gamma correction
R=gammaConv[R+(0<<5)];
G=gammaConv[G+(0<<5)];
B=gammaConv[B+(0<<5)];
pixel=MENU_RGB(R,G,B);
menuTile[currPix]=pixel;
}
}
void SnesDefaultMenuOptions(void)
{
// no options file loaded, so set to defaults
snesMenuOptions.menuVer=SNES_OPTIONS_VER;
snesMenuOptions.frameSkip=0;
snesMenuOptions.soundOn = 1;
snesMenuOptions.volume=100;
memset(snesMenuOptions.padConfig,0xFF,sizeof(snesMenuOptions.padConfig));
snesMenuOptions.showFps=1;
snesMenuOptions.gamma=0;
snesMenuOptions.asmspc700=1;
snesMenuOptions.SpeedHacks=1;
#if defined(__WIZ__)
snesMenuOptions.soundRate=0;
snesMenuOptions.cpuSpeed=8;
#else
snesMenuOptions.soundRate=2;
snesMenuOptions.cpuSpeed=19;
#endif
snesMenuOptions.loadOnInit = 0;
snesMenuOptions.delayedRasterFX = 1;
}
static void ShowMessage(char *text, int showMessage) {
if (showMessage) {
gp_setClipping(0, 0, 310, 239);
PrintBar(prevFB,240-16);
gp_drawString(40,228,strlen(text),text,tTextColorFocus,framebuffer16[prevFB]);
}
}
int LoadMenuOptions(char *path, char *filename, char *ext, char *optionsmem, int maxsize, int showMessage)
{
char fullFilename[MAX_PATH+MAX_PATH+1];
char _filename[MAX_PATH+1];
char _ext[MAX_PATH+1];
FILE *stream;
int size=0;
char text[50];
ShowMessage("Loading...", showMessage);
SplitFilename(filename, _filename, _ext);
sprintf(fullFilename,"%s%s%s.%s",path,DIR_SEP,_filename,ext);
stream=fopen(fullFilename,"rb");
if(stream)
{
// File exists do try to load it
fseek(stream,0,SEEK_END);
size=ftell(stream);
if (size>maxsize) size=maxsize;
fseek(stream,0,SEEK_SET);
fread(optionsmem, 1, size, stream);
fclose(stream);
return(0);
}
else
{
return(1);
}
}
int SaveMenuOptions(char *path, char *filename, char *ext, char *optionsmem, int maxsize, int showMessage)
{
char fullFilename[MAX_PATH+MAX_PATH+1];
char _filename[MAX_PATH+1];
char _ext[MAX_PATH+1];
FILE *stream;
char text[50];
ShowMessage("Saving...", showMessage);
SplitFilename(filename, _filename, _ext);
sprintf(fullFilename,"%s%s%s.%s",path,DIR_SEP,_filename,ext);
stream=fopen(fullFilename,"wb");
if(stream)
{
fwrite(optionsmem, 1, maxsize, stream);
fclose(stream);
sync();
return(0);
}
else
{
return(1);
}
}
int DeleteMenuOptions(char *path, char *filename, char *ext, int showMessage)
{
char fullFilename[MAX_PATH+MAX_PATH+1];
char _filename[MAX_PATH+1];
char _ext[MAX_PATH+1];
char text[50];
ShowMessage("Deleting...", showMessage);
SplitFilename(filename, _filename, _ext);
sprintf(fullFilename,"%s%s%s.%s",path,DIR_SEP,_filename,ext);
remove(fullFilename);
sync();
return(0);
}
#ifdef __GIZ__
void sync(void)
{
}
#endif
static void WaitForButtonsUp(void)
{
int i=0,j=0,z=0;
for(i=0;i<100;i++)
{
while(1)
{
InputUpdate(0);
z=0;
for (j=0;j<32;j++)
{
if (Inp.held[j]) z=1;
}
if (z==0) break;
}
}
}
void MenuPause()
{
int i=0,j=0,z=0;
// wait for keys to be released
for(i=0;i<100;i++) // deal with keybounce by checking a few times
{
while(1)
{
InputUpdate(0);
z=0;
for (j=0;j<32;j++)
{
if (Inp.held[j]) z=1;
}
if (z==0) break;
}
}
for(i=0;i<100;i++) // deal with keybounce by checking a few times
{
while(1)
{
InputUpdate(0);
z=0;
for (j=0;j<32;j++)
{
if (Inp.held[j]) z=1;
}
if (z==1) break;
}
}
}
#if defined (__GP2X__) || defined(__WIZ__)
void MenuFlip()
{
prevFB=currFB;
gp_setFramebuffer(currFB,1);
currFB++;
currFB&=3;
}
#endif
#if defined (__GIZ__)
void MenuFlip()
{
prevFB=currFB=0;
gp_setFramebuffer(currFB,0);
}
#endif
void SplitFilename(char *wholeFilename, char *filename, char *ext)
{
int len=strlen(wholeFilename);
int i=0,y=-1;
ext[0]=0;
filename[0]=0;
//Check given string is not null
if (len<=0)
{
return;
}
y=-1;
for(i=len-2;i>0;i--)
{
if (wholeFilename[i]=='.')
{
y=i;
break;
}
}
if (y>=0)
{
memcpy(filename,wholeFilename,y);
filename[y]=0; // change "." to zero to end string
memcpy(ext,wholeFilename+y+1,len-(y+1));
//ext[len-(y+1)+1]=0;
ext[len-(y+1)]=0;
}
else
{
strcpy(filename,wholeFilename);
}
}
//Ensures all directory seperators are valid for system
void CheckDirSep(char *path)
{
int i=0;
char dirSepBad[2]={DIR_SEP_BAD};
char dirSep[2]={DIR_SEP};
for(i=0;i<strlen(path);i++)
{
if(path[i] == dirSepBad[0]) path[i]=dirSep[0];
}
}
int MenuMessageBox(char *message1,char *message2,char *message3,int mode)
{
int select=0;
int subaction=-1;
int len=0;
while(subaction==-1)
{
InputUpdate(0);
if (Inp.repeat[INP_BUTTON_UP])
{
select^=1; // Up
}
if (Inp.repeat[INP_BUTTON_DOWN])
{
select^=1; // Down
}
if ((Inp.held[INP_BUTTON_MENU_SELECT]==1) || (Inp.held[INP_BUTTON_MENU_CANCEL]==1))
{
subaction=select;
}
PrintTile(currFB);
PrintTitle(currFB);
len=strlen(message1);
if(len>39)len=39;
gp_drawString(8,50,len,message1,tTextColorItem,framebuffer16[currFB]);
len=strlen(message2);
if(len>39)len=39;
gp_drawString(8,60,len,message2,tTextColorItem,framebuffer16[currFB]);
len=strlen(message3);
if(len>39)len=39;
gp_drawString(8,70,len,message3,tTextColorItem,framebuffer16[currFB]);
switch(mode)
{
case 0: // yes no input
if(select==0)
{
PrintBar(currFB, 120-4);
gp_drawString(8,120,3,"YES",tTextColorFocus,framebuffer16[currFB]);
gp_drawString(8,140,2,"NO",tTextColorItem,framebuffer16[currFB]);
}
else
{
PrintBar(currFB, 140-4);
gp_drawString(8,120,3,"YES",tTextColorItem,framebuffer16[currFB]);
gp_drawString(8,140,2,"NO",tTextColorFocus,framebuffer16[currFB]);
}
break;
}
MenuFlip();
}
return(subaction);
}
static
int deleterom(int romindex)
{
char text[MAX_PATH+1];
char fullfilename[MAX_PATH+MAX_PATH+1];
int x;
FILE *stream=NULL;
PrintTile(currFB);
PrintTitle(currFB);
MenuFlip();
sprintf(text,"Deleting Rom..");
gp_drawString(8,50,strlen(text),text,tTextColorItem,framebuffer16[prevFB]);
sprintf(text,"%s",romList[romindex].filename);
x=strlen(text);
if(x>40) x=40;
gp_drawString(0,60,x,text,tTextColorItem,framebuffer16[prevFB]);
sprintf(fullfilename,"%s%s%s",romDir,DIR_SEP,romList[romindex].filename);
remove(fullfilename);
sync();
sprintf(text,"Updating Rom List..");
gp_drawString(8,70,strlen(text),text,tTextColorItem,framebuffer16[prevFB]);
for(x=romindex;x<romCount;x++)
{
strcpy(romList[x].filename, romList[x+1].filename);
romList[x].type = romList[x+1].type;
}
romCount--;
return(1);
}
static int tileCounter=0;
void PrintTile(int flip)
{
short x=0,x2=0;
short y=0,y2=0;
unsigned short *framebuffer1 = framebuffer16[flip]+(48*320);
unsigned short *graphics1 = NULL;
if (isThemeActive() != 0) {
gDrawBitmap16((unsigned short *)framebuffer16[flip], 0, MENU_AREA_Y_START,
tBmpBackground, 0, MENU_AREA_Y_START, tBmpBackground->w, tBmpBackground->h - MENU_AREA_Y_START + 1);
} else {
x2=menutileXscroll;
y2=(menutileYscroll*MENU_TILE_WIDTH);
graphics1 = menuTile+y2;
for (y=0; y<(240-48); y++)
{
for (x=0; x<320; x++)
{
*framebuffer1++ = graphics1[x2];
x2++;
x2&=(MENU_TILE_WIDTH-1);
}
y2+=MENU_TILE_WIDTH;
y2&=((MENU_TILE_HEIGHT*MENU_TILE_WIDTH)-1);
graphics1=menuTile+y2;
}
tileCounter++;
if (tileCounter > 5)
{
tileCounter=0;
menutileXscroll++;
if(menutileXscroll>=MENU_TILE_WIDTH) menutileXscroll=0;
menutileYscroll++;
if(menutileYscroll>=MENU_TILE_HEIGHT) menutileYscroll=0;
}
}
return;
}
void PrintTitle(int flip)
{
unsigned int x,y;
char text[] = DRSNES_VERSION;
//If header already drawn for this layer exit
if (headerDone[flip]) return;
if (isThemeActive() != 0) {
gDrawBitmap16((unsigned short *)framebuffer16[flip], 0, 0, tBmpBackground, 0, 0, tBmpBackground->w, MENU_AREA_Y_START);
} else {
unsigned short *framebuffer = (unsigned short*)framebuffer16[flip];
unsigned short *graphics = (unsigned short*)menuHeader;
for (y=0; y<48; y++)
{
for (x=0; x<320; x++)
{
*framebuffer++ = *graphics++;
}
}
}
//sprintf(text,"%s",DRSNES_VERSION);
gp_drawString(175,15,strlen(text),text,tTextColorVersion,framebuffer16[flip]);
headerDone[currFB] = 1;
}
void PrintBar(int flip, unsigned int givenY)
{
if (isThemeActive()) {
gBlendBitmap16((unsigned short *)framebuffer16[flip], 0, givenY, tBmpBar, 0, 0, tBmpBar->w, tBmpBar->h);
} else {
unsigned int *framebuffer1 = NULL;
unsigned int *graphics1 = (unsigned int *)highLightBar;
unsigned int x,y;
framebuffer1 = (unsigned int*)framebuffer16[flip]+(givenY*160);
for (y=0; y<16; y++)
{
for (x=0; x<160; x++)
{
*framebuffer1++ = *graphics1++;
}
}
}
}
static int StringCompare(char *string1, char *string2)
{
int i=0;
char c1=0,c2=0;
while(1)
{
c1=string1[i];
c2=string2[i];
// check for string end
if ((c1 == 0) && (c2 == 0)) return 0;
if (c1 == 0) return 1;
if (c2 == 0) return -1;
if ((c1 >= 0x61)&&(c1<=0x7A)) c1-=0x20;
if ((c2 >= 0x61)&&(c2<=0x7A)) c2-=0x20;
if (c1>c2)
return 1;
else if (c1<c2)
return -1;
i++;
}
}
#ifdef __GIZ__
static BOOL CharToWChar(wchar_t *wc, char *c)
{
int len=strlen(c);
int x=0;
for (x=0;x<len;x++)
{
wc[x] = btowc(c[x]);
}
wc[len]=0;
return TRUE;
}
#endif
int FileScan()
{
int i=0,j=0;
char text[256];
DIR *d;
struct dirent *de;
char dirCheck[MAX_PATH+1];
int dirCount=0;
char _filename[MAX_PATH+1];
char _ext[MAX_PATH+1];
char ll[1024];
char *llf;
#ifdef __GIZ__
wchar_t wc[MAX_PATH+1];
HANDLE hTest;
WIN32_FIND_DATAW fileInfo;
#endif
PrintTile(currFB);
PrintTitle(currFB);
gp_setClipping(0, 0, 319, 239);
gp_drawString(8,120,25,"Getting Directory Info...",tTextColorItem,framebuffer16[currFB]);
MenuFlip();
for (i=0;i<MAX_ROMS;i++)
{
romList[i].filename[0] = 0;
}
//Get rom directory details
romCount=0;
// Now sort the directory details
sprintf(romList[0].filename,"Save As Default Directory");
sprintf(romList[1].filename,"Back To Main Menu");
sprintf(romList[2].filename,"Parent Directory");
romList[3].filename[0] = 0;
romCount=4;
lastSelected = -1;
defaultDir = (strcmp(snesRomDir, romDir) == 0);
d = opendir(romDir);
if (d)
{
while ((de = readdir(d)))
{
if (de->d_name[0] != '.')
{
#if defined(__GP2X__) || defined(__WIZ__)
if (de->d_type == 4) // Directory
#endif
#ifdef __GIZ__
sprintf(dirCheck,"%s%s%s",romDir,DIR_SEP,de->d_name);
CharToWChar(wc, dirCheck);
hTest=FindFirstFileW(wc, &fileInfo);
if (fileInfo.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
#endif
{
for (i=ROM_SELECTOR_DEFAULT_FOCUS+1;i<=(romCount+1);i++)
{
if (romList[i].filename[0] == 0) // string is empty so shove new value in
{
strcpy(romList[i].filename,de->d_name);
romList[i].type=FILE_TYPE_DIRECTORY;//de->d_type;
break;
}
else
{
if ((StringCompare(romList[i].filename,de->d_name) > 0) ||
(romList[i].type != FILE_TYPE_DIRECTORY))
{
// new entry is lower than current string so move all entries up one and insert
// new value in
for (j=romCount;j>=i;j--)
{
strcpy(romList[j+1].filename,romList[j].filename);
romList[j+1].type=romList[j].type;
}
strcpy(romList[i].filename,de->d_name);
romList[i].type=FILE_TYPE_DIRECTORY;//de->d_type;
break;
}
}
}
dirCount++;
romCount++;
}
else // File
{
// only interested in Zip and SMC files
SplitFilename(de->d_name,_filename,_ext);
if ((StringCompare(_ext,"zip") == 0) ||
(StringCompare(_ext,"smc") == 0) ||
(StringCompare(_ext,"sfc") == 0))
{
for (i=ROM_SELECTOR_DEFAULT_FOCUS+1+dirCount;i<=(romCount+1);i++)
{
if (romList[i].filename[0] == 0) // string is empty so shove new value in
{
strcpy(romList[i].filename,de->d_name);
romList[i].type=FILE_TYPE_FILE;//de->d_type;
break;
}
else
{
if (StringCompare(romList[i].filename,de->d_name) > 0)
{
// new entry is lower than current string so move all entries up one and insert
// new value in
for (j=romCount;j>=i;j--)
{
strcpy(romList[j+1].filename,romList[j].filename);
romList[j+1].type=romList[j].type;
}
strcpy(romList[i].filename,de->d_name);
romList[i].type=FILE_TYPE_FILE;//de->d_type;
break;
}
}
}
romCount++;
}
}
if (romCount > MAX_ROMS)
{
PrintTile(currFB);
PrintTitle(currFB);
sprintf(text,"Max rom limit exceeded! %d max",MAX_ROMS);
gp_drawString(8,120,strlen(text),text,tTextColorItem,framebuffer16[currFB]);
sprintf(text,"Please reduce number of roms");
gp_drawString(8,130,strlen(text),text,tTextColorItem,framebuffer16[currFB]);
MenuFlip();
MenuPause();
break;
}
}
}
closedir(d);
getConfigValue(CONFIG_LASTLOADED, ll, sizeof(ll));
if (strstr(ll, romDir)) { // where loaded in current dir
llf = strrchr(ll, '/');
if (!llf) {
ll[0] = '\0';
llf = ll;
} else llf++;
for(i = 4; i < romCount; i++) {
if ((romList[i].type == FILE_TYPE_FILE) &&
(strncmp(romList[i].filename, llf, strlen(romList[i].filename)) == 0)) {
lastSelected = i;
}
}
}
}
else
{
PrintTile(currFB);
PrintTitle(currFB);
sprintf(text,"Failed to open directory!");
gp_drawString(8,120,strlen(text),text,tTextColorItem,framebuffer16[currFB]);
MenuFlip();
MenuPause();
}
return romCount;
}
int FileSelect(int mode)
{
char text[256];
int romname_length;
int action=0;
int smooth=0;
unsigned short color=0;
int i=0;
int focus=ROM_SELECTOR_DEFAULT_FOCUS;
int menuExit=0;
int scanstart=0,scanend=0;
char dirSep[2]={DIR_SEP};
char dirSepBad[2]={DIR_SEP_BAD};
//int x = lastSelected;
int txt_dir;
int txt_offset;
int frame;
#define TIME_TO_SCREENSHOT (20 * 1)
#define RESET_SCREENSHOT_COUNTER \
timeToScreenshot = TIME_TO_SCREENSHOT;\
if (bmpScreenshot) {\
gDestroyBitmap(bmpScreenshot); \
bmpScreenshot = NULL; \
}\
noScreenshot = 0;
int timeToScreenshot;
int noScreenshot;
int xScreenshot;
gBITMAP *bmpScreenshot = NULL;
FileScan();
#define RESET_NAME_SCROLL \
txt_dir = 1; \
txt_offset = -1;
RESET_NAME_SCROLL
RESET_SCREENSHOT_COUNTER
if (lastSelected >= 0) focus = lastSelected;
if (focus>romCount-1) focus = ROM_SELECTOR_DEFAULT_FOCUS;
smooth=focus<<8;
while (menuExit==0)
{
InputUpdate(0);
// Change which rom is focused on:
if (Inp.repeat[INP_BUTTON_UP])
{
focus--; // Up
RESET_NAME_SCROLL
RESET_SCREENSHOT_COUNTER
}
if (Inp.repeat[INP_BUTTON_DOWN])
{
focus++; // Down
RESET_NAME_SCROLL
RESET_SCREENSHOT_COUNTER
}
if (Inp.held[INP_BUTTON_MENU_CANCEL]==1 ) {action=0; menuExit=1;}
if (Inp.repeat[INP_BUTTON_LEFT] || Inp.repeat[INP_BUTTON_RIGHT] )
{
if (Inp.repeat[INP_BUTTON_LEFT])
{
focus-=12;
smooth=(focus<<8)-1;
}
else if (Inp.repeat[INP_BUTTON_RIGHT])
{
focus+=12;
smooth=(focus<<8)-1;
}
if (focus>romCount-1)
{
focus=romCount-1;
smooth=(focus<<8)-1;
}
else if (focus<0)
{
focus=0;
smooth=(focus<<8)-1;
}
RESET_NAME_SCROLL
RESET_SCREENSHOT_COUNTER
}
if (focus>romCount-1)
{
focus=0;
smooth=(focus<<8)-1;
RESET_NAME_SCROLL
RESET_SCREENSHOT_COUNTER
}
else if (focus<0)
{
focus=romCount-1;
smooth=(focus<<8)-1;
RESET_NAME_SCROLL
RESET_SCREENSHOT_COUNTER
}
//if (defaultDir) lastSelected = focus;
if (Inp.held[INP_BUTTON_MENU_SELECT]==1)
{
switch(focus)
{
case 0: //Save default directory
SaveMenuOptions(snesOptionsDir, DEFAULT_ROM_DIR_FILENAME, DEFAULT_ROM_DIR_EXT, romDir, strlen(romDir),1);
strcpy(snesRomDir,romDir);
break;
case 1: //Return to menu
action=0;
menuExit=1;
break;
case 2: //Goto Parent Directory
// up a directory
//Remove a directory from RomPath and rescan
//Code below will never let you go further up than \SD Card\ on the Gizmondo
//This is by design.
for(i=strlen(romDir)-1;i>0;i--) // don't want to change first char in screen
{
if((romDir[i] == dirSep[0]) || (romDir[i] == dirSepBad[0]))
{
romDir[i] = 0;
break;
}
}
FileScan();
RESET_NAME_SCROLL
RESET_SCREENSHOT_COUNTER
focus=ROM_SELECTOR_DEFAULT_FOCUS; // default menu to non menu item
// just to stop directory scan being started
smooth=focus<<8;
memset(&headerDone,0,sizeof(headerDone)); //clear header
break;
case ROM_SELECTOR_DEFAULT_FOCUS: //blank space - do nothing
break;
default:
// normal file or dir selected
if (romList[focus].type == FILE_TYPE_DIRECTORY)
{
//Just check we are not in root dir as this will always have
//a trailing directory seperater which screws with things
sprintf(romDir,"%s%s%s",romDir,DIR_SEP,romList[focus].filename);
FileScan();
RESET_NAME_SCROLL
RESET_SCREENSHOT_COUNTER
focus=ROM_SELECTOR_DEFAULT_FOCUS; // default menu to non menu item
// just to stop directory scan being started
smooth=focus<<8;
}
else
{
// user has selected a rom, so load it
sprintf(currentRomFilename,romList[focus].filename);
quickSavePresent=0; // reset any quick saves
action=1;
menuExit=1;
}
break;
}
}
if (Inp.held[INP_BUTTON_MENU_DELETE]==1)
{
if(focus>ROM_SELECTOR_DEFAULT_FOCUS)
{
//delete current rom
if (romList[focus].type != FILE_TYPE_DIRECTORY)
{
sprintf(text,"%s",romList[focus].filename);
if(MenuMessageBox("Are you sure you want to delete",text,"",0)==0)
{
deleterom(focus);
RESET_NAME_SCROLL
RESET_SCREENSHOT_COUNTER
}
}
}
}
#define MAX_WIDTH (39 * 8)
if (timeToScreenshot) timeToScreenshot--;
else if ((!bmpScreenshot) && (focus > ROM_SELECTOR_DEFAULT_FOCUS) && (!noScreenshot)) {
char png_fn[1024];
char *ext;
gBITMAP *b;
// Compose focused filename + screenshots dir
snprintf(png_fn, sizeof(png_fn), "%s/%s", getScreenShotsDir(), romList[focus].filename);
// set file ext to .png
ext = strrchr(png_fn, '.');
if (!ext) ext = &png_fn[strlen(png_fn)];
strcpy(ext, ".png");
// load screenshot
b = load_png(png_fn, NULL);
if (!b) noScreenshot = 1;
else {
unsigned int sh, sw;
sh = MENU_AREA_Y_END - MENU_AREA_Y_START - 2 + 1;
sw = (sh * b->w)/ b->h;
bmpScreenshot = gStretchBitmap(b, sw, sh);
gDestroyBitmap(b);
if (!bmpScreenshot) noScreenshot = 1;
else xScreenshot = SCREEN_WIDTH - 2;
}
}
// Draw screen:
PrintTile(currFB);
PrintTitle(currFB);
sprintf(text,"%s:%s",mode?"Select Rom":"Delete Rom",romDir);
gp_setClipping(0, 0, 319, 239);
gp_drawString(6,35,strlen(text)>=40?39:strlen(text),text,tTextColorTitle,framebuffer16[currFB]);
//gp_setClipping(8, MENU_AREA_Y_START, 8 + MAX_WIDTH, MENU_AREA_Y_END);
// Draw focused file's screenshot
if (bmpScreenshot) {
//unsigned int sh, sw;
//sh = MENU_AREA_Y_END - MENU_AREA_Y_START - 2 + 1;
//sw = (sh * bmpScreenshot->w)/ bmpScreenshot->h;
//gDrawScaledBitmap16(framebuffer16[currFB], xScreenshot, MENU_AREA_Y_START + 1, bmpScreenshot, sw, sh);
//if (xScreenshot > (SCREEN_WIDTH - sw - 4)) xScreenshot -= 2;
gDrawBitmap16(framebuffer16[currFB], xScreenshot, MENU_AREA_Y_START + 1, bmpScreenshot, 0, 0, bmpScreenshot->w, bmpScreenshot->h);
if (xScreenshot > (SCREEN_WIDTH - bmpScreenshot->w - 4)) xScreenshot -= 8;
}
smooth=smooth*7+(focus<<8); smooth>>=3;
scanstart=focus-15;
if (scanstart<0) scanstart=0;
scanend = focus+15;
if (scanend>romCount) scanend=romCount;
for (i=scanstart;i<scanend;i++)
{
int x=0,y=0, offset=0;
y=(i<<4)-(smooth>>4);
x=8;
y+=112;
if (y<= (MENU_AREA_Y_START - 8) || y>=232) continue;
gp_setClipping(8, MENU_AREA_Y_START, 8 + MAX_WIDTH, MENU_AREA_Y_END);
romname_length=strlen(romList[i].filename);
if (i==focus)
{
color=tTextColorFocus;
PrintBar(currFB,y-4);
if ((romname_length * 8) > MAX_WIDTH) { // let's scroll romname if length is bigger than screen width
if (frame == 0) txt_offset += txt_dir; // one of each 4 frames
if (txt_offset == 1) {txt_offset = 0; txt_dir = -1;}
if ((romname_length * 8 + txt_offset) < MAX_WIDTH) txt_dir = 1;
offset = txt_offset;
}
}
else
{
color=tTextColorItem;
if (bmpScreenshot) gp_setClipping(8, MENU_AREA_Y_START, xScreenshot - 1, MENU_AREA_Y_END);
}
// Draw Directory icon if current entry is a directory
if(romList[i].type == FILE_TYPE_DIRECTORY)
{
gp_drawString(x-8,y,1,"+",color,framebuffer16[currFB]);
}
gp_drawString(x + offset, y, romname_length,romList[i].filename,color,framebuffer16[currFB]);
}
gp_setClipping(0, 0, 319, 239);
frame = (frame + 1) & 3;
MenuFlip();
}
gDestroyBitmap(bmpScreenshot);
return action;
}
static void ScanSaveStates(char *romname)
{
FILE *stream;
int i=0;
char savename[MAX_PATH+1];
char filename[MAX_PATH+1];
char ext[MAX_PATH+1];
if(!strcmp(romname,saveStateName)) return; // is current save state rom so exit
SplitFilename(romname,filename,ext);
sprintf(savename,"%s.%s",filename,SAVESTATE_EXT);
for(i=0;i<10;i++)
{
/*
need to build a save state filename
all saves are held in current working directory (snesSaveStateDir)
save filename has following format
shortname(minus file ext) + SV + saveno ( 0 to 9 )
*/
sprintf(saveState[i].filename,"%s%d",savename,i);
sprintf(saveState[i].fullFilename,"%s%s%s",snesSaveStateDir,DIR_SEP,saveState[i].filename);
stream=(FILE*)fopen(saveState[i].fullFilename,"rb");
if(stream)
{
// we have a savestate
saveState[i].inUse = 1;
fclose(stream);
}
else
{
// no save state
saveState[i].inUse = 0;
}
}
strcpy(saveStateName,romname); // save the last scanned romname
}
void LoadStateFile(char *filename)
{
S9xUnfreezeGame(filename);
}
static void SaveStateFile(char *filename)
{
S9xFreezeGame(filename);
sync();
}
static int SaveStateSelect(int mode)
{
char text[128];
int action=11;
int saveno=0;
if(currentRomFilename[0]==0)
{
// no rom loaded
// display error message and exit
return(0);
}
memset(&headerDone,0,sizeof(headerDone));
ScanSaveStates(currentRomFilename);
while (action!=0&&action!=100)
{
InputUpdate(0);
if(Inp.held[INP_BUTTON_UP]==1) {saveno--; action=1;}
if(Inp.held[INP_BUTTON_DOWN]==1) {saveno++; action=1;}
if(saveno<-1) saveno=9;
if(saveno>9) saveno=-1;
if(Inp.held[INP_BUTTON_MENU_CANCEL]==1) action=0; // exit
else if((Inp.held[INP_BUTTON_MENU_SELECT]==1)&&(saveno==-1)) action=0; // exit
else if((Inp.held[INP_BUTTON_MENU_SELECT]==1)&&(mode==0)&&((action==2)||(action==5))) action=6; // pre-save mode
else if((Inp.held[INP_BUTTON_MENU_SELECT]==1)&&(mode==1)&&(action==5)) action=8; // pre-load mode
else if((Inp.held[INP_BUTTON_MENU_SELECT]==1)&&(mode==2)&&(action==5))
{
if(MenuMessageBox("Are you sure you want to delete","this save?","",0)==0) action=13; //delete slot with no preview
}
//else if((Inp.held[INP_BUTTON_R]==1)&&(action==12)) action=3; // preview slot mode
else if((Inp.held[INP_BUTTON_MENU_SELECT]==1)&&(mode==1)&&(action==12)) action=8; //load slot with no preview
else if((Inp.held[INP_BUTTON_MENU_SELECT]==1)&&(mode==0)&&(action==12)) action=6; //save slot with no preview
else if((Inp.held[INP_BUTTON_MENU_SELECT]==1)&&(mode==2)&&(action==12))
{
if(MenuMessageBox("Are you sure you want to delete","this save?","",0)==0) action=13; //delete slot with no preview
}
PrintTile(currFB);
PrintTitle(currFB);
if(mode==SAVESTATE_MODE_SAVE) gp_drawString(6,35,10,"Save State",tTextColorTitle,framebuffer16[currFB]);
if(mode==SAVESTATE_MODE_LOAD) gp_drawString(6,35,10,"Load State",tTextColorTitle,framebuffer16[currFB]);
if(mode==SAVESTATE_MODE_DELETE) gp_drawString(6,35,12,"Delete State",tTextColorTitle,framebuffer16[currFB]);
sprintf(text,"Press UP and DOWN to change save slot");
gp_drawString(12,230,strlen(text),text,(unsigned short)MENU_RGB(31,15,5),framebuffer16[currFB]);
if(saveno==-1)
{
if(action!=10&&action!=0)
{
action=10;
}
}
else
{
PrintBar(currFB,60-4);
sprintf(text,"SLOT %d",saveno);
gp_drawString(136,60,strlen(text),text,tTextColorItem,framebuffer16[currFB]);
}
switch(action)
{
case 1:
//gp_drawString(112,145,14,"Checking....",tTextColorItem,framebuffer16[currFB]);
break;
case 2:
gp_drawString(144,145,4,"FREE",tTextColorItem,framebuffer16[currFB]);
break;
case 3:
gp_drawString(104,145,14,"Previewing....",tTextColorItem,framebuffer16[currFB]);
break;
case 4:
gp_drawString(88,145,18,"Previewing....fail",tTextColorItem,framebuffer16[currFB]);
break;
case 5:
gp_drawString(112,145,17, "Not gonna happen!",tTextColorItem,framebuffer16[currFB]);
if(mode==1) gp_drawString((320-(strlen(MENU_TEXT_LOAD_SAVESTATE)<<3))>>1,210,strlen(MENU_TEXT_LOAD_SAVESTATE), MENU_TEXT_LOAD_SAVESTATE,tTextColorItem,framebuffer16[currFB]);
else if(mode==0) gp_drawString((320-(strlen(MENU_TEXT_OVERWRITE_SAVESTATE)<<3))>>1,210,strlen(MENU_TEXT_OVERWRITE_SAVESTATE), MENU_TEXT_OVERWRITE_SAVESTATE,tTextColorItem,framebuffer16[currFB]);
else if(mode==2) gp_drawString((320-(strlen(MENU_TEXT_DELETE_SAVESTATE)<<3))>>1,210,strlen(MENU_TEXT_DELETE_SAVESTATE), MENU_TEXT_DELETE_SAVESTATE,tTextColorItem,framebuffer16[currFB]);
break;
case 6:
gp_drawString(124,145,9,"Saving...",tTextColorItem,framebuffer16[currFB]);
break;
case 7:
gp_drawString(124,145,14,"Saving...Fail!",tTextColorItem,framebuffer16[currFB]);
break;
case 8:
gp_drawString(116,145,11,"loading....",tTextColorItem,framebuffer16[currFB]);
break;
case 9:
gp_drawString(116,145,15,"loading....Fail",tTextColorItem,framebuffer16[currFB]);
break;
case 10:
PrintBar(currFB,145-4);
gp_drawString(104,145,14,"Return To Menu",tTextColorItem,framebuffer16[currFB]);
break;
case 12:
gp_drawString(124,145,9,"Slot used",tTextColorItem,framebuffer16[currFB]);
//gp_drawString((320-(strlen(MENU_TEXT_PREVIEW_SAVESTATE)<<3))>>1,165,strlen(MENU_TEXT_PREVIEW_SAVESTATE),MENU_TEXT_PREVIEW_SAVESTATE,tTextColorItem,framebuffer16[currFB]);
if(mode==1) gp_drawString((320-(strlen(MENU_TEXT_LOAD_SAVESTATE)<<3))>>1,175,strlen(MENU_TEXT_LOAD_SAVESTATE), MENU_TEXT_LOAD_SAVESTATE,tTextColorItem,framebuffer16[currFB]);
else if(mode==0) gp_drawString((320-(strlen(MENU_TEXT_OVERWRITE_SAVESTATE)<<3))>>1,175,strlen(MENU_TEXT_OVERWRITE_SAVESTATE), MENU_TEXT_OVERWRITE_SAVESTATE,tTextColorItem,framebuffer16[currFB]);
else if(mode==2) gp_drawString((320-(strlen(MENU_TEXT_DELETE_SAVESTATE)<<3))>>1,175,strlen(MENU_TEXT_DELETE_SAVESTATE), MENU_TEXT_DELETE_SAVESTATE,tTextColorItem,framebuffer16[currFB]);
break;
case 13:
gp_drawString(116,145,11,"Deleting....",tTextColorItem,framebuffer16[currFB]);
break;
}
MenuFlip();
switch(action)
{
case 1:
if(saveState[saveno].inUse)
{
action=12;
}
else
{
action=2;
}
break;
case 3:
gp_setCpuspeed(MENU_FAST_CPU_SPEED);
LoadStateFile(saveState[saveno].fullFilename);
gp_setCpuspeed(MENU_CPU_SPEED);
action=5;
break;
case 6:
gp_setCpuspeed(MENU_FAST_CPU_SPEED);
SaveStateFile(saveState[saveno].fullFilename);
gp_setCpuspeed(MENU_CPU_SPEED);
saveState[saveno].inUse=1;
action=1;
break;
case 7:
action=1;
break;
case 8:
LoadStateFile(saveState[saveno].fullFilename);
action=100; // loaded ok so exit
break;
case 9:
action=1;
break;
case 11:
action=1;
break;
case 13:
remove(saveState[saveno].fullFilename);
sync();
saveState[saveno].inUse = 0;
action=1;
break;
}
}
memset(&headerDone,0,sizeof(headerDone));
return(action);
}
static
void RenderMenu(char *menuName, int menuCount, int menuSmooth, int menufocus)
{
int i=0;
char text[50];
unsigned short color=0;
PrintTile(currFB);
PrintTitle(currFB);
gp_setClipping(0, 0, 319, 239);
gp_drawString(6,35,strlen(menuName),menuName,tTextColorTitle,framebuffer16[currFB]);
gp_setClipping(8, MENU_AREA_Y_START, SCREEN_WIDTH - 8, MENU_AREA_Y_END);
// RRRRRGGGGGBBBBBI gp32 color format
for (i=0;i<menuCount;i++)
{
int x=0,y=0;
y=(i<<4)-(menuSmooth>>4);
x=8;
y+=112;
if (y<= (MENU_AREA_Y_START - 8) || y>=232) continue;
if (i==menufocus)
{
color=tTextColorFocus;
PrintBar(currFB,y-4);
}
else
{
color=tTextColorItem;
}
sprintf(text,"%s",menutext[i]);
gp_drawString(x,y,strlen(text),text,color,framebuffer16[currFB]);
}
gp_setClipping(0, 0, 319, 239);
}
static
int LoadRomMenu(void)
{
int menuExit=0,menuCount=LOAD_ROM_MENU_COUNT,menufocus=0,menuSmooth=0;
int action=0;
int subaction=0;
memset(&headerDone,0,sizeof(headerDone));
strcpy(romDir,snesRomDir);
subaction=FileSelect(0);
memset(&headerDone,0,sizeof(headerDone));
if(subaction)
{
action=EVENT_LOAD_SNES_ROM;
menuExit=1;
}
return action;
}
static
int SaveStateMenu(void)
{
int menuExit=0,menuCount=SAVESTATE_MENU_COUNT,menufocus=0,menuSmooth=0;
int action=0;
int subaction=0;
memset(&headerDone,0,sizeof(headerDone));
//Update
sprintf(menutext[SAVESTATE_MENU_LOAD],"Load State");
sprintf(menutext[SAVESTATE_MENU_SAVE],"Save State");
sprintf(menutext[SAVESTATE_MENU_DELETE],"Delete State");
sprintf(menutext[SAVESTATE_MENU_RETURN],"Back");
while (!menuExit)
{
InputUpdate(0);
// Change which rom is focused on:
if (Inp.repeat[INP_BUTTON_UP]) menufocus--; // Up
if (Inp.repeat[INP_BUTTON_DOWN]) menufocus++; // Down
if (Inp.held[INP_BUTTON_MENU_CANCEL]==1 ) menuExit=1;
if (menufocus>menuCount-1)
{
menufocus=0;
menuSmooth=(menufocus<<8)-1;
}
else if (menufocus<0)
{
menufocus=menuCount-1;
menuSmooth=(menufocus<<8)-1;
}
if (Inp.held[INP_BUTTON_MENU_SELECT]==1)
{
switch(menufocus)
{
case SAVESTATE_MENU_LOAD:
subaction=SaveStateSelect(SAVESTATE_MODE_LOAD);
if(subaction==100)
{
menuExit=1;
action=100;
}
break;
case SAVESTATE_MENU_SAVE:
SaveStateSelect(SAVESTATE_MODE_SAVE);
break;
case SAVESTATE_MENU_DELETE:
SaveStateSelect(SAVESTATE_MODE_DELETE);
break;
case SAVESTATE_MENU_RETURN:
menuExit=1;
break;
}
}
// Draw screen:
menuSmooth=menuSmooth*7+(menufocus<<8); menuSmooth>>=3;
RenderMenu("Save States", menuCount,menuSmooth,menufocus);
MenuFlip();
}
return action;
}
static
int SramMenu(void)
{
int menuExit=0,menuCount=SRAM_MENU_COUNT,menufocus=0,menuSmooth=0;
int action=0;
int subaction=0;
char *srammem=NULL;
memset(&headerDone,0,sizeof(headerDone));
//Update
sprintf(menutext[SRAM_MENU_LOAD],"Load SRAM");
sprintf(menutext[SRAM_MENU_SAVE],"Save SRAM");
sprintf(menutext[SRAM_MENU_DELETE],"Delete SRAM");
sprintf(menutext[SRAM_MENU_RETURN],"Back");
while (!menuExit)
{
InputUpdate(0);
// Change which rom is focused on:
if (Inp.repeat[INP_BUTTON_UP]) menufocus--; // Up
if (Inp.repeat[INP_BUTTON_DOWN]) menufocus++; // Down
if (Inp.held[INP_BUTTON_MENU_CANCEL]==1 ) menuExit=1;
if (menufocus>menuCount-1)
{
menufocus=0;
menuSmooth=(menufocus<<8)-1;
}
else if (menufocus<0)
{
menufocus=menuCount-1;
menuSmooth=(menufocus<<8)-1;
}
if (Inp.held[INP_BUTTON_MENU_SELECT]==1)
{
switch(menufocus)
{
case SRAM_MENU_LOAD:
//LoadSram(snesSramDir,currentRomFilename,SRAM_FILE_EXT,(char*)&sram);
break;
case SRAM_MENU_SAVE:
//SaveSram(snesSramDir,currentRomFilename,SRAM_FILE_EXT,(char*)&sram);
break;
case SRAM_MENU_DELETE:
//DeleteSram(snesSramDir,currentRomFilename,SRAM_FILE_EXT);
break;
case SRAM_MENU_RETURN:
menuExit=1;
break;
}
}
// Draw screen:
menuSmooth=menuSmooth*7+(menufocus<<8); menuSmooth>>=3;
RenderMenu("SRAM", menuCount,menuSmooth,menufocus);
MenuFlip();
}
return action;
}
static
void SNESOptionsUpdateText(int menu_index)
{
switch(menu_index)
{
case SNES_MENU_SOUND:
switch(snesMenuOptions.soundOn)
{
case 0:
sprintf(menutext[SNES_MENU_SOUND],"Sound: OFF");
break;
case 1:
sprintf(menutext[SNES_MENU_SOUND],"Sound: ON");
break;
}
break;
case SNES_MENU_SOUND_RATE:
if (snesMenuOptions.stereo)
sprintf(menutext[SNES_MENU_SOUND_RATE],"Sound Rate: %d stereo",(unsigned int)soundRates[snesMenuOptions.soundRate]);
else
sprintf(menutext[SNES_MENU_SOUND_RATE],"Sound Rate: %d mono",(unsigned int)soundRates[snesMenuOptions.soundRate]);
break;
#if defined(__GP2X__) || defined(__WIZ__)
case SNES_MENU_CPUSPEED:
sprintf(menutext[SNES_MENU_CPUSPEED],"Cpu Speed: %d",(unsigned int)cpuSpeedLookup[snesMenuOptions.cpuSpeed]);
break;
#endif
case SNES_MENU_SOUND_VOL:
sprintf(menutext[SNES_MENU_SOUND_VOL],"Volume: %d",snesMenuOptions.volume);
break;
case SNES_MENU_FRAMESKIP:
switch(snesMenuOptions.frameSkip)
{
case 0:
sprintf(menutext[SNES_MENU_FRAMESKIP],"Frameskip: AUTO");
break;
default:
sprintf(menutext[SNES_MENU_FRAMESKIP],"Frameskip: %d",snesMenuOptions.frameSkip-1);
break;
}
break;
case SNES_MENU_REGION:
switch(snesMenuOptions.region)
{
case 0:
sprintf(menutext[SNES_MENU_REGION],"Region: AUTO");
break;
case 1:
sprintf(menutext[SNES_MENU_REGION],"Region: NTSC");
break;
case 2:
sprintf(menutext[SNES_MENU_REGION],"Region: PAL");
break;
}
break;
case SNES_MENU_FPS:
switch(snesMenuOptions.showFps)
{
case 0:
sprintf(menutext[SNES_MENU_FPS],"Show FPS: OFF");
break;
case 1:
sprintf(menutext[SNES_MENU_FPS],"Show FPS: ON");
break;
}
break;
#if defined(__GP2X__)
case SNES_MENU_GAMMA:
sprintf(menutext[SNES_MENU_GAMMA],"Brightness: %d",snesMenuOptions.gamma+100);
break;
#endif
case SNES_MENU_TRANSPARENCY:
switch(snesMenuOptions.transparency)
{
case 0:
sprintf(menutext[SNES_MENU_TRANSPARENCY],"Transparencies: OFF");
break;
case 1:
sprintf(menutext[SNES_MENU_TRANSPARENCY],"Transparencies: ON");
break;
}
break;
case SNES_MENU_LOAD_GLOBAL:
sprintf(menutext[SNES_MENU_LOAD_GLOBAL],"Load Global Settings");
break;
case SNES_MENU_SAVE_GLOBAL:
sprintf(menutext[SNES_MENU_SAVE_GLOBAL],"Save Global Settings");
break;
case SNES_MENU_DELETE_GLOBAL:
sprintf(menutext[SNES_MENU_DELETE_GLOBAL],"Delete Global Settings");
break;
case SNES_MENU_LOAD_CURRENT:
sprintf(menutext[SNES_MENU_LOAD_CURRENT],"Load Settings For Current Game");
break;
case SNES_MENU_SAVE_CURRENT:
sprintf(menutext[SNES_MENU_SAVE_CURRENT],"Save Settings For Current Game");
break;
case SNES_MENU_DELETE_CURRENT:
sprintf(menutext[SNES_MENU_DELETE_CURRENT],"Delete Settings For Current Game");
break;
case SNES_MENU_SET_ROMDIR:
sprintf(menutext[SNES_MENU_SET_ROMDIR],"Save Current Rom Directory");
break;
case SNES_MENU_CLEAR_ROMDIR:
sprintf(menutext[SNES_MENU_CLEAR_ROMDIR],"Reset Default Rom Directory");
break;
case SNES_MENU_RETURN:
sprintf(menutext[SNES_MENU_RETURN],"Back");
break;
#if defined(__GP2X__) || defined(__WIZ__)
case SNES_MENU_RENDER_MODE:
switch(snesMenuOptions.renderMode)
{
case RENDER_MODE_UNSCALED:
sprintf(menutext[SNES_MENU_RENDER_MODE],"Render Mode: Unscaled");
break;
case RENDER_MODE_SCALED:
sprintf(menutext[SNES_MENU_RENDER_MODE],"Render Mode: Scaled");
break;
case RENDER_MODE_HORIZONTAL_SCALED:
sprintf(menutext[SNES_MENU_RENDER_MODE],"Render Mode: Horizontal Scaled");
break;
default:
sprintf(menutext[SNES_MENU_RENDER_MODE],"Render Mode: Unscaled");
break;
}
break;
case SNES_MENU_ACTION_BUTTONS:
switch(snesMenuOptions.actionButtons)
{
case 0:
sprintf(menutext[SNES_MENU_ACTION_BUTTONS],"Action Buttons: Normal");
break;
case 1:
sprintf(menutext[SNES_MENU_ACTION_BUTTONS],"Action Buttons: Swapped");
break;
}
break;
#endif
case SNES_MENU_AUTO_SAVE_SRAM:
switch(snesMenuOptions.autoSram)
{
case 0:
sprintf(menutext[SNES_MENU_AUTO_SAVE_SRAM],"Saving SRAM: Manual");
break;
case 1:
sprintf(menutext[SNES_MENU_AUTO_SAVE_SRAM],"Saving SRAM: Automatic");
break;
case 2:
sprintf(menutext[SNES_MENU_AUTO_SAVE_SRAM],"Saving SRAM: Manual + indicator");
break;
}
break;
case SNES_MENU_EMULATION_TYPE:
switch(snesMenuOptions.asmspc700)
{
case 0:
sprintf(menutext[SNES_MENU_EMULATION_TYPE],"Emulation (Reset Required): Compatible");
break;
case 1:
sprintf(menutext[SNES_MENU_EMULATION_TYPE],"Emulation (Reset Required): Fast");
break;
}
break;
case SNES_MENU_LOAD_ROM_ON_INIT:
switch(snesMenuOptions.loadOnInit)
{
case 0:
sprintf(menutext[SNES_MENU_LOAD_ROM_ON_INIT],"Load last played ROM at startup: OFF");
break;
case 1:
sprintf(menutext[SNES_MENU_LOAD_ROM_ON_INIT],"Load last played ROM at startup: ON");
break;
}
break;
case SNES_MENU_ADVANCED_HACKS:
sprintf(menutext[SNES_MENU_ADVANCED_HACKS],"Advanced hacks");
break;
}
}
static
void SNESHacksUpdateText(int menu_index)
{
switch(menu_index)
{
case HACKS_MENU_SNESADVANCE_DAT:
if (snesMenuOptions.SpeedHacks)
sprintf(menutext[HACKS_MENU_SNESADVANCE_DAT],"Apply snesadvance.dat on ROM load: ON");
else
sprintf(menutext[HACKS_MENU_SNESADVANCE_DAT],"Apply snesadvance.dat on ROM load: OFF");
break;
case HACKS_MENU_AUDIO:
if(snesMenuOptions.soundHack)
sprintf(menutext[HACKS_MENU_AUDIO],"Audio Performance hack: ON");
else
sprintf(menutext[HACKS_MENU_AUDIO],"Audio Performance hack: OFF");
break;
#ifdef __OLD_RASTER_FX__
case HACKS_MENU_DELAYED_RASTER_FX:
sprintf(menutext[HACKS_MENU_DELAYED_RASTER_FX], "Delayed Raster FX: %s", snesMenuOptions.delayedRasterFX ? "ON" : "OFF");
break;
#endif
case HACKS_MENU_PALETTE:
if(snesMenuOptions.graphHacks & PPU_IGNORE_PALWRITE)
sprintf(menutext[HACKS_MENU_PALETTE],"Ignore Palette writes: ON");
else
sprintf(menutext[HACKS_MENU_PALETTE],"Ignore Palette writes: OFF");
break;
case HACKS_MENU_FIXEDCOL:
if(snesMenuOptions.graphHacks & PPU_IGNORE_FIXEDCOLCHANGES)
sprintf(menutext[HACKS_MENU_FIXEDCOL],"Ignore Fixed Colour: ON");
else
sprintf(menutext[HACKS_MENU_FIXEDCOL],"Ignore Fixed Colour: OFF");
break;
case HACKS_MENU_WINDOW:
if(snesMenuOptions.graphHacks & PPU_IGNORE_WINDOW)
sprintf(menutext[HACKS_MENU_WINDOW],"Ignore Windows clipping: ON");
else
sprintf(menutext[HACKS_MENU_WINDOW],"Ignore Windows clipping: OFF");
break;
case HACKS_MENU_ADDSUB:
if(snesMenuOptions.graphHacks & PPU_IGNORE_ADDSUB)
sprintf(menutext[HACKS_MENU_ADDSUB],"Ignore Add/Sub modes: ON");
else
sprintf(menutext[HACKS_MENU_ADDSUB],"Ignore Add/Sub modes: OFF");
break;
case HACKS_MENU_OBJ:
if(snesMenuOptions.graphHacks & GFX_IGNORE_OBJ)
sprintf(menutext[HACKS_MENU_OBJ],"Ignore objects layer: ON");
else
sprintf(menutext[HACKS_MENU_OBJ],"Ignore objects layer: OFF");
break;
case HACKS_MENU_BG0:
if(snesMenuOptions.graphHacks & GFX_IGNORE_BG0)
sprintf(menutext[HACKS_MENU_BG0],"Ignore background layer 0: ON");
else
sprintf(menutext[HACKS_MENU_BG0],"Ignore background layer 0: OFF");
break;
case HACKS_MENU_BG1:
if(snesMenuOptions.graphHacks & GFX_IGNORE_BG1)
sprintf(menutext[HACKS_MENU_BG1],"Ignore background layer 1: ON");
else
sprintf(menutext[HACKS_MENU_BG1],"Ignore background layer 1: OFF");
break;
case HACKS_MENU_BG2:
if(snesMenuOptions.graphHacks & GFX_IGNORE_BG2)
sprintf(menutext[HACKS_MENU_BG2],"Ignore background layer 2: ON");
else
sprintf(menutext[HACKS_MENU_BG2],"Ignore background layer 2: OFF");
break;
case HACKS_MENU_BG3:
if(snesMenuOptions.graphHacks & GFX_IGNORE_BG3)
sprintf(menutext[HACKS_MENU_BG3],"Ignore background layer 3: ON");
else
sprintf(menutext[HACKS_MENU_BG3],"Ignore background layer 3: OFF");
break;
case HACKS_MENU_RETURN:
sprintf(menutext[HACKS_MENU_RETURN],"Back");
break;
}
}
static
void SNESHacksUpdateText_All()
{
SNESHacksUpdateText(HACKS_MENU_AUDIO);
SNESHacksUpdateText(HACKS_MENU_SNESADVANCE_DAT);
#ifdef __OLD_RASTER_FX__
SNESHacksUpdateText(HACKS_MENU_DELAYED_RASTER_FX);
#endif
SNESHacksUpdateText(HACKS_MENU_PALETTE);
SNESHacksUpdateText(HACKS_MENU_FIXEDCOL);
SNESHacksUpdateText(HACKS_MENU_WINDOW);
SNESHacksUpdateText(HACKS_MENU_ADDSUB);
SNESHacksUpdateText(HACKS_MENU_OBJ);
SNESHacksUpdateText(HACKS_MENU_BG0);
SNESHacksUpdateText(HACKS_MENU_BG1);
SNESHacksUpdateText(HACKS_MENU_BG2);
SNESHacksUpdateText(HACKS_MENU_BG3);
SNESHacksUpdateText(HACKS_MENU_RETURN);
}
static
int SNESHacksMenu(void)
{
int menuExit=0,menuCount=HACKS_MENU_COUNT,menufocus=0,menuSmooth=0;
int action=0;
int subaction=0;
memset(&headerDone,0,sizeof(headerDone));
//Update all items
SNESHacksUpdateText_All();
while (!menuExit)
{
InputUpdate(0);
// Change which rom is focused on:
if (Inp.repeat[INP_BUTTON_UP]) menufocus--; // Up
if (Inp.repeat[INP_BUTTON_DOWN]) menufocus++; // Down
if (Inp.held[INP_BUTTON_MENU_CANCEL]==1 ) menuExit=1;
if (menufocus>menuCount-1)
{
menufocus=0;
menuSmooth=(menufocus<<8)-1;
}
else if (menufocus<0)
{
menufocus=menuCount-1;
menuSmooth=(menufocus<<8)-1;
}
if (Inp.held[INP_BUTTON_LEFT]==1||
Inp.held[INP_BUTTON_RIGHT]==1||
Inp.repeat[INP_BUTTON_LEFT]||
Inp.repeat[INP_BUTTON_RIGHT])
{
switch(menufocus)
{
case HACKS_MENU_SNESADVANCE_DAT:
snesMenuOptions.SpeedHacks^=1;
SNESHacksUpdateText(HACKS_MENU_SNESADVANCE_DAT);
break;
case HACKS_MENU_AUDIO:
snesMenuOptions.soundHack^=1;
SNESHacksUpdateText(HACKS_MENU_AUDIO);
break;
#ifdef __OLD_RASTER_FX__
case HACKS_MENU_DELAYED_RASTER_FX:
snesMenuOptions.delayedRasterFX ^= 1;
SNESHacksUpdateText(HACKS_MENU_DELAYED_RASTER_FX);
break;
#endif
case HACKS_MENU_PALETTE:
if (snesMenuOptions.graphHacks & PPU_IGNORE_PALWRITE)
snesMenuOptions.graphHacks &= ~PPU_IGNORE_PALWRITE;
else
snesMenuOptions.graphHacks |= PPU_IGNORE_PALWRITE;
SNESHacksUpdateText(HACKS_MENU_PALETTE);
break;
case HACKS_MENU_FIXEDCOL:
if (snesMenuOptions.graphHacks & PPU_IGNORE_FIXEDCOLCHANGES)
snesMenuOptions.graphHacks &= ~PPU_IGNORE_FIXEDCOLCHANGES;
else
snesMenuOptions.graphHacks |= PPU_IGNORE_FIXEDCOLCHANGES;
SNESHacksUpdateText(HACKS_MENU_FIXEDCOL);
break;
case HACKS_MENU_WINDOW:
if (snesMenuOptions.graphHacks & PPU_IGNORE_WINDOW)
snesMenuOptions.graphHacks &= ~PPU_IGNORE_WINDOW;
else
snesMenuOptions.graphHacks |= PPU_IGNORE_WINDOW;
SNESHacksUpdateText(HACKS_MENU_WINDOW);
break;
case HACKS_MENU_ADDSUB:
if (snesMenuOptions.graphHacks & PPU_IGNORE_ADDSUB)
snesMenuOptions.graphHacks &= ~PPU_IGNORE_ADDSUB;
else
snesMenuOptions.graphHacks |= PPU_IGNORE_ADDSUB;
SNESHacksUpdateText(HACKS_MENU_ADDSUB);
break;
case HACKS_MENU_OBJ:
if (snesMenuOptions.graphHacks & GFX_IGNORE_OBJ)
snesMenuOptions.graphHacks &= ~GFX_IGNORE_OBJ;
else
snesMenuOptions.graphHacks |= GFX_IGNORE_OBJ;
SNESHacksUpdateText(HACKS_MENU_OBJ);
break;
case HACKS_MENU_BG0:
if (snesMenuOptions.graphHacks & GFX_IGNORE_BG0)
snesMenuOptions.graphHacks &= ~GFX_IGNORE_BG0;
else
snesMenuOptions.graphHacks |= GFX_IGNORE_BG0;
SNESHacksUpdateText(HACKS_MENU_BG0);
break;
case HACKS_MENU_BG1:
if (snesMenuOptions.graphHacks & GFX_IGNORE_BG1)
snesMenuOptions.graphHacks &= ~GFX_IGNORE_BG1;
else
snesMenuOptions.graphHacks |= GFX_IGNORE_BG1;
SNESHacksUpdateText(HACKS_MENU_BG1);
break;
case HACKS_MENU_BG2:
if (snesMenuOptions.graphHacks & GFX_IGNORE_BG2)
snesMenuOptions.graphHacks &= ~GFX_IGNORE_BG2;
else
snesMenuOptions.graphHacks |= GFX_IGNORE_BG2;
SNESHacksUpdateText(HACKS_MENU_BG2);
break;
case HACKS_MENU_BG3:
if (snesMenuOptions.graphHacks & GFX_IGNORE_BG3)
snesMenuOptions.graphHacks &= ~GFX_IGNORE_BG3;
else
snesMenuOptions.graphHacks |= GFX_IGNORE_BG3;
SNESHacksUpdateText(HACKS_MENU_BG3);
break;
}
}
if (Inp.held[INP_BUTTON_MENU_SELECT]==1)
{
switch(menufocus)
{
case HACKS_MENU_RETURN:
menuExit=1;
break;
}
}
// Draw screen:
menuSmooth=menuSmooth*7+(menufocus<<8); menuSmooth>>=3;
RenderMenu("SNES Advanced Hacks", menuCount,menuSmooth,menufocus);
MenuFlip();
}
return action;
}
static
void SNESOptionsUpdateText_All()
{
SNESOptionsUpdateText(SNES_MENU_SOUND);
SNESOptionsUpdateText(SNES_MENU_SOUND_RATE);
SNESOptionsUpdateText(SNES_MENU_SOUND_VOL);
SNESOptionsUpdateText(SNES_MENU_FRAMESKIP);
SNESOptionsUpdateText(SNES_MENU_REGION);
SNESOptionsUpdateText(SNES_MENU_FPS);
SNESOptionsUpdateText(SNES_MENU_TRANSPARENCY);
SNESOptionsUpdateText(SNES_MENU_LOAD_GLOBAL);
SNESOptionsUpdateText(SNES_MENU_SAVE_GLOBAL);
SNESOptionsUpdateText(SNES_MENU_DELETE_GLOBAL);
SNESOptionsUpdateText(SNES_MENU_LOAD_CURRENT);
SNESOptionsUpdateText(SNES_MENU_SAVE_CURRENT);
SNESOptionsUpdateText(SNES_MENU_DELETE_CURRENT);
SNESOptionsUpdateText(SNES_MENU_SET_ROMDIR);
SNESOptionsUpdateText(SNES_MENU_CLEAR_ROMDIR);
SNESOptionsUpdateText(SNES_MENU_RETURN);
#if defined(__GP2X__) || defined(__WIZ__)
SNESOptionsUpdateText(SNES_MENU_RENDER_MODE);
SNESOptionsUpdateText(SNES_MENU_CPUSPEED);
SNESOptionsUpdateText(SNES_MENU_ACTION_BUTTONS);
#endif
#if defined(__GP2X__)
SNESOptionsUpdateText(SNES_MENU_GAMMA);
#endif
SNESOptionsUpdateText(SNES_MENU_EMULATION_TYPE);
SNESOptionsUpdateText(SNES_MENU_AUTO_SAVE_SRAM);
SNESOptionsUpdateText(SNES_MENU_LOAD_ROM_ON_INIT);
SNESOptionsUpdateText(SNES_MENU_ADVANCED_HACKS);
}
static
int SNESOptionsMenu(void)
{
int menuExit=0,menuCount=SNES_MENU_COUNT,menufocus=0,menuSmooth=0;
int action=0;
int subaction=0;
memset(&headerDone,0,sizeof(headerDone));
//Update all items
SNESOptionsUpdateText_All();
while (!menuExit)
{
InputUpdate(0);
// Change which rom is focused on:
if (Inp.repeat[INP_BUTTON_UP]) menufocus--; // Up
if (Inp.repeat[INP_BUTTON_DOWN]) menufocus++; // Down
if (Inp.held[INP_BUTTON_MENU_CANCEL]==1 ) menuExit=1;
if (menufocus>menuCount-1)
{
menufocus=0;
menuSmooth=(menufocus<<8)-1;
}
else if (menufocus<0)
{
menufocus=menuCount-1;
menuSmooth=(menufocus<<8)-1;
}
if (Inp.held[INP_BUTTON_LEFT]==1||
Inp.held[INP_BUTTON_RIGHT]==1||
Inp.repeat[INP_BUTTON_LEFT]||
Inp.repeat[INP_BUTTON_RIGHT])
{
switch(menufocus)
{
case SNES_MENU_SOUND:
snesMenuOptions.soundOn^=1;
SNESOptionsUpdateText(SNES_MENU_SOUND);
break;
case SNES_MENU_SOUND_RATE:
if (Inp.held[INP_BUTTON_RIGHT]==1||Inp.repeat[INP_BUTTON_RIGHT])
{
if (!snesMenuOptions.stereo)
snesMenuOptions.stereo = 1;
else
{
snesMenuOptions.soundRate++;
snesMenuOptions.stereo = 0;
}
#if defined(__WIZ__)
if(snesMenuOptions.soundRate>2) snesMenuOptions.soundRate=0;
#else
if(snesMenuOptions.soundRate>4) snesMenuOptions.soundRate=0;
#endif
}
else
{
if (snesMenuOptions.stereo)
snesMenuOptions.stereo = 0;
else
{
snesMenuOptions.soundRate--;
snesMenuOptions.stereo = 1;
}
#if defined(__WIZ__)
if(snesMenuOptions.soundRate>2) snesMenuOptions.soundRate=2;
#else
if(snesMenuOptions.soundRate>4) snesMenuOptions.soundRate=4;
#endif
}
SNESOptionsUpdateText(SNES_MENU_SOUND_RATE);
break;
case SNES_MENU_SOUND_VOL:
if (Inp.held[INP_BUTTON_RIGHT]==1||Inp.repeat[INP_BUTTON_RIGHT])
{
snesMenuOptions.volume+=1;
if(snesMenuOptions.volume>100) snesMenuOptions.volume=0;
}
else
{
snesMenuOptions.volume-=1;
if(snesMenuOptions.volume>100) snesMenuOptions.volume=100;
}
SNESOptionsUpdateText(SNES_MENU_SOUND_VOL);
break;
#if defined(__GP2X__) || defined(__WIZ__)
case SNES_MENU_CPUSPEED:
if (Inp.held[INP_BUTTON_RIGHT]==1||Inp.repeat[INP_BUTTON_RIGHT])
{
snesMenuOptions.cpuSpeed++;
if(snesMenuOptions.cpuSpeed>45) snesMenuOptions.cpuSpeed=0;
}
else
{
snesMenuOptions.cpuSpeed--;
if(snesMenuOptions.cpuSpeed>45) snesMenuOptions.cpuSpeed=45;
}
SNESOptionsUpdateText(SNES_MENU_CPUSPEED);
break;
#endif
case SNES_MENU_FRAMESKIP:
if (Inp.held[INP_BUTTON_RIGHT]==1||Inp.repeat[INP_BUTTON_RIGHT])
{
snesMenuOptions.frameSkip++;
if(snesMenuOptions.frameSkip>6) snesMenuOptions.frameSkip=0;
}
else
{
snesMenuOptions.frameSkip--;
if(snesMenuOptions.frameSkip>6) snesMenuOptions.frameSkip=6;
}
SNESOptionsUpdateText(SNES_MENU_FRAMESKIP);
break;
case SNES_MENU_REGION:
if (Inp.held[INP_BUTTON_RIGHT]==1||Inp.repeat[INP_BUTTON_RIGHT])
{
snesMenuOptions.region++;
if(snesMenuOptions.region>2) snesMenuOptions.region=0;
}
else
{
snesMenuOptions.region--;
if(snesMenuOptions.region>2) snesMenuOptions.region=2;
}
SNESOptionsUpdateText(SNES_MENU_REGION);
break;
case SNES_MENU_FPS:
snesMenuOptions.showFps^=1;
SNESOptionsUpdateText(SNES_MENU_FPS);
break;
#if defined(__GP2X__)
case SNES_MENU_GAMMA:
if (Inp.held[INP_BUTTON_RIGHT]==1||Inp.repeat[INP_BUTTON_RIGHT])
{
snesMenuOptions.gamma++;
if(snesMenuOptions.gamma>100) snesMenuOptions.gamma=100;
}
else
{
snesMenuOptions.gamma--;
if(snesMenuOptions.gamma<-100) snesMenuOptions.gamma=-100;
}
set_gamma(snesMenuOptions.gamma+100);
SNESOptionsUpdateText(SNES_MENU_GAMMA);
break;
#endif
#if defined(__GP2X__) || defined(__WIZ__)
case SNES_MENU_ACTION_BUTTONS:
snesMenuOptions.actionButtons^=1;
SNESOptionsUpdateText(SNES_MENU_ACTION_BUTTONS);
break;
#endif
case SNES_MENU_TRANSPARENCY:
snesMenuOptions.transparency^=1;
SNESOptionsUpdateText(SNES_MENU_TRANSPARENCY);
break;
#if defined(__GP2X__) || defined(__WIZ__)
case SNES_MENU_RENDER_MODE:
if (Inp.held[INP_BUTTON_RIGHT]==1||Inp.repeat[INP_BUTTON_RIGHT])
{
snesMenuOptions.renderMode++;
if (snesMenuOptions.renderMode > RENDER_MODE_HORIZONTAL_SCALED)
snesMenuOptions.renderMode = RENDER_MODE_UNSCALED;
}
else
{
snesMenuOptions.renderMode--;
if (snesMenuOptions.renderMode > RENDER_MODE_HORIZONTAL_SCALED)
snesMenuOptions.renderMode = RENDER_MODE_HORIZONTAL_SCALED;
}
SNESOptionsUpdateText(SNES_MENU_RENDER_MODE);
break;
#endif
case SNES_MENU_AUTO_SAVE_SRAM:
//snesMenuOptions.autoSram^=1;
if ((++snesMenuOptions.autoSram) > 2) snesMenuOptions.autoSram = 0;
SNESOptionsUpdateText(SNES_MENU_AUTO_SAVE_SRAM);
break;
case SNES_MENU_EMULATION_TYPE:
snesMenuOptions.asmspc700^=1;
SNESOptionsUpdateText(SNES_MENU_EMULATION_TYPE);
break;
case SNES_MENU_LOAD_ROM_ON_INIT:
snesMenuOptions.loadOnInit ^= 1;
SNESOptionsUpdateText(SNES_MENU_LOAD_ROM_ON_INIT);
break;
}
}
if (Inp.held[INP_BUTTON_MENU_SELECT]==1)
{
switch(menufocus)
{
case SNES_MENU_ADVANCED_HACKS:
memset(&headerDone,0,sizeof(headerDone));
subaction = SNESHacksMenu();
memset(&headerDone,0,sizeof(headerDone));
SNESOptionsUpdateText_All();
break;
case SNES_MENU_LOAD_GLOBAL:
LoadMenuOptions(snesOptionsDir, MENU_OPTIONS_FILENAME, MENU_OPTIONS_EXT, (char*)&snesMenuOptions, sizeof(snesMenuOptions),1);
SNESOptionsUpdateText_All();
break;
case SNES_MENU_SAVE_GLOBAL:
SaveMenuOptions(snesOptionsDir, MENU_OPTIONS_FILENAME, MENU_OPTIONS_EXT, (char*)&snesMenuOptions, sizeof(snesMenuOptions),1);
break;
case SNES_MENU_DELETE_GLOBAL:
DeleteMenuOptions(snesOptionsDir,MENU_OPTIONS_FILENAME,MENU_OPTIONS_EXT,1);
break;
case SNES_MENU_LOAD_CURRENT:
if(currentRomFilename[0]!=0)
{
LoadMenuOptions(snesOptionsDir, currentRomFilename, MENU_OPTIONS_EXT, (char*)&snesMenuOptions, sizeof(snesMenuOptions),1);
SNESOptionsUpdateText_All();
}
break;
case SNES_MENU_SAVE_CURRENT:
if(currentRomFilename[0]!=0)
{
SaveMenuOptions(snesOptionsDir, currentRomFilename, MENU_OPTIONS_EXT, (char*)&snesMenuOptions, sizeof(snesMenuOptions),1);
}
break;
case SNES_MENU_DELETE_CURRENT:
if(currentRomFilename[0]!=0)
{
DeleteMenuOptions(snesOptionsDir, currentRomFilename, MENU_OPTIONS_EXT,1);
}
break;
case SNES_MENU_SET_ROMDIR:
SaveMenuOptions(snesOptionsDir, DEFAULT_ROM_DIR_FILENAME, DEFAULT_ROM_DIR_EXT, romDir, strlen(romDir),1);
strcpy(snesRomDir,romDir);
break;
case SNES_MENU_CLEAR_ROMDIR:
DeleteMenuOptions(snesOptionsDir, DEFAULT_ROM_DIR_FILENAME, DEFAULT_ROM_DIR_EXT,1);
strcpy(snesRomDir,currentWorkingDir);
break;
case SNES_MENU_RETURN:
menuExit=1;
break;
}
}
// Draw screen:
menuSmooth=menuSmooth*7+(menufocus<<8); menuSmooth>>=3;
RenderMenu("SNES Options", menuCount,menuSmooth,menufocus);
MenuFlip();
}
return action;
}
static int screenshotSaved;
static void MainMenuUpdateText(void)
{
sprintf(menutext[MAIN_MENU_ROM_SELECT],"Select Rom");
sprintf(menutext[MAIN_MENU_MANAGE_SAVE_STATE],"Manage Save States");
sprintf(menutext[MAIN_MENU_SAVE_SRAM],"Save SRAM");
if (!screenshotSaved) sprintf(menutext[MAIN_MENU_SAVE_SCREENSHOT],"Save Screenshot");
else sprintf(menutext[MAIN_MENU_SAVE_SCREENSHOT],"[Screenshot already saved]");
sprintf(menutext[MAIN_MENU_SNES_OPTIONS],"SNES Options");
sprintf(menutext[MAIN_MENU_RESET_GAME],"Reset Game");
sprintf(menutext[MAIN_MENU_EXIT_APP],"Exit Application");
sprintf(menutext[MAIN_MENU_RETURN],"Return To Game");
}
int MainMenu(int prevaction)
{
int menuExit=0,menuCount=MAIN_MENU_COUNT,menufocus=0,menuSmooth=0;
int action=prevaction;
int subaction=0;
screenshotSaved = 0;
gp_setCpuspeed(MENU_CPU_SPEED);
gp_initGraphics(16,currFB,1);
gp_clearFramebuffer16((unsigned short*)framebuffer16[currFB],0x0);
MenuFlip();
#if !defined(__WIZ__)
gp_video_RGB_setscaling(320,240);
#endif
memset(&headerDone,0,sizeof(headerDone));
MainMenuUpdateText();
while (!menuExit)
{
InputUpdate(0);
// Change which rom is focused on:
if (Inp.repeat[INP_BUTTON_UP]) menufocus--; // Up
if (Inp.repeat[INP_BUTTON_DOWN]) menufocus++; // Down
if (Inp.held[INP_BUTTON_MENU_CANCEL]==1 )
{
if(currentRomFilename[0]!=0)
{
menuExit=1;
}
}
if (menufocus>menuCount-1)
{
menufocus=0;
menuSmooth=(menufocus<<8)-1;
}
else if (menufocus<0)
{
menufocus=menuCount-1;
menuSmooth=(menufocus<<8)-1;
}
if (Inp.held[INP_BUTTON_MENU_SELECT]==1)
{
switch(menufocus)
{
case MAIN_MENU_ROM_SELECT:
memset(&headerDone,0,sizeof(headerDone));
subaction=LoadRomMenu();
memset(&headerDone,0,sizeof(headerDone));
if(subaction)
{
action=subaction;
menuExit=1;
}
MainMenuUpdateText();
break;
case MAIN_MENU_MANAGE_SAVE_STATE:
if(currentRomFilename[0]!=0)
{
memset(&headerDone,0,sizeof(headerDone));
subaction=SaveStateMenu();
if (subaction==100)
{
menuExit=1;
}
memset(&headerDone,0,sizeof(headerDone));
}
MainMenuUpdateText();
break;
case MAIN_MENU_SAVE_SRAM:
if(currentRomFilename[0]!=0)
{
S9xSaveSRAM();
}
break;
case MAIN_MENU_SNES_OPTIONS:
memset(&headerDone,0,sizeof(headerDone));
subaction=SNESOptionsMenu();
memset(&headerDone,0,sizeof(headerDone));
MainMenuUpdateText();
break;
case MAIN_MENU_SAVE_SCREENSHOT:
if (!screenshotSaved) {
ShowMessage("Saving screenshot...", 1);
if (saveScreenShot() == 0) {
screenshotSaved = 1;
MainMenuUpdateText();
}
}
break;
case MAIN_MENU_RESET_GAME :
if(currentRomFilename[0]!=0)
{
switch(currentEmuMode)
{
case EMU_MODE_SNES:
action=EVENT_RESET_SNES_ROM;
menuExit=1;
break;
}
}
break;
case MAIN_MENU_RETURN:
if(currentRomFilename[0]!=0)
{
menuExit=1;
}
break;
case MAIN_MENU_EXIT_APP:
action=EVENT_EXIT_APP;
menuExit=1;
break;
}
}
// Draw screen:
menuSmooth=menuSmooth*7+(menufocus<<8); menuSmooth>>=3;
RenderMenu("Main Menu", menuCount,menuSmooth,menufocus);
MenuFlip();
}
WaitForButtonsUp();
return action;
}
|