TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: Glen Conboy
date: 1996-01-14 13:14:00
subject: WRITING A PIXEL IN VGA 6

FA>@REPLY: 3:635/544.0 30f2e346
FA>@MSGID: 3:635/544.0 30f512f4 G'Day Owen,

-=> Quoting Owen Kaluza to All <=-

 OK> Can anyone tell me how to write a pixel directly to the video memo
 OK> in VGA 640x480x16 mode, i know how to do it in 320x200x256 but
 OK> my attempts to adapt it to work in 640x480x16 have failed, below i
 OK> the function I have been using in 320x200x256 mode:

 OK> char far *screen=MK_FP(0xA000,0);
 OK> 
 OK> void SetPoint(int x, int y, int c)
 OK> {
 OK> *(screen + (y * 320) + x) = c;
 OK> }

I always wondered how to do this too!  I bought some good books (the 
solution is unfortunately not simple).  I would recommend you take a 
look at 'More Tricks of the Game Programming Gurus', SAMS Publishing, ISBN 
0-672-30697-2.  Or if your interested in games programming under Windows, 
have a read of 'Black Art of Windows Game Programming', The Waite Group, 
ISBN 1-878739-96-6.  This book is written for the programmer who has never 
written Windows programs before, and talks about WinG.  WinG is a library 
released (free) by Microsoft specifically for performing high speed 
graphics under Windows.

Anyway the solution to the problem has many facets.  Firstly unlike 
320x200x256, 640x480x16 isn't a 'standard' video (hence all those different 
video drivers in order to get Windows to run in high res).  So for your 
particular video card you need to work out how to set into 640x480x16.  It 
sounds like you know how to do this though.  Incidently the VESA standard 
was designed to provide standard high res modes.  (That's why most of the 
latest games which can run in high res require that you have a VESA driver 
or VESA compliant video card).  

The solution to your problem is in 'More Tricks...'.  It is written for a 
VESA video card or driver and takes five pages of code.  Basically the 
video memory is divided into pages.  You write to one page, set the next 
page, write, etc...  But if you decide to use WinG instead I think all 
this low level code is handled for you (and supposidly well optimised too).

FA>Dunno, but i still have fresh memories of stuffing, up by not casting t
FA>long. Looking at the above, shouldn't x,y and c be longs ?

No (assuming 16+ bit ints).  X will never be larger than 640, Y larger than 
480, or C larger than 16.

I'm personaly opting for the WinG solution as IMHO Dos will be pretty much 
a thing of the past soon.  Plus you can get lots of drivers etc., like 
WinG, to handle the low level stuff and get on will creating the 
Game/Application/Whatever.  Also WinG comes shipped with Win95 (I think).

Hope this long winded answer sortof helps.
Glen C.

FA>  L8r Frank (fadam{at}ozemail.com.au)

FA>___ Blue Wave/DOS v2.21

FA>--- Maximus 3.00


---
 * WR 1.31 [NR] * UNREGISTERED EVALUATION COPY


--- TMail v1.31.5


FA> * Origin: The Software Parlour (3:635/544)
* Origin: adam.com.au 64 lines all 300 to 28k (08) 370 5775 (3:800/805)
SEEN-BY: 50/99 620/243 623/630 711/401 409 410 413 430 510 808 809 932 934
SEEN-BY: 712/515 713/888 714/906 800/1 2 430 432 805 806 809 810 812 814 822
SEEN-BY: 800/831 841 843 846 7877/2809
@PATH: 800/805 1 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.