On the Atari 2600

I’m using Hugg’s “Making Games for the Atari 2600” (for the most part). His books expects you to use 8BitWorkshop, which I have to admit is a pretty slick thing: an integrated development environment and emulator.

However, I don’t like web apps, so I’m using dasm and Stella (both of which can be installed via homebrew on the mac. My shitty makefile looks like this:

.PHONY: clean

%.run: %.bin
	Stella -format ntsc $*.bin

clean:
	rm *.listing *.bin

%.bin: %.asm
	dasm $*.asm -l$*.listing -f3 -v5 -o$*.bin

So building a specific file, for instance, rainbows.asm goes like this:

make rainbows.run

Which both compiles and executes the Stella emulator (this is a janky Make target, since it doesn’t produce an artifact, but I wanted something that I could run that would always execute the emulator.)

Here is the listing for rainbows.asm if you want to try this at home:

        processor 6502

        include "vcs.h"
        include "macro.h"
        org $f000

BGColor equ $81

Start
        CLEAN_START

NextFrame
        lda #2
        sta VBLANK
        sta VSYNC

        sta WSYNC
        sta WSYNC
        sta WSYNC

        lda #0
        sta VSYNC

        ldx #37
LVBlank
        sta WSYNC
        dex
        bne LVBlank

        lda #0
        sta VBLANK

        ldx #192
        ldy BGColor
LVScan
        sty COLUBK
        sta WSYNC

        iny
        dex
        bne LVScan

        lda #2
        sta VBLANK
        ldx #30

LVOver
        sta WSYNC
        dex
        bne LVOver

        dec BGColor
        jmp NextFrame


        org $fffc
        .word Start
        .word Start