From 89536d1f20dae094b9e18c2f2e8b930f94fbc2c4 Mon Sep 17 00:00:00 2001 From: Alee Date: Sun, 13 May 2018 16:58:36 -0400 Subject: Added souce files --- include/screen.h | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 include/screen.h (limited to 'include/screen.h') diff --git a/include/screen.h b/include/screen.h new file mode 100644 index 0000000..9d2873e --- /dev/null +++ b/include/screen.h @@ -0,0 +1,116 @@ +#ifndef SCREEN_H +#define SCREEN_H +#include "types.h" +#include "system.h" +#include "string.h" +int cursorX = 0, cursorY = 0; +const uint8 sw = 80,sh = 25,sd = 2; //We define the screen width, height, and depth. +void clearLine(uint8 from,uint8 to) +{ + uint16 i = sw * from * sd; + string vidmem=(string)0xb8000; + for(i;i<(sw*to*sd);i++) + { + vidmem[i] = 0x0; + } +} +void updateCursor() +{ + unsigned temp; + + temp = cursorY * sw + cursorX; // Position = (y * width) + x + + outportb(0x3D4, 14); // CRT Control Register: Select Cursor Location + outportb(0x3D5, temp >> 8); // Send the high byte across the bus + outportb(0x3D4, 15); // CRT Control Register: Select Send Low byte + outportb(0x3D5, temp); // Send the Low byte of the cursor location +} +void clearScreen() +{ + clearLine(0,sh-1); + cursorX = 0; + cursorY = 0; + updateCursor(); +} + +void scrollUp(uint8 lineNumber) +{ + string vidmem = (string)0xb8000; + uint16 i = 0; + clearLine(0,lineNumber-1); //updated + for (i;i=sh-1) + { + scrollUp(1); + } +} + +void printch(char c) +{ + string vidmem = (string) 0xb8000; + switch(c) + { + case (0x08): + if(cursorX > 0) + { + cursorX--; + vidmem[(cursorY * sw + cursorX)*sd]=0x00; + } + break; + /* case (0x09): + cursorX = (cursorX + 8) & ~(8 - 1); + break;*/ + case ('\r'): + cursorX = 0; + break; + case ('\n'): + cursorX = 0; + cursorY++; + break; + default: + vidmem [((cursorY * sw + cursorX))*sd] = c; + vidmem [((cursorY * sw + cursorX))*sd+1] = 0x0F; + cursorX++; + break; + + } + if(cursorX >= sw) + { + cursorX = 0; + cursorY++; + } + updateCursor(); + newLineCheck(); +} + +void print (string ch) +{ + uint16 i = 0; + uint8 length = strlength(ch)-1; //Updated (Now we store string length on a variable to call the function only once) + for(i;i