ZX Club #05
29 октября 1997
  Железо  

Soft group - Something about connecting the printer. Ports of computer devices ZX-SPECTRUM.

<b>Soft group</b> - Something about connecting the printer. Ports of computer devices ZX-SPECTRUM.
      SOMETHING ON CONNECTING THE PRINTER

               AND NOT ONLY

Cherkassy (C) Boris Kuritsyn
__________________________________________



     The author is often met with complete incomprehension or 
perverted understanding of technology to connect devices to 
Computer ZX Spectrum; so in the present text describes 
something concerning this topic.



               A. Interface

          PROGRAM - UNIT


     ZX Spectrum uses a UNIX-like
the concept of channels and streams. What is it
consist of?


     Channel, denoted by letter of the Latin
alphabet, symbolizes the DEVICE. For example, ZX Spectrum 
supports the following standard devices:


K - (Keyboard - keyboard)

    something equivalent to "con
    salt ", ie, control panel, lower

    window display at the conclusion of the keyboard

    commissioning; is special for the ZX

    Spectrum;

S - (Screen - screen)

    the upper display window on a conclusion; input

    impossible;

P - (Printer - printer)

    printer to the conclusion (that ZX Printer);

    entry is impossible;

R - (RAM - RAM)

    intra-channel dedicated

    to improve the effectiveness of programs;

    characters appearing in this channel, pop
    give in BUFFER EDITOR COMMAND

    LINES AND ENTRY;

    ie if you bring in this channel string

    characters, and then call the built-in

    editor (the one that implements

    operator INPUT), then this line will be

    prompt the user for Editing
    tion in the lower window of the screen.


   Connecting additional devices

         racshiryaet set of channels.


     Each channel has a unit of description -
leader tape channel (channel record), which
contains information about the binding functions
I / O system and the channel. All the leader tape
placed consecutively in memory, start address is recorded in 
the system variable CHANS (address 23631, address). In the past 
the leader tape is a marker end - a byte with value 80h.



  The general format of the leader tape in assembler notation 
is as follows: 


  DEFW print_out

  DEFW input_in

  DEFB channel_name

  DEFW internal1, internal2

  DEFW record_length

  DEFS record_length-11


  Here:

PRINT_OUT


     Address procedures for the withdrawal of the symbol in the 
channel, the symbol in register A; shadow set registers should 
not be destroyed. Procedure complete command RET. If the 
channel does not support the conclusion of the information, 
procedure output is to initiate error:



  RST 8; interrupt error

  DEFB 23; error Invalid stream -

          ; Incorrectly used flow


INPUT_IN


     Address procedures for entering characters from the 
channel, the symbol should be placed in the register A, in 
addition, must be installed Flags:


CF = 1

     symbol actually received from the device and transmitted 
through register A. Otherwise CF flag must be cleared to 0 and 
set: 

ZF = 1

     if DEVICE is not ready to give the next character. 
Otherwise, 

ZF = 0

     will mean that the situation occurred in the channel end 
of file, which is usually induced error End of file. When

need routine access to the channel itself triggers this error.


     Such a warning system is provided in order to be able to 
implement not only the operation INPUT #, and entering without

expectations INKEY $ # so that for these channel
operation is no different.


     If the channel supports the input, it
should initiate a mistake (as shown
for print_out).

CHANNEL_NAME


     Contains the character name of the channel. Naturally, 
they should not be repeated. 


INTERNAL


     Using these two words in different
implementations are different. Thus, in the Interface One
they contain real addresses and print_out
input_in additional ROM and in the channel
Virtual Disk Spectrum 128K first
word contains the signature (mark)
custom channel (number 1234h), and
second - address closing procedures Channel
close. These words can be defined as
internal.

RECORD_LENGTH


     Word contains the length of leader tape channel
(Minimum 11). This allows you to store a leader tape buffer and 
/ or any additional information associated with the channel. 
For example, in TR-DOS, in the channel "D", associated with the 
file sequential access, store buffer

for assembling of 256-byte characters
sector, byte count in buffer pointer disk space for recording 
sector. On the above scheme, the channel leader tape this

additional area is designated as
DEFS.


     The above-mentioned standard channels leader tape cut - it 
contains only 3 the first lines of the above scheme. These

channels first in the list and insert their
leader tape can only be followed before the end of the marker.


     To create a space in the area with CHANS
to stick a new leader tape channel
necessary to use sub-ROMs
MAKE_ROOM, to remove the leader tape - sub RECLAIM_2.


     The second element of the concept - FLOW
(Stream). It symbolizes the flow of data
traveling from the program device
through the channel. Flow indicates the number of
0 to 15. In fact, there are flows with
numbers -3, -2, -1, but they are the threads of the operating 
system and can be overridden only with specific goals. 


     Stream connects to a channel operator
BASIC:

OPEN # stream, channel $


     Here the stream - stream number, channel $
- A character variable named channel.
For example,

OPEN # 6, "K"


     6 to connect the flow channel "K". This
You can check out:

PRINT # 6; "Hello, World!":
PAUSE 0


     will lead to lower window welcome screen. Same with the 
introduction: 

INPUT # 6; "Type line:";
LINE a $: PRINT a $


     - You have to do to enter a string that will be printed on 
the right of the screen. Similarly, can try INKEY $ # 6.



     Likewise, you can specify the stream for
LIST:

LIST 200, # 6


     Upon completion of the work flow should be
Close:

CLOSE # 6


     The idea of ​​all this technology is
