Warning. Longer post.
armypavarmy wrote:I have many manuals for Plus / 4 ... and Vic20 downloaded in pdf. [...] The remarkable thing is that all these variants and others which I found [are] not described.
O.K. - I took a quick peek at the manuals for download at
DLH/Bombjack and indeed I am puzzled: neither is there any mention of the "length;angle"-syntax, nor (what we hadn't discussed thus far) of relative co-ordinates, where an explicit "+" or "-" precedes the value, and which is used to position the next point relative to the current "hires cursor" position. Strange. My german instruction book bundled with my C116 (at those times, around 1985) was much more verbose in that matter.
But how do you see it accepted and working[?]
Well, I happen to know what the graphics commands and their parameters are supposed to do. Didn't even require me to actually run those programs.
If you make any possible additions OK. [...]
As I wrote, a port of these programs does not require any changes to MINIGRAFIK or MAXIGRAFIK.
I just use the already available graphics commands.
For that matter, here's the port of "XIX.PRG" (
download), which draws the helical figurine with rotated ellipses. Lines 12..24 contain the translation of the CIRCLE command of BASIC V3.5/V7 with all its parameters. The sub-routine requires the array S() dimensioned in line 10 and S() - together with a few auxiliary variables - being initialised in lines 26 and 27. Lines 28..39 then call the ported circle sub-routine as equivalent to the FOR loop in XIX.PRG (+4):
Code: Select all
10 DIMS(90):GOTO26
11 :
12 B=W*B:IFD>=ETHENE=E+F
13 IFRTHENI=D:D=R:GOSUB20:U=C:V=S:D=I
14 GOSUB20:GOSUB18:I=X:J=Y
15 D=D+K:IFD>ETHEND=E
16 GOSUB20:GOSUB18:@G,I,JTOX,Y:I=X:J=Y:IFD<ETHEN15
17 RETURN
18 X=S*A:Y=C*B:IFRTHENZ=U*Y-V*X*W:X=U*X+V*Y/W:Y=Z
19 X=M+X+.5:Y=N-Y+.5:RETURN
20 Z=D-F*INT(D/F)
21 IFZ<QTHENS=S(Z):C=S(Q-Z):RETURN
22 IFZ<HTHENS=S(H-Z):C=-S(Z-Q):RETURN
23 IFZ<TTHENS=-S(Z-H):C=-S(T-Z):RETURN
24 S=-S(F-Z):C=S(Z-T):RETURN
25 :
26 Q=90:H=180:T=270:F=360:W=5/3
27 FORZ=0TO90:S(Z)=SIN({PI}*Z/180):NEXT
28 @ON:@CLR
29 :
30 G=1:N=77:A=30:K=10
31 :
32 FORP=0TO360STEP6
33 M=35+P*.25
34 B=17:D=0:E=360
35 R=P:GOSUB12
36 NEXT
37 :
38 GETA$:IFA$=""THEN38
39 @RETURN
This is for MINIGRAFIK. A version for MAXIGRAFIK would just leave out "@ON" and replace "@CLR" with
CLEAR in line 28, and replace lines 38 and 39 with a single line with a
SHOW command. In line 16, replace "@[...]" with "DRAW[...]"
The ported CIRCLE algorithm additionally needs to take into account the non-square pixel-aspect ratio of the hires pixels with the VIC-I chip. There's already an optimization for non-rotated ellipses (R=0) - the IF statements in lines 13 and 18 are only executed, when R<>0. In line 18, the IF statement contains a modified version for the co-ordinate rotation which honours the aspect ratio. Rotated ellipses take roughly 40% more time to draw because of the extra calculations.
It also takes some thoughts to honour the orientation of the co-ordinate system (it's left-handed here), that rotation angles work clock-wise, and that start- and end-angles are defined from the 12 o'clock position (i.e.
negative Y-axis in their own co-ordinate system). Mathematicians usually use right-handed co-ordinates, counter-clockwise angles, and start- and end-angles defined from the 3 o'clock position (
positive X-axis) - but we want (near complete) compatibility to the CIRCLE command of BASIC 3.5/7.0.
What we can't get is the same resolution as on the TED, i.e. 320x200. With the VIC-20 hardware, MINIGRAFIK allows for the maximum resolution that can be displayed without using the lower 1K ($0000..$03FF) or interrupts (or both). And that is 160x192.
Therefore, if the overall
look of XIX.prg is desired to be retained, we need to rescale some 'parameters' of the emulated circle command in advance. The original FOR loop reads:
Code: Select all
[...]
20 FOR X=0 TO360 STEP6
30 CIRCLE 1,65+X*.5,80,60,33,,,X
40 NEXT
[...]
This results in 61 ellipses, whose centers glide along a line at Y=80 (third parameter) and X co-ordinates ranging from 65 to 245. The whole drawing ends up (nearly) symmetrical to X=160. The half-axes are 60 and 33 - the missing two parameters mean start_angle=0, end_angle=360 - i.e. draw whole ellipse, not an arc. The last parameter specifies the rotation angle, i.e. the ellipses are ultimately turned over a full angle as they are drawn.
For the VIC-20, we mainly have to take into account the halved resolution in X direction. *Both* half-axes are divided by two (i.e. we take 30 and 17), but note the sub-routine will re-scale the Y-axis with "B=W*B" in line 12, so the original value of the Y-half-axis is nearly restored. I did it this way, so if you set both values equal on entry to the sub-routine, it actually draws a
circle (and the user doesn't have to pre-scale the Y-half-axis to get a round circle). The definition of
W=5/3 in line 26 is valid for PAL. NTSC users should replace it with
W=3/2.
Normally, the CIRCLE command of BASIC V3.5/V7 uses a default angle increment value of 2° (in the sub-routine, parameter K).
I set it to 10 for my program. Not only does it make it faster without any great loss of accuracy, actually, the smaller value leads to the jagged appearance of the ellipses in BASIC 3.5.
The Y-co-ordinates of the ellipse centers are assumed to retain their position relative to the vertical resolution: 80/200 = 40% (+4) => 40%*192 = 77 (VIC-20, MINIGRAFIK). If finally the figure is supposed to be centered at X=80, the "circle" command in line 30 then becomes:
Code: Select all
30 CIRCLE 1,35+X*.25,77,30,17,0,360,X,10
That translated command in turn is re-written with parameter assignments (in the ported program, see lines 30, 33, 34 and 35) and a GOSUB to line 12. The FOR loop in the port replaces P for X, as X is committed for use by the sub-routine. For completeness, here's a cross-reference list - the parameters of the circle sub-routine are highlighted with "*)":
Code: Select all
*) A: horizontal half-axis (before rotation)
*) B: vertical half-axis (before rotation)
C: C:=COS(D)
*) D: start angle, running angle
*) E: end angle
F: F:=360
*) G: draw colour
H: H:=180
I: old (transformed) x-offset, D temporary
J: old (transformed) y-offset
*) K: angle increment
L:
*) M: x-co-ordinate of midpoint
*) N: y-co-ordinate of midpoint
O:
P:
Q: Q:=90
*) R: rotation angle
S: S:=SIN(D)
T: T:=270
U: U:=COS(R)
V: V:=SIN(R)
W: W:=5/3 (pixel aspect ratio)
X: (transformed) x-offset
Y: (transformed) y-offset
Z: reduced angle, Y temporary
Ports of the other 3 programs (resp., to MAXIGRAFIK) left as exercise for the reader.
tl;dr just run XIX.prg on the +4, and the ported version (contained in the *.zip below) on the VIC-20 with MINIGRAFIK and compare the visual result.