Curation round 5: Game construction, FXLayers, PlayerManager, the menus; the main menu renders

Eight agents took over ScoreSheet, DeathmatchManager, giantbook and boss overlays, FXLayers, PlayerManager, the menu
manager with the save and prompt flow, twelve menus (character wheel, options, challenges, daily (offline), special
seeds, leaderboard (local), collection, bestiary, stats, controller select, key config, cutscenes), console text input
and gamepad hot-plug through platform listeners. Integration moved input to device ids.
KAGE's projection matrix now reaches the 'ProjectionMatrix' uniform the basic shaders from afterbirthp.a declare, as
well as the exe's 'Transform', which takes the color-mod and HQ4X passes from black to correct output.
Under gdb with stubs skipped, the intro, title, file select, main menu and character wheel render as in the game.
1330 functions taken over, boot path 261/615. build/isaac stops at OnlineEmotes::init in Game::LoadConfigXmls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-11-20 02:59:23 -05:00
1 parent fd8b965350
commit 233d5123e8
128 files changed
+10194 -36967

No files matched your search

+234 -28
View File
@@ -1,13 +1,20 @@
#include "game.h"
#include "data.h"
#include "log.h"
#include "manager.h"
#include "menu_manager.h"
#include "log.h"
#include <optional>
constexpr const char* STAGES_XML = "stages.xml";
constexpr const char* CURSES_XML = "curses.xml";
constexpr const char* MINIBOSSES_XML = "minibosses.xml";
constexpr const char* GIANTBOOK_XML = "giantbook.xml";
constexpr const char* BOSS_OVERLAYS_XML = "bossoverlays.xml";
constexpr const char* AMBUSH_XML = "ambush.xml";
constexpr const char* PRELOAD_XML = "preload.xml";
constexpr const char* COMPLETION_WIDGET_ANM2 = "gfx/ui/completion_widget.anm2";
constexpr const char* COMPLETION_WIDGET_ANIMATION = "Idle";
constexpr const char* GIANTBOOK_CLICKER_PNG = "gfx/ui/giantbook/GiantBook_Clicker.png";
constexpr const char* PIXELATION_SURFACE = "Pixelation Surface";
constexpr const char* BLOOM_SURFACE = "Bloom Surface";
@@ -15,34 +22,82 @@ constexpr const char* OLD_TV_SURFACE = "Old TV Surface";
constexpr const char* HALLUCINATION_SURFACE = "Hallucination Surface";
constexpr const char* HALLUCINATION_SNAPSHOT = "Hallucination Snapshot";
constexpr const char* COLORMOD_SURFACE = "Colormod Surface";
constexpr int FILTER_NEAREST = 0;
constexpr int FILTER_LINEAR = 1;
// The deathmatch type a new Game picks: the first one half the time, else one of the ten after it.
constexpr int DEATHMATCH_TYPE_FIRST = 1;
constexpr int DEATHMATCH_TYPE_RANDOM_FIRST = 2;
constexpr uint32_t DEATHMATCH_TYPE_RANDOM_COUNT = 10;
constexpr int BLOOM_DURATION_DEFAULT = 30;
constexpr int REVIVE_MACHINE_COINS = 10;
constexpr float DIZZY_CHANGE_SPEED_DEFAULT = 0.001f;
constexpr int ITEM_OVERLAY_ACTIVE = 2;
constexpr int BOSS_RUSH_PAR_TIME = 36000;
constexpr int BLUE_WOMB_PAR_TIME = 54000;
constexpr float COLOR_CHANNEL_MAX = 255;
// The attributes of a giant book layer's tint channels.
constexpr std::array<std::string_view, 4> TINT_ATTRIBUTES = {"r", "g", "b", "a"};
constexpr uint32_t CHALLENGE_BACKASSWARDS = 44;
constexpr int DIMENSION_DEATH_CERTIFICATE = 2;
constexpr int STAGE_ID_DEATH_CERTIFICATE = 35;
// 006f1020 Starts the floor with an empty room, picks the deathmatch type and creates the run's render surfaces and the
// loaded mods' shader targets. The co-op awards table it also fills is not modeled yet.
// How a co-op award is decided, beside its name.
struct CoopAwardRule
{
float threshold = 1;
int minimumFirstStat = 0;
int statId = COOP_STAT_NONE;
bool isTieShared = true;
bool isMostWins = true;
};
// The co-op awards' rules, in the order of COOP_AWARD_KEYS.
constexpr std::array<CoopAwardRule, COOP_AWARD_COUNT> COOP_AWARD_RULES = {{{1, 0, 21},
{1, 2, 7, true, false},
{1, 0, 4},
{2, 0, 10},
{12, 2, 2, false, false},
{3, 0, 12},
{20, 0, 15},
{5, 0, 20},
{5, 0, 19},
{10, 0, 8},
{3, 0, 18},
{3, 0, 16},
{2, 0, 9},
{20, 0, 11},
{3, 0, 1},
{5, 0, 5},
{5, 0, 6},
{31, 0, 13},
{10, 0, 14},
{1, 1, 3},
{1000, 1, 17, true, false}}};
// 00425b70 Names the co-op awards in the current language and sets how each is decided.
void coop_awards_load(std::array<CoopAward, COOP_AWARD_COUNT>& awards)
{
for (int i = 0; i < COOP_AWARD_COUNT; i++)
{
const CoopAwardRule& rule = COOP_AWARD_RULES[i];
CoopAward& award = awards[i];
award.name = g_manager->stringTable.translate(COOP_AWARD_KEYS[i]);
award.statId = rule.statId;
award.isTieShared = rule.isTieShared;
award.isMostWins = rule.isMostWins;
award.threshold = rule.threshold;
award.minimumFirstStat = rule.minimumFirstStat;
}
}
// 006f1020 Starts the floor with an empty room, names the co-op awards, draws the versus rules, and creates the run's
// render surfaces and the loaded mods' shader targets.
Game::Game()
{
fadeInColor = kcolor_make(1, 1, 1, 1);
fadeOutColor = kcolor_make(1, 1, 1, 1);
level_reset();
init_coop_awards(&onlinePlayerStats);
bool isRandomType = Random() & 1;
deathmatchManager.set_type(isRandomType ? Random() % DEATHMATCH_TYPE_RANDOM_COUNT + DEATHMATCH_TYPE_RANDOM_FIRST
: DEATHMATCH_TYPE_FIRST);
coop_awards_load(coopAwards);
deathmatchManager.Reset();
// ChallengeParam::Reset on dailyChallenge's params waits for DailyChallenge's takeover (classes.h has bytes).
create_render_surfaces();
@@ -55,7 +110,8 @@ Game::~Game()
}
// 006f4740 Resets the run, then loads the run's configs through the mods' redirection: stages, curses with the mods',
// minibosses, the giant book and boss overlays, then the run's UI, ambushes and preloads.
// minibosses, the giant books and boss overlays, the run's UI, the Boss Rush waves, the preloads and their groups, the
// procedural item surfaces, par times and prompts, then empties the online stats and the console.
void Game::LoadConfigXmls()
{
Game& game = *g_game;
@@ -72,20 +128,144 @@ void Game::LoadConfigXmls()
game.roomConfig.LoadCurses(mods.TryRedirectPath(CURSES_XML), CURSES_REPLACE);
mods.LoadModCurses();
game.roomConfig.LoadMinibosses(mods.TryRedirectPath(MINIBOSSES_XML));
std::string giantBookPath = mods.TryRedirectPath(GIANTBOOK_XML);
load_giantbook_xml(&game.itemOverlay, (uint8_t*)giantBookPath.data());
load_bossoverlays_xml(mods.TryRedirectPath(BOSS_OVERLAYS_XML));
game.load_giantbook_xml(mods.TryRedirectPath(GIANTBOOK_XML));
game.load_bossoverlays_xml(mods.TryRedirectPath(BOSS_OVERLAYS_XML));
reconstruction_missing("Game::LoadConfigXmls 006f4740: game over and leaderboard sprites, emotes, completion "
"widget, pause, revive and minimap init, ambush.xml, preload.xml and its groups, procedural "
"item surfaces, par times, prompts, the giant book clicker and the co-op awards");
// The original also zeroes GameOver's second int and the ints at Game+0x1d63c and Game+0x1d64c, not modeled yet.
game.gameOver._state = 0;
game.leaderboard.LoadAnm2();
game.emotes.init();
reconstruction_missing("OnlineStatsScreen's deeds widget 008ca2c0 (classes.h's CompletionWidget::Load) on Game's "
"online stats screen: gfx/ui/DeedsMenu.anm2");
reconstruction_missing("HUD's graphics reload 009a1970 on Game's HUD");
game.pauseScreen.Init();
game.revivePlayerMenu.Init();
game.minimap.Init();
LoadBossRushXml(mods.TryRedirectPath(AMBUSH_XML));
std::string preloadPath = mods.TryRedirectPath(PRELOAD_XML);
load_preloads_xml(&game.preloadManager, (uint8_t*)preloadPath.data());
reconstruction_missing("PreloadManager::load_group 009c6c90 on Game's preloads: common, enemy, pickups, icons");
init_procedural_item_surfaces(&game.proceduralItemManager);
game.bossRushParTime = BOSS_RUSH_PAR_TIME;
game.blueWombParTime = BLUE_WOMB_PAR_TIME;
game.genericPrompt.Initialize(PROMPT_LARGE);
VictoryRunPrompt::Load();
game.completionWidgetSprite.Load(COMPLETION_WIDGET_ANM2, GRAPHICS_LOAD);
game.completionWidgetSprite.SetFrame(COMPLETION_WIDGET_ANIMATION, 0);
if (!game.giantBookClickerImage)
{
game.giantBookClickerImage = Manager::LoadImage(GIANTBOOK_CLICKER_PNG);
KAGE::Graphics::ImageBase& clicker = *game.giantBookClickerImage;
if (clicker.minFilter != FILTER_NEAREST || clicker.magFilter != FILTER_NEAREST)
clicker.filter_set(FILTER_NEAREST, FILTER_NEAREST);
}
game.onlinePlayerStats._end = game.onlinePlayerStats._begin;
for (CoopAward& award : game.coopAwards) award.userIds.clear();
game.isOnlineStatsFinalized = false;
game.console.reset();
}
// 00420ba0 Reads bossoverlays.xml into the boss overlay's five entries.
// Its this is the overlay, which classes.h lost.
uint32_t Game::load_bossoverlays_xml(std::string_view)
// An attribute when the element has it, empty or not.
static std::optional<std::string_view> attr_find(DataNode node, std::string_view name)
{
reconstruction_missing("Game::load_bossoverlays_xml 00420ba0");
std::string_view value;
if (node["attrs"][name].get(value) != simdjson::SUCCESS) return std::nullopt;
return value;
}
// An attribute as the game reads booleans: "true", "True" or a nonzero number.
static bool attr_bool(std::string_view value)
{
return value == "true" || value == "True" || std::atoi(value.data()) != 0;
}
// The first element of a document with a tag, as rapidxml's first_node finds it.
static std::optional<DataNode> root_find(const Data& data, std::string_view tag)
{
if (node_tag(data.root) == tag) return data.root;
for (DataNode node : node_children(data.root))
if (node_tag(node) == tag) return node;
return std::nullopt;
}
// 009abe70 Reads giantbook.xml into the giant book table, after stopping the item overlay. Each entry's paths are under
// the root's anm2root, and its layers are recolored by 0 to 255 channels. An entry without an id takes the one before
// it, and ids from 48 on are skipped. False when the file is missing.
// The original crashes on a file without its root element or anm2root. Here those read as empty.
bool Game::load_giantbook_xml(std::string_view path)
{
Data data;
int id = GIANTBOOK_ENTRY_COUNT;
itemOverlay._state = 0;
itemOverlay._delay = 0;
data_load(data, path);
if (!data.isLoaded) return false;
std::optional<DataNode> root = root_find(data, "giantbook");
if (!root) return true;
std::string anm2Root(node_attr(*root, "anm2root"));
for (DataNode node : node_children(*root))
{
if (node_tag(node) != "entry") continue;
GiantbookEntry entry;
if (auto text = attr_find(node, "id")) id = std::atoi(text->data());
if (auto text = attr_find(node, "anm2")) entry.anm2Path = anm2Root + std::string(*text);
if (auto text = attr_find(node, "anim")) entry.animation = *text;
if (auto text = attr_find(node, "gfx")) entry.gfxPath = anm2Root + std::string(*text);
for (DataNode layerNode : node_children(node))
{
if (node_tag(layerNode) != "layer") continue;
GiantbookLayer layer;
float* tint = layer.color._tint;
std::fill(tint, tint + TINT_ATTRIBUTES.size(), 1.0f);
layer.name = node_attr(layerNode, "name");
for (size_t channel = 0; channel < TINT_ATTRIBUTES.size(); channel++)
if (auto text = attr_find(layerNode, TINT_ATTRIBUTES[channel]))
tint[channel] = (float)std::atoi(text->data()) / COLOR_CHANNEL_MAX;
if (!layer.name.empty()) entry.layers.push_back(layer);
}
entry.id = id;
if ((unsigned)id < GIANTBOOK_ENTRY_COUNT) giantbookEntries[id] = std::move(entry);
}
return true;
}
// 00420ba0 Reads bossoverlays.xml into the boss overlay table, after stopping the boss overlay. Each entry's .anm2 is
// under the root's anm2root, and ids past 4 are skipped. False when the file is missing.
// The original crashes on a file without its root element or anm2root. Here those read as empty.
bool Game::load_bossoverlays_xml(std::string_view path)
{
Data data;
bossOverlay._state = 0;
data_load(data, path);
if (!data.isLoaded) return false;
std::optional<DataNode> root = root_find(data, "bossoverlay");
if (!root) return true;
std::string anm2Root(node_attr(*root, "anm2root"));
for (DataNode node : node_children(*root))
{
if (node_tag(node) != "entry") continue;
BossOverlayEntry entry;
if (auto text = attr_find(node, "id")) entry.id = std::atoi(text->data());
if (auto text = attr_find(node, "anm2")) entry.anm2Path = anm2Root + std::string(*text);
if (auto text = attr_find(node, "anim")) entry.animation = *text;
if (auto text = attr_find(node, "persist")) entry.isPersistent = attr_bool(*text);
if ((unsigned)entry.id < BOSS_OVERLAY_COUNT) bossOverlayEntries[entry.id] = std::move(entry);
}
return true;
}
// 00834680 Reads ambush.xml into the boss rush waves (its this is Ambush's wave list, which classes.h lost).
@@ -118,7 +298,7 @@ void Game::reset_run_state()
dailyChallenge._specialDailyId = 0;
dailyChallenge._isPractice = false;
// ChallengeParam::Reset on dailyChallenge's params waits for DailyChallenge's takeover (classes.h has bytes).
ScoreSheet::Reset();
scoreSheet.Reset();
currentColorModifier = COLOR_MOD_NEUTRAL;
pixelationDuration = 0;
@@ -246,10 +426,10 @@ bool Game::IsPaused()
bool isOffline = !g_manager->netplayManager.is_online();
if (console.state != CONSOLE_CLOSED && isOffline) return true;
return freezeFrames > 0 || gameOver._state != 0 || leaderboard._state != 0 || stageTransition._state != 0 ||
roomTransition._mode != 0 || itemOverlay._state == ITEM_OVERLAY_ACTIVE ||
return freezeFrames > 0 || gameOver._state != 0 || leaderboard.displayState != LEADERBOARD_HIDDEN ||
stageTransition._state != 0 || roomTransition._mode != 0 || itemOverlay._state == ITEM_OVERLAY_ACTIVE ||
(pauseScreen._state != 0 && isOffline) || g_manager->state != MANAGER_STATE_GAME ||
is_screen_transition_active(&genericPrompt) || onlineStatsScreen._isActive;
genericPrompt.IsActive() || onlineStatsScreen._isActive;
}
// 006f8120 Whether the run plays Greed mode.
@@ -267,3 +447,29 @@ int Game::GetStageID()
if (currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE) return STAGE_ID_DEATH_CERTIFICATE;
return RoomConfig::GetStageID(stage, stageType, ROOM_MODE_CURRENT);
}
// 004217a0 Whether one of the run's state flags is set.
bool Game::GetStateFlag(GameStateFlag flag)
{
return gameStateFlags >> flag & 1;
}
// 00417870 A player by index, the first for an index past the end.
Entity_Player* Game::GetPlayer(int index)
{
return playerManager.GetPlayer(index);
}
// 00706940 The rules the run is played by: the daily's, else its challenge's (a plain run's for none).
ChallengeParam& Game::GetChallengeParams()
{
if (dailyChallenge._id != 0)
reconstruction_missing("Game::GetChallengeParams 00706940: the daily's params, which classes.h holds as bytes");
return g_manager->GetChallengeParams((int)challenge);
}
// 00428b20 Spawns an entity into the current room.
Entity* Game::Spawn(const EntitySpawn&)
{
reconstruction_missing("Game::Spawn 00428b20");
}