          ͻ
           How to acces video segment 0xA000,0xB000,0xB800  
           with Borland C++ 4.0, patched for DOS 32bit/DPMI 
          ͼ

Hello,                          


BC4++ is here !!!
But there's no i386 - 32 bit compiler for MS-DOS.                   :-(

Fortunately, i've found a tips from  Kenneth L. Hurley              :-)
(on the Borland Forum/CIS) to allow BC4++, to produce an i386 code
with 32bit Dos Protected Mode Interface (=>> DPMI)...

Video RAM (0xA000,0xB000,0xB800)

So, if you need to acces Video RAM segment, you must allocate some
selectors using DPMI functions.


HOW TO DO IT ???


1. First, i suggest to you, to copying all the following BC4 files 
   on the Hard Disk... (if you have BC4++ on CD-ROM)

   32RTM    EXE       
   TLIB     EXE       
   STUB32   EXE       
   DPMI32VM OVL       
   CW32     LIB       
   TLINK32  EXE       
   BCC32    EXE       

   TASM32   EXE   (If you have Tasm 4.0,... 
                   if not, rename TASM.EXE into TASM32.EXE, it's work fine)


2. Reading the 32BIT.TXT file. 

3. Rereading the 32BIT.TXT file !

4. Execute the instruction of 32BIT.TXT file.
   
   ERRORMSG.C     (Already modified)

5. You will find "my own" files : 
                  
   
   TESTMCGA.C     Just a nice sample of DPMI & VID_MCGA
   VID_MCGA.C     Several functions for drawing in 320x200 pxl, 256 colours
   DPMI.C         DPMI settings => selectors
   


In french we say: "Un petit exemple vaux mieux qu'un long discours"
                 ="A short exemple is better than a long speech" 
                 (yes,i speak better french!)                      :-!



/*TESTMCGA.C*/
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include "dpmi32.c"             / DPMI functions
#include "vid_mcga.c"           / Video functions

void main(void)                 / Main procedure
{
 int q,w,e;
 
 INITreal();                    / INIT DPMI selectors SEGA000,SEGB800,SEGB000
 initvideo();                   / INIT video mode 0x13

for (q=1;q<=255;q++) setrgb(q,q >>2, 10,10);
                                / SETRGB (colour number 0->255, Red,Green,Blue)
clear(0x30303030);              / Fast Clear Screen Routine 32bits (clear with colour 0x30)
box(0,0,319,199,255);           / Draw a simple BOX (x1,y1,x2,y2, colour)
fbox(10,10,309,189,0);          / Draw a filled BOX (x1,y1,x2,y2, colour)
for (e=0;e<159;e++) 
                {
                line(20,e+20,300,e+20,e);
                                / Draw a simple LINE (x1,y1,x2,y2, colour)
                line(20+e,20,20+e,160,e);
                }
for (e=0;e<98;e++)  circle(160,100,e,e);
                                / Draw a circle (center x,center y,radius, colour)

 DONEreal();                    / Release DPMI selectors (don't forget!!!)
 setvideo(3);                   / Return to video text mode 0x3
}




SUMMARY :


DPMI.C

INITreal                 Init the SEGA000,SEGB000,SEGB800 selectors
DONEreal                 Release the selectors.


VID_MCGA.C

putpixel(x,y,colour)     Put a pixel (warning : no clipping!!!)
line(x1,y1,x2,y2,colour) Line from x1,y1 to x2,y2 with colour
box(x1,y1,x2,y2,colour)
fbox(x1,y1,x2,y2,fill colour)
circle(center x,center y,radius,colour)
clear(32 bit colour)     to clear the screen with the colour 0xfa, clear(0xfafafafa)
setvideo(bios mode)      Set a BIOS mode using BIOS call AX=00 AL=mode
setrgb(col,red,grn,blu)  Set a colour palette...



HOW TO COMPILE


DOS32   TESTMCGA        ; No extention (no .c,.cpp) Compile -> i386 code
DOS32_4 TESTMCGA        ; No extention (no .c,.cpp) Compile -> i486 code




BYE BYE BYE BYE BYE BYE BYE BYE BYE BYE BYE BYE BYE BYE BYE BYE BYE BYE


I hope you find this information useful...

If you have some question or something else, write me at :

  Mail :                        Compuserve CIS
  ======                        ==============
  Cedric Rime                   Cedric Rime
  Rte de Palezieux              100340,2736
  1615 Bossonnens
  Switzeland




