aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2022-11-13 03:36:25 -0500
committerB. Watson <urchlay@slackware.uk>2022-11-13 03:36:25 -0500
commite571754b3e912aec7338cbb73ca208c4595f4a24 (patch)
treef2d6a6d34e29ed3cea8ea8e1f97fd98669b5b41f
parent9d0a7125585360cad3ed3e6ddb6a6168f1503eeb (diff)
downloaddla-asm-e571754b3e912aec7338cbb73ca208c4595f4a24.tar.gz
Use prettier colors in dla2csv.xex.
-rw-r--r--dla2csv.c38
-rw-r--r--dla2csv.xexbin11176 -> 11297 bytes
2 files changed, 29 insertions, 9 deletions
diff --git a/dla2csv.c b/dla2csv.c
index 79de16a..b66b0a4 100644
--- a/dla2csv.c
+++ b/dla2csv.c
@@ -28,7 +28,9 @@
#define STRINGBUF_SIZE 256
-#define PRINT_ID printf("DLA to CSV converter v" VERSION ".\n")
+void print_id(void) {
+ printf("DLA to CSV converter v" VERSION ".\n");
+}
#ifdef __ATARI__
#include <atari.h>
@@ -36,6 +38,10 @@
/* cc65 doesn't "localize" \b to the Atari backspace character, so: */
#define BS CH_DEL
+/* I like these colors. Also they match dla.xex. */
+#define TEXT_COLOR 0x0e
+#define TEXT_BG_COLOR 0x90
+
/* On the Atari, we should show Atari-style error messages, including
the familiar error number.
Another reason to do this: on the Atari, perror() says "Bad file number"
@@ -60,6 +66,13 @@ void disable_break() {
OS.pokmsk = POKEY_WRITE.irqen = (OS.pokmsk & 0x7f);
}
+char old_color1, old_color2;
+
+void restore_colors(void) {
+ OS.color1 = old_color1;
+ OS.color2 = old_color2;
+}
+
void init_console(void) {
/* cc65's startup code turns off caps lock. turn it back on,
since we're typing DOS filenames. in BASIC this would be:
@@ -73,12 +86,24 @@ void init_console(void) {
/* clear the screen */
putchar(CH_CLR);
+
+ /* save the old text & background colors */
+ old_color1 = OS.color1;
+ old_color2 = OS.color2;
+
+ /* Use my glorious and eye-catching color scheme :) */
+ OS.color1 = TEXT_COLOR;
+ OS.color2 = TEXT_BG_COLOR;
+
+ /* Put things back the way they were, when we exit. */
+ atexit(restore_colors);
+ atexit(enable_break);
}
void print_banner(void) {
int i;
- PRINT_ID;
+ print_id();
printf("\n"
"At any filename prompt, you may:\n" );
@@ -136,13 +161,11 @@ void show_dir(char drive) {
Commodore or Apple II). */
#define BS '\b'
#define PERROR(x) perror(x)
+ #define print_banner() print_id()
+ #define noop()
#define enable_break() noop()
#define disable_break() noop()
#define init_console() noop()
-void noop(void) { }
-void print_banner(void) {
- PRINT_ID;
-}
#endif
char inbuf[INBUF_SIZE];
@@ -174,7 +197,6 @@ void readstring(void) {
memset(stringbuf, 0, STRINGBUF_SIZE);
result = fgets(stringbuf, STRINGBUF_SIZE - 1, stdin);
if(result == NULL) {
- enable_break();
exit(1);
}
}
@@ -216,7 +238,6 @@ FILE *prompt_filename(const char *name, const char *mode) {
stringbuf[strlen(stringbuf) - 1] = '\0'; /* kill trailing \n */
if(strlen(stringbuf) == 0) {
if(prompt_yn("Exit program", 0)) {
- enable_break();
exit(0);
}
continue;
@@ -431,6 +452,5 @@ int main(int argc, char **argv) {
if(!prompt_yn("\nConvert another file", 1))
break;
}
- enable_break();
exit(0);
}
diff --git a/dla2csv.xex b/dla2csv.xex
index f89fdd2..7bf1527 100644
--- a/dla2csv.xex
+++ b/dla2csv.xex
Binary files differ