sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
gsInit.c
1// ____ ___ | / _____ _____
2// | __ | |___/ | |
3// |___| ___| | \ __|__ | gsKit Open Source Project.
4// ----------------------------------------------------------------------
5// Copyright 2004 - Chris "Neovanglist" Gilbert <Neovanglist@LainOS.org>
6// Licenced under Academic Free License version 2.0
7// Review gsKit README & LICENSE files for further details.
8//
9// gsInit.c - GS initialization and configuration routines.
10//
11// Parts taken from emoon's BreakPoint Demo Library
12//
13
14#include "gsKit.h"
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <malloc.h>
19#include <unistd.h>
20#include <fcntl.h>
21#include <kernel.h>
22#include <osd_config.h>
23#include <rom0_info.h>
24#include <syscallnr.h>
25
26#define posixIODriver { open, close, (int (*)(int, void *, int))read, O_RDONLY }
27
28short int gsKit_check_rom(void)
29{
30 static int default_signal = -1;
31 char romname[15];
32
33 if(default_signal < 0)
34 {
35 _io_driver driver = posixIODriver;
36 GetRomNameWithIODriver((char *)romname, &driver);
37 romname[14] = '\0';
38
39 //ROMVER string format: VVVVRTYYYYMMDD
40 default_signal = (romname[4] == 'E') ? GS_MODE_PAL : GS_MODE_NTSC;
41 }
42
43 return default_signal;
44}
45
46void gsKit_set_display_offset(GSGLOBAL *gsGlobal, int x, int y)
47{
50
52 // Do not change odd/even start position in interlaced mode
54 }
55
57 gsGlobal->StartX + gsGlobal->StartXOffset, // X position in the display area (in VCK unit
58 gsGlobal->StartY + gsGlobal->StartYOffset, // Y position in the display area (in Raster u
59 gsGlobal->MagH, // Horizontal Magnification
60 gsGlobal->MagV, // Vertical Magnification
61 gsGlobal->DW - 1, // Display area width
62 gsGlobal->DH - 1); // Display area height
63
65 gsGlobal->StartX + gsGlobal->StartXOffset, // X position in the display area (in VCK units)
66 gsGlobal->StartY + gsGlobal->StartYOffset, // Y position in the display area (in Raster units)
67 gsGlobal->MagH, // Horizontal Magnification
68 gsGlobal->MagV, // Vertical Magnification
69 gsGlobal->DW - 1, // Display area width
70 gsGlobal->DH - 1); // Display area height
71}
72
73static void gsKit_set_buffer_attributes(GSGLOBAL *gsGlobal)
74{
75 int gs_DX, gs_DY, gs_DW, gs_DH;
76
79
80 switch (gsGlobal->Mode) {
81 case GS_MODE_NTSC:
82 gsGlobal->StartX = 492;
83 gsGlobal->StartY = 34;
84 gsGlobal->DW = 2880;
85 gsGlobal->DH = 480;
86 break;
87 case GS_MODE_PAL:
88 gsGlobal->StartX = 520;
89 gsGlobal->StartY = 40;
90 gsGlobal->DW = 2880;
91 gsGlobal->DH = 576;
92 break;
94 gsGlobal->StartX = 280;
95 gsGlobal->StartY = 18;
96 gsGlobal->DW = 1280;
97 gsGlobal->DH = 480;
98 break;
100 gsGlobal->StartX = 330;
101 gsGlobal->StartY = 18;
102 gsGlobal->DW = 1280;
103 gsGlobal->DH = 480;
104 break;
106 gsGlobal->StartX = 360;
107 gsGlobal->StartY = 18;
108 gsGlobal->DW = 1280;
109 gsGlobal->DH = 480;
110 break;
112 gsGlobal->StartX = 260;
113 gsGlobal->StartY = 18;
114 gsGlobal->DW = 1280;
115 gsGlobal->DH = 480;
116 break;
118 gsGlobal->StartX = 450;
119 gsGlobal->StartY = 25;
120 gsGlobal->DW = 1600;
121 gsGlobal->DH = 600;
122 break;
125 gsGlobal->StartX = 465;
126 gsGlobal->StartY = 25;
127 gsGlobal->DW = 1600;
128 gsGlobal->DH = 600;
129 break;
131 gsGlobal->StartX = 510;
132 gsGlobal->StartY = 25;
133 gsGlobal->DW = 1600;
134 gsGlobal->DH = 600;
135 break;
137 gsGlobal->StartX = 500;
138 gsGlobal->StartY = 25;
139 gsGlobal->DW = 1600;
140 gsGlobal->DH = 600;
141 break;
143 gsGlobal->StartX = 580;
144 gsGlobal->StartY = 30;
145 gsGlobal->DW = 2048; // does this really need doubling? can't test
146 gsGlobal->DH = 768;
147 break;
149 gsGlobal->StartX = 266;
150 gsGlobal->StartY = 30;
151 gsGlobal->DW = 1024;
152 gsGlobal->DH = 768;
153 break;
155 gsGlobal->StartX = 260;
156 gsGlobal->StartY = 30;
157 gsGlobal->DW = 1024;
158 gsGlobal->DH = 768;
159 break;
161 gsGlobal->StartX = 290;
162 gsGlobal->StartY = 30;
163 gsGlobal->DW = 1024;
164 gsGlobal->DH = 768;
165 break;
168 gsGlobal->StartX = 350;
169 gsGlobal->StartY = 40;
170 gsGlobal->DW = 1280;
171 gsGlobal->DH = 1024;
172 break;
173 case GS_MODE_DTV_480P:
174 gsGlobal->StartX = 232;
175 gsGlobal->StartY = 35;
176 gsGlobal->DW = 1440;
177 gsGlobal->DH = 480; // though rare there are tv's that can handle an interlaced 480p source
178 break;
179 case GS_MODE_DTV_576P:
180 gsGlobal->StartX = 255;
181 gsGlobal->StartY = 44;
182 gsGlobal->DW = 1440;
183 gsGlobal->DH = 576;
184 break;
185 case GS_MODE_DTV_720P:
186 gsGlobal->StartX = 306;
187 gsGlobal->StartY = 24;
188 gsGlobal->DW = 1280;
189 gsGlobal->DH = 720;
190 break;
192 gsGlobal->StartX = 236;
193 gsGlobal->StartY = 38;
194 gsGlobal->DW = 1920;
195 gsGlobal->DH = 1080;
196 break;
197 }
198
200 // NTSC 240p instead of 480i
201 // PAL 288p instead of 576i
202 gsGlobal->StartY /= 2;
203 gsGlobal->DH /= 2;
204 }
205
206 gsGlobal->MagH = (gsGlobal->DW / gsGlobal->Width) - 1; // gsGlobal->DW should be a multiple of the screen width
207 gsGlobal->MagV = (gsGlobal->DH / gsGlobal->Height) - 1; // gsGlobal->DH should be a multiple of the screen height
208
209 // For other video modes, other than NTSC and PAL: if this model supports the GetGsDxDy syscall, get the board-specific offsets.
211 {
212 if(GetSyscallHandler(__NR__GetGsDxDyOffset))
213 {
214 _GetGsDxDyOffset(gsGlobal->Mode, &gs_DX, &gs_DY, &gs_DW, &gs_DH);
215 gsGlobal->StartX += gs_DX;
216 gsGlobal->StartY += gs_DY;
217 }
218 }
219
220 // Keep the framebuffer in the center of the screen
221 gsGlobal->StartX += (gsGlobal->DW - ((gsGlobal->MagH + 1) * gsGlobal->Width )) / 2;
222 gsGlobal->StartY += (gsGlobal->DH - ((gsGlobal->MagV + 1) * gsGlobal->Height)) / 2;
223
225 // Do not change odd/even start position in interlaced mode
226 gsGlobal->StartY &= ~1;
227 }
228
229 // Calculate the actual display width and height
230 gsGlobal->DW = (gsGlobal->MagH + 1) * gsGlobal->Width;
231 gsGlobal->DH = (gsGlobal->MagV + 1) * gsGlobal->Height;
232
234 gsGlobal->MagV--;
235 }
236}
237
239{
240 u64 *p_data;
241 u64 *p_store;
242 int size = 19;
243
246 size++;
247
248 gsKit_set_buffer_attributes(gsGlobal);
249
250#ifdef DEBUG
251 printf("Screen Mode:\n");
252 printf("------------\n");
253 printf("Width : %d\n", gsGlobal->Width);
254 printf("Height: %d\n", gsGlobal->Height);
255 printf("StartX: %d\n", gsGlobal->StartX);
256 printf("StartY: %d\n", gsGlobal->StartY);
257 printf("MagH : %d\n", gsGlobal->MagH);
258 printf("MagV : %d\n", gsGlobal->MagV);
259 printf("DW : %d\n", gsGlobal->DW);
260 printf("DH : %d\n", gsGlobal->DH);
261#endif
262
263 GS_RESET();
264
265 __asm__("sync.p; nop;");
266
267 *GS_CSR = 0x00000000; // Clean CSR registers
268
269 GsPutIMR(0x00007F00); // Masks all interrupts
270
272
273 // Fix 1080i frame mode
275 GS_SET_SMODE2(1, 1, 0);
276
278
280 {
282 gsGlobal->Test->ZTST = 1;
283 }
284
285 DIntr(); // disable interrupts
286
287 GS_SET_PMODE( 0, // Read Circuit 1
288 1, // Read Circuit 2
289 0, // Use ALP Register for Alpha Blending
290 1, // Alpha Value of Read Circuit 2 for Output Selection
291 0, // Blend Alpha with output of Read Circuit 2
292 0x80); // Alpha Value = 1.0
293
294 GS_SET_DISPFB1( 0, // Frame Buffer Base Pointer (Address/2048)
295 gsGlobal->Width / 64, // Buffer Width (Address/64)
296 gsGlobal->PSM, // Pixel Storage Format
297 0, // Upper Left X in Buffer
298 0);
299
300 GS_SET_DISPFB2( 0, // Frame Buffer Base Pointer (Address/2048)
301 gsGlobal->Width / 64, // Buffer Width (Address/64)
302 gsGlobal->PSM, // Pixel Storage Format
303 0, // Upper Left X in Buffer
304 0); // Upper Left Y in Buffer
305
307 gsGlobal->StartX + gsGlobal->StartXOffset, // X position in the display area (in VCK unit
308 gsGlobal->StartY + gsGlobal->StartYOffset, // Y position in the display area (in Raster u
309 gsGlobal->MagH, // Horizontal Magnification
310 gsGlobal->MagV, // Vertical Magnification
311 gsGlobal->DW - 1, // Display area width
312 gsGlobal->DH - 1); // Display area height
313
315 gsGlobal->StartX + gsGlobal->StartXOffset, // X position in the display area (in VCK units)
316 gsGlobal->StartY + gsGlobal->StartYOffset, // Y position in the display area (in Raster units)
317 gsGlobal->MagH, // Horizontal Magnification
318 gsGlobal->MagV, // Vertical Magnification
319 gsGlobal->DW - 1, // Display area width
320 gsGlobal->DH - 1); // Display area height
321
323 gsGlobal->BGColor->Green, // Green
324 gsGlobal->BGColor->Blue); // Blue
325
326 EIntr(); //enable interrupts
327
328 gsGlobal->CurrentPointer = 0; // reset vram pointer too
329
330 // Context 1
332
334 {
336 }
337 else
338 // Context 2
340
341
344
345 gsGlobal->TexturePointer = gsGlobal->CurrentPointer; // first useable address for textures
346
347 p_data = p_store = (u64 *)gsGlobal->dma_misc;
348
349 *p_data++ = GIF_TAG( size - 1, 1, 0, 0, GSKIT_GIF_FLG_PACKED, 1 );
350 *p_data++ = GIF_AD;
351
352 *p_data++ = 1;
353 *p_data++ = GS_PRMODECONT;
354
355 *p_data++ = GS_SETREG_FRAME_1( gsGlobal->ScreenBuffer[0] / 8192, gsGlobal->Width / 64, gsGlobal->PSM, 0 );
356 *p_data++ = GS_FRAME_1;
357
360 *p_data++ = GS_XYOFFSET_1;
361
362 *p_data++ = GS_SETREG_SCISSOR_1( 0, gsGlobal->Width - 1, 0, gsGlobal->Height - 1 );
363 *p_data++ = GS_SCISSOR_1;
364
365 *p_data++ = GS_SETREG_TEST( gsGlobal->Test->ATE, gsGlobal->Test->ATST,
369
370 *p_data++ = GS_TEST_1;
371
375
376 *p_data++ = GS_CLAMP_1;
377
379 {
381 gsGlobal->PSMZ = GS_PSMZ_16; // seems only non-S 16-bit z depth works with this mode
383 gsGlobal->PSMZ = GS_PSMZ_16S; // other depths don't seem to work with 16-bit non-S z depth
384
385 *p_data++ = GS_SETREG_ZBUF_1( gsGlobal->ZBuffer / 8192, gsGlobal->PSMZ, 0 );
386 *p_data++ = GS_ZBUF_1;
387 }
389 {
390 *p_data++ = GS_SETREG_ZBUF_1( 0, gsGlobal->PSM, 1 );
391 *p_data++ = GS_ZBUF_1;
392 }
393
394 *p_data++ = GS_SETREG_COLCLAMP( 255 );
395 *p_data++ = GS_COLCLAMP;
396
397 *p_data++ = GS_SETREG_FRAME_1( gsGlobal->ScreenBuffer[1] / 8192, gsGlobal->Width / 64, gsGlobal->PSM, 0 );
398 *p_data++ = GS_FRAME_2;
399
402 *p_data++ = GS_XYOFFSET_2;
403
404 *p_data++ = GS_SETREG_SCISSOR_1( 0, gsGlobal->Width - 1, 0, gsGlobal->Height - 1);
405 *p_data++ = GS_SCISSOR_2;
406
407 *p_data++ = GS_SETREG_TEST( gsGlobal->Test->ATE, gsGlobal->Test->ATST,
411
412 *p_data++ = GS_TEST_2;
413
417
418 *p_data++ = GS_CLAMP_2;
419
421 {
422 *p_data++ = GS_SETREG_ZBUF_1( gsGlobal->ZBuffer / 8192, gsGlobal->PSMZ, 0 );
423 *p_data++ = GS_ZBUF_2;
424 }
426 {
427 *p_data++ = GS_SETREG_ZBUF_1( 0, gsGlobal->PSM, 1 );
428 *p_data++ = GS_ZBUF_2;
429 }
430
431 *p_data++ = GS_BLEND_BACK2FRONT;
432 *p_data++ = GS_ALPHA_1;
433
434 *p_data++ = GS_BLEND_BACK2FRONT;
435 *p_data++ = GS_ALPHA_2;
436
442 gsGlobal->DitherMatrix[14],gsGlobal->DitherMatrix[15]); // 4x4 dither matrix
443
444 *p_data++ = GS_DIMX;
445
446 *p_data++ = GS_SETREG_TEXA(0x00, 0, 0x80);
447 *p_data++ = GS_TEXA;
448
450 *p_data++ = 1;
451 *p_data++ = GS_DTHE;
452 }
453
454 dmaKit_send_ucab(DMA_CHANNEL_GIF, p_store, size);
456
457 // do a single frame here to get rid whatever needs to be done during the first frame
458
459 gsKit_clear(gsGlobal, GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00)); // clear the screen
460
462
464
466}
467
468GSGLOBAL *gsKit_init_global_custom(int Os_AllocSize, int Per_AllocSize)
469{
470 //s8 dither_matrix[16] = {-4,2,-3,3,0,-2,1,-1,-3,3,-4,2,1,-1,0,-2};
471 s8 dither_matrix[16] = {4,2,5,3,0,6,1,7,5,3,4,2,1,7,0,6}; //different matrix
472 int i = 0;
473
474 GSGLOBAL *gsGlobal = calloc(1,sizeof(GSGLOBAL));
475 gsGlobal->BGColor = calloc(1,sizeof(GSBGCOLOR));
476 gsGlobal->Test = calloc(1,sizeof(GSTEST));
477 gsGlobal->Clamp = calloc(1,sizeof(GSCLAMP));
478 gsGlobal->Os_Queue = calloc(1,sizeof(GSQUEUE));
479 gsGlobal->Per_Queue = calloc(1,sizeof(GSQUEUE));
480 gsGlobal->dma_misc = gsKit_alloc_ucab(512);
481
482 /* Generic Values */
483 _io_driver driver = posixIODriver;
484 if(configGetTvScreenTypeWithIODriver(&driver) == 2) gsGlobal->Aspect = GS_ASPECT_16_9;
485 else
487
490
494
495 // Setup a mode automatically
499 gsGlobal->Width = 640;
500
501 if(gsGlobal->Mode == GS_MODE_PAL) gsGlobal->Height = 512;
502 else gsGlobal->Height = 448;
503
505
507
508 gsGlobal->EvenOrOdd = 0;
509
510 gsGlobal->Os_AllocSize = Os_AllocSize;
512
513 gsGlobal->Per_AllocSize = Per_AllocSize;
515
517
518 gsGlobal->OffsetX = (int)(2048.0f * 16.0f);
519 gsGlobal->OffsetY = (int)(2048.0f * 16.0f);
528
529 for(i = 0; i < 15; i++) {
530 gsGlobal->DitherMatrix[i] = dither_matrix[i];
531 }
532
533 /* BGColor Register Values */
534 gsGlobal->BGColor->Red = 0x00;
535 gsGlobal->BGColor->Green = 0x00;
536 gsGlobal->BGColor->Blue = 0x00;
537
538 /* TEST Register Values */
541 gsGlobal->Test->AREF = 0x80;
542 gsGlobal->Test->AFAIL = 0;
544 gsGlobal->Test->DATM = 0;
546 gsGlobal->Test->ZTST = 2;
547
550 gsGlobal->Clamp->MINU = 0;
551 gsGlobal->Clamp->MAXU = 0;
552 gsGlobal->Clamp->MINV = 0;
553 gsGlobal->Clamp->MAXV = 0;
554
555 return gsGlobal;
556}
557
558void gsKit_deinit_global(GSGLOBAL *gsGlobal)
559{
562
563 gsKit_free_ucab(gsGlobal->dma_misc);
564 free(gsGlobal->Per_Queue);
565 free(gsGlobal->Os_Queue);
566 free(gsGlobal->Clamp);
567 free(gsGlobal->Test);
568 free(gsGlobal->BGColor);
569 free(gsGlobal);
570}
void dmaKit_wait_fast(void)
Definition dmaCore.c:45
void dmaKit_send_ucab(u16 channel, void *data, u32 size)
Definition dmaCore.c:84
#define GS_CMODE_CLAMP
Stretches Texture Across the Surface.
Definition gsCore.h:46
void gsKit_queue_reset(GSQUEUE *Queue)
Reset specified drawqueue to it's initial state (Useful for clearing the Persistent Queue).
Definition gsCore.c:553
void gsKit_clear(GSGLOBAL *gsGlobal, u64 Color)
Definition gsCore.c:244
u32 gsKit_vram_alloc(GSGLOBAL *gsGlobal, u32 size, u8 type)
GS VRAM Allocation.
Definition gsCore.c:20
void gsKit_free_ucab(void *p)
Free UCAB buffer in GSQUEUE, internal use only.
Definition gsCore.c:603
void gsKit_queue_free(GSGLOBAL *gsGlobal, GSQUEUE *Queue)
Free Allocated Memory for Draw Queue.
Definition gsCore.c:634
void gsKit_queue_init(GSGLOBAL *gsGlobal, GSQUEUE *Queue, u8 mode, int size)
Initialize a Draw Queue (Allocates memory for the Queue).
Definition gsCore.c:612
void gsKit_queue_exec(GSGLOBAL *gsGlobal)
Normal User Draw Queue "Execution" (Kicks Oneshot and Persistent Queues).
Definition gsCore.c:567
#define GSKIT_ALLOC_SYSBUFFER
GS VRAM "System" Allocation (Framebuffer, ZBuffer, etc).
Definition gsCore.h:24
void gsKit_sync_flip(GSGLOBAL *gsGlobal)
Definition gsCore.c:63
void * gsKit_alloc_ucab(int size)
Allocate UCAB buffer in GSQUEUE, internal use only.
Definition gsCore.c:588
#define GS_MODE_VGA_800_60
VGA 800x600 @ 60Hz.
Definition gsInit.h:76
#define GS_MODE_VGA_800_75
VGA 800x600 @ 75Hz.
Definition gsInit.h:80
#define GS_ASPECT_4_3
4:3 Aspect Ratio (UNUSED)
Definition gsInit.h:56
#define GS_SETREG_XYOFFSET_1
See GS_SETREG_XYOFFSET.
Definition gsInit.h:738
#define GS_SET_PMODE(EN1, EN2, MMOD, AMOD, SLBG, ALP)
GS PCRTC (Merge Circuit) Register Access Macro.
Definition gsInit.h:623
#define GS_FRAME_1
GS Frame Buffer (Context 1).
Definition gsInit.h:240
#define GS_MODE_VGA_800_56
VGA 800x600 @ 56Hz.
Definition gsInit.h:74
#define GS_NONINTERLACED
Non-Interlaced Mode.
Definition gsInit.h:39
#define GS_DTHE
GS Dither Control.
Definition gsInit.h:226
#define GS_PSMZ_16S
RGBA16 ZBuffer ?
Definition gsInit.h:140
GSGLOBAL * gsKit_init_global_custom(int Os_AllocSize, int Per_AllocSize)
Initialize gsGlobal (With Specified Sizes (In Bytes) for the Persistent and Oneshot drawbuffers).
Definition gsInit.c:468
void gsKit_init_screen(GSGLOBAL *gsGlobal)
Initialize Screen and GS Registers.
Definition gsInit.c:238
#define GS_SETREG_COLCLAMP(clamp)
GS COLCLAMP Packing Macro.
Definition gsInit.h:765
#define GS_CLAMP_2
GS Texture Wrap Mode (Context 2).
Definition gsInit.h:174
#define GS_PER_OS
Draw Persistent objects first, before oneshot objects.
Definition gsInit.h:34
#define GS_FRAME_2
GS Frame Buffer (Context 2).
Definition gsInit.h:242
#define GS_PSM_CT16S
RGBA16 Texture ?
Definition gsInit.h:121
#define GS_SETREG_TEST(ate, atst, aref, afail, date, datm, zte, ztst)
GS TEST Packing Macro.
Definition gsInit.h:758
#define GS_MODE_DTV_480P
DTV 480 Progressive Scan (720x480).
Definition gsInit.h:99
#define GS_PSMZ_32
R8 G8 B8 A8 (RGBA32) ZBuffer.
Definition gsInit.h:134
#define GS_PRMODECONT
GS Primitive Attribute Setting Mode.
Definition gsInit.h:194
#define GS_SET_SMODE2(INT, FFMD, DPMS)
Setting For Modes Related to Video Synchronization.
Definition gsInit.h:634
#define GS_MODE_VGA_1280_75
VGA 1280x1024 @ 75Hz.
Definition gsInit.h:96
#define GS_SET_DISPLAY1(DX, DY, MAGH, MAGV, DW, DH)
GS Display Settings Register Access Macro (Output Circuit 1).
Definition gsInit.h:705
#define GS_MODE_NTSC
NTSC Full Buffer.
Definition gsInit.h:61
#define GS_CLAMP_1
GS Texture Wrap Mode (Context 1).
Definition gsInit.h:172
#define GS_FRAME
Frame Mode - Reads Every Line.
Definition gsInit.h:46
#define GS_SETREG_ZBUF_1
See GS_SETREG_ZBUF.
Definition gsInit.h:745
void gsKit_set_display_offset(GSGLOBAL *gsGlobal, int x, int y)
Position the framebuffer onto the display.
Definition gsInit.c:46
#define GS_SETREG_RGBAQ(r, g, b, a, q)
Object Creation Macro for RGBAQ Color Values.
Definition gsInit.h:579
#define GS_MODE_VGA_1280_60
VGA 1280x1024 @ 60Hz.
Definition gsInit.h:94
#define GS_MODE_PAL
PAL Full Buffer.
Definition gsInit.h:63
#define GS_BLEND_BACK2FRONT
Blend Alpha Primitives "Back To Front".
Definition gsInit.h:145
#define GS_MODE_VGA_1024_70
VGA 1024x768 @ 70Hz.
Definition gsInit.h:87
#define GS_SETTING_OFF
Define a setting to be OFF.
Definition gsInit.h:148
#define GIF_TAG(NLOOP, EOP, PRE, PRIM, FLG, NREG)
DMA Packet Header "GIF Tag" For Packets Sent To GIF.
Definition gsInit.h:570
#define GS_XYOFFSET_2
GS Offset Value.
Definition gsInit.h:192
#define GS_DIMX
GS Dither Matrix.
Definition gsInit.h:224
short int gsKit_check_rom(void)
Checks the console's capabilities based on the ROM version (returns default video format: GS_MODE_NTS...
Definition gsInit.c:28
#define GS_MODE_VGA_800_72
VGA 800x600 @ 72Hz.
Definition gsInit.h:78
#define GS_PSM_CT24
R8 G8 B8 (RGB24) Texture.
Definition gsInit.h:117
#define GS_COLCLAMP
GS Color Clamp.
Definition gsInit.h:228
#define GS_SETTING_ON
Define a setting to be ON.
Definition gsInit.h:151
#define GS_ZBUF_1
GS Z Buffer (Context 1).
Definition gsInit.h:244
#define GS_TEXA
GS Texture Alpha Value.
Definition gsInit.h:210
#define GS_MODE_VGA_640_72
VGA 640x480 @ 72Hz.
Definition gsInit.h:67
#define GS_ONESHOT
Oneshot Draw Queue.
Definition gsInit.h:26
#define GS_MODE_DTV_720P
DTV 720 Progressive Scan (1280x720).
Definition gsInit.h:105
#define GS_MODE_DTV_576P
DTV 576 Progressive Scan (720x576).
Definition gsInit.h:101
#define GS_ASPECT_16_9
16:9 Aspect Ratio (UNUSED)
Definition gsInit.h:58
#define GIF_AD
GIF_TAG Address+Data Setting. (Used after GIF_TAG).
Definition gsInit.h:494
#define GS_MODE_VGA_640_75
VGA 640x480 @ 65Hz.
Definition gsInit.h:69
#define GS_PERSISTENT
Persistent Draw Queue.
Definition gsInit.h:24
#define GS_SCISSOR_2
GS Scissoring Area (Context 2).
Definition gsInit.h:218
#define GS_SCISSOR_1
GS Scissoring Area (Context 1).
Definition gsInit.h:216
#define GS_SET_DISPFB1(FBP, FBW, PSM, DBX, DBY)
GS Framebuffer Register Access Macro (Output Circuit 1).
Definition gsInit.h:684
#define GS_RESET()
GS Reset Macro.
Definition gsInit.h:502
#define GS_TEST_1
GS TEST (Context 1).
Definition gsInit.h:230
#define GS_SET_DISPLAY2(DX, DY, MAGH, MAGV, DW, DH)
GS Display Settings Register Access Macro (Output Circuit 2).
Definition gsInit.h:718
#define GS_MODE_DTV_1080I
DTV 1080 Interlaced (1920x1080).
Definition gsInit.h:103
#define GS_MODE_VGA_640_85
VGA 640x480 @ 85Hz.
Definition gsInit.h:71
#define GS_ALPHA_2
GS Alpha Blending (Context 2).
Definition gsInit.h:222
#define GS_PSMZ_16
RGBA16 ZBuffer.
Definition gsInit.h:138
#define GS_TEST_2
GS TEST (Context 2).
Definition gsInit.h:232
#define GS_MODE_VGA_1024_60
VGA 1024x768 @ 60Hz.
Definition gsInit.h:85
#define GS_SET_BGCOLOR(R, G, B)
GS Background Color Register Access Macro.
Definition gsInit.h:731
#define GS_SETREG_SCISSOR_1
See GS_SETREG_SCISSOR.
Definition gsInit.h:777
#define GS_ALPHA_1
GS Alpha Blending (Context 1).
Definition gsInit.h:220
#define GS_SETREG_CLAMP(wms, wmt, minu, maxu, minv, maxv)
GS CLAMP Packing Macro.
Definition gsInit.h:790
#define GS_XYOFFSET_1
GS Offset Value.
Definition gsInit.h:190
#define GS_ZBUF_2
GS Z Buffer (Context 2).
Definition gsInit.h:246
#define GS_MODE_VGA_1024_75
VGA 1024x768 @ 75Hz.
Definition gsInit.h:89
#define GS_SETREG_FRAME_1
See GS_SETREG_FRAME.
Definition gsInit.h:768
#define GS_MODE_VGA_1024_85
VGA 1024x768 @ 85Hz.
Definition gsInit.h:91
#define GS_INTERLACED
Interlaced Mode.
Definition gsInit.h:41
#define GS_FIELD
Field Mode - Reads Every Other Line.
Definition gsInit.h:44
#define GS_MODE_VGA_640_60
VGA 640x480 @ 60Hz.
Definition gsInit.h:65
#define GS_SET_DISPFB2(FBP, FBW, PSM, DBX, DBY)
GS Framebuffer Register Access Macro (Output Circuit 2).
Definition gsInit.h:693
#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.
Definition gsInit.h:808
#define GS_MODE_VGA_800_85
VGA 800x600 @ 85Hz.
Definition gsInit.h:82
#define GS_CSR
GS CSR (GS System Status) Register.
Definition gsInit.h:540
#define GS_PSM_CT16
RGBA16 Texture.
Definition gsInit.h:119
#define GSKIT_GIF_FLG_PACKED
gsKit GIFTAG data format "FLG"
Definition gsInit.h:299
u8 Green
Green Value.
Definition gsInit.h:818
u8 Blue
Blue Value.
Definition gsInit.h:819
u8 Red
Red Value.
Definition gsInit.h:817
int MAXU
Maximum Horizontal Clamp Value.
Definition gsInit.h:843
int MINV
Minimum Vertical Clamp Value.
Definition gsInit.h:844
u8 WMS
Wrap Mode Horizontal.
Definition gsInit.h:840
u8 WMT
Wrap Mode Vertical.
Definition gsInit.h:841
int MAXV
Maximum Vertical Clamp Value.
Definition gsInit.h:845
int MINU
Minimum Horizontal Clamp Value.
Definition gsInit.h:842
u8 ActiveBuffer
Active Framebuffer.
Definition gsInit.h:916
int PrimAlphaEnable
Primitive Alpha Blending Enable.
Definition gsInit.h:945
u8 EvenOrOdd
Is ((GSREG*)CSR)->FIELD (Used for Interlace Correction).
Definition gsInit.h:912
u8 ZBuffering
Enable/Disable Z Buffering.
Definition gsInit.h:909
int Width
Framebuffer Width (the mode's DW is a multiple of this value).
Definition gsInit.h:918
u32 CurrentPointer
Current VRAM Pointer.
Definition gsInit.h:904
s16 Field
Field / Frame.
Definition gsInit.h:903
int MagH
X Magnification Value (MAGH = DW / Width - 1).
Definition gsInit.h:927
int Per_AllocSize
Persistent Drawbuffer Size (Per Buffer).
Definition gsInit.h:938
GSBGCOLOR * BGColor
Background Color Structure Pointer.
Definition gsInit.h:931
int Os_AllocSize
Oneshot Drawbuffer Size (Per Buffer).
Definition gsInit.h:937
u8 Dithering
Dithering (On/Off).
Definition gsInit.h:906
GSTEST * Test
TEST Register Value Structure Pointer.
Definition gsInit.h:932
int PrimContext
Primitive Context.
Definition gsInit.h:942
GSQUEUE * CurQueue
Draw Queue (Current).
Definition gsInit.h:934
int Aspect
Framebuffer Aspect Ratio (GS_ASPECT_4_3/GS_ASPECT_16_9).
Definition gsInit.h:920
int PSMZ
ZBuffer Pixel Storage Method.
Definition gsInit.h:941
u32 TexturePointer
Pointer to beginning of Texture Buffer.
Definition gsInit.h:905
s16 Mode
Display Mode.
Definition gsInit.h:901
u8 DoubleBuffering
Enable/Disable Double Buffering.
Definition gsInit.h:908
int StartYOffset
Y Starting Coordinate (Used for Placement Correction) Additional correction.
Definition gsInit.h:926
int StartXOffset
X Starting Coordinate (Used for Placement Correction) Additional correction.
Definition gsInit.h:925
GSQUEUE * Os_Queue
Draw Queue (Oneshot).
Definition gsInit.h:936
int OffsetX
X Window Offset.
Definition gsInit.h:921
int DW
Total Display Area Width (DW = Width * (MAGH + 1)).
Definition gsInit.h:929
u32 ScreenBuffer[2]
Screenbuffer Pointer Array.
Definition gsInit.h:910
int StartX
X Starting Coordinate (Used for Placement Correction) Default value.
Definition gsInit.h:923
int PSM
Pixel Storage Method (Color Mode).
Definition gsInit.h:940
u8 DrawOrder
Drawing Order (GS_PER_OS/GS_OS_PER) (GS_PER_OS = Persitant objects always drawn first).
Definition gsInit.h:913
int MagV
Y Magnification Value (MAGV = DH / Height - 1).
Definition gsInit.h:928
int Height
Framebuffer Height (the mode's DH is a multiple of this value).
Definition gsInit.h:919
u64 PrimAlpha
Primitive Alpha Value.
Definition gsInit.h:946
int PrimFogEnable
Primitive Fog Enable.
Definition gsInit.h:943
GSCLAMP * Clamp
CLAMP Register Value Structure Pointer.
Definition gsInit.h:933
int PrimAAEnable
Primitive AntiAlaising Enable.
Definition gsInit.h:944
int OffsetY
Y Window Offset.
Definition gsInit.h:922
u32 ZBuffer
ZBuffer Pointer.
Definition gsInit.h:911
s8 DitherMatrix[16]
Dithering Matrix.
Definition gsInit.h:907
u8 FirstFrame
Have we executed a frame yet?
Definition gsInit.h:914
int DH
Total Display Area Height (DH = Height * (MAGH + 1)).
Definition gsInit.h:930
s16 Interlace
Interlace (On/Off).
Definition gsInit.h:902
int StartY
Y Starting Coordinate (Used for Placement Correction) Default value.
Definition gsInit.h:924
GSQUEUE * Per_Queue
Draw Queue (Persistent).
Definition gsInit.h:935
volatile u8 LockBuffer
Used to lock the buffer so it doesn't switch.
Definition gsInit.h:917
u8 ATE
Alpha Test Enable.
Definition gsInit.h:826
u8 ATST
Alpha Test Method.
Definition gsInit.h:827
u8 ZTE
Depth Test Enable (DO NOT USE THIS - IT IS BUGGED IN PARTICULAR GS REV - SET TO 1 ALWAYS).
Definition gsInit.h:832
u8 DATE
Destination Alpha Enable.
Definition gsInit.h:830
u8 DATM
Destination Alpha Mode.
Definition gsInit.h:831
u8 ZTST
Depth Test Method.
Definition gsInit.h:833
u8 AREF
Alpha Reference Value.
Definition gsInit.h:828
u8 AFAIL
Alpha Failure Action.
Definition gsInit.h:829