From: Francisco Javier Trujillo Mata Date: Sun, 31 Dec 2023 17:27:46 +0000 (+0100) Subject: Adding gskit dependency X-Git-Tag: v2.00~119^2~12 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=888ca0b83ba33424a7ecd242f4fb23c402aade30;p=picodrive.git Adding gskit dependency --- diff --git a/configure b/configure index dc887617..e73c6959 100755 --- a/configure +++ b/configure @@ -157,8 +157,8 @@ set_platform() MFLAGS="" ARCH=mips64r5900el ASFLAGS="$ASFLAGS -G0 -call_shared" - CFLAGS="$CFLAGS -D_EE -G0 -I${PS2SDK}/ee/include -I${PS2SDK}/common/include -I${PS2SDK}/ports/include" - LDFLAGS="$LDFLAGS -Wl,-zmax-page-size=128 -T${PS2SDK}/ee/startup/linkfile -L${PS2SDK}/ee/lib -L${PS2SDK}/ports/lib" + CFLAGS="$CFLAGS -D_EE -G0 -I${PS2SDK}/ee/include -I${PS2SDK}/common/include -I${PS2DEV}/gsKit/include -I${PS2SDK}/ports/include" + LDFLAGS="$LDFLAGS -Wl,-zmax-page-size=128 -T${PS2SDK}/ee/startup/linkfile -L${PS2SDK}/ee/lib -L${PS2DEV}/gsKit/lib -L${PS2SDK}/ports/lib" ;; *) fail "unsupported platform: $platform" diff --git a/platform/ps2/emu.c b/platform/ps2/emu.c index c0dd7d25..a2562f45 100644 --- a/platform/ps2/emu.c +++ b/platform/ps2/emu.c @@ -1,9 +1,14 @@ #include +#include #include #include #include #include +#include +#include +#include +#include #include "in_ps2.h" #include "../libpicofe/input.h" @@ -15,6 +20,11 @@ #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; @@ -42,9 +52,70 @@ const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast 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) @@ -179,6 +250,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) void plat_init(void) { + video_init(); init_joystick_driver(false); in_ps2_init(in_ps2_defbinds); in_probe(); @@ -189,6 +261,7 @@ void plat_init(void) void plat_finish(void) { deinit_audio_driver(); deinit_joystick_driver(false); + video_deinit(); } /* display emulator status messages before holding emulation */