<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.amstrad-cpc.net/index.php?action=history&amp;feed=atom&amp;title=Programming%3ASimple_Raster_Example_2_%28uses_CPC_plus_features%29</id>
	<title>Programming:Simple Raster Example 2 (uses CPC plus features) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.amstrad-cpc.net/index.php?action=history&amp;feed=atom&amp;title=Programming%3ASimple_Raster_Example_2_%28uses_CPC_plus_features%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.amstrad-cpc.net/index.php?title=Programming:Simple_Raster_Example_2_(uses_CPC_plus_features)&amp;action=history"/>
	<updated>2026-09-03T18:35:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.amstrad-cpc.net/index.php?title=Programming:Simple_Raster_Example_2_(uses_CPC_plus_features)&amp;diff=35794&amp;oldid=prev</id>
		<title>CPCLER at 07:58, 14 March 2007</title>
		<link rel="alternate" type="text/html" href="https://wiki.amstrad-cpc.net/index.php?title=Programming:Simple_Raster_Example_2_(uses_CPC_plus_features)&amp;diff=35794&amp;oldid=prev"/>
		<updated>2007-03-14T07:58:19Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:58, 14 March 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l189&quot;&gt;Line 189:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 189:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; 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=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; 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 class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Programming]][[Category:CPC &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;plus&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; 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;[[Category:Programming]][[Category:CPC &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Plus&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>CPCLER</name></author>
	</entry>
	<entry>
		<id>https://wiki.amstrad-cpc.net/index.php?title=Programming:Simple_Raster_Example_2_(uses_CPC_plus_features)&amp;diff=35793&amp;oldid=prev</id>
		<title>CPCLER at 07:57, 14 March 2007</title>
		<link rel="alternate" type="text/html" href="https://wiki.amstrad-cpc.net/index.php?title=Programming:Simple_Raster_Example_2_(uses_CPC_plus_features)&amp;diff=35793&amp;oldid=prev"/>
		<updated>2007-03-14T07:57:37Z</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 shows a simple raster using the CPC+ &lt;br /&gt;
;; extended palette, and using standard CPC compatible &lt;br /&gt;
;; raster interrupts to define the position of the raster &lt;br /&gt;
;; on the display.&lt;br /&gt;
;; &lt;br /&gt;
;; This example is designed for CPC+ only and will&lt;br /&gt;
;; not work on CPC or KC Compact.&lt;br /&gt;
;;&lt;br /&gt;
;;&lt;br /&gt;
;; This example will compile with the MAXAM assembler&lt;br /&gt;
;; or the built-in assembler of WinAPE32.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;; NOTE - For this example to work, the code must not&lt;br /&gt;
;; be in the range &amp;amp;4000-&amp;amp;7fff inclusive. The ASIC registers&lt;br /&gt;
;; are paged into this range, and the code would not be&lt;br /&gt;
;; visible to the CPU if it was also in this range.&lt;br /&gt;
org &amp;amp;8000&lt;br /&gt;
&lt;br /&gt;
.scr_set_mode equ &amp;amp;bc0e&lt;br /&gt;
&lt;br /&gt;
;;--------------------------------------------------&lt;br /&gt;
;; clear screen&lt;br /&gt;
ld a,1&lt;br /&gt;
call scr_set_mode&lt;br /&gt;
&lt;br /&gt;
;;--------------------------------------------------&lt;br /&gt;
;; STEP 1 - Unlock CPC+ additional features&lt;br /&gt;
;; unlock asic to gain access to asic registers&lt;br /&gt;
&lt;br /&gt;
di&lt;br /&gt;
ld b,&amp;amp;bc&lt;br /&gt;
ld hl,sequence&lt;br /&gt;
ld e,17&lt;br /&gt;
.seq &lt;br /&gt;
ld a,(hl)&lt;br /&gt;
out (c),a&lt;br /&gt;
inc hl&lt;br /&gt;
dec e&lt;br /&gt;
jr nz,seq&lt;br /&gt;
ei&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------&lt;br /&gt;
;; STEP 2 - Install a interrupt handler&lt;br /&gt;
;;&lt;br /&gt;
;; install a interrupt handler&lt;br /&gt;
&lt;br /&gt;
;; disable interrupts&lt;br /&gt;
di&lt;br /&gt;
;; interrupt mode 1 (call to interrupt handler at &amp;amp;0038)&lt;br /&gt;
im 1&lt;br /&gt;
&lt;br /&gt;
;; &amp;amp;c9 corresponds to the opcode RET&lt;br /&gt;
;; &amp;amp;fb corresponds to the opcode EI&lt;br /&gt;
;;&lt;br /&gt;
;; RET opcode takes 3us, EI opcode takes 1us&lt;br /&gt;
&lt;br /&gt;
;; write EI,RET to interrupt handler at &amp;amp;0038&lt;br /&gt;
ld hl,&amp;amp;c9fb&lt;br /&gt;
ld (&amp;amp;0038),hl&lt;br /&gt;
&lt;br /&gt;
;; enable interrupts&lt;br /&gt;
ei&lt;br /&gt;
&lt;br /&gt;
;;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
.main_loop&lt;br /&gt;
&lt;br /&gt;
;;---------------------------------------&lt;br /&gt;
;; wait for start of vsync&lt;br /&gt;
;;&lt;br /&gt;
;; at this point the code assumes the VSYNC is not active.&lt;br /&gt;
;;&lt;br /&gt;
;; this code waits for the VSYNC to change from inactive-&amp;gt;active&lt;br /&gt;
;; which signals the start of the VSYNC.&lt;br /&gt;
&lt;br /&gt;
;; PPI port B&lt;br /&gt;
ld b,&amp;amp;f5&lt;br /&gt;
&lt;br /&gt;
.ml1&lt;br /&gt;
;; read input&lt;br /&gt;
in a,(c)&lt;br /&gt;
;; transfer bit 0 into carry&lt;br /&gt;
;; if bit 0=1 then VSYNC is active, if bit 0=0 then VSYNC is inactive&lt;br /&gt;
rra&lt;br /&gt;
jr nc,ml1&lt;br /&gt;
;;----------------------------------------&lt;br /&gt;
&lt;br /&gt;
;; wait for interrupt&lt;br /&gt;
halt&lt;br /&gt;
&lt;br /&gt;
;; wait for interrupt&lt;br /&gt;
halt&lt;br /&gt;
&lt;br /&gt;
;; wait for interrupt&lt;br /&gt;
halt&lt;br /&gt;
&lt;br /&gt;
;; wait for interrupt&lt;br /&gt;
halt&lt;br /&gt;
&lt;br /&gt;
;; delay so that colour change position is not visible (hidden&lt;br /&gt;
;; by border and horizontal flyback)&lt;br /&gt;
defs 20&lt;br /&gt;
&lt;br /&gt;
;; page-in asic registers to &amp;amp;4000-&amp;amp;7fff&lt;br /&gt;
ld bc,&amp;amp;7fb8					;; [3]&lt;br /&gt;
out (c),c					;; [4]&lt;br /&gt;
&lt;br /&gt;
ld de,&amp;amp;6400					;; colour 0&lt;br /&gt;
&lt;br /&gt;
;; start of table&lt;br /&gt;
ld hl,raster_colours&lt;br /&gt;
;; number of colours in table&lt;br /&gt;
ld b,end_raster_colours-raster_colours   &lt;br /&gt;
;; /2&lt;br /&gt;
srl b&lt;br /&gt;
&lt;br /&gt;
.rl&lt;br /&gt;
;; read colour from table (a byte at a time)&lt;br /&gt;
;; write colour to ASIC colour palette (a byte at a time)&lt;br /&gt;
&lt;br /&gt;
ld a,(hl)					;; [2]&lt;br /&gt;
ld (de),a					;; [2]&lt;br /&gt;
inc hl						;; [2]&lt;br /&gt;
inc e						;; [1]&lt;br /&gt;
ld a,(hl)					;; [2]&lt;br /&gt;
ld (de),a					;; [2]&lt;br /&gt;
inc hl						;; [2]&lt;br /&gt;
dec e						;; [1]&lt;br /&gt;
&lt;br /&gt;
;; delay so that the next colour change&lt;br /&gt;
;; occurs immediatly below this one&lt;br /&gt;
defs 64-2-2-2-1-2-2-2-1-1-3&lt;br /&gt;
&lt;br /&gt;
dec b						;; [1]&lt;br /&gt;
jp nz,rl					;; [3]&lt;br /&gt;
&lt;br /&gt;
;; page-out asic registers&lt;br /&gt;
ld bc,&amp;amp;7fa0&lt;br /&gt;
out (c),c&lt;br /&gt;
&lt;br /&gt;
jp main_loop&lt;br /&gt;
&lt;br /&gt;
;;---------------------------------------------&lt;br /&gt;
&lt;br /&gt;
;; - there is two bytes per colour.&lt;br /&gt;
;; - these are stored in a form that can be written direct &lt;br /&gt;
;; to the CPC+ colour palette registers&lt;br /&gt;
;; e.g. xGRB&lt;br /&gt;
.raster_colours&lt;br /&gt;
defw &amp;amp;0111&lt;br /&gt;
defw &amp;amp;0222&lt;br /&gt;
defw &amp;amp;0333&lt;br /&gt;
defw &amp;amp;0444&lt;br /&gt;
defw &amp;amp;0555&lt;br /&gt;
defw &amp;amp;0666&lt;br /&gt;
defw &amp;amp;0777&lt;br /&gt;
defw &amp;amp;0888&lt;br /&gt;
defw &amp;amp;0999&lt;br /&gt;
defw &amp;amp;0aaa&lt;br /&gt;
defw &amp;amp;0bbb&lt;br /&gt;
defw &amp;amp;0ccc&lt;br /&gt;
defw &amp;amp;0ddd&lt;br /&gt;
defw &amp;amp;0eee&lt;br /&gt;
defw &amp;amp;0fff&lt;br /&gt;
defw &amp;amp;0fff&lt;br /&gt;
defw &amp;amp;0eee&lt;br /&gt;
defw &amp;amp;0ddd&lt;br /&gt;
defw &amp;amp;0ccc&lt;br /&gt;
defw &amp;amp;0bbb&lt;br /&gt;
defw &amp;amp;0aaa&lt;br /&gt;
defw &amp;amp;0999&lt;br /&gt;
defw &amp;amp;0888&lt;br /&gt;
defw &amp;amp;0777&lt;br /&gt;
defw &amp;amp;0666&lt;br /&gt;
defw &amp;amp;0555&lt;br /&gt;
defw &amp;amp;0444&lt;br /&gt;
defw &amp;amp;0333&lt;br /&gt;
defw &amp;amp;0222&lt;br /&gt;
defw &amp;amp;0111&lt;br /&gt;
defw &amp;amp;0000&lt;br /&gt;
.end_raster_colours&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------&lt;br /&gt;
;; this is the sequence to unlock the ASIC extra features&lt;br /&gt;
.sequence&lt;br /&gt;
defb &amp;amp;ff,&amp;amp;00,&amp;amp;ff,&amp;amp;77,&amp;amp;b3,&amp;amp;51,&amp;amp;a8,&amp;amp;d4,&amp;amp;62,&amp;amp;39,&amp;amp;9c,&amp;amp;46,&amp;amp;2b,&amp;amp;15,&amp;amp;8a,&amp;amp;cd,&amp;amp;ee&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]][[Category:CPC plus]]&lt;/div&gt;</summary>
		<author><name>CPCLER</name></author>
	</entry>
</feed>