Live data from Hacker News

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

larstofus.com

171–180 of 186 posts

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

#172

Warcraft 1 (1994), Warcraft 2 (1995), and StarCraft (1998) all use power-of-2 aligned map sizes (64 blocks, 128 blocks, and 256 blocks) so the shift-factor could be pre-computed to avoid division/multiplication, which was dang slow on those old 386/486 computers. Each map block was 2x2 cells, and each cell, 8x8 pixels. Made rendering background cells and fog-of-war overlays very straightforward assembly language. All…

It's a shame that when a Redditor discovered the source code for the original StarCraft "gold master" on a CD, they sent it back to Blizzard in exchange for some fucking blizzard merch [1] EA a while back released the source code to (most) of the old Command & Conquer games [2] though interestingly left out Tiberian Sun and Red Alert 2, StarCraft's closest competitors at the time. Would've been nice for historical pr…

I don't think [1] is 100% accurate.

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

#173

Earlier quoted context omitted.

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 draw…

IIRC back then drawing on screen is simply writing into some memory mapped regions. But maybe it is more than that when the game was written, as it was in mid 90s.

I happened to glance over Linux device driver 3e yesterday, and just programming GPIO is ghastly complicated — the programmer needs to request a region, use specific memory in/out functions to write/read, and then release the region, all for just reading and writing some bytes — no real business about.

Not saying that was not a significant feat, but I think it’s almost impossible for anyone to do so nowadays — even with C it is a very good amount of knowledge to write an engine without libraries.

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

#175

Earlier quoted context omitted.

> > What language was RollerCoaster Tycoon programmed in? > It's 99% written in x86 assembler/machine code (yes, really!), with a small amount of C code used to interface to MS Windows and DirectX. https://www.chrissawyergames.com/faq3.htm

Wow. It reminds me of those guys who run a marathon carrying a fridge. Impressive, but ...

Yeah but imagine that if it was writte in anything else it would never had made it to the shelves with the processor power back then.

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

#176

Earlier quoted context omitted.

It's a shame that when a Redditor discovered the source code for the original StarCraft "gold master" on a CD, they sent it back to Blizzard in exchange for some fucking blizzard merch [1] EA a while back released the source code to (most) of the old Command & Conquer games [2] though interestingly left out Tiberian Sun and Red Alert 2, StarCraft's closest competitors at the time. Would've been nice for historical pr…

I don't think [1] is 100% accurate.

What part of it isn't accurate? They're the top commenter and said exactly what I stated

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

#177

Earlier quoted context omitted.

It's a shame that when a Redditor discovered the source code for the original StarCraft "gold master" on a CD, they sent it back to Blizzard in exchange for some fucking blizzard merch [1] EA a while back released the source code to (most) of the old Command & Conquer games [2] though interestingly left out Tiberian Sun and Red Alert 2, StarCraft's closest competitors at the time. Would've been nice for historical pr…

This entire reddit thread aged really poorly now that Blizzard is a shell of its former self. If anything, the attitude in that thread is what paved Blizzard's decline: complete disrespect for its origin. The StarCraft source code is something that must be kept behind closed walls, under tight control by Blizzard, even though the original people working on the game at Blizzard have already left and there is nothing t…

Game source code often includes other people's source code (eg middleware) under NDA, and Blizzard is still under contract for protecting that.

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

#178

Earlier quoted context omitted.

Wow. It reminds me of those guys who run a marathon carrying a fridge. Impressive, but ...

Yeah but imagine that if it was writte in anything else it would never had made it to the shelves with the processor power back then.

Programs spend the vast amount of their cycles in a small sub-set of the code. There is generally very little to be gained by optimizing code that isn't in the small subset.

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

#179
post #4

What language is this article talking where compilers don't optimize multiplication and division by powers of two? Even for division of signed integers, current compilers emit inline code that handles positive and negative values separately, still avoiding the division instruction (unless when optimizing for size, of course).

Well, Sawyer started writing Transport Tycoon in 1992, when free or affordable C compilers were not as widely available. Turbo C was never known for optimizations. GCC 1.40 was good enough for Linus, but I guess Chris was already a good assembly programmer.

Turbo C++ 3.0 from 1992 already does this optimization, according to a quick experiment over there: https://turboc.pages.dev/

       0: 55                    push   %bp
       1: 8b ec                 mov    %sp,%bp
       3: 8b 46 04              mov    0x4(%bp),%ax
       6: c1 e0 02              shl    $0x2,%ax
       9: eb 00                 jmp    0xb
       b: 5d                    pop    %bp
       c: c3                    ret
That's for:

    int
    main (int argc, char **argv)
    {
       return argc * 4;
    }
And disassembled with contemporary binutils (not sure if Turbo C++ came with a disassembler.)
Post reply on HN