<br />
<b>Notice</b>:  Trying to access array offset on value of type bool in <b>/mnt/cpcwiki-httpdocs/includes/libs/IPSet.php</b> on line <b>243</b><br />
<br />
<b>Notice</b>:  Trying to access array offset on value of type bool in <b>/mnt/cpcwiki-httpdocs/includes/libs/IPSet.php</b> on line <b>246</b><br />
<br />
<b>Notice</b>:  Trying to access array offset on value of type bool in <b>/mnt/cpcwiki-httpdocs/includes/libs/IPSet.php</b> on line <b>243</b><br />
<br />
<b>Notice</b>:  Trying to access array offset on value of type bool in <b>/mnt/cpcwiki-httpdocs/includes/libs/IPSet.php</b> on line <b>246</b><br />
<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://oldwiki.cpcwiki.eu/index.php?action=history&amp;feed=atom&amp;title=Programming%3AHardware_scrolling_the_screen_using_the_CRTC</id>
		<title>Programming:Hardware scrolling the screen using the CRTC - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://oldwiki.cpcwiki.eu/index.php?action=history&amp;feed=atom&amp;title=Programming%3AHardware_scrolling_the_screen_using_the_CRTC"/>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=Programming:Hardware_scrolling_the_screen_using_the_CRTC&amp;action=history"/>
		<updated>2026-08-28T23:27:23Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.25.1</generator>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=Programming:Hardware_scrolling_the_screen_using_the_CRTC&amp;diff=15022&amp;oldid=prev</id>
		<title>CPCLER at 20:42, 13 March 2007</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=Programming:Hardware_scrolling_the_screen_using_the_CRTC&amp;diff=15022&amp;oldid=prev"/>
				<updated>2007-03-13T20:42:47Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 20:42, 13 March 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L230&quot; &gt;Line 230:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 230:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.message defb &amp;quot;Lets scroll!!&amp;quot;,0&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.message defb &amp;quot;Lets scroll!!&amp;quot;,0&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Programming]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wikidb:diff:version:1.11a:oldid:14933:newid:15022 --&gt;
&lt;/table&gt;</summary>
		<author><name>CPCLER</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=Programming:Hardware_scrolling_the_screen_using_the_CRTC&amp;diff=14933&amp;oldid=prev</id>
		<title>CPCLER at 09:32, 13 March 2007</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=Programming:Hardware_scrolling_the_screen_using_the_CRTC&amp;diff=14933&amp;oldid=prev"/>
				<updated>2007-03-13T09:32:26Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
