resonance 1.0.1
Loading...
Searching...
No Matches
Renderer Class Reference

In-game renderer that drives the tunnel, the overlay, and the arena for one game. More...

#include <renderer.h>

Inheritance diagram for Renderer:
Collaboration diagram for Renderer:

Classes

struct  Cell
 One cell of the bar grid, a plain record of the last BarStatusMsg state per track and bar. More...

Public Member Functions

 Renderer ()
 Build the tunnel, overlay, and arena for the game about to start.
virtual ~Renderer ()
 Release the three sinks and clear g_pRenderer.
virtual void DispatchPriv (Message *pMsg)
 Dispatch one message.
virtual void PollMessages ()
 Sample the song clock, then deliver every queued message.
virtual void Update ()
 Advance everything the renderer draws to the sampled song tick.
virtual void Draw ()
 Draw the frame.
Cell * GetCell (int nTrack, int nBar)
 Look up the cell for one track and bar.
Public Member Functions inherited from MsgSource
virtual ~MsgSource ()
virtual void AddSink (MsgSink *pSink)
 Register a sink, ignoring a sink that is already registered.
virtual void RemoveSink (MsgSink *pSink)
 Unregister the first occurrence of a sink.
void Send (Message *pMsg) const
 Deliver a message to every registered sink, in registration order.
void ClearSinks ()
 Unregister every sink.
Public Member Functions inherited from RendererBase
 RendererBase ()
 Start the queue with the router as its one sink.
virtual ~RendererBase ()
 Release the queue and the router.
virtual void Dispatch (Message *pMsg)
 Accept a message into the queue.
virtual void Start ()
 Start the renderer running.
virtual void Stop ()
 Stop the renderer running.
virtual void UpdateSimple ()
 Advance the renderer by one frame without the full update.
virtual void DrawSimple ()
 Draw the frame without the full draw.
Public Member Functions inherited from MsgSink
void * operator new (size_t nSize)
 Allocate a sink from the tagged heap under the tag "MsgSink".
void operator delete (void *pBlock)
 Release a sink to the tagged heap.
virtual ~MsgSink ()

Static Public Member Functions

static void LoadCommon ()
 Start the three common loads unless they have already started.
static void UnloadCommon ()
 Release the level loads and then the three common loads.
static void LoadLevel (const GameParams &params)
 Start the level and arena loads for one game unless they are already the ones loaded.
static void UnloadLevel ()
 Delete the level and arena loaders and forget both names.
static int PollCommon (float *pflProgress)
 Poll the common loads, three or, in the European release, four.
static int PollLevel (float *pflProgress)
 Poll the arena and level loads.
static int IsLevelLoaded (const HxStr &arena, const HxStr &level)
 Report whether one arena and level are loaded.

Public Attributes

float mSongTick
 The song tick PollMessages() last sampled, in MIDI ticks.
Public Attributes inherited from MsgSource
int mGraphBuilt
 A word no member of this class reads.

Detailed Description

In-game renderer that drives the tunnel, the overlay, and the arena for one game.

Its RTTI descriptor is at 0x008efc70. It has two public non-virtual bases, MsgSource at +0x00 and RendererBase at +0x14. Its type function is at 0x00431f18.

The base offsets follow from the base sizes in the same way as for MetRenderer. MsgSource is 0x14 bytes and RendererBase is 0x48, and the first member of this class is therefore at +0x5c. The object is 0xa8 bytes, the size the allocation at 0x0018cadc requests under the MsgSink tag. The allocating routine, at 0x0018caa8, is the constructor's one caller and stores the result at +0x28 of the world.

Two tables belong to the class. The MsgSource table at 0x0081a110 has four entries, the same length as MsgSource's table, and only the destructor differs. The RendererBase table at 0x0081a0b0 has eleven entries and adjusts this by -20. A diff against RendererBase's table at 0x007d2d20 reads overrides at slots 1, 3, 6, 7, and 8, and inheritance at slots 2, 4, 5, 9, and 10. Slots 3, 7, and 8 are pure in the base, and this class makes the renderer concrete.

The constructor records the object in g_pRenderer and the destructor clears it. The three objects the renderer builds (AppTunnel, Overlay, and TnlArena) are also its three message sinks. MsgSource::Send() delivers every message DispatchPriv() does not consume to all three.

The translation unit also defines seven static routines over five async loaders and two cached names, all file-scope globals. The front end starts the loads and the constructor waits for them.

The unreferenced forwarder at 0x00432440 in this unit, byte-identical to MsgJoiner::DispatchPriv() at 0x00195b70, has its unwind record at 0x006e32b8 as its only reference and is recorded here rather than declared.

Constructor & Destructor Documentation

◆ Renderer()

Renderer::Renderer ( )

Build the tunnel, overlay, and arena for the game about to start.

Pumps the timers and polls every async load until the three common loaders and then the level and arena loaders report done, the second wait against the arena and level names of configuration codes 0x27c and 0x278. Each wait ends with one more poll whose result is discarded. Resolves outer.env, whose fog colour becomes the device clear colour after the VRAM table is cleared, and the views outer.view, tnl.view, hud.view, and one tnl locald.view per local player, numbered from 1. Reads configuration codes 0x397 and 0x3a2 into the two debug-overlay switches, builds the three sinks, sizes the cell grid from the tunnel object, and records itself in g_pRenderer.

Ghidra address:
NTSC-U/C: 0x0042c2e0
Ghidra address:
PAL: 0x00467da0

◆ ~Renderer()

virtual Renderer::~Renderer ( )
virtual

Release the three sinks and clear g_pRenderer.

Slot 1 of both tables. The sinks are deleted in reverse order of construction.

