mirror of
https://github.com/libretro/beetle-lynx-libretro.git
synced 2024-11-23 08:10:55 +00:00
Opt-in for 24bpp.
This commit is contained in:
parent
06f54d1192
commit
fa5adbacd5
51
libretro.cpp
51
libretro.cpp
@ -14,6 +14,7 @@ static retro_input_poll_t input_poll_cb;
|
||||
static retro_input_state_t input_state_cb;
|
||||
|
||||
static MDFN_Surface *surf;
|
||||
static bool rgb32;
|
||||
|
||||
static uint16_t conv_buf[680 * 480] __attribute__((aligned(16)));
|
||||
static uint32_t mednafen_buf[680 * 480] __attribute__((aligned(16)));
|
||||
@ -84,6 +85,10 @@ bool retro_load_game(const struct retro_game_info *info)
|
||||
if (failed_init)
|
||||
return false;
|
||||
|
||||
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
|
||||
rgb32 = true;
|
||||
|
||||
game = MDFNI_LoadGame("psx", info->path);
|
||||
return game;
|
||||
}
|
||||
@ -178,6 +183,7 @@ void retro_run()
|
||||
|
||||
static int16_t sound_buf[0x10000];
|
||||
static MDFN_Rect rects[480];
|
||||
rects[0].w = ~0;
|
||||
|
||||
EmulateSpecStruct spec = {0};
|
||||
spec.surface = surf;
|
||||
@ -193,8 +199,41 @@ void retro_run()
|
||||
unsigned width = rects[0].w;
|
||||
unsigned height = spec.DisplayRect.h;
|
||||
|
||||
convert_surface();
|
||||
video_cb(conv_buf, width, height, 680 << 1);
|
||||
if (rgb32)
|
||||
{
|
||||
// FIXME: Avoid black borders. Cannot see how DisplayRect exposes this.
|
||||
const uint32_t *ptr = mednafen_buf;
|
||||
if (width == 340)
|
||||
{
|
||||
ptr += 10;
|
||||
width = 320;
|
||||
}
|
||||
else if (width == 680)
|
||||
{
|
||||
ptr += 20;
|
||||
width = 640;
|
||||
}
|
||||
|
||||
video_cb(ptr, width, height, 680 << 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
convert_surface();
|
||||
|
||||
const uint16_t *ptr = conv_buf;
|
||||
if (width == 340)
|
||||
{
|
||||
ptr += 10;
|
||||
width = 320;
|
||||
}
|
||||
else if (width == 680)
|
||||
{
|
||||
ptr += 20;
|
||||
width = 640;
|
||||
}
|
||||
|
||||
video_cb(ptr, width, height, 680 << 1);
|
||||
}
|
||||
|
||||
audio_batch_cb(spec.SoundBuf, spec.SoundBufSize);
|
||||
}
|
||||
@ -212,11 +251,11 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
// Just assume NTSC for now. TODO: Verify FPS.
|
||||
info->timing.fps = 59.97;
|
||||
info->timing.fps = 59.94;
|
||||
info->timing.sample_rate = 44100;
|
||||
info->geometry.base_width = game->nominal_width;
|
||||
info->geometry.base_height = game->nominal_height;
|
||||
info->geometry.max_width = 680;
|
||||
info->geometry.base_width = 320;
|
||||
info->geometry.base_height = 240;
|
||||
info->geometry.max_width = 640;
|
||||
info->geometry.max_height = 480;
|
||||
info->geometry.aspect_ratio = 4.0 / 3.0;
|
||||
}
|
||||
|
14
libretro.h
14
libretro.h
@ -150,7 +150,19 @@ extern "C" {
|
||||
// The returned value can be NULL.
|
||||
// If so, no such directory is defined,
|
||||
// and it's up to the implementation to find a suitable directory.
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10
|
||||
// const enum retro_pixel_format * --
|
||||
// Sets the internal pixel format used by the implementation.
|
||||
// The default pixel format is RETRO_PIXEL_FORMAT_XRGB1555.
|
||||
// If the call returns false, the frontend does not support this pixel format.
|
||||
// This function should be called inside retro_load_game() or retro_get_system_av_info().
|
||||
|
||||
enum retro_pixel_format
|
||||
{
|
||||
RETRO_PIXEL_FORMAT_0RGB1555 = 0, // 0RGB1555, native endian. 0 bit must be set to 0.
|
||||
RETRO_PIXEL_FORMAT_XRGB8888 // XRGB8888, native endian. X bits are ignored.
|
||||
};
|
||||
|
||||
struct retro_message
|
||||
{
|
||||
@ -225,7 +237,7 @@ struct retro_game_info
|
||||
// Environment callback. Gives implementations a way of performing uncommon tasks. Extensible.
|
||||
typedef bool (*retro_environment_t)(unsigned cmd, void *data);
|
||||
|
||||
// Render a frame. Pixel format is 15-bit XRGB1555 native endian.
|
||||
// Render a frame. Pixel format is 15-bit 0RGB1555 native endian unless changed (see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT).
|
||||
// Width and height specify dimensions of buffer.
|
||||
// Pitch specifices length in bytes between two lines in buffer.
|
||||
typedef void (*retro_video_refresh_t)(const void *data, unsigned width, unsigned height, size_t pitch);
|
||||
|
Loading…
Reference in New Issue
Block a user