<?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%3ASimple_Raster_Example_1</id>
		<title>Programming:Simple Raster Example 1 - 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%3ASimple_Raster_Example_1"/>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=Programming:Simple_Raster_Example_1&amp;action=history"/>
		<updated>2026-08-28T07:07:46Z</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:Simple_Raster_Example_1&amp;diff=15053&amp;oldid=prev</id>
		<title>CPCLER at 07:55, 14 March 2007</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=Programming:Simple_Raster_Example_1&amp;diff=15053&amp;oldid=prev"/>
				<updated>2007-03-14T07:55:55Z</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;
;;&lt;br /&gt;
;; This example demonstrates a simple raster.&lt;br /&gt;
;; &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;
;; You might have to modify this file if you are using&lt;br /&gt;
;; a different assembler.&lt;br /&gt;
;;&lt;br /&gt;
;; (c) Kevin Thacker 2001,2002&lt;br /&gt;
;;&lt;br /&gt;
;; This source is released under the GNU Public License v2.&lt;br /&gt;
&lt;br /&gt;
org &amp;amp;8000&lt;br /&gt;
nolist&lt;br /&gt;
&lt;br /&gt;
.scr_set_mode equ &amp;amp;bc0e&lt;br /&gt;
&lt;br /&gt;
;;----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
ld a,1&lt;br /&gt;
call scr_set_mode&lt;br /&gt;
&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;
;; select border&lt;br /&gt;
ld bc,&amp;amp;7f10&lt;br /&gt;
out (c),c&lt;br /&gt;
&lt;br /&gt;
;; set border colour to black&lt;br /&gt;
ld bc,&amp;amp;7f54&lt;br /&gt;
out (c),c&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 by border&lt;br /&gt;
;; and horizontal flyback)&lt;br /&gt;
defs 20&lt;br /&gt;
&lt;br /&gt;
;; Timing information:&lt;br /&gt;
;;&lt;br /&gt;
;; in this example we have waited for 4 interrupts, and we can calculate the exact&lt;br /&gt;
;; position and CRTC state.&lt;br /&gt;
;;&lt;br /&gt;
;; the first interrupt will occur 2 HSYNCs after the start of the VSYNC,&lt;br /&gt;
;; the interrupts following this will occur every 52 HSYNCs.&lt;br /&gt;
;; &lt;br /&gt;
;; The instruction timings are shown in [] bracket's below&lt;br /&gt;
&lt;br /&gt;
;; select pen to change (colour 0)&lt;br /&gt;
ld bc,&amp;amp;7f00               ;; [3]&lt;br /&gt;
out (c),c                 ;; [4]&lt;br /&gt;
&lt;br /&gt;
;; start of table for raster colours&lt;br /&gt;
ld hl,raster_colours      ;; [3]&lt;br /&gt;
;; number of colours in the table&lt;br /&gt;
ld e,end_raster_colours-raster_colours   ;;[2]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.rl&lt;br /&gt;
;; get colour byte from table&lt;br /&gt;
ld a,(hl)                 ;; [2]&lt;br /&gt;
inc hl                    ;; [2]&lt;br /&gt;
;; output colour to hardware&lt;br /&gt;
out (c),a                 ;; [4]&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-4-2-2-1-3&lt;br /&gt;
&lt;br /&gt;
dec e                     ;; [1]&lt;br /&gt;
jp nz,rl                  ;; [3]&lt;br /&gt;
&lt;br /&gt;
jp main_loop&lt;br /&gt;
&lt;br /&gt;
;;---------------------------------------------&lt;br /&gt;
&lt;br /&gt;
;; these bytes represent the colours&lt;br /&gt;
;; they are stored in a form that can be written direct to the hardware&lt;br /&gt;
;; bit 7=0, bit 6=1 = Gate Array function &amp;quot;write colour&amp;quot;&lt;br /&gt;
;; bit 4..0 = hardware colour number&lt;br /&gt;
.raster_colours&lt;br /&gt;
defb &amp;amp;44&lt;br /&gt;
defb &amp;amp;55&lt;br /&gt;
defb &amp;amp;57&lt;br /&gt;
defb &amp;amp;5b&lt;br /&gt;
defb &amp;amp;4b&lt;br /&gt;
defb &amp;amp;4b&lt;br /&gt;
defb &amp;amp;5b&lt;br /&gt;
defb &amp;amp;57&lt;br /&gt;
defb &amp;amp;55&lt;br /&gt;
defb &amp;amp;44&lt;br /&gt;
defb &amp;amp;54					;; black&lt;br /&gt;
.end_raster_colours&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>CPCLER</name></author>	</entry>

	</feed>