sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
gsCore.h File Reference
#include "gsKit.h"

Go to the source code of this file.

Classes

struct  gsVertex
 Basic X/Y/Z Vertex Structure. More...

Macros

#define GSKIT_ALLOC_SYSBUFFER   0x00
 GS VRAM "System" Allocation (Framebuffer, ZBuffer, etc).
#define GSKIT_ALLOC_USERBUFFER   0x01
 GS VRAM "User" Allocation (Texture, CLUT, etc).
#define GSKIT_ALLOC_ERROR   0x00
 Return this is VRAM allocation fails.
#define GS_GIF_BLOCKSIZE   0x7fff
 GS GIF Data Transfer Blocksize.
#define GS_VRAM_BLOCKSIZE_8K   8192
 VRAM Allcoate Blocksize (For System Buffers)(CRITICAL FOR VRAM ALIGNMENT).
#define GS_VRAM_BLOCKSIZE_256   256
 VRAM Allcoate Blocksize (For User Textures)(CRITICAL FOR VRAM ALIGNMENT).
#define GS_VRAM_TBWALIGN   64
 Texture Base Width Allocation Allignment (32/24/16 Bit Textures).
#define GS_VRAM_TBWALIGN_CLUT   128
 Texture Base Width Allocation Allignment (8/4 Bit CLUT Textures).
#define GS_CMODE_REPEAT   0x00
 Repeats ("Tiles") Texture Across the Surface.
#define GS_CMODE_CLAMP   0x01
 Stretches Texture Across the Surface.
#define GS_CMODE_REGION_CLAMP   0x02
 Stretches Texture Across the Region Defined by MINU, MAXU, MINV, and MAXV.
#define GS_CMODE_REGION_REPEAT   0x03
 Repeats a Portion of the Texture Defined by UMSK (MINU), VMSK (MINV), UFIX (MAXU), and VFIX (MAXV).
#define GS_CMODE_RESET   0xFF
 Resets CLAMP vales to whatever is in gsGlobal->Clamp.
#define GS_SCISSOR_RESET   0x00
 Resets SCISSOR values to the entire display bounds.
#define GS_ZTEST_OFF   0x01
 Turns off Z Testing.
#define GS_ZTEST_ON   0x02
 Turns on Z Testing.
#define GS_ATEST_OFF   0x03
 Turns off Alpha Testing (Source).
#define GS_ATEST_ON   0x04
 Turns on Alpha Testing (Source).
#define GS_D_ATEST_OFF   0x05
 Turns off Alpha Testing (Destination).
#define GS_D_ATEST_ON   0x06
 Turns on Alpha Testing (Destination).
#define GS_FILTER_NEAREST   0x00
 Use simple filtering (nearest neighbor).
#define GS_FILTER_LINEAR   0x01
 Use bilinear filter on texture.
#define GS_CLUT_STORAGE_CSM1   0x00
 Use clut storage mode CSM1.
#define GS_CLUT_STORAGE_CSM2   0x01
 Use clut storage mode CSM2.

Typedefs

typedef struct gsVertex GSVERTEX

Enumerations

enum  GSFLIP_MODE { GSFLIP_DIRECT = 0 , GSFLIP_VSYNC = 1 , GSFLIP_RATE_LIMIT_1 = 2 , GSFLIP_RATE_LIMIT_2 = 3 }
 Flip mode for gsKit_hires_flip_ext. More...

Functions

u32 gsKit_vram_alloc (GSGLOBAL *gsGlobal, u32 size, u8 type)
 GS VRAM Allocation.
void gsKit_vram_clear (GSGLOBAL *gsGlobal)
 GS VRAM Clear.
void gsKit_sync_flip (GSGLOBAL *gsGlobal)
void gsKit_lock_buffer (GSGLOBAL *gsGlobal)
void gsKit_unlock_buffer (GSGLOBAL *gsGlobal)
int gsKit_lock_status (GSGLOBAL *gsGlobal)
void gsKit_display_buffer (GSGLOBAL *gsGlobal)
void gsKit_switch_context (GSGLOBAL *gsGlobal)
void gsKit_setactive (GSGLOBAL *gsGlobal)
 Sets Your Active Framebuffer.
