|
Revision 559, 1.0 kB
(checked in by mwhitworth, 7 months ago)
|
|
Merge hybrid/modular branch (to date) with trunk.
|
| Line | |
|---|
| 1 | #include <i386/ioports.h> |
|---|
| 2 | #include <typedefs.h> |
|---|
| 3 | |
|---|
| 4 | BYTE* screen=(BYTE*)0xB8000; |
|---|
| 5 | int curX, curY; |
|---|
| 6 | |
|---|
| 7 | void EarlyConsoleSetPos(int x, int y); |
|---|
| 8 | |
|---|
| 9 | void EarlyConsoleNewLine() |
|---|
| 10 | { |
|---|
| 11 | curY++; |
|---|
| 12 | curX=0; |
|---|
| 13 | |
|---|
| 14 | EarlyConsoleSetPos(curX, curY); |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | void EarlyConsolePrint(char* string, int length) |
|---|
| 18 | { |
|---|
| 19 | int i; |
|---|
| 20 | |
|---|
| 21 | for (i=0; i<length; i++) |
|---|
| 22 | { |
|---|
| 23 | switch (string[i]) |
|---|
| 24 | { |
|---|
| 25 | case '\n': |
|---|
| 26 | EarlyConsoleNewLine(); |
|---|
| 27 | break; |
|---|
| 28 | |
|---|
| 29 | default: |
|---|
| 30 | screen[(curY*(80*2))+(curX*2)]=string[i]; |
|---|
| 31 | screen[(curY*(80*2))+(curX*2)+1]=7; |
|---|
| 32 | curX++; |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | if (curX >= 80) |
|---|
| 36 | EarlyConsoleNewLine(); |
|---|
| 37 | } |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | void EarlyConsoleSetPos(int x, int y) |
|---|
| 41 | { |
|---|
| 42 | WORD position=(y*80)+x; |
|---|
| 43 | |
|---|
| 44 | curX=x; |
|---|
| 45 | curY=y; |
|---|
| 46 | |
|---|
| 47 | outb(0x3D4,14); |
|---|
| 48 | outb(0x3D5,(BYTE)(position >> 8)); |
|---|
| 49 | outb(0x3D4,15); |
|---|
| 50 | outb(0x3D5,(BYTE)(position & 0xFF)); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | void EarlyConsoleClearScreen() |
|---|
| 54 | { |
|---|
| 55 | int i; |
|---|
| 56 | |
|---|
| 57 | for (i=0; i<(80*25*2); i+=2) |
|---|
| 58 | { |
|---|
| 59 | screen[i]=' '; |
|---|
| 60 | screen[i+1]=7; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | EarlyConsoleSetPos(0, 0); |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | void EarlyConsoleInit() |
|---|
| 67 | { |
|---|
| 68 | EarlyConsoleClearScreen(); |
|---|
| 69 | KeSetOutput(EarlyConsolePrint); |
|---|
| 70 | } |
|---|