Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Drawing in VGA using Visual C++ 5.0

Posted on 1998-09-14
3
Medium Priority
?
355 Views
Last Modified: 2013-12-03
Hello,

I'm writing a small library that is supposed to write to a VGA graphic card. I need to test this library with visualC++.

I know how to program VGA mode 18 using registers.
But I don't know how to switch the screen into VGA mode.
I have a borland sample program that is doing it the following way:

#define int10 0x10

union REGS regs;
regs.h.ah = 0;
regs.h.al = (char)18;
int86( int10,&regs,&regs);

Great but I can't find REGS and int86 in Visual C++.

I know the screen is at 0xA0000000;
And color register is set by
outportb( 0x3C4, 2 );
outportb( 0x3C5, color ); /* one of 0..15 (15 = black) */

Bit mask is set by
outportb( 0x3CE, 8 );
outportb( 0x3CF, mask );

Writing into screen memory requires reading the byte first because a latch reset required. (that's what I was told).
Then one can write bits into screen memory.

I would like to be able to try this from Visual C++ 5.0.

I know it is crazy to try drawing into VGA that way but apparently some crazy computer science teacher beleive it is  still extreamly important to know how to do so.

Any help would be welcome.

0
Comment
Question by:meessen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 1414438
visual C++ only produces 32 bit windows programs.  A 32 bit windows program cannot access the VGA card (or any other hardware).  If you want to do this from windows, you will have to write a device driver.  (Or use a compiler that produces either DOS or 16 bit windows programs--but I wouldn't recomend doing this from a 16 bit windows program anyways.)
0
 
LVL 22

Expert Comment

by:nietod
ID: 1414439
Those functions are all fancy C++ interfaces for x86 assembly language instructions.  Given a C++ compiler that produces 16 bit code, you can use inline asssembly to perform the same steps, like

regs.h.ah = 0;
regs.h.al = (char)18;
int86( int10,&regs,&regs);

becomes

__asm
{
   MOV AH,0
   MOV AL,18
   INT 10
}

and

outportb( 0x3C4, 2 );
outportb( 0x3C5, color ); /* one of 0..15 (15 = black) */

becomes

__asm
{
   MOV DX,3C4H
   MOV AL,2
   OUT DX,AL
   MOV DX,3C5H
   MOV AL,color
   OUT DX,AL
}
0
 
LVL 22

Expert Comment

by:nietod
ID: 1414440
Note, you can use the above assembly in VC 5, right now (it will compile).  But when your program tries to perform those commands (INT 10 or OUT) windows will detect it and terminate the program with an access violation.
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question