示例#1
1
int chs_biosdisk(int cmd, int drive, int head, int track,int sector, int nsects, void *buf)
{
	unsigned tries, err;
	struct SREGS sregs;
	union  REGS  regs;

	/* set up registers for INT 13h AH=02/03h */
	sregs.es  = FP_SEG(buf);
	regs.h.dh = head;
	regs.h.dl = drive;
	regs.h.ch = track;
	regs.h.cl = ((track >> 2) & 0xC0) | sector;
	regs.x.bx = FP_OFF(buf);

	/* make 3 attempts */
	for(tries = 1; tries != 0; tries--)
	{
		if(cmd == _DISK_RESET)
			regs.h.ah = 0x00;
		else if(cmd == _DISK_STATUS)
			regs.h.ah = 0x01;
		else if(cmd == _DISK_READ)
			regs.h.ah = 0x02;
		else if(cmd == _DISK_WRITE)
			regs.h.ah = 0x03;
		else if(cmd == _DISK_VERIFY)
			regs.h.ah = 0x04;
		else if(cmd == _DISK_FORMAT)
			regs.h.ah = 0x05;
		else
			return 1; /* invalid command */

		regs.h.al = nsects;
		int86x(0x13, &regs, &regs, &sregs);
		err = regs.h.ah;
		if(err == 0)
			return 0;

		/* reset disk */
		regs.h.ah = 0;
		int86x(0x13,&regs,&regs,&sregs);
	}

	hxc_printf(0,"chs_biosdisk: error 0x%02X\n", err);

	return err;
}
示例#2
0
int isWprot(int drive)
{
      union REGS regs;
      struct SREGS sregs;
      char buf[512], FAR *bufptr = (char FAR *)buf;   /* Needed by MSC  */

      /* First read sector 0  */

      segread(&sregs);
      regs.x.ax = 0x201;
      regs.x.cx = 1;
      regs.x.dx = drive & 0x7f;
      sregs.es  = FP_SEG(bufptr);
      regs.x.bx = FP_OFF(bufptr);
      int86x(0x13, &regs, &regs, &sregs);
      if (regs.x.cflag && regs.h.ah != 6)
      {
            regs.h.ah = 0x00;         /* reset diskette subsystem */
            regs.h.dl = drive & 0x7f;
            int86x(0x13, &regs, &regs, &sregs);
            return -1;
      }

      /* Try to write it back */

      segread(&sregs);
      regs.x.ax = 0x301;
      regs.x.cx = 1;
      regs.x.dx = drive & 0x7f;
      sregs.es  = FP_SEG(bufptr);
      regs.x.bx = FP_OFF(bufptr);
      int86x(0x13, &regs, &regs, &sregs);
      return (3 == regs.h.ah);
}
示例#3
0
/* Set a 256 entry pallette with the values given in "palbuf". */
static void
setmany(unsigned char palbuf[256][3], int start, int count)
{
    unsigned char _far *fp;
    union REGS regs;
    struct SREGS sregs;
    unsigned i;

#if defined( __GNUC__ )
    /* This should work for most compilers - only tested with GNU C++, so
       it isn't turned on for anything else */
    for (i=start;i<start+count;i++) {
	regs.x.ax = 0x1010;
	regs.x.bx = i;
	regs.h.ch = palbuf[i][1];
	regs.h.cl = palbuf[i][2];
	regs.h.dh = palbuf[i][0];
	int86x(0x10, &regs, &regs, &sregs);
	return;
    }
#elif defined( DOS386 )
    /* Put the contents of the new palette into real memory, the only
       place I know that won't impact things is the video RAM. */
    fp = MK_FP(_x386_zero_base_selector, 0xA0000);
#else
    /* If you aren't using GNU C++ or Zortech C++ for 386 protected mode,
       then you need to use a compiler that supports access to all of the
       registers, including ES, to be able to set the pallette all at once. */
    fp = MK_FP(0xA000, 0);
#endif

    /* If you got here then you are using Zortech C++ */
    for (i=start;i<start+count;i++) {
	fp[3*(i-start)  ] = palbuf[i][0];
	fp[3*(i-start)+1] = palbuf[i][1];
	fp[3*(i-start)+2] = palbuf[i][2];
    }

    regs.x.ax = 0x1012;
    regs.x.bx = start;
    regs.x.cx = count;
    regs.x.dx = 0;
    segread(&sregs);
    sregs.es  = 0xA000;
#if defined( DOS386 )
    int86x_real(0x10, &regs, &regs, &sregs);
#else
    int86x(0x10, &regs, &regs, &sregs);
#endif
    /* Now clear off the values that got dumped into the video RAM */
    for (i=0;i<3*count; i++)
	*fp++ = 0;
}
static int
setvesamode(int mode, int clear)
{
   union REGS regs;
   struct SREGS sregs;
   struct ModeInfoBlock *VgaPtr = &VESAModeInfo;
   unsigned i;

   /* Call VESA function 1 to get mode info */
   regs.h.ah = 0x4f;
   regs.h.al = 0x01;
   regs.x.cx = mode;
#if defined( DOS386 )
   regs.x.di = real_buf[0];
   segread(&sregs);
   sregs.es  = real_buf[1];
   int86x_real(0x10, &regs, &regs, &sregs);
   if (regs.h.al != 0x4f || regs.h.ah != 0)
      return 0;
   for (i=0; i<sizeof(struct ModeInfoBlock); i++)
      ((unsigned char *)VgaPtr)[i] = real_ptr[i];
#elif defined( __GNUC__ )
   regs.x.di = real_buf[0];
   int86x(0x10, &regs, &regs, &sregs);
   if (regs.h.al != 0x4f || regs.h.ah != 0)
      return 0;
   for (i=0; i<sizeof(struct ModeInfoBlock); i++)
      ((unsigned char *)VgaPtr)[i] = real_ptr[i];
#else
   regs.x.di = FP_OFF(VgaPtr);
   sregs.es  = FP_SEG(VgaPtr);
   int86x(0x10, &regs, &regs, &sregs);
   if (regs.h.al != 0x4f || regs.h.ah != 0)
      return 0;
#endif

   /* The mode is supported - save useful information and initialize
      the graphics display */
   line_length = VgaPtr->BytesPerScanLine;
   granularity = ((unsigned long)VgaPtr->WinGranularity) << 10;
   screen_maxx = VgaPtr->XResolution;
   screen_maxy = VgaPtr->YResolution;

   if (Reset_Display_Flag) {
      /* Now go set the video adapter into the requested mode */
      regs.h.ah = 0x4f;
      regs.h.al = 0x02;
      regs.x.bx = mode;
      int86(0x10, &regs, &regs);
      return (regs.h.al == 0x4f && regs.h.ah == 0x00 ? 1 : 0);
      }
}
示例#5
0
unsigned int EMSbaseaddress(void)
{
      static const char tag[] = EMS_ID;

      char far      *p;
      int           i;
      union REGS    regs;
      struct SREGS  segs;

      regs.h.ah = 0x35;
      regs.h.al = EMS_INT;
      int86x(0x21, &regs, &regs, &segs);

      p = (char far *) (MK_FP(segs.es, 10)); /* EMS_ID must be at offset 10 */

      for(i = 0; i < 8; i++)
      {
            if(tag[i] != p[i])
                  return 0;                  /* If EMS_ID not found, return */
      }

      regs.h.ah = EMSservice2;               /* Get page frame segment */
      int86(EMS_INT, &regs, &regs);

      return regs.h.ah ? 0 : (unsigned int) regs.x.bx;
}
示例#6
0
void CheckMouseDriver()
{
   union  REGS  regs;
   struct SREGS sregs;

   regs.x.ax = 0x0000;
   int86(MOUSE, &regs, &regs);
   if (regs.x.ax == 0xffff)
   {
      UseMouse = TRUE; /* mouse */
#ifdef CIRRUS_PATCH
      /*
         note from RQ:
            This test is temporary and should be removed in DEU 5.3
            We should create a better "fake cursor" by using the
            mouse callback function.  Remember to remove the callback
            when DEU exits...
      */
      if (CirrusCursor == TRUE)
      {
         regs.x.ax = 0x000C;
         regs.x.cx = 0x0001;
         regs.x.dx = FP_OFF( MouseCallBackFunction);
         sregs.es  = FP_SEG( MouseCallBackFunction);
         int86x( MOUSE, &regs, &regs, &sregs);
      }
#endif /* CIRRUS_PATCH */
   }
   else
      UseMouse = FALSE; /* no mouse */
}
示例#7
0
文件: L42-2.C 项目: FireFish/pcjs
/* Sets up the palette for antialiasing with the specified colors.
 * Intensity steps for each color are scaled from the full desired intensity
 * of the red, green, and blue components for that color down to 0%
 * intensity; each step is rounded to the nearest integer. Colors are
 * corrected for a gamma of 2.3. The values that the palette is programmed
 * with are hardwired for the VGA's 6 bit per color DAC.
 */
