Live data from Hacker News

The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

larstofus.com

161–170 of 186 posts

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#161

I guess I'm showing my age but having read stuff like Michel Abrash's books years ago this article was a bit underwhelming. Like no one who wrote any code back in the 80s or 90s even for a homebrew game was skipping this stuff, it was in almost every book and tutorial. Stuff like bit shifting was extremely common and a lot of games would have had design choices that were informed by coding challenges. Lots and lots o…

[dead]

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#162
post #8

> The same trick can also be used for the other direction to save a division: > NewValue = OldValue >> 3; You need to be careful, because this doesn't work if the value is negative. A

Most CPU's has signed and unsigned right shift instructions (left shift is the same), so yes it works (You can test this in C by casting a signed to unsigned before shifting). The biggest caveat is that right shifting -1 still produces -1 instead of 0, but that's usually fine for much older game fixed-point maths since -1 is close enough to 0.

> -1 still produces -1 instead of 0 That could be a problem depending how you are using it.

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#164
post #67

Earlier quoted context omitted.

> Numeric characteristics are absolutely still a consideration for game designers even in 2026, one that influences what numbers they use in their game designs. The good ones, anyways. I used to think like this, not anymore. What convinced me that these sort of micro-optimizations just don't matter is reading up on the cycle count of modern processors. One a Zen 5, Integer addition is a single cycle, multiplication 3…

Also, it's unusual for a game to be CPU bottlenecked nowadays, and if it is, it's probably more constrained on memory bandwidth than raw FLOPS.

4X games tend to be CPU bottlenecked as far as I understand it.

That, and Factorio. The factory eats 3D V-Cache and single core speed for breakfast.

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#165

Earlier quoted context omitted.

Back in the early, early days, the game designer was the graphic designer, who also was the programmer. So, naturally, the game's rules and logic aligned closely with the processor's native types, memory layout, addressing, arithmetic capabilities, even cache size. Now we have different people doing different roles, and only one of them (the programmer) might have an appreciation for the computer's limits and happy-p…

I wrote the Intellivision Mattel Roulette cartridge game back in the 1970s. It was all in assembler on a 10 bit (!) CPU. In order to get the game to fit in the ROM, you had to do every feelthy dirty trick imaginable.

https://x.com/WalterBright/status/2036264819062665695?s=20

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#166
post #105

"Since the number is stored in a binary system, every shift to the left means the number is doubled. At first this sounds like a strange technical obscurity" Do we not know binary in 2026? Why is this a surprise to the intended audience?

https://xkcd.com/2501/

How many programmers don't know binary?

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#167
post #164
post #67

Earlier quoted context omitted.

Also, it's unusual for a game to be CPU bottlenecked nowadays, and if it is, it's probably more constrained on memory bandwidth than raw FLOPS.

4X games tend to be CPU bottlenecked as far as I understand it. That, and Factorio. The factory eats 3D V-Cache and single core speed for breakfast.

Factorio is the example I was thinking of when I was saying 'memory bandwidth bottlenecked'. It's one of the reasons it benefits from huge caches so much.

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#169
post #2

I had always heard about how RCT was built in Assembly, and thought it was very impressive. The more I actually started digging into assembly, the more this task seems monumental and impossible. I didn't know there was a fork and I'm excited to look into it

Back then a lot of people started with assembly because that was the only way to make games quick enough. Throughout the years they accumulated tons of experience and routines and tools. Not saying that it was not a huge feat, but it’s definitely a lot harder to start from scratch nowadays, even for the same platform.

One thing I really don't understand would be the ergonomics of game dev. I mean, I guess it's just an isometric drawing library, and routines for each object (though this obviously isn't OOP game Dev). But like, for example, he talks about simulating the physics of the roller coasters. I get that, and I think I could figure that out in assembly. But, in my head, connecting the dots from simulating the physics to drawing it on the screen is a huge leap. But yeah, having years of background on using assembler for game Dev would obviously be a big part of that equation.

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#170
post #2

I had always heard about how RCT was built in Assembly, and thought it was very impressive. The more I actually started digging into assembly, the more this task seems monumental and impossible. I didn't know there was a fork and I'm excited to look into it

Programming in assembly isn't really "hard" it mostly takes lots of discipline. Consistency and patterns are key. The language also provides very little implicit documentation, so always document which arguments are passed how and where, what registers are caller and callee saved. Of course it is also very tedious. Now writing very optimized assembly is very hard. Because you need to break your consistency and conven…

This makes sense and it's really that last step. It's one thing to do pattern matching or bit flipping routines. It's a whole different ballgame to build a game engine. Maybe if I knew gamedev better I wouldn't be as intimidated by it, but it really does seem like a herculean task.

I think it'd be cool to do assembler on a Pi Pico or something, that seems like it would be a fun exercise.

Post reply on HN