ZX Review #3-4
22 июля 1997 |
|
Forum - Dmitry Fyodorov: Print images with a mask with pixel precision. Algorithm for calculating the address coordinates to within a pixel.
(C) Denis Fedorov, Vladivostok. Bring to your attention individual, in my opinion, programs. The idea to write something sort of came after in one of the rooms of your remarkable journal was published by way of printing images with pixel accuracy without the use of analogues protseduy PLOT. That same idea is present in my version, but a little changed. Procedures for calculating the display address and HLDOWN - also derived from published your material. If a memory place pristine copy of the screen, based on the submitted program I can try to write how to restore the original image. Title: Printing pictures with the mask up to a pixel. Printing Method - RR, AND, OR. FORMAT OF THE TEMPLATE - 1 mask, 2-byte Figure 3-mask, a 4-figure ... The second line - 1.2; 3,4; .... Third, .... - .............. Total LY lines with a length byte LX each. CALCULATION OF THE LENGTH OF PATTERN - LX * LY * 2. PRINTING MADE DIRECTLY ONTO THE SCREEN. WARNING! If, for example, LY = 16, LX = 2, then the template will have a size 2 * 2 familiarity. This is because the unit izmereniniya LX - one byte, and LY - one line. To print was made in buffer should be added after the ABC lines: LD DE, STEP ADD HL, DE where STEP - module differences between the beginning of the real screen and beginning of the buffer to be used for printing. Check for collision with the boundaries of the screen is not implemented. 148. Special for INFORCOM by SatSoft. (F.D.) text: ORG 40000 - ANY OTHER ; PERMITTED ; VALUE LD A, (LX); PREPARATION LD (LENX +1), A; VARIABLES LD A, (LY); FOR WORK LD (LENY +1), A LD IX, (START) LD DE, (COORDS) LD A, D; DETERMINATION ; Positions AND 7 IN BYTE LD (SHIFT +1), A LD A, # BF; CALCULATION SCREEN SUB E; ADDRESSES WITH PRECISION LD C, A; UP LINES AND # 38 RLCA RLCA SRL D SRL D SRL D ADD A, D LD L, A LD A, C RRCA RRCA RRCA AND # 18 XOR C AND # F8 XOR C ADD A, # 40 ABC LD H, A LEN-Y LD B, 0; CYCLE COLUMN L3 PUSH BC PUSH HL LEN-X LD B, 0; LOOP LINES L2 PUSH BC LD C, (IX +0); Accepts the current INC IX; DATA PATTERN LD E, (IX +0) INC IX LD B, (IX +0) INC IX LD D, (IX +0) INC IX SHIFT LD A, 0; The shift OR A; ON LINE JR Z, CONT L1 AND A RR C RR B RR E RR D DEC A JR NZ, L1 CONT LD A, (HL) AND C OR E LD (HL), A INC HL LD A, (HL) AND B OR D LD (HL), A INC HL POP BC DJNZ L2 POP BC POP HL HLDOWN INC H; STAND HL LD A, H; ON LINE DOWN. AND 7 JR NZ, EDOWN LD A, L ADD A, 32 LD L, A JR C, EDOWN LD A, H SUB 8 LD H, A EDOWN DJNZ L3 RET LY DEFB 0 LX DEFB 0 START DEFW 0000 COORDS DEFB 0; Y-COORD DEFB 0; X-COORD END 2 My version does not include things such as finding the desired pattern according to its number in table or binding source Basic data for three reasons: 1.All is quite easy to exercise, looking at the article Mr. V. Bodrov - SCHEDULE YOUR COMPUTER "(ZX REVIEW 95 / 4, p. 15). 2.Samostoyatelno worked with procedure, changing it in various ways, the reader will better understand structure of the algorithm and be able to example, to implement checking conflict with the boundaries of a template screen. 3. I try to do as much as possible a simple program and modify it as needed. Here it is worth examining way to encode the initial images in the format used by my procedure. Let's say We have a ready-made image fold in size 8, and mask and the raster itself are in different parts of the screen. In this If we have to use the following methods: 148. ORG 41000; ANY OTHER ; VALUE MCOORD DEFW 0000 PCOORD DEFW 0000 YLEN DEFB 00 XLEN DEFB 00 MAIN LD A, (YLEN); length setting LD (YL +1), A; PRINTS LD A, (XLEN) LD (XL +1), A LD HL, (MCOORD); INSTALLATION LD (CRD +1), HL; PARAMETERS LD HL, START; FOR ENTRY LD (ADR +1), HL; MASKS CALL INPUT LD HL, (PCOORD); INSTALLATION LD (CRD +1), HL; PARAMETERS LD HL, START +1; FOR ENTRY LD (ADR +1), HL; RASTER CALL INPUT RET CRD LD DE, 0000 CALCULATION OF DISPLAY LD A, E; Nogo ADDRESSES AND # 18; By coordinates ADD A, # 40 LD H, A LD A, E AND 7 RRCA RRCA RRCA ADD A, D LD L, A ADR LD DE, 0000 INSTALLATION ADDRESS ; Result ; UNIT YL LD B, 00; COUNT Y-LENGTH YLOOP PUSH BC PUSH HL XL LD B, 0; COUNTER X-LONG XLOOP LD A, (HL) LD (DE), A INC DE INC DE INC HL DJNZ XLOOP POP BC POP HL DOWN INC H; DOWN HL LD A, H; per pixel DOWN AND 7 JR NZ, EDOWN LD A, L ADD A, 32 LD L, A JR C, EDOWN LD A, H SUB 8 LD H, A EDOWN DJNZ YLOOP RET END 2 In this case, START - start the resulting block, PCOORD - coordinates of the raster, MCOORD - then same, except for the mask. Magnitude M-and P-COORD, XLEN - are set in familiarity and YLEN - in pixels. In the process of creativity as says new ideas are born. So I have had such idea. I have tried to develop own algorithm for calculating the addresses of the coordinates with an accuracy to the pixel. That's what I got: 148. LD C,% 11100000 LD A, D AND 7 LD B, A; offset within SRL D; LINE SRL D SRL D RR E RR L RR E RR L RR E RR L LD A, L AND C OR D LD L, A; L - FORMED LD A, E AND C CTRL OR% 01000000 LD H, A; H - FORMED END 2 For their own purposes the algorithm uses registers A, BC, HL, DE. Terms standatnye: At the entrance - in DE koodinaty At the exit - HL - corresponding address. Working with three senior bats in the row labeled CTRL, you can get the address printed on the other memory page for ZX-SPECTRUM print buffer. And here's another idea. If you ever have to write something like: 148. XOR A LD (VAR), A LD B, 255 CALL ....... ............... LOOP LD A, (VAR) INC A LD (VAR), A DJNZ LOOP That such a device can be replaced at: LD B, 255 LOOP LD A, B XOR # FF LD (VAR), A CALL ....... ............... DJNZ LOOP 2 Where VAR - variable designed to CALL ...... .
Other articles:
Similar articles:
В этот день... 21 November