--check: 938/3256 method bodies compile for x86_64 (28.8%), 32-bit layout asserts hold; boot path 3/626 curated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
536 lines
13 KiB
C++
536 lines
13 KiB
C++
#include "classes.h"
|
|
|
|
// 004073d0
|
|
void Sprite::SetColor(ColorMod *color)
|
|
{
|
|
float fVar1;
|
|
float fVar2;
|
|
float fVar3;
|
|
|
|
if (&this->_color != color) {
|
|
fVar1 = color->_tint[1];
|
|
fVar2 = color->_tint[2];
|
|
fVar3 = color->_tint[3];
|
|
(this->_color)._tint[0] = color->_tint[0];
|
|
(this->_color)._tint[1] = fVar1;
|
|
(this->_color)._tint[2] = fVar2;
|
|
(this->_color)._tint[3] = fVar3;
|
|
fVar1 = color->_colorize[1];
|
|
fVar2 = color->_colorize[2];
|
|
fVar3 = color->_colorize[3];
|
|
(this->_color)._colorize[0] = color->_colorize[0];
|
|
(this->_color)._colorize[1] = fVar1;
|
|
(this->_color)._colorize[2] = fVar2;
|
|
(this->_color)._colorize[3] = fVar3;
|
|
*GHIDRA_CAST<uint64_t *>((this->_color)._offset) = *GHIDRA_CAST<uint64_t *>(color->_offset);
|
|
(this->_color)._offset[2] = color->_offset[2];
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 00407420
|
|
uint8_t Sprite::FlipX()
|
|
{
|
|
return this->_flipX;
|
|
}
|
|
|
|
// 00407430
|
|
uint8_t Sprite::FlipY()
|
|
{
|
|
return this->_flipY;
|
|
}
|
|
|
|
// 0040a140
|
|
void Sprite::RenderLayer(int layerId, Vector *position, Vector *topLeftClamp, Vector *bottomRightClamp)
|
|
{
|
|
if (this->_loaded != 0) {
|
|
if (this->_overlayRenderFirst != 0) {
|
|
FUN_0040a080(layerId,position,topLeftClamp,bottomRightClamp);
|
|
FUN_0040a080(layerId,position,topLeftClamp,bottomRightClamp);
|
|
return;
|
|
}
|
|
FUN_0040a080(layerId,position,topLeftClamp,bottomRightClamp);
|
|
FUN_0040a080(layerId,position,topLeftClamp,bottomRightClamp);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 0040a2b0
|
|
void Sprite::PlayRandom(uint32_t seed)
|
|
{
|
|
uint8_t bVar1;
|
|
uint8_t *curAnimName;
|
|
uint32_t cmpResult;
|
|
uint8_t *animNameCursor;
|
|
uint8_t *anim;
|
|
bool isLess;
|
|
uint8_t *curAnimData;
|
|
|
|
if (this->_animCount == 0) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("[warn] PlayRandom: no animations\n"));
|
|
return;
|
|
}
|
|
anim = GHIDRA_CAST<uint8_t *>(((seed % GHIDRA_UINT(this->_animCount)) * 0x13c + GHIDRA_INT(this->_animData)));
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((anim + 0x14))) {
|
|
anim = *GHIDRA_CAST<uint8_t **>(anim);
|
|
}
|
|
curAnimData = (this->_animState)._animData;
|
|
if (curAnimData != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
curAnimName = curAnimData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((curAnimData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<uint8_t **>(curAnimData);
|
|
}
|
|
animNameCursor = anim;
|
|
do {
|
|
bVar1 = *curAnimName;
|
|
isLess = bVar1 < *animNameCursor;
|
|
if (bVar1 != *animNameCursor) {
|
|
LAB_0040a320:
|
|
cmpResult = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_0040a325;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimName[1];
|
|
isLess = bVar1 < animNameCursor[1];
|
|
if (bVar1 != animNameCursor[1]) goto LAB_0040a320;
|
|
curAnimName = curAnimName + 2;
|
|
animNameCursor = animNameCursor + 2;
|
|
} while (bVar1 != 0);
|
|
cmpResult = 0;
|
|
LAB_0040a325:
|
|
if (cmpResult == 0) {
|
|
if (curAnimData[0x34] == 0) {
|
|
return;
|
|
}
|
|
if ((this->_animState)._isPlaying != 0) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::SetAnimation(anim,1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::Rewind();
|
|
(this->_animState)._isPlaying = 1;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 0040a360
|
|
void Sprite::Play(std_string *animName, uint8_t isForce)
|
|
{
|
|
if (0xf < animName->_capacity) {
|
|
animName = *GHIDRA_CAST<std_string **>(animName->_buf);
|
|
}
|
|
(GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::Play(GHIDRA_CAST<uint8_t *>(animName),isForce);
|
|
return;
|
|
}
|
|
|
|
// 0040a4b0
|
|
void Sprite::IsPlaying(uint8_t *param_1)
|
|
{
|
|
ANM2 *in_ECX;
|
|
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((param_1 + 0x14))) {
|
|
param_1 = *GHIDRA_CAST<uint8_t **>(param_1);
|
|
}
|
|
(GHIDRA_CAST<ANM2 *>((in_ECX)))->ANM2::IsPlaying(param_1);
|
|
return;
|
|
}
|
|
|
|
// 0040a530
|
|
uint8_t Sprite::IsFinished(std_string *animName)
|
|
{
|
|
uint8_t bVar1;
|
|
|
|
if (0xf < animName->_capacity) {
|
|
animName = *GHIDRA_CAST<std_string **>(animName->_buf);
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::IsFinishedImpl(GHIDRA_CAST<uint8_t *>(animName));
|
|
return bVar1;
|
|
}
|
|
|
|
// 0040a5b0
|
|
uint8_t Sprite::SetAnimation(std_string *name, uint8_t isReset)
|
|
{
|
|
uint8_t bVar1;
|
|
|
|
if (0xf < name->_capacity) {
|
|
name = *GHIDRA_CAST<std_string **>(name->_buf);
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::SetAnimation(GHIDRA_CAST<uint8_t *>(name),isReset);
|
|
return bVar1;
|
|
}
|
|
|
|
// 0040a720
|
|
void Sprite::SetFrame_1(int frame)
|
|
{
|
|
if ((this->_animState)._animData != (void *)0x0) {
|
|
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::SetFrameFloat((float)frame);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 0040a760
|
|
void Sprite::SetLastFrame()
|
|
{
|
|
if ((this->_animState)._animData != (void *)0x0) {
|
|
AnimationState::AdvancePosition
|
|
(&this->_animState,*GHIDRA_CAST<int *>((GHIDRA_INT((this->_animState)._animData) + 0x30)) + -1);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 0040a910
|
|
void Sprite::Stop()
|
|
{
|
|
if ((this->_animState)._animData != (void *)0x0) {
|
|
(this->_animState)._isPlaying = 0;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 0040a920
|
|
void Sprite::PlayOverlay(uint8_t *param_1, uint8_t param_2)
|
|
{
|
|
ANM2 *in_ECX;
|
|
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((param_1 + 0x14))) {
|
|
param_1 = *GHIDRA_CAST<uint8_t **>(param_1);
|
|
}
|
|
(GHIDRA_CAST<ANM2 *>((in_ECX)))->ANM2::PlayOverlay(param_1,param_2);
|
|
return;
|
|
}
|
|
|
|
// 0040a9d0
|
|
void Sprite::IsOverlayPlaying()
|
|
{
|
|
FUN_0040a9f0();
|
|
return;
|
|
}
|
|
|
|
// 0040aa50
|
|
void Sprite::IsOverlayFinished()
|
|
{
|
|
FUN_0040aa70();
|
|
return;
|
|
}
|
|
|
|
// 0040aad0
|
|
uint8_t Sprite::SetOverlayAnimation(std_string *animName, uint8_t isReset)
|
|
{
|
|
uint8_t bVar1;
|
|
|
|
if (0xf < animName->_capacity) {
|
|
animName = *GHIDRA_CAST<std_string **>(animName->_buf);
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::SetOverlayAnimation(GHIDRA_CAST<uint8_t *>(animName),isReset);
|
|
return bVar1;
|
|
}
|
|
|
|
// 0040abb0
|
|
void Sprite::SetOverlayFrame(std_string *animName, int frame)
|
|
{
|
|
uint8_t isAnimationSet;
|
|
|
|
if (0xf < animName->_capacity) {
|
|
animName = *GHIDRA_CAST<std_string **>(animName->_buf);
|
|
}
|
|
isAnimationSet = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::SetOverlayAnimation(GHIDRA_CAST<uint8_t *>(animName),1);
|
|
if ((isAnimationSet != 0) && ((this->_overlayAnimState)._animData != (void *)0x0)) {
|
|
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::SetFrameFloat((float)frame);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 0040ac50
|
|
int Sprite::GetOverlayFrame()
|
|
{
|
|
if ((this->_overlayAnimState)._animData == (void *)0x0) {
|
|
return -1;
|
|
}
|
|
return GHIDRA_INT((this->_overlayAnimState)._animFrame);
|
|
}
|
|
|
|
// 0040ac60
|
|
void Sprite::RemoveOverlay()
|
|
{
|
|
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::SetAnimationData((void *)0x0);
|
|
return;
|
|
}
|
|
|
|
// 0040b000
|
|
uint8_t Sprite::IsEventTriggered(void *eventName)
|
|
{
|
|
uint8_t isTriggered;
|
|
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(eventName) + 0x14))) {
|
|
eventName = *(void **)eventName;
|
|
}
|
|
if ((this->_animState)._animData == (void *)0x0) {
|
|
return 0;
|
|
}
|
|
isTriggered = (GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::IsEventTriggered(eventName);
|
|
return isTriggered;
|
|
}
|
|
|
|
// 0040b060
|
|
uint8_t Sprite::WasEventTriggered(std_string *eventName)
|
|
{
|
|
uint8_t local_AL_32;
|
|
|
|
if (0xf < eventName->_capacity) {
|
|
eventName = *GHIDRA_CAST<std_string **>(eventName->_buf);
|
|
}
|
|
if ((this->_animState)._animData == (void *)0x0) {
|
|
return 0;
|
|
}
|
|
local_AL_32 = (GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::WasEventTriggered(GHIDRA_CAST<uint8_t *>(eventName));
|
|
return local_AL_32;
|
|
}
|
|
|
|
// 0040b1d0
|
|
void * Sprite::GetNullFrame(uint8_t *nullLayerName)
|
|
{
|
|
void *nullFrame;
|
|
|
|
if ((this->_animState)._animData == (void *)0x0) {
|
|
return (void *)0x0;
|
|
}
|
|
nullFrame = (GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::GetNullFrame(nullLayerName);
|
|
return nullFrame;
|
|
}
|
|
|
|
// 0040b200
|
|
LayerState * Sprite::GetLayer(uint8_t *layerName)
|
|
{
|
|
LayerState *layer;
|
|
|
|
layer = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::GetLayer(layerName);
|
|
return layer;
|
|
}
|
|
|
|
// 0040b590
|
|
KColor * Sprite::GetTexel(KColor *param_2, float param_3, float param_4, float param_5, float param_6, float param_7, int param_8)
|
|
{
|
|
float fVar1;
|
|
float fVar2;
|
|
float fVar3;
|
|
Vector samplePos;
|
|
Vector samplePos_00;
|
|
Vector renderPos;
|
|
Vector renderPos_00;
|
|
KColor *candidateTexel;
|
|
KColor candidateTexelBuf;
|
|
|
|
samplePos.y = param_4;
|
|
samplePos.x = param_3;
|
|
renderPos.y = param_6;
|
|
renderPos.x = param_5;
|
|
ANM2::GetTexel(&this->_overlayAnimState,param_2,param_8,samplePos,renderPos,param_7);
|
|
if (param_2->_alpha <= param_7 && param_7 != param_2->_alpha) {
|
|
samplePos_00.y = param_4;
|
|
samplePos_00.x = param_3;
|
|
renderPos_00.y = param_6;
|
|
renderPos_00.x = param_5;
|
|
candidateTexel =
|
|
ANM2::GetTexel(&this->_animState,&candidateTexelBuf,param_8,samplePos_00,renderPos_00,
|
|
param_7);
|
|
fVar1 = candidateTexel->_green;
|
|
fVar2 = candidateTexel->_blue;
|
|
fVar3 = candidateTexel->_alpha;
|
|
param_2->_red = candidateTexel->_red;
|
|
param_2->_green = fVar1;
|
|
param_2->_blue = fVar2;
|
|
param_2->_alpha = fVar3;
|
|
param_2->_unk = candidateTexel->_unk;
|
|
}
|
|
return param_2;
|
|
}
|
|
|
|
// 0040bf30
|
|
uint8_t Sprite::ReplaceSpritesheet(int layerId, std_string *pngFilename)
|
|
{
|
|
uint32_t lengthA;
|
|
uint8_t isSamePath;
|
|
int layerOffset;
|
|
std_string *layerPathData;
|
|
std_string *newPathData;
|
|
std_string *layerPath;
|
|
void *layerStates;
|
|
|
|
if ((-1 < layerId) && (layerId < this->_layerCount)) {
|
|
layerStates = this->_layerState;
|
|
layerOffset = layerId * 0xa0;
|
|
layerPath = GHIDRA_CAST<std_string *>((layerOffset + 8 + GHIDRA_INT(layerStates)));
|
|
layerPathData = layerPath;
|
|
if (0xf < layerPath->_capacity) {
|
|
layerPathData = *GHIDRA_CAST<std_string **>(layerPath->_buf);
|
|
}
|
|
lengthA = pngFilename->_size;
|
|
newPathData = pngFilename;
|
|
if (0xf < pngFilename->_capacity) {
|
|
newPathData = *GHIDRA_CAST<std_string **>(pngFilename->_buf);
|
|
}
|
|
isSamePath = str_eq(GHIDRA_CAST<uint8_t *>(newPathData),lengthA,GHIDRA_CAST<uint8_t *>(layerPathData),layerPath->_size);
|
|
if (isSamePath == 0) {
|
|
if (layerPath == pngFilename) {
|
|
*GHIDRA_CAST<uint8_t *>((layerOffset + 0x30 + GHIDRA_INT(layerStates))) = 0;
|
|
return 1;
|
|
}
|
|
if (0xf < pngFilename->_capacity) {
|
|
pngFilename = *GHIDRA_CAST<std_string **>(pngFilename->_buf);
|
|
}
|
|
(GHIDRA_CAST<msvc::string *>((GHIDRA_CAST<char *>(layerPath))))->msvc::string::assign(GHIDRA_CAST<uint8_t *>(pngFilename),lengthA);
|
|
*GHIDRA_CAST<uint8_t *>((layerOffset + 0x30 + GHIDRA_INT(this->_layerState))) = 0;
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// 0040bff0
|
|
void Sprite::LoadGraphics()
|
|
{
|
|
(GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::LoadGraphics((uint8_t)this);
|
|
return;
|
|
}
|
|
|
|
// 00417200
|
|
Vector * Sprite::Scale()
|
|
{
|
|
return &this->_scale;
|
|
}
|
|
|
|
// 00417210
|
|
long double Sprite::Rotation()
|
|
{
|
|
return (long double)this->_rotation;
|
|
}
|
|
|
|
// 00420160
|
|
uint8_t Sprite::IsLoaded()
|
|
{
|
|
return this->_loaded;
|
|
}
|
|
|
|
// 00420170
|
|
void Sprite::SetScale(Vector *scale)
|
|
{
|
|
(this->_scale).x = scale->x;
|
|
(this->_scale).y = scale->y;
|
|
return;
|
|
}
|
|
|
|
// 004312e0
|
|
std_string * Sprite::GetFilename(std_string *outName)
|
|
{
|
|
(GHIDRA_CAST<msvc::string *>((outName->_buf)))->msvc::string::string(this);
|
|
return outName;
|
|
}
|
|
|
|
// 00431300
|
|
void Sprite::SetOverlayRenderPriority(uint8_t param_2)
|
|
{
|
|
this->_overlayRenderFirst = param_2;
|
|
return;
|
|
}
|
|
|
|
// 00435c60
|
|
void Sprite::set_flip_x(uint8_t isFlipX)
|
|
{
|
|
this->_flipX = isFlipX;
|
|
return;
|
|
}
|
|
|
|
// 0043ee80
|
|
void Sprite::SetRotation(float rotation)
|
|
{
|
|
this->_rotation = rotation;
|
|
return;
|
|
}
|
|
|
|
// 00440e40
|
|
int Sprite::GetLayerCount()
|
|
{
|
|
return this->_layerCount;
|
|
}
|
|
|
|
// 00456340
|
|
void Sprite::set_offset(Vector *offset)
|
|
{
|
|
(this->_offset).x = offset->x;
|
|
(this->_offset).y = offset->y;
|
|
return;
|
|
}
|
|
|
|
// 00456360
|
|
long double Sprite::PlaybackSpeed()
|
|
{
|
|
return (long double)this->_playbackSpeed;
|
|
}
|
|
|
|
// 0049cb40
|
|
Vector * Sprite::Offset()
|
|
{
|
|
return &this->_offset;
|
|
}
|
|
|
|
// 004a5cf0
|
|
std_string * Sprite::GetDefaultAnimationName()
|
|
{
|
|
return &this->_animDefaultName;
|
|
}
|
|
|
|
// 0085db20
|
|
char * Sprite::GetAnimation(char *param_2)
|
|
{
|
|
void *animData;
|
|
|
|
animData = (this->_animState)._animData;
|
|
if (animData == (void *)0x0) {
|
|
param_2[0] = '\0';
|
|
param_2[1] = '\0';
|
|
param_2[2] = '\0';
|
|
param_2[3] = '\0';
|
|
param_2[0x10] = '\0';
|
|
param_2[0x11] = '\0';
|
|
param_2[0x12] = '\0';
|
|
param_2[0x13] = '\0';
|
|
param_2[0x14] = '\x0f';
|
|
param_2[0x15] = '\0';
|
|
param_2[0x16] = '\0';
|
|
param_2[0x17] = '\0';
|
|
*param_2 = '\0';
|
|
param_2[0x10] = '\0';
|
|
param_2[0x11] = '\0';
|
|
param_2[0x12] = '\0';
|
|
param_2[0x13] = '\0';
|
|
*param_2 = '\0';
|
|
return param_2;
|
|
}
|
|
(GHIDRA_CAST<msvc::string *>((param_2)))->msvc::string::string(animData);
|
|
return param_2;
|
|
}
|
|
|
|
// 0085db70
|
|
std_string * Sprite::GetOverlayAnimation(std_string *outName)
|
|
{
|
|
void *animData;
|
|
|
|
animData = (this->_overlayAnimState)._animData;
|
|
if (animData == (void *)0x0) {
|
|
outName->_buf[0] = '\0';
|
|
outName->_buf[1] = '\0';
|
|
outName->_buf[2] = '\0';
|
|
outName->_buf[3] = '\0';
|
|
outName->_size = 0;
|
|
outName->_capacity = 0xf;
|
|
outName->_buf[0] = '\0';
|
|
outName->_size = 0;
|
|
outName->_buf[0] = '\0';
|
|
return outName;
|
|
}
|
|
(GHIDRA_CAST<msvc::string *>((outName->_buf)))->msvc::string::string(animData);
|
|
return outName;
|
|
}
|