ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
graph.h File Reference
#include <graph_vram.h>
+ Include dependency graph for graph.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GRAPH_MODE
 

Macros

#define GRAPH_MODE_AUTO   0
 
#define GRAPH_MODE_NTSC   1
 
#define GRAPH_MODE_PAL   2
 
#define GRAPH_MODE_HDTV_480P   3
 
#define GRAPH_MODE_HDTV_576P   4
 
#define GRAPH_MODE_HDTV_720P   5
 
#define GRAPH_MODE_HDTV_1080I   6
 
#define GRAPH_MODE_VGA_640_60   7
 
#define GRAPH_MODE_VGA_640_72   8
 
#define GRAPH_MODE_VGA_640_75   9
 
#define GRAPH_MODE_VGA_640_85   10
 
#define GRAPH_MODE_VGA_800_56   11
 
#define GRAPH_MODE_VGA_800_60   12
 
#define GRAPH_MODE_VGA_800_72   13
 
#define GRAPH_MODE_VGA_800_75   14
 
#define GRAPH_MODE_VGA_800_85   15
 
#define GRAPH_MODE_VGA_1024_60   16
 
#define GRAPH_MODE_VGA_1024_70   17
 
#define GRAPH_MODE_VGA_1024_75   18
 
#define GRAPH_MODE_VGA_1024_85   19
 
#define GRAPH_MODE_VGA_1280_60   20
 
#define GRAPH_MODE_VGA_1280_75   21
 
#define GRAPH_MODE_NONINTERLACED   0
 
#define GRAPH_MODE_INTERLACED   1
 
#define GRAPH_MODE_FIELD   0
 
#define GRAPH_MODE_FRAME   1
 
#define GRAPH_FIELD_EVEN   0
 
#define GRAPH_FIELD_ODD   1
 
#define GRAPH_DISABLE   0
 
#define GRAPH_ENABLE   1
 
#define GRAPH_GCONT_RGB   0
 
#define GRAPH_GCONT_YCRCB   1
 
#define GRAPH_CMOD_NTSC   2
 
#define GRAPH_CMOD_PAL   3
 
#define GRAPH_VALUE_RC1   0
 
#define GRAPH_VALUE_ALPHA   1
 
#define GRAPH_RC1_ALPHA   0
 
#define GRAPH_RC2_ALPHA   1
 
#define GRAPH_BLEND_RC2   0
 
#define GRAPH_BLEND_BGCOLOR   1
 

Functions

int graph_initialize (int fbp, int width, int height, int psm, int x, int y)
 
int graph_get_region (void)
 
float graph_aspect_ratio (void)
 
void graph_enable_output (void)
 
void graph_disable_output (void)
 
int graph_set_mode (int interlace, int mode, int ffmd, int flicker_filter)
 
int graph_set_screen (int x, int y, int width, int height)
 
void graph_set_framebuffer_filtered (int fbp, int width, int psm, int x, int y)
 
void graph_set_framebuffer (int context, int fbp, int width, int psm, int x, int y)
 
void graph_set_bgcolor (unsigned char r, unsigned char g, unsigned char b)
 
void graph_set_output (int rc1, int rc2, int alpha_select, int alpha_output, int blend_method, unsigned char alpha)
 
int graph_add_vsync_handler (int(*vsync_callback)())
 
void graph_remove_vsync_handler (int callback_id)
 
void graph_wait_hsync (void)
 
void graph_wait_vsync (void)
 
int graph_check_vsync (void)
 
void graph_start_vsync (void)
 
int graph_shutdown (void)
 

Variables

GRAPH_MODE graph_mode []
 

Detailed Description

Graph library

Definition in file graph.h.

Macro Definition Documentation

◆ GRAPH_BLEND_BGCOLOR

#define GRAPH_BLEND_BGCOLOR   1

Definition at line 87 of file graph.h.

◆ GRAPH_BLEND_RC2

#define GRAPH_BLEND_RC2   0

Alpha blending method

Definition at line 86 of file graph.h.

◆ GRAPH_CMOD_NTSC

#define GRAPH_CMOD_NTSC   2

