<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=Z80%3AInput_Routines</id>
	<title>Z80:Input Routines - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=Z80%3AInput_Routines"/>
	<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=Z80:Input_Routines&amp;action=history"/>
	<updated>2026-06-03T04:53:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>http://learn.cemetech.net/index.php?title=Z80:Input_Routines&amp;diff=135&amp;oldid=prev</id>
		<title>KermMartian: Created page with &quot;The main source of user input will be through the keypad, so almost every input routine will require use of a GetKey function.  &#039;&#039;&#039;Note:&#039;&#039;&#039; This page will need to have routine...&quot;</title>
		<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=Z80:Input_Routines&amp;diff=135&amp;oldid=prev"/>
		<updated>2016-02-05T06:38:36Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;The main source of user input will be through the keypad, so almost every input routine will require use of a GetKey function.  &amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; This page will need to have routine...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The main source of user input will be through the keypad, so almost every input routine will require use of a GetKey function.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; This page will need to have routines for actual user input aside from GetKey routines.&lt;br /&gt;
&lt;br /&gt;
= GetKey =&lt;br /&gt;
This is essentially like several of the OS routines. If OS interrupts are read, you can also read from address 8445h. But if you really want a custom routine:&lt;br /&gt;
&lt;br /&gt;
    ;===============================================================&lt;br /&gt;
    GetKey:&lt;br /&gt;
    ;===============================================================&lt;br /&gt;
    ;Outputs:&lt;br /&gt;
    ;     A is a value from 0 to 56 that is the keypress&lt;br /&gt;
    ;    HL is not modified&lt;br /&gt;
    ;    BC is not modified&lt;br /&gt;
    ;Destroys:&lt;br /&gt;
    ;    D&lt;br /&gt;
    ;    E is destroyed if no keys are pressed, else it is also the keypress&lt;br /&gt;
    ;===============================================================&lt;br /&gt;
         ld de,$7FFF&lt;br /&gt;
    KeyLoop:&lt;br /&gt;
         rlc d&lt;br /&gt;
         ld a,d&lt;br /&gt;
         out (1),a&lt;br /&gt;
         sub 7Fh&lt;br /&gt;
         ret z&lt;br /&gt;
         ld a,e&lt;br /&gt;
         add a,8&lt;br /&gt;
         ld e,a&lt;br /&gt;
         in a,(1)&lt;br /&gt;
         inc a&lt;br /&gt;
         jr z,KeyLoop&lt;br /&gt;
         dec a&lt;br /&gt;
           inc e&lt;br /&gt;
           rra&lt;br /&gt;
           jr c,$-2&lt;br /&gt;
         ld a,e&lt;br /&gt;
         ret&lt;br /&gt;
&lt;br /&gt;
= ScanAllKeys =&lt;br /&gt;
This routine requires 7 bytes of RAM pointed to by HL. This will return the value of all the key groups, stored in each of the bytes:&lt;br /&gt;
&lt;br /&gt;
    ScanAllKeys:&lt;br /&gt;
    ;Inputs:&lt;br /&gt;
    ;     HL points to the 7 bytes to output the result to&lt;br /&gt;
    ;Notes:&lt;br /&gt;
    ;     There is not enough delay for 15MHz&lt;br /&gt;
         ld bc,0701h&lt;br /&gt;
         ld a,$FE      ;test the keys&lt;br /&gt;
    KeyUpdateLoop:&lt;br /&gt;
         out (1),a&lt;br /&gt;
         rlca&lt;br /&gt;
         nop&lt;br /&gt;
         ini&lt;br /&gt;
         jr nz,KeyUpdateLoop&lt;br /&gt;
         ret&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{lowercase}}&lt;br /&gt;
[[Category:Z80 Assembly]]&lt;br /&gt;
[[Category:Z80 Heaven]]&lt;/div&gt;</summary>
		<author><name>KermMartian</name></author>
	</entry>
</feed>