TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

BBC BASIC raytracer in 432 characters

194 pointsby neffoover 1 year ago

15 comments

londons_exploreover 1 year ago
In 398 characters, I can give it error diffusion dithering capabilities, which makes the code smaller and the output quality a bit better:<p><a href="https:&#x2F;&#x2F;bbcmic.ro&#x2F;#%7B%22v%22%3A1%2C%22program%22%3A%22MODE1%3AVDU5%3AB%3D0%5CnFORN%3D8TO247%3AFORM%3D0TO319%5CnX%3D0%3AY%3D-.1%3AZ%3D3%3AU%3D%28M-159.5%29%2F160%3AV%3D%28N-127.5%29%2F160%3AW%3D1%2FSQR%28U*U%2BV*V%2B1%29%3AU%3DU*W%3AV%3DV*W%3AI%3DSGNU%3AG%3D1%5CnE%3DX-I%3AF%3DY-I%3AP%3DU*E%2BV*F-W*Z%3AD%3DP*P-E*E-F*F-Z*Z%2B1%3AIFD%3E0T%3D-P-SQRD%3AIFT%3E0X%3DX%2BT*U%3AY%3DY%2BT*V%3AZ%3DZ-T*W%3AE%3DX-I%3AF%3DY-I%3AG%3DZ%3AP%3D2*%28U*E%2BV*F-W*G%29%3AU%3DU-P*E%3AV%3DV-P*F%3AW%3DW%2BP*G%3AI%3D-I%3AGOTO40%5CnIFV%3C0P%3D%28Y%2B2%29%2FV%3AV%3D-V*%28%28INT%28X-U*P%29%2BINT%28Z-W*P%29AND1%29%2F2%2B.3%29%2B.2%5CnB%3DB%2B3*SQRV%3AGCOL0%2C3-INTB%3AB%3DB-INTB%5CnPLOT69%2C4*M%2C4*N%3ANEXT%2C%22%7D" rel="nofollow">https:&#x2F;&#x2F;bbcmic.ro&#x2F;#%7B%22v%22%3A1%2C%22program%22%3A%22MODE1...</a><p>It would look even better with bidirectional error diffusion, but that requires reading back memory which I don&#x27;t know how to do.
评论 #39030913 未加载
评论 #39032069 未加载
评论 #39031572 未加载
LeoPantheraover 1 year ago
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.
评论 #39024069 未加载
评论 #39026813 未加载
评论 #39023789 未加载
poover 1 year ago
Also, don&#x27;t miss the gallery site! <a href="https:&#x2F;&#x2F;www.bbcmicrobot.com" rel="nofollow">https:&#x2F;&#x2F;www.bbcmicrobot.com</a>
评论 #39025013 未加载
ChrisArchitectover 1 year ago
This one was from 2021.<p>Do enjoy the insane things ppl managed to cram into tweets to the bbcmicrobot over the years. Anyone who&#x27;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.
ManuelKiesslingover 1 year ago
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”?
评论 #39024063 未加载
评论 #39026495 未加载
评论 #39025826 未加载
评论 #39023976 未加载
kragenover 1 year ago
a thing that puzzles me is how <a href="https:&#x2F;&#x2F;bbcmic.ro&#x2F;?t=9ctpk" rel="nofollow">https:&#x2F;&#x2F;bbcmic.ro&#x2F;?t=9ctpk</a> is only 4× faster in emulation (about 30 seconds per scan line and so on the order of 2 hours for the whole image)<p>i&#x27;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 about 4800 mips. if the emulation slowdown is 10× (10 host instructions to emulate one guest instruction), which is typical for naïve interpretation, it should be about 1000× faster on this laptop as on the original hardware<p>(possibly the basic is in rom and so it&#x27;s closer to 524288 instructions per second)<p>emulation through qemu-like dynamic code generation should cut the 10× slowdown to 3×, so it should be 3000× faster than the original hardware<p>where did that factor of 1000 go? not the javascript engine, surely?<p>incidentally there is a rocket-ship button underneath the output screen image labeled &#x27;send to beebjit&#x27; which runs the program in about a second
评论 #39026087 未加载
评论 #39028538 未加载
评论 #39027568 未加载
rwmjover 1 year ago
<a href="https:&#x2F;&#x2F;www.pouet.net&#x2F;prod.php?which=78045" rel="nofollow">https:&#x2F;&#x2F;www.pouet.net&#x2F;prod.php?which=78045</a><p>Incredible raytraced demo in 256 bytes.
评论 #39026100 未加载
评论 #39026235 未加载
SillyUsernameover 1 year ago
Can anybody provide de-obfuscated&#x2F;minified source so those of us who understand the principle (tracing rays of light around a scene) can understand the maths?
评论 #39026180 未加载
jugover 1 year ago
This effort is truly specular!
评论 #39025678 未加载
mixedmathover 1 year ago
This is interesting and serves as a potential &quot;hook&quot; for getting people interested in coding. I understand the BASIC appeal!<p>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?
评论 #39030826 未加载
maxgluteover 1 year ago
The dither effect looks really neat on ray trace, then I remembered thats just your average news paper photo. Still would be cool to see it in a game.
评论 #39028033 未加载
anovikovover 1 year ago
Just curious how fast could the same thing be if someone who knows the hardware really well, wrote it in assembly.
评论 #39032552 未加载
Sharlinover 1 year ago
In a subthread, I got nerdsniped to figure out how this works, and for fun transcribed it ~faithfully to Rust – this one just outputs ASCII art instead of plotting pixels. You&#x27;ll want to zoom out your browser as far as you can:<p><a href="https:&#x2F;&#x2F;www.rustexplorer.com&#x2F;b#Zm4gbWFpbigpIHsKICAgIC8vIHJvdyBsb29wIOKAkyB1c2UgZmV3ZXIgcm93cyBkdWUgdG8gbm9uLXNxdWFyZSBhc3BlY3QgcmF0aW8KICAgIC8vIDMwIEZPUk49OFRPMjQ3CiAgICBmb3IgbiBpbiAoMC4uMTIwKS5yZXYoKSB7CiAgICAgICAgLy8gY29sdW1uIGxvb3AKICAgICAgICAvLyBGT1JNPTBUTzMxOQogICAgICAgIGZvciBtIGluIDAuLjMyMCB7CiAgICAgICAgICAgIC8vIGNhbWVyYSBjb29yZHMgPSByYXkgb3JpZ2luIHBvaW50CiAgICAgICAgICAgIC8vIDQwIFg9MDpZPS0uMTpaPTMKICAgICAgICAgICAgbGV0IG11dCB4ID0gMC4wOwogICAgICAgICAgICBsZXQgbXV0IHkgPSAtMC4xOwogICAgICAgICAgICBsZXQgbXV0IHogPSAzLjA7CgogICAgICAgICAgICAvLyByYXkgZGlyZWN0aW9uIHZlY3RvcgogICAgICAgICAgICAvLyBVPShNLTE1OS41KS8xNjA6Vj0oTi0xMjcuNSkvMTYwOlc9MS9TUVIoVSpVK1YqVisxKQogICAgICAgICAgICBsZXQgbXV0IHUgPSAobSBhcyBmMzIgLSAxNjAuMCkgLyAxNjAuMDsgLy8gcmF5IGRpciB4CiAgICAgICAgICAgIGxldCBtdXQgdiA9IChuIGFzIGYzMiAtIDYwLjApIC8gNjAuMDsgLy8gcmF5IGRpciB5CiAgICAgICAgICAgIGxldCBtdXQgdyA9IDEuMCAvICh1ICogdSArIHYgKiB2ICsgMS4wKS5zcXJ0KCk7CgogICAgICAgICAgICAvLyBub3JtYWxpemUgcmF5IGRpcgogICAgICAgICAgICAvLyBVPVUqVzpWPVYqVwogICAgICAgICAgICB1ICo9IHc7CiAgICAgICAgICAgIHYgKj0gdzsKCiAgICAgICAgICAgIC8vIHdoaWNoIHNwaGVyZSB3ZSB0cnkgdG8gaW50ZXJzZWN0IHNvbGVseSBkZXBlbmRzIG9uIHRoZSBzaWduIG9mIHUKICAgICAgICAgICAgLy8gST1TR05VOkc9MQogICAgICAgICAgICBsZXQgbXV0IGkgPSB1LnNpZ251bSgpOwogICAgICAgICAgICBsZXQgbXV0IGcgPSAxLjA7IC8vIHRoZSAxLjAgaXMgYWN0dWFsbHkgbmV2ZXIgdXNlZAoKICAgICAgICAgICAgLy8gc3BoZXJlIGludGVyc2VjdGlvbiBhbmQgcmVmbGVjdGlvbnMKICAgICAgICAgICAgLy8gbm8gcmVjdXJzaW9uIG5lZWRlZCBhcyB3ZSdyZSBub3Qgc3BsaXR0aW5nIHJheXMKICAgICAgICAgICAgLy8gdGhlIG9yaWdpbmFsIHNpbXBseSB1c2VzIGdvdG8gdG8ganVtcCBiYWNrIHNvIHRoaXMgbG9vcCBpcyBpbXBsaWNpdAogICAgICAgICAgICAncmVmbGVjdDogbG9vcCB7CiAgICAgICAgICAgICAgICAvLyBzcGhlcmUgY2VudGVyIGlzIGF0IChlLCBmLCB6KQogICAgICAgICAgICAgICAgLy8gNTAgRT1YLUk6Rj1ZLUkKICAgICAgICAgICAgICAgIGxldCBtdXQgZSA9IHggLSBpOwogICAgICAgICAgICAgICAgbGV0IG11dCBmID0geSAtIGk7CgogICAgICAgICAgICAgICAgLy8gc29sdmUgcmF5LXNwaGVyZSBxdWFkcmF0aWMgZXF1YXRpb24KICAgICAgICAgICAgICAgIC8vIFA9VSpFK1YqRi1XKloKICAgICAgICAgICAgICAgIGxldCBtdXQgcCA9IHUgKiBlICsgdiAqIGYgLSB3ICogejsKCiAgICAgICAgICAgICAgICAvLyBkaXNjcmltaW5hbnQKICAgICAgICAgICAgICAgIC8vIEQ9UCpQLUUqRS1GKkYtWipaKzE6SUZEPjAKICAgICAgICAgICAgICAgIGxldCBkID0gcCAqIHAgLSBlICogZSAtIGYgKiBmIC0geiAqIHogKyAxLjA7CiAgICAgICAgICAgICAgICBpZiBkID4gMC4wIHsgLy8gcmF5IGludGVyc2VjdHMgc3BoZXJlCiAgICAgICAgICAgICAgICAgICAgLy8gdHdvIHNvbHV0aW9ucywgY2hvb3NlIHRoZSBvbmUgY2xvc2VyIHRvIHRoZSBjYW1lcmEKICAgICAgICAgICAgICAgICAgICAvLyBpbnRlcnNlY3QgcG9pbnQgPSByYXlfb3JpZ2luICsgdCAqIHJheV9kaXIKICAgICAgICAgICAgICAgICAgICAvLyBUPS1QLVNRUkQKICAgICAgICAgICAgICAgICAgICBsZXQgdCA9IC1wIC0gZC5zcXJ0KCk7IAogICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgIGlmIHQgPiAwLjAgeyAvLyBpbnRlcnNlY3QgcG9pbnQgbm90IGJlaGluZCByYXkgc3RhcnQgcG9pbnQKICAgICAgICAgICAgICAgICAgICAgICAgLy8gWD1YK1QqVTpZPVkrVCpWOlo9Wi1UKlcKICAgICAgICAgICAgICAgICAgICAgICAgeCArPSB0ICogdTsgLy8KICAgICAgICAgICAgICAgICAgICAgICAgeSArPSB0ICogdjsgLy8gaW50ZXJzZWN0IHBvaW50IGNvb3JkcyA9IHJlZmxlY3RlZCByYXkgc3RhcnQKICAgICAgICAgICAgICAgICAgICAgICAgeiAtPSB0ICogdzsgLy8KCiAgICAgICAgICAgICAgICAgICAgICAgIC8vIHNwaGVyZV9ub3JtYWwgPSBpbnRlcnNlY3RfcHQgLSBjZW50ZXJfcHQKICAgICAgICAgICAgICAgICAgICAgICAgLy8gRT1YLUk6Rj1ZLUk6Rz1aCiAgICAgICAgICAgICAgICAgICAgICAgIGUgPSB4IC0gaTsKICAgICAgICAgICAgICAgICAgICAgICAgZiA9IHkgLSBpOwogICAgICAgICAgICAgICAgICAgICAgICBnID0gejsKCiAgICAgICAgICAgICAgICAgICAgICAgIC8vIHJlZmxlY3QgYWJvdXQgbm9ybWFsCiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFA9MiooVSpFK1YqRi1XKkcpCiAgICAgICAgICAgICAgICAgICAgICAgIHAgPSAyLjAgKiAodSAqIGUgKyB2ICogZiAtIHcgKiBnKTsgCgogICAgICAgICAgICAgICAgICAgICAgICAvLyBuZXcgcmVmbGVjdGVkIHJheSBkaXIKICAgICAgICAgICAgICAgICAgICAgICAgLy8gVT1VLVAqRTpWPVYtUCpGOlc9VytQKkcKICAgICAgICAgICAgICAgICAgICAgICAgdSAtPSBwICogZTsKICAgICAgICAgICAgICAgICAgICAgICAgdiAtPSBwICogZjsgCiAgICAgICAgICAgICAgICAgICAgICAgIHcgKz0gcCAqIGc7CgogICAgICAgICAgICAgICAgICAgICAgICBpID0gLWk7IC8vIHRoZSBvbmx5IHNwaGVyZSB0byByZWZsZWN0IGlzIHRoZSBvdGhlciBvbmUKCiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEdPVE81MAogICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZSAncmVmbGVjdDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAvLyBpbXBsaWNpdCBpbiB0aGUgb3JpZ2luYWwKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CgogICAgICAgICAgICAvLyBwbGFuZSBpbnRlcnNlY3Rpb24KICAgICAgICAgICAgLy8gNjAgSUZWPDAKICAgICAgICAgICAgaWYgdiA8IDAuMCB7IC8vIGV2ZXJ5IGRvd253YXJkIHJheSBldmVudHVhbGx5IGhpdHMgdGhlIHBsYW5lCiAgICAgICAgICAgICAgICAvLyBQPShZKzIpL1YKICAgICAgICAgICAgICAgIGxldCBwID0gKHkgKyAyLjApIC8gdjsgLy8gcGxhbmUgaXMgYXQgeSA9IC0yCgogICAgICAgICAgICAgICAgLy8gd2hldGhlciBhIGxpZ2h0IG9yIGRhcmsgc3F1YXJlCiAgICAgICAgICAgICAgICAvLyAoSU5UKFgtVSpQKStJTlQoWi1XKlApQU5EMQogICAgICAgICAgICAgICAgbGV0IGNoZWNrZXIgPSAoKHggLSB1ICogcCkuZmxvb3IoKSArICgoeiAtIHcgKiBwKS5mbG9vcigpKSkgYXMgaTMyICYgMTsKICAgICAgICAgICAgICAgIC8vIGdyb3VuZCBmb2cgZWZmZWN0CiAgICAgICAgICAgICAgICAvLyBWPS1WKihjaGVja2VyLzIrLjMpKy4yCiAgICAgICAgICAgICAgICB2ID0gLXYgKiAoY2hlY2tlciBhcyBmMzIgLyAyLjAgKyAwLjMpICsgMC4yOwogICAgICAgICAgICB9CgogICAgICAgICAgICAvLyBhc2NpaSBhcnQgcGFsZXR0ZQogICAgICAgICAgICBsZXQgcGFsID0gYiIgLi06Kz0qY28jT0IlQFciOwogICAgICAgICAgICAvLyBuPTQgaW4gd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VKlApK0lOVChaLVcqUClBTkQxKS8yKy4zKSsuMgo3MCBHQ09MMCwzLSg0OCpTUVJWKz8oUEFHRSs1K00gTU9ENCtOIE1PRDQqNCkvMylESVYxNgo4MCBQTE9UNjksNCpNLDQqTjpORVhULAoqLwo=" rel="nofollow">https:&#x2F;&#x2F;www.rustexplorer.com&#x2F;b#Zm4gbWFpbigpIHsKICAgIC8vIHJvd...</a>
miohtamaover 1 year ago
Nice! Is there a commented source code?
kragenover 1 year ago
this says `goto 50` but there are no line numbers
评论 #39023928 未加载
评论 #39023862 未加载