- anm2.h/.cpp take over ANM2, AnimationState, LayerState, AnmCache and the frame data. They read Anm2Ed's JSON documents with simdjson and play them as the game does (interpolation baked at load). src/anm2/ and msvc.h are retired. - font, formatted_text, string_table and rich_text take over the text classes. FormattedText::parse is still bit-exact against its assembly. - options_config and challenge_params take over OptionsConfig, ChallengeParams and the .ini helpers. The tests include Save's exact bytes. - platform.h/.cpp and main.cpp run IsaacMain on SDL3: the window and GL context open, and the run stops at the first built-in shader (FUN_00a13fa0). - source_tree.py: a taken-over parent stays bytes, taken-over methods are not re-emitted as a namespace, and every address in a (a, b, c to d) list on a comment counts as taken over. - log.h: reconstruction_missing() for a taken-over class's methods that are not written yet. 206 functions taken over, boot path 89/615. The full build waits for wave B: item_config, entity_config and mod_manager still use the old APIs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
522 lines
18 KiB
C++
522 lines
18 KiB
C++
#include "classes.h"
|
|
|
|
// 00a11c70
|
|
void * KAGE_Graphics::create_image(void *outImage, int width, int height, int format, uint8_t *name)
|
|
{
|
|
uint8_t bVar1;
|
|
char isLoaded;
|
|
uint32_t uVar2;
|
|
void *allocation;
|
|
uint32_t *extraout_ECX;
|
|
uint32_t *extraout_ECX_00;
|
|
uint32_t *extraout_ECX_01;
|
|
uint32_t *extraout_ECX_02;
|
|
uint32_t *extraout_ECX_03;
|
|
uint32_t *extraout_ECX_04;
|
|
uint32_t *image;
|
|
uint8_t *nameEnd;
|
|
char *nameCopy;
|
|
char *nameSrc;
|
|
uint8_t **stream;
|
|
int *imageRef;
|
|
int *imageRefCount;
|
|
uint32_t local_18;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
int *imageObj;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00b10a5e;
|
|
local_10 = ExceptionList;
|
|
uVar2 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
ExceptionList = &local_10;
|
|
local_18 = 0;
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>((&imageRef)))->KAGE::SmartPointer::SmartPointer((void *)0x0);
|
|
local_8 = 1;
|
|
switch(format) {
|
|
case 0:
|
|
allocation = operator_new(0x60);
|
|
if (allocation == (void *)0x0) {
|
|
LAB_00a11d91:
|
|
image = GHIDRA_CAST<uint32_t *>(0x0);
|
|
}
|
|
else {
|
|
FUN_00a69950(uVar2);
|
|
*extraout_ECX = KAGE::Graphics::ImagePng::vftable;
|
|
image = extraout_ECX;
|
|
}
|
|
break;
|
|
case 1:
|
|
allocation = operator_new(0x60);
|
|
if (allocation == (void *)0x0) goto LAB_00a11d91;
|
|
FUN_00a69950(uVar2);
|
|
*extraout_ECX_00 = KAGE::Graphics::ImageJpg::vftable;
|
|
image = extraout_ECX_00;
|
|
break;
|
|
case 2:
|
|
allocation = operator_new(0x60);
|
|
if (allocation == (void *)0x0) goto LAB_00a11d91;
|
|
FUN_00a69950(uVar2);
|
|
*extraout_ECX_01 = KAGE::Graphics::ImageBmp::vftable;
|
|
image = extraout_ECX_01;
|
|
break;
|
|
case 3:
|
|
allocation = operator_new(0x60);
|
|
if (allocation == (void *)0x0) goto LAB_00a11d91;
|
|
FUN_00a69950(uVar2);
|
|
*extraout_ECX_02 = KAGE::Graphics::ImagePcx::vftable;
|
|
image = extraout_ECX_02;
|
|
break;
|
|
case 4:
|
|
allocation = operator_new(0x60);
|
|
if (allocation == (void *)0x0) goto LAB_00a11d91;
|
|
FUN_00a69950(uVar2);
|
|
*extraout_ECX_03 = KAGE::Graphics::ImageRGBA::vftable;
|
|
image = extraout_ECX_03;
|
|
break;
|
|
case 5:
|
|
allocation = operator_new(0x60);
|
|
if (allocation == (void *)0x0) goto LAB_00a11d91;
|
|
FUN_00a69950(uVar2);
|
|
*extraout_ECX_04 = KAGE::Graphics::ImagePlatform::vftable;
|
|
image = extraout_ECX_04;
|
|
break;
|
|
default:
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("Unknown image format \'%d\' passed to LoadImage\n"));
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>((outImage)))->KAGE::SmartPointer::SmartPointer((void *)0x0);
|
|
local_8 = 2;
|
|
goto LAB_00a11edd;
|
|
}
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>((&imageRef)))->KAGE::SmartPointer::reset(image);
|
|
imageObj = imageRef;
|
|
if ((imageRef == GHIDRA_CAST<int *>(0x0)) || ((**(code **)(*imageRef + 0x3c))(), width == 0)) {
|
|
LAB_00a11e8b:
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>((&imageRef)))->KAGE::SmartPointer::reset((void *)0x0);
|
|
}
|
|
else {
|
|
stream = KAGE::Filesys::BufferedStream::vftable;
|
|
local_8 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),3);
|
|
isLoaded = (**(code **)(*imageObj + 0x38))(&stream,name);
|
|
if (isLoaded != '\0') {
|
|
nameSrc = "unknown";
|
|
if (name != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
nameSrc = GHIDRA_CAST<char *>(name);
|
|
}
|
|
if (GHIDRA_CAST<uint8_t *>(nameSrc) == GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
nameCopy = GHIDRA_CAST<char *>(0x0);
|
|
}
|
|
else {
|
|
nameEnd = GHIDRA_CAST<uint8_t *>(nameSrc);
|
|
do {
|
|
bVar1 = *nameEnd;
|
|
nameEnd = nameEnd + 1;
|
|
} while (bVar1 != 0);
|
|
nameCopy = operator_new_tracked(GHIDRA_UINT((nameEnd + (1 - GHIDRA_INT((nameSrc + 1))))));
|
|
nameEnd = GHIDRA_CAST<uint8_t *>(nameSrc);
|
|
do {
|
|
bVar1 = *nameEnd;
|
|
nameEnd = nameEnd + 1;
|
|
} while (bVar1 != 0);
|
|
strncpy(nameCopy,nameSrc,(size_t)(nameEnd + (1 - GHIDRA_INT((nameSrc + 1)))));
|
|
}
|
|
imageObj[0x10] = GHIDRA_INT(nameCopy);
|
|
}
|
|
FUN_00a12c00();
|
|
local_8 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),1);
|
|
FUN_00a58200();
|
|
if (isLoaded == '\0') goto LAB_00a11e8b;
|
|
(**(code **)(*imageRef + 0x40))();
|
|
FUN_00a120f0(&imageRef);
|
|
}
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>((outImage)))->KAGE::SmartPointer::operator_assign(&imageRef);
|
|
local_8 = 4;
|
|
LAB_00a11edd:
|
|
local_18 = 1;
|
|
if (((imageRefCount != GHIDRA_CAST<int *>(0x0)) &&
|
|
(isLoaded = (**(code **)(*imageRefCount + 0xc))(), isLoaded != '\0')) &&
|
|
(g_imageReleaseFn != (void *)0x0)) {
|
|
(*g_imageReleaseFn)(&imageRef);
|
|
}
|
|
ExceptionList = local_10;
|
|
return outImage;
|
|
}
|
|
|
|
// 00a139f0
|
|
void KAGE_Graphics::flush_batches()
|
|
{
|
|
int iVar1;
|
|
uint32_t uVar2;
|
|
int *piVar3;
|
|
int *piVar4;
|
|
int *batchIt;
|
|
int *batchListEnd;
|
|
int setVertexOffset;
|
|
int local_28;
|
|
int *local_24;
|
|
int local_20;
|
|
int vertexOffset;
|
|
int *local_18;
|
|
int *local_14;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
int bufferArray;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00b10c9d;
|
|
local_10 = ExceptionList;
|
|
uVar2 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
ExceptionList = &local_10;
|
|
piVar4 = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 0x80));
|
|
local_24 = this;
|
|
if (piVar4 != *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 0x84))) {
|
|
do {
|
|
submit_batch(uVar2);
|
|
local_18 = GHIDRA_CAST<int *>(*piVar4);
|
|
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_18) + 8));
|
|
if (iVar1 != 0) {
|
|
*GHIDRA_CAST<uint32_t *>((iVar1 + 0x50)) = *GHIDRA_CAST<uint32_t *>((iVar1 + 0x4c));
|
|
local_18 = GHIDRA_CAST<int *>(*piVar4);
|
|
}
|
|
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_18) + 0x3c));
|
|
bufferArray = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_18) + 0x38));
|
|
vertexOffset = (*GHIDRA_CAST<int *>((bufferArray + 8 + iVar1 * 0x14)) -
|
|
*GHIDRA_CAST<int *>((bufferArray + 0xc + iVar1 * 0x14))) +
|
|
*GHIDRA_CAST<int *>((bufferArray + 4 + iVar1 * 0x14));
|
|
FUN_00a13ca0(&local_20,&vertexOffset);
|
|
piVar4 = piVar4 + 1;
|
|
} while (piVar4 != *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 0x84)));
|
|
piVar4 = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 0x80));
|
|
}
|
|
piVar3 = local_24;
|
|
*GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 0x84)) = piVar4;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x94)) = 0;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x68)) == 0) {
|
|
local_14 = GHIDRA_CAST<int *>(0x0);
|
|
batchListEnd = GHIDRA_CAST<int *>(0x0);
|
|
local_20 = 0;
|
|
local_8 = 0;
|
|
uVar2 = local_24[0x24];
|
|
if (uVar2 != 0) {
|
|
if (0x3fffffff < uVar2) {
|
|
/* WARNING: Subroutine does not return */
|
|
msvc::_Xlen();
|
|
}
|
|
msvc::vector<unsigned_int>::_Reallocate(uVar2);
|
|
}
|
|
local_14 = GHIDRA_CAST<int *>(0x0);
|
|
local_20 = 0;
|
|
local_18 = piVar3 + 0x23;
|
|
piVar4 = GHIDRA_CAST<int *>(*local_18);
|
|
local_24 = GHIDRA_CAST<int *>(*piVar4);
|
|
piVar3 = GHIDRA_CAST<int *>(0x0);
|
|
if (local_24 != piVar4) {
|
|
do {
|
|
piVar4 = local_24 + 5;
|
|
(**(code **)(*GHIDRA_CAST<int *>((local_24[5] + 0x34)) + 0x10))();
|
|
if (batchListEnd == GHIDRA_CAST<int *>(0x0)) {
|
|
msvc::vector<unsigned_int>::_Emplace_reallocate(0,piVar4);
|
|
}
|
|
else {
|
|
*batchListEnd = *piVar4;
|
|
batchListEnd = batchListEnd + 1;
|
|
}
|
|
msvc::
|
|
_Tree_unchecked_const_iterator<msvc::_Tree_val<msvc::_Tree_simple_types<unsigned_int>_>,msvc::_Iterator_base0>
|
|
::operator++((_Tree_unchecked_const_iterator<msvc::_Tree_val<msvc::_Tree_simple_types<unsigned_int>_>,msvc::_Iterator_base0>
|
|
*)&local_24);
|
|
piVar4 = GHIDRA_CAST<int *>(*local_18);
|
|
piVar3 = batchListEnd;
|
|
} while (local_24 != piVar4);
|
|
}
|
|
local_14 = GHIDRA_CAST<int *>(0x0);
|
|
local_20 = 0;
|
|
batchIt = GHIDRA_CAST<int *>(0x0);
|
|
FID_conflict__Erase_tree<fuzzer::fuzzer_allocator<msvc::_Tree_node<fuzzer::TracePC::PCTableEntry_const*,void*>_>_>
|
|
(local_18,(fuzzer_allocator<msvc::_Tree_node<unsigned_int,void*>_> *)local_18,
|
|
(_Tree_node<unsigned_int,void*> *)piVar4[1]);
|
|
piVar4[1] = GHIDRA_INT(piVar4);
|
|
*piVar4 = GHIDRA_INT(piVar4);
|
|
piVar4[2] = GHIDRA_INT(piVar4);
|
|
local_18[1] = 0;
|
|
if (piVar3 != GHIDRA_CAST<int *>(0x0)) {
|
|
do {
|
|
local_28 = *batchIt;
|
|
iVar1 = *GHIDRA_CAST<int *>((local_28 + 0x3c));
|
|
bufferArray = *GHIDRA_CAST<int *>((local_28 + 0x38));
|
|
setVertexOffset =
|
|
(*GHIDRA_CAST<int *>((bufferArray + 8 + iVar1 * 0x14)) - *GHIDRA_CAST<int *>((bufferArray + 0xc + iVar1 * 0x14)))
|
|
+ *GHIDRA_CAST<int *>((bufferArray + 4 + iVar1 * 0x14));
|
|
FUN_00a13ca0(&local_24,&setVertexOffset);
|
|
batchIt = batchIt + 1;
|
|
} while (batchIt != piVar3);
|
|
batchIt = local_14;
|
|
}
|
|
if (batchIt != GHIDRA_CAST<int *>(0x0)) {
|
|
uVar2 = local_20 - GHIDRA_INT(batchIt) & 0xfffffffc;
|
|
piVar4 = batchIt;
|
|
if (0xfff < uVar2) {
|
|
piVar4 = GHIDRA_CAST<int *>(batchIt[-1]);
|
|
uVar2 = uVar2 + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(batchIt) + (-4 - GHIDRA_INT(piVar4))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(piVar4,uVar2);
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 00a18300
|
|
void KAGE_Graphics::SetRenderTarget(void *target, uint8_t isNoFlip)
|
|
{
|
|
int framebufferStatus;
|
|
|
|
*(void **)(GHIDRA_CAST<char *>(this) + 0x68) = target;
|
|
if ((target == (void *)0x0) || (isNoFlip != 0)) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 4)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 4)) | 0x20;
|
|
if (target == (void *)0x0) {
|
|
(*(code *)epoxy_glBindFramebuffer)(0x8d40,0);
|
|
update_depth_renderbuffer(this,0);
|
|
(*(code *)epoxy_glCullFace)(0x405);
|
|
(**(code **)(*GHIDRA_CAST<int *>(this) + 0x7c))();
|
|
update_projection(this);
|
|
return;
|
|
}
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 4)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 4)) & 0xffffffdf;
|
|
}
|
|
update_depth_renderbuffer(this,0);
|
|
(*(code *)epoxy_glBindFramebuffer)(0x8d40,*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0xac)));
|
|
(*(code *)epoxy_glFramebufferTexture2D)(0x8d40,0x8ce0,0xde1,*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(target) + 0x58)),0)
|
|
;
|
|
(*(code *)epoxy_glCullFace)(0x404);
|
|
(*(code *)epoxy_glViewport)
|
|
(0,0,*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(target) + 0x10)),*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(target) + 0x14)));
|
|
update_projection(this);
|
|
framebufferStatus = (*(code *)epoxy_glCheckFramebufferStatus)(0x8d40);
|
|
if (framebufferStatus != 0x8cd5) {
|
|
if (framebufferStatus != 0x8cd9) {
|
|
if (framebufferStatus == 0x8cdd) {
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("GL_FRAMEBUFFER_UNSUPPORTED\n"));
|
|
return;
|
|
}
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("Framebuffer nok Status %x\n"));
|
|
return;
|
|
}
|
|
(*(code *)epoxy_glFramebufferRenderbuffer)(0x8d40,0x8d00,0x8d41,0);
|
|
framebufferStatus = (*(code *)epoxy_glCheckFramebufferStatus)(0x8d40);
|
|
if (framebufferStatus != 0x8cd5) {
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("framebuffer still nok after detaching depth buffer, Status %x\n"));
|
|
return;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 00a18530
|
|
void KAGE_Graphics::update_projection()
|
|
{
|
|
uint32_t transformLocation;
|
|
float fVar1;
|
|
float fVar2;
|
|
float local_58 [6];
|
|
uint32_t local_40;
|
|
uint32_t local_3c;
|
|
uint32_t local_38;
|
|
uint32_t local_34;
|
|
uint32_t local_30;
|
|
uint32_t local_2c;
|
|
float local_28;
|
|
float local_24;
|
|
uint32_t local_20;
|
|
uint32_t local_1c;
|
|
float local_14;
|
|
uint32_t program;
|
|
int renderTarget;
|
|
|
|
local_14 = (float)(__security_cookie ^ GHIDRA_UINT((local_58 + 0x12)));
|
|
if (g_currentShader == (void *)0x0) {
|
|
return;
|
|
}
|
|
renderTarget = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x68));
|
|
if ((renderTarget == 0) || ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(this) + 4)) & 0x20) != 0)) {
|
|
local_58[5] = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0xa0));
|
|
if ((renderTarget != 0) && ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(this) + 4)) & 0x20) == 0)) goto LAB_00a185a5;
|
|
local_28 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x9c)) - 0.0;
|
|
fVar2 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x9c)) + 0.0;
|
|
fVar1 = local_58[5] + 0.0;
|
|
local_58[0] = 2.0 / local_28;
|
|
if (renderTarget == 0) {
|
|
local_58[5] = 0.0 - local_58[5];
|
|
local_24 = -fVar1 / local_58[5];
|
|
goto LAB_00a18638;
|
|
}
|
|
}
|
|
else {
|
|
local_58[5] = (float)((double)*GHIDRA_CAST<int *>((renderTarget + 0x14)) +
|
|
__uint_to_double_fixup[-(*GHIDRA_CAST<int *>((renderTarget + 0x14)) >> 0x1f)]);
|
|
LAB_00a185a5:
|
|
fVar1 = local_58[5] + 0.0;
|
|
fVar2 = (float)((double)*GHIDRA_CAST<int *>((renderTarget + 0x10)) +
|
|
__uint_to_double_fixup[-(*GHIDRA_CAST<int *>((renderTarget + 0x10)) >> 0x1f)]);
|
|
local_28 = fVar2 - 0.0;
|
|
fVar2 = fVar2 + 0.0;
|
|
local_58[0] = 2.0 / local_28;
|
|
}
|
|
local_58[5] = local_58[5] - 0.0;
|
|
local_24 = -fVar1 / local_58[5];
|
|
LAB_00a18638:
|
|
local_58[5] = 2.0 / local_58[5];
|
|
local_28 = -fVar2 / local_28;
|
|
local_1c = 0x3f800000;
|
|
local_20 = 0x80000000;
|
|
local_38 = 0;
|
|
local_34 = 0;
|
|
local_2c = 0;
|
|
local_30 = 0xba83126f;
|
|
local_58[4] = 0.0;
|
|
local_40 = 0;
|
|
local_3c = 0;
|
|
local_58[1] = 0.0;
|
|
local_58[2] = 0.0;
|
|
local_58[3] = 0.0;
|
|
program = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(g_currentShader) + 0x4c));
|
|
transformLocation = (*(code *)epoxy_glGetUniformLocation)(program,"Transform");
|
|
(*(code *)epoxy_glUseProgram)(program);
|
|
(*(code *)epoxy_glUniformMatrix4fv)(transformLocation,1,0,local_58);
|
|
return;
|
|
}
|
|
|
|
// 00a67bd0
|
|
uint32_t KAGE_Graphics::submit_batch()
|
|
{
|
|
uint32_t uVar1;
|
|
uint32_t uVar2;
|
|
uint32_t uVar3;
|
|
uint8_t *puVar4;
|
|
int iVar5;
|
|
short *index;
|
|
int in_ECX;
|
|
uint32_t vertexBytes;
|
|
int iVar6;
|
|
short *indexEnd;
|
|
uint32_t uVar7;
|
|
int bufferRanges;
|
|
int *local_24;
|
|
code *local_20;
|
|
uint32_t vertexCount;
|
|
int local_18;
|
|
uint32_t indexCount;
|
|
short baseVertex;
|
|
uint8_t *blendEquationFn;
|
|
int *indexBuffer;
|
|
|
|
vertexBytes = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((in_ECX + 0x38)) + 0xc + *GHIDRA_CAST<int *>((in_ECX + 0x3c)) * 0x14)) -
|
|
*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((in_ECX + 0x38)) + 0x10 + *GHIDRA_CAST<int *>((in_ECX + 0x3c)) * 0x14));
|
|
if (vertexBytes != 0) {
|
|
local_18 = in_ECX;
|
|
if (*GHIDRA_CAST<int **>((in_ECX + 8)) != GHIDRA_CAST<int *>(0x0)) {
|
|
(**(code **)(**GHIDRA_CAST<int **>((in_ECX + 8)) + 0x54))(0);
|
|
}
|
|
blendEquationFn = epoxy_glBlendEquation;
|
|
switch(*GHIDRA_CAST<uint32_t *>((in_ECX + 0x10))) {
|
|
case 0:
|
|
uVar1 = 0x8006;
|
|
break;
|
|
case 1:
|
|
uVar1 = 0x800a;
|
|
break;
|
|
case 2:
|
|
uVar1 = 0x800b;
|
|
break;
|
|
case 3:
|
|
uVar1 = 0x8007;
|
|
break;
|
|
case 4:
|
|
uVar1 = 0x8008;
|
|
break;
|
|
default:
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Unknwon blend function specified\n"));
|
|
uVar1 = 0xffffffff;
|
|
}
|
|
(*(code *)blendEquationFn)(uVar1);
|
|
local_20 = (code *)epoxy_glBlendFuncSeparate;
|
|
local_24 = GHIDRA_CAST<int *>(FUN_00a18a20());
|
|
uVar1 = FUN_00a18a20();
|
|
uVar2 = FUN_00a18a20();
|
|
uVar3 = FUN_00a18a20();
|
|
(*local_20)(uVar3,uVar2,uVar1,local_24);
|
|
in_ECX = local_18;
|
|
g_currentShader = *(void **)(local_18 + 0x24);
|
|
local_24 = g_currentShader;
|
|
(**(code **)(*GHIDRA_CAST<int *>(g_currentShader) + 0xc))(local_18 + 0x28);
|
|
puVar4 = GHIDRA_CAST<uint8_t *>(FUN_00a14250(&local_24));
|
|
indexBuffer = DAT_00c7367c;
|
|
*puVar4 = 1;
|
|
(**(code **)(*indexBuffer + 4))();
|
|
(**(code **)(*GHIDRA_CAST<int *>((in_ECX + 0x34)) + 4))();
|
|
local_24 = *GHIDRA_CAST<int **>((*GHIDRA_CAST<int *>((in_ECX + 0x38)) + 0x10 + *GHIDRA_CAST<int *>((in_ECX + 0x3c)) * 0x14));
|
|
local_20 = (code *)FUN_00a24e10();
|
|
vertexCount = vertexBytes / GHIDRA_UINT(local_20);
|
|
if (vertexBytes % GHIDRA_UINT(local_20) != 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Misaligned vertex data"));
|
|
}
|
|
iVar6 = DAT_00c7367c[2];
|
|
bufferRanges = DAT_00c7367c[1];
|
|
indexCount = *GHIDRA_CAST<uint32_t *>((bufferRanges + 8 + iVar6 * 0x14)) >> 1;
|
|
iVar5 = (GHIDRA_INT((vertexCount + (GHIDRA_INT(vertexCount) >> 0x1f & 3U))) >> 2) * 6 - indexCount;
|
|
if (0 < iVar5) {
|
|
uVar7 = GHIDRA_UINT(((uint64_t)indexCount * 0xaaaaaaab >> 0x20)) & 0xfffffffc;
|
|
(**(code **)(*DAT_00c7367c + 8))((iVar5 + indexCount) * 2);
|
|
iVar6 = DAT_00c7367c[2];
|
|
bufferRanges = DAT_00c7367c[1];
|
|
iVar5 = *GHIDRA_CAST<int *>((bufferRanges + 4 + iVar6 * 0x14));
|
|
indexEnd = GHIDRA_CAST<short *>((*GHIDRA_CAST<int *>((bufferRanges + 8 + iVar6 * 0x14)) + iVar5));
|
|
index = GHIDRA_CAST<short *>((iVar5 + indexCount * 2));
|
|
if (index < indexEnd) {
|
|
do {
|
|
baseVertex = (short)uVar7;
|
|
uVar7 = uVar7 + 4;
|
|
*index = baseVertex;
|
|
index[2] = baseVertex + 1;
|
|
index[3] = baseVertex + 1;
|
|
index[1] = baseVertex + 2;
|
|
index[4] = baseVertex + 2;
|
|
index[5] = baseVertex + 3;
|
|
index = index + 6;
|
|
} while (index < indexEnd);
|
|
iVar6 = DAT_00c7367c[2];
|
|
bufferRanges = DAT_00c7367c[1];
|
|
}
|
|
in_ECX = local_18;
|
|
}
|
|
uVar1 = *GHIDRA_CAST<uint32_t *>((bufferRanges + 4 + iVar6 * 0x14));
|
|
if (g_currentShader == (void *)0x0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("No shader set\n"));
|
|
}
|
|
uVar7 = vertexCount;
|
|
(**(code **)(*GHIDRA_CAST<int *>(g_currentShader) + 0x20))(local_24,vertexCount,local_20);
|
|
(*(code *)epoxy_glDrawElements)(4,(uVar7 >> 2) * 6,0x1403,uVar1);
|
|
(**(code **)(*GHIDRA_CAST<int *>(g_currentShader) + 0x24))(local_24,uVar7,local_20);
|
|
iVar6 = *GHIDRA_CAST<int *>((in_ECX + 0x38)) + *GHIDRA_CAST<int *>((in_ECX + 0x3c)) * 0x14;
|
|
*GHIDRA_CAST<uint32_t *>((iVar6 + 0x10)) = *GHIDRA_CAST<uint32_t *>((iVar6 + 0xc));
|
|
(**(code **)(*DAT_00c7367c + 0xc))();
|
|
DAT_00c79928 = 0;
|
|
DAT_00c7992c = 0;
|
|
uRam00c79930 = 0;
|
|
uRam00c79934 = 0;
|
|
_DAT_00c79938 = 0;
|
|
uRam00c7993c = 0;
|
|
uRam00c79940 = 0;
|
|
uRam00c79944 = 0;
|
|
}
|
|
*GHIDRA_CAST<uint8_t *>((in_ECX + 4)) = *GHIDRA_CAST<uint8_t *>((in_ECX + 4)) & 0xfc;
|
|
return vertexBytes;
|
|
}
|