Thread: assembly language...the best tool for game programming?

  1. #16
    ---
    Join Date
    May 2004
    Posts
    1,379
    shot down...

  2. #17
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Yeah I installed the so-called Wild Tangent piece o crap and all it did was send my computer off on some tangent.

    I wouldn't program a game in Java if it was the last language left on earth. It's too slow.

    If they can speed it up then perhaps but until then there is no way.

    I'm interested in three main things when it comes to programming.

    Speed.
    Power.
    Tech.

    That's it. With DirectX and/or OpenGL you get all of em. Assembly has the most power to offer but it is not easy to create a large program with it because it is so unstructued. Amounts to having a billion jmps everywhere. C/C++ with some asm thrown in is where the speed, the power, and the technology is. Games have always pushed the envelope of computers and they always will simply because they must not only be real-time but they must provide real-time interactivity. Which means that you can't expect someone to sit there while your slow ass code executes some O(n^2) algo and expect them to be satisfied. I've never seen any Java games on the net, compiled or otherwise, that I was impressed with. Even on DSL and even having the exe right on my machine the code still ran terrible. No go for me.

    So if you want to program a game in a scripting language...feel free but I think your game will be missing quite a bit.

    Judging from some recent books I've read and a very good physics one, the same one that Shadow read and recommended to me, there is no way you will ever get all the calculations and graphics to work in a pure scripting language. I'll probably be creating my own scripting language for AI and use scripts for DirectMusic, effect files, vertex/pixel shaders, etc., in my 'game' so scripts have their use but I'd never use them as my core language.

    I mean....I'm sitting here wondering how I'm going to get all this physics stuff to work in C/C++ with an acceptable frame rate...much less any other known slower languages.
    I'm going to have to compromise and omit some stuff or approximate some stuff just to get it to work and still retain its interactive element. I'm shooting for 30 FPS bare bones which is crap. I'd like to maintain 60 FPS or better so that the engine never dips below the 30 FPS mark.

    And when I say 'game' I'm not talking about tic tac toe, or any of the puzzle games you can play on MSN. I'm talking about real-time in your face high tech who's your daddy games. The rest of gamedom does not interest me. Which is fine because if everyone were like me we'd never have Scrabble or Tic Tac Toe on a computer. I'm just not interested in that type of stuff.

    So you said it. It won't be DOOM and I'll add that in a scripting language...it can't be DOOM. Because of that....I've no interest.

    It seems to me rather than try to use the wrong tool for a job you would want to use the right one to get the best results. Essentially all languages are tools. Trying to design something beyond the capability of a language or even beyond what it was intended for in the first place...to me is a waste of time. Perhaps I'm mistaken though.

    Sure I can create a game in pure assembly and maybe I'd be super cool for doing it but it would end right about there. No one could add to it, plugins would be nightmare, I'd have to re-assemble to change anything, etc., etc.

    I just don't understand why people try to do these things. Use the right language for the job at hand....period. It's really as simple as that.

    There is nothing special about languages but there is something special about using them the right way.

    how do you feel about matrical and quaternion operations, which are infamous for being very slow when sent to the FPU instead of SSE(1/2) registers(I have seen code that is 10x-25x as fast as C equivalent from a few people over at www.gamedev.net)? Because unless I forgot a white paper, I didnt realize GPU's were being used for those kinds of math?
    Yes this is true. Which is what I meant by core functions. However, based on what I've seen in Direct3D it appears that the HAL is taking care of this for you. Since I never send the vertexes to be transformed...rather I simply set the transform matrix and then DrawPrimtive I think that the HAL is taking care of this. After this step then the transformed vertex data is sent to the GPU. But I'm not sure I could code a faster transformation pipeline than has already been provided. I've programmed several transformation pipelines, but D3D seems to be doing the job just fine so it would be arrogant of me to assume I could program a faster one....but later perhaps when it does not suit me and when I move to pixel shaders and such I probably will do this. I'm not sure how OpenGL transforms the vertices...probably through a similar method. I've never seen any info to point to matrices and quats being sent to the GPU....but perhaps someday we will be able to do this which would be nice. Perhaps OpenGL and D3D are already using SSE (if avail) internally....which would make sense.

    This is what I meant by it being 10 times slower. Sorry for being vague. Also if you are not using the hardware to render then you are missing out on an awful lot of speed there. The hardware can do more effects, blending, etc. and faster than anything I've seen in asm. And this makes sense since hardware is supposed to be faster than software.

    I think you misunderstood me a bit and I think we are basically saying the same thing.
    Last edited by VirtualAce; 06-18-2004 at 07:58 AM.

  3. #18
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    How fast or efficient a game written with a scripting language is not the focus of my statement. You made an invalid statement. That it was impossible to make a real time game in a script language.

    Fact:
    You can.

    Web games have a purpose, they are "web" games. They arn't doom4 or quake 28. Get over it. Recognize them for what the are--a medium to provide entertainment through a limmited communication barrier (the internet). Quite frankly, and to be brupt, I've played wild tangent games -- ones programmed with scripting languages, java, and c++. And all of them have been more content, better graphics, and gameplay then you or I have demonstrated on this forum. Even with DirectX, OpenGL and other efficient, fast, powerful api's at our direct use.

    I think you should keep that humbling truth in mind when considering the usefulness of scripting languages.


    cheers.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  4. #19
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Their usefulness is not in games.

    Man...go buy a game mag or something. I can't believe I'm hearing this. We are talking about two totally different genre's here. I'm not blasting your genre and I'm not elevating the one I'm interested in.

    But don't make statements like real-time games can be programmed in scripting languages. What I consider real time and what you consider real-time might be 2 different things. For real-time let's go with 30 FPS renders - not bit blts, not sprites, etc., etc. True 3D, 3D sound, etc, etc. That can only be done with a language like C/C++ and an API like OpenGL or D3D. Even a game in Allegro is going to be slower simply because it does not have access to the hardware. These companies have worked years and years to bring us this cool stuff and I've watched it evolve from the old Rendition Verite 1000 to the newest Nvidia card. With all this cool stuff at our disposal I cannot fathom why someone would use something else. Right now it's a game programmer's paradise. More RAM, more speed, more hardware functions, more...everything...and its only going to get better.

    The games you are talking about do not need total control of the system but the one's I'm talking about do. 2 totally different concepts. And nowhere did I say that I have programmed anything close to what has already been released nor could I with just me at the helm. But I don't need a title under my belt to know when a game is just too slow for my tastes or a language for that matter.

    Chill out.

  5. #20
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    It's obvious you didn't really spend any time trying out wild tangent. Else you would know that most of the games use REAL*** 3d and REAL*** 3d sound. It's part of the api, I know, I've used it. FPS is limmited to user machine. And if you are running sub 30 fps on those games, really you should look at your system cause there is something wrong with it. I play the Men in black game, black hawk game, and several others and post 30 fps. They are really fun.

    I'm only attacking you because of your whacked out definition of real time. Real time (as far as gaming goes) has always been about the nature of game play, not system performance. Your ackward use of the word real time to perpetuate the false idea that games can't be made in a scripting language is what is so frustrating. I would have no problem if you clearly stated what you obviously mean in a way that doesn't result in a false conception in the ability of scripting languages.

    What you mean to say is that scripting languages are by nature (due to their implimentations) are less efficient then the high level (or low level) programming languages they are based on.

    The fact still remains however, they can be used to program games, applications and be used for other software uses so long as you can impliment functionality that isn't impeded by the run time performance. Which is very possible.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  6. #21
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    What you mean to say is that scripting languages are by nature (due to their implimentations) are less efficient then the high level (or low level) programming languages they are based on.
    Yes, I think that sums it up well. Now why couldn't I have said that?

  7. #22
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    I agree. It's really no big deal. As for silk.odyssey's original question... As everyone has said, the best way to write games is to use OpenGL/DirectX. Those libraries themselves, if you look through them, are mostly assembly optimizations to thinkgs like hardware access, speed tweaks, etc. Assembly is the best to use, just in its proper place.

  8. #23
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    I agree. It's really no big deal. As for silk.odyssey's original question... As everyone has said, the best way to write games is to use OpenGL/DirectX. Those libraries themselves, if you look through them, are mostly assembly optimizations to thinkgs like hardware access, speed tweaks, etc. Assembly is the best to use, just in its proper place.
    well, quick question, is the core of D3D HAL written in assembler? Because basically what we are looking at here if it is is the following:

    1) D3D HAL written in assembler, programmer uses C function calls to abstract the assembler subroutines

    2) Programmer writes all core functions to use if available SSE optimizations . . . in assembler. Programmer then abstracts those subroutines to be incorperated in C.

    To Original Poster:
    Notice a pattern here? Basically, what Bubba has been saying, and me attempting to say, is that you can view programming as a multiple tier skyscraper. You begin with assembly, programming all of your necessary core routines so you have a solid foundation, so that when you code runs slow you dont have to go through all of your Matrical operation functions to try to find the bottlepoint, because the bottlepoint is in one of your higher level functions(such as 3D Model loading, BSP rendering,etc.). You then progress to C/++ with everything else, because there is no real reason to program a BSP renderer in pure assembly (with D3D calls), because it really isnt floating point arithmetic intensive.

    NOTE: sorry if the beginning of my words to you OP sound like I am saying that you aren't recognizing something, I tend to come off condescending when I am trying to make things clear for the benifit of the person in the case the person doesnt know it.

  9. #24
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    It seems to me that a lot of people are pre-judging DX and OpenGL without ever having used either one. I for one do not know how DX or OpenGL get the job done exactly but I do know what every 3D API has to do to transform vertexes. I understand the mathematics and I could code them myself but why?

    I'm sure as Ev has stated that the devleopers of DX and GL both took assembly into consideration when they coded the APIs. The API probably does check for SSE SSE2 support and if its available I'm sure it uses it.

    What DX and GL allow all of us to do is....focus on the game, not on the nitty gritty. When you need more speed and have verified this via profiling, testing, etc., then you might be able to get more speed with hand-tuned assembly.

    Ev and I are huge assembly advocates but we also realize that it is completely, or at least very nearly, unstructured and turns into a large mess rather fast. Use assembly where it is needed, but keep in mind that if the hardware supports the function no amount of assembly produced by the best asm programmer on the planet will ever be faster than the hardware. Essentially the hardware is the hard coded asm function.

    For more info I refer you to the AOA book and the chapter on architecture and circuit design.

  10. #25
    Registered User gell10's Avatar
    Join Date
    Jul 2003
    Posts
    46
    As for Scripting Games go. There is one called runescape at http://www.runescape.com That is pretty advanced. It is a mmorpg that is written in pure javascript. I am pretty sure. Sure it is no Doom3 but I think it stresses the fact anything can be written in whatever you like. Just choose what you have researched to have the benefits that matter most and the costs that don't really matter to you.

  11. #26
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Its written in JAVA. not javascript.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  12. #27
    Banned
    Join Date
    May 2004
    Posts
    129
    Those libraries themselves, if you look through them, are mostly assembly optimizations to thinkgs like hardware access, speed tweaks, etc. Assembly is the best to use, just in its proper place.
    How, exactly, do you 'look' through them when the implementations are hidden in dlls?

    I tend to agree with what goten said, because you can use a scripting language to make games. You can even do decent real 3D.

    Is Visual Basic a scripting langauge? I mean, it *is* interpreted at runtime (but it can also be compiled to an exe), which is the basic definition of a scripting language. I've seen some nice 3D rendering projects done in OpenGL and written with Visual Basic.

    edit

    back to the whole assembly issue. I've got a few questions.

    1) How many people on these boards can really effectively use assembly in their projects?

    2) How do you know that your assembly instructions are faster than what you would've written otherwise?

    3) Are you adding assembly to your projects before or after you are done? As a rule, the best idea for projects is to code first (like, get stuff to WORK), and then optimize later (meaning putting assembly code in your project a week into it is essentially sabotaging your later efforts, unless you comment like a demon).
    Last edited by vNvNation; 06-19-2004 at 08:38 AM.

  13. #28
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Quote Originally Posted by vNvNation
    back to the whole assembly issue. I've got a few questions.

    1) How many people on these boards can really effectively use assembly in their projects?
    For the x68 motorolla processor, I can.
    For anything greater, x86 etc. LOL no. But it's only cuase I haven't takin any steps to learn the instruction set or the registers.

    2) How do you know that your assembly instructions are faster than what you would've written otherwise?
    Usualy you can use timing methods to find out. But as a general common sense rule - compilers create fat juicy binary. It has been inflated to allow for general use. 9 times out of 10, hand written assembly code (specifically for a task) will be faster then a high level language code (for general all purposes).
    3) Are you adding assembly to your projects before or after you are done? As a rule, the best idea for projects is to code first (like, get stuff to WORK), and then optimize later (meaning putting assembly code in your project a week into it is essentially sabotaging your later efforts, unless you comment like a demon).
    I prefer to code first, and improve later. At times it becomes important to tackle bottlenecks immediatly though--especially in situations where further code will be revolved around whats already done.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  14. #29
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    The only way to make any code faster is to use better algorithms. If you take code written in any language, and write out the corresponding assembly commands line by line, the programs will be the EXACT same.

    The only time when one should resort to assembly is when the language you are using will not allow you to use a specific algorithm, and assembly will.

  15. #30
    Registered User
    Join Date
    Apr 2004
    Posts
    210
    Quote Originally Posted by silk.odyssey
    Assembly language would be useful in this case because function parameters can be passed through registers.
    I think Delphi/Pascal functions pass their first 2 parameters through registers.

    Quote Originally Posted by silk.odyssey
    Another trick he mentioned was using the left and right shift operators to do multiplication and division.
    I'm fairly sure GCC does this implicitly if possible. No need use it in your code. It performs a lot of other optimizations like using the faster leal asm instruction for additions/multiplications if possible.

    Quote Originally Posted by silk.odyssey
    but if a game is being written for windows only or for one specific platform wouldn't it just be better to use assembly instead of trying to emulate it with a high level language.
    No. The development cost/time would be enormous. You would also need programmers that are better at optimizing asm code than an optimizing compiler is. That excludes 99% of all coders from your project. It's easy to optimize short passages of assembler code, but a whole program? Even trying to do so might seriously impair your mental health

    Quote Originally Posted by silk.odyssey
    A lot of people question whether or not assembly is a suitable development tool today but i think game programming may just be one area where it's a perfect fit.
    It's nice to optimize important parts of your program with it. Use a profiler, see where the bottleneck is and optimize that part in assembler. However, maintaining assemblercode is not easy. I would use it as little as possible.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Learning Assembly
    By mrafcho001 in forum Tech Board
    Replies: 5
    Last Post: 03-12-2006, 05:00 PM
  2. Language of choice after C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 06-15-2004, 01:20 AM
  3. Assembly Help PLease!
    By Tleggo in forum C Programming
    Replies: 2
    Last Post: 05-24-2002, 03:29 PM
  4. C,C++,Perl,Java
    By brusli in forum C Programming
    Replies: 9
    Last Post: 12-31-2001, 03:35 AM
  5. Visual J#
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-08-2001, 02:41 PM