NEW SECTION
Dear readers, let me introduce you to a new
editorial staff
"SPECCY", resident of the town of Abakan,
well known to many sinkleristam, Feskova Kuzma Vladimirovich.
After a short negotiations on a completely voluntary basis, he
agreed participate in the creation of the magazine.
A little history: To the Editor
magazine has repeatedly been requested to open column
which would gradually, step by step, together with readers
would have created the game program. With the Chelyabinsk
programmers There was talk on this subject, but
further conversations it was moving. While ....( see above).
Kuzma Putin decided to start from the beginning. Field,
he opens will be called "style." request to all,
anyone interested in this section
letter is being sent to the address below.
662613 Abakan,
st. Lenin Komsomol,
d.3, kv.16
Feskovu KV
In the future this section will
fully formed in the city
Abakan and published in the
magazine.
(C) 1996 Fes'kov Kuzma
Do not confuse fashion with style ...
TV-6 "Style"
Let me introduce myself, my name is Fes'kov Kuzma. And I
offer you today a new heading - style. Style, it is not
style in fashion and style programming. The more so because
today it is not a luxury, but the main difference between the
programmers from each other. For example KSA known to us style
of "fast" programs, all known Nikolai Rodionov -
style design of its programs
(Pointer Interface), although
Today, his style became
style for a variety of other
programmers. I think that digging in the memory you'll find
many more examples of "fashionable" programming. You can argue
long on necessity of style in programming, but if you
definitely want to stay in the annals of the Spectrum, the
style is what you need!
*
I am here reminded of a long and
boring science lessons when
teacher lectured us on the basics of programming, talked about
what such an algorithm, etc., etc.. I listened and all my mind
was indignant at anxious waiting the moment when we finally bit
of the computer. And now, after years, I sit and write these
lines, me and a huge computer
area of the application of my talents ... And I wonder, but
it worth trying so hard to the computer? Maybe it was necessary
to first understand the basic?
*
Today we'll talk to you about
the internal structure of the program,
We now have a basis for algorithmic.
What is
program? Try to imagine it as a living organism (which,
incidentally, quite close to reality). Years parsing foreign
programs and writing their allowed me to identify some features
of the life of the organism as a program about which you should
know.
Looking into the wrong program
(Especially domestic authors)
I have been extremely difficult to sort out somewhere that. And
all because the procedures are and intertwined with the main
body program. This of course can
serve as a kind of protection, but
Seems to me that Sia is able to properly protect and defend
themselves from the author himself, as found in
such a "hell-node error is extremely difficult. Look at your
early programs, I think
You are now hardly able to
understand them.
And so, I offer you the following action plan for writing
the program:
1.Prikinte on a sheet of a small scheme of your program.
First, it helps you to concentrate on its individual
sites, and not to take it entirely, which is extremely
difficult. Secondly, you never get stuck in how the program
will interact with each other. -------------------------------
SAMPLE. Take for example a small files of that only and will be
what to print on screen sprite. Look at her
scheme:
Data
coordinate address data sizes
you print GOVERNMENTAL sprite sprite
calculation
Address
to screen
drawing sprites
As you can see by looking at this chart, you can easily plan
their work, do not spray their
attention to some minor points. This so-called principle of
structural programming. We are moving
from cattle to a private, reaching
with the minimum indivisible
part. Note, inseparable, in
Currently, despite the fact
that the division of the program easier
comprehend it, not worth it to get involved, as in the pursuit
of structuring you can do so elaborate scheme,
that will not be able to trace the relationship between the
procedures and return to the starting point. Is there out of
this situation? Of course there is! What prevents you select a
specific procedure and took her by the program structure. Let
us return to our example. Clearly, that block drawing of the
sprite " represents a rather
volumetric procedure, which can be selected and structured:
Drawing sprites
print cycle print cycle
in height in length
As you can see, this approach
allows you to very effectively
build.
-------------------------------
2.Napishite first, all the procedures, and then to head the
program, which should only the right time to cause the desired
subroutine. DO NOT DOWNLOAD
main program parts that can be identified as sub, except for
those moments which require speed.
*
Let's finish this our
today's conversation. Upload
assembler and review your
programs that are probably already
is in your piggy bank, try to make their structure.
As an example, as well as
in order to create your style to your attention today Turnout
program interface.
All comments and suggestions to
new column send me an
at 662613 Abakan, Leninskaya str Komsomol, 3,
kv.16. You can also send a small program that would have
contributed to the formation of national identity programmers,
your style! If you are interested in the story of
kinds of programming, writing and
I'll talk about other species. All in
Your hands.
*
The program interface pointer. You are probably not been
seen darting briskly arrow on the screen, which, running up the
options menu, lit it. You are invited to a similar program
today. I will immediately say (to avoid gossip), which is taken
as a basis for program Ricker VV, published in the book
ZX-Forum'1. I cite here the entire program,
but if you have previously typed
this program, download it and
rewrite the program to re-
START, as the changes affected only her. And just to add 3 new
procedure. But before you give this program, I'll give you her
scheme.
Analog Interface
START: main program
Drawing a selection
menu arrow
verification wipe survey
hit the arrow keypad.
Of course, for each sub, you can draw a separate scheme, try
it yourself. START LD HL, (CRDS); Take
And the coordinates O
The arrows.
LD A, 255; Writes
, Number 255 in the number of op
; Function, which suggests
LD (OPC1), A; that tends
; LCA on an option was not hit.
PUSH IX; Further, all
, As in the program.
QO CALL SCRBF
CALL FORM
HALT
IN A, (31)
PUSH AF
CALL BFSCR
POP AF
LD C, A
LD E, STEP
LD D, 254
LD HL, CRDS +1
BIT 0, C
CALL NZ, PL
BIT 1, C
CALL NZ, MIN
LD D, 190
DEC HL
BIT 2, C
CALL NZ, PL
BIT 3, C
CALL NZ, MIN
BIT 4, C
RET NZ
CALL COND; Call
; Validation of
; Of falling arrows.
CALL BAR; Call
; Procedure painting
; Erase option.
JR QO
;
; Hit test POINTERS
;
COND LD IX, (TABLE); In IX for
; Carry the address data.
LD A, 1; Writes
; Number of the first option in
; Auxiliary
LD (OPC), A; changes
; Nuyu.
LD HL, (CRDS); In HL those
; Kuschie coordinates arrows
, Ki.
SRL H; Since
, The coordinates of the arrows in
; Pixels, and the program
SRL H; works
, With familiarity, we divide
And the coordinates of 8.
SRL H
SRL L
SRL L
SRL L
COND1 LD A, (IX +0); In A
; X coordinate of the menu.
CP 255; If
, 255, the data Concha
, And were not on hand
; Options.
RET Z; Exit.
LD D, A; Test
; It hit on X.
LD A, H
CP D
JR C, PROPOPC; If le
; BEE option, skipping
; It.
LD A, D
LD B, (IX +2); In Regis
; Triangle B the length of the options in
; Familiarity.
DEC B
ADD A, B
CP H
JR C, PROPOPC; If
, The right option, skip
; Eat it.
LD A, (IX +1); VA
; Coordinate Y.
CP L
JR NZ, PROPORC; If you do not
, Coincides with the current
; Coordinate Y, transmission
; Kai
LD A, (OPC); If all
; Test passed, then
And we found a number of options
RET; downloading
; Eat it in the A and exit.
PROPOPC LD DE, 3; transition
, We arrive at the following data
; Options.
ADD IX, DE
LD A, (OPC); Number
; Current option increases
; Vai 1.
INC A
LD (OPC), A
JR COND1; Again
; Check.
;
; Paints / DELETE OPTION
;
BAR LD L, A; After
, Exit procedures
; COND in the register A number
; Option, or 255 if
, The arrow will not hit.
LD A, (OPC1); Put
; Does A number of the previous
; Options, compare it
CP L; with the new
And if they are equal, then
; Paint is not necessary.
RET Z; leave.
CP 255; If
; Arrow left with options that
, New paint is not necessary,
JR Z, BAR5; but should
; Repay old that
; Does BAR5.
PUSH AF
LD A, L; Writes
, A new number in place
; Old.
LD (OPC1), A
POP AF
CALL BAR1; Erase
; Old option.
BAR6 LD A, (OPC1); in A but
; Up new options.
CP 255; If it is
; Not an option, then the paint is not
; Necessary.
RET Z; leave.
BAR1 DEC A; prepare
; VKA to shading of the new
; Options.
LD H, 0
LD L, A
PUSH HL
POP DE
ADD HL, HL
ADD HL, DE
EX DE, HL
LD IX, (TABLE)
ADD IX, DE
BAR3 LD H, (IX +0)
LD L, (IX +1)
CALL FILL; procedure
; Pa FILL paints,
; Or erase option.
RET
BAR5 LD A, L
LD (OPC1), A
JR BAR6
FILL LD A, L; The next
; Ing line calculates
; Address option in the Attributes
AND 7
RRCA
RRCA
RRCA
ADD A, H
AND # 18
RRCA
RRCA
RRCA
OR # 58
LD H, A
LOL LD A, (HL); Take
; Byte attribute.
PUSH AF; The next
; Ing line invert
; Option interchanging
AND 7; INK and
; PAPER. BRIGHT do not teach
; Tuva.
SLA A
SLA A
SLA A
LD D, A
POP AF
AND 56
SRA A
SRA A
SRA A
OR D
LD B, (IX +2); In Regis
; Triangle B the length of the options in
; Familiarity.
FILL1 LD (HL), A; If op
; Function printed on the set
; Gotsvetnom background, the
; Cycle
INC HL; should
; Insert rows, starting
; Nye Tagged with LOL.
DJNZ FILL1
RET
BUFFS DEFS 30
STS DEFW 0
CRDS DEFW 0
ORSH DEFB # C0, # E0, # F0
DEFB # F8, # FC, # FE
DEFB # FF, # FE, # FC
DEFB # 1C, # 0E, # 0E
DEFB # 07, # 07, # 03
XORSH DEFB # C0, # A0, # 90
DEFB # 88, # 84, # 82
DEFB # 81, # 86, # B4
DEFB # 14, # 0A, # 0A
DEFB # 05, # 05, # 03
STEP EQU 2
SCRBF LD HL, (CRDS)
LD C, H
LD B, L
LD A, B
CALL # 22B1
LD (STS), HL
LD DE, BUFFS
RB0 LD B, 15
RB1 PUSH HL
LD C, 2
RB2 LD A, (HL)
LD (DE), A
INC L
INC DE
DEC C
JR NZ, RB2
POP HL
CALL DAD1
DJNZ RB1
RET
DAD1 INC H
LD A, H
AND 7
RET NZ
LD A, H
SUB 8
LD H, A
LD A, L
ADD A, 32
LD L, A
RET NC
LD A, H
ADD A, 8
LD H, A
RET
BFSCR LD HL, # 771A
LD (RB2), HL
CALL SCRBF
LD HL, # 127E
LD (RB2), HL
RET
FORM LD A, (CRDS +1)
AND 7
EX AF, AF '
LD IX, ORSH
CALL FORMS
LD IX, MS3
LD (IX +0), # AA
LD (IX +9), # AB
PUSH IX
LD IX, XORSH
CALL FORMS
POP IX
LD (IX +0), # B2
LD (IX +9), # B3
RET
FORMS LD C, 15
LD HL, (STS)
MS1 LD D, B
LD E, B
EX AF, AF '
LD B, A
EX AF, AF '
DEC B
INC B
LD D, (IX +0)
JR Z, MS21
MS2 SRL D
RR E
DJNZ MS2
MS21 LD A, (HL)
MS3 OR D
LD (HL), A
INC L
LD A, L
AND # 1F
JR Z, MS4
LD A, (HL)
OR E
LD (HL), A
MS4 DEC L
INC IX
CALL DAD1
LD A, H
CP # 58
RET NC
DEC C
JR NZ, MS1
RET
PL LD A, (HL)
LD B, E
L0 CP D
JR Z, END
INC A
DJNZ L0
END LD (HL), A
RET
MIN LD A, (HL)
LD B, E
INP AND A
JR Z, END
DEC A
DJNZ INP
LD (HL), A
RET
;
; INITIALIZATION
;
START1 LD (TABLE), HL; this from
; Individual procedure to
; Thoraya sets the coordinates
LD A, (HL); arrows
, So that it falls
; On the first option.
ADD A, A
ADD A, A
ADD A, A
LD D, A
INC HL
LD A, (HL)
ADD A, A
ADD A, A
ADD A, A
LD E, A
INC HL
LD A, (HL)
ADD A, A
ADD A, A
ADD A, A
SUB 4
LD D, A
LD (CRDS), DE
RET
TABLE DEFW 0; Here
, Will address the table.
OPC NOP; Number
; New option.
OPC1 NOP; Number
; Old options.
TABLE1 X, Y, L, X1, Y1, L1, ... , 255
; Data menu.
To work successfully requires:
Make a table describing
menu options in this order -
first coordinate of X, then Y,
then the length of the option in the familiarity.
X and Y are defined in familiarity.
How to practically use
procedure:
PROGRAM LD HL, TEXT; We print
The text menu.
CALL PRINT
LD HL, TABLE1; In HL
; Address data table
; Menu.
CALL START1; Writes
; It in a variable TABLE
, And centering the arrow.
L1 CALL START; Challenge
; Procedures arrows.
LD A, (OPC1); to A by
; Burghers option number for
, Which before pressing
, Was shot arrows
; Ka.
CP 255; If A
, 255, the arrow on the menu
, Was not hit and we again
JR Z, L1; draw
; Arrow (you can respond
; Vat to another).
CP 1 Next
, Check for any op
; Tion was an arrow and
CALL Z, PROG1; do
; Go to is the signature
; Rogrammu.
CP 2, Number NOT
, Depends on the way to
; Options when printed on
JR Z, PROG; screen
, But depends on the compiled
And Noah table.
etc.
After pressing the shot option
remains lit, but it is not always acceptable. To force the
clearing options after the command CALL START must issue the
command CALL BAR6.
Not seldom a situation where we do not need to light option
but got to know whether
pointer to where we need to
this:
PROGRAM LD HL, TABLE1; In HL hell
; Interest table that
, Consists only of code
, 255
LD (TABLE), HL; enters
; In a variable.
CALL START; Call
; Sub arrows.
LD HL, TABLE2; In HL hell
; Interest in this table
; Description.
LD (TABLE), HL; Writes
; It in a variable.
CALL COND; We are looking for but
; Action options. After the release of
; Number will be in A, but not
CP 255; in transition
; Variable OPC1!!!
JR Z, PROGRAM; Next
; Process number
; As you like.
CP 1
CALL Z, PROG
etc.
TABLE1 DEFB 255; Empty
; Table.
TABLE2 X, Y, L, 255; Infusions
; Schaya table.
At this end, let
CEE narrative. Glad if someone this information helps.
*