that the program becomes independent
from the input / output devices - it just
uses threads. And they can be reassigned to required at the 
moment the device. 


     With the standard channels are connected
"Standard" flow: # 0 and # 1 with "K", # 2
"S" and # 3 with "P". It is easy to guess that
PRINT is the same as PRINT # 2,
LPRINT - PRINT # 3, LLIST - LIST # 3, INPUT -
INPUT # 0 and INKEY $ - INKEY $ # 0.


     State flow is described in sitemnoy
area STRMS (starts with 23568, the length of
19 words). Every word of this area represents one stream (-3, 
-2, -1,0,1,2, etc.). It contains 0 on a closed stream, or

offset from the beginning of CHANS leader tape to the channel 
to which this podlyuchen stream. This value is incremented by 
1. For example, the descriptor stream connected to the channel, 
S, will contain the value 6, because Channel S - second in the 
list from the abbreviated leader tape (length of 5 bytes) and 5 
+1 = 6. 


     Need to know that the bug in the ROM
leads to the fact that you can not try to close (at least, 
command CLOSE #) closed flow, or flow, open to

custom channel.


     Also note that the BASIC
You will be able to open stream only to the standard channels, 
since their discovery could be accompanied by specific actions 
in the device. Therefore, the TR-DOS has its own command to 
open / close streams and ZX Interface One expands

Operator OPEN.


     To access the thread table is used routine ROM STR_DATA, 
to set the current thread - CH_OPEN, to display the symbol in 
the stream - PRINT_A_1 (RST 16), to read a character from a 
stream - WAIT_KEY.



     It should be remembered that routine CLS
puts the address of the combined driver channels K, S, P in the 
leader tape of the current flow is used. Therefore, when you 
call it must be a current flow 


               0, 1 or 2.


     Addresses and detailed information about the above and 
below the ROM routines you found in the "Advanced disassembler 
ROM Spectrum ", Logan and O'Hara.




         B. Specifically on printers


     It is normal for your printer
not to create a new channel to reopen
He flow, etc.


     After all, there is a standard channel P, in the leader 
tape which you can simply replace the address print_out. 
Procedure itself, in most cases can be placed now in the former 
buffer ZX - Printer (256 bytes from address 23296). 


     Must take into account that the ZX Spectrum tab character 
has the code 6, and its size - 16, while the "normal" code 
printers tab 9, and size - 8. Therefore, procedure print_out, 
received a code 6, should refer to the printer instead two codes

9. Next, you need to encode the symbol
"Copyright" in another, for example, in "@".
Tokens must pass character by character, taking
text tokens from the table in the ROM at
95h, or by using a subroutine
PO_MESSAGE with a recursive call to the driver
(Because she uses a subroutine
RST 16).


     Another problem: the symbol CR (code
13). The printer has a mode where the code CR
returns the carriage to the top of the line, and LF
(Code 10) takes a string. Most
printer has DIP-switches to set the mode, when both actions are 
performed by the code of CR, but some such a regime does not 
have. Therefore it is better to provide such an option in the 
driver, and Printer leave in the "separate

reaction. "


     Finally, for printing graphics, you need a version of the 
driver that does not make any conversions.




             B. Compatibility


     Hardware incompatibility, in general, -
something very unpleasant. So here's a table of addresses of 
various ports devices that can not be used

new devices for compatibility. Decoding of port addresses is 
recommended for both the address byte. 


             Device ports

         ZX Spectrum Computers

Destination address

7FFD configuration management

         (Only 128 kb)

BFFD, a music processor
FFFD AY-3-8912 or equivalent

xxFE reading - keyboard

         on record - the sound,

         magnetic tape

         BORDER Display

  1F Kempston Joystick

         Interface

  3F Dk'Tronics Light Pen

  FB ZX Printer


     Ports ZX Interface 1


  EF control status

  E7 data

  F7 RS-232 / Network


     ZX Interface 2 ports

EFFE IF2 joystick 1
F7FE IF2 joystick 2


   Ports Beta Disk Interface
(Access is blocked,

              incompatibility does not cause)


  FF control / state

  1F command / status

  3F track

  5F sector

  7F data


       Special Port


  FF this port is not specifically implemented
         van, because his request is not

         meet any one device, it

         always contains the value systems
         Noah data bus in vysokoimpedan
         sleep state, equal to FF. But in

         Sinclair firm among the values

         FF sometimes "slip" means
         of the current output to the discrete
         play attribute that allows u
         frames more accurately sinhronozirova
         tsya to upgrade memory on board -

         It is for this reason, some

         games do not work for Sinclair -

         compatible models.




Other articles:

From the Editor - the process of creating newspapers joined the group Demention. The question of electronic journal in the Altai.

Soft group - Something about connecting the printer. Ports of computer devices ZX-SPECTRUM.

Iron - On Covox'ah, General Sound'e and Sound Drive 2.

ZX-Potpourri - The procedure "OPTION SELECTOR". On the procedure of "Stars" as used in the newspaper.

Club IM2 - Terminology and theoretical aspects of interrupts and multitasking.

Club IM2 - Competition for the best scenario type games DIZZY.

Virus - On the competition of the game "virus 2.

Enjoy - Jokes ...


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

Similar articles:
News - Alone Coder'a impression on CC'2004.
Demopati - intervyu taken Kvazar CC'999 on the group 4D (pROF and JTN).
News - Hackerz Top'99 rescheduled for the summer.
Debut - the author's review of the game "MARSPORT".
VIP - The most noble tale of the scene.

В этот день...   29 April