Files
isaac-port/generated-src/kage/filesys/buffered_stream.cpp
T
shweetandClaude Opus 5.5 9d4d4f5c64 Build 29: zero-length placeholder structs, generated-src with standard types
--check: 938/3256 method bodies compile for x86_64 (28.8%), 32-bit layout asserts hold; boot path 3/626 curated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:41:34 -05:00

150 lines
6.3 KiB
C++

#include "classes.h"
// 0090d360
void * KAGE::Filesys::BufferedStream::operator_assign(void *other)
{
uint32_t dataSize;
void *dstData;
int *buffer;
void *srcData;
buffer = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 0xc));
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 4)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(other) + 4));
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 8)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(other) + 8));
if (buffer != GHIDRA_CAST<int *>((GHIDRA_INT(other) + 0xc))) {
srcData = *(void **)(GHIDRA_CAST<char *>(other) + 0xc);
dstData = (void *)*buffer;
dataSize = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(other) + 0x10)) - GHIDRA_INT(srcData);
if (GHIDRA_UINT((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x14)) - GHIDRA_INT(dstData))) < dataSize) {
msvc::vector<char>::_Clear_and_reserve(dataSize);
dstData = (void *)*buffer;
}
memmove(dstData,srcData,dataSize);
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x10)) = dataSize + GHIDRA_INT(dstData);
}
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x18)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(other) + 0x18));
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x1c)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(other) + 0x1c));
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x20)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(other) + 0x20));
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x24)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(other) + 0x24));
return this;
}
// 00a57fc0
uint8_t KAGE::Filesys::BufferedStream::rebuffer()
{
uint32_t remainingBytes;
uint32_t readBytes;
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x18)) != 0) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Attempting to rebuffer data on a read-only buffer"));
}
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x10)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0xc));
remainingBytes = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) - *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x20));
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x24)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x20));
readBytes = 0;
if (-1 < GHIDRA_INT(remainingBytes)) {
readBytes = remainingBytes;
}
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x1c)) = 0;
if (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 8)) < readBytes) {
readBytes = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 8));
}
if (readBytes == 0) {
return 0;
}
FUN_007dccd0(readBytes);
this->vfunc_9(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x20)));
this->vfunc_10(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0xc)),1,readBytes);
return 1;
}
// 00a58040
KAGE::Filesys::BufferedStream::BufferedStream(int bufferSize)
{
uint32_t available;
uint32_t fillSize;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
puStack_c = &LAB_00b12b18;
local_10 = ExceptionList;
ExceptionList = &local_10;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 4)) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 8)) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0xc)) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x14)) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x18)) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x1c)) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x20)) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x24)) = 0;
*GHIDRA_CAST<uint8_t ***>((GHIDRA_CAST<char *>(this) + 0x28)) = StreamBase::vftable;
local_8 = 1;
*GHIDRA_CAST<uint8_t ***>(this) = vftable;
*GHIDRA_CAST<uint8_t ***>((GHIDRA_CAST<char *>(this) + 0x28)) = vftable;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 8)) = 0xffffffff;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x20)) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 4)) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x18)) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x1c)) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x10)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0xc));
available = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) - *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x20));
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x24)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x20));
fillSize = 0;
if (-1 < GHIDRA_INT(available)) {
fillSize = available;
}
if (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 8)) < fillSize) {
fillSize = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 8));
}
if (fillSize != 0) {
FUN_007dccd0(fillSize);
if (*(code **)(*GHIDRA_CAST<int *>(this) + 0x24) != GridEntity_Statue::Render) {
this->vfunc_9(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x20)));
}
if (*(code **)(*GHIDRA_CAST<int *>(this) + 0x28) != FUN_00a584b0) {
this->vfunc_10(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0xc)),1,fillSize);
}
}
if (bufferSize != 0) {
FUN_007dccd0(bufferSize);
}
ExceptionList = local_10;
return this;
}
// 00a58270
void KAGE::Filesys::BufferedStream::seek_base2(int param_1, int param_2)
{
int in_ECX;
uint32_t streamSize;
uint32_t bufferStart;
uint32_t position;
if (param_2 != 0) {
if (param_2 == 1) {
*GHIDRA_CAST<int *>((in_ECX + -8)) = *GHIDRA_CAST<int *>((in_ECX + -8)) + param_1;
goto LAB_00a582a0;
}
if (param_2 != 2) goto LAB_00a582a0;
param_1 = *GHIDRA_CAST<int *>((in_ECX + -0x24)) + param_1;
}
*GHIDRA_CAST<int *>((in_ECX + -8)) = param_1;
LAB_00a582a0:
if (*GHIDRA_CAST<int *>((in_ECX + -0x10)) == 0) {
streamSize = *GHIDRA_CAST<int *>((in_ECX + -0x18)) - *GHIDRA_CAST<int *>((in_ECX + -0x1c));
}
else {
streamSize = *GHIDRA_CAST<uint32_t *>((in_ECX + -0x24));
}
position = *GHIDRA_CAST<uint32_t *>((in_ECX + -8));
bufferStart = *GHIDRA_CAST<uint32_t *>((in_ECX + -4));
if ((position < bufferStart) || (streamSize < position - bufferStart)) {
rebuffer((void *)(in_ECX + -0x28));
position = *GHIDRA_CAST<uint32_t *>((in_ECX + -8));
bufferStart = *GHIDRA_CAST<uint32_t *>((in_ECX + -4));
}
*GHIDRA_CAST<uint32_t *>((in_ECX + -0xc)) = position - bufferStart;
return;
}