void JCMouse::update(int newx, int newy, int new_but) { int butn,xx,yy; if (newx<0) { if (here) { union REGS in,out; in.w.ax=0x0b; int386(0x33,&in,&out); // get the mouse movement xx=(signed short)out.w.cx; yy=(signed short)out.w.dx; in.w.ax=5; // get the button press info in.w.bx=1|2|4; int386(0x33,&in,&out); butn=out.w.ax; lx=mx; ly=my; lbut=but; but=butn; mx+=xx; my+=yy; if (mx<0) mx=0; if (my<0) my=0; if (mx>=screen->width()) mx=screen->width()-1; if (my>=screen->height()) my=screen->height()-1; } } else { mx=newx; my=newy; but=new_but; } }
void vga_set_text_50() { union REGS regs; regs.w.ax = 0x1202; regs.w.bx = 0x30; int386( 0x10, ®s, ®s ); regs.w.ax = 3; int386( 0x10, ®s, ®s ); regs.w.ax = 0x1112; regs.w.bx = 0x0; int386( 0x10, ®s, ®s ); }
void gr_set_text_43() { union REGS regs; regs.w.ax = 0x1201; regs.w.bx = 0x30; int386( 0x10, ®s, ®s ); regs.w.ax = 3; int386( 0x10, ®s, ®s ); regs.w.ax = 0x1112; regs.w.bx = 0x0; int386( 0x10, ®s, ®s ); }
static int pc_init_vidmode () { union REGS r; int i; clock_count = 0; clock_ticks = 0; screen_buffer = calloc (GFX_WIDTH, GFX_HEIGHT); prev_08 = _dos_getvect (0x08); _dos_setvect (0x08, tick_increment); memset (&r, 0x0, sizeof(union REGS)); #ifdef __WATCOMC__ r.w.ax = 0x13; int386 (0x10, &r, &r); #endif #ifdef __TURBOC__ r.x.ax = 0x13; int86 (0x10, &r, &r); #endif __outp (0x3c8, 0); for (i = 0; i < 32 * 3; i++) __outp (0x3c9, palette[i]); return err_OK; }
int _fast setfsize(int fd, long size) { union REGS r; long pos=tell(fd); lseek(fd, size, SEEK_SET); #ifdef __386__ r.h.ah=0x40; r.x.ebx=fd; r.x.ecx=0; r.x.edx=0; int386(0x21, &r, &r); #else r.h.ah=0x40; r.x.bx=fd; r.x.cx=0; r.x.dx=0; int86(0x21, &r, &r); #endif lseek(fd, pos, SEEK_SET); return 0; }
// // D_DrawTitle // void D_DrawTitle(char *string, int bc, int tc) { int color; int column; int row; int i; union REGS regs; //Calculate text color color = (tc << 4) | bc; //Get column position column = D_GetCursorColumn(); //Get row position row = D_GetCursorRow(); for (i = 0; i < strlen(string); i++) { //Set character regs.h.al = string[i]; regs.h.ah = 9; regs.h.bl = color; regs.h.bh = 0; regs.w.cx = 1; int386(0x10, ®s, ®s); //Check cursor position if (++column >= 80) column = 0; //Set postition D_SetCursorPosition(column, row); } }
static unsigned short allocateTimerStack ( unsigned short size ) { union REGS regs; // clear all registers memset( ®s, 0, sizeof( regs ) ); // DPMI allocate conventional memory regs.w.ax = 0x100; // size in paragraphs regs.w.bx = ( size + 15 ) / 16; int386( 0x31, ®s, ®s ); if (!regs.w.cflag) { // DPMI call returns selector in dx // (ax contains real mode segment // which is ignored here) return( regs.w.dx ); } // Couldn't allocate memory. return( NULL ); }
T_void DirectTalkPollData(T_void) { const union REGS regs ; DebugRoutine("DirectTalkPollData") ; /* Request that any data that needs to be sent to us is done now. */ G_talk->command = DIRECT_TALK_COMMAND_RECV ; G_talk->bufferFilled = FALSE ; /* Do the actual 32-bit interrupt call. */ int386( G_talk->vector, ®s, ®s) ; if (G_talk->bufferFilled) { /* Tell the DOS32 program that it just received data. */ G_receiveCallback( G_talk->buffer, G_talk->bufferLength) ; } DebugEnd() ; }
void far *allocDOS (unsigned nbytes, short *pseg, short *psel) { unsigned npara = (nbytes + 15) / 16; void far *pprot; pprot = NULL; *pseg = 0; // assume will fail *psel = 0; // DPMI call 100h allocates DOS memory segread (&sregs); AX (regs) = 0x0100; // DPMI: Allocate DOS Memory BX (regs) = npara; // number of paragraphs to alloc int386( DPMI_INT, ®s, ®s); if (regs.w.cflag == 0) { *pseg = AX (regs); // the real-mode segment *psel = DX (regs); // equivalent protected-mode selector // pprot is the protected mode address of the same allocated block. // The Rational extender maps the 1 MB physical DOS memory into // the bottom of our virtual address space. pprot = (void far *) ((unsigned)*pseg << 4); } return pprot; }
void freeDOS (short sel) { AX(regs) = 0x0101; // DPMI free DOS memory DX(regs) = sel; int386( DPMI_INT, ®s, ®s); }
/* ** pciPhrlapGetSegmentLinearBase (_dx_tolinear) */ int pciPhrlapGetSegmentLinearBase( USHORT selector, ULONG* lin_addrp ) { union REGS r; /* ** Phar Lap 2508h - Get Segment Linear Base Address */ r.w.ax = 0x2508; /* ** BX segment selector */ r.w.bx = (unsigned short) selector; int386( PHARLAP_INTERRUPT, &r, &r ); if ( r.w.cflag ) { return PHARLAP_UNSPECIFIED_ERROR; } else { /* ** ECX linear base address of segment */ *lin_addrp = (ULONG) r.x.ecx; return 0; } }
/* ** pciPhrlapWritePageTableEntry (_dx_wr_ptinfn) */ int pciPhrlapWritePageTableEntry( ULONG linadr, ULONG pte, ULONG ptinf ) { union REGS r; /* ** Phar Lap 252bh/10 - Write Page Table Entry and Associated Information */ r.w.ax = 0x252b; r.h.bh = 0xa; r.h.bl = 0x0; /* select linear */ /* ** ECX linear address to read PTE for ** ESI page table entry ** EDI additional page table information */ r.x.ecx = linadr; r.x.esi = pte; r.x.edi = ptinf; int386( PHARLAP_INTERRUPT, &r, &r ); if ( r.w.cflag ) { /* ** EAX error code */ return r.x.eax; } else { return 0; } }
void main() { union REGS r; struct SREGS s; s.ds = s.es = s.fs = s.gs = FP_SEG( &s ); #if defined(__PHARLAP__) r.w.ax = 0x2503; /* get real-mode vector */ r.h.cl = 0x33; /* interrupt vector 0x33 */ int386( 0x21, &r, &r ); printf( "mouse handler real-mode address=" "%lx\n", r.x.ebx ); r.w.ax = 0x2502; /* get protected-mode vector */ r.h.cl = 0x33; /* interrupt vector 0x33 */ int386x( 0x21, &r, &r, &s ); printf( "mouse handler protected-mode address=" "%x:%lx\n", s.es, r.x.ebx ); #else r.h.ah = 0x35; /* get vector */ r.h.al = 0x33; /* vector 0x33 */ int386x( 0x21, &r, &r, &s ); printf( "mouse handler protected-mode address=" "%x:%lx\n", s.es, r.x.ebx ); #endif }
void MGenWakeupDll (void) { REGISTERS regs; regs.d.eax = MGENVXD_WAKEUPDLL_ORD << 16 | MGENVXD_DEVICE_ID; int386(CHUNNEL_INT, ®s, ®s); }
word IN_GetMouseButtons ( void ) { word buttons; union REGS inregs; union REGS outregs; if (!MousePresent || !mouseenabled) return (0); inregs.w.ax = MButtons; int386 (MouseInt, &inregs, &outregs); buttons = outregs.w.bx; // Used by menu routines that need to wait for a button release. // Sometimes the mouse driver misses an interrupt, so you can't wait for // a button to be released. Instead, you must ignore any buttons that // are pressed. IgnoreMouse &= buttons; buttons &= ~IgnoreMouse; return (buttons); }
MVFunc *PAS_GetFunctionTable ( void ) { union REGS regs; MVFunc *ptr; regs.w.ax = MV_GetPointerToFunctionTable; #ifdef __386__ int386( MV_SoundInt, ®s, ®s ); #else int86( MV_SoundInt, ®s, ®s ); #endif if ( regs.w.ax != MV_Signature ) { PAS_SetErrorCode( PAS_DriverNotFound ); return( NULL ); } #if defined(__WATCOMC__) && defined(__FLAT__) ptr = ( MVFunc * )( ( ( ( unsigned )regs.w.dx ) << 4 ) + ( ( unsigned )regs.w.bx ) ); #else ptr = MK_FP( regs.w.dx, regs.w.bx ); #endif return( ptr ); }
int curs_set( const int visibility) { union _REGS regs; int start, end; switch (visibility) { case 0: /* invisible */ start = 32; end = 0; /* was 32 */ break; case 2: /* highly visible */ start = 0; /* full-height block */ end = 7; break; default: /*' normal' visibility */ start = 0; end = 31; break; } /* if scrnmode is not set, some BIOSes hang */ regs.h.ah = 0x01; regs.h.al = (unsigned char)3; regs.h.ch = (unsigned char)start; regs.h.cl = (unsigned char)end; int386(0x10, ®s, ®s); return 1; }
uint32_t pci_read_cfg_BIOS(uint8_t bus,uint8_t card,uint8_t func,uint8_t reg,uint8_t size) { static const uint32_t msks[3] = {0xFFUL,0xFFFFUL,0xFFFFFFFFUL}; union REGS regs; if (size > 2) return ~0UL; #if TARGET_MSDOS == 16 if (size == 2) { /* 32-bit DWORD read in real mode when Watcom won't let me use 386 style registers or int386() */ return pci_bios_read_dword_16( /* BH=bus BL(7-3)=card BL(2-0)=func */ (bus << 8) | (card << 3) | func, /* DI=reg */ reg); } #endif regs.w.ax = 0xB108 + size; regs.w.bx = (bus << 8) | (card << 3) | func; regs.w.di = reg; #if TARGET_MSDOS == 32 int386(0x1A,®s,®s); #else int86(0x1A,®s,®s); #endif if (regs.w.cflag & 1) /* carry flag set on error */ return ~0UL; if (regs.h.ah != 0x00) /* AH=0x00 if success */ return ~0UL; #if TARGET_MSDOS == 32 return regs.x.ecx & msks[size]; #else return regs.w.cx & msks[size]; #endif }
int PAS_CheckForDriver ( void ) { union REGS regs; unsigned result; regs.w.ax = MV_CheckForDriver; regs.w.bx = 0x3f3f; #ifdef __386__ int386( MV_SoundInt, ®s, ®s ); #else int86( MV_SoundInt, ®s, ®s ); #endif if ( regs.w.ax != MV_CheckForDriver ) { PAS_SetErrorCode( PAS_DriverNotFound ); return( PAS_Error ); } result = regs.w.bx ^ regs.w.cx ^ regs.w.dx; if ( result != MV_Signature ) { PAS_SetErrorCode( PAS_DriverNotFound ); return( PAS_Error ); } return( PAS_Ok ); }
void pci_write_cfg_BIOS(uint8_t bus,uint8_t card,uint8_t func,uint8_t reg,uint32_t data,uint8_t size) { union REGS regs; if (size > 2) return; #if TARGET_MSDOS == 16 if (size == 2) { /* 32-bit DWORD read in real mode when Watcom won't let me use 386 style registers or int386() */ pci_bios_write_dword_16( /* BH=bus BL(7-3)=card BL(2-0)=func */ (bus << 8) | (card << 3) | func, /* DI=reg */ reg, /* data */ data); return; } #endif regs.w.ax = 0xB10B + size; regs.w.bx = (bus << 8) | (card << 3) | func; regs.w.di = reg; #if TARGET_MSDOS == 32 regs.x.ecx = data; int386(0x1A,®s,®s); #else regs.w.cx = (uint16_t)data; int86(0x1A,®s,®s); #endif }
void gr_set_3dbios_mode( uint mode ) { union REGS regs; memset( ®s, 0, sizeof(regs) ); regs.w.ax = 0x4fd0; regs.w.bx = 0x3d00 | (mode & 0xff); int386( 0x10, ®s, ®s ); }
int MGenWait (void) { REGISTERS regs; regs.d.eax = MGENVXD_WAIT_ORD << 16 | MGENVXD_DEVICE_ID; int386(CHUNNEL_INT, ®s, ®s); return regs.d.eax; }
void gr_setcursor(ubyte x, ubyte y, ubyte sline, ubyte eline) { union REGS regs; memset( ®s, 0, sizeof(regs) ); regs.w.ax = 0x0200; regs.w.bx = 0; regs.h.dh = y; regs.h.dl = x; int386( 0x10, ®s, ®s ); memset( ®s, 0, sizeof(regs) ); regs.w.ax = 0x0100; regs.h.ch = sline & 0xf; regs.h.cl = eline & 0xf; int386( 0x10, ®s, ®s ); }
mouse_detector() { union REGS in,out; memset(&in,0,sizeof(in)); in.w.ax=0; int386(0x33,&in,&out); detected=(((unsigned short)out.w.ax)==0xffff); }
ubyte vga_get_screen_mode( void ) { union REGS regs; regs.w.ax = 0x0f00; int386( 0x10, ®s, ®s ); return regs.w.ax & 0xff; }
void vga_disable_default_palette_loading() { union REGS regs; regs.w.ax = 0x1201; regs.w.bx = 0x31; int386( 0x10, ®s, ®s ); vga_prevent_palette_loading = 1; }
void vga_set_cursor_type( uword ctype ) { union REGS regs; regs.w.ax = 0x0100; regs.w.cx = ctype; int386( 0x10, ®s, ®s ); }
void InitMouse() { memset(®s, 0, sizeof regs); int386(0x33,®s,®s); regs.w.ax=7; regs.w.cx=0; regs.w.dx=640; /*320;*/ /* -- ric:13/Jun/98 - fix horizontal jumps -- */ int386(0x33,®s,®s); regs.w.ax=8; regs.w.cx=0; regs.w.dx=sy; // aen int386(0x33,®s,®s); PutMouse(sx/2,(sy/2) /2); // aen }
void vga_set_text_25() { union REGS regs; regs.w.ax = 3; int386( 0x10, ®s, ®s ); }
void vga_set_misc_mode( uword mode ) { union REGS regs; regs.w.ax = mode; int386( 0x10, ®s, ®s ); }