From 76e2a4a389da276ba4705a29a1d611093840d0a9 Mon Sep 17 00:00:00 2001 From: Yourtion Date: Tue, 10 May 2016 14:55:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=B7=E6=96=B0=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 23_day/Makefile | 10 +++++++++- 23_day/a_nask.nas | 17 +++++++++++++++++ 23_day/console.c | 21 +++++++++++++++------ 23_day/stars2.c | 26 ++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 23_day/stars2.c diff --git a/23_day/Makefile b/23_day/Makefile index 9ff94fa..1cad093 100644 --- a/23_day/Makefile +++ b/23_day/Makefile @@ -127,9 +127,16 @@ stars.bim : stars.obj a_nask.obj Makefile stars.hrb : stars.bim Makefile $(BIM2HRB) stars.bim stars.hrb 47k +stars2.bim : stars2.obj a_nask.obj Makefile + $(OBJ2BIM) @$(RULEFILE) out:stars2.bim stack:1k map:stars2.map \ + stars2.obj a_nask.obj + +stars2.hrb : stars2.bim Makefile + $(BIM2HRB) stars2.bim stars2.hrb 47k + haribote.img : ipl10.bin haribote.sys Makefile \ hello.hrb hello2.hrb a.hrb hello3.hrb hello4.hrb hello5.hrb \ - winhelo.hrb winhelo2.hrb winhelo3.hrb star1.hrb stars.hrb + winhelo.hrb winhelo2.hrb winhelo3.hrb star1.hrb stars.hrb stars2.hrb $(EDIMG) imgin:../z_tools/fdimg0at.tek \ wbinimg src:ipl10.bin len:512 from:0 to:0 \ copy from:haribote.sys to:@: \ @@ -146,6 +153,7 @@ haribote.img : ipl10.bin haribote.sys Makefile \ copy from:winhelo3.hrb to:@: \ copy from:star1.hrb to:@: \ copy from:stars.hrb to:@: \ + copy from:stars2.hrb to:@: \ imgout:haribote.img # 其他指令 diff --git a/23_day/a_nask.nas b/23_day/a_nask.nas index b175d08..1d78502 100644 --- a/23_day/a_nask.nas +++ b/23_day/a_nask.nas @@ -13,6 +13,7 @@ GLOBAL _api_malloc GLOBAL _api_free GLOBAL _api_point + GLOBAL _api_refreshwin [SECTION .text] @@ -133,3 +134,19 @@ _api_point: ; void api_point(int win, int x, int y, int col); POP ESI POP EDI RET + +_api_refreshwin: ; void api_refreshwin(int win, int x0, int y0, int x1, int y1); + PUSH EDI + PUSH ESI + PUSH EBX + MOV EDX,12 + MOV EBX,[ESP+16] ; win + MOV EAX,[ESP+20] ; x0 + MOV ECX,[ESP+24] ; y0 + MOV ESI,[ESP+28] ; x1 + MOV EDI,[ESP+32] ; y1 + INT 0x40 + POP EBX + POP ESI + POP EDI + RET diff --git a/23_day/console.c b/23_day/console.c index 897ecb5..86646ed 100644 --- a/23_day/console.c +++ b/23_day/console.c @@ -337,13 +337,17 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int sheet_updown(sht, 3); /*背景层高度3位于task_a之上*/ reg[7] = (int) sht; } else if (edx == 6) { - sht = (struct SHEET *) ebx; + sht = (struct SHEET *) (ebx & 0xfffffffe); putfonts8_asc(sht->buf, sht->bxsize, esi, edi, eax, (char *) ebp + ds_base); - sheet_refresh(sht, esi, edi, esi + ecx * 8, edi + 16); + if ((ebx & 1) == 0) { + sheet_refresh(sht, esi, edi, esi + ecx * 8, edi + 16); + } } else if (edx == 7) { - sht = (struct SHEET *) ebx; + sht = (struct SHEET *) (ebx & 0xfffffffe); boxfill8(sht->buf, sht->bxsize, ebp, eax, ecx, esi, edi); - sheet_refresh(sht, eax, ecx, esi + 1, edi + 1); + if ((ebx & 1) == 0) { + sheet_refresh(sht, eax, ecx, esi + 1, edi + 1); + } } else if (edx == 8) { memman_init((struct MEMMAN *) (ebx + ds_base)); ecx &= 0xfffffff0; /*以16字节为单位*/ @@ -355,9 +359,14 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int ecx = (ecx + 0x0f) & 0xfffffff0; /*以16字节为单位进位取整*/ memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); } else if (edx == 11) { - sht = (struct SHEET *) ebx; + sht = (struct SHEET *) (ebx & 0xfffffffe); sht->buf[sht->bxsize * edi + esi] = eax; - sheet_refresh(sht, esi, edi, esi + 1, edi + 1); + if ((ebx & 1) == 0) { + sheet_refresh(sht, esi, edi, esi + 1, edi + 1); + } + } else if (edx == 12) { + sht = (struct SHEET *) ebx; + sheet_refresh(sht, eax, ecx, esi, edi); } return 0; } diff --git a/23_day/stars2.c b/23_day/stars2.c new file mode 100644 index 0000000..94a029e --- /dev/null +++ b/23_day/stars2.c @@ -0,0 +1,26 @@ +int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title); +void api_boxfilwin(int win, int x0, int y0, int x1, int y1, int col); +void api_initmalloc(void); +char *api_malloc(int size); +void api_point(int win, int x, int y, int col); +void api_refreshwin(int win, int x0, int y0, int x1, int y1); +void api_end(void); + +int rand(void); /*产生0~32767的随机数*/ + +void HariMain(void) +{ + char *buf; + int win, i, x, y; + api_initmalloc(); + buf = api_malloc(150 * 100); + win = api_openwin(buf, 150, 100, -1, "stars2"); + api_boxfilwin(win + 1, 6, 26, 143, 93, 0);/*黑色*/ + for (i = 0; i < 50; i++) { + x = (rand() % 137) + 6; + y = (rand() % 67) + 26; + api_point(win + 1, x, y, 3);/*黄色*/ + } + api_refreshwin(win, 6, 26, 144, 94); + api_end(); +}