Skip to content

Commit

Permalink
Make ModernRuntime Integration Ready (#26)
Browse files Browse the repository at this point in the history
Co-authored-by: angie <[email protected]>
  • Loading branch information
dcvz and AngheloAlf authored Jun 1, 2024
1 parent e3e7024 commit 56cfbb2
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 255 deletions.
8 changes: 0 additions & 8 deletions librecomp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
cmake_minimum_required(VERSION 3.20)
project(librecomp)

# Check for headers
include(CheckIncludeFile)
check_include_file("malloc.h" HAVE_MALLOC_H)

if(HAVE_MALLOC_H)
add_compile_definitions(HAVE_MALLOC_H)
endif()

# Define the library
add_library(librecomp STATIC
"${CMAKE_CURRENT_SOURCE_DIR}/src/ai.cpp"
Expand Down
5 changes: 0 additions & 5 deletions librecomp/include/recomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
#include <stdint.h>
#include <math.h>
#include <assert.h>
#include <setjmp.h>

#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif

typedef uint64_t gpr;

Expand Down
9 changes: 3 additions & 6 deletions librecomp/include/recomp_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace recomp {
std::span<const char> cache_data;
bool is_enabled;

void (*entrypoint)();
gpr entrypoint_address;
void (*entrypoint)(uint8_t* rdram, recomp_context* context);

std::u8string stored_filename() const;
};
Expand All @@ -29,6 +30,7 @@ namespace recomp {
IncorrectVersion,
OtherError
};
void register_config_path(std::filesystem::path path);
bool register_game(const recomp::GameEntry& entry);
void register_patch(const char* patch, std::size_t size);
void check_all_stored_roms();
Expand All @@ -41,12 +43,7 @@ namespace recomp {
void do_rom_pio(uint8_t* rdram, gpr ram_address, uint32_t physical_addr);
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_);
void start_game(const std::u8string& game_id);
std::filesystem::path get_app_folder_path();
std::u8string current_game_id();

// TODO: implement both
const std::u8string& get_program_id();
void set_program_id(const std::u8string& program_id);
}

#endif
174 changes: 0 additions & 174 deletions librecomp/include/recomp_input.h

This file was deleted.

5 changes: 3 additions & 2 deletions librecomp/include/recomp_overlays.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ namespace recomp {
size_t len;
};

extern void register_overlays(const overlay_section_table_data_t& sections, const overlays_by_index_t& overlays);
extern void register_patch_section(SectionTableEntry* code_sections);
void register_overlays(const overlay_section_table_data_t& sections, const overlays_by_index_t& overlays);
void register_patch_section(SectionTableEntry* code_sections);
void load_patch_functions();
};

extern "C" void load_overlays(uint32_t rom, int32_t ram_addr, uint32_t size);
Expand Down
4 changes: 2 additions & 2 deletions librecomp/include/rsp_vu.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ struct RSP {
bool divdp;
} vpu;

static constexpr r128 zero{0};
static constexpr r128 invert{(uint64_t)-1, (uint64_t)-1};
static constexpr r128 zero{{0}};
static constexpr r128 invert{{(uint64_t)-1, (uint64_t)-1}};

inline auto accumulatorGet(u32 index) const -> u64;
inline auto accumulatorSet(u32 index, u64 value) -> void;
Expand Down
4 changes: 1 addition & 3 deletions librecomp/src/overlays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ extern "C" void unload_overlays(int32_t ram_addr, uint32_t size) {
}
}

void load_patch_functions();

void init_overlays() {
section_addresses = (int32_t *)malloc(sections_info.total_num_sections * sizeof(int32_t));

Expand All @@ -158,7 +156,7 @@ void init_overlays() {
}
);

load_patch_functions();
recomp::load_patch_functions();
}

extern "C" recomp_func_t * get_function(int32_t addr) {
Expand Down
4 changes: 2 additions & 2 deletions librecomp/src/patch_loading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ static SectionTableEntry* code_sections = nullptr;

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

void register_patch_section(SectionTableEntry* sections) {
void recomp::register_patch_section(SectionTableEntry* sections) {
code_sections = sections;
}

void load_patch_functions() {
void recomp::load_patch_functions() {
load_special_overlay(code_sections[0], code_sections[0].ram_addr);
}
5 changes: 3 additions & 2 deletions librecomp/src/pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ struct {
} save_context;

const std::u8string save_folder = u8"saves";
const std::u8string save_filename = std::u8string{recomp::current_game_id()} + u8".bin";

extern std::filesystem::path config_path;

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

void update_save_file() {
Expand Down
Loading

0 comments on commit 56cfbb2

Please sign in to comment.