2018-09-18 08:08:06 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2018-11-11 17:14:06 +01:00
|
|
|
* Copyright (C) 2018 - Francisco Javier Trujillo Mata - fjtrujy
|
2018-09-18 08:08:06 +02:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-17 15:10:22 +02:00
|
|
|
#include <kernel.h>
|
|
|
|
#include <gsKit.h>
|
|
|
|
#include <gsInline.h>
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2018-10-09 19:20:58 +02:00
|
|
|
#include "../../driver.h"
|
2019-06-17 15:10:22 +02:00
|
|
|
#include "../../retroarch.h"
|
2018-10-09 19:20:58 +02:00
|
|
|
#include "../../verbosity.h"
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2019-01-15 01:08:28 +01:00
|
|
|
#include "../../libretro-common/include/libretro_gskit_ps2.h"
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
/* turn white GS Screen */
|
|
|
|
#define GS_TEXT GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00)
|
|
|
|
/* turn white GS Screen */
|
|
|
|
#define GS_BLACK GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00)
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
#define NTSC_WIDTH 640
|
2019-01-03 12:41:29 +01:00
|
|
|
#define NTSC_HEIGHT 448
|
|
|
|
|
2018-10-09 19:20:58 +02:00
|
|
|
typedef struct ps2_video
|
2018-09-18 08:08:06 +02:00
|
|
|
{
|
2018-10-09 19:20:58 +02:00
|
|
|
GSGLOBAL *gsGlobal;
|
2018-10-31 19:45:43 +01:00
|
|
|
GSTEXTURE *menuTexture;
|
|
|
|
GSTEXTURE *coreTexture;
|
2019-01-10 00:44:41 +01:00
|
|
|
bool clearVRAM;
|
2020-02-14 13:06:56 +01:00
|
|
|
/* I need to create this additional field
|
|
|
|
* to be used in the font driver*/
|
|
|
|
bool clearVRAM_font;
|
|
|
|
/* Palette in the cores */
|
|
|
|
struct retro_hw_render_interface_gskit_ps2 iface;
|
2019-02-03 15:49:35 -08:00
|
|
|
|
2018-10-31 19:45:43 +01:00
|
|
|
bool menuVisible;
|
2018-11-01 14:36:59 +01:00
|
|
|
bool fullscreen;
|
2018-11-01 11:35:30 +01:00
|
|
|
|
2019-01-13 16:30:15 +01:00
|
|
|
bool vsync;
|
|
|
|
|
|
|
|
int PSM;
|
2018-11-01 17:26:27 +01:00
|
|
|
bool force_aspect;
|
2018-11-01 14:27:15 +01:00
|
|
|
int menu_filter;
|
|
|
|
int core_filter;
|
2018-10-09 19:20:58 +02:00
|
|
|
} ps2_video_t;
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
/* PRIVATE METHODS */
|
2019-01-10 09:37:09 +01:00
|
|
|
static GSGLOBAL *init_GSGlobal(void)
|
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
GSGLOBAL *gsGlobal = gsKit_init_global();
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
gsGlobal->Mode = GS_MODE_NTSC;
|
|
|
|
gsGlobal->Interlace = GS_INTERLACED;
|
|
|
|
gsGlobal->Field = GS_FIELD;
|
|
|
|
gsGlobal->Width = NTSC_WIDTH;
|
|
|
|
gsGlobal->Height = NTSC_HEIGHT;
|
2019-02-03 15:49:35 -08:00
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
gsGlobal->PSM = GS_PSM_CT16;
|
|
|
|
gsGlobal->PSMZ = GS_PSMZ_16;
|
2019-01-07 00:25:45 +01:00
|
|
|
gsGlobal->DoubleBuffering = GS_SETTING_OFF;
|
2020-02-14 13:06:56 +01:00
|
|
|
gsGlobal->ZBuffering = GS_SETTING_OFF;
|
2019-01-03 11:50:24 +01:00
|
|
|
gsGlobal->PrimAlphaEnable = GS_SETTING_OFF;
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2019-02-03 15:49:35 -08:00
|
|
|
dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
|
2019-01-07 00:25:45 +01:00
|
|
|
D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2019-01-07 00:25:45 +01:00
|
|
|
/* Initialize the DMAC */
|
|
|
|
dmaKit_chan_init(DMA_CHANNEL_GIF);
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2019-01-07 00:25:45 +01:00
|
|
|
gsKit_init_screen(gsGlobal);
|
|
|
|
gsKit_mode_switch(gsGlobal, GS_ONESHOT);
|
2019-01-11 14:42:47 +01:00
|
|
|
gsKit_clear(gsGlobal, GS_BLACK);
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2019-01-07 00:25:45 +01:00
|
|
|
return gsGlobal;
|
2018-10-09 19:20:58 +02:00
|
|
|
}
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2019-01-10 09:37:09 +01:00
|
|
|
static GSTEXTURE * prepare_new_texture(void)
|
|
|
|
{
|
2019-01-07 00:25:45 +01:00
|
|
|
GSTEXTURE *texture = calloc(1, sizeof(*texture));
|
|
|
|
return texture;
|
2018-11-09 21:11:59 +01:00
|
|
|
}
|
|
|
|
|
2019-01-10 09:37:09 +01:00
|
|
|
static void init_ps2_video(ps2_video_t *ps2)
|
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
ps2->gsGlobal = init_GSGlobal();
|
2018-11-09 21:11:59 +01:00
|
|
|
ps2->menuTexture = prepare_new_texture();
|
|
|
|
ps2->coreTexture = prepare_new_texture();
|
2019-01-15 01:08:28 +01:00
|
|
|
|
|
|
|
/* Used for cores that supports palette */
|
2020-02-14 13:06:56 +01:00
|
|
|
ps2->iface.interface_type = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2;
|
2019-01-15 01:08:28 +01:00
|
|
|
ps2->iface.interface_version = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION;
|
2020-02-14 13:06:56 +01:00
|
|
|
ps2->iface.coreTexture = ps2->coreTexture;
|
2018-10-09 19:20:58 +02:00
|
|
|
}
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2019-01-10 09:37:09 +01:00
|
|
|
static void deinitTexture(GSTEXTURE *texture)
|
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
texture->Mem = NULL;
|
2018-11-01 13:56:35 +01:00
|
|
|
texture->Clut = NULL;
|
2018-10-09 19:20:58 +02:00
|
|
|
}
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
static bool texture_need_prepare(GSTEXTURE *texture,
|
|
|
|
int width, int height, int PSM)
|
2019-01-10 09:37:09 +01:00
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
return texture->Width != width ||
|
|
|
|
texture->Height != height ||
|
|
|
|
texture->PSM != PSM;
|
2019-01-10 00:44:41 +01:00
|
|
|
}
|
|
|
|
|
2019-02-03 15:49:35 -08:00
|
|
|
static void transfer_texture(GSTEXTURE *texture, const void *frame,
|
2019-01-13 16:30:15 +01:00
|
|
|
int width, int height, int PSM, int filter, bool color_correction)
|
2019-01-10 09:37:09 +01:00
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
texture->Width = width;
|
2019-01-13 16:30:15 +01:00
|
|
|
texture->Height = height;
|
2020-02-14 13:06:56 +01:00
|
|
|
texture->PSM = PSM;
|
2019-01-13 16:30:15 +01:00
|
|
|
texture->Filter = filter;
|
2020-02-14 13:06:56 +01:00
|
|
|
texture->Mem = (void *)frame;
|
2018-11-01 11:35:30 +01:00
|
|
|
}
|
|
|
|
|
2019-01-10 09:37:09 +01:00
|
|
|
static void vram_alloc(GSGLOBAL *gsGlobal, GSTEXTURE *texture)
|
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
uint32_t size = gsKit_texture_size(texture->Width,
|
|
|
|
texture->Height, texture->PSM);
|
2019-01-07 00:25:45 +01:00
|
|
|
texture->Vram = gsKit_vram_alloc(gsGlobal, size, GSKIT_ALLOC_USERBUFFER);
|
2020-02-14 13:06:56 +01:00
|
|
|
|
|
|
|
if(texture->Vram == GSKIT_ALLOC_ERROR)
|
|
|
|
{
|
2018-11-01 13:56:35 +01:00
|
|
|
printf("VRAM Allocation Failed. Will not upload texture.\n");
|
|
|
|
}
|
2019-01-15 01:08:28 +01:00
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
if (texture->Clut)
|
|
|
|
{
|
2019-01-15 01:08:28 +01:00
|
|
|
/* Right now just supporting 16 x 16 = 256 colours */
|
2020-02-14 13:06:56 +01:00
|
|
|
size = gsKit_texture_size(16, 16, texture->ClutPSM);
|
2019-01-15 01:08:28 +01:00
|
|
|
texture->VramClut = gsKit_vram_alloc(gsGlobal, size , GSKIT_ALLOC_USERBUFFER);
|
|
|
|
}
|
2018-11-01 13:56:35 +01:00
|
|
|
}
|
|
|
|
|
2019-02-16 20:28:33 +01:00
|
|
|
static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition, bool force_aspect, struct retro_hw_ps2_insets padding)
|
2019-01-10 09:37:09 +01:00
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
float x1, y1, x2, y2;
|
|
|
|
float visible_width = texture->Width - padding.left - padding.right;
|
|
|
|
float visible_height = texture->Height - padding.top - padding.bottom;
|
|
|
|
|
|
|
|
if (force_aspect)
|
|
|
|
{
|
|
|
|
float width_proportion = (float)gsGlobal->Width / (float)visible_width;
|
2019-02-16 20:28:33 +01:00
|
|
|
float height_proportion = (float)gsGlobal->Height / (float)visible_height;
|
2020-02-14 13:06:56 +01:00
|
|
|
float delta = MIN(width_proportion, height_proportion);
|
|
|
|
float newWidth = visible_width * delta;
|
|
|
|
float newHeight = visible_height * delta;
|
2019-02-03 15:49:35 -08:00
|
|
|
|
2019-01-07 00:25:45 +01:00
|
|
|
x1 = (gsGlobal->Width - newWidth) / 2.0f;
|
|
|
|
y1 = (gsGlobal->Height - newHeight) / 2.0f;
|
|
|
|
x2 = newWidth + x1;
|
|
|
|
y2 = newHeight + y1;
|
2020-02-14 13:06:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-07 00:25:45 +01:00
|
|
|
x1 = 0.0f;
|
|
|
|
y1 = 0.0f;
|
|
|
|
x2 = gsGlobal->Width;
|
|
|
|
y2 = gsGlobal->Height;
|
|
|
|
}
|
2018-11-01 17:26:27 +01:00
|
|
|
|
2018-11-01 13:56:35 +01:00
|
|
|
gsKit_prim_sprite_texture( gsGlobal, texture,
|
2020-02-14 13:06:56 +01:00
|
|
|
x1, /* X1 */
|
|
|
|
y1, /* Y1 */
|
|
|
|
padding.left, /* U1 */
|
|
|
|
padding.top, /* V1 */
|
|
|
|
x2, /* X2 */
|
|
|
|
y2, /* Y2 */
|
|
|
|
texture->Width - padding.right, /* U2 */
|
|
|
|
texture->Height - padding.bottom, /* V2 */
|
|
|
|
zPosition,
|
|
|
|
GS_TEXT);
|
2018-11-01 13:56:35 +01:00
|
|
|
}
|
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
static void clearVRAMIfNeeded(ps2_video_t *ps2,
|
|
|
|
const void *frame, int width, int height)
|
2019-01-10 09:37:09 +01:00
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
if (!ps2->clearVRAM)
|
|
|
|
{
|
|
|
|
if(frame && frame != RETRO_HW_FRAME_BUFFER_VALID)
|
|
|
|
{
|
|
|
|
bool coreVRAMClear = texture_need_prepare(
|
|
|
|
ps2->coreTexture, width, height, ps2->PSM);
|
2019-01-13 16:30:15 +01:00
|
|
|
ps2->clearVRAM = ps2->clearVRAM || coreVRAMClear;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
if (ps2->clearVRAM)
|
|
|
|
{
|
2019-01-10 00:44:41 +01:00
|
|
|
gsKit_vram_clear(ps2->gsGlobal);
|
2019-02-22 00:01:36 +01:00
|
|
|
ps2->iface.updatedPalette = true;
|
2020-02-14 13:06:56 +01:00
|
|
|
/* we need to upload also palette in the font driver */
|
|
|
|
ps2->clearVRAM_font = true;
|
2019-01-10 00:44:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-10 09:37:09 +01:00
|
|
|
static void refreshScreen(ps2_video_t *ps2)
|
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
if (ps2->vsync)
|
|
|
|
{
|
2019-01-13 16:30:15 +01:00
|
|
|
gsKit_sync_flip(ps2->gsGlobal);
|
|
|
|
}
|
2019-01-10 00:44:41 +01:00
|
|
|
gsKit_queue_exec(ps2->gsGlobal);
|
|
|
|
|
2019-02-26 21:02:29 +01:00
|
|
|
/* Here we are just puting in false the ps2->clearVRAM field
|
|
|
|
however, the ps2->clearVRAM_font should be done in the ps2_font driver */
|
2019-01-10 00:44:41 +01:00
|
|
|
ps2->clearVRAM = false;
|
|
|
|
}
|
2019-02-16 20:28:33 +01:00
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
static void ps2_texture_upload(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
|
|
|
|
bool sendPalette)
|
2019-02-16 20:28:33 +01:00
|
|
|
{
|
|
|
|
gsKit_setup_tbw(Texture);
|
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
if (Texture->PSM == GS_PSM_T8)
|
|
|
|
{
|
2019-02-16 20:28:33 +01:00
|
|
|
gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE);
|
2020-02-14 13:06:56 +01:00
|
|
|
if (sendPalette)
|
|
|
|
{
|
2019-02-16 20:28:33 +01:00
|
|
|
gsKit_texture_send(Texture->Clut, 16, 16, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE);
|
|
|
|
}
|
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
}
|
|
|
|
else if (Texture->PSM == GS_PSM_T4)
|
|
|
|
{
|
2019-02-16 20:28:33 +01:00
|
|
|
gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE);
|
2020-02-14 13:06:56 +01:00
|
|
|
if (sendPalette)
|
|
|
|
{
|
2019-02-16 20:28:33 +01:00
|
|
|
gsKit_texture_send(Texture->Clut, 8, 2, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE);
|
|
|
|
}
|
2020-02-14 13:06:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-16 20:28:33 +01:00
|
|
|
gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_NONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-09 19:20:58 +02:00
|
|
|
static void *ps2_gfx_init(const video_info_t *video,
|
2019-07-27 02:21:24 +02:00
|
|
|
input_driver_t **input, void **input_data)
|
2018-10-09 19:20:58 +02:00
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
void *ps2input = NULL;
|
2018-10-09 19:20:58 +02:00
|
|
|
ps2_video_t *ps2 = (ps2_video_t*)calloc(1, sizeof(ps2_video_t));
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
*input_data = NULL;
|
|
|
|
|
2018-10-31 19:45:43 +01:00
|
|
|
if (!ps2)
|
|
|
|
return NULL;
|
|
|
|
|
2018-11-01 13:56:35 +01:00
|
|
|
init_ps2_video(ps2);
|
2020-02-14 13:06:56 +01:00
|
|
|
if (video->font_enable)
|
2020-02-16 21:59:03 +01:00
|
|
|
font_driver_init_osd(ps2,
|
|
|
|
video,
|
|
|
|
false,
|
|
|
|
video->is_threaded,
|
|
|
|
FONT_DRIVER_RENDER_PS2);
|
2020-02-14 13:06:56 +01:00
|
|
|
|
|
|
|
ps2->PSM = (video->rgb32 ? GS_PSM_CT32 : GS_PSM_CT16);
|
|
|
|
ps2->fullscreen = video->fullscreen;
|
|
|
|
ps2->core_filter = video->smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST;
|
2018-11-01 17:26:27 +01:00
|
|
|
ps2->force_aspect = video->force_aspect;
|
2020-02-14 13:06:56 +01:00
|
|
|
ps2->vsync = video->vsync;
|
|
|
|
ps2->clearVRAM = true;
|
2018-11-01 02:36:49 +01:00
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
if (input && input_data)
|
|
|
|
{
|
2018-10-17 19:02:50 +02:00
|
|
|
settings_t *settings = config_get_ptr();
|
2020-02-14 13:06:56 +01:00
|
|
|
ps2input = input_ps2.init(
|
|
|
|
settings->arrays.input_joypad_driver);
|
|
|
|
*input = ps2input ? &input_ps2 : NULL;
|
|
|
|
*input_data = ps2input;
|
2018-10-17 19:02:50 +02:00
|
|
|
}
|
|
|
|
|
2018-09-18 08:08:06 +02:00
|
|
|
return ps2;
|
|
|
|
}
|
|
|
|
|
2018-10-09 19:20:58 +02:00
|
|
|
static bool ps2_gfx_frame(void *data, const void *frame,
|
2018-09-18 08:08:06 +02:00
|
|
|
unsigned width, unsigned height, uint64_t frame_count,
|
|
|
|
unsigned pitch, const char *msg, video_frame_info_t *video_info)
|
|
|
|
{
|
2018-10-10 08:02:13 +02:00
|
|
|
ps2_video_t *ps2 = (ps2_video_t*)data;
|
|
|
|
|
|
|
|
if (!width || !height)
|
|
|
|
return false;
|
|
|
|
|
2019-01-13 16:30:15 +01:00
|
|
|
#if defined(DEBUG)
|
2020-02-14 13:06:56 +01:00
|
|
|
if (frame_count%60==0)
|
|
|
|
{
|
2019-01-07 00:25:45 +01:00
|
|
|
printf("ps2_gfx_frame %lu\n", frame_count);
|
2018-11-01 13:56:35 +01:00
|
|
|
}
|
2019-01-13 16:30:15 +01:00
|
|
|
#endif
|
2019-01-10 00:44:41 +01:00
|
|
|
|
2019-01-13 16:30:15 +01:00
|
|
|
clearVRAMIfNeeded(ps2, frame, width, height);
|
2019-02-21 00:38:56 +01:00
|
|
|
gsKit_clear(ps2->gsGlobal, GS_BLACK);
|
2018-10-31 19:45:43 +01:00
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
if (frame)
|
|
|
|
{
|
2019-02-16 20:28:33 +01:00
|
|
|
bool sendPalette = false;
|
|
|
|
struct retro_hw_ps2_insets padding = empty_ps2_insets;
|
2020-02-14 13:06:56 +01:00
|
|
|
if (frame != RETRO_HW_FRAME_BUFFER_VALID)
|
|
|
|
{
|
|
|
|
/* Checking if the transfer is done in the core */
|
2019-03-03 14:08:12 +01:00
|
|
|
/* calculate proper width based in the pitch */
|
|
|
|
int bytes_per_pixel = (ps2->PSM == GS_PSM_CT32) ? 4 : 2;
|
2020-02-14 13:06:56 +01:00
|
|
|
int real_width = pitch / bytes_per_pixel;
|
|
|
|
|
2019-03-03 14:08:12 +01:00
|
|
|
transfer_texture(ps2->coreTexture, frame, real_width, height, ps2->PSM, ps2->core_filter, 1);
|
2020-02-14 13:06:56 +01:00
|
|
|
|
|
|
|
padding.right = real_width - width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sendPalette = ps2->iface.updatedPalette;
|
2019-02-16 20:28:33 +01:00
|
|
|
ps2->iface.updatedPalette = false;
|
|
|
|
padding = ps2->iface.padding;
|
2020-02-14 13:06:56 +01:00
|
|
|
if (ps2->iface.clearTexture)
|
2019-02-16 20:28:33 +01:00
|
|
|
ps2->iface.clearTexture = false;
|
2019-01-15 01:08:28 +01:00
|
|
|
}
|
2020-02-14 13:06:56 +01:00
|
|
|
|
|
|
|
if(ps2->clearVRAM)
|
2019-01-10 00:44:41 +01:00
|
|
|
vram_alloc(ps2->gsGlobal, ps2->coreTexture);
|
2020-02-14 13:06:56 +01:00
|
|
|
|
2019-02-16 20:28:33 +01:00
|
|
|
ps2_texture_upload(ps2->gsGlobal, ps2->coreTexture, sendPalette);
|
|
|
|
prim_texture(ps2->gsGlobal, ps2->coreTexture, 1, ps2->force_aspect, padding);
|
2018-10-31 19:45:43 +01:00
|
|
|
}
|
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
if (ps2->menuVisible)
|
|
|
|
{
|
2019-01-07 21:49:55 +01:00
|
|
|
bool texture_empty = !ps2->menuTexture->Width || !ps2->menuTexture->Height;
|
2020-02-14 13:06:56 +01:00
|
|
|
if (!texture_empty)
|
|
|
|
{
|
|
|
|
if(ps2->clearVRAM)
|
2019-01-10 00:44:41 +01:00
|
|
|
vram_alloc(ps2->gsGlobal, ps2->menuTexture);
|
2019-01-07 21:49:55 +01:00
|
|
|
gsKit_texture_upload(ps2->gsGlobal, ps2->menuTexture);
|
2019-02-16 20:28:33 +01:00
|
|
|
prim_texture(ps2->gsGlobal, ps2->menuTexture, 2, ps2->fullscreen, empty_ps2_insets);
|
2019-01-07 21:49:55 +01:00
|
|
|
}
|
2020-01-04 16:24:14 +01:00
|
|
|
}
|
|
|
|
else if (video_info->statistics_show)
|
|
|
|
{
|
2019-01-07 21:49:55 +01:00
|
|
|
struct font_params *osd_params = (struct font_params*)
|
|
|
|
&video_info->osd_stat_params;
|
|
|
|
|
2020-01-04 16:24:14 +01:00
|
|
|
if (osd_params)
|
|
|
|
font_driver_render_msg(ps2, video_info, video_info->stat_text,
|
|
|
|
(const struct font_params*)&video_info->osd_stat_params, NULL);
|
2019-01-07 21:49:55 +01:00
|
|
|
}
|
|
|
|
|
2020-01-04 16:24:14 +01:00
|
|
|
if(!string_is_empty(msg))
|
|
|
|
font_driver_render_msg(ps2, video_info, msg, NULL, NULL);
|
2018-10-31 19:45:43 +01:00
|
|
|
|
2019-01-10 00:44:41 +01:00
|
|
|
refreshScreen(ps2);
|
2018-10-10 08:02:13 +02:00
|
|
|
|
2018-09-18 08:08:06 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-16 22:26:07 +01:00
|
|
|
static void ps2_gfx_set_nonblock_state(void *data, bool toggle,
|
|
|
|
bool adaptive_vsync_enabled, unsigned swap_interval)
|
2018-09-18 08:08:06 +02:00
|
|
|
{
|
2019-01-13 16:30:15 +01:00
|
|
|
ps2_video_t *ps2 = (ps2_video_t*)data;
|
|
|
|
|
|
|
|
if (ps2)
|
|
|
|
ps2->vsync = !toggle;
|
2018-09-18 08:08:06 +02:00
|
|
|
}
|
|
|
|
|
2020-02-14 13:06:56 +01:00
|
|
|
static bool ps2_gfx_alive(void *data) { return true; }
|
|
|
|
static bool ps2_gfx_focus(void *data) { return true; }
|
|
|
|
static bool ps2_gfx_suppress_screensaver(void *data, bool enable) { return false; }
|
|
|
|
static bool ps2_gfx_has_windowed(void *data) { return false; }
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2018-10-09 19:20:58 +02:00
|
|
|
static void ps2_gfx_free(void *data)
|
2018-09-18 08:08:06 +02:00
|
|
|
{
|
|
|
|
ps2_video_t *ps2 = (ps2_video_t*)data;
|
|
|
|
|
2018-11-01 17:26:27 +01:00
|
|
|
gsKit_clear(ps2->gsGlobal, GS_BLACK);
|
2018-11-01 13:56:35 +01:00
|
|
|
gsKit_vram_clear(ps2->gsGlobal);
|
2018-10-31 19:45:43 +01:00
|
|
|
|
2019-01-07 21:49:55 +01:00
|
|
|
font_driver_free_osd();
|
|
|
|
|
2018-10-31 19:45:43 +01:00
|
|
|
deinitTexture(ps2->menuTexture);
|
|
|
|
deinitTexture(ps2->coreTexture);
|
2018-11-01 13:56:35 +01:00
|
|
|
|
2019-09-29 22:41:51 +02:00
|
|
|
free(ps2->menuTexture);
|
|
|
|
free(ps2->coreTexture);
|
|
|
|
|
2018-10-09 19:20:58 +02:00
|
|
|
gsKit_deinit_global(ps2->gsGlobal);
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2018-10-09 19:20:58 +02:00
|
|
|
free(data);
|
2018-09-18 08:08:06 +02:00
|
|
|
}
|
|
|
|
|
2018-10-09 19:20:58 +02:00
|
|
|
static bool ps2_gfx_set_shader(void *data,
|
2020-02-14 13:06:56 +01:00
|
|
|
enum rarch_shader_type type, const char *path) { return false; }
|
2018-09-18 08:08:06 +02:00
|
|
|
|
2018-10-10 08:02:13 +02:00
|
|
|
static void ps2_set_filtering(void *data, unsigned index, bool smooth)
|
|
|
|
{
|
|
|
|
ps2_video_t *ps2 = (ps2_video_t*)data;
|
2018-11-01 14:27:15 +01:00
|
|
|
|
|
|
|
ps2->menu_filter = smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST;
|
2018-10-10 08:02:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ps2_set_texture_frame(void *data, const void *frame, bool rgb32,
|
2020-02-14 13:06:56 +01:00
|
|
|
unsigned width, unsigned height, float alpha)
|
2018-10-10 08:02:13 +02:00
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
ps2_video_t *ps2 = (ps2_video_t*)data;
|
2019-02-03 15:49:35 -08:00
|
|
|
|
2019-01-10 00:44:41 +01:00
|
|
|
bool color_correction = false;
|
2020-02-14 13:06:56 +01:00
|
|
|
int PSM = (rgb32 ? GS_PSM_CT32 : GS_PSM_CT16);
|
|
|
|
bool texture_changed = texture_need_prepare(ps2->menuTexture, width, height, PSM);
|
2019-02-03 15:49:35 -08:00
|
|
|
|
2019-01-13 16:30:15 +01:00
|
|
|
transfer_texture(ps2->menuTexture, frame, width, height, PSM, ps2->menu_filter, color_correction);
|
2019-01-13 20:19:21 +01:00
|
|
|
ps2->clearVRAM = ps2->clearVRAM || texture_changed;
|
2018-10-10 08:02:13 +02:00
|
|
|
}
|
|
|
|
|
2018-11-01 14:36:59 +01:00
|
|
|
static void ps2_set_texture_enable(void *data, bool enable, bool fullscreen)
|
2018-10-10 08:02:13 +02:00
|
|
|
{
|
|
|
|
ps2_video_t *ps2 = (ps2_video_t*)data;
|
2020-02-14 13:06:56 +01:00
|
|
|
|
|
|
|
if (ps2->menuVisible != enable)
|
|
|
|
{
|
2019-01-13 20:19:21 +01:00
|
|
|
/* If Menu change status, CLEAR VRAM */
|
2020-02-14 13:06:56 +01:00
|
|
|
ps2->clearVRAM = true;
|
|
|
|
ps2->iface.clearTexture = true;
|
2019-02-21 00:38:56 +01:00
|
|
|
ps2->iface.updatedPalette = true;
|
2019-01-13 20:19:21 +01:00
|
|
|
}
|
2018-10-31 19:45:43 +01:00
|
|
|
ps2->menuVisible = enable;
|
2020-02-14 13:06:56 +01:00
|
|
|
ps2->fullscreen = fullscreen;
|
2018-10-10 08:02:13 +02:00
|
|
|
}
|
|
|
|
|
2019-02-03 15:49:35 -08:00
|
|
|
static bool ps2_get_hw_render_interface(void* data,
|
2019-01-15 01:08:28 +01:00
|
|
|
const struct retro_hw_render_interface** iface)
|
|
|
|
{
|
2020-02-14 13:06:56 +01:00
|
|
|
ps2_video_t *ps2 = (ps2_video_t*)data;
|
|
|
|
ps2->iface.clearTexture = ps2->clearVRAM;
|
2019-02-16 20:28:33 +01:00
|
|
|
ps2->iface.updatedPalette = true;
|
2020-02-14 13:06:56 +01:00
|
|
|
ps2->iface.padding = empty_ps2_insets;
|
|
|
|
*iface =
|
|
|
|
(const struct retro_hw_render_interface*)&ps2->iface;
|
2019-01-15 01:08:28 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-10-10 08:02:13 +02:00
|
|
|
static const video_poke_interface_t ps2_poke_interface = {
|
|
|
|
NULL, /* get_flags */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL, /* get_refresh_rate */
|
|
|
|
ps2_set_filtering,
|
|
|
|
NULL, /* get_video_output_size */
|
|
|
|
NULL, /* get_video_output_prev */
|
|
|
|
NULL, /* get_video_output_next */
|
|
|
|
NULL, /* get_current_framebuffer */
|
|
|
|
NULL, /* get_proc_address */
|
2019-08-12 12:52:40 +02:00
|
|
|
NULL, /* set_aspect_ratio */
|
|
|
|
NULL, /* apply_state_changes */
|
2018-10-10 08:02:13 +02:00
|
|
|
ps2_set_texture_frame,
|
|
|
|
ps2_set_texture_enable,
|
2020-01-04 16:24:14 +01:00
|
|
|
font_driver_render_msg, /* set_osd_msg */
|
2018-10-10 08:02:13 +02:00
|
|
|
NULL, /* show_mouse */
|
|
|
|
NULL, /* grab_mouse_toggle */
|
|
|
|
NULL, /* get_current_shader */
|
|
|
|
NULL, /* get_current_software_framebuffer */
|
2019-01-15 01:08:28 +01:00
|
|
|
ps2_get_hw_render_interface /* get_hw_render_interface */
|
2018-10-10 08:02:13 +02:00
|
|
|
};
|
|
|
|
|
2018-10-09 19:20:58 +02:00
|
|
|
static void ps2_gfx_get_poke_interface(void *data,
|
|
|
|
const video_poke_interface_t **iface)
|
2018-09-18 08:08:06 +02:00
|
|
|
{
|
|
|
|
(void)data;
|
2018-10-10 08:02:13 +02:00
|
|
|
*iface = &ps2_poke_interface;
|
2018-09-18 08:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
video_driver_t video_ps2 = {
|
2018-10-09 19:20:58 +02:00
|
|
|
ps2_gfx_init,
|
|
|
|
ps2_gfx_frame,
|
|
|
|
ps2_gfx_set_nonblock_state,
|
|
|
|
ps2_gfx_alive,
|
|
|
|
ps2_gfx_focus,
|
|
|
|
ps2_gfx_suppress_screensaver,
|
|
|
|
ps2_gfx_has_windowed,
|
|
|
|
ps2_gfx_set_shader,
|
|
|
|
ps2_gfx_free,
|
2018-09-18 08:08:06 +02:00
|
|
|
"ps2",
|
|
|
|
NULL, /* set_viewport */
|
2019-05-22 07:07:33 +02:00
|
|
|
NULL, /* set_rotation */
|
|
|
|
NULL, /* viewport_info */
|
|
|
|
NULL, /* read_viewport */
|
2018-09-18 08:08:06 +02:00
|
|
|
NULL, /* read_frame_raw */
|
2018-10-09 19:20:58 +02:00
|
|
|
|
2018-09-18 08:08:06 +02:00
|
|
|
#ifdef HAVE_OVERLAY
|
2018-10-09 19:20:58 +02:00
|
|
|
NULL, /* overlay_interface */
|
2019-04-01 04:00:58 +01:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_VIDEO_LAYOUT
|
|
|
|
NULL,
|
2018-09-18 08:08:06 +02:00
|
|
|
#endif
|
2018-10-09 19:20:58 +02:00
|
|
|
ps2_gfx_get_poke_interface,
|
2018-09-18 08:08:06 +02:00
|
|
|
};
|