Skip to content

Commit ac15c80

Browse files
committed
VGA drivers moved to separate files
1 parent 23b8c14 commit ac15c80

File tree

15 files changed

+126
-109
lines changed

15 files changed

+126
-109
lines changed

OS.iso

0 Bytes
Binary file not shown.

build/OS.bin

-5 Bytes
Binary file not shown.

build/full_kernel.bin

-5 Bytes
Binary file not shown.

build/kernel.o

356 Bytes
Binary file not shown.

build/output.c.o

3.46 KB
Binary file not shown.

build/printformat.asm.o

-592 Bytes
Binary file not shown.

build/vga_text_driver.c.o

2.41 KB
Binary file not shown.

build/vga_text_mode.c.o

-4.69 KB
Binary file not shown.

iso/floppy.img

0 Bytes
Binary file not shown.

kernel/drivers/vga_text_driver.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "vga_text_driver.h"
2+
#include "port_io.h"
3+
4+
uint16_t set_cursor_position(coords _pos)
5+
{
6+
uint16_t offset = _pos.y * VGA_WIDTH + _pos.x; /*
7+
Calculates offset in vga buffer to set cursor
8+
*/
9+
if (_pos.x >= 0 && _pos.y >= 0 && offset < 0x7d0)
10+
{
11+
pb_out(VGA_CTRL_REGISTER, VGA_HIGH_OFFSET);
12+
pb_out(VGA_DATA_REGISTER, (uint8_t)(offset));
13+
pb_out(VGA_CTRL_REGISTER, VGA_LOW_OFFSET);
14+
pb_out(VGA_DATA_REGISTER, (uint8_t)(offset << 8));
15+
return offset;
16+
}
17+
return 0;
18+
}
19+
20+
uint8_t color_sum(color_t _c)
21+
{
22+
return _c.bg << 4 | _c.fg; /*
23+
0000 | 0000 bits
24+
BG FG
25+
*/
26+
}
27+
28+
uint16_t vga_struct(const char _char, color_t _color)
29+
{
30+
return color_sum(_color) << 8 | _char; /*
31+
First 8 bits is a color and second bit is a char
32+
0000 | 0000 | 00000000
33+
BG FG Char
34+
*/
35+
}

0 commit comments

Comments
 (0)