Error article "3D graphics"
in the ZX-Power # 3
(C) 1999, Alexander Pelepeychenko
__________________________________________
From the Editor:
In the last issue of the journal published an article about
working with three-dimensional objects, prepared by our friends
from Avalon - (C) Ruff'Viator. And then after a while one of
the readers said us about his comments to the above
article. Publish them here, hoping to
comments from Ruff'a ...
*
I uploaded like a ZX-Power # 3 and became its
read. Actually, not surprising
There. So, I read it, read and
suddenly come across this article. As I
'm a fan of 3D graphics and various
there effects, I decide to look into this
method. Besides promising preface kindle interest in the below
mentioned method.
Subsequently, of course, I realized the ruleznost this way,
but I must say that at first I was not only unable to kerf
in the attached code, but also put under great
questioned the theoretical part (it I, too,
not immediately kerf). Go tell that way very similar to that
proposed in the SPECTRUM EXPERT # 2 "mid-point method."
Carefully read a dozen times this
article, and so did not understand much, I decided
fill it and check its performance. And then began the most
interesting. Firstly, at the end of the procedure I saw K64
it is not clear from grafted a piece of code (and
even more precisely 2 pieces: the first - a label LOOP4
to finish second - what on that tag to the command RET). After
studying these pieces, I realized that it counts the same axes,
but with taking into account the nonzero value of 3D-center.
Generally, it (the piece) did not really need (Except for
clarity). But ... (Read the second part of the article).
A little closer examination of the text, I decided that most
likely some part of the text has been lost. At this point I was
prompted that the drawings are referred to with number 2 and 3,
and a trace of them there not here.
Ca. Ed.: Print everything that was ...
It turned out that the coordinates of points lured God knows
how, and printing is generally incorrect.
Then it dawned on me - errors in the article.
ALASM was loaded, there was nothing,
and I set to debug the program. Theoretical part, I took it for
granted without checking it, and here's the code as it turned
out, a little did not fit the theory.
Errors generously endowed sub AX.
It is unclear why in the beginning of this procedure was
something like:
LD A, E
SUB 32
LD E, A
... , And so on with registers
; L, C, L '
Ca. Ed.: We have not added them back. :))
Further, the reason otfonarnoy print points
and it is unclear what the sequence of storage space, these
points have been lured to places zasylanie stack coordinates.
Of course, I understand that some errors can compensate each
other and not considered an error (which could be
place in the sources of the author), but in the above listing
this did not happen. Probably, these errors arose because the
code article was written from memory. All code that you see
here are drawn from the already operating source, so errors of
this kind is unlikely. I will sdes The entire procedure AX,
since 80% of its part in POWER # 3 are incorrect. At the
entrance of AX in registers are given the coordinates of key
points, already designed into the screen. And in the older half
of the register sits X-coordinate.
TABAX EQU 250; entry:
; DE = 3D Center
AX LD HX, D; BC = the end of the z-axis
LD LX, E; HL = the end of the x-axis
EXX; HL '= end of the y-axis
LD A, L; in POWER # 3
PUSH AF; these PUSH'y
EXX; were
LD A, C; bit
PUSH AF; beguiled
LD A, L;
PUSH AF;
LD A, H;
PUSH AF;
EXX;
LD A, H;
PUSH AF;
EXX;
LD A, TABAX
LD (VAR), A
LD A, B; in POWER # 3 is LD A, H
LD B, HX
CALL K64; (*)
POP AF
LD B, HX
CALL K64
POP AF
LD B, HX
CALL K64
POP AF
LD B, LX
CALL K64; (*)
POP AF
LD B, LX
CALL K64
POP AF
LD B, LX
CALL K64
RET
VAR DEFB 0
Explanation (*) see the second part.
Not passed the procedure of typos and K64. In
a place where there are such teams (look for
them after the label LOOP3):
LOOP3
......
DUP 1964
SBC HL, DE
LD A, H
EXX
......
The replacement for:
DUP 1964
LD A, H
SBC HL, DE
EXX
......
That is the command LD A, H should be
BEFORE SBC HL, DE, otherwise the table is
shifted by 1 byte down.
More errors and inaccuracies I have found.
And despite all this, I want to
noted that, probably, if not for these
errors, I would have never figured would
principle of this method. Of course,
important - the idea, but tend to err each.
Well, with errors eliminated, and now my
survey.
Part 2
The method is very efficient, although you can make it even
faster, more inflate K64. This can be achieved if the
one of the x-coordinate in the calculation of the axes to add
HX, and the same is done with one from the y-coordinate, and
then remove these additions from the procedure of drawing
points. Winnings will be exactly 12 cycles per point. In this
case we can accommodate that piece of code in K64, which I
mentioned above. (Maybe he was fitted for this, but comment to
him was lost in the wording).
Ca. Ed.: Well, that's "attack"! :)) I
We, in the editorial, "Lost" can only
the whole article entirely, but then we do not publish ... ;))
To do this, call it a label, such as K64_1.
Now you need to CALL K64, marked
(*) (See above), replaced by CALL K64_1
and remove the command ADD A, HX and ADD A, LX from
procedures for the withdrawal points.
Idea was to make the 4D (5D, 6D ...) rendering, but there
was no time, and without a good spinner / Fly to do it there
sense.
In general, I thought: 'Why use
alternative register hl 'in K64 if
there are still unused BC??? Then (for
cancellation account EXX'ov) for rendering the same axis in
both coordinates can save another 8 * 64 * 2 = 1024 + beats
about 256 bytes, where 8-sum EXX'ov in cycles, 64 - y
us there DUP 64, 2 - have the same axis two coordinates (x and
y). And these axes 3 pieces ... " I thought so nakodil more
rapid procedure, which saves about 3,072 cycles on each
rendering axes.
K64
CP B; this procedure
JP C, LOOP1; entirely
SUB B; pulled out of the working
LD L, A; source, so that
LD H, 0 errors hardly
ADD HL, HL; there
ADD HL, HL
EX DE, HL
LD HL, 0
LOOP2
LD A, (VAR)
LD B, A
INC A
LD (VAR), A
LD C, 0
DUP 1964
LD A, H
ADD HL, DE
LD (BC), A
INC C
EDUP
RET
LOOP1
LD C, A
LD A, B
SUB C
LD L, A
LD H, 0
ADD HL, HL
ADD HL, HL
EX DE, HL
LD HL, 0
LOOP3
LD A, (VAR)
LD B, A
INC A
LD (VAR), A
LD C, 0
DUP 1964
LD A, H
SBC HL, DE
LD (BC), A
INC C
EDUP
RET
K64_1
CP B
JR C, LOOP4
SUB B
LD L, A
LD H, 0
ADD HL, HL
ADD HL, HL
EX DE, HL
LD H, B
LD L, 0
JP LOOP2
LOOP4
LD C, A
LD A, B
SUB C
LD L, A
LD H, 0
ADD HL, HL
ADD HL, HL
EX DE, HL
ADD A, C
LD H, A
LD L, 0
JP LOOP3
And another thing. If we really and erase the screen An
image to display new, it is desirable to do so as quickly as
possible, that I propose to make a change
POP HL: LD (HL), 0: POP HL .....
this option:
XOR A
POP HL: LD (HL), A: POP HL: LD (HL), A. ..
In general, I was not able to draw
Normal 3D object consisting entirely
of dots and decided (but did not) mix with draw'y. Naturally,
the proposed stiralka was unacceptable.
However, at the points easier to cut off the invisible and
the setting for the screen part, but draw the object ....( me
after trying to draw the idea to make a mini 3D STUDIO).
Problem of perspective can best be met
prospectively sproektiravav 3D coordinate system.
That's all.
__________________________________________