sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
libgs.c
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# (c) 2009 Lion
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
11#include <errno.h>
12#include <stdio.h>
13#include <kernel.h>
14#include <libgs.h>
15
16#include "internal.h"
17
18extern QWORD GsPrimWorkArea[];
19
20/* Initialization functions. */
21
22static GsGParam_t gp_15;
23
24GsGParam_t *GsGetGParam(void)
25{
26 if (!gp_15.version)
27 {
28 gp_15.interlace = GS_INTERLACED;
29 gp_15.omode = GS_MODE_NTSC;
30 gp_15.ffmode = GS_FFMD_FRAME;
31 gp_15.version = 3;
32 }
33 return &gp_15;
34}
35
36void GsResetGraph(s16 mode, s16 interlace, s16 omode, s16 ffmode)
37{
38 GsGParam_t *pGParams;
39
40 switch(mode){
41 case GS_INIT_RESET:
42 GsDmaInit(); //It seems like the Sony developers reset the GIF DMA channel with their libdma library, but a lot of homebrew GS libraries will do this on their own.
43
44 pGParams=GsGetGParam();
45 GS_SET_CSR_reset(1);
46 pGParams->ffmode=ffmode;
47 pGParams->interlace=interlace;
48 pGParams->omode=omode;
49 pGParams->version=GS_GET_CSR_gs_rev_number>>16;
50
51 GsPutIMR(0xFF00);
52
53 SetGsCrt(interlace&1, omode&0xFF, ffmode&1);
54 GsSetCRTCSettings(CRTC_SETTINGS_DEFAULT1, 0x80);
55 break;
57 GS_SET_CSR_flush(1);
58 break;
59 /* There is a mode 5 present in the Sony sceGsResetGraph, but is not documented. It seems to change the video mode without resetting anything. */
60 }
61}
62
63void GsSetCRTCSettings(u64 settings, u8 alpha_value)
64{
65 *((vu64 *)(gs_p_pmode)) = (settings|((u64)(0x001) << 2)|((u64)(alpha_value) << 8));
66}
#define gs_p_pmode
Definition libgs.h:191
#define GS_FFMD_FRAME
Definition libgs.h:44
#define GS_INIT_DRAW_RESET
Definition libgs.h:36
#define GS_INIT_RESET
Definition libgs.h:34
u8 version
Definition libgs.h:30
u8 interlace
Definition libgs.h:24
u8 ffmode
Definition libgs.h:28
u8 omode
Definition libgs.h:26
Definition libgs.h:334