ethidium - The calculation of addresses in the file attributes. Program scrolling specified window 1 pixel to the right. Cleanup of the specified window. Procedure display images from the buffer.

ZX Review #5-6
(C) D. Konovalov, Tver


   1. Very small (15 bytes,
57 cycles) procedure for calculating the addresses in the file 
attributes. Y coordinate in register E, X in register D. 140.


        LD A, E

        RRCA

        RRCA

        RRCA

        LD L, A

        AND 31

        OR 88

        LD H, A

        LD A, L

        AND 252

        OR D

        LD L, A
2

   2. But the program scrolls the specified window by 1 pixel
vpravo.140.


        ORG 40000


        LD A, (HGT)

        LD C, A

        LD HL, (Y)
START PUSH HL

        LD A, L

        AND 7

        RRCA

        RRCA

        RRCA

        ADD A, H

        LD H, L

        LD L, A

        LD A, H

        AND # 18

        OR # 40

        LD H, A

        LD B, 8
ST PUSH HL

        PUSH BC

        LD A, (LEN)

        LD B, A

        AND A
ST1 RR (HL)

        INC HL

        DJNZ ST1

        POP BC

        POP HL

        INC H

        DJNZ ST

        POP HL

        INC L

        DEC C

        RET Z

        JR START

Y DEFB 0
X DEFB 0
LEN DEFB 10; width of the window
HGT DEFB 10; window height
2

   The program does not check out whether the window off the 
screen. To scroll place on 4

pixel, it is necessary to make the following
change: AND A replaced by XOR
A, RR (HL) is replaced by RRD.


   3. This program is designed to clean the specified window
screen. She does this as follows: one pixel line is scrolled to 
the right, the other left, then right again, etc.

140.

        ORG 40000


        LD A, (HGT)

        LD C, A

        LD HL, (Y)
START PUSH HL

        LD A, L

        RRCA

        RRCA

        RRCA

        ADD A, H

        LD H, L

        LD L, A

        LD A, H

        AND # 18

        OR # 40

        LD H, A

        LD B, 4
ST PUSH BC

        LD A, (LEN)

        LD B, A

        AND A
ST1 RR (HL)

        INC HL

        DJNZ ST1

        AND A

        LD A, (LEN)

        LD B, A

        DEC HL

        INC H
ST2 RL (HL)

        DEC HL

        DJNZ ST2

        INC HL

        POP BC

        INC H

        DJNZ ST

        POP HL

        INC L

        DEC C

        RET Z

        JR START

Y DEFB 0
X DEFB 0
LEN DEFB 10
HGT DEFB 10
2

   This procedure is not clear
All the window - it makes only one
passage. For a complete window cleaning
it must be cyclically called from
another program.


   4. And the latter procedure.
It displays a picture of
buffer at 41,000. Picture like "leaves" from the left
edge of the screen to the right, and then being transferred 
attributes. 140.


        ORG 40000


        LD B, 64
ST LD C, 192

        LD DE, 16384

        LD HL, 41000
RUN PUSH BC

        LD C, 2

        XOR A
WORK LD B, 32
LOOP RRD

        INC HL

        DJNZ LOOP

        EX DE, HL

        DEC C

        JR NZ, WORK

        POP BC

        OR A

        DEC C

        JR NZ, RUN

        DJNZ ST

        LD DE, 22528

        LD HL, 47144

        LD BC, 768

        LDIR

        RET
2

   About me: I am 15 years old, fascinated
adventyurnymi and strategic
games.

   Daniel also asked to publish his address for fans
adventyur: 170004, Tver-4,
ul.Stroiteley, 8 / 2,
kv.121, Konovalov, Daniel.


   Ca. Ed.: And once again be reminded of optimization 
software. At the end of program 2 and 3 is a sequence of 
commands: 


        RET Z

        JR START


   But it would be better to replace it with:


        JR NZ, START

        RET


   What's the difference? And in that second
version is faster, because
first option the team holds RET Z
number of times and the whole cycle, and in
the second - once. Of course, there is no
plays a special role, but imagine
that the loop is not 10, but, say,
10000 times. Here is the 5 cycles are translated into
big waste of time.


            *