SoundTrack: BY 5EC70R/SERIOUS S.G.4 DEJAVU
__________________________________________
(C) M.M.A / SPEED CO. aka UnBELIEVER / XTM
__________________________________________
THE OPTIMIZATION
In the first lines of this short article
I would like to mention the fact that I do not consider
a steep coder'om. Yes,
S once were and I have Akad S zyvy to master program
S formation and the achievement of
) S SATISFACTION heights and INM S SULT - hit those far
and S times. However, total
Lack perseverance and RS
S free time soon
led to recognition of the fact
inability to become a real, real
coder. Since then, securing its status as a man who knows asm
Z80, I began to study more things for the benefit of the
approximate favorite SPECCY. Of course, periodically
have to be shipped ALASM for writing
loader'ov, simple protsedurok for the conversion / processing
graphics and sound with pC, but it not at all what I mean by
coder. That is why, in our ENLIGHT'ovskoy
work - NOUMENON - none of my
bits in the code.
Nevertheless, the above reasons
does not prevent me to follow closely the current state of
affairs in coding'e and programming. That is why, having found
in the annex to the seventh issue of the new ZX-FORMAT
assembler STORM, I could not resist tried this product at work.
STORM can be said about a lot of good words. This is
absolutely evil and savage environment. In my subjective
opinion, _nastoyaschie_ effects can not be written in squalid
GENS / ZEUS / MASM, and others. Good effect requires a
comfortable writing with a STORM frame-scrolling of the text is
comfortable environment. However, to each his own ...
So, I sit in this STORM'e and I think
Why would such a nakodit. Watching the rapid scrolling screen,
I decided to try to write something like that. Given given in
the first paragraph of the facts, nor that more than scrolling
the entire screen up with the cleaning of the bottom line, I
did not enough. Write the first option, which
Finally, normal work, I felt a mad desire prooptimizirovat and
accelerate its program. That is what
devoted to the following written bytes of text.
So, our task is to
how to write a procedure that shifts
Full screen up one pixel row. Further, this procedure should be
expedited. There you have it!
Because you, my dear readers, certainly not RST # 7,
EXPLODER or FUX, will not very cool to put a question on the
shift of screen, for example, during one frame.
We are quite satisfied with two or three frames on the shift
that is about 140-210 thousand cycles. It
on this, I suggest that for the process
Copy one line does not use
stackable design POP all: LD SP, nn: PUSH
all, difficult to understand for beginners. Let us confine
ourselves to simple and clear commands to copy blocks - LDIR,
LDDR, LDI, LDD.
To start the optimization, it is necessary
jot down the first version of the procedure, which presented
only two claims - The procedure should work correctly and
be understandable. In order not to reinvent the wheel, below I
present a similar procedure, which is taken from the previous
issue DEJA VU. My credit is only in the calling
program.
;----------------------------------------; SIMPLE LDIR SCROLL
CODED BY MMA ; USING SUBROUTEN BY Serzh Soft
;----------------------------------------
ORG # 8000
LD HL, # C000, DE, # 4000, BC, 6144
LDIR; The transfer to the screen
; Loaded at address # C000
; Pictures
;----------------------------------------; 192 times call the
procedure shifts ; The screen up one line
;----------------------------------------
LD B, 192
LOO PUSH BC
DI
CALL PSRL_UP
EI: HALT; can be removed in order to obtain
; Of the uniform, "damn it
; Givaniya "lines.
POP BC
DJNZ LOO
EI
RET
;----------------------------------------; Shift upward by one
pixel (38 < = 91) ;----------------------------------------
PSRL_UP
LD DE, # 4000; 10
;-LP_PSU1 LD H, D; 4
LD L, E; 4
LD BC, # 0020, 10
INC H; 4
LD A, H; 4
AND # 07; 7
JR NZ, GO_PSUP; 10
LD A, L; 4
ADD A, C; 4
LD L, A; 4
JR C, GO_PSUP; 7
LD A, H; 4
SUB # 08; 7
LD H, A; 4
GO_PSUP PUSH HL; 11
LDIR; 21/16 total = 667
POP DE; 10
LD A, H; 4
CP # 58; 7
JR C, LP_PSU1; 7 cycles = 149,553
-
XOR A; 4
LP_PSU2 LD (DE), A; 7
INC E; 4
JR NZ, LP_PSU2; 10 cycles = 672
RET; only about 151 tys.taktov
All comments on the work of this unit
code can be found in DEJA VU # 3 / 40 BEST
PROCEDURES (Listing 2). In the above
Listing instead of comments are the values of run-time teams
in tact.
Typing and otassemblirovav procedure, you
should be downloaded from the address # C000 (49152) any
schedule to it that move. I recommend the picture aso scr. ,
Which can be found on the disk with DEJA VU # 2. The point
that this picture is black and white, and occupies the entire
screen. This will allow detailed observe when scrolling the
screen to places where the beam sweep ahead of our procedure to
update the screen. A ray will overtake us certainly, since the
whole procedure takes about 151 tys.taktov (more accurately say
difficult, because you have to take a long time). When counting
beats, I took only during the procedure without PSRL_UP
accounting team RET and the caller.
So it's time to start optimizing.
"How?", You ask me. Naive people, you
thought that I will explain everything thoroughly and to the
last byte. No! All this dirty work to optimize
do you and only you. Who among us
two to learn assembler, you or I?
Some clues have yet to give.
Of course, should be replaced LDIR more
quick LDI, stack fucking transfer graphics
We have agreed not to use it! However,
stack can be used for other purposes,
where the aptly delivered PUSH or POP
replace the whole abyss of commands. Certainly
need to accelerate the process of transition from one
screen bar to another and, of course, should be .... No! You
yourself have to guess ... Although, using even half of my
tips, you can easily reach the mark in 116 tys.taktov, to
further improve good bit poraskinut brains.
Well, to give at least some incentive, I
presents data on the procedure to which
able to write to me, holding ldir
restrictions on the transfer of the line:
The size of the procedure - 188 bytes
(After the first run-increasing to 572)
Approximate run time - 111 tys.taktov (almost the exact time of
execution - 110.682)
For eager to look at this monster in the annex to the
magazine placed source (File called LDISCROL. ). I asked
specifically to leave it in the format STORM'a,
as this assembly is not at all, and
according to this, you will most likely not be able to
immediately look back. We'll have some time to consider the
place that some called the head.
Of course, I suspect, and realize that
my procedure can be speeded up. If, however, did not move the
image on the screen and take it from memory, and output in the
right place (even by LDIR'ov), the ...... However, this
another story!
Powered by LACRIMOSA'95 "INFERNO"
MOTHER RUSSIA/SAMARA/13.02.97
P.S. "Friday 13-oe ....."