void SetPalette(struct WuColor * WColors)
{
	int i, j;
	union REGS regset;
	struct SREGS sregset;
	static unsigned char PaletteBlock[256][3];	 /* 256 RGB entries */
	/* Gamma-corrected DAC color components for 64 linear levels from 0% to 100% intensity */
	static unsigned char GammaTable[] = {
		0, 10, 14, 17, 19, 21, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34,
		35, 36, 37, 37, 38, 39, 40, 41, 41, 42, 43, 44, 44, 45, 46, 46,
		47, 48, 48, 49, 49, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55,
		56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63};

	for (i=0; i<NUM_WU_COLORS; i++) {
		for (j=0; j<WColors[i].NumLevels; j++) {
			PaletteBlock[j][0] = GammaTable[((double)WColors[i].MaxRed * (1.0 -
			   (double)j / (double)(WColors[i].NumLevels - 1))) + 0.5];
			PaletteBlock[j][1] = GammaTable[((double)WColors[i].MaxGreen * (1.0 -
			   (double)j / (double)(WColors[i].NumLevels - 1))) + 0.5];
			PaletteBlock[j][2] = GammaTable[((double)WColors[i].MaxBlue * (1.0 -
			   (double)j / (double)(WColors[i].NumLevels - 1))) + 0.5];
		}
		/* Now set up the palette to do Wu antialiasing for this color */
		regset.x.ax = 0x1012;						/* set block of DAC registers function */
		regset.x.bx = WColors[i].BaseColor;			/* first DAC location to load */
		regset.x.cx = WColors[i].NumLevels;			/* # of DAC locations to load */
		regset.x.dx = (unsigned int)PaletteBlock;	/* offset of array from which
													   to load RGB settings */
		sregset.es = _DS;							/* segment of array from which to load settings */
		int86x(0x10, &regset, &regset, &sregset);	/* load the palette block */
	}
}
示例#8
0
void MsCloseMouse()
{
	int x, y;
	MS_WINDOW_PROC* p;
	union REGS r;
	struct SREGS s;
	r.x.ax = 2;
	int86x(0x33, &r, &r, &s);

	/* Unregister Timer Filter */
	TmUnregisterFilter(MsTimerFilter);


	/* Delete map */
	for(x = 0; x < HASH_X; x++)
	{
		for(y = 0; y < HASH_Y; y++)
		{
			p = g_pScreenPos[y][x];
			while(p != NULL)
			{
				g_pScreenPos[y][x] = p->pNext;
				free(p);
				p = p->pNext;
			}
		}
	}
}
示例#9
0
文件: dpmi.c 项目: hallco978/msys
int _go32_dpmi_allocate_real_mode_callback_iret(_go32_dpmi_seginfo *info, _go32_dpmi_registers *regs)
{
  unsigned char *wrapper = (unsigned char *)malloc(sizeof(wrapper_common) + sizeof(wrapper_iret));
  if (wrapper == 0)
    return 0x8015;

  memcpy(wrapper, wrapper_common, sizeof(wrapper_common));
  memcpy(wrapper+sizeof(wrapper_common), wrapper_iret, sizeof(wrapper_iret));
  *(long *)(wrapper+11) = info->pm_offset - (int)wrapper - 15;
  info->size = (int)wrapper;

  r.x.ax = 0x0303;
  r.x.si = (int)wrapper;
  r.x.di = (int)regs;
  s.ds = _go32_my_cs();
  s.es = _go32_my_ds();
  s.fs = 0;
  s.gs = 0;
  int86x(0x31, &r, &r, &s);
  if (r.x.flags & 1)
  {
    return r.x.ax;
  }
  else
  {
    info->rm_segment = r.x.cx;
    info->rm_offset = r.x.dx;
    return 0;
  }
}
示例#10
0
//--------------------------------------------------------------------------
//
//      XMSinit: initialise XMS system (first time only).
//
//      The first time it is called, this function locates the XMS driver
//      and allocates a handle for a zero-byte block.  It returns TRUE if
//      a handle was successfully allocated.  Subsequent calls return the
//      same value.
//
static XMS::error XMSinit ()
{
    //--- check if this is the first time XMSinit has been called
    if (XMSinited == 0)
    {
        //--- now it isn't!
        XMSinited = 1;

        //--- check if an XMS driver is present (magic spell)
        REGS r;
        r.x.ax = 0x4300;
        int86 (0x2F, &r, &r);
        if (r.h.al != 0x80)
            return XMS::NO_DRIVER;

        //--- get the XMS driver's address (magic spell)
        SREGS s;
        r.x.ax = 0x4310;
        int86x (0x2F, &r, &r, &s);
        XMSdriver = (void far (*)()) MK_FP(s.es,r.x.bx);
    }

    //--- return success indicator
    return (XMSdriver != 0 ? XMS::SUCCESS : XMS::NO_DRIVER);
}
示例#11
0
文件: CDROM.CPP 项目: Execsl/usnap
unsigned int ReadSector(unsigned long *secno, unsigned char *buf) {
	union REGS r;
	struct SREGS s;

	r.x.ax = 0x1508; 		/* Absolute Read */
	r.x.si = FP_SEG(secno);        /* SI:DI -> starting sector no. */
	r.x.di = FP_OFF(secno);
	s.es = FP_SEG(buf);		/* ES:BX -> buffer */
	r.x.bx = FP_OFF(buf);
	r.x.cx = 0x4; 			/* Drive E */
	r.x.dx = 0x1; 			/* Num of secs */

	int86x(0x2F, &r, &r, &s);

	if (r.x.cflag) {
		switch (r.x.ax) {
		case 0xF:
			printf("Invalid drive!\n");
			break;
		case 0x15:
			printf("Drive not ready!\n");
			break;
		default:
			printf("Unknown error!\n");
		}
		return r.x.ax;
	} else
		printf("Success Read!\n");
	return 0;
}
示例#12
0
int GetDriverAddress(char *cdDriver){
    int   handle;
    union REGS      regs;
    struct SREGS    sregs;
    struct DTA {
       char         cmd;
       char   far * pdevHdr;
     } dta;
    struct DTA far *pdta;

   handle = open( cdDriver, O_BINARY);
   if (handle==-1) return(-1);
   dta.cmd = 0;
   pdta = &dta;
   regs.h.ah = 0x44;
   regs.h.al = 0x02;
   regs.x.bx = handle;
   regs.x.cx = 5;
   sregs.ds = FP_SEG(pdta);
   regs.x.dx = FP_OFF(pdta);
   int86x (0x21,&regs,&regs,&sregs);
   close(handle);
   if (regs.x.cflag) return(-1);

   FP_SEG(DevStrategy) = FP_SEG(dta.pdevHdr);
   FP_OFF(DevStrategy) = *(int far *)(dta.pdevHdr+6);
   FP_SEG(DevInterrupt) = FP_SEG(dta.pdevHdr);
   FP_OFF(DevInterrupt) = *(int far *)(dta.pdevHdr+8);
   LastUnit = *(dta.pdevHdr+21) - 1;
   return (0);
}
示例#13
0
/* Write sector (Win95 version) */
dsk_err_t win16_write(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
	                         const void *buf, dsk_pcyl_t cylinder,
	                          dsk_phead_t head, dsk_psect_t sector)
{
	WIN16_DSK_DRIVER *w16self;
	union REGS reg;
	struct SREGS sreg;
	dsk_err_t err;
	unsigned char old_dpt[11];
	int tries;

	if (!buf || !self || !geom || self->dr_class != &dc_win16) return DSK_ERR_BADPTR;
	w16self = (WIN16_DSK_DRIVER *)self;
	if (w16self->w16_readonly) return DSK_ERR_RDONLY;
	err = win16_checkgeom(w16self, geom, old_dpt, 0xF6);
	if (err) return err;

	for (tries = 0; tries < 3; tries++)	
	{
		reg.x.ax      = 0x0301;  /* Read 1 sector */
		reg.x.bx      = FP_OFF(buf);
		reg.h.ch      = cylinder;
		reg.h.cl      = sector;
		reg.h.dh      = head;
		reg.h.dl      = w16self->w16_unit - 1;
		reg.x.cflag   = 1;
		sreg.es = sreg.ds = FP_SEG(buf);
		int86x(0x13, &reg, &reg, &sreg);
		if (!reg.x.cflag) break;
	}
	set_dpt(old_dpt);
	if ( reg.x.cflag ) return translate_int13_error(reg.h.ah);
	return DSK_ERR_OK;
}
示例#14
0
void main()
{
    union REGS regs;
    struct SREGS sregs;
    DWORD mi_16;

    regs.w.ax = 0x0500;
    mi_16 = AllocAlias16( &MemInfo );
    sregs.ds = 0;
    sregs.es = HIWORD( mi_16 );
    regs.x.di = LOWORD( mi_16 );

    int86x( DPMI_INT, &regs, &regs, &sregs );
    printf( "Largest available block (in bytes): %ld\n",
            MemInfo.LargestBlockAvail );
    printf( "Maximum unlocked page allocation: %lu\n",
            MemInfo.MaxUnlockedPage );
    printf( "Pages that can be allocated and locked: %lu\n",
            MemInfo.LargestLockablePage );
    printf( "Total linear address space including allocated"
            " pages: %lu\n", MemInfo.LinAddrSpace );
    printf( "Number of free pages available: %lu\n",
             MemInfo.NumFreePagesAvail );
    printf( "Number of physical pages not in use: %lu\n",
             MemInfo.NumPhysicalPagesFree );
    printf( "Total physical pages managed by host: %lu\n",
             MemInfo.TotalPhysicalPages );
    printf( "Free linear address space (pages): %lu\n",
             MemInfo.FreeLinAddrSpace );
    printf( "Size of paging/file partition (pages): %lu\n",
             MemInfo.SizeOfPageFile );
    FreeAlias16( mi_16 );
}
示例#15
0
	void NETBIOS (NCB far * ncb_ptr)
	{
		struct SREGS sregs;
		union REGS regs;
		sregs.es =FP_SEG(ncb_ptr);
		regs.x.bx =FP_OFF(ncb_ptr);
		int86x(0x5C,&regs,&regs,&sregs);
	}
