sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
graph.c
1
#include <
kernel.h
>
2
#include <
gs_privileged.h
>
3
4
#include <
graph.h
>
5
6
int
graph_initialize
(
int
fbp,
int
width,
int
height,
int
psm,
int
x,
int
y)
7
{
8
9
int
mode =
graph_get_region
();
10
11
// Set a default interlaced video mode with flicker filter.
12
graph_set_mode
(GRAPH_MODE_INTERLACED, mode, GRAPH_MODE_FIELD, GRAPH_ENABLE);
13
14
// Set the screen up
15
graph_set_screen
(0,0,width,height);
16
17
// Set black background
18
graph_set_bgcolor
(0,0,0);
19
20
graph_set_framebuffer_filtered
(fbp,width,psm,x,y);
21
22
graph_enable_output
();
23
24
// End function.
25
return
0;
26
27
}
28
29
int
graph_add_vsync_handler
(
int
(*vsync_callback)(
int
cause))
30
{
31
32
int
callback_id;
33
34
DIntr();
35
36
callback_id = AddIntcHandler(INTC_VBLANK_S, vsync_callback, -1);
37
38
EnableIntc(INTC_VBLANK_S);
39
40
EIntr();
41
42
return
callback_id;
43
44
}
45
46
void
graph_remove_vsync_handler
(
int
callback_id)
47
{
48
49
DIntr();
50
51
DisableIntc(INTC_VBLANK_S);
52
53
RemoveIntcHandler(INTC_VBLANK_S, callback_id);
54
55
EIntr();
56
57
}
58
59
int
graph_get_field(
void
)
60
{
61
62
// Return the currently displayed field.
63
if
(*
GS_REG_CSR
& (1 << 13))
64
{
65
66
return
GRAPH_FIELD_ODD;
67
68
}
69
70
return
GRAPH_FIELD_EVEN;
71
72
}
73
74
void
graph_wait_hsync
(
void
)
75
{
76
77
// Initiate hsync interrupt
78
*
GS_REG_CSR
|= *
GS_REG_CSR
& 4;
79
80
// Wait for hsync interrupt to be generated.
81
while
(!(*
GS_REG_CSR
& 4));
82
83
}
84
85
int
graph_check_vsync
(
void
)
86
{
87
88
return
(*
GS_REG_CSR
& 8);
89
90
}
91
92
void
graph_start_vsync
(
void
)
93
{
94
95
*
GS_REG_CSR
|= *
GS_REG_CSR
& 8;
96
97
}
98
99
void
graph_wait_vsync
(
void
)
100
{
101
102
// Initiate vsync interrupt.
103
*
GS_REG_CSR
|= *
GS_REG_CSR
& 8;
104
105
// Wait for vsync interrupt to be generated.
106
while
(!(*
GS_REG_CSR
& 8));
107
108
}
graph.h
graph_set_screen
int graph_set_screen(int x, int y, int width, int height)
Definition
graph_mode.c:195
graph_set_bgcolor
void graph_set_bgcolor(unsigned char r, unsigned char g, unsigned char b)
Definition
graph_mode.c:306
graph_remove_vsync_handler
void graph_remove_vsync_handler(int callback_id)
Definition
graph.c:46
graph_initialize
int graph_initialize(int fbp, int width, int height, int psm, int x, int y)
Definition
graph.c:6
graph_enable_output
void graph_enable_output(void)
Definition
graph_mode.c:324
graph_wait_vsync
void graph_wait_vsync(void)
Definition
graph.c:99
graph_set_framebuffer_filtered
void graph_set_framebuffer_filtered(int fbp, int width, int psm, int x, int y)
Definition
graph_mode.c:277
graph_get_region
int graph_get_region(void)
Definition
graph_mode.c:123
graph_add_vsync_handler
int graph_add_vsync_handler(int(*vsync_callback)(int cause))
Definition
graph.c:29
graph_check_vsync
int graph_check_vsync(void)
Definition
graph.c:85
graph_start_vsync
void graph_start_vsync(void)
Definition
graph.c:92
graph_wait_hsync
void graph_wait_hsync(void)
Definition
graph.c:74
graph_set_mode
int graph_set_mode(int interlace, int mode, int ffmd, int flicker_filter)
Definition
graph_mode.c:139
gs_privileged.h
GS_REG_CSR
#define GS_REG_CSR
Definition
gs_privileged.h:46
kernel.h
core
graph
src
graph.c
Generated by
1.18.0