forked from sanni/cartreader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGBSmart.ino
784 lines (637 loc) · 18 KB
/
GBSmart.ino
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
//******************************************
// GB SMART MODULE
// Supports 32M cart with LH28F016SUT flash
//******************************************
#include "options.h"
#ifdef enable_GBX
#define GB_SMART_GAMES_PER_PAGE 6
/******************************************
Menu
*****************************************/
// GB Smart menu items
static const char gbSmartMenuItem1[] PROGMEM = "Game Menu";
static const char gbSmartMenuItem2[] PROGMEM = "Flash Menu";
static const char gbSmartMenuItem3[] PROGMEM = "Reset";
static const char* const menuOptionsGBSmart[] PROGMEM = {gbSmartMenuItem1, gbSmartMenuItem2, gbSmartMenuItem3};
static const char gbSmartFlashMenuItem1[] PROGMEM = "Read Flash";
static const char gbSmartFlashMenuItem2[] PROGMEM = "Write Flash";
static const char gbSmartFlashMenuItem3[] PROGMEM = "Back";
static const char* const menuOptionsGBSmartFlash[] PROGMEM = {gbSmartFlashMenuItem1, gbSmartFlashMenuItem2, gbSmartFlashMenuItem3};
static const char gbSmartGameMenuItem1[] PROGMEM = "Read Game";
static const char gbSmartGameMenuItem2[] PROGMEM = "Read SRAM";
static const char gbSmartGameMenuItem3[] PROGMEM = "Write SRAM";
static const char gbSmartGameMenuItem4[] PROGMEM = "Switch Game";
static const char gbSmartGameMenuItem5[] PROGMEM = "Reset";
static const char* const menuOptionsGBSmartGame[] PROGMEM = {gbSmartGameMenuItem1, gbSmartGameMenuItem2, gbSmartGameMenuItem3, gbSmartGameMenuItem4, gbSmartGameMenuItem5};
typedef struct
{
uint8_t start_bank;
uint8_t rom_type;
uint8_t rom_size;
uint8_t sram_size;
char title[16];
} GBSmartGameInfo;
uint32_t gbSmartSize = 32 * 131072;
uint16_t gbSmartBanks = 256;
uint8_t gbSmartBanksPerFlashChip = 128;
uint8_t gbSmartBanksPerFlashBlock = 4;
uint32_t gbSmartFlashBlockSize = (gbSmartBanksPerFlashBlock << 14);
uint8_t gbSmartRomSizeGB = 0x07;
uint8_t gbSmartSramSizeGB = 0x04;
uint8_t gbSmartFlashSizeGB = 0x06;
GBSmartGameInfo gbSmartGames[GB_SMART_GAMES_PER_PAGE];
byte signature[48];
uint16_t gameMenuStartBank;
#ifdef enable_NP
extern boolean hasMenu;
extern byte numGames;
#else
boolean hasMenu;
byte numGames;
#endif
byte readByte_GBS(word myAddress) {
PORTF = myAddress & 0xFF;
PORTK = (myAddress >> 8) & 0xFF;
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
// Switch CS(PH3) and RD(PH6) to LOW
PORTH &= ~((1 << 3) | (1 << 6));
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
// Read
byte tempByte = PINC;
// Switch CS(PH3) and RD(PH6) to HIGH
PORTH |= (1 << 3) | (1 << 6);
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
return tempByte;
}
void setup_GBSmart()
{
// take from setup_GB
// Set RST(PH0) to Input
DDRH &= ~(1 << 0);
// Activate Internal Pullup Resistors
PORTH |= (1 << 0);
// Set Address Pins to Output
//A0-A7
DDRF = 0xFF;
//A8-A15
DDRK = 0xFF;
// Set Control Pins to Output CS(PH3) WR(PH5) RD(PH6) AUDIOIN(PH4) RESET(PH0)
DDRH |= (1 << 0) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
// Output a high signal on all pins, pins are active low therefore everything is disabled now
PORTH |= (1 << 0) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
// Set Data Pins (D0-D7) to Input
DDRC = 0x00;
delay(400);
gbSmartRemapStartBank(0x00, 0x00, 0x00);
getCartInfo_GB();
for (byte i = 0; i < 0x30; i++)
signature[i] = readByte_GBS(0x0104 + i);
gameMenuStartBank = 0x02;
hasMenu = true;
numGames = 0;
display_Clear();
display_Update();
}
void gbSmartMenu()
{
uint8_t mainMenu;
// Copy menuOptions out of progmem
convertPgm(menuOptionsGBSmart, 3);
mainMenu = question_box(F("GB Smart"), menuOptions, 3, 0);
// wait for user choice to come back from the question box menu
switch (mainMenu)
{
case 0:
{
gbSmartGameMenu();
break;
}
case 1:
{
mode = mode_GB_GBSmart_Flash;
break;
}
default:
{
asm volatile (" jmp 0");
break;
}
}
}
void gbSmartGameOptions()
{
uint8_t gameSubMenu;
convertPgm(menuOptionsGBSmartGame, 5);
gameSubMenu = question_box(F("GB Smart Game Menu"), menuOptions, 5, 0);
switch (gameSubMenu)
{
case 0: // Read Game
{
display_Clear();
sd.chdir("/");
readROM_GB();
compare_checksum_GB();
break;
}
case 1: // Read SRAM
{
display_Clear();
sd.chdir("/");
readSRAM_GB();
break;
}
case 2: // Write SRAM
{
display_Clear();
sd.chdir("/");
writeSRAM_GB();
uint32_t wrErrors = verifySRAM_GB();
if (wrErrors == 0)
{
println_Msg(F("Verified OK"));
display_Update();
}
else
{
print_Msg(F("Error: "));
print_Msg(wrErrors);
println_Msg(F(" bytes"));
print_Error(F("did not verify."), false);
}
break;
}
case 3: // Switch Game
{
gameMenuStartBank = 0x02;
gbSmartGameMenu();
break;
}
default:
{
asm volatile (" jmp 0");
break;
}
}
if (gameSubMenu != 3)
{
println_Msg(F(""));
println_Msg(F("Press Button..."));
display_Update();
wait();
}
}
void gbSmartGameMenu()
{
uint8_t gameSubMenu = 0;
gb_smart_load_more_games:
if (gameMenuStartBank > 0xfe)
gameMenuStartBank = 0x02;
gbSmartGetGames();
if (hasMenu)
{
char menuOptionsGBSmartGames[7][20];
int i = 0;
for (; i < numGames; i++)
strncpy(menuOptionsGBSmartGames[i], gbSmartGames[i].title, 16);
strncpy(menuOptionsGBSmartGames[i], "...", 16);
gameSubMenu = question_box(F("Select Game"), menuOptionsGBSmartGames, i + 1, 0);
if (gameSubMenu >= i)
goto gb_smart_load_more_games;
}
else
{
gameSubMenu = 0;
}
// copy romname
strcpy(romName, gbSmartGames[gameSubMenu].title);
// select a game
gbSmartRemapStartBank(gbSmartGames[gameSubMenu].start_bank, gbSmartGames[gameSubMenu].rom_size, gbSmartGames[gameSubMenu].sram_size);
getCartInfo_GB();
showCartInfo_GB();
mode = mode_GB_GBSmart_Game;
}
void gbSmartFlashMenu()
{
uint8_t flashSubMenu;
convertPgm(menuOptionsGBSmartFlash, 3);
flashSubMenu = question_box(F("GB Smart Flash Menu"), menuOptions, 3, 0);
switch (flashSubMenu)
{
case 0:
{
// read flash
display_Clear();
sd.chdir("/");
EEPROM_readAnything(0, foldern);
sprintf(fileName, "GBS%d.bin", foldern);
sd.mkdir("GB/GBS", true);
sd.chdir("GB/GBS");
foldern = foldern + 1;
EEPROM_writeAnything(0, foldern);
gbSmartReadFlash();
break;
}
case 1:
{
// write flash
display_Clear();
println_Msg(F("Attention"));
println_Msg(F("This will erase your"));
println_Msg(F("GB Smart Cartridge."));
println_Msg(F(""));
println_Msg(F("Press Button"));
println_Msg(F("to continue"));
display_Update();
wait();
display_Clear();
filePath[0] = '\0';
sd.chdir("/");
fileBrowser(F("Select 4MB file"));
sprintf(filePath, "%s/%s", filePath, fileName);
gbSmartWriteFlash();
break;
}
default:
{
mode = mode_GB_GBSmart;
return;
}
}
println_Msg(F(""));
println_Msg(F("Press Button..."));
display_Update();
wait();
}
void gbSmartGetGames()
{
static const byte menu_title[] = {0x47, 0x42, 0x31, 0x36, 0x4d};
// reset remap setting
gbSmartRemapStartBank(0x00, gbSmartRomSizeGB, gbSmartSramSizeGB);
uint16_t i;
uint8_t myByte, myLength;
// check if contain menu
hasMenu = true;
dataIn_GB();
for (i = 0; i < 5; i++)
{
if (readByte_GBS(0x0134 + i) != menu_title[i])
{
hasMenu = false;
break;
}
}
if (hasMenu)
{
for (i = gameMenuStartBank, numGames = 0; i < gbSmartBanks && numGames < GB_SMART_GAMES_PER_PAGE; )
{
myLength = 0;
// switch bank
dataOut();
writeByte_GB(0x2100, i);
dataIn_GB();
// read signature
for (uint8_t j = 0x00; j < 0x30; j++)
{
if (readByte_GBS(0x4104 + j) != signature[j])
{
i += 0x02;
goto gb_smart_get_game_loop_end;
}
}
for (uint8_t j = 0; j < 15; j++)
{
myByte = readByte_GBS(0x4134 + j);
if (((char(myByte) >= 0x30 && char(myByte) <= 0x39) ||
(char(myByte) >= 0x41 && char(myByte) <= 0x7a)))
gbSmartGames[numGames].title[myLength++] = char(myByte);
}
gbSmartGames[numGames].title[myLength] = 0x00;
gbSmartGames[numGames].start_bank = i;
gbSmartGames[numGames].rom_type = readByte_GBS(0x4147);
gbSmartGames[numGames].rom_size = readByte_GBS(0x4148);
gbSmartGames[numGames].sram_size = readByte_GBS(0x4149);
myByte = (2 << gbSmartGames[numGames].rom_size);
i += myByte;
numGames++;
gb_smart_get_game_loop_end:;
}
gameMenuStartBank = i;
}
else
{
dataIn_GB();
for (uint8_t j = 0; j < 15; j++)
{
myByte = readByte_GBS(0x0134 + j);
if (((char(myByte) >= 0x30 && char(myByte) <= 0x39) ||
(char(myByte) >= 0x41 && char(myByte) <= 0x7a)))
gbSmartGames[0].title[myLength++] = char(myByte);
}
gbSmartGames[0].title[myLength] = 0x00;
gbSmartGames[0].start_bank = 0x00;
gbSmartGames[0].rom_type = readByte_GBS(0x0147);
gbSmartGames[0].rom_size = readByte_GBS(0x0148);
gbSmartGames[0].sram_size = readByte_GBS(0x0149);
numGames = 1;
gameMenuStartBank = 0xfe;
}
}
void gbSmartReadFlash()
{
print_Msg(F("Saving as GB/GBS/"));
print_Msg(fileName);
println_Msg(F("..."));
display_Update();
if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_Error(F("Can't create file on SD"), true);
// reset flash to read array state
for (int i = 0x00; i < gbSmartBanks; i += gbSmartBanksPerFlashChip)
gbSmartResetFlash(i);
// remaps mmc to full access
gbSmartRemapStartBank(0x00, gbSmartRomSizeGB, gbSmartSramSizeGB);
// dump fixed bank 0x00
dataIn_GB();
for (uint16_t addr = 0x0000; addr <= 0x3fff; addr += 512)
{
for (uint16_t c = 0; c < 512; c++)
sdBuffer[c] = readByte_GBS(addr + c);
myFile.write(sdBuffer, 512);
}
// read rest banks
for (uint16_t bank = 0x01; bank < gbSmartBanks; bank++)
{
dataOut();
writeByte_GB(0x2100, bank);
dataIn_GB();
for (uint16_t addr = 0x4000; addr <= 0x7fff; addr += 512)
{
for (uint16_t c = 0; c < 512; c++)
sdBuffer[c] = readByte_GBS(addr + c);
myFile.write(sdBuffer, 512);
}
}
// back to initial state
writeByte_GB(0x2100, 0x01);
myFile.close();
println_Msg("");
println_Msg(F("Finished reading"));
display_Update();
}
void gbSmartWriteFlash()
{
for (int bank = 0x00; bank < gbSmartBanks; bank += gbSmartBanksPerFlashChip)
{
display_Clear();
print_Msg(F("Erasing..."));
display_Update();
gbSmartEraseFlash(bank);
gbSmartResetFlash(bank);
println_Msg(F("Done"));
print_Msg(F("Blankcheck..."));
display_Update();
if (!gbSmartBlankCheckingFlash(bank))
print_Error(F("Could not erase flash"), true);
println_Msg(F("Passed"));
display_Update();
// write full chip
gbSmartWriteFlash(bank);
// reset chip
gbSmartWriteFlashByte(0x0000, 0xff);
}
print_Msg(F("Verifying..."));
display_Update();
writeErrors = gbSmartVerifyFlash();
if (writeErrors == 0)
{
println_Msg(F("OK"));
display_Update();
}
else
{
print_Msg(F("Error: "));
print_Msg(writeErrors);
println_Msg(F(" bytes "));
print_Error(F("did not verify."), true);
}
}
void gbSmartWriteFlash(uint32_t start_bank)
{
if (!myFile.open(filePath, O_READ))
print_Error(F("Can't open file on SD"), true);
// switch to flash base bank
gbSmartRemapStartBank(start_bank, gbSmartFlashSizeGB, gbSmartSramSizeGB);
myFile.seekCur((start_bank << 14));
print_Msg(F("Writing Bank 0x"));
print_Msg(start_bank, HEX);
print_Msg(F("..."));
display_Update();
// handle bank 0x00 on 0x0000
gbSmartWriteFlashFromMyFile(0x0000);
// handle rest banks on 0x4000
for (uint8_t bank = 0x01; bank < gbSmartBanksPerFlashChip; bank++)
{
dataOut();
writeByte_GB(0x2100, bank);
gbSmartWriteFlashFromMyFile(0x4000);
}
myFile.close();
println_Msg("");
}
void gbSmartWriteFlashFromMyFile(uint32_t addr)
{
for (uint16_t i = 0; i < 16384; i += 256)
{
myFile.read(sdBuffer, 256);
// sequence load to page
dataOut();
gbSmartWriteFlashByte(addr, 0xe0);
gbSmartWriteFlashByte(addr, 0xff);
gbSmartWriteFlashByte(addr, 0x00); // BCH should be 0x00
// fill page buffer
for (int d = 0; d < 256; d++)
gbSmartWriteFlashByte(d, sdBuffer[d]);
// start flashing page
gbSmartWriteFlashByte(addr, 0x0c);
gbSmartWriteFlashByte(addr, 0xff);
gbSmartWriteFlashByte(addr + i, 0x00); // BCH should be 0x00
// waiting for finishing
dataIn_GB();
while ((readByte_GBS(addr + i) & 0x80) == 0x00);
}
// blink LED
blinkLED();
}
uint32_t gbSmartVerifyFlash()
{
uint32_t verified = 0;
if (!myFile.open(filePath, O_READ))
{
verified = 0xffffffff;
print_Error(F("Can't open file on SD"), false);
}
else
{
// remaps mmc to full access
gbSmartRemapStartBank(0x00, gbSmartRomSizeGB, gbSmartSramSizeGB);
// verify bank 0x00
dataIn_GB();
for (uint16_t addr = 0x0000; addr <= 0x3fff; addr += 512)
{
myFile.read(sdBuffer, 512);
for (uint16_t c = 0; c < 512; c++)
{
if (readByte_GBS(addr + c) != sdBuffer[c])
verified++;
}
}
// verify rest banks
for (uint16_t bank = 0x01; bank < gbSmartBanks; bank++)
{
dataOut();
writeByte_GB(0x2100, bank);
dataIn_GB();
for (uint16_t addr = 0x4000; addr <= 0x7fff; addr += 512)
{
myFile.read(sdBuffer, 512);
for (uint16_t c = 0; c < 512; c++)
{
if (readByte_GBS(addr + c) != sdBuffer[c])
verified++;
}
}
}
// back to initial state
writeByte_GB(0x2100, 0x01);
myFile.close();
}
return verified;
}
byte gbSmartBlankCheckingFlash(uint8_t flash_start_bank)
{
gbSmartRemapStartBank(flash_start_bank, gbSmartFlashSizeGB, gbSmartSramSizeGB);
// check first bank
dataIn_GB();
for (uint16_t addr = 0x0000; addr <= 0x3fff; addr++)
{
if (readByte_GBS(addr) != 0xff)
return 0;
}
// check rest banks
for (uint16_t bank = 0x01; bank < gbSmartBanksPerFlashChip; bank++)
{
dataOut();
writeByte_GB(0x2100, bank);
dataIn_GB();
for (uint16_t addr = 0x4000; addr <= 0x7fff; addr++)
{
if (readByte_GBS(addr) != 0xff)
return 0;
}
}
return 1;
}
void gbSmartResetFlash(uint8_t flash_start_bank)
{
gbSmartRemapStartBank(flash_start_bank, gbSmartFlashSizeGB, gbSmartSramSizeGB);
dataOut();
gbSmartWriteFlashByte(0x0, 0xff);
}
void gbSmartEraseFlash(uint8_t flash_start_bank)
{
gbSmartRemapStartBank(flash_start_bank, gbSmartFlashSizeGB, gbSmartSramSizeGB);
// handling first flash block
dataOut();
gbSmartWriteFlashByte(0x0000, 0x20);
gbSmartWriteFlashByte(0x0000, 0xd0);
dataIn_GB();
while ((readByte_GBS(0x0000) & 0x80) == 0x00);
// blink LED
blinkLED();
// rest of flash block
for (uint32_t ba = gbSmartBanksPerFlashBlock; ba < gbSmartBanksPerFlashChip; ba += gbSmartBanksPerFlashBlock)
{
dataOut();
writeByte_GB(0x2100, ba);
gbSmartWriteFlashByte(0x4000, 0x20);
gbSmartWriteFlashByte(0x4000, 0xd0);
dataIn_GB();
while ((readByte_GBS(0x4000) & 0x80) == 0x00);
// blink LED
blinkLED();
}
}
void gbSmartWriteFlashByte(uint32_t myAddress, uint8_t myData)
{
PORTF = myAddress & 0xff;
PORTK = (myAddress >> 8) & 0xff;
PORTC = myData;
// wait for 62.5 x 4 = 250ns
__asm__("nop\n\tnop\n\tnop\n\tnop\n\t");
// Pull FLASH_WE (PH4) low
PORTH &= ~(1 << 4);
// pull low for another 250ns
__asm__("nop\n\tnop\n\tnop\n\tnop\n\t");
// Pull FLASH_WE (PH4) high
PORTH |= (1 << 4);
// pull high for another 250ns
__asm__("nop\n\tnop\n\tnop\n\tnop\n\t");
}
// rom_start_bank = 0x00 means back to original state
void gbSmartRemapStartBank(uint8_t rom_start_bank, uint8_t rom_size, uint8_t sram_size)
{
rom_start_bank &= 0xfe;
dataOut();
// clear base bank setting
writeByte_GB(0x1000, 0xa5);
writeByte_GB(0x7000, 0x00);
writeByte_GB(0x1000, 0x98);
writeByte_GB(0x2000, rom_start_bank);
if (rom_start_bank > 1)
{
// start set new base bank
writeByte_GB(0x1000, 0xa5);
dataIn_GB();
rom_start_bank = gbSmartGetResizeParam(rom_size, sram_size);
dataOut();
writeByte_GB(0x7000, rom_start_bank);
writeByte_GB(0x1000, 0x98);
writeByte_GB(0x2100, 0x01);
}
dataIn_GB();
}
// Get magic number for 0x7000 register.
// Use for setting correct rom and sram size
// Code logic is take from SmartCard32M V1.3 menu code,
// see 0x2db2 to 0x2e51 (0xa0 bytes)
uint8_t gbSmartGetResizeParam(uint8_t rom_size, uint8_t sram_size)
{
if (rom_size < 0x0f)
{
rom_size &= 0x07;
rom_size ^= 0x07;
}
else
{
rom_size = 0x01;
}
if (sram_size > 0)
{
if (sram_size > 1)
{
sram_size--;
sram_size ^= 0x03;
sram_size <<= 4;
sram_size &= 0x30;
}
else
{
sram_size = 0x20; // 2KiB treat as 8KiB
}
}
else
{
sram_size = 0x30; // no sram
}
return (sram_size | rom_size);
}
#endif