Commit d896c118 authored by tryal-star's avatar tryal-star
Browse files

add 32-bpp output (optional)

parent 2c0af2ec
......@@ -38,7 +38,7 @@ endif
CACHE_CD = 0
HAVE_HES = 0
NEED_BPP = 32
NEED_BPP = 16
NEED_TREMOR = 1
NEED_BLIP = 1
NEED_CD = 1
......@@ -554,6 +554,10 @@ ifeq ($(NEED_BPP), 16)
FLAGS += -DWANT_16BPP
endif
ifeq ($(NEED_BPP), 32)
FLAGS += -DWANT_32BPP
endif
ifeq ($(FRONTEND_SUPPORTS_RGB565), 1)
FLAGS += -DFRONTEND_SUPPORTS_RGB565
endif
......
......@@ -393,9 +393,19 @@ void retro_init(void)
failed_init = true;
}
#if defined(WANT_16BPP) && defined(FRONTEND_SUPPORTS_RGB565)
enum retro_pixel_format rgb565 = RETRO_PIXEL_FORMAT_RGB565;
if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &rgb565) && log_cb)
log_cb(RETRO_LOG_INFO, "Frontend supports RGB565 - will use that instead of XRGB1555.\n");
#elif defined(WANT_32BPP)
enum retro_pixel_format rgb888 = RETRO_PIXEL_FORMAT_XRGB8888;
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &rgb888))
{
if (log_cb)
log_cb(RETRO_LOG_ERROR, "Pixel format XRGB8888 not supported by platform, cannot use %s.\n", MEDNAFEN_CORE_NAME);
return;
}
#endif
if (environ_cb(RETRO_ENVIRONMENT_GET_PERF_INTERFACE, &perf_cb))
perf_get_cpu_features_cb = perf_cb.get_cpu_features;
......@@ -849,7 +859,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(2, FB_WIDTH * FB_HEIGHT);
surf->pixels = (bpp_t*) calloc(sizeof(bpp_t), FB_WIDTH * FB_HEIGHT);
if (!surf->pixels)
{
......@@ -1081,10 +1091,15 @@ void update_geometry(unsigned width, unsigned height)
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &info);
}
static void hires_blending(uint16 *fb, int width, int height, int pitch)
static void hires_blending(bpp_t *fb, int width, int height, int pitch)
{
int x, y, z;
#define AVERAGE_565(el0, el1) (((el0) & (el1)) + ((((el0) ^ (el1)) & 0xF7DE) >> 1))
#if defined(WANT_32BPP)
#define AVERAGE_565(el0, el1) ((el0 + el1) >> 1)
#else
#define AVERAGE_565(el0, el1) (((el0) & (el1)) + ((((el0) ^ (el1)) & 0xF7DE) >> 1))
#endif
if (vce_resolution.max_rate == 4 && hires_blend == 1) /* Blur method */
{
......@@ -1092,9 +1107,9 @@ static void hires_blending(uint16 *fb, int width, int height, int pitch)
{
for (y = height - 1; y >= 0; y--)
{
uint16 *input = &fb[y * pitch];
uint16 *output = &fb[y * pitch];
uint16 l, r;
bpp_t *input = &fb[y * pitch];
bpp_t *output = &fb[y * pitch];
bpp_t l, r;
l = 0;
r = *input++;
......@@ -1162,11 +1177,11 @@ void retro_run(void)
width = spec.DisplayRect.w;
height = spec.DisplayRect.h;
uint16 *fb = surf->pixels + spec.DisplayRect.x + surf->pitch * spec.DisplayRect.y;
bpp_t *fb = surf->pixels + spec.DisplayRect.x + surf->pitch * spec.DisplayRect.y;
hires_blending(fb, width, height, FB_WIDTH);
video_cb(fb, width, height, FB_WIDTH * 2);
video_cb(fb, width, height, FB_WIDTH * sizeof(bpp_t));
audio_batch_cb(spec.SoundBuf, spec.SoundBufSize);
bool updated = false;
......
......@@ -1078,7 +1078,7 @@ void VCE::EndFrame(MDFN_Rect *DisplayRect)
for(int line = end_y - start_y - 1; line >= 0; line--)
{
uint16* line_ptr = &fb[(start_y + line) * pitch32];
bpp_t* line_ptr = &fb[(start_y + line) * pitch32];
switch(scale)
{
......
......@@ -109,7 +109,7 @@ private:
int32 cd_event;
uint16 *fb; // Pointer to the framebuffer.
bpp_t *fb; // Pointer to the framebuffer.
uint16 pitch32; // Pitch(in 16-bit pixels)
bool FrameDone;
bool ShowHorizOS;
......@@ -122,7 +122,7 @@ private:
int32 clock_divider;
int32 scanline;
uint16 *scanline_out_ptr; // Pointer into fb
bpp_t *scanline_out_ptr; // Pointer into fb
int32 pixel_offset;
int32 hblank_counter;
......
......@@ -3,7 +3,14 @@
#include <stdint.h>
#if defined(FRONTEND_SUPPORTS_RGB565)
#if defined(WANT_32BPP)
#define RED_SHIFT 16
#define GREEN_SHIFT 8
#define BLUE_SHIFT 0
#define ALPHA_SHIFT 24
#define MAKECOLOR(r, g, b, a) ((r << RED_SHIFT) | (g << GREEN_SHIFT) | (b << BLUE_SHIFT) | (a << ALPHA_SHIFT))
typedef uint32_t bpp_t;
#elif defined(FRONTEND_SUPPORTS_RGB565)
/* 16bit color - RGB565 */
#define RED_MASK 0xf800
#define GREEN_MASK 0x7e0
......@@ -15,6 +22,7 @@
#define GREEN_SHIFT 5
#define BLUE_SHIFT 0
#define MAKECOLOR(r, g, b, a) (((r >> RED_EXPAND) << RED_SHIFT) | ((g >> GREEN_EXPAND) << GREEN_SHIFT) | ((b >> BLUE_EXPAND) << BLUE_SHIFT))
typedef uint16_t bpp_t;
#else
/* 16bit color - RGB555 */
#define RED_MASK 0x7c00
......@@ -27,6 +35,7 @@
#define GREEN_SHIFT 5
#define BLUE_SHIFT 0
#define MAKECOLOR(r, g, b, a) (((r >> RED_EXPAND) << RED_SHIFT) | ((g >> GREEN_EXPAND) << GREEN_SHIFT) | ((b >> BLUE_EXPAND) << BLUE_SHIFT))
typedef uint16_t bpp_t;
#endif
#ifdef __cplusplus
......@@ -49,7 +58,7 @@ typedef struct
typedef struct
{
uint16_t *pixels;
bpp_t *pixels;
int32_t width;
int32_t height;
int32_t pitch;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment