Inline assembly pixel manipulation.

Started by
10 comments, last by Antheus 16 years, 8 months ago
Can someone direct me to a tutorial where i can learn the basics of graphics manipulation with inline assembly? I want to write an emulator and was told i would need to run the graphics with assembly code to make it fast enough. P.S. I am using Dev C++. Don't even bother telling me to switch compilers.
Advertisement
Quote:Original post by nick22891
Can someone direct me to a tutorial where i can learn the basics of graphics manipulation with inline assembly? I want to write an emulator and was told i would need to run the graphics with assembly code to make it fast enough.
You were told wrong. There's two ways you'll be able to write better assembly than the compiler:
1. Have been writing assembly for many, many years and have at least equal knowledge of assembly as the compiler writers.
2. Have advance knowledge of some optimisations that can be performed, for instance using prefetch or SSE instructions. Although the performance benifit you'll get from that is almost certainly going to be negligible.

Overall, don't worry about it. Write your emulator in C/C++ and then optimise parts as needed. If you're writing an emulator, you're probably emulating something a fair bit slower than the machine running the emulator anyway.
But how will i deal with the graphics rendering? i dont like libraries. DO i have to use them?
Quote:Original post by Evil Steve
2. Have advance knowledge of some optimisations that can be performed, for instance using prefetch or SSE instructions. Although the performance benifit you'll get from that is almost certainly going to be negligible.
And you're still going to have much better results using SSE intrinsics than you are with inline assembly.

It's quite difficult to even write a working emulator, let alone write one that is fast. Make one that works first, and then move from there. And yes, you'll have to use a library, whether it's SDL, D3D, OGL, or something else.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Enjoy, welcome to ~20 years ago. Sometimes giving people exactly what they ask for is the best way for them to find out they didn't really wanted it in the first place.
Quote:Original post by nick22891
But how will i deal with the graphics rendering? i dont like libraries. DO i have to use them?
Unless you're writing your own OS, you're already using libraries. For raw graphics output, DirectDraw is probably the fastest you'll get since it can basically give you a large array that represents the screen (Locking a surface).

Even using assembly (inline or otherwise) you can't just magically write to video memory.
Quote:
i dont like libraries. DO i have to use them?

Yes, you have to use them.

And you don't really dislike libraries, because if you did, you wouldn't be using them. Which means you'd be doing lots of really unpleasant stuff by hand, including replacing all of the stuff that the C runtime and various supporting OS libraries are doing for you. I find that people who proclaim they "don't like using libraries" are shocked to discover exactly how many libraries and supporting tools they depend on just to get to the point where main() is called.

On a similar note, a good programmer knows the value of tools and the cost of reinventing the wheel for trivialities. Pushing pixels on the screen is one of those cases where you use a library, because the alternative is man-years of effort for something that is, at best, as decent as the default facilities available to you. In short; not worth it.

Note that you could pretend to manually muck around with pixels by writing a DOS application (a real DOS application, not a console-mode application) and running that under the DOS VM. But that would require switching compilers; Dev-C++ (which is, incidentally, an IDE, not a compiler) does not ship with a DOS compiler (as far as I know, at least, MinGW only produces Win32 applications).
Quote:Original post by jpetrie
Note that you could pretend to manually muck around with pixels by writing a DOS application (a real DOS application, not a console-mode application) and running that under the DOS VM. But that would require switching compilers; Dev-C++ (which is, incidentally, an IDE, not a compiler) does not ship with a DOS compiler (as far as I know, at least, MinGW only produces Win32 applications).


That is correct, you would have to replace MinGW with DJGPP.
I just checked out the link to the page the guy posted and im convinced that libraries are the way to go. I thought they were too complicated but now i see how simple they are by comparison.
Quote:Original post by nick22891
But how will i deal with the graphics rendering? i dont like libraries. DO i have to use them?


"But how will I deal with the drawing? I don't like ball-point pens. Do I have to use them (or will a quill and crushed berries work fine)?"

This topic is closed to new replies.

Advertisement