This would be fine except when I do this you can see the text moving up the page as new characters get displayed which isn't very pleasing to the eye when doing something like scrolling through a menu. I tried to find a dbgio command that clears the screen or some way I could print everything I want in one go then flush it (In hopes it just all updates at once), but I couldn't find anything. The only solutions I could think of is setting up another framebuffer and switch between them (But I don't know how that works in KOS without the PVR system), use a different method of drawing with the BIOS font or maybe there is a way to clear the console. Any advice on what should I be doing?
Here's the code I'm currently using
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <dc/maple.h>
#include <dc/maple/controller.h>
#include <kos/fs.h> //Might need it for fs_load()
#include <arch/exec.h> //arch_exec()
#include <assert.h> //assert()
#include <kos/dbgio.h> //Better debug output to the screen
#include <kos/fs.h> //fs_open, fs_readdir
void indent(uint8_t hovering){
if(hovering){
dbgio_printf("> ");
}
else{
dbgio_printf(" ");
}
return;
}
void print_dir(uint16_t cursor_pos, uint16_t counter_pos, uint16_t * file_count){
file_t d;
dirent_t * de;
d = fs_open("/", O_RDONLY | O_DIR);
while(1){
if(counter_pos == 0){
indent(counter_pos == cursor_pos);
dbgio_printf("..\n");
}
else{
de = fs_readdir(d);
if(de == NULL){
break;
}
indent(counter_pos == cursor_pos);
dbgio_printf("/%s\n", de->name);
}
counter_pos++;
}
*file_count = counter_pos; //Update the number of files
int i;
for(i = 1 + *file_count; i < 17; i++){
dbgio_printf("\n");
}
fs_close(d);
return;
}
int main(){
dbgio_dev_select("fb");
uint16_t cursor_pos = 0;
uint16_t counter_pos = 0;
uint16_t file_count;
print_dir(cursor_pos, counter_pos, &file_count);
uint32_t previous_buttons = 0; //Records the previous buttons polled
maple_device_t * controller;
cont_state_t * st;
while(1){
controller = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); //Reads the first plugged in controller
st = (cont_state_t *)maple_dev_status(controller); //State of controller
//Up press
if((st->buttons & CONT_DPAD_UP) && !(previous_buttons & CONT_DPAD_UP)){
if(cursor_pos != 0){
cursor_pos--;
}
print_dir(cursor_pos, counter_pos, &file_count);
}
//Down press
if((st->buttons & CONT_DPAD_DOWN) && !(previous_buttons & CONT_DPAD_DOWN)){
if(cursor_pos < file_count - 1){
cursor_pos++;
}
print_dir(cursor_pos, counter_pos, &file_count);
}
previous_buttons = st->buttons;
}
return 0;
}