Some general information first. There are 1000 possible locations on the Commodore 64 screen. Normally, the screen starts at location 1024 ($0400 in HEXadecimal notation) and goes to location 2023. Each of these locations is 8 bits wide. This means that it can hold any integer number from 0 to 255. Connected with screen memory is a group of 1000 locations called COLOR MEMORY or COLOR RAM. These start at location 55296 ($D800 in HEX) and go up to 56295. Each of the color RAM locations is 4 bits wide, which means that it can hold any integer number from 0 to 15. Since there are 16 possible colors that the Commodore 64 can use, this works out well.
In addition, there are 256 different characters that can be displayed at any time. For normal screen display, each of the 1000 locations in screen memory contains a code number which tells the VIC-II chip which character to display at that screen location.
The various graphics modes are selected by the 47 CONTROL registers in the VIC-II chip. Many of the graphics functions can be controlled by POKEing the correct value into one of the registers. The VIC-II chip is located starting at 53248 ($D000 in HEX) through 53294 ($D02E in HEX).
The VIC-II chip can access ("see") 16K of memory at a time. Since there is 64K of memory in the Commodore 64, you want to be able to have the VIC-II chip see all of it. There is a way. There are 4 possible BANKS (or sections) of 16K of memory. All that is needed is some means of controlling which 16K bank the VIC-II chip looks at. In that way, the chip can "see" the entire 64K of memory. The BANK SELECT bits that allow you access to all the different sections of memory are located in the 6526 COMPLEX INTERFACE ADAPTER CHIP #2 (CIA #2). The POKE and PEEK BASIC statements (or their machine language versions) are used to select a bank, by controlling bits 0 and 1 of PORT A of CIA#2 (location 56576 (or $DD00 HEX)). These 2 bits must be set to outputs by setting bits 0 and 1 of location 56578 ($DD02 HEX) to change banks. The following example shows this:
POKE 56578,PEEK(56578)OR 3: REM MAKE SURE BITS 0 AND 1 ARE OUTPUTS POKE 56576,(PEEK(56576)AND 252)OR A: REM CHANGE BANKS
"A" should have one of the following values:
|This page has been created by Sami Rautiainen.|
|Read the small print.||Last updated January 10, 2003.|