From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: VBE 2.0 Pmode Bank Switching... Date: Sun, 9 Feb 1997 21:10:04 +0000 Organization: None Distribution: world Message-ID: References: NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 38 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp KaRNaGE writes: >ok...i'm trying to get VBE 2.0 Bank Switching to work, but for some reason >it's not switching banks...i got the code from a FAQ..here is how i'm >using it... [snip] > pm_bank = (void *)((char *)pm_info + pm_info->setWindow); [snip] >pm_bank(0); Oy! You can't do that! :-) This function doesn't use the normal C calling convention, so you need to call it in a special way. You should put the window number (usually 0, but it depends on the card) in %bx, the bank number in %dx, and then call it. This means you have to do it from asm... Also, some cards use memory-mapped IO, in which case you have to create a pmode selector for accessing the required addresses, and put it in %es before calling the switch routine. You can determine if this is the case by looking at the IOPrivInfo field in the PM_INFO structure. > regs.x.ax = 0x4F05; > regs.x.bx = 0; > regs.x.dx = bank << 4; /* bank * 16 */ > __dpmi_int(0x10, ®s); That won't work on most cards (and is probably why your stuff doesn't work with UniVBE loaded). The Cirrus uses 16k banks, hence the multiply by 16, but these days 99% of cards have 64k banks. And there are even worse things out there just waiting to trip you up, like 16k banks and 128k memory apertures from 0xA0000 to 0xC0000. For a reliable program, you need to examine the VESA window information structures to get all these params right... /* * Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ * Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'. */