ZX Review #7-8-9-10
08 ноября 1997 |
|
Forum - Multicolor program on any computer model. Using the 2 nd screen Multicolor'a. Demonstration of the text. Electronic journals.
FORUM Music by ZET (C) KM SoftWare '1997 So, in the first place a program that allows you to use MULTICOLOR on any computer model. Input program does not require (only advisable to clear the screen and set the attributes). Imprint: A - number of rows from the beginning of the curb (Parish INT) to the first line of the screen. Example of use: run this test, then run your program, an interrupt output which hangs MULTICOLOR'a. That is, for the withdrawal MULTICOLOR'a have to wait n line screen (224 clocks - 1 line), where n - the number obtained by the test. If you do not wish to write the program a string of delay, do it this way: the label RETURN write command RET (code 201 = # C9), and on arrival INT'a immediately transfer control to label PRINT, and when you return outputting MULTICOLOR. Second: if you do not need first, and some other line of the screen, then change the address in label ADRES - this address of the first byte of the desired on-screen prompt. The program takes only 201 bayt.140. ORG 32768 TEST DI LD DE, # C001; form a vector LD BC, # 0100, for IM 2 LD H, D; 3 (# C000 = 49,152) LD L, C LD A, # C1 LD (HL), A PUSH AF DEC A LD (PRINT +1), A; current row LD I, A LDIR IM 2 ADRES LD HL, 16384; draw on the screen LD B, 32; line L1 LD (HL), 255 INC HL DJNZ L1 POP HL LD L, H LD (HL), # FB; processing program INC HL; interrupts: EI: RET LD (HL), # C9 LD A, B OUT (# FE), A; black border EI; allowed IM 2 LOOP HALT; main loop CALL PRINT; output line CALL KLAV; poll keypad JR NC, LOOP; if not pressed the fire DI; output LD A, # 3F LD I, A; normal output IM 1 LD A, (PRINT +1); take a number INC A; line 1 EI RET; output The poll keypad And if the output of SCF, then pushed the fire. KLAV XOR A; * these lines IN A, (# FE); * principle, we can CPL; * remove ... AND # 1F; * JR Z, NOKEY; * no keys pressed LD A, # FB IN A, (# FE) BIT 0, A; Claudia "Q" JR Z, UP; if so, then the transition LD A, # FD IN A, (# FE) BIT 0, A; Claudia "A" JR Z, DOWN LD A, # 7F IN A, (# FE) RRA JP NC, FIRE; Claudia "SPACE" NOKEY AND A; no keystrokes RET FIRE SCF; output of "SPACE" RET ; Move the line up UP LD A, (PRINT +1) CP 1920 JR Z, NOKEY; limiter DEC A; reduced the number LD (PRINT +1), A JR NOKEY; output ; Move the line down DOWN LD A, (PRINT +1) CP 255; limiter RET Z INC A; increased the number LD (PRINT +1), A JR NOKEY; output ; Output to curb the blue bar PRINT LD B, 0, row number PAUSLIN EX (SP), IX; * this programm EX (SP), IX; * 3propuskaet 224 EX (SP), IX; * tact, that is EX (SP), IX; * one line EX (SP), IX; * EX (SP), IX; * EX (SP), IX; * EX (SP), IX; * LD HL, (0) * NOP; * LD A, 3 * DJNZ PAUSLIN; * EX (SP), IX; miss another EX (SP), IX; 3stroku (almost 224 EX (SP), IX; tact - it is necessary for EX (SP), IX; position correction EX (SP), IX; row from the left edge EX (SP), IX; curb. Almost - EX (SP), IX; because they were already EX (SP), IX; command CALL, LD B, N LD DE, 0 LD H, (HL) NOP RETURN OUT (# FE), A; blue border EX (SP), IX; 3propuskaem 224 cycles EX (SP), IX; 3-11 cycles per EX (SP), IX; command OUT (# FE), A EX (SP), IX EX (SP), IX EX (SP), IX EX (SP), IX EX (SP), IX LD A, (IX +0) NOP LD A, 0 OUT (# FE), A; black border RET; vyhod2 This test works correctly on machines with 224 bar in line. If you have a 220, then it is of course, will not work. About correct operation of this program you can say this: the my buggy Pentagon (66 lines instead of 80 to the screen) vile company Solon. Therefore, the normal machines can be a deviation. If you are using to delay the program PRINT, it is not scary, but if your - if you have to adjust the resulting value (teams ADD A, N, or SUB A, N). By the way, because this company on the its "Pentagon" disgusting go all the demos: the ball is in ILLUSION disappears (no time to conclude on screen), then the synchronization is delayed by 3 MULTICOLOR'a familiarity (EYE ACHE) 'lot, etc. glitches. Little use of the 2 nd screen MULTICOLOR'a. You can use it, and in some cases of need. With the help of you can display in one of familiarity 4 colors instead of 2, and lack of resolution is compensated by the fact that you can use a horizontally though the entire screen. Where can I apply? If you've seen a demo VIBRATIONS, you can understand ... There's a nice start of the output lines, with closer examination it turned out that they are dichromatic: the point violet - a green dot. It seems to be using the second screen (Do not know - this demo, I do not break). With the 2 nd screen can display scroller Text on the picture with a different color. Is not very clear, but still ... Demonstration of the text. Electronic journals. This article - for those who wants to make your e-mail journal, or HELP, but does not know where to start. Let's start with the basics: the main thing in magazine - the visual text. Naturally, it should be on of 97 years, ie necessarily color, and how to pages, and interline scrolling text. Managed this business should or keys (as in SPECTROFON'e) or arrow (ZX-FORMAT) - interfaces to other demonstrators have not yet invented. Thus, the visual text is divided into two separate programs: management and Text scroller. This program should provide scrolling text in 2 directions line by line and page by page. The algorithm works as follows (For the team "line up"): 1. If this is the beginning of the text, then output. 2. Take the current address in the text and move it to a string up. 3. Move the entire screen for one familiarity down. 4. Print on the top line line of current address. 5. Exit. The main loss of time is paragraph 3: zded we can choose one of two ways - either greatly increase the speed scroller - to use a stack or LDI (it uses almost all of the memory 48) or to make a scroller is not very fast, but in color. 1. Using the stack. Cycles deployed. Used in almost all the memory 48 (when considering the text and work programs). It works with illegal interrupts, so SOUNDTRACK impossible. Fullscreen rebuilt in less than two interrupts. An example of constructing such a program, scroll the screen up. This program builds a scroller with the address 26000. When you log in 26000 interrupts are prohibited, then there is scrolled up the screen at one familiarity, restore the stack, the resolution Interrupt and vozvrat.140. ORG 25000 LD HL, 26000; have addressed prog LD (HL), # F3 INC HL LD (HL), # ED INC HL LD (HL), # 73; DI: LD (0), SP INC HL LD (HL), 0 INC HL LD (HL), 0 INC HL EX DE, HL LD BC, 184 * 2 LOOP PUSH BC; now transfers LD HL, BLOK; block 184 * 2 times. LD BC, ENDBLOK-BLOK LDIR; for scrolling POP BC; one line to DEC BC; 2 blocks. LD A, B OR C JR NZ, LOOP EX DE, HL LD (HL), # 31; LD SP, 0: EI: RET INC HL LD (26 000 +3), HL INC HL INC HL LD (HL), # FB INC HL LD (HL), # C9 LD HL, 26006; address of the first SP +1 LD BC, 184; 184 lines LOOP1 LD DE, (ADRES1) LD (HL), E; this pp. puts on INC HL; commands LD SP, 0 LD (HL), D; the correct values. LD DE, 12 ADD HL, DE LD DE, (ADRES3); have addressed INC DE; increased by 1 LD (HL), E; log into the LD SP, NN INC HL LD (HL), D LD DE, 12; increased address ADD HL, DE; until the next LD SP LD DE, (ADRES2) LD (HL), E INC HL LD (HL), D LD DE, 12 ADD HL, DE LD DE, (ADRES4) INC DE LD (HL), E INC HL LD (HL), D LD DE, 12 ADD HL, DE EX DE, HL LD HL, (ADRES1); adjust CALL DHL; screen address LD (ADRES1), HL; (reduced by 1 LD HL, (ADRES2); line) CALL DHL LD (ADRES2), HL LD HL, (ADRES3) CALL DHL LD (ADRES3), HL LD HL, (ADRES4) CALL DHL LD (ADRES4), HL EX DE, HL DEC BC LD A, B OR C JR NZ, LOOP1 RET DHL INC H; DOWN HL for LD A, H; screen. AND 7 RET NZ LD A, L ADD A, 32 LD L, A RET C LD A, H SUB 8 LD H, A RET ADRES3 DW 16384 +16-1; address in the screen ADRES4 DW 16 384 31 ADRES1 DW 16 384 32 ADRES2 DW 16 384 31 17 BLOK LD SP, 0; block POP HL; construction POP DE; program POP BC; scroller POP AF EXX EX AF, AF POP HL POP DE POP BC POP AF LD SP, 0 PUSH AF PUSH BC PUSH DE PUSH HL EXX EX AF, AF PUSH AF PUSH BC PUSH DE PUSH HL ENDBLOK2 2. Instead, the stack is used LDI. Cycles are also deployed. Used by almost 2 times less memory than in the first case. The program works with interrupt enable, the output of music is possible. Full speed scroll: 4-6 interrupts. Example will not lead, as She recalls the principle of constructing the first case, and the structure - the third (only all the cycles deployed). Unit for one line will look like this: 140. BLOK LD HL, 0 LD DE, 0 LD BC, 32 LOOP LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI JP PE, LOOP 2 Of course, have to adjust not only addresses the screen, but also address the transition: JP PE, LOOP, as if, instead of JP PE, LOOP put another 16 LDI, then program will receive a very large (even larger than 1-I). 3. A compressed cycle LDI. Takes very little memory (200-400 bytes), but the speed is naturally reduced to 10-15 interrupts. Interrupts are enabled. In principle, ideal for color scrollers (in SMM, MTV I used exactly this way). 140. ; An example of scrolling up the screen. LD DE, 16384, where (top screen) LD HL, 16384 32, from which (at ; Familiarity below) LD B ,192-8, all lines LOOP PUSH BC; remember PUSH HL PUSH DE LDI; 332 LDI (32 bytes LDI; in a row). Can LDI; replaced by: LDI; LD BC, 32 LDI; LDIR, LDI; but this is LDI; very slowly LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI POP HL CALL DOWNHL POP DE EX DE, HL CALL DOWNHL POP BC DJNZ LOOP RET; output DOWNHL INC H; screen line LD A, H; down for HL. AND 7 RET NZ LD A, L ADD A, 32 LD L, A LD A, H SUB 8 LD H, A RET 2 If you want to make the scroller up, then it will be different only a couple of things: specify the address in DE 23296-31, the HL - Address on familiarity above (23296-63), in BC is the same (192-8), but now we need to adjust Address not DOWNHL, and UPHL - screen line up. Looks like this: 140. UPHL DEC H LD A, H AND 7 CP 7 RET NZ LD A, L SUB 32 LD L, A RET C LD A, H ADD A, 8 LD H, A RET 2 All of the above procedure works only with the graphics. For colored scrollbars will have to carry attributes. Actually, you can transfer them in two ways: 1. Following the transfer of graphics. This is a fast way, but there is one drawback: if your program scrolling graphics do not fit in 1-2 interrupt, then the effect will be very unpleasant: we see how at first be transferred schedule, and then attributes. 2. In parallel with the transfer graphics. More than slow and deep way, but the scroller is look more or less decently. For a split colored scrollbars procedure for scrolling on a routine that would bore the 8 lines of graphics and a line attributes. The text of the program: 140. LD DE, 16384, where (top screen) LD HL, 16384 32, from which (at ; Familiarity below) LD B, 23; total rows / 8 EXX; address attributes LD DE, 22528, where LD HL, 22528 32, from EXX LOOP1 PUSH BC CALL SCROLL; scrolling 8 lines POP BC DJNZ LOOP1 RET; output SCROLL LD B, 8, 8 lines. LOOP PUSH BC; remember PUSH HL PUSH DE LDI; 332 LDI (32 bytes LDI; in a row). Can LDI; replaced by: LDI; LD BC, 32 LDI; LDIR, LDI; but this is LDI; very slowly LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI LDI POP HL CALL DOWNHL POP DE EX DE, HL CALL DOWNHL POP BC DJNZ LOOP EXX; attributes LD BC, 32; newline LDIR EXX RET; output DOWNHL INC H; screen line LD A, H; down for HL. AND 7 RET NZ LD A, L ADD A, 32 LD L, A LD A, H SUB 8 LD H, A RET 2 As you can see, nothing complicated ... A bit of word processing procedures. Actually, we have 4 addresses - the address of the beginning of the text, the address of the end of the text address top line in the text (which is currently displayed on the on top of the screen) and the address of the bottom line in the text. Then the conclusion Text will be the fastest. To scroll up stuffing such a program: 140. SCRUP LD HL, (ADRES1); address the top PUSH HL; line LD DE, (BADRES); starting address AND A; text SBC HL, DE; if equal, then POP HL; correction stack RET Z; and output DEC HL; skipping bytes DEC HL; 3 ENTER = 13 (# 0D) LD A, 13; search for the next LOOP1 CP (HL); line JR Z, FOUND; line found DEC HL; reduced address JR LOOP1; in the cycle FOUND INC HL; in HL-address line LD (ADRES1), HL; remember LD HL, (ADRES2); DEC HL; DEC HL; You LOOP2 CP (HL); adjust JR Z, FOUND1; address lower DEC HL; line. JR LOOP2 FOUND1 INC HL LD (ADRES2), HL LD HL, (ADRES1); address printing PRNSTR LD C, 0; counter LOOP3 LD A, (HL) CP 13, when the end of line JR Z, DOP; then overprint INC C; increased counter PUSH BC PUSH HL CALL PRINT; print symbol POP HL POP BC INC HL; increased address JR LOOP3; in the cycle DOP LD A, 32; overprint lines SUB C; (we must AND A; print exactly RET Z; 332 characters). LD B, A; Remaining count DOP1 PUSH BC LD A, 32; code space CALL PRINT; print POP BC DJNZ DOP1 RET; output 2 This option is for monochrome scrolling. For color have some work to do ... The whole question is that when a color scrolling text automatically becomes a non-standard format - control codes, etc. If you do use this aaplet only for myself, then There is nothing wrong, but if for distribution, you have to write their utility for change the text. In my opinion, for scroller best to use the text in this format: before the code is an attribute of any control code (in the SMM, For example, 17). This combination should be the beginning of each line. Program print (PRINT in our case) should receive a code for 1917 set a new attribute (go the next time you call it) and print all the characters before entering the code 17 in this color. Here is another: need to alter the program LOOP1 and LOOP2 (Search Code 13 - the end line). Now they will be (We are interested in a piece of Procedure): 140. SCRUP LD HL, (ADRES1); address the top PUSH HL; line LD DE, (BADRES); starting address AND A; text SBC HL, DE; if equal, then POP HL; correction stack RET Z; and output DEC HL; skipping bytes DEC HL; 3 ENTER = 13 (# 0D) ; Search for the next LOOP1 LD A, (HL); line CP 1913 JR Z, FOUND; line found PROPUSK DEC HL; reduced address JR LOOP1; in the cycle FOUND DEC HL LD A, (HL) CP 17, it was the color? JR Z, PROPUSK; if so, the transition INC HL INC HL; in HL-address line LD (ADRES1), HL; remember LD HL, (ADRES2); DEC HL; DEC HL; You LOOP2 LD A, (HL); adjust CP 1913 JR Z, FOUND1; address lower PROPSK1 DEC HL; line. JR LOOP2 FOUND1 DEC HL LD A, (HL) CP 1917 JR Z, PROPSK1 INC HL INC HL LD (ADRES2), HL 2 Part Two: Control procedures. Say there is nothing special. In recent years, in programs this kind instead of the keys was used needle. I will say one thing: for "mouse" is, perhaps, convenient, but if the mouse is not, then just a waste of time. Best option would be to determine a mouse, and if it is, then the control arrow, and if not, then the keys. About Keys more than say nothing, talk about managing the arrow. There are two algorithms: first used in the ZX-POWER: when pressed the fire, the arrow disappears, then the screen scrolls, hand printed, and then polled keyboard. But if you still pressed fire, the printing and erasing arrows wasted. Hand starts wildly shimmer, and inhibit the scroller. Another option used in ZX-FORMAT'e: if you pressed the fire arrow disappears, the screen scrolls, and then again queried the fire, and if it is still pressed, without printing arrow turn on the scrolling, but if No, the printing direction. Here we do not waste time on unnecessary printing / erasing, and it's pretty quickly. Ca. Ed. The author leads us to believe that it is impossible to implement full-screen scrolling, fit into the trap. But in some cases it is quite perhaps by reducing the number of bytes sent. Consider two such case. 1. Two top of the screen occupied by service information (title of the article and etc.), and the text occupies the remaining 22 line. Between lines of text on gap in 2 pixel (ie each symbol height is 6 pixels). Calculate how many bytes must send the procedure scrolling shear text on one familiarity up or down. Should be moved to 21 lines of text, ie 21 * 32 * 6 = 4032 bytes, plus the attributes: 21 * 32 = 672 bytes. Total 4704 bytes. A fragment program that performs forwarding 16 byte, looks like this: LD SP, the source address POP AF POP BC POP DE POP HL EXX EX AF, AF ' POP AF POP BC POP DE POP HL LD SP, the destination address 16 PUSH HL PUSH DE PUSH BC PUSH AF EXX EX AF, AF ' PUSH HL PUSH DE PUSH BC PUSH AF The length of a fragment of 26 bytes, the performance of 204 bar. Calculate how many ticks leave to perform the procedure shifts: 4704/16 = 294, 294 * 204 = 59976 cycles, ie still have enough time to print appeared above or below the new row text and on the procedure call playback music. How much memory space will occupy this procedure is the shift? 294 * 26 = 7644 bytes. But since the shift should be executed and up and down, double the value. Obtain 15,288 bytes. If there is 128K of memory is convenient to single out any bank (16384 bytes) and placed in its procedures shift. The disadvantage of this method is height limitation of text characters - not more than 6 pixels. This immediately makes it impossible to output graphics and pseudo-graphic, and font have to edit. 2. Two top of the screen occupied by service information (title of the article and etc.), and the text occupies the remaining 22 line. But each line of text takes the width is not 32 bytes, and 20 (ie in line fit 20 characters 8x8, or 26 characters 6x8, 4x8, or 40 characters). Again calculate the amount of bandwidth byte: 21 * 20 * 8 = 3360, plus the attributes: 21 * 20 = 420 bytes. Total 3780 bytes. Fragment program to forward 20 bytes, as follows: LD SP, the source address POP AF POP BC POP DE POP HL EXX EX AF, AF ' POP AF POP BC POP DE POP HL POP IX POP IY LD SP, the destination address 20 PUSH IY PUSH IX PUSH HL PUSH DE PUSH BC PUSH AF EXX EX AF, AF ' PUSH HL PUSH DE PUSH BC PUSH AF The length of a fragment of 34 bytes, the performance of 262 bar. To perform the entire procedure will take a shift 3780/20 * 262 = 49,518 cycles, and in memory it will take to 3780/20 * 34 = 6426 bytes (respectively, the two procedures for shift up and down, will occupy 12,852 bytes). The advantage of this method - is not limited to the height of characters, ie can output and graphics, and pseudographics. You can use, and two top of the screen - time to process them enough (the shift will take 53,710 cycles). Can be done smooth per-pixel scrolling (though it will look good only if all text set the same attributes). Disadvantage - does not use the right and the left edge of the screen. While on the other hand, it may improve readability. You can increase the line width to 24 bytes (32 characters 6x8, shell-like ZXRevyu) did not greatly increase the time shift. At the same time will further postpone 21 * 4 * 8 = 672 bytes of graphics and 21 * 4 = 84 bytes attributes, only 756 bytes. Fragment for transfer of two bytes is as follows: LD HL, (source address) LD (destination address), HL and takes 6 bytes, and holds up to 32 tact (ie 16 cycles per byte). Then the time of the procedure will increase by 756 * * 16 = 12,096 cycles and the amount 49,518 12,096 = 61,614 cycles, and memory requirements increase by 756 / 2 * 6 = 2268 bytes. Overall length two procedures will be equal to 12 852 +2 * 2268 = 17,388 bytes. By the way, does not necessarily hold in memory of both procedures shift - up or down. You can store only one of them, For example, suppose that it will shift upward. When the user presses the button for the shift in the opposite direction - just change the address in this procedure. And so at each change of shift direction. *
Other articles:
Similar articles:
В этот день... 21 November