Skip to content

Commit f237d1f

Browse files
committed
dir命令
1 parent 88f4f44 commit f237d1f

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

18_day/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ haribote.img : ipl10.bin haribote.sys Makefile
5252
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
5353
wbinimg src:ipl10.bin len:512 from:0 to:0 \
5454
copy from:haribote.sys to:@: \
55+
copy from:ipl10.nas to:@: \
56+
copy from:make.bat to:@: \
5557
imgout:haribote.img
5658

5759
# 其他指令

18_day/bootpack.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
#include <stdio.h>
55
#include <string.h>
66

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+
714
void make_window8(unsigned char *buf, int xsize, int ysize, char *title, char act);
815
void putfonts8_asc_sht(struct SHEET *sht, int x, int y, int c, int b, char *s, int l);
916
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)
380387
char s[30], cmdline[30];
381388
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
382389
int x, y;
390+
struct FILEINFO *finfo = (struct FILEINFO *) (ADR_DISKIMG + 0x002600);
383391

384392
fifo32_init(&task->fifo, 128, fifobuf, task);
385393
timer = timer_alloc();
@@ -451,7 +459,28 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
451459
}
452460
sheet_refresh(sheet, 8, 28, 8 + 240, 28 + 128);
453461
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) {
455484
/*不是命令,也不是空行 */
456485
putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "Bad command.", 12);
457486
cursor_y = cons_newline(cursor_y, sheet);

18_day/bootpack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ struct BOOTINFO { /* 0x0ff0-0x0fff */
88
char *vram;
99
};
1010
#define ADR_BOOTINFO 0x00000ff0
11+
#define ADR_DISKIMG 0x00100000
1112

1213
/* naskfunc.nas */
1314
void io_hlt(void);

0 commit comments

Comments
 (0)