5. Emulation Functions

These S2DEX GBIs are functions for emulation in the CPU.


5.1 guS2DEmuBgRect1Cyc

void guS2DEmuBgRect1Cyc(Gfx **gdl_p, uObjBg *bg);

Emulate the operation of gSPBgRect1Cyc GBI from the S2DEX microcode in the CPU by combining it with another GBI
Arguments: gdl_p Pointer to display list pointer
The value for *gdl_p is automatically added.
  bg Pointer to uObjBg structure

Calling gSPBgRect1Cyc(gdl ++, bg) can be replaced by guS2DEmuBgRect1Cyc(&gdl, bg). See the section on gSPBgRect1Cyc for an explanation of the argument bg.

In addition, in order to announce the setting of a scissoring box and the setting of texture filters to this routine, it is necessary to call the guS2DEmuSetScissor function described below prior to guS2DEmuBgRect1Cyc.

This function generates GBIs which can be processed not only by S2DEX, but also by F3DEX. Because of this, a scaled scrolling BG and a 3D model can both be processed by a single microcode, even when they are displayed together.


5.2 guS2DEmuSetScissor

void guS2DEmuSetScissor(u32 ulx, u32 uly, u32 lrx, u32 lry, u8 bilerp);

Sets the scissoring parameters and texture filters referred to during processing of the function guS2DEmuBgRect1Cyc.
X coordinate at upper-left of scissor box (u10.0)
Y coordinate at upper-left of scissor box (u10.0)
X coordinate at lower-right of scissor box (u10.0)
Y coordinate at lower-right of scissor box (u10.0)
If Bilerp interpolation processing is being done on an image, any value other than 0 is set, if PointSample is used, 0 is set.

Normally, the scissor box range set by g[s]DPSetScissor is conveyed to this function as an argument. In addition, the default values for ulx, uly, lrx, lry, and bilerp are 0, 0, 320, 240, and 0, respectively, setting to render by PointSample in a 320x240 pixel frame buffer.

This function need only be called once prior to calling guS2DEmuBgRect1Cyc. As long as there are no changes to the scissor box and the texture filter, this only needs to be called once when the game is initializing and there is no need to call it every time a frame is rendered.