aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-08 10:04:27 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-08 10:04:27 +0100
commit87388f510f800aa4bc1bb78e35b488ea5636ce87 (patch)
tree8e3f4c35976fc3a26d1540471946fe9c213634d3 /src/main.c
parenta04d006652bc7023ec0d5fa4a299789f1b69b790 (diff)
downloadgold-mine-run-87388f510f800aa4bc1bb78e35b488ea5636ce87.tar.gz
gold-mine-run-87388f510f800aa4bc1bb78e35b488ea5636ce87.zip
CLI and no sound option
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index d5b9df8..c18318e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -12,10 +12,25 @@
#include "menu.h"
#include "game.h"
+#define GAME_NAME "Gold Mine Run!"
+#define GAME_VERSION "A0"
+#define GAME_URL "https://git.usebox.net/dos-jam-2023/about/"
+
/* disable paging because our int handlers are written in C */
int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY;
-void free_all()
+static void run_help(const char *argv0)
+{
+ printf("usage: %s\n\n"
+ " -h\tthis help screen\n"
+ " -v\tprint version and exit\n"
+ " -ns\trun the game with no sound\n\n"
+ "More info and updates:\n"
+ " " GAME_URL "\n\n",
+ argv0);
+}
+
+static void free_all()
{
timer_free();
keyb_free();
@@ -24,7 +39,26 @@ void free_all()
int main(int argc, char *argv[])
{
- if (!sound_init())
+ uint8_t nosound = 0;
+
+ if (argc > 1)
+ {
+ for (uint8_t i = 1; i < argc; i++)
+ if (!strcmp(argv[i], "-h"))
+ {
+ run_help(argv[0]);
+ return 0;
+ }
+ else if (!strcmp(argv[i], "-v"))
+ {
+ printf(GAME_NAME " " GAME_VERSION "\n");
+ return 0;
+ }
+ else if (!strcmp(argv[i], "-ns"))
+ nosound = 1;
+ }
+
+ if (!sound_init(nosound))
{
fprintf(stderr, "ERROR: failed to init sound\n");
return 1;