INTERNAL STRUCTURING
YOUR PROGRAMS
(C) 2000 Max/Compu-Studio Ltd
-------------------------------------------------------
The ways of the encoder are mysterious...
Hello everyone! Today I will continue to “suffer”
nia" on the topic"HOW TO MAKE PROGRAMS",what-
it would be acceptable for you too, young gentlemen
programmers, and us - users. Subject
is still relevant, because partly because
deep laziness, partly due to ignorance of
are programs, demos and pre-releases on
games in a poor internal form. Yes and to already
completed projects sometimes remain pre-
tensions.
The essence of the "problem" is that the program,
located on the disk, it turns out non-transferable
placeable. Some comrades. I won't
point your finger - they will be offended, but follow-
next time, if ever
you will be, please do as I do for you
I suggest. Here we mean moving
bridgeto different tracks and sectors on the disk.
In other words - transfer from one place
disk to another. Agree that it is very
there are often situations when you throw off
from a friend's floppy disks, on which everything is readable and
starts, there are several programs on your disk
ramm, and then it turns out that being not
"in its place", they refuse to load
to huddle, which is very stressful. Okay if
the program should be the very first one on your
on the disk - I fulfilled this condition and to hell with it
her. But I came across games that
according to the intention of their authors, there must be
not even from the beginning. And not even on the second
track, and God knows where. So guess
Tom - where should it be recorded in order to infect
botala? Experienced or persistent user
The tel will try to find out by analyzing it
spare parts loader. But what about everyone?
Who doesn't play around with assembly language? Erase on-
fuck this crap or rewrite it again
friend's program using the track method? Okay,
if a friend lives in the next building, but
what if you received such a bummer in the mail? Convinced
I need you to do the right thing
new internal structuring of programs,
so that the end consumer does not have any problems
similar problems?
The most interesting thing is that the creator himself
The software will lose some of the problems associated with
downloading program files. I'll bring for
example algorithmloading the third issue
my magazine. This number turned out to be
easily moved along the disk thanks to the al-
algorithm that I specially developed.
So, any program starts with the following:
that it needs to be loaded into the computer's RAM
tera. Usually several files need to be read
from disk, and then run
understanding of the main algorithm. I took it for granted
ensure that all files are packed with software
mine HRUST any version. No unpacker.
This is an important point - in short, the program will
children, and it’s easier to work. Also accepted in
provided that all files begin with a circle-
hexadecimal address logo. For example,
from addresses #6000, #8000, #F000 etc. Also
the fundamental point is that it’s easier to work. A
now see how I implemented the loading
log ku:
;Magazine loader "Black Crow #3".
;(C) 2000 Mikhail Maksimenko.
;Auto-detection of downloaded sizes
;files. Pack everythingHRUST`om without dis-
;packer! File sequence:
;B_CROW .BBASIC loader;BC_loader.С this file is in asm
;$ВС_SCR .С splash screen
;VSZ_DB00 .С oscilloscope in page 7
;VSZ_8000 .S the backbone of the magazine
;$ВСЗ_FON .С background in page 6
;VSZ_MUS .S music on page 6
;VSZ_data .С all data for the log
;the following are the texts of the magazine. Their beginning is determined
; appears here automatically.
;Everything except the background screen is unpacked-
;fuck!
;in: H=file download address, L=page number
; file where to upload.
ORG #BD00
START LD HL,#8010;add. #8000 page #10
CALL LOADER ;splash screen
LD HL,#8000 LD DE,#4000
LD ВС,6912
LDIR ;на экран
LD HL,#DB17;music bank в #17
CALL LOADER
LD HL,#6010;костяк журнала
CALL LOADER
LD HL,#F016;титульный лист
CALL LOADER1 ;без распаковки
LD HL,#С016;музыка
CALL LOADER
LD HL,#AA10;данные журнала
CALL LOADER
;ЧИТАТЕЛь! ОБРАТИ НА ЭТО ВНИМАНИЕ!
LDHL,(#AAO2);table address
;size/sect/track
LD DE,(23796)
INC HL ;skip "size"
LD (HL), E ;first sector
INC HL ;bedding txt
LD (HL),D ;and track
JP #8000 ;log start
;entry point with unpacking after download
LOADER LD DE,DEHRUST
PUSH DE ;start unpacking
;download, but do not unpack the file.
LOADER1 LD BC,#7FFD
OUT (C),L
LD L,0 ;whole address #xxOO
LD B,1 ;read from disk
CALL LOADER2 ;one sector
PUSH HL ;beginning of file, spare
PUSH HL ;forged by HRUST!
POP IX
LD A,(IX+4);length packed-
LD B,(IX+5);of the file
OR A ;is a multiple of the sector?
JR Z,LOADER3
INC B ;file size,
;multiple to sector
LOADER3 DEC B ;minus loaded
INC N ;sector and next address
CALL LOADER2
POP HL ;beginning fileLD E,L ;for deHrust
LD D,H ;load address
DI ;falls with the address
RET ;unpacking
;Referring to tr-dos. Can be replaced with
;your own loader, if this is not critical.
LOADER2 PUSH HL
LD DE,(23796)
LD C,5
CALL 15635
POP HL
RET
;This is the unpacker that comes with HRUST.
DEHRUST INCBIN "DEHRUST"
SIZE EQU $-START ;define size
;file measure.
Now I’ll explain all the details. With input-
I hope everything is clear. First we need
read one bootable sector from the disk
th file to determine the size
this file. Please note that in the example I did not
did a check for "size 1 sector",poe-
So, if necessary, install it yourself. Than
the file packed with HRUST`is wonderful, so
this is because all data about the file is recorded
laid at its beginning, including markings
"HR", as a sign of a file from under HRUST.
So, we take data on the file size, not
while forgetting to minus one sector
from the size that has already been read and loaded
press the entire file. If necessary, unpack it
him. For example, I need a background screensaver for
there is no point in unpacking the magazine, so
it is possible to download a file without further
neck unpacking.
Now about the place in the algorithm where I
I asked you to draw your attention to the misunderstanding
new data tab in the just read
nal file. This is also an important place in
program, since the following is determined
track/sector on the disk behind your program.
You need this data if necessary.
bridgesfurther reading additional
game levels, sprites, tables, etc.
In my journal to determine the month-
locations of files of articles and music are special
cial table, which indicates: di-
measures of the file in sectors, as well as the first sec-
torus and track where the file is located. So that everyone
Since you can’t decide on the beginning of this table,
in memory, I made a link to a certain
line address in one of the files - #AAO2,
where is the address of its beginning. That's why
address +1 I’m laying down the next track and
sector that follow the program after
downloads. The table looks like this:
TABLES DEFB #1E,0,0 ;file number 0
DEFB #0A,0,0 ;-----/-----1
DEFB #27,0,0 ;-----/-----2
And so on... The end of the table can be described as
start with zeros so you don’t get lost later.
Here the first value is equal to the file size
in sectors, and subsequent zeros are reserved
are based on sector/track values on the disk.
And then everything is simple - I make the calculation
the following track/sector values by size
files that are in the table. So
how a link to a specific
disk spacethe entire program, including
its additional files.
So, a bookmark has been made in the bootloader
table of values for the first file. Osta-
I could do this for everyone else:
;calculation of the next track and sector
;by file size in sectors.
DATAS LD IX,TABLES
INC IX ;skip size
PUSH IX ;file
POP IY
LD E, (IX) ; initial sector
INC IX
LD D,(IX) ;and track
INC IX
DATAS1 LD (IY),E ;sector
INC IY
LD (IY),D ;track
INC IY
INC IY
LD A,(IX-3)
OR A ;zeros - end of table.
RET Z ;exit
INC IX
INC IX
INC IX
LD C,A
LD A,E
ADD A,CLD L,A
RRA
RRA
RRA
RRA
AND #1F
ADD A,D
LD D,A ;track
LD A,L
AND #0F
LD E,A ;sector
JR DATAS1
Hmmm, it was a poor procedure, but it worked.
tea. What else do you need? If there is a desire, then
rewrite it again. My job is to tell
theory...
Further work of the program concludes -
in organizing file downloads by number
ru occurrences in the table. For example, it is necessary from
three-byte table to extract data about the
downloadable file:
LD A,file number in the table
LD L,A
ADD A,A
ADD A,L ;3-byte table
LD HL,TABLES
ADD A,LLD L,A
JR NC,LABEL1
INC Н
LABEL1 LD В,(HL) ;file size
INC HL
LD E,(HL);sector
INC HL
LD D,(HL) ;track
RET
That's all! You can work calmly and in pain
No longer be distracted by changing the values of the table
faces when moving a group of files. Even
if any file is altered by you,
then it is enough to change (if necessary -
ty) its size, and everything else is a program
will do it for you at the start.
There are many ways to "bind" to a disk
programs or files, but this is the simplest
the one, in my opinion. A more sophisticated way
Sob was realized in his game by Slavik Med-
nonogov - the disk is divided into logical sec-
tora. The files in this case are located in
virtual space from zero to
2544th sector or, if non-standard
disk format, up to the last available from
total number of sectors. It turns out
that file, for example, the tenth one is located on
142 logical sector. The table is located
combining files in the program results in one
byte, but the receiving procedurereally-
th track and sector, as well as size
file, slightly larger due to ongoing
calculations and transformations. The table indicates
Only the numbers of logical sectors are known, with
with which the following is then done: takes-
the required number of the logical sector, for
then the next number determines their
difference. This will be the file size. After
the physical track is calculated and
sectors from data representing
the volume of the disk as a whole, i.e. how many sectors
formatted on the track. Disk, according to
I believe it must have the same format
cov. By the way, to determine the number of sec-
tor within 0-2544 by one byte Sla-
Vic made a transition control from #FF to 0,
which means overflow is taken into account. So
Thus, using this method, any number of
number of logical sectors in one disk
in space - at least a million! Not like
does this bother you about PiSishka?
Examples of implementation of this method are given
I won’t eat, because there is a big co- on the tyrdos
The number of sectors is not relevant. Although,
whether to write a program that widely uses
Winchester, this method may come in handy.
-----
I thought I would end the article here, but where?
there... Coders continue to code, which means
and topicsthe conversation is not exhausted!
Lately, all the
programs and shells in which pre-
looks at what overlays can do and
users, not just their authors. Even
it is very good that such an opportunity is
delivered - wanted to graphical re-
Rector typeGRAPHIC STATIONmake your own
overlay that implements the 3D effect - perhaps -
hundred! No problem - sit and code.
As a rule, complete with such a program
frame is a listing with addresses and points
input so that the programmer can
navigate the codes. Well organized
van and thought out the work withZX-ASM`om, where
there is an appeal to the editor core via RST
#10 plus function number.Remember my Windows
in the second issue"Crows"?There is also a
The principle of working with the shell is exactly the same. And
in the famousIS-DOS`e this is exactly how it is implemented
van interface with the programmer. Much of
what was done by serious groups,
uses this method. He is the most
more simple to implement. Although in the process
All program debugging using STS`a bu-
blowthere are inconveniences associated with
impossibility of tracing the RST 16 command
plus function number in step mode. But
it's not scary - why do you need to trace
shell? As a rule, it is muted.
Another important factor is the
May complete freedom of action as for auto-
rov shells and programs, and for pro-
rammists making their overlays, from the point
in terms of compatibility of subsequent versions,
because the most unpleasant thing disappears - addresses
Routines don't matter anymore! They
replaced by a "dry" function number, which
Roy doesn’t give a damn about everything: he indicated the number - by -
rays result...
Here, at this place, for development
of programs and shells lies the most
great responsibility - we need to produce EVERYTHING
mother so that in subsequent versions it will not
I had to change the INPUT to functions!!! EU-
doesn't your imagination allow you to imagine?
to imagine the unimaginable, then at least spend
user survey or (which is better)
programmers and ask what they
would like to see in future versions of your
software miracle? The results of this survey
sa should not be perceived at all as green
light to action for immediate re-
lization. They will do it themselves if they want.
want. But about ways to solve these problems in
your shell needs to think carefully
and provide ways for their implementation. Then
and to youit will be easier - they won’t blame you for
shortsightedness, lameness, etc. And for
the more outside programmers there are
freedom of action - so much the better! And compatible
The majority of old and new versions will remain on
at the proper level. In short, think about everything...
innovatively, and then just sit down at the as-
sampler!
And I will help you. A little. For the most
For detailed and complete information, read
second issue of "Crows" my article-Help on
WindoWs.
Here I will tell you about the method of working with
functions via RST #10.
So, everyone already knows this, but
I think it’s not superfluous to remember: to bind to
RST #10 must be entered into the system BASIC
#5С51 address of its system, where it finds -
This is the address of the program responsible for the work
with functions and called via RST #10. B
this intricate action requires
due to the peculiarities of the ROM operation
procedures. The procedure itself has approximately
the following form:
;Running the function via RST #10.
;Any inputs, does not violate anything, except
;alternative pair DE.
RST_16 POP HL ;RET from ROM
ROPHL ;HL` alternative
EX (SP),HL;next address after RST
LD E,(HL);function number from #40!
RES 6,E; Why - read below!
RLC E ;divide by 2
LD D,#00
INC HL ;adr. after f. number
EX (SP),HL;output after function
PUSH HL ;HL`
LD HL, function address table
ADD HL,DE
LD E,(HL); take the address of the function
INC HL
LD D,(HL)
POP HL ;HL`
PUSH DE ;to start the function
EXX ;it was shit RST #10
RET ;start function.
And again about the peculiarities of the ROM operation
subroutines for processing command RST #10. And
what a fool wrote so that in the process
work crashes meaning alternative
register DE? More precisely: register pair DE.
We have to put up with it... But this is de-
There is no need to bark at all! You can write
another procedure that does not harm anything
hates! Here it is:
NO_RST LD (REG_A),A
EX (SP),HL
LD A,(HL)
INC HLEX (SP),HL
PUSH HL
PUSH DE
LD HL,function address table
SUB #40
ADD A,A
LD E,A
LD D,#00
ADD HL,DE
LD A,(HL)
INC HL
LD H,(HL)
LD L,A
POP DE
LD A,#00
REG_A EQU $-1
EX (SP),HL
RET
The operating principle is similar to the previous one
algorithm, so comments are unnecessary. I
I just want to note that this algorithm
should be called via CALL NO_RST plus
function number:
CALL NO_RST
DEFB function number.
Now I’ll tell you why I use
Neil numbered the functions from #40, not from zero.
The point is that any number can beput
for a function, just compile it and
look at the result. Everything that is
communicates after the number - merged into food with
I have porridge for him. Not always, true, but so much
often, to make viewing STS uto-
a tedious matter. It will be difficult to debug
creating a program! And here is the number from #40 to
#C0 can be freely used due to the fact that
what these are single-byte command codes mean
visual merging with the following commands
won't happen.
The function table is a self-
what a run-of-the-mill list of routines
rams typed under DEFW. That's it, code!
Oh no! I also forgot to say a few words.
All of the above algorithms, of course,
for internal use in a shell,
but for users and programmers it is necessary
make two entry points: through RST #10 and
some address where it will be
resemblance to a resident. You can do it like this
I did it in myWindoWs`e - the beginning of the code
This block is the entry point into the shell.
The most acceptable solution, in my opinion, is
passionate look, is the organization in
body of the special installation shell
functions that, in addition to device testing,
available memory, etc., will be occupied
connecting a channel for RST. Then
only one single entry point is neededyes. Naturally, it is desirable to have this
called the “final” function, which
which will “extinguish” AY8910/12 by setting
remove IM 1, restore all system
variables including channels and streams after
running your shell via RST #10. Od-
in a word - to put in order everything that
does not quite correspond to the state of the computer
tera after its initialization.
But what about system shells, which
which are used from outside and how to access them
gain access? It's not that complicated,
as it may seem at first. I
I propose to make the functions multi-level.
Such a solution, for example, was implemented in
everyone's favorite magazine ZX-FORMAT. Everything is there
done something like this, although I can go into details
to be wrong:
RST #10
DEFB function number
DEFB function type
DEFB data, data...
It turns out that once in a certain
new function, withdrawal occursfrom memory
the following bytes that can be entered
specific for the function. Anything! All for-
depends on the rules you set. Now
in relation to system variables, which
which need to be changed. I recommend the system to everyone
dark in the shell, to which it is assumed
it is possible to have access from outside, to assign your
serial numbers. Just like functions.
This can be implemented in practice like this:
RST #10
DEFB system installation function
DEFB number of the corrected system -
variable
DEFW two-byte value
You can complicate the operation a little and op-
divide the system dimension into 1-bye
finish or 2-byte. Or do the same
a kidney of introductory drugs, if it is, for example, a
connection to the disk function. Just don't forget-
look at what is on the stack in my examples
return address from function! The same address
som can be used for further
withdrawal of inputs. Similarly, you can organize
call removal of any system variable
fromlist.
Now we should agitate a little
mastering hardware capabilities that
have been widely used recently
Spectrum. We are talking about cache support. From
all the numerous schemes of this are amazing -
I recommend this device to start de-
write programs for a standard 16K cache
with the expectation that this is the easiest
the implemented scheme is also ro-
director of further developments in this field
features: 32K cache, 128th ROM emulation and
so on. I recommend it to all creators
commodities, shells, editors and other software
support this scheme! Well, judge for yourself, before-
horny author of a certain Windows - practically
ki is the entire computer memory, regardless
from its volume, given to the user and program
rammist, which will undoubtedly raise the rating
your OS, and will also simplify to a minimum in
future to adapt existing ones or
programs being developed. Decide in which
ultimately, to you and your capabilities
computer. If the problem is the latter, then
it may be worth solving it and then your program
ramma won't look so bad...
Well, that's all for now. I wish you good luck! I hope
that this article will help you in your work.
DESIGN OF OUR PROGRAMS
====================
(C) 2000 Mg.Beeper/Last Masters
-------------------------------------------------------
Chapter I
I feel sorry for those people for whom the word "di-
zayn" is an empty sound. After all, write a program
frame is one thing, but to decorate it beautifully,
come up with an original design for it - co-
completely different. That's why some
personality, trying to implement on the Spectrum
their ideas face this problem
and, unfortunately, not finding a way out of it,
often abandon their work unfinished
until the end. Some do it without any
or design... Specific examples are given
I won’t give a damn, but why not? Here
one of them.
Remember the demo version of the game called,
if I'm not mistaken - "ROBO".The meaning of the game
is as follows: by controlling a certain character (type
above), you wander among all sorts of traps
shocks and surprises. There was a demo
simply amazing. There were great things in the game -
digitized sounds, andit was, I tell you
I'll say it's cool.
Some time has passed and
The full version of the game has appeared... In the markets
hometown it was sold in large
quantities, and how disappointed those
who purchased this product. All download
was done through BASIC, menu, like that
there was no such thing. There was a sample only of the level
Nya - that's all. I personally interviewed some
such offended users and my expectations are op-
were happy. 99% of respondents abandoned this
game to the top shelf after seeing it
nogo. Where are those digitized sounds?
for which the rating of this game increased
ry?
Yes, they were simply replaced with AY'kovsky ones.
That's the whole design for you! Well, maybe more
one option: The author of the game suddenly
died, and in his dying remark for-
broadcast this game to his ancestors, and the ancestors
these people drank this program to the people in
black, and these people were lamers, and in
they began to do something about this under-
made a work of art and they became
code in BASIC, and thunder struck, and
It started pouring rain. And the suckers in black
coded under an old oak tree, on the branches of which
there was not a single leaf. And it flooded
the computer is theirs, but in the last seconds there is only one
of the ones in black, I managed to make a save
and thus gave THIS to the world. At least believe-
those, at least not, but that’s how it was.Chapter II
Let's now go a little, oh, ver-
Let's look at demomaking little by little.
With this we always had order and extra
I don't feel like writing anymore. Very interesting article
A story about this was published in Fa-
ultless`e #9,although, in my opinion, it is more likely
In total, it was torn from the PC platform. And I
I would just like to remind you, comrades,
momakers that:
1). Your creations are watched not only by programs
rammists, but also ordinary users who
what they don’t understand about the effects, and they judge
your demos are not fast enough
or other effect, but by its beauty and co-
reading with music.
2). Remember also that some of these
users on their TV scan the screen
the wound makes it so that the borders seem to
no. Therefore, it is necessary to warn approaching
exactly like this "Warning! NoW should be done
on your TV little changes" (hereinafter should
The screen diagram is shown belowhow
hardware, and with the help of meditation on
all types of TV). Then everyone will see that
must be done. And how it was with my girls
which or demo - I don’t remember anymore - Rage, which
The second one I either removed or copied from E`97,
which, it turns out, had a scroller on
border and I found out about it in December -
tse. I immediately went into my mini TV set, and
there is neither a word to say nor a pen to write.
So many spinning things. Towards the end
day I still did a normal scan
Noah. After this incident, I was unwrapped
I don't touch it.
3). In general, the conclusion is this - when you
make a demo, before writing it, turn
part, don’t be lazy to invite your
friends, acquaintances or just “from the lamp”
people. Show them your sketches, ask
those - how it will be better or worse. I think that
after this little show-off you have a
new ideas are emerging, and you will bring the old ones into
order.
Chapter III
A long talk about electronic publications
it’s not worth leading, because everyoneCh. editor-
tor thinks that his magazine is the most original
nal and the best. And everyone else
magazines need to adapt to his
rhenium That's why I didn't touch on
take this topic more seriously. I would like to
just to give a couple of tips to beginners, but
nothing more.
Tip 1.
Never start making a magazine
unless you have a good coder. I don't follow-
There is no hope that he will come later. And
you need to find a good musician.
Tip 2.
Don't be afraid to repeat yourself with your design.
our magazine, because the most important conclusion is
lies not in originality, but in the beauty of design
thoughts. And let, for example, the same inter-
a face with windows is already in every magazine -
Xia, but look - this is for almost everyone
I like it, and it’s very convenient. Many journalists
nals sought to make original me-
sniff, flip through, and look what it is -
it happened...
Tip 3.
Try to get interesting math
rials, find yourself partnersby edition.
Do everything together. From time to time...
It is advisable to conduct a survey of users on the topic
popularity of your magazine, its design
leniya, etc. This can help a lot.
Tip 4.
Never turn your nose up!
This may negatively affect your re-
confusion and in the end you are simply thrown
give stones. Or eggs ;)
Tip 5.
Include not only your own in the application
own developments, but also other cars
ditch Find partners who can
you can get a great application, because
the application is the face of your magazine, not
forget about it!
And finally, I want to wish
to all editors of electronic publications
successful work on your
publications so that readers respect
and read your publications so that
you've never had
information hunger,
and in the appendix
there were great programs!
Editor's note: amen...
Share your thoughts about the article