Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/JSystem/J2D/J2DPane.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ struct J2DPane
u8 mColorAlpha; // _0B3
bool mIsInfluencedAlpha; // _0B4
bool mIsConnected; // _0B5
u8 mRotationAxis; // _0B6
char mRotationAxis; // _0B6
u8 mBasePosition; // _0B7
f32 mAngleX; // _0B8
f32 mAngleY; // _0BC
Expand Down
7 changes: 4 additions & 3 deletions include/Kameda/K2DPicture.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#ifndef K2DPICTURE_H
#define K2DPICTURE_H

#include "JSystem/J2D/J2DPicture.h"
#include "JSystem/JGeometry/Box.h"
#include "JSystem/JUtility/TColor.h"

class K2DPicture { // Autogenerated
class K2DPicture : public J2DPicture {
public:
void drawK2D(f32, f32, f32, f32, bool); // 0x8013b9e8
void setTevModeK2D(); // 0x8013bd34
void makeMatrix(f32, f32); // 0x8013c0fc
void makeMatrix(f32 x, f32 y); // 0x8013c0fc
static u8 mK2DGlobalAlpha; // 0x804145a8
// Inline/Unused
void drawOutK2D(const JGeometry::TBox2f &, const JGeometry::TBox2f &);
~K2DPicture();
// Inline
void getNewColor(JUTColor *); // 0x8013bbf8
void getNewColor(JUTColor colors[4]); // 0x8013bbf8
}; // class K2DPicture
#endif // K2DPICTURE_H
186 changes: 182 additions & 4 deletions src/Kameda/K2DPicture.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,187 @@
#include "Kameda/K2DPicture.h"

void K2DPicture::drawK2D(float, float, float, float, bool) {}
#include "dolphin/gx/GXEnum.h"
#include "dolphin/gx/GXGeometry.h"
#include "dolphin/gx/GXLighting.h"
#include "dolphin/gx/GXPixel.h"
#include "dolphin/gx/GXStruct.h"
#include "dolphin/gx/GXTev.h"
#include "dolphin/mtx.h"

void K2DPicture::getNewColor(JUTColor *) {}
static const f32 sZeroDegreeAngle = 0.f;
static const f32 sDegToRad = 0.017453292f;

void K2DPicture::setTevModeK2D() {}
u8 K2DPicture::mK2DGlobalAlpha = 0xFF;

void K2DPicture::makeMatrix(f32, f32) {}
void K2DPicture::drawK2D(float, float, float, float, bool) {

if(!mIsVisible)
{
return;
}
JUTColor color;
GXSetNumTexGens(0);

getNewColor(&color);
}

void K2DPicture::getNewColor(JUTColor colors[4]) {
colors[0].r = mCornerColors[0].r;
colors[0].g = mCornerColors[0].g;
colors[0].b = mCornerColors[0].b;
colors[0].a = mCornerColors[0].a;

colors[1].r = mCornerColors[1].r;
colors[1].g = mCornerColors[1].g;
colors[1].b = mCornerColors[1].b;
colors[1].a = mCornerColors[1].a;

colors[2].r = mCornerColors[2].r;
colors[2].g = mCornerColors[2].g;
colors[2].b = mCornerColors[2].b;
colors[2].a = mCornerColors[2].a;

colors[3].r = mCornerColors[3].r;
colors[3].g = mCornerColors[3].g;
colors[3].b = mCornerColors[3].b;
colors[3].a = mCornerColors[3].a;

if(mColorAlpha != 0xFF)
{
colors[0].a = (colors[0].a * mColorAlpha / 0xFF);
colors[1].a = (colors[1].a * mColorAlpha / 0xFF);
colors[2].a = (colors[2].a * mColorAlpha / 0xFF);
colors[3].a = (colors[3].a * mColorAlpha / 0xFF);
}

if(mK2DGlobalAlpha == 0xFF)
{
return;
}
colors[0].a = ((colors[0].a * mK2DGlobalAlpha) / 0xFF);
colors[1].a = ((colors[1].a * mK2DGlobalAlpha) / 0xFF);
colors[2].a = ((colors[2].a * mK2DGlobalAlpha) / 0xFF);
colors[3].a = ((colors[3].a * mK2DGlobalAlpha) / 0xFF);
}

void K2DPicture::setTevModeK2D() {
bool test = false;
bool test_2 = false;
u32 numStages;

if(mBlack != 0 || mWhite != -1)
{
test = true;
}

if (mColorAlpha != 0xff ||
mCornerColors[0] != -1 ||
mCornerColors[1] != -1 ||
mCornerColors[2] != -1 ||
mCornerColors[3] != -1 ||
K2DPicture::mK2DGlobalAlpha != 0xff)
{
test_2 = true;
}

if(!test_2) {
if(!test){
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_TEXC, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO);

if ((s32)mTextures[0]->getTexInfo()->mTransparency != 0) {
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_TEXA, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO);
} else {
s32 white = -1;
GXSetTevColor(GX_TEVREG2, *(GXColor*)(&white));
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A2, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO);
}

numStages = 1;
}
else {
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);

