aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2022-11-18 15:58:56 -0500
committerB. Watson <urchlay@slackware.uk>2022-11-18 15:58:56 -0500
commitfcd60722034f27a0a600e9a8e802e1aa1cf7d351 (patch)
tree5ee21b32be0cfe60656e1ebed962990ab47e89cf
parent870967edae499b541ddb08b5b5523c44c8005002 (diff)
downloaddla-asm-master.tar.gz
dla2csv.xex: progress bar instead of percentage.HEADmaster
-rw-r--r--README.txt14
-rw-r--r--dla.atrbin92176 -> 92176 bytes
-rw-r--r--dla2csv.c88
-rw-r--r--dla2csv.xexbin10917 -> 10922 bytes
4 files changed, 64 insertions, 38 deletions
diff --git a/README.txt b/README.txt
index da5f057..3efc960 100644
--- a/README.txt
+++ b/README.txt
@@ -115,13 +115,13 @@ Next, you're asked for the output filename[*]. This file will be
overwritten if it exists (unless of course it can't be overwritten due
to permissions or the Atari locked-file bit).
-Next, the conversion process starts. This takes about half a minute
-on the Atari (for a file with 1000 particles), and is instantaneous
-on a modern machine. Progress is shown as a percentage. When it's
-finished, the output CSV file has been written. On the Atari, you can
-press Ctrl-C during the conversion to abort the process (and delete
-the partial CSV file). In case of error (bad filename, disk full, bad
-sector, etc), you'll be given the chance to retry the conversion.
+Next, the conversion process starts. This takes about 15-20 seconds
+on the Atari (for a file with 1000 particles), and is instantaneous on
+a modern machine. Progress is shown as a bar. When it's finished, the
+output CSV file has been written. On the Atari, you can press Ctrl-C
+during the conversion to abort the process (and delete the partial CSV
+file). In case of error (bad filename, disk full, bad sector, etc),
+you'll be given the chance to retry the conversion.
At the end of conversion, you'll be shown the number of particles.
This includes the seed particles, so e.g. if you used the single-dot
diff --git a/dla.atr b/dla.atr
index 7266dca..6757d54 100644
--- a/dla.atr
+++ b/dla.atr
Binary files differ
diff --git a/dla2csv.c b/dla2csv.c
index 413229d..8d25728 100644
--- a/dla2csv.c
+++ b/dla2csv.c
@@ -60,11 +60,6 @@ unsigned char masks[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
/* Uncomment this to see elapsed time in convert() */
#define PROFILE
-/* cc65 doesn't "localize" \b to the Atari backspace character, like it
- does for \n. If we needed it:
- #define BS CH_DEL
-*/
-
/* I like these colors. Also they match dla.xex. */
#define TEXT_COLOR 0x0e
#define TEXT_BG_COLOR 0x90
@@ -224,16 +219,10 @@ unsigned char masks[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
(*(OS.dosvec))();
}
- void backspace2(void) {
- OS.colcrs -= 2;
- }
-
void print_converting(void) {
printf("Press Ctrl-C to abort conversion.\n");
OS.crsinh = 1;
- printf("\nConverting... %%");
- putchar(0xa0);
- backspace2();
+ printf("\nConverting...\n");
}
#define enable_cursor() OS.crsinh = 0
@@ -271,10 +260,23 @@ unsigned char masks[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
}
}
+/* bar instead of percentage. j is chosen to range
+ 1 to 80 (not 0 to 79), and this should only be called
+ every other y loop. */
+ void update_progress(unsigned char i) {
+ int j = (i * 200 / 212) + 1;
+ if(j & 1) {
+ putchar(0x19); /* left half block */
+ OS.colcrs--;
+ } else {
+ putchar(0xa0); /* full block */
+ }
+ }
+
#ifdef PROFILE
#define start_profile_clock() OS.rtclok[0] = OS.rtclok[1] = OS.rtclok[2] = 0
#define print_profile_clock() \
- printf("\nElapsed time: %ds\n", ((OS.rtclok[1] << 8) | OS.rtclok[2]) / 60)
+ printf("Elapsed time: %ds\n", ((OS.rtclok[1] << 8) | OS.rtclok[2]) / 60)
#else
#define start_profile_clock()
#define print_profile_clock()
@@ -282,11 +284,6 @@ unsigned char masks[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
#else
/* non-Atari is assumed to be POSIX (and not something like
Commodore or Apple II). */
- #define BS '\b'
- void backspace2(void) {
- putchar(BS);
- putchar(BS);
- }
#define PERROR(x) perror(x)
#define print_banner() print_id()
#define noop()
@@ -298,11 +295,12 @@ unsigned char masks[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
#define start_profile_clock() noop()
#define print_profile_clock() noop()
#define fix_filename() noop()
+ #define update_progress(x) noop()
#define user_abort() 0
#define show_dir() 0
#define EXIT(x) exit(1)
#define exit_eof_stdin() exit(1)
- #define print_converting() printf("\nConverting... %%")
+ #define print_converting() printf("\nConverting...")
#define REGISTER
/* since utoa() only exists on cc65, can't use it on non-Atari. */
void writepoint(unsigned char x, unsigned char y) {
@@ -451,13 +449,30 @@ int read_file(void) {
return bytes;
}
-/* currently, on the 800 with atariserver, convert() takes:
- 5s for a DLA with no points (a file of zeroes).
- 16s for a DLA with 1000 points.
- 9s for the same DLA, with the fputs() in writepoint() commented out.
+/* currently, on the 800 with atariserver, a single-density disk image,
+ and MyDOS (no high-speed SIO) convert() takes:
+
+ - 15s for a DLA with 1000 points.
+ - 8s for the same DLA, with the fputs() in writepoint() commented out.
+ - 3s for a DLA with no points (a file of zeroes).
+
+ writing the same amount of data as the CSV file (6577 bytes)
+ with a single fwrite() takes 5.3s. comparing the first 2 times
+ above, we're taking 7s for our I/O. buffering it up and doing
+ a single write would save about 1.7s. however, for files with
+ lots of points, we might run out of memory (so have to do
+ multiple writes anyway). not worth doing really.
+
+ the progress bar adds very little overhead (around 0.3 sec),
+ compared to printing percentages (0.8 sec).
+
+ what would be worth doing: speed up the pixel-extraction (the
+ x loop and its inner j loop). it's doing ~200 particles/sec,
+ not counting the 3s overhead (~125/sec with overhead).
*/
int convert(void) {
unsigned char x, y, j, pixx;
+ char byte;
REGISTER char *inp = inbuf;
int particles = 0;
@@ -479,17 +494,16 @@ int convert(void) {
clear_keystroke();
return 0;
}
- if(y & 1) {
- backspace2();
- printf("%02d", y * 100 / HEIGHT); /* percentage */
- fflush(stdout);
- }
+ if(y & 1) update_progress(y);
for(x = 0; x < BYTEWIDTH; ++x) {
if(*inp) {
+ #if 1
+ byte = *inp;
pixx = x * 8;
for(j = 0; j < 8; ++j) {
- if(*inp & masks[j]) {
+ if(byte & masks[j]) {
writepoint(pixx + j, y);
+ /* commenting out the error-checking doesn't save time. */
if(ferror(outf)) {
PERROR(stringbuf);
fclose(outf);
@@ -499,6 +513,19 @@ int convert(void) {
particles++;
}
}
+ #else
+ /* unrolling the loop doesn't save time (!) */
+ byte = *inp;
+ pixx = x * 8;
+ if(byte & masks[0]) writepoint(pixx, y);
+ if(byte & masks[1]) writepoint(pixx + 1, y);
+ if(byte & masks[2]) writepoint(pixx + 2, y);
+ if(byte & masks[3]) writepoint(pixx + 3, y);
+ if(byte & masks[4]) writepoint(pixx + 4, y);
+ if(byte & masks[5]) writepoint(pixx + 5, y);
+ if(byte & masks[6]) writepoint(pixx + 6, y);
+ if(byte & masks[7]) writepoint(pixx + 7, y);
+ #endif
}
inp++;
}
@@ -541,8 +568,7 @@ int main(int argc, char **argv) {
if(result >= 0) {
done = 1;
- backspace2();
- printf("100%%\n%d particles.\n", result);
+ printf("%d particles.\n", result);
print_profile_clock();
} else {
if(!prompt_yn("Conversion failed, try again", 1))
diff --git a/dla2csv.xex b/dla2csv.xex
index 7eefaa1..70b76d6 100644
--- a/dla2csv.xex
+++ b/dla2csv.xex
Binary files differ