44
44
// CONTROL PINS:
45
45
// CLK(PH1) - SNES CPUCLK
46
46
// R/W(PH6) - SNES /RD
47
+ // HALT(PH0) - SNES /RESET
47
48
48
49
// ******************************************
49
50
// Supported Mappers
@@ -58,9 +59,10 @@ static const byte PROGMEM a7800mapsize[] = {
58
59
4 , 4 , 4 , // Double Dragon/Rampage 128K [78AC]
59
60
5 , 3 , 3 , // Realsports Baseball/Tank Command/Tower Toppler/Waterski 64K [78S4]
60
61
6 , 3 , 3 , // Karateka (PAL) 64K [78S4 Variant]
62
+ 7 , 1 , 4 , // Bankset switching
61
63
};
62
64
63
- byte a7800mapcount = 7 ; // (sizeof(a7800mapsize) / sizeof(a7800mapsize[0])) / 3;
65
+ byte a7800mapcount = 8 ; // (sizeof(a7800mapsize) / sizeof(a7800mapsize[0])) / 3;
64
66
byte a7800mapselect;
65
67
int a7800index;
66
68
@@ -96,7 +98,7 @@ void setup_7800() {
96
98
DDRL = 0xFF ;
97
99
98
100
// Set Control Pins to Output
99
- // --- (PH0) ---(PH3) ---(PH4) ---(PH5) R/W(PH6)
101
+ // HALT (PH0) ---(PH3) ---(PH4) ---(PH5) R/W(PH6)
100
102
DDRH |= (1 << 0 ) | (1 << 3 ) | (1 << 4 ) | (1 << 5 ) | (1 << 6 );
101
103
102
104
// Set TIME(PJ0) to Output (UNUSED)
@@ -106,7 +108,7 @@ void setup_7800() {
106
108
DDRC = 0x00 ;
107
109
108
110
// Setting Control Pins to HIGH
109
- // --- (PH0) ---(PH3) ---(PH4) ---(PH5) R/W(PH6)
111
+ // HALT (PH0) ---(PH3) ---(PH4) ---(PH5) R/W(PH6)
110
112
PORTH |= (1 << 0 ) | (1 << 3 ) | (1 << 4 ) | (1 << 5 ) | (1 << 6 );
111
113
112
114
// Set Unused Data Pins (PA0-PA7) to Output
@@ -263,7 +265,32 @@ void writeData_7800(uint32_t addr, uint8_t data) {
263
265
NOP;
264
266
NOP;
265
267
NOP;
268
+ NOP;
269
+ NOP;
270
+ NOP;
271
+ NOP;
272
+ NOP;
273
+ NOP;
274
+ NOP;
275
+ NOP;
276
+ NOP;
277
+ NOP;
266
278
PORTH |= (1 << 6 ); // R/W(PH6) HIGH = READ
279
+ NOP;
280
+ NOP;
281
+ NOP;
282
+ NOP;
283
+ NOP;
284
+ NOP;
285
+ NOP;
286
+ NOP;
287
+ NOP;
288
+ NOP;
289
+ NOP;
290
+ NOP;
291
+ NOP;
292
+ NOP;
293
+ NOP;
267
294
268
295
DDRC = 0x00 ; // Reset to Input
269
296
}
@@ -321,20 +348,11 @@ void readROM_7800() {
321
348
322
349
switch (a7800mapper) {
323
350
case 0 : // Standard 16K/32K/48K [7816/7832/7848]
324
- if (a7800size > 1 )
325
- readSegment_7800 (0x4000 , 0x8000 ); // +16K = 48K
326
- if (a7800size > 0 )
327
- readSegment_7800 (0x8000 , 0xC000 ); // +16K = 32K
328
- // Base 16K
329
- readSegment_7800 (0xC000 , 0x10000 ); // 16K
351
+ readStandard_7800 ();
330
352
break ;
331
353
332
354
case 1 : // SuperGame 128K [78SG]
333
- for (int x = 0 ; x < 7 ; x++) {
334
- writeData_7800 (0x8000 , x); // Banks 0-6
335
- readSegment_7800 (0x8000 , 0xC000 ); // 16K * 7 = 112K
336
- }
337
- readSegment_7800 (0xC000 , 0x10000 ); // Bank 7 +16 = 128K
355
+ readSupergame_7800 ();
338
356
break ;
339
357
340
358
case 2 : // SuperGame - Alien Brigade/Crossbow 144K [78S9]
@@ -392,6 +410,20 @@ void readROM_7800() {
392
410
readSegment_7800 (0x8000 , 0xC000 ); // 16K * 4 = 64K
393
411
}
394
412
break ;
413
+
414
+ case 7 : // Bankset switching
415
+ if (a7800size > 3 ) {
416
+ setHalt_7800 (1 );
417
+ readSupergame_7800 ();
418
+ setHalt_7800 (0 );
419
+ readSupergame_7800 ();
420
+ } else {
421
+ setHalt_7800 (1 );
422
+ readStandard_7800 ();
423
+ setHalt_7800 (0 );
424
+ readStandard_7800 ();
425
+ }
426
+ break ;
395
427
}
396
428
myFile.close ();
397
429
@@ -405,6 +437,38 @@ void readROM_7800() {
405
437
wait ();
406
438
}
407
439
440
+ void readStandard_7800 () {
441
+ if (a7800size > 1 )
442
+ readSegment_7800 (0x4000 , 0x8000 ); // +16K = 48K
443
+ if (a7800size > 0 )
444
+ readSegment_7800 (0x8000 , 0xC000 ); // +16K = 32K
445
+ // Base 16K
446
+ readSegment_7800 (0xC000 , 0x10000 ); // 16K
447
+ }
448
+
449
+ void readSupergame_7800 () {
450
+ for (int x = 0 ; x < 7 ; x++) {
451
+ writeData_7800 (0x8000 , x); // Banks 0-6
452
+ readSegment_7800 (0x8000 , 0xC000 ); // 16K * 7 = 112K
453
+ }
454
+ readSegment_7800 (0xC000 , 0x10000 ); // Bank 7 +16 = 128K
455
+ }
456
+
457
+ void setHalt_7800 (byte on) {
458
+ if (on == 1 ) {
459
+ PORTH |= (1 << 0 ); // HALT(PH0) HIGH = SALLY
460
+ } else {
461
+ PORTH &= ~(1 << 0 ); // HALT(PH0) LOW = MARIA
462
+ }
463
+ NOP;
464
+ NOP;
465
+ NOP;
466
+ NOP;
467
+ NOP;
468
+ NOP;
469
+ NOP;
470
+ }
471
+
408
472
// ******************************************
409
473
// ROM SIZE
410
474
// ******************************************
@@ -560,6 +624,8 @@ void checkStatus_7800() {
560
624
println_Msg (F (" BASEBALL/ETC [78S4]" ));
561
625
else if (a7800mapper == 6 )
562
626
println_Msg (F (" KARATEKA(PAL)[78S4]" ));
627
+ else if (a7800mapper == 7 )
628
+ println_Msg (F (" BANKSET" ));
563
629
print_Msg (F (" ROM SIZE: " ));
564
630
print_Msg (a7800[a7800size]);
565
631
println_Msg (F (" K" ));
@@ -582,6 +648,8 @@ void checkStatus_7800() {
582
648
Serial.println (F (" Realsports Baseball/Tank Command/Tower Toppler/Waterski [78S4]" ));
583
649
else if (a7800mapper == 6 )
584
650
Serial.println (F (" Karateka (PAL) [78S4 Variant]" ));
651
+ else if (a7800mapper == 7 )
652
+ Serial.println (F (" Bankset" ));
585
653
Serial.print (F (" ROM SIZE: " ));
586
654
Serial.print (A7800[a7800size]);
587
655
Serial.println (F (" K" ));
@@ -637,6 +705,8 @@ void setMapper_7800() {
637
705
println_Msg (F (" BASEBALL/ETC [78S4]" ));
638
706
else if (a7800mapselect == 6 )
639
707
println_Msg (F (" KARATEKA(PAL) [78S4]" ));
708
+ else if (a7800mapselect == 7 )
709
+ println_Msg (F (" BANKSET" ));
640
710
display_Update ();
641
711
if (i == (a7800mapcount - 1 ))
642
712
i = 0 ;
@@ -665,6 +735,8 @@ void setMapper_7800() {
665
735
println_Msg (F (" BASEBALL/ETC [78S4]" ));
666
736
else if (a7800mapselect == 6 )
667
737
println_Msg (F (" KARATEKA(PAL) [78S4]" ));
738
+ else if (a7800mapselect == 7 )
739
+ println_Msg (F (" BANKSET" ));
668
740
println_Msg (FS (FSTRING_EMPTY));
669
741
#if defined(ENABLE_OLED)
670
742
print_STR (press_to_change_STR, 1 );
@@ -702,6 +774,8 @@ void setMapper_7800() {
702
774
println_Msg (F (" BASEBALL/ETC [78S4]" ));
703
775
else if (a7800mapselect == 6 )
704
776
println_Msg (F (" KARATEKA(PAL) [78S4]" ));
777
+ else if (a7800mapselect == 7 )
778
+ println_Msg (F (" BANKSET" ));
705
779
println_Msg (FS (FSTRING_EMPTY));
706
780
#if defined(ENABLE_OLED)
707
781
print_STR (press_to_change_STR, 1 );
@@ -738,6 +812,8 @@ void setMapper_7800() {
738
812
println_Msg (F (" BASEBALL/ETC [78S4]" ));
739
813
else if (a7800mapselect == 6 )
740
814
println_Msg (F (" KARATEKA(PAL) [78S4]" ));
815
+ else if (a7800mapselect == 7 )
816
+ println_Msg (F (" BANKSET" ));
741
817
println_Msg (FS (FSTRING_EMPTY));
742
818
#if defined(ENABLE_OLED)
743
819
print_STR (press_to_change_STR, 1 );
@@ -770,7 +846,8 @@ setmapper:
770
846
Serial.println (F (" 4 = Double Dragon/Rampage [78AC]" ));
771
847
Serial.println (F (" 5 = Realsports Baseball/Tank Command/Tower Toppler/Waterski [78S4]" ));
772
848
Serial.println (F (" 6 = Karateka (PAL) [78S4 Variant]" ));
773
- Serial.print (F (" Enter Mapper [0-6]: " ));
849
+ Serial.println (F (" 7 = Bankset" ));
850
+ Serial.print (F (" Enter Mapper [0-7]: " ));
774
851
while (Serial.available () == 0 ) {}
775
852
newmap = Serial.readStringUntil (' \n ' );
776
853
Serial.println (newmap);
0 commit comments