Permalink
Browse files

GUS: Limit DRAM peek/poke address to 1MB. Some demos (such as ACME Me…

…ntal Masturbation) appear to poke samples into GUS RAM using odd and spurious values in the upper bits (bits 23-20) of the DRAM address
  • Loading branch information...
joncampbell123 committed Jul 9, 2018
1 parent de89326 commit 5875ce4c90a53de1e549e87c381152583c0927a3
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/hardware/gus.cpp
@@ -88,6 +88,7 @@ struct GFGus {
Bit8u gRegSelect;
Bit16u gRegData;
Bit32u gDramAddr;
Bit32u gDramAddrMask;
Bit16u gCurChannel;
Bit8u gUltraMAXControl;
@@ -1376,8 +1377,8 @@ static Bitu read_gus(Bitu port,Bitu iolen) {
return reg16;
case 0x307:
if(myGUS.gDramAddr < myGUS.memsize) {
return GUSRam[myGUS.gDramAddr];
if((myGUS.gDramAddr & myGUS.gDramAddrMask) < myGUS.memsize) {
return GUSRam[myGUS.gDramAddr & myGUS.gDramAddrMask];
} else {
return 0;
}
@@ -1587,7 +1588,8 @@ static void write_gus(Bitu port,Bitu val,Bitu iolen) {
ExecuteGlobRegister();
break;
case 0x307:
if(myGUS.gDramAddr < myGUS.memsize) GUSRam[myGUS.gDramAddr] = (Bit8u)val;
if ((myGUS.gDramAddr & myGUS.gDramAddrMask) < myGUS.memsize)
GUSRam[myGUS.gDramAddr & myGUS.gDramAddrMask] = (Bit8u)val;
break;
case 0x306:
case 0x706:
@@ -2182,6 +2184,9 @@ class GUS:public Module_base{
GUS_ICS2101.updateVolPair(gus_ICS2101::MASTER_OUTPUT_PORT);
}
// Default to GUS MAX 1MB maximum
myGUS.gDramAddrMask = 0xFFFFF;
// if instructed, configure the card as if ULTRINIT had been run
if (startup_ultrinit) {
myGUS.gRegData=0x700;

0 comments on commit 5875ce4

Please sign in to comment.