Definition at line 74 of file graph.h.

◆ GRAPH_CMOD_PAL

#define GRAPH_CMOD_PAL   3

Definition at line 75 of file graph.h.

◆ GRAPH_DISABLE

#define GRAPH_DISABLE   0

Generic use

Definition at line 67 of file graph.h.

◆ GRAPH_ENABLE

#define GRAPH_ENABLE   1

Definition at line 68 of file graph.h.

◆ GRAPH_FIELD_EVEN

#define GRAPH_FIELD_EVEN   0

Definition at line 63 of file graph.h.

◆ GRAPH_FIELD_ODD

#define GRAPH_FIELD_ODD   1

Definition at line 64 of file graph.h.

◆ GRAPH_GCONT_RGB

#define GRAPH_GCONT_RGB   0

Smode1 parameters

Definition at line 71 of file graph.h.

◆ GRAPH_GCONT_YCRCB

#define GRAPH_GCONT_YCRCB   1

Definition at line 72 of file graph.h.

◆ GRAPH_MODE_AUTO

#define GRAPH_MODE_AUTO   0

Automatic NTSC or PAL mode setting.

Definition at line 13 of file graph.h.

◆ GRAPH_MODE_FIELD

#define GRAPH_MODE_FIELD   0

Definition at line 60 of file graph.h.

◆ GRAPH_MODE_FRAME

#define GRAPH_MODE_FRAME   1

Definition at line 61 of file graph.h.

◆ GRAPH_MODE_HDTV_1080I

#define GRAPH_MODE_HDTV_1080I   6

1920 x 1080

Definition at line 25 of file graph.h.

◆ GRAPH_MODE_HDTV_480P

#define GRAPH_MODE_HDTV_480P   3

720 x 480

Definition at line 19 of file graph.h.

◆ GRAPH_MODE_HDTV_576P

#define GRAPH_MODE_HDTV_576P   4

656 x 576

Definition at line 21 of file graph.h.

◆ GRAPH_MODE_HDTV_720P

#define GRAPH_MODE_HDTV_720P   5

1280 x 720

Definition at line 23 of file graph.h.

◆ GRAPH_MODE_INTERLACED

#define GRAPH_MODE_INTERLACED   1

Definition at line 58 of file graph.h.

◆ GRAPH_MODE_NONINTERLACED

#define GRAPH_MODE_NONINTERLACED   0

Definition at line 57 of file graph.h.

◆ GRAPH_MODE_NTSC

#define GRAPH_MODE_NTSC   1

256 x 224 to 640 x 448

Definition at line 15 of file graph.h.

◆ GRAPH_MODE_PAL

#define GRAPH_MODE_PAL   2

256 x 256 to 640 x 512

Definition at line 17 of file graph.h.

◆ GRAPH_MODE_VGA_1024_60

#define GRAPH_MODE_VGA_1024_60   16

1024 x 768 @ 60hz

Definition at line 45 of file graph.h.

◆ GRAPH_MODE_VGA_1024_70

#define GRAPH_MODE_VGA_1024_70   17

1024 x 768 @ 70hz

Definition at line 47 of file graph.h.

◆ GRAPH_MODE_VGA_1024_75

#define GRAPH_MODE_VGA_1024_75   18

1024 x 768 @ 75hz

Definition at line 49 of file graph.h.

◆ GRAPH_MODE_VGA_1024_85

#define GRAPH_MODE_VGA_1024_85   19

1024 x 768 @ 85hz

Definition at line 51 of file graph.h.

◆ GRAPH_MODE_VGA_1280_60

#define GRAPH_MODE_VGA_1280_60   20

1280 x 1024 @ 60hz

Definition at line 53 of file graph.h.

◆ GRAPH_MODE_VGA_1280_75

#define GRAPH_MODE_VGA_1280_75   21

1280 x 1024 @ 75hz

Definition at line 55 of file graph.h.

◆ GRAPH_MODE_VGA_640_60

#define GRAPH_MODE_VGA_640_60   7

640 x 480 @ 60hz

Definition at line 27 of file graph.h.

◆ GRAPH_MODE_VGA_640_72

