Compare commits

...

3 Commits

Author SHA1 Message Date
Yourtion
d925a8d992 update 2016-05-18 13:20:49 +08:00
Yourtion
7497159026 日文文字显示(3) 2016-05-18 13:19:01 +08:00
Yourtion
fcd87ee302 日文文字显示(2) 2016-05-18 12:58:00 +08:00
18 changed files with 372 additions and 47 deletions

Binary file not shown.

View File

@@ -14,18 +14,19 @@ default :
#文件生成规则
haribote.img : haribote/ipl10.bin haribote/haribote.sys Makefile \
haribote.img : haribote/ipl20.bin haribote/haribote.sys Makefile \
a/a.hrb hello3/hello3.hrb hello4/hello4.hrb hello5/hello5.hrb \
winhelo/winhelo.hrb winhelo2/winhelo2.hrb winhelo3/winhelo3.hrb \
star1/star1.hrb stars/stars.hrb stars2/stars2.hrb \
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 iroha/iroha.hrb
typeipl/typeipl.hrb type/type.hrb iroha/iroha.hrb \
chklang/chklang.hrb
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
wbinimg src:haribote/ipl10.bin len:512 from:0 to:0 \
wbinimg src:haribote/ipl20.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:@: \
@@ -49,6 +50,8 @@ haribote.img : haribote/ipl10.bin haribote/haribote.sys Makefile \
copy from:typeipl/typeipl.hrb to:@: \
copy from:type/type.hrb to:@: \
copy from:iroha/iroha.hrb to:@: \
copy from:chklang/chklang.hrb to:@: \
copy from:euc.txt to:@: \
copy from:nihongo/nihongo.fnt to:@: \
imgout:haribote.img
@@ -88,6 +91,7 @@ full :
$(MAKE) -C typeipl
$(MAKE) -C type
$(MAKE) -C iroha
$(MAKE) -C chklang
$(MAKE) haribote.img
run_full :
@@ -112,55 +116,57 @@ src_only :
clean_full :
$(MAKE) -C haribote clean
$(MAKE) -C apilib clean
$(MAKE) -C a clean
$(MAKE) -C hello3 clean
$(MAKE) -C hello4 clean
$(MAKE) -C hello5 clean
$(MAKE) -C apilib clean
$(MAKE) -C a clean
$(MAKE) -C hello3 clean
$(MAKE) -C hello4 clean
$(MAKE) -C hello5 clean
$(MAKE) -C winhelo clean
$(MAKE) -C winhelo2 clean
$(MAKE) -C winhelo3 clean
$(MAKE) -C star1 clean
$(MAKE) -C stars clean
$(MAKE) -C stars2 clean
$(MAKE) -C lines clean
$(MAKE) -C walk clean
$(MAKE) -C noodle clean
$(MAKE) -C star1 clean
$(MAKE) -C stars clean
$(MAKE) -C stars2 clean
$(MAKE) -C lines clean
$(MAKE) -C walk clean
$(MAKE) -C noodle clean
$(MAKE) -C beepdown clean
$(MAKE) -C color clean
$(MAKE) -C color2 clean
$(MAKE) -C sosu clean
$(MAKE) -C sosu2 clean
$(MAKE) -C sosu3 clean
$(MAKE) -C color clean
$(MAKE) -C color2 clean
$(MAKE) -C sosu clean
$(MAKE) -C sosu2 clean
$(MAKE) -C sosu3 clean
$(MAKE) -C typeipl clean
$(MAKE) -C type clean
$(MAKE) -C iroha clean
$(MAKE) -C type clean
$(MAKE) -C iroha clean
$(MAKE) -C chklang clean
src_only_full :
$(MAKE) -C haribote src_only
$(MAKE) -C apilib src_only
$(MAKE) -C a src_only
$(MAKE) -C hello3 src_only
$(MAKE) -C hello4 src_only
$(MAKE) -C hello5 src_only
$(MAKE) -C apilib src_only
$(MAKE) -C a src_only
$(MAKE) -C hello3 src_only
$(MAKE) -C hello4 src_only
$(MAKE) -C hello5 src_only
$(MAKE) -C winhelo src_only
$(MAKE) -C winhelo2 src_only
$(MAKE) -C winhelo3 src_only
$(MAKE) -C star1 src_only
$(MAKE) -C stars src_only
$(MAKE) -C stars2 src_only
$(MAKE) -C lines src_only
$(MAKE) -C walk src_only
$(MAKE) -C noodle src_only
$(MAKE) -C star1 src_only
$(MAKE) -C stars src_only
$(MAKE) -C stars2 src_only
$(MAKE) -C lines src_only
$(MAKE) -C walk src_only
$(MAKE) -C noodle src_only
$(MAKE) -C beepdown src_only
$(MAKE) -C color src_only
$(MAKE) -C color2 src_only
$(MAKE) -C sosu src_only
$(MAKE) -C sosu2 src_only
$(MAKE) -C sosu3 src_only
$(MAKE) -C color src_only
$(MAKE) -C color2 src_only
$(MAKE) -C sosu src_only
$(MAKE) -C sosu2 src_only
$(MAKE) -C sosu3 src_only
$(MAKE) -C typeipl src_only
$(MAKE) -C type src_only
$(MAKE) -C iroha src_only
$(MAKE) -C type src_only
$(MAKE) -C iroha src_only
$(MAKE) -C chklang src_only
-$(DEL) haribote.img
refresh :

