aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2022-11-14 22:20:34 -0500
committerB. Watson <urchlay@slackware.uk>2022-11-14 22:20:34 -0500
commitfafd442b6ece11583a0e07da4f96fd5ab20fcee1 (patch)
tree08f5eaeaea027e1a2c4e26a9f1b5ddcf75445f4e
parentdf93c677c4c5b0aa67e6b6f08466a0071aa53531 (diff)
downloaddla-asm-fafd442b6ece11583a0e07da4f96fd5ab20fcee1.tar.gz
C formatting nitpickery.
-rw-r--r--dla2csv.c171
1 files changed, 85 insertions, 86 deletions
diff --git a/dla2csv.c b/dla2csv.c
index 1cc6769..8377af7 100644
--- a/dla2csv.c
+++ b/dla2csv.c
@@ -11,9 +11,9 @@
#include <dirent.h>
#ifdef __CC65__
- #ifndef __ATARI__
- #error Unsupported cc65 machine type: only "-t atari" is supported.
- #endif
+ /* This will error out, if someone tries to compile for e.g. Apple
+ or Commodore with cc65: */
+ #include <atari.h>
#endif
#include "dlaver.h"
@@ -33,14 +33,13 @@ void print_id(void) {
}
#ifdef __ATARI__
- #include <atari.h>
/* 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
+ #define TEXT_COLOR 0x0e
+ #define TEXT_BG_COLOR 0x90
/* On the Atari, we should show Atari-style error messages, including
the familiar error number.
@@ -49,113 +48,113 @@ void print_id(void) {
to fprintf().
On modern platforms, just use perror(). */
#define PERROR(x) atari_perror(x)
-void atari_perror(char *msg) {
- printf("%s: Error %d: %s\n", msg, _oserror, _stroserror(_oserror));
-}
+ void atari_perror(char *msg) {
+ printf("%s: Error %d: %s\n", msg, _oserror, _stroserror(_oserror));
+ }
/* cc65 doesn't play nice with the Break key on the Atari. It
works as expected during disk I/O, but if you press it while
printing to stdout or reading from stdin, the program freezes.
so call disable_break() at startup, then wrap disk I/O in
enable_break() and disable_break(). */
-void enable_break() {
- OS.pokmsk = POKEY_WRITE.irqen = (OS.pokmsk | 0x80);
-}
+ void enable_break() {
+ OS.pokmsk = POKEY_WRITE.irqen = (OS.pokmsk | 0x80);
+ }
-void disable_break() {
- OS.pokmsk = POKEY_WRITE.irqen = (OS.pokmsk & 0x7f);
-}
+ void disable_break() {
+ OS.pokmsk = POKEY_WRITE.irqen = (OS.pokmsk & 0x7f);
+ }
-char old_color1, old_color2;
+ char old_color1, old_color2;
-void restore_colors(void) {
- OS.color1 = old_color1;
- OS.color2 = 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:
- POKE 702,64 */
- OS.shflok = 0x40;
+ 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:
+ POKE 702,64 */
+ OS.shflok = 0x40;
- /* also, cc65 sets APPMHI to $bc1f (last byte before the GR.0
- display list). which causes the atari to lock up when Reset
- is pressed. I can't believe this is useful behaviour... */
- OS.appmhi = 0;
+ /* also, cc65 sets APPMHI to $bc1f (last byte before the GR.0
+ display list). which causes the atari to lock up when Reset
+ is pressed. I can't believe this is useful behaviour... */
+ OS.appmhi = 0;
- /* clear the screen */
- putchar(CH_CLR);
+ /* clear the screen */
+ putchar(CH_CLR);
- /* save the old text & background colors */
- old_color1 = OS.color1;
- old_color2 = OS.color2;
+ /* 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;
+ /* 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);
-}
+ /* Put things back the way they were, when we exit. */
+ atexit(restore_colors);
+ atexit(enable_break);
+ }
-void print_banner(void) {
- int i;
+ void print_banner(void) {
+ int i;
- print_id();
+ print_id();
- printf("\n"
- "At any filename prompt, you may:\n" );
- printf(
- "- Press Return, to exit this program.\n");
- printf(
- "- Enter a number, to get a directory of\n"
- " that drive.");
+ printf("\n"
+ "At any filename prompt, you may:\n" );
+ printf(
+ "- Press Return, to exit this program.\n");
+ printf(
+ "- Enter a number, to get a directory of\n"
+ " that drive.");
- /* be nice to emulator users. */
- for(i = 0; i < 12; i++) {
- if(OS.hatabs[i].id == 'H') {
- printf(" Use 0 for \"H:\".");
- break;
+ /* be nice to emulator users. */
+ for(i = 0; i < 12; i++) {
+ if(OS.hatabs[i].id == 'H') {
+ printf(" Use 0 for \"H:\".");
+ break;
+ }
}
+ printf("\n");
}
- printf("\n");
-}
-/* Show disk directory, in a 3-column layout.
- drive is an ASCII digit, e.g. 0x31 is drive 1. */
-void show_dir(char drive) {
- static char dirspec[16];
- char device = 'D';
- DIR *dir;
- struct dirent *ent;
- int column = 0;
-
- if(drive == '0') {
- drive++;
- device = 'H';
- }
+ /* Show disk directory, in a 3-column layout.
+ drive is an ASCII digit, e.g. 0x31 is drive 1. */
+ void show_dir(char drive) {
+ static char dirspec[16];
+ char device = 'D';
+ DIR *dir;
+ struct dirent *ent;
+ int column = 0;
+
+ if(drive == '0') {
+ drive++;
+ device = 'H';
+ }
- sprintf(dirspec, "%c%c:*.*", device, drive);
+ sprintf(dirspec, "%c%c:*.*", device, drive);
- if(!(dir = opendir(dirspec))) {
- dirspec[2] = '\0';
- PERROR(dirspec);
- return;
- }
+ if(!(dir = opendir(dirspec))) {
+ dirspec[2] = '\0';
+ PERROR(dirspec);
+ return;
+ }
- while((ent = readdir(dir))) {
- printf("%-13s", ent->d_name);
- if(++column == 3) {
- column = 0;
- putchar('\n');
+ while((ent = readdir(dir))) {
+ printf("%-13s", ent->d_name);
+ if(++column == 3) {
+ column = 0;
+ putchar('\n');
+ }
}
- }
- closedir(dir);
- if(column) putchar('\n');
-}
+ closedir(dir);
+ if(column) putchar('\n');
+ }
/* On the Atari, EOF is Ctrl-3. *Terrible* things happen if we
ever get EOF on stdin on the Atari! The screen shows gibberish