Dev: small fixes in programs + new programs #4
@@ -1,5 +1,12 @@
|
|||||||
# Blank OS Developer's Manual
|
# Blank OS Developer's Manual
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
- [Getting Started](#getting-started)
|
||||||
|
- [Writing programs for BlankOS](#writing-programs)
|
||||||
|
- [Changing the TTY font](#changing-font)
|
||||||
|
|
||||||
|
<a name="getting-started"/>
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
### System description
|
### System description
|
||||||
@@ -27,7 +34,10 @@ gdb kernel.elf
|
|||||||
(gdb) target remote localhost:1234
|
(gdb) target remote localhost:1234
|
||||||
```
|
```
|
||||||
|
|
||||||
## Making programs for the OS
|
<a name="getting-started"/>
|
||||||
|
## Writing programs for BlankOS
|
||||||
|
|
||||||
|
Be warned, these are not actual programs in the sense you'd expect. These are indeed functions that are called from the shell, and embedded in the kernel ELF binary. Real programs apart from the kernel are not yet a thing here, but might be one day.
|
||||||
|
|
||||||
### Step 1 - Making the program and the entry point
|
### Step 1 - Making the program and the entry point
|
||||||
|
|
||||||
@@ -86,4 +96,19 @@ The linking process should be taken care of by the appropriate Linker script `li
|
|||||||
|
|
||||||
If you're proud of what you've made, you can clone the repo, make your changes, open a pull request and maybe your program will be added to the main BlankOS repo, and later distributed in the new ISOs!
|
If you're proud of what you've made, you can clone the repo, make your changes, open a pull request and maybe your program will be added to the main BlankOS repo, and later distributed in the new ISOs!
|
||||||
|
|
||||||
|
<a name="changing-font"/>
|
||||||
|
## Changing the TTY font
|
||||||
|
|
||||||
|
In order to change the default font, first get your hands on a 8x16 `.psf` (PC Screen Font 2) formatted font. Then, put it in `include/fonts` and remove the default one (`UniCyr_8x16.psf`).
|
||||||
|
|
||||||
|
Go ahead and run `make` one time. The compilation/linking will fail because of unresolved symbols, but an object file should have been created in `build/fonts` with your custom font's name.
|
||||||
|
|
||||||
|
Read the symbols in that object file:
|
||||||
|
|
||||||
|
```
|
||||||
|
readelf -s -W build/fonts/YOUR_FONT_8x16.o
|
||||||
|
```
|
||||||
|
|
||||||
|
Get the symbol name that ends with `_start` and replace all occurences of it in the `src/drivers/framebuffer.c` file.
|
||||||
|
|
||||||
|
Then, run `make` again and the font should have changed properly.
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ char* motd[] =
|
|||||||
};
|
};
|
||||||
int motd_size = sizeof(motd)/sizeof(motd[0]);
|
int motd_size = sizeof(motd)/sizeof(motd[0]);
|
||||||
|
|
||||||
|
bool do_splash = true;
|
||||||
|
|
||||||
void splash()
|
void splash()
|
||||||
{
|
{
|
||||||
int random = randint(time_seed());
|
int random = randint(time_seed());
|
||||||
@@ -87,7 +89,11 @@ int parse_input(char* input, char* argv[], int max_args)
|
|||||||
|
|
||||||
void shell_install()
|
void shell_install()
|
||||||
{
|
{
|
||||||
|
if (do_splash == true)
|
||||||
|
{
|
||||||
|
do_splash = false;
|
||||||
splash();
|
splash();
|
||||||
|
}
|
||||||
|
|
||||||
register_command("help", program_help);
|
register_command("help", program_help);
|
||||||
register_command("panic", program_panic);
|
register_command("panic", program_panic);
|
||||||
|
|||||||
@@ -62,6 +62,29 @@ enum Colors
|
|||||||
green = 0x0000FF00,
|
green = 0x0000FF00,
|
||||||
blue = 0x000000FF,
|
blue = 0x000000FF,
|
||||||
yellow = 0x00FFFF00,
|
yellow = 0x00FFFF00,
|
||||||
|
cyan = 0x0000FFFF,
|
||||||
|
magenta = 0x00FF00FF,
|
||||||
|
orange = 0x00FFA500,
|
||||||
|
purple = 0x00800080,
|
||||||
|
brown = 0x00A52A2A,
|
||||||
|
gray = 0x00808080,
|
||||||
|
pink = 0x00FFC0CB,
|
||||||
|
lime = 0x00BFFF00,
|
||||||
|
navy = 0x00000080,
|
||||||
|
teal = 0x00008080,
|
||||||
|
maroon = 0x00800000,
|
||||||
|
olive = 0x00808000,
|
||||||
|
silver = 0x00C0C0C0,
|
||||||
|
gold = 0x00FFD700,
|
||||||
|
indigo = 0x004B0082,
|
||||||
|
violet = 0x00EE82EE,
|
||||||
|
coral = 0x00FF7F50,
|
||||||
|
turquoise = 0x0040E0D0,
|
||||||
|
salmon = 0x00FA8072,
|
||||||
|
chocolate = 0x00D2691E,
|
||||||
|
khaki = 0x00F0E68C,
|
||||||
|
lavender = 0x00E6E6FA,
|
||||||
|
beige = 0x00F5F5DC
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -29,14 +29,27 @@ void rot13(char* input, char* output)
|
|||||||
output[i] = '\0';
|
output[i] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void program_rot13()
|
void program_rot13(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
char input_buffer[BUFFER_SIZE];
|
if (argc < 2)
|
||||||
char output[BUFFER_SIZE];
|
{
|
||||||
puts("String? ");
|
printf("Usage: %s <string>\n", argv[0]);
|
||||||
get_input(input_buffer, BUFFER_SIZE);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char input_buffer[BUFFER_SIZE] = {0};
|
||||||
|
char output[BUFFER_SIZE] = {0};
|
||||||
|
|
||||||
|
for (int i=1; i<argc; i++)
|
||||||
|
{
|
||||||
|
strcat(input_buffer, argv[i]);
|
||||||
|
if (i<argc-1)
|
||||||
|
{
|
||||||
|
strcat(input_buffer, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
rot13(input_buffer, output);
|
rot13(input_buffer, output);
|
||||||
printf("\n%s\n", output);
|
printf("%s\n", output);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* morse_alphabet[] = {
|
const char* morse_alphabet[] = {
|
||||||
@@ -121,12 +134,27 @@ void to_morse(const char* input, char* output) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void program_morse() {
|
void program_morse(int argc, char* argv[]) {
|
||||||
char output[512];
|
|
||||||
char input_buffer[BUFFER_SIZE];
|
if (argc < 2)
|
||||||
puts("String? ");
|
{
|
||||||
get_input(input_buffer, BUFFER_SIZE);
|
printf("Usage: %s <string>\n", argv[0]);
|
||||||
to_morse(input_buffer, output);
|
return;
|
||||||
printf("\n%s\n", output);
|
}
|
||||||
|
|
||||||
|
char output[512];
|
||||||
|
char message[BUFFER_SIZE];
|
||||||
|
|
||||||
|
for (int i=1; i<argc; i++)
|
||||||
|
{
|
||||||
|
strcat(message, argv[i]);
|
||||||
|
if (i < argc-1)
|
||||||
|
{
|
||||||
|
strcat(message, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
to_morse(message, output);
|
||||||
|
printf("%s\n", output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,16 +16,37 @@
|
|||||||
#define BUF_SIZE 256
|
#define BUF_SIZE 256
|
||||||
#define COLORS 20
|
#define COLORS 20
|
||||||
|
|
||||||
void program_rainbow()
|
void program_rainbow(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
char input_buffer[BUF_SIZE];
|
if (argc < 2)
|
||||||
puts("What to print? ");
|
{
|
||||||
get_input(input_buffer, BUF_SIZE);
|
printf("Usage: %s <string>\n", argv[0]);
|
||||||
puts("\n");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0; i<COLORS; i++)
|
char input_buffer[BUF_SIZE] = {0};
|
||||||
|
for (int i=1; i<argc; i++)
|
||||||
{
|
{
|
||||||
//colorputs(input_buffer, i);
|
strcat(input_buffer, argv[i]);
|
||||||
|
if (i<argc-1)
|
||||||
|
{
|
||||||
|
strcat(input_buffer, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Colors colors[] = {
|
||||||
|
white, black, red, green, blue, yellow,
|
||||||
|
cyan, magenta, orange, purple, brown,
|
||||||
|
gray, pink, lime, navy, teal, maroon,
|
||||||
|
olive, silver, gold, indigo, violet,
|
||||||
|
coral, turquoise, salmon, chocolate,
|
||||||
|
khaki, lavender, beige
|
||||||
|
};
|
||||||
|
int colors_count = sizeof(colors)/sizeof(colors[0]);
|
||||||
|
|
||||||
|
for (int i=0; i<colors_count-1; i++)
|
||||||
|
{
|
||||||
|
colorputs(input_buffer, colors[i], colors[i+1]);
|
||||||
puts("\n");
|
puts("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user