home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / POLYEDIT.LZH / MODEL / FONTPC.C < prev    next >
C/C++ Source or Header  |  1995-06-25  |  2KB  |  96 lines

  1.  
  2. #include    <stdio.h>
  3. #include    <pc.h>
  4. #include    <go32.h>
  5. #include    <dpmi.h>
  6.  
  7. #include    "graph.h"
  8.  
  9. static    _go32_dpmi_seginfo info ;
  10. static    _go32_dpmi_registers regsh, regsz ;
  11. static    char    *fontbuf ;
  12.  
  13. #define    iskanji( c )    ( ( c & 0x80 ) == 0x80 )
  14.  
  15. static    void    putfont( int, int, int, int );
  16.  
  17. void    FontInit()
  18. {
  19.     info.size = 256 ;
  20.     _go32_dpmi_allocate_dos_memory( &info );
  21.     fontbuf = (char*)( 0xE0000000 + info.rm_segment * 16 + info.rm_offset );
  22.  
  23.     /*  font routine ( 1byte )    */
  24.     regsh.x.ax = 0x5000 ;
  25.     regsh.x.bx = 0x0000 ;
  26.     regsh.x.dx = 0x0810 ;
  27.     regsh.x.ss = regsh.x.sp = 0 ;
  28.     _go32_dpmi_simulate_int( 0x15, ®sh );
  29.  
  30.     regsh.x.ss = regsh.x.sp = 0 ;
  31.     regsh.x.cs = regsh.x.es ;
  32.     regsh.x.ip = regsh.x.bx ;
  33.     regsh.x.es = info.rm_segment ;
  34.     regsh.x.si = info.rm_offset ;
  35.     regsh.x.ss = regsh.x.sp = 0 ;
  36.  
  37.     /*  font routine ( 2byte )    */
  38.     regsz.x.ax = 0x5000 ;
  39.     regsz.x.bx = 0x0100 ;
  40.     regsz.x.dx = 0x1010 ;
  41.     regsz.x.ss = regsz.x.sp = 0 ;
  42.     _go32_dpmi_simulate_int( 0x15, ®sz );
  43.  
  44.     regsz.x.ss = regsz.x.sp = 0 ;
  45.     regsz.x.cs = regsz.x.es ;
  46.     regsz.x.ip = regsz.x.bx ;
  47.     regsz.x.es = info.rm_segment ;
  48.     regsz.x.si = info.rm_offset ;
  49.     regsz.x.ss = regsz.x.sp = 0 ;
  50. }
  51.  
  52. static    void    putfont( x, y, c, color )
  53. int        x, y ;
  54. int        c ;
  55. int        color ;
  56. {
  57.     if ( c < 256 )
  58.     {
  59.         regsh.x.cx = c ;
  60.         _go32_dpmi_simulate_fcall( ®sh );
  61.         graph_pattern2( x, y, color, fontbuf, 8, 16 );
  62.     }
  63.     else
  64.     {
  65.         regsz.x.cx = c ;
  66.         _go32_dpmi_simulate_fcall( ®sz );
  67.         graph_pattern2( x, y, color, fontbuf, 16, 16 );
  68.     }
  69. }
  70.  
  71. void    FontPuts( x, y, str, fg, bg )
  72. int        x, y ;
  73. unsigned    char    *str ; 
  74. int        fg, bg ;
  75. {
  76.     int        color ;
  77.  
  78.     color = ( bg << 4 ) | fg ;
  79.  
  80.     while( *str != '\0' )
  81.     {
  82.         if ( iskanji( *str ) )
  83.         {
  84.             putfont( x, y, str[0]*256+str[1], color );
  85.             x += 16 ;
  86.             str += 2 ;
  87.         }
  88.         else
  89.         {
  90.             putfont( x, y, *str, color );
  91.             x += 8 ;
  92.             str++ ;
  93.         }
  94.     }
  95. }
  96.