Beta

Slashdot: News for Nerds

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Interactive Raycaster For the Commodore 64 Under 256 Bytes

Soulskill posted about a year ago | from the most-useful-software-I've-seen-this-month dept.

Software 143

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

cancel ×

143 comments

OMFG !! (0)

Anonymous Coward | about a year ago | (#43734821)

The c=64 ain't dead yet ??

Re:OMFG !! (1)

Anonymous Coward | about a year ago | (#43734831)

NEVAR!!!!

Mod parent BUTTSEX! (0)

Anonymous Coward | about a year ago | (#43734889)

Yew hearte me! Mods, yes!

Re:OMFG !! (1)

Anonymous Coward | about a year ago | (#43735275)

Page 0. 'Nuf said.

4 KB expansion card (for 1540/1). 'Nuf said.

MC reset switch. 'Nuf said.

Phonome-based, wire-wrapped, GP256 speech-synth for the IO port. 'Nuf said.

But an Amiga was so far beyond, just a few short years later, that it is stupid to even consider the C64 worthy of anything at all. 'Nuf said.

Re:OMFG !! (4, Insightful)

LocalH (28506) | about a year ago | (#43735371)

The C64 is worthy of fun.

Re:OMFG !! (0)

Anonymous Coward | about a year ago | (#43736741)

You go on a lot for someone who said there was no more required to be said after your first sentence....

Real-work problem? (-1)

Anonymous Coward | about a year ago | (#43734847)

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

Re:Real-work problem? (5, Insightful)

Deltaspectre (796409) | about a year ago | (#43734859)

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

Re:Real-work problem? (5, Insightful)

gl4ss (559668) | about a year ago | (#43734881)

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"?

Re: Real-work problem? (4, Insightful)

briancox2 (2417470) | about a year ago | (#43737237)

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.

Re:Real-work problem? (0)

Anonymous Coward | about a year ago | (#43734917)

He's not done with it yet - not until it can fit in a tweet, so he's got 114 bytes to go.

Re:Real-work problem? (5, Funny)

Anonymous Coward | about a year ago | (#43734967)

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.

Re:Real-work problem? (0)

Anonymous Coward | about a year ago | (#43735095)

you will be upgraded
you will be DELTETED. deeeeeleeet

Re:Real-work problem? (0)

Anonymous Coward | about a year ago | (#43736605)

You mean like how right now, everyone gets deleted after 120 years or so?

Re:Real-work problem? (4, Interesting)

Samantha Wright (1324923) | about a year ago | (#43734995)

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.

Re:Real-work problem? (5, Insightful)

gr8_phk (621180) | about a year ago | (#43735085)

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.

Re:Real-work problem? (2)

Samantha Wright (1324923) | about a year ago | (#43735945)

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.

Re:Real-work problem? (1)

greg1104 (461138) | about a year ago | (#43737423)

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 [wikipedia.org] 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.

Re:Real-work problem? (2)

Samantha Wright (1324923) | about a year ago | (#43737593)

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 [youtube.com] ), 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? :)

Re:Real-work problem? (1)

Anonymous Coward | about a year ago | (#43735005)

Send him a job offer. He obviously is quite driven. That's a quality that can be hard to find.

Re:Real-work problem? (5, Insightful)

Tridus (79566) | about a year ago | (#43735013)

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.

Re:Real-work problem? (2)

localman57 (1340533) | about a year ago | (#43735121)

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.

Re:Real-work problem? (0)

Anonymous Coward | about a year ago | (#43735145)

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

Re:Real-work problem? (0)

Anonymous Coward | about a year ago | (#43735147)

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.

Re:Real-work problem? (2)

shreak (248275) | about a year ago | (#43735197)

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

Re:Real-work problem? (0)

Anonymous Coward | about a year ago | (#43735241)

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!

Re:Real-work problem? (5, Insightful)

Beorytis (1014777) | about a year ago | (#43735365)

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

Re:Real-work problem? (0)

Anonymous Coward | about a year ago | (#43735403)

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.

Re:Real-work problem? (2)

Wycliffe (116160) | about a year ago | (#43735641)

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.

Re:Real-work problem? (1)

Anonymous Coward | about a year ago | (#43736225)

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

(oblig) Better late than never (3, Funny)

jeffmeden (135043) | about a year ago | (#43734867)

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.

Re:(oblig) Better late than never (4, Interesting)

cold fjord (826450) | about a year ago | (#43735099)

Had the software been around when I used a C64 (when they were the state of the art) . .

What do you mean? C64 still is state of the art . . . for 1982.

On the other hand, a clever hack borders on being timeless - for example and inspiration if nothing else.

Certainly in a time of ever greater bloatware it can border on mind-blowing to consider what people used to do, and some still do, in handfuls or hundreds of bytes: The Puzzle [folklore.org]

Visual Transistor-level Simulation of the 6502 CPU [visual6502.org]

Zip? (5, Funny)

ZahrGnosis (66741) | about a year ago | (#43734891)

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

Re:Zip? (4, Funny)

jeffmeden (135043) | about a year ago | (#43735027)

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

When you have a 300 baud modem on your C64 and Delphi Online charges by the minute, every last byte adds up!

Re:Zip? (4, Interesting)

tgd (2822) | about a year ago | (#43735201)

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

When you have a 300 baud modem on your C64 and Delphi Online charges by the minute, every last byte adds up!

The funny thing is, back then the handy thing about 300 baud was there was no need to pipe things to more -- you could just cat a file and read it as it downloaded ...

Stupid 1200 baud modems messed that all up ...

Re:Zip? (0)

Anonymous Coward | about a year ago | (#43736777)

I could still keep up with a 9600 bps modem, after that I had to start pausing.

Re:Zip? (2)

jandrese (485) | about a year ago | (#43735441)

The worst part is that zip actually increased the size of the programs by a few bytes. It was counterproductive here, although it did help shrink that relatively gigantic disk image.

Re:Zip? (2)

greg1104 (461138) | about a year ago | (#43737457)

The worst part is that zip actually increased the size of the programs by a few bytes.

Of course it did. If it was possible to compress the program usefully and distribute a smaller version, he would have done that too!

Re:Zip? (2)

bill_mcgonigle (4333) | about a year ago | (#43735869)

And the lameness filter prevents it from being posted here. Aptly named.

Article about Computers on /. ? (0)

Anonymous Coward | about a year ago | (#43734895)

It's not news but it's a story about technology!

Bad link in summary (1)

DrGamez (1134281) | about a year ago | (#43734897)

The vimeo link leads to this article.

Re:Bad link in summary (4, Funny)

Solandri (704621) | about a year ago | (#43735229)

Recursion is the key to generating small op code.

kudos (5, Informative)

excelsior_gr (969383) | about a year ago | (#43734899)

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 [pbm.com] .

Re:kudos (1)

Intrepid imaginaut (1970940) | about a year ago | (#43735061)

Heh, the more things change...

Re:kudos (2)

narcc (412956) | about a year ago | (#43735351)

I was hoping for the story of Mel, a real programmer [utah.edu] .

On the article, it's fantastic. It puts me in mind of First & Third almost FORTH and the recent Fixing E.T. hack.

Vimeo, Vimeo, wherefore art though, Vimeo? (4, Informative)

Anonymous Coward | about a year ago | (#43734905)

Dunno if the link was bad for anyone else, but here's the actual vimeo link [vimeo.com] .

Re:Vimeo, Vimeo, wherefore art thou, Vimeo? (0)

Anonymous Coward | about a year ago | (#43735001)

Shit. I meant "thou" not "though"... damn muscle memory.

Re:Vimeo, Vimeo, wherefore art though, Vimeo? (1)

Intrepid imaginaut (1970940) | about a year ago | (#43735079)

What is that font the C64 uses and where can I get it?

Re:Vimeo, Vimeo, wherefore art though, Vimeo? (2)

innocent_white_lamb (151825) | about a year ago | (#43736361)

Re:Vimeo, Vimeo, wherefore art though, Vimeo? (1)

Intrepid imaginaut (1970940) | about a year ago | (#43736439)

Thanking you!

Re:Vimeo, Vimeo, wherefore art though, Vimeo? (1)

Anonymous Coward | about a year ago | (#43736667)

You might want to (re-)read the license for that file...

You MAY NOT: sell this font; include/redistribute this font in any font collection regardless of pricing; provide the font for direct download from any web site.

You MAY: link to "http://style64.org/c64-truetype [style64.org] " in order for others to download and install the font;...

HP Printer Driver Developers Take Note (5, Insightful)

parlancex (1322105) | about a year ago | (#43734907)

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

Re:HP Printer Driver Developers Take Note (1)

Anonymous Coward | about a year ago | (#43735015)

i would personally love to cause hours of greif and anguish to those who create hp printer drivers.

for they have costed me days in troulbe shooting and reinstalling their bloated drivers and software.

Re:HP Printer Driver Developers Take Note (1)

cheater512 (783349) | about a year ago | (#43735849)

Their Linux drivers are quite slim on the other hand, install easily and work beautifully.
Every feature on every device works through the standard mechanisms too.

Re:HP Printer Driver Developers Take Note (4, Informative)

Solandri (704621) | about a year ago | (#43735205)

The printer driver itself wasn't 500 MB. What happened was that some manager at HP decided tech support was wasting too much time (money) instructing people on how to navigate their byzantine support website to find and download the correct drivers for their printer. So they glommed the drivers for all of their printers into one big binary and told people to just download that.

IMHO the real lesson from the HP printer drive fiasco is that if it's quicker and easier to find something on your website by doing a Google search for it, you need to redesign your website. HP eventually did that, and their site now lets you just type the printer's name and it'll take you directly to its download page.

Re:HP Printer Driver Developers Take Note (1, Troll)

drinkypoo (153816) | about a year ago | (#43735699)

The printer driver itself wasn't 500 MB. [...] IMHO the real lesson from the HP printer drive fiasco is that if it's quicker and easier to find something on your website by doing a Google search for it, you need to redesign your website. HP eventually did that, and their site now lets you just type the printer's name and it'll take you directly to its download page.

...where you can download a 150MB printer driver. Progress!

Re:HP Printer Driver Developers Take Note (1)

cold fjord (826450) | about a year ago | (#43735207)

If you are complaining about HP printer drivers, I think I can just about assure you that you haven't seen the bottom of the barrel - not by a long shot.

Re:HP Printer Driver Developers Take Note (0)

tgd (2822) | about a year ago | (#43735217)

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

God, I hope you're not a programmer.

Re:HP Printer Driver Developers Take Note (1)

parlancex (1322105) | about a year ago | (#43735445)

Why, yes I am! I've written home-brew Xbox games that included graphics and animations, sounds and music(<10MB), and reasonably complicated network software that runs as a service on many of my servers at work (<100KB). I've dabbled in writing demo code as well writing a complex synthesizer with DSP effects and tons of music content in 64kb.

If you're actually defending the need to ship printer drivers literally over 500MB I would really love to hear your logic.

Re:HP Printer Driver Developers Take Note (1)

jandrese (485) | about a year ago | (#43735399)

I will never buy a non-Postscript printer ever again. Postscript printers mean you never have to mess with drivers, especially network Postscript printers.

Re:HP Printer Driver Developers Take Note (0)

Anonymous Coward | about a year ago | (#43735475)

I will never buy a non-Postscript printer ever again. Postscript printers mean you never have to mess with drivers, especially network Postscript printers.

Really? The Postscript printers I've used, network and local, have all required drivers. Maybe this is a stupid question, but how do you control duplex or not, color or B/W, which paper source, etc if you don't have a driver for the printer?

Re:HP Printer Driver Developers Take Note (1)

Dahan (130247) | about a year ago | (#43735741)

Really? The Postscript printers I've used, network and local, have all required drivers. Maybe this is a stupid question, but how do you control duplex or not, color or B/W, which paper source, etc if you don't have a driver for the printer?

A PPD [wikipedia.org] , a text file which describes the printer's capabilities, and the commands to send to change various options.

Re:HP Printer Driver Developers Take Note (1)

NemoinSpace (1118137) | about a year ago | (#43737109)

a rose by another name

Re:HP Printer Driver Developers Take Note (1)

alannon (54117) | about a year ago | (#43737627)

PPD files are platform-independent which always smelled sweet to me when I was using a mac or linux. Other printers I've had to throw in the trash because the driver didn't make the jump from XP to Win7. I maintain a VMWare VM with XP just to print on a not-so-old commercial-quality thermal CD printer.

Re:HP Printer Driver Developers Take Note (1)

avandesande (143899) | about a year ago | (#43736009)

After thinking a long time I decided that I would be impressed if he could implement the print driver to run on a commodore 64!

Re:HP Printer Driver Developers Take Note (2)

parlancex (1322105) | about a year ago | (#43737561)

Then you should be impressed [blip.tv] . If you seriously are a developer who writes printer software for HP you are bad and you should feel bad.

Uses two undocumented / illegal instructions (5, Interesting)

Myria (562655) | about a year ago | (#43734937)

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

Re:Uses two undocumented / illegal instructions (2)

Wisdom (4414) | about a year ago | (#43734987)

The alternative version (1bir-alt.prg/s) uses no illegal opcodes at all. :-)

Re:Uses two undocumented / illegal instructions (1)

ProzacPatient (915544) | about a year ago | (#43735187)

It is not uncommon to find programs utilizing the MOS 6052 instruction set doing the same thing.
This is why if you write a Nintendo NES emulator exactly to spec some games might not work because they use undocumented instructions that work on the real hardware but need to be specifically implemented in software.

Re:Uses two undocumented / illegal instructions (0)

Anonymous Coward | about a year ago | (#43736751)

It's even worse than that. Some NES games does a full byte compare instead of a bit test for reading the joypad data. The rest of the bits aren't driven by the joypad interface and are left floating by the hardware. Because of this the value compared against is a hybrid between the compare opcode and the desired bit value.

Correcting myself (3, Insightful)

Myria (562655) | about a year ago | (#43735285)

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.

Re:Uses two undocumented / illegal instructions (1)

tlhIngan (30335) | about a year ago | (#43735573)

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

The reason for this is simple - the instruction decoder is using a bunch of logic gates to figure out how to drive the various processing bits around, referencing a microcode ROM if necessary. The deal was that most of the opcode space was not completely used up so there are holes where no instruction is officially implemented. Using those encodings will not generate an error (most processors didn't have an illegal instruction error, nor did most microprocessors expect anything more than to crash on error). So these illegal instruction encodings merely tickled the instruction decoder in strange and wonderful ways.

A more modern processor like the Motorola 68K, however, implemented illegal instruction exceptions and thus they have no such features.

And modern processor architectures today often have plenty of gaps in the instruction space - for future instructions or whatnot, and they too generate illegal instruction exceptions. ARM actually defines an ILLEGAL opcode to cause that very exception.

Heck, Microsoft found illegal instructions were fastest [msdn.com] for system call handling, much to Intel's bemusement

Re:Uses two undocumented / illegal instructions (0)

Anonymous Coward | about a year ago | (#43735653)

POP CS wasn't undocumented and the 80186 was the processor that did away with it.

Real x86 examples
SALC (Set AL (the lowest 8 bit of the AX register) to the value in the carry flag. The same function as SBB AL, AL (=Subtract with borrow))
AAD imm8 (ASCII Adjust before Division - used for BCD calculation) which can be used to multiply with a 8 bit constant. It was documented but only as doing a multiplication with 10 and encoded as 0xD5 0x0A.

Correct link for Vimeo video (2)

Wisdom (4414) | about a year ago | (#43734963)

The Vimeo link in the story somehow became broken, the correct link is as follows:

http://vimeo.com/66004524 [vimeo.com]

Good Training for embedded systems (3, Insightful)

localman57 (1340533) | about a year ago | (#43735075)

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.

Re:Good Training for embedded systems (2)

Citizen of Earth (569446) | about a year ago | (#43735461)

No need [wikipedia.org] to create one.

Re:Good Training for embedded systems (2)

greg1104 (461138) | about a year ago | (#43737689)

Line drawing can have a lot of complexity to it beyond just picking the best of the usual approaches. A simple implemtnation of Bresenham's line algorithm may or may not be optimal given the system's other constraints. One common change is to recognize that horizontal and vertical lines are both common enough that they should get their own optimized code paths. If it's possible the code might run on a grey scale display one day, you might code in a way that later allows anti-aliasing. On a computer like the Apple ][, the odd mapping of video memory to the display can favor lookup table driven approaches. And on systems where the code has to run at a consistent speed on each loop to maintain vertical sync like the Atari 2600, you'll have to carefully modify the Bresenham approach, since the d>0 path has more computations than the other side. Those are just a few of the possibilities I remember from my 6502 coding days.

Re:Good Training for embedded systems (0)

Anonymous Coward | about a year ago | (#43735497)

Bresenham to the rescue. Want me to draw circles too? Anyway, the 8-bit uCs will soon become as obscure if not obsolete as the 8-bit home computers have been for two decades. The specialized skills for programming these systems are just too rare, the development time is too long for too little benefit and you have to compromise on functionality way too often. 32-bit processors aren't more expensive, so unless you're locked into an 8-bit architecture, there's no reason not to use faster and more featureful hardware.

While I believe that 8-bit uCs are good teaching tools, because they have all the important aspect in a system that's not so big that it has a very steep learning curve, I think it's a shame that Arduinos have been established as a platform that people design actual projects around. People really shouldn't need to write programs without an underlying operating system anymore. The 32 bit hardware which allows for portable and maintainable code is as cheap as those 80s-machines-on-a-chip.

Re:Good Training for embedded systems (0)

Anonymous Coward | about a year ago | (#43736821)

While 32-bit CPU's are cheap I have yet to see one that is viable for low energy usage.
There are plenty of embedded devices like smoke detectors, remote controls and similar where an average current above 1uA is unacceptable.
The 32-bit microcontrollers also tend to have a pipeline and a lot of overhead on the interrupts so there are a lot of time critical applications where many 32-bit controllers just can't react fast enough.
For the CS dude who wants to start playing a bit closer to the hardware there is not really any reason to use the 8-bit controllers anymore but the 8-bit controllers will not be completely phased out this decade and probably not next either.

Re:Good Training for embedded systems (1)

tibit (1762298) | about a year ago | (#43736859)

Division operations for line drawing? Ever heard of Bresenham's algorithm? It can be further tweaked based on the organization of the frame buffer.

There are many state-of-the-art designs that are memory constrained. Parallax's Propeller has 512 32-bit words for high-speed cog memory. Their new Propeller II adds a third memory space (besides cog and hub memories), but the basic 512 word limit remains unchanged. XMOS XS1 architecture has 64 kbytes of RAM shared between code and data for a multi-core CPU tile. Each tile has at least 4 cores running at 125Mips, from that shared memory. All are quite capable chips, each in its own way (Prop II only exists as an FPGA testbed at the moment).

Nintendoes this also (0)

Anonymous Coward | about a year ago | (#43735159)

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.

Only 254 bytes? (1)

rivercityrandom (626724) | about a year ago | (#43735181)

Wow... perhaps there is some hope for Doom 2600 [wikia.com] after all...

The world is mine. (0)

Anonymous Coward | about a year ago | (#43735363)

I knew it would happen. My C64 just became immensely valuable, right?

right?

Will this run . . . (3, Funny)

hduff (570443) | about a year ago | (#43735511)

Will this run on my VIC-20?

Otherwise, meh.

Re:Will this run . . . (5, Interesting)

Wisdom (4414) | about a year ago | (#43735771)

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.

Re:Will this run . . . (1)

StarWreck (695075) | about a year ago | (#43737155)

I would bet it would run on the VIC-20. Maybe not the .C64 disk image but the source code. VIC-20 had only 5K RAM but it had a full 6502 CPU. Although they have entirely different video chips.

Optimization (4, Interesting)

eulernet (1132389) | about a year ago | (#43735691)

My 6502 is not completely lost.
Here is how to optimize the code a little bit:

Replace:

loop_stepadd
                        lda stepx,x ; & y
                        ora #$7f ; sign extend 8 bit step value to 16 bit
                        bmi *+4
                        lda #$00
                        pha ;clc
                        lda stepx,x ; & y
                        adc rayposx,x ; & y
                        sta rayposx,x ; & y
                        pla

with:

loop_stepadd ;clc
                        lda stepx,x ; & y
                        adc rayposx,x ; & y
                        sta rayposx,x ; & y
                        lda stepx,x ; & y
                        ora #$7f ; sign extend 8 bit step value to 16 bit
                        bmi *+4
                        lda #$00

This saves 2 bytes and a few cycles.

Re:Optimization (4, Funny)

Wisdom (4414) | about a year ago | (#43735989)

Well spotted, I missed that one out. :-) Usual problem of looking at the same thing for so long, now it perplexes me how I missed such an easy one. :-)

Re:Optimization (4, Interesting)

eulernet (1132389) | about a year ago | (#43737017)

Well, it was not obvious.

I originally wanted to optimize the sign extend using some carry tricks, like asl/lda #0/sbc #0, but realized that it was unnecessary.
In fact, you can improve it even more, as follows:

lda stepx,x ; & y
                        bpl *+4
                        dec rayposxh,x
                        adc rayposx,x
                        sta rayposx,x
                        bcc *+4
                        inc rayposxh,x

Saving 6 bytes !

This trick is mentioned here:
http://forum.6502.org/viewtopic.php?p=5262 [6502.org]

BTW, your tsx/txs trick is really horrible, it forces the stack at the bottom of $100.

Lamers (0)

Anonymous Coward | about a year ago | (#43735827)

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.

Or, 2MHz 6809 with full 3d Game (2, Interesting)

Anonymous Coward | about a year ago | (#43735829)

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

Other creative uses of ROM data? (1)

geo255 (2924341) | about a year ago | (#43735891)

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?

Re:Other creative uses of ROM data? (0)

Anonymous Coward | about a year ago | (#43736443)

Know of any other games that made unusual use of ROM data?

It's a bad way to do things, compatability wise. Manufacturers could use different ROM data, even for identical models and revisions of computer.
On the other hand, a modern approach to security uses hardware fingerprints [hp.com] . That's basically the same idea, used for a purpose with fewer caveats.

Re:Other creative uses of ROM data? (2)

Hatta (162192) | about a year ago | (#43736633)

Yars Revenge used its own game code as pseudorandom data to animate the neutral zone.

wow! (0)

Anonymous Coward | about a year ago | (#43736563)

254 bytes? that sounds like black magic:)

r a f t

My expectations were too high (0)

Anonymous Coward | about a year ago | (#43736649)

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.

Re:My expectations were too high (2)

Wisdom (4414) | about a year ago | (#43736707)

Next version is coming up soon, with more features than you actually mentioned in your post. :-) (It will not be under 256 bytes, though). This was, as you said, made to prove that it can be done under 256 bytes. Therefore, the size limit does not really allow to add many more features than there are now (although it is still possible to add small improvements here and there, of course). Lastly, this does not utilize any LUT, except for the usual sine/cosine tables.

Wonderful Acronym (0)

Anonymous Coward | about a year ago | (#43736779)

bir means 1 in Turkish. Kudos to the guy who named so this program.

Awesome! (0)

beaverdownunder (1822050) | about a year ago | (#43737355)

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 [google.com] , and this will be perfect! (Assuming it's free to distribute -- demos usually are but I'm attempting to clarify this...)

Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Create a Slashdot Account

Loading...