• entries
50
92
• views
66637

# VIC-II high resolution bit mapping mode

1055 views

Today I stopped playing with the text mode and entered bit mapping mode ( or, for modern people - bitmap mode ).

VIC-II, C64's graphics chip allows for resolutions of up to 320x200. In text mode that display is divided into 40x25 ( 1000 continuous characters ), each of which is 8x8 pixels big. As I mentioned previously, the characters are stored as 8 bytes, with each bit being either or on off, and making the pixel respectively the color of the character or the color of the background.

This is all fine and dandy in text mode, but how does the high res gfx mode look like? First of all - in high res mode, each 8x8 pixel block can have only 2 colors, much like the text mode. The change is that not the color RAM governs it ( the 0xD800-0xDBE7 ), but the characters in the screen memory ( 0x400-0x7E7 ). How does it work precisely? Each byte consists of lower and higher 4 bits. Low bits are interpreted as the color for background ( off state ), high bits are interpreted as the color for foreground ( on state ). To have first char ( upper left 8x8 pixels ) have black background and white foreground, poke its position ( 1024 or 0x400 ) with 0 ( for black background ) + 16 * 1 ( for white foreground ). Green-blue would be 5 + 16 * 6. Etc. Btw, for color values refer to booklet, wiki page on VIC-II or any other source you can think of.

Ok, that's how the colors are picked. How about the bitmap itself? Well, things are bit complicated here. You designate a bitmap area, and poke it. Bitmap area is 8000 bytes long ( 8 bytes per 8x8 block, 1000 chars ), and it's stored on per-char basis. That means first 8 bytes are first character on the screen, next 8 bytes are the second character, and so forth. Makes for a really confusing plotting when you're trying to do some drawing.

It's not that bad though, and the C64 booklet is quick to help.

I converted yesterday's code to bitmap mode, and here's the result:

It took AGES to render ( minutes, even after turning emulator speed to 2500% of original C64 ). Clearly, it's because I've done it in BASIC and without any optimisations, but at a depth of 16 it looks really nice.

If anybody wants the code, here it is:

sc = 0: pc = 1for i = 1024 to 2023poke i,sc+16*pcnextpoke 53265,peek(53265)or 32poke 53272,peek(53272)or 8for i=8192 to 16191poke i,0next iREM CLEARED SCREEN WHITEoffset = 8192for x = 0 to 319for y = 0 to 199ch=int(x/8)ro=int(y/8)ln= y and 7by = offset + ro*320+8*ch+lnbi = 7-( x and 7 )x0 = ((x/320) * 3.5 - 2.5)y0 = ((y/200) * 2 - 1)iter = 0maxiter = 2a = 0b = 0if a*a + b*b < 4 then goto 27goto 34if iter < maxiter then goto 29goto 34atemp = a*a-b*b+x0b = 2*a*b + y0a = atempiter = iter + 1goto 25if iter > maxiter then goto 36poke by,peek(by)or(2^BI)next ynext x

Just add line numbers as your text editor shows them and you're ready to go. Oh yeah, if you're typing it on VICE, ^ symbol is the upper arrow and it's bound to DEL. And remember, to quit the GFX mode, use ESC-PGUP.

See you next time, when I'll be adding more colors to the high res image!

Also, I have found a website with over 2 GiB worth of old C64 books with awesome titles like 'Artificial Intelligence projects on C64', 'DIY robotics and sensors using C64', 'Make your C64 Sing', 'Start Programming with GORTEK AND THE MICROCHIPS' or 'Will you still love me when I'm 64' :DDDD

The website is here: http://www.bombjack.org/commodore/books.htm

There are no comments to display.

## Create an account

Register a new account