Jump to content

Photo

Graphics 8 Fedora Hat


134 replies to this topic

#126 Spaced Cowboy ONLINE  

Spaced Cowboy

    Chopper Commander

  • 206 posts
  • Location:San Jose, CA

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. 



#127 dmsc OFFLINE  

dmsc

    Moonsweeper

  • 389 posts
  • Location:Viņa del Mar, Chile

Posted Sun Feb 11, 2018 10:31 AM

Hi!
 

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: fedora-orig.png Rounded: fedora-round.png

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

Attached Files



#128 _The Doctor__ OFFLINE  

_The Doctor__

    River Patroller

  • 4,505 posts
  • Location:10-0-11-00:02

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.


#129 tebe OFFLINE  

tebe

    Dragonstomper

  • 739 posts
  • Location:Poland

Posted Tue Feb 13, 2018 2:06 AM

impressive job DMSC

 

CA65 -> MADS RELOC in attachment

 

Attached Files



#130 JamesD OFFLINE  

JamesD

    Quadrunner

  • 8,195 posts
  • Location:Flyover State

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.

CoCoPatch1HiRes.jpg



#131 JamesD OFFLINE  

JamesD

    Quadrunner

  • 8,195 posts
  • Location:Flyover State

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



#132 devwebcl OFFLINE  

devwebcl

    Stargunner

  • 1,207 posts
  • Location:Chile

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.

#133 JamesD OFFLINE  

JamesD

    Quadrunner

  • 8,195 posts
  • Location:Flyover State

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.


#134 tebe OFFLINE  

tebe

    Dragonstomper

  • 739 posts
  • Location:Poland

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

Attached Files


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


#135 JamesD OFFLINE  

JamesD

    Quadrunner

  • 8,195 posts
  • Location:Flyover State

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.
 






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users