![]() |
CRM64Pro GDK v0.18.0
A free cross-platform game development kit built on top of SDL 3.0
|
Central hub for CRM64Pro GDK initialization, module access and high-precision timing [v26.06.1].
The Main module serves as the central entry point and orchestrator for the CRM64Pro Game Development Kit. It manages the complete lifecycle of the application, from system initialization through shutdown, while providing unified access to all other GDK modules.
| Core | Log • Config • Timer • Tool |
|---|---|
| Data | Archive • XML |
| Audio | Audio Track |
| Graphics | Image • Cursor • Tile • Sprite • Font • GFX |
| GUI | GUI • Widgets |
| Tile engine | Scene Core • Scene TileLayer |
| Network | TCP/IP |
The GDK provides two module complexity levels, allowing simple utilities to coexist with feature-rich systems:
| Standard | Simple module with a few methods that may or may not be related |
|---|---|
| Advanced | Complex module with several interconnected methods |
Managers handle object lifecycle and resource sharing. Each manager follows one of these patterns based on its resource requirements:
| Standard | Objects must be unique by name; creation fails if name exists |
|---|---|
| Sharing | Returns shared ID for existing objects; control methods affect all shared instances |
| Cloning | Creates independent copies sharing base data; loaded duplicates auto-clone |
Namespaces | |
| namespace | CRM64Pro::CMem |
| CMem: CRM64Pro Memory Manager. | |
Classes | |
| struct | CRM64Pro::Position |
| Position struct used by Font and GUI Widgets. More... | |
| class | CRM64Pro::Main |
| CRM64Pro GDK Main class. More... | |
Functions | |
| static Main & | CRM64Pro::Main::instance () |
| Access the Main singleton. | |
| static void | CRM64Pro::Main::terminate () |
| Main explicit destructor. | |
| bool | CRM64Pro::Main::info (Sint32 iMode=0) override |
| Request Main module information. | |
| static bool | CRM64Pro::Main::isInit () |
| Check if the GDK is initialized. | |
| const string & | CRM64Pro::Main::getCopyright () const |
| Get copyright string. | |
| void | CRM64Pro::Main::printVersion () |
| Print version and build date to the default log. | |
| const string & | CRM64Pro::Main::getVersion () const |
| Get version string. | |
| bool | CRM64Pro::Main::requireVersion (Uint8 iMajor, Uint8 iMinor) |
| Check if the GDK version is compatible with the given one. | |
| bool | CRM64Pro::Main::intro (Sint32 idScreen=0) |
| Show the MegaStorm and CRM64Pro introduction. | |
| Sint32 | CRM64Pro::Main::update (SDL_Event *evUser=nullptr) |
| Manage the GDK update cycle with a fixed virtual logic frame rate. | |
| float | CRM64Pro::Main::getInterpolationFactor () const |
| Get the current render interpolation factor. | |
| float | CRM64Pro::Main::getDeltaTime () const |
| Get the last frame's high-precision delta time. | |
| float | CRM64Pro::Main::getLogicDeltaTime () const |
| Get the delta time that must be consumed by the current logic step. | |
| bool | CRM64Pro::Main::getKeyState (SDL_Keycode keycode) const |
| Get the current state of a key. | |
| const char * | CRM64Pro::Main::getKeyName (SDL_Keycode keycode) const |
| Get a human-readable name for a key. | |
| Sint32 | CRM64Pro::Main::getKeyboardFocus () const |
| Get the screen that has keyboard focus. | |
| ConfigMgr & | CRM64Pro::Main::configMgr () |
| Get reference to Config Manager. | |
| Tool & | CRM64Pro::Main::tool () |
| Get reference to Tool module. | |
| LogMgr & | CRM64Pro::Main::logMgr () |
| Get reference to Log Manager. | |
| Timer & | CRM64Pro::Main::timer () |
| Get reference to Timer module. | |
| ArchiveMgr & | CRM64Pro::Main::archiveMgr () |
| Get reference to Archive Manager. | |
| XMLMgr & | CRM64Pro::Main::xmlMgr () |
| Get reference to XML Manager. | |
| AudioTrackMgr & | CRM64Pro::Main::audioTrackMgr () |
| Get reference to Audio Track Manager. | |
| ImageMgr & | CRM64Pro::Main::imageMgr () |
| Get reference to Image Manager. | |
| CursorMgr & | CRM64Pro::Main::cursorMgr () |
| Get reference to Cursor Manager. | |
| TileMgr & | CRM64Pro::Main::tileMgr () |
| Get reference to Tile Manager. | |
| SpriteMgr & | CRM64Pro::Main::spriteMgr () |
| Get reference to Sprite Manager. | |
| FontMgr & | CRM64Pro::Main::fontMgr () |
| Get reference to Font Manager. | |
| GFX & | CRM64Pro::Main::gfx () |
| Get reference to GFX module. | |
| Physics & | CRM64Pro::Main::physics () |
| Get reference to Physics module. | |
| VideoMgr & | CRM64Pro::Main::videoMgr () |
| Get reference to Video Manager. | |
| GUIMgr & | CRM64Pro::Main::guiMgr () |
| Get reference to GUI Manager. | |
| SceneMgr & | CRM64Pro::Main::sceneMgr () |
| Get reference to Scene Manager. | |
| NetTCP & | CRM64Pro::Main::netTCP () |
| Get reference to NetTCP module. | |
| enum CRM64Pro::eEventType : Uint32 |
| enum CRM64Pro::eEventCode : Sint32 |
Event codes delivered via user.code when event.type is ET_C64. One code is delivered per event; values are not bitmask flags.
| enum CRM64Pro::eGeneralStatus : Sint32 |
General status. One value must be returned; values are not bitmask flags.
| enum CRM64Pro::ePlaybackStatus : Sint32 |
| enum CRM64Pro::eErrorCode : Sint32 |
Base error code families used by status-returning methods.
| enum CRM64Pro::ePositionHelper : Sint32 |
Position helpers used by Cursors, Sprites, Fonts, GUI Widgets and Scene. One helper must be selected; values are not bitmask flags.
| Enumerator | |
|---|---|
| PH_NONE | No position helper, absolute positioning. |
| PH_SIZE | Cursor::setHotSpot(): set hotspot to cursor_size. Sprite::setAnimHotSpot(): set hotspot to frame_size. |
| PH_CENTER | Cursor::setHotSpot(): set hotspot to cursor_size/2. Sprite::setAnimHotSpot(): set hotspot to frame_size/2. Widget/Font: center with optional offset. Scene: center relative to map bounds. |
| PH_TOP | Widget/Font: top with optional offset. Scene: align to map top/begin (0.0). Valid for Y axis. |
| PH_BOTTOM | Widget/Font: bottom with optional offset. Scene: align to map bottom/end (MapHeight - ViewportHeight). Valid for Y axis. |
| PH_LEFT | Widget/Font: left with optional offset. Scene: align to map left/begin (0.0). Valid for X axis. |
| PH_RIGHT | Widget/Font: right with optional offset. Scene: align to map right/end (MapWidth - ViewportWidth). Valid for X axis. |
| PH_KEEP | Scene: Keep the current value (ignore the new one). |
|
static |
Access the Main singleton.
On first call this performs:
|
static |
|
override |
|
static |
Check if the GDK is initialized.
| const string & CRM64Pro::Main::getCopyright | ( | ) | const |
Get copyright string.
| void CRM64Pro::Main::printVersion | ( | ) |
Print version and build date to the default log.
Writes the version information; no return value.
| const string & CRM64Pro::Main::getVersion | ( | ) | const |
Get version string.
| bool CRM64Pro::Main::requireVersion | ( | Uint8 | iMajor, |
| Uint8 | iMinor ) |
Check if the GDK version is compatible with the given one.
| iMajor | Major version. |
| iMinor | Minor version. |
| bool CRM64Pro::Main::intro | ( | Sint32 | idScreen = 0 | ) |
Show the MegaStorm and CRM64Pro introduction.
| idScreen | valid screen handle; defaults to the primary screen. |
| Sint32 CRM64Pro::Main::update | ( | SDL_Event * | evUser = nullptr | ) |
Manage the GDK update cycle with a fixed virtual logic frame rate.
This method is the heart of the engine's timing system. It replaces standard SDL_PollEvent() and implements a fixed virtual logic frame rate (LFR) with a high-resolution accumulator (nanoseconds). The system uses SDL_GetPerformanceCounter() to provide zero-drift timing and deterministic simulation steps. It manages:
| evUser | Optional SDL event output pointer. If nullptr, an internal SDL event is used and event details are not returned to the caller. If not nullptr, it receives the next pending event. When evUser->type is ::ET_C64, evUser->user.code contains one of the ::eEventCode values. |
| float CRM64Pro::Main::getInterpolationFactor | ( | ) | const |
Get the current render interpolation factor.
Calculates the fractional progress between the last consumed logic frame and the next logic frame. This value ranges from [0.0, 1.0) while a fixed logic frame rate is enabled, and 0.0 when logic is variable-step. It is intended for render-only interpolation of visual state, such as Scene smooth scrolling and Sprite interpolated positions.
| float CRM64Pro::Main::getDeltaTime | ( | ) | const |
Get the last frame's high-precision delta time.
Provides the actual elapsed wall-clock time between the previous and current engine frame in seconds. The value is calculated using nanosecond-precision performance counters and is clamped to a maximum of 0.25s to prevent "spiral of death" catch-up loops after system lags.
| float CRM64Pro::Main::getLogicDeltaTime | ( | ) | const |
Get the delta time that must be consumed by the current logic step.
Returns the canonical logic-step delta in seconds. When a fixed logic frame rate (LFR) is enabled, this returns exactly 1.0 / LFR for every logic update. When LFR is disabled, logic is variable-step and this returns getDeltaTime().
| bool CRM64Pro::Main::getKeyState | ( | SDL_Keycode | keycode | ) | const |
Get the current state of a key.
Uses the SDL keycode representation (layout-independent, character-dependent).
| keycode | SDL keycode to check. |
| const char * CRM64Pro::Main::getKeyName | ( | SDL_Keycode | keycode | ) | const |
Get a human-readable name for a key.
| keycode | SDL_Keycode key to get its human-readable name. |
| Sint32 CRM64Pro::Main::getKeyboardFocus | ( | ) | const |
Get the screen that has keyboard focus.
| ConfigMgr & CRM64Pro::Main::configMgr | ( | ) |
Get reference to Config Manager.
| Tool & CRM64Pro::Main::tool | ( | ) |
Get reference to Tool module.
| LogMgr & CRM64Pro::Main::logMgr | ( | ) |
Get reference to Log Manager.
| Timer & CRM64Pro::Main::timer | ( | ) |
Get reference to Timer module.
| ArchiveMgr & CRM64Pro::Main::archiveMgr | ( | ) |
Get reference to Archive Manager.
| XMLMgr & CRM64Pro::Main::xmlMgr | ( | ) |
Get reference to XML Manager.
| AudioTrackMgr & CRM64Pro::Main::audioTrackMgr | ( | ) |
Get reference to Audio Track Manager.
| ImageMgr & CRM64Pro::Main::imageMgr | ( | ) |
Get reference to Image Manager.
| CursorMgr & CRM64Pro::Main::cursorMgr | ( | ) |
Get reference to Cursor Manager.
| TileMgr & CRM64Pro::Main::tileMgr | ( | ) |
Get reference to Tile Manager.
| SpriteMgr & CRM64Pro::Main::spriteMgr | ( | ) |
Get reference to Sprite Manager.
| FontMgr & CRM64Pro::Main::fontMgr | ( | ) |
Get reference to Font Manager.
| GFX & CRM64Pro::Main::gfx | ( | ) |
Get reference to GFX module.
| Physics & CRM64Pro::Main::physics | ( | ) |
Get reference to Physics module.
| VideoMgr & CRM64Pro::Main::videoMgr | ( | ) |
Get reference to Video Manager.
| GUIMgr & CRM64Pro::Main::guiMgr | ( | ) |
Get reference to GUI Manager.
| SceneMgr & CRM64Pro::Main::sceneMgr | ( | ) |
Get reference to Scene Manager.
| NetTCP & CRM64Pro::Main::netTCP | ( | ) |
Get reference to NetTCP module.