Nanite/src/kernel/nanstd.c

71 lines
2.5 KiB
C

/*----------------*\
|Nanite OS |
|Copyright (C) 2026|
|Xircon |
\*----------------*/
#include "nanstd.h"
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <dri/timer.h>
extern uint8_t _keyboard_scancode;
/*Prints a helpful or cool tip About the OS!*/
void printTip() {
int number = rand() % 17;
switch (number) {
case 1: printf("Tip: The RD in the Version stands for Research and Development!\n"); break;
case 2: printf("Tip: You can use Ctrl+Alt+Del to Reboot!\n"); break;
case 3: printf("Tip: You can use Ctrl+Alt+ESC to Shutdown!\n"); break;
case 4: printf("Tip: Nanite is under a modified BSD 3-Clause Licence!\n"); break;
case 5: printf("Tip: Nanite is also supported on the ESP32 Dev Board!\n"); break;
case 6: printf("Tip: The Serial Interface is at 9600 Baud by Default!\n"); break;
case 7: printf("Tip: This is a hobby OS, worked on in the Author's Spare Time!\n"); break;
case 8: printf("Tip: Nanite Has been Written By Xircon Since 2024!\n"); break;
case 9: printf("Tip: Nanite has its own C std header, like unistd! Its called nanstd.h!\n"); break;
case 10: printf("Tip: Nanite Can be built with a Different Keyboard Layout!\n"); break;
case 11: printf("Tip: Nanite is and always will be Open Source Software!\n"); break;
case 12: printf("Tip: The RD Versioning is in Reference to early Minecraft!\n"); break;
case 13: printf("Tip: Nanite's nanstd.h has factorial support! (I like them!)\n"); break;
case 14: printf("Tip: The Shell's Loading Spinner is just decor and can be removed!\n"); break;
case 15: printf("Tip: Nanite is around 6000 lines of C and ASM as of Version RD-00127!\n"); break;
case 16: printf("Tip: A Bug in the Keyboard Driver used to Allow RCtrl+RAlt to Reboot!\n"); break;
}
return;
}
/*Calculate Factorial of `N`*/
unsigned int factorial(unsigned int N) {
int fact = 1, i;
// Loop from 1 to N to get the factorial
for (i = 1; i <= N; i++) {
fact *= i;
}
return fact;
}
/*Prints A Little Spinning cursor*/
void spinner(int times) {
int x, y;
while (times >= 0) {
printf("|");
Timer_Wait(1);
printf("\b");
printf("/");
Timer_Wait(1);
printf("\b");
printf("-");
Timer_Wait(1);
printf("\b");
printf("\\");
Timer_Wait(1);
printf("\b");
times--;
}
printf(" \b");
}