aboutsummaryrefslogtreecommitdiff
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
parenta04d006652bc7023ec0d5fa4a299789f1b69b790 (diff)
downloadgold-mine-run-87388f510f800aa4bc1bb78e35b488ea5636ce87.tar.gz
gold-mine-run-87388f510f800aa4bc1bb78e35b488ea5636ce87.zip
CLI and no sound option
-rw-r--r--src/main.c38
-rw-r--r--src/sound.c5
-rw-r--r--src/sound.h2
3 files changed, 40 insertions, 5 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;
diff --git a/src/sound.c b/src/sound.c
index f19b7ff..0a10ae4 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -35,11 +35,12 @@ static MODULE *music = NULL;
static uint8_t queue[MAX_QUEUE];
static uint8_t queue_top;
-uint8_t sound_init()
+uint8_t sound_init(uint8_t nosound)
{
MikMod_InitThreads();
- MikMod_RegisterDriver(&drv_sb);
+ if (!nosound)
+ MikMod_RegisterDriver(&drv_sb);
MikMod_RegisterDriver(&drv_nos);
MikMod_RegisterLoader(&load_it);
diff --git a/src/sound.h b/src/sound.h
index be4df88..cd7c20c 100644
--- a/src/sound.h
+++ b/src/sound.h
@@ -11,7 +11,7 @@ enum {
EFX_DEATH,
};
-uint8_t sound_init();
+uint8_t sound_init(uint8_t nosound);
void sound_free();
void sound_update();