Skip to content

Commit

Permalink
add option to start with a specific volume
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed May 20, 2023
1 parent 5032c79 commit cf7c092
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/frontend_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static void posix_zzt_help(int argc, char **argv) {
fprintf(stderr, " -m [] set memory limit, in KB (64-640)\n");
fprintf(stderr, " -M [] set extended memory limit, in KB\n");
fprintf(stderr, " -t enable world testing mode (skip K, C, ENTER)\n");
fprintf(stderr, " -V [] set starting volume (0-100)\n");
fprintf(stderr, "\n");
fprintf(stderr, "See <https://zeta.asie.pl/> for more information.\n");
}
Expand All @@ -74,9 +75,10 @@ static int posix_zzt_init(int argc, char **argv) {
int memory_kbs = -1;
int extended_memory_kbs = -1;
int video_blink = 1;
int starting_volume = 20;

#ifdef USE_GETOPT
while ((c = getopt(argc, argv, "D:be:hl:m:M:t")) >= 0) {
while ((c = getopt(argc, argv, "D:be:hl:m:M:tV:")) >= 0) {
switch(c) {
case 'D':
posix_zzt_arg_note_delay = atof(optarg);
Expand Down Expand Up @@ -116,6 +118,9 @@ static int posix_zzt_init(int argc, char **argv) {
case 't':
skip_kc = 1;
break;
case 'V':
starting_volume = atoi(optarg);
break;
case '?':
fprintf(stderr, "Could not parse options! Try %s -h for help.\n", argv > 0 ? argv[0] : "running with");
exit(0);
Expand All @@ -127,6 +132,9 @@ static int posix_zzt_init(int argc, char **argv) {
zzt_init(memory_kbs);
zzt_set_max_extended_memory(extended_memory_kbs);
zzt_load_blink(video_blink);
if (starting_volume >= 0) {
audio_stream_set_volume(starting_volume * 6 / 10);
}

#ifdef USE_GETOPT
if (argc > optind && posix_vfs_exists(argv[optind])) {
Expand Down
1 change: 0 additions & 1 deletion src/sdl/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ int main(int argc, char **argv) {
if (posix_zzt_arg_note_delay >= 0.0) {
audio_set_note_delay(posix_zzt_arg_note_delay);
}
audio_stream_set_volume(audio_stream_get_max_volume() / 10);
SDL_PauseAudioDevice(audio_device, 0);
}

Expand Down

0 comments on commit cf7c092

Please sign in to comment.