#define GRAPH_MODE_VGA_640_72   8

640 x 480 @ 72hz

Definition at line 29 of file graph.h.

◆ GRAPH_MODE_VGA_640_75

#define GRAPH_MODE_VGA_640_75   9

640 x 480 @ 75hz

Definition at line 31 of file graph.h.

◆ GRAPH_MODE_VGA_640_85

#define GRAPH_MODE_VGA_640_85   10

640 x 480 @ 85hz

Definition at line 33 of file graph.h.

◆ GRAPH_MODE_VGA_800_56

#define GRAPH_MODE_VGA_800_56   11

800 x 600 @ 56hz

Definition at line 35 of file graph.h.

◆ GRAPH_MODE_VGA_800_60

#define GRAPH_MODE_VGA_800_60   12

800 x 600 @ 60hz

Definition at line 37 of file graph.h.

◆ GRAPH_MODE_VGA_800_72

#define GRAPH_MODE_VGA_800_72   13

800 x 600 @ 72hz

Definition at line 39 of file graph.h.

◆ GRAPH_MODE_VGA_800_75

#define GRAPH_MODE_VGA_800_75   14

800 x 600 @ 75hz

Definition at line 41 of file graph.h.

◆ GRAPH_MODE_VGA_800_85

#define GRAPH_MODE_VGA_800_85   15

800 x 600 @ 85hz

Definition at line 43 of file graph.h.

◆ GRAPH_RC1_ALPHA

#define GRAPH_RC1_ALPHA   0

Alpha output value

Definition at line 82 of file graph.h.

◆ GRAPH_RC2_ALPHA

#define GRAPH_RC2_ALPHA   1

Definition at line 83 of file graph.h.

◆ GRAPH_VALUE_ALPHA

#define GRAPH_VALUE_ALPHA   1

Definition at line 79 of file graph.h.

◆ GRAPH_VALUE_RC1

#define GRAPH_VALUE_RC1   0

Alpha Blending value to use

Definition at line 78 of file graph.h.

Function Documentation

◆ graph_add_vsync_handler()

int graph_add_vsync_handler ( int(*)()  vsync_callback)

Add a vsync interrupt handler

Definition at line 29 of file graph.c.

30 {
31 
32  int callback_id;
33 
34  DIntr();
35 
36  callback_id = AddIntcHandler(INTC_VBLANK_S, vsync_callback, -1);
37 
39 
40  EIntr();
41 
42  return callback_id;
43 
44 }
int EnableIntc(int intc)
s32 AddIntcHandler(s32 cause, s32(*handler_func)(s32 cause), s32 next)
@ INTC_VBLANK_S
Definition: kernel.h:85
int DIntr(void)
int EIntr(void)

References AddIntcHandler(), DIntr(), EIntr(), EnableIntc(), and INTC_VBLANK_S.

◆ graph_aspect_ratio()

float graph_aspect_ratio ( void  )

Returns an aspect ratio calculated from system setting, width, and height

Definition at line 397 of file graph_mode.c.

398 {
399 
400  // Get the tv screen type as defined in the osd configuration.
402  {
403 
404  graph_aspect = 1.78f;
405 
406  }
407  else
408  {
409 
410  graph_aspect = 1.33f;
411 
412  }
413 
414  // Return the current aspect ratio
416 
417  return graph_aspect;
418 
419 }
static float graph_height
Definition: graph_mode.c:40
static float graph_aspect
Definition: graph_mode.c:41
static float graph_width
Definition: graph_mode.c:39
int configGetTvScreenType(void)
@ TV_SCREEN_169
Definition: osd_config.h:58

References configGetTvScreenType(), graph_aspect, graph_height, graph_width, and TV_SCREEN_169.

Referenced by render().

◆ graph_check_vsync()

int graph_check_vsync ( void  )

Checks if a vertical sync event is currently generated.

Definition at line 85 of file graph.c.

86 {
87 
88  return (*GS_REG_CSR & 8);
89 
90 }
#define GS_REG_CSR
Definition: gs_privileged.h:45

References GS_REG_CSR.

◆ graph_disable_output()

void graph_disable_output ( void  )