View File

@@ -24,3 +24,4 @@ void api_fseek(int fhandle, int offset, int mode);
int api_fsize(int fhandle, int mode);
int api_fread(char *buf, int maxsize, int fhandle);
int api_cmdline(char *buf, int maxsize);
int api_getlang(void);

View File

@@ -2,7 +2,7 @@ OBJS_API = api001.obj api002.obj api003.obj api004.obj api005.obj api006.obj \
api007.obj api008.obj api009.obj api010.obj api011.obj api012.obj \
api013.obj api014.obj api015.obj api016.obj api017.obj api018.obj \
api019.obj api020.obj api021.obj api022.obj api023.obj api024.obj \
api025.obj api026.obj alloca.obj
api025.obj api026.obj api027.obj alloca.obj
TOOLPATH = ../../z_tools/
INCPATH = ../../z_tools/haribote/

13
28_day/apilib/api027.nas Normal file
View File

@@ -0,0 +1,13 @@
[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[BITS 32]
[FILE "api027.nas"]
GLOBAL _api_getlang
[SECTION .text]
_api_getlang: ; int api_getlang(void);
MOV EDX,27
INT 0x40
RET

View File

@@ -0,0 +1 @@
command

View File

@@ -0,0 +1 @@
cmd.exe

5
28_day/chklang/Makefile Normal file
View File

@@ -0,0 +1,5 @@
APP = chklang
STACK = 1k
MALLOC = 0k
include ../app_make.txt

24
28_day/chklang/chklang.c Normal file
View File

@@ -0,0 +1,24 @@
#include "apilib.h"
void HariMain(void)
{
int langmode = api_getlang();
static char s1[23] = { /* 日本語シフトJISモード日文Shift-JIS模式*/
0x93, 0xfa, 0x96, 0x7b, 0x8c, 0xea, 0x83, 0x56, 0x83, 0x74, 0x83, 0x67,
0x4a, 0x49, 0x53, 0x83, 0x82, 0x81, 0x5b, 0x83, 0x68, 0x0a, 0x00
};
static char s2[17] = { /*日本語EUCモード日文EUC模式*/
0xc6, 0xfc, 0xcb, 0xdc, 0xb8, 0xec, 0x45, 0x55, 0x43, 0xa5, 0xe2, 0xa1,
0xbc, 0xa5, 0xc9, 0x0a, 0x00
};
if (langmode == 0) {
api_putstr0("English ASCII mode\n");
}
if (langmode == 1) {
api_putstr0(s1);
}
if (langmode == 2) {
api_putstr0(s2);
}
api_end();
}

1
28_day/chklang/make.bat Normal file
View File

@@ -0,0 +1 @@
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

1
28_day/euc.txt Normal file
View File

@@ -0,0 +1 @@
日本語EUCで書いてみたよー

View File

@@ -23,7 +23,7 @@ DEL = del
#默认动作
default :
$(MAKE) ipl10.bin
$(MAKE) ipl20.bin
$(MAKE) haribote.sys
# 镜像文件生成
@@ -31,6 +31,9 @@ default :
ipl10.bin : ipl10.nas Makefile
$(NASK) ipl10.nas ipl10.bin ipl10.lst
ipl20.bin : ipl20.nas Makefile
$(NASK) ipl20.nas ipl20.bin ipl20.lst
asmhead.bin : asmhead.nas Makefile
$(NASK) asmhead.nas asmhead.bin asmhead.lst
@@ -76,4 +79,5 @@ clean :
src_only :
$(MAKE) clean
-$(DEL) ipl10.bin
-$(DEL) ipl20.bin
-$(DEL) haribote.sys

View File

@@ -217,7 +217,7 @@ struct TASK {
struct FILEHANDLE *fhandle;
int *fat;
char *cmdline;
char langmode;
unsigned char langmode, langbyte1;
};
struct TASKLEVEL {
int running; /*正在运行的任务数量*/

View File

@@ -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;
}
@@ -329,7 +334,7 @@ void cmd_langmode(struct CONSOLE *cons, char *cmdline)
{
struct TASK *task = task_now();
unsigned char mode = cmdline[9] - '0';
if (mode <= 1) {
if (mode <= 2) {
task->langmode = mode;
} else {
cons_putstr0(cons, "mode number error.\n");
@@ -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");
}
@@ -614,6 +620,8 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
i++;
}
reg[7] = i;
} else if (edx == 27) {
reg[7] = task->langmode;
}
return 0;
}

