(C) Kolotov Sergei, SerzhSoft, October, 1997.
Demo KODIT I WANT TO - LET teach me!
Certainly, in recent demostroenie on Speccy is
one of the leading application efforts vast army of coders,
MUSIC-, GFX and other maker'ov ... It must be noted
progression, improve coding, graphics, music, and their
population - effects (FX). Thus, in the latest "advanced"
demah emphasis is on the timing, conformity
visual and sound effects to each other. Moreover, most
promising direction EURODEMO, or more technical and confusing -
TRACKMO. Demos created by this standard more
undemanding of computer architecture, not to inhibit
komp'ah slow and can not be reset, for example, buggy bus
data affecting the interrupt vector. These demos "go" and
different "branded" versions Speccy (+2 A, +2 B, +3 ...). A
which is very nice - all of these programs are easily
transferred from one system to another (eg, disk), swing across
networks and obtain the largest distribution and popularity.
Here are the most basic requirements, requirements
stipulated by EURODEMO: 1. Correct work at all "branded"
Spectrum, including +2 A, +2 B, +3.
as well.) In a shortened address port # FD to switch
pages, the sixth bit of the port must be installed in
yedinichku.
b). The value of the number of cycles in a single interrupt
(tacts in one frame) should not exceed 224 * 312 = 69888.
Attention! In the country very large distribution received
"Scorpions". If you do not want to reduce the number of viewers
of your creation as a minimum - in 2 times, then count all the
effects of just under Scorpio! This is about 68,000 cycles, and
Scorpion Turbo +: about 70,750 cycles per "Interesting." And
pay attention to (!) - Runtime ALL teams in Scorp'e EVEN! That
is why many tests (for example - Jemmini Commander) break off
and give about 65,000 cycles, which wrong in principle!
cent.) interrupt vector I should be set within
# 80 ... # BE, ie point to address in the "fast" the second page
RAM. Otherwise, you run the risk of slow down program execution
for some machines by about 25%.
city) Vector table must necessarily consist of 257 (!)
bytes, beginning at a multiple of 256, ie, start address
within the # 8000 .. # BE00 (the best option: # BE00 .. #
BF00). If you decide to "save" to 255 bytes, then rest assured:
the machines with unstable data bus and your creation is
unlikely to work!
2. Disk version demos in no case be
made as a monoblock. BASIC part must comply
simple loading and provide for transfer to other
"Not TR-DOS" - system. Under the monoblock understood BASIC file
downloader, and she deme related "dyrkovym" (can
also expressed Inforkom!) by sectors of the TR-DOS. But we can
cunning and small demos of up to 40 kb bring in a zero
REM-line BASIC on the principle of tape loaders and
avoid all the problems of adaptation. Example:
0 REM ... mover ... depacker ... pack_codes ...
10 RANDOMIZE USR VAL "5 + PEEK 23635 + 256 * PEEK 23636"
3. Multicolor effects from best to abandon or
Implemented the first on all branded machines, and only
then already in the PENTAGON, SCORPION ...
4. Desirable place greater emphasis on effects and then - on
schedule and music. Animation is not welcome! The people are
longing REALTIME'ovyh procedures!
5. Ideally, the transition from part to part should be
automatically and in due time. Dema should look at one
breathing. But since the ideal is very difficult to achieve,
then acceleration and transition to the next part - not bad poll
SPACE and ENTER.
The Council is also to look through these articles:
DEJA VU # 1 \ SOFTWARE \ SOFTNOVOSTI \ DEMOSTSENA;
DEJA VU # 1 \ Beyond the hill \ RICH also cry;
ZX-FORMAT # 3 \ PROGRAMMERS / ASSEMBLER.
So what motivates all the coders, graphics designers,
musicians, that makes them whole day and night to sit at the
screen and push, push buttons Speccy, sleepy eyes, appreciating
the work already done ... Do I have to say? I
I hope that once you read this, the answer to this
question may already know, or would not be sitting for all of us
komp'om favorite!
Yes, there are still people for whom the greatest pleasure
is the coding of new effects, for which time spent in
Assembler will never be lost. Possible and You
My readers want to be the coolest coder in the world. In
If so, you probably would be useful to read
following lines, which are opened slightly
techniques of writing quality MEGADEMO ...
It should be noted that recently the greatest emphasis in
megademah made on the implementation of realtime'ovyh effects.
Word 'Realtime' often appears on our screens
Spectrum'ov, and is usually used with a proud tone. But
many USER'ov still this notion is somewhat
puzzled ... And not in vain, because significance of this
rather witty vague:
1. So said all the effects that are not based on simple
Animation (deriving in turn sprites are stored in memory). Then
have made some calculations, etc.
2. Under realtime-effects are those procedures and their
together, have time to return for one interrupt
thus ensuring the smooth graphics and the lack of 'twitching'
image.
3. And since This is often achieved taditsionnymi methods
programming sometimes simply impossible, coders must
resort to various tricks and ruses to ensure that
necessary performance ...
The term 'programming in realtime' in my opinion is just
means one of those cool-programming techniques. Explain what
essence. Before running any effect on performance
SPECIAL procedure creates a (generated) fragments
code, procedures, sometimes occupying the entire 48th memory
Speccy. Such procedures have a very 'loose' code, they usually
'Opened' all the commands of cycles and not the least is
Work with a stack.
Moreover, such procedures are not necessarily located in
memory at different addresses. Different effects addresses the
procedures may be the same, just every time there is 'is
generated' a code ...
All well and just when you have a memory of sitting alone
effect then usually no problems ... But when the effects of
several when they need to somehow tie together so they do not
conflict and do not wipe each other ... Here already and with
the head can befall 'bo-bo'!
Monsters demomakinga already used this technique when
for each effect already diverted all 48 kb Speccy. How does it
achieved? It's very simple ... Created, how-to 'base
packed effects', the so-called 'FX-stack'. And all the effects
(Codes, graphics, tables, ...) weep for additional
Page 128th memory and waiting there in the 'sandwiched' state
of its queue.
Usually left free to the entire 48th memory and seventh bank
RAM - for the effects of using two video page. And then -
All like clockwork: the 'FX-stack' is removed once the effect
rackompressuetsya, creates the necessary signs and
realtime-procedure, and then we see another 'Otpad'.
And so the viewer does not mayalsya waiting until the whole
thing Unpack, 'Settlers' and calculated as necessary, on-screen
displays various inscriptions, messages fuck'i, finally ... (But
In my opinion a good EURODEMO and fuck'i - things are absolutely
incompatible!)
Should be used dekrunchery operating at permitted
interrupts. It is necessary that the music never stopped and
'Pleased user. " In an extreme case, you can always be rewritten
depaker using the stack, changing, for example, POP HL LD on
L, (IX +0): LD H, (IX +1) ... Or, say, using alternative
registers ...
Yes, I almost forgot. It must be noted as a technique called
'Pseudo-realtime'. The essence is as follows. For example, we
take any sprite and memory are calculated and stored it changed
options to get, say another sprite (morphing). Then
is a result we will have in memory the sequence
Sprites, which subsequently will be alternately displayed on
screen - as a simple animation. Such a device, such as
used in the demo MENTAL MASTURBATION (RUSH) at the organization
all of the same morph ...
But back to our sheep ... I am constantly surprised and
to put it mildly - annoying that some megademschiki still
'Spit with high mountains' on the reverse of the beam. And in
the best case graphics are choppy ... And when the missing part
of the sprites, and sometimes whole scrolls - there is
medicine, as they say, powerless! And, perhaps even on the
mountain komp'e encoder all works as expected. But on the other
'wheelbarrows' can occur Anything ... But get rid of the
'radial problems' very, very simply, we need only recall the
existence of 128-Speccy two screens, switching which occurs
simplest OUT'om the port # FD (third bit).
As a result, while both the 'visible' screen will be
one picture, we will modify or generates a new one - at
'Active' screen. And then just swap them. May
be better to give a specific asm-code? We ought to ...
...
; Cell storage
BANK_M EQU # 5B5C
...
, Visible: scr_0, attached: scr_1 (7 banks)
LD A, # 57
; Call the procedure output port # FD
CALL RAMPAGE
...
LOOP HALT; waiting for the arrival interrupt
LD A, (BANK_M)
; Swap the visible and active screens:
; Ekran_0/stranitsa 7 or ekran_1/str. 5
XOR # 0A
CALL RAMPAGE; out (# fd)
...
And create a new image at # C000
...
LD A, # 7F; twist
IN A, (# FE); cycle until the
RRA; not pressed
JR C, LOOP; SPACE
...
;
RAMPAGE; procedure output port # FD
LD BC, # 7FFD; OR # 40
OUT (C), A; OUT (# FD), A
LD (BANK_M), A; preserved. in cell
RET
...
So we have two cases:
1. See screen 0 (starting with # 4000) - the third bit of the
port reset. And at this time connected to the seventh page of
memory with the first screen (# C000), which we are going to
change ... 2. After the arrival of the next interrupt, the team
with XOR # 0A followed OUT'om we will see screen 1 (the third
bit is the port # FD is equal to one) and connect the fifth
page of RAM - the same 0th screen will become active and will
also adresovyvatsya # C000!
3. All again from the beginning ...
But should take into account the fact that it is now
necessary careful with the port # FD. For example, when
processing interruption in the second mode, when playing music,
it is necessary keep track of the contents of the port # FD,
and in particular, third bits. Say, the music, we sat in the
first bank. Then an example interrupt handler is as follows:
...
MY_INT; procedure interrupt
PUSH
...
LD A, (BANK_M); contains. Port # FD
PUSH AF; saved on the stack
AND # F8; preserved. bits of the screen, etc.
OR # 01; page with Mouzon
CALL RAMPAGE; brought to the port
CALL PLAYMUS; lost
POP AF; restored AF
CALL RAMPAGE; have brought to the port
...
POP
EI; allowed to interrupt
RET; exit interrupt
...
Yes, I think we need to show it all 'live'. I'll walk-ka
some realtime-effect. Experience shows that people
learns much faster on concrete examples. And therefore read
article 'floating ATTRIBUTES', where we have used many of the
these ideas ...
I hope that reading this text does not make you feel a sense
of wasted wasted time and something useful to you in the future
work on your favorite Speccy.
If you are interested in any questions DEMO-MAKING'a and
realtime-programming - do not be lazy to ask them, and perhaps
get a complete answer.
And remember:
YOU CAN NOT WRITE demo,
BUT KODIT, ALL F, MUST be able to!