www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/04/23:57:18

Message-Id: <199809050354.XAA27244@delorie.com>
Comments: Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk>
From: "George Foot" <george DOT foot AT merton DOT oxford DOT ac DOT uk>
To: tomstdenis AT my-dejanews DOT com
Date: Sat, 5 Sep 1998 04:52:07 +0000
MIME-Version: 1.0
Subject: Re: 2 questions
Reply-to: mert0407 AT sable DOT ox DOT ac DOT uk
CC: djgpp AT delorie DOT com

On  4 Sep 98 at 21:59, tomstdenis AT my-dejanews DOT com wrote:

> > 1. how do you set the screen to 640x480x16(along with how to set a pixel
> > color)?
> 
> Well you would use the __dpmi_init() function to set up mode 12h.  Like this
> 
> #include <dpmi.h>
> 
> test()
> {
>    __dpmi_regs r;
> 
>    r.d.eax = 0x12;
>    __dpmi_init(0x10, &r);
> }

You meant `__dpmi_int'.

To set a pixel you can choose between three ways; two using direct
memory writes and one using the video BIOS (which will be slow in
djgpp).

For direct writes, first calculate the address of the byte to write 
to, and the bit mask for the pixel you want to write:

    addr = 0xa0000 + y*80 + (x >> 3)
    mask = (1 << ((~x) & 7)

(those may not be quite right, consult a book on EGA/VGA graphics)

Then choose:

1) Using write mode 0: Set the set/reset register with the colour
number, and set the enable set/reset register to 0xF.  Then write a
byte to selector `_dos_ds', offset `addr', the byte being `mask'.

2) Using write mode 2: Set bit mask register to `mask' and write the
colour number you want to use to selector `_dos_ds', offset `addr'.

IIRC in both cases you should latch first, i.e. read from the address 
(and discard the value) before writing back to it.

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019