Skip to content

Commit f70c6c2

Browse files
authored
Added ROM memory domain, core option to ignore EDC/L-EC errors (#239)
* added ROM memory region * new optimizations for volume hacks * safer bit shifting for volume scaling * added core option to ignore cd edc errors
1 parent 9a57c19 commit f70c6c2

6 files changed

Lines changed: 49 additions & 9 deletions

File tree

libretro-common/include/libretro.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ enum retro_language
322322
/* Video ram lets a frontend peek into a game systems video RAM (VRAM). */
323323
#define RETRO_MEMORY_VIDEO_RAM 3
324324

325+
/* ROM lets a frontend peek into a game systems ROM. */
326+
#define RETRO_MEMORY_ROM 4
327+
325328
/* Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. */
326329
enum retro_key
327330
{

libretro.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,16 @@ static void check_variables(bool first_run)
18731873
do_cdsettings = true;
18741874
setting_pce_fast_cdpsgvolume = atoi(var.value);
18751875
}
1876+
1877+
var.key = "pce_fast_cdignoreerrors";
1878+
setting_pce_fast_cdignoreerrors = false;
1879+
1880+
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
1881+
if (strcmp(var.value, "enabled") == 0)
1882+
{
1883+
setting_pce_fast_cdignoreerrors = true;
1884+
}
1885+
18761886

18771887
var.key = "pce_fast_cdspeed";
18781888

@@ -2615,6 +2625,8 @@ void *retro_get_memory_data(unsigned type)
26152625
return BaseRAM;
26162626
case RETRO_MEMORY_VIDEO_RAM:
26172627
return vdc->VRAM;
2628+
case RETRO_MEMORY_ROM:
2629+
return ROMSpace;
26182630
default:
26192631
break;
26202632
}
@@ -2634,6 +2646,8 @@ size_t retro_get_memory_size(unsigned type)
26342646
return 8192;
26352647
case RETRO_MEMORY_VIDEO_RAM:
26362648
return 65536;
2649+
case RETRO_MEMORY_ROM:
2650+
return (0x88 * 8192 + 8192); // TODO: dynamic based on loaded content?
26372651
default:
26382652
break;
26392653
}

libretro_core_options.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,21 @@ struct retro_core_option_v2_definition option_defs_us[] = {
731731
},
732732
"100"
733733
},
734+
{
735+
"pce_fast_cdignoreerrors",
736+
"CD Ignore EDC/L-EC Errors",
737+
NULL,
738+
"Ignore EDC/L-EC errors. Needed for compatibility with some hacks.",
739+
NULL,
740+
"cd",
741+
{
742+
{ "disabled", NULL },
743+
{ "enabled", NULL },
744+
{ NULL, NULL },
745+
},
746+
"disabled"
747+
},
748+
734749
{
735750
"pce_fast_nospritelimit",
736751
"No Sprite Limit",

mednafen/pce_fast/pcecd_drive.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ static int32 CDReadTimer;
158158
static uint32 SectorAddr;
159159
static uint32 SectorCount;
160160

161+
bool setting_pce_fast_cdignoreerrors;
162+
161163

162164
enum
163165
{
@@ -412,7 +414,12 @@ static void CommandCCError(int key, int asc = 0, int ascq = 0)
412414

413415
static bool ValidateRawDataSector(uint8 *data, const uint32 lba)
414416
{
415-
if(!edc_lec_check_and_correct(data, false))
417+
bool c = edc_lec_check_and_correct(data, false);
418+
419+
//if(!c)
420+
// printf("failed ValidateRawDataSector: %x\n", lba);
421+
422+
if(!c && !setting_pce_fast_cdignoreerrors)
416423
{
417424
din.Flush();
418425
cd.data_transfer_done = false;

mednafen/pce_fast/pcecd_drive.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct pcecd_drive_bus_t
1616
};
1717

1818
extern pcecd_drive_bus_t cd_bus; // Don't access this structure directly by name outside of pcecd_drive.c, but use the macros below.
19+
extern bool setting_pce_fast_cdignoreerrors;
1920

2021
// Signals under our(the "target") control.
2122
#define PCECD_Drive_IO_mask 0x001

mednafen/pce_fast/psg.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ void PCEFast_PSG::UpdateOutput_Norm(const int32 timestamp, psg_channel *ch)
5050

5151
if(ch->user_volume < 100)
5252
{
53-
delta0 = (samp[0] - ch->blip_prev_samp[0]) * ch->user_volume / 100;
54-
delta1 = (samp[1] - ch->blip_prev_samp[1]) * ch->user_volume / 100;
53+
delta0 = ((samp[0] - ch->blip_prev_samp[0]) * ch->user_volume * 164) >> 14;
54+
delta1 = ((samp[1] - ch->blip_prev_samp[1]) * ch->user_volume * 164) >> 14;
5555
} else {
5656
delta0 = samp[0] - ch->blip_prev_samp[0];
5757
delta1 = samp[1] - ch->blip_prev_samp[1];
@@ -76,8 +76,8 @@ void PCEFast_PSG::UpdateOutput_Noise(const int32 timestamp, psg_channel *ch)
7676

7777
if(ch->user_volume < 100)
7878
{
79-
delta0 = (samp[0] - ch->blip_prev_samp[0]) * ch->user_volume / 100;
80-
delta1 = (samp[1] - ch->blip_prev_samp[1]) * ch->user_volume / 100;
79+
delta0 = ((samp[0] - ch->blip_prev_samp[0]) * ch->user_volume * 164) >> 14;
80+
delta1 = ((samp[1] - ch->blip_prev_samp[1]) * ch->user_volume * 164) >> 14;
8181
} else {
8282
delta0 = samp[0] - ch->blip_prev_samp[0];
8383
delta1 = samp[1] - ch->blip_prev_samp[1];
@@ -100,8 +100,8 @@ void PCEFast_PSG::UpdateOutput_Off(const int32 timestamp, psg_channel *ch)
100100

101101
if(ch->user_volume < 100)
102102
{
103-
delta0 = (samp[0] - ch->blip_prev_samp[0]) * ch->user_volume / 100;
104-
delta1 = (samp[1] - ch->blip_prev_samp[1]) * ch->user_volume / 100;
103+
delta0 = ((samp[0] - ch->blip_prev_samp[0]) * ch->user_volume * 164) >> 14;
104+
delta1 = ((samp[1] - ch->blip_prev_samp[1]) * ch->user_volume * 164) >> 14;
105105
} else {
106106
delta0 = samp[0] - ch->blip_prev_samp[0];
107107
delta1 = samp[1] - ch->blip_prev_samp[1];
@@ -126,8 +126,8 @@ void PCEFast_PSG::UpdateOutput_Accum(const int32 timestamp, psg_channel *ch)
126126

127127
if(ch->user_volume < 100)
128128
{
129-
delta0 = (samp[0] - ch->blip_prev_samp[0]) * ch->user_volume / 100;
130-
delta1 = (samp[1] - ch->blip_prev_samp[1]) * ch->user_volume / 100;
129+
delta0 = ((samp[0] - ch->blip_prev_samp[0]) * ch->user_volume * 164) >> 14;
130+
delta1 = ((samp[1] - ch->blip_prev_samp[1]) * ch->user_volume * 164) >> 14;
131131
} else {
132132
delta0 = samp[0] - ch->blip_prev_samp[0];
133133
delta1 = samp[1] - ch->blip_prev_samp[1];

0 commit comments

Comments
 (0)