Merge pull request #1 from Tatsuya79/patch-3

PAR fixes for non PAR aspect ratios, Horizontal overscan parameter, better centering of the picture for libretro.
This commit is contained in:
Tatsuya79 2016-10-23 17:37:50 +02:00 committed by GitHub
commit 8e47a8c67a
4 changed files with 75 additions and 60 deletions

View File

@ -32,7 +32,7 @@
#define MEDNAFEN_CORE_GEOMETRY_BASE_H 243
#define MEDNAFEN_CORE_GEOMETRY_MAX_W 512
#define MEDNAFEN_CORE_GEOMETRY_MAX_H 243
#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0)
#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (6.0 / 5.0)
#define FB_WIDTH 512
#define FB_HEIGHT 243
@ -519,6 +519,7 @@ static MDFNSetting PCESettings[] =
{ "pce_fast.ocmultiplier", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "CPU overclock multiplier.", NULL, MDFNST_UINT, "1", "1", "100"},
{ "pce_fast.cdspeed", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "CD-ROM data transfer speed multiplier.", NULL, MDFNST_UINT, "1", "1", "100" },
{ "pce_fast.nospritelimit", MDFNSF_NOFLAGS, "Remove 16-sprites-per-scanline hardware limit.", NULL, MDFNST_BOOL, "0" },
{ "pce_fast.hoverscan", MDFNSF_NOFLAGS, "Display 352 pixels width instead of 341.", NULL, MDFNST_BOOL, "0" },
{ "pce_fast.cdbios", MDFNSF_EMU_STATE, "Path to the CD BIOS", NULL, MDFNST_STRING, "syscard3.pce" },
@ -1310,6 +1311,17 @@ static void check_variables(void)
else if (strcmp(var.value, "enabled") == 0)
setting_pce_fast_nospritelimit = 1;
}
var.key = "pce_hoverscan";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "disabled") == 0)
setting_pce_hoverscan = 0;
else if (strcmp(var.value, "enabled") == 0)
setting_pce_hoverscan = 1;
}
var.key = "pce_initial_scanline";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
@ -1645,8 +1657,13 @@ void retro_run(void)
audio_batch_cb(spec.SoundBuf, spec.SoundBufSize);
bool updated = false;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated){
check_variables();
if(PCE_IsCD){
psg->SetVolume(0.678 * setting_pce_fast_cdpsgvolume / 100);
}
}
}
void retro_get_system_info(struct retro_system_info *info)
@ -1715,12 +1732,13 @@ void retro_set_environment(retro_environment_t cb)
static const struct retro_variable vars[] = {
{ "pce_fast_cdimagecache", "CD Image Cache (Restart); disabled|enabled" },
{ "pce_nospritelimit", "No Sprite Limit; disabled|enabled" },
{ "pce_nospritelimit", "No Sprite Limit (Restart); disabled|enabled" },
{ "pce_hoverscan", "Horizontal Overscan (Restart); disabled|enabled" },
{ "pce_initial_scanline", "Initial scanline; 3|4|5|6|7|8|9|10|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|0|1|2" },
{ "pce_last_scanline", "Last scanline; 241|242|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|234|235|236|237|238|239|240" },
{ "pce_cddavolume", "(CD) CDDA Volume; 100|0|10|20|30|40|50|60|70|80|90" },
{ "pce_adpcmvolume", "(CD) ADPCM Volume; 100|0|10|20|30|40|50|60|70|80|90" },
{ "pce_cdpsgvolume", "(CD) CD PSG Volume; 100|0|10|20|30|40|50|60|70|80|90" },
{ "pce_last_scanline", "Last scanline; 242|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|234|235|236|237|238|239|240|241" },
{ "pce_cddavolume", "(CD) CDDA Volume %; 100|110|120|130|140|150|160|170|180|190|200|0|10|20|30|40|50|60|70|80|90" },
{ "pce_adpcmvolume", "(CD) ADPCM Volume %; 100|110|120|130|140|150|160|170|180|190|200|0|10|20|30|40|50|60|70|80|90" },
{ "pce_cdpsgvolume", "(CD) CD PSG Volume %; 100|110|120|130|140|150|160|170|180|190|200|0|10|20|30|40|50|60|70|80|90" },
{ "pce_cdspeed", "(CD) CD Speed; 1|2|4|8" },
{ "Turbo_Delay", "Turbo Delay; Fast|Medium|Slow" },
{ "p0_turbo_I_enable", "P1 Turbo I; disabled|enabled" },

View File

@ -37,7 +37,7 @@ static uint32 userle; // User layer enable.
static uint32 disabled_layer_color;
static bool unlimited_sprites;
static bool correct_aspect;
static bool hoverscan;
#define ULE_BG0 1
#define ULE_SPR0 2
@ -46,6 +46,7 @@ static bool correct_aspect;
static const uint8 bat_width_shift_tab[4] = { 5, 6, 7, 7 };
static const uint8 bat_height_mask_tab[2] = { 32 - 1, 64 - 1 };
static const int defined_width[3] = { 256, 341, 512};
static unsigned int VDS;
static unsigned int VSW;
@ -405,42 +406,6 @@ DECLFW(VDC_Write)
}
}
// 682 + 8 + 128 = 818.
static INLINE void CalcStartEnd(const vdc_t *vdc, uint32 &start, uint32 &end)
{
//static const unsigned int ClockModeWidths[3] = { 288, 384, 576 };
static const unsigned int ClockPixelWidths[3] = { 341, 455, 682 };
start = (M_vdc_HDS + 1) * 8;
// Semi-hack for Asuka 120%
if(vce.dot_clock == 1 && M_vdc_HDS == 5 && M_vdc_HDE == 6 && M_vdc_HDW == 43 && M_vdc_HSW == 2)
start -= 8;
else if(vce.dot_clock == 0 && M_vdc_HDS == 2 && M_vdc_HDE == 3 && M_vdc_HDW == 33 && M_vdc_HSW == 2)
start -= 4;
// and for Addams Family
else if(vce.dot_clock == 1 && M_vdc_HDS == 4 && M_vdc_HDE == 4 && M_vdc_HDW == 43 && M_vdc_HSW == 9)
start -= 4;
end = start + (M_vdc_HDW + 1) * 8;
if(start > (ClockPixelWidths[vce.dot_clock]))
start = ClockPixelWidths[vce.dot_clock];
if(end > (ClockPixelWidths[vce.dot_clock]))
end = ClockPixelWidths[vce.dot_clock];
if(start == end) // In case HDS is way off-screen, REMOVE when we confirm the rest of the code won't flip out
start = end - 8; // when start == end;
// For: start - (vdc->BG_XOffset & 7)
end += 8;
start += 8;
// For: alignment space when correct_aspect == 0
end += 128;
start += 128;
}
#define CB_EXL(n) (((n) << 4) | ((n) << 12) | ((n) << 20) | ((n) << 28) | ((n) << 36) | ((n) << 44) | ((n) << 52) | ((n) << 60))
static const uint64 cblock_exlut[16] = {
CB_EXL(0ULL), CB_EXL(1ULL), CB_EXL(2ULL), CB_EXL(3ULL), CB_EXL(4ULL), CB_EXL(5ULL), CB_EXL(6ULL), CB_EXL(7ULL),
@ -843,13 +808,12 @@ void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES)
if(!skip)
{
static const int ws[2][3] = {
{ 341, 341, 682 },
{ 256, 341, 512 }
};
DisplayRect->x = 0;
DisplayRect->w = ws[correct_aspect][vce.dot_clock];
if(hoverscan == 1 && vce.dot_clock == 1){
DisplayRect->w = 352;
}else{
DisplayRect->w = defined_width[vce.dot_clock];
}
}
int chip = 0;
@ -926,9 +890,8 @@ void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES)
if(fc_vrm)
{
uint32 start, end;
CalcStartEnd(vdc, start, end);
uint32 start = (M_vdc_HDS + 1) * 8;
uint32 end = start + (M_vdc_HDW + 1) * 8;
if((vdc->CR & 0x80) && SHOULD_DRAW)
{
@ -951,7 +914,35 @@ void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES)
int32 width = end - start;
int32 source_offset = 0;
int32 target_offset = 0;
//Centre any picture thinner than its display mode width
if(width > 0 && width < defined_width[vce.dot_clock]){
if(vce.dot_clock ==1 && hoverscan ==1){
target_offset = (352 - width)/2;
}else{
target_offset = (defined_width[vce.dot_clock] - width)/2;
}
}
//Centre cropping of overscan OFF
if(vce.dot_clock == 1 && hoverscan == 0 && width > 341){
target_offset = (341 - width) / 2;
}
// Align TV Sport Basketball
if(vce.dot_clock ==2 && width > 512){
target_offset = - 16;
}
// Semi-hack for Asuka 120%
if(vce.dot_clock == 1 && M_vdc_HDS == 5 && M_vdc_HDE == 6 && M_vdc_HDW == 43 && M_vdc_HSW == 2)
target_offset = 0;
else if(vce.dot_clock == 0 && M_vdc_HDS == 2 && M_vdc_HDE == 3 && M_vdc_HDW == 33 && M_vdc_HSW == 2)
target_offset = 0;
// and for Addams Family
else if(vce.dot_clock == 1 && M_vdc_HDS == 4 && M_vdc_HDE == 4 && M_vdc_HDW == 43 && M_vdc_HSW == 9)
target_offset = 0;
if(target_offset < 0)
{
width += target_offset;
@ -1044,7 +1035,11 @@ void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES)
//printf("%d\n", vce.lc263);
} while(frame_counter != VBlankFL); // big frame loop!
DisplayRect->w = (M_vdc_HDW + 1) * 8; //Horizontal Display Width in eight pixel tiles minus one
if(vce.dot_clock ==1 && hoverscan ==1){
DisplayRect->w = 352;
}else{
DisplayRect->w = defined_width[vce.dot_clock];
}
}
void VDC_Reset(void)
@ -1067,7 +1062,7 @@ void VDC_Power(void)
void VDC_Init(int sgx)
{
unlimited_sprites = MDFN_GetSettingB("pce_fast.nospritelimit");
correct_aspect = MDFN_GetSettingB("pce_fast.correct_aspect");
hoverscan = MDFN_GetSettingB("pce_fast.hoverscan");
userle = ~0;
vdc = (vdc_t *)malloc(sizeof(vdc_t));

View File

@ -23,12 +23,12 @@
int setting_initial_scanline = 0;
int setting_last_scanline = 242;
int setting_pce_hoverscan = 0;
int setting_pce_fast_nospritelimit = 0;
int setting_pce_fast_cddavolume = 100;
int setting_pce_fast_adpcmvolume = 100;
int setting_pce_fast_cdpsgvolume = 100;
uint32_t setting_pce_fast_cdspeed = 1;
uint32_t setting_pce_keepaspect = 1;
uint64 MDFN_GetSettingUI(const char *name)
{
@ -46,6 +46,8 @@ uint64 MDFN_GetSettingUI(const char *name)
return setting_initial_scanline;
if (!strcmp("pce_fast.slend", name))
return setting_last_scanline;
if (!strcmp("pce_fast.hoverscan", name))
return setting_pce_hoverscan;
fprintf(stderr, "unhandled setting UI: %s\n", name);
return 0;
@ -82,8 +84,8 @@ bool MDFN_GetSettingB(const char *name)
return 0;
if (!strcmp("pce_fast.adpcmlp", name))
return 0;
if (!strcmp("pce_fast.correct_aspect", name))
return setting_pce_keepaspect;
if (!strcmp("pce_fast.hoverscan", name))
return setting_pce_hoverscan;
/* CDROM */
if (!strcmp("cdrom.lec_eval", name))
return 1;

View File

@ -6,11 +6,11 @@
extern int setting_initial_scanline;
extern int setting_last_scanline;
extern int setting_pce_fast_nospritelimit;
extern int setting_pce_hoverscan;
extern int setting_pce_fast_cddavolume;
extern int setting_pce_fast_adpcmvolume;
extern int setting_pce_fast_cdpsgvolume;
extern uint32_t setting_pce_fast_cdspeed;
extern uint32_t setting_pce_keepaspect;
// This should assert() or something if the setting isn't found, since it would
// be a totally tubular error!