home *** CD-ROM | disk | FTP | other *** search
- // Copyright (c) 1993 NeXT Computer, Inc. All rights reserved.
- //
- // setVGAMode3.vp - Set the VGA into mode 0x03.
- //
- // HISTORY
- // 29 July 1993 Derek B Clegg
- // Created.
- //
- //
-
- // Parameters for VGA mode 0x03.
-
- .data
- vgaMiscOutput:
- .word 0x67
- vgaFeatureControl:
- .word 0x00
- vgaSequencer:
- .word 0x01, 0x00, 0x03, 0x00, 0x02
- vgaCrtcParameters:
- .word 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, 0x00, 0x4f
- .word 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28
- .word 0x1f, 0x96, 0xb9, 0xa3, 0xff
- vgaAttrParameters:
- .word 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39
- .word 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x0c, 0x00, 0x0f, 0x08
- vgaGrfxParameters:
- .word 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff
-
- // NOTE: The attribute registers are a little weird. For most registers,
- // there is a separate index and data port. The attribute register set
- // has just one port that gets used for both. You write an index to the
- // port, then use the same port for data. The VGA automatically toggles
- // the sense of the port (between index and data) with an internal
- // flip-flop. You set the state of the flip-flop by doing an inb() on
- // the input status 1 port.
- //
- // The other weird thing is that the attribute index register also
- // contains a palette access bit. This bit determines whether the
- // CPU or the VGA has control of the palette. While the CPU owns the
- // palette, the display is effectively off.
-
- .text
- vgaSetMode3:
- // Turn the video off while we are doing this....
-
- // Set the attribute flip-flop to "index", and give the palette to
- // the CPU, turning off video.
- inb VGA_INPUT_STATUS_1, r0
- outb VGA_ATTR_INDEX, 0x00
-
- // Set the misc. output register.
- load @vgaMiscOutput, r0
- outb VGA_MISC_OUTPUT, r0
-
- // Set the feature control register.
- load @vgaFeatureControl, r0
- outb VGA_FEATURE_CTRL, r0
-
- // Load the sequencer registers.
- load vgaSequencer, r0
- load 0, r1
- 0: load @r0, r2
- outx VGA_SEQ_INDEX, r1, r2
- add 1, r0, r0
- add 1, r1, r1
- cmp r1, VGA_SEQ_COUNT
- blt 0b
-
- // Reset the sequencer. Low order two bits are reset bits.
- outx VGA_SEQ_INDEX, 0x00, 0x03
-
- // Load the CRTC registers. CRTC registers 0-7 are locked by a bit
- // in register 0x11. We need to unlock these registers before we can
- // start setting them.
-
- outx VGA_CRTC_INDEX, 0x11, 0x00 // Unlocks registers 0-7.
-
- load vgaCrtcParameters, r0
- load 0, r1
- 0: load @r0, r2
- outx VGA_CRTC_INDEX, r1, r2
- add 1, r0, r0
- add 1, r1, r1
- cmp r1, VGA_CRTC_COUNT
- blt 0b
-
- // Load the attribute registers.
-
- // Set the attribute flip-flop to "index".
- inb VGA_INPUT_STATUS_1, r0
-
- load vgaAttrParameters, r0
- load 0, r1
- 0: load @r0, r2
- outb VGA_ATTR_INDEX, r1
- outb VGA_ATTR_DATA, r2
- add 1, r0, r0
- add 1, r1, r1
- cmp r1, VGA_ATTR_COUNT
- blt 0b
-
- load vgaGrfxParameters, r0
- load 0, r1
- 0: load @r0, r2
- outx VGA_GRFX_INDEX, r1, r2
- add 1, r0, r0
- add 1, r1, r1
- cmp r1, VGA_GRFX_COUNT
- blt 0b
-
- // Re-enable video.
-
- // Set the attribute flip-flop to "index", and give the palette
- // back to the VGA.
- inb VGA_INPUT_STATUS_1, r0
- outb VGA_ATTR_INDEX, 0x20
- return
-