Better messaging when BLASTER has problems

This commit is contained in:
Ian Scott committed 2026-04-13 18:20:56 -06:00
1 parent 452f863936
commit 889dfa89c7
1 file changed
+43 -14
+43 -14
View File
@@ -182,23 +182,48 @@ static void err_ultrasnd(void)
}
static void err_blaster(void)
typedef enum {
BLASTER_UNSET,
BLASTER_MALFORMED,
BLASTER_DMA16_MISMATCH,
BLASTER_MISMATCH,
} blaster_err_t;
static void err_blaster_format_help(void)
{
// "................................................................................\n"
fprintf(stderr, "ERROR: In SB mode but no BLASTER variable set or is malformed!\n");
fprintf(stderr, "The BLASTER environment variable must be set in the following format:\n");
fprintf(stderr, "\tset BLASTER=Axxx Iy Dz Hz Tw\n");
fprintf(stderr, "Where xxx = port, y = IRQ, z = DMA. w = SB type:\n");
fprintf(stderr, " 1 - SB 1.x, 2 - SB Pro 1 (dual OPL2), 3 - SB 2.0,\n");
fprintf(stderr, " 4 - SB Pro 2 (OPL3), 6 - SB 16\n");
fprintf(stderr, "Port is set via /sbport xxx option; DMA and IRQ configued via jumper then also\n");
fprintf(stderr, "set via /sbirq y and /sbdma y options.\n");
}
static void err_blaster16_dma_mismatch(void)
static void err_blaster(blaster_err_t reason)
{
// "................................................................................\n"
fprintf(stderr, "ERROR: In SB 16 mode, low (Dx) and high (Hx) DMA in BLASTER variable must match!\n");
// "................................................................................\n"
switch (reason) {
case BLASTER_UNSET:
fprintf(stderr, "ERROR: In SB mode but BLASTER environment variable is not set!\n");
err_blaster_format_help();
fprintf(stderr, "Then run pgusinit /sbenv to apply the BLASTER settings to the card.\n");
break;
case BLASTER_MALFORMED:
fprintf(stderr, "ERROR: BLASTER environment variable is malformed!\n");
fprintf(stderr, "Current value: BLASTER=%s\n", getenv("BLASTER"));
err_blaster_format_help();
break;
case BLASTER_DMA16_MISMATCH:
fprintf(stderr, "ERROR: In SB 16 mode, low (Dx) and high (Hx) DMA in BLASTER variable must match!\n");
fprintf(stderr, "Current value: BLASTER=%s\n", getenv("BLASTER"));
break;
case BLASTER_MISMATCH:
fprintf(stderr, "ERROR: SB settings on card don't match the BLASTER environment variable!\n");
fprintf(stderr, "Double-check that PicoGUS is jumpered correctly for the desired IRQ and DMA,\n");
fprintf(stderr, "then run pgusinit /sbenv to set card resources from the BLASTER variable.\n");
fprintf(stderr, "Alternatively, use /sbport, /sbirq, /sbdma, /sbtype to set values directly.\n");
break;
}
}
static void err_pigus(void)
@@ -278,7 +303,7 @@ static int init_sb(void)
char* blaster = getenv("BLASTER");
if (blaster == NULL) {
err_blaster();
err_blaster(BLASTER_UNSET);
return 1;
}
char blasterTemp[256];
@@ -299,8 +324,12 @@ static int init_sb(void)
p = strtok(NULL, " ");
}
if ((port == -1) || (irq == -1) || (dma8 == -1) || (sbtype > 6) || (dspver[sbtype] == 0) || ((sbtype == 6) && (dma8 != dma16))) {
err_blaster();
if ((port == -1) || (irq == -1) || (dma8 == -1) || (sbtype > 6) || (dspver[sbtype] == 0)) {
err_blaster(BLASTER_MALFORMED);
return 2;
}
if ((sbtype == 6) && (dma8 != dma16)) {
err_blaster(BLASTER_DMA16_MISMATCH);
return 2;
}
@@ -322,28 +351,28 @@ static int init_sb(void)
outp(CONTROL_PORT, CMD_SBPORT); // Select port register
uint16_t tmp_port = inpw(DATA_PORT_LOW);
if (port != tmp_port) {
err_blaster();
err_blaster(BLASTER_MISMATCH);
return 2;
}
outp(CONTROL_PORT, CMD_SBIRQ); // Select IRQ register
uint8_t tmp_irq = inp(DATA_PORT_HIGH);
if (irq != tmp_irq) {
err_blaster();
err_blaster(BLASTER_MISMATCH);
return 2;
}
outp(CONTROL_PORT, CMD_SBDMA); // Select DMA register
uint8_t tmp_dma = inp(DATA_PORT_HIGH);
if (dma8 != tmp_dma) {
err_blaster();
err_blaster(BLASTER_MISMATCH);
return 2;
}
outp(CONTROL_PORT, CMD_SBTYPE); // Select SB type register
uint8_t tmp_type = inp(DATA_PORT_HIGH);
if (sbtype != tmp_type) {
err_blaster();
err_blaster(BLASTER_MISMATCH);
return 2;
}
}