void gsKit_finish (void)
 Blocks until FINISH is triggered.
void gsKit_vsync_wait (void)
 Blocks Until a VSync.
void gsKit_hsync_wait (void)
 Blocks until a HSync.
void gsKit_vsync_nowait (void)
 Initiates a vsync but doesn't block.
int gsKit_add_vsync_handler (int(*vsync_callback)(int))
 Installs a vsync interrupt handler (vblank_start).
void gsKit_remove_vsync_handler (int callback_id)
 Removes a vsync interrupt handler.
int gsKit_add_hsync_handler (int(*hsync_callback)(int))
 Installs a hsync interrupt handler (hblank_start).
void gsKit_remove_hsync_handler (int callback_id)
 Removes a hsync interrupt handler.
int gsKit_add_finish_handler (int(*finish_callback)(int))
 Installs a finish interrupt handler.
void gsKit_remove_finish_handler (int callback_id)
 Removes a finish interrupt handler.
void gsKit_get_field (GSGLOBAL *gsGlobal)
 Sets gsGlobal->EvenOrOdd depending on current field drawing.
void gsKit_set_drawfield (GSGLOBAL *gsGlobal, u8 field)
 Sets the GS to draw only on even/odd/both fields (from libgraph).
void gsKit_clear (GSGLOBAL *gsGlobal, u64 Color)
void gsKit_set_scissor (GSGLOBAL *gsGlobal, u64 ScissorBounds)
void gsKit_set_test (GSGLOBAL *gsGlobal, u8 Preset)
void gsKit_set_clamp (GSGLOBAL *gsGlobal, u8 Preset)
void gsKit_set_primalpha (GSGLOBAL *gsGlobal, u64 AlphaMode, u8 PerPixel)
 Sets the Alpha Blending Parameters.
void gsKit_set_texfilter (GSGLOBAL *gsGlobal, u8 FilterMode)
 Sets the Texture Filtering Parameters.
void gsKit_set_texclut (GSGLOBAL *gsGlobal, gs_texclut texClut)
 Sets the CLUT position specfications.
void gsKit_set_dither_matrix (GSGLOBAL *gsGlobal)
 Sets the Dither Matrix Setting.
void gsKit_set_dither (GSGLOBAL *gsGlobal)
 Enables/Disables dithering, with the gsGlobal Dithering option.
GSQUEUE gsKit_set_finish (GSGLOBAL *gsGlobal)
 Append the Current Queue with a GS_FINISH Register.
void gsKit_queue_reset (GSQUEUE *Queue)
 Reset specified drawqueue to it's initial state (Useful for clearing the Persistent Queue).
void gsKit_queue_exec (GSGLOBAL *gsGlobal)
 Normal User Draw Queue "Execution" (Kicks Oneshot and Persistent Queues).
void gsKit_queue_exec_real (GSGLOBAL *gsGlobal, GSQUEUE *Queue)
 Specific Draw Queue "Execution" (Kicks the Queue passed for the second argument).
void * gsKit_alloc_ucab (int size)
 Allocate UCAB buffer in GSQUEUE, internal use only.
void gsKit_free_ucab (void *p)
 Free UCAB buffer in GSQUEUE, internal use only.
void gsKit_queue_init (GSGLOBAL *gsGlobal, GSQUEUE *Queue, u8 mode, int size)
 Initialize a Draw Queue (Allocates memory for the Queue).
void gsKit_queue_free (GSGLOBAL *gsGlobal, GSQUEUE *Queue)
 Free Allocated Memory for Draw Queue.
void gsKit_queue_set (GSGLOBAL *gsGlobal, GSQUEUE *Queue)
 Set Current Draw Queue.
void gsKit_mode_switch (GSGLOBAL *gsGlobal, u8 mode)
 Set Current Draw Queue (Between GS_ONESHOT and GS_PERSISTENT).

Macro Definition Documentation

◆ GS_ATEST_OFF

