wavelength 1.0.0
Loading...
Searching...
No Matches
GsDoubleBuffer Class Reference

The display and draw environments of a double-buffered framebuffer. More...

#include <gsdoublebuffer.h>

Classes

struct  DispEnv
 One display environment, 0x40 bytes. More...
struct  DrawHalf
 One draw environment preceded by its GIFtag and followed by its clear, 0xf0 bytes. More...

Public Member Functions

void SetBufferPages (short nWidth, short nHeight, short nPsm)
 Place buffer 0 at page 0, buffer 1 after it, and the depth buffer after both.
void SetDefaults (short nWidth, short nHeight, short nPsm, short nZTest, short nZPsm, short nClear)
 Fill both halves for a framebuffer and a depth buffer laid out from page 0.
void SetDispBuffers (short nWidth, short nHeight, short nPsm, short nFbp0, short nFbp1)
 Build both display environments.
void SetDrawBuffersSmall (short nWidth, short nHeight, short nPsm, short nFbp0, short nFbp1, short nZbp, short nZTest, short nZPsm, short nClear)
 Build both draw environments, their GIFtags, and their clears.
void PutDispBuffer (int nHalf, int bEnableCircuit1)
 Write one display environment to the privileged GS registers.
void PutDrawBufferSmall (int nHalf, int bClear)
 Send one draw environment to the GS through the SDK.
short GetZbp () const
 Display environments of the two halves.
DrawHalf & GetHalf (int nHalf)
 Report one of the two buffers.
const DrawHalf & GetHalf (int nHalf) const
 Report one of the two buffers.

Detailed Description

The display and draw environments of a double-buffered framebuffer.

This is the game's own structure rather than the SDK's sceGsDBuff. Its draw halves begin at +0x80 and +0x170, and it records its parameters from +0x268 on. The extra room at the front comes from each display environment recording a second pair of display registers for read circuit 1 beside the SDK's pair for read circuit 2.

The two read circuits show the same buffer one line apart, and PMODE blends them at half strength. SetDispBuffers() builds both pairs.

The class is not polymorphic and has no RTTI, and no literal in the image identifies it. Its name and the names of its members are inferred from what the routines below do with it. Ps addresses the one instance at an uncached address and reads the draw environments and the depth buffer page directly with no accessor. The data members are therefore public.

Member Function Documentation

◆ SetBufferPages()

void GsDoubleBuffer::SetBufferPages ( short nWidth,
short nHeight,
short nPsm )

Place buffer 0 at page 0, buffer 1 after it, and the depth buffer after both.

The page count assumes 4 bytes per pixel for any format other than PSMCT24 and PSMCT16. The name is inferred.

Parameters
nWidthWidth in pixels.
nHeightHeight in pixels.
nPsmPixel storage format of the frame buffers.
Ghidra address:
NTSC-U/C: 0x0021ac38
Ghidra address:
PAL: 0x00223a50

◆ SetDefaults()

void GsDoubleBuffer::SetDefaults ( short nWidth,
short nHeight,
short nPsm,
short nZTest,
short nZPsm,
short nClear )

Fill both halves for a framebuffer and a depth buffer laid out from page 0.

Records the geometry, places the buffers with SetBufferPages(), then builds the display and draw environments.

Parameters
nWidthWidth in pixels.
nHeightHeight in pixels.
nPsmPixel storage format of the frame buffers.
nZTestDepth test, where zero also masks depth writes.
nZPsmPixel storage format of the depth buffer.
nClearPassed through to SetDrawBuffersSmall() and never read.
Ghidra address:
NTSC-U/C: 0x0021aca0
Ghidra address:
PAL: 0x00223ab8

◆ SetDispBuffers()

void GsDoubleBuffer::SetDispBuffers ( short nWidth,
short nHeight,
short nPsm,
short nFbp0,
short nFbp1 )

Build both display environments.

Each takes the SDK defaults with PMODE blending at 0x80 and both circuits enabled. Circuit 1 shows the buffer as the SDK set it, and circuit 2 starts one line lower, one line shorter, and two units to the right.

Parameters
nWidthWidth in pixels.
nHeightHeight in pixels.
nPsmPixel storage format.
nFbp0Page of buffer 0.
nFbp1Page of buffer 1.
Ghidra address:
NTSC-U/C: 0x0021ad88
Ghidra address:
PAL: 0x00223ba0

◆ SetDrawBuffersSmall()

void GsDoubleBuffer::SetDrawBuffersSmall ( short nWidth,
short nHeight,
short nPsm,
short nFbp0,
short nFbp1,
short nZbp,
short nZTest,
short nZPsm,
short nClear )

Build both draw environments, their GIFtags, and their clears.

Parameters
nWidthWidth in pixels.
nHeightHeight in pixels.
nPsmPixel storage format of the frame buffers.
nFbp0Page of buffer 0.
nFbp1Page of buffer 1.
nZbpPage of the depth buffer.
nZTestDepth test, where zero also masks depth writes.
nZPsmPixel storage format of the depth buffer.
nClearNever read. The caller passes it in the tenth argument slot on the stack.
Ghidra address:
NTSC-U/C: 0x0021af98
Ghidra address:
PAL: 0x00223db0

◆ PutDispBuffer()

void GsDoubleBuffer::PutDispBuffer ( int nHalf,
int bEnableCircuit1 )

Write one display environment to the privileged GS registers.

Read circuit 2 is always enabled. Circuit 1 is enabled or disabled by bEnableCircuit1, and the choice is stored back into the environment.

Parameters
nHalfZero for half 0, anything else for half 1.
bEnableCircuit1Non-zero to enable read circuit 1.
Ghidra address:
NTSC-U/C: 0x0021b248
Ghidra address:
PAL: 0x00224060

◆ PutDrawBufferSmall()

void GsDoubleBuffer::PutDrawBufferSmall ( int nHalf,
int bClear )

Send one draw environment to the GS through the SDK.

Both GIFtags receive the loop count first. The choice of clear therefore persists into the other half.

Parameters
nHalfZero for half 0, anything else for half 1.
bClearNon-zero to send the clear with the environment.
Ghidra address:
NTSC-U/C: 0x0021b398
Ghidra address:
PAL: 0x002241b0

◆ GetZbp()

short GsDoubleBuffer::GetZbp ( ) const
inline

Display environments of the two halves.

+0x000

Returns
The zbp.

◆ GetHalf() [1/2]

DrawHalf & GsDoubleBuffer::GetHalf ( int nHalf)
inline

Report one of the two buffers.

Parameters
nHalfThe buffer, 0 or 1.
Returns
The buffer.

◆ GetHalf() [2/2]

const DrawHalf & GsDoubleBuffer::GetHalf ( int nHalf) const
inline

Report one of the two buffers.

Parameters
nHalfThe buffer, 0 or 1.
Returns
The buffer.

The documentation for this class was generated from the following file: