Skip to content

Commit df7e820

Browse files
authored
VI accuracy fixes and osSetTime implementation (#123)
* Rewrite VI functionality for higher accuracy * Implement osSetTime and move update screen to before VI update
1 parent cea072b commit df7e820

5 files changed

Lines changed: 225 additions & 134 deletions

File tree

librecomp/src/ultra_translation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,21 @@ extern "C" void osGetCount_recomp(uint8_t * rdram, recomp_context * ctx) {
7373
ctx->r2 = osGetCount();
7474
}
7575

76+
extern "C" void osSetCount_recomp(uint8_t * rdram, recomp_context * ctx) {
77+
osSetCount(ctx->r4);
78+
}
79+
7680
extern "C" void osGetTime_recomp(uint8_t * rdram, recomp_context * ctx) {
7781
uint64_t total_count = osGetTime();
7882
ctx->r2 = (int32_t)(total_count >> 32);
7983
ctx->r3 = (int32_t)(total_count >> 0);
8084
}
8185

86+
extern "C" void osSetTime_recomp(uint8_t * rdram, recomp_context * ctx) {
87+
uint64_t t = ((uint64_t)(ctx->r4) << 32) | ((ctx->r5) & 0xFFFFFFFFu);
88+
osSetTime(t);
89+
}
90+
8291
extern "C" void osSetTimer_recomp(uint8_t * rdram, recomp_context * ctx) {
8392
uint64_t countdown = ((uint64_t)(ctx->r6) << 32) | ((ctx->r7) & 0xFFFFFFFFu);
8493
uint64_t interval = load_doubleword(rdram, ctx->r29, 0x10);

ultramodern/include/ultramodern/renderer_context.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ struct SDL_Window;
2828

2929
namespace ultramodern {
3030
namespace renderer {
31+
struct ViRegs {
32+
unsigned int VI_STATUS_REG;
33+
unsigned int VI_ORIGIN_REG;
34+
unsigned int VI_WIDTH_REG;
35+
unsigned int VI_INTR_REG;
36+
unsigned int VI_V_CURRENT_LINE_REG;
37+
unsigned int VI_TIMING_REG;
38+
unsigned int VI_V_SYNC_REG;
39+
unsigned int VI_H_SYNC_REG;
40+
unsigned int VI_LEAP_REG;
41+
unsigned int VI_H_START_REG;
42+
unsigned int VI_V_START_REG;
43+
unsigned int VI_V_BURST_REG;
44+
unsigned int VI_X_SCALE_REG;
45+
unsigned int VI_Y_SCALE_REG;
46+
};
47+
ViRegs* get_vi_regs();
3148

3249
#if defined(_WIN32)
3350
// Native HWND handle to the target window.
@@ -67,7 +84,7 @@ namespace ultramodern {
6784

6885
virtual void enable_instant_present() = 0;
6986
virtual void send_dl(const OSTask* task) = 0;
70-
virtual void update_screen(uint32_t vi_origin) = 0;
87+
virtual void update_screen() = 0;
7188
virtual void shutdown() = 0;
7289
virtual uint32_t get_display_framerate() const = 0;
7390
virtual float get_resolution_scale() const = 0;

ultramodern/include/ultramodern/ultra64.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ void osViSetYScale(float scale);
290290
PTR(void) osViGetNextFramebuffer();
291291
PTR(void) osViGetCurrentFramebuffer();
292292
u32 osGetCount();
293+
void osSetCount(u32 count);
293294
OSTime osGetTime();
295+
void osSetTime(OSTime t);
294296
int osSetTimer(RDRAM_ARG PTR(OSTimer) timer, OSTime countdown, OSTime interval, PTR(OSMesgQueue) mq, OSMesg msg);
295297
int osStopTimer(RDRAM_ARG PTR(OSTimer) timer);
296298
u32 osVirtualToPhysical(PTR(void) addr);

0 commit comments

Comments
 (0)