Skip to content

Commit

Permalink
Merge pull request #933 from smesgr9000/master
Browse files Browse the repository at this point in the history
remove some duplicate printing code and declare more global text strings
  • Loading branch information
sanni authored Apr 22, 2024
2 parents 5d0ae98 + e7e0da8 commit 50a147b
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 316 deletions.
99 changes: 50 additions & 49 deletions Cart_Reader/2600.ino
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ byte a2600[] = { 2, 4, 8, 12, 16, 32, 64 };
byte a2600mapper = 0;
byte new2600mapper;
byte a2600size;
byte e7size;

// EEPROM MAPPING
// 07 MAPPER
Expand Down Expand Up @@ -273,6 +272,7 @@ boolean checkE7(int bank) {
}

void readROM_2600() {
byte e7size;
strcpy(fileName, romName);
strcat(fileName, ".a26");

Expand Down Expand Up @@ -576,8 +576,8 @@ void readROM_2600() {
// ROM SIZE
//******************************************

void println_Mapper2600(byte mapper) {
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
void println_Mapper(byte mapper) {
if (mapper == 0x04)
println_Msg(F("F4SC"));
else if (mapper == 0x06)
Expand All @@ -598,8 +598,29 @@ void println_Mapper(byte mapper) {
println_Msg(F("TP"));
else
println_Msg(mapper, HEX);
}
#else
if (mapper == 0x04)
Serial.println(F("F4SC"));
else if (mapper == 0x06)
Serial.println(F("F6SC"));
else if (mapper == 0x08)
Serial.println(F("F8SC"));
else if (mapper == 0x20)
Serial.println(F("2K"));
else if (mapper == 0x40)
Serial.println(F("4K"));
else if (mapper == 0x0A)
Serial.println(F("UA"));
else if (mapper == 0xC0)
Serial.println(F("CV"));
else if (mapper == 0xD0)
Serial.println(F("DPC"));
else if (mapper == 0xF9)
Serial.println(F("TP"));
else
Serial.println(mapper, HEX);
#endif
}

void checkStatus_2600() {
EEPROM_readAnything(7, a2600mapper);
Expand All @@ -612,10 +633,10 @@ void checkStatus_2600() {
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display_Clear();
println_Msg(F("ATARI 2600 READER"));
println_Msg(F("CURRENT SETTINGS"));
println_Msg(FS(FSTRING_CURRENT_SETTINGS));
println_Msg(FS(FSTRING_EMPTY));
print_Msg(F("MAPPER: "));
println_Mapper(a2600mapper);
println_Mapper2600(a2600mapper);
print_Msg(F("ROM SIZE: "));
if (a2600mapper == 0xD0)
print_Msg(F("10"));
Expand All @@ -626,26 +647,7 @@ void checkStatus_2600() {
wait();
#else
Serial.print(F("MAPPER: "));
if (mapper == 0x04)
Serial.println(F("F4SC"));
else if (mapper == 0x06)
Serial.println(F("F6SC"));
else if (mapper == 0x08)
Serial.println(F("F8SC"));
else if (a2600mapper == 0x20)
Serial.println(F("2K"));
else if (a2600mapper == 0x40)
Serial.println(F("4K"));
else if (a2600mapper == 0x0A)
Serial.println(F("UA"));
else if (a2600mapper == 0xC0)
Serial.println(F("CV"));
else if (a2600mapper == 0xD0)
Serial.println(F("DPC"));
else if (a2600mapper == 0xF9)
Serial.println(F("TP"));
else
Serial.println(a2600mapper, HEX);
println_Mapper2600(a2600mapper);

Serial.print(F("ROM SIZE: "));
if (a2600mapper == 0xD0)
Expand All @@ -662,20 +664,23 @@ void checkStatus_2600() {
//******************************************

#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
void displayMapperSelect_2600(int index) {
void displayMapperSelect_2600(uint8_t index, boolean printInstructions) {
display_Clear();
print_Msg(F("Mapper: "));
a2600index = index * 2;
a2600mapselect = pgm_read_byte(a2600mapsize + a2600index);
println_Mapper(a2600mapselect);
println_Msg(FS(FSTRING_EMPTY));
println_Mapper2600(a2600mapselect);

if(printInstructions) {
println_Msg(FS(FSTRING_EMPTY));
#if defined(ENABLE_OLED)
print_STR(press_to_change_STR, 1);
print_STR(right_to_select_STR, 1);
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);
print_STR(rotate_to_change_STR, 1);
print_STR(press_to_select_STR, 1);
#endif
}
display_Update();
}
#endif
Expand Down Expand Up @@ -706,21 +711,17 @@ void setMapper_2600() {
i--;
break;
}
display_Clear();
print_Msg(F("Mapper: "));
a2600index = i * 2;
a2600mapselect = pgm_read_byte(a2600mapsize + a2600index);
println_Mapper(a2600mapselect);
display_Update();
displayMapperSelect_2600(i, false);
if (i == (a2600mapcount - 1))
i = 0;
else
i++;
delay(250);
}
}
b = 0;

displayMapperSelect_2600(i);
displayMapperSelect_2600(i, true);

while (1) {
b = checkButton();
Expand All @@ -731,7 +732,7 @@ void setMapper_2600() {
i--;

// Only update display after input because of slow LCD library
displayMapperSelect_2600(i);
displayMapperSelect_2600(i, true);
}
if (b == 1) { // Next Mapper (press)
if (i == (a2600mapcount - 1))
Expand All @@ -740,7 +741,7 @@ void setMapper_2600() {
i++;

// Only update display after input because of slow LCD library
displayMapperSelect_2600(i);
displayMapperSelect_2600(i, true);
}
if (b == 3) { // Long Press - Execute (hold)
new2600mapper = a2600mapselect;
Expand All @@ -749,7 +750,7 @@ void setMapper_2600() {
}
display.setCursor(0, 56);
print_Msg(F("MAPPER "));
println_Mapper(new2600mapper);
println_Mapper2600(new2600mapper);
println_Msg(F(" SELECTED"));
display_Update();
delay(1000);
Expand All @@ -774,7 +775,7 @@ setmapper:
Serial.println(F("14 = FA [CBS RAM Plus]"));
Serial.println(F("15 = FE [Activision]"));
Serial.println(F("16 = TP [Time Pilot 8K]"));
Serial.println(F("16 = UA [UA Ltd]"));
Serial.println(F("17 = UA [UA Ltd]"));
Serial.print(F("Enter Mapper [0-17]: "));
while (Serial.available() == 0) {}
newmap = Serial.readStringUntil('\n');
Expand Down Expand Up @@ -957,10 +958,10 @@ bool getCartListInfo_2600() {
}
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
println_Msg(FS(FSTRING_EMPTY));
println_Msg(F("END OF FILE"));
println_Msg(FS(FSTRING_END_OF_FILE));
display_Update();
#else
Serial.println(F("END OF FILE"));
Serial.println(FS(FSTRING_END_OF_FILE));
#endif

return false;
Expand All @@ -970,7 +971,7 @@ void checkCSV_2600() {
if (getCartListInfo_2600()) {
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display_Clear();
println_Msg(F("CART SELECTED"));
println_Msg(FS(FSTRING_CART_SELECTED));
println_Msg(FS(FSTRING_EMPTY));
println_Msg(a2600game);
display_Update();
Expand All @@ -981,7 +982,7 @@ void checkCSV_2600() {
display_Update();
#else
Serial.println(FS(FSTRING_EMPTY));
Serial.println(F("CART SELECTED"));
Serial.println(FS(FSTRING_CART_SELECTED));
Serial.println(a2600game);
// Display Settings
Serial.print(F("CODE: "));
Expand All @@ -991,10 +992,10 @@ void checkCSV_2600() {
} else {
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display.setCursor(0, 56);
println_Msg(F("NO SELECTION"));
println_Msg(FS(FSTRING_NO_SELECTION));
display_Update();
#else
Serial.println(F("NO SELECTION"));
Serial.println(FS(FSTRING_NO_SELECTION));
#endif
}
}
Expand Down
Loading

0 comments on commit 50a147b

Please sign in to comment.