News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Help i'm new

Started by gbmach7, May 12, 2013, 01:32:39 AM

Previous topic - Next topic

gbmach7

How do I write/draw to the screen using interrupts so i can create say a hello world application.

Vortex

Hi gbmach7,

Welcome to the forum.

Here is an example for you :

http://wyding.blogspot.com/2009/04/helloworld-for-16bit-dos-assembly.html

gbmach7

Okay so that worked, thank you. Now I read that INT 10h is slow compared to accessing video memory directly from http://en.wikipedia.org/wiki/INT_10H . How would I go about doing that since I want to create a simple game?

dedndave

you can load the video buffer segment into the ES register (or DS, if you are careful)
depends on the video mode, but the segment is usually either 0B000h or 0B800h
try 0B800h first   :P
i think 0B000h is for TTL modes, which is 7, i guess

from there, you can write bytes directly to the video buffer
each character cell has 2 bytes, one is the character, the next one is the attribute
the attribute is divided into lower and upper nybbles, which controls colors for background and foreground
http://webpages.charter.net/danrollins/techhelp/0087.HTM

there is an extra bit for foreground color - that is intensity
and another bit that controls blink or underline
whether it is blink or underline is selectable by writing a register - or, there may be some INT to do it   :P

i might add.....
INT 10h wasn't the fastest way - back in the day
you could improve speed by writing directly to the buffer
but, it was best if you syncronized the writes with the retrace signal - a little tricky

thing is - that was great on a 4.77 MHz 8088 machine
nowdays, the computers are much faster, and you will find that INT 10h is pretty good   :t

FORTRANS

Hi,

   0B000H and 0B800H are the text video segments.  0A000H
is the graphics video segment.

Regards,

Steve

dedndave

yes - A000h for EGA/VGA
B800h for CGA
B000h for TTL/herc

gbmach7

Okay so INT 10 is only 8bit color. If I use VGA segment address will that be 16bit color? Or how exactly do i get say 32bit color, with another interrupt? Sorry I'm more just researching then actually trying the stuff out that you guys are providing unless there's a tutorial on this that I'm missing. Thanks for help so far! :greenclp:

dedndave

you can select different video modes using INT 10h, AH = 0, AL = video mode

the problem with more colors and larger screens is that the video buffer no longer fits into a single 64 kb segment
so - you have to do page flipping to access the different parts of the buffer

one of the video modes i used to play with (for graphics) was mode 13h, 320x200, 256 color
you can program each of the 256 palette registers to one of 256 k colors, as i recall
it was easy to code for because the entire buffer is 64000 bytes   :P

MichaelW

Other advantages of mode 13h are that each pixel is represented by one byte, and the entire buffer is effectively in a single plane, so it can be accessed as a linear array. The VGA does not support anything beyond 8-bit color. For 16-bit or 32-bit color you need SVGA.
Well Microsoft, here's another nice mess you've gotten us into.

Gunther

Hi  gbmach7,

welcome to the forum. As Michael wrote, the standard VGA with the resolution 640 by 480 pixel can display only 16 colors. This mode is complicated. Much more easy is the mode 13h and some Mode X variants. If you need better resolutions or more colors, one way is to use the VESA driver. But these are tasks for experienced programmers, because you have to do bank switching or the linear frame buffer over 1 MB (only possible in protected mode). You shold go first in another direction if you would like to learn assemly language.

Gunther
You have to know the facts before you can distort them.

FORTRANS

Hi,

   This was an example of writing text directly to the screen.

Here is an example of writing to the screen.

   These programs showed the speed difference between using the
Video BIOS and writing to the video buffer directly.  Mode 12H and
Mode 13H graphics.

Graphics example programs

HTH,

Steve N.

Gunther

Hi Steve,

very good example for teaching purposes. :t

Gunther
You have to know the facts before you can distort them.

FORTRANS

Hi Gunther,

   Thank you.  Nice to get some feedback.

Regards,

Steve N.

gbmach7

Just a follow up. I tried video mode 13h which is 256 colors and I get a popup that says "This system does not support fullscreen mode" with a close or ignore button but both shut down the program. :( I am running windows 7 Home Premium with a widescreen monitor. http://stanislavs.org/helppc/int_10-0.html says that 13h is the only one with 256 colors so I'm stuck with 16 colors. Thanks for all the help! :t

Edit: Btw FORTRANS all your examples have the same popup

Just installed DOSBOX and all the examples and my program work :icon_cool:

dedndave

yah - it does require fullscreen - as well as any other "old" graphics mode
you aren't going to have much luck with DOS code under win 7/8, really
but - you may be able to boot up in DOS and run them

the fact is, if i want to write a graphics program today, i use a 32-bit GUI app
you get all the colors and resolution the system will support, and a user-oriented multi-task interface

other than nostalgia, 16-bit code is past-tense   :P