#include "classes.h" #include "data.h" #include "gl.h" #include "kage_sound.h" #include "lua_engine.h" #include "manager.h" #include "platform.h" #include #include #include #include #include constexpr const char* GAME_VERSION = "J460"; constexpr const char* LOCALHOST_FLAG = "--localhost_match"; constexpr const char* RESOURCES_FLAG = "--resources"; constexpr const char* MUTE_FLAG = "--mute"; constexpr const char* LOG_FILE = "log.txt"; constexpr const char* LOCALHOST_LOG = "localhost/log_"; constexpr const char* CLAMP_COLOR_EXTENSION = "GL_ARB_color_buffer_float"; // GL 3.0, as major * 10 + minor. constexpr int CLAMP_COLOR_VERSION = 30; constexpr int VERSION_MINOR_DIGITS = 10; // The context's GL version as major * 10 + minor, 0 without one. static int gl_version_get() { const char* version = gl.GetString ? (const char*)gl.GetString(GL_VERSION) : nullptr; int major = 0; int minor = 0; if (version) std::sscanf(version, "%d.%d", &major, &minor); return major * VERSION_MINOR_DIGITS + minor; } // 00931050 Starts the engine and the game, logging the command line, then runs one frame at a time at 60 Hz until // the window closes. "--localhost_match" logs to a timestamped file under localhost/ instead of log.txt. // The theora log hook, COM, the Win32 window-move listener, Steam and the Windows power and timer settings are left // out. A debug flag nothing sets (DAT_00c35e68) would skip the update and render. int IsaacMain(int argc, uint8_t** argv) { platform.directories_load(); std::string logPath = platform.userDataDirectory + LOG_FILE; for (int i = 0; i < argc; i++) { if (std::strcmp((const char*)argv[i], LOCALHOST_FLAG) != 0) continue; logPath = platform.userDataDirectory + LOCALHOST_LOG + std::to_string(std::time(nullptr)) + ".txt"; break; } log_open(logPath); platform.bindings_load(); platform.engine_init(); log_printf(LOG_INFO, "Command Line: \n"); for (int i = 0; i < argc; i++) log_printf(LOG_INFO, "\t%s\n", (const char*)argv[i]); log_printf(LOG_INFO, "Game Version: %s \n", GAME_VERSION); if (gl.ClampColor && (SDL_GL_ExtensionSupported(CLAMP_COLOR_EXTENSION) || gl_version_get() >= CLAMP_COLOR_VERSION)) gl.ClampColor(GL_CLAMP_VERTEX_COLOR, GL_FALSE); IsaacStartup(argc, argv); while (true) { g_manager->framesPerSecond = platform.frame_begin(); // 00a714e0 KAGE::System::update ran here without polling input: its video clips, lobby commands, deferred heap // frees and EOS tick have nothing to run, and the log is flushed with every message. Manager::Update(); g_manager->Render(); if (g_game) lua_engine_get().gc_update(); if (platform.isQuitRequested) break; platform.frame_wait(); } Isaac::Shutdown(); platform.engine_shutdown(); return 0; } // The Linux entry point: "--resources " says where the imported game files are, "--mute" plays nothing, then the // game's own main runs. int main(int argc, char** argv) { for (int i = 1; i < argc; i++) { if (std::strcmp(argv[i], MUTE_FLAG) == 0) KAGE::Sound::manager.isMuted = true; else if (std::strcmp(argv[i], RESOURCES_FLAG) == 0 && i + 1 < argc) dataDirectory = std::string(argv[i + 1]) + "/"; } return IsaacMain(argc, (uint8_t**)argv); }