PDA

View Full Version : Smooth Text Scrolling on C-64



jeff48356
December 24th, 2007, 06:27 AM
I noticed in some machine language programs on the C-64, there is smooth (pixel-by-pixel) scrolling text, like a banner. This doesn't seem possible in BASIC, where only character-by-character scrolling is possible. How do the programmers accomplish this in ML?

carlsson
December 25th, 2007, 02:56 PM
The VIC-II chip has two shift registers, one for horizontal and one for vertical scrolling. It also has an option to select 38/40 visible columns and 24/25 visible rows. By setting the screen to 38 columns, scroll it eight pixels to the left, copy the screen contents one character to the left and repeat the scroll process, you will get a smooth scrolling text. Actually, it can be done in Basic too, but it will flicker a bit:

5 PRINT"{CLS}":A$="THIS IS AN EXAMPLE OF A SCROLLING TEXT - WRAP! "
10 FORI=1TOLEN(A$):POKE53270,199
20 PRINT"{HOME}{RIGHT}";CHR$(20);TAB(39);MID$(A$,I,1)
25 FORJ=199TO192STEP-1:POKE53270,J:NEXTJ
30 NEXTI:GOTO10

The flicker comes from line 20, when the text suddenly is pulled back one character. Using machine code, the routine could be timed to run at a specific raster row so the flicker would not be visible. Another idea is to use double buffering, which in this case means allocating space for two video matrices and swapping between them. I can elaborate on these techniques later if you're seriously interested.