第一个应用程序

This commit is contained in:
Yourtion
2016-04-29 13:04:00 +08:00
parent 60fce32986
commit 51e4e06648
3 changed files with 72 additions and 23 deletions

View File

@@ -46,7 +46,10 @@ bootpack.bim : $(OBJS_BOOTPACK) Makefile
bootpack.hrb : bootpack.bim Makefile
$(BIM2HRB) bootpack.bim bootpack.hrb 0
haribote.sys : asmhead.bin bootpack.hrb Makefile
hlt.hrb : hlt.nas Makefile
$(NASK) hlt.nas hlt.hrb hlt.lst
haribote.sys : asmhead.bin bootpack.hrb hlt.hrb Makefile
copy /B asmhead.bin+bootpack.hrb haribote.sys
haribote.img : ipl10.bin haribote.sys Makefile
@@ -55,6 +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:@: \
imgout:haribote.img
# 其他指令

View File

@@ -4,28 +4,6 @@
#include <stdio.h>
#include <string.h>
int cons_newline(int cursor_y, struct SHEET *sheet)
{
int x, y;
if (cursor_y < 28 + 112) {
cursor_y += 16; /*换行*/
} else {
/*滚动*/
for (y = 28; y < 28 + 112; y++) {
for (x = 8; x < 8 + 240; x++) {
sheet->buf[x + y * sheet->bxsize] = sheet->buf[x + (y + 16) * sheet->bxsize];
}
}
for (y = 28 + 112; y < 28 + 128; y++) {
for (x = 8; x < 8 + 240; x++) {
sheet->buf[x + y * sheet->bxsize] = COL8_000000;
}
}
sheet_refresh(sheet, 8, 28, 8 + 240, 28 + 128);
}
return cursor_y;
}
void console_task(struct SHEET *sheet, unsigned int memtotal)
{
struct TIMER *timer;
@@ -36,6 +14,7 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
int x, y;
struct FILEINFO *finfo = (struct FILEINFO *) (ADR_DISKIMG + 0x002600);
int *fat = (int *) memman_alloc_4k(memman, 4 * 2880);
struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT;
fifo32_init(&task->fifo, 128, fifobuf, task);
timer = timer_alloc();
@@ -207,6 +186,45 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
cursor_y = cons_newline(cursor_y, sheet);
}
cursor_y = cons_newline(cursor_y, sheet);
} else if (strcmp(cmdline, "hlt") == 0) {
/*启动应用程序hlt.hrb */
for (y = 0; y < 11; y++) {
s[y] = ' ';
}
s[0] = 'H';
s[1] = 'L';
s[2] = 'T';
s[8] = 'H';
s[9] = 'R';
s[10] = 'B';
for (x = 0; x < 224; ) {
if (finfo[x].name[0] == 0x00) {
break;
}
if ((finfo[x].type & 0x18) == 0) {
for (y = 0; y < 11; y++) {
if (finfo[x].name[y] != s[y]) {
goto hlt_next_file;
}
}
break; /*找到文件*/
}
hlt_next_file:
x++;
}
if (x < 224 && finfo[x].name[0] != 0x00) {
/*找到文件的情况*/
p = (char *) memman_alloc_4k(memman, finfo[x].size);
file_loadfile(finfo[x].clustno, finfo[x].size, p, fat, (char *) (ADR_DISKIMG + 0x003e00));
set_segmdesc(gdt + 1003, finfo[x].size - 1, (int) p, AR_CODE32_ER);
farjmp(0, 1003 * 8);
memman_free_4k(memman, (int) p, finfo[x].size);
} else {
/*没有找到文件的情况*/
putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "File not found.", 15);
cursor_y = cons_newline(cursor_y, sheet);
}
cursor_y = cons_newline(cursor_y, sheet);
} else if (cmdline[0] != 0) {
/*不是命令,也不是空行 */
putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "Bad command.", 12);
@@ -236,3 +254,25 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
}
}
}
int cons_newline(int cursor_y, struct SHEET *sheet)
{
int x, y;
if (cursor_y < 28 + 112) {
cursor_y += 16; /*换行*/
} else {
/*滚动*/
for (y = 28; y < 28 + 112; y++) {
for (x = 8; x < 8 + 240; x++) {
sheet->buf[x + y * sheet->bxsize] = sheet->buf[x + (y + 16) * sheet->bxsize];
}
}
for (y = 28 + 112; y < 28 + 128; y++) {
for (x = 8; x < 8 + 240; x++) {
sheet->buf[x + y * sheet->bxsize] = COL8_000000;
}
}
sheet_refresh(sheet, 8, 28, 8 + 240, 28 + 128);
}
return cursor_y;
}

5
19_day/hlt.nas Normal file
View File

@@ -0,0 +1,5 @@
[BITS 32]
CLI
fin:
HLT
JMP fin