699f228b091361502b1630ef46d52a72ab88632a
[reactos.git] / reactos / drivers / dd / vga / miniport / initvga.c
1 #include <internal/i386/io.h>
2
3 #include "vgaVideo.h"
4
5 void outxay(unsigned short ad, unsigned char x, unsigned char y)
6 {
7 unsigned short xy = (x << 8) + y;
8 VideoPortWritePortUshort(ad, xy);
9 }
10
11 void setMode(VideoMode mode)
12 {
13 unsigned char x;
14
15 VideoPortWritePortUchar((PUCHAR)MISC, mode.Misc);
16 VideoPortWritePortUchar((PUCHAR)STATUS, 0);
17 VideoPortWritePortUchar((PUCHAR)FEATURE, mode.Feature);
18
19 for(x=0; x<5; x++)
20 {
21 outxay(SEQ, mode.Seq[x], x);
22 }
23
24 VideoPortWritePortUshort((USHORT)CRTC, 0x11);
25 VideoPortWritePortUshort((USHORT)CRTC, (mode.Crtc[0x11] & 0x7f));
26
27 for(x=0; x<25; x++)
28 {
29 outxay(CRTC, mode.Crtc[x], x);
30 }
31
32 for(x=0; x<9; x++)
33 {
34 outxay(GRAPHICS, mode.Gfx[x], x);
35 }
36
37 x=VideoPortReadPortUchar(FEATURE);
38
39 for(x=0; x<21; x++)
40 {
41 VideoPortWritePortUchar((PUCHAR)ATTRIB, x);
42 VideoPortWritePortUchar((PUCHAR)ATTRIB, mode.Attrib[x]);
43 }
44
45 x=VideoPortReadPortUchar(STATUS);
46
47 VideoPortWritePortUchar(ATTRIB, 0x20);
48 }
49
50 VideoMode Mode12 = {
51 0xa000, 0xe3, 0x00,
52
53 {0x02, 0x01, 0x0f, 0x00, 0x06},
54
55 {0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, 0x00, 0x40, 0x00, 0x00,
56 0x00, 0x00, 0x00, 0x59, 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3,
57 0xff},
58
59 {0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x05, 0x0f, 0xff},
60
61 {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
62 0x0c, 0x0d, 0x0e, 0x0f, 0x81, 0x00, 0x0f, 0x00, 0x00}
63 };
64
65 VideoMode Mode13 = {
66 0xa000, 0x63, 0x00,
67
68 {0x03, 0x01, 0x0f, 0x00, 0x0e},
69
70 {0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, 0x00, 0x41, 0x00, 0x00,
71 0x00, 0x00, 0x00, 0x00, 0x9c, 0x0e, 0x8f, 0x28, 0x40, 0x96, 0xb9, 0xa3,
72 0xff},
73
74 {0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x07, 0x0f, 0xff},
75
76 {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
77 0x0c, 0x0d, 0x0e, 0x0f, 0x41, 0x00, 0x0f, 0x00, 0x00}
78 };
79
80 void myvgaPutPixel(int x, int y, unsigned char c)
81 {
82 unsigned offset;
83 unsigned char a;
84
85 offset = xconv[x]+y80[y];
86
87 VideoPortWritePortUchar((PUCHAR)0x3ce,0x08); // Set
88 VideoPortWritePortUchar((PUCHAR)0x3cf,maskbit[x]); // the MASK
89 VideoPortWritePortUshort((PUSHORT)0x3ce,0x0205); // write mode = 2 (bits 0,1)
90 // read mode = 0 (bit 3
91 a = vidmem[offset]; // Update bit buffer
92 vidmem[offset] = c; // Write the pixel
93 }
94
95 void InitVGAMode()
96 {
97 // vidmem += __djgpp_conventional_base;
98
99 setMode(Mode12);
100 RtlZeroMemory(vidmem, 38400);
101 vgaPreCalc();
102 }