actually they are quite different: http://manillismo.bl...iferencias.html

Most of those differences probably come down to a phase difference in the algorithm.

Started by Wally1, Nov 10 2013 11:26 AM

134 replies to this topic

Posted Sat Feb 10, 2018 10:23 PM

actually they are quite different: http://manillismo.bl...iferencias.html

Most of those differences probably come down to a phase difference in the algorithm.

- devwebcl likes this

Posted Sun Feb 11, 2018 10:31 AM

Hi!

And in the rounding differences. Attached are two versions, the old one that does not round in the last operation and a new that does round, the results ar different, but I don't know which is really "better".

Original: Rounded:

In run-time the rounded one is less than 0.1s slower.
#### Attached Files

Most of those differences probably come down to a phase difference in the algorithm.

And in the rounding differences. Attached are two versions, the old one that does not round in the last operation and a new that does round, the results ar different, but I don't know which is really "better".

Original: Rounded:

In run-time the rounded one is less than 0.1s slower.

- rdea6, _The Doctor__ and mytek like this

Posted Sun Feb 11, 2018 10:46 AM

oddly enough I like the second one better, and that is slightly confusing to me. And in fact I've now downloaded it.

**Edited by _The Doctor__, Sun Feb 11, 2018 10:46 AM.**

Posted Sun Apr 22, 2018 9:42 AM

I posted a BASIC patch for the CoCo 3 today that replaces the regular multiply with a version that uses the hardware multiply instruction of the 6809.

It speeds up BASIC code without any other changes.

This was a quick and dirty test comparison vs regular BASIC, it hasn't been timed yet and it was just thrown together.

It will give you an idea of the speed difference. 20% to 30% faster? And there's room for improvement.

- Stephen likes this

Posted Mon Apr 23, 2018 3:11 PM

It took a while to find the right code in this thread. Here is the Atari code and the CoCo 3 patches including timing

It takes just under 14 minutes to complete, down from over 19.

That time is better than my original estimate for the 6309 which should now be under 11.2 minutes.

100 SX=144:SY=56:SZ=64:CX=320:CY=192 110 C1=2.2*SY:C2=1.6*SY 120 DIM RR(CX) 130 FOR I=0 TO CX:RR(I)=CY:NEXT I 140 GRAPHICS 8+16:SETCOLOR 2,0,0:COLOR 1 150 CX=CX*0.5:CY=CY*0.46875:FX=SX/64:FZ=SZ/64 160 XF=4.71238905/SX 170 FOR ZI=64 TO -64 STEP -1 180 ZT=ZI*FX:ZS=ZT*ZT 190 XL=INT(SQR(SX*SX-ZS)+0.5) 200 ZX=ZI*FZ+CX:ZY=CY+ZI*FZ 210 FOR XI=0 TO XL 220 A=SIN(SQR(XI*XI+ZS)*XF) 230 Y1=ZY-A*(C1-C2*A*A) 240 X1=XI+ZX 250 IF RR(X1)>Y1 THEN RR(X1)=Y1:PLOT X1,Y1 260 X1=ZX-XI 270 IF RR(X1)>Y1 THEN RR(X1)=Y1:PLOT X1,Y1 280 NEXT XI 290 NEXT ZI 80 TIMER=0 90 POKE 65497,0 140 PMODE 4,1:HSCREEN 2:SCREEN 1,1 250 IF RR(X1)>Y1 THEN RR(X1)=Y1:HSET(X1,Y1) 270 IF RR(X1)>Y1 THEN RR(X1)=Y1:HSET(X1,Y1) 300 PRINT"TIME",TIMER/60

Posted Sat May 5, 2018 6:27 AM

It took a while to find the right code in this thread. Here is the Atari code and the CoCo 3 patches including timing

It takes just under 14 minutes to complete, down from over 19.

That time is better than my original estimate for the 6309 which should now be under 11.2 minutes.

