Sign in to follow this  

Old Games

This topic is 4409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, folks! :) I'm interested in how the old games (but still not text based but having graphical counterpart) were made. I mean what technics were used, did they code all this in asm? Anyone having interesting links on the topic plz share :)

Share this post


Link to post
Share on other sites
most of the source code for old games are gpl'ed "you can download the source to recompile" I know games like quake 2 used asm for rendering and timing but i don't if they had any thing else. But to answer your question i believe they used a mixed of c/c++/asm but i could be wrong

Share this post


Link to post
Share on other sites
Depends how long back you want to go:
* Very long ago, it was all ASM, with lookup tables for everything, even addition (Commodore 64)

* Then it was higher level languages, with ASM for everything requiring performance, and still plenty of lookup tables. (Atari/Amiga/PC)

* Then PC's took over and got faster, so ASM was only used in the most time critical inner loops, everything else was coded in high level languages. And lookuptabls were mostly used for ver expencive inner loop calculations and trigonometry functions.

* Then hardware accelerated graphic cards entered the scene and compilers got sophisticated enough to produce reasonably fast ASM code. This coupled with HW acceleration and faster PC speeds made hand optimized assembler programming obsolete. Thus it was that the beautiful art was forever lost to mankind.


Transport Tychoon, as an example of a fairly recent game in the whole picture, was written exclusively in ASM, and is still one damn fine piece of software.


It's still possible to hand write optimized ASM and get certain inner loops [edit]20 percent, not 20 times![/edit] faster than any compiler could ever produce. But for the most part it's no longer necessary since we have such immense computing power sitting in our little gray boxes.

[Edited by - Bad Maniac on November 13, 2005 4:02:15 PM]

Share this post


Link to post
Share on other sites
Try intruder I know you don't want text based but it great fun and has lots of reply value (try the church and the guys closet for hidden points and set fire to the preist to acces down stairs! can't find the source on it buts it's still fun!

Share this post


Link to post
Share on other sites
Quote:

It's still possible to hand write optimized ASM and get certain inner loops 20 times faster than any compiler could ever produce.


I have serious doubts about this. Do you have any real examples?

Share this post


Link to post
Share on other sites
Quote:
Original post by RDragon1
Quote:

It's still possible to hand write optimized ASM and get certain inner loops 20 times faster than any compiler could ever produce.


I have serious doubts about this. Do you have any real examples?
It's a bit off topic but I'll take any bragging opprotunities I can get..

I've recently spent some time on developing an image compressor using vector quantization for a realtime image decompression (essentially the software equivalent of hardware texture compression). The algorithm is highly asymmetrical, so while decompression (blitting) is blazingly fast the compression can be an overnight batch job.

In my compressor 99% of the time is spent on making a brute-force search matching a set of pixels from the source bitmap against a codebook.
To optimize it I switched to a counter-intuitive interlaced fixed-point datastructure, instead of a direct floating point implementation as seen in the article's example code. The result was more than a 15x improvement over the original C code.
And together with a few algorithmic improvements it's now possible to compress a 640x480 image in less than a second on fast machines =)

And, yes, I do realize that an intelligent compiler might be able to produce something similar to my code if given the same datastructures to work with. But this is kind of a moot point since I essentially had to write the assembly code to figure it out in the first place.

Share this post


Link to post
Share on other sites
Quote:
Original post by RDragon1I have serious doubts about this. Do you have any real examples?
Not really related to the topic...

In almost any application where data can be operated on differently by different processors and/or instruction sets, the compiler can only ever optimize for the currently selected CPU, or a selected best overall. Hand written assembly has the advantage of multiple code paths, each highly optimized for it's specific target platform, selected at run time depending on available instruction sets.

Examples include software rendering where hand optimized assembly code is essential for getting real time performance even on todays massively fast machines.
On almost all performance intensive applications such as audio or video editing software, emulators and realtime raytracers, you still find large blocks of pure assembly, simply because no other method gave the same performance benefits. And I'm willing to bet Epic still has a few choice lines of ASM in their Unreal engines.

I have co-written a software 2D blitting library, and we have seen speed improvements of sometimes 100 times from a standard C implementetion with all optimization options enabled in the compiler compared to hand written asembly versions of the same blitters.

You always know better what your code is doing than the compiler, and can thus optmize better for the task at hand. Furthermore, you can view the compiler output assembly code, and improve on it, while the compiler can't read your mind and figure out how to best optimize your application.

Share this post


Link to post
Share on other sites
Quote:
Original post by Daniel MillerModern CPUs are very fast at floating point math
Modern computers are even faster at integer math, and fixed point is far more precise than floating point. So the optimization might not have been solely for performance benefits.

But this is getting largely off topic =/

Share this post


Link to post
Share on other sites
Quote:
Original post by Daniel Miller
Was this run on a modern computer and compiled a modern compiler?

