home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / sound / nh10src / vr.c < prev   
Encoding:
C/C++ Source or Header  |  1991-12-15  |  2.5 KB  |  79 lines

  1. #include <mem.h>
  2. #include <dos.h>
  3.  
  4. unsigned fontblock[0x1000];
  5. unsigned buffer[0x1000];
  6.  
  7. main()
  8. {
  9.    vid_plane_read(fontblock, 2, 0x1000);
  10.    vid_plane_write(fontblock, 4, 0x1000);
  11.    return;
  12. }
  13.  
  14.  
  15.  
  16. //┌───────────────────────────────────────────────────────────────────────┐//
  17. //│ Saves font block 0 directly from plane 2, EGA/VGA only                │//
  18. //│ Reference: Programmer Guide to EGA/VGA page 357+                      │//
  19. //└───────────────────────────────────────────────────────────────────────┘//
  20. vid_plane_read(unsigned near *chunk, char plane, unsigned size)
  21. {
  22.      outp (0x3ce, 4);    // Read Map Register (index 5)
  23.    outp (0x3cf, plane);    // read from plane 2
  24.  
  25.      outp (0x3ce, 5);    // Mode Register (index 5)
  26.      outp (0x3cf, 0);    // disable O/E bit 4 for sequential addressing
  27.  
  28.      outp (0x3c4, 4);    // Memory Mode (index 4)
  29.      outp (0x3c5, 6);    // enable O/E bit 2 for sequential addressing
  30.  
  31.    movedata (0xb800, 0, _DS, (unsigned)chunk, size);
  32.  
  33.      outp (0x3c4, 4);    // Memory Mode (index 4)
  34.      outp (0x3c5, 2);    // disable O/E Bit 2 for sequential addressing
  35.  
  36.      outp (0x3ce, 5);    // Mode Register (index 5)
  37.      outp (0x3cf, 16);   // enable O/E bit 4 for sequential addressing
  38.  
  39.      outp (0x3ce, 4);    // Read Map Register (index 5)
  40.      outp (0x3cf, 0);    // read from plane 0 (default)
  41.  
  42.    return;
  43. }
  44.  
  45.  
  46.  
  47. //┌───────────────────────────────────────────────────────────────────────┐//
  48. //│ Saves font block 0 directly from plane 2, EGA/VGA only                │//
  49. //│ Reference: Programmer Guide to EGA/VGA page 357+                      │//
  50. //└───────────────────────────────────────────────────────────────────────┘//
  51. vid_plane_write(unsigned near *chunk, char mask, unsigned size)
  52. {
  53.  
  54.      outp (0x3c4, 4);    // Memory Mode (index 4)
  55.      outp (0x3c5, 6);    // enable O/E Bit for sequential addressing
  56.  
  57.      outp (0x3ce, 5);    // Mode Ragister (index 5)
  58.      outp (0x3cf, 0);    // disable O/E bit for sequential addressing
  59.  
  60.      outp (0x3c4, 2);    // Map mask for write mode 0 (index 2)
  61.    outp (0x3c5, mask); // Plane mask, 4 = 0100 = plane 2
  62.  
  63.    movedata (_DS, (unsigned)chunk, 0xb800, 0, size);
  64.  
  65.      outp (0x3c4, 4);    // Memory Mode (index 4)
  66.      outp (0x3c5, 2);    // disable O/E Bit for odd/even addressing
  67.  
  68.      outp (0x3ce, 5);    // Mode Ragister (index 5)
  69.      outp (0x3cf, 16);    // disable O/E bit for sequential addressing
  70.  
  71.      outp (0x3c4, 2);    // Map mask for write mode 0 (index 2)
  72.      outp (0x3c5, 3);    // Plane mask, 3 = 0011 = planes 0 and 1
  73.  
  74.     return;
  75. }
  76.  
  77.  
  78.  
  79.