mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp
synced 2026-06-07 20:11:44 -04:00
Build system & dependency refactoring
Switched to a makefile + clang build system Now builds as a library by default Removed SDL2 dependency Changed RT64 integration to use zilmar spec in order to pass a window handle Proper unaligned loads and stores implementation
This commit is contained in:
+19
-15
@@ -1,6 +1,14 @@
|
||||
#include "../portultra/multilibultra.hpp"
|
||||
#include "recomp.h"
|
||||
|
||||
static Multilibultra::input_callbacks_t input_callbacks;
|
||||
|
||||
void Multilibultra::set_input_callbacks(const input_callbacks_t* callbacks) {
|
||||
if (callbacks != nullptr) {
|
||||
input_callbacks = *callbacks;
|
||||
}
|
||||
}
|
||||
|
||||
static int max_controllers = 0;
|
||||
|
||||
extern "C" void osContInit_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||
@@ -37,28 +45,24 @@ struct OSContPad {
|
||||
u8 errno_;
|
||||
};
|
||||
|
||||
int button = 0;
|
||||
int stick_x = 0;
|
||||
int stick_y = 0;
|
||||
|
||||
void press_button(int button) {
|
||||
|
||||
}
|
||||
|
||||
void release_button(int button) {
|
||||
|
||||
}
|
||||
|
||||
extern "C" void osContGetReadData_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||
int32_t pad = (int32_t)ctx->r4;
|
||||
|
||||
uint16_t buttons = 0;
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
|
||||
if (input_callbacks.get_input) {
|
||||
input_callbacks.get_input(&buttons, &x, &y);
|
||||
}
|
||||
|
||||
if (max_controllers > 0) {
|
||||
// button
|
||||
MEM_H(0, pad) = button;
|
||||
MEM_H(0, pad) = buttons;
|
||||
// stick_x
|
||||
MEM_B(2, pad) = stick_x;
|
||||
MEM_B(2, pad) = (int8_t)(127 * x);
|
||||
// stick_y
|
||||
MEM_B(3, pad) = stick_y;
|
||||
MEM_B(3, pad) = (int8_t)(127 * y);
|
||||
// errno
|
||||
MEM_B(4, pad) = 0;
|
||||
}
|
||||
|
||||
+40
-29
@@ -69,30 +69,10 @@ extern "C" void unload_overlays(int32_t ram_addr, uint32_t size);
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
//if (argc != 2) {
|
||||
// printf("Usage: %s [baserom]\n", argv[0]);
|
||||
// exit(EXIT_SUCCESS);
|
||||
//}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Set up console output to accept UTF-8 on windows
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
|
||||
// Change to a font that supports Japanese characters
|
||||
CONSOLE_FONT_INFOEX cfi;
|
||||
cfi.cbSize = sizeof cfi;
|
||||
cfi.nFont = 0;
|
||||
cfi.dwFontSize.X = 0;
|
||||
cfi.dwFontSize.Y = 16;
|
||||
cfi.FontFamily = FF_DONTCARE;
|
||||
cfi.FontWeight = FW_NORMAL;
|
||||
wcscpy_s(cfi.FaceName, L"NSimSun");
|
||||
SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
|
||||
#else
|
||||
std::setlocale(LC_ALL, "en_US.UTF-8");
|
||||
#endif
|
||||
std::unique_ptr<uint8_t[]> rdram_buffer;
|
||||
recomp_context context{};
|
||||
|
||||
__declspec(dllexport) extern "C" void init() {
|
||||
{
|
||||
std::basic_ifstream<uint8_t> rom_file{ get_rom_name(), std::ios::binary };
|
||||
|
||||
@@ -128,9 +108,8 @@ int main(int argc, char **argv) {
|
||||
load_overlays(0x1000, (int32_t)entrypoint, 1024 * 1024);
|
||||
|
||||
// Allocate rdram_buffer (16MB to give room for any extra addressable data used by recomp)
|
||||
std::unique_ptr<uint8_t[]> rdram_buffer = std::make_unique<uint8_t[]>(16 * 1024 * 1024);
|
||||
rdram_buffer = std::make_unique<uint8_t[]>(16 * 1024 * 1024);
|
||||
std::memset(rdram_buffer.get(), 0, 8 * 1024 * 1024);
|
||||
recomp_context context{};
|
||||
|
||||
// Initial 1MB DMA (rom address 0x1000 = physical address 0x10001000)
|
||||
do_rom_read(rdram_buffer.get(), entrypoint, 0x10001000, 0x100000);
|
||||
@@ -152,14 +131,46 @@ int main(int argc, char **argv) {
|
||||
MEM_W(osRomBase, 0) = 0xB0000000u; // standard rom base
|
||||
MEM_W(osResetType, 0) = 0; // cold reset
|
||||
MEM_W(osMemSize, 0) = 8 * 1024 * 1024; // 8MB
|
||||
}
|
||||
|
||||
debug_printf("[Recomp] Starting\n");
|
||||
__declspec(dllexport) extern "C" void start(void* window_handle, const Multilibultra::audio_callbacks_t* audio_callbacks, const Multilibultra::input_callbacks_t* input_callbacks) {
|
||||
Multilibultra::set_audio_callbacks(audio_callbacks);
|
||||
Multilibultra::set_input_callbacks(input_callbacks);
|
||||
std::thread game_thread{[](void* window_handle) {
|
||||
debug_printf("[Recomp] Starting\n");
|
||||
|
||||
Multilibultra::preinit(rdram_buffer.get(), rom.get());
|
||||
Multilibultra::preinit(rdram_buffer.get(), rom.get(), window_handle);
|
||||
|
||||
recomp_entrypoint(rdram_buffer.get(), &context);
|
||||
recomp_entrypoint(rdram_buffer.get(), &context);
|
||||
|
||||
debug_printf("[Recomp] Quitting\n");
|
||||
}, window_handle};
|
||||
|
||||
debug_printf("[Recomp] Quitting\n");
|
||||
game_thread.detach();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
#ifdef _WIN32
|
||||
// Set up console output to accept UTF-8 on windows
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
|
||||
// Change to a font that supports Japanese characters
|
||||
CONSOLE_FONT_INFOEX cfi;
|
||||
cfi.cbSize = sizeof cfi;
|
||||
cfi.nFont = 0;
|
||||
cfi.dwFontSize.X = 0;
|
||||
cfi.dwFontSize.Y = 16;
|
||||
cfi.FontFamily = FF_DONTCARE;
|
||||
cfi.FontWeight = FW_NORMAL;
|
||||
wcscpy_s(cfi.FaceName, L"NSimSun");
|
||||
SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
|
||||
#else
|
||||
std::setlocale(LC_ALL, "en_US.UTF-8");
|
||||
#endif
|
||||
|
||||
init();
|
||||
start(nullptr, nullptr, nullptr);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+8
-5
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "../portultra/multilibultra.hpp"
|
||||
#include "rt64_layer.h"
|
||||
#include "SDL.h"
|
||||
|
||||
static uint8_t DMEM[0x1000];
|
||||
static uint8_t IMEM[0x1000];
|
||||
@@ -44,7 +43,7 @@ void dummy_check_interrupts() {
|
||||
|
||||
}
|
||||
|
||||
void RT64Init(uint8_t* rom, uint8_t* rdram) {
|
||||
void RT64Init(uint8_t* rom, uint8_t* rdram, void* window_handle) {
|
||||
// Dynamic loading
|
||||
//auto RT64 = LoadLibrary("RT64.dll");
|
||||
//if (RT64 == 0) {
|
||||
@@ -57,6 +56,9 @@ void RT64Init(uint8_t* rom, uint8_t* rdram) {
|
||||
//GET_FUNC(RT64, UpdateScreen);
|
||||
|
||||
GFX_INFO gfx_info{};
|
||||
gfx_info.hWnd = window_handle;
|
||||
gfx_info.hStatusBar = nullptr;
|
||||
|
||||
gfx_info.HEADER = rom;
|
||||
gfx_info.RDRAM = rdram;
|
||||
gfx_info.DMEM = DMEM;
|
||||
@@ -89,9 +91,6 @@ void RT64Init(uint8_t* rom, uint8_t* rdram) {
|
||||
gfx_info.VI_Y_SCALE_REG = &VI_Y_SCALE_REG;
|
||||
|
||||
gfx_info.CheckInterrupts = dummy_check_interrupts;
|
||||
gfx_info.version = 2;
|
||||
gfx_info.SP_STATUS_REG = &SP_STATUS_REG;
|
||||
gfx_info.RDRAM_SIZE = &RDRAM_SIZE;
|
||||
|
||||
InitiateGFX(gfx_info);
|
||||
}
|
||||
@@ -112,3 +111,7 @@ void RT64UpdateScreen(uint32_t vi_origin) {
|
||||
|
||||
UpdateScreen();
|
||||
}
|
||||
|
||||
void RT64ChangeWindow() {
|
||||
ChangeWindow();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user