News for hackers. Stuff that matters.
Re:Show HN: Space Invaders in C by loadzero on Friday December 06, 2019 @01:01AM (#21719601)
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.

Re:Show HN: Space Invaders in C by CamperBob2 on Friday December 06, 2019 @06:00PM (#21726884)
Looking 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?
Re:Show HN: Space Invaders in C by loadzero on Saturday December 07, 2019 @12:16AM (#21728627)
Yes, it is coming from the ROM.

Well spotted, it looks like you are right. A quick glance here https://computerarcheology.com/Arcade/SpaceInvaders/Code.htm...

and here

https://www.fontzip.com/apple-ii-screen-typeface

Shows a distinct similarity.

Re:Show HN: Space Invaders in C by tombert on Friday December 06, 2019 @01:18PM (#21724515)
I 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).

Re:Show HN: Space Invaders in C by mrfredward on Friday December 06, 2019 @02:16PM (#21725034)
I'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.

Re:Show HN: Space Invaders in C by loadzero on Friday December 06, 2019 @05:04PM (#21726453)
This 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.

Re:Show HN: Space Invaders in C by pcwalton on Friday December 06, 2019 @06:28PM (#21727121)
> 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.

Re:Show HN: Space Invaders in C by _sbrk on Friday December 06, 2019 @05:47PM (#21726792)
I'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.

Re:Show HN: Space Invaders in C by fortran77 on Saturday December 07, 2019 @11:05AM (#21730940)
Well, it wouldn't have been "Space Invaders in C" if he had used Rust.