Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Blinker 5.10 Online Reference - <b> dosgetmachinemode()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 DosGetMachineMode()
------------------------------------------------------------------------------
 Purpose:
 Get the current machine mode (real, 286 protected).

 Syntax:
 USHORT BLXAPI DosGetMachineMode(BYTE __far *mmode);

 Parameters:
 mmode  Pointer to a byte to receive the machine mode.

 Returns:
 Machine mode indicator byte.

 Description:
 DosGetMachineMode() returns the current machine mode (either real or
 protected). Since Blinker has the capability of creating dual mode programs
 that may run in protected or real mode depending on the host environment,
 DosGetMachineMode() may be used to determine the current mode and take
 appropriate action.

 Example:
 #include <stdlib.h>                                                         
 #include <stdio.h>                                                          
 #include <string.h>                                                         
 #include <blx286.h>                                                         
                                                                             
 unsigned char far *VideoBuffer;                                             
                                                                             
 void main(void)                                                             
 {                                                                           
 BYTE     machinemode;                                                       
 SEL         selector;                                                       
                                                                             
 if (DosGetMachineMode(&machinemode) == 0)                                   
    switch (machinemode)                                                     
       {                                                                     
       case MODE_REAL:                                                       
          printf ("\nReal mode - absolute pointers ok\n");                   
          VideoBuffer = MK_FP(0xb800,0);                                     
          break;                                                             
       case MODE_PROTECTED:                                                  
          printf ("\n286 Protected mode - plenty memory\n");                 
          if (DosMapRealSeg (0xb800, 0x8000l, &selector))                    
             {                                                               
             printf ("\nTrouble\n");                                         
             exit (1);                                                       
             }                                                               
          VideoBuffer = MK_FP(selector,0);                                   
          break;                                                             
       default:                                                              
          printf ("\nOther mode - interesting\n");                           
          exit(1);                                                           
       }                                                                     
 }                                                                           
                                                                             
 Then:                                                                       
                                                                             
 /* Display a '*' in top left corner of screen*/                             
 *VideoBuffer[0] = '*';                                                      

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson