Skip to content

Commit 56cfbb2

Browse files
dcvzAngheloAlf
andauthored
Make ModernRuntime Integration Ready (#26)
Co-authored-by: angie <angheloalf95@gmail.com>
1 parent e3e7024 commit 56cfbb2

16 files changed

Lines changed: 53 additions & 255 deletions

File tree

librecomp/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
cmake_minimum_required(VERSION 3.20)
22
project(librecomp)
33

4-
# Check for headers
5-
include(CheckIncludeFile)
6-
check_include_file("malloc.h" HAVE_MALLOC_H)
7-
8-
if(HAVE_MALLOC_H)
9-
add_compile_definitions(HAVE_MALLOC_H)
10-
endif()
11-
124
# Define the library
135
add_library(librecomp STATIC
146
"${CMAKE_CURRENT_SOURCE_DIR}/src/ai.cpp"

librecomp/include/recomp.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
#include <stdint.h>
66
#include <math.h>
77
#include <assert.h>
8-
#include <setjmp.h>
9-
10-
#ifdef HAVE_MALLOC_H
11-
#include <malloc.h>
12-
#endif
138

149
typedef uint64_t gpr;
1510

librecomp/include/recomp_game.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ namespace recomp {
1616
std::span<const char> cache_data;
1717
bool is_enabled;
1818

19-
void (*entrypoint)();
19+
gpr entrypoint_address;
20+
void (*entrypoint)(uint8_t* rdram, recomp_context* context);
2021

2122
std::u8string stored_filename() const;
2223
};
@@ -29,6 +30,7 @@ namespace recomp {
2930
IncorrectVersion,
3031
OtherError
3132
};
33+
void register_config_path(std::filesystem::path path);
3234
bool register_game(const recomp::GameEntry& entry);
3335
void register_patch(const char* patch, std::size_t size);
3436
void check_all_stored_roms();
@@ -41,12 +43,7 @@ namespace recomp {
4143
void do_rom_pio(uint8_t* rdram, gpr ram_address, uint32_t physical_addr);
4244
void start(ultramodern::WindowHandle window_handle, const recomp::rsp::callbacks_t& rsp_callbacks, const ultramodern::audio_callbacks_t& audio_callbacks, const ultramodern::input_callbacks_t& input_callbacks, const ultramodern::gfx_callbacks_t& gfx_callbacks, const ultramodern::events::callbacks_t& thread_callbacks, const ultramodern::error_handling::callbacks_t& error_handling_callbacks_);
4345
void start_game(const std::u8string& game_id);
44-
std::filesystem::path get_app_folder_path();
4546
std::u8string current_game_id();
46-
47-
// TODO: implement both
48-
const std::u8string& get_program_id();
49-
void set_program_id(const std::u8string& program_id);
5047
}
5148

5249
#endif

librecomp/include/recomp_input.h

Lines changed: 0 additions & 174 deletions
This file was deleted.

librecomp/include/recomp_overlays.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ namespace recomp {
1616
size_t len;
1717
};
1818

19-
extern void register_overlays(const overlay_section_table_data_t& sections, const overlays_by_index_t& overlays);
20-
extern void register_patch_section(SectionTableEntry* code_sections);
19+
void register_overlays(const overlay_section_table_data_t& sections, const overlays_by_index_t& overlays);
20+
void register_patch_section(SectionTableEntry* code_sections);
21+
void load_patch_functions();
2122
};
2223

2324
extern "C" void load_overlays(uint32_t rom, int32_t ram_addr, uint32_t size);

librecomp/include/rsp_vu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ struct RSP {
110110
bool divdp;
111111
} vpu;
112112

113-
static constexpr r128 zero{0};
114-
static constexpr r128 invert{(uint64_t)-1, (uint64_t)-1};
113+
static constexpr r128 zero{{0}};
114+
static constexpr r128 invert{{(uint64_t)-1, (uint64_t)-1}};
115115

116116
inline auto accumulatorGet(u32 index) const -> u64;
117117
inline auto accumulatorSet(u32 index, u64 value) -> void;

librecomp/src/overlays.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ extern "C" void unload_overlays(int32_t ram_addr, uint32_t size) {
142142
}
143143
}
144144

145-
void load_patch_functions();
146-
147145
void init_overlays() {
148146
section_addresses = (int32_t *)malloc(sections_info.total_num_sections * sizeof(int32_t));
149147

@@ -158,7 +156,7 @@ void init_overlays() {
158156
}
159157
);
160158

161-
load_patch_functions();
159+
recomp::load_patch_functions();
162160
}
163161

164162
extern "C" recomp_func_t * get_function(int32_t addr) {

librecomp/src/patch_loading.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ static SectionTableEntry* code_sections = nullptr;
99

1010
void load_special_overlay(const SectionTableEntry& section, int32_t ram);
1111

12-
void register_patch_section(SectionTableEntry* sections) {
12+
void recomp::register_patch_section(SectionTableEntry* sections) {
1313
code_sections = sections;
1414
}
1515

16-
void load_patch_functions() {
16+
void recomp::load_patch_functions() {
1717
load_special_overlay(code_sections[0], code_sections[0].ram_addr);
1818
}

librecomp/src/pi.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ struct {
9494
} save_context;
9595

9696
const std::u8string save_folder = u8"saves";
97-
const std::u8string save_filename = std::u8string{recomp::current_game_id()} + u8".bin";
97+
98+
extern std::filesystem::path config_path;
9899

99100
std::filesystem::path get_save_file_path() {
100-
return recomp::get_app_folder_path() / save_folder / save_filename;
101+
return config_path / save_folder / (std::u8string{recomp::current_game_id()} + u8".bin");
101102
}
102103

103104
void update_save_file() {

0 commit comments

Comments
 (0)