ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/30/08:27:51

Date: Sat, 30 Nov 1996 21:08:46 +0800 (GMT)
From: Orlando Andico <orly AT gibson DOT eee DOT upd DOT edu DOT ph>
To: Dean <deanh AT zip DOT com DOT au>
cc: djgpp AT delorie DOT com
Subject: Re: Setting VESA palette in DJGPP
In-Reply-To: <57p1np$dtq@the-fly.zip.com.au>
Message-ID: <Pine.SGI.3.93.961130204942.15527A-100000@gibson.eee.upd.edu.ph>
MIME-Version: 1.0

On 30 Nov 1996, Dean wrote:

> How do you set the palette in VESA mode under DJGPP?
> 
> I read the VESA function to do it is 09h, but since VESA is real mode, you 
> need to pass a pointer you your palette in the ES:DI resgisteer pair, so, how 
> do you do?

the correct answer (as Eli would quickly point out!) is READ THE FAQ!!
there's a nice and very informative section on precisely this sort of
thing there..

here's a quickie version if you feel disinclined to wade through the
monstrous FAQ _or are lazy_ (as am I... ;)


--- BEGIN CODE SEGMENT ---

	#include <dpmi.h>

	_go32_dpmi_seginfo seginfo;
	_go32_dpmi_registers reg;
	char your_data[NUMBER_OF_BYTES];

	/* zero out the registers.. */
	memset (&reg, 0, sizeof (_go32_dpmi_registers));

	/* now get a small bit of DOS memory (below 1MB) */
	seginfo.size = (NUMBER_OF_BYTES + 15) / 16;
	if (_go32_dpmi_allocate_dos_memory (&seginfo)) abort ();

	/* copy your_data into the DOS memory area */
	dosmemput (your_data, NUMBER_OF_BYTES,
		seginfo.rm_segment * 16);

	/* now you said your palette is pointed to by ES:DI? so... */
	reg.x.es = seginfo.rm_segment;
	reg.x.di = 0;

	/* set up the rest of your registers, eg if AX=0x09.. */
	reg.x.ax = 0x09;
	
	/* make the interrupt call.. */
	_go32_dpmi_simulate_int (INTERRUPT_VECTOR, &reg);

	/* free the DOS memory you just used */
	if (_go32_dpmi_free_dos_memory (&seginfo)) abort ();

--- END CODE SEGMENT ---

tada!
this code should work (just replace the constants with whatever you're
using) because i used it for my undergrad thesis..

but: you'd BETTER read the FAQ, it's quite illuminating.. although the
above code does seem a little bit self-evident right? the hairy stuff is
writing your own interrupt handler :)  which i (wisely) leave to the real
experts...



.-----------------------------------------------------------------.
| Orlando Andico                email: orly AT gibson DOT eee DOT upd DOT edu DOT ph |
| IRC Lab/EE Dept/UP Diliman   http://gibson.eee.upd.edu.ph/~orly |
|  "through adventure we are not adventuresome" -- 10000 Maniacs  |
`-----------------------------------------------------------------'


- Raw text -


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