View File

@@ -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,50 @@ 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;
}
}
if (task->langmode == 2) {
for (; *s != 0x00; s++) {
if (task->langbyte1 == 0) {
if (0x81 <= *s && *s <= 0xfe) {
task->langbyte1 = *s;
} else {
putfont8(vram, xsize, x, y, c, nihongo + *s * 16);
}
} else {
k = task->langbyte1 - 0xa1;
t = *s - 0xa1;
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;
}
}

Binary file not shown.

109
28_day/haribote/ipl20.nas Normal file
View File

@@ -0,0 +1,109 @@
; haribote-ipl
; TAB=4
CYLS EQU 20 ; 声明CYLS=20
ORG 0x7c00 ; 指明程序装载地址
; 标准FAT12格式软盘专用的代码 Stand FAT12 format floppy code
JMP entry
DB 0x90
DB "HARIBOTE" ; 启动扇区名称8字节
DW 512 ; 每个扇区sector大小必须512字节
DB 1 ; 簇cluster大小必须为1个扇区
DW 1 ; FAT起始位置一般为第一个扇区
DB 2 ; FAT个数必须为2
DW 224 ; 根目录大小一般为224项
DW 2880 ; 该磁盘大小必须为2880扇区1440*1024/512
DB 0xf0 ; 磁盘类型必须为0xf0
DW 9 ; FAT的长度必??9扇区
DW 18 ; 一个磁道track有几个扇区必须为18
DW 2 ; 磁头数(必??2
DD 0 ; 不使用分区必须是0
DD 2880 ; 重写一次磁盘大小
DB 0,0,0x29 ; 意义不明(固定)
DD 0xffffffff ; (可能是)卷标号码
DB "HARIBOTEOS " ; 磁盘的名称必须为11字?,不足填空格)
DB "FAT12 " ; 磁盘格式名称(必??8字?,不足填空格)
RESB 18 ; 先空出18字节
; 程序主体
entry:
MOV AX,0 ; 初始化寄存器
MOV SS,AX
MOV SP,0x7c00
MOV DS,AX
; 读取磁盘
MOV AX,0x0820
MOV ES,AX
MOV CH,0 ; 柱面0
MOV DH,0 ; 磁头0
MOV CL,2 ; 扇区2
readloop:
MOV SI,0 ; 记录失败次数寄存器
retry:
MOV AH,0x02 ; AH=0x02 : 读入磁盘
MOV AL,1 ; 1个扇区
MOV BX,0
MOV DL,0x00 ; A驱动器
INT 0x13 ; 调用磁盘BIOS
JNC next ; 没出错则跳转到fin
ADD SI,1 ; 往SI加1
CMP SI,5 ; 比较SI与5
JAE error ; SI >= 5 跳转到error
MOV AH,0x00
MOV DL,0x00 ; A驱动器
INT 0x13 ; 重置驱动器
JMP retry
next:
MOV AX,ES ; 把内存地址后移0x200512/16十六进制转换
ADD AX,0x0020
MOV ES,AX ; ADD ES,0x020因为没有ADD ES只能通过AX进行
ADD CL,1 ; 往CL里面加1
CMP CL,18 ; 比较CL与18
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.sys执行
MOV [0x0ff0],CH ; IPLがどこまで読んだのかをメモ
JMP 0xc200
error:
MOV SI,msg
putloop:
MOV AL,[SI]
ADD SI,1 ; 给SI加1
CMP AL,0
JE fin
MOV AH,0x0e ; 显示一个文字
MOV BX,15 ; 指定字符颜色
INT 0x10 ; 调用显卡BIOS
JMP putloop
fin:
HLT ; 让CPU停止等待指令
JMP fin ; 无限循环
msg:
DB 0x0a, 0x0a ; 换行两次
DB "load error"
DB 0x0a ; 换行
DB 0
RESB 0x7dfe-$ ; 填写0x00直到0x001fe
DB 0x55, 0xaa

107
28_day/haribote/jp.nas Normal file
View File

@@ -0,0 +1,107 @@
; haribote-ipl
; TAB=4
CYLS EQU 10 ; どこまで読み込むか
ORG 0x7c00 ; このプログラムがどこに読み込まれるのか
; 以下は標準的なFAT12フォーマットフロッピーディスクのための記述
JMP entry
DB 0x90
DB "HARIBOTE" ; ブートセクタの名前を自由に書いてよい8バイト
DW 512 ; 1セクタの大きさ512にしなければいけない
DB 1 ; クラスタの大きさ1セクタにしなければいけない
DW 1 ; FATがどこから始まるか普通は1セクタ目からにする
DB 2 ; FATの個数2にしなければいけない
DW 224 ; ルートディレクトリ領域の大きさ普通は224エントリにする
DW 2880 ; このドライブの大きさ2880セクタにしなければいけない
DB 0xf0 ; メディアのタイプ0xf0にしなければいけない
DW 9 ; FAT領域の長さ9セクタにしなければいけない
DW 18 ; 1トラックにいくつのセクタがあるか18にしなければいけない
DW 2 ; ヘッドの数2にしなければいけない
DD 0 ; パーティションを使ってないのでここは必ず0
DD 2880 ; このドライブ大きさをもう一度書く
DB 0,0,0x29 ; よくわからないけどこの値にしておくといいらしい
DD 0xffffffff ; たぶんボリュームシリアル番号
DB "HARIBOTEOS " ; ディスクの名前11バイト
DB "FAT12 " ; フォーマットの名前8バイト
RESB 18 ; とりあえず18バイトあけておく
; プログラム本体
entry:
MOV AX,0 ; レジスタ初期化
MOV SS,AX
MOV SP,0x7c00
MOV DS,AX
; ディスクを読む
MOV AX,0x0820
MOV ES,AX
MOV CH,0 ; シリンダ0
MOV DH,0 ; ヘッド0
MOV CL,2 ; セクタ2
readloop:
MOV SI,0 ; 失敗回数を数えるレジスタ
retry:
MOV AH,0x02 ; AH=0x02 : ディスク読み込み
MOV AL,1 ; 1セクタ
MOV BX,0
MOV DL,0x00 ; Aドライブ
INT 0x13 ; ディスクBIOS呼び出し
JNC next ; エラーがおきなければnextへ
ADD SI,1 ; SIに1を足す
CMP SI,5 ; SIと5を比較
JAE error ; SI >= 5 だったらerrorへ
MOV AH,0x00
MOV DL,0x00 ; Aドライブ
INT 0x13 ; ドライブのリセット
JMP retry
next:
MOV AX,ES ; アドレスを0x200進める
ADD AX,0x0020
MOV ES,AX ; ADD ES,0x020 という命令がないのでこうしている
ADD CL,1 ; CLに1を足す
CMP CL,18 ; CLと18を比較
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.sysを実行だ
MOV [0x0ff0],CH ; IPLがどこまで読んだのかをメモ
JMP 0xc200
error:
MOV AX,0
MOV ES,AX
MOV SI,msg
putloop:
MOV AL,[SI]
ADD SI,1 ; SIに1を足す
CMP AL,0
JE fin
MOV AH,0x0e ; 一文字表示ファンクション
MOV BX,15 ; カラーコード
INT 0x10 ; ビデオBIOS呼び出し
JMP putloop
fin:
HLT ; 何かあるまでCPUを停止させる
JMP fin ; 無限ループ
msg:
DB 0x0a, 0x0a ; 改行を2つ
DB "load error"
DB 0x0a ; 改行
DB 0
RESB 0x7dfe-$ ; 0x7dfeまでを0x00で埋める命令
DB 0x55, 0xaa