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

The PlayStation 2 renderer. More...

#include <ps.h>

Inheritance diagram for Ps:
Collaboration diagram for Ps:

Public Member Functions

 Ps ()
 Construct a renderer with a full-screen blur rectangle and register the toggle_heapnum command.
virtual ~Ps ()
 Release the frame's pending memory handles list.
void Init () override
 Read the configuration, round the display to a size the GS shows, and set the display up.
void Terminate () override
 Restore the generic factories, stop the vertical blank handler, and release the MFIFO ring.
void SetClearColor (const Color &color) override
 Set the colour the frame is cleared to and write it into the clears of both buffers.
void DumpStats () override
 Pass the drawing statistics and the free GS memory to DebugPrint().
void ScreenDump (const char *pszName) override
 Save the buffer on display to a numbered BMP file.
void DrawRect (const Rect &rect, const Color &color) override
 Fill a rectangle of the screen, blended and in front of everything.
float DrawString (const char *pszText, const Vector2 &pos, const Vector2 &charSize, const Color &color) override
 Draw text with the line font.
void BeginFrame () override
 Swap the buffers, restart the MFIFO drain, and set the frame up.
void EndFrame () override
 Draw the blur when it is active, end the packet, and send it.
void ClearAndFlip () override
 Clear the buffer being drawn and show it outside a frame.
void RestoreFrameBufferTarget () override
 Point FRAME_1 and XYOFFSET_1 at the buffer being drawn, and dither a 16-bit display.
float AspectRatio () override
 Report the ratio of the height of the display to its width, fixed at 3 to 4.
bool SupportsTextures () override
 Report that the renderer reads texture files.
void ShowModal (int *pState, const char *pszText)
 Show a message on a dark blue screen until the player presses a button.
int GetReservedVramWords () const
 Report the GS memory the frame buffers and the depth buffer occupy.
void ReleaseForMovie ()
 Give the display up to the movie player.
void RestoreAfterMovie ()
 Set the display up, the first time from Init() and again after the movie player.
void SaveScratchpad ()
 Copy the scratchpad to a new block in main memory, releasing an earlier copy.
void RestoreScratchpad ()
 Copy the block SaveScratchpad() made back to the scratchpad and release it.
void SetGsReg (int nReg, unsigned long long qwValue, unsigned long long qwMask)
 Write a GS register through an A+D tag unless its shadow already has the value.
int PacketQwordsFree () const
 Report how many quadwords the packet being built still has room for.
void Flush ()
 Send the packet being built and start the next one in the other half of the scratchpad.
void SwapBuffers ()
 Release the memory handles of the frame, wait for the vertical blank, and swap the buffers.
void DrawBlur ()
 Draw the frame back over itself, offset and translucent, inside mBlurRect.
void ReleaseAfterFrame (MemHandle *pHandle)
 Release a memory handle at the next buffer swap, once the GS no longer reads it.
int GetBlurActive () const
void SetBlurActive (int nBlurActive)
float GetBlurAmount () const
void SetBlurAmount (float fBlurAmount)
int GetBlurCount () const
void SetBlurCount (int nBlurCount)
const float * GetBlurRect () const
float * GetBlurRect ()
void SetBlurRect (int nIndex, float fValue)
 Set one entry of the part of the screen DrawBlur() covers, x, y, w, and h.
int GetDepthBytes () const
int GetNtsc () const
Public Member Functions inherited from RndRenderer
 RndRenderer ()
 Set an opaque grey of 0.3, a display of 640 by 480 at 16 bits, and a timer ceiling of 50.
virtual void SetShowTimers (int bShow, int nMaxMs)
 Show or hide the timer overlay.
virtual void SetShowStats (int bShow)
 Show or hide the statistics overlay.
virtual void SetShowRate (int bShow)
 Show or hide the frame rate overlay.
const Color & GetClearColor () const
int GetFrameCount () const
int GetScreenHeight () const
int GetScreenWidth () const
int GetTimerMaxMs () const

Static Public Member Functions

static void ModalCallback (int *pState, const char *pszText)
 Show a message through ThePs, the routine Init() gives TheDebug.

Static Public Attributes

static constexpr int kGsRegCount = 128
 The number of GS registers mGsRegs shadows.
static constexpr float kAspect = 0.75f
 The ratio AspectRatio() reports.

