Live data from Hacker News

Original Age of Empires 2 dev talks about its usage of assembly code

old.reddit.com

81–90 of 113 posts

Re: Original Age of Empires 2 dev talks about its usage of assembly code

#81
post #20

Earlier quoted context omitted.

> uses half the instructions generated by the C++ compiler is there a tool that could profile/predict ahead of time, so that one does not attempt to hand write assembly before knowing for sure it will beat the compiled version?

There was Intel VTune, which I heard was good, though I haven't used it myself. One difficulty is that there are many non-obvious and hard-to-predict factors that interact to produce pipeline stalls. Instructions had specified throughputs and latencies (throughout being the number of cycles before another independent instruction of that type could be initiated; latency being the number of cycles before its output cou…

Yup. Back in the day VTune was useful and good, then I haven't used it for more than 20 years. It might be still good, but knowing how much more complicated the current CPU architecture is, and how much I've lost touch with low-level assembly I don't know if it's going to be useful to me. I'm relying now on profiling, and other programmers that have become way better in this than me to hear their opinion, and use that as basis (or others on the web).

Most of the time, some good optimized library would do pretty good.

Re: Original Age of Empires 2 dev talks about its usage of assembly code

#82

Earlier quoted context omitted.

There was Intel VTune, which I heard was good, though I haven't used it myself. One difficulty is that there are many non-obvious and hard-to-predict factors that interact to produce pipeline stalls. Instructions had specified throughputs and latencies (throughout being the number of cycles before another independent instruction of that type could be initiated; latency being the number of cycles before its output cou…

VTune still exists and is free since a few years. Neat thing with VTune is that it has support for a few runtimes, so it understands for example CPython internals to the point that stack-traces can be a mixture of languages. That's something only becoming available just now outside of VTune, like Python 3.12 has some hooks for Linux perf. A purely pen-and-paper tool was IACA; you simply inserted some macros around a…

Awesome - I'll try it again!

Re: Original Age of Empires 2 dev talks about its usage of assembly code

#83
post #77
post #4

I worked on port of a Konami game from PSX to PC, that was 1999-2000 - the code (C) had lots of #ifdefs like where inline assembly was placed, and the original "C" code was kept. It seemed all done by one specific programmer, and what really saved us (in porting) the game was the originallly kept "C" code. My mips knowledge was never as good as x86. So yes, it was the norm back then. My second job (1998), was working…

> mipmapping and texture swizzling Imagine reading this as a layman

well I've now realized I've used the terms I now know, and looking at what I've read back then - it was roto zoomers (lol) and it looks like it was the "block" texture way instead of what's considered now the term - swizzling - https://www.khronos.org/opengl/wiki/Texture#Swizzle_mask

Re: Original Age of Empires 2 dev talks about its usage of assembly code

#84
post #12

Earlier quoted context omitted.

I was actually trying to find it - there were lots of .txt files published back then - and there was one about texture mapping from 1992... 1994? - and it explained swizzling and why it was efficient with caches.

fatmap.txt discusses tiled textures a bit https://hornet.org/code/3d/trifill/texmap/fatmap.txt

I think that's what I was looking at, and read back then - it was only txt files :)

Re: Original Age of Empires 2 dev talks about its usage of assembly code

#85
post #5
post #2

>The use of assembly in the drawing core resulting in a ~10x sprite drawing speed improvement over the C++ Wow that's a chunky improvement over an already fast lang

This was in 1999. C++ compilers have come a long ways since then. While there are still opportunities for hand-written asm to go and order of magnitude faster than C++, they're mostly around manual vectorization where the auto-vectorizer fails.

Assembly is still used in whole program coding to this day, for example some modern music synthesizers are written in assembly code.

Re: Original Age of Empires 2 dev talks about its usage of assembly code

#86

Earlier quoted context omitted.

They do. Over their desks, while working or in a video call.

We get a 1 hour lunch break required by law and yet people still do this willingly.

I often would rather go home from work an hour earlier than sit and eat lunch for an hour. It's as simple as that, really.

Re: Original Age of Empires 2 dev talks about its usage of assembly code

#87
post #66

Earlier quoted context omitted.

I think AOE was using DirectX, so I assume that was one level up the stack, ie figuring out which sprites are visible to which extent by walking different data structures and then just throwing stuff at directdraw.

DirectDraw wasn't really meant as a drawing toolkit; you _did_ have blits, but they were not hardware accelerated AFAIK and not nearly flexible enough for what the article suggests (mirror, stiple, probably other stuff). In general, what DirectDraw gave you was a rectangle you could draw pixels into, and a way to get those pixels efficiently to the screen. In other words, more like a clean abstraction over the displa…

DirectDraw did accelerate blits, but only simple cases, and even then only if the hardware and drivers supported it. Hazy memory is that accelerated blit support was sketchy for pre-3D GPUs, especially stretchblts. It also had significant overhead for drawing small sprites. DirectDraw was critical for video players at the time due to being much faster than GDI and even sometimes Direct3D.

Re: Original Age of Empires 2 dev talks about its usage of assembly code

#88

Earlier quoted context omitted.

We get a 1 hour lunch break required by law and yet people still do this willingly.

I often would rather go home from work an hour earlier than sit and eat lunch for an hour. It's as simple as that, really.

Actually no, it's not "as simple as that" when everyone except you doesn't take lunch hour and schedules meetings at noon. We have a right to the lunch hour.

Re: Original Age of Empires 2 dev talks about its usage of assembly code

#89
post #66

Earlier quoted context omitted.

DirectDraw wasn't really meant as a drawing toolkit; you _did_ have blits, but they were not hardware accelerated AFAIK and not nearly flexible enough for what the article suggests (mirror, stiple, probably other stuff). In general, what DirectDraw gave you was a rectangle you could draw pixels into, and a way to get those pixels efficiently to the screen. In other words, more like a clean abstraction over the displa…

DirectDraw did accelerate blits, but only simple cases, and even then only if the hardware and drivers supported it. Hazy memory is that accelerated blit support was sketchy for pre-3D GPUs, especially stretchblts. It also had significant overhead for drawing small sprites. DirectDraw was critical for video players at the time due to being much faster than GDI and even sometimes Direct3D.

Yeah, sounds about right. And yes, obviously it was much faster than GDI for games, since you had more or less direct access to a framebuffer. Not building up some device-independent bitmap and going through some slow path to convert it into the right format for the GPU (which wasn't called a GPU back then, of course).

Re: Original Age of Empires 2 dev talks about its usage of assembly code

#90
post #27
post #4

I worked on port of a Konami game from PSX to PC, that was 1999-2000 - the code (C) had lots of #ifdefs like where inline assembly was placed, and the original "C" code was kept. It seemed all done by one specific programmer, and what really saved us (in porting) the game was the originallly kept "C" code. My mips knowledge was never as good as x86. So yes, it was the norm back then. My second job (1998), was working…

Another Flipcode user! I missed that other game forums of similar vintage are now gone. The way to being able to do Assembly in Borland products, and to lesser extent on VC++, was great. I always feel like vomiting when looking at the mess UNIX compilers have come up for it, instead of inferring how registers are being used, and the whole string concatenation stuff.

It’s cool that gamedev.net is still around but I really miss flipcode!
Post reply on HN