Ghidra address:
NTSC-U/C: 0x0042ce08
Ghidra address:
PAL: 0x004689c0

Member Function Documentation

◆ DispatchPriv()

virtual void Renderer::DispatchPriv ( Message * pMsg)
virtual

Dispatch one message.

RendererBase slot 3, pure in the base. A GameBeginMsg runs OnMsg(), a BarStatusMsg runs OnBarStatus(), and a PointAmountMsg runs OnPointAmount(). Every other message is sent on to the sinks.

Parameters
pMsgThe message to dispatch.
Ghidra address:
NTSC-U/C: 0x0042d3b8
Ghidra address:
PAL: 0x00468f70

Implements MsgSink.

◆ PollMessages()

virtual void Renderer::PollMessages ( )
virtual

Sample the song clock, then deliver every queued message.

RendererBase slot 6. The tick is stored as a float in mSongTick before RendererBase::PollMessages() drains the queue.

Ghidra address:
NTSC-U/C: 0x00432460
Ghidra address:
PAL: 0x0046e138

Reimplemented from RendererBase.

◆ Update()

virtual void Renderer::Update ( )
virtual

Advance everything the renderer draws to the sampled song tick.

RendererBase slot 7, pure in the base. The tick goes to the three sinks and the three views, and each view then recomposes its world transform.

Ghidra address:
NTSC-U/C: 0x004324a0
Ghidra address:
PAL: 0x0046e178

Implements RendererBase.

◆ Draw()

virtual void Renderer::Draw ( )
virtual

Draw the frame.

RendererBase slot 8, pure in the base. Draws outer.view, sets up an alternative GS draw context while g_nLsdMode is set, draws each local tunnel view after AppTunnel::PrepareLocalView() has placed it, draws hud.view and the overlay, and finally the two debug overlays under mDrawTimingGraph and mDrawRenderStats.

Ghidra address:
NTSC-U/C: 0x0042d258
Ghidra address:
PAL: 0x00468e10

Implements RendererBase.

◆ GetCell()

Cell * Renderer::GetCell ( int nTrack,
int nBar )

Look up the cell for one track and bar.

The bar wraps modulo the slice count, with a negative remainder raised into range. The title is inferred.

Parameters
nTrackThe track. It selects the row.
nBarThe bar. It selects the column.
Returns
The cell.
Ghidra address:
NTSC-U/C: 0x004322b8
Ghidra address:
PAL: 0x0046df90

◆ LoadCommon()

void Renderer::LoadCommon ( )
static

Start the three common loads unless they have already started.

Rewinds the zone rndCommon, starts tunnel/tunnel_new.rnd, tunnel/launch.rnd, and hud/hud.rnd, passing the zone's index as each loader's third argument, and enqueues all three. The European release also starts hud/game_fonts<suffix>.rnd, the suffix being GetFontLanguageSuffix(), and enqueues that load first.

Ghidra address:
NTSC-U/C: 0x0042b7a0
Ghidra address:
PAL: 0x00466d60

◆ UnloadCommon()

void Renderer::UnloadCommon ( )
static

Release the level loads and then the three common loads.

Each common loader is unloaded and then deleted, hud/hud.rnd first, and its global is cleared. The European release unloads its font load after hud/hud.rnd.

Ghidra address:
NTSC-U/C: 0x0042bb38
Ghidra address:
PAL: 0x004673e8

◆ LoadLevel()

void Renderer::LoadLevel ( const GameParams & params)
static

Start the level and arena loads for one game unless they are already the ones loaded.

A changed level name drops both loaders, and a changed arena name drops the arena loader. Each missing loader then rewinds its zone (rndTnlLevel or rndTnlArena) and starts levels/<level>/images/images.rnd or arenas/<arena>/<arena>.rnd, and the new name is recorded.

Parameters
paramsThe settings whose level and arena names are loaded.
Ghidra address:
NTSC-U/C: 0x0042bbe8
Ghidra address:
PAL: 0x004674c8

◆ UnloadLevel()

void Renderer::UnloadLevel ( )
static

Delete the level and arena loaders and forget both names.

Ghidra address:
NTSC-U/C: 0x00432128
Ghidra address:
PAL: 0x0046de00

◆ PollCommon()

int Renderer::PollCommon ( float * pflProgress)
static

Poll the common loads, three or, in the European release, four.

Parameters
pflProgressReceives the mean progress of the loads. Not written when the loads have not started.
Returns
1 when all are done, and 0 otherwise.
Ghidra address:
NTSC-U/C: 0x00432080
Ghidra address:
PAL: 0x0046dd38

◆ PollLevel()

int Renderer::PollLevel ( float * pflProgress)
static

Poll the arena and level loads.

Parameters
pflProgressReceives the mean progress of the two loads. Not written when the arena load has not started.
Returns
1 when both are done, and 0 otherwise.
Ghidra address:
NTSC-U/C: 0x004321a8
Ghidra address:
PAL: 0x0046de80

◆ IsLevelLoaded()

int Renderer::IsLevelLoaded ( const HxStr & arena,
const HxStr & level )
static

Report whether one arena and level are loaded.

The image has no caller.

Parameters
arenaThe arena name to compare.
levelThe level name to compare.
Returns
1 when both names match the recorded ones and both loads are done, and 0 otherwise.
Ghidra address:
NTSC-U/C: 0x00432228
Ghidra address:
PAL: 0x0046df00

Member Data Documentation

◆ mSongTick

float Renderer::mSongTick

The song tick PollMessages() last sampled, in MIDI ticks.

+0x60

Public because Overlay's handlers at 0x0041fdd8 and 0x0042b068 and AppTunnel::OnBarChanged() read it directly through the renderer they record, and the image has no accessor for it.


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