#include <sys/types.h>
#include "../libsdl/sdl.h"
#include "../libsdl/opengl.h"
+#include "../libsdl/print.h"
#include "../libcpu/m68k.h"
#include "../libcpu/execute.h"
#include "../libvideo/video.h"
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"))
config_amiga_speed = 0;
else {
illegal_parameter:
- printf("Illegal parameter, use '--help'!\n");
+ print_info("Illegal parameter, use '--help'!\n");
return -1;
}
} else
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++;
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;
}
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);
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;
}
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)
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:
/* 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;
}
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;
}
/* 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();