#define GS_ATEST_OFF   0x03

Turns off Alpha Testing (Source).

Definition at line 62 of file gsCore.h.

◆ GS_ATEST_ON

#define GS_ATEST_ON   0x04

Turns on Alpha Testing (Source).

Definition at line 64 of file gsCore.h.

◆ GS_CLUT_STORAGE_CSM1

#define GS_CLUT_STORAGE_CSM1   0x00

Use clut storage mode CSM1.

Definition at line 76 of file gsCore.h.

◆ GS_CLUT_STORAGE_CSM2

#define GS_CLUT_STORAGE_CSM2   0x01

Use clut storage mode CSM2.

Definition at line 78 of file gsCore.h.

◆ GS_CMODE_CLAMP

#define GS_CMODE_CLAMP   0x01

Stretches Texture Across the Surface.

Definition at line 46 of file gsCore.h.

◆ GS_CMODE_REGION_CLAMP

#define GS_CMODE_REGION_CLAMP   0x02

Stretches Texture Across the Region Defined by MINU, MAXU, MINV, and MAXV.

Definition at line 48 of file gsCore.h.

◆ GS_CMODE_REGION_REPEAT

#define GS_CMODE_REGION_REPEAT   0x03

Repeats a Portion of the Texture Defined by UMSK (MINU), VMSK (MINV), UFIX (MAXU), and VFIX (MAXV).

Definition at line 50 of file gsCore.h.

◆ GS_CMODE_REPEAT

#define GS_CMODE_REPEAT   0x00

Repeats ("Tiles") Texture Across the Surface.

Definition at line 44 of file gsCore.h.

◆ GS_CMODE_RESET

#define GS_CMODE_RESET   0xFF

Resets CLAMP vales to whatever is in gsGlobal->Clamp.

Definition at line 52 of file gsCore.h.

◆ GS_D_ATEST_OFF

#define GS_D_ATEST_OFF   0x05

Turns off Alpha Testing (Destination).

Definition at line 66 of file gsCore.h.

◆ GS_D_ATEST_ON

#define GS_D_ATEST_ON   0x06

Turns on Alpha Testing (Destination).

Definition at line 68 of file gsCore.h.

◆ GS_FILTER_LINEAR

#define GS_FILTER_LINEAR   0x01

Use bilinear filter on texture.

Definition at line 73 of file gsCore.h.

◆ GS_FILTER_NEAREST

#define GS_FILTER_NEAREST   0x00

Use simple filtering (nearest neighbor).

Definition at line 71 of file gsCore.h.

◆ GS_GIF_BLOCKSIZE

#define GS_GIF_BLOCKSIZE   0x7fff

GS GIF Data Transfer Blocksize.

Definition at line 32 of file gsCore.h.

◆ GS_SCISSOR_RESET

#define GS_SCISSOR_RESET   0x00

Resets SCISSOR values to the entire display bounds.

Definition at line 55 of file gsCore.h.

◆ GS_VRAM_BLOCKSIZE_256

#define GS_VRAM_BLOCKSIZE_256   256

VRAM Allcoate Blocksize (For User Textures)(CRITICAL FOR VRAM ALIGNMENT).

Definition at line 37 of file gsCore.h.

◆ GS_VRAM_BLOCKSIZE_8K

#define GS_VRAM_BLOCKSIZE_8K   8192

VRAM Allcoate Blocksize (For System Buffers)(CRITICAL FOR VRAM ALIGNMENT).

Definition at line 35 of file gsCore.h.

◆ GS_VRAM_TBWALIGN

#define GS_VRAM_TBWALIGN   64

Texture Base Width Allocation Allignment (32/24/16 Bit Textures).

Definition at line 39 of file gsCore.h.

◆ GS_VRAM_TBWALIGN_CLUT

#define GS_VRAM_TBWALIGN_CLUT   128

Texture Base Width Allocation Allignment (8/4 Bit CLUT Textures).

Definition at line 41 of file gsCore.h.

◆ GS_ZTEST_OFF

#define GS_ZTEST_OFF   0x01

Turns off Z Testing.

