Skip to content

Commit

Permalink
Implement osViGetCurrentLine and osViGetCurrentField
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvz committed Jun 19, 2024
1 parent e94dc40 commit 8719abe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions librecomp/src/vi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ extern "C" void osViRepeatLine_recomp(uint8_t* rdram, recomp_context* ctx) {
osViRepeatLine(_arg<0, u8>(rdram, ctx));
}

extern "C" void osViGetCurrentLine_recomp(uint8_t* rdram, recomp_context* ctx) {
ctx->r2 = (gpr)osViGetCurrentLine();
}

extern "C" void osViGetCurrentField_recomp(uint8_t* rdram, recomp_context* ctx) {
ctx->r2 = (gpr)osViGetCurrentField();
}

extern "C" void osViSetSpecialFeatures_recomp(uint8_t* rdram, recomp_context* ctx) {
osViSetSpecialFeatures((uint32_t)ctx->r4);
}
Expand Down
4 changes: 4 additions & 0 deletions ultramodern/include/ultramodern/ultra64.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ typedef uint8_t u8;
# ifdef __cplusplus
# define NULLPTR (PTR(void))0
# endif
# define PHYS_TO_K1(x) ((x)|0xA0000000)
# define IO_READ(addr) (*(volatile uint32_t*)PHYS_TO_K1(addr))
#endif

#ifndef NULL
Expand Down Expand Up @@ -285,6 +287,8 @@ void osViSetMode(RDRAM_ARG PTR(OSViMode));
void osViSetSpecialFeatures(uint32_t func);
void osViBlack(uint8_t active);
void osViRepeatLine(uint8_t active);
u32 osViGetCurrentLine();
u32 osViGetCurrentField();
void osViSetXScale(float scale);
void osViSetYScale(float scale);
PTR(void) osViGetNextFramebuffer();
Expand Down
8 changes: 8 additions & 0 deletions ultramodern/src/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,14 @@ extern "C" void osViRepeatLine(uint8_t active) {
}
}

extern "C" u32 osViGetCurrentLine() {
return IO_READ(VI_V_CURRENT_LINE_REG);
}

extern "C" u32 osViGetCurrentField() {
return IO_READ(VI_V_CURRENT_LINE_REG) & 1;
}

extern "C" void osViSetXScale(float scale) {
if (scale != 1.0f) {
assert(false);
Expand Down

0 comments on commit 8719abe

Please sign in to comment.