N64FlashcartMenu
Loading...
Searching...
No Matches
datel_codes.h
Go to the documentation of this file.
1
7#ifndef DATEL_CODES_H__
8#define DATEL_CODES_H__
9
10#include <stdbool.h>
11#include <stdint.h>
12#include <stddef.h>
13
14// The maximum number of cheat codes to support is dependent on the available space in the N64 RAM.
15// However, for simplicity, we will hardcode it to 64 for now, as this number of codes should handle most games (keeping it low allows us to collect caveats).
16// The Krikzz official menu only supports upto 34 codes, so this is already an improvement.
17#define MAX_CHEAT_CODES (64) // Maximum number of cheat codes to support. This can be changed later if needed.
18#define MAX_CHEAT_CODE_ARRAYLIST_SIZE (MAX_CHEAT_CODES * 2 + 2) // Maximum size of the cheat code list (address/value pairs + two trailing zeros)
19
21typedef struct {
22 uint32_t address;
23 uint16_t value;
24 bool enabled;
25 char description[32];
27
28
30typedef enum {
31 CHEAT_FILE_LOAD_OK,
32 CHEAT_FILE_LOAD_ERR_MEMORY_ALLOC_FAIL,
33 CHEAT_FILE_LOAD_ERR_FILE_OPEN_FAIL,
34 CHEAT_FILE_LOAD_ERR_FILE_STAT_FAIL,
35 CHEAT_FILE_LOAD_ERR_FILE_EMPTY,
36 CHEAT_FILE_LOAD_ERR_FILE_TOO_BIG,
37 CHEAT_FILE_LOAD_ERR_FILE_CONTENTS_ALLOC_FAIL,
38 CHEAT_FILE_LOAD_ERR_FILE_READ_FAIL,
39 CHEAT_FILE_LOAD_ERR_FILE_CLOSE_FAIL,
40 CHEAT_FILE_LOAD_ERR_UNKNOWN
42
43
52size_t generate_enabled_cheats_array(cheat_file_code_t *cheats_in, uint32_t *cheats_out);
53
59
65
70void load_cheats_from_file(char *path);
71
76void save_cheats_to_file(char *path);
77
78#endif /* DATEL_CODES_H__ */
void set_cheat_codes(cheat_file_code_t *cheats)
Set the cheat codes.
Definition datel_codes.c:57
uint32_t address
Definition datel_codes.h:22
void save_cheats_to_file(char *path)
Save cheats to a file.
Definition datel_codes.c:278
cheat_file_load_err_t
Cheat code loading enum.
Definition datel_codes.h:30
void load_cheats_from_file(char *path)
Load cheats from a file.
Definition datel_codes.c:214
uint16_t value
Definition datel_codes.h:23
size_t generate_enabled_cheats_array(cheat_file_code_t *cheats_in, uint32_t *cheats_out)
Generate a cheats array containing enabled cheats as address/value pairs. The last two entries will a...
Definition datel_codes.c:30
cheat_file_code_t * get_cheat_codes(void)
Get the cheat codes.
Definition datel_codes.c:49
bool enabled
Definition datel_codes.h:24
Cheat file code Structure.
Definition datel_codes.h:21