Skip to content

Commit

Permalink
Fix_180x_registers ( #142 )
Browse files Browse the repository at this point in the history
Do not repeat 0x1800-0f registers (no 'echoes' in other memory locations).
Also, treat 0x180e and 0x180f as separate registers (with no behaviour behind them at this time).
  • Loading branch information
dshadoff committed Dec 26, 2023
1 parent 78e26dd commit 5334089
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions mednafen/src/pce/pcecd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ typedef struct
uint8 LastCmd;
uint32 SampleFreq;

uint8 Reg0e;
uint8 Reg0f;

uint8 PlayBuffer;
uint8 ReadBuffer;
int32 ReadPending;
Expand Down Expand Up @@ -551,8 +554,10 @@ MDFN_FASTCALL uint8 PCECD_Read(uint32 timestamp, uint32 A, int32 &next_event, co
if(!PeekMode)
PCECD_Run(timestamp);

switch(A & 0xf)
if ((A & 0x1F00) == 0x1800)
{
switch(A & 0xff)
{
case 0x0:
ret = 0;
ret |= SCSICD_GetBSY() ? 0x80 : 0x00;
Expand Down Expand Up @@ -641,6 +646,16 @@ MDFN_FASTCALL uint8 PCECD_Read(uint32 timestamp, uint32 A, int32 &next_event, co
case 0xd:
ret = ADPCM.LastCmd;
break;

case 0xe:
ret = ADPCM.Reg0e;
break;

case 0xf:
ret = ADPCM.Reg0f;
break;

}
}
}

Expand Down Expand Up @@ -685,8 +700,10 @@ MDFN_FASTCALL int32 PCECD_Write(uint32 timestamp, uint32 physAddr, uint8 data)

PCECD_Run(timestamp);

switch (physAddr & 0xf)
if ((physAddr & 0x1F00) == 0x1800)
{
switch (physAddr & 0xff)
{
case 0x0:
SCSICD_SetSEL(1);
SCSICD_Run(timestamp);
Expand Down Expand Up @@ -828,6 +845,7 @@ MDFN_FASTCALL int32 PCECD_Write(uint32 timestamp, uint32 physAddr, uint8 data)

MSM5205.SetSample(0x800);
MSM5205.SetSSI(0);
ADPCM.LastCmd = data;
break;
}

Expand Down Expand Up @@ -885,6 +903,7 @@ MDFN_FASTCALL int32 PCECD_Write(uint32 timestamp, uint32 physAddr, uint8 data)

case 0xe: // Set ADPCM playback rate
{
ADPCM.Reg0e = data;
uint8 freq = V & 0x0F;

ADPCM.SampleFreq = freq;
Expand All @@ -895,6 +914,7 @@ MDFN_FASTCALL int32 PCECD_Write(uint32 timestamp, uint32 physAddr, uint8 data)
break;

case 0xf:
ADPCM.Reg0f = data;
Fader.Command = V;

#ifdef PCECD_DEBUG
Expand All @@ -920,6 +940,7 @@ MDFN_FASTCALL int32 PCECD_Write(uint32 timestamp, uint32 physAddr, uint8 data)
}
Fader_SyncWhich();
break;
}
}


Expand Down

0 comments on commit 5334089

Please sign in to comment.