PS2SDK
PS2 Homebrew Libraries
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={GS_INTERLACED, GS_MODE_NTSC, GS_FFMD_FRAME, 3};
23
24GsGParam_t *GsGetGParam(void)
25{
26 return &gp_15;
27}
28
29void GsResetGraph(s16 mode, s16 interlace, s16 omode, s16 ffmode)
30{
31 GsGParam_t *pGParams;
32
33 switch(mode){
34 case GS_INIT_RESET:
35 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.
36
37 pGParams=GsGetGParam();
38 GS_SET_CSR_reset(1);
39 pGParams->ffmode=ffmode;
40 pGParams->interlace=interlace;
41 pGParams->omode=omode;
42 pGParams->version=GS_GET_CSR_gs_rev_number>>16;
43
44 GsPutIMR(0xFF00);
45
46 SetGsCrt(interlace&1, omode&0xFF, ffmode&1);
47 GsSetCRTCSettings(CRTC_SETTINGS_DEFAULT1, 0x80);
48 break;
50 GS_SET_CSR_flush(1);
51 break;
52 /* There is a mode 5 present in the Sony sceGsResetGraph, but is not documented. It seems to change the video mode without resetting anything. */
53 }
54}
55
56void GsSetCRTCSettings(u64 settings, u8 alpha_value)
57{
58 *((vu64 *)(gs_p_pmode)) = (settings|((u64)(0x001) << 2)|((u64)(alpha_value) << 8));
59}
u8 version
Definition libgs.h:29
#define gs_p_pmode
Definition libgs.h:190
u8 interlace
Definition libgs.h:23
#define GS_FFMD_FRAME
Definition libgs.h:43
u8 ffmode
Definition libgs.h:27
u8 omode
Definition libgs.h:25
#define GS_INIT_DRAW_RESET
Definition libgs.h:35
#define GS_INIT_RESET
Definition libgs.h:33
Definition libgs.h:333