wavelength 1.0.0
Loading...
Searching...
No Matches
ps.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4
6#include "math/color.h"
7#include "math/rect.h"
8#include "math/vector2.h"
9#include "os/memhandle.h"
10#include "rnd/dmapacket.h"
11#include "rnd/rndrenderer.h"
12
21class Ps : public RndRenderer {
22public:
24 static constexpr int kGsRegCount = 128;
25
33 Ps();
34
41 virtual ~Ps();
42
55 void Init() override;
56
63 void Terminate() override;
64
72 void SetClearColor(const Color &color) override;
73
80 void DumpStats() override;
81
91 void ScreenDump(const char *pszName) override;
92
101 void DrawRect(const Rect &rect, const Color &color) override;
102
118 float DrawString(const char *pszText,
119 const Vector2 &pos,
120 const Vector2 &charSize,
121 const Color &color) override;
122
132 void BeginFrame() override;
133
140 void EndFrame() override;
141
148 void ClearAndFlip() override;
149
157
165 float AspectRatio() override {
166 return kAspect;
167 }
168
176 bool SupportsTextures() override {
177 return true;
178 }
179
181 static constexpr float kAspect = 0.75f;
182
195 void ShowModal(int *pState, const char *pszText);
196
207 static void ModalCallback(int *pState, const char *pszText);
208
219
230
242
252
262
275 void SetGsReg(int nReg, unsigned long long qwValue, unsigned long long qwMask);
276
286 int PacketQwordsFree() const;
287
297 void Flush();
298
308
318 void DrawBlur();
319
330
332 int GetBlurActive() const {
333 return mBlurActive;
334 }
335
337 void SetBlurActive(int nBlurActive) {
338 mBlurActive = nBlurActive;
339 }
340
342 float GetBlurAmount() const {
343 return mBlurAmount;
344 }
345
347 void SetBlurAmount(float fBlurAmount) {
348 mBlurAmount = fBlurAmount;
349 }
350
352 int GetBlurCount() const {
353 return mBlurCount;
354 }
355
357 void SetBlurCount(int nBlurCount) {
358 mBlurCount = nBlurCount;
359 }
360
362 const float *GetBlurRect() const {
363 return mBlurRect;
364 }
365
367 float *GetBlurRect() {
368 return mBlurRect;
369 }
370
377 void SetBlurRect(int nIndex, float fValue) {
378 mBlurRect[nIndex] = fValue;
379 }
380
382 int GetDepthBytes() const {
383 return mDepthBytes;
384 }
385
387 int GetNtsc() const {
388 return mNtsc;
389 }
390
391private:
392 void *mScratchpadCopy;
393 int mNtsc;
394 int mDepthBytes;
396 unsigned long long mGsRegs[kGsRegCount];
397 int mSwapVblank;
398 int mDrawBuffer;
399 int mReserved458; // +0x458 Cleared by the constructor and never read.
400 GsDoubleBuffer *mDisplayBuffers;
401 int mReserved460; // +0x460 Set to 5 by the constructor and never read.
402 int mReserved464; // +0x464 Cleared by the constructor and never read.
403 int mReserved468; // +0x468 Cleared by the constructor and never read.
408 int mBlurActive;
409 float mBlurRect[4];
410 float mBlurAmount;
411 int mBlurCount;
412 int mInFrame;
413 int mScreenDumpCount;
414 void *mMfifo;
415 std::list<MemHandle *> mFrameHandles;
416};
417
423extern Ps ThePs;
424
431extern volatile int gVCount;
432
439
The display and draw environments of a double-buffered framebuffer.
Definition gsdoublebuffer.h:21
Movable block of a handle heap, reached through a handle the block points back to.
Definition memhandle.h:21
The PlayStation 2 renderer.
Definition ps.h:21
void ReleaseAfterFrame(MemHandle *pHandle)
Release a memory handle at the next buffer swap, once the GS no longer reads it.
void SaveScratchpad()
Copy the scratchpad to a new block in main memory, releasing an earlier copy.
void Terminate() override
Restore the generic factories, stop the vertical blank handler, and release the MFIFO ring.
virtual ~Ps()
Release the frame's pending memory handles list.
void Flush()
Send the packet being built and start the next one in the other half of the scratchpad.
void RestoreAfterMovie()
Set the display up, the first time from Init() and again after the movie player.
float * GetBlurRect()
Definition ps.h:367
int GetNtsc() const
Definition ps.h:387
void RestoreScratchpad()
Copy the block SaveScratchpad() made back to the scratchpad and release it.
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().
bool SupportsTextures() override
Report that the renderer reads texture files.
Definition ps.h:176
void SetBlurRect(int nIndex, float fValue)
Set one entry of the part of the screen DrawBlur() covers, x, y, w, and h.
Definition ps.h:377
int GetBlurActive() const
Definition ps.h:332
void ClearAndFlip() override
Clear the buffer being drawn and show it outside a frame.
const float * GetBlurRect() const
Definition ps.h:362
static constexpr int kGsRegCount
The number of GS registers mGsRegs shadows.
Definition ps.h:24
Ps()
Construct a renderer with a full-screen blur rectangle and register the toggle_heapnum command.
float GetBlurAmount() const
Definition ps.h:342
void ReleaseForMovie()
Give the display up to the movie player.
void DrawRect(const Rect &rect, const Color &color) override
Fill a rectangle of the screen, blended and in front of everything.
int GetReservedVramWords() const
Report the GS memory the frame buffers and the depth buffer occupy.
static constexpr float kAspect
The ratio AspectRatio() reports.
Definition ps.h:181
void SwapBuffers()
Release the memory handles of the frame, wait for the vertical blank, and swap the buffers.
int GetDepthBytes() const
Definition ps.h:382
void ScreenDump(const char *pszName) override
Save the buffer on display to a numbered BMP file.
float DrawString(const char *pszText, const Vector2 &pos, const Vector2 &charSize, const Color &color) override
Draw text with the line font.
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.
void DrawBlur()
Draw the frame back over itself, offset and translucent, inside mBlurRect.
float AspectRatio() override
Report the ratio of the height of the display to its width, fixed at 3 to 4.
Definition ps.h:165
void Init() override
Read the configuration, round the display to a size the GS shows, and set the display up.
void BeginFrame() override
Swap the buffers, restart the MFIFO drain, and set the frame up.
int PacketQwordsFree() const
Report how many quadwords the packet being built still has room for.
void SetBlurCount(int nBlurCount)
Definition ps.h:357
void ShowModal(int *pState, const char *pszText)
Show a message on a dark blue screen until the player presses a button.
int GetBlurCount() const
Definition ps.h:352
void EndFrame() override
Draw the blur when it is active, end the packet, and send it.
void SetBlurAmount(float fBlurAmount)
Definition ps.h:347
static void ModalCallback(int *pState, const char *pszText)
Show a message through ThePs, the routine Init() gives TheDebug.
void RestoreFrameBufferTarget() override
Point FRAME_1 and XYOFFSET_1 at the buffer being drawn, and dither a 16-bit display.
void SetBlurActive(int nBlurActive)
Definition ps.h:337
RndRenderer()
Set an opaque grey of 0.3, a display of 640 by 480 at 16 bits, and a timer ceiling of 50.
DmaQuadword g_vu1MicrocodeChain[]
The DMA chain that loads the VU1 microprograms and resets the VIF1 double buffer, ending with an END ...
volatile int gVCount
The vertical blanks counted since start-up.
DmaQuadword g_vu0MicrocodeChain[]
The DMA chain that loads the VU0 microprograms, ending with an END tag.
Ps ThePs
The renderer.
Linear colour with four float components.
Definition color.h:12
One quadword of a DMA packet, viewed as doublewords, words, or halfwords.
Definition dmapacket.h:4
Axis-aligned rectangle given by a corner and a size.
Definition rect.h:11
Two-component vector, used for texture coordinates.
Definition vector2.h:12