mirror of
https://github.com/libretro/beetle-psx-libretro.git
synced 2024-11-23 16:59:49 +00:00
Create rsx_lib_soft
This commit is contained in:
parent
35a74f0936
commit
40e9d04a71
@ -153,6 +153,7 @@ SOURCES_CXX += \
|
||||
SOURCES_C += \
|
||||
$(MEDNAFEN_DIR)/file.c \
|
||||
$(CORE_DIR)/rsx/rsx_intf.c \
|
||||
$(CORE_DIR)/rsx/rsx_lib_soft.c \
|
||||
$(MEDNAFEN_DIR)/md5.c \
|
||||
$(MEDNAFEN_DIR)/mednafen-endian.c
|
||||
|
||||
|
@ -5,14 +5,11 @@
|
||||
#include <boolean.h>
|
||||
|
||||
#include "rsx_intf.h"
|
||||
#ifdef HAVE_RUST
|
||||
#include "rsx.h"
|
||||
#endif
|
||||
#ifdef HAVE_OPENGL
|
||||
#include "rsx_lib_gl.h"
|
||||
#endif
|
||||
uint8_t psx_gpu_upscale_shift;
|
||||
uint8_t widescreen_hack;
|
||||
#include "rsx_lib_soft.h"
|
||||
|
||||
static enum rsx_renderer_type rsx_type =
|
||||
#ifdef HAVE_RUST
|
||||
@ -21,16 +18,13 @@ RSX_EXTERNAL_RUST
|
||||
RSX_SOFTWARE
|
||||
#endif
|
||||
;
|
||||
static bool rsx_is_pal = false;
|
||||
static retro_video_refresh_t rsx_video_cb;
|
||||
static retro_environment_t rsx_environ_cb;
|
||||
|
||||
void rsx_intf_set_environment(retro_environment_t cb)
|
||||
{
|
||||
switch (rsx_type)
|
||||
{
|
||||
case RSX_SOFTWARE:
|
||||
rsx_environ_cb = cb;
|
||||
rsx_soft_set_environment(cb);
|
||||
break;
|
||||
case RSX_OPENGL:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
@ -50,7 +44,7 @@ void rsx_intf_set_video_refresh(retro_video_refresh_t cb)
|
||||
switch (rsx_type)
|
||||
{
|
||||
case RSX_SOFTWARE:
|
||||
rsx_video_cb = cb;
|
||||
rsx_soft_set_video_refresh(cb);
|
||||
break;
|
||||
case RSX_OPENGL:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
@ -65,24 +59,12 @@ void rsx_intf_set_video_refresh(retro_video_refresh_t cb)
|
||||
}
|
||||
}
|
||||
|
||||
static float video_output_framerate(void)
|
||||
{
|
||||
return rsx_is_pal ? 49.842 : 59.941;
|
||||
}
|
||||
|
||||
void rsx_intf_get_system_av_info(struct retro_system_av_info *info)
|
||||
{
|
||||
switch (rsx_type)
|
||||
{
|
||||
case RSX_SOFTWARE:
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->timing.fps = video_output_framerate();
|
||||
info->timing.sample_rate = 44100;
|
||||
info->geometry.base_width = MEDNAFEN_CORE_GEOMETRY_BASE_W << psx_gpu_upscale_shift;
|
||||
info->geometry.base_height = MEDNAFEN_CORE_GEOMETRY_BASE_H << psx_gpu_upscale_shift;
|
||||
info->geometry.max_width = MEDNAFEN_CORE_GEOMETRY_MAX_W << psx_gpu_upscale_shift;
|
||||
info->geometry.max_height = MEDNAFEN_CORE_GEOMETRY_MAX_H << psx_gpu_upscale_shift;
|
||||
info->geometry.aspect_ratio = !widescreen_hack ? MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO : (float)16/9;
|
||||
rsx_soft_get_system_av_info(info);
|
||||
break;
|
||||
case RSX_OPENGL:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
@ -128,19 +110,19 @@ bool rsx_intf_open(bool is_pal)
|
||||
switch (rsx_type)
|
||||
{
|
||||
case RSX_SOFTWARE:
|
||||
rsx_is_pal = is_pal;
|
||||
if (!rsx_soft_open(is_pal))
|
||||
return false;
|
||||
break;
|
||||
case RSX_OPENGL:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
if (!rsx_gl_open(is_pal))
|
||||
return false;
|
||||
rsx_type = RSX_OPENGL;
|
||||
rsx_is_pal = is_pal;
|
||||
#endif
|
||||
break;
|
||||
case RSX_EXTERNAL_RUST:
|
||||
#ifdef HAVE_RUST
|
||||
rsx_open(is_pal);
|
||||
if (!rsx_open(is_pal))
|
||||
return false;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@ -212,7 +194,7 @@ void rsx_intf_finalize_frame(const void *fb, unsigned width,
|
||||
switch (rsx_type)
|
||||
{
|
||||
case RSX_SOFTWARE:
|
||||
rsx_video_cb(fb, width, height, pitch);
|
||||
rsx_soft_finalize_frame(fb, width, height, pitch);
|
||||
break;
|
||||
case RSX_OPENGL:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
|
55
rsx/rsx_lib_soft.c
Normal file
55
rsx/rsx_lib_soft.c
Normal file
@ -0,0 +1,55 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <boolean.h>
|
||||
|
||||
#include "rsx.h"
|
||||
#include "rsx_intf.h"
|
||||
|
||||
static bool rsx_is_pal = false;
|
||||
uint8_t widescreen_hack;
|
||||
uint8_t psx_gpu_upscale_shift;
|
||||
|
||||
static retro_environment_t rsx_environ_cb;
|
||||
static retro_video_refresh_t rsx_video_cb;
|
||||
|
||||
static float video_output_framerate(void)
|
||||
{
|
||||
return rsx_is_pal ? 49.842 : 59.941;
|
||||
}
|
||||
|
||||
bool rsx_soft_open(bool is_pal)
|
||||
{
|
||||
rsx_is_pal = is_pal;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void rsx_soft_get_system_av_info(struct retro_system_av_info *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->timing.fps = video_output_framerate();
|
||||
info->timing.sample_rate = 44100;
|
||||
info->geometry.base_width = MEDNAFEN_CORE_GEOMETRY_BASE_W << psx_gpu_upscale_shift;
|
||||
info->geometry.base_height = MEDNAFEN_CORE_GEOMETRY_BASE_H << psx_gpu_upscale_shift;
|
||||
info->geometry.max_width = MEDNAFEN_CORE_GEOMETRY_MAX_W << psx_gpu_upscale_shift;
|
||||
info->geometry.max_height = MEDNAFEN_CORE_GEOMETRY_MAX_H << psx_gpu_upscale_shift;
|
||||
info->geometry.aspect_ratio = !widescreen_hack ? MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO : (float)16/9;
|
||||
}
|
||||
|
||||
void rsx_soft_set_environment(retro_environment_t callback)
|
||||
{
|
||||
rsx_environ_cb = callback;
|
||||
}
|
||||
|
||||
void rsx_soft_set_video_refresh(retro_video_refresh_t callback)
|
||||
{
|
||||
rsx_video_cb = callback;
|
||||
}
|
||||
|
||||
void rsx_soft_finalize_frame(const void *fb, unsigned width,
|
||||
unsigned height, unsigned pitch)
|
||||
{
|
||||
rsx_video_cb(fb, width, height, pitch);
|
||||
}
|
68
rsx/rsx_lib_soft.h
Normal file
68
rsx/rsx_lib_soft.h
Normal file
@ -0,0 +1,68 @@
|
||||
#ifndef __RSX_SOFT_H__
|
||||
#define __RSX_SOFT_H__
|
||||
|
||||
#include "libretro.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void rsx_soft_set_environment(retro_environment_t);
|
||||
void rsx_soft_set_video_refresh(retro_video_refresh_t);
|
||||
void rsx_soft_get_system_av_info(struct retro_system_av_info *);
|
||||
|
||||
void rsx_soft_init(void);
|
||||
bool rsx_soft_open(bool is_pal);
|
||||
void rsx_soft_close(void);
|
||||
void rsx_soft_refresh_variables(void);
|
||||
void rsx_soft_prepare_frame(void);
|
||||
void rsx_soft_finalize_frame(const void *fb, unsigned width,
|
||||
unsigned height, unsigned pitch);
|
||||
|
||||
void rsx_soft_set_draw_offset(int16_t x, int16_t y);
|
||||
void rsx_soft_set_draw_area(uint16_t x, uint16_t y,
|
||||
uint16_t w, uint16_t h);
|
||||
void rsx_soft_set_display_mode(uint16_t x, uint16_t y,
|
||||
uint16_t w, uint16_t h,
|
||||
bool depth_24bpp);
|
||||
|
||||
void rsx_soft_push_triangle(int16_t p0x, int16_t p0y,
|
||||
int16_t p1x, int16_t p1y,
|
||||
int16_t p2x, int16_t p2y,
|
||||
uint32_t c0,
|
||||
uint32_t c1,
|
||||
uint32_t c2,
|
||||
uint16_t t0x, uint16_t t0y,
|
||||
uint16_t t1x, uint16_t t1y,
|
||||
uint16_t t2x, uint16_t t2y,
|
||||
uint16_t texpage_x, uint16_t texpage_y,
|
||||
uint16_t clut_x, uint16_t clut_y,
|
||||
uint8_t texture_blend_mode,
|
||||
uint8_t depth_shift,
|
||||
bool dither);
|
||||
|
||||
void rsx_soft_push_line(int16_t p0x, int16_t p0y,
|
||||
int16_t p1x, int16_t p1y,
|
||||
uint32_t c0,
|
||||
uint32_t c1,
|
||||
bool dither);
|
||||
|
||||
void rsx_soft_load_image(uint16_t x, uint16_t y,
|
||||
uint16_t w, uint16_t h,
|
||||
uint16_t *vram);
|
||||
|
||||
void rsx_soft_fill_rect(uint32_t color,
|
||||
uint16_t x, uint16_t y,
|
||||
uint16_t w, uint16_t h);
|
||||
|
||||
void rsx_soft_copy_rect(uint16_t src_x, uint16_t src_y,
|
||||
uint16_t dst_x, uint16_t dst_y,
|
||||
uint16_t w, uint16_t h);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*__RSX_SOFT_H__ */
|
Loading…
Reference in New Issue
Block a user