Reconstruction layout: generated-src/ (generated) and src/ (curated), CMake, the first takeover: RNG
The decompiled C++ tree moves to generated-src/ (classes.h, C++20); src/ is for code written by hand. A curated function defines the generated declaration and starts its comment with its address, and source_tree.py stops emitting that body. src/rng.cpp takes over RNG (SetSeed, the constructor, Next, RandomInt, RandomFloat, Shuffle) with the shift table read from the exe as a constexpr array; src/log.h names KAGE_LogMessage's levels (1 INFO, 2 NET, 4 WARN, 8 ERROR, 16 ASSERT, from its prefix jump table). CMakeLists.txt builds src/*.cpp against generated-src/classes.h (clean with -Wall -Wextra). structs.hpp and headers.py are retired: scripts/merge_fields.py writes the merged field list, classes.h checks the layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2ff2d5d87f
commit
3ce74c6e2d
331 files changed
+485
-7835
No files matched your search
@@ -0,0 +1,535 @@
|
||||
#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<undefined8 *>((this->_color)._offset) = *GHIDRA_CAST<undefined8 *>(color->_offset);
|
||||
(this->_color)._offset[2] = color->_offset[2];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 00407420
|
||||
byte Sprite::FlipX()
|
||||
{
|
||||
return this->_flipX;
|
||||
}
|
||||
|
||||
// 00407430
|
||||
byte 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(uint seed)
|
||||
{
|
||||
byte bVar1;
|
||||
byte *curAnimName;
|
||||
uint cmpResult;
|
||||
byte *animNameCursor;
|
||||
byte *anim;
|
||||
bool isLess;
|
||||
byte *curAnimData;
|
||||
|
||||
if (this->_animCount == 0) {
|
||||
KAGE_LogMessage(1,GHIDRA_CAST<byte *>("[warn] PlayRandom: no animations\n"));
|
||||
return;
|
||||
}
|
||||
anim = GHIDRA_CAST<byte *>(((seed % GHIDRA_UINT(this->_animCount)) * 0x13c + GHIDRA_INT(this->_animData)));
|
||||
if (0xf < *GHIDRA_CAST<uint *>((anim + 0x14))) {
|
||||
anim = *GHIDRA_CAST<byte **>(anim);
|
||||
}
|
||||
curAnimData = (this->_animState)._animData;
|
||||
if (curAnimData != GHIDRA_CAST<byte *>(0x0)) {
|
||||
curAnimName = curAnimData;
|
||||
if (0xf < *GHIDRA_CAST<uint *>((curAnimData + 0x14))) {
|
||||
curAnimName = *GHIDRA_CAST<byte **>(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, byte isForce)
|
||||
{
|
||||
if (0xf < animName->_capacity) {
|
||||
animName = *GHIDRA_CAST<std_string **>(animName->_buf);
|
||||
}
|
||||
(GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::Play(GHIDRA_CAST<byte *>(animName),isForce);
|
||||
return;
|
||||
}
|
||||
|
||||
// 0040a4b0
|
||||
void Sprite::IsPlaying(byte *param_1)
|
||||
{
|
||||
ANM2 *in_ECX;
|
||||
|
||||
if (0xf < *GHIDRA_CAST<uint *>((param_1 + 0x14))) {
|
||||
param_1 = *GHIDRA_CAST<byte **>(param_1);
|
||||
}
|
||||
(GHIDRA_CAST<ANM2 *>((in_ECX)))->ANM2::IsPlaying(param_1);
|
||||
return;
|
||||
}
|
||||
|
||||
// 0040a530
|
||||
byte Sprite::IsFinished(std_string *animName)
|
||||
{
|
||||
byte bVar1;
|
||||
|
||||
if (0xf < animName->_capacity) {
|
||||
animName = *GHIDRA_CAST<std_string **>(animName->_buf);
|
||||
}
|
||||
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::IsFinishedImpl(GHIDRA_CAST<byte *>(animName));
|
||||
return bVar1;
|
||||
}
|
||||
|
||||
// 0040a5b0
|
||||
byte Sprite::SetAnimation(std_string *name, byte isReset)
|
||||
{
|
||||
byte bVar1;
|
||||
|
||||
if (0xf < name->_capacity) {
|
||||
name = *GHIDRA_CAST<std_string **>(name->_buf);
|
||||
}
|
||||
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(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(byte *param_1, byte param_2)
|
||||
{
|
||||
ANM2 *in_ECX;
|
||||
|
||||
if (0xf < *GHIDRA_CAST<uint *>((param_1 + 0x14))) {
|
||||
param_1 = *GHIDRA_CAST<byte **>(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
|
||||
byte Sprite::SetOverlayAnimation(std_string *animName, byte isReset)
|
||||
{
|
||||
byte bVar1;
|
||||
|
||||
if (0xf < animName->_capacity) {
|
||||
animName = *GHIDRA_CAST<std_string **>(animName->_buf);
|
||||
}
|
||||
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::SetOverlayAnimation(GHIDRA_CAST<byte *>(animName),isReset);
|
||||
return bVar1;
|
||||
}
|
||||
|
||||
// 0040abb0
|
||||
void Sprite::SetOverlayFrame(std_string *animName, int frame)
|
||||
{
|
||||
byte isAnimationSet;
|
||||
|
||||
if (0xf < animName->_capacity) {
|
||||
animName = *GHIDRA_CAST<std_string **>(animName->_buf);
|
||||
}
|
||||
isAnimationSet = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::SetOverlayAnimation(GHIDRA_CAST<byte *>(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
|
||||
byte Sprite::IsEventTriggered(void *eventName)
|
||||
{
|
||||
byte isTriggered;
|
||||
|
||||
if (0xf < *GHIDRA_CAST<uint *>((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
|
||||
byte Sprite::WasEventTriggered(std_string *eventName)
|
||||
{
|
||||
byte 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<byte *>(eventName));
|
||||
return local_AL_32;
|
||||
}
|
||||
|
||||
// 0040b1d0
|
||||
void * Sprite::GetNullFrame(byte *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(byte *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
|
||||
byte Sprite::ReplaceSpritesheet(int layerId, std_string *pngFilename)
|
||||
{
|
||||
uint lengthA;
|
||||
byte 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<byte *>(newPathData),lengthA,GHIDRA_CAST<byte *>(layerPathData),layerPath->_size);
|
||||
if (isSamePath == 0) {
|
||||
if (layerPath == pngFilename) {
|
||||
*GHIDRA_CAST<undefined1 *>((layerOffset + 0x30 + GHIDRA_INT(layerStates))) = 0;
|
||||
return 1;
|
||||
}
|
||||
if (0xf < pngFilename->_capacity) {
|
||||
pngFilename = *GHIDRA_CAST<std_string **>(pngFilename->_buf);
|
||||
}
|
||||
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(layerPath))))->std::string::assign(GHIDRA_CAST<byte *>(pngFilename),lengthA);
|
||||
*GHIDRA_CAST<undefined1 *>((layerOffset + 0x30 + GHIDRA_INT(this->_layerState))) = 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 0040bff0
|
||||
void Sprite::LoadGraphics()
|
||||
{
|
||||
(GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>(this))))->ANM2::LoadGraphics((byte)this);
|
||||
return;
|
||||
}
|
||||
|
||||
// 00417200
|
||||
Vector * Sprite::Scale()
|
||||
{
|
||||
return &this->_scale;
|
||||
}
|
||||
|
||||
// 00417210
|
||||
float10 Sprite::Rotation()
|
||||
{
|
||||
return (float10)this->_rotation;
|
||||
}
|
||||
|
||||
// 00420160
|
||||
byte 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<std::string *>((outName->_buf)))->std::string::string(this);
|
||||
return outName;
|
||||
}
|
||||
|
||||
// 00431300
|
||||
void Sprite::SetOverlayRenderPriority(byte param_2)
|
||||
{
|
||||
this->_overlayRenderFirst = param_2;
|
||||
return;
|
||||
}
|
||||
|
||||
// 00435c60
|
||||
void Sprite::set_flip_x(byte 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
|
||||
float10 Sprite::PlaybackSpeed()
|
||||
{
|
||||
return (float10)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<std::string *>((param_2)))->std::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<std::string *>((outName->_buf)))->std::string::string(animData);
|
||||
return outName;
|
||||
}
|
||||
Reference in new issue
Block a user