Added non_moving_put, fixed bug with int_to_ functions that would cause them to not properly convert "0" to a string. Added character printing to printf
This commit is contained in:
parent
b660fa1a0b
commit
a184efbc9f
@ -42,6 +42,9 @@ void set_curpos_raw(int curpos) {
|
|||||||
outb(0x3D5, cursor_position_split[0]);
|
outb(0x3D5, cursor_position_split[0]);
|
||||||
outb(0x3D4, 0x0E);
|
outb(0x3D4, 0x0E);
|
||||||
outb(0x3D5, cursor_position_split[1]);
|
outb(0x3D5, cursor_position_split[1]);
|
||||||
|
|
||||||
|
cursor_x = (*(uint16_t*)cursor_position_split) % TERM_WIDTH;
|
||||||
|
cursor_y = (*(uint16_t*)cursor_position_split) / TERM_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_curpos(int x, int y) {
|
void set_curpos(int x, int y) {
|
||||||
@ -57,6 +60,8 @@ int int_to_decimal(unsigned int number, char* string_buffer) {
|
|||||||
|
|
||||||
int index = 9;
|
int index = 9;
|
||||||
unsigned int acc = number;
|
unsigned int acc = number;
|
||||||
|
if (acc == 0)
|
||||||
|
string_buffer[index--] = '0';
|
||||||
while (acc != 0) {
|
while (acc != 0) {
|
||||||
string_buffer[index--] = 0x30+(acc%10);
|
string_buffer[index--] = 0x30+(acc%10);
|
||||||
acc /= 10;
|
acc /= 10;
|
||||||
@ -71,6 +76,8 @@ int int_to_hex(unsigned int number, char* string_buffer) {
|
|||||||
|
|
||||||
int index = 7;
|
int index = 7;
|
||||||
unsigned int acc = number;
|
unsigned int acc = number;
|
||||||
|
if (acc == 0)
|
||||||
|
string_buffer[index--] = '0';
|
||||||
while (acc != 0) {
|
while (acc != 0) {
|
||||||
string_buffer[index--] = dec_to_hex[acc%0x10];
|
string_buffer[index--] = dec_to_hex[acc%0x10];
|
||||||
acc /= 0x10;
|
acc /= 0x10;
|
||||||
@ -125,6 +132,13 @@ void printf(const char* string, ...) {
|
|||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
printf(va_arg(ptr, const char*));
|
printf(va_arg(ptr, const char*));
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
int mem_pos = cursor_y * TERM_WIDTH + cursor_x++;
|
||||||
|
int promoted = va_arg(ptr, int);
|
||||||
|
char charred = promoted;
|
||||||
|
VMEM_ADDR[mem_pos] = charred + (0x07<<8);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -139,3 +153,8 @@ void printf(const char* string, ...) {
|
|||||||
|
|
||||||
va_end(ptr);
|
va_end(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void non_moving_put(char chr) {
|
||||||
|
int mem_pos = cursor_y * TERM_WIDTH + cursor_x;
|
||||||
|
VMEM_ADDR[mem_pos] = chr + (0x07<<8);
|
||||||
|
}
|
@ -14,5 +14,6 @@ void set_curpos(int x, int y);
|
|||||||
int int_to_decimal(unsigned int number, char* string_buffer);
|
int int_to_decimal(unsigned int number, char* string_buffer);
|
||||||
int int_to_hex(unsigned int number, char* string_buffer);
|
int int_to_hex(unsigned int number, char* string_buffer);
|
||||||
void printf(const char* string, ...);
|
void printf(const char* string, ...);
|
||||||
|
void non_moving_put(char chr);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user