Track LUS changes for LUS refactor. (#163)

* Track LUS changes. So far implemented:
- Moving the big switch into unordered maps.
- Dynamically switching between different ucodes. So far tested switching between f3dex2 and s2dex.

* track LUS changes

* LUS Bump
This commit is contained in:
louist103
2024-05-22 09:05:00 -05:00
committed by Garrett Cox
parent 5a258fecd4
commit 27b70f03c1
11 changed files with 56 additions and 34 deletions
+3 -1
View File
@@ -28,6 +28,7 @@ void FB_CreateFramebuffers(void) {
* Setting oncePerFrame ensures that the copy will only happen once every game frame. This
* is important for effects that could be affected by increased frame interpolation (like motion blur).
* A pointer to a boolean is passed to the render for the render to set once the copy has been performed.
* This function uses opcodes from f3dex2 but may be called when s2dex is loaded, such as during shrink window. Make sure f3dex2 is loaded before this function is called.
*/
void FB_CopyToFramebuffer(Gfx** gfxp, s32 fb_src, s32 fb_dest, u8 oncePerFrame, u8* hasCopied) {
Gfx* gfx = *gfxp;
@@ -89,7 +90,8 @@ void FB_DrawFromFramebuffer(Gfx** gfxp, s32 fb, u8 alpha) {
}
/**
* Similar to FB_DrawFromFramebuffer, but scales the image relative to the center of the screen
* Similar to FB_DrawFromFramebuffer, but scales the image relative to the center of the screen.
* This function uses opcodes from f3dex2 but may be called when s2dex is loaded, such as during shrink window. Make sure f3dex2 is loaded before this function is called.
*/
void FB_DrawFromFramebufferScaled(Gfx** gfxp, s32 fb, u8 alpha, float scaleX, float scaleY) {
Gfx* gfx = *gfxp;
+2 -1
View File
@@ -1104,7 +1104,8 @@ void Check_RegionIsSupported(void);
u64* SysUcode_GetUCodeBoot(void);
size_t SysUcode_GetUCodeBootSize(void);
u64* SysUcode_GetUCode(void);
// BENTODO move this into its own header so we don't have so much header bloat with lus bridge
uint32_t SysUcode_GetUCode(void);
u64* SysUcode_GetUCodeData(void);
void func_80183070(void);
+3 -2
View File
@@ -18,6 +18,7 @@
#include "stackcheck.h"
#include <stdlib.h>
#include <string.h>
#include "public/bridge/gfxbridge.h"
/**
* Assigns the "save" values in PreRender
@@ -791,7 +792,7 @@ void Prerender_DrawBackground2DImpl(PreRenderBackground2DParams* bg2D, Gfx** gfx
bg->b.imageFlip = 0;
if (loadS2DEX2) {
gSPLoadUcodeL(gfx++, gspS2DEX2_fifo);
gSPLoadUcodeL(gfx++, ucode_s2dex);
}
if ((bg2D->fmt == G_IM_FMT_CI) && (bg2D->tlut != NULL)) {
@@ -836,7 +837,7 @@ void Prerender_DrawBackground2DImpl(PreRenderBackground2DParams* bg2D, Gfx** gfx
gDPPipeSync(gfx++);
if (loadS2DEX2) {
gSPLoadUcode(gfx++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
gSPLoadUcode(gfx++, SysUcode_GetUCode());
}
*gfxp = gfx;
+1 -1
View File
@@ -180,7 +180,7 @@ retry:
task->ucode_boot = SysUcode_GetUCodeBoot();
task->ucode_boot_size = SysUcode_GetUCodeBootSize();
task->ucode = SysUcode_GetUCode();
task->ucode_data = SysUcode_GetUCodeData();
//task->ucode_data = SysUcode_GetUCodeData();
task->ucode_size = SP_UCODE_SIZE;
task->ucode_data_size = SP_UCODE_DATA_SIZE;
task->dram_stack = (u64*)gGfxSPTaskStack;
+12 -12
View File
@@ -70,18 +70,18 @@ GfxMasterList D_0E000000;
Mtx D_01000000;
u16 D_0F000000[SCREEN_WIDTH * SCREEN_HEIGHT];
u64 gspS2DEX_fifoTextStart[1], gspS2DEX_fifoTextEnd[1];
u64 gspS2DEX_fifoDataStart[1], gspS2DEX_fifoDataEnd[1];
u64 gspS2DEX_fifo_dTextStart[1], gspS2DEX_fifo_dTextEnd[1];
u64 gspS2DEX_fifo_dDataStart[1], gspS2DEX_fifo_dDataEnd[1];
u64 gspS2DEX2_fifoTextStart[1], gspS2DEX2_fifoTextEnd[1];
u64 gspS2DEX2_fifoDataStart[1], gspS2DEX2_fifoDataEnd[1];
u64 gspS2DEX2_xbusTextStart[1], gspS2DEX2_xbusTextEnd[1];
u64 gspS2DEX2_xbusDataStart[1], gspS2DEX2_xbusDataEnd[1];
u64 gspF3DZEX2_NoN_PosLight_fifoTextStart[1];
u64 gspF3DZEX2_NoN_PosLight_fifoTextEnd[1];
u64 gspF3DZEX2_NoN_PosLight_fifoDataStart[1];
u64 gspF3DZEX2_NoN_PosLight_fifoDataEnd[1];
//u64 gspS2DEX_fifoTextStart[1], gspS2DEX_fifoTextEnd[1];
//u64 gspS2DEX_fifoDataStart[1], gspS2DEX_fifoDataEnd[1];
//u64 gspS2DEX_fifo_dTextStart[1], gspS2DEX_fifo_dTextEnd[1];
//u64 gspS2DEX_fifo_dDataStart[1], gspS2DEX_fifo_dDataEnd[1];
//u64 gspS2DEX2_fifoTextStart[1], gspS2DEX2_fifoTextEnd[1];
//u64 gspS2DEX2_fifoDataStart[1], gspS2DEX2_fifoDataEnd[1];
//u64 gspS2DEX2_xbusTextStart[1], gspS2DEX2_xbusTextEnd[1];
//u64 gspS2DEX2_xbusDataStart[1], gspS2DEX2_xbusDataEnd[1];
//u64 gspF3DZEX2_NoN_PosLight_fifoTextStart[1];
//u64 gspF3DZEX2_NoN_PosLight_fifoTextEnd[1];
//u64 gspF3DZEX2_NoN_PosLight_fifoDataStart[1];
//u64 gspF3DZEX2_NoN_PosLight_fifoDataEnd[1];
Vec3f gZeroVec3f;
Vec3s gZeroVec3s;
+7 -6
View File
@@ -3,9 +3,10 @@
* Description: Functions for obtaining locations and sizes of microcode
*/
#include "global.h"
#include "public/bridge/gfxbridge.h"
u64* initialgspUcodeText = gspF3DZEX2_NoN_PosLight_fifoTextStart;
u64* initialgspUcodeData = gspF3DZEX2_NoN_PosLight_fifoDataStart;
UcodeHandlers initialgspUcodeText = ucode_f3dex2;
//u64* initialgspUcodeData = gspF3DZEX2_NoN_PosLight_fifoDataStart;
u64* SysUcode_GetUCodeBoot(void) {
return rspbootTextStart;
@@ -15,10 +16,10 @@ size_t SysUcode_GetUCodeBootSize(void) {
return (uintptr_t)rspbootTextEnd - (uintptr_t)rspbootTextStart;
}
u64* SysUcode_GetUCode(void) {
UcodeHandlers SysUcode_GetUCode(void) {
return initialgspUcodeText;
}
u64* SysUcode_GetUCodeData(void) {
return initialgspUcodeData;
}
//u64* SysUcode_GetUCodeData(void) {
// return initialgspUcodeData;
//}
+2 -2
View File
@@ -6642,13 +6642,13 @@ void Interface_Draw(PlayState* play) {
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha);
// Load in Grandma's Story
gSPLoadUcodeL(OVERLAY_DISP++, gspS2DEX2_fifo);
gSPLoadUcodeL(OVERLAY_DISP++, ucode_s2dex);
gfx = OVERLAY_DISP;
Prerender_DrawBackground2D(&gfx, sStoryTextures[interfaceCtx->storyType],
sStoryTLUTs[interfaceCtx->storyType], SCREEN_WIDTH, SCREEN_HEIGHT, G_IM_FMT_CI,
G_IM_SIZ_8b, 0x8000, 0x100, 0.0f, 0.0f, 1.0f, 1.0f, 0);
OVERLAY_DISP = gfx;
gSPLoadUcode(OVERLAY_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
gSPLoadUcode(OVERLAY_DISP++, SysUcode_GetUCode());
gDPPipeSync(OVERLAY_DISP++);
+7 -4
View File
@@ -2,6 +2,9 @@
#include "PR/gs2dex.h"
#include "debug.h"
#include "public/bridge/gfxbridge.h"
void Room_Noop(PlayState* play, Room* room, Input* input, s32 arg3) {
}
@@ -325,7 +328,7 @@ void Room_DrawImageSingle(PlayState* play, Room* room, u32 flags) {
}
if (drawBackground) {
gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2_fifo);
gSPLoadUcodeL(POLY_OPA_DISP++, ucode_s2dex);
gfx = POLY_OPA_DISP;
@@ -343,7 +346,7 @@ void Room_DrawImageSingle(PlayState* play, Room* room, u32 flags) {
POLY_OPA_DISP = gfx;
gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode());
}
}
@@ -424,7 +427,7 @@ void Room_DrawImageMulti(PlayState* play, Room* room, u32 flags) {
}
if (drawBackground) {
gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2_fifo);
gSPLoadUcodeL(POLY_OPA_DISP++, ucode_s2dex);
gfx = POLY_OPA_DISP;
@@ -442,7 +445,7 @@ void Room_DrawImageMulti(PlayState* play, Room* room, u32 flags) {
POLY_OPA_DISP = gfx;
gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode());
}
}
+15 -2
View File
@@ -15,6 +15,7 @@
#include "sys_cfb.h"
#include <string.h>
#include "2s2h/framebuffer_effects.h"
#include "public/bridge/gfxbridge.h"
#define SCALE_MIN 0.032f
#define SCALE_MAX 1.0f //!< also unchanged scale
@@ -170,7 +171,11 @@ void VisFbuf_ApplyEffects(VisFbuf* this, Gfx** gfxP, void* source, void* img, s3
G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE,
G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2);
// The function FB_CopyToFramebuffer uses f3dex2 opcodes, clear and set geometry ode. We need to load f3dex2, call the function, and then reload s2dex.
gSPLoadUcode(gfx++, ucode_f3dex2);
FB_CopyToFramebuffer(&gfx, 0, gReusableFrameBuffer, false, NULL);
gSPLoadUcode(gfx++, ucode_s2dex);
gDPPipeSync(gfx++);
// fill framebuffer with primColor
@@ -186,7 +191,10 @@ void VisFbuf_ApplyEffects(VisFbuf* this, Gfx** gfxP, void* source, void* img, s3
//! @bug VisFbuf_SetBgSimple() sets the current color image back to the frame's default framebuffer at the end,
//! so this will always fill in the default framebuffer, whatever are used as `source` and `img`. This does not
//! arise in-game since this function is always used with `source = D_0F000000`.
gSPLoadUcode(gfx++, ucode_f3dex2);
gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(width - 1), height - 1);
gSPLoadUcode(gfx++, ucode_s2dex);
gDPPipeSync(gfx++);
// Set lod and primColor from struct, perform interpolation, draw image with scaling (this is the most general
@@ -224,9 +232,14 @@ void VisFbuf_ApplyEffects(VisFbuf* this, Gfx** gfxP, void* source, void* img, s3
// 2S2H [Port][Widescreen]
// Draw shrunk window using an adjusted horizontal scale accounting for different aspect ratios
// The function FB_DrawFromFramebufferScaled uses f3dex2 opcodes. We need to load f3dex2, call the function, and then
// reload s2dex.
gSPLoadUcode(gfx++, ucode_f3dex2);
FB_DrawFromFramebufferScaled(&gfx, gReusableFrameBuffer, 255,
(1.0f - scale) * (OTRGetAspectRatio() / ((float)SCREEN_WIDTH / SCREEN_HEIGHT)),
(1.0f - scale));
gSPLoadUcode(gfx++, ucode_s2dex);
}
gDPPipeSync(gfx++);
@@ -313,7 +326,7 @@ void VisFbuf_DrawInterpolate(VisFbuf* this, Gfx** gfxP, void* img, s32 width, s3
void VisFbuf_Draw(VisFbuf* this, Gfx** gfxP, void* img) {
Gfx* gfx = *gfxP;
gSPLoadUcodeL(gfx++, gspS2DEX2_fifo);
gSPLoadUcodeL(gfx++, ucode_s2dex);
switch (this->mode) {
case VIS_FBUF_MODE_GENERAL:
@@ -328,7 +341,7 @@ void VisFbuf_Draw(VisFbuf* this, Gfx** gfxP, void* img) {
break;
}
gSPLoadUcode(gfx++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
gSPLoadUcode(gfx++, SysUcode_GetUCode());
*gfxP = gfx;
}
@@ -9,6 +9,7 @@
#include "sys_cfb.h"
#include "z_fbdemo_wipe5.h"
#include <string.h>
#include "public/bridge/gfxbridge.h"
#define THIS ((TransitionWipe5*)thisx)
@@ -89,7 +90,7 @@ void TransitionWipe5_Draw(void* thisx, Gfx** gfxP) {
s32 alpha = (1.0f - this->unk_0C) * 255.0f;
gDPPipeSync(gfx++);
gSPLoadUcodeL(gfx++, gspS2DEX2_fifo);
gSPLoadUcodeL(gfx++, ucode_s2dex);
if (this->unk_10 == 0) {
gDPSetOtherMode(gfx++,
G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE |
@@ -114,7 +115,7 @@ void TransitionWipe5_Draw(void* thisx, Gfx** gfxP) {
VisFbuf_SetBgSimple(&gfx, workBuffer, D_0F000000_TO_SEGMENTED, width, height, VIS_FBUF_BG_CYC_1CYC);
}
gDPPipeSync(gfx++);
gSPLoadUcode(gfx++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
gSPLoadUcode(gfx++, SysUcode_GetUCode());
*gfxP = gfx;
}