ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
draw_buffers.h File Reference
#include <tamtypes.h>
+ Include dependency graph for draw_buffers.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  texinfo_t
 
struct  framebuffer_t
 
struct  zbuffer_t
 
struct  texbuffer_t
 
struct  clutbuffer_t
 

Macros

#define TEXTURE_COMPONENTS_RGB   0
 
#define TEXTURE_COMPONENTS_RGBA   1
 
#define TEXTURE_FUNCTION_MODULATE   0
 
#define TEXTURE_FUNCTION_DECAL   1
 
#define TEXTURE_FUNCTION_HIGHLIGHT   2
 
#define TEXTURE_FUNCTION_HIGHLIGHT2   3
 
#define CLUT_STORAGE_MODE1   0
 
#define CLUT_STORAGE_MODE2   1
 
#define CLUT_NO_LOAD   0
 
#define CLUT_LOAD   1
 
#define CLUT_LOAD_COPY_CBP0   2
 
#define CLUT_LOAD_COPY_CBP1   3
 
#define CLUT_COMPARE_CBP0   4
 
#define CLUT_COMPARE_CBP1   5
 

Functions

unsigned char draw_log2 (unsigned int x)
 
qword_tdraw_framebuffer (qword_t *q, int context, framebuffer_t *frame)
 
qword_tdraw_zbuffer (qword_t *q, int context, zbuffer_t *zbuffer)
 
qword_tdraw_texturebuffer (qword_t *q, int context, texbuffer_t *texbuffer, clutbuffer_t *clut)
 
qword_tdraw_clutbuffer (qword_t *q, int context, int psm, clutbuffer_t *clut)
 
qword_tdraw_clut_offset (qword_t *q, int cbw, int u, int v)
 

Detailed Description

Draw library buffer functions

Definition in file draw_buffers.h.

Macro Definition Documentation

◆ CLUT_COMPARE_CBP0

#define CLUT_COMPARE_CBP0   4

Definition at line 30 of file draw_buffers.h.

◆ CLUT_COMPARE_CBP1

#define CLUT_COMPARE_CBP1   5

Definition at line 31 of file draw_buffers.h.

◆ CLUT_LOAD

#define CLUT_LOAD   1

Definition at line 27 of file draw_buffers.h.

◆ CLUT_LOAD_COPY_CBP0

#define CLUT_LOAD_COPY_CBP0   2

Definition at line 28 of file draw_buffers.h.

◆ CLUT_LOAD_COPY_CBP1

#define CLUT_LOAD_COPY_CBP1   3

Definition at line 29 of file draw_buffers.h.

◆ CLUT_NO_LOAD

#define CLUT_NO_LOAD   0

CLUT Load Control

Definition at line 26 of file draw_buffers.h.

◆ CLUT_STORAGE_MODE1

#define CLUT_STORAGE_MODE1   0

CLUT Storage Mode

Definition at line 22 of file draw_buffers.h.

◆ CLUT_STORAGE_MODE2

#define CLUT_STORAGE_MODE2   1

Definition at line 23 of file draw_buffers.h.

◆ TEXTURE_COMPONENTS_RGB

#define TEXTURE_COMPONENTS_RGB   0

Texture Color Components

Definition at line 12 of file draw_buffers.h.

◆ TEXTURE_COMPONENTS_RGBA

#define TEXTURE_COMPONENTS_RGBA   1

Definition at line 13 of file draw_buffers.h.

◆ TEXTURE_FUNCTION_DECAL

#define TEXTURE_FUNCTION_DECAL   1

Definition at line 17 of file draw_buffers.h.

◆ TEXTURE_FUNCTION_HIGHLIGHT

#define TEXTURE_FUNCTION_HIGHLIGHT   2

Definition at line 18 of file draw_buffers.h.

◆ TEXTURE_FUNCTION_HIGHLIGHT2

#define TEXTURE_FUNCTION_HIGHLIGHT2   3

Definition at line 19 of file draw_buffers.h.

◆ TEXTURE_FUNCTION_MODULATE

#define TEXTURE_FUNCTION_MODULATE   0

Texture Function

Definition at line 16 of file draw_buffers.h.

Function Documentation

◆ draw_clut_offset()

qword_t* draw_clut_offset ( qword_t q,
int  cbw,
int  u,
int  v 
)

CLUT Storage Mode 2 Information

Definition at line 95 of file draw_environment.c.

96 {
97 
99  q++;
100 
102  q++;
103 
104  return q;
105 
106 }
#define PACK_GIFTAG(Q, D0, D1)
Definition: gif_tags.h:76
#define GIF_SET_TAG(NLOOP, EOP, PRE, PRIM, FLG, NREG)
Definition: gif_tags.h:80
#define GIF_REG_AD
Definition: gif_tags.h:72
#define GIF_FLG_PACKED
Definition: gif_tags.h:35
#define GS_SET_TEXCLUT(CBW, CU, CV)
Definition: gs_gp.h:304
#define GS_REG_TEXCLUT
Definition: gs_gp.h:65

References GIF_FLG_PACKED, GIF_REG_AD, GIF_SET_TAG, GS_REG_TEXCLUT, GS_SET_TEXCLUT, and PACK_GIFTAG.

◆ draw_clutbuffer()

qword_t* draw_clutbuffer ( qword_t q,
int  context,
int  psm,
clutbuffer_t clut 
)

CLUT Storage Mode 1 Information

Definition at line 77 of file draw_environment.c.

