Advertisement
Guest User

111

a guest
Apr 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #include <DOS.H>
  2. #include <conio.h>
  3. #include <stdio.h>
  4. #include <emurtk.h>
  5. #include <time.h>
  6.  
  7. unsigned char SNS0, SNS1, SNS2;
  8. int SN[18], SNB[18], a, d, z = 0, x = 0, y = 0;
  9. char DRV[3];
  10. unsigned char inputD()
  11. {
  12. unsigned char data = 0;
  13. outportb(0x37A, 0x2E);
  14. outportb(0x378, 0xFF);
  15. outportb(0x37A, 0x2F);
  16. delay(1);
  17. data = inportb(0x378);
  18. outportb(0x37A, 0x04);
  19. return data;
  20. }
  21. void writeRC(char data)
  22. {
  23. outportb(0x37A, 0x04);
  24. outportb(0x378, data);
  25. outportb(0x37A, 0x00);
  26. delay(1);
  27. outportb(0x37A, 0x04);
  28. }
  29. void writeRA(char data)
  30. {
  31. outportb(0x37A, 0x0E);
  32. outportb(0x378, data);
  33. outportb(0x37A, 0x0A);
  34. delay(1);
  35. outportb(0x37A, 0x0E);
  36. }
  37. void RS()
  38. {
  39. writeRC(0x13);
  40. SNS0 = inputD();
  41. SNS1 = inputD();
  42. SNS2 = inputD();
  43. int SNS[3] = { SNS0 ,SNS1 ,SNS2 };
  44. int u = 0, i, j;
  45. for (i = 0; i<3; i++) {
  46. for (j = 0; j<6; j++) {
  47. SN[u] = (SNS[i] + 1) % 2;
  48. SNS[i] /= 2;
  49. u++;
  50. }
  51. }
  52. }
  53. void Doit(char DRV)
  54. {
  55. writeRC(0x11);
  56. writeRA(0x80);
  57. writeRA(DRV);
  58. }
  59. void Stop()
  60. {
  61. writeRC(0x11);
  62. writeRA(0x00);
  63. writeRA(0x00);
  64. }
  65.  
  66. void calibration()
  67. {
  68. while (!kbhit()) {
  69. if ((SN[0] != 1) && (SN[3] != 1) && (SN[6] != 1)) {
  70. Doit(0x15);
  71.  
  72. }if ((SN[0] != 0) && (SN[3] != 1) && (SN[6] != 1)) {
  73. Doit(0x14);
  74.  
  75. }if ((SN[0] != 1) && (SN[3] != 0) && (SN[6] != 1)) {
  76. Doit(0x11);
  77.  
  78. }if ((SN[0] != 1) && (SN[3] != 1) && (SN[6] != 0)) {
  79. Doit(0x05);
  80.  
  81. }if ((SN[0] != 0) && (SN[3] != 0) && (SN[6] != 1)) {
  82. Doit(0x10);
  83.  
  84. }if ((SN[0] != 0) && (SN[3] != 1) && (SN[6] != 0)) {
  85. Doit(0x04);
  86.  
  87. }if ((SN[0] != 0) && (SN[3] != 1) && (SN[6] != 0)) {
  88. Doit(0x01);
  89. }
  90. }
  91. }
  92.  
  93. int main()
  94. {
  95.  
  96.  
  97. RS();
  98. printf("na4alo");
  99. calibration();
  100. printf("\nSN[0]=%d, SN[3]=%d, SN[6]=%d\n", SN[0], SN[3], SN[6]);
  101. printf("vipolneno");
  102. return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement