Skip to content

Commit

Permalink
乱码修正
Browse files Browse the repository at this point in the history
  • Loading branch information
yourtion committed Jun 3, 2016
1 parent 3f393fb commit b7c6272
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 70 deletions.
102 changes: 52 additions & 50 deletions src/kernel/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,19 @@ void cons_putchar(struct CONSOLE *cons, int chr, char move)
cons_newline(cons);
}
if (((cons->cur_x - 8) & 0x1f) == 0) {
break; /* 32�Ŋ���؂ꂽ��break */
break; /*被32整除则break*/
}
}
} else if (s[0] == 0x0a) { /* ���s */
} else if (s[0] == 0x0a) { /*换行*/
cons_newline(cons);
} else if (s[0] == 0x0d) { /* ���A */
/* �Ƃ肠�����Ȃɂ����Ȃ� */
} else { /* ���ʂ̕��� */
} else if (s[0] == 0x0d) { /*回车*/
/*先不做任何操作*/
} else { /*一般字符*/
if (cons->sht != 0) {
putfonts8_asc_sht(cons->sht, cons->cur_x, cons->cur_y, COL8_FFFFFF, COL8_000000, s, 1);
}
if (move != 0) {
/* move��0�̂Ƃ��̓J�[�\����i�߂Ȃ� */
/* move为0时光标不后移*/
cons->cur_x += 8;
if (cons->cur_x == 8 + 240) {
cons_newline(cons);
Expand All @@ -161,9 +161,9 @@ void cons_newline(struct CONSOLE *cons)
struct SHEET *sheet = cons->sht;
struct TASK *task = task_now();
if (cons->cur_y < 28 + 112) {
cons->cur_y += 16; /* ���̍s�� */
cons->cur_y += 16; /*到下一行*/
} else {
/* �X�N���[�� */
/*滚动*/
if (sheet != 0) {
for (y = 28; y < 28 + 112; y++) {
for (x = 8; x < 8 + 240; x++) {
Expand All @@ -180,7 +180,7 @@ void cons_newline(struct CONSOLE *cons)
}
cons->cur_x = 8;
if (task->langmode == 1 && task->langbyte1 != 0) {
cons->cur_x = 16;
cons->cur_x += 8;
}
return;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, int memtotal)
cmd_mem(cons, memtotal);
} else if (strcmp(cmdline, "cls") == 0 && cons->sht != 0) {
cmd_cls(cons);
} else if (strcmp(cmdline, "dir") == 0 && cons->sht != 0) {
} else if ((strcmp(cmdline, "dir") == 0 || strcmp(cmdline, "ls") == 0) && cons->sht != 0) {
cmd_dir(cons);
} else if (strcmp(cmdline, "exit") == 0) {
cmd_exit(cons, fat);
Expand All @@ -218,9 +218,9 @@ void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, int memtotal)
cmd_ncst(cons, cmdline, memtotal);
} else if (strncmp(cmdline, "langmode ", 9) == 0) {
cmd_langmode(cons, cmdline);
} else if (cmdline[0] != 0) {
}else if (cmdline[0] != 0) {
if (cmd_app(cons, fat, cmdline) == 0) {
/* �R�}���h�ł͂Ȃ��A�A�v���ł��Ȃ��A����ɋ�s�ł��Ȃ� */
/*不是命令,不是应用程序,也不是空行*/
cons_putstr0(cons, "Bad command.\n\n");
}
}
Expand Down Expand Up @@ -288,9 +288,9 @@ void cmd_exit(struct CONSOLE *cons, int *fat)
memman_free_4k(memman, (int) fat, 4 * 2880);
io_cli();
if (cons->sht != 0) {
fifo32_put(fifo, cons->sht - shtctl->sheets0 + 768); /* 768�`1023 */
fifo32_put(fifo, cons->sht - shtctl->sheets0 + 768); /* 7681023 */
} else {
fifo32_put(fifo, task - taskctl->tasks0 + 1024); /* 1024�`2023 */
fifo32_put(fifo, task - taskctl->tasks0 + 1024); /*10242023*/
}
io_sti();
for (;;) {
Expand All @@ -306,11 +306,11 @@ void cmd_start(struct CONSOLE *cons, char *cmdline, int memtotal)
int i;
sheet_slide(sht, 32, 4);
sheet_updown(sht, shtctl->top);
/* �R�}���h���C���ɓ��͂��ꂽ��������A�ꕶ�����V�����R���\�[���ɓ��� */
/*将命令行输入的字符串逐字复制到新的命令行窗口中*/
for (i = 6; cmdline[i] != 0; i++) {
fifo32_put(fifo, cmdline[i] + 256);
}
fifo32_put(fifo, 10 + 256); /* Enter */
fifo32_put(fifo, 10 + 256); /*回车键*/
cons_newline(cons);
return;
}
Expand All @@ -320,11 +320,12 @@ void cmd_ncst(struct CONSOLE *cons, char *cmdline, int memtotal)
struct TASK *task = open_constask(0, memtotal);
struct FIFO32 *fifo = &task->fifo;
int i;
/* �R�}���h���C���ɓ��͂��ꂽ��������A�ꕶ�����V�����R���\�[���ɓ��� */

/*将命令行输入的字符串逐字复制到新的命令行窗口中*/
for (i = 5; cmdline[i] != 0; i++) {
fifo32_put(fifo, cmdline[i] + 256);
}
fifo32_put(fifo, 10 + 256); /* Enter */
fifo32_put(fifo, 10 + 256); /*回车键*/
cons_newline(cons);
return;
}
Expand All @@ -346,25 +347,26 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
{
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
struct FILEINFO *finfo;
struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT;
char name[18], *p, *q;
struct TASK *task = task_now();
int i, segsiz, datsiz, esp, dathrb, appsiz;
struct SHTCTL *shtctl;
struct SHEET *sht;

/* �R�}���h���C������t�@�C�����𐶐� */
/*根据命令行生成文件名*/
for (i = 0; i < 13; i++) {
if (cmdline[i] <= ' ') {
break;
}
name[i] = cmdline[i];
}
name[i] = 0; /* �Ƃ肠�����t�@�C�����̌���0�ɂ��� */
name[i] = 0; /*暂且将文件名的后面置为0*/

/* �t�@�C����T�� */
/*寻找文件 */
finfo = file_search(name, (struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224);
if (finfo == 0 && name[i - 1] != '.') {
/* ���‚���Ȃ������̂Ō���".HRB"���‚��Ă�����x�T���Ă݂� */
/*由于找不到文件,故在文件名后面加上“.hrb”后重新寻找*/
name[i ] = '.';
name[i + 1] = 'H';
name[i + 2] = 'R';
Expand All @@ -374,7 +376,7 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
}

if (finfo != 0) {
/* �t�@�C�������‚������ꍇ */
/*如果找到文件*/
appsiz = finfo->size;
p = file_loadfile2(finfo->clustno, &appsiz, fat);
if (appsiz >= 36 && strncmp(p + 4, "Hari", 4) == 0 && *p == 0x00) {
Expand All @@ -384,8 +386,8 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
dathrb = *((int *) (p + 0x0014));
q = (char *) memman_alloc_4k(memman, segsiz);
task->ds_base = (int) q;
set_segmdesc(task->ldt + 0, appsiz - 1, (int) p, AR_CODE32_ER + 0x60);
set_segmdesc(task->ldt + 1, segsiz - 1, (int) q, AR_DATA32_RW + 0x60);
set_segmdesc(task->ldt + 0, finfo->size - 1, (int) p, AR_CODE32_ER + 0x60);
set_segmdesc(task->ldt + 1, segsiz - 1, (int) q, AR_DATA32_RW + 0x60);
for (i = 0; i < datsiz; i++) {
q[esp + i] = p[dathrb + i];
}
Expand All @@ -394,11 +396,11 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
for (i = 0; i < MAX_SHEETS; i++) {
sht = &(shtctl->sheets0[i]);
if ((sht->flags & 0x11) == 0x11 && sht->task == task) {
/* �A�v�����J�����ςȂ��ɂ����������𔭌� */
sheet_free(sht); /* �‚��� */
/*找到被应用程序遗留的窗口*/
sheet_free(sht); /*关闭*/
}
}
for (i = 0; i < 8; i++) { /* �N���[�Y���ĂȂ��t�@�C�����N���[�Y */
for (i = 0; i < 8; i++) { /*将未关闭的文件关闭*/
if (task->fhandle[i].buf != 0) {
memman_free_4k(memman, (int) task->fhandle[i].buf, task->fhandle[i].size);
task->fhandle[i].buf = 0;
Expand All @@ -414,7 +416,7 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
cons_newline(cons);
return 1;
}
/* �t�@�C�������‚���Ȃ������ꍇ */
/*没有找到文件的情况*/
return 0;
}

Expand All @@ -426,8 +428,8 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
struct SHTCTL *shtctl = (struct SHTCTL *) *((int *) 0x0fe4);
struct SHEET *sht;
struct FIFO32 *sys_fifo = (struct FIFO32 *) *((int *) 0x0fec);
int *reg = &eax + 1; /* eax�̎��̔Ԓn */
/* �ۑ��̂��߂�PUSHAD�������ɏ��������� */
int *reg = &eax + 1; /* eax后面的地址*/
/*强行改写通过PUSHAD保存的值*/
/* reg[0] : EDI, reg[1] : ESI, reg[2] : EBP, reg[3] : ESP */
/* reg[4] : EBX, reg[5] : EDX, reg[6] : ECX, reg[7] : EAX */
int i;
Expand All @@ -450,7 +452,7 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
sheet_setbuf(sht, (char *) ebx + ds_base, esi, edi, eax);
make_window8((char *) ebx + ds_base, esi, edi, (char *) ecx + ds_base, 0);
sheet_slide(sht, ((shtctl->xsize - esi) / 2) & ~3, (shtctl->ysize - edi) / 2);
sheet_updown(sht, shtctl->top); /* ���̃}�E�X�Ɠ��������ɂȂ�悤�Ɏw��F �}�E�X�͂��̏�ɂȂ� */
sheet_updown(sht, shtctl->top); /*将窗口图层高度指定为当前鼠标所在图层的高度,鼠标移到上层*/
reg[7] = (int) sht;
} else if (edx == 6) {
sht = (struct SHEET *) (ebx & 0xfffffffe);
Expand All @@ -466,13 +468,13 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
}
} else if (edx == 8) {
memman_init((struct MEMMAN *) (ebx + ds_base));
ecx &= 0xfffffff0; /* 16�o�C�g�P�ʂ� */
ecx &= 0xfffffff0; /*以16字节为单位*/
memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx);
} else if (edx == 9) {
ecx = (ecx + 0x0f) & 0xfffffff0; /* 16�o�C�g�P�ʂɐ؂�グ */
ecx = (ecx + 0x0f) & 0xfffffff0; /*以16字节为单位进位取整*/
reg[7] = memman_alloc((struct MEMMAN *) (ebx + ds_base), ecx);
} else if (edx == 10) {
ecx = (ecx + 0x0f) & 0xfffffff0; /* 16�o�C�g�P�ʂɐ؂�グ */
ecx = (ecx + 0x0f) & 0xfffffff0; /*以16字节为单位进位取整*/
memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx);
} else if (edx == 11) {
sht = (struct SHEET *) (ebx & 0xfffffffe);
Expand Down Expand Up @@ -506,7 +508,7 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
io_cli();
if (fifo32_status(&task->fifo) == 0) {
if (eax != 0) {
task_sleep(task); /* FIFO����Ȃ̂ŐQ�đ҂� */
task_sleep(task); /* FIFO为空,休眠并等待*/
} else {
io_sti();
reg[7] = -1;
Expand All @@ -515,32 +517,32 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
}
i = fifo32_get(&task->fifo);
io_sti();
if (i <= 1 && cons->sht != 0) { /* �J�[�\���p�^�C�} */
/* �A�v�����s���̓J�[�\�����o�Ȃ��̂ŁA���‚����͕\���p��1�𒍕����Ă��� */
timer_init(cons->timer, &task->fifo, 1); /* ����1�� */
if (i <= 1) { /*光标用定时器*/
/*应用程序运行时不需要显示光标,因此总是将下次显示用的值置为1*/
timer_init(cons->timer, &task->fifo, 1); /*下次置为1*/
timer_settime(cons->timer, 50);
}
if (i == 2) { /* �J�[�\��ON */
if (i == 2) { /*光标ON */
cons->cur_c = COL8_FFFFFF;
}
if (i == 3) { /* �J�[�\��OFF */
if (i == 3) { /*光标OFF */
cons->cur_c = -1;
}
if (i == 4) { /* �R���\�[��������‚��� */
if (i == 4) { /*只关闭命令行窗口*/
timer_cancel(cons->timer);
io_cli();
fifo32_put(sys_fifo, cons->sht - shtctl->sheets0 + 2024); /* 2024�`2279 */
fifo32_put(sys_fifo, cons->sht - shtctl->sheets0 + 2024); /*20242279*/
cons->sht = 0;
io_sti();
}
if (i >= 256) { /* �L�[�{�[�h�f�[�^�i�^�X�NA�o�R�j�Ȃ� */
if (i >= 256) { /*键盘数据(通过任务A)等*/
reg[7] = i - 256;
return 0;
}
}
} else if (edx == 16) {
reg[7] = (int) timer_alloc();
((struct TIMER *) reg[7])->flags2 = 1; /* �����L�����Z���L�� */
((struct TIMER *) reg[7])->flags2 = 1; /*允许自动取消*/
} else if (edx == 17) {
timer_init((struct TIMER *) ebx, &task->fifo, eax + 256);
} else if (edx == 18) {
Expand Down Expand Up @@ -568,13 +570,13 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
fh = &task->fhandle[i];
reg[7] = 0;
if (i < 8) {
finfo = file_search((char *) ebx + ds_base,
(struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224);
finfo = file_search((char *) ebx + ds_base, (struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224);
if (finfo != 0) {
reg[7] = (int) fh;
fh->buf = (char *) memman_alloc_4k(memman, finfo->size);
fh->size = finfo->size;
fh->pos = 0;
fh->buf = file_loadfile2(finfo->clustno, &fh->size, task->fat);
file_loadfile2(finfo->clustno, &fh->size, task->fat);
}
}
} else if (edx == 22) {
Expand Down Expand Up @@ -642,7 +644,7 @@ int *inthandler0c(int *esp)
cons_putstr0(cons, "\nINT 0C :\n Stack Exception.\n");
sprintf(s, "EIP = %08X\n", esp[11]);
cons_putstr0(cons, s);
return &(task->tss.esp0); /* �ُ�I�������� */
return &(task->tss.esp0); /*强制结束程序*/
}

int *inthandler0d(int *esp)
Expand All @@ -653,7 +655,7 @@ int *inthandler0d(int *esp)
cons_putstr0(cons, "\nINT 0D :\n General Protected Exception.\n");
sprintf(s, "EIP = %08X\n", esp[11]);
cons_putstr0(cons, s);
return &(task->tss.esp0); /* �ُ�I�������� */
return &(task->tss.esp0); /*强制结束程序*/
}

void hrb_api_linewin(struct SHEET *sht, int x0, int y0, int x1, int y1, int col)
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/ipl10.nas
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ CYLS EQU 30 ; 声明CYLS=10
DD 2880 ; 重写一次磁盘大小
DB 0,0,0x29 ; 意义不明(固定)
DD 0xffffffff ; (可能是)卷标号码
DB "HARIBOTEOS " ; 磁盘的名称(必须为11字?,不足填空格)
DB "FAT12 " ; 磁盘格式名称(必??8字?,不足填空格)
DB "HARIBOTEOS " ; 磁盘的名称(必须为11字节,不足填空格)
DB "FAT12 " ; 磁盘格式名称(必须8字节,不足填空格)
RESB 18 ; 先空出18字节

; 程序主体
Expand Down
Loading

0 comments on commit b7c6272

Please sign in to comment.