User`s guide
Page 25
www.commodorefree.com
store f3 hex at screen location 1024 (0400 in hex), the two
colours are affected in the corresponding bit of the bitmap
area (top-left 8x8 pixel block in this case, assuming your
bitmap resides at memory location 8192 onwards). How the
colours are worked out is to split the byte into four bits, so f
hex is equal to 15 decimal, which is light grey, and 3 hex is
exactly the same as it would be in decimal, which is cyan.
Therefore the pixels switched off in the block will be cyan and
those switched on will be light grey.
Let's have a look at a quick example of a high-resolution
bitmap then in assembly:
*=$c000 ; Where our program resides in memory
lda #$60
sta $fc
lda #$00
sta $fb ; This will indirectly index the bitmap RAM
lda $d011 ; The following sets up hi-resolution
bitmap
ora #%00100000
sta $d011
lda $dd00
and #%11111100
ora #%00000010
sta $dd00
lda #$5c
sta $0288
lda #$79
sta $d018
lda #$f3 ; This is our default colour setting
ldy #$00
DEFCOL ; Sets up default colour to new screen area
sta $5c00,y
sta $5d00,y
sta $5e00,y
sta $5f00,y
iny
bne DEFCOL
lda #%10000001 ; This will be our default pattern
ldy #$00
sty $d020 ; Sets the border colour according to Y
index
ldx #$20 ; How many pages of RAM we'll be using
LOOP ; This will set our default pattern as above
sta ($fb),y ; if A was set to zero, it would clear all
bits
iny
bne LOOP
inc $fc
dex ; We've set one page, X is decreased
bne LOOP ; This will check if X is zero.
HOLD ; Marker for unconditional infinite loop
jmp HOLD ; Infinite loop
Run it by using SYS 49152 and you should see something that
looks a little like rather sickening stripy wall paper. To find out
more about mono-colour bitmaps, please email me or check
out tinyurl.com/C64-Coding.
Banks and sprites – Part 10
Recapping on last week, I briefly described bit-mapping the
screen on the Commodore 64, and gave a quick example of
displaying a not-very-exciting high-resolution image that could
be said to resemble some rather horrid looking stripy wall
paper. Hopefully, you had the chance to play around with the
example and change the colours and the bit pattern displayed.
You may have noticed that bit-mapping, like re-defining the
character set, requires you to change the VIC-II memory
pointers so it 'sees' the relevant 16K bank of RAM, so in other
words, if you were going to use last week’s example for a basis
to display a title or splash screen, and you had user defined
graphics (UDGs) in your project too, you'd have to ensure your
UDGs where in the same bank as the bit-map when reverting
to text display whilst remembering that all characters should
be written to 5C00 in hexadecimal, unless of course you were
to change the pointer in the VIC-II afterwards to a different
bank. It's therefore easy to guess that memory management is
an issue when creating your C64 project, although there's
nothing that is insurmountable without a bit of forward
thinking, which is where a pencil and paper proves useful. Here
is some example code of changing the bank:
BANKSWITCH
lda $dd00 ; This memory location is used for bank
switching on the VIC-II chip
and #%11111100 ; We only need bits 0 and 1, so we'll
leave bits 2 - 7 unaltered
ora #%00000010 ; and then 'or' the value with the bank
that we want to see
sta $dd00 ; and now we should write the new value
back to location DD00 hexadecimal
rts
So, if you want the default bank on start-up (VIC bank zero,
memory location 0 to 3FFF hex), you'd change the third line of
the above code to:
ora #%00000011
For VIC bank one (located from 4000 to 7FFF hexadecimal), the
value would be as in the code example above, bank two
(starting at 8000 through to BFFF hex), the value would be
#%00000001 and finally bank three (C000 to FFFF hex) would
be #%00000000. Of course, each change will alter where the
character screen and bit-map screen is in RAM - more about
this on the forums at tinyurl.com/C64-Coding, where you may
pose any questions to me. As it's not possible to go too far in-
depth through these pages, it's worth reading up about
memory management by searching the vast Internet for
information, but a good site covering such subject matters is at
codebase64.org.
Looking Spritely
Another feature of the host graphics chip is hardware sprites.
Note that 'sprites' are sometimes referred to as Movable
Object Blocks (MOBs) in some literature.
Without worrying about advanced programming techniques
such as multi-plexing or anything fancy like that, the C64 can