home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 328_01 / msc.h < prev    next >
C/C++ Source or Header  |  1989-12-27  |  3KB  |  121 lines

  1. /* MSC.H header file for porting Turbo C v2 to Microsoft C v5
  2.  *
  3.  *    This header file 'irons out' some of the minor differences.
  4.  *
  5.  */
  6.  
  7.  
  8. /* memory model indicator -- at least one must be defined,
  9.  * default is medium (for Quick C)
  10.  */
  11. #ifndef __SMALL__
  12.     #ifndef __LARGE__
  13.         #ifndef __MEDIUM__
  14.             #ifndef __COMPACT__
  15.                 #ifndef __HUGE__
  16.                     #ifndef __TINY__
  17.                         #define __MEDIUM__ 1
  18.                     #endif
  19.                 #endif
  20.             #endif
  21.         #endif
  22.     #endif
  23. #endif        /* end memory model indicator */
  24.  
  25.  
  26. /* In-Line interrupts - TurboC can, microsoft C can't
  27.  *
  28.  *
  29.  *  To use this technique, ALWAYS load the registers in inverse
  30.  *  alphabetical order (DX first, then CX, BX and AX last)
  31.  *  and don't try to do any complex computations in the lines
  32.  *  that access the registers.
  33.  *     WRONG, for 3 reasons:
  34.  *        _AH = 1;
  35.  *        _DX = value1 + 3*value2;    ===> TurboC uses AX
  36.  *        geninterrupt ( variable_int_number );  ditto
  37.  *    RIGHT, but useless:
  38.  *        value3 = value1 + 3*value2;
  39.  *        if ( int_number = 0x01 )
  40.  *            {
  41.  *            _DX = value3;
  42.  *            _AX = 1;
  43.  *            geninterrupt ( 0x01 );
  44.  *            }
  45.  *        else    {
  46.  *            _DX = value3;
  47.  *            _AX = 1;
  48.  *            geninterrupt ( 0x02 );
  49.  *            }
  50.  *
  51.  */
  52.         #define PSEUDOREGS union REGS regs; struct SREGS sregs;
  53.         #define _AX    regs.x.ax
  54.         #define _AL    regs.h.al
  55.         #define _AH    regs.h.ah
  56.         #define _BX    regs.x.bx
  57.         #define _BL    regs.h.bl
  58.         #define _BH    regs.h.bh
  59.         #define _CX    regs.x.cx
  60.         #define _CL    regs.h.cl
  61.         #define _CH    regs.h.ch
  62.         #define _DX    regs.x.dx
  63.         #define _DL    regs.h.dl
  64.         #define _DH    regs.h.dh
  65.  
  66.          #define _ES    sregs.es
  67.         #define _CS    sregs.cs
  68.         #define _SS    sregs.ss
  69.         #define _DS    sregs.ds
  70.         
  71.         /* Microsoft C can't access the flags.
  72.          */
  73.         #undef _FLAGS
  74.  
  75.         #define INTERRUPT(intno)    int86((intno), ®s, ®s)
  76.  
  77.         #define INTERRUPTX(intno) int86x ( (intno), ®s, ®s, &sregs )
  78.         
  79. /* interrupt handlers
  80.  */
  81. #define enable()         _enable()
  82. #define disable()         _disable()
  83. #define setvect(x,y)       _dos_setvect((x),(y))
  84. #define getvect(x)       _dos_getvect((x))
  85.  
  86. /* In Line outport()
  87.  */
  88. #define outport(x,y)  outp((x),(y))
  89. #define inport(x)     inp ((x))
  90.  
  91.  
  92.  
  93. /* Memory allocation.
  94.  * uses different names from TurboC
  95.  */
  96.     #define farmalloc(nb)    halloc(nb, 1)
  97.     #define farfree(x)         hfree(x)
  98.  
  99.  
  100.  
  101. /* make a far ptr given a seg & offset
  102.  */
  103. #define MK_FP(s,o) (void far *)(((unsigned long)(s)<<16)|((unsigned)(o)))
  104.  
  105.  
  106.  
  107.  
  108. /* simple graphics calls
  109.  */
  110. #define line(a,b,c,d)    \
  111.             _moveto((a),(b)), _lineto((c),(d)) 
  112. #define lineto(a,b)  _lineto ((a), (b))
  113. #define setviewport(a,b,c,d,x)  \
  114.     _setviewport((a),(b),(c),(d)), \
  115.     if (x) {_setcliprgn ((a),(b),(c),(d)) }
  116. #define putpixel(a,b,c)  _setcolor((c)), _setpixel ((a),(b))
  117. #define getpixel(a,b)    _getpixel ((a),(b))
  118. #define setcolor(x)      _setcolor((x))
  119.  
  120.  
  121.