home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Examples / DriverKit / S3_IOVPCode / setVGAMode3.vp < prev    next >
Encoding:
Text File  |  1993-08-28  |  3.0 KB  |  119 lines

  1. // Copyright (c) 1993 NeXT Computer, Inc.  All rights reserved. 
  2. //
  3. // setVGAMode3.vp - Set the VGA into mode 0x03.
  4. //
  5. // HISTORY
  6. //   29 July 1993    Derek B Clegg
  7. //    Created.
  8. //
  9. //
  10.  
  11. // Parameters for VGA mode 0x03.
  12.  
  13.     .data
  14. vgaMiscOutput:
  15.     .word    0x67
  16. vgaFeatureControl:
  17.     .word    0x00
  18. vgaSequencer:
  19.     .word    0x01, 0x00, 0x03, 0x00, 0x02
  20. vgaCrtcParameters:
  21.     .word    0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, 0x00, 0x4f
  22.     .word    0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28
  23.     .word    0x1f, 0x96, 0xb9, 0xa3, 0xff
  24. vgaAttrParameters:
  25.     .word    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39
  26.     .word    0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x0c, 0x00, 0x0f, 0x08
  27. vgaGrfxParameters:
  28.     .word    0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff
  29.  
  30. // NOTE: The attribute registers are a little weird. For most registers,
  31. // there is a separate index and data port. The attribute register set
  32. // has just one port that gets used for both. You write an index to the 
  33. // port, then use the same port for data. The VGA automatically toggles
  34. // the sense of the port (between index and data) with an internal
  35. // flip-flop.  You set the state of the flip-flop by doing an inb() on
  36. // the input status 1 port.
  37. //
  38. // The other weird thing is that the attribute index register also
  39. // contains a palette access bit. This bit determines whether the
  40. // CPU or the VGA has control of the palette. While the CPU owns the
  41. // palette, the display is effectively off.
  42.  
  43.     .text
  44. vgaSetMode3:
  45.     // Turn the video off while we are doing this....
  46.  
  47.     // Set the attribute flip-flop to "index", and give the palette to
  48.     // the CPU, turning off video.
  49.     inb    VGA_INPUT_STATUS_1, r0
  50.     outb    VGA_ATTR_INDEX, 0x00
  51.  
  52.     // Set the misc. output register.
  53.     load    @vgaMiscOutput, r0
  54.     outb    VGA_MISC_OUTPUT, r0
  55.     
  56.     // Set the feature control register.
  57.     load    @vgaFeatureControl, r0
  58.     outb    VGA_FEATURE_CTRL, r0
  59.  
  60.     // Load the sequencer registers.
  61.     load    vgaSequencer, r0
  62.     load    0, r1
  63. 0:    load    @r0, r2
  64.     outx    VGA_SEQ_INDEX, r1, r2
  65.     add    1, r0, r0
  66.     add    1, r1, r1
  67.     cmp    r1, VGA_SEQ_COUNT
  68.     blt    0b
  69.  
  70.     // Reset the sequencer.  Low order two bits are reset bits.
  71.     outx    VGA_SEQ_INDEX, 0x00, 0x03
  72.  
  73.     // Load the CRTC registers.  CRTC registers 0-7 are locked by a bit
  74.     // in register 0x11. We need to unlock these registers before we can
  75.     // start setting them.
  76.  
  77.     outx    VGA_CRTC_INDEX, 0x11, 0x00    // Unlocks registers 0-7.
  78.  
  79.     load    vgaCrtcParameters, r0
  80.     load    0, r1
  81. 0:    load    @r0, r2
  82.     outx    VGA_CRTC_INDEX, r1, r2
  83.     add    1, r0, r0
  84.     add    1, r1, r1
  85.     cmp    r1, VGA_CRTC_COUNT
  86.     blt    0b
  87.  
  88.     // Load the attribute registers.
  89.  
  90.     // Set the attribute flip-flop to "index".
  91.     inb    VGA_INPUT_STATUS_1, r0
  92.  
  93.     load    vgaAttrParameters, r0
  94.     load    0, r1
  95. 0:    load    @r0, r2
  96.     outb    VGA_ATTR_INDEX, r1
  97.     outb    VGA_ATTR_DATA, r2
  98.     add    1, r0, r0
  99.     add    1, r1, r1
  100.     cmp    r1, VGA_ATTR_COUNT
  101.     blt    0b
  102.  
  103.     load    vgaGrfxParameters, r0
  104.     load    0, r1
  105. 0:    load    @r0, r2
  106.     outx    VGA_GRFX_INDEX, r1, r2
  107.     add    1, r0, r0
  108.     add    1, r1, r1
  109.     cmp    r1, VGA_GRFX_COUNT
  110.     blt    0b
  111.  
  112.     // Re-enable video.
  113.  
  114.     // Set the attribute flip-flop to "index", and give the palette
  115.     // back to the VGA.
  116.     inb    VGA_INPUT_STATUS_1, r0
  117.     outb    VGA_ATTR_INDEX, 0x20
  118.     return
  119.