Additional Inherited Members

Protected Attributes inherited from RndRenderer
Color mClearColor
int mScreenWidth
int mScreenHeight
int mScreenBpp
int mTimerMaxMs
int mFrameCount
int mShowTimers
int mShowStats
int mShowRate

Detailed Description

The PlayStation 2 renderer.

The RTTI includes the name and records RndRenderer as the one base. ThePs is the one instance, and TheRnd points at it. The frame is built in the scratchpad by DmaPacket::shared() and sent from there through the MFIFO ring in main memory to VIF1. mGsRegs shadows the GS registers, and SetGsReg() writes a register only when its value changes.

Constructor & Destructor Documentation

◆ Ps()

Ps::Ps ( )

Construct a renderer with a full-screen blur rectangle and register the toggle_heapnum command.

Ghidra address:
NTSC-U/C: 0x0020fbe8
Ghidra address:
PAL: 0x00218a00

◆ ~Ps()

virtual Ps::~Ps ( )
virtual

Release the frame's pending memory handles list.

Ghidra address:
NTSC-U/C: 0x0037c868
Ghidra address:
PAL: 0x003eaf98

Member Function Documentation

◆ Init()

void Ps::Init ( )
overridevirtual

Read the configuration, round the display to a size the GS shows, and set the display up.

The width becomes 640, 512, 384, or 256, and the height 512, 448, 256, or 224, each the largest that does not exceed the request. A height of 448 or 224 selects NTSC output. The MFIFO ring is allocated, the packet builder is placed after it in the scratchpad, and the PlayStation 2 factories replace the generic ones. The modal message routine of TheDebug becomes ModalCallback().

Ghidra address:
NTSC-U/C: 0x00210330
Ghidra address:
PAL: 0x00219148

Reimplemented from RndRenderer.

◆ Terminate()

void Ps::Terminate ( )
overridevirtual

Restore the generic factories, stop the vertical blank handler, and release the MFIFO ring.

Ghidra address:
NTSC-U/C: 0x00210650
Ghidra address:
PAL: 0x00219468

Reimplemented from RndRenderer.

◆ SetClearColor()

void Ps::SetClearColor ( const Color & color)
overridevirtual

Set the colour the frame is cleared to and write it into the clears of both buffers.

Parameters
colorThe colour.
Ghidra address:
NTSC-U/C: 0x00211010
Ghidra address:
PAL: 0x00219e28

Reimplemented from RndRenderer.

◆ DumpStats()

void Ps::DumpStats ( )
overridevirtual

Pass the drawing statistics and the free GS memory to DebugPrint().

Ghidra address:
NTSC-U/C: 0x002115b8
Ghidra address:
PAL: 0x0021a3d0

Reimplemented from RndRenderer.

◆ ScreenDump()

void Ps::ScreenDump ( const char * pszName)
overridevirtual

Save the buffer on display to a numbered BMP file.

An open frame is closed first and opened again afterwards.

Parameters
pszNameThe base name of the file.
Ghidra address:
NTSC-U/C: 0x00211c88
Ghidra address:
PAL: 0x0021aaa0

Reimplemented from RndRenderer.

◆ DrawRect()

void Ps::DrawRect ( const Rect & rect,
const Color & color )
overridevirtual

Fill a rectangle of the screen, blended and in front of everything.

Parameters
rectThe rectangle in pixels.
colorThe colour.
Ghidra address:
NTSC-U/C: 0x00211748
Ghidra address:
PAL: 0x0021a560

Reimplemented from RndRenderer.

◆ DrawString()

float Ps::DrawString ( const char * pszText,
const Vector2 & pos,
const Vector2 & charSize,
const Color & color )
overridevirtual

Draw text with the line font.

The characters from A to _, the lowercase letters, and the characters from ' to : have glyphs. Every other character draws nothing. Every character but a newline advances the pen by one and a half cells, and a newline starts a line two cells lower.

Parameters
pszTextThe text.
posThe top left corner in pixels.
charSizeThe size of a cell in pixels.
colorThe colour.
Returns
The top of the line after the text.
Ghidra address:
NTSC-U/C: 0x0020fce0
Ghidra address:
PAL: 0x00218af8

Reimplemented from RndRenderer.

◆ BeginFrame()

void Ps::BeginFrame ( )
overridevirtual

