Functions
These are the functions the loader links into the game. Cycle counts are in 6507 cycles, and the marks on the right show support in the latest version of each implementation.
Startup
How the game starts and what the loader tells it.
- elf_main(3V)The game’s entry point. The loader calls it once linking is done.●●●◐●●?●
Flow control
Jumps and delays. They keep the 6507 inside the cartridge’s 4 KB and let you use up an exact number of cycles.
- vcsJmp3(3V)Sends the 6507 back to $1000 with a JMP.●●●●●●?●
- vcsNop2(3V)Serves a NOP, which does nothing for two cycles.●●●●●●?●
- vcsNop2n(3V)Serves count NOPs in a row, while the ARM gets on with other work.●●●●●●?●
- vcsNop3(3V)Serves NOP zp, an illegal opcode that uses up three cycles with a single instruction.–●●–––?–
- vcsSleep(3V)A macro that waits an exact number of cycles, as long as it’s more than 1.●●●●●●?●
- vcsJsr6(3V)Serves a JSR, so the 6507 pushes the return address and carries on at target.●●●●––?–
- vcsTxs2(3V)Serves TXS, which copies X into the stack pointer.●●●●––?–
Loads and stores
Loading A, X and Y, and writing to the TIA or to RAM.
- vcsLda2(3V)Serves LDA #, which loads an immediate value into A.●●●●●●?●
- vcsLdx2(3V)Serves LDX #, which loads an immediate value into X.●●●●●●?●
- vcsLdy2(3V)Serves LDY #, which loads an immediate value into Y.●●●●●●?●
- vcsSta3(3V)Serves STA zp, which writes A to a TIA register or to RAM.●●●●●●?●
- vcsStx3(3V)Serves STX zp, which writes X to a TIA register or to RAM.●●●●●●?●
- vcsSty3(3V)Serves STY zp, which writes Y to a TIA register or to RAM.●●●●●●?●
- vcsSax3(3V)Serves SAX zp, an illegal opcode that writes A AND X.●●●●●●?–
- vcsSta4(3V)Serves STA with an absolute address, which does the same as the zero-page version one cycle later.●◐◐●●●?◐
- vcsStx4(3V)Serves STX with an absolute address, which does the same as the zero-page version one cycle later.●◐◐●●●?–
- vcsSty4(3V)Serves STY with an absolute address, which does the same as the zero-page version one cycle later.●◐◐●●●?–
- vcsWrite5(3V)Serves LDA # and STA zp to write a value to a TIA register or to RAM.●●●●●●?●
- vcsWrite6(3V)Like vcsWrite5, but with an absolute address (LDA # and STA abs).●●●●●●?●
Reads
Joysticks, console switches, collisions and the timer.
Bus stuffing
Three-cycle writes where the cartridge forces the data onto the bus while the 6507 writes.
- vcsLdaForBusStuff2(3V)Loads A with the mask the cartridge needs for bus stuffing.◐●●●–●?–
- vcsLdxForBusStuff2(3V)Loads X with the mask the cartridge needs for bus stuffing.◐●●●–●?–
- vcsLdyForBusStuff2(3V)Loads Y with the mask the cartridge needs for bus stuffing.◐●●●–●?–
- vcsWrite3(3V)Writes any value in three cycles, with the cartridge forcing the data while the 6507 writes.◐●●●–●?–
- vcsWrite4(3V)vcsWrite3 with an absolute address, one cycle slower.–●–●––?–
Stack
PHA, PHP, PLA, PLP and JSR, usually with the stack pointing at the TIA.
- vcsPha3(3V)Serves PHA, so the 6507 pushes A onto the stack.●●–●––?–
- vcsPhp3(3V)Serves PHP, so the 6507 pushes its flags onto the stack.●●●●––?–
- vcsPla4(3V)Serves PLA, so the 6507 pulls A from the stack.●●●●––?–
- vcsPlp4(3V)Serves PLP, so the 6507 pulls its flags from the stack.●●●●––?–
- vcsPla4Ex(3V)Serves PLA with the stack in the TIA, and the cartridge puts data on D0–D5 while the 6507 reads.–●●◐––?–
- vcsPlp4Ex(3V)Serves PLP with the stack in the TIA, and the cartridge puts data on D0–D5 while the 6507 reads.–●●●––?–
Overblank
The 6507 runs VSYNC, VBLANK and overscan by itself from RIOT RAM, which leaves the ARM free.
- vcsCopyOverblankToRiotRam(3V)Copies into RIOT RAM the program that runs VSYNC, VBLANK and overscan without the cartridge.●●●●●●?◐
- vcsStartOverblank(3V)Jumps to the program in RIOT RAM, and for about 63 lines the 6507 doesn’t need the cartridge.●●●●●●?●
- vcsEndOverblank(3V)Waits for the overblank to finish and sends the 6507 back to $1000.●●●◐◐●?●
7800 bus
The 7800’s 6502 doesn’t wait for the cartridge, so these functions park it, listen to the bus and feed MARIA’s DMA.
- vcsJmpToRam3(3V)Jumps into the console’s RAM, where the 6507 carries on by itself.●●●●●◐?○
- vcsWaitForAddress(3V)The ARM waits until the console puts address on the bus.–●●●–●?○
- vcsSnoopRead(3V)Waits for the console to read address and returns the byte that went across the bus.––●–●●?○
- vcsInjectDmaData(3V)Serves bytes to a run of consecutive reads starting at address, which is how MARIA’s DMA reads them.––●○◐●?○
Cartridge ROM
What the cartridge serves when the 6507 reads on its own.
- vcsPokeRomByte(3V)Changes the byte the cartridge serves at address when the 6507 reads it on its own.–●●–––?–
- vcsSetNextAddress(3V)Tells the cartridge which address the 6507 will read the next byte from.–●●–––?–
Saving
Non-volatile storage with two slots.
- vcsInitNvStore(3V)Registers the two areas of memory that get saved.–●●○––?–
- vcsWriteNvChunk(3V)Starts saving one of the two slots.–●●○––?–
- vcsProcessNvStoreEvents(3V)Moves the save in progress forward.–●●○––?–
- vcsIsNvBusy(3V)Tells you whether there is still something left to save.–●●○––?–
Utilities
Tables and C library functions provided by the loader.
- randint(3V)A random number from the cartridge.●●●●●●?–
- ReverseByte(3V)A table that reverses the order of the bits in a byte.●●●●●●?–
- ColorLookup(3V)A colour table in the firmware that is being phased out.●●●–––?–
- memset(3V)Fills a block of memory with a byte.●●●●●●??
- memcpy(3V)Copies a block of memory.●●●●●●??
No function matches those filters.
● complete ◐ works with differences ○ exists but does nothing – missing ? no data