Definition at line 58 of file gsCore.h.

◆ GS_ZTEST_ON

#define GS_ZTEST_ON   0x02

Turns on Z Testing.

Definition at line 60 of file gsCore.h.

◆ GSKIT_ALLOC_ERROR

#define GSKIT_ALLOC_ERROR   0x00

Return this is VRAM allocation fails.

Definition at line 29 of file gsCore.h.

◆ GSKIT_ALLOC_SYSBUFFER

#define GSKIT_ALLOC_SYSBUFFER   0x00

GS VRAM "System" Allocation (Framebuffer, ZBuffer, etc).

Definition at line 24 of file gsCore.h.

◆ GSKIT_ALLOC_USERBUFFER

#define GSKIT_ALLOC_USERBUFFER   0x01

GS VRAM "User" Allocation (Texture, CLUT, etc).

Definition at line 26 of file gsCore.h.

Typedef Documentation

◆ GSVERTEX

typedef struct gsVertex GSVERTEX

Definition at line 87 of file gsCore.h.

Enumeration Type Documentation

◆ GSFLIP_MODE

Flip mode for gsKit_hires_flip_ext.

Enumerator
GSFLIP_DIRECT 

Flip immediately, no vsync wait.

GSFLIP_VSYNC 

Wait for vsync before flipping.

GSFLIP_RATE_LIMIT_1 

Limit to 60fps (1 vsync per frame).

GSFLIP_RATE_LIMIT_2 

Limit to 30fps (2 vsyncs per frame).

Definition at line 90 of file gsCore.h.

Function Documentation

◆ gsKit_add_finish_handler()

int gsKit_add_finish_handler ( int(* finish_callback )(int))

Installs a finish interrupt handler.

Definition at line 219 of file gsCore.c.

◆ gsKit_add_hsync_handler()

int gsKit_add_hsync_handler ( int(* hsync_callback )(int))

Installs a hsync interrupt handler (hblank_start).

Definition at line 195 of file gsCore.c.

◆ gsKit_add_vsync_handler()

int gsKit_add_vsync_handler ( int(* vsync_callback )(int))

Installs a vsync interrupt handler (vblank_start).

Definition at line 171 of file gsCore.c.

◆ gsKit_alloc_ucab()

void * gsKit_alloc_ucab ( int size)

Allocate UCAB buffer in GSQUEUE, internal use only.

Definition at line 588 of file gsCore.c.

◆ gsKit_clear()

void gsKit_clear ( GSGLOBAL * gsGlobal,
u64 Color )

Clears the Screen With the Specified Color This actually just momentarily turns off Z Test, then draws a sprite with the given color at a Z depth of 0. It then restores whatever your previous Z Test settings were.

Definition at line 244 of file gsCore.c.

◆ gsKit_display_buffer()

void gsKit_display_buffer ( GSGLOBAL * gsGlobal)

Switches the currently displayed buffer for the current working buffer or front buffer with back buffer

Definition at line 135 of file gsCore.c.

◆ gsKit_finish()

void gsKit_finish ( void )

Blocks until FINISH is triggered.

Definition at line 115 of file gsCore.c.

◆ gsKit_free_ucab()

void gsKit_free_ucab ( void * p)

Free UCAB buffer in GSQUEUE, internal use only.

Definition at line 603 of file gsCore.c.

◆ gsKit_get_field()

void gsKit_get_field ( GSGLOBAL * gsGlobal)

Sets gsGlobal->EvenOrOdd depending on current field drawing.

Definition at line 160 of file gsCore.c.

◆ gsKit_hsync_wait()

void gsKit_hsync_wait ( void )

Blocks until a HSync.

Definition at line 165 of file gsCore.c.

◆ gsKit_lock_buffer()

void gsKit_lock_buffer ( GSGLOBAL * gsGlobal)

Sets the LockBuffer parameter of gsGlobal to GS_SETTING_ON Used with gsKit_unlock_buffer and gsKit_lock_status This enables you to lock your current working buffer so it isn't flipped while it's being worked on

Definition at line 120 of file gsCore.c.

