ZX Format #01
31 октября 1995
  IS-DOS  

IS-DOS - programmers: Window System IS-DOS

<b>IS-DOS</b> - programmers: Window System IS-DOS
Category "IS-DOS - the programmers." No 1


              Eliseev VA

        "The window system IS-DOS"

          (Journal version)

(C) PENCRAFT 1995
(C) IskraSoft 1995


    One of the undoubted merits of the operating system IS-DOS 
can be considered friendly window interface that allows

programmer you arrange your program.


    The idea of ​​windowing, absent in the traditional 
operating system, ZX Spectrum, always attracted developers who 
wanted to be work looked at the professional level. One of the 
masterpieces of window technology is considered to be the 
famous "window interface Peter Cook" used in many games, 
branded programs, Art Studio, ASTRO, and even in some of the 
works of local programmers - DCU, FUT, STM, F Commander

etc.


    Developers of IS-DOS, naturally did not go away, and 
realizing the importance and necessity of implementing a

professional system of windowing technology, gave it a whole 
level of the system, called WIND.SYS. 


    Level WIND.SYS contains 23 restart, ensuring the work with 
windows, strings of characters, cursor, etc. With these 
restarts can organize information output to the display, 
execution of the work screen, as well as to organize a dialogue 
with the user using the line editor. 


   Unfortunately, the scope of this article can not review in 
detail all 23 restart, the components level WIND.SYS, so it now 
goes only about 19 of are directly related to working with 
windows and textual information in them. Description of the 
line editor and file system management panels will be separate 
article under the heading "IS-DOS - the programmers."



             Creating windows.


    Operation of any windowing begins, naturally, with the 
procedure of opening the window. Window in the IS-DOS has 
following structure (see Figure 1): 



           pane

       Workspace window



       - Area frame


       - Print area


       - The shadow region


       - Field

 Fig. 1: Structure of the windows in the IS-DOS



    Window area defined by the values
XS (X-size) and YS (Y-size), and is measured in
familiarity 8 * 8 pixel area frame
has a width of 8 pixels (1 familiarity
8 * 8) around the perimeter of the window, therefore, the size 
of the window are XS-2 and YS-2. The size and location box, 
print margins, as well as the width of the left and right 
margins are determined prnt pos. and print size and is measured 
in familiarity 6 * 8. The upper and lower edge of the print

limited area of ​​the frame.


    Shadow region is edging the bottom and right sides of the 