100 SX=144:SY=56:SZ=64:CX=320:CY=192 110 C1=2.2*SY:C2=1.6*SY 120 DIM RR(CX) 130 FOR I=0 TO CX:RR(I)=CY:NEXT I 140 GRAPHICS 8+16:SETCOLOR 2,0,0:COLOR 1 150 CX=CX*0.5:CY=CY*0.46875:FX=SX/64:FZ=SZ/64 160 XF=4.71238905/SX 170 FOR ZI=64 TO -64 STEP -1 180 ZT=ZI*FX:ZS=ZT*ZT 190 XL=INT(SQR(SX*SX-ZS)+0.5) 200 ZX=ZI*FZ+CX:ZY=CY+ZI*FZ 210 FOR XI=0 TO XL 220 A=SIN(SQR(XI*XI+ZS)*XF) 230 Y1=ZY-A*(C1-C2*A*A) 240 X1=XI+ZX 250 IF RR(X1)>Y1 THEN RR(X1)=Y1:PLOT X1,Y1 260 X1=ZX-XI 270 IF RR(X1)>Y1 THEN RR(X1)=Y1:PLOT X1,Y1 280 NEXT XI 290 NEXT ZI 80 TIMER=0 90 POKE 65497,0 140 PMODE 4,1:HSCREEN 2:SCREEN 1,1 250 IF RR(X1)>Y1 THEN RR(X1)=Y1:HSET(X1,Y1) 270 IF RR(X1)>Y1 THEN RR(X1)=Y1:HSET(X1,Y1) 300 PRINT"TIME",TIMER/60

Well done. Still I think executing to the half by it synmetry is much better.

Posted Sat May 5, 2018 8:01 AM

Well done. Still I think executing to the half by it synmetry is much better.

I just ported it, someone else came up with the algorithm.

My replacement line 140 has a couple old commands that aren't needed for the Super Extended Color BASIC graphics mode.

It guess it only needs the HSCREEN. I've written exactly 3 BASIC programs for the CoCo 3, and all years apart, so I'm not exactly an expert on it.

There is a 16x16 bit multiply I could patch that would speed up array indexing.

It would speed this up a little as would several other changes I made to the MC-10 ROM. That is now around 8% faster for non-math intensive stuff, so there is clearly room for improvement, but the CoCo has a lot of BASIC software that could break, where the MC-10 did not.

For benchmarking it would probably be better to use a faster plot to make timing easier.

The end result isn't as pretty though.

Fractals, foureir transforms, etc... are some other things this patch would speed up.

**Edited by JamesD, Sat May 5, 2018 8:02 AM.**

Posted Sun May 6, 2018 5:54 AM

program fedora_hat; uses crt, graph, sysutils; const sx: single = 144; sx_2 : single = 144 * 144; sy: single = 56; half: single = 0.5; sz = 64; cx = 320; cy = 192; var c1, c2, scx, scy, xf, zt, zs, fx, fy, fz, zx, zy, a, ifz: single; i: word; gd, gm, xl, xi, x1, y1: smallint; zi: shortint; tim: cardinal; rr: array [0..cx-1] of smallint; begin gd := D8bit; gm := m640x480; InitGraph(gd,gm,''); tim:=GetTickCount; c1:=2.2*sy; c2:=1.6*sy; for i:=0 to cx-1 do rr[i] := cy; scx:=cx * 0.5; scy:=cy * 0.46875; fx:=sx/64; fz:=sz/64; zt:=fx*64; ifz:=fz*64; xf:=4.71238905/sx; for zi:=64 downto -64 do begin zs:=zt*zt; xl:=trunc(sqrt(sx_2-zs)+half); zx:=ifz+scx; zy:=ifz+scy; for xi:=0 to xl do begin a:=sin(sqrt(xi*xi+zs)*xf); y1:=trunc(zy-a*(c1-c2*a*a)); x1:=trunc(xi+zx); if rr[x1] > y1 then begin rr[x1]:=y1; PutPixel(x1,y1, 15) end; x1:=trunc(zx-xi); if rr[x1] > y1 then begin rr[x1]:=y1; PutPixel(x1,y1, 15) end; end; zt:=zt-fx; ifz:=ifz-fz; end; writeln(GetTickCount - tim,' tick'); repeat until keypressed; end.

22455 ticks = ~7.485 min

**Edited by tebe, Sun May 6, 2018 5:56 AM.**

Posted Sun May 6, 2018 8:46 AM

22455 ticks = ~7.485 min

Nice! I've always preferred C over Pascal, but I liked Pascal better than BASIC.

A good compiler is always going to beat interpreters.

Having to parse lines and convert numerical constants every time a line is executed really slows down most interpreters.

- devwebcl likes this

0 members, 0 guests, 0 anonymous users