|
- /* vdir.c - the :dir command for the c64 vim clone.
- *
- * Kept in its own unit: power c miscompiles jumps once one object file holds more
- * than 8 KB of code (a return in main jumped to garbage), so vim.c must stay small.
- */
-
- extern int redraw;
-
- /* :dir - show the disk directory over the editor, a page at a time.
- the drive sends it as a basic program: load address, then per line a link
- word, the block count, the text and a 0; a link of 0 ends it.
- RUN/STOP stops early, any other key pages on. returns 1 if it listed */
- dirlist()
- {
- int f, lo, hi, bl, bh, ch, row, col, r, p, k;
- char t[8];
-
- if (open(15, 8, 15, "") == 0) return 0; /* command channel first */
- f = open(5, 8, 0, "$");
- if (f == 0) {
- close(15);
- return 0;
- }
- for (r = 0; r < 25; r++) sclr(r, 0, 40);
- getc(5); /* load address */
- getc(5);
- row = 0;
- for (;;) {
- lo = getc(5);
- hi = getc(5);
- if (lo < 0) break;
- if (hi < 0) break;
- if (lo == 0 && hi == 0) break; /* end of directory */
- bl = getc(5);
- bh = getc(5);
- if (bh < 0) break;
- p = dnum(t, 0, bl + bh * 256);
- col = 0;
- for (k = 0; k < p; k++) spc(row, col++, t[k]);
- col = 5;
- for (;;) {
- ch = getc(5);
- if (ch <= 0) break;
- if (ch < 32) ch = 32; /* reverse on etc: show a blank */
- if (col < 40) spc(row, col++, ch);
- }
- row++;
- if (row == 24) {
- sclr(24, 0, 40);
- sps(24, 0, "-- more --");
- k = skey();
- for (r = 0; r < 25; r++) sclr(r, 0, 40);
- row = 0;
- if (k == 3) break;
- }
- }
- close(5);
- close(15); /* last: it closes everything */
- if (row > 0) {
- sclr(24, 0, 40);
- sps(24, 0, "-- any key --");
- skey();
- }
- redraw = 2;
- return 1;
- }
|