Speccy #05
30 апреля 1996

Programming - How to make a running stitch.

<b>Programming</b> - How to make a running stitch.
       PROGRAMMING


Vladimir Kuznetsov



 Every beginner
programmer wants to
make the running
line. But why
start? Could it have
someone to "pull"?



 The answer to the question is very simple:
appeal to those who have it
made myself! To me, many
been asked for help and
I decided to publish a few
specific examples. And so,
begin ...


      ORG # 8000

FONT EQU # 3D00; address of the beginning

                  ; Font

WBUF EQU # 7E00; address of the beginning

                  ; Buffer

SCROL1: LD A, 1

        RRCA

        LD (SCROL1 +1), A

        JR NC, SCROL5

 Trying to calculate the location of the font of a new letter 
... 

SCROL3: LD HL, TEXT

        LD A, (HL)

        INC HL

        SUB # 20

        JR NC, SCROL2

End of the text - the code is less than # 20


        LD HL, TEXT

        XOR A
SCROL2: LD (SCROL3 +1), HL

        LD DE, FONT

        LD L, A

        LD H, 0

        ADD HL, HL

        ADD HL, HL

        ADD HL, HL

        ADD HL, DE

Transfer the character to the work buffer


        LD B, 8

        LD DE, WBUF +32
SCROL4: PUSH BC

        LDI

        EX DE, HL

        LD BC, 32

        ADD HL, BC

        EX DE, HL

        POP BC

        DJNZ SCROL4

 Scroll the (shift) working
Buffer ...

SCROL5: LD HL, WBUF +263

        LD B, 132
SCROL6: RL (HL)

        DEC HL

        RL (HL)

        DEC HL

        DJNZ SCROL6

 If you use TASM3.2 and
you do not mind the memory (the procedure
increases in ob'eme 518
B), it can be written
as follows:

SCROL5: LD HL, WBUF +263

        DEFS 264, # CB, # 16, # 2B

 But the gain in time
amount to 1586 cycles! Increase
performance can be further to 264
tact:

SCROL5: LD HL, WBUF +263

        DEFS 132, # CB, # 16, # 2B

        DEFS # CB, # 16, # 2D

Next, we derive the buffer to the screen ...
This can be done the traditional
way:


        LD HL, WBUF

        LD DE, # 5000

        LD B, 8
SCROL7: PUSH BC

        PUSH DE

        LD BC, 32

        LDIR

        POP DE

        POP BC

        INC HL

        INC D

        DJNZ SCROL7

        RET

| GSkorost Hours: 5968 cycles.
But there are more cunning and
moreover, faster ways
output.
For example you can draw a conclusion
as follows:

        LD HL, WBUF

        LD DE, # 5000

        LD B, 8
SCROL7: PUSH BC

        PUSH DE

        DEFS 32, # ED, # A0

        POP DE

        POP BC

        INC HL

        INC D

        DJNZ SCROL7

        RET
Speed: 4,688 cycles.
A "revealing" cycle, you increase
output speed up to 4424 cycles!
But personally I like more
the copying of the stack:


        DI

        EXX

        PUSH HL

        LD (SAVESP +1), SP

        LD SP, WBUF

        POP AF

        POP HL

        POP DE

        POP BC

        EX AF, AF '

        EXX

        POP AF

        POP HL

        POP DE

        POP BC

        LD SP, # 5010

        PUSH BC

        PUSH DE

        PUSH HL

        PUSH AF

        EX AF, AF '

        EXX

        PUSH BC

        PUSH DE

        PUSH HL

        PUSH AF
 Then repeat this block, but
with the changes:

        LD SP, WBUF +16

        POP AF

        .....

        LD SP, # 5020

        PUSH BC

        .....

        LD SP, WBUF +33

        POP AF

        .....

        LD SP, # 5110

        PUSH BC

        .....

        LD SP, WBUF +49

        POP AF

        .....

        LD SP, # 5120

        PUSH BC

        .....

        .....

        .....

        LD SP, # 5720

        PUSH BC

        .....
SAVESP: LD SP, 0

        POP HL

        EXX

        EI

        RET
Noticed an algorithm for computing?
If not, then use my
applets:

10 FOR I = 0 TO 7
20 PRINT I * 33, I * 33 16
30 NEXT I

The obtained numbers are shifts in the working buffer.
Screen addresses are calculated as follows:

10 FOR I = 0 TO 7
20 PRINT I * 256 +16, I * 256 32
30 NEXT I

Note: When working with a stack
interruption should be banned
(Command DI) and saved register pair HL '(alternative).
Operating speed: 3520 cycles!


             *





Other articles:

authoring program - Bestseller from Star - Player tunes.

Authoring - schema Sound Drive V1.02 and Covox.

Igroskop - On the game: Biff, Crime Santa Claus.

Igroskop - On the game: Mugsy.

Igroskop - All about games: Star Heritage.

Muzoboz - Table of results of the 1 st round. The competition continues ...

Multrolik - Multrolik "Walk".

Novella - Novella "UFO - Enemy Unknown" Part 2.1.

Novella - Novella "UFO - Enemy Unknown" Part 2.2.

From the Editor - On changes in the magazine and its distribution.

Programming - How to make a running stitch.

Programming - The main unit ZX-Spectrum.

Advertising - Advertising and announcements.

Tusovka - Greetings and congratulations.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Warm greetings - Visiting magazine Sinclair User - Sir Clive Sinclair. Conversation with K. Sinclair Spectrum on and around it.
Opinion - Phantom Lord tells what "real music".

В этот день...   21 November