Miracle #03
16 июля 1999

kodit Who's there? - Quick graphics: a few recipes from Zetter'a (print sprites, update the screen).

<b>kodit Who's there?</b> - Quick graphics: a few recipes from Zetter'a (print sprites, update the screen).
    (C) ROM corp. / VVG, 1997

    ----------------------

       Fast graphics.


    I have long wanted to talk about
chart SPECCY, and not just about graphics, and a rapid
schedule, which is used in
most music DEMO,
as well as many brand
toys. In this article I want to
offer a somewhat different approach to these issues.

1: Application of the method table
Programming for printing
sprites.

2: Use a stack to print
clear the screen. By cleaning
here defined as any action leading to refreshment
screen memory, including
filling the screen sprites
any format, create all sorts of reticula, etc.


    So now more about
all of this. I will not give
here all the listings of which
will be discussed, since all
it's pretty transparent, but
key points will be discussed in detail.


      1.PECHAT Sprite


    All attempts to create a quick procedure for printing a 
sprite classical method is doomed

to fail because of monstrous
the slow work of the calculator
address on the screen. What to do? Comes to the aid table 
method of programming. Suppose that somewhere in the memory is 
a table of addresses of all lines screen, then how to print

sprite looks like this:


    PRINT_SPRITE


          LD H, 0; HL PUT Y coordinates

          LD L, YCOORD; OUR Sprite

                          , (In pixels)

          ADD HL, HL; Multiply it by 2

                          , AS E-Mail address

                          2 bytes, then to multiply

                          ; By 2 to give

                          ; OFFSET from the top

                          ; TABLES

          LD DE, DATA; In DE-TOP TABLES

                          S address

          ADD HL, DE; ADD

          LD (STACK), SP; SAVE STACK

                          ; In VARIABLE

          LD SP, HL; rearrange the stack on

                          , Address table

          LD A, LINES; In A-HEIGHT Sprite

                          ; In pixels


    ; PREPARATORY operation is over,

    ; NOW BEGINS own stamp


    LOOP LD BC, XCOORD; In BC-X coordinate

                          ; Sprite from the left edge

                          ; SCREEN IN familiarity

          POP DE; HERE this team and

                          ; Select address FROM

                          ; TABLES

          EX DE, HL; Tracing X

          ADD HL, BC; COORDINATES

          EX DE, HL;

          LDI; transfer LINE Sprite

          LDI; IN SCREEN TEAM

                          ; LDI FASTER THAN LDIR

          ... ; TO 5 cycles per byte

                          ; Number of teams

          LDI; LDI equal to the width

                          , Sprite

          DEC A; DECREASE COUNTER

          JR NZ, LOOP; LINES AND TRANSITION

          LD SP, (STACK); RECOVERY STACK

          RET; RETURN


    Now let's see what
us a cost: 384 bytes
plates and a little LDI, but
but: print independent of
familiarity and segments of the screen,
has the highest rate:
calculation of addresses (or, more sampling) of 39 cycles.
NOTE: if X is 0,
You can delete rows from the change in X (which can be used
with scroll-e of the screen).

Print takes the following form:


          POP DE

          LDI

          LDI


          ...


          LDI

          LDI


    You can go even further and
open cycle in A, s'ekonomiv
17 more strokes on the line. In this
option to spend 16 bytes
cycles and plus 10 (POP DE) divided by the width of the sprite. 
In total, average about 20 cycles per byte.



    You may ask: how
the seal up to a horizontal pixels? The answer is:
can be up to the pixel, but again with
a little trick. We will
print sprite up
pixel familiarity. You
say: what nonsense! So
cause there is! The idea is to
creation of eight phases of our
sprite with a shift to one
pixel and print each of the
them up to familiarity.
The algorithm is as follows: take
X, in pixels, divided by 8.
Private is the X coordinate in the
familiarity, and the remainder is the number of phases of our 
sprite with a corresponding shift, and further just print 
already familiar to us protsedurkoy



    Now about how to create
