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,320 @@
|
||||
#include "classes.h"
|
||||
|
||||
// 00428cd0
|
||||
MusicManager::MusicManager()
|
||||
{
|
||||
return &g_manager->_musicManager;
|
||||
}
|
||||
|
||||
// 0067f070
|
||||
Vector * MusicManager::RandomVector(Vector *outVec)
|
||||
{
|
||||
uint randomValue;
|
||||
float fVar1;
|
||||
float fVar2;
|
||||
|
||||
randomValue = ::Random();
|
||||
fVar1 = (float)((double)GHIDRA_INT(randomValue) + __uint_to_double_fixup[-(GHIDRA_INT(randomValue) >> 0x1f)]) *
|
||||
2.3283064e-10 * 3.14;
|
||||
fVar1 = fVar1 + fVar1;
|
||||
fVar2 = cos(fVar1);
|
||||
outVec->x = fVar2;
|
||||
fVar1 = sin(fVar1);
|
||||
outVec->y = fVar1;
|
||||
return outVec;
|
||||
}
|
||||
|
||||
// 007df450
|
||||
MusicManager::~MusicManager()
|
||||
{
|
||||
int iVar1;
|
||||
char isLastRef;
|
||||
int in_ECX;
|
||||
int layersLeft;
|
||||
int iVar2;
|
||||
int channelsLeft;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
int local_8;
|
||||
|
||||
local_8 = 0xffffffff;
|
||||
puStack_c = &LAB_00b007d0;
|
||||
local_10 = ExceptionList;
|
||||
ExceptionList = &local_10;
|
||||
iVar2 = in_ECX + 0xd;
|
||||
channelsLeft = 2;
|
||||
do {
|
||||
KAGE::SmartPointer<SoundSourceBase>::reset(0);
|
||||
*GHIDRA_CAST<undefined2 *>((iVar2 + -1)) = 0;
|
||||
*GHIDRA_CAST<undefined1 *>((iVar2 + 1)) = 0;
|
||||
layersLeft = 6;
|
||||
*GHIDRA_CAST<undefined4 *>((iVar2 + 3)) = 0x3f800000;
|
||||
*GHIDRA_CAST<undefined4 *>((iVar2 + 7)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((iVar2 + 0xb)) = 0x3f800000;
|
||||
iVar1 = iVar2;
|
||||
do {
|
||||
KAGE::SmartPointer<SoundSourceBase>::reset(0);
|
||||
*GHIDRA_CAST<undefined2 *>((iVar1 + 0x33)) = 0;
|
||||
*GHIDRA_CAST<undefined1 *>((iVar1 + 0x35)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((iVar1 + 0x37)) = 0x3f800000;
|
||||
*GHIDRA_CAST<undefined4 *>((iVar1 + 0x3b)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((iVar1 + 0x3f)) = 0x3f800000;
|
||||
layersLeft = layersLeft + -1;
|
||||
iVar1 = iVar1 + 0x34;
|
||||
} while (layersLeft != 0);
|
||||
iVar2 = iVar2 + 0x184;
|
||||
channelsLeft = channelsLeft + -1;
|
||||
} while (channelsLeft != 0);
|
||||
KAGE::SmartPointer<SoundSourceBase>::reset(0);
|
||||
*GHIDRA_CAST<undefined2 *>((in_ECX + 0x334)) = 0;
|
||||
*GHIDRA_CAST<undefined1 *>((in_ECX + 0x336)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((in_ECX + 0x338)) = 0x3f800000;
|
||||
*GHIDRA_CAST<undefined4 *>((in_ECX + 0x33c)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((in_ECX + 0x340)) = 0x3f800000;
|
||||
local_8 = layersLeft;
|
||||
KAGE::SmartPointer<SoundSourceBase>::reset(0);
|
||||
*GHIDRA_CAST<undefined2 *>((in_ECX + 0x334)) = 0;
|
||||
*GHIDRA_CAST<undefined1 *>((in_ECX + 0x336)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((in_ECX + 0x338)) = 0x3f800000;
|
||||
*GHIDRA_CAST<undefined4 *>((in_ECX + 0x33c)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((in_ECX + 0x340)) = 0x3f800000;
|
||||
local_8 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),1);
|
||||
if (*GHIDRA_CAST<int **>((in_ECX + 0x330)) != GHIDRA_CAST<int *>(0x0)) {
|
||||
isLastRef = (**(code **)(**GHIDRA_CAST<int **>((in_ECX + 0x330)) + 0xc))();
|
||||
if ((isLastRef != '\0') && (g_soundReleaseFn != (void *)0x0)) {
|
||||
(*g_soundReleaseFn)(in_ECX + 0x32c);
|
||||
}
|
||||
}
|
||||
local_8 = 0xffffffff;
|
||||
std::vector<MusicTrack>::_Tidy();
|
||||
_eh_vector_destructor_iterator_((void *)(in_ECX + 4),0x184,2,FUN_007df3f0);
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
|
||||
// 007e1780
|
||||
int MusicManager::GetCurrentMusicID()
|
||||
{
|
||||
return this->_currentMusicID;
|
||||
}
|
||||
|
||||
// 007e1790
|
||||
int MusicManager::GetQueuedMusicID()
|
||||
{
|
||||
int musicId;
|
||||
|
||||
musicId = this->_queuedMusicID;
|
||||
if (musicId == 0) {
|
||||
musicId = this->_currentMusicID;
|
||||
}
|
||||
return musicId;
|
||||
}
|
||||
|
||||
// 007e1e70
|
||||
void MusicManager::Crossfade(int musicId, float fadeRate)
|
||||
{
|
||||
char isPlaying;
|
||||
void *pvVar1;
|
||||
uint newChannel;
|
||||
int layersLeft;
|
||||
int *piVar2;
|
||||
int channelIdx;
|
||||
Manager *manager;
|
||||
|
||||
if ((((-1 < musicId) &&
|
||||
(musicId < (GHIDRA_INT((this->_entries)._end) - GHIDRA_INT((this->_entries)._begin)) / 0x60)) ||
|
||||
(KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Music ID %d out of bounds.\n")), -1 < musicId)) &&
|
||||
(pvVar1 = (this->_entries)._begin, musicId < (GHIDRA_INT((this->_entries)._end) - GHIDRA_INT(pvVar1)) / 0x60)
|
||||
) {
|
||||
if (musicId == this->_currentMusicID) {
|
||||
KAGE_LogMessage(1,(byte *)
|
||||
"Music::Crossfade: music already playing, only adjusting target volume.\n");
|
||||
if ((g_manager->_musicManager)._isEnabled == 0) {
|
||||
this->_channels[this->_currentChannel]._targetVolume = 0.0;
|
||||
return;
|
||||
}
|
||||
this->_channels[this->_currentChannel]._targetVolume =
|
||||
(g_manager->_optionsConfig)._musicVolume;
|
||||
return;
|
||||
}
|
||||
pvVar1 = (void *)(musicId * 0x60 + GHIDRA_INT(pvVar1));
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x44)) == 0) {
|
||||
KAGE_LogMessage(1,GHIDRA_CAST<byte *>("[warn] no music for ID %d (%s).\n"));
|
||||
return;
|
||||
}
|
||||
this->_channels[this->_currentChannel]._targetVolume = 0.0;
|
||||
channelIdx = this->_currentChannel;
|
||||
if ((*GHIDRA_CAST<int **>((this->_channels + channelIdx)) != GHIDRA_CAST<int *>(0x0)) &&
|
||||
(isPlaying = (**(code **)(**GHIDRA_CAST<int **>((this->_channels + channelIdx)) + 0x28))(),
|
||||
isPlaying != '\0')) {
|
||||
piVar2 = *GHIDRA_CAST<int **>((this->_channels + channelIdx));
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[channelIdx])) + 0x8))) = 0;
|
||||
if (piVar2 != GHIDRA_CAST<int *>(0x0)) {
|
||||
(**(code **)(*piVar2 + 0x40))(0);
|
||||
}
|
||||
}
|
||||
layersLeft = 6;
|
||||
piVar2 = GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[channelIdx])) + 0x34))));
|
||||
do {
|
||||
if ((GHIDRA_CAST<int *>(*piVar2) != GHIDRA_CAST<int *>(0x0)) &&
|
||||
(isPlaying = (**(code **)(*GHIDRA_CAST<int *>(*piVar2) + 0x28))(), isPlaying != '\0')) {
|
||||
*GHIDRA_CAST<undefined1 *>((piVar2 + 2)) = 0;
|
||||
if (GHIDRA_CAST<int *>(*piVar2) != GHIDRA_CAST<int *>(0x0)) {
|
||||
(**(code **)(*GHIDRA_CAST<int *>(*piVar2) + 0x40))(0);
|
||||
}
|
||||
}
|
||||
piVar2 = piVar2 + 0xd;
|
||||
layersLeft = layersLeft + -1;
|
||||
} while (layersLeft != 0);
|
||||
this->_channels[this->_currentChannel]._fadeRate = fadeRate;
|
||||
newChannel = this->_currentChannel + 1U & 0x80000001;
|
||||
if (GHIDRA_INT(newChannel) < 0) {
|
||||
newChannel = (newChannel - 1 | 0xfffffffe) + 1;
|
||||
}
|
||||
this->_currentChannel = newChannel;
|
||||
manager = g_manager;
|
||||
this->_currentMusicID = musicId;
|
||||
this->_queuedMusicID = 0;
|
||||
this->_channels[newChannel]._volume = 0.0;
|
||||
this->_channels[newChannel]._targetVolume = (manager->_optionsConfig)._musicVolume;
|
||||
MusicChannel::play_track(pvVar1);
|
||||
this->_channels[newChannel]._fadeRate = fadeRate;
|
||||
FUN_007df5b0();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 007e2280
|
||||
void MusicManager::EnableLayer(int layerId, byte isInstant)
|
||||
{
|
||||
int iVar1;
|
||||
char isAnyLayer;
|
||||
int channelOffset;
|
||||
int extraout_EDX;
|
||||
undefined4 fullVolume;
|
||||
undefined4 volume;
|
||||
int *enabledLayers;
|
||||
|
||||
if ((GHIDRA_UINT(layerId) < 6) &&
|
||||
(enabledLayers = &this->_channels[this->_currentChannel]._enabledLayers + (GHIDRA_UINT(layerId) >> 5),
|
||||
*enabledLayers = *enabledLayers | 1 << ((byte)layerId & 0x1f), isInstant != 0)) {
|
||||
iVar1 = this->_currentChannel;
|
||||
channelOffset = iVar1 * 0x184;
|
||||
enabledLayers = &this->_channels[iVar1]._enabledLayers;
|
||||
fullVolume = 0x3f800000;
|
||||
if ((*enabledLayers != 0) && (this->_channels[iVar1]._layerMode == 2)) {
|
||||
isAnyLayer = std::bitset<8>::any();
|
||||
if (isAnyLayer == '\0') {
|
||||
volume = fullVolume;
|
||||
}
|
||||
else {
|
||||
volume = 0;
|
||||
}
|
||||
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[iVar1])) + 0x20)))) = volume;
|
||||
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[iVar1])) + 0x1c)))) = volume;
|
||||
channelOffset = extraout_EDX;
|
||||
}
|
||||
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[iVar1])) + 0x5c))) != '\0') {
|
||||
if ((*enabledLayers & 1) == 0) {
|
||||
volume = 0;
|
||||
}
|
||||
else {
|
||||
volume = fullVolume;
|
||||
}
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0x54))) + channelOffset)) = volume;
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0x50))) + channelOffset)) = volume;
|
||||
}
|
||||
if ((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0x90))))[channelOffset] != '\0') {
|
||||
if ((*enabledLayers & 2) == 0) {
|
||||
volume = 0;
|
||||
}
|
||||
else {
|
||||
volume = fullVolume;
|
||||
}
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0x88))) + channelOffset)) = volume;
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0x84))) + channelOffset)) = volume;
|
||||
}
|
||||
if ((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0xc4))))[channelOffset] != '\0') {
|
||||
if ((*enabledLayers & 4) == 0) {
|
||||
volume = 0;
|
||||
}
|
||||
else {
|
||||
volume = fullVolume;
|
||||
}
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0xbc))) + channelOffset)) = volume;
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0xb8))) + channelOffset)) = volume;
|
||||
}
|
||||
if ((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0xf8))))[channelOffset] != '\0') {
|
||||
if ((*enabledLayers & 8) == 0) {
|
||||
volume = 0;
|
||||
}
|
||||
else {
|
||||
volume = fullVolume;
|
||||
}
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0xf0))) + channelOffset)) = volume;
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0xec))) + channelOffset)) = volume;
|
||||
}
|
||||
if ((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0x12c))))[channelOffset] != '\0') {
|
||||
if ((*enabledLayers & 0x10) == 0) {
|
||||
volume = 0;
|
||||
}
|
||||
else {
|
||||
volume = fullVolume;
|
||||
}
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0x124))) + channelOffset)) = volume;
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0x120))) + channelOffset)) = volume;
|
||||
}
|
||||
if ((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0x160))))[channelOffset] != '\0') {
|
||||
if ((*enabledLayers & 0x20) == 0) {
|
||||
fullVolume = 0;
|
||||
}
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0x158))) + channelOffset)) = fullVolume;
|
||||
*GHIDRA_CAST<undefined4 *>((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this->_channels[0])) + 0x154))) + channelOffset)) = fullVolume;
|
||||
}
|
||||
(GHIDRA_CAST<MusicChannel *>((this->_channels + iVar1)))->MusicChannel::update_volume(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 007e2480
|
||||
void MusicManager::Queue(int musicId)
|
||||
{
|
||||
if ((-1 < musicId) &&
|
||||
(musicId < (GHIDRA_INT((this->_entries)._end) - GHIDRA_INT((this->_entries)._begin)) / 0x60)) {
|
||||
this->_queuedMusicID = musicId;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 007e24c0
|
||||
void MusicManager::PitchSlide(float param_2)
|
||||
{
|
||||
this->_targetPitch = param_2;
|
||||
return;
|
||||
}
|
||||
|
||||
// 0085e410
|
||||
void MusicManager::Enable()
|
||||
{
|
||||
this->_isEnabled = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
// 0085e420
|
||||
void MusicManager::Disable()
|
||||
{
|
||||
this->_isEnabled = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// 0085e430
|
||||
byte MusicManager::IsEnabled()
|
||||
{
|
||||
return this->_isEnabled;
|
||||
}
|
||||
|
||||
// 0086fc60
|
||||
Game * MusicManager::Game_0()
|
||||
{
|
||||
return g_game;
|
||||
}
|
||||
Reference in new issue
Block a user