Make section_addresses dynamic

This commit is contained in:
dcvz 2024-05-22 14:47:18 +02:00 committed by David Chavez
parent 03d286191f
commit 195a6cacf8
2 changed files with 7 additions and 5 deletions

View file

@ -256,7 +256,7 @@ recomp_func_t* get_function(int32_t vram);
#define LOOKUP_FUNC(val) \
get_function((int32_t)(val))
extern int32_t section_addresses[];
extern int32_t* section_addresses;
#define LO16(x) \
((x) & 0xFFFF)

View file

@ -44,9 +44,9 @@ void load_special_overlay(const SectionTableEntry& section, int32_t ram) {
}
//extern "C" {
//int32_t section_addresses[get_num_sections()];
//}
extern "C" {
int32_t* section_addresses = nullptr;
}
extern "C" void load_overlays(uint32_t rom, int32_t ram_addr, uint32_t size) {
// Search for the first section that's included in the loaded rom range
@ -139,7 +139,9 @@ extern "C" void unload_overlays(int32_t ram_addr, uint32_t size) {
void load_patch_functions();
void init_overlays() {
for (size_t section_index = 0; section_index < num_code_sections; section_index++) {
section_addresses = (int32_t *)malloc(get_num_sections() * sizeof(int32_t));
for (size_t section_index = 0; section_index < get_num_sections(); section_index++) {
section_addresses[get_section_table()[section_index].index] = get_section_table()[section_index].ram_addr;
}