Curation round 3: Lua engine, Manager, sound, menus, cutscenes, rooms, item pools, saves; boots past LuaEngine::Init
Seven agents took over LuaEngine (the mod API registration deferred), the rest of Manager (LoadConfigs, fonts, render surfaces, Update/Render), MusicManager/SFXManager, MenuManager with the title/save/game menus, Cutscene/NightmareScene/ Backdrop, RoomConfig (src/rooms ported and retired) with ItemPool, and PersistentGameData (the original binary save format) with InfoDisplay. An integration pass moved call sites to the new APIs, declared the taken-over free functions, fixed two data.cpp crashes (an empty children array, null attribute strings), and made the generator keep a header's own name where a prototype names another address. Clean build (0 warnings with -Wall -Wextra). build/isaac runs the game's Lua scripts (without the mod API yet) and stops at reload_resource_paths. 901 functions taken over, boot path 204/615. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a7061306fa
commit
ddf913f304
137 files changed
+12684
-50687
No files matched your search
+5
-39
@@ -28,13 +28,11 @@ constexpr float RADIANS_PER_DEGREE = 0.017453292f;
|
||||
constexpr float GLITCH_TURN = 90;
|
||||
constexpr int SHIMMER_STEPS = 256;
|
||||
constexpr uint32_t GRAPHICS_PREMULTIPLIED_ALPHA = 4;
|
||||
constexpr uint32_t MSVC_STRING_INLINE_CAPACITY = 15;
|
||||
constexpr char LIGHT_LAYER_PREFIX = '*';
|
||||
constexpr std::string_view SHADOW_LAYER_NAME = "shadow";
|
||||
constexpr std::string_view APPEAR_ANIMATION = "Appear";
|
||||
constexpr std::string_view IDLE_ANIMATION = "Idle";
|
||||
constexpr std::string_view CHAMPION_COLOR_UNIFORM = "ChampionColor";
|
||||
constexpr int UNIFORM_COLOR_MOD = 11;
|
||||
|
||||
// Delirium's forms swap a boss's or monster's spritesheets for the ones under DELIRIUM_FORMS_FOLDER.
|
||||
constexpr int DELIRIUM_TYPE = 412;
|
||||
@@ -47,13 +45,6 @@ constexpr std::string_view DELIRIUM_FORMS_FOLDER = "Bosses/AfterbirthPlus/Deliri
|
||||
constexpr uint32_t GLITCH_SEED = 0x9e3779b9;
|
||||
constexpr uint32_t PROCEDURAL_SHIFTS[] = {5, 9, 7};
|
||||
|
||||
// What Manager::LoadImage fills: the image and its KAGE reference count.
|
||||
struct ImageHandle
|
||||
{
|
||||
KAGE::Graphics::ImageBase* image = nullptr;
|
||||
void* refCount = nullptr;
|
||||
};
|
||||
|
||||
// What reading one .anm2 needs at hand: its path for messages and its spritesheets' regions as keyframes.
|
||||
struct Anm2Parse
|
||||
{
|
||||
@@ -77,12 +68,6 @@ static void log_print(LogLevel level, const char* format, ...)
|
||||
KAGE_LogMessage(level, (uint8_t*)message);
|
||||
}
|
||||
|
||||
// An MSVC string's text, for the records still kept in the original layout.
|
||||
static std::string_view std_string_view(const std_string& text)
|
||||
{
|
||||
return {text._capacity > MSVC_STRING_INLINE_CAPACITY ? *(char* const*)text._buf : text._buf, text._size};
|
||||
}
|
||||
|
||||
static bool is_prefix_case_insensitive(std::string_view text, std::string_view prefix)
|
||||
{
|
||||
auto isSame = [](char a, char b) { return std::tolower((unsigned char)a) == std::tolower((unsigned char)b); };
|
||||
@@ -539,19 +524,6 @@ static std::shared_ptr<const AnmFileData> file_parse(const std::string& path)
|
||||
return file;
|
||||
}
|
||||
|
||||
// A KAGE image as layers share it. The texture cache keeps a cached one until the last layer showing it lets go.
|
||||
static std::shared_ptr<KAGE::Graphics::ImageBase> image_share(ImageHandle loaded, const std::string& path,
|
||||
bool isCached)
|
||||
{
|
||||
if (!loaded.image) return nullptr;
|
||||
|
||||
auto release = [path, isCached](KAGE::Graphics::ImageBase*)
|
||||
{
|
||||
if (isCached) TextureCache::Release((uint8_t*)path.c_str());
|
||||
};
|
||||
return {loaded.image, release};
|
||||
}
|
||||
|
||||
// 0040db90 Gives a sprite the parsed file at its path, parsing it on first use, with fresh layer states.
|
||||
// A file that fails to load leaves the sprite as it was. The original's reload flag is set by nothing, so a cached
|
||||
// file is never parsed again.
|
||||
@@ -592,9 +564,8 @@ void AnmCache::Preload(std::string_view path)
|
||||
for (const LayerData& layer : cacheFiles[key]->layers)
|
||||
{
|
||||
if (TextureCache::Has((uint8_t*)layer.spriteSheetPath.c_str())) continue;
|
||||
ImageHandle loaded;
|
||||
Manager::LoadImage(&loaded, (uint8_t*)layer.spriteSheetPath.c_str());
|
||||
TextureCache::Add(loaded.image, loaded.refCount);
|
||||
KAGE::Graphics::ImagePtr image = Manager::LoadImage(layer.spriteSheetPath);
|
||||
TextureCache::Add(image.get(), nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1340,20 +1311,15 @@ void ANM2::Reload()
|
||||
LoadGraphics();
|
||||
}
|
||||
|
||||
// 0040c000, 0040bff0 Loads the spritesheet of every layer that lacks it, sharing images through the texture cache.
|
||||
// 0040c000, 0040bff0 Loads the spritesheet of every layer that lacks it, sharing images through KAGE's image cache.
|
||||
void ANM2::LoadGraphics()
|
||||
{
|
||||
for (LayerState& layer : layerStates)
|
||||
{
|
||||
if (layer.isSpriteSheetLoaded) continue;
|
||||
|
||||
ImageHandle loaded;
|
||||
Manager::LoadImage(&loaded, (uint8_t*)layer.spriteSheetPath.c_str());
|
||||
bool isValid = loaded.image && loaded.image->isLoaded;
|
||||
if (isValid) TextureCache::Add(loaded.image, loaded.refCount);
|
||||
|
||||
layer.spriteSheet = image_share(loaded, layer.spriteSheetPath, isValid);
|
||||
layer.isSpriteSheetLoaded = isValid;
|
||||
layer.spriteSheet = Manager::LoadImage(layer.spriteSheetPath);
|
||||
layer.isSpriteSheetLoaded = layer.spriteSheet && layer.spriteSheet->isLoaded;
|
||||
layer.isUnknown31 = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user