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

One entry of the GS video memory palette table. More...

#include <vram.h>

Collaboration diagram for VramPalEntry:

Public Member Functions

int GetSlotIndex () const
 Slot index of the record's blocks within the palette region.
void ClearLockMask ()
 Release every lock on the record.
int GetBlockAddr ()
 Mark the record as used this packet and return the GS address of its palette.
int UploadClut (const void *pSource, int nWidth, int nHeight, int nBitsPerPixel, int nPsm)
 Move a palette into the record's slot, allocating the slot first when needed.
void FreeSelf ()
 Release the record, freeing its slot and returning itself to the free list.

Static Public Member Functions

static int AllocBlock ()
 Take a free palette slot, evicting unlocked palettes when every slot is taken.
static int SwapOutOldest ()
 Release up to sixteen unlocked palettes, oldest first.

Public Attributes

unsigned short mMemAddr
 First block of the slot, zero while the record is not resident.
unsigned short mLockMask
 Generation bits.
int mLastUsed
 Value of Rnd::VRAM::mFlushCount at the last GetBlockAddr().
VramPalEntry * mpPrev
 Previous record, towards the most recently used end of the chain.
VramPalEntry * mpNext
 Next record, towards the least recently used end.

Detailed Description

One entry of the GS video memory palette table.

The title is inferred, from the diagnostics "VRAM pal entry should have lockmask %d set" and "No unlocked VRAM pal entries to swap out!". mMemAddr, mpPrev, and mpNext are attested verbatim by "Pal entry in chain has mMemAddr of 0 (mpPrev: %p, mpNext: %p)".

A palette occupies kVramPalBlocks blocks inside the region Rnd::VRAM::Init() reserves below the texture pool, and which slots of that region are taken is tracked in a bitmap rather than in a free list. Resident records form one chain, most recently used first, which is the order SwapOutOldest() walks backwards.

The image records no access control. Every member and method below is reached from Rnd::VRAM or from Rnd::PsTex. A friend declaration fits the image as well as the public section written here.

Member Function Documentation

◆ AllocBlock()

int VramPalEntry::AllocBlock ( )
static

Take a free palette slot, evicting unlocked palettes when every slot is taken.

The routine is the one place in the unit whose title is attested by a literal, its own diagnostic "AllocBlock: trying to set vpalIndex: %d, already set".

Returns
First block of the slot.
Ghidra address:
NTSC-U/C: 0x00513900
Ghidra address:
PAL: 0x00553be8

◆ SwapOutOldest()

int VramPalEntry::SwapOutOldest ( )
static

Release up to sixteen unlocked palettes, oldest first.

Returns
Slot index of the last palette released.
Ghidra address:
NTSC-U/C: 0x00513780
Ghidra address:
PAL: 0x00553a68

◆ GetSlotIndex()

int VramPalEntry::GetSlotIndex ( ) const

Slot index of the record's blocks within the palette region.

Returns
Index in the range zero to kVramPalSlots.
Ghidra address:
NTSC-U/C: 0x005153f0
Ghidra address:
PAL: 0x00555720

◆ ClearLockMask()

void VramPalEntry::ClearLockMask ( )

Release every lock on the record.

Ghidra address:
NTSC-U/C: 0x005154c8
Ghidra address:
PAL: 0x005557f8

◆ GetBlockAddr()

int VramPalEntry::GetBlockAddr ( )

Mark the record as used this packet and return the GS address of its palette.

Returns
First block of the slot, or zero while the record is not resident.
Ghidra address:
NTSC-U/C: 0x00513a40
Ghidra address:
PAL: 0x00553d28

◆ UploadClut()

int VramPalEntry::UploadClut ( const void * pSource,
int nWidth,
int nHeight,
int nBitsPerPixel,
int nPsm )

Move a palette into the record's slot, allocating the slot first when needed.

Parameters
pSourcePalette entries to move.
nWidthPalette width in entries.
nHeightPalette height in entries.
nBitsPerPixelBits per entry. The routine does not read it.
nPsmGS pixel storage mode.
Returns
First block of the slot.
Ghidra address:
NTSC-U/C: 0x00515590
Ghidra address:
PAL: 0x005558c0

◆ FreeSelf()

void VramPalEntry::FreeSelf ( )

Release the record, freeing its slot and returning itself to the free list.

Ghidra address:
NTSC-U/C: 0x005154d0
Ghidra address:
PAL: 0x00555800

Member Data Documentation

◆ mMemAddr

unsigned short VramPalEntry::mMemAddr

First block of the slot, zero while the record is not resident.

Attested.

◆ mLockMask

unsigned short VramPalEntry::mLockMask

Generation bits.

The literals write it "lockmask".

◆ mLastUsed

int VramPalEntry::mLastUsed

Value of Rnd::VRAM::mFlushCount at the last GetBlockAddr().

◆ mpPrev

VramPalEntry* VramPalEntry::mpPrev

Previous record, towards the most recently used end of the chain.

Attested.

◆ mpNext

VramPalEntry* VramPalEntry::mpNext

Next record, towards the least recently used end.

Attested.


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