platform, improve 32x handling for h32 (all supported platforms)

This commit is contained in:
kub 2021-11-23 21:49:34 +01:00
parent 52e4a905c8
commit 1bbe9abf75
4 changed files with 39 additions and 33 deletions

View file

@ -350,6 +350,7 @@ void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode)
} }
// always need upscaling for H32, before mixing in 32X layer // always need upscaling for H32, before mixing in 32X layer
PicoIn.opt |= POPT_EN_SOFTSCALE; PicoIn.opt |= POPT_EN_SOFTSCALE;
PicoIn.opt &= ~POPT_DIS_32C_BORDER;
if (use_32x_line_mode) if (use_32x_line_mode)
// we'll draw via FinalizeLine32xRGB555 (rare) // we'll draw via FinalizeLine32xRGB555 (rare)

View file

@ -501,9 +501,13 @@ static void vid_reset_mode(void)
int gp2x_mode = 16; int gp2x_mode = 16;
int renderer = get_renderer(); int renderer = get_renderer();
PicoIn.opt &= ~POPT_ALT_RENDERER; PicoIn.opt &= ~(POPT_ALT_RENDERER|POPT_DIS_32C_BORDER|POPT_EN_SOFTSCALE);
emu_scan_begin = NULL; if (currentConfig.scaling == EOPT_SCALE_SW) {
emu_scan_end = NULL; PicoIn.opt |= POPT_EN_SOFTSCALE;
PicoIn.filter = EOPT_FILTER_BILINEAR2;
} else if (currentConfig.scaling == EOPT_SCALE_HW)
// hw scaling, render without any padding
PicoIn.opt |= POPT_DIS_32C_BORDER;
switch (renderer) { switch (renderer) {
case RT_16BIT: case RT_16BIT:
@ -535,6 +539,9 @@ static void vid_reset_mode(void)
gp2x_mode = 16; gp2x_mode = 16;
} }
emu_scan_begin = NULL;
emu_scan_end = NULL;
if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) { if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {
if ((PicoIn.AHW & PAHW_32X) || renderer == RT_16BIT) { if ((PicoIn.AHW & PAHW_32X) || renderer == RT_16BIT) {
emu_scan_begin = EmuScanBegin16_rot; emu_scan_begin = EmuScanBegin16_rot;
@ -572,14 +579,6 @@ static void vid_reset_mode(void)
Pico.m.dirtyPal = 1; Pico.m.dirtyPal = 1;
PicoIn.opt &= ~(POPT_DIS_32C_BORDER|POPT_EN_SOFTSCALE);
if (currentConfig.scaling == EOPT_SCALE_SW) {
PicoIn.opt |= POPT_EN_SOFTSCALE;
PicoIn.filter = EOPT_FILTER_BILINEAR2;
} else if (currentConfig.scaling == EOPT_SCALE_HW)
// hw scaling, render without any padding
PicoIn.opt |= POPT_DIS_32C_BORDER;
// palette converters for 8bit modes // palette converters for 8bit modes
make_local_pal = (PicoIn.AHW & PAHW_SMS) ? make_local_pal_sms : make_local_pal_md; make_local_pal = (PicoIn.AHW & PAHW_SMS) ? make_local_pal_sms : make_local_pal_md;
} }

View file

@ -43,6 +43,7 @@
#else #else
#include <platform/common/upscale.h> #include <platform/common/upscale.h>
#endif #endif
#include <platform/common/emu.h>
#ifdef _3DS #ifdef _3DS
#include "3ds/3ds_utils.h" #include "3ds/3ds_utils.h"
@ -619,6 +620,17 @@ int plat_mem_set_exec(void *ptr, size_t size)
return ret; return ret;
} }
static void apply_renderer()
{
PicoIn.opt &= ~(POPT_ALT_RENDERER|POPT_EN_SOFTSCALE);
PicoIn.opt |= POPT_DIS_32C_BORDER;
if (vout_format == PDF_NONE)
PicoIn.opt |= POPT_ALT_RENDERER;
PicoDrawSetOutFormat(vout_format, 0);
if (!vout_16bit && vout_format == PDF_8BIT)
PicoDrawSetOutBuf(Pico.est.Draw2FB, 328);
}
void emu_video_mode_change(int start_line, int line_count, int start_col, int col_count) void emu_video_mode_change(int start_line, int line_count, int start_col, int col_count)
{ {
struct retro_system_av_info av_info; struct retro_system_av_info av_info;
@ -629,8 +641,6 @@ void emu_video_mode_change(int start_line, int line_count, int start_col, int co
vm_current_col_count = col_count; vm_current_col_count = col_count;
// 8bit renderes create a 328x256 CLUT image, while 16bit creates 320x240 RGB // 8bit renderes create a 328x256 CLUT image, while 16bit creates 320x240 RGB
vout_16bit = vout_format == PDF_RGB555 || (PicoIn.AHW & PAHW_32X);
#if defined(RENDER_GSKIT_PS2) #if defined(RENDER_GSKIT_PS2)
// calculate the borders of the real image inside the picodrive image // calculate the borders of the real image inside the picodrive image
vout_width = (vout_16bit ? VOUT_MAX_WIDTH : VOUT_8BIT_WIDTH); vout_width = (vout_16bit ? VOUT_MAX_WIDTH : VOUT_8BIT_WIDTH);
@ -680,7 +690,10 @@ void emu_video_mode_change(int start_line, int line_count, int start_col, int co
void emu_32x_startup(void) void emu_32x_startup(void)
{ {
PicoIn.filter = EOPT_FILTER_SMOOTHER; // for H32 upscaling
PicoDrawSetOutFormat(vout_format, 0); PicoDrawSetOutFormat(vout_format, 0);
vout_16bit = 1;
if ((vm_current_start_line != -1) && if ((vm_current_start_line != -1) &&
(vm_current_line_count != -1) && (vm_current_line_count != -1) &&
(vm_current_start_col != -1) && (vm_current_start_col != -1) &&
@ -1302,9 +1315,7 @@ bool retro_load_game(const struct retro_game_info *info)
PicoIn.sndOut = sndBuffer; PicoIn.sndOut = sndBuffer;
PsndRerate(0); PsndRerate(0);
PicoDrawSetOutFormat(vout_format, 0); apply_renderer();
if (vout_format == PDF_8BIT)
PicoDrawSetOutBuf(Pico.est.Draw2FB, 328);
/* Setup retro memory maps */ /* Setup retro memory maps */
set_memory_maps(); set_memory_maps();
@ -1651,13 +1662,9 @@ static void update_variables(bool first_run)
vout_format = PDF_8BIT; vout_format = PDF_8BIT;
else if (strcmp(var.value, "accurate") == 0) else if (strcmp(var.value, "accurate") == 0)
vout_format = PDF_RGB555; vout_format = PDF_RGB555;
vout_16bit = vout_format == PDF_RGB555 || (PicoIn.AHW & PAHW_32X);
PicoIn.opt &= ~POPT_ALT_RENDERER; apply_renderer();
if (vout_format == PDF_NONE)
PicoIn.opt |= POPT_ALT_RENDERER;
PicoDrawSetOutFormat(vout_format, 0);
if (vout_format == PDF_8BIT)
PicoDrawSetOutBuf(Pico.est.Draw2FB, 328);
} }
var.value = NULL; var.value = NULL;

View file

@ -202,6 +202,15 @@ void plat_video_set_buffer(void *buf)
static void apply_renderer(void) static void apply_renderer(void)
{ {
PicoIn.opt &= ~(POPT_ALT_RENDERER|POPT_EN_SOFTSCALE|POPT_DIS_32C_BORDER); PicoIn.opt &= ~(POPT_ALT_RENDERER|POPT_EN_SOFTSCALE|POPT_DIS_32C_BORDER);
if (is_16bit_mode()) {
if (currentConfig.scaling == EOPT_SCALE_SW) {
PicoIn.opt |= POPT_EN_SOFTSCALE;
PicoIn.filter = currentConfig.filter;
} else if (currentConfig.scaling == EOPT_SCALE_HW)
// hw scaling, render without any padding
PicoIn.opt |= POPT_DIS_32C_BORDER;
} else
PicoIn.opt |= POPT_DIS_32C_BORDER;
switch (get_renderer()) { switch (get_renderer()) {
case RT_16BIT: case RT_16BIT:
@ -226,16 +235,6 @@ static void apply_renderer(void)
if (PicoIn.AHW & PAHW_32X) if (PicoIn.AHW & PAHW_32X)
PicoDrawSetOutBuf(screen_buffer(g_screen_ptr), g_screen_ppitch * 2); PicoDrawSetOutBuf(screen_buffer(g_screen_ptr), g_screen_ppitch * 2);
if (is_16bit_mode()) {
if (currentConfig.scaling == EOPT_SCALE_SW) {
PicoIn.opt |= POPT_EN_SOFTSCALE;
PicoIn.filter = currentConfig.filter;
} else if (currentConfig.scaling == EOPT_SCALE_HW)
// hw scaling, render without any padding
PicoIn.opt |= POPT_DIS_32C_BORDER;
} else
PicoIn.opt |= POPT_DIS_32C_BORDER;
Pico.m.dirtyPal = 1; Pico.m.dirtyPal = 1;
} }
@ -389,7 +388,7 @@ void emu_video_mode_change(int start_line, int line_count, int start_col, int co
PicoDrawSetCallbacks(cb_vscaling_begin,cb_vscaling_nop); PicoDrawSetCallbacks(cb_vscaling_begin,cb_vscaling_nop);
break; break;
case EOPT_SCALE_SW: case EOPT_SCALE_SW:
screen_y = (screen_h - 240)/2; screen_y = (screen_h - 240)/2 + (out_h > 144);
// NTSC always has 224 visible lines, anything smaller has bars // NTSC always has 224 visible lines, anything smaller has bars
if (out_h < 224 && out_h > 144) if (out_h < 224 && out_h > 144)
screen_y += (224 - out_h)/2; screen_y += (224 - out_h)/2;