|
Revision 2034, 1.3 KB
(checked in by mwhitworth, 3 years ago)
|
|
Scroll the screen of earlyconsole (soon, video/console.c may not be loaded at startup).
|
| Line | |
|---|
| 1 | #include <i386/ioports.h> |
|---|
| 2 | #include <typedefs.h> |
|---|
| 3 | #include <print.h> |
|---|
| 4 | #include <string.h> |
|---|
| 5 | |
|---|
| 6 | BYTE* screen=(BYTE*)0xC00B8000; |
|---|
| 7 | int curX, curY; |
|---|
| 8 | |
|---|
| 9 | void EarlyConsoleSetPos(int x, int y); |
|---|
| 10 | |
|---|
| 11 | void EarlyConsoleNewLine() |
|---|
| 12 | { |
|---|
| 13 | int i; |
|---|
| 14 | |
|---|
| 15 | curY++; |
|---|
| 16 | curX=0; |
|---|
| 17 | |
|---|
| 18 | if (curY < 25) |
|---|
| 19 | EarlyConsoleSetPos(curX, curY); |
|---|
| 20 | else{ |
|---|
| 21 | |
|---|
| 22 | for (i=0; i < 24 ; i++) |
|---|
| 23 | memcpy ( &screen [ i*80*2] , &screen [ (i+1)*80*2 ] , 80*2); |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | memsetw( &screen[ i*80*2 ] , 80*2, ((0x07 << 8) | (' '))); |
|---|
| 27 | |
|---|
| 28 | curY = 24; |
|---|
| 29 | } |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | void EarlyConsolePrint(char* string, int length) |
|---|
| 33 | { |
|---|
| 34 | int i; |
|---|
| 35 | |
|---|
| 36 | for (i=0; i<length; i++) |
|---|
| 37 | { |
|---|
| 38 | switch (string[i]) |
|---|
| 39 | { |
|---|
| 40 | case '\n': |
|---|
| 41 | EarlyConsoleNewLine(); |
|---|
| 42 | break; |
|---|
| 43 | |
|---|
| 44 | default: |
|---|
| 45 | screen[(curY*(80*2))+(curX*2)]=string[i]; |
|---|
| 46 | screen[(curY*(80*2))+(curX*2)+1]=7; |
|---|
| 47 | curX++; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | if (curX >= 80) |
|---|
| 51 | EarlyConsoleNewLine(); |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | void EarlyConsoleSetPos(int x, int y) |
|---|
| 56 | { |
|---|
| 57 | WORD position=(y*80)+x; |
|---|
| 58 | |
|---|
| 59 | curX=x; |
|---|
| 60 | curY=y; |
|---|
| 61 | |
|---|
| 62 | outb(0x3D4,14); |
|---|
| 63 | outb(0x3D5,(BYTE)(position >> 8)); |
|---|
| 64 | outb(0x3D4,15); |
|---|
| 65 | outb(0x3D5,(BYTE)(position & 0xFF)); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | void EarlyConsoleClearScreen() |
|---|
| 69 | { |
|---|
| 70 | int i; |
|---|
| 71 | |
|---|
| 72 | for (i=0; i<(80*25*2); i+=2) |
|---|
| 73 | { |
|---|
| 74 | screen[i]=' '; |
|---|
| 75 | screen[i+1]=7; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | EarlyConsoleSetPos(0, 0); |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | void EarlyConsoleInit() |
|---|
| 82 | { |
|---|
| 83 | EarlyConsoleClearScreen(); |
|---|
| 84 | KeSetOutput(EarlyConsolePrint); |
|---|
| 85 | } |
|---|