mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-13 00:15:05 +01:00
Cleanup voltage requests
The `setVoltage()` function should be called even when `ENABLE_VSELECT` is disabled because `ENABLE_3V3FIX` also uses it. There is no resource cost to do this as when both options are disabled the compiler will optimize this function out. This just "future proofs" the code so if that function ever does more it doesn't need updated everywhere. This applies to `setup_FlashVoltage()` as well. The changes to OSCR.cpp are just for code formatting and additional comments to clarify this.
This commit is contained in:
parent
9fb7af3f5b
commit
2cf7f5dbe7
@ -56,10 +56,8 @@ static const char arcMenuItem4[] PROGMEM = "Reset";
|
||||
static const char* const menuOptionsARC[] PROGMEM = { arcMenuItem1, arcMenuItem2, arcMenuItem3, arcMenuItem4 };
|
||||
|
||||
void setup_ARC() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
// Arcadia 2001 uses A0-A13 [A14-A23 UNUSED]
|
||||
|
@ -63,10 +63,8 @@ static const char atariMenuItem4[] PROGMEM = "Reset";
|
||||
static const char* const menuOptionsATARI[] PROGMEM = { atariMenuItem1, atariMenuItem2, atariMenuItem3, atariMenuItem4 };
|
||||
|
||||
void setup_ATARI() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
// Atari 2600 uses A0-A12 [A13-A23 UNUSED]
|
||||
|
@ -55,10 +55,8 @@ static const char colMenuItem3[] PROGMEM = "Set Size";
|
||||
static const char* const menuOptionsCOL[] PROGMEM = { colMenuItem1, colMenuItem2, colMenuItem3, string_reset2 };
|
||||
|
||||
void setup_COL() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
// Colecovision uses A0-A14 [A15-A23 UNUSED]
|
||||
|
@ -87,10 +87,8 @@ static const char fairchildMenuItem5[] PROGMEM = "Reset";
|
||||
static const char* const menuOptionsFAIRCHILD[] PROGMEM = { fairchildMenuItem1, fairchildMenuItem2, fairchildMenuItem3, fairchildMenuItem4, fairchildMenuItem5 };
|
||||
|
||||
void setup_FAIRCHILD() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
// Channel F uses A0-A4 [A5-A23 UNUSED]
|
||||
|
@ -680,7 +680,7 @@ void id_Flash16() {
|
||||
/******************************************
|
||||
Setup
|
||||
*****************************************/
|
||||
#ifdef ENABLE_VSELECT
|
||||
#if defined(ENABLE_VSELECT) || defined(ENABLE_3V3FIX)
|
||||
static const char flashvoltItem1[] PROGMEM = "3.3V";
|
||||
static const char flashvoltItem2[] PROGMEM = "5V";
|
||||
//static const char flashvoltItem3[] PROGMEM = "Reset"; (stored in common strings array)
|
||||
@ -696,12 +696,12 @@ void setup_FlashVoltage() {
|
||||
// wait for user choice to come back from the question box menu
|
||||
switch (flashvolt) {
|
||||
case 0:
|
||||
// Set Automatic Voltage Selection to 3V
|
||||
// Request 3.3V
|
||||
setVoltage(VOLTS_SET_3V3);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
break;
|
||||
|
||||
@ -710,6 +710,9 @@ void setup_FlashVoltage() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// The compiler will optimize this out when this condition is met.
|
||||
void setup_FlashVoltage() {}
|
||||
#endif
|
||||
|
||||
void setup_Flash8() {
|
||||
|
@ -370,10 +370,8 @@ void gbMenu() {
|
||||
Setup
|
||||
*****************************************/
|
||||
void setup_GB() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
//A0-A7
|
||||
|
@ -246,10 +246,8 @@ void gbaMenu() {
|
||||
Setup
|
||||
*****************************************/
|
||||
void setup_GBA() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 3V
|
||||
// Request 3.3V
|
||||
setVoltage(VOLTS_SET_3V3);
|
||||
#endif
|
||||
|
||||
setROM_GBA();
|
||||
|
||||
|
@ -184,10 +184,8 @@ void gbmMenu() {
|
||||
Setup
|
||||
*****************************************/
|
||||
void setup_GBM() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set RST(PH0) to Input
|
||||
DDRH &= ~(1 << 0);
|
||||
|
@ -109,10 +109,8 @@ byte readByte_GBS(word myAddress) {
|
||||
}
|
||||
|
||||
void setup_GBSmart() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// take from setup_GB
|
||||
// Set RST(PH0) to Input
|
||||
|
@ -99,10 +99,8 @@ static const char intvMenuItem3[] PROGMEM = "Set Mapper + Size";
|
||||
static const char* const menuOptionsINTV[] PROGMEM = { intvMenuItem1, intvMenuItem2, intvMenuItem3, string_reset2 };
|
||||
|
||||
void setup_INTV() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output (UNUSED)
|
||||
//A0-A7
|
||||
|
@ -463,10 +463,8 @@ void segaCDMenu() {
|
||||
Setup
|
||||
*****************************************/
|
||||
void setup_MD() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
#ifdef use_md_conf
|
||||
mdLoadConf();
|
||||
|
@ -181,10 +181,8 @@ void msxMenu() {
|
||||
// SETUP
|
||||
//******************************************
|
||||
void setup_MSX() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
// MSX uses A0-A15
|
||||
|
@ -399,10 +399,8 @@ void n64CartMenu() {
|
||||
Setup
|
||||
*****************************************/
|
||||
void setup_N64_Controller() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 3V
|
||||
// Request 3.3V
|
||||
setVoltage(VOLTS_SET_3V3);
|
||||
#endif
|
||||
|
||||
// Output a low signal
|
||||
PORTH &= ~(1 << 4);
|
||||
@ -411,10 +409,8 @@ void setup_N64_Controller() {
|
||||
}
|
||||
|
||||
void setup_N64_Cart() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 3V
|
||||
// Request 3.3V
|
||||
setVoltage(VOLTS_SET_3V3);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output and set them low
|
||||
//A0-A7
|
||||
|
@ -418,10 +418,8 @@ void nesChipMenu() {
|
||||
Setup
|
||||
*****************************************/
|
||||
void setup_NES() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// CPU R/W, IRQ, PPU /RD, PPU /A13, CIRAM /CE, PPU /WR, /ROMSEL, PHI2
|
||||
DDRF = 0b10110111;
|
||||
|
@ -21,10 +21,8 @@ uint8_t manufacturerID;
|
||||
uint8_t deviceID;
|
||||
|
||||
void setup_NGP() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 3V
|
||||
// Request 3.3V
|
||||
setVoltage(VOLTS_SET_3V3);
|
||||
#endif
|
||||
|
||||
// A0 - A7
|
||||
DDRF = 0xff;
|
||||
|
@ -69,10 +69,8 @@ static const char ody2MenuItem4[] PROGMEM = "Reset";
|
||||
static const char* const menuOptionsODY2[] PROGMEM = { ody2MenuItem1, ody2MenuItem2, ody2MenuItem3, ody2MenuItem4 };
|
||||
|
||||
void setup_ODY2() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
// Odyssey 2 uses A0-A13 [A14-A23 UNUSED]
|
||||
|
@ -186,27 +186,27 @@ VOLTS setVoltage(VOLTS volts) {
|
||||
) return VOLTS_SUCCESS; // Just return if already as requested
|
||||
|
||||
// Adjust voltage high if VSELECT is available
|
||||
#if defined(ENABLE_VSELECT)
|
||||
PORTD &= ~(1 << 7); /*[1]*/
|
||||
voltage = VOLTS_SET_5V;
|
||||
#endif
|
||||
#if defined(ENABLE_VSELECT)
|
||||
PORTD &= ~(1 << 7); /*[1]*/
|
||||
voltage = VOLTS_SET_5V;
|
||||
#endif
|
||||
|
||||
// Adjust clock speed when 3V3FIX is enabled
|
||||
#if defined(ENABLE_3V3FIX)
|
||||
// Stop serial if running
|
||||
#if !defined(enable_serial) && defined(ENABLE_UPDATER)
|
||||
ClockedSerial.end();
|
||||
#endif
|
||||
// Set clock speed
|
||||
clock = CS_16MHZ;
|
||||
setClockScale(volts); /*[2]*/
|
||||
// Restart serial
|
||||
#if !defined(enable_serial) && defined(ENABLE_UPDATER)
|
||||
ClockedSerial.begin(UPD_BAUD);
|
||||
#endif
|
||||
#else
|
||||
clock = CS_16MHZ;
|
||||
#endif
|
||||
#if defined(ENABLE_3V3FIX)
|
||||
// Stop serial if running
|
||||
#if !defined(enable_serial) && defined(ENABLE_UPDATER)
|
||||
ClockedSerial.end();
|
||||
#endif
|
||||
// Set clock speed
|
||||
clock = CS_16MHZ;
|
||||
setClockScale(volts); /*[2]*/
|
||||
// Restart serial
|
||||
#if !defined(enable_serial) && defined(ENABLE_UPDATER)
|
||||
ClockedSerial.begin(UPD_BAUD);
|
||||
#endif
|
||||
#else
|
||||
clock = CS_16MHZ;
|
||||
#endif
|
||||
|
||||
// Done
|
||||
return VOLTS_SUCCESS;
|
||||
@ -226,22 +226,23 @@ VOLTS setVoltage(VOLTS volts) {
|
||||
) return VOLTS_SUCCESS; // Just return if already as requested
|
||||
|
||||
// Adjust clock speed when 3V3FIX is enabled
|
||||
#if defined(ENABLE_3V3FIX)
|
||||
#if !defined(enable_serial) && defined(ENABLE_UPDATER)
|
||||
ClockedSerial.end();
|
||||
#endif
|
||||
clock = CS_8MHZ;
|
||||
setClockScale(volts); /*[2]*/
|
||||
#if !defined(enable_serial) && defined(ENABLE_UPDATER)
|
||||
ClockedSerial.begin(UPD_BAUD);
|
||||
#endif
|
||||
#endif
|
||||
#if defined(ENABLE_3V3FIX)
|
||||
#if !defined(enable_serial) && defined(ENABLE_UPDATER)
|
||||
ClockedSerial.end();
|
||||
#endif
|
||||
// Set clock speed
|
||||
clock = CS_8MHZ;
|
||||
setClockScale(volts); /*[2]*/
|
||||
#if !defined(enable_serial) && defined(ENABLE_UPDATER)
|
||||
ClockedSerial.begin(UPD_BAUD);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Adjust voltage high if VSELECT is available
|
||||
#if defined(ENABLE_VSELECT)
|
||||
PORTD |= (1 << 7); /*[1]*/
|
||||
voltage = VOLTS_SET_3V3;
|
||||
#endif
|
||||
#if defined(ENABLE_VSELECT)
|
||||
PORTD |= (1 << 7); /*[1]*/
|
||||
voltage = VOLTS_SET_3V3;
|
||||
#endif
|
||||
|
||||
// Done
|
||||
return VOLTS_SUCCESS;
|
||||
@ -252,6 +253,9 @@ VOLTS setVoltage(VOLTS volts) {
|
||||
}
|
||||
}
|
||||
#else
|
||||
// The compiler will optimize this out when this condition is met.
|
||||
// Yes, even though it has a return value it will only be compiled
|
||||
// if something reads that value. Currently nothing does.
|
||||
VOLTS setVoltage(VOLTS volts __attribute__((unused))) {
|
||||
return VOLTS_NOTENABLED;
|
||||
}
|
||||
|
@ -170,10 +170,8 @@ void pin_init_PCE(void) {
|
||||
}
|
||||
|
||||
void setup_cart_PCE(void) {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set cicrstPin(PG1) to Output
|
||||
DDRG |= (1 << 1);
|
||||
|
@ -101,10 +101,8 @@ byte bank1;
|
||||
//******************************************
|
||||
|
||||
void setup_PCW() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
//A8-A15
|
||||
|
@ -105,10 +105,8 @@ void pokeMenu() {
|
||||
// SETUP
|
||||
//******************************************
|
||||
void setup_POKE() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 3V
|
||||
// Request 3.3V
|
||||
setVoltage(VOLTS_SET_3V3);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
// Pokemon Mini uses A0-A9 (DUAL A10-A19) + A20 (CONNECT TO SNES A10) [A11-A23 UNUSED]
|
||||
|
@ -524,10 +524,8 @@ void getGames(char gameCode[8][20], boolean* hasMenu, byte* numGames) {
|
||||
Setup
|
||||
*****************************************/
|
||||
void setup_SFM() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set cicrstPin(PG1) to Output
|
||||
DDRG |= (1 << 1);
|
||||
|
@ -155,10 +155,8 @@ void smsOperations() {
|
||||
// Setup I/O
|
||||
//********************************
|
||||
void setup_SMS() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
//A0-A7
|
||||
|
@ -172,9 +172,7 @@ void snsMenu() {
|
||||
|
||||
#ifdef enable_FLASH
|
||||
case 3:
|
||||
#ifdef ENABLE_VSELECT
|
||||
setup_FlashVoltage();
|
||||
#endif
|
||||
reproMenu();
|
||||
break;
|
||||
#endif
|
||||
@ -388,10 +386,8 @@ void stopSnesClocks_resetCic_resetCart() {
|
||||
Setup
|
||||
*****************************************/
|
||||
void setup_Snes() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set cicrstPin(PG1) to Output
|
||||
DDRG |= (1 << 1);
|
||||
|
@ -17,10 +17,8 @@ static const char acanMenuItem6[] PROGMEM = "Flash repro";
|
||||
static const char *const menuOptionsAcan[] PROGMEM = { acanMenuItem1, acanMenuItem2, acanMenuItem3, acanMenuItem4, acanMenuItem5, string_reset2, acanMenuItem6 };
|
||||
|
||||
void setup_SuprAcan() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// addr as output
|
||||
DDRF = 0xff; // A0 - A7
|
||||
|
@ -101,10 +101,8 @@ void svMenu() {
|
||||
Setup
|
||||
*****************************************/
|
||||
void setup_SV() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set cicrstPin(PG1) to Output
|
||||
DDRG |= (1 << 1);
|
||||
|
@ -56,10 +56,8 @@
|
||||
//******************************************
|
||||
|
||||
void setup_VBOY() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 5V
|
||||
// Request 5V
|
||||
setVoltage(VOLTS_SET_5V);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
//A0-A7
|
||||
|
@ -46,10 +46,8 @@ static uint8_t wsEepromShiftReg[2];
|
||||
static boolean wsWitch = false;
|
||||
|
||||
void setup_WS() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 3V
|
||||
// Request 3.3V
|
||||
setVoltage(VOLTS_SET_3V3);
|
||||
#endif
|
||||
|
||||
// A-1 - A6
|
||||
DDRF = 0xff;
|
||||
|
@ -53,10 +53,8 @@ byte newwsvsize;
|
||||
//******************************************
|
||||
|
||||
void setup_WSV() {
|
||||
#ifdef ENABLE_VSELECT
|
||||
// Set Automatic Voltage Selection to 3V
|
||||
// Request 3.3V
|
||||
setVoltage(VOLTS_SET_3V3);
|
||||
#endif
|
||||
|
||||
// Set Address Pins to Output
|
||||
//A0-A7
|
||||
|
Loading…
Reference in New Issue
Block a user