 |
There are 3 arrays used to define the screen: Bitmap, Display, and
Screen
 |
Screen is the only formally declared array. It is an array of
words, one for every 16x16 pixel tile. Each member in the array is a
pointer to the actual pixel data as well as a pointer to 1 of the 64 sets of
colors.
 |
It is a bit complex how each word member of Screen can be a pointer
(which is a word size, 16 bits) as well as hold the color info (6 bits).
But, this has to do with alignment... The Display array that Screen
points to is aligned so that the last 6 bits of each address are always 0.
So, these 6 bits are used to also hold the color info. |
|
 |
The bitmap and display arrays are not declared, but just reserved
memory. The base addresses are declared by these lines:
bitmap_base = $2000
display_base = $5000
 |
Note that the "display_base" address should end in
"00" for reasons of alignment, discussed above. |
 |
These arrays take up most of the 32kB of hub RAM. The bitmap array
extends from $2000 up to $4FFF and the display array extends from
$5000 up to $7FFF (the end of memory). |
 |
Because there is so little room left for actual
code, this compiler directive: |
_stack =
($3000 + $3000 + 100) >> 2 'accomodate display memory and stack
 |
Is used to reserve the space for these arrays,
about 12kB each. |
|
 |
The Display array holds the actual pixel data for
the graphics that is displayed on the screen. The Screen array is
filled with pointers to the Display array. |
 |
The Bitmap array is just like the Display array,
but it is the working buffer to draw on. After all the drawing is done
for the next frame, the entire Bitmap array is copied to the Display array.
Then, the Bitmap array is cleared and work begins on drawing the next frame
into it. This gives a flicker-free display. |
 |
Each tile takes 16 longs (64 bytes or 512 bits) to
represent it as each tile is 16x16 pixels by 2 bits of color (4 possible
color values). |
 |
The screen is made up of 16x12 tiles. So,
the total memory requirement is 16x12x16 = 3,072 longs = 12,288 Bytes.
Note that 12,288 is $3000 in hex, which explains the size of Bitmap and
Display arrays. |
|