Assembly + C and graphic mode help

Started by serberustr, July 24, 2010, 06:09:24 PM

Previous topic - Next topic

serberustr

Hi! I'm new member and i wanna learn assembly to achieve my goal. I'm just trying to make my own BGI :) Therefore I have started to learn asm. Read alot documents( just read). Then, found out int 10 and 13h... On the other hand, I am a C/C++ programmer( not beginner or profession, between them). I am trying to call asm function in C++. I can do it use by MASM(ml.exe) and compile objects file with g++.

So, My question is;

I wrote a asm file:
.586
.MODEL FLAT,STDCALL
OPTION CASEMAP:NONE

.CODE

    start PROC C
        mov   ax,13
   int   10
;ret
    start ENDP
   
END

and
in C/C++ i can call start() function, but that's not work. What's wrong or what must i learn? :)

dedndave

INT 10h is for 16-bit programs
32-bit windows programs do not allow use of BIOS or DOS INT's

welcome to the forum   :U

serberustr

Thanks. I know that's rule, but is there any way to do it? I know this topic is too big for me, but i just want to learn. I can use MASM to put pixel on screen but i can't do it in C/C++.

dedndave

truthfully, the easiest way is to write a 16-bit program
but, you don't want to waste your time learning to write 16-bit code
you will soon find out how limited it is - and i suppose you'd need an old C compiler, too

graphics in the 32-bit world is a bit more complex
DirectX, GDI+, and OpenGL are things you'll find interesting
you can google those terms and use the forum search tool, as well
there are a few good examples
Donkey and Farabi are 2 forum members that come to mind

also - qWord has recently written a fun little app using GDI+
sadly, no source code for it   :'(
but - it is very cool

http://www.masm32.com/board/index.php?topic=14445.msg115824#msg115824

BogdanOntanu

Unfortunately the internet is full of old and obsolete tutorials that advocate old 16 bits code and use of INT10/ INT13. In today windows you can not do that anymore.

Your best choice is to use Windows API in order to gain access to a drawing surface in a way that is independent of the hardware and then perform your algorithm in ASM in that surface "as if" it was directly "on screen".

Now in order to gain access to a drawing surface you can use the folowing paths of research:
1) use GDI, select a bitmap into a device context and obtain a pointer to the bitmap's pixels then draw into that bitmap
2) Use IDirectDraw older DirectX interface, lock a surface draw into that surface, Unlock the surface and show it on screen
3) Use the Direct3D interface, lock a texture, draw to that texture, unlock the texture, map the texture on a rectangle made of 2 triangles and present it on screen using an orthographic projection (disable anti-alias if possible)
4) Check the new Direct2D emerging interfaces

good luck ;)
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

serberustr

Thanks alot :) I already use OpenGl and Glut to graphics programming. As a result, I can't use interrupts on Win32. :(

frktons

Quote from: serberustr on July 24, 2010, 07:57:26 PM
Thanks alot :) I already use OpenGl and Glut to graphics programming. As a result, I can't use interrupts on Win32. :(

I'm afraid that: yes, you can't :(
Mind is like a parachute. You know what to do in order to use it :-)