Slashdot Mirror


Interactive Raycaster For the Commodore 64 Under 256 Bytes

New submitter Wisdom writes "1bir (1 Block Interactive Raycaster) is a simple ray casting engine implemented only in 254 bytes to run on a stock, unexpanded Commodore 64. The name comes from the fact that on a C64 floppy disk, 1 block is equivalent to 254 bytes stored on a disk sector. In 254 bytes, 1bir sets up the screen for drawing, creates sine and cosine tables for 256 brads based on a simple approximation, casts rays into a 2D map that lives inside the C64 KERNAL ROM, renders the screen in coordination with KERNAL, evaluates 8-way joystick input and detects collision against walls. The ray casting core employs a brute force algorithm to determine visible walls, while the mapping portion supports both open-ended (infinitely looped) and traditional, closed maps. The source code in 6502 assembly is available, with extensive comments. A YouTube video showcases 1bir in a detailed manner with both kind of maps and more information, while a Vimeo video presents a shorter demonstration."

11 of 143 comments (clear)

  1. Re:Real-work problem? by Deltaspectre · · Score: 5, Insightful

    Don't underestimate the productivity of being able to work on a hobby project you enjoy

    --
    My UID is prime... is yours?
  2. Re:Real-work problem? by gl4ss · · Score: 5, Insightful

    I work with a health IT company that's trying to give doctors better tools to solve and treat disease. Our project could improve the lives of lots of folks, and its quite difficult to find talented technical folks to join the team.

    I appreciate this is a cool hobby project, I just wish the guy would use his not inconsiderable talents to work on something that has a more obvious real-world payoff (unless this is all a hologram running on 4x10^16 Commadore 64s).

    I got an idea.Pay him to do it. Your company works for money.

    You wouldn't be working for one of the two dozen firms doing mobile apps for connecting doctors to patients, looking for funding, explaining how you work "with" and not "for"?

    --
    world was created 5 seconds before this post as it is.
  3. Zip? by ZahrGnosis · · Score: 5, Funny

    The source code is zipped. For a 254 byte program. This just tickles me for some reason.

  4. kudos by excelsior_gr · · Score: 5, Informative

    It is nice to see that in this world of plenty (at least as far as system memory and CPU speed goes) some people find joy in efficiency; and they go so far as to pull something like that off, just for the fun of it. Needless to say, the dude that did this is a real programmer.

  5. HP Printer Driver Developers Take Note by parlancex · · Score: 5, Insightful

    The next time you churn your next 500MB printer driver think about programs like this. Think long and hard.

  6. Uses two undocumented / illegal instructions by Myria · · Score: 5, Interesting

    It's interesting to note that the code uses two "undocumented" 6510 instructions:

    lax $91
    anc #$00 ; clears carry for sinadd below

    These instructions are undefined; they work by taking advantage of the internal CPU architecture to execute a hybrid of other legal opcodes. A lot of other older processors have such behavior, such as the Z80. Even the 8086 had a bit of this: "pop cs" and the second encoding of "sar" come to mind. (The 8086's "pop cs" was stolen by the 286 to mean an escape to a second opcode page.)

    --
    "Screw Sun, cross-platform will never work. Let's move on and steal the Java language." - Visual J++ Product Manager
  7. Re:Real-work problem? by Anonymous Coward · · Score: 5, Funny

    I work with an advanced robotics research firm that's trying to take humans out of fragile, disease-ridden bodies and put them in immortal robot bodies. Our project would allow humanity to transcend mortal existence, and it's quite difficult to find talented technical folks to join the team.

    I appreciate your cool hobby project, I just wish you would use your not inconsiderable talents to work on something that has a more obvious long-term payoff.

  8. Re:Real-work problem? by Tridus · · Score: 5, Insightful

    Can't find talented technical folks to join the team, or can't find talented technical folks to join the team for well below market wages?

    Usually when people say one, they really mean the other.

    --
    -- "So they told me that using the download page to download something was not something they anticipated." - Bill Gates
  9. Re:Real-work problem? by gr8_phk · · Score: 5, Insightful

    As a bioinformatician who's trying to give researchers better tools to identify disease, whose projects could also improve the lives of lots of folks: this is not that kind of programming. Demoscene programmers are generally hired by graphics companies and embedded systems development, where their formidable optimization abilities actually get put to use; those skills are not transferable to general high-performance computing.

    Actually the skills do transfer. The techniques of code optimization are many and universal. Which ones constitute acceptable use depends on the application (i.e. mathematical approximations are not always OK). From what I keep reading, HPC focuses a lot on matrix math - an area where some tricks can help a lot without affecting the results. I was manipulating 1GB 3d data sets interactively on a machine with 128M of RAM back in the day, and I suspect the technique has not gone mainstream yet.

  10. Re:Real-work problem? by Beorytis · · Score: 5, Insightful

    Do you visit model railroad clubs and chastise them for playing with toys when there's so much real freight to be moved?

  11. Re:Will this run . . . by Wisdom · · Score: 5, Interesting

    It is quite possible that it will run on VIC20, but it will probably need some modification to the actual render code (I do not have a VIC20, so I am not sure). Other than that, it should work, as RAM usage is minimal (just needs 320 bytes for sine/cosine tables, ZeroPage and the 1K video RAM).

    Nevertheless, I will include it in the next release. Thanks for the idea.