Thread overview
Linear Video Memory
Nov 11, 2001
Imran Haider
Nov 11, 2001
NancyEtRoland
Re: Linear Video Memory: 2 answer
Nov 14, 2001
Roland
November 11, 2001
Does all system support the 0C00:0000 location for linear video memory?  In my PC,  I could use 000A:0000 location to output VGA colors, I could also use 0c00:0000 to output colors. the 0c00:0000 works faster so I just wanted to know weather it is compatible with all PCs. If you more about this please tell me. Thanks. Bye.


November 11, 2001
Imran Haider a écrit :

> Does all system support the 0C00:0000 location for linear video memory?  In my PC,  I could use 000A:0000 location to output VGA colors, I could also use 0c00:0000 to output colors. the 0c00:0000 works faster so I just wanted to know weather it is compatible with all PCs. If you more about this please tell me. Thanks. Bye.

vbe cf int 10h fc 4f01h gives you a structure like this:

//---------------------------------------------------- //VesaModInfo

//flag tq:
//  b0: 1 -> mode supporté par hard
//  b1: 1 -> info optionnelles / reserved (VBE>=1.2)
#define _VesaModTTYOk  (1<<2) //1 -> fc text bios tty ok (int 10h fc
1,2,6,7,9,a,e)
#define _VesaModIsColor  (1<<3) //1 -> mode couleur
#define _VesaModIsGraphic (1<<4) //1 -> mode graphique
//  b5: 0 -> mode compatible vga
//  b6: 0 -> acces mode compatible vga
#define _VesaModIsFlatOk (1<<7) //vbe>=2.0: 1 -> flat frame buffer mode
valide
         //vbe <2.0: toujours a 0


 #ifdef __SC__
#pragma SC align 1
 #else
#pragma option -a-
 #endif

struct VesaModInfo {
//cf int 10h fc 4f01h
 int isttyok() {
  return (flags & _VesaModTTYOk)!=0;
 }
 int iscolor() {
  return (flags & _VesaModIsColor)!=0;
 }
 int isgraphic() {
  return (flags & _VesaModIsGraphic)!=0;
 }

 int isflatok();
 //return flat frame buffer valide
 //ù rem: 11/99, bug dans vbe de S3 Savage3D => return false si S3
Savage3D detecte
 //ù !! => vesa_init doit avoir ete execute (_vesainfo a jour)

  unsigned short flags;
  byte acces_flags1;
  byte acces_flags2;
  unsigned short acces_granul; //en ko
  unsigned short acces_size; //en ko
  unsigned short acces_seg1;
  unsigned short acces_seg2;
  dosptr acces_func; //dosptr sur fonction appellee par int 10h fc 4f05h

  unsigned short l_size;  //size ligne en byte
//optionel, en standard pour VBE 1.2 et plus:
  unsigned short scr_x;  //szx scr en pix/char
  unsigned short scr_y;  //szy scr en pix/char
  byte chr_x;
  byte chr_y;
  byte pln;               //nb pln
  byte bpx;               //bit/pix
  byte nbbank;              //nb bank ?
  byte model;             //model memoire
  byte banksize;         //size bank en ko
  byte nbimage;             //nb image
  byte _reserved1;
//direct color:
  byte directcolorzone[9];
//a partir de VBE 2.0
  dword physbaseptr;      //addresse physique de flat frame buffer
  dword offscreenofs;     //debut memoire off screen
  unsigned short offscreenmemsize;    //size off screen mem en ko
  byte _reserved2[206];
};
 #ifdef __SC__
#pragma SC align
 #else
#pragma option -a.
 #endif


//acces_flags tq:
#define _Acces_  (1<<0) //1 -> fen dispo
#define _rAcces_ (1<<1) //1 -> lecture ok
#define _wAcces_ (1<<2) //1 -> ecriture ok

//model tq:
#define _ModelText_ 0 //-> text
#define _ModelCga_ 1 //-> format graphic cga
#define _ModelHerc_ 2 //-> format graphic hercules
#define _ModelEga16_ 3 //-> format ega/vga 16 couleur (plan)
#define _ModelNibble_ 4 //-> format compact, 2 nibble/byte
#define _ModelEga256_ 5 //-> format ega/vga 256 couleur, 1 byte/pixel
#define _ModelDirectColor 6
#define _ModelYUV       7

//----------------------------------------------------

if supported, flat frame buffer addresse is here: VesaModInfo::physbaseptr

to access this buffer do like this (considering you work on DOSX model):

byte* __accesptr;
__accesptr =
_x386_map_physical_address((void*)modinfo.physbaseptr,4000000ul);

now you can read or write in the buffer.

Ciao

Roland




November 14, 2001
NancyEtRoland a écrit :

>
> Imran Haider a écrit :
>
> > Does all system support the 0C00:0000 location for linear video memory?  In my PC,  I could use 000A:0000 location to output VGA colors, I could also use 0c00:0000 to output colors. the 0c00:0000 works faster so I just wanted to know weather it is compatible with all PCs. If you more about this please tell me. Thanks. Bye.
>
> vbe cf int 10h fc 4f01h gives you a structure like this...
>

after this reply i was expecting 2 questions:
1- how can i call a real mode interrupt not implemented by DOSX ? (easy),
2- how can i pass a buffer to a real mode interrupt ? (more complicate)

Even if those questions were not asked, i reply, may be they are good candidate for the FAQ.

1- how can i call a real mode interrupt not implemented by DOSX ?

call int86_real or int86x_real

or define something like this if you want your code to compile on DOSX and large model as well:

        #if (sizeof(int)==4)
#define _CALL_INT(intnum,regsin,regsout) int86_real(intnum,&(regsin),&(regsout))
#define _CALL_INTS(intnum,regsin,regsout,segregs) int86x_real(intnum,&(regsin),&(regsout),&(segregs))
         #else
#define _CALL_INT(intnum,regsin,regsout) int86(intnum,&regsin,&regsout)
#define _CALL_INTS(intnum,regsin,regsout,segregs) int86x(intnum,&(regsin),&(regsout),&(segregs))
         #endif        //sizeof(int)==4

2- how can i pass a buffer to a real mode interrupt ?

the real mode interrupt expects a real mode pointer (segment:offset) below 1 Mbyte limite.
you have to allocate a buffer in real mode memory and pass its real mode addresse to the interrupt.
do like this:

unsigned short _x386_convmemalloc(unsigned size);
//allocate a  conventional memory block
//return the conventional memory segment, 0 if error
//!!! allocate 4 k byte minimum !!!
//!!! there is no way to deallocate this memory !!!

unsigned short _x386_convmemalloc(const unsigned size) {
    REGS regs;
     regs.x.bx = (unsigned short)((size+15)>>4);
     regs.h.ah = 0x48;
     int86(0x21,&regs,&regs);
    return (regs.x.flags&_cf_) ?
          0                //DOS error no is in ax
    :    regs.x.ax;
}

example:

        #if (sizeof(int)==4)

unsigned convmemseg,dosptr;    //real mode segment, pointer
void* dosxptr;                            //dosx pointer
#define DGROUP MKFP(getDS(),0)

convmemseg = (unsigned)_x386_convmemalloc(size);
dosptr = convmemseg<<16;        //offset = 0
dosxptr =  (void*)(-_x386_get_abs_address(DGROUP)+(convmemseg<<4));

         #endif        //sizeof(int)==4

(hope no syntax error)

Ciao

Roland