diff --git a/librecomp/src/vi.cpp b/librecomp/src/vi.cpp index e38152f..129de91 100644 --- a/librecomp/src/vi.cpp +++ b/librecomp/src/vi.cpp @@ -17,6 +17,10 @@ extern "C" void osViBlack_recomp(uint8_t* rdram, recomp_context* ctx) { osViBlack((uint32_t)ctx->r4); } +extern "C" void osViRepeatLine_recomp(uint8_t* rdram, recomp_context* ctx) { + osViRepeatLine((uint32_t)ctx->r4); +} + extern "C" void osViSetSpecialFeatures_recomp(uint8_t* rdram, recomp_context* ctx) { osViSetSpecialFeatures((uint32_t)ctx->r4); } diff --git a/ultramodern/include/ultramodern/ultra64.h b/ultramodern/include/ultramodern/ultra64.h index 395cadb..0b81345 100644 --- a/ultramodern/include/ultramodern/ultra64.h +++ b/ultramodern/include/ultramodern/ultra64.h @@ -245,6 +245,7 @@ void osViSwapBuffer(RDRAM_ARG PTR(void) frameBufPtr); void osViSetMode(RDRAM_ARG PTR(OSViMode)); void osViSetSpecialFeatures(uint32_t func); void osViBlack(uint8_t active); +void osViRepeatLine(uint8_t active); void osViSetXScale(float scale); void osViSetYScale(float scale); PTR(void) osViGetNextFramebuffer(); diff --git a/ultramodern/src/events.cpp b/ultramodern/src/events.cpp index 9ca13c2..fe527de 100644 --- a/ultramodern/src/events.cpp +++ b/ultramodern/src/events.cpp @@ -360,9 +360,12 @@ extern unsigned int VI_V_BURST_REG; extern unsigned int VI_X_SCALE_REG; extern unsigned int VI_Y_SCALE_REG; +#define VI_STATE_BLACK 0x20 +#define VI_STATE_REPEATLINE 0x40 + uint32_t hstart = 0; uint32_t vi_origin_offset = 320 * sizeof(uint16_t); -bool vi_black = false; +uint16_t state = 0; void set_dummy_vi() { VI_STATUS_REG = 0x311E; @@ -381,11 +384,16 @@ void set_dummy_vi() { } extern "C" void osViSwapBuffer(RDRAM_ARG PTR(void) frameBufPtr) { - if (vi_black) { + VI_H_START_REG = hstart; + if (state & VI_STATE_BLACK) { VI_H_START_REG = 0; - } else { - VI_H_START_REG = hstart; } + + if (state & VI_STATE_REPEATLINE) { + VI_Y_SCALE_REG = 0; + VI_ORIGIN_REG = osVirtualToPhysical(frameBufPtr); + } + events_context.vi.next_buffer = frameBufPtr; events_context.action_queue.enqueue(SwapBuffersAction{ osVirtualToPhysical(frameBufPtr) + vi_origin_offset }); } @@ -472,7 +480,19 @@ extern "C" void osViSetSpecialFeatures(uint32_t func) { } extern "C" void osViBlack(uint8_t active) { - vi_black = active; + if (active) { + state |= VI_STATE_BLACK; + } else { + state &= ~VI_STATE_BLACK; + } +} + +extern "C" void osViRepeatLine(uint8_t active) { + if (active) { + state |= VI_STATE_REPEATLINE; + } else { + state &= ~VI_STATE_REPEATLINE; + } } extern "C" void osViSetXScale(float scale) {