Live data from Hacker News

BBC BASIC raytracer in 432 characters

mastodon.me.uk

11–20 of 96 posts

Re: BBC BASIC raytracer in 432 characters

#12
This one was from 2021.

Do enjoy the insane things ppl managed to cram into tweets to the bbcmicrobot over the years. Anyone who's followed any part of the demoscene especially the classic smaller payload demos.. 4k etc.....this kinda thing is mindblowing and totally in the same spirit.

Re: BBC BASIC raytracer in 432 characters

#14

Ok, this is probably a dumb question: I get that the code traces the rays for this scene, obviously — but where is the scene, then? That is, where is the “data” (as opposed to the algorithm) that says “there’s a sphere at coordinates x,y,z with radius r, and here’s the other one, and here’s the checkerboard plane”?

  W=1/SQR(U*U+V*V+1)
This makes a sphere. It gets multiplied by two coordinates to make spheres at different places, U and V.

Re: BBC BASIC raytracer in 432 characters

#15
post #5

this says `goto 50` but there are no line numbers

If you go to the source link - https://bbcmic.ro/?t=9ctpk - then you can see the numbers with the lines. They increment in steps of 10 (which IIRC you could override manually with numbers in-between).

If you're playing with this on a BBC micro emulator, the best way to get this code into the emulator is to download the disk image from the above link. The actual basic program is named "PROGRAM" on the disc. List the code by typing LIST20, (the computer will lock up if you try to list line 10).

If you just want to see the result, type MODE 1 and then press return, then type *LOAD SCREEN and press return again.

Re: BBC BASIC raytracer in 432 characters

#16

Ok, this is probably a dumb question: I get that the code traces the rays for this scene, obviously — but where is the scene, then? That is, where is the “data” (as opposed to the algorithm) that says “there’s a sphere at coordinates x,y,z with radius r, and here’s the other one, and here’s the checkerboard plane”?

It’s mostly implicit. See how the spheres are symmetric about the centerpoint? (Well, almost, the camera is at Y = -0.1.) The (X, Y) coordinates of their centers are simply (-1, -1) and (1, 1), given by the `I = SGN U` variable at the end of line 40. The Z is implicitly zero. Their radius is 1. The plane is basically defined by `P = Y - 2` at line 60.

Re: BBC BASIC raytracer in 432 characters

#17

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'm running this on a BBC micro emulator running at period-accurate speed, and it's taking just under a minute to draw one line. So I think it's going to finish in about 4 hours, which would make sense - approximately twice as fast as the Acorn Electron.

Re: BBC BASIC raytracer in 432 characters

#18

Earlier quoted context omitted.

BBC BASIC is surprisingly efficient for an interpreted language. It kind of had to be, running on processors that slow.

Some good discussion of that on The BBC BASIC wiki entry: https://en.wikipedia.org/wiki/BBC_BASIC (paragraph beginning "Due to a number of optimizations[…]".

Also you could swap out hot spots with assembly trivially as it had an inline assembler. And you had indirect pointers in it!

Re: BBC BASIC raytracer in 432 characters

#19
post #5

this says `goto 50` but there are no line numbers

If you go to the source link - https://bbcmic.ro/?t=9ctpk - then you can see the numbers with the lines. They increment in steps of 10 (which IIRC you could override manually with numbers in-between).

thanks! i didn't see that link. but i think the 432 bytes leaves the line numbers out, so it should actually be 448 bytes

Re: BBC BASIC raytracer in 432 characters

#20
post #4

Earlier quoted context omitted.

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

BBC BASIC is surprisingly efficient for an interpreted language. It kind of had to be, running on processors that slow.

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

Post reply on HN