|
4 | 4 | #include <stdio.h>
|
5 | 5 | #include <string.h>
|
6 | 6 |
|
| 7 | +struct FILEINFO { |
| 8 | + unsigned char name[8], ext[3], type; |
| 9 | + char reserve[10]; |
| 10 | + unsigned short time, date, clustno; |
| 11 | + unsigned int size; |
| 12 | +}; |
| 13 | + |
7 | 14 | void make_window8(unsigned char *buf, int xsize, int ysize, char *title, char act);
|
8 | 15 | void putfonts8_asc_sht(struct SHEET *sht, int x, int y, int c, int b, char *s, int l);
|
9 | 16 | void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c);
|
@@ -380,6 +387,7 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
|
380 | 387 | char s[30], cmdline[30];
|
381 | 388 | struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
382 | 389 | int x, y;
|
| 390 | + struct FILEINFO *finfo = (struct FILEINFO *) (ADR_DISKIMG + 0x002600); |
383 | 391 |
|
384 | 392 | fifo32_init(&task->fifo, 128, fifobuf, task);
|
385 | 393 | timer = timer_alloc();
|
@@ -451,7 +459,28 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
|
451 | 459 | }
|
452 | 460 | sheet_refresh(sheet, 8, 28, 8 + 240, 28 + 128);
|
453 | 461 | cursor_y = 28;
|
454 |
| - } else if (cmdline[0] != 0) { |
| 462 | + } else if (strcmp(cmdline, "dir") == 0 || strcmp(cmdline, "ls") == 0) { |
| 463 | + /* dir命令 */ |
| 464 | + for (x = 0; x < 224; x++) { |
| 465 | + if (finfo[x].name[0] == 0x00) { |
| 466 | + break; |
| 467 | + } |
| 468 | + if (finfo[x].name[0] != 0xe5) { |
| 469 | + if ((finfo[x].type & 0x18) == 0) { |
| 470 | + sprintf(s, "filename.ext %7d", finfo[x].size); |
| 471 | + for (y = 0; y < 8; y++) { |
| 472 | + s[y] = finfo[x].name[y]; |
| 473 | + } |
| 474 | + s[ 9] = finfo[x].ext[0]; |
| 475 | + s[10] = finfo[x].ext[1]; |
| 476 | + s[11] = finfo[x].ext[2]; |
| 477 | + putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, s, 30); |
| 478 | + cursor_y = cons_newline(cursor_y, sheet); |
| 479 | + } |
| 480 | + } |
| 481 | + } |
| 482 | + cursor_y = cons_newline(cursor_y, sheet); |
| 483 | + } else if (cmdline[0] != 0) { |
455 | 484 | /*不是命令,也不是空行 */
|
456 | 485 | putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "Bad command.", 12);
|
457 | 486 | cursor_y = cons_newline(cursor_y, sheet);
|
|
0 commit comments