78 {
79 
81  {
82  clut->start = 0;
83  }
84 
86  q++;
87 
89  q++;
90 
91  return q;
92 
93 }
u8 context
Definition: main.c:71
clutbuffer_t clut
Definition: main.c:80
#define CLUT_STORAGE_MODE2
Definition: draw_buffers.h:23
#define GS_SET_TEX2(PSM, CBA, CPSM, CSM, CSA, CLD)
Definition: gs_gp.h:295
#define GS_REG_TEX2
Definition: gs_gp.h:49
unsigned int load_method
Definition: draw_buffers.h:68
unsigned int start
Definition: draw_buffers.h:67
unsigned int storage_mode
Definition: draw_buffers.h:66
unsigned int psm
Definition: draw_buffers.h:65
unsigned int address
Definition: draw_buffers.h:64

References clutbuffer_t::address, clut, CLUT_STORAGE_MODE2, context, GIF_FLG_PACKED, GIF_REG_AD, GIF_SET_TAG, GS_REG_TEX2, GS_SET_TEX2, clutbuffer_t::load_method, PACK_GIFTAG, clutbuffer_t::psm, clutbuffer_t::start, and clutbuffer_t::storage_mode.

◆ draw_framebuffer()

qword_t* draw_framebuffer ( qword_t q,
int  context,
framebuffer_t frame 
)

Framebuffer Attributes

Definition at line 33 of file draw_environment.c.

34 {
35 
37  q++;
38  PACK_GIFTAG(q, GS_SET_FRAME(frame->address>>11,frame->width>>6,frame->psm,frame->mask), GS_REG_FRAME + context);
39  q++;
40 
41  return q;
42 
43 }
#define GS_SET_FRAME(FBA, FBW, PSM, FMSK)
Definition: gs_gp.h:209
#define GS_REG_FRAME
Definition: gs_gp.h:119
unsigned int address
Definition: draw_buffers.h:41
unsigned int psm
Definition: draw_buffers.h:44
unsigned int mask
Definition: draw_buffers.h:45
unsigned int width
Definition: draw_buffers.h:42

References framebuffer_t::address, context, GIF_FLG_PACKED, GIF_REG_AD, GIF_SET_TAG, GS_REG_FRAME, GS_SET_FRAME, framebuffer_t::mask, PACK_GIFTAG, framebuffer_t::psm, and framebuffer_t::width.

Referenced by flip_buffers().

◆ draw_log2()

unsigned char draw_log2 ( unsigned int  x)

Returns the power of 2 needed for texture width and height

Definition at line 348 of file draw.c.

349 {
350 
351  unsigned char res;
352 
353  __asm__ __volatile__ ("plzcw %0, %1\n\t" : "=r" (res) : "r" (x));
354 
355  res = 31 - (res + 1);
356  res += (x > (1<<res) ? 1 : 0);
357 
358  return res;
359 }
s32 x
Definition: libmouse.c:34

References x.

Referenced by InitCB(), run_demo(), set_lod_clut_prim_tex_buff(), and setup_texture().

◆ draw_texturebuffer()

qword_t* draw_texturebuffer ( qword_t q,
int  context,
texbuffer_t texbuffer,
clutbuffer_t clut 
)

TextureBuffer Attributes

Definition at line 57 of file draw_environment.c.

58 {
59 
61  {
62  clut->start = 0;
63  }
64 
66  q++;
67 
68  PACK_GIFTAG(q, GS_SET_TEX0(texture->address>>6,texture->width>>6,texture->psm,
69  texture->info.width,texture->info.height,texture->info.components,texture->info.function,
71  q++;
72 
73  return q;
74 
75 }
#define GS_SET_TEX0(TBA, TBW, PSM, TW, TH, TCC, TFNCT, CBA, CPSM, CSM, CSA, CLD)
Definition: gs_gp.h:281
#define GS_REG_TEX0
Definition: gs_gp.h:25

References texbuffer_t::address, clutbuffer_t::address, clut, CLUT_STORAGE_MODE2, texinfo_t::components, context, texinfo_t::function, GIF_FLG_PACKED, GIF_REG_AD, GIF_SET_TAG, GS_REG_TEX0, GS_SET_TEX0, texinfo_t::height, texbuffer_t::info, clutbuffer_t::load_method, PACK_GIFTAG, texbuffer_t::psm, clutbuffer_t::psm, clutbuffer_t::start, clutbuffer_t::storage_mode, texinfo_t::width, and texbuffer_t::width.

Referenced by run_demo(), and setup_texture().

◆ draw_zbuffer()

qword_t* draw_zbuffer ( qword_t q,
int  context,
zbuffer_t zbuffer 
)

ZBuffer Attributes

Definition at line 45 of file draw_environment.c.

46 {
47 
49  q++;
50  PACK_GIFTAG(q, GS_SET_ZBUF(zbuffer->address>>11,zbuffer->zsm,zbuffer->mask), GS_REG_ZBUF + context);
51  q++;
52 
53  return q;
54 
55 }
#define GS_REG_ZBUF
Definition: gs_gp.h:125
#define GS_SET_ZBUF(ZBA, ZSM, ZMSK)
Definition: gs_gp.h:334
unsigned int mask
Definition: draw_buffers.h:53
unsigned int address
Definition: draw_buffers.h:51
unsigned int zsm
Definition: draw_buffers.h:52

References zbuffer_t::address, context, GIF_FLG_PACKED, GIF_REG_AD, GIF_SET_TAG, GS_REG_ZBUF, GS_SET_ZBUF, zbuffer_t::mask, PACK_GIFTAG, and zbuffer_t::zsm.