Turns off the read circuits.

Definition at line 330 of file graph_mode.c.

331 {
332 
333  graph_set_output(0,0,0,0,0,0);
334 
335 }
void graph_set_output(int rc1, int rc2, int alpha_select, int alpha_output, int blend_method, unsigned char alpha)
Definition: graph_mode.c:301

References graph_set_output().

Referenced by graph_shutdown().

◆ graph_enable_output()

void graph_enable_output ( void  )

Sets a default output method.

Definition at line 312 of file graph_mode.c.

313 {
314 
315  if (graph_filter)
316  {
317 
319 
320  }
321  else
322  {
323 
324  graph_set_output(0,1,0,1,0,0x80);
325 
326  }
327 
328 }
#define GRAPH_ENABLE
Definition: graph.h:68
#define GRAPH_RC1_ALPHA
Definition: graph.h:82
#define GRAPH_VALUE_ALPHA
Definition: graph.h:79
#define GRAPH_BLEND_RC2
Definition: graph.h:86
static int graph_filter
Definition: graph_mode.c:43

References GRAPH_BLEND_RC2, GRAPH_ENABLE, graph_filter, GRAPH_RC1_ALPHA, graph_set_output(), and GRAPH_VALUE_ALPHA.

Referenced by graph_initialize().

◆ graph_get_region()

int graph_get_region ( void  )

Retrieves the PS2's region for automatic mode selection.

Definition at line 111 of file graph_mode.c.

112 {
113 
114  char romname[14];
115 
116  GetRomName((char *)romname);
117 
118  if (romname[4] == 'E')
119  {
120  return GRAPH_MODE_PAL;
121  }
122 
123  return GRAPH_MODE_NTSC;
124 
125 }
#define GRAPH_MODE_NTSC
Definition: graph.h:15
#define GRAPH_MODE_PAL
Definition: graph.h:17
char * GetRomName(char *romname)

References GetRomName(), GRAPH_MODE_NTSC, and GRAPH_MODE_PAL.

Referenced by graph_initialize().

◆ graph_initialize()

int graph_initialize ( int  fbp,
int  width,
int  height,
int  psm,
int  x,
int  y 
)

Initializes a default NTSC/PAL mode with default settings.

Definition at line 6 of file graph.c.

7 {
8 
9  int mode = graph_get_region();
10 
11  // Set a default interlaced video mode with flicker filter.
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 
23 
24  // End function.
25  return 0;
26 
27 }
int graph_set_screen(int x, int y, int width, int height)
Definition: graph_mode.c:183
void graph_set_bgcolor(unsigned char r, unsigned char g, unsigned char b)
Definition: graph_mode.c:294
void graph_enable_output(void)
Definition: graph_mode.c:312
void graph_set_framebuffer_filtered(int fbp, int width, int psm, int x, int y)
Definition: graph_mode.c:265
int graph_get_region(void)
Definition: graph_mode.c:111
#define GRAPH_MODE_INTERLACED
Definition: graph.h:58
int graph_set_mode(int interlace, int mode, int ffmd, int flicker_filter)
Definition: graph_mode.c:127
#define GRAPH_MODE_FIELD
Definition: graph.h:60
s32 x
Definition: libmouse.c:34
s32 y
Definition: libmouse.c:34
s32 mode
Definition: rpc_client.c:15

References GRAPH_ENABLE, graph_enable_output(), graph_get_region(), GRAPH_MODE_FIELD, GRAPH_MODE_INTERLACED, graph_set_bgcolor(), graph_set_framebuffer_filtered(), graph_set_mode(), graph_set_screen(), mode, x, and y.

Referenced by draw_init_env(), init_gs(), and main().

◆ graph_remove_vsync_handler()

void graph_remove_vsync_handler ( int  callback_id)

Remove a vsync interrupt handler

Definition at line 46 of file graph.c.

47 {
48 
49  DIntr();
50 
52 
53  RemoveIntcHandler(INTC_VBLANK_S, callback_id);
54 
55  EIntr();
56 
57 }
int DisableIntc(int intc)
s32 RemoveIntcHandler(s32 cause, s32 handler_id)

