delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/28/10:12:21

From: yorka AT dlc DOT fi (aYk)
Newsgroups: comp.os.msdos.djgpp
Subject: Problems with vbe2 linear framebuffer deinitialization
Date: Sat, 27 Jun 1998 11:43:13 GMT
Organization: Majik
Lines: 78
Message-ID: <3594d67a.231650@news.dlc.fi>
NNTP-Posting-Host: cccxcv.kdyn.saunalahti.fi
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I am having trouble with the code below. It is almost entirely ripped
from the DJGPP User's Guide vesa-programming sections (thanks Shawn
:)) with slight modifications. Read the comments for more info.

#include <ylib.h>	// this is my own lib's include file
#include <conio.h>
#include <go32.h>
#include <dpmi.h>
#include <sys/farptr.h>

__dpmi_meminfo mapping;
int selector;

/* This function initializes a linear framebuffer for the current vesa
mode by setting a selector to the globally defined variable */
void InitLFB()
{
 VBEModeInfo mode_info;
 VBEInfo vesa_info;

 GetVBEModeInfo(QueryCurrentMode(),&mode_info);
 GetVBEInfo(&vesa_info);

 /* map into linear memory */
 mapping.address = mode_info.PhysBasePtr;
 mapping.size = vesa_info.TotalMemory << 16;
 if (__dpmi_physical_address_mapping(&mapping) != 0) return;

 /* allocate an LDT descriptor to access the linear region */
 selector = __dpmi_allocate_ldt_descriptors(1);
 if (selector < 0) 
 {
  __dpmi_free_physical_address_mapping(&mapping);
  return;
 }

 /* set the descriptor location and size */
 __dpmi_set_segment_base_address(selector, mapping.address);
 __dpmi_set_segment_limit(selector, mapping.size-1);
}

/* This function should free the dpmi meminfo struct and the ldt
descriptor. It works just fine in plain DOS but crashes under Windows
95 DOS box (the __dpmi_free_physical_address_mapping causes the
crash). Why is that? */
void DeinitLFB()
{
 __dpmi_free_physical_address_mapping(&mapping); 
 __dpmi_free_ldt_descriptor(selector);
}


/* Here's just the main function which shows how I make the function
calls. Everything works except for the DeinitLFB() -function under
Windows 95. */
int main()
{
 SetVBEMode(320,200,15);
 InitLFB();
 getch();
 _farpokew(selector,0,0xFFFF); // this is here just to test the LFB
 getch();
 DeinitLFB(); 
 GraphicsMode(0x03);
 return 1;
}

Thanks in advance for all help.

- aYk -

| Atte "Yorkaturr" Koivula 	- aYk -	 |
| -------------------------------------- |
| God of Evil | yorka AT dlc DOT fi             |
| Programmer  |	yorka AT newbies DOT net        |
| Graphician  |	yorkaturr AT majik DOT netti DOT fi |
| -------------------------------------- |
| Majik MURPE  -  http://majik.netti.fi  |

- Raw text -


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