home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / POLYEDIT.LZH / MODEL / TEXT98.C < prev    next >
C/C++ Source or Header  |  1994-08-15  |  2KB  |  169 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <dos.h>
  4. #include "text.h"
  5. #include "graph.h"
  6.  
  7. #define    TRUE    1
  8. #define    FALSE    0
  9.  
  10. #define        iskanji( c )    ( ( (c) & 0x80 ) != 0 )
  11.  
  12. int        Cols, Lines ;
  13.  
  14. static    int        Cx, Cy ;
  15. static    int        Attr ;
  16. static    int        Cursor ;
  17.  
  18. void    InitText()
  19. {
  20.     Cols = 80 ;
  21.     Lines = 25 ;
  22.     Attr = ColorNomal ;
  23.     Cx = Cy = 0 ;
  24.     CursorOFF();
  25. }
  26.  
  27. void    ExitText()
  28. {
  29.     ClearScreen();
  30. }
  31.  
  32. /*    コンソール入力    */
  33.  
  34. int        GetChar()
  35. {
  36.     int        code ;
  37.     union REGS    regs;
  38.  
  39.     regs.h.ah = 0x07 ;
  40.     intdos( ®s, ®s );
  41.     code = regs.h.al ;
  42.     return code ;
  43. }
  44.  
  45. int        KeyIn()
  46. {
  47.     union REGS    regs;
  48.     int        code ;
  49.  
  50.     regs.h.ah = 0x00 ;
  51.     int86( 0x18, ®s, ®s );
  52.  
  53.     code = regs.x.ax >> 8 ;
  54.     if ( 0x62 <= code && code <= 0x6b )
  55.     {
  56.         if ( ShiftSense() & 1 )
  57.             code = 0x8000 + code - 0x62 + 11 ;
  58.         else
  59.             code = 0x8000 + code - 0x62 + 1 ;
  60.     }
  61.     else if ( 0x36 <= code && code <= 0x3d )
  62.     {
  63.         code = 0x8000 + code - 0x36 + 0x15 ;
  64.     }
  65.     else if ( code == 0x3e )
  66.     {
  67.         code = 0x8000 + 0x1f ;
  68.     }
  69.     else if ( code == 0x3f )
  70.     {
  71.         code = 0x8000 + 0x1e ;
  72.     }
  73.     else
  74.         code = regs.x.ax & 0xff ;
  75.  
  76.     return code ;
  77. }
  78.  
  79. int        KeySense()
  80. {
  81.     union REGS    regs;
  82.  
  83.     regs.h.ah = 0x01 ;
  84.     int86( 0x18, ®s, ®s );
  85.     return regs.h.bh ;
  86. }
  87.  
  88. int        ShiftSense()
  89. {
  90.     union REGS    regs;
  91.  
  92.     regs.h.ah = 0x02 ;
  93.     int86( 0x18, ®s, ®s );
  94.  
  95.     return regs.h.al ;
  96. }
  97.  
  98. void    Wait()
  99. {
  100.     int        i ;
  101.  
  102.     for( i = 0 ; i < 10000 ; ++i )
  103.         KeySense();
  104. }
  105.  
  106. void    ClearScreen()
  107. {
  108.     int        i ;
  109.     short    *vram, *attr ;
  110.  
  111.     vram = (short*)0xe00a0000 ;
  112.     attr = (short*)0xe00a2000 ;
  113.  
  114.     for( i = 0 ; i < Cols*Lines ; ++i )
  115.     {
  116.         *vram++ = ' ' ;
  117.         *attr++ = 0xE1 ;
  118.     }
  119.  
  120.     graph_fill( 0, 0, 639, 399, Attr >> 4 );
  121. }
  122.  
  123. void    Locate( x, y )
  124. int        x, y ;
  125. {
  126.     union    REGS    regs ;
  127.  
  128.     Cx = x ;
  129.     Cy = y ;
  130.  
  131.     if ( Cursor )
  132.     {
  133.         regs.h.ah = 0x13 ;
  134.         regs.x.dx = ( y * 80 + x ) * 2 ;
  135.         int86( 0x18, ®s, ®s );
  136.     }
  137. }
  138.  
  139. void    CursorON()
  140. {
  141.     union    REGS    regs ;
  142.  
  143.     Cursor = TRUE ;
  144.     Locate( Cx, Cy );
  145.  
  146.     regs.h.ah = 0x11 ;
  147.     int86( 0x18, ®s, ®s );
  148. }
  149.  
  150. void    CursorOFF()
  151. {
  152.     union    REGS    regs ;
  153.     Cursor = FALSE ;
  154.     regs.h.ah = 0x12 ;
  155.     int86( 0x18, ®s, ®s );
  156. }
  157.  
  158. void    Bell()
  159. {
  160.     bdos( 6, 7, 0 );
  161. }
  162.  
  163. void    GetCursor( xp, yp )
  164. int        *xp, *yp ;
  165. {
  166.     *xp = Cx ;
  167.     *yp = Cy ;
  168. }
  169.