From 4b25da47afd363fcd6db4fb048ccfd686bc8845e Mon Sep 17 00:00:00 2001 From: westonlast Date: Mon, 18 Jul 2016 02:00:04 -0500 Subject: [PATCH 1/2] Fix compilation using GCC --- libretro-common/include/retro_inline.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/include/retro_inline.h b/libretro-common/include/retro_inline.h index 8535d84..f998624 100644 --- a/libretro-common/include/retro_inline.h +++ b/libretro-common/include/retro_inline.h @@ -26,7 +26,7 @@ #ifndef INLINE #if !defined(__cplusplus) && defined(_WIN32) -#define INLINE _inline +#define INLINE inline #elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L #define INLINE inline #elif defined(__GNUC__) From d78f6bb77693da178272dd284aac250c82f914ae Mon Sep 17 00:00:00 2001 From: westonlast Date: Mon, 18 Jul 2016 02:32:52 -0500 Subject: [PATCH 2/2] Correct Pixel Aspect Ratio --- libretro.cpp | 58 ++++++++++++++++----------------------- mednafen/git.h | 1 - mednafen/pce_fast/vdc.cpp | 30 ++++---------------- 3 files changed, 29 insertions(+), 60 deletions(-) diff --git a/libretro.cpp b/libretro.cpp index f8fcbae..d33ad76 100755 --- a/libretro.cpp +++ b/libretro.cpp @@ -23,6 +23,19 @@ #include "mednafen/msvc_compat.h" #endif +#define MEDNAFEN_CORE_NAME_MODULE "pce_fast" +#define MEDNAFEN_CORE_NAME "Mednafen PCE Fast" +#define MEDNAFEN_CORE_VERSION "v0.9.38.7" +#define MEDNAFEN_CORE_EXTENSIONS "pce|cue|ccd" +#define MEDNAFEN_CORE_TIMING_FPS 59.82 +#define MEDNAFEN_CORE_GEOMETRY_BASE_W 512 +#define MEDNAFEN_CORE_GEOMETRY_BASE_H 242 +#define MEDNAFEN_CORE_GEOMETRY_MAX_W 512 +#define MEDNAFEN_CORE_GEOMETRY_MAX_H 242 +#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0) +#define FB_WIDTH 512 +#define FB_HEIGHT 242 + static bool old_cdimagecache = false; extern MDFNGI EmulatedPCE_Fast; @@ -878,8 +891,8 @@ MDFNGI EmulatedPCE_Fast = 0, // lcm_height NULL, // Dummy - 288, // Nominal width - 232, // Nominal height + MEDNAFEN_CORE_GEOMETRY_BASE_W, // Nominal width + MEDNAFEN_CORE_GEOMETRY_BASE_H, // Nominal height 512, // Framebuffer width 242, // Framebuffer height @@ -1191,8 +1204,6 @@ static retro_audio_sample_batch_t audio_batch_cb; static retro_environment_t environ_cb; static retro_input_poll_t input_poll_cb; static retro_input_state_t input_state_cb; - -static bool overscan; static double last_sound_rate; static MDFN_Surface *surf; @@ -1219,19 +1230,6 @@ static void set_basename(const char *path) #include "mednafen/pce_fast/pcecd.h" -#define MEDNAFEN_CORE_NAME_MODULE "pce_fast" -#define MEDNAFEN_CORE_NAME "Mednafen PCE Fast" -#define MEDNAFEN_CORE_VERSION "v0.9.38.7" -#define MEDNAFEN_CORE_EXTENSIONS "pce|cue|ccd" -#define MEDNAFEN_CORE_TIMING_FPS 59.82 -#define MEDNAFEN_CORE_GEOMETRY_BASE_W 288 -#define MEDNAFEN_CORE_GEOMETRY_BASE_H 232 -#define MEDNAFEN_CORE_GEOMETRY_MAX_W 512 -#define MEDNAFEN_CORE_GEOMETRY_MAX_H 242 -#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0) -#define FB_WIDTH 512 -#define FB_HEIGHT 242 - #define FB_MAX_HEIGHT FB_HEIGHT static void check_system_specs(void) @@ -1522,10 +1520,6 @@ bool retro_load_game(const struct retro_game_info *info) }; environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc); - - overscan = false; - environ_cb(RETRO_ENVIRONMENT_GET_OVERSCAN, &overscan); - set_basename(info->path); check_variables(); @@ -1542,8 +1536,7 @@ bool retro_load_game(const struct retro_game_info *info) surf->width = FB_WIDTH; surf->height = FB_HEIGHT; surf->pitch = FB_WIDTH; - - surf->pixels = (uint16_t*)calloc(1, FB_WIDTH * FB_HEIGHT * 3); + surf->pixels = (uint16_t*) calloc(2, FB_WIDTH * FB_HEIGHT); if (!surf->pixels) { @@ -1654,11 +1647,14 @@ void retro_run(void) spec.SoundBufSize = spec.SoundBufSizeALMS + SoundBufSize; - unsigned width = spec.DisplayRect.w & ~0x1; + unsigned width = spec.DisplayRect.w; unsigned height = spec.DisplayRect.h; - - video_cb(surf->pixels + surf->pitch * spec.DisplayRect.y, width, height, FB_WIDTH << 1); - + struct retro_system_av_info system_av_info; + system_av_info.geometry.base_width = width; + system_av_info.geometry.base_height = height; + system_av_info.geometry.aspect_ratio = MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO; + environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &system_av_info); + video_cb(surf->pixels + surf->pitch * spec.DisplayRect.y, width, height, FB_WIDTH * 2); video_frames++; audio_frames += spec.SoundBufSize; @@ -1977,14 +1973,6 @@ void MDFND_Message(const char *str) log_cb(RETRO_LOG_INFO, "%s\n", str); } -void MDFND_MidSync(const EmulateSpecStruct *) -{} - -void MDFN_MidLineUpdate(EmulateSpecStruct *espec, int y) -{ - //MDFND_MidLineUpdate(espec, y); -} - void MDFND_PrintError(const char* err) { if (log_cb) diff --git a/mednafen/git.h b/mednafen/git.h index b154c8e..fe68961 100644 --- a/mednafen/git.h +++ b/mednafen/git.h @@ -188,7 +188,6 @@ typedef struct MDFN_Surface *surface; // Will be set to TRUE if the video pixel format has changed since the last call to Emulate(), FALSE otherwise. - // Will be set to TRUE on the first call to the Emulate() function/method bool VideoFormatChanged; // Set by the system emulation code every frame, to denote the horizontal and vertical offsets of the image, and the size diff --git a/mednafen/pce_fast/vdc.cpp b/mednafen/pce_fast/vdc.cpp index 41efbfe..1388bd7 100644 --- a/mednafen/pce_fast/vdc.cpp +++ b/mednafen/pce_fast/vdc.cpp @@ -771,13 +771,7 @@ void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES) int32 *LineWidths = espec->LineWidths; bool skip = espec->skip || IsHES; - // x and w should be overwritten in the big loop - - if(!skip) - { - DisplayRect->x = 0; - DisplayRect->w = 256; - + if(!skip){ DisplayRect->y = MDFN_GetSettingUI("pce_fast.slstart"); DisplayRect->h = MDFN_GetSettingUI("pce_fast.slend") - DisplayRect->y + 1; } @@ -788,7 +782,7 @@ void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES) if(frame_counter == 0) { - VDS = M_vdc_VDS; + VDS = 12 /*constant that fills the framebuffer*//*M_vdc_VDS*/; //Vertical Display Start position minus two VSW = M_vdc_VSW; VDW = M_vdc_VDW; VCR = M_vdc_VCR; @@ -953,16 +947,10 @@ void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES) memset(spr_linebuf + 0x20, 0, sizeof(uint16) * (end - start)); } - if(SHOULD_DRAW) - { - static const int xs[2][3] = { - { 24 - 43, 38, 96 - 43 * 2 }, - { 24, 38, 96 } - }; - + if(SHOULD_DRAW){ int32 width = end - start; int32 source_offset = 0; - int32 target_offset = start - (128 + 8 + xs[correct_aspect][vce.dot_clock]); + int32 target_offset = 0; if(target_offset < 0) { @@ -974,9 +962,6 @@ void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES) if((target_offset + width) > DisplayRect->w) width = (int32)DisplayRect->w - target_offset; - //if(vdc->display_counter == 50) - // MDFN_DispMessage("soffset=%d, toffset=%d, width=%d", source_offset, target_offset, width); - if(width > 0) { //else if(target_ptr16) @@ -1011,11 +996,6 @@ void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES) } } - if(SHOULD_DRAW && fc_vrm) - { - MDFN_MidLineUpdate(espec, frame_counter - 14); - } - if((vdc->CR & 0x08) && need_vbi[0]) vdc->status |= VDCS_VD; @@ -1064,6 +1044,8 @@ 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 + DisplayRect->h = M_vdc_VDW + 1; //Vertical Display Width in pixels minus one } void VDC_Reset(void)