Programming - the procedure for printing messages in the lower lines of the screen.

Deja Vu #0A
__________________________________________

(C) SKL-KEEPER
__________________________________________

       About printing messages in the bottom
  screen lines

   Very often among novice programmers
the question arises: how can you print
some message at the very bottom, so
so-called "service" lines of the screen, i.e.
e. in lines with numbers 22 and 23?
 Yes, practically, as simple as
when printing to the main screen! Just need it
remember that to display a message in the bottom
part of the screen is necessary before using the command
Please print to open another channel. How from-
known, when printing in the main part of the screen
you need to open channel #2, but for lines with
numbers 22  and 23 there are several ways
make the processor print a message
where we need it :-)
   Let me remind you that standard channels for
information output on the Spectrum arechannels "S" - the main part of the screen, "P" -
standard ZX printer and "K" - the bottom two
screen lines. Standard for these channels
streams connected:

 - stream "0" - to channel "K";
 - stream "1" - also to channel "K";
 - stream "2" - to channel "S";
 - stream "3" - to channel "P".

   Since Spectrum cannot simultaneously
but to provide information, for example, on
screen and printer, at any time
only one input channel is always used
yes-output and only one thread associated with
him. This channel and this stream are called
current.
   So, the first way to make it current is
print cash "K" - switch to the desired one
us flow #1 by calling the ROM procedure, which
it's called heavenCHAN_OPEN  and is located by
address #1601:

LD A,1 ;Stream number - to the accumulator.
CALL #1601 ;Made it current.

   Almost the same thing happens if
open a channel with number "minus three", or
#253.
 When programming in machine code, switch
You can start from channel "S" to "K" and vice versa
but in one more way. System zero bit
variable TVFLAG, located at
address #5C3C, carries information about
about what flow is in a given period of time
is current. When it is turned off, i.e.
is equal to zero, the channel "S", is used and when
yes enabled - channel "K". Opening procedure
channel "K" will look like this:

LD A,1
 LD (#5C3C),A

   Thus, the simplest procedure for re-
chat messages in the lower lines of the screen
it will look like this:

 LD A,1 ;B "A" is the channel number.
 CALL #1601 ;Open. channel systems. windows.
 LD DE,MES ;Message start address.
LD BC,11 ;Message length.
 CALL #203C ;Call process. ROM PR_STRING
 ;to print a message.
PAUS HALT ;This part of the program is for
 ;so that the message
 ;"0:O.K.", appearing. after
 ; program execution, not
 ;moved displayed to
 ;screen line. In machine
 ; in codes this is equivalent to code ;mande "PAUSE 0".  So,
 ;waiting for interruption.
BIT 5,(IY+1);We check the 5th bit of the systems.
 ;variable FLAGS.
 JR Z,PAUS ;If the key. didn't press
 ;it's off, let's go to the metal
 ;ku PAUS.
RES 5,(IY+1);If it is on, turn off
 ; click it and move on.
 RET ;Exit the procedure.

MES  DEFB "OUR MESSAGE"  ;Message text.

   There is another way to print messages.
scheniya, the most powerful and frequently used.
It is used in cases where the program
frame there are many different messages, and
the programmer does not know in advance when what
will have to print. It's convenient to print
text, indicating only its number in the table
messages!
   So that the program knows wherebegins and
where the desired message ends, applies-
such a witty technique: in the last
character of each message is forced
the most significant bit is turned on, i.e., other layers
you, to the code of the last character add -
The number is 127. And the program realizes that
if the character code is greater than 127, then it is a mar-
ker of the end of the message.
   A small program that I want
bring to your attention, I "pulled" from
installed boot MINI BOOT 3.0. Tab-
faces of possible inscriptions should begin
with #80. If the inscription consists of two lines,
then between them you need to put the code #06.

 LD A,#03 ;Message number.
 CALL PR_MES ;Try post-
 CALL OPROS ; insert numbers here
 RET ;from 0 to 3.

   And here is a list of possible messages with
information about which number is which connection
communication corresponds to:

Zero  - NO PROGRAMS;
Unit - MORE THEN 65 FILES;
Two  - MINI BOOT v3.0 WRITTEN BY ...
Troika  - INSERT DISK FOR READING CATALOG

   Naturally, you can write any text
your...

PR_MES  LD DE,MES_TAB ;Print inscription
        CALL #0C0A ;Subroutine
                        ;print messages
        RET

   To execute this ROM routine in
DE the starting address of the co-table is loaded
messages, in register A - message number in
her minus one. The first byte in the table
should be 128 (#80). To set the end
message the most significant bit of its last byte
must be set to one.

MES_TAB DEFB #80,#16,#0A,#05
 DEFB "!!! NO  PROGRAMS !!!"
        DEFB #A0
        DEFB #16,#0A,#02,#10,4
        DEFB " MORE THEN 65 BASIC FILES"
        DEFB #A0
        DEFB #11,#00,#10,#04,#13,1
        DEFB "      -= Mini BOOT v3.0 =-"
        DEFB #06
        DEFB "Written by *S.Sergey.* "
        DEFB "12.06.95"
        DEFB #A0
        DEFB #10,#02,#13,1
        DEFB "       INSERT NEW DISK"
        DEFB #06
        DEFB "     FOR READING CATALOG..."
        DEFB #A0

OPROS   EI              ;Для чего эта под-
        RES 5,(IY+#01)  ;программа, дога-
        HALT            ;даться будет не-
        CALL RAINB      ;сложно?
        BIT 5,(IY+#01)
        JR Z,OPROS
        RET

RAINB   LD HL,#5AE1     ;Радуга на надписи
        PUSH HL         ;в нижней строке.
        POP DE
        DEC DE
        LD BC,#001F
        LDIR
        LD HL,#5AFF
        LD A,(LAB_1)
  OR A
        JR Z,LAB_2
        LD A,(HL)
        AND #07
        INC A
        CP #08
        JR NZ,LAB_3
        XOR A
        LD (LAB_1),A
        LD A,#07
LAB_2   LD A,(HL)
        AND #07
        DEC A
        OR A
        JR NZ,LAB_3
        CPL
        LD (LAB_1),A
        LD A,#01
LAB_3   LD (HL),A
        RET

LAB_1   DEFB #FF
------------------------------------------

Share your thoughts about the article