Jump to content
IGNORED

Graphics 8 Fedora Hat


Wally1

Recommended Posts

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: post-18634-0-31760700-1518366566.png Rounded: post-18634-0-91478400-1518366585.png

 

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

fedora-orig.xex

fedora-round.xex

  • Like 7
Link to comment
Share on other sites

  • 2 months later...

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.

post-10422-0-35902300-1524411463_thumb.jpg

  • Like 3
Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

fedorahat_pascal.zip

Edited by tebe
  • Like 4
Link to comment
Share on other sites

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.

 

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

I tried it using turbo basic xl 1.5 with altirra emulator and it ran 3 times faster if I remember correctly !

 

About 1 houre instead of 3 houres with atari basic.

 

In quick basic 64 on windows 10 64 bits I think I got over 100 frames per second... on a 4.0 ghz cpu...

 

I intend to try it on VICE emulator for pet cbm computer with hires video card emulator... version 3.2 (or 3.3) ? emulates hires grafx I think...

 

To be continued...

Edited by TheGreatGrizz
Link to comment
Share on other sites

I already did a version for the C64 on the VICE emulator. It was nice because the 320X200 resolution matched the calculated extents in the program without having to trap for an out of bounds error as the Atari code has to do. Unfortunately, the lack of any plot or drawto commands in Commodore Basic V2.0 made the graphics very "POKEy"

  • Like 1
Link to comment
Share on other sites

Latest run on Atari800/Incognito (and 800XL/Ultimate):

 

1. Assembler / Machine code: 00m:16.80s

2. Altirra Basic v1.55: 11m:27.31s

3. TurboBasic v1.50: 12m:15.22s

 

Hand-timed, directly, to avoid fouled-up internal timers.

 

Above results achieved with high-performance ROMs that I posted a while ago, as well as shutting down Antic for max. 6502 throughput (now supported NATIVELY by such ROMs thanks to Atari's own vestigial code left in there since 1983, and no longer needed in Basic or any other high-level code).

Edited by Faicuai
  • Like 2
Link to comment
Share on other sites

would be cool to have you post up the complete fedora with O.S. package in a zip for all to enjoy right here in this thread. perhaps a blurb on how the folks can do the burn and install and all the methods in between. I kind of would like this to become the official rom of the line... :)

  • Like 1
Link to comment
Share on other sites

would be cool to have you post up the complete fedora with O.S. package in a zip for all to enjoy right here in this thread. perhaps a blurb on how the folks can do the burn and install and all the methods in between. I kind of would like this to become the official rom of the line... :)

 

Good idea!

 

Been working on putting this together, with some extra bonus items.

Here's the most recent update:

 

  1. Assembler / Machine code: 00m:16.80s
  2. FastBasic 3.5: 09m:05s (=> includes spatial optimization that chops 10secs. of runtime, about 2,500 FO ops).
  3. Altirra Basic v1.55: 11m:27.31s
  4. TurboBasic v1.50: 12m:15.22s

 

