The section "IS-DOS - for programmers". No 1 Eliseev V. A. "Window system IS-DOS" (journal version)
(C) PENCRAFT 1995 (C) IskraSoft 1995
One of the undeniable advantages of the IS-DOS operating system can be considered its convenient window interface, allowing programmers to beautifully design their programs.
The idea of a window interface, which was absent in the traditional ZX Spectrum operating system, has always attracted programmers who dreamed of their works looking professional. One of the masterpieces of window technology is rightly considered the famous "Peter Cook's Window Interface," which was used in many games, in branded programs like Art Studio, ASTRO, and even in some creations of domestic programmers - DCU, FUT, STM, F Commander, etc.
The developers of the IS-DOS system, of course, did not remain indifferent and, realizing the importance and necessity of implementing window technology in a professional system, allocated an entire level of the system for it, which was named WIND.SYS.
The WIND.SYS level contains 23 restarts that provide functionality for working with windows, character strings, cursors, etc. With the help of these restarts, one can organize output to the display, design the working screen, and also organize a dialogue with the user through a string editor. Unfortunately, the volume of this article does not allow for a detailed examination of all 23 restarts that make up the WIND.SYS level, so we will only discuss 19 of them, which are directly related to working with windows and text information within them. A separate article in the "IS-DOS - for programmers" section will be dedicated to the description of the string editor and the file panel management system.
Creating windows.
The work of any window interface naturally begins with the procedure for opening a window. A window in the IS-DOS system has the following structure (see Fig. 1):
┌───────────────────────────────────────┐
│ │
│ │ window area │ │
│ │ │ working area of the window │ │ ││ │ │ │ │ │
│ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ │
│ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒ │
│ ▓▓ ░░░░░░░░░░░░░░░░░░░░ ▓▓▒▒ │
│ ▓▓ ░░░░░░░░░░░░░░░░░░░░ ▓▓▒▒ │
│ ▓▓ ░░░░░░░░░░░░░░░░░░░░ ▓▓▒▒ │
│ ▓▓ ░░░░░░░░░░░░░░░░░░░░ ▓▓▒▒ │
│ ▓▓ ░░░░░░░░░░░░░░░░░░░░ ▓▓▒▒ │
│ ▓▓ ░░░░░░░░░░░░░░░░░░░░ ▓▓▒▒ │
│ ▓▓ ░░░░░░░░░░░░░░░░░░░░ ▓▓▒▒ │
│ ▓▓ ░░░░░░░░░░░░░░░░░░░░ ▓▓▒▒ │
│ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒ │
│ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒ │
│ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
│ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
│ │
│ ▓▓▓ - frame area │
│ │
│ ░░░ - print area │
│ │
│ ▒▒▒ - shadow area │
│ ││ - margins │
├───────────────────────────────────────┤
│ Fig. 1: Structure of a window in IS-DOS │
└───────────────────────────────────────┘
The window area is defined by the values XS (X-size) and YS (Y-size) and is measured in character cells of 8*8 pixels, the frame area has a width of 8 pixels (1 character cell 8*8) around the entire perimeter of the window, therefore, the dimensions of the working area of the window are XS-2 and YS-2. The size and position of the print area in the window, as well as the width of the left and right margins, are determined by prnt pos. and print size and are measured in character cells of 6*8. The upper and lower edges of the print area are limited only by the frame area.
The shadow area is a border along the bottom and right sides of the window, 1 character cell of 8*8 thick and set back 1 character cell from the left and top borders of the window area.
wt (#61)
In the IS-DOS system, the wt restart (code #61) is used to open a window. It creates a window on the screen with parameters specified in a special table called the "window vector." The address of the window vector at the time of calling the restart must be in the IX register pair, while the contents of the A register determine the appearance of the window as follows:
The 7th bit, set to 1, makes the opened window "transparent," i.e., the window opens only by changing attributes, and the pixels inside it are not cleared.
The remaining bits determine the appearance of the window frame:
000000 - single frame
000010 - double frame
All other values result in opening a window without a frame.
Thus, the format for specifying the appearance of the window can be represented in the following table:
╔═════════╦══════════╤═════════╤════════╗
║ ║ single │ double │ without ║
║ Window ║ frame │ frame │ frame ║
║ ║ │ │ ║
╟─────────╫──────────┼─────────┼────────╢
║ ║ │ │ A=#81 ║
║ transparent║ A=#80 │ A=#82 │ A=#83- ║
║ ║ │ │ #FF ║
║ ║ │ │ ║
╟─────────╫──────────┼─────────┼────────╢
║ ║ │ │ A=#01 ║║ opaque ║ A=#00 │ A=#02 │ A=#03- ║
║ ║ │ │ #7F ║
║ ║ │ │ ║
╚═════════╩══════════╧═════════╧════════╝
So, the procedure for opening a window in the IS-DOS system looks as follows:
LD IX,WIND ;load into IX
;the address of the window vector
LD C,#61 ;load into C the code
;of the wt restart
LD A,n ;load into A the value
;defining the appearance of the window
RST #10 ;call the restart
Structure of the window vector:
WIND DEFB #00 ;X-coordinate of the upper
;left corner of the window
;in character cells
;8*8 pixels
DEFB #00 ;Y-coordinate of the upper
;left corner of the window
;in character cells
;8*8 pixels
The coordinate values are counted from the upper left corner of the screen
DEFB #0F ;height of the window in character
;cells 8*8
DEFB #0F ;width of the window in character
;cells 8*8
DEFB %00000111 ;window colors
The colors are encoded in the standard way:
bit 7 - flash
bit 6 - bright
bits 5...3 - paper
bits 2...0 - ink
DEFB %00000001 ;shadow colors of the window
It is noteworthy that in the shadow colors of the window, both the paper color and the ink color can be specified, which allows making visible part of the information on which the shadow from the window falls and ensures maximum natural perception. If the byte of shadow colors is equal to #FF, then the shadow is not displayed.
DEFB #01 ;X-coordinate for the
;text printing procedure
;in the window
DEFB #12 ;width of the print area
;in the window
The last two parameters are expressed in character cells of size 6*8, not 8*8 like the others, this is done because this system of counting is used by all print restarts in IS-DOS. The value of the print X-coordinate is absolute and is counted not from the left edge of the window, but from the left edge of the screen. The conversion of window coordinates to print coordinates and vice versa can be carried out using the formulas:
(1) n=N*8/6
(2) N=n*6/8,
where n - value in character cells of 6*8, and N - value in character cells of 8*8.
The print Y-coordinate is not specified since most print restarts automatically count it from the top line of the window.
Several windows can be opened on the screen, with the current one being considered the window whose vector address is in the IX register pair. For more efficient use of RAM, the information covered by the window at the moment of its opening is not saved, therefore, if you suddenly need to return to the previous window, you will have to open it again.
Let's consider a simple example. The task is to create a window at the coordinates X=5 and Y=3 with a size of 28*16 character cells with a double frame, blue paper, white ink, and a black-blue shadow, defining the text print area with an offset of 1 character cell from the left and 5 character cells from the right edge of the window.
To create this simple program, in addition to the window opening restart wt(#61), we will need three more subprograms - for clearing the screen, waiting for a key press, and returning to IS-DOS. The actions of these subprograms are based on other restarts of the IS-DOS system, which will be described in subsequent issues of the magazine, but for now, 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 a key press
RET
EXIT XOR A ;standard exit
LD A,#F4 ;to IS-DOS
RET
So, let's consider Listing 1:
;****************************************
;Listing 1 Example of creating a window
;Input data:
; 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
;main program
START CALL CLS ;call the procedure
;to clear the screen
LD IX,WIND ;address of the window vector
LD C,#61 ;code of the wt restart
LD A,2 ;code for double frame
RST #10 ;call the restart
CALL WAIT ;call the procedure
;to wait for a key press
JP EXIT ;jump to the procedure for returning to IS-DOS
;window vector
WIND DEFB 5
DEFB 3
DEFB 16
DEFB 20
DEFB %00001111
DEFB %00000001
DEFB 8
DEFB 20
;Data for print position (printing with an offset of 1 character cell 6*8 from the left edge of the window) were obtained by calculation using formula (3):
; (3) PP=X*8/6+LM,
;where PP - print pos. in character cells 6*8
; X - X-coord. of the window in character cells 8*8
; LM - left margin in character cells 6*8
;Data for print size were obtained by calculation using formula (4):
; (4) PS=XS*8/6-LM-RM,
;where PS - print size in character cells 6*8
; XS - size of the window in character cells 8*8
; LM - left margin in character cells 6*8
; RM - right margin in character cells 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
EXIT XOR A ;standard exit
LD A,#F4 ;to IS-DOS
RET
;****************************************
As a result of executing the program in Listing 1, a window corresponding to the image in Fig. 2 should appear on the screen; otherwise, check the correctness of the program input.
┌───────────────────────────────────────┐
│ │
│ ││ ╔═══════════════════╗ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ║ ║▒ │
│ ╚═══════════════════╝▒ │
│ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
│ │
│ │
├───────────────────────────────────────┤
│ Fig. 2: result of the program execution │
│ Listing 1 │└───────────────────────────────────────┘ ... box (#62) The next restart box(#62) allows drawing or erasing any possible frame in the area of the window frame, or any of its sides in any combination. Since the width of the frame area in the IS-DOS window is 8 pixels, there are a total of 8 different single frames possible. By calling the box restart several times, one can draw double, triple, and even quadruple frames, as well as frames of varying thickness - a total of 256 combinations. As input parameters, the box(#62) restart uses the window vector, the address of which is specified in the IX register, as well as the offset values from the edge of the window in Y and X in pixels, specified in registers D and E respectively, and the contents of register A, which determine what exactly needs to be drawn or erased. The contents of register A are defined as follows: bit 7=0 - draw, 1 - erase; bits 6...4 - not used; the remaining bits indicate which sides of the frame the operation is performed on: bit 3=0 - left side of the frame; bit 2=0 - right side of the frame; bit 1=0 - top side of the frame; bit 0=0 - bottom side of the frame. For bits 3...0, any combinations are possible. The general form of the drawing/erasing frame procedure looks like this: LD IX,WIND ;address of the window vector LD C,#62 ;code of the box restart LD D,N1 ;offset in Y LD E,N2 ;offset in X LD A,n ;what to do RST #10 ;call the restart To specify the offset values of the frame, it is preferable to use numbers from 0 to 7, with a value of 0 loaded into registers D and E, the frame will be output on the outer edge of the window, and when loading a value of 7 - on the inner edge of the frame area. A value of 8 will yield the same effect as 0, 9 - the same as 1, and so on. Let's consider an example. We will take Listing 1 as a basis, but first depict the window without a frame, and then output a double frame such that its outer line is twice as wide as the inner one, after which we will make the left and right sides of the outer frame single thickness. ;**************************************** ;Listing 2 Example of drawing a window frame ORG #5D64 ;opening the window START CALL CLS ;clear the screen LD IX,WIND LD C,#61 LD A,1 ;window without a frame RST #10 CALL WAIT;drawing the outer double frame;performed in two passes LD IX,WIND ;address of the window vector LD C,#62 ;code of the box restart LD D,0 ;offset in Y LD E,0 ;offset in X LD A,%00000000;all bits equal to 0 - draw the entire frame RST #10 LD IX,WIND LD C,#62 LD D,1 LD E,1 LD A,%00000000 RST #10 CALL WAIT;drawing the inner frame LD IX,WIND LD C,#62 LD D,3 LD E,3 LD A,%00000000 RST #10 CALL WAIT;erasing the side edges LD IX,WIND LD C,#62 LD D,2 LD E,1 LD A,%10000011;7th bit set - erase command;set bits 0 and 1 indicate that the top and bottom sides of the frame are not affected in this operation RST #10 CALL WAIT JR EXIT;window vector WIND DEFB 5 DEFB 3 DEFB 16 DEFB 20 DEFB %00001111 DEFB %00000001 DEFB 8 DEFB 20;additional procedures CLS LD C,#73 RST #10 RET WAIT LD C,#07 RST #10 RET EXIT XOR A LD A,#F4 RET;**************************************** If necessary to organize frames, drawing vertical and horizontal lines inside the window (beyond the frame area), one can also use the box(#62) restart, however, for this it will be necessary to create a dummy window vector in such a way that the required frame fits within the frame area of this imaginary window. Let's explain with an example: Suppose it is necessary to create a frame inside the window (see Listing 1) with an offset of 2 character cells from the top edge of the window, 4 from the bottom, and 3 from the left and right sides. For this, we will create a dummy window vector WIND1, and to calculate its parameters, we will use the following formulas: (5) Y1=Y+UM, where Y1 - Y-coordinate of the frame, Y - Y-coordinate of the window, UM - top offset (6) X1=X+LM, where X1 - X-coordinate of the frame, X - X-coordinate of the window, LM - left offset (7) YS1=YS-UM-DM, where YS1 - size of the frame in Y, YS - size of the window in Y, UM - top offset, DM - bottom offset (8) XS1=XS-LM-RM, where XS1 - size of the frame in X, XS - size of the window in X, LM - left offset, RM - right offset All values are measured in character cells of 8*8. We will choose the same color values for the frame as for the main window, but without a shadow (S.Colors=#FF), the values for Print pos. and Print size can be anything. So, ;**************************************** ;Listing 3 Example of drawing internal ; frames using box(#62) ;Input data: ; Up Margin (UM) = 2 ; Down Margin (DM) = 4 ; Left Margin (LM) = 3 ; Right Margin (RM) = 3 ORG #5D64 ;opening the window START CALL CLS ;clear the screen LD IX,WIND LD C,#61 LD A,2 RST #10 CALL WAIT;no need to draw the second window, just place its vector address in register IX for passing parameters to the box restart;drawing the frame inside the window LD IX,WIND1 ;frame vector LD C,#62 LD D,0 LD E,0 LD A,%00000000 RST #10 CALL WAIT JR EXIT;window vector WIND DEFB 5 DEFB 3 DEFB 16 DEFB 20 DEFB %00001111 DEFB %00000001 DEFB 8 DEFB 20;window vector 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,#73 RST #10 RET WAIT LD C,#07 RST #10 RET EXIT XOR A LD A,#F4 RET;**************************************** As a result of the program in Listing 3, the screen should display the picture shown in Fig. 3 ┌───────────────────────────────────────┐ │ │ │ │ │ ╔═══════════════════╗ │ │ ║ ║▒ │ │ ║ ┌───────────┐ ║▒ │ │ ║ │ │ ║▒ │ │ ║ │ │ ║▒ │ │ ║ │ │ ║▒ │ │ ║ │ │ ║▒ │ │ ║ │ │ ║▒ │ │ ║ │ │ ║▒ │ │ ║ │ │ ║▒ │ │ ║ │ │ ║▒ │ │ ║ └───────────┘ ║▒ │ │ ║ ║▒ │ │ ║ ║▒ │ │ ║ ║▒ │ │ ╚═══════════════════╝▒ │ │ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │ │ │ │ │ ├───────────────────────────────────────┤ │ Fig. 3: result of the program execution │ │ Listing 3 │ └───────────────────────────────────────┘ Similarly, vertical and horizontal lines are drawn - they are represented as sides of an imaginary frame and defined using a dummy window vector. By adjusting the contents of registers D and E, it is not difficult to achieve positioning of the frame or line with an accuracy of up to 1 pixel. To be continued ... In the next issue, we will talk about another equally important group of system restarts in IS-DOS - the character and string printing restarts.
Contents of the publication: ZX Format #01
- IS-DOS
IskraSoft introduces IS-DOS Classic 4.0 with advanced text editing features, a disk utility, a hard drive controller for ZX Spectrum, and a program debugger.
- IS-DOS - Владимир Елисеев
Overview of IS-DOS for ZX Spectrum, highlighting its advantages over TR-DOS. Discussion on installation, usage, and file management features of IS-DOS. Introduction to system utilities and interface similar to Norton Commander.
- IS-DOS - Владимир Елисеев
The article provides a concise guide to the IS-DOS system disk, listing all essential files with explanations. Files are sorted alphabetically and grouped by directories for easy navigation. The guide focuses on a basic overview of files and commands without extensive descriptions.
- IS-DOS - Владимир Елисеев
Discussion on the UniColor standard for color settings in IS-DOS programs, its implementation, and advantages for user customization.
- IS-DOS - Владимир Елисеев
Discussion of IS-DOS window interface features. Implementation of window system in IS-DOS and its advantages. Example programs for creating windows and frames.
- IS-DOS - Владимир Елисеев
Description of the internal workings of the gmen.com program for IS-DOS, focusing on device management and menu handling with detailed source code and comments.
- Hardware - Vladimir Larkov
Discussion on modifying Scorpion ZS-256 hardware for compatibility with specific software. Describes blocking port #1FFD to run incompatible programs. Provides technical details for implementation.
- Железо - Nemo
Discussing hardware braking devices for ZX Spectrum. Focus on creation and impact of brakes on overclocked processors. Warning about potential side effects.
- Железо
Discussion of the impracticality of repairing old computers and the economic sense in replacing them with modern hardware. The article highlights challenges in DIY repairs and suggests alternative solutions. Emphasizes the benefits of upgrading to newer, more reliable components.
- Железо
Discussion of new peripheral developments for Scorpion ZS 256, including an innovative universal controller and MIDI interface. Highlights enhancements in keyboard and mouse controllers and expansion of built-in software capabilities. Offers details on professional ROM extension and turbo mode for improved performance.
- Игрушки - Ruster
A detailed walkthrough of the game Crystal Kingdom Dizzy, including solutions to puzzles and tips for progressing through the story.
- Игрушки - Павел Рындин
Description of the logic game 'Bulls and Cows', its mechanics and gameplay. Explains levels of difficulty and the goal to guess a number with minimal attempts.
- Игрушки - Вячеслав Медноногов
Discussion on the nuances of 'UFO: Enemy Unknown' game, focusing on alien species, their tactics, and gameplay strategies. Details on game mechanics and future sequel 'UFO-2: Devils of the Abyss'. Includes programming insights and development history.
- Игрушки - SParker
Overview of games and software on the Saint Petersburg market in 1995.
- Интервью
Vyacheslav Mednonogov shares his journey as a programmer, from assembling his first Spectrum-48 to developing notable games like 'UFO. Enemy Unknown'. He describes challenges and insights in game development and the rise of Russian game localization. His experiences highlight the evolution of programming and software distribution in the 1990s.
- Информация
Introduction to ZX-Format, a new electronic magazine for ZX Spectrum enthusiasts, focusing on games, programming, hardware, and community interaction.
- Конкурс
Discussion on organizing a new competition for the magazine. Readers are invited to submit their theme ideas. Selected themes will be featured in future issues.
- Конкурс
ZX Format announces a competition for the best mission created using the mission editor for the game Laser Squad. Submissions are accepted by mail or in person. Winner receives a box of 3M disks and the next issue for free.
- Отдохнём - Килат Амор
A programmer's day filled with dreams, gaming, and casual conversations. Vasetchkin balances ambition with relaxation, embodying the programmer's spirit. Reflects on the demands and enjoyment of a programmer's life.
- Mailbox - Максим Романов
Discussion on hardware and software offers in St. Petersburg by LOGROS and Create Soft, including detailed insights on Kempston Mouse interface.
- Mailbox - SParker
Compilation of cheat codes for ZX Spectrum games by Sergey Pavlov. Techniques for extra lives and immortality. Not recommended for fans of fair play.
- Mailbox
Description of submission guidelines for letters and articles to the magazine, including formatting and submission preferences.
- Премьера - Алексей Щекин
Gameplay of Lines game on ZX Spectrum, similar to Color Lines. Move balls to form lines of the same color. Scoring and controls are described.
- Программистам - Дмитрий Рудовский
Introduction to advanced BASIC programming techniques for ZX Spectrum 48, highlighting its advantages over 128 BASIC. Plans for future articles include service programs and language extensions. The article serves as a guide for experienced programmers.
- Программистам - Михаил Спицын
Introduction to assembly language on ZX Spectrum. Explanation of Z80 processor structure, registers, and basic commands. Includes example programs for learning.
- Программистам - Андрей Седов
Mission editor for Laser Squad by Andrey Sedov allows fans to create new missions. Includes user-friendly interface with minimal controls. Offers features like object editing, price adjustments, and sprite assignment.
- Various
History of Amiga computer development, its creators, and key features. Evolution from arcade games to a leading home computer. Amiga's market success and technological advancements.
- Разное
Review of upcoming ZX Spectrum software products with demos. Highlights include adventure games, RPG trials, and strategic tactics. Several well-known developers contribute to these releases.