IntroI am reading this book "On The Edge - Spectacular Rise and Fall of Commodore" and enjoying the history of some of the coolest home computers ever. It was a wild ride for Commodore and people that were part of that history. C64 was my first computer when I was growing up. Anyhow, I did not have much input on C64 details at the time. I also got Simon's Basic cartridge so I did not have to learn all the PEEK and POKE tricks. Not that I did not know some.

I do have couple of Commodore 64s, but I find VICE emulator running on my Ubuntu Linux very useful. I occasionally enjoy some of the games. From time to time I explore some of the features I never played with. This entry is on how to set up high resolution graphics (calling 320x200 pixels high resolution, he he). There is whole shabazz of VIC II locations (control registers) and several options what can be done with the graphics. Not very impressive now, but quite powerful at the time. VIC II chip was probably one of the most important parts in the C64. Wish they did not screw up the fast serial lines and were not that much in a hurry and used better version of BASIC.
ProgramI am checking the Commodore 64 Programmer's Reference Guide. The following program combines info from its pages into a small demo plotting a line on the screen.

The program switches on the graphics mode. Sets the memory location for the bit map. Then, both the bit map memory area and the text area are set to clear the screen and define the colors for each 8x8 region on the screen. Finally, a routine for plotting a line is called.
Running the ProgramThe cool thing is that the C64 BASIC is so slow that you can see stuff happening before your eyes. Please note that VICE emulator does pretty good job on timings.

Once the graphics was turned on, there is this garbage on the screen. The two loops there are to POKE graphics memory to clear the screen. This takes several seconds to finish.

Second loop fills in the text memory and defines colors. This is little faster as we talking about 1000 locations as compared to 8000 locations of graphics bit map.

Finally, the last loop plots the line point by point. The subroutine for plotting the line starts at line 1000. The subroutine to plot individual dot starts at 2000.
Referencehttp://www.devili.iki.fi/Computers/Commodore/C64/Programmers_Reference/page_iii.html
No comments:
Post a Comment