From 40f4e37abc55a8d1a7664cf165cb2958ddd6f1ee Mon Sep 17 00:00:00 2001 From: Apaczer <94932128+Apaczer@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:49:42 +0200 Subject: [PATCH 1/5] accept only integer type values for arguments --- logo.cpp | 22 +++++++++++++--------- logo.h | 8 ++++---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/logo.cpp b/logo.cpp index 5f5087e..4a84be8 100644 --- a/logo.cpp +++ b/logo.cpp @@ -33,12 +33,12 @@ //---------------------------------------------------// int main(int argc, char* argv[]) { - memset(&argfloat, 0, sizeof(argfloat)); + memset(&argint, 0, sizeof(argint)); if (argc == 1) { args = false; } else if (argc == 4) { for (size_t i = 1; i < argc; ++i) { - argfloat[i] = strtof(argv[i], &str); + argint[i] = strtof(argv[i], &str); if (*str != '\0') { fprintf(stderr, "Invalid argument: %s\n", argv[i]); if (args) args = false; @@ -54,14 +54,18 @@ int main(int argc, char* argv[]) { } if (args) { - animdel = argfloat[1] * 60; - enddel = argfloat[2] * 60; - animfps = argfloat[3]; + animdel = argint[1] * 60; + enddel = argint[2] * 60; + animspeed = argint[3]; } else { animdel = ANIMDELAY; enddel = ENDDELAY; - animfps = ANIMSPEED; - printf("Usage: %s \nRunning default setup: %s %f %f %d\n", argv[0], argv[0], animdel/60, enddel/60, animfps); + animspeed = ANIMSPEED; + printf("Usage: %s \nRunning default setup: %s", argv[0], argv[0]); + if ((int)animdel%60 != 0 || (int)enddel%60 != 0) + printf(" %i.%i %i.%i %i\n", (int)animdel/60, (int)animdel%60, (int)enddel/60, (int)enddel%60, animspeed); + else + printf(" %i %i %i\n", (int)animdel/60, (int)enddel/60, animspeed); } homepath = getenv("HOME"); @@ -127,7 +131,7 @@ int main(int argc, char* argv[]) { color = SDL_MapRGB(screen->format, R, G, B); dest_y = (screen->h - logoimg->h) / 2; curr_time = old_time = SDL_GetTicks(); - for (int i = 0 - logoimg->h - animdel; i <= dest_y && (!quit_app); i = i + animfps) { + for (int i = 0 - logoimg->h - animdel; i <= dest_y && (!quit_app); i = i + animspeed) { input_poll(); rect.x = 0; rect.y = 0; @@ -186,4 +190,4 @@ void input_poll() { break; } } -} \ No newline at end of file +} diff --git a/logo.h b/logo.h index 2042dde..f2f3a32 100644 --- a/logo.h +++ b/logo.h @@ -13,10 +13,10 @@ Mix_Chunk *logosound; bool quit_app = false; bool args = true; -float animdel, enddel; -int animfps; +int animdel, enddel; +int animspeed; char* str; -float argfloat[3]; +float argint[3]; void quit(); void input_poll(); @@ -28,4 +28,4 @@ int dest_y; uint32_t curr_time, old_time; uint32_t color; bool blitbg = false; -#endif /*LOGO_H_*/ \ No newline at end of file +#endif /*LOGO_H_*/ From 57b39941392b916b69ad2ee1c2e46ad75382530e Mon Sep 17 00:00:00 2001 From: Apaczer <94932128+Apaczer@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:55:08 +0200 Subject: [PATCH 2/5] use int types where it is expected from arithmetics --- logo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/logo.cpp b/logo.cpp index 4a84be8..7beb5bf 100644 --- a/logo.cpp +++ b/logo.cpp @@ -129,7 +129,7 @@ int main(int argc, char* argv[]) { } color = SDL_MapRGB(screen->format, R, G, B); - dest_y = (screen->h - logoimg->h) / 2; + dest_y = (int)(screen->h - logoimg->h) / 2; curr_time = old_time = SDL_GetTicks(); for (int i = 0 - logoimg->h - animdel; i <= dest_y && (!quit_app); i = i + animspeed) { input_poll(); @@ -142,7 +142,7 @@ int main(int argc, char* argv[]) { } else { SDL_FillRect(screen, &rect, color); } - dstrect.x = (screen->w - logoimg->w) / 2; + dstrect.x = (int)(screen->w - logoimg->w) / 2; dstrect.y = i; dstrect.w = logoimg->w; dstrect.h = logoimg->h; @@ -161,7 +161,7 @@ int main(int argc, char* argv[]) { input_poll(); } - for (int j = 0 ; j < (sqrt(2+8*enddel*10)-1)/2 && (!quit_app); j++){ + for (int j = 0 ; j < (int)(sqrt(2+8*enddel*10)-1)/2 && (!quit_app); j++){ input_poll(); SDL_Delay(j); } From 5fa675f18a72ee2dc881c7f47a63fa05a1ec250d Mon Sep 17 00:00:00 2001 From: Apaczer <94932128+Apaczer@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:09:24 +0200 Subject: [PATCH 3/5] use direct values from args read --- README.md | 6 +++--- logo.cpp | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b002fd8..ee7de22 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ **Usage:** -`boot-logo ` +`boot-logo ` -- logo_start = delay until the logo start in [seconds] -- logo_ending = time from the moment the logo stops moving and sound is played until the logo app closes in [seconds] +- logo_start = delay until the logo start in [1/60th of a second] +- logo_ending = time from the moment the logo stops moving and sound is played until the logo app closes in [1/60th of a second] - logo_speed = speed at which the logo moves in [pixels per frame] You can customize your boot-logo output by modyfing following files: diff --git a/logo.cpp b/logo.cpp index 7beb5bf..75bf5f6 100644 --- a/logo.cpp +++ b/logo.cpp @@ -54,18 +54,16 @@ int main(int argc, char* argv[]) { } if (args) { - animdel = argint[1] * 60; - enddel = argint[2] * 60; + animdel = argint[1]; + enddel = argint[2]; animspeed = argint[3]; } else { animdel = ANIMDELAY; enddel = ENDDELAY; animspeed = ANIMSPEED; - printf("Usage: %s \nRunning default setup: %s", argv[0], argv[0]); - if ((int)animdel%60 != 0 || (int)enddel%60 != 0) - printf(" %i.%i %i.%i %i\n", (int)animdel/60, (int)animdel%60, (int)enddel/60, (int)enddel%60, animspeed); - else - printf(" %i %i %i\n", (int)animdel/60, (int)enddel/60, animspeed); + printf("Usage: %s \nRunning default setup: %s", argv[0], argv[0]); + printf(" %i %i %i\n", animdel, enddel, animspeed); + printf("tick - 1/60th of a second\nppf - pixels per frame\n"); } homepath = getenv("HOME"); From dd63bcb5a6ee02faeec4b20cecf2f766f8042e88 Mon Sep 17 00:00:00 2001 From: Apaczer <94932128+Apaczer@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:14:23 +0200 Subject: [PATCH 4/5] change EOF in logo.h to LF --- logo.h | 62 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/logo.h b/logo.h index f2f3a32..3726778 100644 --- a/logo.h +++ b/logo.h @@ -1,31 +1,31 @@ -#ifndef LOGO_H_ -#define LOGO_H_ -SDL_RWops *RWops; -SDL_Surface *logoimg; -SDL_Surface *screen; -SDL_RWops *RWops2; -SDL_Rect rect; -SDL_Rect dstrect; -SDL_Event event; -SDL_Surface* logobg; -Mix_Chunk *logosound; - -bool quit_app = false; - -bool args = true; -int animdel, enddel; -int animspeed; -char* str; -float argint[3]; - -void quit(); -void input_poll(); - -char* homepath; -char logoimg_path[256], logosound_path[256], logobg_path[256]; - -int dest_y; -uint32_t curr_time, old_time; -uint32_t color; -bool blitbg = false; -#endif /*LOGO_H_*/ +#ifndef LOGO_H_ +#define LOGO_H_ +SDL_RWops *RWops; +SDL_Surface *logoimg; +SDL_Surface *screen; +SDL_RWops *RWops2; +SDL_Rect rect; +SDL_Rect dstrect; +SDL_Event event; +SDL_Surface* logobg; +Mix_Chunk *logosound; + +bool quit_app = false; + +bool args = true; +int animdel, enddel; +int animspeed; +char* str; +float argint[3]; + +void quit(); +void input_poll(); + +char* homepath; +char logoimg_path[256], logosound_path[256], logobg_path[256]; + +int dest_y; +uint32_t curr_time, old_time; +uint32_t color; +bool blitbg = false; +#endif /*LOGO_H_*/ From a4c98101c3cb9c4e9c3f76e4f0e9911d3f3efca0 Mon Sep 17 00:00:00 2001 From: Apaczer <94932128+Apaczer@users.noreply.github.com> Date: Sat, 27 Jul 2024 13:50:00 +0200 Subject: [PATCH 5/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ee7de22..c4272f0 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ `boot-logo ` -- logo_start = delay until the logo start in [1/60th of a second] -- logo_ending = time from the moment the logo stops moving and sound is played until the logo app closes in [1/60th of a second] +- logo_start = delay until the logo start in [tick=¹⁄₆₀ of a second] +- logo_ending = time from the moment the logo stops moving and sound is played until the logo app closes in [tick=¹⁄₆₀ of a second] - logo_speed = speed at which the logo moves in [pixels per frame] You can customize your boot-logo output by modyfing following files: