mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-26 20:44:15 +01:00
Rename files
Start adding info
This commit is contained in:
parent
3f6fc7966c
commit
d9fd168a1c
2
Makefile
2
Makefile
@ -47,7 +47,7 @@ SRCS = \
|
|||||||
menu/path.c \
|
menu/path.c \
|
||||||
menu/png_decoder.c \
|
menu/png_decoder.c \
|
||||||
menu/rom_info.c \
|
menu/rom_info.c \
|
||||||
menu/rom_patcher.c \
|
menu/rom_patch_info.c \
|
||||||
menu/settings.c \
|
menu/settings.c \
|
||||||
menu/sound.c \
|
menu/sound.c \
|
||||||
menu/usb_comm.c \
|
menu/usb_comm.c \
|
||||||
|
@ -156,7 +156,7 @@ static view_t menu_views[] = {
|
|||||||
{ MENU_MODE_FLASHCART, view_flashcart_info_init, view_flashcart_info_display },
|
{ MENU_MODE_FLASHCART, view_flashcart_info_init, view_flashcart_info_display },
|
||||||
{ MENU_MODE_LOAD_ROM, view_load_rom_init, view_load_rom_display },
|
{ MENU_MODE_LOAD_ROM, view_load_rom_init, view_load_rom_display },
|
||||||
{ MENU_MODE_LOAD_DISK, view_load_disk_init, view_load_disk_display },
|
{ MENU_MODE_LOAD_DISK, view_load_disk_init, view_load_disk_display },
|
||||||
{ MENU_MODE_LOAD_PATCH, view_load_rom_patch_init, view_load_rom_patch_display },
|
{ MENU_MODE_LOAD_ROM_PATCH, view_load_rom_patch_init, view_load_rom_patch_display },
|
||||||
{ MENU_MODE_LOAD_EMULATOR, view_load_emulator_init, view_load_emulator_display },
|
{ MENU_MODE_LOAD_EMULATOR, view_load_emulator_init, view_load_emulator_display },
|
||||||
{ MENU_MODE_ERROR, view_error_init, view_error_display },
|
{ MENU_MODE_ERROR, view_error_init, view_error_display },
|
||||||
{ MENU_MODE_FAULT, view_fault_init, view_fault_display },
|
{ MENU_MODE_FAULT, view_fault_init, view_fault_display },
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "boot/boot.h"
|
#include "boot/boot.h"
|
||||||
#include "disk_info.h"
|
#include "disk_info.h"
|
||||||
#include "rom_patcher.h"
|
#include "rom_patch_info.h"
|
||||||
#include "flashcart/flashcart.h"
|
#include "flashcart/flashcart.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "rom_info.h"
|
#include "rom_info.h"
|
||||||
@ -39,7 +39,7 @@ typedef enum {
|
|||||||
MENU_MODE_LOAD_ROM,
|
MENU_MODE_LOAD_ROM,
|
||||||
MENU_MODE_LOAD_DISK,
|
MENU_MODE_LOAD_DISK,
|
||||||
MENU_MODE_LOAD_EMULATOR,
|
MENU_MODE_LOAD_EMULATOR,
|
||||||
MENU_MODE_LOAD_PATCH,
|
MENU_MODE_LOAD_ROM_PATCH,
|
||||||
MENU_MODE_ERROR,
|
MENU_MODE_ERROR,
|
||||||
MENU_MODE_FAULT,
|
MENU_MODE_FAULT,
|
||||||
MENU_MODE_BOOT,
|
MENU_MODE_BOOT,
|
||||||
@ -107,8 +107,8 @@ typedef struct {
|
|||||||
rom_info_t rom_info;
|
rom_info_t rom_info;
|
||||||
path_t *disk_path;
|
path_t *disk_path;
|
||||||
disk_info_t disk_info;
|
disk_info_t disk_info;
|
||||||
path_t *patch_path;
|
path_t *rom_patch_path;
|
||||||
//patch_info_t patch_info;
|
rom_patch_info_t rom_patch_info;
|
||||||
} load;
|
} load;
|
||||||
} menu_t;
|
} menu_t;
|
||||||
|
|
||||||
|
@ -1,23 +1,19 @@
|
|||||||
#include <fatfs/ff.h>
|
#include <fatfs/ff.h>
|
||||||
#include <libdragon.h>
|
#include <libdragon.h>
|
||||||
#include "utils/fs.h"
|
#include "utils/fs.h"
|
||||||
#include "rom_patcher.h"
|
#include "rom_patch_info.h"
|
||||||
|
#include "rom_info.h"
|
||||||
|
|
||||||
#define PATCH_APS_MAGIC_GBA "APS1"
|
|
||||||
#define PATCH_APS_MAGIC_N64 "APS10"
|
|
||||||
#define PATCH_IPS_MAGIC "PATCH"
|
|
||||||
#define PATCH_BPS_MAGIC "BPS1"
|
|
||||||
#define PATCH_UPS_MAGIC "UPS1"
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char header_magic[5]; // The header type, should always be "APS10" for N64.
|
char header_magic[6]; // The header type, should always be "APS10" for N64. (plus null char)
|
||||||
uint8_t type; // The patch type, 0 for a Simple Patch, 1 for a N64 Specific Patch.
|
aps_patch_type_t type; // The patch type, 0 for a Simple Patch, 1 for a N64 Specific Patch.
|
||||||
uint8_t encoding_method; // Encoding Method, 0 for Simple Encoding.
|
aps_patch_encoding_t encoding_method; // Encoding Method, 0 for Simple Encoding.
|
||||||
char description[50]; // Patch description.
|
char description[50]; // Patch description. (plus null char)
|
||||||
bool endian; // image file format 0 = Doctor V64, 1 = CD64/Z64/Wc/SP.
|
bool endian; // image file format 0 = Doctor V64, 1 = CD64/Z64/Wc/SP.
|
||||||
uint16_t rom_id; // This is the two bytes of Cart ID taken directly from the original image.
|
uint16_t rom_id; // This is the two bytes of Cart ID taken directly from the original image.
|
||||||
uint8_t country_code; // The original image's country code.
|
rom_destination_type_t destination_code; // The original rom image's market code.
|
||||||
uint64_t crc; // The original image's CRC taken directly out of the original image.
|
uint64_t crc; // The original image's CRC taken directly out of the original image.
|
||||||
uint32_t size; // Size of destination image.
|
uint32_t size; // Size of destination image.
|
||||||
} aps_patch_header_t;
|
} aps_patch_header_t;
|
||||||
@ -39,14 +35,30 @@ typedef struct
|
|||||||
} ips_patch_record_rle_t;
|
} ips_patch_record_rle_t;
|
||||||
|
|
||||||
|
|
||||||
rom_patcher_err_t apply_patch_type_bps(FIL *fil)
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t file_offset; // The start address of the data to modify as big endian. NOTE: this is only 3 bytes for IPS.
|
||||||
|
uint8_t byte_count; // Number of times to repeat the following byte as big endian.
|
||||||
|
uint8_t byte; // The repeatitive byte to be written to "Address".
|
||||||
|
uint8_t repetitions; // The repeatitive byte to be written to "Address".
|
||||||
|
} aps_patch_record_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t file_offset; // The start address of the data to modify as big endian. NOTE: this is only 3 bytes for IPS.
|
||||||
|
uint8_t byte_count; // Number of times to repeat the following byte as big endian.
|
||||||
|
uint8_t *bytes; // The repeatitive byte to be written to "Address".
|
||||||
|
} aps_patch_record_rle_t;
|
||||||
|
|
||||||
|
|
||||||
|
rom_patch_load_err_t apply_patch_type_bps(FIL *fil)
|
||||||
{
|
{
|
||||||
// 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(FIL *fil)
|
rom_patch_load_err_t apply_patch_type_ips(FIL *fil)
|
||||||
{
|
{
|
||||||
// https://web.archive.org/web/20170624071240/http://www.smwiki.net:80/wiki/IPS_file_format
|
// https://web.archive.org/web/20170624071240/http://www.smwiki.net:80/wiki/IPS_file_format
|
||||||
|
|
||||||
@ -66,7 +78,7 @@ rom_patcher_err_t apply_patch_type_ips(FIL *fil)
|
|||||||
return PATCH_OK;
|
return PATCH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
rom_patcher_err_t apply_patch_type_aps(FIL *fil)
|
rom_patch_load_err_t apply_patch_type_aps(FIL *fil)
|
||||||
{
|
{
|
||||||
// https://github.com/btimofeev/UniPatcher/wiki/APS-(N64)
|
// https://github.com/btimofeev/UniPatcher/wiki/APS-(N64)
|
||||||
|
|
||||||
@ -82,22 +94,22 @@ rom_patcher_err_t apply_patch_type_aps(FIL *fil)
|
|||||||
return PATCH_ERR_INVALID;
|
return PATCH_ERR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
rom_patcher_err_t apply_patch_type_ups(FIL *fil)
|
rom_patch_load_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(FIL *fil)
|
rom_patch_load_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)
|
rom_patch_load_err_t rom_patch_info_load (char *path)
|
||||||
{
|
{
|
||||||
FIL fil;
|
FIL fil;
|
||||||
rom_patcher_err_t err;
|
rom_patch_load_err_t err;
|
||||||
|
|
||||||
if (f_open(&fil, strip_sd_prefix(path), FA_READ) != FR_OK) {
|
if (f_open(&fil, strip_sd_prefix(path), FA_READ) != FR_OK) {
|
||||||
return PATCH_ERR_NO_FILE;
|
return PATCH_ERR_NO_FILE;
|
||||||
@ -113,23 +125,23 @@ rom_patcher_err_t rom_patcher_load_file (char *path)
|
|||||||
|
|
||||||
switch (patch_ext_type)
|
switch (patch_ext_type)
|
||||||
{
|
{
|
||||||
case PATCH_TYPE_BPS:
|
case PATCH_TYPE_BPS:
|
||||||
err = apply_patch_type_bps(&fil);
|
err = apply_patch_type_bps(&fil);
|
||||||
break;
|
break;
|
||||||
case PATCH_TYPE_IPS:
|
case PATCH_TYPE_IPS:
|
||||||
err = apply_patch_type_ips(&fil);
|
err = apply_patch_type_ips(&fil);
|
||||||
break;
|
break;
|
||||||
case PATCH_TYPE_APS:
|
case PATCH_TYPE_APS:
|
||||||
err = apply_patch_type_aps(&fil);
|
err = apply_patch_type_aps(&fil);
|
||||||
break;
|
break;
|
||||||
case PATCH_TYPE_UPS:
|
case PATCH_TYPE_UPS:
|
||||||
err = apply_patch_type_ups(&fil);
|
err = apply_patch_type_ups(&fil);
|
||||||
break;
|
break;
|
||||||
case PATCH_TYPE_XDELTA:
|
case PATCH_TYPE_XDELTA:
|
||||||
err = apply_patch_type_xdelta(&fil);
|
err = apply_patch_type_xdelta(&fil);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return PATCH_ERR_UNSUPPORTED;
|
return PATCH_ERR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
67
src/menu/rom_patch_info.h
Normal file
67
src/menu/rom_patch_info.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
* @file rom_patcher.h
|
||||||
|
* @brief N64 ROM patcher
|
||||||
|
* @ingroup menu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ROM_PATCH_INFO_H__
|
||||||
|
#define ROM_PATCH_INFO_H__
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "path.h"
|
||||||
|
|
||||||
|
/** @brief Patch state enumeration. */
|
||||||
|
typedef enum {
|
||||||
|
PATCH_OK,
|
||||||
|
PATCH_ERR_IO,
|
||||||
|
PATCH_ERR_NO_FILE,
|
||||||
|
PATCH_ERR_INVALID,
|
||||||
|
PATCH_ERR_UNSUPPORTED,
|
||||||
|
} rom_patch_load_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;
|
||||||
|
|
||||||
|
|
||||||
|
#define PATCH_BPS_MAGIC "BPS1"
|
||||||
|
#define PATCH_APS_MAGIC_GBA "APS1"
|
||||||
|
#define PATCH_APS_MAGIC_N64 "APS10"
|
||||||
|
#define PATCH_IPS_MAGIC "PATCH"
|
||||||
|
#define PATCH_UPS_MAGIC "UPS1"
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief APS patch type enumeration. */
|
||||||
|
typedef enum {
|
||||||
|
/** @brief Is a simple patch. */
|
||||||
|
APS_PATCH_TYPE_SIMPLE,
|
||||||
|
/** @brief Is an N64 specific patch. */
|
||||||
|
APS_PATCH_TYPE_N64_SPECIFIC,
|
||||||
|
} aps_patch_type_t;
|
||||||
|
|
||||||
|
/** @brief APS patch type enumeration. */
|
||||||
|
typedef enum {
|
||||||
|
/** @brief Is a simple patch encoding. */
|
||||||
|
PATCH_ENCODING_SIMPLE,
|
||||||
|
} aps_patch_encoding_t;
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief ROM Patch Information Structure. */
|
||||||
|
typedef struct {
|
||||||
|
rom_patch_type_t patch_type;
|
||||||
|
// patch description
|
||||||
|
|
||||||
|
} rom_patch_info_t;
|
||||||
|
|
||||||
|
//rom_patch_load_err_t rom_patch_info_load (path_t *path, rom_patch_info_t *rom_patch_info);
|
||||||
|
rom_patch_load_err_t rom_patch_info_load_file (char *path);
|
||||||
|
|
||||||
|
#endif
|
@ -1,34 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file rom_patcher.h
|
|
||||||
* @brief N64 ROM patcher
|
|
||||||
* @ingroup menu
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ROM_PATCHER_H__
|
|
||||||
#define ROM_PATCHER_H__
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/** @brief Patch state enumeration. */
|
|
||||||
typedef enum {
|
|
||||||
PATCH_OK,
|
|
||||||
PATCH_ERR_IO,
|
|
||||||
PATCH_ERR_NO_FILE,
|
|
||||||
PATCH_ERR_INVALID,
|
|
||||||
PATCH_ERR_UNSUPPORTED,
|
|
||||||
} 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);
|
|
||||||
|
|
||||||
#endif
|
|
@ -309,7 +309,7 @@ static void process (menu_t *menu) {
|
|||||||
menu->next_mode = MENU_MODE_LOAD_EMULATOR;
|
menu->next_mode = MENU_MODE_LOAD_EMULATOR;
|
||||||
break;
|
break;
|
||||||
case ENTRY_TYPE_PATCH:
|
case ENTRY_TYPE_PATCH:
|
||||||
menu->next_mode = MENU_MODE_LOAD_PATCH;
|
menu->next_mode = MENU_MODE_LOAD_ROM_PATCH;
|
||||||
break;
|
break;
|
||||||
case ENTRY_TYPE_IMAGE:
|
case ENTRY_TYPE_IMAGE:
|
||||||
menu->next_mode = MENU_MODE_IMAGE_VIEWER;
|
menu->next_mode = MENU_MODE_IMAGE_VIEWER;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "../cart_load.h"
|
#include "../cart_load.h"
|
||||||
#include "../rom_patcher.h"
|
#include "../rom_patch_info.h"
|
||||||
#include "boot/boot.h"
|
#include "boot/boot.h"
|
||||||
#include "views.h"
|
#include "views.h"
|
||||||
|
|
||||||
@ -8,14 +8,15 @@ static bool load_pending;
|
|||||||
static bool load_rom;
|
static bool load_rom;
|
||||||
|
|
||||||
|
|
||||||
// static char *convert_error_message (rom_patcher_err_t err) {
|
static char *convert_error_message (rom_patch_load_err_t err) {
|
||||||
// switch (err) {
|
switch (err) {
|
||||||
// case PATCH_ERR_IO: return "I/O error during loading patch file information";
|
case PATCH_ERR_IO: return "I/O error during loading patch file information";
|
||||||
// case PATCH_ERR_NO_FILE: return "Couldn't open patch file";
|
case PATCH_ERR_NO_FILE: return "Couldn't open patch file";
|
||||||
// case PATCH_ERR_INVALID: return "Invalid patch file";
|
case PATCH_ERR_INVALID: return "Invalid patch file";
|
||||||
// default: return "Unknown patch info load error";
|
case PATCH_ERR_UNSUPPORTED: return "The patch type is not (yet) supported";
|
||||||
// }
|
default: return "Unknown patch info load error";
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void process (menu_t *menu) {
|
static void process (menu_t *menu) {
|
||||||
@ -126,16 +127,16 @@ static void load (menu_t *menu) {
|
|||||||
|
|
||||||
|
|
||||||
void view_load_rom_patch_init (menu_t *menu) {
|
void view_load_rom_patch_init (menu_t *menu) {
|
||||||
if (menu->load.patch_path) {
|
if (menu->load.rom_patch_path) {
|
||||||
path_free(menu->load.patch_path);
|
path_free(menu->load.rom_patch_path);
|
||||||
menu->load.patch_path = NULL;
|
menu->load.rom_patch_path = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
load_pending = false;
|
load_pending = false;
|
||||||
|
|
||||||
menu->load.patch_path = path_clone_push(menu->browser.directory, menu->browser.entry->name);
|
menu->load.rom_patch_path = path_clone_push(menu->browser.directory, menu->browser.entry->name);
|
||||||
|
|
||||||
// rom_patcher_err_t err = patch_info_load(path_get(menu->load.patch_path), &menu->load.patch_info);
|
// rom_patch_load_err_t err = patch_info_load(path_get(menu->load.rom_patch_path), &menu->load.patch_info);
|
||||||
// if (err != PATCH_OK) {
|
// if (err != PATCH_OK) {
|
||||||
// menu_show_error(menu, convert_error_message(err));
|
// menu_show_error(menu, convert_error_message(err));
|
||||||
// }
|
// }
|
||||||
|
Loading…
Reference in New Issue
Block a user