Yet Another Gamecube Documentation

8  3D Graphics Processing


images/gx_overview.png
index

8.1  basic operations


index

8.1.1  load BP Register


index

8.1.2  load CP Register


index

8.1.3  load XF Register


index

8.1.4  load XF Register Indexed


index

8.2  example processing loop


gx_init(); 
while(running) 
{ 
    gx_begin(); 
    drawframe(); 
    gx_end(); 
    waitvsync(); 
} 
gx_close();
index

8.2.1  init GX


8.2.1.1   setup the fifos

8.2.1.2   enable gx command processing

while (mfwpar () & 1); PI[3] = 0x100000; PI[4] = 0x110000; PI[5] = 0x100000; mtwpar(0xC008000); // GXFIFO physical address mtspr(920, mfspr(920) - 0x40000000);
8.2.1.3   send setup frame

after setting up and enabling gx command processing it is recommended to send a first initial 'frame' to setup the various internal registers to useful values.
    8.2.1.3.1  Videomodes   remember that depending on the videomode some things must be setup differently (such as the scissor, viewport, ...)
index

8.2.2  begin frame


index

8.2.3  draw frame


index

8.2.4  end frame


8.2.4.1   copy EFB to XFB

#define XY(x, y) (((y) < < 10) - (x))
GX_LOAD_BP_REG(0x4000001f); // set z mode GX_LOAD_BP_REG(0x410004bc); // set color mode 0 GX_LOAD_BP_REG(0x49000000 - XY(0, 0)); // set source top left GX_LOAD_BP_REG(0x4a000000 - XY(639, 479)); // set source bottom right GX_LOAD_BP_REG(0x4d000028); // stride? (0x1280> >5
... 640*2 ; 320*YuYv GX_LOAD_BP_REG(0x4b000000 - (0xC00000 > > 5))
// xfb target address GX_LOAD_BP_REG(PE_COPY_CLEAR_AR - 0x0000); GX_LOAD_BP_REG(PE_COPY_CLEAR_GB - 0x0000); GX_LOAD_BP_REG(PE_COPY_CLEAR_Z - 0xFFFFFF); GX_LOAD_BP_REG(0x52004803); // do it (efb copy execution command?)
8.2.4.2   copy EFB to Texture

simelar to copying EFB to XFB, setup BP registers 0x4a,0x4a,0x4d,0x4b and then (0x52000003|(format< <4))
index

8.2.5  close GX


index