?
Solved

2 page SVGA256.bgi?

Posted on 2003-03-11
5
Medium Priority
?
634 Views
Last Modified: 2007-12-19
I'm trying to develop a program that runs in 640x480x256, and managed to find a SVGA256.bgi driver by Jonathan Hargreaves (?)

Anyways, one flaw I found with the driver was that while it CAN do two pages, the 2nd page, when displayed, starts at about location 385,400, and wraps around the right side, and the top and bottom. For example, one test I have has a blue pac-man opening and closing his mouth. When using two pages the result looks sort of like this:
 ______
|......|
|..C...|
|......|
|____O_|

Where C is when the mouth is open (on page 1) and O is a closed mouth (page 2).

If anyone could offer any help on how to make the 2nd page work properly, or offer a better driver, any help would be appreciated.
0
Comment
Question by:Cypher19
[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
  • 2
  • 2
5 Comments
 

Author Comment

by:Cypher19
ID: 8117304
Geez, that didn't turn out well...

let's try that again.

 ______
|_____|
|__C__|
|_____|
|___O_|
0
 
LVL 5

Expert Comment

by:Kocil
ID: 8117872
Yeah, I asked about using monospace in EE and the admin answered, it is on top isues but don't hold your breath waiting for it :)
0
 
LVL 12

Expert Comment

by:Salte
ID: 8117881
I don't think there's many using SVGA driver any more and if the driver has bug I think you have problems finding anyone who can fix it or anyone who even have the sourcecode for it anymore. I may be wrong in this but that's my guess.

Chances are that you just have to live with any bugs that there may be.

In any case, what system or platform are you talking about here. I would guess PC but you mention an address 385400 which doesn't ring any bells with me.

Graphics memory is starting from address 0xa0000 on a PC and that would be address 655360 in decimal, very much higher than 385400 (and I don't think anyone in their right mind would use decimal numbers to refer to memory addresses anyway) so that leaves the alternative that 385400 is a hex address in which case it is way beyond where any PC using SVGA store their graphics data.

So chances are you are not running on a PC and in that case it really would help if you could tell which system you are on. If you are on a PC I would prefer you somehow reoriented your memory addresses so that they get in the range 0xa0000.. 0xb0000 which is what is available to graphics data. How you get the value 385400 from is beyond me if it is decimal it corresopnd to 0x5e178 and I still get no bells ringing.

Secondly, if you're running on a PC running old MS-DOS 6.22 or earlier then you probably should continue trying to dig up a graphics driver for SVGA but if you're on more modern machines you probably should take a look into DirectX. It might be what you need.

Alf
0
 

Author Comment

by:Cypher19
ID: 8120617
No, the memory address itself isn't at 385400, but it's just that when the 1st page is displayed while there is content on the 2nd, the second page is visible, and its origin is at (as deduced from experimentation) the coordinate (384, 412).

Btw, I'm using Borland's C++ 4.52, and if possible would prefer using a bgi graphics driver, since it's for a school project which requires the use of graphics.h, so DirectX (even if I DID have the SDK) is out of the question.
0
 
LVL 12

Accepted Solution

by:
Salte earned 100 total points
ID: 8122468
Ok, in this case it is simple enough - Not sure about the .bgi driver but the hardware is simple enough:


640 x 480 x 256 means you use one byte per pixel and you have 480 x 640 = 307200 = bytes. These bytes start from address 0xa000:0000 since this would be up to address
0xcb00:0000 there's no room for this graphics data in the regular memory. Thus the video graphics will only show you a fraction of that memory at a time. You control which part of the image by sending codes to the graphics' card's control registers.

The .bgi driver simplifies this by doing all that juggling with the control registers for you. However, it is important that you only operate on the part that the .bgi driver maps into your ram at any one time. You control this by a 'window' or viewport if I remember correctly which is a rectangular area of the screen which you can operate on at the moment.

If there's a second page it means that the video ram must be at least twice the area I indicated above since the first page would occupy the first bytes.

Also, using 256 colors means you need a palette. I believe that is also stored in the video memory at some place, either directly after the first page or some such.

So if there's a second page it will probably be located after page 1 (in which case the palette will come after page 2) or it will be located after the palette.

Do you run a 24 bit palette? so that each entry is 24 bits or 3 bytes? if so the palette is 256 * 3 bytes = 768 bytes. This is very small compared to the graphics data.

I am not sure if the palette is per page or if each page has its own palette, this will also determine where the palette might be located.

In any case, for you to draw any graphics on the screen you must have mapped into your ram the video memory that form a rectangle that you can draw on.

Since your video memory (as seen from the PC) is maximum 65536 bytes (from A000:000 to A000:FFFF) you cannot make the view part larger than 65536/640 = approx 100 lines or so (assuming the viewport cover the width of 640 pixels).

so 640x100 is your maximum viewport size, anything beyond that will cause troubles I believe.

This means that if you want to draw the screen you must do it in several stages:

juggle the control registers to change the viewport (I think borland does that for you if you use their function to change viewport) and take 100 lines at a time and draw your picture on the page 2 (the page that doesn't show).

Then when you have drawn the full picture you can set the control registers to flip from showing page 1 to page 2. Make sure you do that flip while the cannon moves from lower right corner to upper left so that you don't change the picture while the cannon is drawing a picture. Not sure if borland takes care of that for you as well.

Of course, I assume here that you access and draw on a picture that isn't shown (the monitor shows page 1 while you draw on page 2 and vice versa). I am not sure how you tell borland to do that but some way to control this must be achieved.

All in all, I think such old software may have problems to handle such big screen. Why are you working on such ancient technology?

Just to tell you about the new world, using DirectX you can  - in a hardware independent manner - map the whole video memory into your memory and get a pointer to the whole 307200 bytes chunk for each buffer - or you can switch to 640x480x(32 bit per pixel) or maybe 800x600x(32 bit per pixel) and work on the whole buffer as one huge array.

Alf
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 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