APPLICATIONSPROGRAMMATION ★ KEY FACTS (PERSONAL COMPUTING TODAY) ★

Key Facts (Personal Computing Today)Applications Programmation
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

If you're finding that the manual is a little difficult to follow in the area of key redefinition, read on for a full explanation and program. By David Ellis.

The keyboard of the Amstrad CPC64 must be one of the most versatile ever produced on a micro — it is entirely 'soft'. All of the keys, including the joystick, can be programmed to produce any character with any key, in both shifted and unshifted modes, and also when the 'CTRL' key is used. Any key can be programmed to auto repeat or not, when held down, and the initial delay and repeat speed can also be set.

Commands are available to test not only which key is pressed — as is usual on most micros — but whichever combination of keys is pressed. You could specify that four keys (or even more) have to be pressed simultaneously, before a certain operation is performed. Add to this the
fact that up to 32 of the keys can be used as function keys, and that each function key can consist of 255 characters, and this gives a total of nearly 8K of user defined keyboard functions.

Now that last statement may be a little confusing to those of you who are familiar with the CPC464. Perhaps you thought that only the numeric pad could be used for funtion keys, and everyone knows that the maximum number of characters allowed is 1 20 in total. On the first point, the manual is not very clear. You can indeed use any key as a function key. On the second point — well it is possible very easily by using a machine code routine just 9 bytes in length.

Key definition

Before showing how this is done let's look at the basic operation of defining keys, and please don't confuse this with redefining of the ASCII characters themselves — this is done with the SYMBOL AFTER command and does not concern us here.

Each of the keys on the keyboard (including the joystick) is given a number between 0 and 79. There is an apparent logical sequence for the way in which the keys are numbered. Appendix III page 16 in the user manual shows all the various numbers for the keys.

The KEY DEF command is used to determine which characters appear on the screen when that particular key is pressed, and whether or not the key will auto repeat. Five parameters are required by this command:

  • The number of the key
  • Whether the key will auto repeat (1 ) or not (0)
  • Character when UNSHIFTED
  • Character when SHIFTED
  • Character when CTRL key is used

For example, the 'A' key could be redefined to print the letter 'B' when unshifted, 'C' when shifted, and 'E' with the CTRL key, and auto repeat by the following line:

KEY DEF 69,1,66,67 ,69

69 is the key number for 'A'. Auto repeat is indicated by '1'B', 'C' and 'E' by 66, 67, and 69 respectively. Any number in the range 0 to 255 could be used for the last three parameters. However, the numbers from 128 to 159 are set aside for the 'expansion characters'. I shall refer to these as the keyboard functions.

These are merely a string of characters which will be printed out when the appropriate key is pressed. The CHR$ function can be used at the beginning or at the end of the string if required. The function is set up by the keyword KEY. This is simply KEY, followed by a number between 1 28 and 159, followed by the character string. For example:

KEY 128,"CLS" + CHR$ (13)

When the key that uses this function is pressed, CLS will be printed on the screen, and the CHR$(13) will cause a carriage return to be issued — thus the screen will clear. All that needs doing is to assign this function to whatever key you wish by using the KEY DEF command. To put this function on the CLR key (number 16) the following could be used:

KEY DEF 16,1,16,16,128

The operation of the CLR key will remain the same in the unshifted and shifted states but with the CTRL key pressed, it will call the key function assigned to 128 — ie it will clear the screen.

Key assignations

It is now a simple matter to define whatever string function you require for the remaining function codes 129 and 159 and then assign these to whichever keys you desire. In most cases it will be better to use the CTRL key, but for some of the keys you could use the function in the shifted state — the RETURN key, SPACE BAR, and the keys on the NUMERIC PAD for instance, which are not normally used with the shift key.

The only problem now, is that once the 1 20 characters are used up for the function strings, the BASIC interpreter will return an error condition and will not accept any more KEY functions. It is possible through the 'JUMPBLOCK' though, to set the starting address and the size of the buffer that is to hold the function characters.

