Live data from Hacker News

BBC BASIC raytracer in 432 characters

mastodon.me.uk

71–80 of 96 posts

Re: BBC BASIC raytracer in 432 characters

#71
post #32

a thing that puzzles me is how https://bbcmic.ro/?t=9ctpk is only 4× faster in emulation (about 30 seconds per scan line and so on the order of 2 hours for the whole image) i'm running this on a ryzen 5 3500u at 2400 megahertz. the acorn electron which supposedly takes 8 hours and 40 minutes is a 1 megahertz 6502 when running from ram, roughly, 262144 instructions per second. at 2 ipc one core of the ryzen should be…

The rocket ship icon seems to have disappeared. Maybe I used it too much, or maybe the site owner removed it? (was it serverside and overloaded?)

i had that problem when i visited via a saved url in tinyurl.com

Re: BBC BASIC raytracer in 432 characters

#72
post #4

Earlier quoted context omitted.

that's astounding; i would have guessed months or years

I recreated a mandlebrot zoom I saw in a library book in bbc basic and the last image took two weeks. I had 8 of them saved on a floppy and that would slideshow them for a 2fps "movie"

that is fucking awesome, you are a legend

Re: BBC BASIC raytracer in 432 characters

#73
post #51

In the replies underneath, someone ran it on a real Acorn Electron computer (6502 at 1 MHz), where it completed in 8 hours and 40 minutes. Not too bad really.

I wonder how much of that it spent just computing those square roots.

Does anybody happen to know what SQR algorithm BBC Basic uses? http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin7.html#printha... does not seem to have the actual algorithm.

Intel's optimization manual has suggestions for fast versions at 15.12.3 (recommended by @James https://stackoverflow.com/a/2637823/10981777) Don't look especially long to implement for 22-bit approximation.

https://software.intel.com/content/www/us/en/develop/downloa...

Also, what's the SQRD? Not finding that referred to anywhere.

Re: BBC BASIC raytracer in 432 characters

#74
post #73
post #51

Earlier quoted context omitted.

I wonder how much of that it spent just computing those square roots.

Does anybody happen to know what SQR algorithm BBC Basic uses? http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin7.html#printha... does not seem to have the actual algorithm. Intel's optimization manual has suggestions for fast versions at 15.12.3 (recommended by @James https://stackoverflow.com/a/2637823/10981777 ) Don't look especially long to implement for 22-bit approximation. https://software.intel.com/content/www/u…

SQRD is just SQR D :)

Re: BBC BASIC raytracer in 432 characters

#75

In 398 characters, I can give it error diffusion dithering capabilities, which makes the code smaller and the output quality a bit better: https://bbcmic.ro/#%7B%22v%22%3A1%2C%22program%22%3A%22MODE1... It would look even better with bidirectional error diffusion, but that requires reading back memory which I don't know how to do.

It makes the output better in some ways, but since it's just 1 dimensional and there isn't really any noise in the image it does produce a very stripy image on the portion I let it run for.

Re: BBC BASIC raytracer in 432 characters

#76

In 398 characters, I can give it error diffusion dithering capabilities, which makes the code smaller and the output quality a bit better: https://bbcmic.ro/#%7B%22v%22%3A1%2C%22program%22%3A%22MODE1... It would look even better with bidirectional error diffusion, but that requires reading back memory which I don't know how to do.

Thanks for sharing. I asked ChatGPT to analyze your code, while telling it what it does. How well do you think it did? Did it make any mistakes? https://chat.openai.com/share/6e754fa1-531d-432e-a767-8c8132...

Wow - I never thought of using ChatGPT for analysing code. It reads well - but does the author agree ?

Re: BBC BASIC raytracer in 432 characters

#77
post #20

Earlier quoted context omitted.

all the basics i used on processors that slow were surprisingly inefficient, even for an interpreted languages i thought they had to be, running on processors with that little memory. though later on i learned about forth, which is surprisingly efficient for an interpreted language a more likely explanation is that sophie wilson was just a better hacker than bill gates and paul allen

Yeah, BBC BASIC is really good. Both the language design and the implementation. I loved it at the time, and the more I think back on it the more impressed I am. Like it had a very decent suite of floating-point routines, which if I remember right were very performant. In a 32KB ROM!

Some of the improvement in BBC BASIC over Microsoft's BASIC is attributable to the larger ROM(the first Altair BASIC was just 4k), but it's also that the BBC Micro's 6502 and DRAM was clocked higher than contemporaries. It's just a faster, more refined 8-bit machine all around.

Re: BBC BASIC raytracer in 432 characters

#78
post #74
post #73

Earlier quoted context omitted.

Does anybody happen to know what SQR algorithm BBC Basic uses? http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin7.html#printha... does not seem to have the actual algorithm. Intel's optimization manual has suggestions for fast versions at 15.12.3 (recommended by @James https://stackoverflow.com/a/2637823/10981777 ) Don't look especially long to implement for 22-bit approximation. https://software.intel.com/content/www/u…

SQRD is just SQR D :)

Thanks. So much more of that code makes sense now. IFD, SGNU, FORN, FORM. FORM especially. So many codes now have the word FORM as a special word.

What a nightmare to read though if you don't know what it's supposed to be written like. Is it a: "FORM=" or a "FOR M=" ? Is it: "S GNU:G", "SG NU:G", "SGN U:G"? SQRD totally looks like some special kind of square root implementation.

Re: BBC BASIC raytracer in 432 characters

#79

In 398 characters, I can give it error diffusion dithering capabilities, which makes the code smaller and the output quality a bit better: https://bbcmic.ro/#%7B%22v%22%3A1%2C%22program%22%3A%22MODE1... It would look even better with bidirectional error diffusion, but that requires reading back memory which I don't know how to do.

I wish there was an option to run at greater than realtime!

Re: BBC BASIC raytracer in 432 characters

#80
post #78
post #74

Earlier quoted context omitted.

SQRD is just SQR D :)

Thanks. So much more of that code makes sense now. IFD, SGNU, FORN, FORM. FORM especially. So many codes now have the word FORM as a special word. What a nightmare to read though if you don't know what it's supposed to be written like. Is it a: "FORM=" or a "FOR M=" ? Is it: "S GNU:G", "SG NU:G", "SGN U:G"? SQRD totally looks like some special kind of square root implementation.

Yeah, early BASICs tended to let you skip the spaces, and in fact it sometimes did have a measurable effect on parsing/execution speed. And of course on file size too… Additionally, at least C64 Basic had two-character shorthands for all keywords.
Post reply on HN