Files
isaac-port/generated-src/png_writer.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

122 lines
4.8 KiB
C++

#include "classes.h"
// 009e8d40
void PngWriter::write_end()
{
void *pngPtr;
int compression;
undefined4 *in_ECX;
int *textChunk;
int textOffset;
undefined1 exception [12];
int textIndex;
undefined4 *local_c;
undefined1 crcBytes;
undefined1 local_7;
undefined1 local_6;
undefined1 local_5;
int compression;
undefined4 crc;
local_c = in_ECX;
compression = setjmp3(*in_ECX,0);
if (compression != 0) {
FUN_009e6bd0(local_c + 0x14);
/* WARNING: Subroutine does not return */
_CxxThrowException(exception,GHIDRA_CAST<ThrowInfo *>(&DAT_00bd5cc0));
}
pngPtr = (void *)local_c[0x12];
compression = local_c[0x13];
if ((*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(pngPtr) + 0x60)) & 4) == 0) {
/* WARNING: Subroutine does not return */
FUN_00a64610();
}
if (compression != 0) {
if (((*GHIDRA_CAST<uint *>((compression + 8)) & 0x200) != 0) && ((*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(pngPtr) + 100)) & 0x10000) == 0)) {
FUN_00a931f0();
}
textIndex = 0;
if (0 < *GHIDRA_CAST<int *>((compression + 0x30))) {
textOffset = 0;
do {
textChunk = GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((compression + 0x38)) + textOffset));
compression = *textChunk;
if (compression < 0) {
if (compression == -1) {
FUN_00a92520(textChunk[2],textChunk[3]);
*GHIDRA_CAST<undefined4 *>((textOffset + *GHIDRA_CAST<int *>((compression + 0x38)))) = 0xfffffffd;
}
}
else {
png_write_zTXt(textChunk[2],textChunk[3],compression);
*GHIDRA_CAST<undefined4 *>((textOffset + *GHIDRA_CAST<int *>((compression + 0x38)))) = 0xfffffffe;
}
textOffset = textOffset + 0x10;
textIndex = textIndex + 1;
} while (textIndex < *GHIDRA_CAST<int *>((compression + 0x30)));
}
}
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(pngPtr) + 0x60)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(pngPtr) + 0x60)) | 8;
png_write_chunk_header(pngPtr,GHIDRA_CAST<byte *>(&DAT_00c12990),0);
crc = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(pngPtr) + 0x108));
local_5 = (undefined1)crc;
crcBytes = (undefined1)(GHIDRA_UINT(crc) >> 0x18);
local_7 = (undefined1)(GHIDRA_UINT(crc) >> 0x10);
local_6 = (undefined1)(GHIDRA_UINT(crc) >> 8);
if (*(code **)(GHIDRA_CAST<char *>(pngPtr) + 0x4c) == (code *)0x0) {
/* WARNING: Subroutine does not return */
FUN_00a64610();
}
(**(code **)(GHIDRA_CAST<char *>(pngPtr) + 0x4c))(pngPtr,&crcBytes,4);
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(pngPtr) + 0x60)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(pngPtr) + 0x60)) | 0x10;
return;
}
// 009e8ee0
void PngWriter::write_info()
{
int iVar1;
void *pvVar2;
int iVar3;
undefined1 local_14 [12];
void *local_8;
int pngInfo;
local_8 = this;
iVar3 = setjmp3(*GHIDRA_CAST<undefined4 *>(this),0);
pvVar2 = local_8;
if (iVar3 != 0) {
FUN_009e6bd0(GHIDRA_INT(local_8) + 0x50);
/* WARNING: Subroutine does not return */
_CxxThrowException(local_14,GHIDRA_CAST<ThrowInfo *>(&DAT_00bd5cc0));
}
FUN_00a63100(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_8) + 0x10)),*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_8) + 0x14)),
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_8) + 0x18)),*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_8) + 0x1c)),
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_8) + 0x20)),*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_8) + 0x24)),
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_8) + 0x28)));
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 0x1c)) == 3) {
iVar3 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 0x2c));
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 0x30));
if (((iVar3 != iVar1) && (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 8)) != 0)) &&
(pngInfo = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 0xc)), pngInfo != 0)) {
*GHIDRA_CAST<int *>((pngInfo + 0x10)) = iVar3;
*GHIDRA_CAST<uint *>((pngInfo + 8)) = *GHIDRA_CAST<uint *>((pngInfo + 8)) | 8;
*GHIDRA_CAST<short *>((pngInfo + 0x14)) = (short)((iVar1 - iVar3) / 3);
}
iVar3 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 0x38));
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 0x3c));
if (iVar3 != iVar1) {
pngInfo = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 0xc));
if ((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 8)) != 0) && (pngInfo != 0)) {
if (iVar3 != 0) {
*GHIDRA_CAST<int *>((pngInfo + 0x4c)) = iVar3;
}
*GHIDRA_CAST<uint *>((pngInfo + 8)) = *GHIDRA_CAST<uint *>((pngInfo + 8)) | 0x10;
*GHIDRA_CAST<short *>((pngInfo + 0x16)) = (short)iVar1 - (short)iVar3;
}
}
}
png_write_info();
return;
}