;; This example demonstrates hardware scrolling using the CRTC.&lt;br /&gt;
;;&lt;br /&gt;
;; This example will function on CPC, CPC+ and KC Compact and ALL CRTC&lt;br /&gt;
;; variants.&lt;br /&gt;
;;&lt;br /&gt;
;; The rate of horizontal scroll is a minimum of 2 CRTC characters.&lt;br /&gt;
;; This is equivalent to:&lt;br /&gt;
;; - 4 pixels in mode 0&lt;br /&gt;
;; - 8 pixels in mode 1&lt;br /&gt;
;; - 16 pixels in mode 2&lt;br /&gt;
;;&lt;br /&gt;
;; The rate of vertical scroll is a minimum of a CRTC character line (the number&lt;br /&gt;
;; of scanlines in the CRTC line is defined using register 9 of the CRTC).&lt;br /&gt;
;; With 8 scanlines per CRTC character line this is equivalent to 8 scanlines.&lt;br /&gt;
;;&lt;br /&gt;
;; The horizontal scroll rate can be improved to scroll by:&lt;br /&gt;
;; This is equivalent to:&lt;br /&gt;
;; - 2 pixels in mode 0&lt;br /&gt;
;; - 4 pixels in mode 1&lt;br /&gt;
;; - 8 pixels in mode 2&lt;br /&gt;
;;&lt;br /&gt;
;; Using register 3 of the CRTC. Another example will demonstrate this method.&lt;br /&gt;
;;&lt;br /&gt;
;; The vertical scroll rate can be improved to scroll by a single scanline at a time,&lt;br /&gt;
;; by using register 5 of the CRTC. Another example will demonstrate this method.&lt;br /&gt;
;;&lt;br /&gt;
;; It is very difficult to scroll the screen pixel by pixel using hardware alone&lt;br /&gt;
;; on the standard CPC hardware. If you want pixel scrolling using the hardware,&lt;br /&gt;
;; then please use the CPC+ enhancements.&lt;br /&gt;
;;&lt;br /&gt;
;; Hardware scrolling is made by changing the start address&lt;br /&gt;
;; of the display.&lt;br /&gt;
;;&lt;br /&gt;
;; Use the following keys:&lt;br /&gt;
;; Q - scroll screen up&lt;br /&gt;
;; A - scroll screen down&lt;br /&gt;
;; O - scroll screen to left&lt;br /&gt;
;; P - scroll screen to right&lt;br /&gt;
&lt;br /&gt;
;; NOTE position of this code is not important&lt;br /&gt;
org &amp;amp;4000&lt;br /&gt;
nolist&lt;br /&gt;
&lt;br /&gt;
.km_read_key equ &amp;amp;bb1b&lt;br /&gt;
.mc_wait_flyback equ &amp;amp;bd19&lt;br /&gt;
.scr_set_mode equ &amp;amp;bc0e&lt;br /&gt;
.txt_output	equ &amp;amp;bb5a&lt;br /&gt;
&lt;br /&gt;
;; set the screen mode&lt;br /&gt;
ld a,1&lt;br /&gt;
call scr_set_mode&lt;br /&gt;
&lt;br /&gt;
;; display a message (so we can see how the screen is scrolling; by the movement&lt;br /&gt;
;; of the message)&lt;br /&gt;
ld hl,message&lt;br /&gt;
call display_message&lt;br /&gt;
&lt;br /&gt;
.loop&lt;br /&gt;
;; wait for vsync &lt;br /&gt;
;;&lt;br /&gt;
;; (synchronises scroll with the screen refresh; as a result it&lt;br /&gt;
;; updates at a constant rate and is smooth)&lt;br /&gt;
call mc_wait_flyback&lt;br /&gt;
&lt;br /&gt;
;; check if any keys are pressed (they will update the scroll offset)&lt;br /&gt;
call check_keys&lt;br /&gt;
&lt;br /&gt;
;; set the scroll offset&lt;br /&gt;
ld hl,(scroll_offset)&lt;br /&gt;
call set_offset&lt;br /&gt;
&lt;br /&gt;
;; loop&lt;br /&gt;
jp loop&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------------------&lt;br /&gt;
.check_keys&lt;br /&gt;
;; test if any key has been pressed&lt;br /&gt;
call km_read_key&lt;br /&gt;
ret nc&lt;br /&gt;
;; A = code of the key that has been pressed&lt;br /&gt;
;;&lt;br /&gt;
;; check the codes we are using and handle appropiatly.&lt;br /&gt;
cp 'Q'				; Q&lt;br /&gt;
jp z,scroll_up&lt;br /&gt;
cp 'A'				; A&lt;br /&gt;
jp z,scroll_down&lt;br /&gt;
cp 'O'				; O&lt;br /&gt;
jp z,scroll_left&lt;br /&gt;
cp 'P'				; P&lt;br /&gt;
jp z,scroll_right&lt;br /&gt;
ret&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
.scroll_up&lt;br /&gt;
;; get the current scroll offset&lt;br /&gt;
ld hl,(scroll_offset)&lt;br /&gt;
&lt;br /&gt;
;; update it&lt;br /&gt;
;;&lt;br /&gt;
;; NOTE: &lt;br /&gt;
;; - 40 is the number of CRTC characters in a CRTC character row &lt;br /&gt;
;; and it is identical to the value written to CRTC register 1 (Horizontal Displayed).&lt;br /&gt;
;;&lt;br /&gt;
;; - If you change the width of the display (using register 1), then you must&lt;br /&gt;
;; change this to the same value for the scroll to operate correctly.&lt;br /&gt;
&lt;br /&gt;
ld bc,40&lt;br /&gt;
or a&lt;br /&gt;
sbc hl,bc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;; ensure scroll offset is in range &amp;amp;000-&amp;amp;3ff&lt;br /&gt;
ld a,h&lt;br /&gt;
and &amp;amp;3&lt;br /&gt;
ld h,a&lt;br /&gt;
&lt;br /&gt;
;; store new scroll offset. It is now ready to be written to the CRTC.&lt;br /&gt;
ld (scroll_offset),hl&lt;br /&gt;
ret&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------------------&lt;br /&gt;
.scroll_down&lt;br /&gt;
;; get current scroll offset&lt;br /&gt;
ld hl,(scroll_offset)&lt;br /&gt;
&lt;br /&gt;
;; update it&lt;br /&gt;
;;&lt;br /&gt;
;; NOTE: &lt;br /&gt;
;; - 40 is the number of CRTC characters in a CRTC character row &lt;br /&gt;
;; and it is identical to the value written to CRTC register 1 (Horizontal Displayed).&lt;br /&gt;
;;&lt;br /&gt;
;; - If you change the width of the display (using register 1), then you must&lt;br /&gt;
;; change this to the same value for the scroll to operate correctly.&lt;br /&gt;
ld bc,40&lt;br /&gt;
add hl,bc&lt;br /&gt;
&lt;br /&gt;
;; ensure scroll offset is in range &amp;amp;000-&amp;amp;3ff&lt;br /&gt;
ld a,h&lt;br /&gt;
and &amp;amp;3&lt;br /&gt;
ld h,a&lt;br /&gt;
&lt;br /&gt;
;; store new scroll offset. It is now ready to be written to the CRTC.&lt;br /&gt;
ld (scroll_offset),hl&lt;br /&gt;
ret&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------------------&lt;br /&gt;
.scroll_left&lt;br /&gt;
;; get current scroll offset&lt;br /&gt;
ld hl,(scroll_offset)&lt;br /&gt;
&lt;br /&gt;
;; update it&lt;br /&gt;
dec hl&lt;br /&gt;
&lt;br /&gt;
;; ensure scroll offset is in range &amp;amp;000-&amp;amp;3ff&lt;br /&gt;
ld a,h&lt;br /&gt;
and &amp;amp;3&lt;br /&gt;
ld h,a&lt;br /&gt;
&lt;br /&gt;
;; store new scroll offset. It is now ready to be written to the CRTC.&lt;br /&gt;
ld (scroll_offset),hl&lt;br /&gt;
ret&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
.scroll_right&lt;br /&gt;
;; get current scroll offset&lt;br /&gt;
ld hl,(scroll_offset)&lt;br /&gt;
&lt;br /&gt;
;; update it&lt;br /&gt;
inc hl&lt;br /&gt;
&lt;br /&gt;
;; ensure scroll offset is in range &amp;amp;000-&amp;amp;3ff&lt;br /&gt;
ld a,h&lt;br /&gt;
and &amp;amp;3&lt;br /&gt;
ld h,a&lt;br /&gt;
&lt;br /&gt;
;; store new scroll offset. It is now ready to be written to the CRTC.&lt;br /&gt;
ld (scroll_offset),hl&lt;br /&gt;
ret&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------------------&lt;br /&gt;
;;&lt;br /&gt;
;; HL = scroll offset in CRTC character units&lt;br /&gt;
&lt;br /&gt;
.set_offset&lt;br /&gt;
ld bc,&amp;amp;bc0c				;; select CRTC register 12&lt;br /&gt;
out (c),c&lt;br /&gt;
ld b,&amp;amp;bd				;; B = I/O address for CRTC register write&lt;br /&gt;
&lt;br /&gt;
;; combine with scroll base&lt;br /&gt;
ld a,(scroll_base)&lt;br /&gt;
or h&lt;br /&gt;
out (c),a&lt;br /&gt;
&lt;br /&gt;
ld bc,&amp;amp;bc0d				;; select CRTC register 13&lt;br /&gt;
out (c),c&lt;br /&gt;
ld b,&amp;amp;bd				;; B = I/O address for CRTC register write&lt;br /&gt;
out (c),l&lt;br /&gt;
ret&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------------------&lt;br /&gt;
;; HL = points to start of message&lt;br /&gt;
;; message is terminated with a 0 character&lt;br /&gt;
&lt;br /&gt;
.display_message&lt;br /&gt;
ld a,(hl)			;; get character&lt;br /&gt;
inc hl				;; increment message pointer&lt;br /&gt;
or a				;; termination character?&lt;br /&gt;
ret z&lt;br /&gt;
call txt_output		;; display character&lt;br /&gt;
jr display_message	;; loop&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
;; high byte of the screen base address&lt;br /&gt;
;; &amp;amp;00 -&amp;gt; screen uses &amp;amp;0000-&amp;amp;3fff&lt;br /&gt;
;; &amp;amp;10 -&amp;gt; screen uses &amp;amp;4000-&amp;amp;7fff&lt;br /&gt;
;; &amp;amp;20 -&amp;gt; screen uses &amp;amp;8000-&amp;amp;bfff&lt;br /&gt;
;; &amp;amp;30 -&amp;gt; screen uses &amp;amp;c000-&amp;amp;ffff&lt;br /&gt;
&lt;br /&gt;
.scroll_base defb &amp;amp;30&lt;br /&gt;
&lt;br /&gt;
;; the scroll offset in CRTC character units&lt;br /&gt;
.scroll_offset defw 0&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------------------&lt;br /&gt;
.message defb &amp;quot;Lets scroll!!&amp;quot;,0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>CPCLER</name></author>	</entry>

	</feed>