Recent site activity

News‎ > ‎

6502 Game Library Update 2

posted Jul 21, 2011 9:37 PM by Andrew Dieffenbach   [ updated Jul 21, 2011 10:20 PM ]
So, I've been wrapping my brain around the Apple II lately. The book "Apple Graphics & Arcade Game Design" has proved to be of help. I've been poking around with BASIC and the built-in assembler on the Apple IIe (via the AppleWin emulator).

It has never been so apparent to me that the Apple II was just not a gaming machine. The graphics interface is atrocious. Polling the single joystick interface is way overly complicated. The sound is likely to be as abysmal but I haven't delved into that yet (this book does not cover sound, unfortunately). These three elements; in how they were implemented on the Apple II, makes some practical sense but it's clear that gaming was an afterthought... reading the joystick is more or less a hack on an interface that is probably better suited for reading analog gauges of sorts.

My initial run at creating a proof a concept has been surprisingly successful. The game library runs minimally (without alot of features) on the Apple II, but it appears as though there is enough room to grow.


The screenshot shows a rough (and clearly inaccurate) representation of the game shown in previous posts (for the C64/NES). The mainly vertical purple line on the left is a tracer of when the "sprite" falls from the sky and lands on the ground, due to gravity. The tracers are from the graphics being drawn but not erased. There is some reasonable bad screen wrapping going on, which causes the four main horizontal sections. The arcs you see are when the "sprite" walks and jumps. All of this not coming as a surprise though, which is good!

I've applied the same pre-processed table technique I've learned from Georg Rottensteiner, in order to quickly determine the video memory addresses of each horizontal line. It wasn't a simple task--fortunately, the book by Jeffrey Stanton lays down a formula for determining line addresses as well. In the end, I've managed to create the address lookup tables in assembly (formatted for ACME) as follows:

SCREEN_LINE_OFFSET_TABLE_LO
        !set y=0
        !do while y < SCREEN_LINE_HEIGHT {
                !set a=y/64
                !set d=y-(64*a)
                !set b=d/8
                !set c=d-(8*b)
                !byte ( HI_RES_PAGE_1 + ( 1024 * c ) +
                        ( 128 * b ) +
                        ( SCREEN_LINE_WIDTH * a ) )
                      & 0x00ff
                !set y=y+1
        }

SCREEN_LINE_OFFSET_TABLE_HI
        !set y=0
        !do while y < SCREEN_LINE_HEIGHT {
                !set a=y/64
                !set d=y-(64*a)
                !set b=d/8
                !set c=d-(8*b)
                !byte ( ( HI_RES_PAGE_1 +
                          ( 1024 * c ) +
                          ( 128 * b ) +
                          ( SCREEN_LINE_WIDTH * a ) )
                          & 0xff00 ) >> 8
                !set y=y+1
        }

As you can tell from the screenshot, I'm not drawing proper sprites or background graphics. Instead, I'm only drawing the bytes that are 7 pixel wide lines. I'll need to devise a system for doing both which likely will incorporate the tables listed above, require an additional table, and perhaps a block of screen character RAM. I'm going to probably apply the preshifting technique laid down by another great 6502 mind, Bill Budge, in his article "Preshift-Table Graphics on Your Apple". I'm going to have to wrap my head around that concept a couple times. The intent is clear; the solution to Woz's crazy video system is not.