ZX Format #02
30 ноября 1995 |
|
IS-DOS - programmers No 2
Category "IS-DOS - the programmers." No 2 Eliseev VA "The window system IS-DOS" (Journal version) (C) PENCRAFT 1995 (C) IskraSoft 1995 Continued from the No 1. _________________________________________ Restarts printing. The next major operation - print text messages - is presented in IS-DOS system, the whole group of restarts, differing mainly in a manner set the initial parameters and some additional capabilities. In total, the level WIND.SYS There are 7 restarts relating to the process of print texts. The first three of them characterized using as coordinates printing of the information contained in the vector window (Print pos, Print size, Y-coord). Almost three restart constitute a program with three points of entry for setting various parameters. lwt (# 65) lwt (# 65) - allows you to print in window specified number of rows from a text buffer with indent on Y from the upper edge of the window. Input parameters: C - code restart (# 65) IX - the address of the vector window HL - address of text buffer A - the value of the indentation on the top of the Y window border B - number of printed lines The format of the text buffer for lwt is standard for most restarts printing in IS-DOS: characters are placed sequentially, starting from the first location in the direction of increasing addresses, lines are separated by the symbol code # 0D, handle end of the text - the character with code # 03. When working lwt marker # 03 is not necessary, since the printed text is limited to a specified number of rows. However, If the marker # 03 will meet in the text to how will print the required number of lines, printing stops. Newline characters, too, are not mandatory, since reaching the right edge of the window printing continues with the next row, and row count takes into account this is so regardless of the characters # 0D box is printed the specified number of rows. The rest of the the text is cropped. If the specified number of rows exceeds the size of the window, the text continues to be displayed outside. When working restart lwt saved unaltered contents of the register IX and in the register pair HL. Consider this example: ;**************************************** ; Listing 4 Example lwt (# 65) ORG # 5D64 ; Opening windows CALL CLS LD IX, WIND1 LD C, # 1961 LD A, 2 RST # 10 LD IX, WIND2 LD C, # 1961 LD A, 0 RST # 10 CALL WAIT ; Printing lines of text from the clipboard in window 1 LD IX, WIND1; address vector window LD HL, TEXT1; address text LD C, # 65; code restart LD A, 1; indented with Y LD B, 4 rows RST # 10 CALL WAIT ; Printing lines of text from the clipboard in window 2 LD IX, WIND2 LD HL, TEXT2 LD C, # 1965 LD A, 1 LD B, 4 RST # 10 CALL WAIT JP EXIT ; Vectors windows WIND1 DEFB 5 DEFB 2 DEFB 8 DEFB 20 DEFB% 00001111 DEFB% 00000001 DEFB 8 DEFB 20 WIND2 DEFB 5 DEFB 12 DEFB 8 DEFB 20 DEFB% 00001111 DEFB% 00000001 DEFB 8 DEFB 20 ; Text buffers TEXT1 DEFM "Restart lwt (65)" DEFB 13 DEFM "allows you to print" DEFB 13 DEFM "in the text box of" DEFB 13 DEFM "text buffer." DEFB 13 TEXT2 DEFM "in the register B is set to" DEFB 13 DEFM "rows" DEFB 13 DEFM "want" DEFB 13 DEFM "print" DEFB 13 ; 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 for the clicking RET; Tia Keys EXIT XOR A; standard output LD A, # F4; in the IS-DOS RET ;**************************************** The output is Listing 1 see Fig. 4. Restart lwt (# 65) to print in the text box of Text Buffer in the register B is set number of rows which is necessary print Fig. 4: Printing text in the box lwt (# 65) adrwt (# 66) adrwt (# 66) - is designed to print in the text box located immediately after the vector window. Input parameters: C - code restart (# 66) IX - the address of the vector window Restart adrwt very convenient for printing windows with text, tightly bound to specific window. Its main advantage - Only one input parameter (not counting code itself restart in case C). For text output on the screen adrwt uses the same procedure as lwt, so all that was said about text format for lwt, valid for adrwt. Upon reaching the bottom of the window printing stops and the rest text is ignored. When working restart adrwt content Register IX is retained. Example: ;**************************************** ; Listing 5 Printing with adrwt (# 66) ORG # 5D64 ; Opening windows CALL CLS LD IX, WIND1 LD C, # 1961 LD A, 2 RST # 10 LD IX, WIND2 LD C, # 1961 LD A, 0 RST # 10 CALL WAIT ; Printing lines of text in window 1 LD IX, WIND1; address vector window LD C, # 66; code restart RST # 10 CALL WAIT ; Printing lines of text in window 2 LD IX, WIND2 LD C, # 1966 RST # 10 CALL WAIT JP EXIT ; Vectors windows WIND1 DEFB 5 DEFB 3 DEFB 7 DEFB 20 DEFB% 00001111 DEFB% 00000001 DEFB 8 DEFB 20 The text window 1 DEFM "Restart adrwt (66)" DEFB # 0D DEFM "allows you to print" DEFB # 0D DEFM "text following" DEFB # 0D DEFM "vector for the window." DEFB # 03 WIND2 DEFB 5 DEFB 12 DEFB 7 DEFB 20 DEFB% 00001111 DEFB% 00000001 DEFB 8 DEFB 20 The text window 2 DEFM "Lines are separated by" DEFB # 0D DEFM "symbol with a code # 0D" DEFB # 0D DEFM "end of the text -" DEFB # 0D DEFM "symbol with the code # 03" " DEFB # 03 ; 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 for the clicking RET; Tia Keys EXIT XOR A; standard output LD A, # F4; in the IS-DOS RET ;**************************************** lenwt (# 67) lenwt (# 67) - also designed to print text in the box but the text does not assigned to the vector of a particular window, and can be arbitrarily in the program. The main advantage of the restart lenwt - The ability to print one text several windows, and vice versa - an opportunity print different texts in one window. Input parameters: C - code restart IX - the address of the vector window HL - address of the text When working restart lenwt content Register IX and in the register pair HL is preserved. Example: ;**************************************** ; Listing 6 Print by lenwt (# 67) ORG # 5D64 ; Opening windows CALL CLS LD IX, WIND1 LD C, # 1961 LD A, 2 RST # 10 LD IX, WIND2 LD C, # 1961 LD A, 0 RST # 10 CALL WAIT ; Printing lines of text from the clipboard in window 1 LD IX, WIND1; address vector window LD HL, TEXT; address text LD C, # 67; code restart RST # 10 CALL WAIT ; Printing lines of text from the clipboard in window 2 LD IX, WIND2 LD HL, TEXT LD C, # 1967 RST # 10 CALL WAIT JP EXIT ; Vectors windows WIND1 DEFB 5 DEFB 3 DEFB 7 DEFB 20 DEFB% 00001111 DEFB% 00000001 DEFB 8 DEFB 20 WIND2 DEFB 5 DEFB 12 DEFB 7 DEFB 20 DEFB% 00001111 DEFB% 00000001 DEFB 8 DEFB 20 ; Text buffer TEXT DEFM "Restart lenwt (67)" DEFB # 0D DEFM "allows you to print" DEFB # 0D DEFM "the text being" DEFB # 0D DEFM "anywhere" DEFB # 0D DEFM "program" DEFB # 03 ; 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 for the clicking RET; Tia Keys EXIT XOR A; standard output LD A, # F4; in the IS-DOS RET ;**************************************** The output in Listing 6 shown in Fig. 5: Restart lenwt (67) to print These appear anywhere program Restart lenwt (67) to print These appear anywhere program Fig. 5: Printing text lenwt (# 67) ... ... prstr (# 68) Restart prstr (# 68) - the most powerful and universal of all restarts that are intended for printing lines of text in the window. Its main advantage is the ability to automatically align line to the left and right, as well as centering line. Restart has 4 sub-functions, allowing to set-printable string in different ways. Subfunction code placed in the register E: E = 0 - print lines on a logical name defined in a special array analyzer E = 1 - print line of a given length, contained at the address E = 2 - the service sub-function, which is neither Why not print, but it allows you number of parameters for the previous subfunctions, knowing the starting address text buffer and line number E = 3 - print line number on it text - is actually a combination of subfunctions 2 and 1 Manager subfunctions has "protection from fool - if you set in the register E number greater than 3, it will automatically be set to zero. Now consider in more detail the work with application restart prstr (# 68). For a start - general provisions. When call to restart in case A should be the number that defines two basic print options - alignment mode (The two most significant bits) and an offset in the Y from the top of the window (six bits). Alignment mode is encoded as follows as follows: 00 - left aligned 01 - left aligned 10 - right-aligned 11 - centering the line When you work restart the contents of register A is not preserved. The format of the text buffer for prstr standard - the characters are arranged sequentially, starting from the first location, the rows are separated by the symbol # 0D, handle end of the text - # 03. To display the characters on the screen prstr uses restart ttyout (# 0A) from the level of DOS.SYS. In forming the text buffer, indent and number printed characters need to independently ensure that the text has not gone beyond the window. With the width of the line, more than field width print window is automatically aligned to the left edge, regardless of the status of the two bits of the register A. Subfunction 0, as already reported above, allows you to print lines from a text buffer on their logical names. What is it? Suppose you want to print box to the text containing the repetitive line. Instead of repeatedly call prstr, each time asking all parameters and are strictly making sure that any of the following lines of print, or that even worse, scoring a text buffer identical strings, you can just make an array, which will be installed sequence of printing lines by links to their serial numbers in the buffer. Quickly switching the different arrays, you can easily rearrange your texts, swap lines, insert others, etc. Using subfunction 0 It is also easy to organize the printing of text messages on the code from the table (like error messages in Spectrum BASIC). Input parameters: C - code restart (# 68) E - subfunction code (0) IX - the address of the vector window HL - address of the array analyzer A - mode alignment and indentation on the Y (See above) B - logical name of the line - any code except # FF Output at normal termination of HL register contains a number, one less than the address of first character line following the printed, remains unchanged contents of register IX, contents of registers A, B, C, E - is lost. Restart prstr also modifies the system variable xypos (see the vector character of the output device). Possible errors: 1. If the logical name string is not found in the array analyzer, then restart returned to the calling program with C flag set and error code 140 (No name in the array) in register A. 2. If the text does not contain a line with a serial number listed in the array Restart returns with flag set C and an error code 141 (no line in text) in register A. Mass analyzer has the following structure: the first two bytes - the address of text buffer, then - and double-byte records in which the first byte - Boolean string name, and the second - its number in the buffer. Completes the array of required code # FF. Consider an example. View on the screen frame of the stars in two different versions for two windows (see Figure 6).: ************************* * * ************************* * * * * ************************* ************************* * * * ************************* * * * ************************* Fig. 6: Frames from stars to demonstration prstr To draw these two frameworks using subfunction 0 restart prstr needed only 4 types of lines: 1. "*************************" 2. "*" 3. "*" 4. "*" Composes a program that performs this problem: ;***************************************** ; Listing 7 Printing with ; Subfunction 0 restart prstr ORG # 5D60 ; Opening windows CALL CLS; clear screen LD IX, WIND1; open window 1 LD C, # 1961 LD A, 2 RST # 10 LD IX, WIND2; open the window 2 LD C, # 1961 LD A, 0 RST # 10 ; Print the first frame LD IX, WIND1; address vector window LD HL, TABL1; array address CALL PRINT; procedure call ; Print text ; Print the second frame LD IX, WIND2 LD HL, TABL2 CALL PRINT CALL WAIT; waiting for the keys JP EXIT; output in the IS-DOS ; How to print PRINT LD B, # 09; the number of rows, a cat. ; Need Raspe ; Chat simultaneously ; Simultaneously - a logical The name of the first row ; Alignment mode - in the center, ; Indent - 1 Line LD A,% 11000001 M1 PUSH HL; save on the stack ; Array address PUSH AF; save on the stack ; Alignment mode , And the current value ; Indentation in Y LD C, # 68; code restart LD E, # 00; subfunction code RST # 10; call restart POP AF; removed from the stack , The current value ; Indent INC A; increase it by 1 ; To print the following ; Ing line POP HL; restore HL ; Array address DJNZ M1; repeat until , The value of B is not ; Reduced to 0 , Value B also serves as the counter ; In a series of print and the logical name is obvious; anterior printed line RET; return to the main ; Program ; Vectors windows WIND1 DEFB 0 DEFB 0 DEFB 11 DEFB 30 DEFB% 00001111 DEFB # FF DEFB 3 DEFB 38 WIND2 DEFB 0 DEFB 12 DEFB 11 DEFB 30 DEFB% 00001111 DEFB # FF DEFB 3 DEFB 38 ; Text buffer TEXT DEFM "*************************" DEFB # 0D DEFM "* *" DEFB # 0D DEFM "* * *" DEFB # 0D DEFM "* * * *" DEFB # 0D DEFB # 03 ; Arrays analyzers TABL1 DEFW TEXT DEFB # 09 DEFB 1 DEFB # 08 DEFB 3 DEFB # 07 DEFB 3 DEFB # 06 DEFB 1 DEFB # 05 DEFB 2 DEFB # 04 DEFB 2 DEFB # 03 DEFB 2 DEFB # 02 DEFB 2 DEFB # 01 DEFB 1 DEFB # FF TABL2 DEFW TEXT DEFB # 09 DEFB 1 DEFB # 08 DEFB 4 DEFB # 07 DEFB 4 DEFB # 06 DEFB 4 DEFB # 05 DEFB 1 DEFB # 04 DEFB 3 DEFB # 03 DEFB 3 DEFB # 02 DEFB 3 DEFB # 01 DEFB 1 DEFB # FF ; Additional procedures CLS LD C, # 73, clear screen RST # 10 RET WAIT LD C, # 07; waiting for the keys RST # 10 RET EXIT XOR A; standard output LD A, # F4; in the IS-DOS RET ;**************************************** Subfunction 1 allows you to print string of given length, which is stored in memory at that address. This subfunction calculates the coordinates of printing a string, given the number of characters, indent mode alignment and width of the print margins. When She uses the same procedure, that subfunction 0, so for the same size as the window size of the text must follow their own. After calculating the coordinates of a sub-function is the same restart ttyout (# 0A) in the loop as long as will print the required number of characters. Input parameters: C - code restart (# 68) E - subfunction code (# 01) IX - the address of the vector window HL - address of the start line B - length of string A - alignment mode, and padding in the Y The length of the printed line is determined only the value of register B. Newline # 0D, in this case is replaced by a space, the remaining characters codes is less than # 20 is not recommended in order to avoid "garbage" screen. Example of using subfunction 1: ;**************************************** ; Listing 8 Example of printing with ; Prstr (# 68) Subfunction 1 ORG # 5D64 , Opening a window CALL CLS LD IX, WIND LD C, # 1961 LD A, 2 RST # 10 CALL WAIT ; Print a line of text from the clipboard window ; By Subfunction 1 LD IX, WIND; vector window LD C, # 68; code restart LD E, 1; subfunction code LD HL, TEXT1; address line LD A,% 11000010 And two bits of the - alignment mode , (In this case - centering) And six junior - space from above (2 lines) LD B, 30; the number of characters ; In a row RST # 10; call restart CALL WAIT ; Print next line LD IX, WIND; vector window LD C, # 68; code restart LD E, 1; subfunction code LD HL, TEXT2; starting address ; Line LD A,% 11000100 ; Printing without alignment and indentation ; Top - 4 lines LD B, 36, the number of characters ; In a row RST # 10; call restart CALL WAIT JP EXIT And the vector window WIND DEFB 1 DEFB 1 DEFB 8 DEFB 30 DEFB% 00001111 DEFB% 00000001 DEFB 3 DEFB 38 ; Text buffer TEXT1 DEFM "Restart prstr (68)" DEFM "subfunction 1 TEXT2 DEFM "print lines in the window DEFM "aligned" ; Additional procedures CLS LD C, # 73, clear screen RST # 10 RET WAIT LD C, # 07; waiting for the keys RST # 10 RET EXIT XOR A; standard output LD A, # F4; in the IS-DOS RET ;**************************************** Subfunction 2 allows us to calculate input parameters for the subfunction 1 (address and length of the string) to its number in the text buffer. Input parameters: C - code restart (# 68) E - subfunction code (# 02) HL - address of the beginning of the text B - line number Output parameters: HL - address of string B - length of string The contents of registers C and E are not conserved. Text format - a standard. If value of line number exceeds the number of lines in the text, restart returns with flag set C and an error code 141 (no line in the text) in register A. ... ... Example of using subfunction 2: ;**************************************** ; Listing 9 Example ; Prstr (# 68), subfunction 2 ORG # 5D64 , Opening a window CALL CLS LD IX, WIND LD C, # 1961 LD A, 2 RST # 10 CALL WAIT ; An example of a subfunction 2 ; Determine the parameters for a subfunction ; On the famous line number in the text LD C, # 68; code restart LD E, 2; code subfunction 2 LD HL, TEXT; starting address ; Text LD B, 1; line number RST # 10 ; Output in HL '- string address , And B - Length EXX LD C, # 1968 LD E, 1; code Subfunction 1 LD A,% 11000001 RST # 10 LD C, # 1968 LD E, 2; definition LD HL, TEXT; parameters trail. LD B, 2 rows RST # 10 EXX LD C, # 1968 LD E, 1; print LD A,% 11000011 RST # 10 LD C, # 1968 LD E, 2 LD HL, TEXT LD B, 3 RST # 10 EXX LD C, # 1968 LD E, 1 LD A,% 11000101 RST # 10 CALL WAIT JP EXIT And the vector window WIND DEFB 1 DEFB 1 DEFB 8 DEFB 30 DEFB% 00001111 DEFB% 00000001 DEFB 3 DEFB 38 ; Text buffer TEXT DEFM "Restart prstr (68)" DEFM "subfunction 2" DEFB # 0D DEFM "defines the parameters for" DEFB # 0D DEFM "subfunction 1 DEFB # 0D DEFB # 03 ; Additional procedures CLS LD C, # 73, clear screen RST # 10 RET WAIT LD C, # 07; waiting for the keys RST # 10 RET EXIT XOR A; standard output LD A, # F4; in the IS-DOS RET ;**************************************** Subfunction 3 - a combination of subfunctions 2 and 1. The input parameters used the start address of text and line number in it. First sub-function 3 with two subfunctions computes addresses and length of the string, after which control is transferred to a subfunction. Input parameters: C - code restart (# 68) E - subfunction code (# 03) IX - the address of the vector window HL - address of the beginning of the text B - number of rows A - alignment mode, and padding in the Y As in the subfunction 2, in the absence of text string with a specified serial number leads to a return to the calling program with C flag set and error code 141 (no line in the text) in register A. Example of using subfunction 3: ;**************************************** ; Listing 10 Example ; Prstr (# 68), subfunction 3 ORG # 5D64 , Opening a window CALL CLS LD IX, WIND LD C, # 1961 LD A, 2 RST # 10 CALL WAIT ; Printing lines of text from the clipboard window ; A subfunction 3 LD IX, WIND; vector window LD C, # 68; code restart LD E, 3; subfunction code LD HL, TEXT; starting address ; Text LD A,% 11000010 ; Seal with centering and indent ; Top - 2 lines LD B, 1; line number ; In the text RST # 10; call restart CALL WAIT LD IX, WIND; vector window LD C, # 68; code restart LD E, 3; subfunction code LD A,% 11000101 LD B, 2; seal RST # 10; rows in the CALL WAIT JP EXIT And the vector window WIND DEFB 1 DEFB 1 DEFB 8 DEFB 30 DEFB% 00001111 DEFB% 00000001 DEFB 3 DEFB 38 ; Text buffer TEXT DEFM "Restart prstr (68)" DEFM "subfunction 3 DEFB # 0D DEFM "print string to number" DEFB # 0D DEFB # 03 ; Additional procedures CLS LD C, # 73, clear screen RST # 10 RET WAIT LD C, # 07; waiting for the keys RST # 10 RET EXIT $ XOR A; standard output LD A, # F4; in the IS-DOS RET ;**************************************** The next two restarts are to print on the screen in absolute coordinates, not tied to a particular window. str (# 6C) Restart str (# 6C) - print the current position of the screen line, limited code # 0D. String address is given in the register pair HL. This restart is convenient for printing lines on the screen outside the windows, does not require the assignment of coordinates, and uses the current print position, which is stored in the system variable XYPOS. Restart str - it is just cyclical appeal to the already mentioned above, restart ttyout (# 0A) from the level of DOS.SYS, carried out as long as does not meet code newline # 0D. To determine the coordinates of printing uses a system variable XYPOS, located in the vector character of the output device. Access to this variable can be obtained using restarts wtpos (# 6B) and prapd (# 0C), as several later. When working restart str newline is considered only as text qualifier, and the real translation line when printing is performed. It should be noted that the size of the print margins in the call str limited to one third of the screen - top, middle or bottom, namely, the one within which the current print position to call. Upon reaching the right edge of the screen printing on the next line, the latter character may be "broken" when moving and when the the lower boundary of the corresponding third of the screen print is transferred to the first of eight rows of the third. Input parameters: C - code restart (# 6C) HL - address of string XYPOS - a system variable - current print position. Example: ;**************************************** ; Listing 11 Example of str (# 6C) ORG # 5D64 CALL CLS; clear screen LD HL, TEXT1; address text LD C, # 6C; code restart RST # 10; print line CALL WAIT LD HL, TEXT2; second printing LD C, # 6C; line RST # 10 CALL WAIT LD HL, TEXT3; print thirds LD C, # 6C; line RST # 10 CALL WAIT JP EXIT ; Text buffer TEXT1 DEFM "Restart str (# 6C)" DEFB # 0D TEXT2 DEFM "allows you to print" DEFB # 0D TEXT3 DEFM "the absolute" DEFM "coordinates" DEFB # 0D ; Additional procedures CLS LD C, # 73; restart cls RST # 10, for cleaning 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 ;**************************************** lnstr (# 6D) Restart lnstr (# 6D) - as well as previous appeal to the cycle of ttyout (# 0A), but prints only the specified number of characters. Coordinates Printing is also stored in the system variable XYPOS. Input parameters: C - code restart (# 6D) HL - address of text string B - number of characters XYPOS - a system variable - current print position. When printing newlines # 0D replaced with spaces, others characters with codes less # 20 does not apply recommended. As in the case of str, the field is limited to print one of the thirds screen. For the coordinates of a system variable XYPOS use restarts prapd (# 0C) of the level and DOS.SYS wtpos (# 6B). Example: ;**************************************** ; Listing 12 Example lnstr (# 6D) ORG # 5D64 CALL CLS; clear screen LD HL, TEXT; address text LD C, # 6D $? Code restart LD B, 81 RST # 10; print line CALL WAIT JP EXIT ; Text buffer TEXT DEFM "Restart str (# 6C)" DEFM "allows you to print" DEFM "the absolute" DEFM "coordinates" ; Additional procedures CLS LD C, # 73; restart cls RST # $ 10; for cleaning 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 ;**************************************** Another restart print tylin (# 71) has a direct bearing on the work line editor edstr (# 7F), therefore it will be considered one of the following articles in our categories. To be continued ... In the next issue of our magazine you will meet with fairly large group subsidiary restarts, also included in the level WIND.SYS. _________________________________________
Other articles:
Similar articles:
В этот день... 21 November