Skip to content

Commit 3ffe8dc

Browse files
committed
Trying figuring out why does function get_cursor_position breaks code flow
1 parent 22dc7bb commit 3ffe8dc

11 files changed

Lines changed: 20 additions & 9 deletions

File tree

OS.iso

0 Bytes
Binary file not shown.

build/OS.bin

60 Bytes
Binary file not shown.

build/full_kernel.bin

60 Bytes
Binary file not shown.

build/full_kernel.elf

13.3 KB
Binary file not shown.

build/kernel.o

56 Bytes
Binary file not shown.

debug.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
i386-elf-ld -o build/full_kernel.elf -Ttext 0x1000 build/*.o
2+
qemu-system-i386 -s -S build/OS.bin & i386-elf-gdb -ex "target remote localhost:1234" -ex "symbol-file build/full_kernel.elf"

iso/floppy.img

0 Bytes
Binary file not shown.

kernel/drivers/vga_text_driver.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ uint16_t set_cursor_position(coords _pos)
66
uint16_t offset = _pos.y * VGA_WIDTH + _pos.x; /*
77
Calculates offset in vga buffer to set cursor
88
*/
9-
if (_pos.x >= 0 && _pos.y >= 0 && offset < 0x7d0)
9+
if (_pos.x >= 0 && _pos.y >= 0 && offset < 2000)
1010
{
1111
pb_out(VGA_CTRL_REGISTER, VGA_HIGH_OFFSET);
1212
pb_out(VGA_DATA_REGISTER, (uint8_t)(offset));
@@ -32,4 +32,13 @@ uint16_t vga_struct(const char _char, color_t _color)
3232
0000 | 0000 | 00000000
3333
BG FG Char
3434
*/
35-
}
35+
}
36+
37+
// coords get_cursor_position(uint16_t _offset)
38+
// {
39+
// coords pos = {
40+
// _offset % VGA_WIDTH,
41+
// _offset / VGA_WIDTH
42+
// };
43+
// return pos;
44+
// }

kernel/drivers/vga_text_driver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ extern uint16_t vga_struct(const char _char, color_t _color);
2828
*/
2929
uint8_t color_sum(color_t _c);
3030

31+
32+
coords get_cursor_position(uint16_t _offset);
33+
3134
#endif

kernel/kernel.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ extern void main()
44
{
55
uint16_t* tty_buffer = (uint16_t*)0xb8000;
66
clear(tty_buffer, (color_t){CYAN, BLUE});
7-
coords center = {
8-
VGA_WIDTH / 2 - 2,
9-
VGA_HEIGHT / 2 - 1
10-
};
117

12-
uint16_t offset = set_cursor_position(center);
8+
uint16_t offset = 0;
139

14-
offset = print("Hey!", (color_t){CYAN, BLUE}, offset, tty_buffer);
10+
const char* string = "Hey! I like how its done, but I don't understand why it does not work sometimes.";
11+
offset = print(string, (color_t){CYAN, BLUE}, offset, tty_buffer);
12+
1513
set_cursor_position((coords){0, 0});
1614
return;
1715
}

0 commit comments

Comments
 (0)