References DIntr(), DisableIntc(), EIntr(), INTC_VBLANK_S, and RemoveIntcHandler().

◆ graph_set_bgcolor()

void graph_set_bgcolor ( unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Sets the background color for merge circuit.

Definition at line 294 of file graph_mode.c.

295 {
296 
297  *GS_REG_BGCOLOR = GS_SET_BGCOLOR(r,g,b);
298 
299 }
#define GS_REG_BGCOLOR
Definition: gs_privileged.h:43
#define GS_SET_BGCOLOR(r, g, b)
Definition: libgs.h:1243

References GS_REG_BGCOLOR, and GS_SET_BGCOLOR.

Referenced by graph_initialize().

◆ graph_set_framebuffer()

void graph_set_framebuffer ( int  context,
int  fbp,
int  width,
int  psm,
int  x,
int  y 
)

Sets the framebuffer attributes for the read circuits.

Definition at line 275 of file graph_mode.c.

276 {
277 
278  if (context == 0)
279  {
280 
281  *GS_REG_DISPFB1 = GS_SET_DISPFB(fbp>>11,width>>6,psm,x,y);
282 
283  }
284  else
285  {
286 
287  // For flicker filter, we need to offset the lines by 1 for the other read circuit.
288  *GS_REG_DISPFB2 = GS_SET_DISPFB(fbp>>11,width>>6,psm,x,y);
289 
290  }
291 
292 }
u8 context
Definition: main.c:71
#define GS_SET_DISPFB(FBP, FBW, PSM, DBX, DBY)
Definition: gs_privileged.h:70
#define GS_REG_DISPFB1
Definition: gs_privileged.h:29
#define GS_REG_DISPFB2
Definition: gs_privileged.h:33

References context, GS_REG_DISPFB1, GS_REG_DISPFB2, GS_SET_DISPFB, x, and y.

◆ graph_set_framebuffer_filtered()

void graph_set_framebuffer_filtered ( int  fbp,
int  width,
int  psm,
int  x,
int  y 
)

Sets the framebuffer attributes for the read circuits with filter.

Definition at line 265 of file graph_mode.c.

266 {
267 
268  *GS_REG_DISPFB1 = GS_SET_DISPFB(fbp>>11,width>>6,psm,x,y);
269 
270  // For flicker filter, we need to offset the lines by 1 for the other read circuit.
271  *GS_REG_DISPFB2 = GS_SET_DISPFB(fbp>>11,width>>6,psm,x,y+1);
272 
273 }

References GS_REG_DISPFB1, GS_REG_DISPFB2, GS_SET_DISPFB, x, and y.

Referenced by graph_initialize(), and render().

◆ graph_set_mode()

int graph_set_mode ( int  interlace,
int  mode,
int  ffmd,
int  flicker_filter 
)

Sets the graphics mode.

Definition at line 127 of file graph_mode.c.

128 {
129 
130  char romname[14];
131 
132  // Reset GS.
133  *GS_REG_CSR = (u64)1<<9;
134 
135  // Clear GS CSR.
136  *GS_REG_CSR = GS_SET_CSR(0,0,0,0,0,0,0,0,0,0,0,0);
137 
138  // Unmask GS VSYNC Interrupt.
139  GsPutIMR(0x00007700);
140 
141  // Ensure registers are written prior to setting another mode.
142  asm volatile ("sync.p\n\t"
143  "nop\n\t");
144 
145  // If 576P is requested, check if bios supports it.
146  if (mode == GRAPH_MODE_HDTV_576P)
147  {
148 
149  GetRomName((char *)romname);
150 
151  if (strtol(romname,NULL,10) < 220) { mode = GRAPH_MODE_PAL; }
152 
153  }
154 
155  // 1080I is forced to be interlaced so correct value just in case.
157  {
158 
159  interlace = GRAPH_MODE_INTERLACED;
160 
161  }
162 
163  if (interlace == GRAPH_MODE_NONINTERLACED)
164  {
165 
166  flicker_filter = GRAPH_DISABLE;
167 
168  }
169 
170  // Set graph's mode, interlacing and field mode.
172  graph_interlace = interlace;
173  graph_ffmd = ffmd;
174  graph_filter = flicker_filter;
175 
176  // Set the requested mode.
178 
179  return 0;
180 
181 }
#define GRAPH_MODE_NONINTERLACED
Definition: graph.h:57
#define GRAPH_DISABLE
Definition: graph.h:67
#define GRAPH_MODE_HDTV_576P
Definition: graph.h:21
#define GRAPH_MODE_HDTV_1080I
Definition: graph.h:25
static int graph_ffmd
Definition: graph_mode.c:46
static int graph_interlace
Definition: graph_mode.c:45
static int graph_crtmode
Definition: graph_mode.c:44
GRAPH_MODE graph_mode[22]
Definition: graph_mode.c:11
void SetGsCrt(s16 interlace, s16 pal_ntsc, s16 field)
u64 GsPutIMR(u64 imr)
#define GS_SET_CSR(signal_evnt, finish_evnt, hsync_intrupt, vsync_intrupt, write_terminate, flush, reset, nfield, current_field, fifo_status, gs_rev_number, gs_id)
Definition: libgs.h:1249
#define NULL
Definition: tamtypes.h:91
unsigned long u64
Definition: tamtypes.h:34

References GetRomName(), graph_crtmode, GRAPH_DISABLE, graph_ffmd, graph_filter, graph_interlace, graph_mode, GRAPH_MODE_HDTV_1080I, GRAPH_MODE_HDTV_576P, GRAPH_MODE_INTERLACED, GRAPH_MODE_NONINTERLACED, GRAPH_MODE_PAL, GS_REG_CSR, GS_SET_CSR, GsPutIMR(), mode, NULL, and SetGsCrt().

Referenced by graph_initialize(), and graph_set_config().

◆ graph_set_output()

void graph_set_output ( int  rc1,
int  rc2,
int  alpha_select,
int  alpha_output,
int  blend_method,
unsigned char  alpha 
)

Sets the read circuits and merge cicuit.

Definition at line 301 of file graph_mode.c.

302 {
303 
304  graph_pmode = GS_SET_PMODE(rc1, rc2, alpha_select, alpha_output, blend_method, alpha);
306 
307 }
static u64 graph_pmode
Definition: graph_mode.c:52
#define GS_REG_PMODE
Definition: gs_privileged.h:15
#define GS_SET_PMODE(enable_rc1, enable_rc2, mmod, amod, blend_style, blend_value)
Definition: libgs.h:1142

References graph_pmode, GS_REG_PMODE, and GS_SET_PMODE.

Referenced by graph_disable_output(), and graph_enable_output().

◆ graph_set_screen()

int graph_set_screen ( int  x,
int  y,
int  width,
int  height 
)

Sets the screen dimensions for the read circuits.

Definition at line 183 of file graph_mode.c.

184 {
185 
186  int dx,dy,dw,dh;
187 
188  graph_x = x;
189  graph_y = y;
190 
191  graph_width = (float)width;
192  graph_height = (float)height;
193 
194  // Check if the mode has been set
196  {
197 
198  return -1;
199 
200  }
201 
202  // Add X adjustment to default X offset
204 
205  // Get default Y offset
206  dy = graph_mode[graph_crtmode].y;
207 
208  // Get screen's width and height
211 
212  // Double Y offset for interlacing in FIELD mode
213  // Double screen's height parameter
215  {
216 
217  dy = (dy - 1) * 2;
218  dh = graph_mode[graph_crtmode].height * 2;
219 
220  }
221 
222  // Now add Y adjustment
223  dy += graph_y;
224 
225  // Determine magnification
226  graph_magh = dw / width;
227  graph_magv = dh / height;
228 
229  // Make sure it doesn't turn negative
230  if (graph_magh < 1)
231  {
232 
233  graph_magh = 1;
234 
235  }
236 
237  if (graph_magv < 1)
238  {
239 
240  graph_magv = 1;
241 
242  }
243 
244  // Set the display attributes but use the user defined height.
245  if (graph_filter)
246  {
247 
248  // For flicker filter, we need to get add an extra line.
249  *GS_REG_DISPLAY1 = GS_SET_DISPLAY(dx,dy,graph_magh-1,graph_magv-1,dw-1,height-1);
250  *GS_REG_DISPLAY2 = GS_SET_DISPLAY(dx,dy,graph_magh-1,graph_magv-1,dw-1,height-2);
251 
252  }
253  else
254  {
255 
256  *GS_REG_DISPLAY1 = GS_SET_DISPLAY(dx,dy,graph_magh-1,graph_magv-1,dw-1,height-1);
257  *GS_REG_DISPLAY2 = GS_SET_DISPLAY(dx,dy,graph_magh-1,graph_magv-1,dw-1,height-1);
258 
259  }
260 
261  return 0;
262 
263 }
#define GRAPH_MODE_AUTO
Definition: graph.h:13
static int graph_x
Definition: graph_mode.c:47
static int graph_magv
Definition: graph_mode.c:50
static int graph_y
Definition: graph_mode.c:48
static int graph_magh
Definition: graph_mode.c:49
#define GS_REG_DISPLAY1
Definition: gs_privileged.h:31
#define GS_SET_DISPLAY(DX, DY, MAGH, MAGV, DW, DH)
Definition: gs_privileged.h:75
#define GS_REG_DISPLAY2
Definition: gs_privileged.h:35
int width
Definition: graph.h:91
int y
Definition: graph.h:90
int height
Definition: graph.h:91
int x
Definition: graph.h:90

References graph_crtmode, graph_ffmd, graph_filter, graph_height, graph_interlace, graph_magh, graph_magv, graph_mode, GRAPH_MODE_AUTO, GRAPH_MODE_FIELD, graph_width, graph_x, graph_y, GS_REG_DISPLAY1, GS_REG_DISPLAY2, GS_SET_DISPLAY, GRAPH_MODE::height, GRAPH_MODE::width, GRAPH_MODE::x, x, GRAPH_MODE::y, and y.

Referenced by graph_initialize().

◆ graph_shutdown()

int graph_shutdown ( void  )

Shut down the graphics library and hardware.

Definition at line 428 of file graph_mode.c.

429 {
430 
432 
433  // Reset GS.
434  *GS_REG_CSR = (u64)1<<9;
435 
436  // Clear GS CSR.
437  *GS_REG_CSR = GS_SET_CSR(0,0,0,0,0,0,0,0,0,0,0,0);
438 
439  // Reset the static variables.
440  graph_aspect = 1.0f;
441  graph_width = 0.0f;
442  graph_height = 0.0f;
443  graph_filter = 0;
444  graph_crtmode = 0;
445  graph_interlace = 0;
446  graph_ffmd = 0;
447  graph_x = 0;
448  graph_y = 0;
449  graph_magh = 0;
450  graph_magv = 0;
451 
452  return 0;
453 
454 }
void graph_disable_output(void)
Definition: graph_mode.c:330

References graph_aspect, graph_crtmode, graph_disable_output(), graph_ffmd, graph_filter, graph_height, graph_interlace, graph_magh, graph_magv, graph_width, graph_x, graph_y, GS_REG_CSR, and GS_SET_CSR.

Referenced by main().

◆ graph_start_vsync()

void graph_start_vsync ( void  )

Starts a vertical sync event and returns immediately.

Definition at line 92 of file graph.c.

93 {
94 
95  *GS_REG_CSR |= *GS_REG_CSR & 8;
96 
97 }

References GS_REG_CSR.

◆ graph_wait_hsync()

void graph_wait_hsync ( void  )

Starts a horizontal sync event and waits

Definition at line 74 of file graph.c.

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 }

References GS_REG_CSR.

◆ graph_wait_vsync()

void graph_wait_vsync ( void  )

Starts a vertical sync event and waits.

Definition at line 99 of file graph.c.

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 }

References GS_REG_CSR.

Referenced by main(), render(), and run_demo().

Variable Documentation

◆ graph_mode

GRAPH_MODE graph_mode[]
extern

Definition at line 11 of file graph_mode.c.

Referenced by graph_set_mode(), and graph_set_screen().