So.... coding an #atari2600 how hard can it be? it is a 40 year old machine after all, nothing existed back then, let alone complex coding design structures, right? πβ
Well, yes, but coding a system that is this old comes along with the limitations of those times, and there are a lot of them.
Overall, the main board has 3 ICs, the CPU, that does all the calculations, the TIA chip that does all the Television Interface, Sound and collision stuff (plus some potentiometer reading), and the RIOT chip that has the RAM does Input output and Timer related things.
You program the 6507 CPU, that is a cut down 6502, using #6502assembly and you interact with the other two chips by the use of memory registers. π§βπ«β
You have (if you exclude banking techniques) 4Kbyte of space to write your program which will end up in the Cartridge and 128 Bytes of Ram ( yes, bytes ) that is used for everything runtime, including the stack.
Oh, and no framebuffer, you have to make sure you pipe data to the TIA chip the moment it needs them, this is where the term βracing the beamβ comes from. πΌοΈβ
My console is PAL, so there are some particular numbers that i need to put in place, so that the image shows correctly. Generally the difference between PAL and NTSC is that the second runs faster, as NTSC creates an image at almost 60 frames per second, while PAL every 50. But for PAL on this extra time you can draw more lines, so... bigger playfield!
For developing, i use the #StellaEmulator (https://stella-emu.github.io/), pretty much the de facto choice, and #DASM (https://dasm-assembler.github.io/), the assembler that makes our assembly code to something that the Atari can understand.
I code in Vim on Linux, but VSCode plug-ins for DASM exist to be used.
You can also use #8bitworkshop for an Online IDE, the main difference is that you have less control over the registers/ram/state of a program compared to Stella, but in return you get much faster previews and you don't need to install anything to use it.
OK, enough with that, lets jump into some code. The first task is to make a blue screen that works on my PAL Atari, letβs call it the Blue screen of Life πβ
Here is the snippet ( fixed access ):
https://gitlab.com/-/snippets/2459337
I hope the code comments are good enough, check the images on the post for the raster scan details that are mentioned in it.
You can take the code as it is and paste it on https://8bitworkshop.com/ to see the result... I will show how to make a cartridge to use it in real life once i have the PCBs delivered. π―β
This is not the best way to create a playfield, as later on we will need to use timers to avoid losing the sync due to CPU calculating the game logic, but it is the best way to understand basic Atari 2600 Graphic generation.
I am going to watch some blue screen, and decide on what kind of game to write now... maybe it will watch me back ?