X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=mercenary-reloaded.git;a=blobdiff_plain;f=src%2Fmercenary%2Fmain.c;h=c15f23e38b89b18c2a2d6d890e698e28542c09f5;hp=384b821da7d94f04ed632c998b1e69f0b6a7aece;hb=99218ad73b476cad66afa0efb8de9c763108747b;hpb=f9e72953571609089acedec0ce3e275cf63ef008 diff --git a/src/mercenary/main.c b/src/mercenary/main.c index 384b821..c15f23e 100644 --- a/src/mercenary/main.c +++ b/src/mercenary/main.c @@ -24,6 +24,7 @@ #include #include "../libsdl/sdl.h" #include "../libsdl/opengl.h" +#include "../libsdl/print.h" #include "../libcpu/m68k.h" #include "../libcpu/execute.h" #include "../libvideo/video.h" @@ -83,20 +84,20 @@ int parse_args(int argc, char *argv[]) while (argc > i) { if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { - printf("Usage: %s\n", argv[0]); - printf(" -s --amiga-speed original | full\n"); - printf(" Set speed of rendering to original Amiga or full speed.\n"); - printf(" -v --video-filter on | off\n"); - printf(" Set video filter.\n"); - printf(" -a --audio-filter on | off\n"); - printf(" Set audio filter.\n"); + print_info("Usage: %s\n", argv[0]); + print_info(" -s --amiga-speed original | full\n"); + print_info(" Set speed of rendering to original Amiga or full speed.\n"); + print_info(" -v --video-filter on | off\n"); + print_info(" Set video filter.\n"); + print_info(" -a --audio-filter on | off\n"); + print_info(" Set audio filter.\n"); return -1; } else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--amiga-speed")) { i++; if (argc == i) { missing_parameter: - printf("Missing parameter, use '--help'!\n"); + print_info("Missing parameter, use '--help'!\n"); return -1; } if (!strcmp(argv[i], "original")) @@ -106,7 +107,7 @@ missing_parameter: config_amiga_speed = 0; else { illegal_parameter: - printf("Illegal parameter, use '--help'!\n"); + print_info("Illegal parameter, use '--help'!\n"); return -1; } } else @@ -134,7 +135,7 @@ illegal_parameter: else goto illegal_parameter; } else { - printf("Illegal option '%s', use '--help'!\n", argv[i]); + print_info("Illegal option '%s', use '--help'!\n", argv[i]); return -1; } i++; @@ -284,7 +285,7 @@ static int last_track = 0; static void disk_read(int track, int __attribute__((unused)) side, uint32_t data, uint16_t length) { if (length > sizeof(game_save[0])) { - fprintf(stderr, "loading game state failed, because length exceeds game save data size, please fix!\n"); + print_error("loading game state failed, because length exceeds game save data size, please fix!\n"); return; } @@ -306,7 +307,7 @@ static void disk_read(int track, int __attribute__((unused)) side, uint32_t data fp = fopen(filename, "r"); if (!fp) { fail: - fprintf(stderr, "failed to load game from '%s'\n", filename); + print_error("failed to load game from '%s'\n", filename); goto copy; } got = fread(game_save, sizeof(game_save[0]), 2, fp); @@ -328,14 +329,14 @@ static void disk_write(int track, int __attribute__((unused)) side, uint32_t dat length -= 0x200; if (length != sizeof(game_save[0])) { - fprintf(stderr, "saving game state failed, because length of data does not match, please fix!\n"); + print_error("saving game state failed, because length of data does not match, please fix!\n"); return; } /* don't save if last track is the same, because disk is written on both sides with the same data */ if (track == last_track) { if (memcmp(memory + data, game_save[track & 1], length)) { - fprintf(stderr, "saving game data on other side of the disk is different, please fix!\n"); + print_error("saving game data on other side of the disk is different, please fix!\n"); } return; } @@ -361,10 +362,10 @@ static void disk_write(int track, int __attribute__((unused)) side, uint32_t dat fp = fopen(filename, "w"); if (!fp) { fail: - fprintf(stderr, "failed to save game to '%s'\n", filename); + print_error("failed to save game to '%s'\n", filename); return; } - printf("Game state saved to '%s'\n", filename); + print_info("Game state saved to '%s'\n", filename); wrote = fwrite(game_save, sizeof(game_save[0]), 2, fp); fclose(fp); if (wrote != 2) @@ -384,19 +385,19 @@ static void keyboard_sdl(int down, SDL_Keycode sym) case SDLK_v: if (down && ctrl) { config_video_filter ^= 1; - printf("video filter: %s\n", (config_video_filter) ? "on" : "off"); + print_info("video filter: %s\n", (config_video_filter) ? "on" : "off"); } break; case SDLK_a: if (down && ctrl) { config_audio_filter ^= 1; - printf("audio filter: %s\n", (config_audio_filter) ? "on" : "off"); + print_info("audio filter: %s\n", (config_audio_filter) ? "on" : "off"); } break; case SDLK_s: if (down && ctrl) { config_amiga_speed ^= 1; - printf("amiga speed: %s\n", (config_amiga_speed) ? "original" : "full"); + print_info("amiga speed: %s\n", (config_amiga_speed) ? "original" : "full"); } break; case SDLK_c: @@ -571,16 +572,16 @@ int main(int argc, char *argv[]) /* allocate image */ image = calloc(IMAGE_WIDTH * IMAGE_HEIGHT * ((double_size) ? 4 : 1), 3); if (!image) { - fprintf(stderr, "Failed to allocate image buffer\n"); + print_error("Failed to allocate image buffer\n"); goto done; } if ((SOUND_SAMPLERATE % IRQ_RATE)) { - fprintf(stderr, "Sample rate must be a multiple of IRQ rate, please fix!\n"); + print_error("Sample rate must be a multiple of IRQ rate, please fix!\n"); goto done; } if ((1000 % IRQ_RATE)) { - fprintf(stderr, "1000 (Ticks per second) rate must be a multiple of IRQ rate, please fix!\n"); + print_error("1000 (Ticks per second) rate must be a multiple of IRQ rate, please fix!\n"); goto done; } @@ -596,19 +597,19 @@ int main(int argc, char *argv[]) sound_buffer_size = SOUND_SAMPLERATE / IRQ_RATE * SOUND_CHUNKS; sound_buffer = calloc(sound_buffer_size, sizeof(*sound_buffer)); if (!sound_buffer) { - fprintf(stderr, "Failed to allocate image buffer\n"); + print_error("Failed to allocate image buffer\n"); goto done; } /* allocate memory */ memory = calloc(MEMORY_SIZE, 1); if (!memory) { - fprintf(stderr, "Failed to allocate cpu's memory\n"); + print_error("Failed to allocate cpu's memory\n"); goto done; } chipreg = calloc(IOSIZE, 1); if (!chipreg) { - fprintf(stderr, "Failed to allocate chip register\n"); + print_error("Failed to allocate chip register\n"); goto done; } @@ -639,16 +640,16 @@ int main(int argc, char *argv[]) /* start cpu */ reset_cpu(); - printf("**********************************\n"); - printf("* Welcome to Mercenary Reloaded! *\n"); - printf("**********************************\n\n"); - printf("Press CTRL + cursor keys to select inventory or pickup/drop item.\n"); - printf("Press CTRL + f to toggle full screen.\n"); - printf("Press CTRL + s to toggle rendering speed.\n"); - printf("Press CTRL + v to toggle video filter.\n"); - printf("Press CTRL + a to toggle audio filter.\n"); - printf("Press CTRL + c to exit game.\n\n"); - printf("Use '--help' as command line option for configuration settings.\n\n"); + print_info("**********************************\n"); + print_info("* Welcome to Mercenary Reloaded! *\n"); + print_info("**********************************\n\n"); + print_info("Press CTRL + cursor keys to select inventory or pickup/drop item.\n"); + print_info("Press CTRL + f to toggle full screen.\n"); + print_info("Press CTRL + s to toggle rendering speed.\n"); + print_info("Press CTRL + v to toggle video filter.\n"); + print_info("Press CTRL + a to toggle audio filter.\n"); + print_info("Press CTRL + c to exit game.\n\n"); + print_info("Use '--help' as command line option for configuration settings.\n\n"); /* run game */ main_loop();