Echo #02
30 ноября 1996

Tricks - Elegant clear the screen. Quickly scan the keyboard. Setting interrupt (IM2).

<b>Tricks</b> - Elegant clear the screen.
 Quickly scan the keyboard.
 Setting interrupt (IM2).

           Tips and Tricks



   Every programmer has their own tricks, often known only to 
himself. To publish this sort of thing and will be designed 
this section. 


   Today we have:


   1. Elegant clear the screen:


   Usually the screen clean as follows:


   XOR A; 1

   OUT (# FE), A; 2

   LD HL, # 4000; 3

   LD DE, # 4001, 3 Size in bytes

   LD BC, # 1AFF; 3

   LD (HL), A; 1

   LDIR; 2


   Size: 15 bytes.


   And we like:


   XOR A; 1

   OUT (# FE), A; 2

   LD HL, # 5B00; 3
L1 DEC HL; 1

   LD (HL), A; 1

   OR (HL); 1

   JR Z, L1; 2


   Size: 11 bytes. Four bytes shorter. It seems a trifle, but 
nice ... 


   2. Quickly scan the keyboard:


   LD L, 0

   LD A, # FE
L1 LD C, A

   LD B, 5

   IN A, (# FE)
L2 RRA

   JR NC, YES_KEY

   INC L

   DJNZ L1

   LD A, C

   RLCA

   JP C, L2
NO_KEY; no keys are pressed. In

             ; L sticks # 28 (40)

YES_KEY; on something pressed. In the L-code

             ; Keys. Convert to
ASCII can be using the tablet:



    Key code key code


    # 00 C. SHIFT # 14 0


    # 01 Z # 15 September


    # 02 X # 16 August


    C # # 03 July 17


    V # # 04 June 18


    # 05 A # 19 P


    # 06 S # 1A O


    # 07 D # 1B I


    # 08 F # 1C U


    # 09 G # 1D Y


    0A # Q # 1E ENTER


    # 0B W # 1F L


    # 0C E # 20 K


    # 0D R # 21 J


    # 0E T # 22 H


    # 0F 1 # 1923 SPACE


    # 10 2 # 24 S. SHIFT


    # 11 3 # 25 M


    # 12 4 # 26 N


    # 13 5 # 27 B



   If you have received value of the trigger
and keys, check the keyboard, you want to continue scanning, 
then let JP L2, while the registers A, BC, L should remain the 
same values ​​that were in the Output from the procedure. In 
bars scan takes maximum 1432 (NO_KEY)! 


   3. And here is a very old but beautiful setting IM 2 (we 
were not the invented): 


   LD HL, TABLE_ADR; TABLE_ADR should be

   LD A, H; multiple of 256!

   LD I, A

   LD B, L

   INC A
L1 LD (HL), A

   INC HL

   DJNZ L1

   LD (HL), A

   LD L, H

   LD (HL), # C9; RET

   IM 2


   Generate an interrupt table
with TABLE_ADR and establish processing procedures: a single 
command RET. Takes only 3 +1 +2 +1 +1 +1 +1 +2 +1 +1 +2 +2 = 18 
bytes. 


   Well enough for now ... Please send us your
Tricks, readers! If someone is able to thread the needle better 
than we will be happy. 




Other articles:

Introduction - A new interface in the newspaper.

Tricks - Elegant clear the screen. Quickly scan the keyboard. Setting interrupt (IM2).

HARDWARE - A few words about the drives 5'25 and 3'5. Refinement of the Baltic. Falcon SounDrive.

Presentation - Sprite Generator v4.5 by REAL SOFT.

Problems Byte - Why do not some programs on the Spectrum-compatible computer "byte".

Fantasy - A fantastic story of Ray Bradbury "Ice and Flame" (Part 1).

Tales of Uncle Gill'a - Short Stories: The Autobiography, an incubator period, incident on the street, Rehabilitation ...

tree death - A report on the work of service "Rescue 911".

Rich also cry - The problems that create SNG'shnye encoders for corporate users Spectrum (EXODUS from Poland).

Form - A survey amongst Spectrum in CIS countries.

Did you know ... - Dim SH-shku zero in the port # FF can not. Before recording a # 3D13 to a specific path, if a motor is turned on, and on her head sticking out. How to speed up the process of reading and downloading through # 3D13, If you want to download / burn a few small blocks in a row.

Muzobzor - Interview with "Too Late! Frozen".

book about the delicious food - Cold appetizers, hot appetizers and soups. (Cooking recipes). Advertising: watch commander.

Music - Formats compiled modules known musical editors. Pro Tracker v2.101 by GDC, A standard player.

Open Letter - An Open Letter OLDMAN'u about creating newspapers ...

AMIGA vs IBM - What are the opportunities for these computers.

Amiga - A little history of the Amiga.

Amiga - Short description of various models of the Amiga.

Amiga - Description of the AMIGA 500/2000 - Amiga from within: a keyboard, drives, I / O Connectors. What else can you connect?

Amiga - Description of the AMIGA 1200.

Besta - We offer a fold in the fresh programs for the Spectrum across Byelorussia and buy it wherever possible.

Nove - A list of new software, which appeared in Brest in December.

PENTIUM - Pentium Processor - Technical review.

Advertising - Advertisements and announcements ...

Credits - the creators of the newspaper.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Iron - reset circuit in the "Gluk Reset Service".
Demo Party - the results of Chaos Construction 999.
Novella - A fantastic story of the game "Laser Squad" (continued).
Advertising - Advertisements and announcements ...

В этот день...   21 November