From 75a82443c1c504b5b3ff65ed12a7dc05698a2414 Mon Sep 17 00:00:00 2001 From: Yourtion Date: Mon, 9 May 2016 18:34:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 22_day/Makefile | 10 +++++++++- 22_day/a_nask.nas | 17 +++++++++++++++++ 22_day/bootpack.c | 1 + 22_day/console.c | 21 ++++++++++++++++----- 22_day/winhelo.c | 11 +++++++++++ 5 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 22_day/winhelo.c diff --git a/22_day/Makefile b/22_day/Makefile index 5c8a62b..3718ae8 100644 --- a/22_day/Makefile +++ b/22_day/Makefile @@ -80,6 +80,13 @@ hello5.bim : hello5.obj Makefile hello5.hrb : hello5.bim Makefile $(BIM2HRB) hello5.bim hello5.hrb 0 +winhelo.bim : winhelo.obj a_nask.obj Makefile + $(OBJ2BIM) @$(RULEFILE) out:winhelo.bim stack:1k map:winhelo.map \ + winhelo.obj a_nask.obj + +winhelo.hrb : winhelo.bim Makefile + $(BIM2HRB) winhelo.bim winhelo.hrb 0 + bug1.bim : bug1.obj Makefile $(OBJ2BIM) @$(RULEFILE) out:bug1.bim map:bug1.map bug1.obj a_nask.obj @@ -100,7 +107,7 @@ bug3.hrb : bug3.bim Makefile haribote.img : ipl10.bin haribote.sys Makefile \ hello.hrb hello2.hrb a.hrb hello3.hrb bug1.hrb bug2.hrb bug3.hrb \ - hello4.hrb hello5.hrb + hello4.hrb hello5.hrb winhelo.hrb $(EDIMG) imgin:../z_tools/fdimg0at.tek \ wbinimg src:ipl10.bin len:512 from:0 to:0 \ copy from:haribote.sys to:@: \ @@ -115,6 +122,7 @@ haribote.img : ipl10.bin haribote.sys Makefile \ copy from:bug3.hrb to:@: \ copy from:hello4.hrb to:@: \ copy from:hello5.hrb to:@: \ + copy from:winhelo.hrb to:@: \ imgout:haribote.img # 其他指令 diff --git a/22_day/a_nask.nas b/22_day/a_nask.nas index 7a71f20..d02e6ea 100644 --- a/22_day/a_nask.nas +++ b/22_day/a_nask.nas @@ -6,6 +6,7 @@ GLOBAL _api_putchar GLOBAL _api_putstr0 GLOBAL _api_end + GLOBAL _api_openwin [SECTION .text] @@ -26,3 +27,19 @@ _api_putstr0: ; void api_putstr0(char *s); _api_end: ; void api_end(void); MOV EDX,4 INT 0x40 + +_api_openwin: ; int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title); + PUSH EDI + PUSH ESI + PUSH EBX + MOV EDX,5 + MOV EBX,[ESP+16] ; buf + MOV ESI,[ESP+20] ; xsiz + MOV EDI,[ESP+24] ; ysiz + MOV EAX,[ESP+28] ; col_inv + MOV ECX,[ESP+32] ; title + INT 0x40 + POP EBX + POP ESI + POP EDI + RET diff --git a/22_day/bootpack.c b/22_day/bootpack.c index c215441..c0c9240 100644 --- a/22_day/bootpack.c +++ b/22_day/bootpack.c @@ -64,6 +64,7 @@ void HariMain(void) task_a = task_init(memman); fifo.task = task_a; task_run(task_a, 1, 2); + *((int *) 0x0fe4) = (int) shtctl; /* sht_back */ sht_back = sheet_alloc(shtctl); diff --git a/22_day/console.c b/22_day/console.c index 6f92944..f3eb8be 100644 --- a/22_day/console.c +++ b/22_day/console.c @@ -312,19 +312,30 @@ 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 cs_base = *((int *) 0xfe8); + int ds_base = *((int *) 0xfe8); struct TASK *task = task_now(); struct CONSOLE *cons = (struct CONSOLE *) *((int *) 0x0fec); + struct SHTCTL *shtctl = (struct SHTCTL *) *((int *) 0x0fe4); + struct SHEET *sht; + 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 */ if (edx == 1) { cons_putchar(cons, eax & 0xff, 1); } else if (edx == 2) { - cons_putstr0(cons, (char *) ebx + cs_base); + cons_putstr0(cons, (char *) ebx + ds_base); } else if (edx == 3) { - cons_putstr1(cons, (char *) ebx + cs_base, ecx); + cons_putstr1(cons, (char *) ebx + ds_base, ecx); } else if (edx == 4) { return &(task->tss.esp0); - } else if (edx == 123456789) { - *((char *) 0x00102600) = 0; + } else if (edx == 5) { + sht = sheet_alloc(shtctl); + 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, 100, 50); + sheet_updown(sht, 3); /*背景层高度3位于task_a之上*/ + reg[7] = (int) sht; } return 0; } diff --git a/22_day/winhelo.c b/22_day/winhelo.c new file mode 100644 index 0000000..6d7fb0a --- /dev/null +++ b/22_day/winhelo.c @@ -0,0 +1,11 @@ +int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title); +void api_end(void); + +char buf[150 * 50]; + +void HariMain(void) +{ + int win; + win = api_openwin(buf, 150, 50, -1, "hello"); + api_end(); +}