replace cart select code with code used in NES, COLV, INTV

This commit is contained in:
smesgr9000 2024-04-24 20:07:44 +02:00
parent 3441cedfd4
commit 3ce23a57ad
2 changed files with 287 additions and 311 deletions

View File

@ -70,9 +70,7 @@ byte a7800[] = { 16, 32, 48, 64, 128, 144 };
byte a7800lo = 0; // Lowest Entry byte a7800lo = 0; // Lowest Entry
byte a7800hi = 5; // Highest Entry byte a7800hi = 5; // Highest Entry
byte a7800mapper = 0; byte a7800mapper = 0;
byte new7800mapper;
byte a7800size; byte a7800size;
byte new7800size;
// EEPROM MAPPING // EEPROM MAPPING
// 07 MAPPER // 07 MAPPER
@ -159,7 +157,6 @@ void a7800Menu() {
case 0: case 0:
// Select Cart // Select Cart
setCart_7800(); setCart_7800();
wait();
setup_7800(); setup_7800();
break; break;
@ -507,6 +504,7 @@ void println_Mapper7800(byte mapper) {
#endif #endif
void setROMSize_7800() { void setROMSize_7800() {
byte new7800size;
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD)) #if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display_Clear(); display_Clear();
if (a7800lo == a7800hi) if (a7800lo == a7800hi)
@ -691,6 +689,7 @@ void displayMapperSelect_7800(int index, boolean printInstructions) {
#endif #endif
void setMapper_7800() { void setMapper_7800() {
byte new7800mapper = 0;
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD)) #if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
uint8_t b = 0; uint8_t b = 0;
int i = 0; int i = 0;
@ -782,222 +781,6 @@ setmapper:
//****************************************** //******************************************
// CART SELECT CODE // CART SELECT CODE
//****************************************** //******************************************
FsFile a7800csvFile;
char a7800game[36]; // title
char a7800mm[3]; // mapper
char a7800rr[3]; // mapper
char a7800ll[4]; // linelength (previous line)
unsigned long a7800csvpos; // CSV File Position
char a7800cartCSV[] = "7800.txt"; // CSV List
char a7800csvEND[] = "EOF"; // CSV End Marker for scrolling
bool readLine_7800(FsFile& f, char* line, size_t maxLen) {
for (size_t n = 0; n < maxLen; n++) {
int c = f.read();
if (c < 0 && n == 0) return false; // EOF
if (c < 0 || c == '\n') {
line[n] = 0;
return true;
}
line[n] = c;
}
return false; // line too long
}
bool readVals_7800(char* a7800game, char* a7800mm, char* a7800rr, char* a7800ll) {
char line[44];
a7800csvpos = a7800csvFile.position();
if (!readLine_7800(a7800csvFile, line, sizeof(line))) {
return false; // EOF or too long
}
char* comma = strtok(line, ",");
int x = 0;
while (comma != NULL) {
if (x == 0)
strcpy(a7800game, comma);
else if (x == 1)
strcpy(a7800mm, comma);
else if (x == 2)
strcpy(a7800rr, comma);
else if (x == 3)
strcpy(a7800ll, comma);
comma = strtok(NULL, ",");
x += 1;
}
return true;
}
bool getCartListInfo_7800() {
bool buttonreleased = 0;
bool cartselected = 0;
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display_Clear();
println_Msg(F(" HOLD TO FAST CYCLE"));
display_Update();
#else
Serial.println(F("HOLD BUTTON TO FAST CYCLE"));
#endif
delay(2000);
#if defined(ENABLE_OLED)
buttonVal1 = (PIND & (1 << 7)); // PD7
#elif defined(ENABLE_LCD)
boolean buttonVal1 = (PING & (1 << 2)); //PG2
#endif
if (buttonVal1 == LOW) { // Button Held - Fast Cycle
while (1) { // Scroll Game List
while (readVals_7800(a7800game, a7800mm, a7800rr, a7800ll)) {
if (strcmp(a7800csvEND, a7800game) == 0) {
a7800csvFile.seek(0); // Restart
} else {
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display_Clear();
println_Msg(F("CART TITLE:"));
println_Msg(FS(FSTRING_EMPTY));
println_Msg(a7800game);
display_Update();
#else
Serial.print(F("CART TITLE:"));
Serial.println(a7800game);
#endif
#if defined(ENABLE_OLED)
buttonVal1 = (PIND & (1 << 7)); // PD7
#elif defined(ENABLE_LCD)
boolean buttonVal1 = (PING & (1 << 2)); //PG2
#endif
if (buttonVal1 == HIGH) { // Button Released
buttonreleased = 1;
break;
}
if (buttonreleased) {
buttonreleased = 0; // Reset Flag
break;
}
}
}
#if defined(ENABLE_OLED)
buttonVal1 = (PIND & (1 << 7)); // PD7
#elif defined(ENABLE_LCD)
boolean buttonVal1 = (PING & (1 << 2)); //PG2
#endif
if (buttonVal1 == HIGH) // Button Released
break;
}
}
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display.setCursor(0, 56);
println_Msg(F("FAST CYCLE OFF"));
display_Update();
#else
Serial.println(FS(FSTRING_EMPTY));
Serial.println(F("FAST CYCLE OFF"));
Serial.println(F("PRESS BUTTON TO STEP FORWARD"));
Serial.println(F("DOUBLE CLICK TO STEP BACK"));
Serial.println(F("HOLD TO SELECT"));
Serial.println(FS(FSTRING_EMPTY));
#endif
while (readVals_7800(a7800game, a7800mm, a7800rr, a7800ll)) {
if (strcmp(a7800csvEND, a7800game) == 0) {
a7800csvFile.seek(0); // Restart
} else {
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display_Clear();
println_Msg(F("CART TITLE:"));
println_Msg(FS(FSTRING_EMPTY));
println_Msg(a7800game);
display.setCursor(0, 48);
#if defined(ENABLE_OLED)
print_STR(press_to_change_STR, 1);
print_STR(right_to_select_STR, 1);
#elif defined(ENABLE_LCD)
print_STR(rotate_to_change_STR, 1);
print_STR(press_to_select_STR, 1);
#endif
display_Update();
#else
Serial.print(F("CART TITLE:"));
Serial.println(a7800game);
#endif
while (1) { // Single Step
uint8_t b = checkButton();
if (b == 1) { // Continue (press)
break;
}
if (b == 2) { // Reset to Start of List (doubleclick)
byte prevline = strtol(a7800ll, NULL, 10);
a7800csvpos -= prevline;
a7800csvFile.seek(a7800csvpos);
break;
}
if (b == 3) { // Long Press - Select Cart (hold)
new7800mapper = strtol(a7800mm, NULL, 10);
new7800size = strtol(a7800rr, NULL, 10);
EEPROM_writeAnything(7, new7800mapper);
EEPROM_writeAnything(8, new7800size);
cartselected = 1; // SELECTION MADE
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
println_Msg(F("SELECTION MADE"));
display_Update();
#else
Serial.println(F("SELECTION MADE"));
#endif
break;
}
}
if (cartselected) {
cartselected = 0; // Reset Flag
return true;
}
}
}
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
println_Msg(FS(FSTRING_EMPTY));
println_Msg(FS(FSTRING_END_OF_FILE));
display_Update();
#else
Serial.println(FS(FSTRING_END_OF_FILE));
#endif
return false;
}
void checkCSV_7800() {
if (getCartListInfo_7800()) {
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display_Clear();
println_Msg(FS(FSTRING_CART_SELECTED));
println_Msg(FS(FSTRING_EMPTY));
println_Msg(a7800game);
display_Update();
// Display Settings
display.setCursor(0, 56);
print_Msg(F("CODE: M"));
print_Msg(new7800mapper);
print_Msg(F("/R"));
println_Msg(new7800size);
display_Update();
#else
Serial.println(FS(FSTRING_EMPTY));
Serial.println(FS(FSTRING_CART_SELECTED));
Serial.println(a7800game);
// Display Settings
Serial.print(F("CODE: M"));
Serial.print(new7800mapper);
Serial.print(F("/R"));
Serial.println(new7800size);
Serial.println(FS(FSTRING_EMPTY));
#endif
} else {
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display.setCursor(0, 56);
println_Msg(FS(FSTRING_NO_SELECTION));
display_Update();
#else
Serial.println(FS(FSTRING_NO_SELECTION));
#endif
}
}
void checkSize_7800() { void checkSize_7800() {
EEPROM_readAnything(7, a7800mapper); EEPROM_readAnything(7, a7800mapper);
for (int i = 0; i < a7800mapcount; i++) { for (int i = 0; i < a7800mapcount; i++) {
@ -1011,29 +794,83 @@ void checkSize_7800() {
} }
void setCart_7800() { void setCart_7800() {
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD)) //go to root
display_Clear();
println_Msg(a7800cartCSV);
display_Update();
#endif
sd.chdir(); sd.chdir();
sprintf(folder, "7800/CSV");
sd.chdir(folder); // Switch Folder char gamename[100];
a7800csvFile = sd.open(a7800cartCSV, O_READ); byte gameMapper;
if (!a7800csvFile) { byte gameSize;
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display_Clear(); // Select starting letter
println_Msg(F("CSV FILE NOT FOUND!")); byte myLetter = starting_letter();
display_Update();
#else // Open database
Serial.println(F("CSV FILE NOT FOUND!")); if (myFile.open("7800.txt", O_READ)) {
seek_first_letter_in_database(myFile, myLetter);
// Display database
while (myFile.available()) {
display_Clear();
get_line(gamename, &myFile, sizeof(gamename));
// Read mapper
gameMapper = myFile.read() - 48;
// Skip over semicolon
myFile.seekCur(1);
// Read rom size
gameSize = myFile.read() - 48;
// Skip rest of line
myFile.seekCur(2);
skip_line(&myFile);
println_Msg(F("Select your cartridge"));
println_Msg(FS(FSTRING_EMPTY));
println_Msg(gamename);
#if defined(ENABLE_OLED)
print_STR(press_to_change_STR, 1);
print_STR(right_to_select_STR, 1);
#elif defined(ENABLE_LCD)
print_STR(rotate_to_change_STR, 1);
print_STR(press_to_select_STR, 1);
#elif defined(SERIAL_MONITOR)
println_Msg(F("U/D to Change"));
println_Msg(F("Space to Select"));
#endif #endif
while (1) { display_Update();
if (checkButton() != 0)
setup_7800(); uint8_t b = 0;
while (1) {
// Check button input
b = checkButton();
// Next
if (b == 1) {
break;
}
// Previous
else if (b == 2) {
rewind_line(myFile, 6);
break;
}
// Selection
else if (b == 3) {
EEPROM_writeAnything(7, gameMapper);
EEPROM_writeAnything(8, gameSize);
myFile.close();
break;
}
}
} }
} else {
print_FatalError(F("Database file not found"));
} }
checkCSV_7800();
a7800csvFile.close();
} }
#endif #endif

View File

@ -1,71 +1,210 @@
32 in 1,0,3,0 32 in 1
Ace of Aces,1,4,15 0,3
Alien Brigade,2,5,20
Asteroids,0,0,22 Ace of Aces
Atari 7800 Development Card,0,0,18 1,4
Ballblazer,0,1,36
Barnyard Blaster,1,4,19 Alien Brigade
Baseball,0,1,25 2,5
Basketbrawl,1,4,17
Centipede,0,0,20 Asteroids
Choplifter! (Europe),0,2,18 0,0
Choplifter! (USA),0,1,29
Commando,1,4,26 Atari 7800 Development Card
Crack'ed,1,4,17 0,0
Crossbow,2,5,17
Dark Chambers,1,4,17 Ballblazer
Desert Falcon,0,2,22 0,1
Diagnostic Test Cartridge,0,1,22
Dig Dug (Europe),0,1,34 Barnyard Blaster
Dig Dug (USA),0,0,25 1,4
Donkey Kong,0,2,22
Donkey Kong Junior,0,2,20 Baseball
Double Dragon,4,4,27 0,1
F-18 Hornet,3,3,22
Fatal Run,1,4,20 Basketbrawl
Fight Night,1,4,18 1,4
Food Fight (Europe),0,2,20
Food Fight (USA),0,1,28 Centipede
Galaga (Europe),0,2,25 0,0
Galaga (USA),0,1,24
Hat Trick,0,2,21 Choplifter! (Europe)
Ikari Warriors,1,4,18 0,2
Impossible Mission,1,4,23
Jinks,1,4,27 Choplifter! (USA)
Joust (Europe),0,2,14 0,1
Joust (USA),0,1,23
Karateka (Europe),6,3,20 Commando
Karateka (USA),0,2,26 1,4
Kung-Fu Master,0,1,23
Mario Bros.,0,2,23 Crack'ed
Mat Mania Challenge,1,4,20 1,4
Mean 18 Ultimate Golf,1,4,28
Meltdown,1,4,30 Crossbow
Midnight Mutants,1,4,17 2,5
Motor Psycho,1,4,25
Ms. Pac-Man (Europe),0,1,21 Dark Chambers
Ms. Pac-Man (USA),0,0,29 1,4
Ninja Golf,1,4,26
One-on-One Basketball,0,2,19 Desert Falcon
Pete Rose Baseball,0,1,30 0,2
Planet Smashers,1,4,27
Pole Position II,0,1,24 Diagnostic Test Cartridge
Rampage,4,4,25 0,1
RealSports Baseball,5,3,16
Robotron 2084,0,1,28 Dig Dug (Europe)
Scrapyard Dog,1,4,22 0,1
Sentinel,1,4,22
Summer Games,1,4,17 Dig Dug (USA)
Super Huey UH-IX,0,2,21 0,0
Super Skateboardin',0,1,25
Tank Command,5,3,28 Donkey Kong
Title Match Pro Wrestling,0,1,21 0,2
Tomcat,0,1,34
Touchdown Football,1,4,15 Donkey Kong Junior
Tower Toppler,5,3,27 0,2
Water Ski,5,3,22
Winter Games,1,4,18 Double Dragon
Xenophobe,1,4,21 4,4
Xevious (Europe),0,2,18
Xevious (USA),0,1,25 F-18 Hornet
EOF,0,0,0 3,3
Fatal Run
1,4
Fight Night
1,4
Food Fight (Europe)
0,2
Food Fight (USA)
0,1
Galaga (Europe)
0,2
Galaga (USA)
0,1
Hat Trick
0,2
Ikari Warriors
1,4
Impossible Mission
1,4
Jinks
1,4
Joust (Europe)
0,2
Joust (USA)
0,1
Karateka (Europe)
6,3
Karateka (USA)
0,2
Kung-Fu Master
0,1
Mario Bros.
0,2
Mat Mania Challenge
1,4
Mean 18 Ultimate Golf
1,4
Meltdown
1,4
Midnight Mutants
1,4
Motor Psycho
1,4
Ms. Pac-Man (Europe)
0,1
Ms. Pac-Man (USA)
0,0
Ninja Golf
1,4
One-on-One Basketball
0,2
Pete Rose Baseball
0,1
Planet Smashers
1,4
Pole Position II
0,1
Rampage
4,4
RealSports Baseball
5,3
Robotron 2084
0,1
Scrapyard Dog
1,4
Sentinel
1,4
Summer Games
1,4
Super Huey UH-IX
0,2
Super Skateboardin'
0,1
Tank Command
5,3
Title Match Pro Wrestling
0,1
Tomcat
0,1
Touchdown Football
1,4
Tower Toppler
5,3
Water Ski
5,3
Winter Games
1,4
Xenophobe
1,4
Xevious (Europe)
0,2
Xevious (USA)
0,1