PSXSDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
psxgpu.h
Go to the documentation of this file.
1 #ifndef _PSXGPU_H
2 #define _PSXGPU_H
3 
11 void GsInit(void);
12 
21 void GsInitEx(unsigned int flags);
22 
27 void GsReset(void);
28 
37 void GsEnableDisplay(int enable);
38 
53 int GsSetVideoMode(int width, int height, int video_mode);
54 
74 int GsSetVideoModeEx(int width, int height, int video_mode, int rgb24, int inter, int reverse);
75 
84 void GsSetList(unsigned int *listptr);
85 
96 void GsSetListEx(unsigned int *listptr, unsigned int listpos);
97 
104 void GsDrawList(void);
105 
118 void GsDrawListPIO(void);
119 
125 void GsSetAutoWait(void);
126 
129 typedef struct
130 {
132  unsigned char r;
134  unsigned char g;
136  unsigned char b;
138  short x[3];
140  short y[3];
142  unsigned int attribute;
143 }GsPoly3;
144 
147 typedef struct
148 {
150  unsigned char r;
152  unsigned char g;
154  unsigned char b;
156  short x[4];
158  short y[4];
160  unsigned int attribute;
161 }GsPoly4;
162 
165 typedef struct
166 {
168  unsigned char r;
170  unsigned char g;
172  unsigned char b;
174  short x[3];
176  short y[3];
178  unsigned char u[3];
180  unsigned char v[3];
182  short cx;
184  short cy;
186  unsigned int attribute;
188  unsigned char tpage;
189 }GsTPoly3;
190 
193 typedef struct
194 {
196  short x[4];
198  short y[4];
200  unsigned char r;
202  unsigned char g;
204  unsigned char b;
206  short cx;
208  short cy;
210  unsigned char tpage;
212  unsigned char u[4];
214  unsigned char v[4];
216  unsigned int attribute;
217 }GsTPoly4;
218 
221 typedef struct
222 {
224  unsigned char r[3];
226  unsigned char g[3];
228  unsigned char b[3];
230  short x[3];
232  short y[3];
234  unsigned int attribute;
235 }GsGPoly3;
236 
239 typedef struct
240 {
242  unsigned char r[4];
244  unsigned char g[4];
246  unsigned char b[4];
248  short x[4];
250  short y[4];
252  unsigned int attribute;
253 }GsGPoly4;
254 
257 typedef struct
258 {
260  unsigned char r[3];
262  unsigned char g[3];
264  unsigned char b[3];
266  short x[3];
268  short y[3];
270  short cx;
272  short cy;
274  unsigned char tpage;
276  unsigned char u[3];
278  unsigned char v[3];
280  unsigned int attribute;
281 }GsGTPoly3;
282 
285 typedef struct
286 {
288  unsigned char r[4];
290  unsigned char g[4];
292  unsigned char b[4];
294  short x[4];
296  short y[4];
298  short cx;
300  short cy;
302  unsigned char tpage;
304  unsigned char u[4];
306  unsigned char v[4];
308  unsigned int attribute;
309 }GsGTPoly4;
310 
313 typedef struct
314 {
316  unsigned char r;
318  unsigned char g;
320  unsigned char b;
322  short x[2];
324  short y[2];
326  unsigned int attribute;
327 }GsLine;
328 
331 typedef struct
332 {
334  unsigned char r;
336  unsigned char g;
338  unsigned char b;
340  short x;
342  short y;
344  unsigned int attribute;
345 }GsDot;
346 
349 typedef struct
350 {
352  unsigned char r[2];
354  unsigned char g[2];
356  unsigned char b[2];
358  short x[2];
360  short y[2];
362  unsigned int attribute;
363 }GsGLine;
364 
367 typedef struct
368 {
369  short x, y; /* X, Y positions */
370  unsigned char u, v; /* Offset into texture page of sprite image data */
371  short w, h; /* Width and height of sprite */
372  short cx, cy; /* Color look up table (palette) X, Y positions */
373  unsigned char r, g, b; /* Luminosity of color components - 128 is normal luminosity */
374  unsigned char tpage; /* Texture page */
375  unsigned int attribute; /* Attribute */
376 
377  /* Scaling? These are only candidates...
378 
379  scalex:
380  Denotes horizontal scaling
381 
382  0 = true size (unmodified)
383  1 = true size (*1)
384  2 = double size (*2)
385  3 = triple size (*3)
386  ...
387 
388  -1 = true size (/1)
389  -2 = half size (/2)
390  -3 = one-third size (/3)
391  ...
392 
393  scaley:
394  Denotes vertical scaling
395 
396  *** The behaviour below was introduced in PSXSDK 0.5
397 
398  If scalex > 8,
399  resulting width will be (original_width * scalex) / 4096
400  scalex = 4096 (SCALE_ONE) (original width), scalex = 2048 (half width), etc.
401  If scaley > 8,
402  resulting height will be (original_height * scaley) / 4096
403  works like scalex but affects height
404  */
405  int scalex, scaley;
406 
407  int rotate; // Rotation angle - Fixed point notation, 4096 = 1 degree
408  int mx, my; // Coordinates of rotation center - relative to coordinates of sprite
409 }GsSprite;
410 
413 typedef struct
414 {
415 
416  short x, y;
417  short w, h;
418  unsigned char r, g, b;
419  unsigned int attribute; /* Attribute */
420 }GsRectangle;
421 
422 typedef struct
423 {
425  unsigned int npoints;
427  unsigned char r;
429  unsigned char g;
431  unsigned char b;
433  short *x;
435  short *y;
437  unsigned int attribute;
438 }GsPolyLine;
439 
440 typedef struct
441 {
443  unsigned int npoints;
445  unsigned char *r;
447  unsigned char *g;
449  unsigned char *b;
451  short *x;
453  short *y;
455  unsigned int attribute;
456 }GsGPolyLine;
457 
460 //typedef struct
461 //{
462 // short x, y; /* X, Y positions */
463 // unsigned char u, v; /* Offset into texture page of sprite image data */
464 // short w, h; /* Width and height of tilemap */
465 // short l; /* Length of tilemap line */
466 // short cx, cy; /* Color look up table (palette) X, Y positions */
467 // unsigned char r, g, b; /* Luminosity of color components - 128 is normal luminosity */
468 // unsigned char tpage; /* Texture page */
469 // unsigned int attribute; /* Attribute */
470 //
471 // unsigned short tmw, tmh; /* Map texture width and height */
472 // unsigned char tw, th; /* Map tile width and height */
473 //
474 // unsigned char tsize; /* Size of tile in map (1 = 8-bit, 2 = 16-bit, 4 = 32-bit) */
475 //
476 // unsigned int tmask; /* Inverted mask for tile number */
477 //
478 // void *data; /* Pointer to beginning of map data */
479 //}GsMap;
480 
484 {
493 };
494 
503 #define NORMAL_LUMINANCE 128
504 #define NORMAL_LUMINOSITY NORMAL_LUMINANCE
505 
509 #define COLORMODE(x) x&3
510 
540 #define TRANS_MODE(x) ((x&3)<<2)
541 
544 #define ENABLE_TRANS (1<<4)
545 
548 #define H_FLIP (1<<5)
549 
552 #define V_FLIP (1<<6)
553 
558 typedef struct
559 {
563  unsigned char dither;
571  unsigned char draw_on_display;
572 
576  short x;
580  short y;
584  short w;
588  short h;
589 
590  /*
591  * Drawing offset
592  */
593  //short off_x, off_y;
594 
602  unsigned char ignore_mask;
606  unsigned char set_mask;
607 }GsDrawEnv;
608 
615 typedef struct
616 {
618  short x;
620  short y;
621 }GsDispEnv;
622 
628 typedef struct
629 {
630 
631 
633  int pmode;
635  int has_clut;
637  int clut_x;
639  int clut_y;
641  int clut_w;
643  int clut_h;
645  int x;
647  int y;
649  int w;
651  int h;
653  void *clut_data;
655  void *data;
656 }GsImage;
657 
663 void GsSortPoly3(GsPoly3 *poly3);
664 
670 void GsSortPoly4(GsPoly4 *poly4);
671 
677 void GsSortTPoly3(GsTPoly3 *tpoly3);
678 
684 void GsSortTPoly4(GsTPoly4 *tpoly4);
685 
691 void GsSortGPoly3(GsGPoly3 *poly3);
692 
698 void GsSortGPoly4(GsGPoly4 *poly4);
699 
705 void GsSortGTPoly3(GsGTPoly3 *tpoly3);
706 
712 void GsSortGTPoly4(GsGTPoly4 *tpoly4);
713 
719 void GsSortLine(GsLine *line);
720 
726 void GsSortGLine(GsGLine *line);
727 
733 void GsSortDot(GsDot *dot);
734 
740 void GsSortSprite(GsSprite *sprite);
741 
754 void GsSortSimpleSprite(GsSprite *sprite);
755 
761 void GsSortRectangle(GsRectangle *rectangle);
762 
774 void MoveImage(int src_x, int src_y, int dst_x, int dst_y, int w, int h);
775 
785 void LoadImage(void *img, int x, int y, int w, int h);
786 
799 void DrawFBRect(int x, int y, int w, int h, int r, int g, int b);
800 
806 void GsSetDrawEnv(GsDrawEnv *drawenv);
807 
813 void GsSetDispEnv(GsDispEnv *dispenv);
814 
815 
816 
817 /* If this flag is set, pixels drawn have MSB set */
818 #define MASK_SET 1
819 /* If this flag is set, pixels aren't drawn over pixels with MSB set */
820 #define MASK_IGNORE 2
821 
827 void GsSetMasking(unsigned char flag);
828 
834 unsigned int GsListPos(void);
835 
840 void gpu_ctrl(unsigned int command, unsigned int param);
841 void gpu_data(unsigned int data);
842 void gpu_data_ctrl(unsigned int command, unsigned int param);
843 
848 int GsImageFromTim(GsImage *image, void *timdata);
849 
854 void GsUploadImage(GsImage *image);
855 
862 int GsSpriteFromImage(GsSprite *sprite, GsImage *image, int do_upload);
863 
869 int GsIsDrawing(void);
870 
876 int GsIsWorking(void); // Alias of GsIsDrawing()
877 
882 void GsClearMem(void);
883 
899 void GsLoadFont(int fb_x, int fb_y, int cx, int cy);
900 
909 unsigned int GsPrintFont(int x, int y, const char *fmt, ...);
910 
922 unsigned int GsVPrintFont(int x, int y, const char *fmt, va_list ap);
923 
928 void GsSetFont(int fb_x, int fb_y, int cx, int cy);
929 
964 void GsSetFontAttrib(unsigned int flags);
965 
975 void GsSetDrawEnvSimple(int x, int y, int w, int h);
976 
983 void GsSetDispEnvSimple(int x, int y);
984 
989 {
994 };
995 
998 #define SCALE_ONE 4096
999 
1002 #define ROTATE_ONE 4096
1003 
1004 // GsSetFontAttrib() Attribute Flags
1005 
1006 #define PRFONT_WRAP 1
1007 #define PRFONT_CENTER 2
1008 #define PRFONT_RIGHT 4
1009 #define PRFONT_SCALE 8
1010 #define PRFONT_UNIXLF 16
1011 #define PRFONT_COLOR 32
1012 
1013 // These below are not really attributes... but use them as if they were.
1014 
1015 unsigned int PRFONT_SCALEX(int i);
1016 unsigned int PRFONT_SCALEY(int i);
1017 unsigned int PRFONT_RL(unsigned char f);
1018 unsigned int PRFONT_GL(unsigned char f);
1019 unsigned int PRFONT_BL(unsigned char f);
1020 
1021 // Use this to get the final X and Y positions from the return value
1022 // of GsPrintFont(). Especially useful after wrapping.
1023 
1024 #define prfont_get_fx(i) ((short)(i & 0xffff))
1025 #define prfont_get_fy(i) ((short)((i >> 16) & 0xffff))
1026 
1027 // Width and height of the screen in the current video mode
1028 
1030 extern unsigned short GsScreenW;
1032 extern unsigned short GsScreenH;
1035 extern unsigned char GsScreenM; // Current video mode
1036 
1038 extern unsigned short GsCurDrawEnvW;
1040 extern unsigned short GsCurDrawEnvH;
1041 
1049 void GsSortCls(int r, int g, int b);
1050 
1061 #define gs_get_tpage_num(x,y) ((x/64)+((y/256)*16))
1062 
1068 #define gs_get_tpage_u(x) (x&0x3f)
1069 
1075 #define gs_get_tpage_v(y) (y&0xff)
1076 
1084 #define gs_rgb_to_psx(r, g, b) ((r>>3)|((g>>3)<<5)|((b>>3)<<10))
1085 
1096 #define gs_rgba_to_psx(r, g, b, a) ((r>>3)|((g>>3)<<5)|((b>>3)<<10)|(a==0?0:1))
1097 
1112 void GsRotateVector(int x_a, int y_a, int z_a, double *v, double *n);
1113 
1119 void GsSortPolyLine(GsPolyLine *line);
1120 
1126 void GsSortGPolyLine(GsGPolyLine *line);
1127 
1128 //void GsSortSimpleMap(GsMap *map);
1129 
1130 #endif