Differences between implementations
vcsLib has no specification. Each loader was written from the PlusCart header and whatever games its author had for testing. These are the differences that make a game work in one place and fail in another, and how to avoid them.
- vcsJmpToRam3 on the Chameleon Cart expects the return one byte earlier
- Some implementations of vcsSta4 only use the low byte
- vcsRead4 doesn’t take the same number of cycles everywhere
- You can’t test bus stuffing in Stella
- Functions with a different name, or that do nothing
- Where the game code runs
- The Chameleon Cart calls elf_main with the console already running
vcsJmpToRam3 on the Chameleon Cart expects the return one byte earlier
vcsJmpToRam3 serves a three-byte JMP and lets go of the bus. The 6507 runs its routine in RAM and comes back to the cartridge with another JMP. For the cartridge to start serving instructions again, that JMP has to land exactly on the address the cartridge expects to read next.
Stella, the PlusCart and Gopher2600 count all three bytes of the JMP, so after a vcsJmp3 the routine comes back with jmp $1003. The Chameleon Cart firmware only counts two. It bumps its expected address after the opcode and after the low byte, but not after the high byte, so it waits for the return at $1002. With jmp $1003 the cartridge keeps waiting for an address that has already gone by, and the 6507 reads whatever happens to be on the bus. The picture breaks up or the console hangs.
Osito Panda calls vcsJmpToRam3 on every line of its title screen, which plays PCM music in 2600 mode. It gets around the problem when it copies its routines into RIOT RAM, by taking the low byte of each jmp $1003 from a variable that holds 3, or 2 when the game starts on a Chameleon Cart (FF_CHAMELEON_CART).
The Chameleon Cart’s vcsStartOverblank is a vcsJmpToRam3(0x80), so the firmware’s own overblank program already returns where the firmware expects it to. The problem only shows up in the game’s own routines.
Gopher2600 had a different bug in this function until 25 November 2026. It moved the expected address to the RAM address, so the return to the cartridge was never recognised. It’s fixed in master (0082998a3).
Related functions: vcsJmpToRam3, vcsStartOverblank, vcsSetNextAddress
| Stella | It expects the return at JMP + 3 ($1003 after vcsJmp3). |
|---|---|
| PlusCart and UnoCart | JMP + 3. |
| Gopher2600 | JMP + 3 since 25 November 2026, and the RAM address before that. |
| Test7800 | JMP + 3. |
| Chameleon Cart | JMP + 2 ($1002 after vcsJmp3). |
| Chameleon Cart, alternative firmware | JMP + 2 on the 2600, since it uses the template’s version. |
| VCSIDE ACE adapter | It does nothing. |
served by the cartridgewritten by the 6507answered by RAM, the TIA or the RIOT
served by the cartridgewritten by the 6507answered by RAM, the TIA or the RIOT
/* The routine in RIOT RAM returns with jmp $10xx, and xx depends on the cartridge. */
uint8_t return_low = 0x03; /* Stella, PlusCart, Gopher2600 */
if (args[MP_FEATURE_FLAGS] & FF_CHAMELEON_CART)
return_low = 0x02; /* its vcsJmpToRam3 expects $1002 */
static const uint8_t end_line[] = { 0x85, WSYNC, 0x4C, 0x03, 0x10 }; /* sta WSYNC / jmp $1003 */
for (int i = 0; i < sizeof end_line; i++)
vcsWrite5(0x80 + i, i == 3 ? return_low : end_line[i]);
vcsJmp3();
vcsJmpToRam3(0x80); /* the 6507 comes back by itself at the end of the line */Some implementations of vcsSta4 only use the low byte
The PlusCart header declares vcsSta4(uint16_t address) and the Chameleon header declares vcsSta4(uint8_t ZP). Stella, the PlusCart and the Chameleon firmware serve both bytes of the address, while Gopher2600 and Test7800 serve the low byte with 00 as the high byte.
As long as the address is on zero page they all do the same thing. To write outside zero page, use vcsWrite6.
| Stella | 16 bits. |
|---|---|
| PlusCart and UnoCart | 16 bits. |
| Chameleon Cart | 16 bits, even though the header says uint8_t. |
| Gopher2600 | Low byte, with 00 as the high byte. |
| Test7800 | Low byte, with 00 as the high byte. |
| VCSIDE ACE adapter | Only vcsSta4 exists, and only for zero page. |
vcsRead4 doesn’t take the same number of cycles everywhere
In Stella, Gopher2600 and the PlusCart it’s the 4 cycles of an lda abs. The Chameleon Cart serves an extra NOP afterwards, which makes 6 cycles like vcsRead6, and the ACE adapter needs 7 or 8.
The PlusCart has taken it out of its header in favour of vcsRead6, but keeps it in the firmware so that older games still work. A kernel that reads in the middle of a line with tight timing has to allow for these differences, or do the read after a WSYNC, where there’s time to spare.
| Stella | 4 cycles. |
|---|---|
| Gopher2600 | 4 cycles. |
| PlusCart and UnoCart | 4 cycles, kept for older games. |
| Chameleon Cart | 6 cycles (lda abs and a nop). |
| VCSIDE ACE adapter | 7 cycles, or 8 above $FF. |
You can’t test bus stuffing in Stella
Stella always serves STA in vcsWrite3, writes the whole byte to the TIA and loads 0 into all three masks (vcsLdxForBusStuff2 and vcsLdyForBusStuff2 serve LDA as well). The picture comes out as expected, but not the way it does on a console, so a wrong mask or a bad calibration goes unnoticed.
Gopher2600 picks the opcode the way the firmware does, but it doesn’t simulate which bits the cartridge wins either. To check bus stuffing you need a real console, or a bus simulator like the one used for the alternative Chameleon firmware.
Related functions: vcsWrite3, vcsWrite4, vcsLdaForBusStuff2
| Stella | Always STA, and the whole byte gets written. |
|---|---|
| Gopher2600 | It picks the opcode like the firmware, and the whole byte gets written. |
| PlusCart and UnoCart | Calibrated masks. It’s only on if the ELF references vcsWrite3 or vcsWrite4. |
| Chameleon Cart | No bus stuffing. |
| Chameleon Cart, alternative firmware | Calibrated masks. |
Functions with a different name, or that do nothing
If an ELF references a function the loader doesn’t have, it won’t load, and you find out straight away. If the function exists but is empty, the game starts and then goes wrong later without any warning.
The 7800 function that serves DMA is called injectDmaData in Stella and on the PlusCart, and vcsInjectDmaData on the Chameleon and in Test7800. On the PlusCart it’s empty as well, like the four save functions.
The vcsLib.h in the Chameleon template declares functions its firmware doesn’t have (the stack functions, vcsJsr6, vcsWaitForAddress, vcsPokeRomByte…), so the error turns up when the image is linked.
Related functions: vcsInjectDmaData, vcsWaitForAddress, vcsInitNvStore
| Stella | injectDmaData. vcsWaitForAddress and the Ex functions stop emulation. |
|---|---|
| PlusCart and UnoCart | injectDmaData and the save functions are empty, and there’s no vcsSnoopRead. |
| Chameleon Cart | The header declares functions that aren’t in the firmware. |
Where the game code runs
On the PlusCart and the UnoCart the game is copied to RAM and vcsLib stays in flash, further away than a Thumb BL can reach. Every call into vcsLib has to be a long call (the long_call attribute or #pragma long_calls), or the loader rejects the ELF.
On the Chameleon Cart the game runs from flash, and the flash wait states can leave the 6507 without its byte in time. Code that feeds the 6507 outside the overblank has to live in RAM, in the .RamFunc section, which the firmware copies over at startup.
Related functions: elf_main
| PlusCart and UnoCart | The game runs in RAM and vcsLib in flash, so calls need long_call. |
|---|---|
| Chameleon Cart | The game runs in flash, and the kernel goes in .RamFunc. |
| Stella | No restrictions. |
| Gopher2600 | No restrictions, but it warns about branch distances. |
The Chameleon Cart calls elf_main with the console already running
Multicarts call elf_main with the 6507 waiting at $1000. The Chameleon Cart calls it with the console already initialised and running its own overblank, and says so with FF_CHAMELEON_CART. The game has to get out of it with vcsEndOverblank before serving anything.
Its vcsEndOverblank waits for $1FFF to show up on the bus and then serves a 0. If it starts waiting while a read of $1FFF is already under way, the 0 arrives too late. Osito Panda first waits for the bus to move off $1FFF.
The flags are bits, but the template compares them with ==, so its FF_REDUCED_HMOVE check never succeeds. The PlusCart doesn’t set FF_CHAMELEON_CART or FF_REDUCED_HMOVE, and never reports a 7800 system type.
Related functions: elf_main, vcsEndOverblank
| PlusCart and UnoCart | The 6507 is at $1000 and only FF_MULTI_CART is set. |
|---|---|
| Chameleon Cart | The console is in the firmware’s overblank, with FF_CHAMELEON_CART set. |
| Stella | The 6507 is at $1000. |