User`s guide

Page 24
www.commodorefree.com
ASSEMBLER PROGRAMMING
MICRO MART BY SHAUN BEBBINGTON (C)
Author's notes: This is the third lot of tutorials (parts 9 through
to 12 inclusive) that were published in Micro Mart magazine
between February and July 2011 in the 'Specialist' section,
which also includes Amiga, Apple, Linux and gaming news and
views – see www.micromart.co.uk for more information about
this publication.
Disclaimer: The tutorials assume some prior knowledge of
machine code, so you may need to read the last two issues of
Commodore FREE which has parts one through to four and five
through to eight . None of this will not be very useful if you are
not a complete beginner and I'm only providing a foundation
on which to build. I'm sure all of the example code could be
improved greatly. Remember: the more you experimentation
you do with your code, and the more you read up about the
Commodore 64's hardware, the more you will learn. Even
better if you enjoy programming, because this will aid your
progression as much [or more] than anything else.
I retain the copyright for these articles, which are used in
Commodore FREE with permission. If you would like to contact
me about them, then you may do so through the Micro Mart
forums and a link is provided. Without any further ado, here is
the next installment, which covers some of the very basics. The
original images that I provided with the articles are included
for illustration purposes only.
Bitmapping – Part 9
Without delving too far into the secrets of the Commodore 64's
many graphics modes, such as Flexible Line Interpretation
(known as FLI) or the interlaced version [IFLI], the VIC-II chip
sees the screen as 8x8 character blocks by default, but can also
'bit-map' the screen, allowing 64,000 pixels to be manipulated
by the user. Each eight pixels is grouped together in a byte, so
the bit-mapped screen excluding colour RAM is 8,000 bytes of
memory, or just under 8K. By comparison, a screen full of
characters is 8 times smaller, excluding colour nybbles (and
any memory used for user-defined graphics).
Whether you're using plain old characters (or UDGs) or you're
bit-mapping the screen, or using both, you can toggle multi-
coloured mode, which means that the vertical resolution is
essentially halved and the number of colours in an 8x8 pixel
area is doubled from two to four, giving a 'chunky' 160 x 200
pixel matrix. More about this later. For now, we'll just worry
about high-resolution bit-mapping (sometimes referred to as
mono-colour mode).
The first thing that you will need to do when switching on
bitmap mode is to know where your bitmap will reside in
memory. For a full bitmap, there are certain places in RAM
that are used and these cannot be altered at will. You should
also note that when in this mode, each character block on the
text screen is used to define the colour of the pixel area on the
bitmap that it matches (assuming mono-colour, also referred
to as high-resolution). The easiest way to think of this is that
the each character on the normal screen is below each 8x8
pixel area of the bitmap, and affects the foreground and
background colour in each block (pixels that are on or off
respectively). As the C64 has just 16 colours, ranging from 0 to
15 inclusive, the colours are represented by four-bits each, as
this fits exactly into our 8-bit hexadecimal system, so if you