Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accept only integer type values for arguments #16

Merged
merged 5 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

**Usage:**

`boot-logo <logo_start[sec]> <logo_ending[sec]> <logo_speed[fps]>`
`boot-logo <logo_start[tick]> <logo_ending[tick]> <logo_speed[ppf]>`

- 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 [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:
Expand Down
26 changes: 14 additions & 12 deletions logo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -54,14 +54,16 @@ int main(int argc, char* argv[]) {
}

if (args) {
animdel = argfloat[1] * 60;
enddel = argfloat[2] * 60;
animfps = argfloat[3];
animdel = argint[1];
enddel = argint[2];
animspeed = argint[3];
} else {
animdel = ANIMDELAY;
enddel = ENDDELAY;
animfps = ANIMSPEED;
printf("Usage: %s <logo_start[sec]> <logo_ending[sec]> <logo_speed[fps]>\nRunning default setup: %s %f %f %d\n", argv[0], argv[0], animdel/60, enddel/60, animfps);
animspeed = ANIMSPEED;
printf("Usage: %s <logo_start[tick]> <logo_ending[tick]> <logo_speed[ppf]>\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");
Expand Down Expand Up @@ -125,9 +127,9 @@ 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 + animfps) {
for (int i = 0 - logoimg->h - animdel; i <= dest_y && (!quit_app); i = i + animspeed) {
input_poll();
rect.x = 0;
rect.y = 0;
Expand All @@ -138,7 +140,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;
Expand All @@ -157,7 +159,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);
}
Expand Down Expand Up @@ -186,4 +188,4 @@ void input_poll() {
break;
}
}
}
}
62 changes: 31 additions & 31 deletions logo.h
Original file line number Diff line number Diff line change
@@ -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;
float animdel, enddel;
int animfps;
char* str;
float argfloat[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_*/