From 591fa69b74e3c83cb48f0eb62d45337738e4505d Mon Sep 17 00:00:00 2001 From: Yourtion Date: Tue, 10 May 2016 16:03:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E9=94=AE=E7=9B=98=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=9D=A5=E6=B6=88=E9=81=A3=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 23_day/Makefile | 10 +++++++++- 23_day/walk.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 23_day/walk.c diff --git a/23_day/Makefile b/23_day/Makefile index b46962b..b61f4a2 100644 --- a/23_day/Makefile +++ b/23_day/Makefile @@ -141,10 +141,17 @@ lines.bim : lines.obj a_nask.obj Makefile lines.hrb : lines.bim Makefile $(BIM2HRB) lines.bim lines.hrb 48k +walk.bim : walk.obj a_nask.obj Makefile + $(OBJ2BIM) @$(RULEFILE) out:walk.bim stack:1k map:walk.map \ + walk.obj a_nask.obj + +walk.hrb : walk.bim Makefile + $(BIM2HRB) walk.bim walk.hrb 48k + 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 stars2.hrb \ - lines.hrb + lines.hrb walk.hrb $(EDIMG) imgin:../z_tools/fdimg0at.tek \ wbinimg src:ipl10.bin len:512 from:0 to:0 \ copy from:haribote.sys to:@: \ @@ -163,6 +170,7 @@ haribote.img : ipl10.bin haribote.sys Makefile \ copy from:stars.hrb to:@: \ copy from:stars2.hrb to:@: \ copy from:lines.hrb to:@: \ + copy from:walk.hrb to:@: \ imgout:haribote.img # 其他指令 diff --git a/23_day/walk.c b/23_day/walk.c new file mode 100644 index 0000000..6b106b4 --- /dev/null +++ b/23_day/walk.c @@ -0,0 +1,35 @@ +int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title); +void api_putstrwin(int win, int x, int y, int col, int len, char *str); +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_refreshwin(int win, int x0, int y0, int x1, int y1); +void api_linewin(int win, int x0, int y0, int x1, int y1, int col); +void api_closewin(int win); +int api_getkey(int mode); +void api_end(void); + +void HariMain(void) +{ + char *buf; + int win, i, x, y; + api_initmalloc(); + buf = api_malloc(160 * 100); + win = api_openwin(buf, 160, 100, -1, "walk"); + api_boxfilwin(win, 4, 24, 155, 95, 0);/*黑色*/ + x = 76; + y = 56; + api_putstrwin(win, x, y, 3, 1, "*");/*黄色*/ + for (;;) { + i = api_getkey(1); + api_putstrwin(win, x, y, 0 , 1, "*"); /*用黑色擦除*/ + if (i == '4' && x > 4) { x -= 8; } + if (i == '6' && x < 148) { x += 8; } + if (i == '8' && y > 24) { y -= 8; } + if (i == '2' && y < 80) { y += 8; } + if (i == 0x0a) { break; } /*按回车键结束*/ + api_putstrwin(win, x, y, 3 , 1, "*");/*黄色*/ + } + api_closewin(win); + api_end(); +}