I am attaching two .ATRs:

 

  1. First one is a hand-picked collection of system BIOS/ROMS, to be used (preferably) on Incognito and/or Ultimate (because it is breeze to upload them there, via SDX and UFlash).
    • They can also be burned in a compatible EPROM chip, if that's what is available.
    • All of these ROMs have been properly signed and will pass checksum tests, where applicable.
    • So far, they will beat the shit (in relative terms) out of practically anything that is out there, math-wise.
    • A special, custom high-performance FP version of Avery's Altirra ROM has been included (for testing / joy purposes).
    • Altirra Basic 1.55 8K rom also included, which combined with the above, puts the A800/XL into early (stock) Intel 8088 / 8086 territory, while STILL being interpreted, and STILL fitting 8K, also matching or exceeding Z80 performance (when it comes to most of these classical benchmarks).
    • Anything that shows "XE0Xi___" is for INCOGNITO (A800), and "XE0Xu___" is for Ultimate (XL).
    • F__ means only 1200XL function-keys revived. FP_ means latter+ FP pack. FPH means latter + XL Help key enabled.
    • BIOS-Ultimate_Incognito.atr
  2. Second one is a collection of classical (hand written and/or ported) benchmarks, in both Basic and machine-executable code:
    1. .BAS stands for Atari Basic
    2. .FAB stands for Fast Basic (FEDORA02.FAB, from the above update is there)
    3. .MSB stands for Microsoft Basic
    4. .CPM stands for CPM text file to be run with Microsoft Basic 5.29 (CPM). NO NEED to translate with ICDS copy function.
    5. Most basic files include extensive cross-platform results in REM section, for your convenience.
    6. .OBJ means that is directly executable from SDX / DOS prompt.
    7. ICDS utility to transfer from SIO attached ATR into IndusGT (#1) SIO floppy drive.
    8. A revised Trub Terminal with better colors.
    9. Scratchpad.atr

Have fun!

Edited by Faicuai
  • Like 3
Link to comment
Share on other sites

Here is an updated Python 3 version of the program. Should run on any platform which has Python 3 installed:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------
# Name:        archimedes.py
# Purpose:     implement the Archimedes' spiral prgoram in Python 3.x
#
# Author:      fujidude for just the Python version, original code
#              Charles Bachand, pub. Antic magazine, issue 7, pp.60-61.
#
# Created:     2018-10-29
# ----------------------------------------------------------------------------

# import necessary modules
import tkinter
import math


def end():
    rootwin.destroy()


rootwin = tkinter.Tk()  # main (root) application window based on Tkinter
rootwin.wm_title("Archimedes' Spiral")

quitBtn = tkinter.Button(rootwin, text="Exit", command=end)
quitBtn.pack(side="bottom")

graphzone = tkinter.Canvas(rootwin, width=320, height=192, bg="lightblue")
graphzone.pack()

XP = 144
XR = 4.71238905
XF = XR / XP

for ZI in range(-64, 65):
    ZT = ZI * 2.25
    ZS = ZT * ZT
    XL = int(math.sqrt(20736 - ZS) + 0.5)
    for XI in range(0 - XL, XL+1):
        XT = math.sqrt(XI * XI + ZS) * XF
        YY = (math.sin(XT) + math.sin(XT * 3) * 0.4) * 56
        X1 = XI + ZI + 160
        Y1 = 90 - YY + ZI
        graphzone.create_oval(X1, Y1, X1, Y1, fill="white")
        graphzone.create_line(X1, Y1+1, X1, 191, fill="white")

rootwin.mainloop()

And then here is a screenshot of it after run:

 

post-40960-0-00821200-1540879920.png

Edited by fujidude
  • Like 1
Link to comment
Share on other sites

  • 2 months later...

My ports to the Tandy Color Computer 1/2 and 3. The 1/2 run in the PMODE 4 screen 256x192 black on white background, using the high speed POKE in there. The CoCo 3 runs in its highest 640x192 BASIC resolution screen, also with the high speed POKE plus a little banner added just for fun once the graph is finished.

The TRS-80 Model 4 version I did more or less is the same as the CoCo 3.

 

- - - - - - - - - -

 

10 ' CoCo 1/2 Archimedes Hat
20 '
40 ' from the AtariAge Forum
50 '
90 POKE 65495,0
100 SX=116:SY=44:SZ=51:CX=256:CY=192
110 DIM RR(CX)
120 FOR I=0 TO CX:RR(I)=CY:NEXT I
130 PMODE 4:PCLS 1:SCREEN 1,1:COLOR 0
140 CX=CX*.5:CY=CY*.46875:FX=SX/64:FZ=SZ/64
150 XF=4.71238905/SX
160 FOR ZI=64 TO -64 STEP -1
170 ZT=ZI*FX:ZS=ZT*ZT
180 XL=INT(SQR(SX*SX-ZS)+.5)
190 ZX=ZI*FZ+CX:ZY=CY+ZI*FZ
200 FOR XI=0 TO XL
210 XT=SQR(XI*XI+ZS)*XF
220 YY=(SIN(XT)+SIN(XT*3)*.4)*SY
230 X1=XI+ZX:Y1=ZY-YY
240 IF RR(X1)>Y1 THEN RR(X1)=Y1:PSET(X1,Y1)
250 X1=ZX-XI
260 IF RR(X1)>Y1 THEN RR(X1)=Y1:PSET(X1,Y1)
270 NEXT XI,ZI
280 SOUND 180,5
290 GOTO 290

 

- - - - - - - - - -

 

10 ' CoCo 3 Archimedes Hat
15 ' 640x192 HSCREEN Version
20 '
30 ' from the AtariAge Forum
40 '
90 POKE 65497,0:ON BRK GOTO 300
100 SX=256:SY=56:SZ=64:CX=640:CY=192
110 DIM RR(CX)
120 FOR I=0 TO CX:RR(I)=CY:NEXT I
125 RGB:PALETTE 0,0:PALETTE 1,18
130 HSCREEN 3:HCLS 0
140 CX=CX*.5:CY=CY*.46875:FX=SX/64:FZ=SZ/64
150 XF=4.71238905/SX
160 FOR ZI=64 TO -64 STEP -1
170 ZT=ZI*FX:ZS=ZT*ZT
180 XL=INT(SQR(SX*SX-ZS)+.5)
190 ZX=ZI*FZ+CX:ZY=CY+ZI*FZ
200 FOR XI=0 TO XL
210 XT=SQR(XI*XI+ZS)*XF
220 YY=(SIN(XT)+SIN(XT*3)*.4)*SY
230 X1=XI+ZX:Y1=ZY-YY
240 IF RR(X1)>Y1 THEN RR(X1)=Y1:HSET(X1,Y1)
250 X1=ZX-XI
260 IF RR(X1)>Y1 THEN RR(X1)=Y1:HSET(X1,Y1)
270 NEXT XI,ZI
280 SOUND 180,5
285 HPRINT(0,0),"El Sombrero de Arquimides"
290 GOTO 290
300 POKE 65496,0:RGB:END

  • Like 2
Link to comment
Share on other sites

  • 3 years later...
  • 3 months later...
On 8/14/2022 at 6:18 PM, Ricky Spanish said:

With stock 1200XL, BASICXE w/ extension disk, did some optimizations to the code, 5min 15sec runtime. 

Seems I made an error. I was using an already modified 'fedora' program. Rookie mistake. I since used the real Archimedes Spiral program from ANALOG. With BASICXE w/extensions disk runtime went from the 3 hour original, to 1hr 10mins 25 secs. 1hr 9mins 59 secs with the FAST command. Zero modifications to the program. I must say the original program looks smoother/better than any of the modified ones. In my humble opinion.

Link to comment
Share on other sites

  • 2 months later...
On 4/23/2018 at 3:11 PM, JamesD said:

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.

I timed it at 11.7 minutes.  Okay, I was off by half a minute on the estimate.

Link to comment
Share on other sites

  • 1 year later...

I came over to this topic from a discussion about Turbo Basic XL on the Atari 8-bit. I love seeing these 3D "curve" programs on the Atari. When I was growing up, I always saw these on other computers, but not the Atari.

 

I tried compiling the optimizations I saw discussed between @dmsc and @devwebcl, and only saw a performance improvement of a few minutes compared to the interpreted versions.

 

The fastest I was able to get was 14.2 minutes with dmsc's code:

 

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

 

This figures, since as someone on here said, compiling doesn't speed up the trig functions, nor drawing on the screen, since one relies on TB's runtime, and the other depends on the OS. So, it's just getting to the same functions faster. :)

 

I was unable to get the Compute version of "Fedora" (which started this discussion) to run properly after compiling (the runtime complained of an invalid value at Line 90). The interpreted version ran fine. Pretty typical for the compiler...

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...