Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!husc6!husc7!byrd From: byrd@husc7.HARVARD.EDU (John Byrd) Newsgroups: comp.sys.cbm Subject: Re: Machine Language Smooth Scrolling Problem Keywords: machine language, scrolling, C64 Message-ID: <2823@husc6.harvard.edu> Date: 11 Oct 89 08:02:18 GMT References: <2317@jarthur.Claremont.EDU> <136@cbmtor.UUCP> Sender: news@husc6.harvard.edu Reply-To: byrd@husc7.UUCP (John Byrd) Organization: Harvard University Science Center Cambridge, MA Lines: 45 There have been a number of messages requesting help on "smooth scrolling" for the 64 mode, and Jim Butterfield posted a very intelligent solution to this problem. However, his solution may have been a little difficult to understand for novice programmers. I hope that I can explain the smooth- scroll idea here in more of lay-programmers' terms. Locations $D011 and $D016 in the 64 contain the smooth-scroll information in the lower 3 bits of each of the registers. All the information on the screen may be slid up to 7 pixels (dots) to the right and 7 pixels down. So how does a programmer achieve the sliding, scrolling effect popular in games? When the screen picture has been slid to its maximum distance, e.g. when a register contains $111 in its lower 3 bits, all the characters on the screen must be moved via a software routine, and new characters must be added on to one side of the screen. At this point the register may be reset to $000. The effect is that of shifting the picture one pixel. This procedure may be reversed and used on the other register to facilitate scrolling in any direction. The programmer must watch for "flicker" when designing and writing this type of sliding routine. If the raster (present line which is being drawn on the television screen) happens to be on the screen when the screen is being moved via the software routine, the screen will flicker. This can be resolved by checking location $D012. The raster is on the screen only when the value of this location is between 51 and 251, AND when the high bit of location $D011 is OFF. Otherwise it is okay to do the software scroll. Jim Butterfield suggested that TWO separate screens should be maintained. In essence, display one screen while preparing the other for viewing; then, when the raster is off the screen, swap the viewed screen and the hidden screen. This swap can generally be done with a few POKES and PEEKS, although the BASIC language is inadvisable for this type of programming due to its lack of speed. Speed of processing is essential for raster techniques; the raster makes a pass of the screen every 1/60th of a second. I hope that this message gives a better understanding of scrolling techniques. ------------------------------------------------------------------------------ John Byrd byrd@husc7.bitnet Q-Link: John Byrd -----------------------------------------------------------------------------