Modern CPUs are very fast at floating point math, so I don't see how your omptimization would have helped (or why it couldn't have been done C).
Yes, it was run primarily on my P4. And the C version was compiled with MSVC 6 and 2k5.
My first instinct was the same as yours, especially since the algorithm relies heavily on multiplications which are very slow on the normal integer unit of a P4.
However by using 128-bit MMX and 16-bit words I was able to process and store twice as many words, and unrolling the loop really helped in hiding latencies (you also get a free addition with the pmaddwd instruction). Additionally I was able to insert an 8-bit index in the low byte of the resulting 32-bit integer, which really helped with keeping track of the best match.

So I really *had* to write it in assembly language to figure out how to format it's input.

Share this post


Link to post
Share on other sites
Tamior: I programmed 11 years ago in pascal/c as a highschool student (wow i feel old) and since the graphics library that came with pascal was super slow we (me and friends) coded basic graphics algorithms in assembly. (using tutorials we found in BBS's - ahh the world before internet..). The rest of the game we coded in highlevel. So it was like writing a game in allegro today except we had to make our own allegro...

as for the assembly use today:
The greatest performance lost goes to bad algorithms and bad datastructures, which is a high level issue. IE when using O(n) algo instead of O(logn) things can take all night instead of seconds.

you should know what the cpu does behind the scenes so (cache, prefetch, pipelines, etc..). The classic for this is searching a matrix by columns instead of by rows (both are O(n), but rows is much nicer on the cache).
Even in this hardware related optimizations you hardly need to use assembly.

what im trying to say, first optimize your algorithms in high level. If you still need more speed (and usualy you dont) consult the hardware related tricks. If there is no choice use assembly. I very doubt you can get a 20 times improvment just by switching to assembly.

Iftah.

Share this post


Link to post
Share on other sites
Quote:
Original post by Iftah
as for the assembly use today:
The greatest performance lost goes to bad algorithms and bad datastructures, which is a high level issue. IE when using O(n) algo instead of O(logn) things can take all night instead of seconds.

I very doubt you can get a 20 times improvment just by switching to assembly.


No, that's not what I meant either, if that's what it sounded like. By simply switching to ASM, while keeping the data structures and algorithms the same will yield no significant performance gain, unless you can force the code to use some undocumented CPU feature, or an insruction set the compiler doesn't work with. Or it might yield a few percent gain overall, if you can generate ASM code more specifically tuned to the task. My 20% statement goes from a generic pure C implementation, to a highly optimized assembler function, written specifically for the task at hand.
We have also seen that ASM gives virtually no gains in certain scenarios, and obviously if you aren't that fluent in ASM, the implementation can indeed cost performance.

ASM isn't magic, nor is it, as stated in my first reply, generally necessary today. BUT, in the right situation, hand written assembly allows you to utilize very specific optimizations that the compiler might not be ables to. And in those precious few scenarios the gains will be worth the added implementation time. And can indeed gain anything from a 1% performance increase (vital if it is an inner loop getting called a zillion times per second), to almost any ammount of increase. My 20% noted above is just a figure we noticed in one particular scenario. Obviously switching a code block to asm isn't going to always give a certain percent performance increase, but I would have thought that was rather obvious.

Assembler is pretty cool tho ;)

[edit]
GAH! I just noticed in my first reply that I stated 20 TIMES, this is not what I meant, I meant 20 percent! Sorry for the confusion.[/edit]

Share this post


Link to post
Share on other sites
Quote:
Original post by owiley
most of the source code for old games are gpl'ed "you can download the source to recompile" I know games like quake 2 used asm for rendering and timing but i don't if they had any thing else. But to answer your question i believe they used a mixed of c/c++/asm but i could be wrong


C++ was standerdized in 1998 I think so any real old games didn't use it. Developers are just starting to use C++.(relativly)

Share this post


Link to post
Share on other sites
Quote:
Original post by Deyja
Quote:
with lookup tables for everything, even addition


That's just stupid. Using the lookup table would take TWO additions.
I see that you're (un)fortunate enough not to have optimized any 6502 assembly code..

Seriously though, it only supports additions with carry between the accumulator and memory. But indexed addressing modes with x or y has a "free" built-in addition which, combined with a bit of self modifying code for the other operand, can shave off a few cycles.

edit: I suppose an even funnier example would be the identity LUT which can be used to perform arithmetic operations between the accumulator and one of the index registers (i.e. "ADC identity,x").


[Edited by - doynax on November 13, 2005 5:30:26 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Bad Maniac
Transport Tychoon, as an example of a fairly recent game in the whole picture, was written exclusively in ASM, and is still one damn fine piece of software.


Darn true dude ;).

If anyone would like to get their hands on a copy of the game, head over to :
Abandonia.com

That's site you want to know if you want to try out the classics ;)

Share this post


Link to post
Share on other sites

This topic is 4409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this