Changes
CRTC
,/* Hardware scrolling */
<br>
=== Hardware Coarse hardware scrolling ===
The start address can be manipulated to achieve horizontal and/or vertical hardware scrolling:
The first game that used R12/R13 for both horizontal and vertical hardware scrolling is [https://www.cpc-power.com/index.php?page=detail&num=1839 Roland on the Ropes], released in 1984.
The following BASIC program demonstrates the coarse scrolling by setting the R12 and R13 registers based on keyboard input:
<pre>
10 ma%=0
20 IF INKEY(1)=0 THEN GOSUB 100
30 IF INKEY(2)=0 THEN GOSUB 300
40 IF INKEY(8)=0 THEN GOSUB 500
50 IF INKEY(0)=0 THEN GOSUB 700
60 GOTO 20
100 ' right
110 ma%=ma%+1: GOSUB 900: RETURN
300 ' down
310 ma%=ma%+40: GOSUB 900: RETURN
500 ' left
510 ma%=ABS(ma%-1): GOSUB 900: RETURN
700 ' up
710 ma%=ABS(ma%-40): GOSUB 900: RETURN
900 ' set R12 and R13
910 l%=ma% AND 255: h%=&30 OR ((ma%\256) AND 3) :OUT &BC00,13:OUT &BD00,l%: OUT &BC00,12:OUT &BD00,h%
930 RETURN
</pre>
Which looks like the following:
[[File:CRTC-Coarse-scroll.gif]]
<br>
=== Advanced hardware scrolling ===
To achieve smoother hardware scrolling, other tricks are required in complement to R12/R13. Usually, R3 is used for smooth horizontal scroll and R5 for smooth vertical scroll.