diff --git a/io_funcs.h b/io_funcs.h index d0845e1..593874f 100644 --- a/io_funcs.h +++ b/io_funcs.h @@ -2,7 +2,7 @@ #define __IO_FUNCS_H /** - * @file io_funcs.c + * @file io_funcs.h * @author Karim Vergnes * @copyright GPLv2 * @brief Functions to interpose with UMD driver diff --git a/patch.c b/patch.c index 8c46abe..d369417 100644 --- a/patch.c +++ b/patch.c @@ -1,7 +1,7 @@ #include "io_funcs.h" #include "patch.h" -lp_UMDiffCommand cmd_buffer[1024]; +lp_UMDiffCommand cmd_buffer[CMD_BUFFER_SIZE]; lp_UMDiffFile lp_PatchSet_open(const char *path) diff --git a/patch.h b/patch.h index 7cb3ea4..d53197b 100644 --- a/patch.h +++ b/patch.h @@ -1,9 +1,43 @@ #ifndef __PATCH_H #define __PATCH_H +/** + * @file patch.h + * @author Karim Vergnes + * @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" +/** + * 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 lp_loadCmdsForIndex(long sector); #endif //__PATCH_H + +// vim: ft=c.doxygen