#include <vector>
#include "os/hxstr.h"
Go to the source code of this file.
◆ HashArkString()
| short HashArkString |
( |
const char * | pszName | ) |
|
Hash a file name or a relative path for the table searches.
Each character is shifted left by one more place than the character before it, the shift wrapping from 7 back to 0, and combined into a 16-bit accumulator with exclusive or.
- Parameters
-
| pszName | The string to hash. |
- Returns
- The hash.
- Ghidra address:
- NTSC-U/C: 0x0055c340
- Ghidra address:
- PAL: 0x0059d560
◆ EraseArkStream()
| int EraseArkStream |
( |
int | nHandle | ) |
|
Erase a stream record by handle.
- Parameters
-
| nHandle | The stream handle. |
- Returns
- Zero when the record was erased, or -1 when no record has that handle.
- Ghidra address:
- NTSC-U/C: 0x0055a1a0
- Ghidra address:
- PAL: 0x0059b3c0
◆ LookupOpenFile()
Find the record of an open stream.
kFileHandleArkStream is masked off the handle before the search. A caller may therefore pass the handle with the bit or without it.
- Parameters
-
| nHandle | The stream handle. |
- Returns
- The record, or null when no record has that handle.
- Ghidra address:
- NTSC-U/C: 0x0055c158
- Ghidra address:
- PAL: 0x0059d378
◆ FindOpenFileInArk()
Report the file entry a stream reads.
The entry is what gives a caller the stream's stored and inflated sizes without a file table search of its own. The search walks the stream vector here rather than through LookupOpenFile(), and it masks kFileHandleArkStream off the handle in the same way.
- Parameters
-
| nHandle | The stream handle, with the bit or without it. |
- Returns
- The entry, or null when no record has that handle.
- Ghidra address:
- NTSC-U/C: 0x0055be80
- Ghidra address:
- PAL: 0x0059d0a0
◆ OpenFileInArk()
| int OpenFileInArk |
( |
const char * | pszPath | ) |
|
Open a stream on a file inside a mounted archive.
- Parameters
-
| pszPath | The path of the file. |
- Returns
- The stream handle, without kFileHandleArkStream, or -1 when no mounted archive lists the file.
- Ghidra address:
- NTSC-U/C: 0x0055bce8
- Ghidra address:
- PAL: 0x0059cf08
◆ GetArkFileLengthByPath()
| int GetArkFileLengthByPath |
( |
const char * | pszPath | ) |
|
Report the stored length of a file inside a mounted archive.
The shipped program does not call it.
- Parameters
-
| pszPath | The path of the file. |
- Returns
- The length in bytes, or -1 when no mounted archive lists the file.
- Ghidra address:
- NTSC-U/C: 0x0055bee0
- Ghidra address:
- PAL: 0x0059d100
◆ ReadArkStreamThroughCache()
| int ReadArkStreamThroughCache |
( |
int | nHandle, |
|
|
void * | pBuffer, |
|
|
unsigned | nBytes ) |
Read from an ark stream through the sector cache.
The request is clamped to the bytes left in the file. Each 64 KiB chunk the read touches is taken from the cache, and a chunk the cache does not have is read into the least recently used row first, at the position ArkfileLogicalToPhysicalSector() maps it to. A cached chunk the current asynchronous operation is still filling waits for that operation through AsyncCheck().
- Parameters
-
| nHandle | The stream handle. |
| pBuffer | The destination. |
| nBytes | The number of bytes requested. |
- Returns
- The number of bytes read, or -1 when no record has that handle or the stream is at the end of its file.
- Ghidra address:
- NTSC-U/C: 0x0055a280
- Ghidra address:
- PAL: 0x0059b4a0
◆ IoctlFile()
| int IoctlFile |
( |
int | nFile, |
|
|
int | nRequest, |
|
|
void * | pArg ) |
Forward a control request to sceIoctl().
The shipped program does not call it.
- Parameters
-
| nFile | The file descriptor. |
| nRequest | The request. |
| pArg | The request argument. |
- Returns
- The sceIoctl() result.
- Ghidra address:
- NTSC-U/C: 0x0055c3e0
- Ghidra address:
- PAL: 0x0059d600
◆ WaitForFileIdle()
| void WaitForFileIdle |
( |
int | nFile | ) |
|
Wait until no asynchronous operation is running on a file.
The routine polls sceIoctl() with kSceFsExecuting and performs no other work between the polls. A negative descriptor returns at once. The shipped program does not call it.
- Parameters
-
| nFile | The file descriptor. |
- Ghidra address:
- NTSC-U/C: 0x0055c458
- Ghidra address:
- PAL: 0x0059d678
◆ GetArkfileIdFromFileFd()
| int GetArkfileIdFromFileFd |
( |
int | nHandle | ) |
|
Report the archive a stream reads from.
- Parameters
-
| nHandle | The stream handle. |
- Returns
- The archive's file, or -1 when no record has that handle.
- Ghidra address:
- NTSC-U/C: 0x0055c000
- Ghidra address:
- PAL: 0x0059d220
◆ ArkfileGetBaseSector()
| int ArkfileGetBaseSector |
( |
int | nFile | ) |
|
Report the disc sector a mounted archive starts at.
A file that is not a mounted archive is fatal, and the report lists every mounted archive's file before stopping.
- Parameters
-
- Returns
- The archive's start sector.
- Ghidra address:
- NTSC-U/C: 0x0055a590
- Ghidra address:
- PAL: 0x0059b7b0
◆ ArkfileLogicalToPhysicalSector()
| int ArkfileLogicalToPhysicalSector |
( |
int | nFile, |
|
|
int | nSector ) |
Map a chunk of an archive to the chunk position the disc stores it at.
An archive built without the optimized block stores its chunks in order, and the argument is returned unchanged. An optimized archive stores them in the order the game reads them, and its optimized block is an array of two-byte logical chunk indices whose slot number is the position on the disc. The lookup is therefore a search of that array for the logical index, returning the slot it was found in.
OpenArkObject::mOptimizedCursor makes the common case constant time. It records the slot after the one the last lookup resolved. That is the slot a sequential read wants next. A miss on the guess reports through the log, abandons the cursor, and falls back to searching the whole array. A chunk that appears in no slot is fatal.
A file that is not a mounted archive is reported through the log, and the argument is returned unchanged.
- Parameters
-
| nFile | The archive's file. |
| nSector | The logical chunk index. |
- Returns
- The chunk position on the disc.
- Ghidra address:
- NTSC-U/C: 0x0055a410
- Ghidra address:
- PAL: 0x0059b630
◆ InitArk()
Mount the archives the game needs for the whole session.
Performs no work when ark archives are not in use. The first archive that fails to mount is reported on cout, and the archives after it are not tried.
- Returns
- Non-zero when every archive was mounted.
- Ghidra address:
- NTSC-U/C: 0x004dfb20
- Ghidra address:
- PAL: 0x0051e280
◆ CloseArk()
Unmount the archives InitArk() mounted.
Each archive is closed through OpenArkObject::Close() even when an earlier one was refused. The result counts the unmounts, so it is zero after a successful teardown. It is non-zero only when ark archives are not in use or when none of the three was still mounted.
- Returns
- Non-zero when no archive was unmounted.
- Ghidra address:
- NTSC-U/C: 0x004dfbd8
- Ghidra address:
- PAL: 0x0051e338
◆ kArkHeaderSize
| int kArkHeaderSize = 0x100 |
|
constexpr |
The number of bytes of the archive header the mount copies into the record.
◆ kArkVersion
The archive header version the mount accepts.
◆ kArkMountPointSize
| int kArkMountPointSize = 0x80 |
|
constexpr |
The number of bytes the mount point occupies, which is the rest of the record.
◆ kArkSectorCacheRows
| int kArkSectorCacheRows = 8 |
|
constexpr |
Rows the sector cache is asked for on the first mount.
◆ kArkDevicePathSize
| int kArkDevicePathSize = 0x100 |
|
constexpr |
The number of bytes of the device path Open() builds on its stack.
◆ kArkDiscRoot
| char kArkDiscRoot[] = "cdrom0:\\ARK" |
|
constexpr |
Directory the archives live in on the disc.
◆ kArkHostRoot
| char kArkHostRoot[] = "host0:" |
|
constexpr |
Prefix that reads an archive over the host link instead.
◆ kArkRunComponent
| char kArkRunComponent[] = "run" |
|
constexpr |
Path component of the archive header that fixes the mount point.
◆ kArkPathBufferSize
| int kArkPathBufferSize = 0x80 |
|
constexpr |
◆ kArkNameBufferSize
| int kArkNameBufferSize = 0x80 |
|
constexpr |
◆ kArkRelPathBufferSize
| int kArkRelPathBufferSize = 0x100 |
|
constexpr |
◆ kArkIndexAny
Archive index that asks OpenArkObject::FindFileEntryByPath() to search every mounted archive.
OpenArkObject::MapPathToArkIndex() never reports it, and the search is therefore unreachable.
◆ kSessionArkCount
The number of archives in g_apSessionArkPaths.
◆ g_apSessionArkPaths
The archives InitArk() mounts for the session and CloseArk() unmounts: ark/root.ark, ark/levels.ark, and ark/arenas.ark.
- Ghidra address:
- NTSC-U/C: 0x00702650
- Ghidra address:
- PAL: 0x007460a0
◆ g_apMountedArks
Every archive mounted right now.
- Ghidra address:
- NTSC-U/C: 0x00725e90
- Ghidra address:
- PAL: 0x00769b30
◆ gOpenArkFileTable
Every stream open on a mounted archive.
- Ghidra address:
- NTSC-U/C: 0x00725ea0
- Ghidra address:
- PAL: 0x00769b40
◆ gOpenFileIndex
Handle OpenArkObject::OpenStream() gives the next stream, incremented after every open.
- Ghidra address:
- NTSC-U/C: 0x00725e88
- Ghidra address:
- PAL: 0x00769b28