Implement osViRepeatLine (#30)

* Implement osViRepeatLine

* Address feedback

* Include helpers header

* Address feedback
This commit is contained in:
David Chavez 2024-06-18 23:00:26 +02:00 committed by GitHub
parent 93fab7ecc4
commit e94dc4055b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 5 deletions

View file

@ -1,5 +1,6 @@
#include <ultramodern/ultramodern.hpp>
#include "recomp.h"
#include "helpers.hpp"
extern "C" void osViSetYScale_recomp(uint8_t* rdram, recomp_context * ctx) {
osViSetYScale(ctx->f12.fl);
@ -17,6 +18,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(_arg<0, u8>(rdram, ctx));
}
extern "C" void osViSetSpecialFeatures_recomp(uint8_t* rdram, recomp_context* ctx) {
osViSetSpecialFeatures((uint32_t)ctx->r4);
}

View file

@ -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();

View file

@ -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;
static uint16_t vi_state = 0;
void set_dummy_vi() {
VI_STATUS_REG = 0x311E;
@ -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 (vi_state & VI_STATE_BLACK) {
VI_H_START_REG = 0;
} else {
VI_H_START_REG = hstart;
}
if (vi_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 });
}
@ -457,7 +465,19 @@ extern "C" void osViSetSpecialFeatures(uint32_t func) {
}
extern "C" void osViBlack(uint8_t active) {
vi_black = active;
if (active) {
vi_state |= VI_STATE_BLACK;
} else {
vi_state &= ~VI_STATE_BLACK;
}
}
extern "C" void osViRepeatLine(uint8_t active) {
if (active) {
vi_state |= VI_STATE_REPEATLINE;
} else {
vi_state &= ~VI_STATE_REPEATLINE;
}
}
extern "C" void osViSetXScale(float scale) {