Files
wii-ipl/src/scene/setting/iplSensitivity.cpp
coah 90e7b0ff2c iplSensitivity: suppress inline Rect dtor weak (#641)
Define IPL_CONTROLLER_TRIVIAL_RECT_DTOR so this TU no longer emits
~nw4r::ut::Rect. Compiled .text becomes byte-identical to the extract
(1112 bytes). Matching still blocked on .sdata2 layout (48 vs 56).

Co-authored-by: linker <linker@users.noreply.github.com>
2026-10-01 18:33:24 -05:00

90 lines
3.5 KiB
C++

#define IPL_CONTROLLER_TRIVIAL_RECT_DTOR
#include <nw4r/ut/Rect.h>
#undef IPL_CONTROLLER_TRIVIAL_RECT_DTOR
#include "system/iplSystem.h"
#include "system/iplNand.h"
#include "utility/iplGraphics.h"
#include <revolution/tpl.h>
extern "C" {
WPADStatus* KPADGetWPADRingBuffer(s32 channel);
WPADFSStatus* KPADGetWPADFSRingBuffer(s32 channel);
WPADCLStatus* KPADGetWPADCLRingBuffer(s32 channel);
}
namespace ipl {
class SensitivityDrawing {
public:
static void draw(nand::File* texture);
};
void SensitivityDrawing::draw(nand::File* texture) {
GXRenderModeObj renderMode = *System::getRenderModeObj();
nw4r::ut::Rect projection;
System::getProjectionRect(&projection);
GXColor background = {96, 96, 96, 192};
u32 scissorX, scissorY, scissorWidth, scissorHeight;
GXGetScissor(&scissorX, &scissorY, &scissorWidth, &scissorHeight);
f32 projectionWidth = projection.GetWidth();
f32 projectionHeight = projection.GetHeight();
f32 halfWidth = 0.5f * projectionWidth;
f32 scaleX = renderMode.fbWidth / projectionWidth;
f32 scaleY = renderMode.efbHeight / projectionHeight;
f32 halfHeight = 0.5f * projectionHeight;
utility::Graphics::setDefaultOrtho(0);
projectionHeight = projection.GetHeight();
projectionWidth = projection.GetWidth();
GXSetScissor(scaleX * (0.5f * projection.left + halfWidth),
scaleY * (-45.0f + (0.5f * projection.top + halfHeight)),
scaleX * (0.5f * projectionWidth),
scaleY * (0.5f * projectionHeight));
utility::Graphics::drawPolygon(projection, background);
controller::Interface* controller = System::getYoungController();
if (controller != NULL && controller->getKPADStatus() != NULL) {
GXTexObj image;
TPLGetGXTexObjFromPalette((TPLPalette*)texture->getBuffer(), &image, 1);
GXInitTexObjWrapMode(&image, GX_MIRROR, GX_MIRROR);
f32 width = projection.GetWidth();
f32 height = projection.GetHeight();
f32 horizontalScale = (0.5f * width) / 1024.0f;
f32 verticalScale = (0.5f * height) / 768.0f;
int sample = WPADGetLatestIndexInBuf(controller->getChannel());
DPDObject* object;
DPDObject* first;
switch (controller->getType()) {
case 0: {
WPADStatus* status = KPADGetWPADRingBuffer(controller->getChannel()) + sample;
object = &status->obj[3];
first = &status->obj[0];
break;
}
case 1: {
WPADFSStatus* status = KPADGetWPADFSRingBuffer(controller->getChannel()) + sample;
object = &status->obj[3];
first = &status->obj[0];
break;
}
case 2: {
WPADCLStatus* status = KPADGetWPADCLRingBuffer(controller->getChannel()) + sample;
object = &status->obj[3];
first = &status->obj[0];
break;
}
}
do {
if (object->size != 0) {
f32 radius = 0.15f * (object->size + 25);
f32 x = (object->x - 512) * horizontalScale;
f32 y = (object->y - 384) * verticalScale;
GXColor foreground = {255, 255, 255, 255};
nw4r::ut::Rect rectangle(x - radius, -y + radius - -45.0f,
x + radius, -y - radius - -45.0f);
utility::Graphics::drawTexture(rectangle, image, foreground, 2, utility::Graphics::ORI_NONE);
}
} while (--object >= first);
}
GXSetScissor(scissorX, scissorY, scissorWidth, scissorHeight);
}
}