|
2 | 2 | ; BareMetal -- a 64-bit OS written in Assembly for x86-64 systems |
3 | 3 | ; Copyright (C) 2008-2025 Return Infinity -- see LICENSE.TXT |
4 | 4 | ; |
5 | | -; VGA Text mode functions |
| 5 | +; VGA text mode Output |
6 | 6 | ; ============================================================================= |
7 | 7 |
|
8 | 8 |
|
9 | 9 | ; ----------------------------------------------------------------------------- |
10 | 10 | ; vga_init -- Initialize VGA text output |
11 | 11 | ; IN: Nothing |
12 | 12 | ; OUT: Nothing |
13 | | -; All other registers preserved |
14 | 13 | vga_init: |
15 | 14 | mov word [vga_Rows], 25 |
16 | 15 | mov word [vga_Cols], 80 |
@@ -60,36 +59,6 @@ nexttritone: |
60 | 59 | ; ----------------------------------------------------------------------------- |
61 | 60 |
|
62 | 61 |
|
63 | | -; ----------------------------------------------------------------------------- |
64 | | -; vga_clear_screen -- Clear the screen |
65 | | -; IN: Nothing |
66 | | -; OUT: All registers preserved |
67 | | -vga_clear_screen: |
68 | | - push rdi |
69 | | - push rcx |
70 | | - push rax |
71 | | - pushfq |
72 | | - |
73 | | - ; Set cursor to top left corner |
74 | | - mov word [vga_Cursor_Row], 0 |
75 | | - mov word [vga_Cursor_Col], 0 |
76 | | - |
77 | | - cld ; Clear the direction flag as we want to increment through memory |
78 | | - |
79 | | - xor ecx, ecx |
80 | | - mov ax, 0x8F20 ; 0x8F for gray background/bright white foreground, 0x20 for space (black) character |
81 | | - mov edi, 0xB8000 |
82 | | - mov ecx, 2000 ; 80 x 25 |
83 | | - rep stosw ; Clear the screen. Store word in AX to RDI, RCX times |
84 | | - |
85 | | - popfq |
86 | | - pop rax |
87 | | - pop rcx |
88 | | - pop rdi |
89 | | - ret |
90 | | -; ----------------------------------------------------------------------------- |
91 | | - |
92 | | - |
93 | 62 | ; ----------------------------------------------------------------------------- |
94 | 63 | ; os_inc_cursor -- Increment the cursor by one, scroll if needed |
95 | 64 | ; IN: Nothing |
@@ -377,6 +346,36 @@ vga_output_chars_done: |
377 | 346 | ; ----------------------------------------------------------------------------- |
378 | 347 |
|
379 | 348 |
|
| 349 | +; ----------------------------------------------------------------------------- |
| 350 | +; vga_clear_screen -- Clear the screen |
| 351 | +; IN: Nothing |
| 352 | +; OUT: All registers preserved |
| 353 | +vga_clear_screen: |
| 354 | + push rdi |
| 355 | + push rcx |
| 356 | + push rax |
| 357 | + pushfq |
| 358 | + |
| 359 | + ; Set cursor to top left corner |
| 360 | + mov word [vga_Cursor_Row], 0 |
| 361 | + mov word [vga_Cursor_Col], 0 |
| 362 | + |
| 363 | + cld ; Clear the direction flag as we want to increment through memory |
| 364 | + |
| 365 | + xor ecx, ecx |
| 366 | + mov ax, 0x8F20 ; 0x8F for gray background/bright white foreground, 0x20 for space (black) character |
| 367 | + mov edi, 0xB8000 |
| 368 | + mov ecx, 2000 ; 80 x 25 |
| 369 | + rep stosw ; Clear the screen. Store word in AX to RDI, RCX times |
| 370 | + |
| 371 | + popfq |
| 372 | + pop rax |
| 373 | + pop rcx |
| 374 | + pop rdi |
| 375 | + ret |
| 376 | +; ----------------------------------------------------------------------------- |
| 377 | + |
| 378 | + |
380 | 379 | ; ----------------------------------------------------------------------------- |
381 | 380 | ; vga_draw_line - Draw the line for the rolling output |
382 | 381 | vga_draw_line: |
|
0 commit comments