Hi-Res Graphics Mind Meld

2008 November 1
by JJ Sonick

I read a description of how memory addressing for the hi-resolution screen works three times, each time from a different source.  The first two times my brain simply melted before such a byzantine structure.  The third time it finally clicked.  Surely this had something to do with it being my third attempt to grasp the concept, but I believe even more of it had to do with the third source’s description being the most clear, well-written and well-illustrated.

That third source is “Applesoft BASIC Subroutines & Secrets” by Jeanette Sullivan and David Sullivan. It appears to be an excellent book all around.  Below are scans of the two pages on hi-res memory addressing, to assist anyone else puzzling out the same issue:

Hi Res Memory Addressing 1

Hi Res Memory Addressing 1

Hi Res Memory Addressing 2

Hi Res Memory Addressing 2

(click on the images above to download full-size scans)

The book also includes a nifty little BASIC program that will compute the address of any particular block, and lays out the formula the program uses, further reinforcing how the addressing works.  Scans of that are below.

Hi Res Memory Addressing Program

Hi Res Memory Addressing Program

Hi Res Memory Addressing Program

Hi Res Memory Addressing Program

(click on the images above to download full-size scans)

In assembly programming news, “Assembly Language for the Applesoft Programmer” continues its traditional of clear writing/explanations and annoying typos in listings.  I’m also going through Don Lancaster’s “Assembly Cookbook for the Apple II/IIe” — Lancaster completely skips over the basics (he basically waves his finger at you and says ‘Don’t you dare think of using an assembler until you’ve learned to code 100s of lines of machine language on your own’), but has lots of opinionated advice on surrounding aspects of assembly.  I’m learning, slow but steady.

1 Comment leave one →
2009 August 12
Jonathan permalink

My favorite book was “Apple Graphics and Arcade Game Design”

It’s pretty easy for HGR…
Essentially you need to figure out your ROW address then add to it your column address. Sure there are lots of silly algorithms to calculate the Woz’s complicated framebuffer layout but most people just use a lookup table. i.e. have two lists of bytes in memory, one representing the low byte of the initial address of each hi-res row and the other representing the hi-byte. Then do something like this:

LDX #COLUMN ; It’s best to think of the hi-res screen as 40 columns of bytes where every bit in the byte (except for the “7th”) is a monochrome pixel. On a colour screen each pair of pixels can be arranged into one of four patterns which make a colour – The 7th bit of the byte the pattern resides in could be thought of as setting the “pallet”

LDY #ROW; This is more straight forward as each byte of screen memory writes to a single horizontal line on the screen.

LDA $LOWTABEL,Y; $LOWTABLE here is an address in memory which has the low byte of each row.
STA ZEROPAGE; Store it to some zeropage location.
LDA $HITABLE,Y; This is a table of the high bytes
STA ZEROPAGE+1; Store it to the next zero page location

LDA #BYTEYOUWANTTOWRITETOTHESCREEN; Take the value you want to store into screen memory and load it into the accumulator

STA ($ZEROPAGE),X; This writes it to the desired row or column of the screen.

Leave A Comment

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS