Files
isaac-port/generated-src/sound_instance.cpp
T
shweetandClaude Opus 5.5 3ce74c6e2d 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>
2026-11-19 21:10:23 -05:00

132 lines
5.5 KiB
C++

#include "classes.h"
// 00a2a990
SoundInstance::SoundInstance()
{
char cVar1;
uint uVar2;
ReferenceCountBase *refCount;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
puStack_c = &LAB_00b1203c;
local_10 = ExceptionList;
uVar2 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
ExceptionList = &local_10;
*GHIDRA_CAST<undefined4 *>(this) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 4)) = 0;
local_8 = 0;
refCount = operator_new(0x18);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 1;
if (refCount == GHIDRA_CAST<ReferenceCountBase *>(0x0)) {
refCount = GHIDRA_CAST<ReferenceCountBase *>(0x0);
}
else {
(GHIDRA_CAST<ReferenceCountBase *>((refCount)))->ReferenceCountBase::ReferenceCountBase();
*GHIDRA_CAST<undefined ***>(refCount) = ReferenceCount<KAGE::Sound::SoundSourceBase>::vftable;
*GHIDRA_CAST<undefined4 *>((refCount + 0x14)) = 0;
}
local_8 = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(GHIDRA_UINT(local_8))) + 0x1))) << 8;
if (*GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 4)) != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 4)) + 0xc))(uVar2);
if ((cVar1 != '\0') && (g_soundReleaseFn != (void *)0x0)) {
(*g_soundReleaseFn)(this);
}
}
*GHIDRA_CAST<ReferenceCountBase **>((GHIDRA_CAST<char *>(this) + 4)) = refCount;
*GHIDRA_CAST<undefined4 *>(this) = 0;
*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(this) + 8)) = 0;
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(this) + 10)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)) = 0x3f800000;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x14)) = 0x3f800000;
ExceptionList = local_10;
return;
}
// 00a2ac90
void SoundInstance::operator_assign(void *other)
{
undefined4 uVar1;
undefined4 uVar2;
char isLastRef;
uint loopFlags;
undefined4 *swappedSource;
undefined1 oldSource [4];
int *oldSourceRefCount;
undefined1 sourceCopy [4];
int *sourceCopyRefCount;
undefined4 local_1c;
undefined4 local_18;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
undefined2 loopFlags;
local_8 = 0xffffffff;
puStack_c = &LAB_00b1206d;
local_10 = ExceptionList;
loopFlags = __security_cookie ^ GHIDRA_UINT((sourceCopy + 0x20));
ExceptionList = &local_10;
FUN_008f2d20(other);
local_8 = 0;
uVar1 = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(other) + 0xc));
loopFlags = *GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(other) + 8));
local_18 = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(other) + 0x10));
local_1c = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(other) + 0x14));
KAGE::SmartPointer<SoundSourceBase>::reset(0);
*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(this) + 8)) = 0;
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(this) + 10)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)) = 0x3f800000;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x14)) = 0x3f800000;
swappedSource = GHIDRA_CAST<undefined4 *>(FUN_008f2d20(sourceCopy));
uVar2 = swappedSource[1];
swappedSource[1] = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 4));
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 4)) = uVar2;
uVar2 = *swappedSource;
*swappedSource = *GHIDRA_CAST<undefined4 *>(this);
*GHIDRA_CAST<undefined4 *>(this) = uVar2;
local_8 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),1);
if (oldSourceRefCount != GHIDRA_CAST<int *>(0x0)) {
isLastRef = (**(code **)(*oldSourceRefCount + 0xc))(loopFlags);
if ((isLastRef != '\0') && (g_soundReleaseFn != (void *)0x0)) {
(*g_soundReleaseFn)(oldSource);
}
}
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)) = uVar1;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)) = local_18;
*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(this) + 8)) = (char)loopFlags;
*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(this) + 9)) = (char)((ushort)loopFlags >> 8);
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x14)) = local_1c;
local_8 = 2;
if (sourceCopyRefCount != GHIDRA_CAST<int *>(0x0)) {
isLastRef = (**(code **)(*sourceCopyRefCount + 0xc))();
if ((isLastRef != '\0') && (g_soundReleaseFn != (void *)0x0)) {
(*g_soundReleaseFn)(sourceCopy);
}
}
ExceptionList = local_10;
return;
}
// 00a2add0
void SoundInstance::assign(void *source)
{
KAGE::SmartPointer<SoundSourceBase>::reset(0);
*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(this) + 8)) = 0;
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(this) + 10)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)) = 0x3f800000;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x14)) = 0x3f800000;
FUN_008f2c90(source);
if (*GHIDRA_CAST<int **>(this) != GHIDRA_CAST<int *>(0x0)) {
(**(code **)(**GHIDRA_CAST<int **>(this) + 0x40))(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(this) + 8)));
(**(code **)(**GHIDRA_CAST<int **>(this) + 0x48))(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)));
(**(code **)(**GHIDRA_CAST<int **>(this) + 0x50))(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)));
(**(code **)(**GHIDRA_CAST<int **>(this) + 0x58))(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x14)));
}
return;
}