From fcd87ee3020771b5a51a1cb8837caa124fe36784 Mon Sep 17 00:00:00 2001 From: Yourtion Date: Wed, 18 May 2016 12:58:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E6=96=87=E6=96=87=E5=AD=97=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=EF=BC=882=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 28_day/Makefile | 2 +- 28_day/haribote/bootpack.h | 2 +- 28_day/haribote/console.c | 6 +++ 28_day/haribote/graphic.c | 31 +++++++++-- 28_day/haribote/jp.nas | 107 +++++++++++++++++++++++++++++++++++++ 5 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 28_day/haribote/jp.nas diff --git a/28_day/Makefile b/28_day/Makefile index ae13e61..191f468 100644 --- a/28_day/Makefile +++ b/28_day/Makefile @@ -25,7 +25,7 @@ haribote.img : haribote/ipl10.bin haribote/haribote.sys Makefile \ $(EDIMG) imgin:../z_tools/fdimg0at.tek \ wbinimg src:haribote/ipl10.bin len:512 from:0 to:0 \ copy from:haribote/haribote.sys to:@: \ - copy from:haribote/ipl10.nas to:@: \ + copy from:haribote/jp.nas to:@: \ copy from:make.bat to:@: \ copy from:a/a.hrb to:@: \ copy from:hello3/hello3.hrb to:@: \ diff --git a/28_day/haribote/bootpack.h b/28_day/haribote/bootpack.h index 3247663..f2e8243 100644 --- a/28_day/haribote/bootpack.h +++ b/28_day/haribote/bootpack.h @@ -217,7 +217,7 @@ struct TASK { struct FILEHANDLE *fhandle; int *fat; char *cmdline; - char langmode; + unsigned char langmode, langbyte1; }; struct TASKLEVEL { int running; /*正在运行的任务数量*/ diff --git a/28_day/haribote/console.c b/28_day/haribote/console.c index 7d6b750..e2e20f8 100644 --- a/28_day/haribote/console.c +++ b/28_day/haribote/console.c @@ -37,6 +37,7 @@ void console_task(struct SHEET *sheet, int memtotal) } else { task->langmode = 0; } + task->langbyte1 = 0; /*显示提示符*/ cons_putchar(&cons, '>', 1); @@ -158,6 +159,7 @@ void cons_newline(struct CONSOLE *cons) { int x, y; struct SHEET *sheet = cons->sht; + struct TASK *task = task_now(); if (cons->cur_y < 28 + 112) { cons->cur_y += 16; /*到下一行*/ } else { @@ -177,6 +179,9 @@ void cons_newline(struct CONSOLE *cons) } } cons->cur_x = 8; + if (task->langmode == 1 && task->langbyte1 != 0) { + cons->cur_x += 8; + } return; } @@ -403,6 +408,7 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline) } timer_cancelall(&task->fifo); memman_free_4k(memman, (int) q, segsiz); + task->langbyte1 = 0; } else { cons_putstr0(cons, ".hrb file format error.\n"); } diff --git a/28_day/haribote/graphic.c b/28_day/haribote/graphic.c index 0df664b..ab39ac9 100644 --- a/28_day/haribote/graphic.c +++ b/28_day/haribote/graphic.c @@ -107,9 +107,10 @@ void putfont8(char *vram, int xsize, int x, int y, char c, char *font) void putfonts8_asc(char *vram, int xsize, int x, int y, char c, unsigned char *s) { extern char hankaku[4096]; - /* C语言中,字符串都是以0x00结尾 */ struct TASK *task = task_now(); - char *nihongo = (char *) *((int *) 0x0fe8); + char *nihongo = (char *) *((int *) 0x0fe8), *font; + int k, t; + if (task->langmode == 0) { for (; *s != 0x00; s++) { putfont8(vram, xsize, x, y, c, hankaku + *s * 16); @@ -118,7 +119,31 @@ void putfonts8_asc(char *vram, int xsize, int x, int y, char c, unsigned char *s } if (task->langmode == 1) { for (; *s != 0x00; s++) { - putfont8(vram, xsize, x, y, c, nihongo + *s * 16); + if (task->langbyte1 == 0) { + if ((0x81 <= *s && *s <= 0x9f) || (0xe0 <= *s && *s <= 0xfc)) { + task->langbyte1 = *s; + } else { + putfont8(vram, xsize, x, y, c, nihongo + *s * 16); + } + } else { + if (0x81 <= task->langbyte1 && task->langbyte1 <= 0x9f) { + k = (task->langbyte1 - 0x81) * 2; + } else { + k = (task->langbyte1 - 0xe0) * 2 + 62; + } + if (0x40 <= *s && *s <= 0x7e) { + t = *s - 0x40; + } else if (0x80 <= *s && *s <= 0x9e) { + t = *s - 0x80 + 63; + } else { + t = *s - 0x9f; + k++; + } + task->langbyte1 = 0; + font = nihongo + 256 * 16 + (k * 94 + t) * 32; + putfont8(vram, xsize, x - 8, y, c, font ); /* 左半部分 */ + putfont8(vram, xsize, x , y, c, font + 16); /* 右半部分 */ + } x += 8; } } diff --git a/28_day/haribote/jp.nas b/28_day/haribote/jp.nas new file mode 100644 index 0000000..3f7cb00 --- /dev/null +++ b/28_day/haribote/jp.nas @@ -0,0 +1,107 @@ +; haribote-ipl +; TAB=4 + +CYLS EQU 10 ; ǂ܂œǂݍނ + + ORG 0x7c00 ; ̃vOǂɓǂݍ܂̂ + +; ȉ͕WIFAT12tH[}bgtbs[fBXN̂߂̋Lq + + JMP entry + DB 0x90 + DB "HARIBOTE" ; u[gZN^̖ORɏĂ悢i8oCgj + DW 512 ; 1ZN^̑傫i512ɂȂ΂Ȃj + DB 1 ; NX^̑傫i1ZN^ɂȂ΂Ȃj + DW 1 ; FATǂn܂邩iʂ1ZN^ڂɂj + DB 2 ; FAŤi2ɂȂ΂Ȃj + DW 224 ; [gfBNg̈̑傫iʂ224Ggɂj + DW 2880 ; ̃hCȗ傫i2880ZN^ɂȂ΂Ȃj + DB 0xf0 ; fBÃ^Cvi0xf0ɂȂ΂Ȃj + DW 9 ; FAT̈̒i9ZN^ɂȂ΂Ȃj + DW 18 ; 1gbNɂ‚̃ZN^邩i18ɂȂ΂Ȃj + DW 2 ; wbh̐i2ɂȂ΂Ȃj + DD 0 ; p[eBVgĂȂ̂ł͕K0 + DD 2880 ; ̃hCu傫x + DB 0,0,0x29 ; 悭킩Ȃǂ̒lɂĂƂ炵 + DD 0xffffffff ; Ԃ{[VAԍ + DB "HARIBOTEOS " ; fBXN̖Oi11oCgj + DB "FAT12 " ; tH[}bg̖Oi8oCgj + RESB 18 ; Ƃ肠18oCgĂ + +; vO{ + +entry: + MOV AX,0 ; WX^ + MOV SS,AX + MOV SP,0x7c00 + MOV DS,AX + +; fBXNǂ + + MOV AX,0x0820 + MOV ES,AX + MOV CH,0 ; V_0 + MOV DH,0 ; wbh0 + MOV CL,2 ; ZN^2 +readloop: + MOV SI,0 ; s񐔂𐔂郌WX^ +retry: + MOV AH,0x02 ; AH=0x02 : fBXNǂݍ + MOV AL,1 ; 1ZN^ + MOV BX,0 + MOV DL,0x00 ; AhCu + INT 0x13 ; fBXNBIOSĂяo + JNC next ; G[Ȃnext + ADD SI,1 ; SI1𑫂 + CMP SI,5 ; SI5r + JAE error ; SI >= 5 error + MOV AH,0x00 + MOV DL,0x00 ; AhCu + INT 0x13 ; hCũZbg + JMP retry +next: + MOV AX,ES ; AhX0x200i߂ + ADD AX,0x0020 + MOV ES,AX ; ADD ES,0x020 Ƃ߂Ȃ̂łĂ + ADD CL,1 ; CL1𑫂 + CMP CL,18 ; CL18r + JBE readloop ; CL <= 18 readloop + MOV CL,1 + ADD DH,1 + CMP DH,2 + JB readloop ; DH < 2 readloop + MOV DH,0 + ADD CH,1 + CMP CH,CYLS + JB readloop ; CH < CYLS readloop + +; ǂݏÎharibote.syssI + + MOV [0x0ff0],CH ; IPLǂ܂œǂ񂾂̂ + JMP 0xc200 + +error: + MOV AX,0 + MOV ES,AX + MOV SI,msg +putloop: + MOV AL,[SI] + ADD SI,1 ; SI1𑫂 + CMP AL,0 + JE fin + MOV AH,0x0e ; ꕶ\t@NV + MOV BX,15 ; J[R[h + INT 0x10 ; rfIBIOSĂяo + JMP putloop +fin: + HLT ; ܂CPU~ + JMP fin ; [v +msg: + DB 0x0a, 0x0a ; s2 + DB "load error" + DB 0x0a ; s + DB 0 + + RESB 0x7dfe-$ ; 0x7dfe܂ł0x00Ŗ߂閽 + + DB 0x55, 0xaa