diff --git a/sources/core/apps/datetime/target/amd64/makefile b/sources/core/apps/datetime/target/amd64/makefile index c31632d5d..f8dc89bbf 100644 --- a/sources/core/apps/datetime/target/amd64/makefile +++ b/sources/core/apps/datetime/target/amd64/makefile @@ -18,8 +18,7 @@ VERSION = 0-0-1 CFLAGS = -Werror LDFLAGS = -Wall \ - -lc \ - -lz + -lc # Recursive Wild Card rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) @@ -37,7 +36,7 @@ $(LIB)/%_c.o: $(SOURCE)/%.c link: @ mkdir -m 777 -p $(BIN) - @ $(CC) $(LDFLAGS) -o $(BIN)/datetime $(OBJS) $(LIBRARIES)/libcurl.a $(LIBRARIES)/libtls.a $(LIBRARIES)/libssl.a + @ $(CC) $(LDFLAGS) -o $(BIN)/datetime $(OBJS) $(LIBRARIES)/libcurl.a $(LIBRARIES)/libtls.a $(LIBRARIES)/libssl.a $(LIBRARIES)/libz.a tar: @ mkdir -m 777 -p $(TAR) diff --git a/sources/core/apps/init/source/core/core.c b/sources/core/apps/init/source/core/core.c index 4d2b04647..0410435ba 100644 --- a/sources/core/apps/init/source/core/core.c +++ b/sources/core/apps/init/source/core/core.c @@ -4,8 +4,10 @@ #include #include #include +#include #include #include +#include int main(int argc, char* argv[]){ @@ -27,7 +29,19 @@ int main(int argc, char* argv[]){ setenv("PS1", "\\[\e[0;92m$USER@$HOSTNAME\e[0;37m: \e[0;94m\\w\e[0;37m\\$\e[0m\\] ", 1); // '#' is used to indicate root user session - char *exe_argv[2] = {"/usr/bin/bash", NULL}; + pid_t p = fork(); + if(p < 0){ + perror("init: fork fail"); + return EXIT_FAILURE; + }else if (p == 0){ + char* exe_argv[2] = {"/usr/bin/welcome", NULL}; + execvp("/usr/bin/welcome", exe_argv); + } + + int status = 0; + wait(&status); + + char* exe_argv[2] = {"/usr/bin/bash", NULL}; execvp("/usr/bin/bash", exe_argv); perror("init: /usr/bin/bash"); diff --git a/sources/core/apps/ip/target/amd64/makefile b/sources/core/apps/ip/target/amd64/makefile index 512223f23..3feecd3a6 100644 --- a/sources/core/apps/ip/target/amd64/makefile +++ b/sources/core/apps/ip/target/amd64/makefile @@ -18,8 +18,7 @@ VERSION = 0-0-1 CFLAGS = -Werror LDFLAGS = -Wall \ - -lc \ - -lz + -lc # Recursive Wild Card rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) @@ -37,7 +36,7 @@ $(LIB)/%_c.o: $(SOURCE)/%.c link: @ mkdir -m 777 -p $(BIN) - @ $(CC) $(LDFLAGS) -o $(BIN)/ip $(OBJS) $(LIBRARIES)/libcurl.a $(LIBRARIES)/libtls.a $(LIBRARIES)/libssl.a + @ $(CC) $(LDFLAGS) -o $(BIN)/ip $(OBJS) $(LIBRARIES)/libcurl.a $(LIBRARIES)/libtls.a $(LIBRARIES)/libssl.a $(LIBRARIES)/libz.a tar: @ mkdir -m 777 -p $(TAR) diff --git a/sources/core/apps/llm/target/amd64/makefile b/sources/core/apps/llm/target/amd64/makefile index d6070f5b5..2f42a45a2 100644 --- a/sources/core/apps/llm/target/amd64/makefile +++ b/sources/core/apps/llm/target/amd64/makefile @@ -18,8 +18,7 @@ VERSION = 0-0-1 CFLAGS = -Werror LDFLAGS = -Wall \ - -lc \ - -lz + -lc # Recursive Wild Card rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) @@ -37,7 +36,7 @@ $(LIB)/%_c.o: $(SOURCE)/%.c link: @ mkdir -m 777 -p $(BIN) - @ $(CC) $(LDFLAGS) -o $(BIN)/llm $(OBJS) $(LIBRARIES)/libcurl.a $(LIBRARIES)/libtls.a $(LIBRARIES)/libssl.a + @ $(CC) $(LDFLAGS) -o $(BIN)/llm $(OBJS) $(LIBRARIES)/libcurl.a $(LIBRARIES)/libtls.a $(LIBRARIES)/libssl.a $(LIBRARIES)/libz.a tar: @ mkdir -m 777 -p $(TAR) diff --git a/sources/core/apps/store/target/amd64/makefile b/sources/core/apps/store/target/amd64/makefile index 9111a2abb..ea7cd0e80 100644 --- a/sources/core/apps/store/target/amd64/makefile +++ b/sources/core/apps/store/target/amd64/makefile @@ -16,8 +16,7 @@ LIB = lib CFLAGS = -Werror LDFLAGS = -Wall \ - -lc \ - -lz + -lc # Recursive Wild Card rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) @@ -35,6 +34,6 @@ $(LIB)/%_c.o: $(SOURCE)/%.c link: @ mkdir -m 777 -p $(BIN) - @ $(CC) $(LDFLAGS) -o $(BIN)/store $(OBJS) $(LIBRARIES)/libcurl.a $(LIBRARIES)/libtls.a $(LIBRARIES)/libssl.a $(LIBRARIES)/libcjson.a + @ $(CC) $(LDFLAGS) -o $(BIN)/store $(OBJS) $(LIBRARIES)/libcurl.a $(LIBRARIES)/libtls.a $(LIBRARIES)/libssl.a $(LIBRARIES)/libcjson.a $(LIBRARIES)/libz.a build: $(OBJS) link diff --git a/sources/core/apps/weather/target/amd64/makefile b/sources/core/apps/weather/target/amd64/makefile index 330c87828..2ca45a747 100644 --- a/sources/core/apps/weather/target/amd64/makefile +++ b/sources/core/apps/weather/target/amd64/makefile @@ -18,8 +18,7 @@ VERSION = 0-0-1 CFLAGS = -Werror LDFLAGS = -Wall \ - -lc \ - -lz + -lc # Recursive Wild Card rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) @@ -37,7 +36,7 @@ $(LIB)/%_c.o: $(SOURCE)/%.c link: @ mkdir -m 777 -p $(BIN) - @ $(CC) $(LDFLAGS) -o $(BIN)/weather $(OBJS) $(LIBRARIES)/libcurl.a $(LIBRARIES)/libtls.a $(LIBRARIES)/libssl.a + @ $(CC) $(LDFLAGS) -o $(BIN)/weather $(OBJS) $(LIBRARIES)/libcurl.a $(LIBRARIES)/libtls.a $(LIBRARIES)/libssl.a $(LIBRARIES)/libz.a tar: @ mkdir -m 777 -p $(TAR) diff --git a/sources/core/apps/welcome/source/core/core.c b/sources/core/apps/welcome/source/core/core.c index 2c03039e4..c74bc87f0 100644 --- a/sources/core/apps/welcome/source/core/core.c +++ b/sources/core/apps/welcome/source/core/core.c @@ -18,19 +18,20 @@ #include #include -#define TEXT_WIDTH 500 -#define TEXT_MARGIN 100 -#define TITLE_SIZE 36 -#define TEXT_SIZE 27 -#define SIGNATURE_SIZE 24 -#define TEXT_START TEXT_MARGIN / 2 -#define TEXT_COLOR 0xffffff -#define LINK_COLOR 0x33ddff -#define TEXT_BACKGROUND 0x222222 -#define TEXT_BOX_WIDTH TEXT_WIDTH + TEXT_MARGIN -#define SLIDE_TIME 5000 -#define PROGRESSBAR_HEIGHT 50 -#define PROGRESSBAR_COLOR 0xffffff +#define TEXT_WIDTH (500) +#define TEXT_MARGIN (100) +#define TITLE_SIZE (36) +#define TEXT_SIZE (27) +#define SIGNATURE_SIZE (24) +#define TEXT_START (TEXT_MARGIN / 2) +#define TEXT_COLOR (0xffffff) +#define LINK_COLOR (0x33ddff) +#define TEXT_BACKGROUND (0x222222) +#define TEXT_BOX_WIDTH (TEXT_WIDTH + TEXT_MARGIN) +#define SLIDE_TIME (5000) +#define PROGRESSBAR_HEIGHT (5) +#define PROGRESSBAR_COLOR (0xffffff) +#define INFO_SIZE (16) kfont_t font; @@ -59,6 +60,7 @@ int get_key(int* pressed, uint64_t* key){ *pressed = false; } *key = buffer & ~((uint64_t)1 << 63); + return 1; } return 0; } @@ -69,18 +71,53 @@ int wait_for_the_next_slide(){ uint64_t current_tick = start_tick; uint64_t tick_to_stop = start_tick + SLIDE_TIME; - while(current_tick < tick_to_stop){ - current_tick = get_ticks_ms(); - uint64_t progress_size = ((current_tick - start_tick) * TEXT_BOX_WIDTH) / SLIDE_TIME; - draw_rectangle(&fb, 0, fb.height - PROGRESSBAR_HEIGHT, progress_size, PROGRESSBAR_HEIGHT, PROGRESSBAR_COLOR); - draw_frame(); + set_pen_size(font, INFO_SIZE); + write_paragraph(font, -1, fb.height - INFO_SIZE - (PROGRESSBAR_HEIGHT * 4) - 10, fmin(TEXT_WIDTH, fb.width), PARAGRAPH_CENTER, "Quit : | Next : | Pause :

