- Name
elf_main
The game’s entry point. The loader calls it once linking is done.
- Synopsis
#include "vcsLib.h" void elf_main(uint32_t *args);- Description
The loader relocates the ELF, resolves its calls into vcsLib and then calls elf_main with an array of arguments. At that point the 6507 is waiting for instructions at $1000, except on the Chameleon Cart, where it is still running the firmware’s overblank.
args[MP_SYSTEM_TYPE] (0) is the system, one of ST_NTSC_2600 (0), ST_PAL_2600 (1), ST_PAL60_2600 (2), ST_NTSC_7800 (3) and ST_PAL_7800 (4). args[MP_CLOCK_HZ] (1) is the ARM clock. args[MP_FEATURE_FLAGS] (2) is a bit mask. FF_MULTI_CART (1) means the game was started from a menu and elf_main may return to it, FF_CHAMELEON_CART (2) means the console has already been initialised, and FF_REDUCED_HMOVE (4) is set on consoles where a late HMOVE moves one pixel less, like some 2600 Jr units. Indices 3 and 4 (MP_ELAPSED, MP_THRESHOLD) are for debugging and will change.
Several flags can be set at once, so test them with & rather than ==.
- On the bus
It doesn’t put anything on the bus.
- Example
void elf_main(uint32_t *args) { int pal = args[MP_SYSTEM_TYPE] == ST_PAL_2600; int menu = (args[MP_FEATURE_FLAGS] & FF_MULTI_CART) != 0; if (args[MP_FEATURE_FLAGS] & FF_CHAMELEON_CART) vcsEndOverblank(); /* leave the firmware's overblank */ /* ... */ }- Compatibility
● complete ◐ works with differences ○ exists but does nothing – missing ? no data
Implementation By version Notes Stella ● 7.0● master It only looks for elf_main. Gopher2600 ● 2022-2023● 2025-04● v0.51.0● v0.53.0● master Test7800 ● 2025● v0.8.0 – v0.9.0 PlusCart and UnoCart ◐ 2.3.15 – 2.3.28◐ git 2025-11◐ 2.3.32 It accepts main or elf_main. It only ever sets FF_MULTI_CART, and MP_SYSTEM_TYPE is always 0, 1 or 2. Chameleon Cart ● 2025-10-23 The console is already initialised and running the firmware’s overblank, so the game has to call vcsEndOverblank before it serves anything at $1000. Chameleon Cart, alternative firmware ● 2026-11-28 Newbroo Wild Cart and Decker ? 2026 VCSIDE ACE adapter ● 2026-11 - Known issues
- Stella: It only looks for elf_main.
- PlusCart and UnoCart: It accepts main or elf_main. It only ever sets FF_MULTI_CART, and MP_SYSTEM_TYPE is always 0, 1 or 2.
- Chameleon Cart: The console is already initialised and running the firmware’s overblank, so the game has to call vcsEndOverblank before it serves anything at $1000.
- See also Where the game code runs.
- See also The Chameleon Cart calls elf_main with the console already running.
- See also
vcsEndOverblank(3V)