示例#16
0
文件: bcc.c 项目: AlanDrake/ags
static void device_request(void *block)
{
    inregs.x.ax = 0x1510;
    inregs.x.cx = cdrom_data.first_drive;
    inregs.x.bx = FP_OFF(block);
    sregs.es = FP_SEG(block);
    int86x(0x2f, &inregs, &outregs, &sregs);
}
示例#17
0
文件: mouse.c 项目: berkus/D-Flat
static void near mouse(int m1,int m2,int m3,int m4)
{
    regs.x.dx = m4;
    regs.x.cx = m3;
    regs.x.bx = m2;
    regs.x.ax = m1;
    int86x(MOUSE, &regs, &regs, &sregs);
}
示例#18
0
//**************** get pointer to system function FUNCNO into SEG:OFS *******
void ps_get_func_ptr(Byte funcno, Word *seg, Word *ofs)
{
    union REGS regs;                     // generic registers
    struct SREGS segregs;                // segment registers
    regs.h.ah = funcno;                  // put required funcno to AH
    int86x(0xFF,&regs,&regs,&segregs);   // do int FFh with regs structures
    *seg=segregs.ds;                     // read segment from DS
    *ofs=regs.x.dx;                      // read offset from DX
}
/* --------------------------------------------------------------------
   BlinkRate:
   Specifies the graphics cursor blinking rate (Normal blink = 9)
   -------------------------------------------------------------------- */
