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>
194 lines
6.8 KiB
C++
194 lines
6.8 KiB
C++
#include "classes.h"
|
|
|
|
// 007df710
|
|
void MusicChannel::play_track(int param_1)
|
|
{
|
|
int layerBias;
|
|
int trackLayer;
|
|
int *in_ECX;
|
|
undefined4 *layerPath;
|
|
int *piVar1;
|
|
uint layerIndex;
|
|
undefined4 in_XMM3_Da;
|
|
|
|
piVar1 = GHIDRA_CAST<int *>((param_1 + 0x34));
|
|
if (*GHIDRA_CAST<int *>((param_1 + 0x2c)) == 0) {
|
|
MusicStream::play(piVar1,*GHIDRA_CAST<undefined1 *>((param_1 + 0x4c)),in_XMM3_Da);
|
|
}
|
|
else {
|
|
MusicStream::play(param_1 + 0x1c,0,in_XMM3_Da);
|
|
if (0xf < *GHIDRA_CAST<uint *>((param_1 + 0x48))) {
|
|
piVar1 = GHIDRA_CAST<int *>(*piVar1);
|
|
}
|
|
if (GHIDRA_CAST<int *>(*in_ECX) != GHIDRA_CAST<int *>(0x0)) {
|
|
(**(code **)(*GHIDRA_CAST<int *>(*in_ECX) + 0xc))(piVar1,*GHIDRA_CAST<undefined1 *>((param_1 + 0x4c)));
|
|
}
|
|
}
|
|
layerIndex = 0;
|
|
in_ECX[0x5c] = GHIDRA_UINT(*GHIDRA_CAST<byte *>((param_1 + 0x4d)));
|
|
in_ECX[8] = 0x3f800000;
|
|
in_ECX[7] = 0x3f800000;
|
|
in_ECX[6] = *GHIDRA_CAST<int *>((param_1 + 0x50));
|
|
in_ECX[9] = *GHIDRA_CAST<int *>((param_1 + 0x54));
|
|
in_ECX[0x5b] = 0;
|
|
piVar1 = in_ECX + 0x10;
|
|
layerBias = -0x40 - GHIDRA_INT(in_ECX);
|
|
do {
|
|
if ((char)piVar1[7] != '\0') {
|
|
if (GHIDRA_CAST<int *>(piVar1[-3]) != GHIDRA_CAST<int *>(0x0)) {
|
|
(**(code **)(*GHIDRA_CAST<int *>(piVar1[-3]) + 0x3c))();
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(piVar1) + -3)) = 0;
|
|
}
|
|
KAGE::SmartPointer<SoundSourceBase>::reset(0);
|
|
*GHIDRA_CAST<undefined2 *>((piVar1 + -1)) = 0;
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(piVar1) + -2)) = 0;
|
|
*piVar1 = 0x3f800000;
|
|
piVar1[1] = 0;
|
|
piVar1[2] = 0x3f800000;
|
|
*GHIDRA_CAST<undefined1 *>((piVar1 + 7)) = 0;
|
|
piVar1[8] = 0;
|
|
}
|
|
if ((layerIndex < *GHIDRA_CAST<uint *>((param_1 + 0x5c))) &&
|
|
(trackLayer = GHIDRA_INT(piVar1) + *GHIDRA_CAST<int *>((param_1 + 0x58)) + layerBias,
|
|
*GHIDRA_CAST<int *>((trackLayer + 0x28)) != 0)) {
|
|
if (*GHIDRA_CAST<int *>((trackLayer + 0x10)) == 0) {
|
|
MusicStream::play(trackLayer + 0x18,1,in_XMM3_Da);
|
|
}
|
|
else {
|
|
MusicStream::play(trackLayer,0,in_XMM3_Da);
|
|
layerPath = GHIDRA_CAST<undefined4 *>((GHIDRA_INT(piVar1) + *GHIDRA_CAST<int *>((param_1 + 0x58)) + 0x18 + layerBias));
|
|
if (0xf < GHIDRA_UINT(layerPath[5])) {
|
|
layerPath = GHIDRA_CAST<undefined4 *>(*layerPath);
|
|
}
|
|
if (GHIDRA_CAST<int *>(piVar1[-3]) != GHIDRA_CAST<int *>(0x0)) {
|
|
(**(code **)(*GHIDRA_CAST<int *>(piVar1[-3]) + 0xc))(layerPath,1);
|
|
}
|
|
}
|
|
piVar1[5] = 0;
|
|
piVar1[4] = 0;
|
|
if (GHIDRA_CAST<int *>(piVar1[-3]) != GHIDRA_CAST<int *>(0x0)) {
|
|
(**(code **)(*GHIDRA_CAST<int *>(piVar1[-3]) + 0x2c))(1);
|
|
*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(piVar1) + -3)) = 1;
|
|
}
|
|
piVar1[6] = *GHIDRA_CAST<int *>((param_1 + 0x54));
|
|
piVar1[3] = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(piVar1) + *GHIDRA_CAST<int *>((param_1 + 0x58)) + 0x30 + layerBias));
|
|
}
|
|
layerIndex = layerIndex + 1;
|
|
piVar1 = piVar1 + 0xd;
|
|
} while (layerIndex < 6);
|
|
return;
|
|
}
|
|
|
|
// 007df8e0
|
|
void MusicChannel::update_volume(byte isStopWhenSilent)
|
|
{
|
|
undefined1 *puVar1;
|
|
int i;
|
|
undefined4 topLayerVolume;
|
|
float newVolume;
|
|
undefined4 layerVolume;
|
|
int layersLeft;
|
|
float currentVolume;
|
|
|
|
currentVolume = this->_volume;
|
|
newVolume = this->_targetVolume;
|
|
if (this->_fadeRate < ABS(currentVolume - newVolume)) {
|
|
newVolume = (newVolume - currentVolume) * this->_fadeRate + currentVolume;
|
|
}
|
|
this->_volume = newVolume;
|
|
topLayerVolume = 0x3f800000;
|
|
if (this->_layerMode == 2) {
|
|
if (this->_enabledLayers == 0) {
|
|
layerVolume = 0x3f800000;
|
|
}
|
|
else {
|
|
layerVolume = 0;
|
|
}
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x20)))) = layerVolume;
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x5c))) != '\0') {
|
|
if ((this->_enabledLayers & 1) == 0) {
|
|
layerVolume = 0;
|
|
}
|
|
else {
|
|
layerVolume = 0x3f800000;
|
|
}
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x54)))) = layerVolume;
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x90))) != '\0') {
|
|
if ((this->_enabledLayers & 2) == 0) {
|
|
layerVolume = 0;
|
|
}
|
|
else {
|
|
layerVolume = 0x3f800000;
|
|
}
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x88)))) = layerVolume;
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0xc4))) != '\0') {
|
|
if ((this->_enabledLayers & 4) == 0) {
|
|
layerVolume = 0;
|
|
}
|
|
else {
|
|
layerVolume = 0x3f800000;
|
|
}
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0xbc)))) = layerVolume;
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0xf8))) != '\0') {
|
|
if ((this->_enabledLayers & 8) == 0) {
|
|
layerVolume = 0;
|
|
}
|
|
else {
|
|
layerVolume = 0x3f800000;
|
|
}
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0xf0)))) = layerVolume;
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x12c))) != '\0') {
|
|
if ((this->_enabledLayers & 0x10) == 0) {
|
|
layerVolume = 0;
|
|
}
|
|
else {
|
|
layerVolume = 0x3f800000;
|
|
}
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x124)))) = layerVolume;
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x160))) != '\0') {
|
|
if ((this->_enabledLayers & 0x20) == 0) {
|
|
topLayerVolume = 0;
|
|
}
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x158)))) = topLayerVolume;
|
|
}
|
|
FUN_007e15a0(0);
|
|
i = 6;
|
|
do {
|
|
FUN_007e15a0(0);
|
|
i = i + -1;
|
|
} while (i != 0);
|
|
this->_isSavedStreamFlag = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x28)));
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x28))) == 0) {
|
|
puVar1 = &(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x3d)));
|
|
layersLeft = 6;
|
|
do {
|
|
if (puVar1[0x1f] != '\0') {
|
|
if (*GHIDRA_CAST<int **>((puVar1 + -9)) != GHIDRA_CAST<int *>(0x0)) {
|
|
(**(code **)(**GHIDRA_CAST<int **>((puVar1 + -9)) + 0x3c))();
|
|
*puVar1 = 0;
|
|
}
|
|
KAGE::SmartPointer<SoundSourceBase>::reset(0);
|
|
*GHIDRA_CAST<undefined2 *>((puVar1 + -1)) = 0;
|
|
puVar1[1] = 0;
|
|
*GHIDRA_CAST<undefined4 *>((puVar1 + 3)) = 0x3f800000;
|
|
*GHIDRA_CAST<undefined4 *>((puVar1 + 7)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((puVar1 + 0xb)) = 0x3f800000;
|
|
puVar1[0x1f] = 0;
|
|
*GHIDRA_CAST<undefined4 *>((puVar1 + 0x23)) = 0;
|
|
}
|
|
puVar1 = puVar1 + 0x34;
|
|
layersLeft = layersLeft + -1;
|
|
} while (layersLeft != 0);
|
|
}
|
|
if ((this->_volume <= 0.0) && (isStopWhenSilent != 0)) {
|
|
FUN_007df600();
|
|
}
|
|
return;
|
|
}
|