ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
graph.c File Reference
#include <kernel.h>
#include <gs_privileged.h>
#include <graph.h>
+ Include dependency graph for graph.c:

Go to the source code of this file.

Functions

int graph_initialize (int fbp, int width, int height, int psm, int x, int y)
 
int graph_add_vsync_handler (int(*vsync_callback)())
 
void graph_remove_vsync_handler (int callback_id)
 
int graph_get_field (void)
 
void graph_wait_hsync (void)
 
int graph_check_vsync (void)
 
void graph_start_vsync (void)
 
void graph_wait_vsync (void)
 

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_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_get_field()

int graph_get_field ( void  )

Definition at line 59 of file graph.c.

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 }
#define GRAPH_FIELD_EVEN
Definition: graph.h:63
#define GRAPH_FIELD_ODD
Definition: graph.h:64

References GRAPH_FIELD_EVEN, GRAPH_FIELD_ODD, and GS_REG_CSR.

◆ 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
#define GRAPH_ENABLE
Definition: graph.h:68
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_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().