void BlinkRate(int Rate)
{
    union REGS regs;
    struct SREGS segregs;

    regs.x.cx = Rate;
    regs.x.ax = 0xdc02;
    int86x(0x10, &regs, &regs, &segregs);
}
示例#20
0
int MsInitMouse()
{
	/* Set mouse style */
	union REGS r;
	struct SREGS s;
	r.x.ax = 0;
	int86x(0x33,&r,&r,&s);

	/* Set new handler */
	r.x.ax = 0x14;
	r.x.cx = 0x2 | 0x1; /* push left button */
	s.es = FP_SEG(MsFilterProc);
	r.x.flags = r.x.cflag = 0;  /* CF = 0 */
	r.x.dx = FP_OFF(MsFilterProc);
	int86x(0x33, &r, &r, &s);

	return r.x.ax;
}
示例#21
0
    void net_delete_name(char *name)
	{
	 memset(&delete_name_ncb,0,sizeof(NCB));
	 delete_name_ncb.NCB_COMMAND =DELETE_NAME;
	 strcpy(delete_name_ncb.NCB_NAME,name);
	 sregs.es=FP_SEG((void far *) &delete_name_ncb);
	 regs.x.bx =FP_OFF((void far *) &delete_name_ncb);
	 int86x(0x5c,&regs,&regs,&sregs);
	 }
