Skip to content

Commit

Permalink
Fix disabling ports
Browse files Browse the repository at this point in the history
  • Loading branch information
polpo committed Jul 30, 2024
1 parent e1110de commit 489370b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
12 changes: 8 additions & 4 deletions pgusinit/pgusinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,14 @@ int main(int argc, char* argv[]) {
printf("Running in Sound Blaster 2.0 mode on port %x ", tmp_uint16);
outp(CONTROL_PORT, MODE_OPLPORT); // Select port register
tmp_uint16 = inpw(DATA_PORT_LOW); // Get port
printf("(AdLib port %x", tmp_uint16);
outp(CONTROL_PORT, MODE_OPLWAIT); // Select Adlib wait register
tmp_uint8 = inp(DATA_PORT_HIGH);
printf("%s)\n", tmp_uint8 ? ", wait on" : "");
if (tmp_uint16) {
printf("(AdLib port %x", tmp_uint16);
outp(CONTROL_PORT, MODE_OPLWAIT); // Select Adlib wait register
tmp_uint8 = inp(DATA_PORT_HIGH);
printf("%s)\n", tmp_uint8 ? ", wait on" : "");
} else {
printf("(AdLib port disabled)\n");
}
break;
default:
printf("Running in unknown mode (maybe upgrade pgusinit?)\n");
Expand Down
46 changes: 23 additions & 23 deletions sw/picogus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,17 @@ __force_inline uint8_t read_picogus_high(void) {
case MODE_BOOTMODE: // Mode (GUS, OPL, MPU, etc...)
return settings.startupMode;
case MODE_GUSPORT: // GUS Base port
return settings.GUS.basePort >> 8;
return settings.GUS.basePort == 0xFFFF ? 0 : (settings.GUS.basePort >> 8);
case MODE_OPLPORT: // Adlib Base port
return settings.SB.oplBasePort >> 8;
return settings.SB.oplBasePort == 0xFFFF ? 0 : (settings.SB.oplBasePort >> 8);
case MODE_SBPORT: // SB Base port
return settings.SB.basePort >> 8;
return settings.SB.basePort == 0xFFFF ? 0 : (settings.SB.basePort >> 8);
case MODE_MPUPORT: // MPU Base port
return settings.MPU.basePort >> 8;
return settings.MPU.basePort == 0xFFFF ? 0 : (settings.MPU.basePort >> 8);
case MODE_TANDYPORT: // Tandy Base port
return settings.Tandy.basePort >> 8;
return settings.Tandy.basePort == 0xFFFF ? 0 : (settings.Tandy.basePort >> 8);
case MODE_CMSPORT: // CMS Base port
return settings.CMS.basePort >> 8;
return settings.CMS.basePort == 0xFFFF ? 0 : (settings.CMS.basePort >> 8);
case MODE_JOYEN: // enable joystick
return settings.Joy.basePort == 0x201u;
case MODE_GUSBUF: // GUS audio buffer size
Expand Down Expand Up @@ -392,6 +392,23 @@ __force_inline uint8_t read_picogus_high(void) {


void processSettings(void) {
#if defined(SOUND_GUS)
settings.startupMode = GUS_MODE;
#elif defined(SOUND_TANDY)
settings.startupMode = TANDY_MODE;
#elif defined(SOUND_CMS)
settings.startupMode = CMS_MODE;
#elif defined(SOUND_SB)
settings.startupMode = SB_MODE;
#elif defined(SOUND_OPL)
settings.startupMode = ADLIB_MODE;
#elif defined(MPU_ONLY)
settings.startupMode = MPU_MODE;
#elif defined(USB_ONLY)
settings.startupMode = USB_MODE;
#else
settings.startupMode = INVALID_MODE;
#endif
#ifdef SOUND_SB
sb_port_test = settings.SB.basePort >> 4;
#endif
Expand Down Expand Up @@ -774,23 +791,6 @@ int main()

// Load settings from flash
loadSettings(&settings);
#if defined(SOUND_GUS)
settings.startupMode = GUS_MODE;
#elif defined(SOUND_TANDY)
settings.startupMode = TANDY_MODE;
#elif defined(SOUND_CMS)
settings.startupMode = CMS_MODE;
#elif defined(SOUND_SB)
settings.startupMode = SB_MODE;
#elif defined(SOUND_OPL)
settings.startupMode = ADLIB_MODE;
#elif defined(MPU_ONLY)
settings.startupMode = MPU_MODE;
#elif defined(USB_ONLY)
settings.startupMode = USB_MODE;
#else
settings.startupMode = INVALID_MODE;
#endif
hw_clear_bits(&xip_ctrl_hw->ctrl, XIP_CTRL_EN_BITS);

// Determine board type. GPIO 29 is grounded on PicoGUS v2.0, and on a Pico, it's VSYS/3 (~1.666V)
Expand Down

0 comments on commit 489370b

Please sign in to comment.