Swap the buffers, restart the MFIFO drain, and set the frame up.

The statistics are cleared, the default camera and the default material are applied, the texture cache ages, and every named timer is reset.

Ghidra address:
NTSC-U/C: 0x00211410
Ghidra address:
PAL: 0x0021a228

Reimplemented from RndRenderer.

◆ EndFrame()

void Ps::EndFrame ( )
overridevirtual

Draw the blur when it is active, end the packet, and send it.

Ghidra address:
NTSC-U/C: 0x00211518
Ghidra address:
PAL: 0x0021a330

Reimplemented from RndRenderer.

◆ ClearAndFlip()

void Ps::ClearAndFlip ( )
overridevirtual

Clear the buffer being drawn and show it outside a frame.

Ghidra address:
NTSC-U/C: 0x00211570
Ghidra address:
PAL: 0x0021a388

Reimplemented from RndRenderer.

◆ RestoreFrameBufferTarget()

void Ps::RestoreFrameBufferTarget ( )
overridevirtual

Point FRAME_1 and XYOFFSET_1 at the buffer being drawn, and dither a 16-bit display.

Ghidra address:
NTSC-U/C: 0x00211230
Ghidra address:
PAL: 0x0021a048

Reimplemented from RndRenderer.

◆ AspectRatio()

float Ps::AspectRatio ( )
inlineoverridevirtual

Report the ratio of the height of the display to its width, fixed at 3 to 4.

Returns
0.75.
Ghidra address:
NTSC-U/C: 0x0037c858
Ghidra address:
PAL: 0x003eaf88

Reimplemented from RndRenderer.

◆ SupportsTextures()

bool Ps::SupportsTextures ( )
inlineoverridevirtual

Report that the renderer reads texture files.

Returns
true.
Ghidra address:
NTSC-U/C: 0x0037c850
Ghidra address:
PAL: 0x003eaf80

Reimplemented from RndRenderer.

◆ ShowModal()

void Ps::ShowModal ( int * pState,
const char * pszText )

Show a message on a dark blue screen until the player presses a button.

The overlays are hidden while the message shows, and an open frame is closed first and opened again afterwards. A state of 2 is cleared when the button is the one at bit 11. The name is inferred.

Parameters
pStateThe caller's state.
pszTextThe message.
Ghidra address:
NTSC-U/C: 0x002100c8
Ghidra address:
PAL: 0x00218ee0

◆ ModalCallback()

void Ps::ModalCallback ( int * pState,
const char * pszText )
static

Show a message through ThePs, the routine Init() gives TheDebug.

The name is inferred.

Parameters
pStateThe caller's state.
pszTextThe message.
Ghidra address:
NTSC-U/C: 0x002100a0
Ghidra address:
PAL: 0x00218eb8

◆ GetReservedVramWords()

int Ps::GetReservedVramWords ( ) const

Report the GS memory the frame buffers and the depth buffer occupy.

The name is inferred.

Returns
The size in words.
Ghidra address:
NTSC-U/C: 0x002102d8
Ghidra address:
PAL: 0x002190f0

◆ ReleaseForMovie()

void Ps::ReleaseForMovie ( )

Give the display up to the movie player.

The scratchpad is saved, the GS path is drained, and the GIF interrupt handler is removed. The name is inferred.

Ghidra address:
NTSC-U/C: 0x00210b88
Ghidra address:
PAL: 0x002199a0

◆ RestoreAfterMovie()

void Ps::RestoreAfterMovie ( )

Set the display up, the first time from Init() and again after the movie player.

The register shadow is cleared, the GS is reset, the display buffers are placed for the depth, the VU microprograms are sent, and the MFIFO ring is restarted. A depth other than 16, 24, or 32 bits becomes 32. The name is inferred.

Ghidra address:
NTSC-U/C: 0x00210bb8
Ghidra address:
PAL: 0x002199d0

◆ SaveScratchpad()

void Ps::SaveScratchpad ( )

Copy the scratchpad to a new block in main memory, releasing an earlier copy.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00210e70
Ghidra address:
PAL: 0x00219c88

◆ RestoreScratchpad()

void Ps::RestoreScratchpad ( )

Copy the block SaveScratchpad() made back to the scratchpad and release it.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00210ed8
Ghidra address:
PAL: 0x00219cf0

