Jump to content
IGNORED

Please help a newbie to run a program


vol

Recommended Posts

Hi

I am a 6502 enthusiast but I used mostly Commodores.  I had some experience with the Atari but it was long ago. Now I am trying to learn the Atari again.

There is an interesting project - http://forum.6502.org/viewtopic.php?f=1&t=6323 - it draws Mandelbrot using ASCII chars.

Would anybody like to help me to run it on the Atari? I use Atari 800 emulator.

How to convert Basic text to a format which may be accepted by the emulator?

  100 rem a basic, ascii mandelbrot
  110 rem
  120 rem this implementation copyright (c) 2019, gordon henderson
  130 rem
  140 rem permission to use/abuse anywhere for any purpose granted, but
  150 rem it comes with no warranty whatsoever. good luck!
  160 rem
  170 c$ = ".,'~=+:;[/<&?oxOX# " : rem 'pallet' lightest to darkest...
  180 so = 1 : rem set to 0 if your mid$() indexes from 0.
  190 mi = len(c$)
  200 mx = 4
  210 ls = -2.0
  220 tp = 1.25
  230 xs = 2.5
  240 ys = -2.5
  250 w = 38
  260 h = 21
  270 sx = xs / w
  280 sy = ys / h
  290 q = time
  300 for y = 0 to h
  310   cy = y * sy + tp
  320   for x = 0 to w
  330     cx = x * sx + ls
  340     zx = 0
  350     zy = 0
  360     cc = so
  370     x2 = zx * zx
  380     y2 = zy * zy
  390     if cc > mi then goto 460
  400     if (x2 + y2) > mx then goto 460
  410     t = x2 - y2 + cx
  420     zy = 2 * zx * zy + cy
  430     zx = t
  440     cc = cc + 1
  450     goto 370
  460     print mid$(c$, cc - so, 1);
  470   next
  480   print
  490 next
  500 print
  510 print (time - q) / 60
  520 end

What to do next?  Thank you.

Link to comment
Share on other sites

@vol You can always try ctrl c ctrl v-ing the text into the emulator. If that doesn't work then you have to type it in yourself. Also this subforum is mainly used for designing your own programs for the 5200 and A8 platform. You can always ask questions in the main A8 subforum though!

  • Like 1
Link to comment
Share on other sites

First up you'll need it as uppercase.

 

Next up you'd want optimizations.

Easiest is to do statement stacking, Atari Basic runs much better if there's less total line #s to have to scan for when the program branches.

 

Also string handling is way different to other Basics - no MID$ so you'd need to convert that to our way of doing it.

 

In Altirra I think you'd need to use the right-click with mouse pointer - CTRL-V would likely just get passed to the Atari.

  • Like 1
Link to comment
Share on other sites

I ported this over for you, and attached the disk.  It may not work 100%, but hopefully you can tweak it now.

 

Some notes.  In line 170 it has a tilde ~, which is not a valid character on the Atari so I replaced it with a minus sign -.

 

On the Atari, string are similar to the way they are in C, so you have to dimension their size.  So I added.

 

165 DIM C$(20)

 

Also no MID$

 

460 PRINT C$(CC-SO,CC-SO);

 

Also, in vanilla Atari Basic you can't just us NEXT (470,490).  So I replaced with NEXT X and NEXT Y where appropriate.

 

I saved the program as "MANDEL.BAS"

 

 

 

Mandel.atr

Edited by Gibstov
Problems with disk
  • Like 3
Link to comment
Share on other sites

