Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. void vr_synch(void) {
  2.  
  3. asm mov dx,3DAh;
  4.  
  5. vr1:
  6.  
  7. asm in al,dx;
  8. asm test al,8;
  9. asm jne vr1;
  10.  
  11. vr2:
  12.  
  13. asm in al,dx;
  14. asm test al,8;
  15. asm je vr2;
  16.  
  17. }
  18. void mcga(void) {
  19. asm {
  20. mov ax, 13h // load the mode to the ax register
  21. int 10h // interupt 10h
  22. }
  23. }
  24.  
  25.  
  26. long i(int x, int y) {
  27. return ((y * 320) + x);
  28. }
  29.  
  30. void putpixel(int x_coordinate, int y_coordinate, char color) {
  31.  
  32. asm mov ax,0a000h;
  33. asm mov es,ax;
  34. asm mov di,[y_coordinate];
  35. asm mov ax,[y_coordinate];
  36. asm shl di,8;
  37. asm shl ax,6;
  38. asm add di,ax;
  39. asm add di,[x_coordinate];
  40. asm xor ax,ax;
  41. asm mov al,[color];
  42. asm mov [es:di],al;
  43.  
  44. }
  45.  
  46. void drawscreen(char *sbuffer) {
  47. vr_synch();
  48. for (int y = 0; y < 200; y++)
  49. for (int x = 0; x < 320; x++)
  50. putpixel(x, y, sbuffer[(y * 200) + x]);
  51. }
  52.  
  53.  
  54. void setpal(char r, char g, char b, char location) {
  55.  
  56. asm push dx; // save dx
  57. asm mov dx,3c8h; // 3c8h is the setting of the number
  58. // (0-255) in which the color will
  59. // be held in the pallette
  60. asm mov al,[location]; // move the pallette location into al
  61. asm out dx,al; // output al to dx (3c8h)
  62. asm inc dx; // increase dx to become 3c9h. This
  63. // is the setting that controls the
  64. // RGB values of the pallette number
  65. asm mov al,r; // move red value to al
  66. asm out dx,al; // output al to dx, setting the red value
  67. asm mov al,g; // move green value to al
  68. asm out dx,al; // output al to dx, setting the green value
  69. asm mov al,b; // move blue value to al
  70. asm out dx,al; // output al to dx, settign the blue value
  71. // wh00p, all done!
  72. asm pop dx; // put back dx
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement