Files
isaac-port/generated-src/daily_challenge.cpp
T
shweetandClaude Opus 5.5 780767f5e1 Curation round 2, wave A: anm2 (Anm2Ed JSON), text, config as idiomatic classes; SDL3 platform opens a window
- 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>
2026-11-19 23:04:54 -05:00

390 lines
12 KiB
C++

#include "classes.h"
// 00426a50
void DailyChallenge::Init(uint32_t dailyDate)
{
code *pcVar1;
int iVar2;
tm *tmResult;
uint32_t uVar3;
uint32_t rolledPlayerType;
bool isGroundhogDay;
RNG rng;
uint8_t date [8];
__time64_t dateTime;
tm dateTm;
uint32_t local_c;
uint8_t auStack_8 [4];
local_c = __security_cookie ^ GHIDRA_UINT((auStack_8 + 4));
this->_id = 0;
this->_seed = 0;
this->_specialDailyId = 0;
this->_isPractice = 0;
ChallengeParam::Reset(&this->_params);
(this->_params)._isPathTypeSet = 1;
iVar2 = holiday_get_current(dailyDate);
this->_specialDailyId = iVar2;
this->_id = dailyDate;
DateTime::set_from_yyyymmdd(date,dailyDate);
isGroundhogDay = this->_specialDailyId == 2;
rng._seed = dailyDate;
if (isGroundhogDay) {
rng._seed = dailyDate - 1;
}
rng._shift3 = 0x15;
rng._shift1 = 10;
rng._shift2 = 9;
(this->_params)._playerType = 0x29;
uVar3 = dailyDate - 1;
if (!isGroundhogDay) {
uVar3 = dailyDate;
}
do {
if (uVar3 == 0) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
pcVar1 = (code *)swi(3);
(*pcVar1)();
return;
}
rng._seed = GHIDRA_UINT(rng._seed) >> 10 ^ rng._seed;
rng._seed = rng._seed << 9 ^ rng._seed;
rng._seed = GHIDRA_UINT(rng._seed) >> 0x15 ^ rng._seed;
rolledPlayerType = GHIDRA_UINT(rng._seed) % 0x14;
(this->_params)._playerType = rolledPlayerType;
uVar3 = rng._seed;
} while ((((rolledPlayerType == 0xc) || (rolledPlayerType == 0xb)) || (rolledPlayerType == 0x11))
|| (rolledPlayerType == 0x14));
if (rng._seed == 0) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
pcVar1 = (code *)swi(3);
(*pcVar1)();
return;
}
rng._seed = GHIDRA_UINT(rng._seed) >> 10 ^ rng._seed;
rng._seed = rng._seed << 9 ^ rng._seed;
rng._seed = GHIDRA_UINT(rng._seed) >> 0x15 ^ rng._seed;
switch(rng._seed & 3) {
case 0:
(this->_params)._endStage = 6;
break;
case 1:
(this->_params)._endStage = 8;
break;
case 2:
(this->_params)._endStage = 10;
break;
case 3:
(this->_params)._endStage = 0xb;
}
if ((this->_params)._endStage < 10) {
LAB_00426bde:
iVar2 = 1;
}
else {
if (rng._seed == 0) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
pcVar1 = (code *)swi(3);
(*pcVar1)();
return;
}
rng._seed = GHIDRA_UINT(rng._seed) >> 10 ^ rng._seed;
rng._seed = rng._seed << 9 ^ rng._seed;
rng._seed = GHIDRA_UINT(rng._seed) >> 0x15 ^ rng._seed;
if ((rng._seed & 1U) != 0) goto LAB_00426bde;
iVar2 = 0;
}
(this->_params)._pathType = iVar2;
(this->_params)._isMegaSatan = 0;
(this->_params)._difficulty = 0;
if ((date[0] & 2) != 0) {
dateTime = _mkgmtime64(&dateTm);
}
if ((date[0] & 3) != 0) {
tmResult = _gmtime64(&dateTime);
dateTm.tm_sec = tmResult->tm_sec;
dateTm.tm_min = tmResult->tm_min;
dateTm.tm_hour = tmResult->tm_hour;
dateTm.tm_mday = tmResult->tm_mday;
dateTm.tm_mon = tmResult->tm_mon;
dateTm.tm_year = tmResult->tm_year;
dateTm.tm_wday = tmResult->tm_wday;
dateTm.tm_yday = tmResult->tm_yday;
dateTm.tm_isdst = tmResult->tm_isdst;
}
date[0] = date[0] & 0xfc;
if ((char)dateTm.tm_wday == '\0') {
(this->_params)._endStage = 0xb;
(this->_params)._isMegaSatan = 1;
if (rng._seed == 0) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
pcVar1 = (code *)swi(3);
(*pcVar1)();
return;
}
rng._seed = GHIDRA_UINT(rng._seed) >> ((uint8_t)rng._shift1 & 0x1f) ^ rng._seed;
rng._seed = rng._seed << ((uint8_t)rng._shift2 & 0x1f) ^ rng._seed;
rng._seed = GHIDRA_UINT(rng._seed) >> ((uint8_t)rng._shift3 & 0x1f) ^ rng._seed;
if (rng._seed != (GHIDRA_UINT(rng._seed) / 6) * 6) goto LAB_00427185;
LAB_0042717b:
(this->_params)._difficulty = 1;
goto LAB_00427185;
}
if ((char)dateTm.tm_wday == '\x01') {
(this->_params)._pathType = 2;
(this->_params)._endStage = 8;
goto LAB_00427185;
}
if ((char)dateTm.tm_wday == '\x02') {
switch((this->_params)._playerType) {
case 0:
(this->_params)._playerType = 0x15;
break;
case 1:
(this->_params)._playerType = 0x16;
break;
case 2:
(this->_params)._playerType = 0x17;
break;
case 3:
(this->_params)._playerType = 0x18;
break;
case 4:
(this->_params)._playerType = 0x19;
break;
case 5:
(this->_params)._playerType = 0x1a;
break;
case 6:
(this->_params)._playerType = 0x1b;
break;
case 7:
(this->_params)._playerType = 0x1c;
break;
case 8:
(this->_params)._playerType = 0x1d;
break;
case 9:
(this->_params)._playerType = 0x1e;
break;
case 10:
(this->_params)._playerType = 0x1f;
break;
default:
KAGE_LogMessage(8,(uint8_t *)
"GetTaintedId() could not find tainted counterpart to given ePlayerType (%d) \n"
);
break;
case 0xd:
(this->_params)._playerType = 0x20;
break;
case 0xe:
(this->_params)._playerType = 0x21;
break;
case 0xf:
(this->_params)._playerType = 0x22;
break;
case 0x10:
(this->_params)._playerType = 0x23;
break;
case 0x12:
(this->_params)._playerType = 0x24;
break;
case 0x13:
(this->_params)._playerType = 0x25;
}
if (rng._seed == 0) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
pcVar1 = (code *)swi(3);
(*pcVar1)();
return;
}
rng._seed = GHIDRA_UINT(rng._seed) >> ((uint8_t)rng._shift1 & 0x1f) ^ rng._seed;
rng._seed = rng._seed << ((uint8_t)rng._shift2 & 0x1f) ^ rng._seed;
rng._seed = GHIDRA_UINT(rng._seed) >> ((uint8_t)rng._shift3 & 0x1f) ^ rng._seed;
uVar3 = GHIDRA_UINT(rng._seed) % 100;
if (uVar3 < 0x14) {
(this->_params)._endStage = 6;
goto LAB_00427185;
}
if (uVar3 < 0x28) {
(this->_params)._endStage = 8;
goto LAB_00427185;
}
if (0x31 < uVar3) {
if (0x40 < uVar3) {
if (0x4f < uVar3) {
(this->_params)._endStage = 0xb;
(this->_params)._pathType = GHIDRA_UINT((0x59 < uVar3));
goto LAB_00427185;
}
goto LAB_00426e6e;
}
goto LAB_00426e53;
}
}
else {
if ((char)dateTm.tm_wday == '\x03') {
(this->_params)._endStage = 0xc;
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(2);
(this->_params)._pathType = GHIDRA_UINT((uVar3 == 0));
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(100);
if (GHIDRA_INT(uVar3) < 0x14) {
(this->_params)._endStage = 6;
goto LAB_00427185;
}
if (GHIDRA_INT(uVar3) < 0x28) {
(this->_params)._endStage = 8;
goto LAB_00427185;
}
}
else {
if ((char)dateTm.tm_wday == '\x04') {
(this->_params)._pathType = 3;
(this->_params)._endStage = 0xd;
goto LAB_00427185;
}
if ((char)dateTm.tm_wday != '\x05') {
if ((char)dateTm.tm_wday != '\x06') goto LAB_00427185;
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(100);
if (GHIDRA_INT(uVar3) < 0xf) {
(this->_params)._endStage = 6;
}
else if (GHIDRA_INT(uVar3) < 0x1e) {
(this->_params)._endStage = 8;
}
else if (GHIDRA_INT(uVar3) < 0x28) {
(this->_params)._endStage = 0xc;
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(2);
(this->_params)._pathType = GHIDRA_UINT((uVar3 == 0));
}
else if (GHIDRA_INT(uVar3) < 0x32) {
(this->_params)._endStage = 10;
(this->_params)._pathType = 0;
}
else if (GHIDRA_INT(uVar3) < 0x3c) {
(this->_params)._endStage = 10;
(this->_params)._pathType = 1;
}
else if (GHIDRA_INT(uVar3) < 0x46) {
(this->_params)._endStage = 0xb;
(this->_params)._pathType = 0;
}
else if (GHIDRA_INT(uVar3) < 0x50) {
(this->_params)._endStage = 0xb;
(this->_params)._pathType = 1;
}
else if (GHIDRA_INT(uVar3) < 0x5a) {
(this->_params)._pathType = 3;
(this->_params)._endStage = 0xd;
}
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(2);
if (uVar3 != 0) {
switch((this->_params)._playerType) {
case 0:
(this->_params)._playerType = 0x15;
break;
case 1:
(this->_params)._playerType = 0x16;
break;
case 2:
(this->_params)._playerType = 0x17;
break;
case 3:
(this->_params)._playerType = 0x18;
break;
case 4:
(this->_params)._playerType = 0x19;
break;
case 5:
(this->_params)._playerType = 0x1a;
break;
case 6:
(this->_params)._playerType = 0x1b;
break;
case 7:
(this->_params)._playerType = 0x1c;
break;
case 8:
(this->_params)._playerType = 0x1d;
break;
case 9:
(this->_params)._playerType = 0x1e;
break;
case 10:
(this->_params)._playerType = 0x1f;
break;
default:
KAGE_LogMessage(8,(uint8_t *)
"GetTaintedId() could not find tainted counterpart to given ePlayerType (%d) \n"
);
break;
case 0xd:
(this->_params)._playerType = 0x20;
break;
case 0xe:
(this->_params)._playerType = 0x21;
break;
case 0xf:
(this->_params)._playerType = 0x22;
break;
case 0x10:
(this->_params)._playerType = 0x23;
break;
case 0x12:
(this->_params)._playerType = 0x24;
break;
case 0x13:
(this->_params)._playerType = 0x25;
}
}
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(2);
if (uVar3 == 0) goto LAB_00427185;
goto LAB_0042717b;
}
(this->_params)._difficulty = 1;
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(100);
if (GHIDRA_INT(uVar3) < 0x14) {
(this->_params)._endStage = 6;
goto LAB_00427185;
}
if (GHIDRA_INT(uVar3) < 0x28) {
(this->_params)._endStage = 8;
goto LAB_00427185;
}
}
if (0x31 < GHIDRA_INT(uVar3)) {
if (0x40 < GHIDRA_INT(uVar3)) {
if (0x4f < GHIDRA_INT(uVar3)) {
(this->_params)._endStage = 0xb;
(this->_params)._pathType = GHIDRA_UINT((0x59 < GHIDRA_INT(uVar3)));
goto LAB_00427185;
}
LAB_00426e6e:
(this->_params)._endStage = 10;
(this->_params)._pathType = 1;
goto LAB_00427185;
}
LAB_00426e53:
(this->_params)._endStage = 10;
(this->_params)._pathType = 0;
goto LAB_00427185;
}
}
(this->_params)._endStage = 0xc;
uVar3 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(2);
(this->_params)._pathType = GHIDRA_UINT((uVar3 == 0));
LAB_00427185:
if (rng._seed == 0) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
pcVar1 = (code *)swi(3);
(*pcVar1)();
return;
}
uVar3 = GHIDRA_UINT(rng._seed) >> ((uint8_t)rng._shift1 & 0x1f) ^ rng._seed;
uVar3 = uVar3 << ((uint8_t)rng._shift2 & 0x1f) ^ uVar3;
this->_seed = uVar3 >> ((uint8_t)rng._shift3 & 0x1f) ^ uVar3;
FUN_00427290(this->_specialDailyId);
return;
}