ZX Review #3-4
22 июля 1997 |
|
reader-reader - I. Roshchin. Display driver for the computer, "Pentagon-128.
The Reader - Reader (C) Ivan Roshchin, Moscow, 1997. Screen drivers for your computer "The Pentagon-128. Bring to your attention screen driver - a small procedure in assembly (211 bytes) caused an interrupt 2-nd kind. Using this driver, very easy to write a program realizing the full screen MULTICOLOR - effect (each row together with a border drawn his color). In this case, all the problems associated with different timing for different types of computers, are solved by simply replacing driver (the proposed option designed to "Pentagon-128). Here is a sample program that uses the driver for the implementation of simple effect - the screen move three colored bands. Pay special attention to the fact as programmed by this effect, as well as the length of the program - only 217 bytes (without driver). 140. ORG # 6000 ; MAIN PROGRAM: N EQU 37; vertical dimension in the familiarity LD HL, # 5800; INSTALLATION LD DE, # 5801; ATTRIBUTES LD BC, # 2FF; (NOT REQUIRED) LD (HL), L LDIR ; Draw the grid (necessary for MULTICOLOR'A): LD HL, # 4000 LP1 XOR A BIT 0, H JR NZ, NE_FF CPL NE_FF LD (HL), A INC HL LD A, H CP # 58 JR NZ, LP1 ; INITIALIZING THE EFFECT: CALL E_INIT ; TO CAUSE THE DRIVER TO THE INTERRUPTION, ; SHAPING table, for example, C ADDRESSES ; # FEFE: LD HL, # FE00 LD B, 0 LOOPT LD (HL), # 62 INC HL DJNZ LOOPT LD (HL), # 62 LD A, # FE LD I, A IM 2 LOOP_M HALT CALL EFFECT IN A, (254), something pressed? CPL AND% 00011111 JR Z, LOOP_M; IF NO IM 1 RET; Exit ;--------------------------------------; Obtain the effect of "Color bars": ; Entry point for initialization: E_INIT LD HL, DATA +40 LD DE, DATA +41 LD BC, 300 LD (HL), 0 LDIR LD HL, DATA LD DE, DATA +1 LD BC, 39 LD (HL), 7 LDIR RET ; Entry point for CALL EVERY INTERRUPT: EFFECT LD HL, (A_BEG) LD B, 1 LD A, (A_WAY) CALL MOVE LD (A_WAY), A LD (A_BEG), HL LD HL, (B_BEG) LD B, 2 LD A, (B_WAY) CALL MOVE CALL MOVE LD (B_WAY), A LD (B_BEG), HL LD HL, (C_BEG) LD B, 4 LD A, (C_WAY) CALL MOVE CALL MOVE CALL MOVE LD (C_WAY), A LD (C_BEG), HL RET ; PROCEDURE MOVE Moves the band: MOVE AND A JR NZ, MOVE_D ; Upward shift: LD A, H OR L JR Z, MOVE_D MOVE_UP DEC HL PUSH HL LD DE, DATA ADD HL, DE LD A, (HL) OR B LD (HL), A LD DE, 40 ADD HL, DE LD A, (HL) XOR B LD (HL), A POP HL XOR A RET ; Shift down: MOVE_D LD DE ,297-40 AND A SBC HL, DE PUSH AF ADD HL, DE POP AF JR Z, MOVE_UP PUSH HL LD DE, DATA ADD HL, DE LD A, (HL) XOR B LD (HL), A LD DE, 40 ADD HL, DE LD A, (HL) OR B LD (HL), A POP HL INC HL LD A, 1 RET A_BEG DW 0; COORDINATES B_BEG DW 0; BANDS C_BEG DW 0 A_WAY DB 0; DIRECTION B_WAY DB 0; TRAFFIC C_WAY DB 0 ;-------------------------------------- ORG # 6262 ;======================================= ; Display driver: DI PUSH AF; Stores the value of PUSH BC; USED PUSH DE; REGISTERS PUSH HL PUSH IX PUSH IY LD (M122 +1), SP ; Delay while the beam did not get to the top line: LD D, H; WAIT LD E, L; WAIT LD BC, 171; WAIT LDIR; WAIT LD IX, DATA +1; ADDRESS TABLE LD HL, # 5720; CURRENT ADDRESS ATTRIBUTES LD BC, 3; B is always 0, C-COUNTER. LD A, (DATA); COLOR FIRST STRING LD YL, A; REMEMBER COLOR LD DE, # 20 ; BEAM AT THE BEGINNING OF NEXT LINE: M3 LD SP, HL SBC HL, DE LD A, YL OUT (254), A LD A, (IX +1) LD YL, A AND A RLCA RLCA RLCA OR (IX) LD D, A LD A, H CP # 58 JR C, NO_ATR CP # 5B JR NC, NO_ATR2 And half the line already drawn, , And attributes can be changed. LD E, D PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE ; 16 bytes COMPLETE BEAM IN THE BEGINNING ; Following lines: LD A, D AND 7 OUT (254), A LD A, C ; I still ATTRIBUTES: LD C, # 20; BC = # 20 ADD HL, BC LD SP, HL PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE LD C, A INC XL LD A, 0; WAIT NEXT_L LD DE, # 10 INC IX DEC C JR NZ, M10 LD C, 4 ADD HL, DE JR M3 M10 SBC HL, DE JP M3 ; Get here, if the current line ; Belong entirely to the curb: NO_ATR LD A, 0; WAIT LD A, 0; WAIT ; CHECK ON IMPORTANCE HL: Is it time to ; EXIT INTERRUPT? NO_ATR2 LD DE, # 5720 + ((N-1) * # 20) AND A SBC HL, DE JR NC, M122 ADD HL, DE LD DE, (0); WAIT LD DE, (0); WAIT NOP; WAIT LD A, (IX) OUT (254), A LD A, (IX); WAIT LD A, (IX); WAIT LD A, (IX); WAIT LD A, (IX); WAIT INC DE; WAIT LD DE, # 20 ADD HL, DE INC XL JR NEXT_L ; OUT OF INTERRUPTION: M122 LD SP, 0 POP IY; RESTORES POP IX; register value POP HL POP DE POP BC XOR A OUT (254), A POP AF EI RET ;======================================= ORG # 7001 ;--------------------------------------; ARRAY OF DATA FOR MULTICOLOR'A: DATA DS 320 ;-------------------------------------- 2 Some remarks on the Program: - You can see nedokumenti an orthonormal click INC XL. Such its designation is perceived assembler ZX ASM 3.0. But in Other assemblers, as well as STS debugger is denoted as INC LX (code DD 2C). - Lines of code that are marked commentary "WAIT", need only for the delay. - Address of the beginning of the array DATA necessarily necessarily must be odd. When working with a driver programmer can assume that the video memory - an array of data located at DATA and occupies as many bytes as MULTICOLOR'a lines he wants to see on the screen. The value of each bytes in the array - a number between 0 to 7, indicating the color of the corresponding row in the screen. If array does not change, MULTICOLOR-effect will be fixed. That he was moving, it is necessary every 1 / 50 seconds (or less) modify data in the array. Vertical size MULTICOLOR'a in familiarity is determined by the variable N. This value can not be arbitrary, but only within the boundaries of 1 .. 7 and 31 .. 37 inclusive. The point that the condition of the end of the driver is only checked if the current row is entirely true to the curb (or at the top or the bottom of the screen). Even if you "Pentagon128", a driver can not work very good (band blink, and so etc.). The fact that even the computers of one type of situation INT'a regarding staffing clock may vary. In this case, you can try adjust the value of the delay in driver. To do this, find the commands marked "WAIT", at the beginning of the driver. You will see a snippet: 147. LD D, H; WAIT LD E, L; WAIT LD BC, 171; WAIT LDIR; WAIT 2 Achieve the best quality Images can be loaded by changing the BC number, or adding NOP'y (or a combination of both). Monitor the result of the changes it is convenient, if Every time you start the program appears on the screen a still picture with colored lines. To do this, remove the line CALL E_INIT and CALL EFFECT, and instead of a string DATA DS 320 to put the following lines: DATA DB 7,0,4,0,4,0,4,0 DB 4,0,4,0,4,0,4,0 DB 4,0,4,0,4,0,4,0 DB 4,0,4,0,4,0,4,0 DB 4,0,4,0,4,0,4,0 DB 4,0,4,0,4,0,4,0 DB 4,0,4,0,4,0,4,0 DB 4,0,4,0,4,0,4,7 DB 0,1,2,3,4,5,6,7 DB 4,0,4,0,4,0,4,0 ....................... When using the driver their programs better synchronize with the interrupt command HALT. This is due to the fact that at the time of interruption of the processor is busy executing a long command, the driver later, will begin its work, and the picture can be displaced. If you do decide to program MULTICOLOR-effects without using a driver, you have to carefully calculate, for how many cycles performed that a portion of the program. So as constantly looking in the directory of information about the duration of the execution of one or the other team may be uncomfortable, I recommend to use for this purpose program "HELP_Z80" - an electronic directory of commands Microprocessor Z80, which You can download any assembler debugger instead of STS (or along with it) and call at the right moment by pressing a couple buttons. P.S. I propose to announce the best graphic effect effect created by driver. *
Other articles:
Similar articles:
В этот день... 21 November