plate addresses. I will not
result in listing, it is not complicated, and will describe the 
algorithm: take any procedure for calculating the address in 
pixels (I used procedure from the elementary diagrams). Next, a 
loop from 0 to 191. Compute the address and records

table, we increase the pointer
current element by 2 and repeat all over again. By the way,
the same plate can be used for any transactions
screen


      2.OSVEZHENIE SCREEN AND reticula

To ensure the smooth graphics to refresh the screen
50 times per second. For this purpose, a nice way stack 
printing method. He There are many varieties.

Consider some of them.


    1: Cleaning the Screen

          LD A, 0 (XOR A); Zeroing BATTERY

          LD H, A; FILLS HL BATTERY

          LD L, A; (although you can use

                          ; ANY Distinctive PAIR)

          PUSH HL; REPEAT AS MANY PUSH

          ... ; Times as you want

          PUSH HL; for complete cleaning

Instead of 0 you can send any
another byte and receive all sorts of stripes on the screen.


      3.SETOCHKA 8x8


    From the previous paragraph can easily obtain a variety of
meshes in full screen, which
so love to use in demah. The idea is: take
spraytik 8x8 pixels, and the late start is displayed on the 
screen, line by line. There are several ways to implement this 
effect, we consider one of them. Let there is some spraytik 
8x8pix, our task is to fill their screen.



          LD IX, SPRITE; pointer to sprite

          LD (STACK), SP; SAVE SP

          LD SP, 22528; rearrange SP at the end DISPLAY

          LD H, (IX +7); HL FILL IN THE LAST

          LD L, H; BYTES Sprite

          PUSH HL; PUSH HL REPEATS 128

          ... ;> TIME TO FILL ALL

          PUSH HL; / BOTTOM LINE SCREEN

          LD H, (IX +6); FILL HL penultimate

          LD L, H; BYTES

          PUSH HL;

          ... ;> PUSH HL * 128

          PUSH HL; /

                          ; REPEAT ALL FOR IX +5, IX +4,

          ... ; IX +3, IX +2, IX +1

          LD H, (IX +0); And FOR IX +0

          LD L, H;

          PUSH HL;

          ... ;

          PUSH HL;


    ; Lower segment ZAPOLNEN.TEPER NEED

    ; TO REPEAT THE ENTIRE TEXT OF LD H, (IX +7) TO

    ; END 2 more times TO FILL THE REST

    ; SEGMENTS OF THE SCREEN


          LD SP, (STACK); LATE TO RESTORE THE STACK

          RET; AND RETURN TO RET


    Here, the fixed mesh
on the screen. And how to make it
move? Very simple: we must
create a block sprites containing motion phase of mesh
screen. In this case (8x8)
this is normal font,
created in ARTSTUDIO or
another editor. Algorithm
motion to file sprites
(Fonts) is very similar to the beginning of the routine 
character 8x8:



          LD A, NUM; NUM-IS CURRENT ISSUE

                          , Sprite

          LD XH, 0; DOWNLOADED THROUGH IX suboxide
          LD XL, A; MENTIROVANNYE TEAMS

                          ; To expedite the process

          ADD IX, IX; MULTIPLICATION BY 8

          ADD IX, IX;

          ADD IX, IX;

          LD DE, SPRITES; Tracing the start address

          ADD IX, DE; FILE Sprite

Received in IX address is used in the previous procedure.


    Now I would like to say
on how to get the file
phases of movement. The first and most obvious, but the most
time-consuming it is to draw them
(Phase) in a photo editor. And the second - is to generate it 
during the installation program. Consider the idea of 
installation details. In the steepest option is