Thanks for help!  I could run it!  However I had to set proper margins and fight with timer.  IMHO it is a large miss that Atari Basic doesn't have support for the timer. I also can't use Ctrl-C and Ctrl-V. :(

I have added and changed the next lines:

166 POKE 82,0 : POKE 83,39 : GRAPHICS0 : REM PROPER MARGINS
290 Q0 = PEEK(20): Q1 = PEEK(19): Q2 = PEEK(18)
505 T0 = PEEK(20): T1 = PEEK(19): T2 = PEEK(18)
510 PRINT ((T2 - Q2)*65536 + (T1 - Q1)*256 + (T0 - Q0)) / 50 : REM 60 FOR NTSC

Indeed that timer calculation needs the interrupts disabled to be always correct. It is a bit surprising that there is no Basic syntax highlight for posted code.

I have only one more question: is it possible to turn Atari 800 emu into fast (full throttle) mode? 

EDIT. I can google information about Altirra Basic.

atari-mandel-all.png

Edited by vol
Link to comment
Share on other sites

16 minutes ago, vol said:

also can't use Ctrl-C and Ctrl-V. :(

I don't know about Atari800, but in Altirra, you can highlight on screen text using left mouse and use 

right mouse to copy and paste.

 

If I write some code in Notepad++, I can select/copy in Notepad++ then in Altirra right click screen and paste

the program gets entered, have to press return on last line though

 

Link to comment
Share on other sites

4 hours ago, TGB1718 said:

I don't know about Atari800, but in Altirra, you can highlight on screen text using left mouse and use 

right mouse to copy and paste.

 

If I write some code in Notepad++, I can select/copy in Notepad++ then in Altirra right click screen and paste

the program gets entered, have to press return on last line though

 

Does Altirra have Full throttle button?

 

3 hours ago, ivop said:

 

$ atari800 --help |grep -i fast
    -turbo           Run emulated Atari as fast as possible

 

They have missed this option in the man-page. :( And it is rather useless: what to do with a computer which always runs at more than 1000% speed? We need an option to toggle fast/normal mode.

Link to comment
Share on other sites

Hi!

1 hour ago, vol said:

Does Altirra have Full throttle button?

 

They have missed this option in the man-page. :( And it is rather useless: what to do with a computer which always runs at more than 1000% speed? We need an option to toggle fast/normal mode.

Altirra: Just keep F1 pressed.

Atari800: Toggle with F12

 

Have Fun!

 

  • Like 2
Link to comment
Share on other sites

On 11/7/2020 at 5:47 PM, vol said:

Thanks for help!  I could run it!  However I had to set proper margins and fight with timer.  IMHO it is a large miss that Atari Basic doesn't have support for the timer.

Turbo BASIC XL has a TIME function that will allow direct POKE-less access to the timer. IIRC the timer being interrupted should not be a problem if you don't access the floppy (which the program doesn't). The timer is not 100% exact as it does not run at exactly 50/60 ticks per second and therefore needs a correction every few hundred jiffies to stay in sync with a clock.

  • Like 1
Link to comment
Share on other sites

@vol, there are several free and Atari compatible BASICs (supersets of the inbuilt BASIC) that would be great to checkout...plus they are faster >>https://seriouscomputerist.atariverse.com/pages/language/language.basic.htm

 

Turbo BASIC XL (TBXL also comes with a compiler and linker), Altirra Extended BASIC (Turbo BASIC XL compatible, plus PMG commands, etc), Altirra BASIC (more of a directly compatible, drop-in for Atari BASIC),U BASIC (Atari BASIC compatible and many more KB of available memory). BASIC XL and BASIC XE from OSS are mostly compatible, but also greatly expanded. Fast BASIC v4.4 is a more modern BASIC, relatively speaking. It has inbuilt PMG and DLI commands...and is smoking fast. Advan BASIC is also a greatly expanded BASIC (relatively speaking) including DLI, PMG, etc. routines. It has some pretty good inbuilt routines to play sound/music and PMG during the VBI. There are a couple of issues in Advan that were never fixed.

Link to comment
Share on other sites

  • 2 weeks later...
On 11/14/2020 at 1:05 AM, slx said:

Turbo BASIC XL has a TIME function that will allow direct POKE-less access to the timer. IIRC the timer being interrupted should not be a problem if you don't access the floppy (which the program doesn't). The timer is not 100% exact as it does not run at exactly 50/60 ticks per second and therefore needs a correction every few hundred jiffies to stay in sync with a clock.

Would you like to type a formula which can correct a result from peeking addresses 18-20?  I use only ROM-Basics for my tests.  It is interesting that Altirra Basic is about 160% faster for this Mandelbrot than the standard Basic!

Edited by vol
Link to comment
Share on other sites

On 11/29/2020 at 10:40 AM, vol said:

Would you like to type a formula which can correct a result from peeking addresses 18-20?  I use only ROM-Basics for my tests.  It is interesting that Altirra Basic is about 160% faster for this Mandelbrot than the standard Basic!

Turbo BASIC XL, Fast Basic, Advan BASIC, Altirra Extended BASIC, etc. have inbuilt TIME functions...so no need to recreate the wheel in those languages; they aren't ROM based, however. If you are using Altirra or other emulator, using a ROM based BASIC makes no sense, since you are loading virtual files in any case.

 

Altirra BASIC implements faster floating point routines. It can be burned to an EPROM and used in a real machine :) It is pretty neat to play some of the old type-in games, my favorite being Risky Rescue, and running them in one of the faster flavors of Atari BASIC compatible BASICS.

 

I will play about with the above code and move it over to a couple of different BASICs for comparison. Attached is the code, as publised by Gibstov above, with the code you added for the left/right margins and timers, and dropped directly into Turbo BASIC XL and compiled. Using a stock Altirra NTSC machine the time is 64.51 seconds.

 

 

mandel2.com

  • Like 2
Link to comment
Share on other sites

Turbo BASIC XL (not 'compiled' as directly above) and BASIC XE (a ROM based BASIC) both run your program a touch under 155 seconds.

EDIT: For s&!^$ and giggles, I ran the compiled TBXL version with a Rapidus machine = 7.716 seconds

 

I moved it over to Advan BASIC, having high hopes that it'd do better than the compiled TBXL version, but it was a good bit slower.

 

The floppy image attached has three Advan BASIC files on it. MANDEL03.COD is the quickest at 93.883 seconds; it is compiled with the F option, so that it uses its own floating point routines. MANDEL02.COD is compiled, but using the Atari's original inbuilt floating point routines...and takes a whopping 238.73 seconds. MANDEL02.ADV is the source. I kept it as similar to the other versions as possible.

 

I will port it over to Fast Basic this weekend and see how it works out. It will probably still be slower than the TBXL compiled version, because the author has went to great lengths to keep it to 8KB in size. TBXL uses a bit of extra space for tables for some math stuff, at the expense of a larger footprint. You should give Fast Basic a whirl, regardless. dmsc, the author, is extremely helpful to the community here. Fast Basic is *very* feature rich, with DLI and Player Missile Graphics commands, etc. Good stuff, for sure. If you haven't seen it already, there is Altirra Extended BASIC (can be ROM based, if you have an Atari Max cart, or one of the more all purpose carts with SD card support, etc - like UNO Cart, Ultimate Cart, AVG, SIDE 2 or 3, etc) that is fully Atari BASIC compatible, fully Turbo BASIC XL compatible, a superset of TBXL commands, and an inbuilt help feature...all for free!

MANDELAA.ATR

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

...I finally went to the link at 6502 org and see why you wanted a "stock" BASIC.

 

Regardless and FWIW, I piddled about in Turbo BASIC XL with writing the text directly to screen memory vs printing using the stock handler; writing directly to screen memory is pretty close to 85% quicker.

  • 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...