diff --git a/28_day/Makefile b/28_day/Makefile index 046fcf9..ae13e61 100644 --- a/28_day/Makefile +++ b/28_day/Makefile @@ -21,7 +21,7 @@ haribote.img : haribote/ipl10.bin haribote/haribote.sys Makefile \ lines/lines.hrb walk/walk.hrb noodle/noodle.hrb \ beepdown/beepdown.hrb color/color.hrb color2/color2.hrb \ sosu/sosu.hrb sosu2/sosu2.hrb sosu3/sosu3.hrb \ - typeipl/typeipl.hrb type/type.hrb + typeipl/typeipl.hrb type/type.hrb iroha/iroha.hrb $(EDIMG) imgin:../z_tools/fdimg0at.tek \ wbinimg src:haribote/ipl10.bin len:512 from:0 to:0 \ copy from:haribote/haribote.sys to:@: \ @@ -48,6 +48,8 @@ haribote.img : haribote/ipl10.bin haribote/haribote.sys Makefile \ copy from:sosu3/sosu3.hrb to:@: \ copy from:typeipl/typeipl.hrb to:@: \ copy from:type/type.hrb to:@: \ + copy from:iroha/iroha.hrb to:@: \ + copy from:nihongo/nihongo.fnt to:@: \ imgout:haribote.img #命令 @@ -85,6 +87,7 @@ full : $(MAKE) -C sosu3 $(MAKE) -C typeipl $(MAKE) -C type + $(MAKE) -C iroha $(MAKE) haribote.img run_full : @@ -131,6 +134,7 @@ clean_full : $(MAKE) -C sosu3 clean $(MAKE) -C typeipl clean $(MAKE) -C type clean + $(MAKE) -C iroha clean src_only_full : $(MAKE) -C haribote src_only @@ -154,8 +158,9 @@ src_only_full : $(MAKE) -C sosu src_only $(MAKE) -C sosu2 src_only $(MAKE) -C sosu3 src_only - $(MAKE) -C typeipl src_only + $(MAKE) -C typeipl src_only $(MAKE) -C type src_only + $(MAKE) -C iroha src_only -$(DEL) haribote.img refresh : diff --git a/28_day/haribote/bootpack.c b/28_day/haribote/bootpack.c index d4f821a..92754c6 100644 --- a/28_day/haribote/bootpack.c +++ b/28_day/haribote/bootpack.c @@ -47,6 +47,10 @@ void HariMain(void) int key_shift = 0, key_leds = (binfo->leds >> 4) & 7, keycmd_wait = -1; int j, x, y, mmx = -1, mmy = -1, mmx2 = 0; struct SHEET *sht = 0, *key_win, *sht2; + int *fat; + unsigned char *nihongo; + struct FILEINFO *finfo; + extern char hankaku[4096]; init_gdtidt(); init_pic(); @@ -71,6 +75,7 @@ void HariMain(void) fifo.task = task_a; task_run(task_a, 1, 2); *((int *) 0x0fe4) = (int) shtctl; + task_a->langmode = 0; /* sht_back */ sht_back = sheet_alloc(shtctl); @@ -96,10 +101,28 @@ void HariMain(void) sheet_updown(sht_mouse, 2); keywin_on(key_win); - /*为了避免和键盘当前状态冲突,在一开始先进行设置*/ + /* 为了避免和键盘当前状态冲突,在一开始先进行设置 */ fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); + /* 载入nihongo.fnt */ + nihongo = (unsigned char *) memman_alloc_4k(memman, 16 * 256 + 32 * 94 * 47); + fat = (int *) memman_alloc_4k(memman, 4 * 2880); + file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200)); + finfo = file_search("nihongo.fnt", (struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224); + if (finfo != 0) { + file_loadfile(finfo->clustno, finfo->size, nihongo, fat, (char *) (ADR_DISKIMG + 0x003e00)); + } else { + for (i = 0; i < 16 * 256; i++) { + nihongo[i] = hankaku[i]; /* 没有字库,半角部分直接复制英文字库 */ + } + for (i = 16 * 256; i < 16 * 256 + 32 * 94 * 47; i++) { + nihongo[i] = 0xff; /* 没有字库,全角部分以0xff填充 */ + } + } + *((int *) 0x0fe8) = (int) nihongo; + memman_free_4k(memman, (int) fat, 4 * 2880); + for (;;) { if (fifo32_status(&keycmd) > 0 && keycmd_wait < 0) { /* 如果存在向键盘控制器发送的数据,则发送它 */ diff --git a/28_day/haribote/bootpack.h b/28_day/haribote/bootpack.h index 56c12b8..3247663 100644 --- a/28_day/haribote/bootpack.h +++ b/28_day/haribote/bootpack.h @@ -217,6 +217,7 @@ struct TASK { struct FILEHANDLE *fhandle; int *fat; char *cmdline; + char langmode; }; struct TASKLEVEL { int running; /*正在运行的任务数量*/ @@ -268,6 +269,7 @@ void cmd_dir(struct CONSOLE *cons); void cmd_exit(struct CONSOLE *cons, int *fat); void cmd_start(struct CONSOLE *cons, char *cmdline, int memtotal); void cmd_ncst(struct CONSOLE *cons, char *cmdline, int memtotal); +void cmd_langmode(struct CONSOLE *cons, char *cmdline); int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline); int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int eax); int *inthandler0d(int *esp); diff --git a/28_day/haribote/console.c b/28_day/haribote/console.c index 3d0c70b..7d6b750 100644 --- a/28_day/haribote/console.c +++ b/28_day/haribote/console.c @@ -12,6 +12,7 @@ void console_task(struct SHEET *sheet, int memtotal) struct FILEHANDLE fhandle[8]; struct CONSOLE cons; char cmdline[30]; + unsigned char *nihongo = (char *) *((int *) 0x0fe8); cons.sht = sheet; cons.cur_x = 8; @@ -31,6 +32,11 @@ void console_task(struct SHEET *sheet, int memtotal) } task->fhandle = fhandle; task->fat = fat; + if (nihongo[4096] != 0xff) { /* 是否载入了字库?*/ + task->langmode = 1; + } else { + task->langmode = 0; + } /*显示提示符*/ cons_putchar(&cons, '>', 1); @@ -205,7 +211,9 @@ void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, int memtotal) cmd_start(cons, cmdline, memtotal); } else if (strncmp(cmdline, "ncst ", 5) == 0) { cmd_ncst(cons, cmdline, memtotal); - } else if (cmdline[0] != 0) { + } else if (strncmp(cmdline, "langmode ", 9) == 0) { + cmd_langmode(cons, cmdline); + }else if (cmdline[0] != 0) { if (cmd_app(cons, fat, cmdline) == 0) { /*不是命令,不是应用程序,也不是空行*/ cons_putstr0(cons, "Bad command.\n\n"); @@ -317,6 +325,19 @@ void cmd_ncst(struct CONSOLE *cons, char *cmdline, int memtotal) return; } +void cmd_langmode(struct CONSOLE *cons, char *cmdline) +{ + struct TASK *task = task_now(); + unsigned char mode = cmdline[9] - '0'; + if (mode <= 1) { + task->langmode = mode; + } else { + cons_putstr0(cons, "mode number error.\n"); + } + cons_newline(cons); + return; +} + int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline) { struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; diff --git a/28_day/haribote/graphic.c b/28_day/haribote/graphic.c index 4bd6979..0df664b 100644 --- a/28_day/haribote/graphic.c +++ b/28_day/haribote/graphic.c @@ -108,9 +108,19 @@ void putfonts8_asc(char *vram, int xsize, int x, int y, char c, unsigned char *s { extern char hankaku[4096]; /* C语言中,字符串都是以0x00结尾 */ - for (; *s != 0x00; s++) { - putfont8(vram, xsize, x, y, c, hankaku + *s * 16); - x += 8; + struct TASK *task = task_now(); + char *nihongo = (char *) *((int *) 0x0fe8); + if (task->langmode == 0) { + for (; *s != 0x00; s++) { + putfont8(vram, xsize, x, y, c, hankaku + *s * 16); + x += 8; + } + } + if (task->langmode == 1) { + for (; *s != 0x00; s++) { + putfont8(vram, xsize, x, y, c, nihongo + *s * 16); + x += 8; + } } return; } diff --git a/28_day/iroha/!cons_9x.bat b/28_day/iroha/!cons_9x.bat new file mode 100644 index 0000000..e42252a --- /dev/null +++ b/28_day/iroha/!cons_9x.bat @@ -0,0 +1 @@ +command \ No newline at end of file diff --git a/28_day/iroha/!cons_nt.bat b/28_day/iroha/!cons_nt.bat new file mode 100644 index 0000000..6e07473 --- /dev/null +++ b/28_day/iroha/!cons_nt.bat @@ -0,0 +1 @@ +cmd.exe \ No newline at end of file diff --git a/28_day/iroha/Makefile b/28_day/iroha/Makefile new file mode 100644 index 0000000..df134ad --- /dev/null +++ b/28_day/iroha/Makefile @@ -0,0 +1,5 @@ +APP = iroha +STACK = 1k +MALLOC = 0k + +include ../app_make.txt diff --git a/28_day/iroha/iroha.c b/28_day/iroha/iroha.c new file mode 100644 index 0000000..3ed1dd8 --- /dev/null +++ b/28_day/iroha/iroha.c @@ -0,0 +1,9 @@ +#include "apilib.h" + +void HariMain(void) +{ + static char s[9] = { 0xb2, 0xdb, 0xca, 0xc6, 0xce, 0xcd, 0xc4, 0x0a, 0x00 }; + /*半角片假名イロハニホヘト的字符编码+换行+0 */ + api_putstr0(s); + api_end(); +} diff --git a/28_day/iroha/make.bat b/28_day/iroha/make.bat new file mode 100644 index 0000000..6b0dbfc --- /dev/null +++ b/28_day/iroha/make.bat @@ -0,0 +1 @@ +..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9 \ No newline at end of file diff --git a/28_day/nihongo/jpn16v00.bin b/28_day/nihongo/jpn16v00.bin new file mode 100644 index 0000000..135f07c Binary files /dev/null and b/28_day/nihongo/jpn16v00.bin differ diff --git a/28_day/nihongo/jpn16v00.fnt b/28_day/nihongo/jpn16v00.fnt new file mode 100644 index 0000000..cd7387a Binary files /dev/null and b/28_day/nihongo/jpn16v00.fnt differ diff --git a/28_day/nihongo/nihongo.fnt b/28_day/nihongo/nihongo.fnt new file mode 100644 index 0000000..e312bf5 Binary files /dev/null and b/28_day/nihongo/nihongo.fnt differ