Deja Vu #09
13 ноября 1999

Coding - a set of procedures for constructing the user interface.

<b>Coding</b> - a set of procedures for constructing the user interface.
(C) Rezonance group
__________________________________________



          Interface ...



   Too often the programs you want to interrogate the keyboard, 
joystick or mouse. Below are procedures that I would like to

to share with readers of the magazine.


   The most commonly used
technique: the table consistently recorded the required number 
of senior level, mask, pointing to the desired key in the 
series, and the byte that indicates the direction in the format 
of Kempston joystick. 

KEY1A LD HL, KEY1F

      LD C, 0

      LD A, (HL)
KEY1B INC HL

      IN A, (# FE)

      AND (HL)

      INC HL

      JR NZ, KEY1C

      LD A, (HL)

      OR C

      LD C, A
KEY1C INC HL

      LD A, (HL)

      AND A

      JR NZ, KEY1B

      LD A, C

      RET
KEY1F DEFB # DF, # 01, # 01; P

      DEFB # EF, # 08, # 01, 7

      DEFB # F7, # 02, # 01, 2

      DEFB # DF, # 02, # 02; O

      DEFB # EF, # 10, # 02, 6

      DEFB # F7, # 01, # 02, 1

      DEFB # FD, # 01, # 04; A

      DEFB # EF, # 04, # 04, 8

      DEFB # F7, # 04, # 04, 3

      DEFB # FB, # 01, # 08; Q

      DEFB # EF, # 02, # 08, 9

      DEFB # F7, # 08, # 08, 4

      DEFB # 7F, # 01, # 10; Sp

      DEFB # EF, # 01, # 10, 0

      DEFB # F7, # 10, # 10, 5

      DEFB 0,0,0



   As is evident from the text of the program, except
Standard Q, A, O, P, Space, here is queried Sinclear1 and 
Sinclear2. At the exit in register 'A' in the format of 
Kempston joystick, we have the desired direction. 

   But it's best to provide choices to the user control device, 
and examine only the desired device. This will help a little 
bit to save resources in the where they are needed.


   What could be simpler survey Kempston
joystick?

KEMPSTON

      IN A, (# 1F)

      AND # 1F

      RET



   Poll Sinclear1, the output data in register 'A', converted 
into a format Kempston joystick through a table. Fast simple, 
convenient! 

SINCLEAR1

      LD A, # EF

      IN A, (# FE)

      AND # 1F

      XOR # 1F

      LD HL, SINCLEAR1F

      LD D, 0

      LD E, A

      ADD HL, DE

      LD A, (HL)

      RET
SINCLEAR1F

      DEFB # 00, # 1F, # 08, # 18, # 04

      DEFB # 14, # 0C, # 1C, # 01, # 11

      DEFB # 09, # 19, # 05, # 15, # 0D

      DEFB # 1D, # 02, # 12, # 0A, # 1A

      DEFB # 06, # 16, # 0E, # 1E, # 03

      DEFB # 13, # 0B, # 1B, # 07, # 17

      DEFB # 0F, # 1F



   The table occupies 32 bytes, if desired
it can be reduced to 15, but complicating
thus the procedure. Is it worth doing?

   Same thing, but for Sinclear2.

SINCLEAR2

      LD A, # F7

      IN A, (# FE)

      AND # 1F

      XOR # 1F

      LD HL, SINCLEAR2F

      LD D, 0

      LD E, A

      ADD HL, DE

      LD A, (HL)

      RET
SINCLEAR2F

      DEFB # 00, # 02, # 01, # 03, # 04

      DEFB # 06, # 05, # 07, # 08, # 0A

      DEFB # 09, # 0B, # 0C, # 0E, # 0D

      DEFB # 0F, # 10, # 12, # 11, # 13

      DEFB # 14, # 16, # 15, # 17, # 18

      DEFB # 1A, # 19, # 1B, # 1C, # 1E

      DEFB # 1D, # 1F



   Fast, but rather cumbersome
version of the poll keypad. The data is still output in 
register 'A'. 

KEYscan1

      LD C, 0

      LD A, # DF; P

      IN A, (# FE)

      AND # 01

      JR NZ, KEYscan11

      SET 0, C
KEYscan11

      LD A, # DF; O

      IN A, (# FE)

      AND # 02

      JR NZ, KEYscan12

      SET 1, C
KEYscan12

      LD A, # FD; A

      IN A, (# FE)

      AND # 01

      JR NZ, KEYscan13

      SET 2, C
KEYscan13

      LD A, # FB; Q

      IN A, (# FE)

      AND # 01

      JR NZ, KEYscan14

      SET 3, C
KEYscan14

      LD A, # 7F

      IN A, (# FE)

      AND # 01

      JR NZ, KEYscan15

      SET 4, C
KEYscan15

      LD A, C

      RET



   But I like the next version, the compact and simple.

KEYscan2

      LD C, 0

      LD A, # DF; P

      LD DE, # 0101

      CALL KEYscan2F

      LD A, # DF; O

      LD DE, # 0202

      CALL KEYscan2F

      LD A, # FD; A

      LD DE, # 0104

      CALL KEYscan2F

      LD A, # FB; Q

      LD DE, # 0108

      CALL KEYscan2F

      LD A, # 7F; Space

      LD DE, # 0110

      CALL KEYscan2F

      LD A, C

      RET
KEYscan2F

      IN A, (# FE)

      AND D

      RET NZ

      LD A, C

      OR E

      LD C, A

      RET



   What is the best program can do without the Kempston mouse. 
Procedure after call changes the coordinates of dependence

from the movement of the mouse.

MOUSE10

      LD HL, (XYkoor)

      LD BC, # FBDF

      IN A, (C)
MOUSE11

      LD D, 0

      LD (MOUSE11 +1), A

      SUB D

      CALL NZ, MOUSE30

      LD B, # FF

      IN A, (C)
MOUSE12

      LD D, 0

      LD (MOUSE12 +1), A

      SUB D

      CALL NZ, MOUSE40

      LD (XYkoor), HL

      RET
MOUSE30

      JP M, MOUSE35

      ADD A, H

      LD H, A

      RET NC

      LD H, # FF

      RET
MOUSE35

      XOR # FF

      INC A

      LD D, A

      LD A, H

      SUB D

      LD H, A

      RET NC

      LD H, 0

      RET
MOUSE40

      JP M, MOUSE45

      LD E, A

      LD A, L

      SUB E

      LD L, A

      RET NC

      LD L, # 0

      RET
MOUSE45

      XOR # FF

      INC A

      ADD A, L

      LD L, A

      RET NC

      LD L, # FF

      RET



   This procedure shows how all
This can be used.

CONTROL DEFB 0
XYkoor DEFW 0

      LD B, 0

      CALL SINCLEAR1

      OR B

      LD B, A

      CALL SINCLEAR2

      OR B

      LD B, A

      CALL KEYscan1

      OR B

      LD (CONTROL), A

      CALL MOUSE10

      RET



   It now remains to determine whether
user's mouse or joystick. At the exit
in register 'A' set the 0th bit, if
a joystick, and the first bit, if there is a mouse.

AUTOconfig

      LD E, 0

      LD B, 250
A_config01

      IN A, (# 1F)

      AND # 1F

      JR NZ, A_config02

      DJNZ A_config01

      SET 0, E
A_config02

      LD B, 250
A_config03

      LD A, # FA

      IN A, (# DF)

      XOR # FF

      JR NZ, A_config04

      DJNZ A_config03

      SET 1, E
A_config04

      LD A, E

      RET



   Now, it seems, everything. I hope nothing
forgotten. Until we meet again.
-----------------------------------------





Other articles:

Apperativchik - the entry of the authors.

Apperativchik - On the control of Deja Vu.

Apperativchik - Freebie number 2: pirates and hacked versions of the magazine.

Apperativchik - Dejavu Info: How to buy the magazine Deja Vu.

Topic - Swap: "From letters to parcels" as found in the city Spektrumistov.

Topic - Tusovka: CSP'99 - interview with Slack Den.

Topic - Tusovka: CSP'99 - an interview with the main coder'om young Novosibirsk group AREASoft

Topic - Tusovka: CSP'99 - interview with one of the publishers 'electronic journal Deja Vu' Daniel / Playgear Co. / Binary Dimension.

Topic - Tusovka: CSP'99 - interview with one of Rybinsk of Cav / Auryn.

Topic - Tusovka: CSP'99 - an interview with the father of Playgear cool uncle Ze Pagan.

Topic - Tusovka: CSP'99 - an interview with the main coder'om Flash and concurrently one of the founders of the group - Alex Rider.

Topic - Tusovka: CSP'99 - poll as the party was held in a nutshell, the general impression.

Topic - Tusovka: Legend of the way passed Crazy Siberian Party 1999.

drop of solder - HD discs: Finalization of the drive controller to work with HD-disks.

drop of solder - The decision PROBLEMS 1.2MB drive.

drop of solder - increase the amount of RAM up to 1024K on SPECCY option Taganrog 128K!

drop of solder - circuit programmer for chip-only memory (ROM).

drop of solder - a dot-matrix printers.

drop of solder - ISA-Spectrum: card inserted into the ISA slot is IBM, which is part or a complete computer ZX-Spectrum.

Software - demoscene: Obzor'ing demozov: 63 bit III, Jam, Anamnesis, 7 Up, 63 bit IV, DemoDyin, Napalm, Crapmo 2, Bunch of Arce, Devotion, WorkStop, Energy , Yes.

Software - Game Review: MIST: Monstrland Part Two, Bomb Lakes, Marbles, KluXer, 4x4 Puzzle, Soldiers, Boats.

Software - Gun Commander: User's Guide.

Coding - coding for Dummies: civilized way in TR-DOS.

Coding - coding for Dummies: More about one of the ways to survey the keyboard.

Coding - coding for Dummies: How does the "Boot" from the inside.

Coding - coding for Dummies: refine MINI BOOT V3.0.

Coding - how to print 42 characters per line (with trabutami), the procedure is quick print sprites with pixel precision.

Coding - Bystrai printing 64 characters per line.

Coding - Conversion of numbers from the stack calculator in the character string.

Coding - fast print 2x2 sprite familiarity, up to familiarity.

Coding - Hrust Library svobodnopasppostpanyaemaya library window procedure by means of eccentricity can be packaged and paspakovyvat VARIOUS data.

Coding - Error Handling TR-DOS when working through # 3D13.

Coding - a set of procedures for constructing the user interface.

Coding - pishim virus invisible to TR-DOS.

Another world - The illusion of safety: Terrifying tales of Windows security and the Internet (Part One).

Hall of Fame - 3 methods to distinguish pealny ZX Spectrum from emulyatopov.

Hall of Fame - the charter of the National Fund of the Spectrum (HFSP).

Hall of Fame - Reserves: an attempt to present the perfect ZX Spectrum.

Hall of Fame - boiling: "And there still alive Speccy, sympathy Boxing?" Reflections in hearing.

Hall of Fame - schA say number 1: optimization of procedures, the announcement of the magazine and the new arcade toy.

Hall of Fame - schA say number 1: disassembly and Serg'a Playgear, hacking calling card, the announcement Crazy Siberian Party '2000.

Hall of Fame - A brief history of the Kemerovo group Digital Life Group.

Seven and 1 / 2 - Student mythology.

Seven and 1 / 2 - April Fools' Day 2 (end).

Seven and 1 / 2 - fairy tales for children.

Seven and 1 / 2 - Features a national ruleza or pure Siberian project (the story of Crazy Siberian Party 1999).

Samples pen - memory: story of the game "Black Crow".

Samples pen - story, "Elixir of the Beast."

Samples pen - "Last Warrior".

Advertising - text ads and announcements.

Advertising - a graphical advertising and announcements.


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

Similar articles:
Contest - Competition for the best poster / logo for FunTop'98.
We will understand - Description of the missions the game BATTLE COMMAND.
People - Out spektrumist - Andrew Cmirnov (Ded Smirnoff) from "Power Of Sound" Group.

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