window thickness of 1 familiarity 8 * 8 and indented in a 
familiarity on the left and top boundaries of the window. 


                wt (# 61)


    The system IS-DOS to open the window
use restart wt (code # 61). He
provides the formation of the on-screen window
with the parameters set in the special
table, called a "vector box".
Vector address window at the time of the call should be 
restarted in the register pair IX, while the contents of 
register A determines the appearance of the window as follows: 


    7-bit set to 1 does open a window "transparent", ie the 
window opens only change the attributes

and pixels inside it are not cleared.


    The remaining bits define the type of frame
window:


       000000 - Single Frame

       000010 - double frame


    All other values ​​lead to the discovery of a window 
without frames. 


    Thus, the format specify the appearance of the window can 
be represented as table:




           single-double without

  Window frame frame frame



                                A = # 81
 trans-A = # A = # 80 82 A = # 83
   Noe # FF



                                A = # 01
 neproz-A = # A = # 00 02 A = # 03 # 7F rachnoe



    Thus, the procedure of opening windows on the IS-DOS as 
follows: 


       LD IX, WIND; loading in IX

                      ; Address vector

                      The windows

       LD C, # 61; loading into C code

                      ; Restart wt

       LD A, n; load in A values
                      ; Radiation, which determines
                      ; Sheha window view

       RST # 10; call restart


   The structure of the vector window:

WIND DEFB # 00; X-coordinate of the top
                      ; He left corner

                      The windows in the familiarity

                      , 8 * 8 pixels

       DEFB # 00; Y-coordinate of the top
                      ; He left corner

                      The windows in the familiarity

                      , 8 * 8 pixels

coordinate values ​​are measured from the top left corner of 
the screen 


       DEFB # 0F; height windows in the value
                      ; COMEST 8 * 8

       DEFB # 0F; width of the window in the value
                      ; COMEST 8 * 8


       DEFB% 00000111; color box

color coded in a standard way:


            Bit 7 - flash

            Bit 6 - bright

            Bits 5 ... 3 - paper

            bits 2 ... 0 - ink


       DEFB% 00000001; color shadow box


    It is noteworthy that in the colors of the shadow box can 
be set as the color of paper, and color ink, which allows us to 
make visible part of the information on which the shadow

from the window and maximizes natural perception. If the byte 
is equal to the color shade # FF, then the shadow is not 
displayed. 


       DEFB # 01; X-coordinate for

                      ; The routine

                      ; Text in the box

       DEFB # 12; field width Pec
                      ; Tee box


    The last two parameters are expressed in
familiarity size 6 * 8 instead of 8 * 8 as
the rest is done because such
reference system used by all restarts
Printing IS-DOS. The value of X-coordinates
Print absolute, and is measured not by
the left border of the window, and from the left border
screen. Translate the coordinates of the window in kooordinaty 
print and vice versa can be done by the formulas:


 (1) n = N * 8 / 6

 (2) N = n * 6 / 8,

where n - the value of familiarity 6 * 8,

  and N - a value in familiarity 8 * 8.


    Y-coordinate of the Print is not specified, so
most of the restarts print yourself counts her from the top of 
the line box. 


    The screen can be opened multiple windows, and the current 
will be a window, the address of the vector which is in the 
register pair IX. In order to more rational use of

RAM information, closes the window at the time of its opening 
is not preserved, so if you suddenly needed to go back to the 
previous window, you'll need it rediscover.



    Consider a simple example. Problem
- Create a point with coordinates X = 5 and
Y = 3 box of 28 * 16 familiarity with a double frame, blue 
paper, white ink and black-and-blue shade, the field of print 
text indented to define a familiarity of the left and a 
5-familiarity of the right the window border.



    To create this simple program except restart the window 
opening wt (# 61) We need another three routines -

clear the screen, wait keypress
and return to the IS-DOS.


    The effect of these routines is based on
Other system resets IS-DOS, which
will be described in the next issue, but so far just remember 
them: 

CLS LD C, # 73; restart cls

       RST # 10; to clear the screen

       RET

WAIT LD C, # 07; restart ttyin

       RST # 10; to wait for the clicking
       RET; Tia Keys

EXIT XOR A; standard output

       LD A, # F4; in the IS-DOS

       RET


    So, consider Listing 1:

;****************************************

; Listing 1: Example of creating a window

; Background:

; X-coord (X) = 5
; Y-coord (Y) = 3
; X-size (XS) = 20
; Y-size (YS) = 16
; W. Colors (WC) =% 00001111
; S. Colors (SC) =% 00000001
; L. Margin (LM) = 1
; R. Margin (RM) = 5


       ORG # 5D64

; The main program

START CALL CLS; procedure call

                      ; Clear the screen

       LD IX, WIND; address vector window

       LD C, # 61; code restart wt

       LD A, 2; code double frame

       RST # 10; call restart


       CALL WAIT; procedure call

                      ; Standby button

       JP EXIT; transition to procedure
                      ; Fool return to

                      ; IS-DOS

And the vector window

WIND DEFB 5

       DEFB 3

       DEFB 16

       DEFB 20

       DEFB% 00001111

       DEFB% 00000001

       DEFB 8

       DEFB 20

; Data for the print position (printing
; Indented familiarity in 1 6 * 8 of the left
; Of the window) were obtained by calculating on
; (3):

(3) PP = X * 8 / 6 + LM,

, Where PP - print pos. familiarity in the 6 * 8
; X - X-coord. windows familiarity 8 * 8
; LM - left field in the familiarity 6 * 8

; Data for the print size obtained by
, Calculated by formula (4):

(4) PS = XS * 8/6-LM-RM,

, Where PS - print size in the familiarity 6 * 8
; XS - window size in the familiarity 8 * 8
; LM - left field in the familiarity 6 * 8
; RM - right-field familiarity 6 * 8


; Additional procedures

CLS LD C, # 73; restart cls

       RST # 10; to clear the screen

       RET

WAIT LD C, # 07; restart ttyin

       RST # 10; to wait

       RET; pressing

EXIT XOR A; standard output

       LD A, # F4; in the IS-DOS

       RET

;****************************************


    As a result, program execution
Listing 1 on the screen should get a window, the corresponding 
image in Figure 2, otherwise, check your dialing program.




 Fig. 2: The output of the program

                  Listing 1


                                      ...


                box (# 62)


    Next restart the box (# 62) allows
draw or erase in the frame
window every possible frame, or any of the
her side in any combination. Since
the width of the window frame in IS-DOS is
8 pixels, with maybe 8 different
single framework. Causing restart box a few times you can draw 
double, triple and even quad frame, as well as frames of 
varying thickness - only 256 combinations. 


    As input parameters restart box (# 62) uses a vector of the 
window at the address given in register IX, and also the values 
​​of the indentation from the edge of the window in the Y and X 
in pixels defined in registers D and E, respectively, and the 
contents Register A, indicating that it is required to draw or 
erase. 


    The contents of register A is determined
as follows:


  Bit 7 = 0 - Draw 1 - Wash

  Bits 6 ... 4 - not used

the other bits indicate which of the
party framework is the operation:


  Bit 3 = 0 - left side frame

  bit 2 = 0 - right-hand side of the frame

  bit 1 = 0 - the upper side frame

  Bit 0 = 0 - the lower side of the frame

The bits 3 ... 0 is possible in any combination.


    Shared form of procedure of drawing / erasing frame looks 
like this: 


       LD IX, WIND; address vector window

       LD C, # 62; code restart box

       LD D, N1; indented with Y

       LD E, N2; indented with X

       LD A, n; what to do

       RST # 10; call restart


    To set the values ​​of the indent beyond
preferable to use the numbers from 0
to 7, and when loaded into the registers D and
E values ​​of 0 frame will be displayed on the outer edge of 
the window, and when loading the values ​​7 - on the inner edge 
of the frame. Value of 8 has the same effect as 0, 9-same as 1, 
etc. 


    Consider an example. As a basis
take Listing 1, but depict the first
window without the frame, and then derive the double
frame so that its outer line was
twice as wide as the inside, and then make a left and right 
sides of the outer frame single thickness. 

;****************************************

; Listing 2 Example of a drawing of the window frame


       ORG # 5D64

, Opening a window

START CALL CLS; clear screen

       LD IX, WIND

       LD C, # 1961

       LD A, 1; window without frames

       RST # 10


       CALL WAIT

, Drawing the outer frame double thickness
; Performed in two steps


       LD IX, WIND; address vector window

       LD C, # 62; code rstarta box

       LD D, 0; indented with Y

       LD E, 0; margin of X


       LD A,% 00000000

And all the bits ravney 0 - to draw an entire frame


       RST # 10


       LD IX, WIND

       LD C, # 1962

       LD D, 1

       LD E, 1

       LD A,% 00000000

       RST # 10


       CALL WAIT

, Drawing the inner frame


       LD IX, WIND

       LD C, # 1962

       LD D, 3

       LD E, 3

       LD A,% 00000000

       RST # 10


       CALL WAIT

; Wipe the sides of the


       LD IX, WIND

       LD C, # 1962

       LD D, 2

       LD E, 1

       LD A,% 10000011

, 7-th bit is set - the team erase
; Set 0-th and 1 th bits designate,
; Not affected in this operation, the upper
, And the lower side of the frame


       RST # 10


       CALL WAIT

       JR EXIT

And the vector window

WIND DEFB 5

       DEFB 3

       DEFB 16

       DEFB 20

       DEFB% 00001111

       DEFB% 00000001

       DEFB 8

       DEFB 20

; Additional procedures

CLS LD C, # 1973

       RST # 10

       RET

WAIT LD C, # 2007

       RST # 10

       RET

EXIT XOR A

       LD A, # F4

       RET

;****************************************


    If necessary, the organization framework
drawing vertical and horizontal
lines within the window (outside the region
frame) can also use the services
restart the box (# 62), however, this will create a fictitious 
vector window so that the desired frame is within the area 
beyond this imaginary box. 

Let us explain with an example:


    Suppose you want to create inside the box
(See Listing 1) frame with an indent of 2 familiarity from the 
top of the window in a 4 - to the bottom and 3 from the left 
and right sides. 


    To do this, create a dummy vector
windows WIND1, and for the calculation of its parameters
use the following formula:

 (5) Y1 = Y + UM,

where Y1 - Y-coordinate frame,

    Y - Y-coordinate of window

    UM - upper margin

 (6) X1 = X + LM,

where X1 - X-coordinate frame,

    X - X-coordinate of window

    LM - left indent

 (7) YS1 = YS-UM-DM,

where YS1 - frame size on Y,

    YS - window size on Y,

    UM - space from above,

    DM - padding bottom

 (8) XS1 = XS-LM-RM,

where XS1 - frame size on X,

    XS - window size X,

    LM - left indent,

    RM - right margin


    All values ​​are measured in familiarity 8 * 8. Color 
values ​​we choose same as in the main window, but without a 
shadow (S. Colors = # FF), meaning Print pos. and

Print size can be arbitrary.


   Thus,

;****************************************

; Listing 3 Example of a drawing of internal
; Frames with box (# 62)

; Background:

; Up Margin (UM) = 2
; Down Margin (DM) = 4
; Left Margin (LM) = 3
; Right Margin (RM) = 3


       ORG # 5D64

, Opening a window

START CALL CLS; clear screen

       LD IX, WIND

       LD C, # 1961

       LD A, 2

       RST # 10


       CALL WAIT
, Draw a second box is not required
; Enough to just put the address of its
; Vector in register IX to transfer
; Parameters restart box

, Drawing a frame within a window


       LD IX, WIND1; vector scope

       LD C, # 1962

       LD D, 0

       LD E, 0

       LD A,% 00000000

       RST # 10


       CALL WAIT

       JR EXIT

And the vector window

WIND DEFB 5

       DEFB 3

       DEFB 16

       DEFB 20

       DEFB% 00001111

       DEFB% 00000001

       DEFB 8

       DEFB 20

And the vector window for the frame

WIND1 DEFB 8

       DEFB 5

       DEFB 10

       DEFB 14

       DEFB% 00001111

       DEFB # FF

       DEFB # 00

       DEFB # 00

; Additional procedures

CLS LD C, # 1973

       RST # 10

       RET

WAIT LD C, # 2007
       RST # 10

       RET

EXIT XOR A

       LD A, # F4

       RET

;****************************************


    As a result of the program Listing 3 on the screen should 
get a picture shown in Fig. 3 



 Fig. 3: The output of the program

                  Listing 3



    Similarly, run vertical or horizontal lines - they
presented as an imaginary part
frame and are given a fictitious vector window.
Selecting the contents of registers D and E it is easy to 
achieve positioning the frame or line to within 1 pixel.



         To be continued ...

In the next issue we will talk about the other
no less important group of system restarts IS-DOS - restart 
printing characters and lines.






Other articles:

IS-DOS - Information: The news in the world IS-DOS

IS-DOS - a beginner: IS-DOS - the first acquaintance

IS-DOS - users: A short guide on system drive IS-DOS

IS-DOS - Programmers: UniColor - Standard color settings in the programs of IS-DOS

IS-DOS - programmers: Window System IS-DOS

IS-DOS - Programmers: Program gmen.com

Iron - Revised:-lock to port # 1FFD on Scorpion ZS-256

Iron - The provinces of: brake KAY'ya

Iron - Manufacturer: KAY

Iron - Manufacturers: Scorpion ZS 256

Toys - Novella: Crystal Kingdom Dizzy

Toys - on the shelves: Bulls and Cows

Toys - on the shelves: a UFO. Enemy Unknown

Toys - What's New: Overview of new products

Interview - Old friends: A Story of Glory Mednonogova on its activities as a programmer

Information - From the authors

Contest - Competition for the Competition

Contest - Levels of Laser Squad

a rest - Something: one day in the life of a programmer

Mailbox - Classified Ad

Mailbox - Exchange of experiences: Cheats

Mailbox - Letters Game

Premiere - Color Lines

Programmers - Basic for All: Basic programmers

Programmers - Assembler: Assembler for Dummies

Programmers - Systems: Editor missions to the game Laser Squad

Miscellaneous - Amiga: Amiga History

Miscellaneous - Outlook: Toy


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

Similar articles:
Authors - the authors and their addresses.
Iron - on turbirovanie Spectrum machines.
ZXNet - On a password on the network ZXNet.
Likbez - a full disassembler ROM (part 22).

В этот день...   3 December