Fixed cannon circle

This commit is contained in:
KiritoDv
2026-01-08 20:23:40 -06:00
parent 27f55e1e11
commit dbe51e6c0e
4 changed files with 135 additions and 13 deletions
+12 -11
View File
@@ -253,8 +253,8 @@ s32 render_screen_transition(s8 fadeTimer, s8 transType, u8 transTime, struct Wa
}
Gfx* render_cannon_circle_base(void) {
Vtx* verts = alloc_display_list(8 * sizeof(*verts));
Gfx* dlist = alloc_display_list(20 * sizeof(*dlist));
Vtx* verts = alloc_display_list(4 * sizeof(*verts));
Gfx* dlist = alloc_display_list(35 * sizeof(*dlist));
Gfx* g = dlist;
if (verts != NULL && dlist != NULL) {
@@ -263,11 +263,16 @@ Gfx* render_cannon_circle_base(void) {
make_vertex(verts, 2, SCREEN_WIDTH, SCREEN_HEIGHT, -1, 1152, 192, 0, 0, 0, 255);
make_vertex(verts, 3, 0, SCREEN_HEIGHT, -1, -1152, 192, 0, 0, 0, 255);
// Render black rectangles outside the 4:3 area.
make_vertex(verts, 4, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), 0, -1, 0, 0, 0, 0, 0, 255);
make_vertex(verts, 5, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), 0, -1, 0, 0, 0, 0, 0, 255);
make_vertex(verts, 6, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), SCREEN_HEIGHT, -1, 0, 0, 0, 0, 0, 255);
make_vertex(verts, 7, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), SCREEN_HEIGHT, -1, 0, 0, 0, 0, 0, 255);
gDPPipeSync(g++);
gDPSetPrimColor(g++, 0, 0, 0, 0, 0, 255);
gDPSetColorDither(g++, G_CD_NOISE);
gDPSetAlphaDither(g++, G_AD_NOISE);
gDPSetCycleType(g++, G_CYC_1CYCLE);
gDPSetCombineMode(g++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
gDPSetRenderMode(g++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
gDPFillWideRectangle(g++, OTRGetRectDimensionFromLeftEdge(0), 0, 0, SCREEN_HEIGHT);
gDPFillWideRectangle(g++, SCREEN_WIDTH, 0,
OTRGetRectDimensionFromRightEdge(0), SCREEN_HEIGHT);
gSPDisplayList(g++, dl_proj_mtx_fullscreen);
gDPSetCombineMode(g++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
@@ -278,10 +283,6 @@ Gfx* render_cannon_circle_base(void) {
gSPVertex(g++, VIRTUAL_TO_PHYSICAL(verts), 4, 0);
gSPDisplayList(g++, dl_draw_quad_verts_0123);
gSPTexture(g++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF);
gDPSetCombineMode(g++, G_CC_SHADE, G_CC_SHADE);
gSPVertex(g++, VIRTUAL_TO_PHYSICAL(verts + 4), 4, 4);
gSP2Triangles(g++, 4, 0, 3, 0, 4, 3, 7, 0);
gSP2Triangles(g++, 1, 5, 6, 0, 1, 6, 2, 0);
gSPDisplayList(g++, dl_screen_transition_end);
gSPEndDisplayList(g);
} else {
+100
View File
@@ -35,6 +35,7 @@
#include <ship/resource/factory/BlobFactory.h>
#include <ship/utils/StringHelper.h>
#include <ship/resource/ResourceType.h>
#include <ship/window/gui/resource/Font.h>
#include "importer/AssetArrayFactory.h"
#include "port/importer/GenericArrayFactory.h"
@@ -692,4 +693,103 @@ extern "C" Animation* GameEngine_LoadAnimation(const uint32_t animId) {
return nullptr;
}
return engine->animationsTable[animId];
}
// Gets the width of the main ImGui window
extern "C" uint32_t OTRGetCurrentWidth() {
return GameEngine::Instance->context->GetWindow()->GetWidth();
}
// Gets the height of the main ImGui window
extern "C" uint32_t OTRGetCurrentHeight() {
return GameEngine::Instance->context->GetWindow()->GetHeight();
}
extern "C" float OTRGetHUDAspectRatio() {
if (CVarGetInteger("gHUDAspectRatio.Enabled", 0) == 0 || CVarGetInteger("gHUDAspectRatio.X", 0) == 0 || CVarGetInteger("gHUDAspectRatio.Y", 0) == 0) {
return GameEngine_GetAspectRatio();
}
return ((float)CVarGetInteger("gHUDAspectRatio.X", 1) / (float)CVarGetInteger("gHUDAspectRatio.Y", 1));
}
extern "C" float OTRGetDimensionFromLeftEdge(float v) {
auto interpreter = GameEngine_GetInterpreter();
return (interpreter->mNativeDimensions.width / 2 - interpreter->mNativeDimensions.height / 2 * interpreter->mCurDimensions.aspect_ratio + (v));
}
extern "C" float OTRGetDimensionFromRightEdge(float v) {
auto interpreter = GameEngine_GetInterpreter();
return (interpreter->mNativeDimensions.width / 2 + interpreter->mNativeDimensions.height / 2 * interpreter->mCurDimensions.aspect_ratio - (v));
}
extern "C" float OTRGetDimensionFromLeftEdgeForcedAspect(float v, float aspectRatio) {
auto interpreter = GameEngine_GetInterpreter();
return (interpreter->mNativeDimensions.width / 2 - interpreter->mNativeDimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : interpreter->mCurDimensions.aspect_ratio) + (v));
}
extern "C" float OTRGetDimensionFromRightEdgeForcedAspect(float v, float aspectRatio) {
auto interpreter = GameEngine_GetInterpreter();
return (interpreter->mNativeDimensions.width / 2 + interpreter->mNativeDimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : interpreter->mCurDimensions.aspect_ratio) - (v));
}
extern "C" float OTRGetDimensionFromLeftEdgeOverride(float v) {
return OTRGetDimensionFromLeftEdgeForcedAspect(v, OTRGetHUDAspectRatio());
}
extern "C" float OTRGetDimensionFromRightEdgeOverride(float v) {
return OTRGetDimensionFromRightEdgeForcedAspect(v, OTRGetHUDAspectRatio());
}
// Gets the width of the current render target area
extern "C" uint32_t OTRGetGameRenderWidth() {
auto interpreter = GameEngine_GetInterpreter();
return interpreter->mCurDimensions.width;
}
// Gets the height of the current render target area
extern "C" uint32_t OTRGetGameRenderHeight() {
auto interpreter = GameEngine_GetInterpreter();
return interpreter->mCurDimensions.height;
}
extern "C" int16_t OTRGetRectDimensionFromLeftEdge(float v) {
return ((int) floorf(OTRGetDimensionFromLeftEdge(v)));
}
extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v) {
return ((int) ceilf(OTRGetDimensionFromRightEdge(v)));
}
extern "C" int16_t OTRGetRectDimensionFromLeftEdgeForcedAspect(float v, float aspectRatio) {
return ((int) floorf(OTRGetDimensionFromLeftEdgeForcedAspect(v, aspectRatio)));
}
extern "C" int16_t OTRGetRectDimensionFromRightEdgeForcedAspect(float v, float aspectRatio) {
return ((int) ceilf(OTRGetDimensionFromRightEdgeForcedAspect(v, aspectRatio)));
}
extern "C" int16_t OTRGetRectDimensionFromLeftEdgeOverride(float v) {
return OTRGetRectDimensionFromLeftEdgeForcedAspect(v, OTRGetHUDAspectRatio());
}
extern "C" int16_t OTRGetRectDimensionFromRightEdgeOverride(float v) {
return OTRGetRectDimensionFromRightEdgeForcedAspect(v, OTRGetHUDAspectRatio());
}
extern "C" int32_t OTRConvertHUDXToScreenX(int32_t v) {
auto interpreter = GameEngine_GetInterpreter();
float gameAspectRatio = interpreter->mCurDimensions.aspect_ratio;
int32_t gameHeight = interpreter->mCurDimensions.height;
int32_t gameWidth = interpreter->mCurDimensions.width;
float hudAspectRatio = 4.0f / 3.0f;
int32_t hudHeight = gameHeight;
int32_t hudWidth = hudHeight * hudAspectRatio;
float hudScreenRatio = (hudWidth / 320.0f);
float hudCoord = v * hudScreenRatio;
float gameOffset = (gameWidth - hudWidth) / 2;
float gameCoord = hudCoord + gameOffset;
float gameScreenRatio = (320.0f / gameWidth);
float screenScaledCoord = gameCoord * gameScreenRatio;
int32_t screenScaledCoordInt = screenScaledCoord;
return screenScaledCoordInt;
}
+22 -1
View File
@@ -75,11 +75,32 @@ Fast::Interpreter* GameEngine_GetInterpreter();
extern "C" {
#endif
// HUD and Rendering related
float GameEngine_GetAspectRatio();
uint32_t OTRGetCurrentWidth(void);
uint32_t OTRGetCurrentHeight(void);
float OTRGetHUDAspectRatio();
int32_t OTRConvertHUDXToScreenX(int32_t v);
float OTRGetDimensionFromLeftEdge(float v);
float OTRGetDimensionFromRightEdge(float v);
int16_t OTRGetRectDimensionFromLeftEdge(float v);
int16_t OTRGetRectDimensionFromRightEdge(float v);
float OTRGetDimensionFromLeftEdgeForcedAspect(float v, float aspectRatio);
float OTRGetDimensionFromRightEdgeForcedAspect(float v, float aspectRatio);
int16_t OTRGetRectDimensionFromLeftEdgeForcedAspect(float v, float aspectRatio);
int16_t OTRGetRectDimensionFromRightEdgeForcedAspect(float v, float aspectRatio);
float OTRGetDimensionFromLeftEdgeOverride(float v);
float OTRGetDimensionFromRightEdgeOverride(float v);
int16_t OTRGetRectDimensionFromLeftEdgeOverride(float v);
int16_t OTRGetRectDimensionFromRightEdgeOverride(float v);
uint32_t OTRGetGameRenderWidth();
uint32_t OTRGetGameRenderHeight();
// Engine related
void GameEngine_ProcessGfxCommands(Gfx* commands);
uint32_t GameEngine_GetInterpolatedFPS();
uint32_t GameEngine_GetSampleRate();
uint32_t GameEngine_GetSamplesPerFrame();
float GameEngine_GetAspectRatio();
struct CtlEntry* GameEngine_LoadBank(uint8_t bankId);
uint8_t GameEngine_IsBankLoaded(uint8_t bankId);
void GameEngine_UnloadBank(uint8_t bankId);
+1 -1
View File
@@ -46,7 +46,7 @@ void DrawFlagTableArray32(const FlagTable& flagTable, uint16_t row, uint32_t& fl
ImGui::PopStyleColor();
if (ImGui::IsItemHovered() && hasDescription) {
ImGui::BeginTooltip();
ImGui::Text("%s", UIWidgets::WrappedText(flagTable.flagDescriptions.at(flagIndex), 60));
ImGui::Text("%s", UIWidgets::WrappedText(flagTable.flagDescriptions.at(flagIndex), 60).c_str());
ImGui::EndTooltip();
}
ImGui::PopID();