sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
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
18
extern
QWORD
GsPrimWorkArea[];
19
20
/* Initialization functions. */
21
22
static
GsGParam_t
gp_15;
23
24
GsGParam_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
36
void
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
;
56
case
GS_INIT_DRAW_RESET
:
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
63
void
GsSetCRTCSettings(u64 settings, u8 alpha_value)
64
{
65
*((vu64 *)(
gs_p_pmode
)) = (settings|((u64)(0x001) << 2)|((u64)(alpha_value) << 8));
66
}
kernel.h
internal.h
libgs.h
gs_p_pmode
#define gs_p_pmode
Definition
libgs.h:191
GS_FFMD_FRAME
#define GS_FFMD_FRAME
Definition
libgs.h:44
GS_INIT_DRAW_RESET
#define GS_INIT_DRAW_RESET
Definition
libgs.h:36
GS_INIT_RESET
#define GS_INIT_RESET
Definition
libgs.h:34
stdio.h
GsGParam_t
Definition
libgs.h:22
GsGParam_t::version
u8 version
Definition
libgs.h:30
GsGParam_t::interlace
u8 interlace
Definition
libgs.h:24
GsGParam_t::ffmode
u8 ffmode
Definition
libgs.h:28
GsGParam_t::omode
u8 omode
Definition
libgs.h:26
QWORD
Definition
libgs.h:334
core
libgs
src
libgs.c
Generated by
1.18.0