mirror of
https://github.com/GearsProgress/Poke_Transporter_GB.git
synced 2026-09-12 02:55:42 -05:00
Save data implementation
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#ifndef SAVE_DATA_MANAGER_H
|
||||
#define SAVE_DATA_MANAGER_H
|
||||
|
||||
#include <tonc.h>
|
||||
|
||||
#define HALL_OF_FAME 0x01C000
|
||||
#define MYSTERY_GIFT 0x01E000
|
||||
#define HOF_SECTION 2032
|
||||
|
||||
void load_save_data();
|
||||
void write_save_data();
|
||||
bool is_caught(int dex_num);
|
||||
void set_caught(int dex_num);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
vu32 newest_save_offset = MEM_CRAM + SAVE_A_OFFSET;
|
||||
|
||||
vu32 memory_section_array[14] = {};
|
||||
u8 memory_buffer[0x1000];
|
||||
u8 memory_buffer[1];
|
||||
char mem_name = 'A';
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <maxmod.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "flash_mem.h"
|
||||
//#include "flash_mem.h"
|
||||
#include "gba_flash.h"
|
||||
#include "interrupt.h"
|
||||
#include "gb_link.h"
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "pokedex.h"
|
||||
#include "global_frame_counter.h"
|
||||
#include "pkmn_font.h"
|
||||
#include "save_data_manager.h"
|
||||
|
||||
/*TODO:
|
||||
--------
|
||||
@@ -56,6 +57,11 @@ INJECTION:
|
||||
- Randomize base seed
|
||||
- Enable ribbon viewing
|
||||
|
||||
SAVE DATA:
|
||||
- Add warning
|
||||
- Add ability to erase
|
||||
- Add check for Hall of Fame
|
||||
|
||||
TESTING:
|
||||
- Test all the aspects of a Pokemon (Shiny, Pokerus, etc.)
|
||||
- Test invalid moves
|
||||
@@ -106,10 +112,10 @@ int main(void)
|
||||
irq_enable(II_VBLANK);
|
||||
|
||||
flash_init(FLASH_SIZE_128KB);
|
||||
initalize_memory_locations();
|
||||
//initalize_memory_locations();
|
||||
load_save_data();
|
||||
rand_set_seed(0x12162001);
|
||||
init_text_engine();
|
||||
|
||||
add_script_party_var(party);
|
||||
|
||||
// Sound bank init
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "sprite_data.h"
|
||||
#include "pokemon_data.h"
|
||||
#include "global_frame_counter.h"
|
||||
#include "save_data_manager.h"
|
||||
|
||||
Dex dex_array[DEX_MAX];
|
||||
int dex_shift = 0;
|
||||
@@ -74,9 +75,9 @@ int pokedex_loop()
|
||||
for (int i = 0; i < DEX_MAX; i++)
|
||||
{
|
||||
tte_set_pos(dex_x_cord + (1 * 8), (i * 8 * 3) + 16);
|
||||
tte_write("^");
|
||||
tte_write(is_caught(dex_shift + i + 1) ? "^" : " ");
|
||||
tte_set_pos(dex_x_cord + (3 * 8), (i * 8 * 3) + 16);
|
||||
tte_write(std::string(NAMES[dex_shift + i]).data());
|
||||
tte_write(is_caught(dex_shift + i + 1) ? std::string(NAMES[dex_shift + i]).data() : "----------");
|
||||
tte_set_pos(dex_x_cord + (14 * 8), (i * 8 * 3) + 16);
|
||||
tte_write("000");
|
||||
if(dex_shift + i + 1 < 10){
|
||||
|
||||
@@ -1,6 +1,31 @@
|
||||
#include <tonc.h>
|
||||
#include "save_data_manager.h"
|
||||
#include "gba_flash.h"
|
||||
|
||||
#define HALL_OF_FAME 0x01C000
|
||||
#define MYSTERY_GIFT 0x01E000
|
||||
#define HOF_SECTION 3968
|
||||
u8 save_data_buffer[0x1000];
|
||||
|
||||
|
||||
void load_save_data(){
|
||||
flash_read(HALL_OF_FAME + 0x1000, &save_data_buffer[0], 0x1000);
|
||||
}
|
||||
|
||||
void write_save_data(){
|
||||
flash_write(HALL_OF_FAME + 0x1000, &save_data_buffer[0], 0x1000);
|
||||
}
|
||||
|
||||
bool is_caught(int dex_num){
|
||||
return (((save_data_buffer[HOF_SECTION + (dex_num / 8)]) >> dex_num % 8) & 1);
|
||||
}
|
||||
|
||||
void set_caught(int dex_num){
|
||||
save_data_buffer[HOF_SECTION + (dex_num / 8)] = save_data_buffer[HOF_SECTION + (dex_num / 8)] | (1 << (dex_num % 8));
|
||||
}
|
||||
|
||||
/* Data map:
|
||||
|
||||
Byte 0: Has made it through the tutorial
|
||||
0 - 31: Caught data
|
||||
|
||||
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user