From dc29fff86f2de3c5310eb905b05c8e6d8cb21401 Mon Sep 17 00:00:00 2001 From: Yourtion Date: Tue, 10 May 2016 14:31:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=BB=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 23_day/Makefile | 18 +++++++++++++++++- 23_day/a_nask.nas | 17 ++++++++++++++++- 23_day/console.c | 4 ++++ 23_day/star1.c | 18 ++++++++++++++++++ 23_day/stars.c | 24 ++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 23_day/star1.c create mode 100644 23_day/stars.c diff --git a/23_day/Makefile b/23_day/Makefile index 6314477..9ff94fa 100644 --- a/23_day/Makefile +++ b/23_day/Makefile @@ -113,9 +113,23 @@ winhelo3.bim : winhelo3.obj a_nask.obj Makefile winhelo3.hrb : winhelo3.bim Makefile $(BIM2HRB) winhelo3.bim winhelo3.hrb 40k +star1.bim : star1.obj a_nask.obj Makefile + $(OBJ2BIM) @$(RULEFILE) out:star1.bim stack:1k map:star1.map \ + star1.obj a_nask.obj + +star1.hrb : star1.bim Makefile + $(BIM2HRB) star1.bim star1.hrb 47k + +stars.bim : stars.obj a_nask.obj Makefile + $(OBJ2BIM) @$(RULEFILE) out:stars.bim stack:1k map:stars.map \ + stars.obj a_nask.obj + +stars.hrb : stars.bim Makefile + $(BIM2HRB) stars.bim stars.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 + winhelo.hrb winhelo2.hrb winhelo3.hrb star1.hrb stars.hrb $(EDIMG) imgin:../z_tools/fdimg0at.tek \ wbinimg src:ipl10.bin len:512 from:0 to:0 \ copy from:haribote.sys to:@: \ @@ -130,6 +144,8 @@ haribote.img : ipl10.bin haribote.sys Makefile \ copy from:winhelo.hrb to:@: \ copy from:winhelo2.hrb to:@: \ copy from:winhelo3.hrb to:@: \ + copy from:star1.hrb to:@: \ + copy from:stars.hrb to:@: \ imgout:haribote.img # 其他指令 diff --git a/23_day/a_nask.nas b/23_day/a_nask.nas index 63ed27b..b175d08 100644 --- a/23_day/a_nask.nas +++ b/23_day/a_nask.nas @@ -12,6 +12,7 @@ GLOBAL _api_initmalloc GLOBAL _api_malloc GLOBAL _api_free + GLOBAL _api_point [SECTION .text] @@ -117,4 +118,18 @@ _api_free: ; void api_free(char *addr, int size); INT 0x40 POP EBX RET - \ No newline at end of file + +_api_point: ; void api_point(int win, int x, int y, int col); + PUSH EDI + PUSH ESI + PUSH EBX + MOV EDX,11 + MOV EBX,[ESP+16] ; win + MOV ESI,[ESP+20] ; x + MOV EDI,[ESP+24] ; y + MOV EAX,[ESP+28] ; col + INT 0x40 + POP EBX + POP ESI + POP EDI + RET diff --git a/23_day/console.c b/23_day/console.c index ff80a71..897ecb5 100644 --- a/23_day/console.c +++ b/23_day/console.c @@ -354,6 +354,10 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int } else if (edx == 10) { ecx = (ecx + 0x0f) & 0xfffffff0; /*以16字节为单位进位取整*/ memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); + } else if (edx == 11) { + sht = (struct SHEET *) ebx; + sht->buf[sht->bxsize * edi + esi] = eax; + sheet_refresh(sht, esi, edi, esi + 1, edi + 1); } return 0; } diff --git a/23_day/star1.c b/23_day/star1.c new file mode 100644 index 0000000..8d80ffa --- /dev/null +++ b/23_day/star1.c @@ -0,0 +1,18 @@ +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_end(void); + +void HariMain(void) +{ + char *buf; + int win; + api_initmalloc(); + buf = api_malloc(150 * 100); + win = api_openwin(buf, 150, 100, -1, "star1"); + api_boxfilwin(win, 6, 26, 143, 93, 0);/*黑色*/ + api_point(win, 75, 59, 3);/*黄色*/ + api_end(); +} diff --git a/23_day/stars.c b/23_day/stars.c new file mode 100644 index 0000000..dc38b2b --- /dev/null +++ b/23_day/stars.c @@ -0,0 +1,24 @@ +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_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, "stars"); + api_boxfilwin(win, 6, 26, 143, 93, 0);/*黑色*/ + for (i = 0; i < 50; i++) { + x = (rand() % 137) + 6; + y = (rand() % 67) + 26; + api_point(win, x, y, 3);/*黄色*/ + } + api_end(); +}