Line 10 in Listing 1 sets the 'Top of BASIC' to &9000 (36846 ), which is also the start of the 9 byte machine code program held in line 40. The start address for the buffer is held in the second and third bytes of the program, and this starts immediately after the machine code program at &900A (36874). Bytes 5 and 6 hold the length of the buffer (LSB/MSB), in this instance set to 0 and 4 (4 * 256 + 10 =1024), which is 1 K.

TABLE 1
LIST OF KEY FUNCTIONS
KEY NO.KEYFUNCTIONKEY NO.KEYFUNCTION
69AASC(46NNEXT^
54BBORDER^34OORIGIN^
62CCHR$(27PPEEK(
61DDRAW^67Qnot used
58EEVERY^50RRIGHT$(
53FFOR X=60SSOUND^
52GGOSUB^51TTAGOFF^
44HHEX$(42UUPPER$(
35I=INKEY$^55VVAL(
45Jnot used59WWINDOW^
37Knot used63Xnot used
36LLEFT$43Ynot used
38MMID$71Znot used
^ denotes a space

For most cases this amount will be ample. To set aside more buffer space, then the top of BASIC address, the LOCATION address, and the start of the buffer address should all be lowered by the same amount in bytes 5 and 6 of the machine code program.

The rest of the program sets up the various functions and assigns them to the keys as shown in Table 1 . The first 20 function stings will return the string shown, whilst the last 12 function strings (Table 2) are used with the carriage return to perform some useful operations. You can change any of the strings to whatever you like. The ones presented here are the ones that I find are most useful for myself. You may prefer your layout to be different from mine.

TABLE 2
The following perform functions as opposed to printing a keyword
KEY NO.KEYFUNCTION PERFORMED
320MODE 0 + CHR$(13)
641MODE 1 + CHR$(13)
652MODE 2 + CHR$(13)
573PRINT HIMEM,FRE(0),HIMEM-FRE(0) - 368 + CHR$(13)
564FOR X=0 TO 255: PRINT X; CHR$(61) CHR$(32); CHR$(1); +CHR$(X);:NEXT
495:PRINT PEEK(X);:NEXT + CHR$(13)
486INK 0,20:INK 1,1:BORDER 20 + CHR$(13)
417PRINT INT(TIME/18000) + CHR$(13)
408AUTO + CHR$(13)
339RENUM + CHR#(13)
16CLRCLS + CHR#(13)
24£/^LIST + CHR#(13)
N.B.

Key 3 prints TOP of BASIC, MEMORY LEFT, and SIZE of BASIC PROGRAM
key 4 prints out all 255 ASCII CHARACTERS and CONTROL CODES (0-31)
key 5 is for use with the 'F' key function
key 6 sets up a clear 80 column mode
key 7 prints out the TIME in MINUTES since SWITCH-ON

Remember to SAVE the program before RUNning it for the first time as the program NEWs itself in line 100. You have been warned!

Hopefully your friends with other micros will be green with envy when they see the functions that you can call up at the touch of one key — well two to be exact . Look — single key entry — a la SPECTRUM!!

PCT

★ PUBLISHER: Personal Computing Today
★ YEAR: 1985
★ CONFIG: 64K + AMSDOS
★ LANGUAGE:
★ LiCENCE: LISTING
★ AUTHOR: David ELLIS



★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listing:
» Key  Facts    (Personal  Computing  Today)    ENGLISH    LISTINGDATE: 2025-10-28
DL: 17
TYPE: PDF
SiZE: 923Ko
NOTE: Supplied by archive.org ; 1 page/PDFlib v1.6

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Applications » Copy Key Utility (Computing With the Amstrad)
» Applications » RSX Key-Arrow
» Applications » Pause Key Routine
» Applications » Delcode Key (CPC Amstrad International)
» Applications » Swift Software - Keyword
» Applications » Simulated Ikon Control - Joystick Or Cursor Keys (The Amstrad User)
Je participe au site:
» Pour ce titre nous ne disposons de fichier executable sur CPC (Dump, Saisie du listing) , alors si vous avez ça dans vos cartons ou vous désirez usé vos petit doigts boudinés sur votre clavier faites le nous savoir.
» Vous avez des infos personnel ?
» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.732-desktop/c
Page créée en 274 millisecondes et consultée 105 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.