3 ms·
Author here. This is a bit of a love letter to Space Invaders, and video games in general. I started working on this as a simple emulation project, to rekindl
by loadzero 7y ago
Author here.
This is a bit of a love letter to Space Invaders, and video games in general.
I started working on this as a simple emulation project, to rekindle my own passion in low level video game hacking, but then realized with a bit of care I could take it further.
So, this is not a simple clone of the game, but rather a painstaking recreation of the source code in clean, readable C code.
I wanted to make something nice that would last a while, as a tribute to the original, and hopefully function a bit like a rosetta stone for future audiences.
Enjoy.
- tombert 7y agoI have to ask an honest question (as someone who is interested in emulation and old-game restoration as a whole): why C? Did you consider a newer hacker-news-friendly language like D or Rust? (my usual disclaimer: I'm not asking this passive aggressively, I'm genuinely interested in the answer to this).
- mrfredward 7y agoI'm obviously not the author, but I can think of a good reason not to use rust. The project works exactly as the original and recreates the memory state byte for byte, so like the original it has different tasks running at once that are reading and writing to shared memory. Rust's borrow check exists to prevent this sort of thing, because it is so hard to do it correctly or prove it is correct once you have done it. So to use rust, the author would have needed to either totally re-architect Space Invaders, or write the whole thing in ugly, non-idiomatic rust. Rust simply doesn't let you do the things assembly and C programmers did all the time in 1978 (and with the complexity of our software now and the extra computing power, that's usually for the better). C, on the other hand, has at times been described as "portable assembly," which makes it a good choice for someone wanting to stay true to the original program flow.
- loadzero 7y agoThis is a good answer, and does reflect a good chunk of the reason for picking C. Dealing with such low level tasks is what the language was made for. The other big reason I used C, is that it is more of a lingua franca than something more modern, and will make the code more accessible to a wider audience.
- pcwalton 7y ago> Rust simply doesn't let you do the things assembly and C programmers did all the time in 1978 (and with the complexity of our software now and the extra computing power, that's usually for the better). Rust does let you do those things. You could run this repo through c2rust and get a working Rust program. It'll be ugly Rust code, though.
- KibbutzDalia 7y agoHere come the Rust Invaders!
- _sbrk 7y agoI'm a hacker-news reader and I use C on a daily basis. Seems pretty friendly to me. Every language has a problem that it is good at solving, and some languages express the underlying idea more clearly than others. In this case, the author has done a bang-up job picking a common, everyday language to solve the problem.
- fortran77 7y agoWell, it wouldn't have been "Space Invaders in C" if he had used Rust.
- CamperBob2 7y agoLooking through your code, the text character set seems to be coming from the original ROM image. Is that correct? What I thought was interesting was that the glyphs appear 100% identical to the original Apple II character set, down to the pixel. Was there some kind of unexplored connection between Space Invaders and Apple, back in the day?
- loadzero 7y agoYes, it is coming from the ROM. Well spotted, it looks like you are right. A quick glance here https://computerarcheology.com/Arcade/SpaceInvaders/Code.html#text-character-sprites https://computerarcheology.com/Arcade/SpaceInvaders/Code.htm... and here https://www.fontzip.com/apple-ii-screen-typeface https://www.fontzip.com/apple-ii-screen-typeface Shows a distinct similarity.