为应用程序自由命名

This commit is contained in:
Yourtion
2016-05-03 11:55:45 +08:00
parent ff3319e083
commit 2fb28adf44
4 changed files with 40 additions and 19 deletions

View File

@@ -46,10 +46,10 @@ bootpack.bim : $(OBJS_BOOTPACK) Makefile
bootpack.hrb : bootpack.bim Makefile
$(BIM2HRB) bootpack.bim bootpack.hrb 0
hlt.hrb : hlt.nas Makefile
$(NASK) hlt.nas hlt.hrb hlt.lst
hello.hrb : hello.nas Makefile
$(NASK) hello.nas hello.hrb hello.lst
haribote.sys : asmhead.bin bootpack.hrb hlt.hrb Makefile
haribote.sys : asmhead.bin bootpack.hrb hello.hrb Makefile
copy /B asmhead.bin+bootpack.hrb haribote.sys
haribote.img : ipl10.bin haribote.sys Makefile
@@ -58,7 +58,7 @@ haribote.img : ipl10.bin haribote.sys Makefile
copy from:haribote.sys to:@: \
copy from:ipl10.nas to:@: \
copy from:make.bat to:@: \
copy from:hlt.hrb to:@: \
copy from:hello.hrb to:@: \
imgout:haribote.img
# 其他指令

View File

@@ -242,7 +242,7 @@ void cmd_mem(struct CONSOLE *cons, unsigned int memtotal);
void cmd_cls(struct CONSOLE *cons);
void cmd_dir(struct CONSOLE *cons);
void cmd_type(struct CONSOLE *cons, int *fat, char *cmdline);
void cmd_hlt(struct CONSOLE *cons, int *fat);
int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline);
/* file.c */
struct FILEINFO {

View File

@@ -157,13 +157,13 @@ void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, unsigned int mem
cmd_dir(cons);
} else if (strncmp(cmdline, "type ", 5) == 0) {
cmd_type(cons, fat, cmdline);
} else if (strcmp(cmdline, "hlt") == 0) {
cmd_hlt(cons, fat);
} else if (cmdline[0] != 0) {
/*不是命令,也不是空行*/
putfonts8_asc_sht(cons->sht, 8, cons->cur_y, COL8_FFFFFF, COL8_000000, "Bad command.", 12);
cons_newline(cons);
cons_newline(cons);
if (cmd_app(cons, fat, cmdline) == 0) {
/*不是命令,不是应用程序,也不是空行*/
putfonts8_asc_sht(cons->sht, 8, cons->cur_y, COL8_FFFFFF, COL8_000000, "Bad command.", 12);
cons_newline(cons);
cons_newline(cons);
}
}
return;
}
@@ -245,12 +245,35 @@ void cmd_type(struct CONSOLE *cons, int *fat, char *cmdline)
return;
}
void cmd_hlt(struct CONSOLE *cons, int *fat)
int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
{
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
struct FILEINFO *finfo = file_search("HLT.HRB", (struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224);
struct FILEINFO *finfo;
struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT;
char *p;
char name[18], *p;
int i;
/*根据命令行生成文件名*/
for (i = 0; i < 13; i++) {
if (cmdline[i] <= ' ') {
break;
}
name[i] = cmdline[i];
}
name[i] = 0; /*暂且将文件名的后面置为0*/
/*寻找文件 */
finfo = file_search(name, (struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224);
if (finfo == 0 && name[i -1]!= '.') {
/*由于找不到文件,故在文件名后面加上“.hrb”后重新寻找*/
name[i ] = '.';
name[i + 1] = 'H';
name[i + 2] = 'R';
name[i + 3] = 'B';
name[i + 4] = 0;
finfo = file_search(name, (struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224);
}
if (finfo != 0) {
/*找到文件的情况*/
p = (char *) memman_alloc_4k(memman, finfo->size);
@@ -258,11 +281,9 @@ void cmd_hlt(struct CONSOLE *cons, int *fat)
set_segmdesc(gdt + 1003, finfo->size - 1, (int) p, AR_CODE32_ER);
farcall(0, 1003 * 8);
memman_free_4k(memman, (int) p, finfo->size);
} else {
/*没有找到文件的情况*/
putfonts8_asc_sht(cons->sht, 8, cons->cur_y, COL8_FFFFFF, COL8_000000, "File not found.", 15);
cons_newline(cons);
return 1;
}
cons_newline(cons);
return;
/*没有找到文件的情况*/
return 0;
}