示例#22
0
static unsigned doslowblock( void )
{
    union REGS          regs;
    struct SREGS        sregs;

    regs.h.ah = 0x52;
    int86x( DOS, &regs, &regs, &sregs );
    return( * (unsigned _WCFAR *) (sregs.es*0x10000 + (regs.x.bx - 2)) + 1 );
}
示例#23
0
void MsShowMouse()
{
	union REGS r;
	struct SREGS s;
	r.x.ax = 1;
	int86x(0x33, &r, &r, &s);

	/* Register Timer Filter */
	TmRegisterFilter(MsTimerFilter);
}
示例#24
0
void mouseCursor(int *cur)
{
	i.x.ax = 9;
	i.x.bx = 0;
	i.x.cx = 0;
	i.x.dx = (unsigned)cur;
	segread(&s);
	s.es = s.ds;
	int86x(0x33,&i,&i,&s);
}
示例#25
0
void SetEGAPalette(void)
{
   union REGS regs;
   struct SREGS sregs;
   regs.h.ah = 0x10;
   regs.h.al = 0x2;
   regs.x.dx = FP_OFF(egacolortable);
   sregs.es = FP_SEG(egacolortable);
   int86x(0x10,&regs,&regs,&sregs);
}
change(int *shape)
{
i.x.ax=9;
i.x.bx=0;
i.x.cx=0;
i.x.dx=(unsigned)shape;
segread(&s);
s.es=s.ds;
int86x(0x33,&i,&i,&s);
}
示例#27
0
void MOUSE::FormaCursor() {
	union REGS r;
	struct SREGS s;
	r.x.ax = 0x09;
	r.x.bx = 7;
	r.x.cx = 7;
	s.es = FP_SEG (fig);
	r.x.dx = FP_OFF (fig);
	int86x (0x33,&r, &r, &s );
}
示例#28
0
文件: BICHO.C 项目: acassis/langc
void mudamouse(unsigned segimag,unsigned offimag,unsigned lin,unsigned col)
{
  union REGS regs;
  struct SREGS sregs;
  regs.x.ax=0x09;
  regs.x.bx=col;
  regs.x.cx=lin;
  sregs.es=segimag;
  regs.x.dx=offimag;
  int86x(0x33,&regs,&regs,&sregs);
}
示例#29
0
void x_map_pal(char *palette)   /* namapovani 16 pal.registru */
{
  union REGS in,out;
  struct SREGS segreg;

  in.h.ah = 0x10;
  in.h.al = 2;
  in.x.dx = FP_OFF(palette);
  segreg.es = FP_SEG(palette);
  int86x(0x10,&in,&out,&segreg);
}
示例#30
0
//initialize the vga palette with data from palette[256][3]
void initpalette(char palette[256][3])
{
	REGS regs;
	SREGS sregs;
	regs.x.ax = 0x1012;
	regs.x.bx = 0;
	regs.x.cx = 256;
	regs.x.dx = FP_OFF(palette);
	sregs.es = FP_SEG(palette);
	int86x(0x10, &regs, &regs, &sregs);
}