Skip to content

Commit

Permalink
Add dosbox.conf option to control GUS register readback alias
Browse files Browse the repository at this point in the history
  • Loading branch information
joncampbell123 committed Aug 10, 2024
1 parent 1564120 commit 3aecdb4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ NEXT
of 1997 demo "Out of Control" by Contract, all GUS registers
have a N and (N+0x80) alias, or at least register 0x4C, and
you can read them back from either index. Or else the demo
fails to detect the GUS. So add this alias. (joncampbell123).
fails to detect the GUS. So add this alias, but only if
enabled in dosbox.conf. Real hardware testing is required to
know if the actual GUS behaves this way and which versions.
(joncampbell123).
- Move the INT 3 default vector to well within the initial 16
bytes of the DOS kernel, away from the List of Lists and SFT.
The previous placement caused certain versions of Windows 3.2
Expand Down
8 changes: 8 additions & 0 deletions src/dosbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3803,6 +3803,14 @@ void DOSBOX_SetupConfigSections(void) {
Pbool->Set_help("Enable the Gravis Ultrasound emulation.");
Pbool->SetBasic(true);

Pstring = secprop->Add_string("global register read alias", Property::Changeable::WhenIdle, "auto");
Pstring->Set_values(truefalseautoopt);
Pstring->Set_help("If true, all GUS global registers have a read alias at N and N+0x80.\n"
"If false, only the voice registers 0x0-0xF have a read alias at 0x80-0x8F as officially documented.\n"
"If auto, automatically choose based on other settings such as GUS type.\n"
"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("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
19 changes: 14 additions & 5 deletions src/hardware/gus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ struct GFGus {
bool force_master_irq_enable;
bool fixed_sample_rate_output;
bool clearTCIfPollingIRQStatus;
bool globalread80alias;
double lastIRQStatusPollAt;
int lastIRQStatusPollRapidCount;
// IRQ status register values
Expand Down Expand Up @@ -813,11 +814,8 @@ static uint16_t ExecuteReadRegister(void) {
*
* TODO: Does the Interwave emulate this behavior or does it enforce
* registers as documented, and therefore "Out of Control"
* would not work on the Interwave?
*
* TODO: Make this a dosbox.conf setting, visible only under the
* "show all settings" mode only of course */
if (effective > 0x8F) effective &= 0x7F;
* would not work on the Interwave? */
if (myGUS.globalread80alias && effective > 0x8F) effective &= 0x7F;

// LOG_MSG("Read global reg %x",myGUS.gRegSelect,effective);

Expand Down Expand Up @@ -2343,6 +2341,17 @@ class GUS:public Module_base{
if (myGUS.force_master_irq_enable)
LOG(LOG_MISC,LOG_DEBUG)("GUS: Master IRQ enable will be forced on as instructed");

{
const char *s = section->Get_string("global register read alias");

if (!strcmp(s,"true") || !strcmp(s,"1"))
myGUS.globalread80alias = true;
else if (!strcmp(s,"false") || !strcmp(s,"0"))
myGUS.globalread80alias = false;
else /* auto */
myGUS.globalread80alias = false; /* TODO: Test real hardware, which versions of the GUS behave like this? */
}

myGUS.rate=(unsigned int)section->Get_int("gusrate");

ultradir = section->Get_string("ultradir");
Expand Down

0 comments on commit 3aecdb4

Please sign in to comment.