GXSetTevColor(GX_TEVREG0, mBlack);
GXSetTevColor(GX_TEVREG1, mWhite);
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_C0, GX_CC_C1, GX_CC_TEXC, GX_CC_ZERO);

if ((s32)mTextures[0]->getTexInfo()->mTransparency != 0) {
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_A1, GX_CA_TEXA, GX_CA_ZERO);
} else {
s32 white = -1;
GXSetTevColor(GX_TEVREG2, *(GXColor*)(&white));
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_A1, GX_CA_A2, GX_CA_ZERO);
}

numStages = 1;
}
} else {
if (!test)
{
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_RASC, GX_CC_ZERO);

if ((s32)mTextures[0]->getTexInfo()->mTransparency != 0) {
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_RASA, GX_CA_ZERO);
} else {
s32 white = -1;
GXSetTevColor(GX_TEVREG2, *(GXColor*)(&white));
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_A0, GX_CA_RASA, GX_CA_ZERO);
}

numStages = 1;
} else {

GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);

GXSetTevColor(GX_TEVREG0, *(GXColor*)&mBlack);
GXSetTevColor(GX_TEVREG1, *(GXColor*)&mWhite);
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_C0, GX_CC_C1, GX_CC_TEXC, GX_CC_ZERO);

if ((s32)mTextures[0]->getTexInfo()->mTransparency != 0) {
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_A1, GX_CA_TEXA, GX_CA_ZERO);
} else {
s32 white = -1;
GXSetTevColor(GX_TEVREG2, *(GXColor*)(&white));
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_A1, GX_CA_A2, GX_CA_ZERO);
}

GXSetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_CPREV, GX_CC_RASC, GX_CC_ZERO);
GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_APREV, GX_CA_RASA, GX_CA_ZERO);

numStages = 2;
}
}

GXSetNumTevStages(numStages);
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
GXSetNumChans(1);
}

void K2DPicture::makeMatrix(f32 x, f32 y) {
Mtx _matrix_1;
Mtx _matrix_2;
Mtx _matrix_3;
if (mAngleZ != sZeroDegreeAngle) {
PSMTXTrans(_matrix_1, -mAnchorPoint.x, -mAnchorPoint.y, sZeroDegreeAngle);

f32 degree;
if (mRotationAxis == J2DROTATE_Z) {
degree = -mAngleZ;
} else {
degree = mAngleZ;
}

PSMTXRotRad(_matrix_2, mRotationAxis, degree * sDegToRad);

PSMTXTrans(_matrix_3, mAnchorPoint.x + x, mAnchorPoint.y + y, sZeroDegreeAngle);

PSMTXConcat(_matrix_2, _matrix_1, mPositionMtx);

PSMTXConcat(_matrix_3, mPositionMtx, mPositionMtx);
} else {
PSMTXTrans(mPositionMtx, x, y, sZeroDegreeAngle);
}
}
Loading