TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: Tristan Ball
date: 1996-01-16 23:08:00
subject: Writing a pixel in VGA 6

> G'Day Owen,

 > -=> Quoting Owen Kaluza to All <=-

 >  OK> Can anyone tell me how to write a pixel directly to the video memory
 >  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 is
 >  OK> the function I have been using in 320x200x256 mode:

Writing pixels in mode 12h is extreemly complex, as well as highly
obsolete. If I was you, I'd either use the compiler library if you have to
use mode 12h, (yer, I know it's slow), or to use VESA and go into
640x480x256.
Just about all cards support VESA these days, and those that don't usually
have drivers, or you can use univesa, which is a PD/SW? tsr.


 >  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> }

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

They should be unsigned ints for asthetic reasons. However, it doesn't
actually make any difference. Hang onto yer hat while I explain.

In my understanding, in an expression, all values are promoted to the
highest type in that expression. In the above line, screen is a far ptr,
for the compiler to do proper arithmatic, the other two values are also
promoted to far pointers. (Actually, near pointers, as only the offset part
is incremented).

The highest offset in an mode13h screen is 64000, an this is easily
encompased by an int expression anyway.

Later,
    Tristan

--- FMail/386 0.98a

* Origin: No nuclear bombs were tested in the writing of this message! (3:800/894.5)
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 868 876 877 890 894 850/116 7877/2809
@PATH: 800/894 2 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™.