-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a hexes library for printing to screen
- Loading branch information
Showing
8 changed files
with
95 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
#include "pic.h" | ||
#include "dma.h" | ||
#include "hexes.h" | ||
|
||
void _irq6_handler(); | ||
void floppy_init(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "hexes.h" | ||
|
||
void hexes_move_cursor(int row, int col) { | ||
uint16_t position = row * 80 + col; | ||
|
||
outb(0x3D4, 0x0F); | ||
outb(0x3D5, position & 0xFF); | ||
|
||
outb(0x3D4, 0x0E); | ||
outb(0x3D5, (position >> 8) & 0xFF); | ||
} | ||
|
||
void hexes_write_char(uint8_t character, int row, int col) { | ||
uint16_t position = row * 80 + col; | ||
|
||
*(char*)(0xb8000 + position * 2) = character; | ||
} | ||
|
||
void hexes_write_string(char *str, int row, int col) { | ||
while(*str) { | ||
hexes_write_char(*str, row, col); | ||
col++; | ||
str++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef HEXES_H | ||
#define HEXES_H | ||
|
||
#include "types.h" | ||
#include "io.h" | ||
|
||
void hexes_move_cursor(int row, int col); | ||
void hexes_write_char(uint8_t character, int row, int col); | ||
void hexes_write_string(char *str, int row, int col); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "keyboard.h" | ||
|
||
uint8_t last_keycode = 0; | ||
|
||
void _keyboard_int(int keycode) { | ||
last_keycode = keycode; | ||
hexes_write_char(get_last_key(), 0, 2); | ||
} | ||
|
||
uint8_t key_translate[] = { | ||
0x00, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, // 0x00 | ||
0x37, 0x38, 0x39, 0x30, 0x2D, 0x3D, 0x7F, 0x09, // 0x08 | ||
0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, // 0x10 | ||
0x6F, 0x70, 0x00, 0x00, 0x0A, 0x00, 0x61, 0x73, // 0x18 | ||
0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x00, // 0x20 | ||
0x00, 0x00, 0x00, 0x00, 0x7A, 0x78, 0x63, 0x76, // 0x28 | ||
0x62, 0x6E, 0x6D, 0x00, 0x2E, 0x2F, 0x00, 0x00, // 0x30 | ||
0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // 0x38 | ||
}; | ||
|
||
uint8_t get_last_key() { | ||
if (last_keycode < 0xFF) { | ||
return key_translate[last_keycode]; | ||
} else { | ||
return 0x00; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef KEYBOARD_H | ||
#define KEYBOARD_H | ||
|
||
#include "types.h" | ||
#include "hexes.h" | ||
|
||
uint8_t get_last_key(); | ||
void _keyboard_int(int keycode); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters