--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>
1028 lines
34 KiB
C++
1028 lines
34 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;
|
|
}
|
|
|
|
// 00a18750
|
|
void KAGE_Graphics::update_depth_renderbuffer(uint8_t isForced)
|
|
{
|
|
uint32_t uVar1;
|
|
uint32_t height;
|
|
uint32_t widthBits;
|
|
uint8_t shift;
|
|
uint32_t uVar2;
|
|
undefined3 in_stack_00000005;
|
|
uint32_t prevFramebuffer;
|
|
int currentHeight;
|
|
int pow2Width;
|
|
uint32_t *renderbufferId;
|
|
|
|
uVar1 = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0xb4));
|
|
if (GHIDRA_INT(uVar1) < 1) {
|
|
uVar1 = (**(code **)(*GHIDRA_CAST<int *>(this) + 0x5c))();
|
|
}
|
|
height = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0xb8));
|
|
if (GHIDRA_INT(height) < 1) {
|
|
height = (**(code **)(*GHIDRA_CAST<int *>(this) + 0x60))();
|
|
}
|
|
if ((isForced == 0) && (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xb0)) != 0)) {
|
|
(*(code *)epoxy_glBindRenderbuffer)(0x8d41,*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xb0)));
|
|
(*(code *)epoxy_glGetRenderbufferParameteriv)(0x8d41,0x8d42,&isForced);
|
|
(*(code *)epoxy_glGetRenderbufferParameteriv)(0x8d41,0x8d43,¤tHeight);
|
|
if ((GHIDRA_INT(uVar1) <= _isForced) && (GHIDRA_INT(height) <= currentHeight)) {
|
|
return;
|
|
}
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xb0)) != 0) {
|
|
(*(code *)epoxy_glDeleteRenderbuffers)(1,GHIDRA_INT(this) + 0xb0);
|
|
}
|
|
if (GHIDRA_INT(uVar1) < 9) {
|
|
uVar1 = 8;
|
|
uVar2 = 7;
|
|
widthBits = 4;
|
|
LAB_00a18808:
|
|
shift = 1;
|
|
do {
|
|
uVar2 = uVar2 | widthBits;
|
|
shift = shift + 1;
|
|
widthBits = uVar1 >> (shift & 0x1f);
|
|
} while (widthBits != 0);
|
|
}
|
|
else {
|
|
uVar2 = uVar1 - 1;
|
|
widthBits = uVar1 >> 1;
|
|
if (widthBits != 0) goto LAB_00a18808;
|
|
}
|
|
_isForced = uVar2 + 1;
|
|
if (GHIDRA_INT(height) < 9) {
|
|
height = 8;
|
|
uVar1 = 7;
|
|
uVar2 = 4;
|
|
}
|
|
else {
|
|
uVar1 = height - 1;
|
|
uVar2 = height >> 1;
|
|
if (uVar2 == 0) goto LAB_00a18850;
|
|
}
|
|
shift = 1;
|
|
do {
|
|
uVar1 = uVar1 | uVar2;
|
|
shift = shift + 1;
|
|
uVar2 = height >> (shift & 0x1f);
|
|
} while (uVar2 != 0);
|
|
LAB_00a18850:
|
|
(*(code *)epoxy_glGetIntegerv)(0x8ca6,&prevFramebuffer);
|
|
(*(code *)epoxy_glBindFramebuffer)(0x8d40,*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0xac)));
|
|
renderbufferId = GHIDRA_CAST<uint32_t *>((GHIDRA_INT(this) + 0xb0));
|
|
(*(code *)epoxy_glGenRenderbuffers)(1,renderbufferId);
|
|
pow2Width = _isForced;
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Renderbuffer ID: %d size %dx%d\n"));
|
|
(*(code *)epoxy_glBindRenderbuffer)(0x8d41,*renderbufferId);
|
|
(*(code *)epoxy_glRenderbufferStorage)(0x8d41,0x81a6,pow2Width,uVar1 + 1);
|
|
(*(code *)epoxy_glFramebufferRenderbuffer)(0x8d40,0x8d00,0x8d41,*renderbufferId);
|
|
(*(code *)epoxy_glBindFramebuffer)(0x8d40,prevFramebuffer);
|
|
return;
|
|
}
|
|
|
|
// 00a196b0
|
|
void KAGE_Graphics::set_fullscreen(uint8_t isFullscreen, uint8_t isExclusive)
|
|
{
|
|
void *pvVar1;
|
|
int iVar2;
|
|
HWND hWnd;
|
|
Vector *viewportOffset;
|
|
code *assertFn;
|
|
int *piVar3;
|
|
int cx;
|
|
bool isResizable;
|
|
HWND hWndInsertAfter;
|
|
int X;
|
|
int Y;
|
|
UINT uFlags;
|
|
uint32_t framebufferWidth;
|
|
uint32_t framebufferHeight;
|
|
void *local_8;
|
|
uint32_t currentModeAddr;
|
|
|
|
if (((uint8_t)(g_graphicsManager_flags >> 8) & 1) == isFullscreen) {
|
|
return;
|
|
}
|
|
if (isFullscreen == 0) {
|
|
g_graphicsManager_flags = g_graphicsManager_flags & 0xfffffeff;
|
|
FUN_00a6b0a0(DAT_00c799b0,DAT_00c799b4,DAT_00c799a8,DAT_00c799ac,0);
|
|
pvVar1 = g_glfwWindow;
|
|
assertFn = _wassert_exref;
|
|
if (g_glfwWindow == (void *)0x0) {
|
|
_wassert(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\window.c"
|
|
,0x3a3);
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(pvVar1) + 8)) = 1;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x40)) == 0) {
|
|
(*DAT_00c7377c)(pvVar1,1);
|
|
}
|
|
}
|
|
pvVar1 = g_glfwWindow;
|
|
isResizable = DAT_00c79a3d != '\0';
|
|
if (g_glfwWindow == (void *)0x0) {
|
|
_wassert(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\window.c"
|
|
,0x3a3);
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(pvVar1) + 4)) = GHIDRA_UINT(isResizable);
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x40)) == 0) {
|
|
(*DAT_00c73778)(pvVar1,GHIDRA_UINT(isResizable));
|
|
}
|
|
}
|
|
uFlags = 3;
|
|
iVar2 = 0;
|
|
cx = 0;
|
|
Y = 0;
|
|
X = 0;
|
|
hWndInsertAfter = (HWND)0xfffffffe;
|
|
hWnd = (HWND)FUN_00a5f090();
|
|
}
|
|
else {
|
|
g_graphicsManager_flags = g_graphicsManager_flags | 0x100;
|
|
local_8 = window_get_current_monitor(&DAT_00c798e0);
|
|
assertFn = _wassert_exref;
|
|
if (local_8 == (void *)0x0) {
|
|
_wassert(L"monitor != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\monitor.c"
|
|
,0x1c1);
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
piVar3 = GHIDRA_CAST<int *>(0x0);
|
|
}
|
|
else {
|
|
currentModeAddr = GHIDRA_INT(local_8) + 0x98;
|
|
iVar2 = (*DAT_00c736fc)(local_8,currentModeAddr);
|
|
piVar3 = GHIDRA_CAST<int *>((-GHIDRA_UINT((iVar2 != 0)) & currentModeAddr));
|
|
}
|
|
if (isExclusive != 0) {
|
|
FUN_00a6b0a0(0,0,*piVar3,piVar3[1],piVar3[5]);
|
|
goto LAB_00a1993f;
|
|
}
|
|
FUN_00a6b0a0(0,0,*piVar3 + 1,piVar3[1],0);
|
|
pvVar1 = g_glfwWindow;
|
|
if (g_glfwWindow == (void *)0x0) {
|
|
_wassert(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\window.c"
|
|
,0x3a3);
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(pvVar1) + 8)) = 0;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x40)) == 0) {
|
|
(*DAT_00c7377c)(pvVar1,0);
|
|
}
|
|
}
|
|
pvVar1 = g_glfwWindow;
|
|
if (g_glfwWindow == (void *)0x0) {
|
|
_wassert(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\window.c"
|
|
,0x3a3);
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(pvVar1) + 4)) = 0;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x40)) == 0) {
|
|
(*DAT_00c73778)(pvVar1,0);
|
|
}
|
|
}
|
|
iVar2 = piVar3[1];
|
|
cx = *piVar3 + 1;
|
|
hWnd = (HWND)FUN_00a5f090();
|
|
uFlags = 0x10;
|
|
Y = 0;
|
|
X = -1;
|
|
hWndInsertAfter = (HWND)0xffffffff;
|
|
}
|
|
SetWindowPos(hWnd,hWndInsertAfter,X,Y,cx,iVar2,uFlags);
|
|
LAB_00a1993f:
|
|
pvVar1 = g_glfwWindow;
|
|
if (g_glfwWindow == (void *)0x0) {
|
|
(*assertFn)(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\window.c"
|
|
,0x333);
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
}
|
|
else if ((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x40)) == 0) &&
|
|
((*DAT_00c73748)(pvVar1), *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x14)) != 0)) {
|
|
(*DAT_00c73754)(pvVar1);
|
|
}
|
|
pvVar1 = g_glfwWindow;
|
|
if (isFullscreen == 0) {
|
|
g_graphicsManager_flags = g_graphicsManager_flags & 0xfffff7ff;
|
|
}
|
|
else {
|
|
g_graphicsManager_flags = g_graphicsManager_flags | 0x800;
|
|
}
|
|
if (g_glfwWindow == (void *)0x0) {
|
|
(*assertFn)(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\window.c"
|
|
,0x260);
|
|
}
|
|
framebufferWidth = 0;
|
|
framebufferHeight = 0;
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
}
|
|
else {
|
|
(*DAT_00c73720)(pvVar1,&framebufferWidth,&framebufferHeight);
|
|
}
|
|
piVar3 = GHIDRA_CAST<int *>(*DAT_00c799b8);
|
|
if (piVar3 != DAT_00c799b8) {
|
|
do {
|
|
(*(code *)piVar3[2])(framebufferWidth,framebufferHeight,piVar3[3]);
|
|
piVar3 = GHIDRA_CAST<int *>(*piVar3);
|
|
} while (piVar3 != DAT_00c799b8);
|
|
}
|
|
viewportOffset = GHIDRA_CAST<Vector *>(&DAT_00c79984);
|
|
if ((g_graphicsManager_flags & 0x40) == 0) {
|
|
viewportOffset = &g_vectorZero;
|
|
}
|
|
(*(code *)epoxy_glViewport)
|
|
(GHIDRA_INT(viewportOffset->x),GHIDRA_INT(viewportOffset->y),DAT_00c799a8,DAT_00c799ac);
|
|
update_projection(&DAT_00c798e0);
|
|
update_depth_renderbuffer(&DAT_00c798e0,0);
|
|
pvVar1 = g_glfwWindow;
|
|
if (isFullscreen == 0) {
|
|
if (g_glfwWindow == (void *)0x0) {
|
|
(*assertFn)(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\input.c"
|
|
,0x24c);
|
|
}
|
|
if (_glfw != 0) {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x70)) == 0x34001) {
|
|
return;
|
|
}
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(pvVar1) + 0x70)) = 0x34001;
|
|
(*DAT_00c736a0)(pvVar1,GHIDRA_INT(pvVar1) + 0x1e0,GHIDRA_INT(pvVar1) + 0x1e8);
|
|
(*DAT_00c736a8)(pvVar1,0x34001);
|
|
return;
|
|
}
|
|
}
|
|
else {
|
|
if (g_glfwWindow == (void *)0x0) {
|
|
(*assertFn)(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\input.c"
|
|
,0x24c);
|
|
}
|
|
if (_glfw != 0) {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x70)) == 0x34002) {
|
|
return;
|
|
}
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(pvVar1) + 0x70)) = 0x34002;
|
|
(*DAT_00c736a0)(pvVar1,GHIDRA_INT(pvVar1) + 0x1e0,GHIDRA_INT(pvVar1) + 0x1e8);
|
|
(*DAT_00c736a8)(pvVar1,0x34002);
|
|
return;
|
|
}
|
|
}
|
|
_glfwInputError(0x10001,0);
|
|
return;
|
|
}
|
|
|
|
// 00a19df0
|
|
uint32_t KAGE_Graphics::create_window()
|
|
{
|
|
HMODULE hInstance;
|
|
HICON dwNewLong;
|
|
uint32_t windowStyle;
|
|
LPVOID currentContext;
|
|
int *piVar1;
|
|
int *in_ECX;
|
|
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 extraout_ECX_05;
|
|
uint32_t extraout_ECX_06;
|
|
uint32_t uVar2;
|
|
HWND hwnd;
|
|
uint32_t extraout_ECX_07;
|
|
int *piVar3;
|
|
LPCSTR lpIconName;
|
|
int iVar4;
|
|
int local_10;
|
|
|
|
glfwWindowHint();
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
uVar2 = extraout_ECX_00;
|
|
}
|
|
else {
|
|
_DAT_00c73830 = 0;
|
|
uVar2 = extraout_ECX;
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
uVar2 = extraout_ECX_01;
|
|
}
|
|
else {
|
|
_DAT_00c7383c = 0;
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
uVar2 = extraout_ECX_02;
|
|
}
|
|
else {
|
|
_DAT_00c73c6c = 2;
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
uVar2 = extraout_ECX_03;
|
|
}
|
|
else {
|
|
_DAT_00c73c70 = 0;
|
|
}
|
|
local_10 = glfwCreateWindow(DAT_00c79a30,uVar2,in_ECX[0x2f]);
|
|
if (local_10 == 0) {
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
uVar2 = extraout_ECX_05;
|
|
}
|
|
else {
|
|
_DAT_00c73c6c = 1;
|
|
uVar2 = extraout_ECX_04;
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
uVar2 = extraout_ECX_06;
|
|
}
|
|
else {
|
|
_DAT_00c73c70 = 0;
|
|
}
|
|
local_10 = glfwCreateWindow(DAT_00c79a30,uVar2,in_ECX[0x2f]);
|
|
if (local_10 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Failed to create OpenGL window / context\n"));
|
|
}
|
|
}
|
|
if (in_ECX[0x2f] != 0) {
|
|
FUN_00a6af90();
|
|
}
|
|
lpIconName = (LPCSTR)GHIDRA_UINT(DAT_00c79a40);
|
|
hInstance = GetModuleHandleA((LPCSTR)0x0);
|
|
dwNewLong = LoadIconA(hInstance,lpIconName);
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
hwnd = (HWND)0x0;
|
|
}
|
|
else if (DAT_00c73694 == 0x60001) {
|
|
hwnd = *GHIDRA_CAST<HWND *>((local_10 + 0x2b4));
|
|
}
|
|
else {
|
|
_glfwInputError(0x1000e,"Win32: Platform not initialized");
|
|
hwnd = (HWND)0x0;
|
|
}
|
|
SetClassLongA(hwnd,-0xe,(LONG)dwNewLong);
|
|
if ((in_ECX[1] & 0x400U) == 0) {
|
|
iVar4 = -0x10;
|
|
hwnd = (HWND)FUN_00a5f090(extraout_ECX_07);
|
|
windowStyle = GetWindowLongA(hwnd,iVar4);
|
|
windowStyle = windowStyle & 0xfffeffff;
|
|
iVar4 = -0x10;
|
|
hwnd = (HWND)FUN_00a5f090();
|
|
SetWindowLongA(hwnd,iVar4,windowStyle);
|
|
}
|
|
in_ECX[0x2f] = local_10;
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
goto LAB_00a1a0a2;
|
|
}
|
|
if (DAT_00c74b80 != 1) {
|
|
_wassert(L"tls->win32.allocated == GLFW_TRUE",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\win32_thread.c"
|
|
,0x3f);
|
|
}
|
|
currentContext = TlsGetValue(DAT_00c74b84);
|
|
if ((local_10 != 0) && (*GHIDRA_CAST<int *>((local_10 + 500)) == 0)) {
|
|
_glfwInputError(0x1000a,
|
|
"Cannot make current with a window that has no OpenGL or OpenGL ES context");
|
|
goto LAB_00a1a0a2;
|
|
}
|
|
if (currentContext == (LPVOID)0x0) {
|
|
LAB_00a1a092:
|
|
if (local_10 == 0) goto LAB_00a1a0a2;
|
|
}
|
|
else if ((local_10 == 0) || (*GHIDRA_CAST<int *>((local_10 + 0x1f8)) != *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(currentContext) + 0x1f8))))
|
|
{
|
|
(**(code **)(GHIDRA_CAST<char *>(currentContext) + 0x22c))(0);
|
|
goto LAB_00a1a092;
|
|
}
|
|
(**(code **)(local_10 + 0x22c))(local_10);
|
|
LAB_00a1a0a2:
|
|
(*(code *)epoxy_glGetString)(0x1f02);
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("OpenGL version %s\n"));
|
|
(*(code *)epoxy_glGetString)(0x8b8c);
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("GLSL version %s\n"));
|
|
piVar1 = in_ECX + 0x2b;
|
|
if (*piVar1 != 0) {
|
|
(*(code *)epoxy_glBindFramebuffer)(0x8d40,0);
|
|
(*(code *)epoxy_glDeleteFramebuffers)(1,piVar1);
|
|
}
|
|
if (epoxy_glGenFramebuffers == GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("glGenFramebuffers is NULL!\n"));
|
|
return 0;
|
|
}
|
|
(*(code *)epoxy_glGenFramebuffers)(1,piVar1);
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Framebuffer ID: %d\n"));
|
|
(*(code *)epoxy_glBindFramebuffer)(0x8d40,*piVar1);
|
|
update_depth_renderbuffer(in_ECX,1);
|
|
(*(code *)epoxy_glBindFramebuffer)(0x8d40,0);
|
|
iVar4 = in_ECX[0x2f];
|
|
if (iVar4 == 0) {
|
|
_wassert(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\window.c"
|
|
,0x41f);
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
}
|
|
else {
|
|
*(code **)(iVar4 + 0x274) = FUN_00a19bf0;
|
|
}
|
|
iVar4 = in_ECX[0x2f];
|
|
if (iVar4 == 0) {
|
|
_wassert(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\window.c"
|
|
,0x414);
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<uint8_t **>((iVar4 + 0x270)) = &UNK_00a19ca0;
|
|
}
|
|
iVar4 = in_ECX[0x2f];
|
|
if (iVar4 == 0) {
|
|
_wassert(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\window.c"
|
|
,0x440);
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<uint8_t **>((iVar4 + 0x280)) = &UNK_00a19d40;
|
|
}
|
|
if ((in_ECX[1] & 0x100U) == 0) {
|
|
iVar4 = in_ECX[0x2f];
|
|
if (iVar4 == 0) {
|
|
_wassert(L"window != NULL",
|
|
L"C:\\nicalis\\builderbob\\projects\\KAGE\\Source\\Platforms\\PC\\Shared\\Source\\External\\gl\\GLFW_3.4\\src\\window.c"
|
|
,0x245);
|
|
}
|
|
piVar3 = in_ECX + 0x34;
|
|
piVar1 = in_ECX + 0x35;
|
|
if (piVar3 != GHIDRA_CAST<int *>(0x0)) {
|
|
*piVar3 = 0;
|
|
}
|
|
if (piVar1 != GHIDRA_CAST<int *>(0x0)) {
|
|
*piVar1 = 0;
|
|
}
|
|
if (_glfw == 0) {
|
|
_glfwInputError(0x10001,0);
|
|
(**(code **)(*in_ECX + 0x78))();
|
|
return 1;
|
|
}
|
|
(*_DAT_00c73718)(iVar4,piVar3,piVar1);
|
|
}
|
|
(**(code **)(*in_ECX + 0x78))();
|
|
return 1;
|
|
}
|
|
|
|
// 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;
|
|
}
|