Skip to content

Commit

Permalink
GUS: Add dosbox.conf configuration option to enable a logfile warning…
Browse files Browse the repository at this point in the history
… every time a peek or poke is made to an out of bounds address to GUS DRAM
  • Loading branch information
joncampbell123 committed Jan 13, 2025
1 parent e6d2126 commit 0cf8f51
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/dosbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3887,6 +3887,9 @@ void DOSBOX_SetupConfigSections(void) {
"This setting may be needed for DOS demoscene entries that assume aliasing behavior such as Out of Control by Contract.");
Pstring->SetBasic(true);

Pbool = secprop->Add_bool("warn on out of bounds dram access",Property::Changeable::WhenIdle,false);
Pbool->Set_help("Controls whether attempts to access GUS DRAM beyond the 1MB maximum supported by the card are logged to the log file as a warning.");

Pbool = secprop->Add_bool("autoamp",Property::Changeable::WhenIdle,false);
Pbool->Set_help("If set, GF1 output will reduce in volume automatically if the sum of all channels exceeds full volume.\n"
"If not set, then loud music will clip to full volume just as it would on real hardware.\n"
Expand Down
16 changes: 12 additions & 4 deletions src/hardware/gus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ static bool unmask_irq = false;
static bool enable_autoamp = false;
static bool startup_ultrinit = false;
static bool ignore_active_channel_write_while_active = false;
static bool warn_out_of_bounds_dram_access = false;
static bool dma_enable_on_dma_control_polling = false;
static uint16_t vol16bit[4096];
static uint32_t pantable[16];
Expand Down Expand Up @@ -1567,11 +1568,13 @@ static Bitu read_gus(Bitu port,Bitu iolen) {

return reg16;
case 0x307:
if((myGUS.gDramAddr & myGUS.gDramAddrMask) < myGUS.memsize) {
if (warn_out_of_bounds_dram_access && myGUS.gDramAddr >= myGUS.memsize)
LOG(LOG_MISC,LOG_WARN)("GUS: out of bounds DRAM read %x",(unsigned int)myGUS.gDramAddr);

if((myGUS.gDramAddr & myGUS.gDramAddrMask) < myGUS.memsize)
return GUSRam[myGUS.gDramAddr & myGUS.gDramAddrMask];
} else {
else
return 0;
}
case 0x306:
case 0x706:
if (gus_type >= GUS_MAX)
Expand Down Expand Up @@ -1812,8 +1815,12 @@ static void write_gus(Bitu port,Bitu val,Bitu iolen) {
ExecuteGlobRegister();
break;
case 0x307:
if (warn_out_of_bounds_dram_access && myGUS.gDramAddr >= myGUS.memsize)
LOG(LOG_MISC,LOG_WARN)("GUS: out of bounds DRAM write %x val %x",(unsigned int)myGUS.gDramAddr,(unsigned int)val & 0xffu);

if ((myGUS.gDramAddr & myGUS.gDramAddrMask) < myGUS.memsize)
GUSRam[myGUS.gDramAddr & myGUS.gDramAddrMask] = (uint8_t)val;
GUSRam[myGUS.gDramAddr & myGUS.gDramAddrMask] = (uint8_t)val;

break;
case 0x306:
case 0x706:
Expand Down Expand Up @@ -2280,6 +2287,7 @@ class GUS:public Module_base{
memset(GUSRam,0,1024*1024);

ignore_active_channel_write_while_active = section->Get_bool("ignore channel count while active");
warn_out_of_bounds_dram_access = section->Get_bool("warn on out of bounds dram access");

unmask_irq = section->Get_bool("pic unmask irq");
enable_autoamp = section->Get_bool("autoamp");
Expand Down

0 comments on commit 0cf8f51

Please sign in to comment.