- 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>
339 lines
13 KiB
C++
339 lines
13 KiB
C++
#include "classes.h"
|
|
|
|
// 00711780
|
|
void GridEntity_Lock::BeginBatches()
|
|
{
|
|
uint8_t isAnimSet;
|
|
Entity_Player *payToPlayOwner;
|
|
char *pcVar1;
|
|
uint32_t size;
|
|
std_string anm2Path;
|
|
uint32_t local_14;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00afc99d;
|
|
local_10 = ExceptionList;
|
|
local_14 = __security_cookie ^ GHIDRA_UINT(&(&anm2Path)[1]._size);
|
|
ExceptionList = &local_10;
|
|
anm2Path._size = 0;
|
|
anm2Path._capacity = 0xf;
|
|
anm2Path._buf[0] = '\0';
|
|
anm2Path._buf[1] = '\0';
|
|
anm2Path._buf[2] = '\0';
|
|
anm2Path._buf[3] = '\0';
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20);
|
|
anm2Path._size = 0x18;
|
|
anm2Path._capacity = 0x1f;
|
|
builtin_strncpy((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0))),"gfx/grid/grid_locks.anm2",0x19);
|
|
local_8 = 0;
|
|
ANM2::Load(&this->_sprite,&anm2Path,1);
|
|
local_8 = 0xffffffff;
|
|
if (0xf < anm2Path._capacity) {
|
|
size = anm2Path._capacity + 1;
|
|
pcVar1 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0)));
|
|
if (0xfff < size) {
|
|
pcVar1 = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + -4));
|
|
size = anm2Path._capacity + 0x24;
|
|
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar1))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(pcVar1,size);
|
|
}
|
|
anm2Path._size = 0;
|
|
anm2Path._capacity = 0xf;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) & 0xffffff00;
|
|
payToPlayOwner =
|
|
PlayerManager::FirstCollectibleOwner
|
|
(&g_game->_playerManager,0x17c,GHIDRA_CAST<RNG **>(&g_game->_playerManager),1);
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x154))) = payToPlayOwner != GHIDRA_CAST<Entity_Player *>(0x0);
|
|
if (*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0xc)))) == 0) {
|
|
pcVar1 = "IdleCoin";
|
|
if (payToPlayOwner == GHIDRA_CAST<Entity_Player *>(0x0)) {
|
|
pcVar1 = GHIDRA_CAST<char *>(s_Idle);
|
|
}
|
|
isAnimSet = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST<uint8_t *>(pcVar1),1);
|
|
if ((isAnimSet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) {
|
|
AnimationState::SetFrameFloat(&(this->_sprite)._animState,0.0);
|
|
if ((this->_sprite)._animState._animData != (void *)0x0) {
|
|
(this->_sprite)._animState._isPlaying = 0;
|
|
}
|
|
}
|
|
this->_collisionClass = 4;
|
|
if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 4000;
|
|
}
|
|
}
|
|
else {
|
|
isAnimSet = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST<uint8_t *>("Broken"),1);
|
|
if ((isAnimSet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) {
|
|
AnimationState::SetFrameFloat(&(this->_sprite)._animState,0.0);
|
|
if ((this->_sprite)._animState._animData != (void *)0x0) {
|
|
(this->_sprite)._animState._isPlaying = 0;
|
|
}
|
|
}
|
|
this->_collisionClass = 0;
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 00711950
|
|
void GridEntity_Lock::Update()
|
|
{
|
|
Entity_Player *player_00;
|
|
uint8_t isBreakTriggered;
|
|
uint32_t *playerSlot;
|
|
void *playerListEnd;
|
|
Game *game;
|
|
PlayerManager *playerManager;
|
|
uint32_t i;
|
|
float dx;
|
|
float dy;
|
|
Entity_Player *player;
|
|
int roomWidth;
|
|
|
|
if (((this->_sprite)._animState._animData != (void *)0x0) &&
|
|
(isBreakTriggered =
|
|
AnimationState::IsEventTriggered(&(this->_sprite)._animState,GHIDRA_CAST<uint8_t *>("Break")),
|
|
isBreakTriggered != 0)) {
|
|
this->_collisionClass = 0;
|
|
game = g_game;
|
|
if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 0;
|
|
goto LAB_007119ac;
|
|
}
|
|
}
|
|
game = g_game;
|
|
LAB_007119ac:
|
|
if (*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0xc)))) == 0) {
|
|
playerManager = &game->_playerManager;
|
|
i = 0;
|
|
if (GHIDRA_INT((game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2
|
|
!= 0) {
|
|
do {
|
|
playerListEnd = (playerManager->_playerList)._end;
|
|
if (GHIDRA_INT(playerListEnd) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("(GHIDRA_CAST<PlayerManager *>(()))->PlayerManager::GetPlayer() : There are no players! \n"));
|
|
playerListEnd = (playerManager->_playerList)._end;
|
|
game = g_game;
|
|
}
|
|
playerSlot = (playerManager->_playerList)._begin;
|
|
if (i < GHIDRA_UINT((GHIDRA_INT(playerListEnd) - GHIDRA_INT(playerSlot) >> 2))) {
|
|
playerSlot = playerSlot + i;
|
|
}
|
|
player_00 = GHIDRA_CAST<Entity_Player *>(*playerSlot);
|
|
if ((player_00->_variant == 0) &&
|
|
(roomWidth = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(game->_room) + 0xc)),
|
|
dx = (player_00->_pos).x - ((float)(this->_gridIndex % roomWidth) * 40.0 + 40.0),
|
|
dy = (player_00->_pos).y - ((float)(this->_gridIndex / roomWidth) * 40.0 + 120.0),
|
|
dy * dy + dx * dx < 961.0)) {
|
|
try_unlock(this,player_00,0);
|
|
game = g_game;
|
|
}
|
|
playerManager = &game->_playerManager;
|
|
i = i + 1;
|
|
} while (i < GHIDRA_UINT((GHIDRA_INT((game->_playerManager)._playerList._end) -
|
|
GHIDRA_INT((playerManager->_playerList)._begin) >> 2)));
|
|
}
|
|
}
|
|
if ((this->_sprite)._loaded != 0) {
|
|
AnimationState::Update(&(this->_sprite)._animState);
|
|
AnimationState::Update(&(this->_sprite)._overlayAnimState);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 00711af0
|
|
void GridEntity_Lock::try_unlock(Entity_Player *player, uint8_t isForce)
|
|
{
|
|
uint8_t isKeyUsed;
|
|
int paperClipMultiplier;
|
|
GridEntity_Lock *soundId [2];
|
|
Manager *manager;
|
|
|
|
if (*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0xc)))) == 0) {
|
|
if (isForce == 0) {
|
|
soundId[0] = this;
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x154))) == '\0') {
|
|
paperClipMultiplier = (GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::GetTrinketMultiplier(0x13);
|
|
if ((paperClipMultiplier < 2) &&
|
|
(isKeyUsed = (GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::TryUseKey(), isKeyUsed == 0)) {
|
|
return;
|
|
}
|
|
}
|
|
else {
|
|
if (player->_numCoins < 1) {
|
|
return;
|
|
}
|
|
(GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::AddCoins(-1);
|
|
}
|
|
}
|
|
manager = g_manager;
|
|
soundId[0] = GHIDRA_CAST<GridEntity_Lock *>(0x9c);
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x154))) != '\0') {
|
|
soundId[0] = GHIDRA_CAST<GridEntity_Lock *>(0x2d);
|
|
}
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(soundId));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(soundId[0]),1.0,2,0,1.0,0.0);
|
|
break_open(this,player);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 00711bb0
|
|
void GridEntity_Lock::break_open(Entity_Player *player)
|
|
{
|
|
uint8_t bVar1;
|
|
int iVar2;
|
|
uint32_t uVar3;
|
|
int gridX;
|
|
void *trinketRngEnd;
|
|
uint32_t *trinketRng;
|
|
uint32_t *playerIt;
|
|
uint32_t variant;
|
|
char *anim;
|
|
RNG dropRng;
|
|
GridEntity_Lock *lock;
|
|
Vector local_10;
|
|
code *debugBreak;
|
|
Game *game;
|
|
Manager *manager;
|
|
void *trinketRngBegin;
|
|
|
|
manager = g_manager;
|
|
local_10.y = 3.20897e-43;
|
|
lock = this;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_10.y));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_10.y),1.0,2,0,1.0,0.0);
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x154))) == '\0') {
|
|
if ((player == GHIDRA_CAST<Entity_Player *>(0x0)) || (anim = "BreakingGolden", player->_hasGoldenKey == 0)) {
|
|
anim = "Breaking";
|
|
}
|
|
}
|
|
else {
|
|
anim = "BreakingCoin";
|
|
}
|
|
bVar1 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST<uint8_t *>(anim),1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(this->_sprite)._animState);
|
|
(this->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
uVar3 = *GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x14))));
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0xc)))) = 1;
|
|
game = g_game;
|
|
dropRng._shift1 = 1;
|
|
dropRng._shift2 = 5;
|
|
dropRng._shift3 = 0x10;
|
|
if (uVar3 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
debugBreak = (code *)swi(3);
|
|
(*debugBreak)();
|
|
return;
|
|
}
|
|
uVar3 = uVar3 >> 1 ^ uVar3;
|
|
uVar3 = uVar3 << 5 ^ uVar3;
|
|
local_10.y = (float)(uVar3 >> 0x10 ^ uVar3);
|
|
if (0.1 <= (float)((double)GHIDRA_INT(local_10.y) + __uint_to_double_fixup[-(GHIDRA_INT(local_10.y) >> 0x1f)]) *
|
|
2.3283062e-10) {
|
|
return;
|
|
}
|
|
if (player == GHIDRA_CAST<Entity_Player *>(0x0)) {
|
|
playerIt = (g_game->_playerManager)._playerList._begin;
|
|
if (playerIt != (g_game->_playerManager)._playerList._end) {
|
|
do {
|
|
player = GHIDRA_CAST<Entity_Player *>(*playerIt);
|
|
if ((player->_variant == 0) &&
|
|
(bVar1 = (GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::HasTrinket(0x16,0), bVar1 != 0)) goto LAB_00711d1a;
|
|
playerIt = playerIt + 1;
|
|
} while (playerIt != (game->_playerManager)._playerList._end);
|
|
}
|
|
player = GHIDRA_CAST<Entity_Player *>(0x0);
|
|
}
|
|
LAB_00711d1a:
|
|
if (local_10.y == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
debugBreak = (code *)swi(3);
|
|
(*debugBreak)();
|
|
return;
|
|
}
|
|
uVar3 = GHIDRA_UINT(local_10.y) >> ((uint8_t)dropRng._shift1 & 0x1f) ^ GHIDRA_UINT(local_10.y);
|
|
uVar3 = uVar3 << ((uint8_t)dropRng._shift2 & 0x1f) ^ uVar3;
|
|
dropRng._seed = uVar3 >> 0x10 ^ uVar3;
|
|
local_10.y = (float)dropRng._seed;
|
|
if (0.25 <= (float)((double)dropRng._seed + __uint_to_double_fixup[-(dropRng._seed >> 0x1f)]) *
|
|
2.3283062e-10) {
|
|
LAB_00711e7c:
|
|
if (local_10.y == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
debugBreak = (code *)swi(3);
|
|
(*debugBreak)();
|
|
return;
|
|
}
|
|
uVar3 = GHIDRA_UINT(local_10.y) >> ((uint8_t)dropRng._shift1 & 0x1f) ^ GHIDRA_UINT(local_10.y);
|
|
uVar3 = uVar3 << ((uint8_t)dropRng._shift2 & 0x1f) ^ uVar3;
|
|
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
|
|
gridX = lock->_gridIndex % iVar2;
|
|
iVar2 = lock->_gridIndex / iVar2;
|
|
uVar3 = uVar3 >> 0x10 ^ uVar3;
|
|
variant = 0x14;
|
|
}
|
|
else {
|
|
if (player != GHIDRA_CAST<Entity_Player *>(0x0)) {
|
|
trinketRngEnd = (player->_trinketRNGs)._end;
|
|
if (GHIDRA_INT((GHIDRA_INT(trinketRngEnd) - GHIDRA_INT((player->_trinketRNGs)._begin) & 0xfffffff0U)) < 0x161) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Trinket ID out of bounds!\n"));
|
|
trinketRngEnd = (player->_trinketRNGs)._end;
|
|
}
|
|
trinketRngBegin = (player->_trinketRNGs)._begin;
|
|
uVar3 = (GHIDRA_INT(trinketRngEnd) - GHIDRA_INT(trinketRngBegin) >> 4) - 1;
|
|
if (0x16 < uVar3) {
|
|
uVar3 = 0x16;
|
|
}
|
|
trinketRng = GHIDRA_CAST<uint32_t *>((uVar3 * 0x10 + GHIDRA_INT(trinketRngBegin)));
|
|
uVar3 = *trinketRng;
|
|
if (uVar3 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar3 = *trinketRng;
|
|
if (uVar3 == 0) {
|
|
debugBreak = (code *)swi(3);
|
|
(*debugBreak)();
|
|
return;
|
|
}
|
|
}
|
|
uVar3 = uVar3 >> ((uint8_t)trinketRng[1] & 0x1f) ^ uVar3;
|
|
uVar3 = uVar3 << ((uint8_t)trinketRng[2] & 0x1f) ^ uVar3;
|
|
uVar3 = uVar3 >> ((uint8_t)trinketRng[3] & 0x1f) ^ uVar3;
|
|
*trinketRng = uVar3;
|
|
if (uVar3 != (uVar3 / 5) * 5) goto LAB_00711e7c;
|
|
}
|
|
uVar3 = (GHIDRA_CAST<RNG *>((&dropRng)))->RNG::Next();
|
|
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
|
|
gridX = lock->_gridIndex % iVar2;
|
|
iVar2 = lock->_gridIndex / iVar2;
|
|
variant = 10;
|
|
}
|
|
local_10.x = (float)gridX * 40.0 + 40.0;
|
|
local_10.y = (float)iVar2 * 40.0 + 120.0;
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(5,variant,&local_10,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,uVar3);
|
|
return;
|
|
}
|
|
|
|
// 00712090
|
|
void * GridEntity_Lock::GetWaterClipInfo(void *outInfo)
|
|
{
|
|
uint32_t clipValue;
|
|
|
|
clipValue = 0x26;
|
|
if (this->_collisionClass != 0) {
|
|
clipValue = 0x39;
|
|
}
|
|
*GHIDRA_CAST<uint32_t *>(outInfo) = clipValue;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(outInfo) + 4)) = 0;
|
|
return outInfo;
|
|
}
|