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

  1. /* ╓≈╠Γú║16X16╡π╒≤╫╓┐Γú¼UCDOS─ú┐Θ╩╢▒≡ */
  2. /*
  3.    1    IsUcdosResident       UCDOS╫ñ┴⌠─┌┤µ     AX=DB00H,INT 2FH
  4.    2    QueryModuleResident   ▓Θ╤»─ú┐Θ╩╟╖±░▓╫░  AH=01H  ,INT 79H
  5.    3    ReadDot               ╢┴UCDOS╧╘╩╛╫╓┐Γ            INT 7FH
  6. */
  7.  
  8. #include                <dos.h>
  9. #include                <stdio.h>
  10.  
  11. int IsUcdosResident(void)
  12. {
  13.    union REGS regs;
  14.  
  15.    regs.x.ax = 0xdb00;
  16.    int86(0x2f,®s,®s);
  17.    return regs.x.bx == 0x5450;
  18. }
  19.  
  20. int QueryModuleResident(int ModuleNo)
  21. {
  22.    union REGS regs;
  23.  
  24.    if (!IsUcdosResident()) return 0;
  25.    regs.h.ah = 0;
  26.    regs.h.al = ModuleNo;
  27.    int86(0x79,®s,®s);
  28.    return regs.x.flags & 0x40 ? 1 : 0;
  29. }
  30.  
  31. void ReadDot(char *ChineseCode,char *DotBuf)
  32. {
  33.    union REGS           regs;
  34.  
  35.    regs.h.dh=ChineseCode[0];
  36.    regs.h.dl=ChineseCode[1];
  37.  
  38.    int86(0x7f,®s,®s);                     /* ╖╡╗╪ DX:0 ╬¬╫╓┐Γ─┌╚▌╡╪╓╖ */
  39.    movedata(regs.x.dx, 0, FP_SEG(DotBuf), FP_OFF(DotBuf), 32);
  40. }
  41.  
  42. void SetDisplayMode(int Mode)
  43. {
  44.    union REGS regs;
  45.  
  46.    regs.h.ah = 0;
  47.    regs.h.al = Mode;
  48.    int86(0x10,®s,®s);
  49. }
  50.  
  51. void SetPixel(int Col,int Row,int Color)
  52. {
  53.    union REGS regs;
  54.  
  55.    regs.h.ah = 0xc;
  56.    regs.h.al = Color;
  57.    regs.x.cx = Col;
  58.    regs.x.dx = Row;
  59.    int86(0x10,®s,®s);
  60. }
  61.  
  62. /******************************************************************************
  63.     ▓╬╩²╦╡├≈:   x,y             ╧╘╩╛║║╫╓╡─╫≤╔╧╜╟╫°▒Ω
  64.                 FrColor         ╧╘╩╛║║╫╓╡─╟░╛░╔½
  65.                 BgColor         ╧╘╩╛║║╫╓╡─▒│╛░╔½
  66.                 ChineseCode     ╙√╧╘╩╛╡─║║╫╓
  67. ******************************************************************************/
  68. void DispChinese(int x,int y,int FrColor,int BgColor,char *ChineseCode)
  69. {
  70.    unsigned char        DotBuf[32],c;
  71.    int                  i,j;
  72.  
  73.    ReadDot(ChineseCode,DotBuf);
  74.  
  75.    for (i=0;i<16;i++){
  76.       c=DotBuf[i*2];
  77.       for (j=0;j<8;j++){
  78.          if (c & 0x80) SetPixel(x+j,y+i,FrColor);
  79.          else SetPixel(x+j,y+i,BgColor);
  80.          c=c<<1;
  81.       }
  82.  
  83.       c=DotBuf[i*2+1];
  84.       for (j=0;j<8;j++){
  85.          if (c & 0x80) SetPixel(x+j+8,y+i,FrColor);
  86.          else SetPixel(x+j+8,y+i,BgColor);
  87.          c=c<<1;
  88.       }
  89.    }
  90. }
  91.  
  92. void main(void)
  93. {
  94.  
  95.    if (!QueryModuleResident(0x00)) { /* 0x00 ╩╟RD16╡──ú┐Θ║┼ */
  96.       printf("Rd16 not in memory!\n");
  97.       exit();
  98.       }
  99.    SetDisplayMode(3);
  100.    DispChinese(120,120,15,1,"╧ú");
  101.    DispChinese(160,120,15,1,"═√");
  102.    getch();
  103.    SetDisplayMode(3);
  104. }
  105.