will look like this: there
some two-dimensional function (although
The same sine wave), the program
computes the schedule and records
him to sign. Next, the program performs the conversion
plate mod 8, and simply leaves instead of the full
coordinates of the remainder of the division
it to 8. Next step: the formation of a set of sprite
(Font): take the initial
sprite rotates (!) X times
right, Y down again and recorded
on a regular place in the table.
You can create multiple functions and multiple sets
sprites, and can be combined
them on the OR or other logical operations for
reticula with several plans
motion (for example: two grids: one moves up and
other diagonally down). Here
and is ready to mesh, but if you
try to start it, even
through HALT then you have nothing
good would come (although the whole
Printing takes about half
INTa (30000 cycles) because of the intersection of the ULA and 
the fill stack. Helps out a second screen (128-x models). His 
incorporation takes place almost instantaneously, and this 
provides the desired effect. 


    LOOP LD BC, 32765; CONNECT THE SECOND PAGE

          LD A, 23; screen when you turn

          OUT (C), A; FIRST SCREEN

          CALL PRINT; PRINT

          HALT; TIMING

          LD BC, 32765; CONNECT THE FIRST PAGE

          LD A, 21 +8 Vågå screen when you turn

          OUT (C), A; second screen

          CALL PRINT; PRINT

          HALT; TIMING

          JR LOOP;

That's two screen technology.
On this matter can be hung
music, sprites, and also that
anything, but we need to monitor
execution time so that it
not surpassed 1 INT. A couple more
Note: If used
Sprites, the address sign
necessary to generate a
address of 49152 rather than 16384, for
IM2 using vector
interrupts must be below
49152, and if higher, then it should be duplicated at all
used pages. Music is also desirable to be
is below 49152, and if
You want to put it on
page, you have to memorize the number of port 32765 and not
switch screens for the time
playing music.


    2: mesh 16x16


          LD IX, SPRITE; pointer to sprite

          LD (STACK), SP; SAVE SP

          LD SP, 22528; rearrange SP at the end DISPLAY

          LD B, (IX +31); In BC Get the latest and

          LD C, (IX +30); penultimate BYTES Sprite

          LD D, (IX +15); AV DE two bytes FROM THE MIDDLE

          LD E, (IX +14); Sprite: 15 AND 16

          PUSH BC * 16 * 4; draw LOWER AND MIDDLE

          PUSH DE * 16 /; Sprite LINES IN ONE

                          ; Third of the screen

          LD B, (IX +29); REUPLOAD Distinctive

          LD C, (IX +28); couples Sweep PER

          LD D, (IX +13); LINE UP

          LD E, (IX +12);

          PUSH BC * 16 * 4; draw another 2 LINES

          PUSH DE * 16 /;

          ... ; BE continues to shift

                          ; UP AND DRAW

                          ; ON TWO LINES

          LD B, (IX +17); and, finally, Loads

          LD C, (IX +16); Distinctive PAIR OF BYTES

          LD D, (IX +1); FROM THE MIDDLE AND FROM THE BEGINNING

          LD E, (IX +0); Sprite

          PUSH BC * 16 * 4;

          PUSH DE * 16 /;


    , ALL, one-third draw, It now remains

    ; REPEAT IT ALL STILL ON THE TEAM 2 times

    ; LD B, (IX +31) to finish.


          LD SP, (STACK)

          RET


    By the time this mesh
is almost the same
as the previous one is 30000 cycles. All of the above about the 
movement and the establishment phase applies to this species 
effect, but creation function of the movement, it is necessary 
to take the remainder after dividing by 16, not 8, as in 
previous case. I must say that it's pretty versatile way to 
print on the screen. If you understand the principle of the 
above effects, then you will easily modify them to other 
dimensions: 3x3, 4x4, 2x4, etc.


In conclusion I would like to receive
feedback on this material, and
also offers help and
cooperation on all issues related to programming ASSEMBLERe.

My address is:



       394016, Voronezh

       UL.TULSKAYA, 16

         Nasonova RA

         (ROM CORP.)






Other articles:

From the Editor - Preface: For what purpose we are releasing the magazine?

From the Editor - shell: a description of a new obolchka to the magazine.

From the Editor - a letter to the journal: Dr.Sioux / Phantom Family, Fistsoft, Mr.Z / HardWave, Kurov N., Eagle / Computer Ratz Group, Rom Corp / Virtual Vision Group.

From the Editor - in this issue: Content.

Project of the Year - presentation version of the game of Robo KT-soft/ETC.

Project of the Year - a presentation of the game from a group of Spark: Townships.

Project of the Year - a presentation of the game "12 secret book."

Project of the Year - a few words about the upcoming game, Chip & Dale.

Project of the Year - an amazing story to the game "Navigator".

Project of the Year - World of Darkness: a description of a new real-time strategy.

Rattles - Fresh or not, but savory cheats.

Rattles - Crematorium: STALKER game - a description of all items.

Rattles - Crematorium: Country Myths - Tips specials.

SWAP'A Basics - information for beginners as well as a few sly misrepresent, which You can crank the mail.

kodit Who's there? - Quick graphics: a few recipes from Zetter'a (print sprites, update the screen).

kodit Who's there? - Packer'y and Depacker'y: the truth about the packer or the ranting of Sir Kot'a.

kodit Who's there? - Working with MS-DOS: All about the mod files - a full description of the structure of mod-file, as well as a description of all effects.

kodit Who's there? - Working with MS-DOS: Ms-Dos floppy disk - a description of the structure of Ms-Dos disk.

kodit Who's there? - Chanky flame: a description of the algorithm chankovogo fire.

kodit Who's there? - Attribute bump mapping: bump mapping for those who have not entered.

kodit Who's there? - Guru meditates: optimization programs for execution time and size.

kodit Who's there? - An approximate search for a given sequence of bytes!

kodit Who's there? - Fast 42 print: fast how to print 42 characters in a row.

Party zone - KidSoft'98: a report from the Voronezh Festival of Computer Art.

Party zone - EarthQuake'99: a report from the Chelyabinsk festival of computer art.

Myself - 128 colors on the Spectrum: Revised scheme of up to 128 colors from the Donetsk group Spark.

Myself - Kettle: Connection General Sound to Profi through the system connector.

Myself - Uninterruptible Power Supplies: UPS-information technology.

Myself - General Sound Filter: story of the new gadgets to the GS.

Myself - Modems: Diagrams, charts! Scheme G. Shepeleva Kondratiev and M. Hayes modem connection.

Myself - Modems: Command - Command terminal.

Myself - Modems: Total modemizatsiya - a call to connect momedov.

System Software - FastCopy 3.0: a complete description of tricked out turbo-copyist.

System Software - Pro Tracker bugs! Several glyuchkov in ProTracker'ah.

System Software - Pro Tracker 3.4 final presentation remix Pro Tracker from Samara.

News - Chelyabinsk: X-Raizor returned to the Spectrum, Wocen wrote boot, Blade otdahyet, Steelzer joined Triumph, Crite completed the alpha version of the "World of Darkness", Bytic bought GS, Edison makes the site, Ironman wants to buy Spectrum.

News - Omsk: full staff and are expected products from a group of U98.

News - Kaliningrad: The loud death or Spectrum quiet life in Kaliningrad.

Techno-nature - Electronic music: Dj.Ironman talks about technology (Part 1).

Techno-nature - Electronic music: Dj.Ironman talks about technology (part 2).

Techno-nature - Internet music-sites: a lot of addresses where you can learn new about electronic music.

Techno-nature - Addiction XX: bike from Dj.Ironman 'as well.

a quarter to four - the story of everyday life from the X-Raizor'a.

Room with laughter - smells in and around: funny story from the magazine PTUCH.

Room with laughter - Perdmen: damning story of all of the same PTYuCh'a.

Room with laughter - Wick: nekolko scenarios from the film chronicles the wick.

Room with laughter - Halo: The end of the story published in the second room.

Proclamation - advertisements and announcements about finding friends on the Spectrum.

Proclamation - advertisements and announcements about finding friends on the Spectrum.


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

Similar articles:
All life is a game - Novella to the game "Operation RR"
world of sound Spectrum - Annex 1, 2: Listings sound effects SUPER SOUND'a, tips assembler.
Projects - a project of hardware-software complex is to integrate the Spectrum Internet: NetSpec.
Presentation - the story of Cheboksary Phantom FAMILY.
AY-VS / M - The output of the connection AY 3-8910 or YM2149F to ATM-TURBO2.

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