Skip to content

Commit

Permalink
Implement osViRepeatLine
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvz committed Jun 10, 2024
1 parent 835c14b commit 71e299a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
4 changes: 4 additions & 0 deletions librecomp/src/vi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions ultramodern/include/ultramodern/ultra64.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,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();
Expand Down
30 changes: 25 additions & 5 deletions ultramodern/src/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,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;
Expand All @@ -366,11 +369,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 });
}
Expand Down Expand Up @@ -457,7 +465,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) {
Expand Down

0 comments on commit 71e299a

Please sign in to comment.