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

Cache of disc blocks that ArkFile reads go through. More...

#include <blockmgr.h>

Collaboration diagram for BlockMgr:

Public Member Functions

void Init ()
 Build the blocks of the cache.
void GetBlockSpan (long long nOffset, int nBytes, int *pnFirst, int *pnCount, int *pnBlockSize)
 Report the blocks a run of bytes of the disc covers.
void KillBlockRequests (ArkFile *pFile)
 Drop every task of a file, and every request left with no task unless its block is loading.
int SectorToByte (int nSector)
 Report the byte of the disc a sector starts at.
char * GetBlockData (int nBlock)
 Report the data of a loaded block and mark the block used.
void AddRequest (const AsyncTask &task)
 Queue a task, joining the request for its block or inserting a new one in block order.
void Poll ()
 Finish the block that loaded, completing its tasks, and start loading the next request.
Block * FindBlock (int nBlock)
 Find the block holding a block of the disc.
Block * FindOldestBlock ()
 Find the block used longest ago.
const std::vector< std::unique_ptr< Block > > & GetBlocks () const
void Init ()
 Take the block buffers.
void GetAssociatedBlocks (__int64 offset, int bytes, int &firstBlock, int &numBlocks, int &blockSize)
 Report the blocks a range of the archive covers.
void KillBlockRequests (ArkFile *file)
 Drop every waiting read of a file, and every request left with no read unless its block is loading.
char * GetBlockData (int blockNum)
 Report the data of a loaded block and mark the block as just used.
void AddRequest (const AsyncTask &task)
 Queue a read on the request of its block, creating the request when needed.
void Poll ()
 Finish the loading block and satisfy its reads, then start loading the next requested block.
Block * FindBlock (int blockNum)
 Find the buffer of a block.
Block * GetOldestBlock ()
 Find the least recently used buffer.

Static Public Member Functions

static bool ReadDone ()
 Report whether the read of the drive finished.
static int ReadError ()
 Report the error of the last read of the drive.
static bool Read (int nSector, int nCount, void *pBuffer)
 Start reading sectors of the disc.

Public Attributes

std::vector< Block * > mBlocks
Block * mLoadingBlock

Detailed Description

Cache of disc blocks that ArkFile reads go through.

Cache of archive blocks that satisfies the reads of ArkFile.

The class is not polymorphic and emits no RTTI, and the name is inferred. One block loads at a time. Requests are kept sorted by block, and the oldest unused block takes the next load.

The object is 0x18 bytes. One block loads at a time, into the least recently used buffer, and the requests stay sorted by block.

Member Function Documentation

◆ Init() [1/2]

void BlockMgr::Init ( )

Build the blocks of the cache.

Ghidra address:
NTSC-U/C: 0x0028f978
Ghidra address:
PAL: 0x00299340

◆ GetBlockSpan()

void BlockMgr::GetBlockSpan ( long long nOffset,
int nBytes,
int * pnFirst,
int * pnCount,
int * pnBlockSize )

Report the blocks a run of bytes of the disc covers.

Parameters
nOffsetThe first byte.
nBytesThe number of bytes.
pnFirstReceives the first block.
pnCountReceives the number of blocks, at least 1.
pnBlockSizeReceives the size of a block in bytes.
Ghidra address:
NTSC-U/C: 0x0028fa80
Ghidra address:
PAL: 0x00299448

◆ KillBlockRequests() [1/2]

void BlockMgr::KillBlockRequests ( ArkFile * pFile)

Drop every task of a file, and every request left with no task unless its block is loading.

Parameters
pFileThe file.
Ghidra address:
NTSC-U/C: 0x0028fb58
Ghidra address:
PAL: 0x00299520

◆ SectorToByte()

int BlockMgr::SectorToByte ( int nSector)

Report the byte of the disc a sector starts at.

Parameters
nSectorThe sector.
Returns
The byte.
Ghidra address:
NTSC-U/C: 0x0028fcf8
Ghidra address:
PAL: 0x002996c0

◆ GetBlockData() [1/2]

char * BlockMgr::GetBlockData ( int nBlock)

Report the data of a loaded block and mark the block used.

Parameters
nBlockThe block of the disc.
Returns
The data, or null when the block is not loaded or still loading.
Ghidra address:
NTSC-U/C: 0x0028fd00
Ghidra address:
PAL: 0x002996c8

◆ AddRequest() [1/2]

