65oo2/vm/main.c

82 lines
1.3 KiB
C
Raw Permalink Normal View History

2024-02-29 12:01:58 +00:00
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <SDL.h>
2024-04-25 19:27:27 +00:00
#include "libutils/utils.h"
#include "video.h"
2024-02-29 12:01:58 +00:00
2024-04-25 19:27:27 +00:00
static int
vm_maim(void)
{
SDL_Event event;
int run;
if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO) != 0)
{
fatal("SDL: %s", SDL_GetError());
}
monitor_setup();
run = 1;
while (run)
{
while(SDL_PollEvent(&event))
{
if(event.type == SDL_QUIT)
{
run = 0;
}
}
monitor_draw();
}
monitor_cleanup();
SDL_Quit();
return (EXIT_SUCCESS);
}
2024-02-29 12:01:58 +00:00
static void
usage(int retcode)
{
if (retcode == EXIT_FAILURE)
{
fprintf(stderr,
2024-04-25 19:27:27 +00:00
"Try '%s -h' for more information.\n", get_exec_name());
2024-02-29 12:01:58 +00:00
}
else
{
2024-04-25 19:27:27 +00:00
printf("Usage: %s [-hV] [-b bios]\n", get_exec_name());
2024-02-29 12:01:58 +00:00
printf("\t-h\tdisplay this help and exit\n");
printf("\t-V\toutput version information\n");
printf("\nReport bugs to <%s>\n", PACKAGE_BUGREPORT);
}
exit(retcode);
}
int
main(int argc, char **argv)
{
2024-04-25 19:27:27 +00:00
set_exec_name(argv[0]);
2024-02-29 12:01:58 +00:00
while ((argc > 1) && (argv[1][0] == '-'))
{
switch (argv[1][1])
{
case 'h':
usage(EXIT_SUCCESS);
break;
case 'V':
version();
break;
default:
usage(EXIT_FAILURE);
break;
}
argv++;
argc--;
}
2024-04-25 19:27:27 +00:00
return (vm_maim());
2024-02-29 12:01:58 +00:00
}