22#include <osd_config.h>
26#define posixIODriver { open, close, (int (*)(int, void *, int))read, O_RDONLY }
30 static int default_signal = -1;
33 if(default_signal < 0)
35 _io_driver driver = posixIODriver;
36 GetRomNameWithIODriver((
char *)romname, &driver);
43 return default_signal;
73static void gsKit_set_buffer_attributes(GSGLOBAL *
gsGlobal)
75 int gs_DX, gs_DY, gs_DW, gs_DH;
212 if(GetSyscallHandler(__NR__GetGsDxDyOffset))
214 _GetGsDxDyOffset(
gsGlobal->
Mode, &gs_DX, &gs_DY, &gs_DW, &gs_DH);
248 gsKit_set_buffer_attributes(
gsGlobal);
251 printf(
"Screen Mode:\n");
252 printf(
"------------\n");
265 __asm__(
"sync.p; nop;");
269 GsPutIMR(0x00007F00);
347 p_data = p_store = (u64 *)
gsGlobal->dma_misc;
446 *p_data++ = GS_SETREG_TEXA(0x00, 0, 0x80);
471 s8 dither_matrix[16] = {4,2,5,3,0,6,1,7,5,3,4,2,1,7,0,6};
474 GSGLOBAL *
gsGlobal = calloc(1,
sizeof(GSGLOBAL));
483 _io_driver driver = posixIODriver;
529 for(i = 0; i < 15; i++) {
558void gsKit_deinit_global(GSGLOBAL *
gsGlobal)
void dmaKit_wait_fast(void)
void dmaKit_send_ucab(u16 channel, void *data, u32 size)
#define GS_CMODE_CLAMP
Stretches Texture Across the Surface.
void gsKit_queue_reset(GSQUEUE *Queue)
Reset specified drawqueue to it's initial state (Useful for clearing the Persistent Queue).
void gsKit_clear(GSGLOBAL *gsGlobal, u64 Color)
u32 gsKit_vram_alloc(GSGLOBAL *gsGlobal, u32 size, u8 type)
GS VRAM Allocation.
void gsKit_free_ucab(void *p)
Free UCAB buffer in GSQUEUE, internal use only.
void gsKit_queue_free(GSGLOBAL *gsGlobal, GSQUEUE *Queue)
Free Allocated Memory for Draw Queue.
void gsKit_queue_init(GSGLOBAL *gsGlobal, GSQUEUE *Queue, u8 mode, int size)
Initialize a Draw Queue (Allocates memory for the Queue).
void gsKit_queue_exec(GSGLOBAL *gsGlobal)
Normal User Draw Queue "Execution" (Kicks Oneshot and Persistent Queues).
#define GSKIT_ALLOC_SYSBUFFER
GS VRAM "System" Allocation (Framebuffer, ZBuffer, etc).
void gsKit_sync_flip(GSGLOBAL *gsGlobal)
void * gsKit_alloc_ucab(int size)
Allocate UCAB buffer in GSQUEUE, internal use only.
#define GS_MODE_VGA_800_60
VGA 800x600 @ 60Hz.
#define GS_MODE_VGA_800_75
VGA 800x600 @ 75Hz.
#define GS_ASPECT_4_3
4:3 Aspect Ratio (UNUSED)
#define GS_SETREG_XYOFFSET_1
See GS_SETREG_XYOFFSET.
#define GS_SET_PMODE(EN1, EN2, MMOD, AMOD, SLBG, ALP)
GS PCRTC (Merge Circuit) Register Access Macro.
#define GS_FRAME_1
GS Frame Buffer (Context 1).
#define GS_MODE_VGA_800_56
VGA 800x600 @ 56Hz.
#define GS_NONINTERLACED
Non-Interlaced Mode.
#define GS_DTHE
GS Dither Control.
#define GS_PSMZ_16S
RGBA16 ZBuffer ?
GSGLOBAL * gsKit_init_global_custom(int Os_AllocSize, int Per_AllocSize)
Initialize gsGlobal (With Specified Sizes (In Bytes) for the Persistent and Oneshot drawbuffers).
void gsKit_init_screen(GSGLOBAL *gsGlobal)
Initialize Screen and GS Registers.
#define GS_SETREG_COLCLAMP(clamp)
GS COLCLAMP Packing Macro.
#define GS_CLAMP_2
GS Texture Wrap Mode (Context 2).
#define GS_PER_OS
Draw Persistent objects first, before oneshot objects.
#define GS_FRAME_2
GS Frame Buffer (Context 2).
#define GS_PSM_CT16S
RGBA16 Texture ?
#define GS_SETREG_TEST(ate, atst, aref, afail, date, datm, zte, ztst)
GS TEST Packing Macro.
#define GS_MODE_DTV_480P
DTV 480 Progressive Scan (720x480).
#define GS_PSMZ_32
R8 G8 B8 A8 (RGBA32) ZBuffer.
#define GS_PRMODECONT
GS Primitive Attribute Setting Mode.
#define GS_SET_SMODE2(INT, FFMD, DPMS)
Setting For Modes Related to Video Synchronization.
#define GS_MODE_VGA_1280_75
VGA 1280x1024 @ 75Hz.
#define GS_SET_DISPLAY1(DX, DY, MAGH, MAGV, DW, DH)
GS Display Settings Register Access Macro (Output Circuit 1).
#define GS_MODE_NTSC
NTSC Full Buffer.
#define GS_CLAMP_1
GS Texture Wrap Mode (Context 1).
#define GS_FRAME
Frame Mode - Reads Every Line.
#define GS_SETREG_ZBUF_1
See GS_SETREG_ZBUF.
void gsKit_set_display_offset(GSGLOBAL *gsGlobal, int x, int y)
Position the framebuffer onto the display.
#define GS_SETREG_RGBAQ(r, g, b, a, q)
Object Creation Macro for RGBAQ Color Values.
#define GS_MODE_VGA_1280_60
VGA 1280x1024 @ 60Hz.
#define GS_MODE_PAL
PAL Full Buffer.
#define GS_BLEND_BACK2FRONT
Blend Alpha Primitives "Back To Front".
#define GS_MODE_VGA_1024_70
VGA 1024x768 @ 70Hz.
#define GS_SETTING_OFF
Define a setting to be OFF.
#define GIF_TAG(NLOOP, EOP, PRE, PRIM, FLG, NREG)
DMA Packet Header "GIF Tag" For Packets Sent To GIF.
#define GS_XYOFFSET_2
GS Offset Value.
#define GS_DIMX
GS Dither Matrix.
short int gsKit_check_rom(void)
Checks the console's capabilities based on the ROM version (returns default video format: GS_MODE_NTS...
#define GS_MODE_VGA_800_72
VGA 800x600 @ 72Hz.
#define GS_PSM_CT24
R8 G8 B8 (RGB24) Texture.
#define GS_COLCLAMP
GS Color Clamp.
#define GS_SETTING_ON
Define a setting to be ON.
#define GS_ZBUF_1
GS Z Buffer (Context 1).
#define GS_TEXA
GS Texture Alpha Value.
#define GS_MODE_VGA_640_72
VGA 640x480 @ 72Hz.
#define GS_ONESHOT
Oneshot Draw Queue.
#define GS_MODE_DTV_720P
DTV 720 Progressive Scan (1280x720).
#define GS_MODE_DTV_576P
DTV 576 Progressive Scan (720x576).
#define GS_ASPECT_16_9
16:9 Aspect Ratio (UNUSED)
#define GIF_AD
GIF_TAG Address+Data Setting. (Used after GIF_TAG).
#define GS_MODE_VGA_640_75
VGA 640x480 @ 65Hz.
#define GS_PERSISTENT
Persistent Draw Queue.
#define GS_SCISSOR_2
GS Scissoring Area (Context 2).
#define GS_SCISSOR_1
GS Scissoring Area (Context 1).
#define GS_SET_DISPFB1(FBP, FBW, PSM, DBX, DBY)
GS Framebuffer Register Access Macro (Output Circuit 1).
#define GS_RESET()
GS Reset Macro.
#define GS_TEST_1
GS TEST (Context 1).
#define GS_SET_DISPLAY2(DX, DY, MAGH, MAGV, DW, DH)
GS Display Settings Register Access Macro (Output Circuit 2).
#define GS_MODE_DTV_1080I
DTV 1080 Interlaced (1920x1080).
#define GS_MODE_VGA_640_85
VGA 640x480 @ 85Hz.
#define GS_ALPHA_2
GS Alpha Blending (Context 2).
#define GS_PSMZ_16
RGBA16 ZBuffer.
#define GS_TEST_2
GS TEST (Context 2).
#define GS_MODE_VGA_1024_60
VGA 1024x768 @ 60Hz.
#define GS_SET_BGCOLOR(R, G, B)
GS Background Color Register Access Macro.
#define GS_SETREG_SCISSOR_1
See GS_SETREG_SCISSOR.
#define GS_ALPHA_1
GS Alpha Blending (Context 1).
#define GS_SETREG_CLAMP(wms, wmt, minu, maxu, minv, maxv)
GS CLAMP Packing Macro.
#define GS_XYOFFSET_1
GS Offset Value.
#define GS_ZBUF_2
GS Z Buffer (Context 2).
#define GS_MODE_VGA_1024_75
VGA 1024x768 @ 75Hz.
#define GS_SETREG_FRAME_1
See GS_SETREG_FRAME.
#define GS_MODE_VGA_1024_85
VGA 1024x768 @ 85Hz.
#define GS_INTERLACED
Interlaced Mode.
#define GS_FIELD
Field Mode - Reads Every Other Line.
#define GS_MODE_VGA_640_60
VGA 640x480 @ 60Hz.
#define GS_SET_DISPFB2(FBP, FBW, PSM, DBX, DBY)
GS Framebuffer Register Access Macro (Output Circuit 2).
#define GS_SETREG_DIMX(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)
GS DIMX Packing Macro from dma.h in ps2sdk.
#define GS_MODE_VGA_800_85
VGA 800x600 @ 85Hz.
#define GS_CSR
GS CSR (GS System Status) Register.
#define GS_PSM_CT16
RGBA16 Texture.
#define GSKIT_GIF_FLG_PACKED
gsKit GIFTAG data format "FLG"
int MAXU
Maximum Horizontal Clamp Value.
int MINV
Minimum Vertical Clamp Value.
u8 WMS
Wrap Mode Horizontal.
u8 WMT
Wrap Mode Vertical.
int MAXV
Maximum Vertical Clamp Value.
int MINU
Minimum Horizontal Clamp Value.
u8 ActiveBuffer
Active Framebuffer.
int PrimAlphaEnable
Primitive Alpha Blending Enable.
u8 EvenOrOdd
Is ((GSREG*)CSR)->FIELD (Used for Interlace Correction).
u8 ZBuffering
Enable/Disable Z Buffering.
int Width
Framebuffer Width (the mode's DW is a multiple of this value).
u32 CurrentPointer
Current VRAM Pointer.
int MagH
X Magnification Value (MAGH = DW / Width - 1).
int Per_AllocSize
Persistent Drawbuffer Size (Per Buffer).
GSBGCOLOR * BGColor
Background Color Structure Pointer.
int Os_AllocSize
Oneshot Drawbuffer Size (Per Buffer).
u8 Dithering
Dithering (On/Off).
GSTEST * Test
TEST Register Value Structure Pointer.
int PrimContext
Primitive Context.
GSQUEUE * CurQueue
Draw Queue (Current).
int Aspect
Framebuffer Aspect Ratio (GS_ASPECT_4_3/GS_ASPECT_16_9).
int PSMZ
ZBuffer Pixel Storage Method.
u32 TexturePointer
Pointer to beginning of Texture Buffer.
u8 DoubleBuffering
Enable/Disable Double Buffering.
int StartYOffset
Y Starting Coordinate (Used for Placement Correction) Additional correction.
int StartXOffset
X Starting Coordinate (Used for Placement Correction) Additional correction.
GSQUEUE * Os_Queue
Draw Queue (Oneshot).
int OffsetX
X Window Offset.
int DW
Total Display Area Width (DW = Width * (MAGH + 1)).
u32 ScreenBuffer[2]
Screenbuffer Pointer Array.
int StartX
X Starting Coordinate (Used for Placement Correction) Default value.
int PSM
Pixel Storage Method (Color Mode).
u8 DrawOrder
Drawing Order (GS_PER_OS/GS_OS_PER) (GS_PER_OS = Persitant objects always drawn first).
int MagV
Y Magnification Value (MAGV = DH / Height - 1).
int Height
Framebuffer Height (the mode's DH is a multiple of this value).
u64 PrimAlpha
Primitive Alpha Value.
int PrimFogEnable
Primitive Fog Enable.
GSCLAMP * Clamp
CLAMP Register Value Structure Pointer.
int PrimAAEnable
Primitive AntiAlaising Enable.
int OffsetY
Y Window Offset.
u32 ZBuffer
ZBuffer Pointer.
s8 DitherMatrix[16]
Dithering Matrix.
u8 FirstFrame
Have we executed a frame yet?
int DH
Total Display Area Height (DH = Height * (MAGH + 1)).
s16 Interlace
Interlace (On/Off).
int StartY
Y Starting Coordinate (Used for Placement Correction) Default value.
GSQUEUE * Per_Queue
Draw Queue (Persistent).
volatile u8 LockBuffer
Used to lock the buffer so it doesn't switch.
u8 ATST
Alpha Test Method.
u8 ZTE
Depth Test Enable (DO NOT USE THIS - IT IS BUGGED IN PARTICULAR GS REV - SET TO 1 ALWAYS).
u8 DATE
Destination Alpha Enable.
u8 DATM
Destination Alpha Mode.
u8 ZTST
Depth Test Method.
u8 AREF
Alpha Reference Value.
u8 AFAIL
Alpha Failure Action.