void BlockMgr::AddRequest ( const AsyncTask & task)

Queue a task, joining the request for its block or inserting a new one in block order.

Parameters
taskThe task.
Ghidra address:
NTSC-U/C: 0x0028fd50
Ghidra address:
PAL: 0x00299718

◆ Poll() [1/2]

void BlockMgr::Poll ( )

Finish the block that loaded, completing its tasks, and start loading the next request.

A read that failed is started again.

Ghidra address:
NTSC-U/C: 0x0028ff88
Ghidra address:
PAL: 0x00299950

◆ FindBlock() [1/2]

Block * BlockMgr::FindBlock ( int nBlock)

Find the block holding a block of the disc.

Parameters
nBlockThe block of the disc.
Returns
The block, or null.
Ghidra address:
NTSC-U/C: 0x002901a8
Ghidra address:
PAL: 0x00299b70

◆ FindOldestBlock()

Block * BlockMgr::FindOldestBlock ( )

Find the block used longest ago.

Returns
The block, or null when every block was used at the latest mark.
Ghidra address:
NTSC-U/C: 0x002901f8
Ghidra address:
PAL: 0x00299bc0

◆ ReadDone()

bool BlockMgr::ReadDone ( )
static

Report whether the read of the drive finished.

Returns
Whether the read finished.
Ghidra address:
NTSC-U/C: 0x00290378
Ghidra address:
PAL: 0x00299d40

◆ ReadError()

int BlockMgr::ReadError ( )
static

Report the error of the last read of the drive.

Returns
The sceCdGetError() code.
Ghidra address:
NTSC-U/C: 0x00290398
Ghidra address:
PAL: 0x00299d60

◆ Read()

bool BlockMgr::Read ( int nSector,
int nCount,
void * pBuffer )
static

Start reading sectors of the disc.

Parameters
nSectorThe first sector.
nCountThe number of sectors.
pBufferReceives the sectors.
Returns
Whether the read started.
Ghidra address:
NTSC-U/C: 0x002903b8
Ghidra address:
PAL: 0x00299d80

◆ GetBlocks()

const std::vector< std::unique_ptr< Block > > & BlockMgr::GetBlocks ( ) const
inline
Returns
The blocks of the cache.

◆ Init() [2/2]

void BlockMgr::Init ( )

Take the block buffers.

Ghidra address:
0x1000f170

◆ GetAssociatedBlocks()

void BlockMgr::GetAssociatedBlocks ( __int64 offset,
int bytes,
int & firstBlock,
int & numBlocks,
int & blockSize )

Report the blocks a range of the archive covers.

Parameters
offsetThe offset of the range.
bytesThe size of the range.
firstBlockReceives the first block.
numBlocksReceives the number of blocks.
blockSizeReceives the size of a block.
Ghidra address:
0x1000f280

◆ KillBlockRequests() [2/2]

void BlockMgr::KillBlockRequests ( ArkFile * file)

Drop every waiting read of a file, and every request left with no read unless its block is loading.

Parameters
fileThe file.
Ghidra address:
0x1000f300

◆ GetBlockData() [2/2]

char * BlockMgr::GetBlockData ( int blockNum)

Report the data of a loaded block and mark the block as just used.

Parameters
blockNumThe block.
Returns
The data, or null when the block is not loaded or still loading.
Ghidra address:
0x1000f3b0

◆ AddRequest() [2/2]

void BlockMgr::AddRequest ( const AsyncTask & task)

Queue a read on the request of its block, creating the request when needed.

Parameters
taskThe read.
Ghidra address:
0x1000f3e0

◆ Poll() [2/2]

void BlockMgr::Poll ( )

Finish the loading block and satisfy its reads, then start loading the next requested block.

Ghidra address:
0x1000f5c0

◆ FindBlock() [2/2]

Block * BlockMgr::FindBlock ( int blockNum)

Find the buffer of a block.

Parameters
blockNumThe block.
Returns
The buffer, or null.
Ghidra address:
0x1000f720

◆ GetOldestBlock()

Block * BlockMgr::GetOldestBlock ( )

Find the least recently used buffer.

Returns
The buffer, or null when every buffer was used at the latest timestamp.
Ghidra address:
0x1000f770

Member Data Documentation

◆ mBlocks

std::vector<Block *> BlockMgr::mBlocks

The block buffers.

◆ mLoadingBlock

Block* BlockMgr::mLoadingBlock

The buffer being loaded, or null.


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