I think I’m pretty good at writing software, and then I see stuff like this, and the impostor syndrome kicks in hard. A fully working chess game in 4K of ROM, using each of the 128 bytes of RAM for several purposes? That’s some genius. Bravo to OP for the disassembly and explanation, too!
I've worked through all the 2600 programming books, including the authors. I've yet to start on anything of my own worth while. At one point I thought maybe I could start reverse engineering some games for some inspiration. Didn't get more than a few hours into it before I decided I'd just rather watch other people do great things with the 2600.
In the early 00's one enthusiast had the idea to make a simple BASIC compiler for the 2600. I was one of the early testers and the first thing I did was make a functional "BREAKOUT", bounce the ball off the bat to eliminate bricks in a wall game.
It took a couple hours and was, I think, the first (and buggy) playable program authored by someone other than the language author. And it was fun!
What the author did was kind of brilliant in that he packaged up several of the common tricks used to make games and presented them along with a simple BASIC.
Variables, for example, were just bytes and or individual bits, essentially addressing bits in a byte like an array.
J = %01101101
If J[2] = 0 then X = X +1
Here is a sample program to move a sprite around on the screen: x=50
y=50
main2
COLUP0=28
COLUBK=02
player0:
%00011100
%00011000
%00011000
%00100000
%01011010
%01111100
%00100100
%00010000
%00011000
%00111100
%00011000
end
player0x=x
player0y=y
drawscreen
if joy0right then x=x+1
if joy0left then x=x-1
if joy0up then y=y-1
if joy0down then y=y+1
goto main2
On the VCS, a game is a loop that renders the display and in-between display frames, during VBLANK, one computes the next game state to be displayed, and it all runs at 50 or 60Hz, locked to the display refresh rate.The BASIC exposes the little bit of hardware to a programmer in a simple way that I found to be a lot of fun because the really hard parts of assembly language are not necessary, but can be written in-line just as easily as defining a sprite is:
asm
LDA J
ASL
ASL
.
.
.
end
Any hoo, it was fun and surprisingly productive. I found I could knock out simple concepts in an hour or two.