Made recompiled output run the game's entrypoint, various reorganization, clang warning fixes

This commit is contained in:
Mr-Wiseguy 2022-11-25 15:31:16 -05:00
parent 6e45fac005
commit 0af9d489b3
13 changed files with 3921 additions and 100 deletions

View file

@ -4,6 +4,8 @@
#include <cinttypes>
#include <variant>
#include <unordered_map>
#include <utility>
#include <mutex>
#include <Windows.h>
#include "SDL.h"
@ -18,7 +20,7 @@ struct SpTaskAction {
};
struct SwapBuffersAction {
int32_t origin;
uint32_t origin;
};
using Action = std::variant<SpTaskAction, SwapBuffersAction>;
@ -262,7 +264,7 @@ void gfx_thread_func(uint8_t* rdram, uint8_t* rom) {
}
extern "C" void osViSwapBuffer(RDRAM_ARG PTR(void) frameBufPtr) {
events_context.action_queue.enqueue(SwapBuffersAction{ frameBufPtr + 640 });
events_context.action_queue.enqueue(SwapBuffersAction{ osVirtualToPhysical(frameBufPtr) + 640 });
}
void Multilibultra::submit_rsp_task(RDRAM_ARG PTR(OSTask) task_) {

View file

@ -0,0 +1,24 @@
#include "ultra64.h"
extern uint64_t start_time;
#define K0BASE 0x80000000
#define K1BASE 0xA0000000
#define K2BASE 0xC0000000
#define IS_KSEG0(x) ((u32)(x) >= K0BASE && (u32)(x) < K1BASE)
#define IS_KSEG1(x) ((u32)(x) >= K1BASE && (u32)(x) < K2BASE)
#define K0_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg0 to physical */
#define K1_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg1 to physical */
u32 osVirtualToPhysical(PTR(void) addr) {
uintptr_t addr_val = (uintptr_t)addr;
if (IS_KSEG0(addr_val)) {
return K0_TO_PHYS(addr_val);
} else if (IS_KSEG1(addr_val)) {
return K1_TO_PHYS(addr_val);
} else {
// TODO handle TLB mappings
return (u32)addr_val;
}
}

View file

@ -164,6 +164,7 @@ void osViSetEvent(RDRAM_ARG PTR(OSMesgQueue), OSMesg, u32);
void osViSwapBuffer(RDRAM_ARG PTR(void) frameBufPtr);
u32 osGetCount();
OSTime osGetTime();
u32 osVirtualToPhysical(PTR(void) addr);
#ifdef __cplusplus
} // extern "C"