I missed this interview the first time around, this is with the founder of Electronic Arts, Trip Hawkins. His story is entertaining with him working at the early Apple computers, to him creating a game publishing company because he saw programmers as tomorrow’s rock stars. The tale is filled with perfect timing, being right for the wrong reasons, and tenacity.
The interview left me a bit shaken. I wonder what the moral of his story is, what does it mean for people in the software industry in 2015. I see a man that is driven, who was wildly successfully and fantastically got his ass handed to him. I guess the lesson is, you have to love playing the game because if you are playing to win its probably more out of your hands than you want to believe.
My latest obsession has been developing for the Commodore 64 with 6502 assembly. I missed out on the c64 craze unfortunately. My family’s first computer was a 128k mac. It didn’t ship with BASIC so that delayed my access to programming by a few years.
So, in order to do c64 development I’ve been writing the code on a modern computer then cross compiling with the ACME assembler then running the result with the VICE emulator. I couldn’t bring myself to type out the code on the c64 itself since I’m too used to emacs keybindings.
For this post I’m just going to provide links to the sources I’ve been using and collect some tips I’ve picked up along the way.
VICE has the ability to monitor your emulator. While it is running if you go into the menu and find the option “Monitor” the machine will pause and you will be provided with a prompt similar to gdb. From there you can print the contents of memory, the values of registers, step over lines of code, see the disassembled code in memory, and add breakpoints. You’ll need to use this at some point.
Learn to do 16 bit arithmetic. This will come up eventually.
6502 16bit addition
At some point in your 6502 code you will accidentally type “$00” when you meant “#$00”. It’s an easy typo to grab the contents of memory location zero instead of the constant zero, it can be difficult to spot so keep an eye out for it.
Be aware of what machine you are developing for. By default VICE runs as C64:PAL. Since your code will probably be tied to screen refresh interrupts, code that works on PAL might not work as you expected on C64:NTSC.
C64 computers can have one of 2 sound chips, the 6581 or the 8580. Developing music for one might not sound good on the other. The huge difference everyone mentions is the 6581 has a bug in it where it pops when you set certain parameters, people use this bug in order to playback PCM audio.
Indirect Addressing (pointers) only work if the address is on the Zero Page (the first 255 bytes of memory). Also the Zero Page is hotly contested real estate, one safe place to put things is $FB and $FC.
The VIC-II (the video card) can run in one mode at a time:
hires character mode – a single global and background color, video memory is a series of 40×25 character codes. Character codes are 8×8 bits, each bit deciding if its background or foreground color.
multicolor character mode – similar to hires character mode, except each character is now 4×8 pixels since each pixel is represented by 2 bits. It will chose from 3 global colors or a 4th color that is an 40×25 array, an element for each character.
bitmap mode – this can be multicolor or hires as well. This mode lays out all the pixels somewhat sequentially in memory. They are sequentially aligned like characters. So the first 8 bytes represent the colors in the top left square of real estate, instead of the top line as you might have expected.
There are other modes mentioned elsewhere but these are the ones the old documents talk about. I’m guessing those graphics modes are hacks to get different qualities like more colors.
Joystick handling is inverted, each button and direction on the joystick has a bit associated with it in the hardware register $dc00, it is being activated when that value is zero, not one.
All games and thus most users assume the joystick is plugged into port 2 not port 1.
LDA sets the zero flag and negative flag. I was expecting only math or logical operations to set flags.