Live data from Hacker News

BBC BASIC raytracer in 432 characters

mastodon.me.uk

61–70 of 96 posts

Re: BBC BASIC raytracer in 432 characters

#63
post #57
post #53

Earlier quoted context omitted.

> rem if instead y component is negative, make a checkerboard of pieces of sky I'd maybe phrase this a bit differently – in both cases it uses the v coordinate to calculate the shade but whereas the sky is a simple gradient, the plane has a "ground fog" type effect that can be adjusted with those +.3 and +.2 magic constants.

i was trying to figure out how the ground fog happens, and i still don't

The value of v corresponds to how far away the intersection point is. At the horizon v=0 so the color value is just constant 0.2. The closer to the camera, the more the checker value (0 or 1) contributes. The exact values are probably chosen experimentally, but note the important property that -v*(checker/2+0.3)+0.2 is always between 0 and 1. Note also that 1 means black and 0 white here, as ultimately the value is negated at line 70.

Re: BBC BASIC raytracer in 432 characters

#64
post #38
post #26

https://www.pouet.net/prod.php?which=78045 Incredible raytraced demo in 256 bytes.

last year i wrote a tetris in arm assembly https://asciinema.org/a/622461 and was pleased to get it down below 1024 bytes then i looked and rrrola's 4is256 https://www.pouet.net/prod.php?which=29286 is a working tetris in under 256 bytes, and it's better than mine because it has colors and scoring. i could blame a little bit of inflation on arm being 32-bit rather than 16-bit, but not 4×

The upper limit of instruction density on x86 is much higher than any RISC.

Re: BBC BASIC raytracer in 432 characters

#65
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 Acorn Electron is a very different design, and the BBC Micro runs measurably faster (particularly in this case due to the high res graphics). The bbcmic.ro emulation will almost certainly be pretty much exactly the same speed as real BBC Micro.

The Firefox profiler suggests it's spending most of its time doing nothing, waiting for the next Window.requestAnimationFrame.

Re: BBC BASIC raytracer in 432 characters

#66
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!

Basic was actually a 16KB ROM. MOS occupied another 16KB ROM.

Re: BBC BASIC raytracer in 432 characters

#67
This is interesting and serves as a potential "hook" for getting people interested in coding. I understand the BASIC appeal!

In something like python, an analogous thing is turtle graphics. Is there something more similar (but still very basic) in python for something like this? A mini graphical language?

Re: BBC BASIC raytracer in 432 characters

#68

This is interesting and serves as a potential "hook" for getting people interested in coding. I understand the BASIC appeal! In something like python, an analogous thing is turtle graphics. Is there something more similar (but still very basic) in python for something like this? A mini graphical language?

Hmm, something like graphics.py maybe? https://mcsp.wartburg.edu/zelle/python/ppics2/code/graphics....

Re: BBC BASIC raytracer in 432 characters

#69

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

Re: BBC BASIC raytracer in 432 characters

#70
post #38

Earlier quoted context omitted.

last year i wrote a tetris in arm assembly https://asciinema.org/a/622461 and was pleased to get it down below 1024 bytes then i looked and rrrola's 4is256 https://www.pouet.net/prod.php?which=29286 is a working tetris in under 256 bytes, and it's better than mine because it has colors and scoring. i could blame a little bit of inflation on arm being 32-bit rather than 16-bit, but not 4×

The upper limit of instruction density on x86 is much higher than any RISC.

that hasn't been my experience with instructions i've written myself, but then again, i'm not rrrola
Post reply on HN