Macros | |
#define | GPU_DATA_PORT_ADDR 0x1f801810 |
#define | GPU_CONTROL_PORT_ADDR 0x1f801814 |
#define | GPU_DATA_PORT *((unsigned int*)GPU_DATA_PORT_ADDR) |
#define | GPU_CONTROL_PORT *((unsigned int*)GPU_CONTROL_PORT_ADDR) |
#define | DPCR *((unsigned int*)0x1f8010f0) |
#define | D2_MADR *((unsigned int*)0x1f8010a0) |
#define | D2_BCR *((unsigned int*)0x1f8010a4) |
#define | D2_CHCR *((unsigned int*)0x1f8010a8) |
#define | get_clutid(cx, cy) (((cx&0x3ff)>>4)|((cy&0x1ff)<<6)) |
Functions | |
unsigned int | PRFONT_SCALEX (int i) |
unsigned int | PRFONT_SCALEY (int i) |
unsigned int | PRFONT_RL (unsigned char f) |
unsigned int | PRFONT_GL (unsigned char f) |
unsigned int | PRFONT_BL (unsigned char f) |
unsigned int | setup_attribs (unsigned char tpage, unsigned int attribute, unsigned char *packet) |
int | gs_calculate_scaled_size (int size, int scale) |
void | GsSetList (unsigned int *listptr) |
Assigns the internal pointer to the primitive list to the desired one, and resets the linked list position counter. | |
void | GsDrawList () |
Draws the primitive list. | |
void | GsDrawListPIO () |
Draws the primitive list using port I/O access. | |
void | GsSortPoly3 (GsPoly3 *poly3) |
Adds a monochrome 3 point polygon to the packet list. | |
void | GsSortPoly4 (GsPoly4 *poly4) |
Adds a monochrome 4 point polygon to the packet list. | |
void | GsSortGPoly3 (GsGPoly3 *poly3) |
Adds a gradated 3 point polygon to the packet list. | |
void | GsSortGPoly4 (GsGPoly4 *poly4) |
Adds a gradated 4 point polygon to the packet list. | |
void | GsSortLine (GsLine *line) |
Adds a monochrome line to the packet list. | |
void | GsSortGLine (GsGLine *line) |
Adds a gradated line to the packet list. | |
void | GsSortDot (GsDot *dot) |
Adds a dot (pixel) to the packet list. | |
void | GsSortSprite (GsSprite *sprite) |
Adds a sprite to the packet list. | |
void | GsSortSimpleSprite (GsSprite *sprite) |
Always adds a REAL sprite to the packet list. | |
void | GsSortRectangle (GsRectangle *rectangle) |
Adds a rectangle to the packet list. | |
void | GsSortTPoly4 (GsTPoly4 *tpoly4) |
Adds a textured 4 point polygon to the packet list. | |
void | GsSortTPoly3 (GsTPoly3 *tpoly3) |
Adds a textured 3 point polygon to the packet list. | |
void | MoveImage (int src_x, int src_y, int dst_x, int dst_y, int w, int h) |
Moves image data from a part of the framebuffer to another. | |
void | LoadImage (void *img, int x, int y, int w, int h) |
Loads image data into framebuffer memory. | |
void | GsSetDrawEnv (GsDrawEnv *drawenv) |
Set drawing environment. | |
void | GsSetDispEnv (GsDispEnv *dispenv) |
Set display environment. | |
void | gpu_ctrl (unsigned int command, unsigned int param) |
Three functions which send data to the control port and to the data port. | |
void | gpu_data (unsigned int data) |
void | gpu_data_ctrl (unsigned int command, unsigned int param) |
unsigned int | GsListPos () |
Return pointer position in linked list. | |
void | GsEnableDisplay (int enable) |
Enables the display (i.e. | |
void | GsReset () |
Resets the GPU. | |
void | GsInitEx (unsigned int flags) |
Initializes the GPU. | |
void | GsInit () |
Initializes the GPU. | |
int | GsSetVideoMode (int width, int height, int video_mode) |
Sets a video mode and enables the display. | |
int | GsSetVideoModeEx (int width, int height, int video_mode, int rgb24, int inter, int reverse) |
Works like GsSetVideoMode() but offers more control. | |
void | DrawFBRect (int x, int y, int w, int h, int r, int g, int b) |
Draws a rectangle in the framebuffer, without considering drawing and display environments (i.e. | |
void | GsClearMem () |
Clear Video RAM. | |
int | GsImageFromTim (GsImage *image, void *timdata) |
Puts information about a TIM image passed in a buffer in a GsImage structure. | |
void | GsUploadImage (GsImage *image) |
Uploads an image described by a GsImage structure to video memory. | |
int | GsSpriteFromImage (GsSprite *sprite, GsImage *image, int do_upload) |
Fills a GsSprite structure with information from an image described by a GsImage structure, then optionally uploads data to video memory. | |
void | GsSetMasking (unsigned char flag) |
Sets masking settings. | |
int | GsIsDrawing () |
Checks if the GPU is drawing. | |
void | GsSetDrawEnvSimple (int x, int y, int w, int h) |
Sets drawing environment Enables drawing on the display area, disables dithering and disables all masking flags by default. | |
void | GsSetDispEnvSimple (int x, int y) |
Sets display environment. | |
void | GsLoadFont (int fb_x, int fb_y, int cx, int cy) |
Loads the built-in 8x8 font in Video RAM at the specified coordinates. | |
unsigned int | GsPrintFont_Draw (int x, int y, int scalex, int scaley) |
unsigned int | GsVPrintFont (int x, int y, const char *fmt, va_list ap) |
Prints string using 8x8 font at screen coordinates x, y Apart from using a variable argument list, this function is identical to GsPrintFont() | |
unsigned int | GsPrintFont (int x, int y, const char *fmt,...) |
Prints string using 8x8 font at screen coordinates x, y. | |
void | GsSetFont (int fb_x, int fb_y, int cx, int cy) |
Change font coordinates without reloading it. | |
void | GsSetFontAttrib (unsigned int flags) |
This is a function that sets an internal variable flags should be specified as an OR mask. | |
int | GsIsWorking () |
Checks if the GPU is working. | |
void | GsSortCls (int r, int g, int b) |
Clear the entire drawing area with specified color. | |
void | GsSetAutoWait () |
Makes non-blocking gpu functions like GsDrawList() wait for completion. | |
void | GsRotateVector (int x_a, int y_a, int z_a, double *v, double *n) |
This function can rotate a vector about the X, Y and Z axes If you don't want to rotate a vector about an axis, pass 0 as angle to that axis. | |
void | GsSetListEx (unsigned int *listptr, unsigned int listpos) |
Assigns the internal pointer to the primitive list to the desired one, an sets the linked list position counter to the specified value. | |
void | GsSortPolyLine (GsPolyLine *line) |
Adds a monochrome polyline to the packet list. | |
void | GsSortGPolyLine (GsGPolyLine *line) |
Adds a gradated polyline to the packet list. | |
void | GsSortGTPoly4 (GsGTPoly4 *tpoly4) |
Adds a gradated 4 point polygon to the packet list. | |
void | GsSortGTPoly3 (GsGTPoly3 *tpoly3) |
Adds a gradated textured 3 point polygon to the packet list. | |
Variables | |
volatile int | __psxsdk_gpu_dma_finished |
int | fb_font_x |
int | fb_font_y |
int | fb_font_cx |
int | fb_font_cy |
unsigned short | GsScreenW |
This global variable reports the current screen width, as set by GsSetVideoMode(). | |
unsigned short | GsScreenH |
This global variable reports the current screen height, as set by GsSetVideoMode(). | |
unsigned char | GsScreenM |
This global variable reports the current screen color mode (PAL or NTSC), as set by GsSetVideoMode(). | |
unsigned short | GsCurDrawEnvW |
This global variable reports the width of the current drawing environment. | |
unsigned short | GsCurDrawEnvH |
This global variable reports the height of the current drawing environment. | |
double | gs_vbuf [4][3] |
unsigned int | draw_mode_packet |
#define D2_BCR *((unsigned int*)0x1f8010a4) |
#define D2_CHCR *((unsigned int*)0x1f8010a8) |
#define D2_MADR *((unsigned int*)0x1f8010a0) |
#define DPCR *((unsigned int*)0x1f8010f0) |
#define get_clutid | ( | cx, | |
cy | |||
) | (((cx&0x3ff)>>4)|((cy&0x1ff)<<6)) |
#define GPU_CONTROL_PORT *((unsigned int*)GPU_CONTROL_PORT_ADDR) |
#define GPU_CONTROL_PORT_ADDR 0x1f801814 |
#define GPU_DATA_PORT *((unsigned int*)GPU_DATA_PORT_ADDR) |
#define GPU_DATA_PORT_ADDR 0x1f801810 |
void DrawFBRect | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
int | r, | ||
int | g, | ||
int | b | ||
) |
Draws a rectangle in the framebuffer, without considering drawing and display environments (i.e.
it does so in an absolute way)
x | Top-left X coordinate of area |
y | Top-left Y coordinate of area |
w | Area width |
h | Area height |
r | Red (0 - 255) |
g | Green (0 - 255) |
b | Blue (0 - 255) |
void gpu_ctrl | ( | unsigned int | command, |
unsigned int | param | ||
) |
Three functions which send data to the control port and to the data port.
void gpu_data | ( | unsigned int | data | ) |
void gpu_data_ctrl | ( | unsigned int | command, |
unsigned int | param | ||
) |
int gs_calculate_scaled_size | ( | int | size, |
int | scale | ||
) |
void GsClearMem | ( | void | ) |
Clear Video RAM.
void GsDrawList | ( | void | ) |
Draws the primitive list.
This also has the effect of resetting the current drawing list position.
void GsDrawListPIO | ( | void | ) |
Draws the primitive list using port I/O access.
GsDrawList() uses DMA to transfer the primitive data in the linked list to the GPU.
This function which is of main interest to low-level programmers, uses GPU port I/O access instead, and it is slower (as reads and writes must be done by the main CPU), but works in all situations, even when you can't get DMA working.
This function due to its nature is blocking, and always waits for completion.
void GsEnableDisplay | ( | int | enable | ) |
Enables the display (i.e.
generation of video output).
Unless you are doing low-level GPU programming, you don't need to call this function; the display is enabled automatically by GsSetVideoMode().
enable | If TRUE (>=1) the display will be enabled, if FALSE (== 0) it will be disabled |
int GsImageFromTim | ( | GsImage * | image, |
void * | timdata | ||
) |
Puts information about a TIM image passed in a buffer in a GsImage structure.
void GsInit | ( | void | ) |
Initializes the GPU.
Same as GsInitEx(0)
The display is left disabled. You can enable it with GsEnableDisplay() or more preferably with GsSetVideoMode()
void GsInitEx | ( | unsigned int | flags | ) |
Initializes the GPU.
The display is left disabled. You can enable it with GsEnableDisplay() or more preferably with GsSetVideoMode()
flags | Flag bitmask |
int GsIsDrawing | ( | void | ) |
Checks if the GPU is drawing.
int GsIsWorking | ( | void | ) |
unsigned int GsListPos | ( | void | ) |
Return pointer position in linked list.
void GsLoadFont | ( | int | fb_x, |
int | fb_y, | ||
int | cx, | ||
int | cy | ||
) |
Loads the built-in 8x8 font in Video RAM at the specified coordinates.
Specifying cx and cy as -1 will not load the black&white CLUT to video memory. Use GsSetFont() to specify clut x and clut y in that case.
The font occupies a space of 16x128 pixels in 16-bit mode, and 64x128 in 4-bit mode.
fb_x | X coordinate in framebuffer |
fb_y | Y coordinate in framebuffer |
cx | X coordinate of black/white CLUT in framebuffer |
cy | Y coordinate of black/white CLUT in framebuffer |
unsigned int GsPrintFont | ( | int | x, |
int | y, | ||
const char * | fmt, | ||
... | |||
) |
Prints string using 8x8 font at screen coordinates x, y.
x | X coordinate |
y | Y coordinate |
fmt | format (like *printf()) |
unsigned int GsPrintFont_Draw | ( | int | x, |
int | y, | ||
int | scalex, | ||
int | scaley | ||
) |
void GsReset | ( | void | ) |
Resets the GPU.
void GsRotateVector | ( | int | x_a, |
int | y_a, | ||
int | z_a, | ||
double * | v, | ||
double * | n | ||
) |
This function can rotate a vector about the X, Y and Z axes If you don't want to rotate a vector about an axis, pass 0 as angle to that axis.
It is correct to pass the same argument to v and n, as calculations are first done in an internal buffer and then stored in the output array
x_a | Number of degrees (0-359) to which the vector should be rotated about the X axis |
y_a | Number of degrees (0-359) to which the vector should be rotated about the Y axis |
z_a | Number of degrees (0-359) to which the vector should be rotated about the Z axis |
v | Pointer to an array of coordinates for the source vector |
n | Pointer to destination array for the coordinates of the rotated vector |
void GsSetAutoWait | ( | void | ) |
Makes non-blocking gpu functions like GsDrawList() wait for completion.
Removes the need to use GsIsDrawing()/GsIsWorking()
void GsSetDispEnv | ( | GsDispEnv * | dispenv | ) |
Set display environment.
dispenv | Pointer to display environment structure |
void GsSetDispEnvSimple | ( | int | x, |
int | y | ||
) |
Sets display environment.
x | Top-left X coordinate of framebuffer area to display |
y | Top-left Y coordinate of framebuffer area to display |
void GsSetDrawEnv | ( | GsDrawEnv * | drawenv | ) |
Set drawing environment.
drawenv | Pointer to drawing environment structure |
void GsSetDrawEnvSimple | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
Sets drawing environment Enables drawing on the display area, disables dithering and disables all masking flags by default.
x | Top-left X coordinate of framebuffer area to use for drawing |
y | Top-left Y coordinate of framebuffer area to use for drawing |
w | Width of area |
h | Height of area |
void GsSetFont | ( | int | fb_x, |
int | fb_y, | ||
int | cx, | ||
int | cy | ||
) |
Change font coordinates without reloading it.
void GsSetFontAttrib | ( | unsigned int | flags | ) |
This is a function that sets an internal variable flags should be specified as an OR mask.
to set the wrap and scale attributes, with X scaling factor 2 and Y scaling factor 3, for example: GsSetFontAttrib(PRFONT_WRAP | PRFONT_SCALE | PRFONT_SCALEX(2) | PRFONT_SCALEY(3));
to remove all attributes (normal printing):
GsSetFontAttrib(0);
PRFONT_WRAP can't coexist with PRFONT_CENTER or PRFONT_RIGHT PRFONT_CENTER and PRFONT_RIGHT are justifying attributes and as such they are mutually exclusive - they cannot coexist with each other. Specifying both will give priority to PRFONT_CENTER.
Attribute list:
PRFONT_WRAP - Wrap to next row when the text would fall off the screen Ideal for debug PRFONT_SCALE - Enable font scaling PRFONT_SCALEX(i) - Specifies the factor "i" as the X scaling factor This has the same meaning as a sprite's scaling factor PRFONT_SCALEY(i) - Specify the factor "i" as the Y scaling factor This has the same meaning as a sprite's scaling factor PRFONT_RIGHT - Justifies text to the right PRFONT_CENTER - Justifies text at the center PRFONT_RL(f) - Luminance factor for the red component PRFONT_GL(f) - Luminance factor for the green component PRFONT_BL(f) - Luminance factor for the blue component
void GsSetList | ( | unsigned int * | listptr | ) |
Assigns the internal pointer to the primitive list to the desired one, and resets the linked list position counter.
The memory address specified by your pointer has to have enough space free to contain all the packets which you want to send.
listptr | Pointer to primitive list |
void GsSetListEx | ( | unsigned int * | listptr, |
unsigned int | listpos | ||
) |
Assigns the internal pointer to the primitive list to the desired one, an sets the linked list position counter to the specified value.
The memory address specified by your pointer has to have enough space free to contain all the packets which you want to send, and you must ensure that the specified position is not out of bounds.
listptr | Pointer to primitive list |
listpos | List position |
void GsSetMasking | ( | unsigned char | flag | ) |
Sets masking settings.
flag | Bitwise flags |
int GsSetVideoMode | ( | int | width, |
int | height, | ||
int | video_mode | ||
) |
Sets a video mode and enables the display.
It does so in a quicker way than GsSetVideoModeEx(), which wants more arguments but offers greater control
width | Width
|
height | Height
|
video_mode | Video mode
|
int GsSetVideoModeEx | ( | int | width, |
int | height, | ||
int | video_mode, | ||
int | rgb24, | ||
int | inter, | ||
int | reverse | ||
) |
Works like GsSetVideoMode() but offers more control.
Interlaced, 24-bit RGB, and "reverse" flags can be specified.
width | Width
|
height | Height
|
video_mode | Video mode
|
rgb24 | 24-bit RGB mode
|
inter | Interlacing
|
reverse | Reverse??
|
void GsSortCls | ( | int | r, |
int | g, | ||
int | b | ||
) |
Clear the entire drawing area with specified color.
r | Red (0 - 255) |
g | Green (0 - 255) |
b | Blue (0 - 255) |
void GsSortDot | ( | GsDot * | dot | ) |
Adds a dot (pixel) to the packet list.
dot | Pointer to structure for dot |
void GsSortGLine | ( | GsGLine * | line | ) |
Adds a gradated line to the packet list.
line | Pointer to structure for gradated line |
void GsSortGPoly3 | ( | GsGPoly3 * | poly3 | ) |
Adds a gradated 3 point polygon to the packet list.
poly3 | Pointer to structure for gradated 3 point polygon |
void GsSortGPoly4 | ( | GsGPoly4 * | poly4 | ) |
Adds a gradated 4 point polygon to the packet list.
poly4 | Pointer to structure for gradated 4 point polygon |
void GsSortGPolyLine | ( | GsGPolyLine * | line | ) |
Adds a gradated polyline to the packet list.
line | Pointer to structure for monochrome line |
void GsSortGTPoly3 | ( | GsGTPoly3 * | tpoly3 | ) |
Adds a gradated textured 3 point polygon to the packet list.
tpoly3 | Pointer to structure for textured 3 point polygon |
void GsSortGTPoly4 | ( | GsGTPoly4 * | tpoly4 | ) |
Adds a gradated 4 point polygon to the packet list.
tpoly4 | Pointer to structure for textured 4 point polygon |
void GsSortLine | ( | GsLine * | line | ) |
Adds a monochrome line to the packet list.
line | Pointer to structure for monochrome line |
void GsSortPoly3 | ( | GsPoly3 * | poly3 | ) |
Adds a monochrome 3 point polygon to the packet list.
poly3 | Pointer to structure for monochrome 3 point polygon |
void GsSortPoly4 | ( | GsPoly4 * | poly4 | ) |
Adds a monochrome 4 point polygon to the packet list.
poly4 | Pointer to structure for monochrome 4 point polygon |
void GsSortPolyLine | ( | GsPolyLine * | line | ) |
Adds a monochrome polyline to the packet list.
line | Pointer to structure for monochrome polyline |
void GsSortRectangle | ( | GsRectangle * | rectangle | ) |
Adds a rectangle to the packet list.
rectangle | Pointer to structure for rectangle |
void GsSortSimpleSprite | ( | GsSprite * | sprite | ) |
Always adds a REAL sprite to the packet list.
sprite | Pointer to structure for sprite |
void GsSortSprite | ( | GsSprite * | sprite | ) |
Adds a sprite to the packet list.
sprite | Pointer to structure for sprite |
void GsSortTPoly3 | ( | GsTPoly3 * | tpoly3 | ) |
Adds a textured 3 point polygon to the packet list.
tpoly3 | Pointer to structure for textured 3 point polygon |
void GsSortTPoly4 | ( | GsTPoly4 * | tpoly4 | ) |
Adds a textured 4 point polygon to the packet list.
tpoly4 | Pointer to structure for textured 4 point polygon |
void GsUploadImage | ( | GsImage * | image | ) |
Uploads an image described by a GsImage structure to video memory.
unsigned int GsVPrintFont | ( | int | x, |
int | y, | ||
const char * | fmt, | ||
va_list | ap | ||
) |
Prints string using 8x8 font at screen coordinates x, y Apart from using a variable argument list, this function is identical to GsPrintFont()
x | X coordinate |
y | Y coordinate |
fmt | format (like *printf()) |
ap | Variable argument list |
void LoadImage | ( | void * | img, |
int | x, | ||
int | y, | ||
int | w, | ||
int | h | ||
) |
Loads image data into framebuffer memory.
img | Pointer to raw image data |
x | Top-left X coordinate of destination area |
y | Top-left Y coordinate of destination area |
w | Width of image data |
h | Height of image data |
void MoveImage | ( | int | src_x, |
int | src_y, | ||
int | dst_x, | ||
int | dst_y, | ||
int | w, | ||
int | h | ||
) |
Moves image data from a part of the framebuffer to another.
Actually it does a copy.
src_x | Top-left X coordinate of source area |
src_y | Top-left Y coordinate of source area |
dst_x | Top-left X coordinate of destination area |
dst_y | Top-left Y coordinate of destination area |
w | Width of area |
h | Height of area |
unsigned int PRFONT_BL | ( | unsigned char | f | ) |
unsigned int PRFONT_GL | ( | unsigned char | f | ) |
unsigned int PRFONT_RL | ( | unsigned char | f | ) |
unsigned int PRFONT_SCALEX | ( | int | i | ) |
unsigned int PRFONT_SCALEY | ( | int | i | ) |
unsigned int setup_attribs | ( | unsigned char | tpage, |
unsigned int | attribute, | ||
unsigned char * | packet | ||
) |
volatile int __psxsdk_gpu_dma_finished |
unsigned int draw_mode_packet |
int fb_font_cx |
int fb_font_cy |
int fb_font_x |
int fb_font_y |
double gs_vbuf[4][3] |
unsigned short GsCurDrawEnvH |
This global variable reports the height of the current drawing environment.
unsigned short GsCurDrawEnvW |
This global variable reports the width of the current drawing environment.
unsigned short GsScreenH |
This global variable reports the current screen height, as set by GsSetVideoMode().
Do not modify.
unsigned char GsScreenM |
This global variable reports the current screen color mode (PAL or NTSC), as set by GsSetVideoMode().
You can use the values in the psx_gpu_vmodes enum to evaluate this. Do not modify.
unsigned short GsScreenW |
This global variable reports the current screen width, as set by GsSetVideoMode().
Do not modify.