mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-12 21:45:19 -04:00
00ed9402cd
* fix kankyo UB
* Fix TEV Stage DL writing
BE issue
* BE Fixes in materials/shapes
* Move to Aurora GD impl
* JUTDataFileHeader
* j3d: load vertex and texture not through GD
* Endian swap vertex data (mostly)
* Just exit(0) when closing the game
Fix crashes :godo:
* fix fopAcM_ct_placement and remove memcpy
* J3D: track vertex arrays correctly, swap work
* fix visibility, turn off overridden new/delete when we call into aurora
* event: cut name be
* Default window improvements
Double size, allow OS to decide position
* survive TParse::parseHeader_next
* color swap fix
* swap endian/fixes oob function pointer
* Remove GXGetViewportv stub
Aurora has it now
* Set array pointers via GD again
Relies on https://github.com/encounter/aurora/pull/35
* Let Aurora decide graphics backend
* disable procbar drawing
* Fix TColor endianness conversion issues
Fixes the wrong color for the flashing logo
* cam param swap
* simplify vtx loading, mat/amb color fix
* endian swap stb/fvb data
* aurora stat changes
* fix storage buffer crash
dont unnecessarily reassign vertex buffers in a way that forces aurora to recache things
* set bgobj spec fix
* add camera debug, endian swap more stb data, d_a_bg_obj::spec_data_c swapped
* JKRExpHeap: fix bad allocator slowdown
* solid tex
* texture caching
* log level
* fix window aspect ratio, disable bloom, endian swap camera type data
camera is now actually playing opening cutscene!!!!
* add GXDestroyTexObj to a couple stack init'd GXTexObjs, remove some diag printfs
* endian swap joint weight envelope data
* move to dusk config
* verbose arg errors
* better stub logging (for now)
* less logging, more BE
* more stubbing, move logging stuff around
* move all logging to aurora logging
* fix STUB_LOG, __FUNCTION__ isn't a string literal, wasn't building as it
was.
* update aurora
* fix heap alignment mismatch and always head align for now
* prevent them from fucking up my shit
* forward jut warning to DuskLog
* remove report logging
* maybe and i must emphasize maybe fix JMessage parsing
* this was a dumb idea
* preserve negative alignment for JKRHeap
* use normal free on macos and linux
* ^
* fix JMAHermiteInterpolation c impl
* endian swap J2DScreen mColor (oops)
* swap more J3D anim data, remove weird pointer addr check in J3DMaterial getMaterialAnm
* typo fix
* Fix aligned_alloc() size issues on POSIX
aligned_alloc() requires its input size to be a multiple of alignment. This wasn't being upheld so there were allocation failures in init code that made the game fail to start outside Windows.
Also just cleaned up some of this code a bit and removed fallback cases that *shouldn't* get hit.
* _Exit instead of exit()
Seriously I don't want destructors to run. Let the OS reclaim that shit.
* Reapply "Isolate JKRHeap operator overloads" (#39)
This reverts commit 78d4169929.
* Fix some oopsies
* Fix hardcoded pointer size in JUTCacheFont::allocArray
* More operator overload fixes
Add void template specialization for jkrDelete
Add new[] placement overload. Apparently.
* Fix delete macros on nullptr
TIL C++ allows that.
* fix delete[]
* fix new(std::nothrow) overload
* fix avoid ub
* swap remaining anim data needed for title logo
* get rid of op 7
* move aurora_end_frame to correct spot
* juttexture destroy tex
* j2d animation be
* shutdown crash
* link warp material fix
* mDoExt_3DlineMat1_c fix
* hacky keyboard controls
* endian swap J2DResReference, add kb_pad to files.cmake
* fix some missing endian swaps in J2D, remove addr alignment check
* Remove heap unsetting in aurora calls
Never worked properly and not the right solution even if it did
* Don't print in DC stubs
They're fine to never implement
* Fix alignment stuff again
* Compile GF from dolphin lib
Doesn't seem to break anything and shuts up some stub warnings
* j3dtexture tlut obj fix
* addTexMtxIndexInDL fix
* don't recreate null tex data every frame
* the actual fix i wanted to push
* its kinda fakematch city over here
* insert hte efb copy
* limited window size / viewport support
* IsDelete FIX
---------
Co-authored-by: madeline <qwertytrogi@gmail.com>
Co-authored-by: Jasper St. Pierre <jstpierre@mecheye.net>
Co-authored-by: Jeffrey Crowell <jeff@crowell.biz>
Co-authored-by: TakaRikka <takarikka@outlook.com>
Co-authored-by: CraftyBoss <talibabdulmaalik@gmail.com>
Co-authored-by: Lurs <l_werdes@gmx.de>
872 lines
24 KiB
C++
872 lines
24 KiB
C++
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
|
|
|
#include "JSystem/J2DGraph/J2DPane.h"
|
|
#include "JSystem/J2DGraph/J2DAnimation.h"
|
|
#include "JSystem/J2DGraph/J2DOrthoGraph.h"
|
|
#include "JSystem/J2DGraph/J2DScreen.h"
|
|
#include "JSystem/J3DGraphBase/J3DTransform.h"
|
|
#include "JSystem/JSupport/JSURandomInputStream.h"
|
|
#include "JSystem/JUtility/JUTResource.h"
|
|
#ifndef __MWERKS__
|
|
#include "dusk/math.h"
|
|
#endif
|
|
|
|
J2DPane::J2DPane() : mBounds(), mGlobalBounds(), mClipRect(), mPaneTree(this) {
|
|
mTransform = NULL;
|
|
mKind = 'PAN1';
|
|
mVisible = true;
|
|
mInfoTag = 0;
|
|
mUserInfoTag = 0;
|
|
mBounds.set(0, 0, 0, 0);
|
|
initiate();
|
|
changeUseTrans(NULL);
|
|
calcMtx();
|
|
}
|
|
|
|
void J2DPane::initiate() {
|
|
field_0x4 = -1;
|
|
mRotateX = 0.0f;
|
|
mRotateY = 0.0f;
|
|
mRotateZ = 0.0f;
|
|
mRotateOffsetX = 0.0f;
|
|
mRotateOffsetY = 0.0f;
|
|
mBasePosition = 0;
|
|
mRotAxis = ROTATE_Z;
|
|
mScaleX = 1.0f;
|
|
mScaleY = 1.0f;
|
|
mCullMode = GX_CULL_NONE;
|
|
mAlpha = 255;
|
|
mIsInfluencedAlpha = true;
|
|
mColorAlpha = 255;
|
|
mConnected = false;
|
|
|
|
calcMtx();
|
|
}
|
|
|
|
J2DPane::J2DPane(J2DPane* p_pane, bool visible, u64 tag, JGeometry::TBox2<f32> const& bounds)
|
|
: mBounds(), mGlobalBounds(), mClipRect(), mPaneTree(this) {
|
|
mTransform = NULL;
|
|
initialize(p_pane, visible, tag, bounds);
|
|
}
|
|
|
|
void J2DPane::initialize(J2DPane* p_pane, bool visible, u64 infoTag,
|
|
JGeometry::TBox2<f32> const& bounds) {
|
|
mKind = 'PAN1';
|
|
mVisible = visible;
|
|
mInfoTag = infoTag;
|
|
mUserInfoTag = 0;
|
|
mBounds.set(bounds);
|
|
if (p_pane != NULL) {
|
|
p_pane->mPaneTree.appendChild(&mPaneTree);
|
|
}
|
|
|
|
initiate();
|
|
changeUseTrans(p_pane);
|
|
calcMtx();
|
|
}
|
|
|
|
J2DPane::J2DPane(u64 infoTag, JGeometry::TBox2<f32> const& bounds)
|
|
: mBounds(), mGlobalBounds(), mClipRect(), mPaneTree(this) {
|
|
mTransform = NULL;
|
|
initialize(infoTag, bounds);
|
|
}
|
|
|
|
void J2DPane::initialize(u64 tag, const JGeometry::TBox2<f32>& bounds) {
|
|
mKind = 'PAN1';
|
|
mVisible = true;
|
|
mInfoTag = tag;
|
|
mUserInfoTag = 0;
|
|
mBounds.set(bounds);
|
|
initiate();
|
|
changeUseTrans(NULL);
|
|
calcMtx();
|
|
}
|
|
|
|
J2DPane::J2DPane(J2DPane* p_pane, JSURandomInputStream* p_stream, u8 isEx) : mPaneTree(this) {
|
|
mTransform = NULL;
|
|
if (!isEx) {
|
|
s32 position = p_stream->getPosition();
|
|
|
|
J2DPaneHeader header;
|
|
p_stream->read(&header, sizeof(header));
|
|
mKind = header.mKind;
|
|
position += header.mSize;
|
|
makePaneStream(p_pane, p_stream);
|
|
p_stream->seek(position, JSUStreamSeekFrom_SET);
|
|
} else {
|
|
s32 position = p_stream->getPosition();
|
|
|
|
J2DPaneHeader header;
|
|
p_stream->peek(&header, sizeof(header));
|
|
mKind = header.mKind;
|
|
position += header.mSize;
|
|
makePaneExStream(p_pane, p_stream);
|
|
p_stream->seek(position, JSUStreamSeekFrom_SET);
|
|
}
|
|
}
|
|
|
|
void J2DPane::makePaneStream(J2DPane* p_pane, JSURandomInputStream* p_stream) {
|
|
u8 unk;
|
|
p_stream->read(unk);
|
|
p_stream->read(mVisible);
|
|
p_stream->skip(2);
|
|
|
|
mInfoTag = p_stream->read32b();
|
|
|
|
f32 x0 = p_stream->readS16();
|
|
f32 y0 = p_stream->readS16();
|
|
f32 x1 = x0 + p_stream->readS16();
|
|
f32 y1 = y0 + p_stream->readS16();
|
|
mBounds.set(x0, y0, x1, y1);
|
|
|
|
unk -= u8(6);
|
|
mRotateX = 0;
|
|
mRotateY = 0;
|
|
mRotateZ = 0;
|
|
if (unk != 0) {
|
|
mRotateZ = p_stream->readU16();
|
|
unk--;
|
|
}
|
|
|
|
if (unk != 0) {
|
|
u8 r28 = p_stream->readU8();
|
|
mBasePosition = r28;
|
|
unk--;
|
|
} else {
|
|
mBasePosition = 0;
|
|
}
|
|
mRotAxis = ROTATE_Z;
|
|
|
|
mAlpha = 255;
|
|
if (unk != 0) {
|
|
mAlpha = p_stream->readU8();
|
|
unk--;
|
|
}
|
|
|
|
mIsInfluencedAlpha = true;
|
|
if (unk != 0) {
|
|
mIsInfluencedAlpha = p_stream->readU8();
|
|
unk--;
|
|
}
|
|
|
|
p_stream->align(4);
|
|
if (p_pane != NULL) {
|
|
p_pane->mPaneTree.appendChild(&mPaneTree);
|
|
}
|
|
|
|
mCullMode = GX_CULL_NONE;
|
|
mColorAlpha = 255;
|
|
mConnected = false;
|
|
field_0x4 = 0xFFFF;
|
|
mScaleX = 1;
|
|
mScaleY = 1;
|
|
mUserInfoTag = 0;
|
|
changeUseTrans(p_pane);
|
|
calcMtx();
|
|
}
|
|
|
|
void J2DPane::changeUseTrans(J2DPane* p_pane) {
|
|
f32 xOffset = 0;
|
|
f32 yOffset = 0;
|
|
if (mBasePosition % 3 == 1) {
|
|
xOffset = getWidth() / 2;
|
|
} else if (mBasePosition % 3 == 2) {
|
|
xOffset = getWidth();
|
|
}
|
|
|
|
if (mBasePosition / 3 == 1) {
|
|
yOffset = getHeight() / 2;
|
|
} else if (mBasePosition / 3 == 2) {
|
|
yOffset = getHeight();
|
|
}
|
|
|
|
mTranslateX = mBounds.i.x + xOffset;
|
|
mTranslateY = mBounds.i.y + yOffset;
|
|
|
|
mRotateOffsetX = xOffset;
|
|
mRotateOffsetY = yOffset;
|
|
|
|
mBounds.addPos(JGeometry::TVec2<f32>(-mTranslateX, -mTranslateY));
|
|
|
|
if (p_pane != NULL) {
|
|
u8 otherBasePos = p_pane->mBasePosition;
|
|
f32 width = p_pane->getWidth();
|
|
f32 height = p_pane->getHeight();
|
|
|
|
if (otherBasePos % 3 == 1) {
|
|
mTranslateX -= width / 2;
|
|
} else if (otherBasePos % 3 == 2) {
|
|
mTranslateX -= width;
|
|
}
|
|
|
|
if (otherBasePos / 3 == 1) {
|
|
mTranslateY -= height / 2;
|
|
} else if (otherBasePos / 3 == 2) {
|
|
mTranslateY -= height;
|
|
}
|
|
}
|
|
}
|
|
|
|
J2DPane::~J2DPane() {
|
|
JSUTreeIterator<J2DPane> iterator = mPaneTree.getFirstChild();
|
|
for (; iterator != mPaneTree.getEndChild();) {
|
|
JKR_DELETE((iterator++).getObject());
|
|
}
|
|
}
|
|
|
|
bool J2DPane::appendChild(J2DPane* p_child) {
|
|
if (p_child == NULL)
|
|
return false;
|
|
|
|
const J2DPane* parent = p_child->getParentPane();
|
|
bool result = mPaneTree.appendChild(&p_child->mPaneTree);
|
|
|
|
if (result && parent == NULL) {
|
|
p_child->add(mBounds.i.x, mBounds.i.y);
|
|
p_child->calcMtx();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
bool J2DPane::insertChild(J2DPane* p_prev, J2DPane* p_child) {
|
|
if (p_child == NULL)
|
|
return false;
|
|
|
|
const J2DPane* parent = p_child->getParentPane();
|
|
|
|
bool result =
|
|
mPaneTree.insertChild(p_prev != NULL ? &p_prev->mPaneTree : NULL, &p_child->mPaneTree);
|
|
|
|
if (result && parent == NULL) {
|
|
p_child->add(mBounds.i.x, mBounds.i.y);
|
|
p_child->calcMtx();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
void J2DPane::draw(f32 x, f32 y, J2DGrafContext const* p_grafCtx, bool isOrthoGraf, bool param_4) {
|
|
param_4 = param_4 && mVisible;
|
|
if (p_grafCtx->getGrafType() != 1) {
|
|
isOrthoGraf = false;
|
|
}
|
|
|
|
JSUTree<J2DPane>* parentTree = mPaneTree.getParent();
|
|
J2DPane* parent = NULL;
|
|
if (parentTree != NULL) {
|
|
parent = parentTree->getObject();
|
|
}
|
|
|
|
if (mBounds.isValid()) {
|
|
mGlobalBounds = mBounds;
|
|
|
|
mGlobalBounds.addPos(JGeometry::TVec2<f32>(mTranslateX, mTranslateY));
|
|
|
|
if (param_4) {
|
|
mClipRect = mBounds;
|
|
rewriteAlpha();
|
|
}
|
|
|
|
if (parent != NULL) {
|
|
mGlobalBounds.addPos(JGeometry::TVec2<f32>(parent->mGlobalBounds.i.x - parent->mBounds.i.x, parent->mGlobalBounds.i.y - parent->mBounds.i.y));
|
|
#if !PLATFORM_GCN
|
|
f32 f28 = mPositionMtx[0][0];
|
|
f32 f27 = mPositionMtx[1][0];
|
|
f32 f26 = mPositionMtx[2][0];
|
|
if (getUserInfo() == 'n_43' && p_grafCtx->getGrafType() == 1) {
|
|
JGeometry::TBox2<f32>* bounds = ((J2DOrthoGraph*)p_grafCtx)->getBounds();
|
|
const JGeometry::TBox2<f32>* ortho = ((J2DOrthoGraph*)p_grafCtx)->getOrtho();
|
|
f32 f31 = 608.0f / (ortho->f.x - ortho->i.x);
|
|
mPositionMtx[0][0] *= f31;
|
|
mPositionMtx[0][1] *= f31;
|
|
mPositionMtx[0][2] *= f31;
|
|
}
|
|
#endif
|
|
MTXConcat(parent->mGlobalMtx, mPositionMtx, mGlobalMtx);
|
|
#if !PLATFORM_GCN
|
|
mPositionMtx[0][0] = f28;
|
|
mPositionMtx[1][0] = f27;
|
|
mPositionMtx[2][0] = f26;
|
|
#endif
|
|
|
|
if (param_4) {
|
|
if (isOrthoGraf) {
|
|
mClipRect = mGlobalBounds;
|
|
mClipRect.intersect(parent->mClipRect);
|
|
}
|
|
|
|
mColorAlpha = mAlpha;
|
|
if (mIsInfluencedAlpha) {
|
|
mColorAlpha = (mAlpha * parent->mColorAlpha) / 255;
|
|
}
|
|
}
|
|
} else {
|
|
#if !PLATFORM_GCN
|
|
f32 f25 = mScaleX;
|
|
f32 f24 = mTranslateX;
|
|
if (getUserInfo() != 'n_43' && p_grafCtx->getGrafType() == 1) {
|
|
JGeometry::TBox2<f32>* bounds = ((J2DOrthoGraph*)p_grafCtx)->getBounds();
|
|
const JGeometry::TBox2<f32>* ortho = ((J2DOrthoGraph*)p_grafCtx)->getOrtho();
|
|
f32 f30 = (ortho->f.x - ortho->i.x) / 608.0f;
|
|
f32 f29 = 304.0f;
|
|
mScaleX *= f30;
|
|
mTranslateX = f30 * (mTranslateX - f29) + f29;
|
|
}
|
|
#endif
|
|
mGlobalBounds.addPos(JGeometry::TVec2<f32>(x, y));
|
|
makeMatrix(mTranslateX + x, mTranslateY + y);
|
|
MTXCopy(mPositionMtx, mGlobalMtx);
|
|
mClipRect = mGlobalBounds;
|
|
mColorAlpha = mAlpha;
|
|
#if !PLATFORM_GCN
|
|
mScaleX = f25;
|
|
mTranslateX = f24;
|
|
#endif
|
|
}
|
|
|
|
JGeometry::TBox2<f32> scissorBounds(0, 0, 0, 0);
|
|
if (param_4 && isOrthoGraf) {
|
|
((J2DOrthoGraph*)p_grafCtx)->scissorBounds(&scissorBounds, &mClipRect);
|
|
}
|
|
|
|
if (param_4 && (mClipRect.isValid() || !isOrthoGraf)) {
|
|
J2DGrafContext tmpGraf(*p_grafCtx);
|
|
if (isOrthoGraf) {
|
|
tmpGraf.scissor(scissorBounds);
|
|
tmpGraf.setScissor();
|
|
}
|
|
GXSetCullMode((GXCullMode)mCullMode);
|
|
drawSelf(x, y, &tmpGraf.mPosMtx);
|
|
}
|
|
|
|
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
|
iter->draw(0, 0, p_grafCtx, isOrthoGraf, param_4);
|
|
}
|
|
}
|
|
}
|
|
|
|
void J2DPane::place(JGeometry::TBox2<f32> const& box) {
|
|
JGeometry::TBox2<f32> tmpBox;
|
|
|
|
if (mBounds.i.x == 0) {
|
|
tmpBox.i.x = 0;
|
|
tmpBox.f.x = box.getWidth();
|
|
mTranslateX = box.i.x;
|
|
} else if (mBounds.f.x == 0) {
|
|
tmpBox.i.x = -box.getWidth();
|
|
tmpBox.f.x = 0;
|
|
mTranslateX = box.f.x;
|
|
} else {
|
|
tmpBox.i.x = -(box.getWidth() / 2);
|
|
tmpBox.f.x = box.getWidth() / 2;
|
|
mTranslateX = (box.i.x + box.f.x) / 2;
|
|
}
|
|
|
|
if (mBounds.i.y == 0) {
|
|
tmpBox.i.y = 0;
|
|
tmpBox.f.y = box.getHeight();
|
|
mTranslateY = box.i.y;
|
|
} else if (mBounds.f.y == 0) {
|
|
tmpBox.i.y = -box.getHeight();
|
|
tmpBox.f.y = 0;
|
|
mTranslateY = box.f.y;
|
|
} else {
|
|
tmpBox.i.y = -(box.getHeight() / 2);
|
|
tmpBox.f.y = box.getHeight() / 2;
|
|
mTranslateY = (box.i.y + box.f.y) / 2;
|
|
}
|
|
|
|
f32 xOff = tmpBox.i.x - mBounds.i.x;
|
|
f32 yOff = tmpBox.i.y - mBounds.i.y;
|
|
J2DPane* child;
|
|
for (child = getFirstChildPane(); child != NULL; child = child->getNextChildPane()) {
|
|
child->mTranslateX += xOff;
|
|
child->mTranslateY += yOff;
|
|
if (xOff != 0 || yOff != 0) {
|
|
child->calcMtx();
|
|
}
|
|
}
|
|
mBounds = tmpBox;
|
|
|
|
J2DPane* parent = getParentPane();
|
|
if (parent != NULL) {
|
|
mTranslateX += parent->mBounds.i.x;
|
|
mTranslateY += parent->mBounds.i.y;
|
|
}
|
|
calcMtx();
|
|
}
|
|
|
|
void J2DPane::move(f32 x, f32 y) {
|
|
f32 width = mBounds.getWidth();
|
|
f32 height = mBounds.getHeight();
|
|
place(JGeometry::TBox2<f32>(x, y, x + width, y + height));
|
|
}
|
|
|
|
void J2DPane::add(f32 x, f32 y) {
|
|
mTranslateX += x;
|
|
mTranslateY += y;
|
|
calcMtx();
|
|
}
|
|
|
|
void J2DPane::resize(f32 x, f32 y) {
|
|
JGeometry::TBox2<f32> box = mBounds;
|
|
|
|
box.addPos(JGeometry::TVec2<f32>(mTranslateX, mTranslateY));
|
|
|
|
const J2DPane* parent = getParentPane();
|
|
if (parent != NULL) {
|
|
box.addPos(JGeometry::TVec2<f32>(-parent->mBounds.i.x, -parent->mBounds.i.y));
|
|
}
|
|
|
|
box.f.x = box.i.x + x;
|
|
box.f.y = box.i.y + y;
|
|
place(box);
|
|
}
|
|
|
|
JGeometry::TBox2<f32> J2DPane::static_mBounds(0, 0, 0, 0);
|
|
|
|
JGeometry::TBox2<f32>& J2DPane::getBounds() {
|
|
static_mBounds = mBounds;
|
|
|
|
static_mBounds.addPos(JGeometry::TVec2<f32>(mTranslateX, mTranslateY));
|
|
|
|
const J2DPane* parent = getParentPane();
|
|
if (parent != NULL) {
|
|
static_mBounds.addPos(JGeometry::TVec2<f32>(-parent->mBounds.i.x, -parent->mBounds.i.y));
|
|
}
|
|
|
|
return static_mBounds;
|
|
}
|
|
|
|
void J2DPane::rotate(f32 offsetX, f32 offsetY, J2DRotateAxis axis, f32 angle) {
|
|
mRotateOffsetX = offsetX;
|
|
mRotateOffsetY = offsetY;
|
|
mRotAxis = axis;
|
|
rotate(angle);
|
|
}
|
|
|
|
void J2DPane::rotate(f32 angle) {
|
|
if (mRotAxis == ROTATE_X) {
|
|
mRotateX = angle;
|
|
} else if (mRotAxis == ROTATE_Y) {
|
|
mRotateY = angle;
|
|
} else {
|
|
mRotateZ = angle;
|
|
}
|
|
|
|
calcMtx();
|
|
}
|
|
|
|
void J2DPane::clip(JGeometry::TBox2<f32> const& bounds) {
|
|
JGeometry::TBox2<f32> box(bounds);
|
|
box.addPos(JGeometry::TVec2<f32>(mGlobalBounds.i.x, mGlobalBounds.i.y));
|
|
mClipRect.intersect(box);
|
|
}
|
|
|
|
J2DPane* J2DPane::search(u64 tag) {
|
|
if (tag == mInfoTag) {
|
|
return this;
|
|
}
|
|
|
|
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
|
if (J2DPane* result = iter.getObject()->search(tag)) {
|
|
return result;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
J2DPane* J2DPane::searchUserInfo(u64 tag) {
|
|
if (tag == mUserInfoTag) {
|
|
return this;
|
|
}
|
|
|
|
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
|
if (J2DPane* result = iter.getObject()->searchUserInfo(tag)) {
|
|
return result;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
bool J2DPane::isUsed(const ResTIMG* p_timg) {
|
|
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
|
if (iter.getObject()->isUsed(p_timg))
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool J2DPane::isUsed(const ResFONT* p_font) {
|
|
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
|
if (iter.getObject()->isUsed(p_font))
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void J2DPane::makeMatrix(f32 param_0, f32 param_1, f32 param_2, f32 param_3) {
|
|
f32 tmpX = mRotateOffsetX - param_2;
|
|
f32 tmpY = mRotateOffsetY - param_3;
|
|
Mtx rotX, rotY, rotZ, rotMtx, mtx, tmp;
|
|
MTXTrans(mtx, -tmpX, -tmpY, 0);
|
|
MTXRotRad(rotX, 'x', DEG_TO_RAD(mRotateX));
|
|
MTXRotRad(rotY, 'y', DEG_TO_RAD(mRotateY));
|
|
MTXRotRad(rotZ, 'z', DEG_TO_RAD(-mRotateZ));
|
|
MTXConcat(rotZ, rotX, tmp);
|
|
MTXConcat(rotY, tmp, rotMtx);
|
|
MTXScaleApply(mtx, mPositionMtx, mScaleX, mScaleY, 1);
|
|
MTXConcat(rotMtx, mPositionMtx, tmp);
|
|
MTXTransApply(tmp, mPositionMtx, param_0 + tmpX, param_1 + tmpY, 0);
|
|
}
|
|
|
|
void J2DPane::setCullBack(GXCullMode mode) {
|
|
mCullMode = mode;
|
|
|
|
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
|
iter.getObject()->setCullBack(mode);
|
|
}
|
|
}
|
|
|
|
void J2DPane::setBasePosition(J2DBasePosition position) {
|
|
mBasePosition = position;
|
|
mRotAxis = ROTATE_Z;
|
|
|
|
mRotateOffsetX = 0;
|
|
|
|
if (position % 3 == 1) {
|
|
mRotateOffsetX = getWidth() / 2;
|
|
} else if (position % 3 == 2) {
|
|
mRotateOffsetX = getWidth();
|
|
}
|
|
|
|
mRotateOffsetY = 0;
|
|
if (position / 3 == 1) {
|
|
mRotateOffsetY = getHeight() / 2;
|
|
} else if (position / 3 == 2) {
|
|
mRotateOffsetY = getHeight();
|
|
}
|
|
|
|
calcMtx();
|
|
}
|
|
|
|
void J2DPane::setInfluencedAlpha(bool influencedAlpha, bool param_1) {
|
|
if (param_1 && mIsInfluencedAlpha != influencedAlpha) {
|
|
J2DPane* parent = getParentPane();
|
|
u8 alpha = 255;
|
|
|
|
for (; parent != NULL; parent = parent->getParentPane()) {
|
|
if (parent->getAlpha() == 0) {
|
|
alpha = 0;
|
|
break;
|
|
}
|
|
alpha = (((f32)alpha) * parent->getAlpha() / 255);
|
|
if (!parent->isInfluencedAlpha()) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (influencedAlpha) {
|
|
if (alpha == 0) {
|
|
setAlpha(0);
|
|
} else {
|
|
f32 fAlpha = ((f32)getAlpha()) / alpha * 255;
|
|
|
|
u8 alpha;
|
|
if (fAlpha > 255) {
|
|
alpha = 255;
|
|
} else {
|
|
alpha = fAlpha;
|
|
}
|
|
setAlpha(alpha);
|
|
}
|
|
} else {
|
|
f32 fAlpha = f32(alpha * getAlpha()) / 255;
|
|
setAlpha(fAlpha);
|
|
}
|
|
}
|
|
|
|
mIsInfluencedAlpha = influencedAlpha;
|
|
}
|
|
|
|
Vec J2DPane::getGlbVtx(u8 param_0) const {
|
|
Vec out;
|
|
if (param_0 >= 4) {
|
|
out.x = 0;
|
|
out.y = 0;
|
|
out.z = 0;
|
|
return out;
|
|
}
|
|
|
|
f32 x = param_0 & 1 ? mBounds.f.x : mBounds.i.x;
|
|
f32 y = param_0 & 2 ? mBounds.f.y : mBounds.i.y;
|
|
|
|
out.x = x * mGlobalMtx[0][0] + y * mGlobalMtx[0][1] + mGlobalMtx[0][3];
|
|
out.y = x * mGlobalMtx[1][0] + y * mGlobalMtx[1][1] + mGlobalMtx[1][3];
|
|
out.z = x * mGlobalMtx[2][0] + y * mGlobalMtx[2][1] + mGlobalMtx[2][3];
|
|
return out;
|
|
}
|
|
|
|
J2DPane* J2DPane::getFirstChildPane() {
|
|
if (!getFirstChild())
|
|
return NULL;
|
|
|
|
return getFirstChild()->getObject();
|
|
}
|
|
|
|
J2DPane* J2DPane::getNextChildPane() {
|
|
if (getPaneTree()->getNextChild() == NULL)
|
|
return NULL;
|
|
|
|
return getPaneTree()->getNextChild()->getObject();
|
|
}
|
|
|
|
J2DPane* J2DPane::getParentPane() {
|
|
if (getPaneTree()->getParent() == NULL)
|
|
return NULL;
|
|
|
|
return getPaneTree()->getParent()->getObject();
|
|
}
|
|
|
|
/* name unknown */
|
|
struct J2DPaneInfo {
|
|
/* 0x00 */ BE(u32) mKind;
|
|
/* 0x04 */ BE(u32) mSize;
|
|
/* 0x08 */ BE(u16) field_0x8;
|
|
/* 0x0A */ BE(u16) field_0xa;
|
|
/* 0x0B */ u8 mVisible;
|
|
/* 0x0C */ u8 mBasePosition;
|
|
/* 0x10 */ BE(u64) mInfoTag;
|
|
/* 0x18 */ BE(u64) mUserInfoTag;
|
|
/* 0x20 */ BE(f32) mRotOffsetX;
|
|
/* 0x24 */ BE(f32) mRotOffsetY;
|
|
/* 0x28 */ BE(f32) mScaleX;
|
|
/* 0x2C */ BE(f32) mScaleY;
|
|
/* 0x30 */ BE(f32) mRotateX;
|
|
/* 0x34 */ BE(f32) mRotateY;
|
|
/* 0x38 */ BE(f32) mRotateZ;
|
|
/* 0x3C */ BE(f32) mTranslateX;
|
|
/* 0x40 */ BE(f32) mTranslateY;
|
|
}; // Size: 0x48
|
|
|
|
void J2DPane::makePaneExStream(J2DPane* p_parent, JSURandomInputStream* p_stream) {
|
|
s32 r30 = p_stream->getPosition();
|
|
|
|
J2DPaneInfo data;
|
|
p_stream->read(&data, sizeof(data));
|
|
field_0x4 = data.field_0xa;
|
|
mVisible = !!data.mVisible;
|
|
mInfoTag = data.mInfoTag;
|
|
mUserInfoTag = data.mUserInfoTag;
|
|
mScaleX = data.mScaleX;
|
|
mScaleY = data.mScaleY;
|
|
mRotateX = data.mRotateX;
|
|
mRotateY = data.mRotateY;
|
|
mRotateZ = data.mRotateZ;
|
|
mTranslateX = data.mTranslateX;
|
|
mTranslateY = data.mTranslateY;
|
|
mRotAxis = ROTATE_Z;
|
|
|
|
if (data.mBasePosition % 3 == 0) {
|
|
mRotateOffsetX = 0;
|
|
} else if (data.mBasePosition % 3 == 1) {
|
|
mRotateOffsetX = data.mRotOffsetX / 2;
|
|
} else {
|
|
mRotateOffsetX = data.mRotOffsetX;
|
|
}
|
|
|
|
if (data.mBasePosition / 3 == 0) {
|
|
mRotateOffsetY = 0;
|
|
} else if (data.mBasePosition / 3 == 1) {
|
|
mRotateOffsetY = data.mRotOffsetY / 2;
|
|
} else {
|
|
mRotateOffsetY = data.mRotOffsetY;
|
|
}
|
|
|
|
mBounds.set(-mRotateOffsetX, -mRotateOffsetY, data.mRotOffsetX - mRotateOffsetX,
|
|
data.mRotOffsetY - mRotateOffsetY);
|
|
mBasePosition = data.mBasePosition;
|
|
|
|
mAlpha = 255;
|
|
mIsInfluencedAlpha = false;
|
|
|
|
if (p_parent != NULL) {
|
|
p_parent->mPaneTree.appendChild(&mPaneTree);
|
|
}
|
|
|
|
mCullMode = GX_CULL_NONE;
|
|
mColorAlpha = 255;
|
|
mConnected = false;
|
|
calcMtx();
|
|
}
|
|
|
|
s16 J2DPane::J2DCast_F32_to_S16(f32 value, u8 arg2) {
|
|
if (arg2 >= 0xF) {
|
|
return 0;
|
|
}
|
|
|
|
f32 tmpF;
|
|
tmpF = value;
|
|
if (value < 0) {
|
|
tmpF = -tmpF;
|
|
}
|
|
int tmp = tmpF * (1 << arg2);
|
|
if (tmp >= 0x8000) {
|
|
if (value < 0) {
|
|
return 0x8000;
|
|
} else {
|
|
return 0x7FFF;
|
|
}
|
|
} else if (value < 0) {
|
|
return ~tmp + 1;
|
|
} else {
|
|
return tmp;
|
|
}
|
|
}
|
|
|
|
void* J2DPane::getPointer(JSURandomInputStream* p_stream, u32 param_1, JKRArchive* p_archive) {
|
|
JUTResReference resRef;
|
|
|
|
void* pointer;
|
|
if (p_archive == NULL) {
|
|
if (J2DScreen::getDataManage() == NULL) {
|
|
pointer = resRef.getResource(p_stream, param_1, NULL);
|
|
} else {
|
|
s32 prevPos = p_stream->getPosition();
|
|
pointer = resRef.getResource(p_stream, param_1, NULL);
|
|
if (pointer == NULL) {
|
|
p_stream->seek(prevPos, JSUStreamSeekFrom_SET);
|
|
pointer = J2DScreen::getDataManage()->get(p_stream);
|
|
}
|
|
}
|
|
} else {
|
|
s32 prevPos = p_stream->getPosition();
|
|
pointer = resRef.getResource(p_stream, param_1, p_archive);
|
|
if (pointer == NULL) {
|
|
p_stream->seek(prevPos, JSUStreamSeekFrom_SET);
|
|
pointer = resRef.getResource(p_stream, param_1, NULL);
|
|
}
|
|
|
|
if (pointer == NULL) {
|
|
if (J2DScreen::getDataManage() != NULL) {
|
|
p_stream->seek(prevPos, JSUStreamSeekFrom_SET);
|
|
pointer = J2DScreen::getDataManage()->get(p_stream);
|
|
}
|
|
}
|
|
}
|
|
return pointer;
|
|
}
|
|
|
|
void J2DPane::setAnimation(J2DAnmBase* p_anm) {
|
|
if (p_anm != NULL) {
|
|
switch (p_anm->getKind()) {
|
|
case KIND_TRANSFORM:
|
|
setAnimation(static_cast<J2DAnmTransform*>(p_anm));
|
|
break;
|
|
case KIND_COLOR:
|
|
setAnimation(static_cast<J2DAnmColor*>(p_anm));
|
|
break;
|
|
case KIND_VTX_COLOR:
|
|
setAnimation(static_cast<J2DAnmVtxColor*>(p_anm));
|
|
break;
|
|
case KIND_TEXTURE_SRT:
|
|
setAnimation(static_cast<J2DAnmTextureSRTKey*>(p_anm));
|
|
break;
|
|
case KIND_TEX_PATTERN:
|
|
setAnimation(static_cast<J2DAnmTexPattern*>(p_anm));
|
|
break;
|
|
case KIND_VISIBILITY:
|
|
setAnimation(static_cast<J2DAnmVisibilityFull*>(p_anm));
|
|
break;
|
|
case KIND_TEV_REG:
|
|
setAnimation(static_cast<J2DAnmTevRegKey*>(p_anm));
|
|
break;
|
|
default:
|
|
OS_REPORT("J2DPane: this is not a J3D Binary.\n");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void J2DPane::setAnimation(J2DAnmTransform* p_anm) {
|
|
mTransform = p_anm;
|
|
}
|
|
|
|
void J2DPane::animationTransform() {
|
|
if (mTransform != NULL)
|
|
animationTransform(mTransform);
|
|
}
|
|
|
|
void J2DPane::clearAnmTransform() {
|
|
setAnimation((J2DAnmTransform*)NULL);
|
|
|
|
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
|
iter.getObject()->clearAnmTransform();
|
|
}
|
|
}
|
|
|
|
const J2DAnmTransform* J2DPane::animationTransform(const J2DAnmTransform* p_transform) {
|
|
const J2DAnmTransform* p = p_transform;
|
|
if (mTransform != NULL)
|
|
p = mTransform;
|
|
|
|
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
|
iter.getObject()->animationTransform(p);
|
|
}
|
|
|
|
updateTransform(p);
|
|
return p;
|
|
}
|
|
|
|
void J2DPane::setVisibileAnimation(J2DAnmVisibilityFull* p_visibility) {
|
|
setAnimationVF(p_visibility);
|
|
|
|
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
|
iter.getObject()->setVisibileAnimation(p_visibility);
|
|
}
|
|
}
|
|
|
|
void J2DPane::setVtxColorAnimation(J2DAnmVtxColor* p_vtxColor) {
|
|
setAnimationVC(p_vtxColor);
|
|
|
|
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
|
iter.getObject()->setVtxColorAnimation(p_vtxColor);
|
|
}
|
|
}
|
|
|
|
const J2DAnmTransform* J2DPane::animationPane(const J2DAnmTransform* p_transform) {
|
|
const J2DAnmTransform* p = p_transform;
|
|
if (mTransform != NULL)
|
|
p = mTransform;
|
|
|
|
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
|
iter.getObject()->animationPane(p);
|
|
}
|
|
|
|
updateTransform(p);
|
|
return p;
|
|
}
|
|
|
|
void J2DPane::updateTransform(J2DAnmTransform const* p_anmTransform) {
|
|
if (field_0x4 != 0xFFFF && p_anmTransform != NULL) {
|
|
J3DTransformInfo info;
|
|
p_anmTransform->getTransform(field_0x4, &info);
|
|
mScaleX = info.mScale.x;
|
|
mScaleY = info.mScale.z;
|
|
mRotateX = (u16)info.mRotation.x * 360.0f / 65535.0f;
|
|
mRotateY = (u16)info.mRotation.z * 360.0f / 65535.0f;
|
|
mRotateZ = (u16)info.mRotation.y * 360.0f / 65535.0f;
|
|
mTranslateX = info.mTranslate.x;
|
|
mTranslateY = info.mTranslate.z;
|
|
calcMtx();
|
|
}
|
|
}
|
|
|
|
static void dummy(J2DPane* pane) {
|
|
pane->drawSelf(0.0f, 0.0f);
|
|
pane->update();
|
|
pane->setConnectParent(false);
|
|
pane->setCullBack(false);
|
|
}
|