mirror of
https://github.com/Mr-Wiseguy/Zelda64Recomp.git
synced 2024-11-26 14:44:19 +01:00
Added mechanism for getting aspect ratio from recompiled code, fixed wipe3 transition in widescreen
This commit is contained in:
parent
b6cec905c7
commit
99c14fde04
@ -55,6 +55,7 @@ namespace recomp {
|
|||||||
|
|
||||||
void destroy_ui();
|
void destroy_ui();
|
||||||
void apply_color_hack();
|
void apply_color_hack();
|
||||||
|
void get_window_size(int& width, int& height);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
8
patches/graphics.h
Normal file
8
patches/graphics.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef __PATCH_GRAPHICS_H__
|
||||||
|
#define __PATCH_GRAPHICS_H__
|
||||||
|
|
||||||
|
#include "patch_helpers.h"
|
||||||
|
|
||||||
|
DECLARE_FUNC(float, recomp_get_aspect_ratio);
|
||||||
|
|
||||||
|
#endif
|
@ -8,3 +8,4 @@ recomp_handle_quicksave_actions_main = 0x8100000C;
|
|||||||
osRecvMesg_recomp = 0x81000010;
|
osRecvMesg_recomp = 0x81000010;
|
||||||
osSendMesg_recomp = 0x81000014;
|
osSendMesg_recomp = 0x81000014;
|
||||||
recomp_get_gyro_deltas = 0x81000018;
|
recomp_get_gyro_deltas = 0x81000018;
|
||||||
|
recomp_get_aspect_ratio = 0x8100001C;
|
||||||
|
43
patches/widescreen_effect_fixes.c
Normal file
43
patches/widescreen_effect_fixes.c
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#include "patches.h"
|
||||||
|
#include "graphics.h"
|
||||||
|
|
||||||
|
extern TransitionOverlay gTransitionOverlayTable[];
|
||||||
|
extern Gfx sTransWipe3DL[];
|
||||||
|
|
||||||
|
#define THIS ((TransitionWipe3*)thisx)
|
||||||
|
// @recomp patched to scale the transition based on aspect ratio
|
||||||
|
void TransitionWipe3_Draw(void* thisx, Gfx** gfxP) {
|
||||||
|
Gfx* gfx = *gfxP;
|
||||||
|
Mtx* modelView = &THIS->modelView[THIS->frame];
|
||||||
|
f32 scale = 14.8f;
|
||||||
|
Gfx* texScroll;
|
||||||
|
|
||||||
|
// @recomp Modify the scale based on the aspect ratio to make sure the transition circle covers the whole screen
|
||||||
|
scale *= (recomp_get_aspect_ratio() / (4.0f / 3.0f));
|
||||||
|
|
||||||
|
THIS->frame ^= 1;
|
||||||
|
gDPPipeSync(gfx++);
|
||||||
|
texScroll = Gfx_BranchTexScroll(&gfx, THIS->scrollX, THIS->scrollY, 16, 64);
|
||||||
|
gSPSegment(gfx++, 0x09, texScroll);
|
||||||
|
gSPSegment(gfx++, 0x08, THIS->curTexture);
|
||||||
|
gDPSetColor(gfx++, G_SETPRIMCOLOR, THIS->color.rgba);
|
||||||
|
gDPSetColor(gfx++, G_SETENVCOLOR, THIS->color.rgba);
|
||||||
|
gSPMatrix(gfx++, &THIS->projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||||
|
gSPPerspNormalize(gfx++, THIS->normal);
|
||||||
|
gSPMatrix(gfx++, &THIS->lookAt, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
|
||||||
|
|
||||||
|
if (scale != 1.0f) {
|
||||||
|
guScale(modelView, scale, scale, 1.0f);
|
||||||
|
gSPMatrix(gfx++, modelView, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||||
|
}
|
||||||
|
// sTransWipe3DL is an overlay symbol, so its addresses need to be offset to get the actual loaded vram address.
|
||||||
|
// TODO remove this once the recompiler is able to handle overlay symbols automatically for patch functions.
|
||||||
|
ptrdiff_t reloc_offset;
|
||||||
|
TransitionOverlay* overlay_entry = &gTransitionOverlayTable[FBDEMO_WIPE3];
|
||||||
|
reloc_offset = (uintptr_t)Lib_PhysicalToVirtual(overlay_entry->loadInfo.addr) - (uintptr_t)overlay_entry->vramStart;
|
||||||
|
gSPDisplayList(gfx++, (Gfx*)((u8*)sTransWipe3DL + reloc_offset));
|
||||||
|
gDPPipeSync(gfx++);
|
||||||
|
*gfxP = gfx;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef THIS
|
@ -4,6 +4,7 @@
|
|||||||
#include "recomp_input.h"
|
#include "recomp_input.h"
|
||||||
#include "../ultramodern/ultramodern.hpp"
|
#include "../ultramodern/ultramodern.hpp"
|
||||||
#include "../patches/input.h"
|
#include "../patches/input.h"
|
||||||
|
#include "../patches/graphics.h"
|
||||||
|
|
||||||
// Arrays that hold the mappings for every input for keyboard and controller respectively.
|
// Arrays that hold the mappings for every input for keyboard and controller respectively.
|
||||||
using input_mapping = std::array<recomp::InputField, recomp::bindings_per_input>;
|
using input_mapping = std::array<recomp::InputField, recomp::bindings_per_input>;
|
||||||
@ -127,3 +128,11 @@ extern "C" void recomp_get_gyro_deltas(uint8_t* rdram, recomp_context* ctx) {
|
|||||||
|
|
||||||
recomp::get_gyro_deltas(x_out, y_out);
|
recomp::get_gyro_deltas(x_out, y_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "recomp_ui.h"
|
||||||
|
extern "C" void recomp_get_aspect_ratio(uint8_t* rdram, recomp_context* ctx) {
|
||||||
|
int width, height;
|
||||||
|
recomp::get_window_size(width, height);
|
||||||
|
|
||||||
|
_return(ctx, static_cast<float>(width) / height);
|
||||||
|
}
|
||||||
|
@ -877,6 +877,10 @@ struct {
|
|||||||
// TODO make this not be global
|
// TODO make this not be global
|
||||||
extern SDL_Window* window;
|
extern SDL_Window* window;
|
||||||
|
|
||||||
|
void recomp::get_window_size(int& width, int& height) {
|
||||||
|
SDL_GetWindowSizeInPixels(window, &width, &height);
|
||||||
|
}
|
||||||
|
|
||||||
void init_hook(RT64::RenderInterface* interface, RT64::RenderDevice* device) {
|
void init_hook(RT64::RenderInterface* interface, RT64::RenderDevice* device) {
|
||||||
printf("RT64 hook init\n");
|
printf("RT64 hook init\n");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user