document patch loader

This commit is contained in:
TheSola10 2025-04-04 19:27:24 +02:00
parent b7db74ce26
commit 8c8b71293d
Signed by: thesola10
GPG Key ID: 89245619BEBB95BA
3 changed files with 36 additions and 2 deletions

View File

@ -2,7 +2,7 @@
#define __IO_FUNCS_H #define __IO_FUNCS_H
/** /**
* @file io_funcs.c * @file io_funcs.h
* @author Karim Vergnes <me@thesola.io> * @author Karim Vergnes <me@thesola.io>
* @copyright GPLv2 * @copyright GPLv2
* @brief Functions to interpose with UMD driver * @brief Functions to interpose with UMD driver

View File

@ -1,7 +1,7 @@
#include "io_funcs.h" #include "io_funcs.h"
#include "patch.h" #include "patch.h"
lp_UMDiffCommand cmd_buffer[1024]; lp_UMDiffCommand cmd_buffer[CMD_BUFFER_SIZE];
lp_UMDiffFile lp_UMDiffFile
lp_PatchSet_open(const char *path) lp_PatchSet_open(const char *path)

34
patch.h
View File

@ -1,9 +1,43 @@
#ifndef __PATCH_H #ifndef __PATCH_H
#define __PATCH_H #define __PATCH_H
/**
* @file patch.h
* @author Karim Vergnes <me@thesola.io>
* @copyright GPLv2
* @brief UMDiff patch loader functions
*
* This module is responsible for interfacing with a UMDiff file, and carrying
* out the actual patching algorithm.
*/
#include "umdiff/umdiff.h" #include "umdiff/umdiff.h"
/**
* How many @ref lp_UMDiffCommand objects should be loaded in memory at once.
*/
#define CMD_BUFFER_SIZE 1024
/**
* @brief Load buffer with commands at index offset for sector
*
* This loader is designed with the worst-case scenario in mind -- one command
* per sector. Since the resulting commands table would weigh in at 1.6 million
* commands, each 20 bytes, we couldn't possibly hope to store all of it in the
* PSP's working memory. Instead, we load a buffer with @ref CMD_BUFFER_SIZE
* commands, and perform lookup within.
*
* This function is responsible for seeking to the index pointer containing the
* given sector, and filling the buffer with commands starting at that point.
*
* This function will not do anything if the buffer already contains commqnds
* from the requested index.
*
* @param sector The sector offset the read request starts at.
*/
int int
lp_loadCmdsForIndex(long sector); lp_loadCmdsForIndex(long sector);
#endif //__PATCH_H #endif //__PATCH_H
// vim: ft=c.doxygen