Author Topic: Help i'm new  (Read 4505 times)

gbmach7

  • Guest
Help i'm new
« on: May 12, 2013, 01:32:39 AM »
How do I write/draw to the screen using interrupts so i can create say a hello world application.

Vortex

  • Member
  • *****
  • Posts: 1730
Re: Help i'm new
« Reply #1 on: May 12, 2013, 03:26:10 AM »
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

  • Guest
Re: Help i'm new
« Reply #2 on: May 12, 2013, 04:12:48 AM »
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

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: Help i'm new
« Reply #3 on: May 12, 2013, 04:21:09 AM »
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

  • Member
  • ****
  • Posts: 946
Re: Help i'm new
« Reply #4 on: May 12, 2013, 05:15:16 AM »
Hi,

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

Regards,

Steve

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: Help i'm new
« Reply #5 on: May 12, 2013, 05:19:58 AM »
yes - A000h for EGA/VGA
B800h for CGA
B000h for TTL/herc

gbmach7

  • Guest
Re: Help i'm new
« Reply #6 on: May 12, 2013, 05:46:43 AM »
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

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: Help i'm new
« Reply #7 on: May 12, 2013, 06:25:20 AM »
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

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: Help i'm new
« Reply #8 on: May 12, 2013, 01:29:10 PM »
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

  • Member
  • *****
  • Posts: 3517
  • Forgive your enemies, but never forget their names
Re: Help i'm new
« Reply #9 on: May 12, 2013, 09:09:50 PM »
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
Get your facts first, and then you can distort them.

FORTRANS

  • Member
  • ****
  • Posts: 946
Re: Help i'm new
« Reply #10 on: May 12, 2013, 10:37:00 PM »
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

  • Member
  • *****
  • Posts: 3517
  • Forgive your enemies, but never forget their names
Re: Help i'm new
« Reply #11 on: May 12, 2013, 10:44:37 PM »
Hi Steve,

very good example for teaching purposes. :t

Gunther
Get your facts first, and then you can distort them.

FORTRANS

  • Member
  • ****
  • Posts: 946
Re: Help i'm new
« Reply #12 on: May 12, 2013, 11:03:07 PM »
Hi Gunther,

   Thank you.  Nice to get some feedback.

Regards,

Steve N.

gbmach7

  • Guest
Re: Help i'm new
« Reply #13 on: May 13, 2013, 12:56:20 AM »
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

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: Help i'm new
« Reply #14 on: May 13, 2013, 01:24:22 AM »
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