◆ gsKit_lock_status()

int gsKit_lock_status ( GSGLOBAL * gsGlobal)

Returns the status of LockBuffer parameter of gsGlobal If it returns GS_SETTING_ON then the buffer is locked If it returns GS_SETTING_OFF then the buffer is unlocked

Definition at line 130 of file gsCore.c.

◆ gsKit_mode_switch()

void gsKit_mode_switch ( GSGLOBAL * gsGlobal,
u8 mode )

Set Current Draw Queue (Between GS_ONESHOT and GS_PERSISTENT).

Definition at line 657 of file gsCore.c.

◆ gsKit_queue_exec()

void gsKit_queue_exec ( GSGLOBAL * gsGlobal)

Normal User Draw Queue "Execution" (Kicks Oneshot and Persistent Queues).

Definition at line 567 of file gsCore.c.

◆ gsKit_queue_exec_real()

void gsKit_queue_exec_real ( GSGLOBAL * gsGlobal,
GSQUEUE * Queue )

Specific Draw Queue "Execution" (Kicks the Queue passed for the second argument).

Definition at line 509 of file gsCore.c.

◆ gsKit_queue_free()

void gsKit_queue_free ( GSGLOBAL * gsGlobal,
GSQUEUE * Queue )

Free Allocated Memory for Draw Queue.

Definition at line 634 of file gsCore.c.

◆ gsKit_queue_init()

void gsKit_queue_init ( GSGLOBAL * gsGlobal,
GSQUEUE * Queue,
u8 mode,
int size )

Initialize a Draw Queue (Allocates memory for the Queue).

Definition at line 612 of file gsCore.c.

◆ gsKit_queue_reset()

void gsKit_queue_reset ( GSQUEUE * Queue)

Reset specified drawqueue to it's initial state (Useful for clearing the Persistent Queue).

Definition at line 553 of file gsCore.c.

◆ gsKit_queue_set()

void gsKit_queue_set ( GSGLOBAL * gsGlobal,
GSQUEUE * Queue )

Set Current Draw Queue.

Definition at line 652 of file gsCore.c.

◆ gsKit_remove_finish_handler()

void gsKit_remove_finish_handler ( int callback_id)

Removes a finish interrupt handler.

Definition at line 233 of file gsCore.c.

◆ gsKit_remove_hsync_handler()

void gsKit_remove_hsync_handler ( int callback_id)

Removes a hsync interrupt handler.

Definition at line 209 of file gsCore.c.

◆ gsKit_remove_vsync_handler()

void gsKit_remove_vsync_handler ( int callback_id)

Removes a vsync interrupt handler.

Definition at line 185 of file gsCore.c.

◆ gsKit_set_clamp()

void gsKit_set_clamp ( GSGLOBAL * gsGlobal,
u8 Preset )

Sets the CLAMP Parameters This manipulates the CLAMP struture of gsGlobal according to the Preset value. It then sends the new CLAMP parameters to the GS to put it into effect.

Valid Presets Are:

GS_CMODE_REPEAT - Repeats ("Tiles") Texture Across the Surface.

GS_CMODE_CLAMP - Stretches Texture Across the Surface

GS_CMODE_REGION_REPEAT - Stretches Texture Across the Region Defined by MINU, MAXU, MINV, and MAXV

GS_CMODE_REGION_CLAMP - Repeats a Portion of the Texture Defined by UMSK (MINU), VMSK (MINV), UFIX (MAXU), and VFIX (MAXV)

Definition at line 318 of file gsCore.c.

◆ gsKit_set_dither()

void gsKit_set_dither ( GSGLOBAL * gsGlobal)

Enables/Disables dithering, with the gsGlobal Dithering option.

Definition at line 421 of file gsCore.c.

◆ gsKit_set_dither_matrix()

void gsKit_set_dither_matrix ( GSGLOBAL * gsGlobal)

Sets the Dither Matrix Setting.

Definition at line 404 of file gsCore.c.

◆ gsKit_set_drawfield()

void gsKit_set_drawfield ( GSGLOBAL * gsGlobal,
u8 field )

