mirror of
https://github.com/BanjoRecomp/BanjoRecomp
synced 2026-05-24 15:01:02 -04:00
Tagging for skybox and most projections, skip interpolation on the frame after all markers are reset to avoid glitches on scene load
This commit is contained in:
@@ -1,16 +1,36 @@
|
||||
#include "patches.h"
|
||||
#include "transform_ids.h"
|
||||
#include "core1/core1.h"
|
||||
|
||||
s32 cur_perspective_projection_transform_id = 0;
|
||||
s32 backup_perspective_projection_transform_id = 0;
|
||||
|
||||
s32 cur_ortho_projection_transform_id = 0;
|
||||
s32 backup_ortho_projection_transform_id = 0;
|
||||
|
||||
void reset_projection_ids() {
|
||||
cur_perspective_projection_transform_id = 0;
|
||||
cur_ortho_projection_transform_id = 0;
|
||||
}
|
||||
|
||||
extern f32 sViewportFOVy;
|
||||
extern f32 sViewportAspect;
|
||||
extern f32 sViewportNear;
|
||||
extern f32 sViewportFar;
|
||||
extern f32 sViewportLookVector[3];
|
||||
extern f32 sViewportPosition[3];
|
||||
extern f32 sViewportRotation[3];
|
||||
extern Vp sViewportStack[];
|
||||
extern MtxF sViewportMatrix;
|
||||
extern s32 sViewportStackIndex;
|
||||
|
||||
// @recomp Patched to specify the view matrix for better transform interpolation.
|
||||
extern f32 sViewportBackupPosition[3];
|
||||
extern f32 sViewportBackupRotation[3];
|
||||
extern f32 sViewportBackupFrustumPlanes[4][4];
|
||||
extern f32 sViewportBackupLookVector[3];
|
||||
extern MtxF sViewportBackupMatrix;
|
||||
|
||||
// @recomp Patched to specify the view matrix for better transform interpolation and set up a matrix group for the new projection.
|
||||
RECOMP_PATCH void viewport_setRenderPerspectiveMatrix(Gfx **gfx, Mtx **mtx, f32 near, f32 far) {
|
||||
u16 perspNorm;
|
||||
|
||||
@@ -42,7 +62,18 @@ RECOMP_PATCH void viewport_setRenderPerspectiveMatrix(Gfx **gfx, Mtx **mtx, f32
|
||||
MtxF* view = (MtxF*)*mtx;
|
||||
(*mtx)++;
|
||||
guTranslateF(view->m, sViewportPosition[0], sViewportPosition[1], sViewportPosition[2]);
|
||||
gEXSetViewMatrixFloat((*gfx)++, view->m);
|
||||
gEXSetViewMatrixFloat((*gfx)++, view->m);
|
||||
|
||||
// @recomp If a perspective projection transform ID is set, apply it as the projection matrix group. Otherwise, use auto as the projection matrix group.
|
||||
if (all_interpolation_skipped()) {
|
||||
gEXMatrixGroupNoInterpolate((*gfx)++, G_EX_NOPUSH, G_MTX_PROJECTION, G_EX_EDIT_NONE);
|
||||
}
|
||||
else if (cur_perspective_projection_transform_id != 0) {
|
||||
gEXMatrixGroupSimpleNormal((*gfx)++, cur_perspective_projection_transform_id, G_EX_NOPUSH, G_MTX_PROJECTION, G_EX_EDIT_NONE);
|
||||
}
|
||||
else {
|
||||
gEXMatrixGroupSimpleNormal((*gfx)++, G_EX_ID_AUTO, G_EX_NOPUSH, G_MTX_PROJECTION, G_EX_EDIT_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
float identity_matrix[4][4] = {
|
||||
@@ -64,4 +95,57 @@ RECOMP_PATCH void viewport_setRenderViewportAndOrthoMatrix(Gfx **gfx, Mtx **mtx)
|
||||
|
||||
// @recomp Set an identity view matrix.
|
||||
gEXSetViewMatrixFloat((*gfx)++, identity_matrix);
|
||||
|
||||
// @recomp If an ortho projection transform ID is set, apply it as the projection matrix group. Otherwise, use auto as the projection matrix group.
|
||||
if (all_interpolation_skipped()) {
|
||||
gEXMatrixGroupNoInterpolate((*gfx)++, G_EX_NOPUSH, G_MTX_PROJECTION, G_EX_EDIT_NONE);
|
||||
}
|
||||
else if (cur_ortho_projection_transform_id != 0) {
|
||||
gEXMatrixGroupSimpleNormal((*gfx)++, cur_ortho_projection_transform_id, G_EX_NOPUSH, G_MTX_PROJECTION, G_EX_EDIT_NONE);
|
||||
}
|
||||
else {
|
||||
gEXMatrixGroupSimpleNormal((*gfx)++, G_EX_ID_AUTO, G_EX_NOPUSH, G_MTX_PROJECTION, G_EX_EDIT_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
// @recomp Patched to also back up the projection matrix transform ID and reset the current one.
|
||||
RECOMP_PATCH void viewport_backupState(void) {
|
||||
s32 i, j;
|
||||
|
||||
viewport_getPosition_vec3f(sViewportBackupPosition);
|
||||
viewport_getRotation_vec3f(sViewportBackupRotation);
|
||||
viewport_getFrustumPlanes(sViewportBackupFrustumPlanes[0], sViewportBackupFrustumPlanes[1], sViewportBackupFrustumPlanes[2], sViewportBackupFrustumPlanes[3]);
|
||||
viewport_getLookVector(sViewportBackupLookVector);
|
||||
|
||||
for(i = 0; i < 4; i++){
|
||||
for(j = 0; j < 4; j++){
|
||||
sViewportBackupMatrix.m[i][j] = sViewportMatrix.m[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
// @recomp Back up the projection transform IDs and reset them.
|
||||
backup_perspective_projection_transform_id = cur_perspective_projection_transform_id;
|
||||
cur_perspective_projection_transform_id = 0;
|
||||
backup_ortho_projection_transform_id = cur_ortho_projection_transform_id;
|
||||
cur_ortho_projection_transform_id = 0;
|
||||
}
|
||||
|
||||
// @recomp Patched to also restore the backed up projection matrix transform ID.
|
||||
RECOMP_PATCH void viewport_restoreState(void) {
|
||||
s32 i, j;
|
||||
|
||||
viewport_setPosition_vec3f(sViewportBackupPosition);
|
||||
viewport_setRotation_vec3f(sViewportBackupRotation);
|
||||
viewport_setFrustumPlanes(sViewportBackupFrustumPlanes[0], sViewportBackupFrustumPlanes[1], sViewportBackupFrustumPlanes[2], sViewportBackupFrustumPlanes[3]);
|
||||
ml_vec3f_copy(sViewportLookVector, sViewportBackupLookVector);
|
||||
|
||||
for(i = 0; i < 4; i++){
|
||||
for(j = 0; j < 4; j++){
|
||||
sViewportMatrix.m[i][j] = sViewportBackupMatrix.m[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
// @recomp Restore the backed up projection transform IDs.
|
||||
cur_perspective_projection_transform_id = backup_perspective_projection_transform_id;
|
||||
cur_ortho_projection_transform_id = backup_ortho_projection_transform_id;
|
||||
}
|
||||
|
||||
@@ -121,4 +121,7 @@ RECOMP_PATCH void game_draw(s32 arg0){
|
||||
scissorBox_setDefault();
|
||||
}
|
||||
}
|
||||
|
||||
// Allow interpolation for the next frame.
|
||||
set_all_interpolation_skipped(FALSE);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ extern u8 D_80383428[0x1C];
|
||||
void func_8032F3D4(s32 arg0[3], ActorMarker *marker, s32 arg2);
|
||||
ActorMarker * func_80332A60(void);
|
||||
|
||||
// @recomp Patched to reset all extended marker data.
|
||||
// @recomp Patched to reset all extended marker data and skip interpolation for the next frame.
|
||||
RECOMP_PATCH void func_803329AC(void){
|
||||
s32 i;
|
||||
|
||||
@@ -29,8 +29,11 @@ RECOMP_PATCH void func_803329AC(void){
|
||||
D_8036E7C8[i].unk5C = 0;
|
||||
}
|
||||
|
||||
// @recomp Reset all actor data.
|
||||
// @recomp Reset all actor data and skip interpolation for the next frame.
|
||||
// Interpolation is skipped as the next frame will potentially reuse IDs from the previous frame,
|
||||
// as the marker ID tracking gets reset here.
|
||||
recomp_clear_all_object_data(EXTENSION_TYPE_MARKER);
|
||||
set_all_interpolation_skipped(TRUE);
|
||||
}
|
||||
|
||||
// @recomp Patched to create extension data for the marker.
|
||||
|
||||
@@ -81,5 +81,7 @@ int recomp_printf(const char* fmt, ...);
|
||||
|
||||
void set_additional_model_scale(f32 x, f32 y, f32 z);
|
||||
void set_frustum_checks_enabled(int enabled);
|
||||
void set_all_interpolation_skipped(bool skipped);
|
||||
bool all_interpolation_skipped();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,312 @@
|
||||
#include "patches.h"
|
||||
#include "transform_ids.h"
|
||||
#include "core1/core1.h"
|
||||
#include "functions.h"
|
||||
#include "../src/core2/gc/zoombox.h"
|
||||
|
||||
extern u32 D_803835E0;
|
||||
void func_802BBD2C(f32 *arg0, f32 *arg1);
|
||||
s32 func_80320708(void);
|
||||
void spawnQueue_unlock(void);
|
||||
void sky_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
bool mapModel_has_xlu_bin(void);
|
||||
void mapModel_opa_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
int game_is_frozen(void);
|
||||
void func_80322E64(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
void player_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
void func_80302C94(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
void jiggylist_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
void func_803500D8(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
void func_802F2ED0(Struct64s *arg0, Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
Struct64s* func_8032994C(void);
|
||||
void partEmitMgr_drawPass0(Gfx **gdl, Mtx **mptr, Vtx **vptr);
|
||||
void mapModel_xlu_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
void func_8032D3D8(Gfx **gdl, Mtx **mptr, Vtx **vptr);
|
||||
void partEmitMgr_drawPass1(Gfx **gdl, Mtx **mptr, Vtx **vptr);
|
||||
void func_8034F6F0(Gfx **gdl, Mtx **mptr, Vtx **vptr);
|
||||
void func_802D520C(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
void partEmitMgr_draw(Gfx **gdl, Mtx **mptr, Vtx **vptr);
|
||||
void func_80350818(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
void func_802BBD0C(Gfx **gdl, Mtx **mptr, Vtx **vptr);
|
||||
void spawnQueue_lock(void);
|
||||
s32 getGameMode(void);
|
||||
void sfx_rand_sync_to_rand(void);
|
||||
void func_803162B4(GcZoombox *this);
|
||||
void rand_sync_to_sfx_rand(void);
|
||||
void func_80338338(s32, s32, s32);
|
||||
void func_803382FC(s32);
|
||||
void func_803382E4(s32);
|
||||
void func_8033687C(Gfx **);
|
||||
void func_80335D30(Gfx **);
|
||||
void func_80344090(BKSpriteDisplayData *self, s32 frame, Gfx **gfx);
|
||||
|
||||
// @recomp Patched to set the projection transform ID for the main projection.
|
||||
RECOMP_PATCH void func_80334540(Gfx** gdl, Mtx **mptr, Vtx **vptr) {
|
||||
f32 sp44;
|
||||
f32 sp40;
|
||||
|
||||
if (D_803835E0 == 0) {
|
||||
drawRectangle2D(gdl, 0, 0, gFramebufferWidth, gFramebufferHeight, 0, 0, 0);
|
||||
func_802BBD2C(&sp44, &sp40);
|
||||
viewport_setNearAndFar(sp44, sp40);
|
||||
|
||||
// @recomp Set the perpsective projection transform ID.
|
||||
cur_perspective_projection_transform_id = PROJECTION_GAMEPLAY_TRANSFORM_ID;
|
||||
|
||||
viewport_setRenderViewportAndPerspectiveMatrix(gdl, mptr);
|
||||
return;
|
||||
}
|
||||
if (func_80320708() == 0) {
|
||||
eeprom_writeBlocks(0, 0, (void*)0x80BC7230, EEPROM_MAXBLOCKS);
|
||||
}
|
||||
spawnQueue_unlock();
|
||||
sky_draw(gdl, mptr, vptr);
|
||||
func_802BBD2C(&sp44, &sp40);
|
||||
viewport_setNearAndFar(sp44, sp40);
|
||||
|
||||
// @recomp Set the perpsective projection transform ID.
|
||||
cur_perspective_projection_transform_id = PROJECTION_GAMEPLAY_TRANSFORM_ID;
|
||||
|
||||
viewport_setRenderViewportAndPerspectiveMatrix(gdl, mptr);
|
||||
if (mapModel_has_xlu_bin() != 0) {
|
||||
mapModel_opa_draw(gdl, mptr, vptr);
|
||||
if (game_is_frozen() == 0) {
|
||||
func_80322E64(gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
player_draw(gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
func_80302C94(gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
jiggylist_draw(gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
func_803500D8(gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
func_802F2ED0(func_8032994C(), gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
partEmitMgr_drawPass0(gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
mapModel_xlu_draw(gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
func_8032D3D8(gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
partEmitMgr_drawPass1(gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
func_8034F6F0(gdl, mptr, vptr);
|
||||
}
|
||||
func_802D520C(gdl, mptr, vptr);
|
||||
} else {
|
||||
mapModel_opa_draw(gdl, mptr, vptr);
|
||||
func_80322E64(gdl, mptr, vptr);
|
||||
func_8034F6F0(gdl, mptr, vptr);
|
||||
player_draw(gdl, mptr, vptr);
|
||||
func_80302C94(gdl, mptr, vptr);
|
||||
func_8032D3D8(gdl, mptr, vptr);
|
||||
jiggylist_draw(gdl, mptr, vptr);
|
||||
func_803500D8(gdl, mptr, vptr);
|
||||
func_802F2ED0(func_8032994C(), gdl, mptr, vptr);
|
||||
func_802D520C(gdl, mptr, vptr);
|
||||
partEmitMgr_draw(gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
func_80350818(gdl, mptr, vptr);
|
||||
}
|
||||
if (game_is_frozen() == 0) {
|
||||
func_802BBD0C(gdl, mptr, vptr);
|
||||
}
|
||||
spawnQueue_lock();
|
||||
|
||||
// @recomp Clear the perpsective projection transform ID.
|
||||
cur_perspective_projection_transform_id = 0;
|
||||
}
|
||||
|
||||
void actor_predrawMethod(Actor *);
|
||||
void actor_postdrawMethod(ActorMarker *);
|
||||
extern bool D_8037DE84;
|
||||
|
||||
// @recomp Patched to set the transform ID for the press start projection.
|
||||
RECOMP_PATCH Actor *chOverlayPressStart_draw(ActorMarker *marker, Gfx **gdl, Mtx **mptr, Vtx **vptr){
|
||||
Actor * actor;
|
||||
f32 sp58[3];
|
||||
f32 sp4C[3];
|
||||
f32 sp40[3];
|
||||
f32 sp34[3];
|
||||
|
||||
|
||||
actor = marker_getActor(marker);
|
||||
if(D_8037DE84)
|
||||
return actor;
|
||||
|
||||
modelRender_preDraw((GenFunction_1)actor_predrawMethod, (s32)actor);
|
||||
modelRender_postDraw((GenFunction_1)actor_postdrawMethod, (s32)marker);
|
||||
viewport_backupState();
|
||||
{sp58[0] = 0.0f; sp58[1] = 0.0f; sp58[2] = 1312.5f;};
|
||||
{sp4C[0] = 0.0f; sp4C[1] = 0.0f; sp4C[2] = 0.0f;};
|
||||
viewport_setPosition_vec3f(sp58);
|
||||
viewport_setRotation_vec3f(sp4C);
|
||||
viewport_update();
|
||||
|
||||
// @recomp Record the current projection transform, then set the projection transform ID for the press start projection.
|
||||
s32 prev_perspective_projection_transform = cur_perspective_projection_transform_id;
|
||||
cur_perspective_projection_transform_id = PROJECTION_PRESS_START_TRANSFORM_ID;
|
||||
|
||||
viewport_setRenderViewportAndPerspectiveMatrix(gdl, mptr);
|
||||
{sp40[0] = 0.0f; sp40[1] = 0.0f; sp40[2] = 0.0f;};
|
||||
{sp34[0] = 0.0f; sp34[1] = 400.0f; sp34[2] = 0.0f;};
|
||||
modelRender_draw(gdl, mptr, sp40, 0, 1.0f, sp34, marker_loadModelBin(marker));
|
||||
|
||||
// @recomp Restore the previous perpsective projection transform ID.
|
||||
cur_perspective_projection_transform_id = prev_perspective_projection_transform;
|
||||
|
||||
viewport_restoreState();
|
||||
viewport_setRenderViewportAndPerspectiveMatrix(gdl, mptr);
|
||||
|
||||
return actor;
|
||||
}
|
||||
|
||||
#define ASSET_54D_MODEL_BK_TITLE_LOGO 0x54D
|
||||
#define ASSET_56C_MODEL_THE_END 0x56C
|
||||
|
||||
// @recomp Patched to set the transform ID for the title logo and copyright text projections.
|
||||
RECOMP_PATCH Actor *func_802DC7E0(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){
|
||||
Actor *this;
|
||||
f32 sp58[3];
|
||||
f32 sp4C[3];
|
||||
f32 sp40[3];
|
||||
f32 sp34[3];
|
||||
|
||||
this = marker_getActor(marker);
|
||||
modelRender_preDraw( (GenFunction_1)actor_predrawMethod, (s32)this);
|
||||
modelRender_postDraw((GenFunction_1)actor_postdrawMethod, (s32)marker);
|
||||
viewport_backupState();
|
||||
sp58[0] = 0.0f;
|
||||
sp58[1] = 0.0f;
|
||||
sp58[2] = 860.0f;
|
||||
sp4C[0] = 0.0f;
|
||||
sp4C[1] = 0.0f;
|
||||
sp4C[2] = 0.0f;
|
||||
viewport_setPosition_vec3f(sp58);
|
||||
viewport_setRotation_vec3f(sp4C);
|
||||
viewport_update();
|
||||
|
||||
// @recomp Record the current projection transform, then set the projection transform ID for the projection determined by the model ID.
|
||||
s32 prev_perspective_projection_transform = cur_perspective_projection_transform_id;
|
||||
if (marker->modelId == ASSET_54D_MODEL_BK_TITLE_LOGO) {
|
||||
cur_perspective_projection_transform_id = PROJECTION_BK_LOGO_TRANSFORM_ID;
|
||||
}
|
||||
else if (marker->modelId == ASSET_54E_MODEL_COPYRIGHT_OVERLAY) {
|
||||
cur_perspective_projection_transform_id = PROJECTION_COPYRIGHT_TRANSFORM_ID;
|
||||
}
|
||||
|
||||
viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx);
|
||||
sp40[0] = 0.0f;
|
||||
sp40[1] = 0.0f;
|
||||
sp40[2] = 0.0f;
|
||||
sp34[0] = 0.0f;
|
||||
sp34[1] = -87.0f;
|
||||
sp34[2] = 0.0f;
|
||||
modelRender_draw(gfx, mtx, sp40, NULL, 1.0f, sp34, marker_loadModelBin(marker));
|
||||
|
||||
// @recomp Restore the previous perpsective projection transform ID.
|
||||
cur_perspective_projection_transform_id = prev_perspective_projection_transform;
|
||||
viewport_restoreState();
|
||||
viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx);
|
||||
return this;
|
||||
}
|
||||
|
||||
// @recomp Patched to set the transform ID for the game over and THE END projections.
|
||||
RECOMP_PATCH Actor *func_802DC320(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){
|
||||
Actor *this;
|
||||
f32 vp_position[3];
|
||||
f32 vp_rotation[3];
|
||||
f32 model_position[3];
|
||||
f32 sp34[3];
|
||||
|
||||
this = marker_getActor(marker);
|
||||
modelRender_preDraw( (GenFunction_1)actor_predrawMethod, (s32)this);
|
||||
modelRender_postDraw((GenFunction_1)actor_postdrawMethod, (s32)marker);
|
||||
viewport_backupState();
|
||||
vp_position[0] = 0.0f;
|
||||
vp_position[1] = 0.0f;
|
||||
vp_position[2] = 937.5f;
|
||||
vp_rotation[0] = 0.0f;
|
||||
vp_rotation[1] = 0.0f;
|
||||
vp_rotation[2] = 0.0f;
|
||||
viewport_setPosition_vec3f(vp_position);
|
||||
viewport_setRotation_vec3f(vp_rotation);
|
||||
viewport_update();
|
||||
|
||||
// @recomp Record the current projection transform, then set the projection transform ID for the projection determined by the model ID.
|
||||
s32 prev_perspective_projection_transform = cur_perspective_projection_transform_id;
|
||||
if (marker->modelId == ASSET_54C_MODEL_GAME_OVER) {
|
||||
cur_perspective_projection_transform_id = PROJECTION_GAME_OVER_TRANSFORM_ID;
|
||||
}
|
||||
else if (marker->modelId == ASSET_56C_MODEL_THE_END) {
|
||||
cur_perspective_projection_transform_id = PROJECTION_THE_END_TRANSFORM_ID;
|
||||
}
|
||||
|
||||
viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx);
|
||||
model_position[0] = 0.0f;
|
||||
model_position[1] = 0.0f;
|
||||
model_position[2] = 0.0f;
|
||||
sp34[0] = 0.0f;
|
||||
sp34[1] = 137.5f;
|
||||
sp34[2] = 0.0f;
|
||||
modelRender_draw(gfx, mtx, model_position, NULL, 1.0f, sp34, marker_loadModelBin(marker));
|
||||
|
||||
// @recomp Restore the previous perpsective projection transform ID.
|
||||
cur_perspective_projection_transform_id = prev_perspective_projection_transform;
|
||||
viewport_restoreState();
|
||||
viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx);
|
||||
return this;
|
||||
}
|
||||
|
||||
// @recomp Patched to set the zoombox portrait's ortho projection transform ID.
|
||||
RECOMP_PATCH void func_803164B0(GcZoombox *this, Gfx **gfx, Mtx **mtx, s32 arg3, s32 arg4, BKSpriteDisplayData *arg5, f32 arg6) {
|
||||
f32 sp2C[3];
|
||||
f32 temp_f12;
|
||||
|
||||
if (this->portrait_id == ZOOMBOX_SPRITE_46_TUMBLAR) {
|
||||
arg6 = 0.75f;
|
||||
}
|
||||
func_80338338(0xFF, 0xFF, 0xFF);
|
||||
func_803382FC(this->unk168 * arg6);
|
||||
func_803382E4(5);
|
||||
func_80335D30(gfx);
|
||||
|
||||
// @recomp Set the ortho projection transform ID for the portrait.
|
||||
cur_ortho_projection_transform_id = PROJECTION_PORTRAIT_TRANSFORM_ID_START + this->portrait_id;
|
||||
|
||||
viewport_setRenderViewportAndOrthoMatrix(gfx, mtx);
|
||||
|
||||
// @recomp Clear the current ortho projection transform ID.
|
||||
cur_ortho_projection_transform_id = 0;
|
||||
|
||||
mlMtxIdent();
|
||||
if (this->unk1A4_24) {
|
||||
mlMtxRotYaw(180.0f);
|
||||
sp2C[0] = (f32) this->unk170 - ((f32) arg3 * this->unk198);
|
||||
} else {
|
||||
sp2C[0] = (f32) this->unk170 + ((f32) arg3 * this->unk198);
|
||||
}
|
||||
sp2C[1] = this->unk172 + ((f32) arg4 * this->unk198);
|
||||
sp2C[2] = -10.0f;
|
||||
func_80252330((sp2C[0] * 4.0f) - ((f32)gFramebufferWidth * 2), ((f32)gFramebufferHeight * 2) - (sp2C[1] * 4.0f), sp2C[2]);
|
||||
temp_f12 = (f32) ((f64) this->unk198 * 0.8);
|
||||
mlMtxScale_xyz(temp_f12, temp_f12, 1.0f);
|
||||
mlMtxApply(*mtx);
|
||||
gSPMatrix((*gfx)++, (*mtx)++, G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
modelRender_setDepthMode(MODEL_RENDER_DEPTH_NONE);
|
||||
func_80344090(arg5, this->unk186, gfx);
|
||||
func_8033687C(gfx);
|
||||
viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "patches.h"
|
||||
#include "transform_ids.h"
|
||||
#include "core1/core1.h"
|
||||
|
||||
typedef struct {
|
||||
s16 model_id;
|
||||
// u8 pad2[0x2];
|
||||
f32 scale;
|
||||
f32 rotation_speed;
|
||||
}SkyInfo;
|
||||
|
||||
typedef struct {
|
||||
s16 map;
|
||||
// u8 pad2[2];
|
||||
SkyInfo sky_list[3];
|
||||
}MapSkyInfo;
|
||||
|
||||
extern struct
|
||||
{
|
||||
MapSkyInfo *sky_info;
|
||||
BKModel *model[3];
|
||||
BKModelBin *model_bins[3];
|
||||
f32 timer;
|
||||
} gcSky;
|
||||
|
||||
// @recomp Patched to tag the skybox projection and skybox models.
|
||||
RECOMP_PATCH void sky_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx){
|
||||
int i;
|
||||
f32 position[3];
|
||||
f32 rotation[3];
|
||||
BKModelBin *iAsset;
|
||||
|
||||
viewport_setNearAndFar(5.0f, 15000.0f);
|
||||
if(gcSky.model_bins[0]){
|
||||
drawRectangle2D(gfx, 0, 0, (s32)(f32) gFramebufferWidth, (s32)(f32)gFramebufferHeight,0, 0, 0); //fill screen with black
|
||||
// @recomp Set the skybox projection matrix group.
|
||||
gEXMatrixGroupSimpleNormal((*gfx)++, PROJECTION_SKYBOX_TRANSFORM_ID, G_EX_PUSH, G_MTX_PROJECTION, G_EX_EDIT_NONE);
|
||||
|
||||
viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx);
|
||||
viewport_getPosition_vec3f(position);
|
||||
for(i = 0; i < 3; i++){
|
||||
iAsset = gcSky.model_bins[i];
|
||||
if(iAsset){
|
||||
rotation[0] = 0.0f;
|
||||
rotation[1] = gcSky.sky_info->sky_list[i].rotation_speed * gcSky.timer;
|
||||
rotation[2] = 0.0f;
|
||||
|
||||
// @recomp Set the model transform ID before drawing the skybox.
|
||||
cur_drawn_model_transform_id = SKYBOX_TRANSFORM_ID_START + SKYBOX_MODEL_TRANSFORM_ID_COUNT * i;
|
||||
|
||||
modelRender_draw(gfx, mtx, position, rotation, gcSky.sky_info->sky_list[i].scale, NULL, iAsset);
|
||||
|
||||
// @recomp Clear the model transform ID after drawing the skybox.
|
||||
cur_drawn_model_transform_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// @recomp Pop the skybox projection matrix group.
|
||||
gEXPopMatrixGroup((*gfx)++, G_MTX_PROJECTION);
|
||||
}
|
||||
else{//L8030B200
|
||||
drawRectangle2D(gfx, 0, 0, (s32)(f32) gFramebufferWidth, (s32)(f32)gFramebufferHeight, 0, 0, 0);
|
||||
}//L8030B254
|
||||
}
|
||||
@@ -34,3 +34,4 @@ strlen_recomp = 0x8F000074;
|
||||
osVirtualToPhysical_recomp = 0x8F000078;
|
||||
osPiStartDma_recomp = 0x8F00007C;
|
||||
recomp_abort = 0x8F000080;
|
||||
recomp_get_target_aspect_ratio = 0x8F000084;
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
#define PROJECTION_TRANSITION_TRANSFORM_ID 0x00001002
|
||||
#define PROJECTION_PRESS_START_TRANSFORM_ID 0x00001003
|
||||
#define PROJECTION_BOTTLES_BONUS_TRANSFORM_ID 0x00001004
|
||||
#define PROJECTION_BK_LOGO_TRANSFORM_ID 0x00001005
|
||||
#define PROJECTION_COPYRIGHT_TRANSFORM_ID 0x00001006
|
||||
#define PROJECTION_GAME_OVER_TRANSFORM_ID 0x00001007
|
||||
#define PROJECTION_THE_END_TRANSFORM_ID 0x00001008
|
||||
#define PROJECTION_PORTRAIT_TRANSFORM_ID_START 0x00001100 // 1 for each portrait ID
|
||||
|
||||
#define MAP_MODEL_OPA_TRANSFORM_ID_START 0x00801000
|
||||
|
||||
@@ -6,11 +6,20 @@
|
||||
#include "core1/mlmtx.h"
|
||||
#include "functions.h"
|
||||
|
||||
bool skip_all_interpolation = FALSE;
|
||||
bool has_additional_model_scale = FALSE;
|
||||
f32 additional_model_scale_x;
|
||||
f32 additional_model_scale_y;
|
||||
f32 additional_model_scale_z;
|
||||
|
||||
void set_all_interpolation_skipped(bool skipped) {
|
||||
skip_all_interpolation = skipped;
|
||||
}
|
||||
|
||||
bool all_interpolation_skipped() {
|
||||
return skip_all_interpolation;
|
||||
}
|
||||
|
||||
void set_additional_model_scale(f32 x, f32 y, f32 z) {
|
||||
has_additional_model_scale = TRUE;
|
||||
additional_model_scale_x = x;
|
||||
@@ -54,8 +63,8 @@ RECOMP_PATCH void func_803387F8(Gfx **gfx, Mtx **mtx, void *arg2){
|
||||
mlMtxApply(*mtx);
|
||||
gSPMatrix((*gfx)++, (*mtx)++, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
if (cur_drawn_model_transform_id == -1) {
|
||||
// @recomp Skip interpolation if the transform id is -1.
|
||||
if (skip_all_interpolation || cur_drawn_model_transform_id == -1) {
|
||||
// @recomp Skip interpolation if all interpolation is currently skipped or the transform id is -1.
|
||||
gEXMatrixGroupNoInterpolate((*gfx)++, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_ALLOW);
|
||||
}
|
||||
else if (cur_drawn_model_transform_id != 0) {
|
||||
@@ -449,7 +458,11 @@ RECOMP_PATCH BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3],
|
||||
gSPMatrix((*gfx)++, (*mtx)++, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
// @recomp Create a matrix group if a transform id is set.
|
||||
if (cur_drawn_model_transform_id != 0) {
|
||||
if (skip_all_interpolation || cur_drawn_model_transform_id == -1) {
|
||||
// @recomp Skip interpolation if all interpolation is currently skipped or the transform id is -1.
|
||||
gEXMatrixGroupNoInterpolate((*gfx)++, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_ALLOW);
|
||||
}
|
||||
else if (cur_drawn_model_transform_id != 0) {
|
||||
gEXMatrixGroupDecomposedVerts((*gfx)++, cur_drawn_model_transform_id, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_ALLOW);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user