mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2025-02-19 19:42:53 +01:00
Improvements
This commit is contained in:
parent
2258df3c1f
commit
9fb88b6022
@ -1,57 +1,93 @@
|
|||||||
#include <fatfs/ff.h>
|
#include <fatfs/ff.h>
|
||||||
#include <libdragon.h>
|
#include <libdragon.h>
|
||||||
|
#include "utils/fs.h"
|
||||||
#include "rom_patcher.h"
|
#include "rom_patcher.h"
|
||||||
|
|
||||||
|
|
||||||
rom_patcher_err_t rom_patcher_load_file (char *path)
|
rom_patcher_err_t apply_patch_type_bps(FIL *fil)
|
||||||
{
|
|
||||||
// ROM file should be loaded before patch is applied.
|
|
||||||
// See https://github.com/marcrobledo/RomPatcher.js/ for an example lib.
|
|
||||||
// Though needs conversion from JS to C
|
|
||||||
// apply patch dependent on extension.
|
|
||||||
//return apply_patch_type_bps(path);
|
|
||||||
//return apply_patch_type_ips(path);
|
|
||||||
//return apply_patch_type_aps(path);
|
|
||||||
//return apply_patch_type_ups(path);
|
|
||||||
//return apply_patch_type_xdelta(path);
|
|
||||||
// aps should be PATCH_ERR_UNSUPPORTED; as not really a thing?!
|
|
||||||
return PATCH_ERR_IO;
|
|
||||||
}
|
|
||||||
|
|
||||||
rom_patcher_err_t apply_patch_type_bps(char *path)
|
|
||||||
{
|
{
|
||||||
// https://github.com/Alcaro/Flips/blob/master/bps_spec.md
|
// https://github.com/Alcaro/Flips/blob/master/bps_spec.md
|
||||||
// https://www.romhacking.net/documents/746/
|
// https://www.romhacking.net/documents/746/
|
||||||
return PATCH_ERR_UNSUPPORTED;
|
return PATCH_ERR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
rom_patcher_err_t apply_patch_type_ips(char *path)
|
rom_patcher_err_t apply_patch_type_ips(FIL *fil)
|
||||||
{
|
{
|
||||||
// http://www.smwiki.net/wiki/IPS_file_format
|
// http://www.smwiki.net/wiki/IPS_file_format
|
||||||
return PATCH_ERR_INVALID;
|
return PATCH_ERR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
rom_patcher_err_t apply_patch_type_aps(char *path)
|
rom_patcher_err_t apply_patch_type_aps(FIL *fil)
|
||||||
{
|
{
|
||||||
// https://github.com/btimofeev/UniPatcher/wiki/APS-(N64)
|
// https://github.com/btimofeev/UniPatcher/wiki/APS-(N64)
|
||||||
return PATCH_ERR_INVALID;
|
return PATCH_ERR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
rom_patcher_err_t apply_patch_type_ups(char *path)
|
rom_patcher_err_t apply_patch_type_ups(FIL *fil)
|
||||||
{
|
{
|
||||||
// http://www.romhacking.net/documents/392/
|
// http://www.romhacking.net/documents/392/
|
||||||
return PATCH_ERR_UNSUPPORTED;
|
return PATCH_ERR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
rom_patcher_err_t apply_patch_type_xdelta(char *path)
|
rom_patcher_err_t apply_patch_type_xdelta(FIL *fil)
|
||||||
{
|
{
|
||||||
return PATCH_ERR_UNSUPPORTED;
|
return PATCH_ERR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rom_patcher_err_t rom_patcher_load_file (char *path)
|
||||||
|
{
|
||||||
|
FIL fil;
|
||||||
|
rom_patcher_err_t err;
|
||||||
|
|
||||||
// Krikzz implementation:
|
if (f_open(&fil, strip_sd_prefix(path), FA_READ) != FR_OK) {
|
||||||
|
return PATCH_ERR_NO_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ROM file should be loaded before patch is applied.
|
||||||
|
// See https://github.com/marcrobledo/RomPatcher.js/ for an example lib.
|
||||||
|
// Though needs conversion from JS to C
|
||||||
|
// apply patch dependent on extension.
|
||||||
|
|
||||||
|
rom_patch_type_t patch_ext_type = PATCH_TYPE_IPS; // FIXME: should be the extension of the file!
|
||||||
|
|
||||||
|
switch (patch_ext_type)
|
||||||
|
{
|
||||||
|
case PATCH_TYPE_BPS:
|
||||||
|
err = apply_patch_type_bps(&fil);
|
||||||
|
break;
|
||||||
|
case PATCH_TYPE_IPS:
|
||||||
|
err = apply_patch_type_ips(&fil);
|
||||||
|
break;
|
||||||
|
case PATCH_TYPE_APS:
|
||||||
|
err = apply_patch_type_aps(&fil);
|
||||||
|
break;
|
||||||
|
case PATCH_TYPE_UPS:
|
||||||
|
err = apply_patch_type_ups(&fil);
|
||||||
|
break;
|
||||||
|
case PATCH_TYPE_XDELTA:
|
||||||
|
err = apply_patch_type_xdelta(&fil);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return PATCH_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (f_close(&fil) != FR_OK) {
|
||||||
|
return PATCH_ERR_IO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err != PATCH_OK) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PATCH_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Krikzz implementation for ref:
|
||||||
// #define APS_BUFF_SIZE 32768
|
// #define APS_BUFF_SIZE 32768
|
||||||
|
|
||||||
// static uint8_t aps_buff[APS_BUFF_SIZE];
|
// static uint8_t aps_buff[APS_BUFF_SIZE];
|
||||||
@ -99,7 +135,6 @@ rom_patcher_err_t apply_patch_type_xdelta(char *path)
|
|||||||
|
|
||||||
|
|
||||||
// // for (i = 0; i < 5; i++)apsGetNextByte();
|
// // for (i = 0; i < 5; i++)apsGetNextByte();
|
||||||
// // gSetXY(4, 4);
|
|
||||||
|
|
||||||
// while (aps_addr < len) {
|
// while (aps_addr < len) {
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file patcher.h
|
* @file rom_patcher.h
|
||||||
* @brief N64 ROM patcher
|
* @brief N64 ROM patcher
|
||||||
* @ingroup menu
|
* @ingroup menu
|
||||||
*/
|
*/
|
||||||
@ -20,6 +20,15 @@ typedef enum {
|
|||||||
PATCH_ERR_UNSUPPORTED,
|
PATCH_ERR_UNSUPPORTED,
|
||||||
} rom_patcher_err_t;
|
} rom_patcher_err_t;
|
||||||
|
|
||||||
|
/** @brief Patch type enumeration. */
|
||||||
|
typedef enum {
|
||||||
|
PATCH_TYPE_BPS,
|
||||||
|
PATCH_TYPE_APS,
|
||||||
|
PATCH_TYPE_IPS,
|
||||||
|
PATCH_TYPE_UPS,
|
||||||
|
PATCH_TYPE_XDELTA,
|
||||||
|
} rom_patch_type_t;
|
||||||
|
|
||||||
rom_patcher_err_t rom_patcher_load_file (char *path);
|
rom_patcher_err_t rom_patcher_load_file (char *path);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,14 +60,14 @@ static void draw (menu_t *menu, surface_t *d) {
|
|||||||
|
|
||||||
component_actions_bar_text_draw(
|
component_actions_bar_text_draw(
|
||||||
ALIGN_LEFT, VALIGN_TOP,
|
ALIGN_LEFT, VALIGN_TOP,
|
||||||
"A: Load ROM\n"
|
"A: Load and run patched ROM\n"
|
||||||
"B: Exit"
|
"B: Exit"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (menu->load.rom_path) {
|
if (menu->load.rom_path) {
|
||||||
component_actions_bar_text_draw(
|
component_actions_bar_text_draw(
|
||||||
ALIGN_RIGHT, VALIGN_TOP,
|
ALIGN_RIGHT, VALIGN_TOP,
|
||||||
"R: Load patched ROM"
|
"R: Load with ROM"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,9 +107,21 @@ static void load (menu_t *menu) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
menu->next_mode = MENU_MODE_BOOT;
|
menu->next_mode = MENU_MODE_BOOT;
|
||||||
menu->boot_params->device_type = BOOT_DEVICE_TYPE_ROM;
|
|
||||||
menu->boot_params->tv_type = BOOT_TV_TYPE_PASSTHROUGH;
|
if (load_rom) {
|
||||||
menu->boot_params->detect_cic_seed = true;
|
menu->boot_params->device_type = BOOT_DEVICE_TYPE_ROM;
|
||||||
|
menu->boot_params->detect_cic_seed = rom_info_get_cic_seed(&menu->load.rom_info, &menu->boot_params->cic_seed);
|
||||||
|
switch (rom_info_get_tv_type(&menu->load.rom_info)) {
|
||||||
|
case ROM_TV_TYPE_PAL: menu->boot_params->tv_type = BOOT_TV_TYPE_PAL; break;
|
||||||
|
case ROM_TV_TYPE_NTSC: menu->boot_params->tv_type = BOOT_TV_TYPE_NTSC; break;
|
||||||
|
case ROM_TV_TYPE_MPAL: menu->boot_params->tv_type = BOOT_TV_TYPE_MPAL; break;
|
||||||
|
default: menu->boot_params->tv_type = BOOT_TV_TYPE_PASSTHROUGH; break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
menu->boot_params->device_type = BOOT_DEVICE_TYPE_ROM;
|
||||||
|
menu->boot_params->tv_type = BOOT_TV_TYPE_NTSC;
|
||||||
|
menu->boot_params->detect_cic_seed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user