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

  1. /* ╓≈╠Γú║╣Γ▒Ω┐╪╓╞ */
  2. /*
  3.    1    SetCursorShape      ╔Φ╓├╣Γ▒Ω╨╬╫┤        AH=01H
  4.    2    GotoXY              ╔Φ╓├╣Γ▒Ω╬╗╓├        AH=02H
  5.    3    SaveCursor          ╢┴╣Γ▒Ω╬╗╓├/╨╬╫┤     AH=03H
  6.    4    EnableCursor        ╘╩╨φ╣Γ▒Ω╧╘╩╛        AX=FF01H,BL=01H
  7.    5    DisableCursor       ╜√╓╣╣Γ▒Ω╧╘╩╛        ..
  8.    6    GetCursorStatus     ╢┴╣Γ▒Ω╩╟╖±╘╩╨φ      AX=FF01H,BL=11H
  9.    7    EnableGraphCursor   ╘╩╨φ═╝╨╬─ú╩╜╣Γ▒Ω    AX=FF01H,BL=02H
  10.    8    DisableGraphCursor  ╜√╓╣═╝╨╬─ú╩╜╣Γ▒Ω    ..
  11.    9    GetCursorBlinkTime  ╢┴╣Γ▒Ω╔┴╦╕╦┘┬╩      AX=FF01H,BL=10H
  12.   10    SetCursorBlinkTime  ╓├╣Γ▒Ω╔┴╦╕╦┘┬╩      AX=FF01H,BL=00H
  13. */
  14. #include                "dos.h"
  15. #include                "stdio.h"
  16.  
  17. typedef                 unsigned char   BYTE;
  18. typedef                 unsigned int    WORD;
  19.  
  20. void SetCursorShape(int FirstLine,int LastLine)
  21. {
  22.    union REGS regs;
  23.  
  24.    regs.h.ah = 1;
  25.    regs.h.ch = FirstLine;
  26.    regs.h.cl = LastLine;
  27.    int86(0x10,®s,®s);
  28.  
  29. }
  30.  
  31. void GotoXY(int Row,int Col)
  32. {
  33.    union REGS regs;
  34.  
  35.    regs.h.ah = 2;
  36.    regs.h.bh = 0;
  37.    regs.h.dh = Row;
  38.    regs.h.dl = Col;
  39.    int86(0x10,®s,®s);
  40. }
  41.  
  42. void SaveCursor(int * Row, int * Col, int * FirstLine, int * LastLine)
  43. {
  44.    union REGS regs;
  45.  
  46.    regs.h.ah = 3;
  47.    int86(0x10,®s,®s);
  48.    *Row = (int)regs.h.dh;
  49.    *Col = (int)regs.h.dl;
  50.    *FirstLine = (int)regs.h.ch;
  51.    *LastLine = (int)regs.h.cl;
  52. }
  53.  
  54. void EnableCursor(void)
  55. {
  56.    union REGS regs;
  57.  
  58.    regs.x.ax = 0xff01;
  59.    regs.h.bl = 1;
  60.    regs.h.bh = 1;
  61.    int86(0x10,®s,®s);
  62. }
  63.  
  64. void DisableCursor(void)
  65. {
  66.    union REGS regs;
  67.  
  68.    regs.x.ax = 0xff01;
  69.    regs.h.bl = 1;
  70.    regs.h.bh = 0;
  71.    int86(0x10,®s,®s);
  72. }
  73.  
  74. int GetCursorStatus(void)
  75. {
  76.    union REGS regs;
  77.  
  78.    regs.x.ax = 0xff01;
  79.    regs.h.bl = 0x11;
  80.    int86(0x10,®s,®s);
  81.    return regs.h.al;
  82. }
  83.  
  84. void EnableGraphCursor(void)
  85. {
  86.    union REGS regs;
  87.  
  88.    regs.x.ax = 0xff01;
  89.    regs.h.bl = 2;
  90.    regs.h.bh = 1;
  91.    int86(0x10,®s,®s);
  92. }
  93.  
  94. void DisableGraphCursor(void)
  95. {
  96.    union REGS regs;
  97.  
  98.    regs.x.ax = 0xff01;
  99.    regs.h.bl = 2;
  100.    regs.h.bh = 0;
  101.    int86(0x10,®s,®s);
  102. }
  103.  
  104. int GetCursorBlinkTime(void)
  105. {
  106.    union REGS regs;
  107.  
  108.    regs.x.ax = 0xff01;
  109.    regs.h.bl = 0x10;
  110.    int86(0x10,®s,®s);
  111.    return regs.h.al;
  112. }
  113.  
  114. void SetCursorBlinkTime(int BlinkCount)
  115. {
  116.    union REGS regs;
  117.  
  118.    regs.x.ax = 0xff01;
  119.    regs.h.bl = 0x00;
  120.    regs.h.bh = BlinkCount;
  121.    int86(0x10,®s,®s);
  122. }
  123.  
  124. void SetDisplayMode(BYTE Mode)
  125. {
  126.    union REGS regs;
  127.  
  128.    regs.h.ah = 0;
  129.    regs.h.al = Mode;
  130.    int86(0x10,®s,®s);
  131. }
  132.  
  133. void main()
  134. {
  135.    int          SaveCursorEnable;
  136.    int          x,y,BeginLine,EndLine;
  137.    int          CurBlinkTime;
  138.    char         ch;
  139.  
  140.    SetDisplayMode(0x3);
  141.    GotoXY(2,0);
  142.    SaveCursorEnable = GetCursorStatus();
  143.    EnableCursor();
  144.    SetCursorShape(0x6,0x7);
  145.    printf("╣Γ▒Ω┤ª╙┌╘╩╨φ╫┤╠¼ú¼░┤╚╬╥Γ╝ⁿ╣╪▒╒╣Γ▒Ω\n");
  146.    getch();
  147.    DisableCursor();
  148.    printf("╣Γ▒Ω▒╗╣╪▒╒ú¼░┤╚╬╥Γ╝ⁿ┐¬╞⌠╣Γ▒Ω\n");
  149.    getch();
  150.    EnableCursor();
  151.    SaveCursor(&x,&y,&BeginLine,&EndLine);
  152.    printf("╣Γ▒Ω╞≡╩╝╔¿├Φ╧▀ = %d, ╜ß╩°╔¿├Φ╧▀ = %d\n",BeginLine,EndLine);
  153.    printf("░┤╚╬╥Γ╝ⁿ╔Φ╓├╣Γ▒Ω╬¬┤≤╣Γ▒Ω\n");
  154.    getch();
  155.    SetCursorShape(0x0,0x7);
  156.    printf("░┤╚╬╥Γ╝ⁿ╗╓╕┤╣Γ▒Ω╬¬╨í╣Γ▒Ω\n");
  157.    getch();
  158.    SetCursorShape(0x6,0x7);
  159.    SetCursorBlinkTime(8);
  160.    CurBlinkTime = GetCursorBlinkTime();
  161.    printf("╡▒╟░╣Γ▒Ω╔┴╦╕╦┘┬╩╬¬ %d,░┤╚╬╥Γ╝ⁿ╜√╓╣╣Γ▒Ω╔┴╦╕\n",CurBlinkTime);
  162.    getch();
  163.    SetCursorBlinkTime(0);
  164.    printf("░┤╚╬╥Γ╝ⁿ╜°╚δ═╝╨╬╖╜╩╜ú¼╔Φ╓├╣Γ▒Ω╬¬╘╩╨φ╫┤╠¼\n");
  165.    getch();
  166.    SetCursorBlinkTime(3);
  167.    SetDisplayMode(0x12);
  168.    EnableGraphCursor();
  169.    printf("░┤╚╬╥Γ╝ⁿ╜√╓╣╣Γ▒Ω╧╘╩╛\n");
  170.    getch();
  171.    DisableGraphCursor();
  172.    printf("░┤╚╬╥Γ╝ⁿ═╦│÷\n");
  173.    getch();
  174.    SetDisplayMode(0x3);
  175.    if (SaveCursorEnable == 0) DisableCursor();
  176. }
  177.