diff ater/play_cmd.c @ 51:db39e8855f3d

ater: implement play-d144
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 25 Sep 2024 05:53:38 +0000
parents 16715bd149e0
children
line wrap: on
line diff
--- a/ater/play_cmd.c	Tue Sep 24 06:15:40 2024 +0000
+++ b/ater/play_cmd.c	Wed Sep 25 05:53:38 2024 +0000
@@ -47,6 +47,38 @@
 	at->play_wait_align = true;
 }
 
+void cmd_play_d144(int argc, char **argv)
+{
+	int nr, rc;
+	struct ater_subslot *at;
+
+	if (argc != 3) {
+usage:		fprintf(stderr, "usage: %s 0|1|2|3 play-file.bin\n", argv[0]);
+		return;
+	}
+	if (argv[1][0] < '0' || argv[1][0] > '3' || argv[1][1])
+		goto usage;
+	nr = argv[1][0] - '0';
+	at = &subslots[nr];
+	if (!at->is_active) {
+		fprintf(stderr, "error: subslot %d is not active\n", nr);
+		return;
+	}
+	if (!at->is_data_144) {
+		fprintf(stderr, "error: subslot %d is not in D144 mode\n", nr);
+		return;
+	}
+	if (at->play_buffer) {
+		fprintf(stderr, "error: file play already in progress\n");
+		return;
+	}
+	rc = read_binary_file_d144(argv[2], &at->play_buffer,
+				   &at->play_buf_total);
+	if (rc < 0)
+		return;		/* error msg already printed */
+	at->play_buf_ptr = 0;
+}
+
 void cmd_play_stop(int argc, char **argv)
 {
 	int nr;