home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / volume_3.zip / BIOS10.CPP next >
Text File  |  1995-10-19  |  10KB  |  480 lines

  1. #ifndef __BIOS10_
  2.     #include "C:\tc\bios10.h"
  3. #endif
  4. //////////////////////////////////////////////////////////////////////////////
  5. //////////////////////////////////////////////////////////////////////////////
  6. int Get_Tick(void)
  7. {
  8. // this function uses the internal time keeper timer i.e. the one that goes
  9. // at 18.2 clicks/sec.  You can find a 32 bit value of
  10. // this timer at 0000:046Ch
  11. unsigned int far *clock = (unsigned int far *)0x0000046CL;
  12. unsigned int now;
  13. // get current time
  14. now = abs(*clock);
  15. return now;
  16. }
  17.  
  18.  
  19.  
  20. // disolve the screen...in one line I might add!
  21. void Desolve_256(void)
  22. {
  23. for (long index=0; index<=300000; index++,Plot_Pixel_Fast(rand()%320, rand()%200, 0));
  24. return;
  25. } // end Desolve_PCX_256
  26.  
  27.  
  28. void Plot_Pixel_Fast(int x,int y,unsigned char color)
  29. {
  30.  
  31. // plots the pixel in the desired color a little quicker using binary shifting
  32. // to accomplish the multiplications
  33.  
  34. // use the fact that 320*y = 256*y + 64*y = y<<8 + y<<6
  35.  
  36. video_buffer[((y<<8) + (y<<6)) + x] = color;
  37.  
  38. } // end Plot_Pixel_Fast
  39.  
  40.  
  41. /*******************************************************
  42. Function: void Write_Char_Page2(char chr,int page,int num)
  43. INT 10 AH= 0x0A or 0x10
  44. Description:
  45. *******************************************************/
  46. void Write_Char_Page2(char chr,int page,int num)
  47. {
  48.    union REGS regs;
  49.    regs.h.ah = 0x0A;
  50.    regs.h.bh = page;
  51.    regs.h.al = chr;
  52.    regs.x.cx = num;
  53.    int86(0x10, ®s, ®s);
  54. return;
  55. }
  56. /* ******************************************************
  57. Function: void Write_Char_Page(char chr,int page,int num,int color)
  58. INT 10 ah = 0x09
  59. Description:Attribute set,Cursor not moved,Control characters
  60.         not processed
  61. ****************************************************** */
  62. void Write_Char_Page(char chr,int page,int num,int color)
  63. {
  64.    union REGS regs;
  65.    regs.h.ah = 0x09;
  66.    regs.h.bh = page;
  67.    regs.h.bl = color;
  68.    regs.h.al = chr;
  69.    regs.x.cx = num;
  70.    int86(0x10, ®s, ®s);
  71. return;
  72. }
  73.  
  74.  
  75. /*******************************************************
  76. Function: void Write_Teletype(char ch,int color,int page)
  77. INT 10 AH = 0x0E or 0x14
  78. Description:
  79. *******************************************************/
  80. void Write_Teletype(char ch,int color,int page)
  81. {
  82.    union REGS regs;
  83.    regs.h.ah = 0x0E;
  84.    regs.h.al = ch;
  85.    regs.h.bh = page;
  86.    regs.h.bl = color;
  87.    int86(0x10, ®s, ®s);
  88. return;
  89. }
  90. //Same as above but accepts ASCII value
  91. void Write_Teletype(int ch,int color,int page)
  92. {
  93.    union REGS regs;
  94.    regs.h.ah = 0x0E;
  95.    regs.h.al = ch;
  96.    regs.h.bh = page;
  97.    regs.h.bl = color;
  98.    int86(0x10, ®s, ®s);
  99. return;
  100. }
  101. //Same as above but gets current page twice as slow
  102. void Write_Teletype(char ch,int color)
  103. {
  104.    union REGS regs;
  105.    regs.h.ah = 0x0E;
  106.    regs.h.al = ch;
  107.    regs.h.bh = Get_Current_Page();
  108.    regs.h.bh = color;
  109.    int86(0x10, ®s, ®s);
  110. return;
  111. }
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120. int Read_Pixel(int X,int Y,int page)
  121. {
  122.    union REGS regs;
  123.    regs.h.ah = 0x0D;
  124.    regs.h.bh = page;
  125.    regs.x.cx = X;
  126.    regs.x.dx = Y;
  127.    int86(0x10, ®s, ®s);
  128. return regs.h.al;
  129. }
  130.  
  131.  
  132. int Read_Pixel(int X,int Y)
  133. {
  134.    union REGS regs;
  135.    regs.h.ah = 0x0D;
  136.    regs.h.bh = Get_Current_Page();
  137.    regs.x.cx = X;
  138.    regs.x.dx = Y;
  139.    int86(0x10, ®s, ®s);
  140. return regs.h.al;
  141. }
  142.  
  143.  
  144.  
  145. void Write_Pixel_XOR(int X,int Y,int color,int page)
  146. {
  147.  
  148.    union REGS regs;
  149.    regs.h.ah = 0x0C;
  150.    regs.h.al = color; //Bit 7 of color if true will XOR it, HOW?????
  151.    regs.h.bh = page;
  152.    regs.x.cx = X;
  153.    regs.x.dx = Y;
  154.    int86(0x10, ®s, ®s);
  155. return;
  156. }
  157.  
  158.  
  159. void Write_Pixel2(int X,int Y,int color)
  160. {
  161.    union REGS regs;
  162.    regs.h.ah = 0x0C;
  163.    regs.h.al = color;
  164.    regs.h.bh = 0;
  165.    regs.x.cx = X;
  166.    regs.x.dx = Y;
  167.    int86(0x10, ®s, ®s);
  168. return;
  169. }
  170.  
  171.  
  172.  
  173. void Write_Pixel(int X,int Y,int color,int page)
  174. {
  175.    union REGS regs;
  176.    regs.h.ah = 0x0C;
  177.    regs.h.al = color;
  178.    regs.h.bh = page;
  179.    regs.x.cx = X;
  180.    regs.x.dx = Y;
  181.    int86(0x10, ®s, ®s);
  182. return;
  183. }
  184.  
  185.  
  186. void Write_Pixel(int X,int Y,int color)
  187. {
  188.    union REGS regs;
  189.    regs.h.ah = 0x0C;
  190.    regs.h.al = color;
  191.    regs.h.bh = Get_Current_Page();
  192.    regs.x.cx = X;
  193.    regs.x.dx = Y;
  194.    int86(0x10, ®s, ®s);
  195. return;
  196. }
  197.  
  198. void Write_Pixel(int X,int Y)
  199. {
  200.    union REGS regs;
  201.    regs.h.ah = 0x0C;
  202.    regs.h.bh = Get_Current_Page();
  203.    regs.x.cx = X;
  204.    regs.x.dx = Y;
  205.    int86(0x10, ®s, ®s);
  206. return;
  207. }
  208.  
  209.  
  210.  
  211. void Border_Color(int color)
  212. {
  213.    union REGS regs;
  214.    regs.h.ah = 0x0B;
  215.    regs.h.bl = color;
  216.    regs.h.bh = 0x00;
  217.    int86(0x10, ®s, ®s);
  218. return;
  219. }
  220.  
  221. char Read_Char_Page(int *attribute,int page)
  222. {
  223.    union REGS regs;
  224.    regs.h.ah = 0x08;
  225.    regs.h.bh = page;
  226.    int86(0x10, ®s, ®s);
  227.    *attribute = regs.h.al;
  228. return regs.h.al;
  229. }
  230.  
  231. char Read_Char(int *attribute)
  232. {
  233.    union REGS regs;
  234.    regs.h.ah = 0x08;
  235.    regs.h.bh = Get_Current_Page();
  236.    int86(0x10, ®s, ®s);
  237.    *attribute = regs.h.al;
  238. return regs.h.al;
  239. }
  240.  
  241.  
  242.  
  243.  
  244.  
  245. /*******************************************************
  246. Function: void Select_Page(int page)
  247.  
  248. Description:
  249. *******************************************************/
  250. void Select_Page(int page)
  251. {
  252.    union REGS regs;
  253.    regs.h.ah = 0x05;
  254.    regs.h.al = page;
  255.    int86(0x10, ®s, ®s);
  256. return;
  257. }
  258.  
  259.  
  260.  
  261.  
  262. /*******************************************************
  263. Function: unsigned int Get_Current_Mode_Col(void)
  264.  
  265. Description:
  266. *******************************************************/
  267. unsigned int Get_Current_Mode_Col(void)
  268. {
  269.    union REGS regs;
  270.    regs.h.ah = 0x0F;
  271.    int86(0x10, ®s, ®s);
  272. return  regs.h.al;
  273. }
  274.  
  275.  
  276.  
  277.  
  278.  
  279. /*******************************************************
  280. Function: unsigned int Get_Current_Page(void)
  281.  
  282. Description: Returns Current Page
  283. *******************************************************/
  284. unsigned int Get_Current_Page(void)
  285. {
  286.    union REGS regs;
  287.    regs.h.ah = 0x0F;
  288.    int86(0x10, ®s, ®s);
  289. return regs.h.bh;
  290. }
  291.  
  292.  
  293. /*******************************************************
  294. Function: void Get_CursorXY(int page,int *X,int *Y)
  295.  
  296. Description: Gets X&Y Location
  297. *******************************************************/
  298. void Get_CursorXY(int page,int *X,int *Y)
  299. {
  300.    union REGS regs;
  301.    regs.h.ah = 0x03;
  302.    regs.h.bh = page;
  303.    int86(0x10, ®s, ®s);
  304.    *X = regs.h.dl;
  305.    *Y = regs.h.dh;
  306. return;
  307. }
  308. int  Get_CursorY(int page)
  309. {
  310.    union REGS regs;
  311.    regs.h.ah = 0x03;
  312.    regs.h.bh = page;
  313.    int86(0x10, ®s, ®s);
  314. return regs.h.dh;
  315. }
  316. int Get_CursorX(int page)
  317. {
  318.    union REGS regs;
  319.    regs.h.ah = 0x03;
  320.    regs.h.bh = page;
  321.    int86(0x10, ®s, ®s);
  322. return regs.h.dl;
  323. }
  324.  
  325.  
  326.  
  327. /*******************************************************
  328. Function: void Get_Cursor_Type(int *cl,int *ch,int page)
  329.  
  330. Description:
  331. *******************************************************/
  332. void Get_Cursor_Type(int *cl,int *ch,int page)
  333. {
  334.    union REGS regs;
  335.    regs.h.ah = 0x03;
  336.    regs.h.bh = page;
  337.    int86(0x10, ®s, ®s);
  338.    *cl = regs.h.ch;
  339.    *ch = regs.h.cl;
  340. return;
  341. }
  342.  
  343.  
  344.  
  345. /*******************************************************
  346. Function: void Move_Cursor(int X,int Y,int page)
  347.  
  348. Description:
  349. *******************************************************/
  350. void Move_Cursor(int X,int Y,int page)
  351. {
  352.    union REGS regs;
  353.    regs.h.ah = 0x02;
  354.    regs.h.dl = X ;
  355.    regs.h.dh = Y ;
  356.    regs.h.bh = page;
  357.    int86(0x10, ®s, ®s);
  358. return;
  359. }
  360. void Move_Cursor(int X,int Y)
  361. {
  362.    union REGS regs;
  363.    regs.h.ah = 0x02;
  364.    regs.h.dl = X ;
  365.    regs.h.dh = Y ;
  366.    regs.h.bh = Get_Current_Page();
  367.    int86(0x10, ®s, ®s);
  368. return;
  369. }
  370. void Cursor_Home(void)
  371. {
  372.    union REGS regs;
  373.    regs.h.ah = 0x02;
  374.    regs.h.dl = 0 ;
  375.    regs.h.dh = 0 ;
  376.    regs.h.bh = 0;
  377.    int86(0x10, ®s, ®s);
  378. return;
  379. }
  380.  
  381.  
  382.  
  383.  
  384. /*******************************************************
  385. Function: void Set_Cursor(int cl,int ch)
  386.  
  387. Description: Changes Cursor
  388. *******************************************************/
  389. void Set_Cursor(int cl,int ch)
  390. {
  391.    union REGS regs;
  392.    regs.h.ah = 0x01;
  393.    regs.h.ch = ch;
  394.    regs.h.cl = cl;
  395.    int86(0x10, ®s, ®s);
  396. return;
  397. }
  398. void BLOCK_Cursor(void)
  399. {
  400.    union REGS regs;
  401.    regs.h.ah = 0x01;
  402.    regs.h.ch = 0;
  403.    regs.h.cl = 7;
  404.  
  405.    int86(0x10, ®s, ®s);
  406. return;
  407. }
  408. void NORMAL_Cursor(void)
  409. {
  410.    union REGS regs;
  411.    regs.h.ah = 0x01;
  412.    regs.h.ch = 6;
  413.    regs.h.cl = 6;
  414.    int86(0x10, ®s, ®s);
  415. return;
  416. }
  417. void HIDDEN_Cursor(void)
  418. {
  419.    union REGS regs;
  420.    regs.h.ah = 0x01;
  421.    regs.h.ch = 20;
  422.    regs.h.cl = 0;
  423.    int86(0x10, ®s, ®s);
  424. return;
  425. }
  426.  
  427.  
  428.  
  429. /*******************************************************
  430. Function: void Set_Mode(int mode)
  431.  
  432. Description: Changes Video Mode
  433. *******************************************************/
  434. void Set_Mode(int mode)
  435. //INT 10H AH = 00h Set Video Mode
  436. {
  437.    union REGS regs;
  438.    regs.h.ah = 0x00;
  439.    regs.h.al = (unsigned char)mode;
  440.    int86(0x10, ®s, ®s);
  441. return;  //Returns 0 if valid
  442. }
  443. void VGA13_Mode(void)
  444. {
  445.    union REGS regs;
  446.    regs.h.ah = 0x00;
  447.    regs.h.al = 13;
  448.    int86(0x10, ®s, ®s);
  449. return;
  450. }
  451. void TEXT_Mode(void)
  452. {
  453.    union REGS regs;
  454.    regs.h.ah = 0x00;
  455.    regs.h.al = 3;
  456.    int86(0x10, ®s, ®s);
  457. return;
  458. }
  459.  
  460.  
  461.  
  462.  
  463.  
  464. /*******************************************************
  465. Function: unsigned int Get_Current_Mode(void)
  466.  
  467. Description:
  468. *******************************************************/
  469. unsigned int Get_Current_Mode(void)
  470. {
  471.    union REGS regs;
  472.    regs.h.ah = 0x0F;
  473.    int86(0x10, ®s, ®s);
  474. return  regs.h.al;
  475. }
  476.  
  477.  
  478.  
  479.  
  480.