home *** CD-ROM | disk | FTP | other *** search
/ Computer Installation Guide - Dragon Clan Series / CD2.iso / ucdos70 / 5 / SRC.ZIP / API / APITEST9.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-25  |  3.7 KB  |  127 lines

  1. /* ╓≈╠Γú║┤≥╙í╫╓┐Γ╢┴╚í */
  2. /*
  3.    1    DispChinese     ╢┴╚íPostscript╫╓┐Γ╡π╒≤          INT 7EH
  4. */
  5. #include                <dos.h>
  6. #include                <stdio.h>
  7. #include                <stdlib.h>
  8.  
  9. #define                 TRUE            1
  10. #define                 FALSE           0
  11.  
  12. int IsUcdosResident(void)
  13. {
  14.    union REGS regs;
  15.  
  16.    regs.x.ax = 0xdb00;
  17.    int86(0x2f,®s,®s);
  18.    return regs.x.bx == 0x5450;
  19. }
  20.  
  21. int QueryModuleResident(int ModuleNo)
  22. {
  23.    union REGS regs;
  24.  
  25.    if (!IsUcdosResident()) return 0;
  26.    regs.h.ah = 0;
  27.    regs.h.al = ModuleNo;
  28.    int86(0x79,®s,®s);
  29.    return regs.x.flags & 0x40 ? 1 : 0;
  30. }
  31.  
  32.  
  33. void SetDisplayMode(int Mode)
  34. {
  35.    union REGS regs;
  36.  
  37.    regs.h.ah = 0;
  38.    regs.h.al = Mode;
  39.    int86(0x10,®s,®s);
  40. }
  41.  
  42. void SetPixel(int Col,int Row,int Color)
  43. {
  44.    union REGS regs;
  45.  
  46.    regs.h.ah = 0xc;
  47.    regs.h.al = Color;
  48.    regs.x.cx = Col;
  49.    regs.x.dx = Row;
  50.    int86(0x10,®s,®s);
  51. }
  52.  
  53. /******************************************************************************
  54.     ▓╬╩²╦╡├≈:   x,y             ╧╘╩╛║║╫╓╡─╫≤╔╧╜╟╫°▒Ω
  55.                 FrColor         ╧╘╩╛║║╫╓╡─╟░╛░╔½
  56.                 BgColor         ╧╘╩╛║║╫╓╡─▒│╛░╔½
  57.                 ChineseCode     ╙√╧╘╩╛╡─║║╫╓
  58.                 Font            ╩╣╙├╡─╫╓┐Γ▒α║┼
  59.                 Fontx           ╧╘╩╛║║╫╓╡─╦«╞╜┐φ╢╚
  60.                 Fonty           ╧╘╩╛║║╫╓╡─┤╣╓▒╕▀╢╚
  61. ******************************************************************************/
  62. int DispChinese(int x,int y,int FrColor,int BgColor,char *ChineseCode,
  63.                  int Font,int Fontx,int Fonty)
  64. {
  65.    union REGS           regs;
  66.    struct SREGS         sregs;
  67.    struct Int7eStru{
  68.       unsigned char     Word[2];                /* ║║╫╓╗·─┌┬δ     */
  69.       unsigned int      Font;                   /* ╫╓┐Γ▒α║┼       */
  70.       unsigned int      Fontx,Fonty;            /* ║║╫╓╕▀╢╚║═┐φ╢╚ */
  71.       unsigned int      Top,Bot;                /* ╞≡╩╝╧▀║═╓╒╓╣╧▀ */
  72.       unsigned int      Attribute;              /* ╩⌠╨╘           */
  73.       unsigned int      BufLen;                 /* ╗║│σ╟°│ñ╢╚     */
  74.    }Int7eArg;
  75.  
  76.    unsigned char        *DotBuf,*s,c;
  77.    int                  i,j,n;
  78.  
  79.    DotBuf=malloc(max(4096,((Fontx+7)/8*Fonty)*4));
  80.  
  81.    if (DotBuf == NULL) return FALSE;
  82.  
  83.    Int7eArg.Word[0]=ChineseCode[1];
  84.    Int7eArg.Word[1]=ChineseCode[0];             /* ║║╫╓▒α┬δ▒╪╨δ╡╣╥╗╧┬   */
  85.    Int7eArg.Font=Font;                          /* ╫╓┐Γ▒α║┼             */
  86.    Int7eArg.Fontx=Fontx;                        /* ║║╫╓┐φ╢╚             */
  87.    Int7eArg.Fonty=Fonty;                        /* ║║╫╓╕▀╢╚             */
  88.    Int7eArg.Top=0;                              /* ╞≡╩╝╧▀, 0▒φ╩╛╢Ñ╢╦    */
  89.    Int7eArg.Bot=Fonty-1;                        /* ╓╒╓╣╧▀, Fonty-1╬¬╬▓╢╦*/
  90.    Int7eArg.Attribute=1;                        /* ╩⌠╨╘=1, ▒φ╩╛╧╘╩╛╕±╩╜ */
  91.    Int7eArg.BufLen=((Fontx+7)/8*Fonty)*2 + 3*1024;
  92.                                                 /* ╗║│σ╟°┤≤╨í           */
  93.    regs.x.si=FP_OFF(&Int7eArg);
  94.    regs.x.di=FP_OFF(DotBuf);
  95.    sregs.ds=FP_SEG(&Int7eArg);
  96.    sregs.es=FP_SEG(DotBuf);
  97.  
  98.    int86x(0x7e,®s,®s,&sregs);
  99.  
  100.    s=DotBuf;
  101.    for (i=0;i<Fonty;i++){
  102.       for (j=0;j<Fontx;j++){
  103.          if (!(j % 8)){
  104.             c=*s++;
  105.             n=0x80;
  106.          }
  107.          if (c & n) SetPixel(x+j,y+i,FrColor);
  108.          else SetPixel(x+j,y+i,BgColor);
  109.          n>>=1;
  110.       }
  111.    }
  112. }
  113.  
  114. void main(void)
  115. {
  116.    if (!QueryModuleResident(0x1)) { /* RDPS╡──ú┐Θ║┼╬¬1 */
  117.       printf("RDPS not in memory!\n");
  118.       exit(0);
  119.       }
  120.    SetDisplayMode(3);
  121.    if (!DispChinese(220,110,15,1,"░í",0,200,260)){
  122.       printf("─┌┤µ▓╗╣╗\n\7");
  123.    }
  124.    getch();
  125.    SetDisplayMode(3);
  126. }
  127.