Пример #1
0
static void vm_getkey(unsigned char *chScan, unsigned char *chChar)
{
    union REGS regs;
    regs.h.ah = 0x00;
    _int86(0x16, &regs, &regs);
    *chScan = regs.h.ah;
    *chChar = regs.h.al;
}
Пример #2
0
int vm_kbhit(void)
{
    if (_osmode == DOS_MODE)
    {
        union REGS regs;
        static unsigned short counter = 0;
        if (counter % 10 == 0)
        {
            opsysTimeSlice();
        }
        counter++;
        regs.h.ah = 0x01;
        _int86(0x16, &regs, &regs);
        return !(regs.x.flags & 0x40);
    }
    else
    {
        KBDKEYINFO ki;
        ki.fbStatus = 0;
        KbdPeek(&ki, 0);
        return ki.fbStatus & KBDTRF_FINAL_CHAR_IN;
    }
}
Пример #3
0
Int64 GetFreeDisk(const char *FileName)
{
#ifdef _WIN_32
  char Root[NM];
  GetPathRoot(FileName,Root);

  typedef BOOL (WINAPI *GETDISKFREESPACEEX)(
    LPCTSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER
   );
  static GETDISKFREESPACEEX pGetDiskFreeSpaceEx=NULL;

  if (pGetDiskFreeSpaceEx==NULL)
  {
    HMODULE hKernel=GetModuleHandle("kernel32.dll");
    if (hKernel!=NULL)
      pGetDiskFreeSpaceEx=(GETDISKFREESPACEEX)GetProcAddress(hKernel,"GetDiskFreeSpaceExA");
  }
  if (pGetDiskFreeSpaceEx!=NULL)
  {
    GetFilePath(FileName,Root);
    ULARGE_INTEGER uiTotalSize,uiTotalFree,uiUserFree;
    uiUserFree.u.LowPart=uiUserFree.u.HighPart=0;
    if (pGetDiskFreeSpaceEx(*Root ? Root:NULL,&uiUserFree,&uiTotalSize,&uiTotalFree) &&
        uiUserFree.u.HighPart<=uiTotalFree.u.HighPart)
      return(int32to64(uiUserFree.u.HighPart,uiUserFree.u.LowPart));
  }

  DWORD SectorsPerCluster,BytesPerSector,FreeClusters,TotalClusters;
  if (!GetDiskFreeSpace(*Root ? Root:NULL,&SectorsPerCluster,&BytesPerSector,&FreeClusters,&TotalClusters))
    return(1457664);
  Int64 FreeSize=SectorsPerCluster*BytesPerSector;
  FreeSize=FreeSize*FreeClusters;
  return(FreeSize);
#elif defined(_BEOS)
  char Root[NM];
  GetFilePath(FileName,Root);
  dev_t Dev=dev_for_path(*Root ? Root:".");
  if (Dev<0)
    return(1457664);
  fs_info Info;
  if (fs_stat_dev(Dev,&Info)!=0)
    return(1457664);
  Int64 FreeSize=Info.block_size;
  FreeSize=FreeSize*Info.free_blocks;
  return(FreeSize);
#elif defined(_UNIX)
  return(1457664);
#elif defined(_EMX)
  int Drive=(!isalpha(FileName[0]) || FileName[1]!=':') ? 0:toupper(FileName[0])-'A'+1;
  if (_osmode == OS2_MODE)
  {
    FSALLOCATE fsa;
    if (DosQueryFSInfo(Drive,1,&fsa,sizeof(fsa))!=0)
      return(1457664);
    Int64 FreeSize=fsa.cSectorUnit*fsa.cbSector;
    FreeSize=FreeSize*fsa.cUnitAvail;
    return(FreeSize);
  }
  else
  {
    union REGS regs,outregs;
    memset(&regs,0,sizeof(regs));
    regs.h.ah=0x36;
    regs.h.dl=Drive;
    _int86 (0x21,&regs,&outregs);
    if (outregs.x.ax==0xffff)
      return(1457664);
    Int64 FreeSize=outregs.x.ax*outregs.x.cx;
    FreeSize=FreeSize*outregs.x.bx;
    return(FreeSize);
  }
#else
  #define DISABLEAUTODETECT
  return(1457664);
#endif
}
Пример #4
0
int pcvid_putc(KS_CONSTANT char c)
{
PFBYTE p;

    pcvid_init_term(0);
    if(linewrap_flag && c!='\r' && c!='\n')
    {
        cursor_x=1;
        if(cursor_y<24)
        {
            cursor_y++;
        }
        else
        {
            pcvid_scroll_up();
        }
    }

    linewrap_flag=FALSE;

    if(c!='\t'&&c!='\b'&&c!='\n'&&c!='\r')
    {
        p = pvideo + (cursor_y*(PCVID_SCREEN_COLS*2)) + (cursor_x*2);
        *p++ = c;
        *p = 0x07;  /* white on black */
        cursor_x++;
    }
    else if(c=='\b')
    {
        if(cursor_x>0)
        {
            cursor_x--;
            p = pvideo + (cursor_y*(PCVID_SCREEN_COLS*2)) + (cursor_x*2);
            *p++ = ' ';
            *p = 0x07;  /* white on black */
        }
    } 
    else if(c=='\t')
    {
        cursor_x--;
        cursor_x+=8;
        cursor_x/=8;
        cursor_x*=8;
        cursor_x++;
    } 
    else if(c=='\r')
    {
        cursor_x=1;
    } 
    else if(c=='\n')
    {
        if(cursor_y<24)
        {
            cursor_y++;
        }
        else
        {
            pcvid_scroll_up();
        }
    }
    
    if(cursor_x>79)
    {
        cursor_x=0;
        linewrap_flag=TRUE;
    }

#if (!defined (DJGPP) )
    {
        union _REGS regs;
    
        /* put cursor at appropriate position   */
        regs.h.ah=2;
        regs.h.dl=(byte)cursor_x;
        regs.h.dh=(byte)cursor_y;
        regs.h.bh=0;
        _int86(0x10,&regs,&regs);
    }
#elif (AT_MOTHERBOARD && (IS_MS_PM || IS_BCC_PM || IS_WC_PM || IS_HC_PM))
    /*
     * [i_a] added code to update cursor position for any VGA/EGA/CGA or HGC
     * card IFF we can access the video hardware registers using I/O 
     * instructions. Maybe the condition above is a bit too restrictive, but
     * it works for them :-)
     */
    {
        unsigned int pos = cursor_y * PCVID_SCREEN_COLS + cursor_x;
                     
        if (pcvid_mode == 0)
        {             
            /*
                3d4h index  Eh (R/W):  CRTC: Cursor Location High Register
                bit 0-7  Upper 8 bits of the address of the cursor
                
                3d4h index  Fh (R/W):  CRTC: Cursor Location Low Register
                bit 0-7  Lower 8 bits of the address of the cursor
             */   
            OUTBYTE(0x3D4,0x0E);        
            OUTBYTE(0x3D5,pos >> 8);      
            OUTBYTE(0x3D4,0x0F);        
            OUTBYTE(0x3D5,pos);      
        }
        else 
        {