Live data from Hacker News

Si78c: Memory-accurate reimplementation of Space Invaders in C

github.com

1–10 of 21 posts

Re: Si78c: Memory-accurate reimplementation of Space Invaders in C

#5

Holy Moly, look at that monster struct at line 125. So much code for such a simple game. Now imagine the code base of original Diablo. And yet, it run (still does) on a toaster.

That struct wouldn't actually have been in the original game. The idiomatic C analogue would be static variables inside functions, or (occasionally) global variables, but that wouldn't make it a memory-accurate reimplementation.

I think the game code proper starts around line 670, but still, there's quite a lot of emulator code interspersed with the game logic after that point. (Multiple-line functions for something that would've been a single memory read in the original game.)

Re: Si78c: Memory-accurate reimplementation of Space Invaders in C

#6
> The original code is interrupt driven, and partially co-operatively multitasked. The game spends about a third of the time running the main thread, which gets pre-empted by the midscreen and vblank interrupts. The other two thirds of the time is split between those interrupt contexts, which are not pre-empted, but decide when to return to main.

That's just how interrupts work; it is not cooperative multitasking. Taking an interrupt which just returns (no scheduler) is not usually called preemption.

Re: Si78c: Memory-accurate reimplementation of Space Invaders in C

#8

Holy Moly, look at that monster struct at line 125. So much code for such a simple game. Now imagine the code base of original Diablo. And yet, it run (still does) on a toaster.

> Now imagine the code base of original Diablo.

No need to imagine! https://github.com/diasurgical/devilution

This is >99% binary exact when compiling with the original toolchain.

Re: Si78c: Memory-accurate reimplementation of Space Invaders in C

#9

Holy Moly, look at that monster struct at line 125. So much code for such a simple game. Now imagine the code base of original Diablo. And yet, it run (still does) on a toaster.

Well, that struct is that toaster, or its memory layout declared in C syntax, including all the game's global variables. It's surprising how many there are.

Re: Si78c: Memory-accurate reimplementation of Space Invaders in C

#10

    The keyboard controls are:
    
    a   LEFT
    d   RIGHT
    1   1P
    2   2P
    j   FIRE
    5   COIN
    t   TILT
TILT! I was surprised and amused to see that there's an actual tilt sensor input.

I think most people with a passing familiarity with arcade machines know that pinball machines had "tilt" sensors. People would smack, shake, tilt, etc. the tables in an attempt to change the trajectory of the ball. Or, perhaps they just abused them out of frustration. So, there were tilt sensors built into pinball machines that would end your game and light up a "TILT" message if tried those potentially damaging shenanigans. After all, those machines weren't cheap.

I had no idea they were built into early solid state games like Space Invaders as well. That's hilarious.

I guess people tried jiggling the machines in order to help them avoid the aliens? Or Taito, at least, feared they would?

Post reply on HN