27#define FILE_CACHE_SLOTS 64
48#define CD_SECTOR_SIZE 0x800
92 void *(*load)(
u32 file);
96 void *(*getEntry)(
u32 fileAndIndex);
97 void *(*getArchiveEntry)(
s32 index,
void *archive);
103#define RLEN_MAGIC 0x4E454C52
184#define FILE_MENU_SPRITES 0x277
185#define FILE_FONT 0x278
186#define TEXT_FILE(file) (file)
188#define FILE_MENU_SPRITES 0x286
189#define FILE_FONT 0x287
190#define TEXT_FILE(file) (LANGUAGE + (file) - 1)
193#define FILE_MENU_SPRITES 0x277
194#define FILE_FONT 0x278
195#define TEXT_FILE(file) (LANGUAGE + (file) - 1)
200#define TEXT_AMATERASU_MAP 0x02
201#define TEXT_ASUKA_MAP 0x09
202#define TEXT_CARD_GAME 0x10
203#define TEXT_CARD_NAMES 0x17
204#define TEXT_CARD_EFFECTS 0x1E
205#define TEXT_CARD_ALBUM 0x25
206#define TEXT_DECK_EDITOR 0x2C
207#define TEXT_CARD_SHOP 0x33
208#define TEXT_DIGI_LAB 0x3A
209#define TEXT_DIGIMON_NAMING 0x41
210#define TEXT_DIGIMON_INFO 0x48
211#define TEXT_DIGIMON_NAMES 0x4F
212#define TEXT_FIGHT_REPORT 0x56
213#define TEXT_INN_NAMES 0x5D
214#define TEXT_ITEM_INFO 0x64
215#define TEXT_ITEM_NAMES 0x6B
216#define TEXT_ITEM_SHOP 0x72
217#define TEXT_MEMORY_CARD 0x79
218#define TEXT_BATTLE_MENU 0x80
219#define TEXT_NAME_ENTRY 0x87
220#define TEXT_ONLINE 0x8E
221#define TEXT_SHOP_NAMES 0x95
222#define TEXT_SKILL_INFO 0x9C
223#define TEXT_SKILL_NAMES 0xA3
224#define TEXT_AREA_NAMES 0xAA
225#define TEXT_STATUS 0xB1
226#define TEXT_STAGE_NAMES 0xB8
238#if VERSION_US || VERSION_JP
239#define TEXT_TALKS_00 0xCD
240#define TEXT_TALKS_01 0xD4
241#define TEXT_TALKS_02 0xDB
242#define TEXT_TALKS_03 0xE2
243#define TEXT_TALKS_04 0xE9
244#define TEXT_TALKS_05 0xF0
245#define TEXT_TALKS_06 0xF7
246#define TEXT_TALKS_07 0xFE
247#define TEXT_TRAINING 0x105
248#define TEXT_EVENTS_200 0x10C
249#define TEXT_EVENTS_260 0x113
250#define TEXT_EVENTS_270 0x11A
251#define TEXT_EVENTS_300 0x121
252#define TEXT_EVENTS_305 0x128
253#define TEXT_EVENTS_400 0x12F
254#define TEXT_EVENTS_500 0x136
255#define TEXT_EVENTS_600 0x13D
256#define TEXT_EVENTS_700 0x144
257#define TEXT_EVENTS_800 0x14B
259#define TEXT_TALKS_00 0xC6
260#define TEXT_TALKS_01 0xCD
261#define TEXT_TALKS_02 0xD4
262#define TEXT_TALKS_03 0xDB
263#define TEXT_TALKS_04 0xE2
264#define TEXT_TALKS_05 0xE9
265#define TEXT_TALKS_06 0xF0
266#define TEXT_TALKS_07 0xF7
267#define TEXT_TALKS_08 0xFE
268#define TEXT_TALKS_09 0x105
269#define TEXT_TRAINING 0x10C
270#define TEXT_EVENTS_200 0x113
271#define TEXT_EVENTS_260 0x11A
272#define TEXT_EVENTS_270 0x121
273#define TEXT_EVENTS_300 0x128
274#define TEXT_EVENTS_305 0x12F
275#define TEXT_EVENTS_400 0x136
276#define TEXT_EVENTS_500 0x13D
277#define TEXT_EVENTS_600 0x144
278#define TEXT_EVENTS_700 0x14B
279#define TEXT_EVENTS_800 0x152
280#define TEXT_EVENTS_900 0x159
286#if VERSION_US || VERSION_JP
287#define FILE_BATTLE_MENU 0x445
288#define FILE_BATTLE_IMAGES 0x446
289#define FILE_BATTLE_IMAGES_1 0x78F
290#define FILE_BATTLE_IMAGES_2 0x79F
291#define FILE_BATTLE_IMAGES_3 0x7D2
292#define FILE_BATTLE_IMAGES_4 0x7D4
294#define FILE_BATTLE_MENU 0x455
295#define FILE_BATTLE_IMAGES 0x456
296#define FILE_BATTLE_IMAGES_1 0x79E
297#define FILE_BATTLE_IMAGES_2 0x7AE
298#define FILE_BATTLE_IMAGES_3 0x7E1
299#define FILE_BATTLE_IMAGES_4 0x7E3
The task system and its registry (task/)
#define TASK_HEADER(Type)
void * getFileEntry(u32 fileAndIndex)
Files are often archives: a table of offsets from the start of the file.
FileSlot * findOldestFile(void)
The loaded file used least recently (the biggest one on a tie)
void freeFilesFrom(u32 addr)
Frees the files that reach past addr (to load something there)
void updateDecompressor(Decompressor *task)
The decompressor task: unpacks a chunk a frame, frees the buffer at the end.
void freeFile(s32 file)
Drops a loaded file from the cache.
void decompressorAllocBuffer(Decompressor *task)
Makes the buffer big enough for the unpacked size.
void decompressorStep(Decompressor *task)
Unpacks at least chunkSize bytes; back to substate 0 at the end.
void updateFileCache(void)
Starts reading the next queued file and marks the one read as loaded.
void * decompressorRun(Decompressor *task, s32 *data)
Decompressor method: unpacks data at once; returns it unpacked (plain data as it is)
FileSlot * findFreeFileSlot(void)
A free cache slot, or NULL.
void decompressorFree(Decompressor *task)
Decompressor method: frees its buffer.
void * decompressorGetData(Decompressor *task)
Decompressor method: the unpacked data, or NULL while it is unpacking.
FileSlotState
FileSlot.state.
s32 isFileLoading(s32)
0 once the file is in the cache; requests it if needed
s32 cdCheckSector(void)
Checks that the sector just read is the next one.
void cdSyncCallback(s32 status, u_char *result)
The CdSyncCallback: Setloc, Setmode (double speed, whole sectors), ReadN, and CdlPause once the secto...
s32 fileExists(s32 file)
Whether the disc has file file
void cdReadyCallback(s32 status, u_char *result)
The CdReadyCallback: copies each sector as it arrives, pauses at the end.
void readFile(s32 file, s32 offset, s32 size, void *buffer, s32 *done)
Starts reading size sectors (0: all) of a file into buffer; ignored while busy.
Decompressor * createDecompressor(void)
A decompressor task.
s32 isCdReading(void)
Whether the CD reader is busy.
CdReader CD_READER
The CD reader.
void * getArchiveEntry(s32 index, void *archive)
Entry index (the low 16 bits) of an archive already in memory.
s32 getFileSectorCount(s32 file)
The sectors of a file.
CdReadState
What the CD reader waits for (CdReader.state): the command each state sent to complete,...
void markCachedFiles(void)
markCachedFiles + touchMarkedFiles: refresh the files cached before a load
void requestFile(s32)
Queues a file for the cache (just marks it used when it is there)
CdSectorHeader CD_SECTOR_HEADER
file/cd_reader.c's
void freeAllFiles(void)
Drops every file from the cache.
FileTableFuncs FILE_TABLE
The disc's file table.
void decompressorStart(Decompressor *task, s32 *data, s32 chunkSize)
Decompressor method: starts unpacking data chunkSize bytes a frame.
void decompressorSetData(Decompressor *task, s32 *data)
Points the decompressor at data, which is RLEN-packed or plain.
#define FILE_CACHE_SLOTS
The files the cache holds at most.
void waitForFile(s32 file)
Reads a file into the cache before returning.
void evictOldestFile(void)
Frees the loaded file used least recently, to make room in the heap.
s32 getFileSector(s32 file)
The first sector of a file.
s32 FILE_SECTORS[]
Where each file starts on the disc, and its size, in sectors.
void * loadFile(u32 file)
Returns the file's data, reading it now if it is not in the cache.
void touchMarkedFiles(void)
Marks the files markCachedFiles saw as just used (the European and Japanese versions,...
FileSlot * findFileSlot(s32 file)
The cache slot of a file, or NULL.
FileCache FILE_CACHE
The file cache.
void getFilePos(s32 file, s32 offset, void *pos)
The CdlLOC of sector offset of a file.
void startCdRead(void)
Starts the read readFile set up: seeks to its first sector.
Reads whole sectors of a file with CdlReadN, from callbacks.
void(* read)(s32 file, s32 offset, s32 size, void *buf, s32 *done)
s32 * done
set to 1 when the read is complete
Expands "RLEN" data (a run-length encoding: a byte n < 0x80 copies n bytes, n | 0x80 repeats the next...
void * src
the next packed byte
The file cache (FILE_CACHE): up to 64 files loaded in the heap (tag 3), read in the background one at...
void(* touchMarked)(void)
s32(* isLoading)(s32 file)
void(* freeFrom)(u32 addr)
void(* evictOldest)(void)
void(* request)(s32 file)
The disc's file table (FILE_TABLE): files are numbered, not named.
s32(* getSectorCount)(s32 file)
s32(* getSector)(s32 file)
void(* getPos)(s32 file, s32 offset, void *loc)