Sets the GS to draw only on even/odd/both fields (from libgraph).

Definition at line 440 of file gsCore.c.

◆ gsKit_set_finish()

GSQUEUE gsKit_set_finish ( GSGLOBAL * gsGlobal)

Append the Current Queue with a GS_FINISH Register.

Definition at line 491 of file gsCore.c.

◆ gsKit_set_primalpha()

void gsKit_set_primalpha ( GSGLOBAL * gsGlobal,
u64 AlphaMode,
u8 PerPixel )

Sets the Alpha Blending Parameters.

Definition at line 356 of file gsCore.c.

◆ gsKit_set_scissor()

void gsKit_set_scissor ( GSGLOBAL * gsGlobal,
u64 ScissorBounds )

Sets the SCISSOR Parameters

GS_SCISSOR_RESET resets scissor box to the entire display; otherwise, GS_SETREG_SCISSOR() provides a specific box.

Definition at line 270 of file gsCore.c.

◆ gsKit_set_test()

void gsKit_set_test ( GSGLOBAL * gsGlobal,
u8 Preset )

Sets the TEST Parameters This manipulates the TEST struture of gsGlobal according to the Preset value. It then sends the new TEST parameters to the GS to put it into effect.

Valid Presets Are:

GS_ZTEST_OFF - Turns off Z Testing

GS_ZTEST_ON - Turns on Z Testing

GS_ATEST_OFF - Turns off Alpha Testing (Source)

GS_ATEST_ON - Turns on Alpha Testing (Source)

GS_D_ATEST_OFF - Turns off Alpha Testing (Destination)

GS_D_ATEST_ON - Turns on Alpha Testing (Destination)

Definition at line 286 of file gsCore.c.

◆ gsKit_set_texclut()

void gsKit_set_texclut ( GSGLOBAL * gsGlobal,
gs_texclut texClut )

Sets the CLUT position specfications.

Definition at line 390 of file gsCore.c.

◆ gsKit_set_texfilter()

void gsKit_set_texfilter ( GSGLOBAL * gsGlobal,
u8 FilterMode )

Sets the Texture Filtering Parameters.

Definition at line 376 of file gsCore.c.

◆ gsKit_setactive()

void gsKit_setactive ( GSGLOBAL * gsGlobal)

Sets Your Active Framebuffer.

Definition at line 83 of file gsCore.c.

◆ gsKit_switch_context()

void gsKit_switch_context ( GSGLOBAL * gsGlobal)

Switches the current working buffer with the last displayed buffer or back buffer with front buffer

Definition at line 141 of file gsCore.c.

◆ gsKit_sync_flip()

void gsKit_sync_flip ( GSGLOBAL * gsGlobal)

Flips Framebuffers on VSync This calls gsKit_vsync_wait, then calls gsKit_setactive to swap your framebuffers.

It then sets your active PrimContext and ActiveBuffer appropriately.

Definition at line 63 of file gsCore.c.

◆ gsKit_unlock_buffer()

void gsKit_unlock_buffer ( GSGLOBAL * gsGlobal)

Sets the LockBuffer parameter of gsGlobal to GS_SETTING_OFF Used with gsKit_unlock_buffer and gsKit_lock_status This enables you to unlock your current working buffer so it can be flipped

Definition at line 125 of file gsCore.c.

◆ gsKit_vram_alloc()

u32 gsKit_vram_alloc ( GSGLOBAL * gsGlobal,
u32 size,
u8 type )

GS VRAM Allocation.

Definition at line 20 of file gsCore.c.

◆ gsKit_vram_clear()

void gsKit_vram_clear ( GSGLOBAL * gsGlobal)

GS VRAM Clear.

Definition at line 53 of file gsCore.c.

◆ gsKit_vsync_nowait()

void gsKit_vsync_nowait ( void )

Initiates a vsync but doesn't block.

Definition at line 155 of file gsCore.c.

◆ gsKit_vsync_wait()

void gsKit_vsync_wait ( void )

Blocks Until a VSync.

Definition at line 149 of file gsCore.c.