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."
The c=64 ain't dead yet ??
Don't underestimate the productivity of being able to work on a hobby project you enjoy
My UID is prime... is yours?
Good thing it only took him 30 years of development to come up with this. Had the software been around when I used a C64 (when they were the state of the art) I would probably still be looping around inside those maps.
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.
Yew hearte me! Mods, yes!
The source code is zipped. For a 254 byte program. This just tickles me for some reason.
It's not news but it's a story about technology!
The vimeo link leads to this article.
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.
Dunno if the link was bad for anyone else, but here's the actual vimeo link.
The next time you churn your next 500MB printer driver think about programs like this. Think long and hard.
He's not done with it yet - not until it can fit in a tweet, so he's got 114 bytes to go.
It's interesting to note that the code uses two "undocumented" 6510 instructions:
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
The Vimeo link in the story somehow became broken, the correct link is as follows:
http://vimeo.com/66004524
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.
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. You'll have to keep hiring out of the general CS grad pool.
Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
Shit. I meant "thou" not "though"... damn muscle memory.
Send him a job offer. He obviously is quite driven. That's a quality that can be hard to find.
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
Projects like this are a great way to train new engineers for small embedded systems. There is a lot of work out there on 8-bit systems with a couple k of program space and a few hundred bytes of ram. At my place we actively collect books that targeted advanced computer programming techniques in the early 80's, because they line up good with the resources we typically have on a microcontroller that costs $1.27 now .
For example, given a 128x96 black and white LCD, create an algorithm that will draw a line between any two points. Oh, and you can only use integer math, and we'd prefer it if you kept division operations to a minimum, because we have to do division through a software library call...
The old-timers did that stuff in their spare time 30 years ago.
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.
you will be upgraded
you will be DELTETED. deeeeeleeet
I work with a health IT company that's trying to give doctors better tools to solve and treat disease.
That's cool. I'm between jobs right now, so I have a lot of time on my hands. But the bright side is that just a few dollars from my unemployment check will buy a whole bunch of eggs, so I'm cool.
Say, why don't you tell me where you live, and I'll come over and we'll talk about that disease treating thingie you're interested in.
I work with habitat for humanity that's trying to build homes for the needy. Our project could improve the lives of lots of folks, and its quite difficult to find talented folks to join the team. I appreciate this woodworking, crafting, handyman related, etc hobby project, I just with these guys would use their not inconsiderable talens and personal free time to work on something that has a more obvious real-world payoff.
Most people do a LOT of things a hobbies that are not "productive". Here's the key- it's a hobby. For fun. That isn't stressful. This guy probably either works as a programmer or is going to school for such a degree. Doing so probably includes a lot of stressful work, stuff that is important. This project, on the other hand, is something that is not at all stressful. There's no timetables involved, no pressure getting it to work asap, no need to take forced shortcuts, based things on other people's code, worry about code maintanability, and if things don't work there isn't any impact on anyone else's life. It's fun and zero stress. Working on a project like you suggest is, on the other hand, going to be very very stressful. There are going to be things that need to be done right, there will be deadlines and budgets to meet, there's going to be a lot of very unfun tasks that need to be done that a hobby project doesn't need to worry about, and it's going to have a very important real world effect on real people. In other words, lots of stress. Not something people are going to want to do "for fun" in their free time (and if they did, they'd likely burn themselves out pretty quick due to not having any downtime between "real" work and this).
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).
Listen, if health were an app away, there would be a zillion of them in every platform's app store already. The bottom line is that even compared to this very brilliant feat, making sick people better at the touch of a button is *pretty fucking hard*.
Hell, making sick people better, for a large portion of the western world, involves just taking a fucking *jog* now and then and you see how far that approach gets. Some sick people just don't _want_ to get better.
This reminds me of a raycaster for the NES. http://www.youtube.com/watch?v=po69zgqyFWM
It works on real hardware too. Sadly, not under 256 bytes though.
Wow... perhaps there is some hope for Doom 2600 after all...
Hang on there. Why are you using your talents on a project that may save 1000s when you could be working in vaccination projects that could save 10s of 1000s? Wait! Forget that. You and those time wasting vaccination workers should be focused on biotechnology that could create crops to feed millions world wide!
Hold it! Scratch that. Global warming will end up destroying the entire planet. Get those lay-about biotech-crop workers on that!
Wait! Heat death of the universe. Only billions of years away and effects EVERYTHING. Stop wasting time on trivial projects and solve the most important problem in the universe! /thread
Do you ever stop working with that health IT company? Why are you wasting your time sleeping when you could be helping them further their goals to solve and treat diseases?! You're selfish for wasting time not working for them!
and the second encoding of "sar" come to mind
Sorry, but it's "SHL" that has a duplicate encoding on x86. There are four slots for non-rotating shift instructions in "group 2": 4=SHL, 5=SHR, 6=???, 7=SAR. The /6 variant looks like it ought to be "SAL", and it is. However, unsigned left shifting is equivalent to signed left shifting, and thus the two opcodes end up doing the same thing. The original 8086 happy processed this instruction as a signed left shift because of how it interpreted the opcode bits, but that's the same as an unsigned left shift.
This was retained in modern processors, whereas "pop cs" was not.
"Screw Sun, cross-platform will never work. Let's move on and steal the Java language." - Visual J++ Product Manager
I knew it would happen. My C64 just became immensely valuable, right?
right?
Do you visit model railroad clubs and chastise them for playing with toys when there's so much real freight to be moved?
Well woo-hoo for you. Maybe it's hard to find people to join your team because: 1) you're a bunch of self-important assholes 2) your work is boring as hell 3) the talented, smart people are out solving more important problems like curing cancer and not run-of-the-mill IT stuff 4) all of the above
If everything people did in the world had to be a "real-work problem" (sic), quality of life wouldn't be very high at all.
Will this run on my VIC-20?
Otherwise, meh.
"I believe in Karma. That means I can do bad things to people all day long and I assume they deserve it." : Dogbert
How do you even know what he is using his talents for at his day job? This type of project is
fun, allows a programmers to relax, reduce stress, and unwind but also allows them to hone
their skills so that there actually are "talented technical folks" for you to hire. I have yet to
meet a great programmer that doesn't do this sort of thing in their spare time and therefore
I honestly believe that eliminating this sort of behavior would actually reduce your ability to
hire qualified candidates.
My 6502 is not completely lost.
Here is how to optimize the code a little bit:
Replace:
with:
This saves 2 bytes and a few cycles.
Amazing how a bunch of internet lamers can turn such an awesome small piece of code, and accompanying story... into a tl;dr thread about postscript printer drivers and complain about how old the 64 is. As for the vic20... source is there, port it.
I don't want to live on this planet anymore.
This was done a decade ago for the Color Computer (6809). A self-modifying 3d engine in ~256 bytes was turned into a full "doom" style 3d game.
http://members.optusnet.com.au/nickma/ProjectArchive/crasher.html
With video!
https://www.youtube.com/watch?v=jVFn_djQ6EY
I got a kick out of the use of bytes already in ROM as the map. I did something similar for an old DOS game of mine, Tunneler, where I used bytes taken from IBM PC ROM to replace the player's usual game view with a TV static/snow effect (simulated loss of signal). I grabbed bytes from an address in ROM that resulted in random-looking values interspersed with a few horizontal streaks. Know of any other games that made unusual use of ROM data?
Which ones constitute acceptable use [...]
And that's the trick. These people focus predominantly on mathematical approximations, extreme memory limitations, and knowing the ins-and-outs of the CPU itself, or the API they're using if it's a PC demo. All C64 demos are programmed in assembly. So while optimization is common to both fields, the level of detail is much too tight. In demo programming, effects are chosen because they optimize well. That doesn't fit with matrix programming or stats where accurately capturing an algorithm is the top priority—not just because mathematical approximations are undesirable, but because the complexity of many processes is the major bottleneck, and the operations themselves are simple and cannot be optimized through cheating.
Even if a demoscener did, for example, rewrite BLAST, the result would be completely unmaintainable, which is no good to anyone. It's much better to leave the optimization of scientific software to the compiler.
Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
> 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.
My most beloved word in the dictionary is "freedom". People are, today, still free to write stuff for fun if they want to for the C64.
My worst nightmare would be a world in which, in the name of morality, everybody was forced to work on something with "Real-World payoff" [TM]. And what would be the point of living in such a world? What's the point in being a slave, although a little bit healthier?
I choose to be a little less healthy, to live a little less longer and get the opportunity to be amazed by what people are still doing, for fun, on the C64.
254 bytes? that sounds like black magic:)
r a f t
You mean like how right now, everyone gets deleted after 120 years or so?
Having seen so many killer C-64 demo vids on YouTube, my expectations for this demo were much higher. I regard it as a PoC. Let's see what they can do when they throw some sprites in there with raster interrupts to display more than 8. Get the perspective for the sprites in that LUT, throw some SID music on top, and really blow us away!
No disrespect. Mad respect actually, from somebody who played with the C-64 back in the day and never got that far. If you don't believe me, search YouTube and prepare to have your mind absolutely blown.
bir means 1 in Turkish. Kudos to the guy who named so this program.
Yeah. I'm also tired of self-righteous people claiming we shouldn't have fun because, somewhere there's a person with a need. Life isn't about sacrificing all your interests to the need of others. Even Jesus let his feet get washed from time to time.
We should learn what we need to know about issues, before we decide what we need to feel about them.
Awesome! If only we could teleport today's knowledge back to 1983! =)
I had been looking for a small demo to include with our Android .TAP-file renderer https://play.google.com/store/apps/details?id=co.kica.tapdancer, and this will be perfect! (Assuming it's free to distribute -- demos usually are but I'm attempting to clarify this...)
Even if a demoscener did, for example, rewrite BLAST, the result would be completely unmaintainable
So same as it is now?
Your comments about exact calculations in this context strike me as kind of funny. The whole reason BLAST exists is because it replaces an expensive search for an optimal match with a heuristic method. It is at its core cheating to optimize a process that wasn't running fast enough. And if you take a look at how the original Smith–Waterman algorithm has been sped up, you'll see that clever ways to cut the code down so it will run on specialized hardware are exactly what people in the industry do. There are a lot of problems in the medical space that the classic demo scene skills wouldn't apply to, but improving BLAST is exactly the sort of thing I would hire one of those guys to do.
Up to a point, I agree with you—I've even implemented some optimizations of Smith-Waterman myself, so I know how bad it can get. The thing is, to fully maximize the kinds of cheating that you typically see in demos, you usually have to sacrifice the flexibility of the algorithm itself. A lot of the genius in low-power C64 and Amiga demos comes from precalculating data and constraining the perspectives from which the image on screen is shown; they're illusions. While a demoscene programmer may be excellent at core optimization tasks, these abilities in particular would be go unused. (Metaphors about cutting raw meat with a bread knife come to mind.) It would be better to look for someone more dedicated to the job, especially if they have experience with parallel processing and high-performance computing.
Of course, that's not to say there aren't individuals interested in all three categories—graphics tricks, code optimization, and high-performance computing—but the aptitudes aren't correlated. Demosceners are motivated by a strong sense of community, the audacity of their medium, and the gratification of seeing their work in action (see documentary), which doesn't jive well with what computational biology offers.
...that being said, I'm a computational biologist, I'm pretty fond of the demoscene, and I hate BLAST; where do I sign? :)
Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
I got an idea.Pay him to do it. Your company works for money.
Heh. Money well spent on Health IT innovations.
-
sorry, spilt my coffee.
If I had a DeLorean... I would probably only drive it from time to time.
This uses a C64 font among others for generating captchas
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.
That's funny, when I said I couldn't find talented technical folk for well below market wages, I'm pretty sure I didn't mean I couldn't find talented folks at all.
I think it's a necessity to have fun.
Yes, life can be hard, cruel and short, but those are all reasons to enjoy it anytime you have the possibility.
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
So people need to work on productive stuff that will save lives and treat disease, 24/7. They can't go to the movies, they can't go to the park, they can't take a break. The MUST always be doing something productive? You know, stuff like this is the way some people take a break from their other work. Maybe they enjoy solving problems, or doing something different sometimes. Maybe this person learned something from this?
Everyone can't be solving hard problems all the time.
I wish I had kept all of that old stuff through moves and... life :)
My karma is bad because I'm a bad person.
I own HP printers and scanners, I know what I am saying is a fact. HP printer drivers are still stupidly oversized. If you're using a real printer that speaks a real language you don't even need a driver, just the PPD, and that is actually provided for some models. But for their more primitive printers (like personal laserwriters, which for the most part don't even speak PCL) you need to download a massive driver that probably won't work on the next version of Windows. I've owned several HP printers specifically because the prior owners could no longer use them due to an OS upgrade.
Nice to see there's an HP shill here, though. I wouldn't have thought they could afford them any longer.
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
640k would still be enough for everyone.
Meh. For someone who is fond of demoscene you make pretty lazy generalizations about demo coding :/
By all means, feel free to point out anything specific; I apologise if I've misconstrued anything.
Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
The main thing that separates democoders from random coders is that they are more likely to have been doing it since they were, like, ten. Anything else is more an assumption than a fact. What you see at the parties and what gets voted up at pouet/etc is not actually very representative selection of their real skills. People who are really good at something have nowadays done that as their day jobs "since forever" and mostly take a break from it when doing scenestuff.
In all fairness, here's the best the Commies have to offer:
M.O.O.D.
http://www.youtube.com/watch?v=X3Oqz5WjDPI
And here's the Atarians best attempt at a Wolfenstein 3D clone:
Project-M
http://www.youtube.com/watch?v=Z3-J2-VeoH8
You be the judge.
Daniel Klugh
I was aware of that, and I feel my point stands: essentially, it would be cruel to hire someone based on a portfolio of work that emphasizes skills the job doesn't require. It's important to recognize how much of a demo is trickery, and that those abilities won't necessarily transfer to a typical real-world job. (Otherwise it wouldn't be a "break" for sceners to work on demos, as you say.)
Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
I can just say that you can't tell easily from a prod that there are known cryptographists or medical scanning fft experts working on a demo (or just hanging around and boozing) and it's nonobvious to figure that those folks might be overrepresented compared to the general population.
Granted, yes.
Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
Actually, a lot of the really talented people go to finance.
Whether they help humanity on the whole is debatable.
Since you said company, I suspect it plans to turn a profit on this. Either convert to a non-profit and ask him to contribute or send him paying job offer.