\n"); + + bool is_paused = false; + uint64_t progress_size = 0; + + while(current_tick < tick_to_stop || is_paused){ + if(!is_paused){ + current_tick = get_ticks_ms(); + progress_size = ((current_tick - start_tick) * TEXT_BOX_WIDTH) / SLIDE_TIME; + draw_rectangle(&fb, 0, fb.height - PROGRESSBAR_HEIGHT, progress_size, PROGRESSBAR_HEIGHT, PROGRESSBAR_COLOR); + draw_frame(); + } + + int pressed; + uint64_t key; + if(get_key(&pressed, &key)){ + if(pressed && key == 28){ + break; + } + if(pressed && key == 1){ + ret = 1; + break; + } + if(pressed && key == 25){ + is_paused = true; + draw_rectangle(&fb, 0, fb.height - PROGRESSBAR_HEIGHT, progress_size, PROGRESSBAR_HEIGHT, TEXT_BACKGROUND); + draw_frame(); + } + if(!pressed && key == 25){ + if(is_paused){ + start_tick = get_ticks_ms(); + current_tick = start_tick; + tick_to_stop = start_tick + SLIDE_TIME; + is_paused = false; + } + } + } } return ret; } int main(int argc, char* argv[]){ - fb_fd = open("/dev/fb0", O_RDWR); + fb_fd = open("/dev/fb0", O_RDWR); + + printf("Loading welcome app...\n"); assert(fb_fd >= 0); diff --git a/sources/core/apps/welcome/target/amd64/makefile b/sources/core/apps/welcome/target/amd64/makefile index 3c64882f8..fc435adc1 100644 --- a/sources/core/apps/welcome/target/amd64/makefile +++ b/sources/core/apps/welcome/target/amd64/makefile @@ -16,8 +16,7 @@ LIB = lib CFLAGS = -Werror LDFLAGS = -Wall \ - -lc \ - -lz + -lc # Recursive Wild Card rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) @@ -35,7 +34,7 @@ $(LIB)/%_c.o: $(SOURCE)/%.c link: @ mkdir -m 777 -p $(BIN) - @ $(CC) $(LDFLAGS) -o $(BIN)/welcome $(OBJS) $(LIBRARIES)/libkot-graphics.a $(LIBRARIES)/libfreetype.a $(LIBRARIES)/libturbojpeg.a + $(CC) $(LDFLAGS) -o $(BIN)/welcome $(OBJS) $(LIBRARIES)/libkot-graphics.a $(LIBRARIES)/libfreetype.a $(LIBRARIES)/libz.a $(LIBRARIES)/libturbojpeg.a copy_res: @ mkdir -m 777 -p $(BIN)/res/welcome diff --git a/sources/core/libs/kot-graphics/source/utils/utils.c b/sources/core/libs/kot-graphics/source/utils/utils.c index 116bdb6d3..2686282fb 100644 --- a/sources/core/libs/kot-graphics/source/utils/utils.c +++ b/sources/core/libs/kot-graphics/source/utils/utils.c @@ -57,7 +57,7 @@ uint32_t blend_alpha(uint32_t color, uint8_t factor){ void draw_rectangle(kframebuffer_t* fb, uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t color){ for (uint32_t i = 0; i < width; i++) { for (uint32_t j = 0; j < height; j++) { - *(uint32_t*)((uint64_t)fb->buffer + i * fb->btpp + j * fb->pitch) = color; + *(uint32_t*)((uint64_t)fb->buffer + (i + x) * fb->btpp + (j + y) * fb->pitch) = color; } } } \ No newline at end of file