#include <stddef.h>
+#include <malloc.h>
#include <kernel.h>
#include <ps2_joystick_driver.h>
#include <ps2_audio_driver.h>
#include <libpad.h>
+#include <gsKit.h>
+#include <dmaKit.h>
+#include <gsToolkit.h>
+#include <gsInline.h>
#include "in_ps2.h"
#include "../libpicofe/input.h"
#define OSD_FPS_X 220
+/* turn black GS Screen */
+#define GS_BLACK GS_SETREG_RGBA(0x00, 0x00, 0x00, 0x80)
+/* Generic tint color */
+#define GS_TEXT GS_SETREG_RGBA(0x80, 0x80, 0x80, 0x80)
+
static int osd_buf_cnt, osd_cdleds;
static int out_x, out_y;
const char *renderer_names32x[] = { "accurate", "faster", "fastest", NULL };
enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT };
+typedef struct ps2_video {
+ GSGLOBAL *gsGlobal;
+
+ GSTEXTURE *scrbitmap;
+ GSTEXTURE *tex_spr0;
+ GSTEXTURE *tex_spr1;
+ GSTEXTURE *tex_spr2;
+ GSTEXTURE *tex_fix;
+ uint32_t offset;
+ uint8_t vsync; /* 0 (Disabled), 1 (Enabled), 2 (Dynamic) */
+ uint8_t pixel_format;
+} ps2_video_t;
+
+ps2_video_t *ps2_video = NULL;
+
#define is_16bit_mode() \
(currentConfig.renderer == RT_16BIT || (PicoIn.AHW & PAHW_32X))
+static void video_init(void)
+{
+ ps2_video = (ps2_video_t*)calloc(1, sizeof(ps2_video_t));
+
+ GSGLOBAL *gsGlobal;
+
+ gsGlobal = gsKit_init_global();
+
+ gsGlobal->Mode = GS_MODE_NTSC;
+ gsGlobal->Height = 448;
+
+ gsGlobal->PSM = GS_PSM_CT24;
+ gsGlobal->PSMZ = GS_PSMZ_16S;
+ gsGlobal->ZBuffering = GS_SETTING_OFF;
+ gsGlobal->DoubleBuffering = GS_SETTING_ON;
+ gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
+ gsGlobal->Dithering = GS_SETTING_OFF;
+
+ gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0, 1, 0, 1, 0), 0);
+
+ dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
+ dmaKit_chan_init(DMA_CHANNEL_GIF);
+
+ gsKit_set_clamp(gsGlobal, GS_CMODE_REPEAT);
+
+ gsKit_vram_clear(gsGlobal);
+
+ gsKit_init_screen(gsGlobal);
+
+ gsKit_TexManager_init(gsGlobal);
+
+ gsKit_mode_switch(gsGlobal, GS_ONESHOT);
+ gsKit_clear(gsGlobal, GS_BLACK);
+ ps2_video->gsGlobal = gsGlobal;
+}
+
+static void video_deinit(void)
+{
+ if (!ps2_video) return;
+
+ gsKit_clear(ps2_video->gsGlobal, GS_BLACK);
+ gsKit_vram_clear(ps2_video->gsGlobal);
+ gsKit_deinit_global(ps2_video->gsGlobal);
+ free(ps2_video);
+}
+
static int get_renderer(void)
{
if (PicoIn.AHW & PAHW_32X)
void plat_init(void)
{
+ video_init();
init_joystick_driver(false);
in_ps2_init(in_ps2_defbinds);
in_probe();
void plat_finish(void) {
deinit_audio_driver();
deinit_joystick_driver(false);
+ video_deinit();
}
/* display emulator status messages before holding emulation */