◆ SetGsReg()

void Ps::SetGsReg ( int nReg,
unsigned long long qwValue,
unsigned long long qwMask )

Write a GS register through an A+D tag unless its shadow already has the value.

A mask of 0 writes the whole value without the comparison. Otherwise only the bits of the mask are compared and changed.

Parameters
nRegThe register.
qwValueThe value.
qwMaskThe bits to set, or 0 for all of them.
Ghidra address:
NTSC-U/C: 0x00210f28
Ghidra address:
PAL: 0x00219d40

◆ PacketQwordsFree()

int Ps::PacketQwordsFree ( ) const

Report how many quadwords the packet being built still has room for.

The name is inferred.

Returns
The quadwords.
Ghidra address:
NTSC-U/C: 0x00211100
Ghidra address:
PAL: 0x00219f18

◆ Flush()

void Ps::Flush ( )

Send the packet being built and start the next one in the other half of the scratchpad.

The routine waits until the MFIFO ring has room. An empty packet is not sent. The name is inferred.

Ghidra address:
NTSC-U/C: 0x00211128
Ghidra address:
PAL: 0x00219f40

◆ SwapBuffers()

void Ps::SwapBuffers ( )

Release the memory handles of the frame, wait for the vertical blank, and swap the buffers.

The shadow takes the context 1 registers of the new draw environment. The name is inferred.

Ghidra address:
NTSC-U/C: 0x002112c0
Ghidra address:
PAL: 0x0021a0d8

◆ DrawBlur()

void Ps::DrawBlur ( )

Draw the frame back over itself, offset and translucent, inside mBlurRect.

The texture is the buffer on display, and the sprite does not test or write depth. The title is inferred.

Ghidra address:
NTSC-U/C: 0x00211930
Ghidra address:
PAL: 0x0021a748

◆ ReleaseAfterFrame()

void Ps::ReleaseAfterFrame ( MemHandle * pHandle)

Release a memory handle at the next buffer swap, once the GS no longer reads it.

A null handle is ignored. The name is inferred.

Parameters
pHandleThe handle, or null.
Ghidra address:
NTSC-U/C: 0x00211e70
Ghidra address:
PAL: 0x0021ac88

◆ GetBlurActive()

int Ps::GetBlurActive ( ) const
inline
Returns
BlurActive.

◆ SetBlurActive()

void Ps::SetBlurActive ( int nBlurActive)
inline
Parameters
nBlurActiveBlurActive.

◆ GetBlurAmount()

float Ps::GetBlurAmount ( ) const
inline
Returns
The opacity of the frame DrawBlur() draws.

◆ SetBlurAmount()

void Ps::SetBlurAmount ( float fBlurAmount)
inline
Parameters
fBlurAmountThe opacity of the frame DrawBlur() draws.

◆ GetBlurCount()

int Ps::GetBlurCount ( ) const
inline
Returns
The offset of the frame DrawBlur() draws, in 1/16 pixel.

◆ SetBlurCount()

void Ps::SetBlurCount ( int nBlurCount)
inline
Parameters
nBlurCountThe offset of the frame DrawBlur() draws, in 1/16 pixel.

◆ GetBlurRect() [1/2]

const float * Ps::GetBlurRect ( ) const
inline
Returns
The part of the screen DrawBlur() covers, x, y, w, and h.

◆ GetBlurRect() [2/2]

float * Ps::GetBlurRect ( )
inline
Returns
The part of the screen DrawBlur() covers, x, y, w, and h, for writing.

◆ SetBlurRect()

void Ps::SetBlurRect ( int nIndex,
float fValue )
inline

Set one entry of the part of the screen DrawBlur() covers, x, y, w, and h.

Parameters
nIndexThe entry.
fValueThe value.

◆ GetDepthBytes()

int Ps::GetDepthBytes ( ) const
inline
Returns
The bytes of a depth buffer pixel.

◆ GetNtsc()

int Ps::GetNtsc ( ) const
inline
Returns
Non-zero for NTSC output, zero for PAL.

Member Data Documentation

◆ kGsRegCount

int Ps::kGsRegCount = 128
staticconstexpr

The number of GS registers mGsRegs shadows.

◆ kAspect

float Ps::kAspect = 0.75f
staticconstexpr

The ratio AspectRatio() reports.


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