diff --git a/27_day/Makefile b/27_day/Makefile index 719f71d..f1ed997 100644 --- a/27_day/Makefile +++ b/27_day/Makefile @@ -21,15 +21,16 @@ BIM2HRB = $(TOOLPATH)bim2hrb.exe RULEFILE = $(TOOLPATH)haribote/haribote.rul EDIMG = $(TOOLPATH)edimg.exe IMGTOL = $(TOOLPATH)imgtol.com +GOLIB = $(TOOLPATH)golib00.exe COPY = copy DEL = del -# 默认动作 +# ftHg default : $(MAKE) img -# 镜像文件生成 +# t@CK ipl10.bin : ipl10.nas Makefile $(NASK) ipl10.nas ipl10.bin ipl10.lst @@ -54,27 +55,24 @@ bootpack.hrb : bootpack.bim Makefile haribote.sys : asmhead.bin bootpack.hrb Makefile copy /B asmhead.bin+bootpack.hrb haribote.sys -hello.hrb : hello.nas Makefile - $(NASK) hello.nas hello.hrb hello.lst +apilib.lib : Makefile $(OBJS_API) + $(GOLIB) $(OBJS_API) out:apilib.lib -hello2.hrb : hello2.nas Makefile - $(NASK) hello2.nas hello2.hrb hello2.lst - -a.bim : a.obj $(OBJS_API) Makefile - $(OBJ2BIM) @$(RULEFILE) out:a.bim map:a.map a.obj $(OBJS_API) +a.bim : a.obj apilib.lib Makefile + $(OBJ2BIM) @$(RULEFILE) out:a.bim map:a.map a.obj apilib.lib a.hrb : a.bim Makefile $(BIM2HRB) a.bim a.hrb 0 -hello3.bim : hello3.obj $(OBJS_API) Makefile - $(OBJ2BIM) @$(RULEFILE) out:hello3.bim map:hello3.map hello3.obj $(OBJS_API) +hello3.bim : hello3.obj apilib.lib Makefile + $(OBJ2BIM) @$(RULEFILE) out:hello3.bim map:hello3.map hello3.obj apilib.lib hello3.hrb : hello3.bim Makefile $(BIM2HRB) hello3.bim hello3.hrb 0 -hello4.bim : hello4.obj $(OBJS_API) Makefile +hello4.bim : hello4.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:hello4.bim stack:1k map:hello4.map \ - hello4.obj $(OBJS_API) + hello4.obj apilib.lib hello4.hrb : hello4.bim Makefile $(BIM2HRB) hello4.bim hello4.hrb 0 @@ -85,108 +83,99 @@ hello5.bim : hello5.obj Makefile hello5.hrb : hello5.bim Makefile $(BIM2HRB) hello5.bim hello5.hrb 0 -winhelo.bim : winhelo.obj $(OBJS_API) Makefile +winhelo.bim : winhelo.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:winhelo.bim stack:1k map:winhelo.map \ - winhelo.obj $(OBJS_API) + winhelo.obj apilib.lib winhelo.hrb : winhelo.bim Makefile $(BIM2HRB) winhelo.bim winhelo.hrb 0 -winhelo2.bim : winhelo2.obj $(OBJS_API) Makefile +winhelo2.bim : winhelo2.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:winhelo2.bim stack:1k map:winhelo2.map \ - winhelo2.obj $(OBJS_API) + winhelo2.obj apilib.lib winhelo2.hrb : winhelo2.bim Makefile $(BIM2HRB) winhelo2.bim winhelo2.hrb 0 -winhelo3.bim : winhelo3.obj $(OBJS_API) Makefile +winhelo3.bim : winhelo3.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:winhelo3.bim stack:1k map:winhelo3.map \ - winhelo3.obj $(OBJS_API) + winhelo3.obj apilib.lib winhelo3.hrb : winhelo3.bim Makefile $(BIM2HRB) winhelo3.bim winhelo3.hrb 40k -star1.bim : star1.obj $(OBJS_API) Makefile +star1.bim : star1.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:star1.bim stack:1k map:star1.map \ - star1.obj $(OBJS_API) + star1.obj apilib.lib star1.hrb : star1.bim Makefile $(BIM2HRB) star1.bim star1.hrb 47k -stars.bim : stars.obj $(OBJS_API) Makefile +stars.bim : stars.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:stars.bim stack:1k map:stars.map \ - stars.obj $(OBJS_API) + stars.obj apilib.lib stars.hrb : stars.bim Makefile $(BIM2HRB) stars.bim stars.hrb 47k -stars2.bim : stars2.obj $(OBJS_API) Makefile +stars2.bim : stars2.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:stars2.bim stack:1k map:stars2.map \ - stars2.obj $(OBJS_API) + stars2.obj apilib.lib stars2.hrb : stars2.bim Makefile $(BIM2HRB) stars2.bim stars2.hrb 47k -lines.bim : lines.obj $(OBJS_API) Makefile +lines.bim : lines.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:lines.bim stack:1k map:lines.map \ - lines.obj $(OBJS_API) + lines.obj apilib.lib lines.hrb : lines.bim Makefile $(BIM2HRB) lines.bim lines.hrb 48k -walk.bim : walk.obj $(OBJS_API) Makefile +walk.bim : walk.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:walk.bim stack:1k map:walk.map \ - walk.obj $(OBJS_API) + walk.obj apilib.lib walk.hrb : walk.bim Makefile $(BIM2HRB) walk.bim walk.hrb 48k -noodle.bim : noodle.obj $(OBJS_API) Makefile +noodle.bim : noodle.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:noodle.bim stack:1k map:noodle.map \ - noodle.obj $(OBJS_API) + noodle.obj apilib.lib noodle.hrb : noodle.bim Makefile $(BIM2HRB) noodle.bim noodle.hrb 40k -beepdown.bim : beepdown.obj $(OBJS_API) Makefile +beepdown.bim : beepdown.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:beepdown.bim stack:1k map:beepdown.map \ - beepdown.obj $(OBJS_API) + beepdown.obj apilib.lib beepdown.hrb : beepdown.bim Makefile $(BIM2HRB) beepdown.bim beepdown.hrb 40k -color.bim : color.obj $(OBJS_API) Makefile +color.bim : color.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:color.bim stack:1k map:color.map \ - color.obj $(OBJS_API) + color.obj apilib.lib color.hrb : color.bim Makefile $(BIM2HRB) color.bim color.hrb 56k -color2.bim : color2.obj $(OBJS_API) Makefile +color2.bim : color2.obj apilib.lib Makefile $(OBJ2BIM) @$(RULEFILE) out:color2.bim stack:1k map:color2.map \ - color2.obj $(OBJS_API) + color2.obj apilib.lib color2.hrb : color2.bim Makefile $(BIM2HRB) color2.bim color2.hrb 56k -crack7.bim : crack7.obj Makefile - $(OBJ2BIM) @$(RULEFILE) out:crack7.bim stack:1k map:crack7.map crack7.obj - -crack7.hrb : crack7.bim Makefile - $(BIM2HRB) crack7.bim crack7.hrb 0k - 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 walk.hrb noodle.hrb beepdown.hrb color.hrb color2.hrb \ - crack7.hrb + a.hrb hello3.hrb hello4.hrb hello5.hrb winhelo.hrb winhelo2.hrb \ + winhelo3.hrb star1.hrb stars.hrb stars2.hrb lines.hrb walk.hrb \ + noodle.hrb beepdown.hrb color.hrb color2.hrb $(EDIMG) imgin:../z_tools/fdimg0at.tek \ wbinimg src:ipl10.bin len:512 from:0 to:0 \ copy from:haribote.sys to:@: \ copy from:ipl10.nas to:@: \ copy from:make.bat to:@: \ - copy from:hello.hrb to:@: \ - copy from:hello2.hrb to:@: \ copy from:a.hrb to:@: \ copy from:hello3.hrb to:@: \ copy from:hello4.hrb to:@: \ @@ -203,12 +192,11 @@ haribote.img : ipl10.bin haribote.sys Makefile \ copy from:beepdown.hrb to:@: \ copy from:color.hrb to:@: \ copy from:color2.hrb to:@: \ - copy from:crack7.hrb to:@: \ imgout:haribote.img -# 其他指令 +# ʋK -%.gas : %.c bootpack.h Makefile +%.gas : %.c bootpack.h apilib.h Makefile $(CC1) -o $*.gas $*.c %.nas : %.gas Makefile @@ -217,7 +205,7 @@ haribote.img : ipl10.bin haribote.sys Makefile \ %.obj : %.nas Makefile $(NASK) $*.nas $*.obj $*.lst -# 运行程序 +# R}h img : $(MAKE) haribote.img @@ -239,6 +227,7 @@ clean : -$(DEL) *.bim -$(DEL) *.hrb -$(DEL) haribote.sys + -$(DEL) apilib.lib src_only : $(MAKE) clean diff --git a/27_day/a.c b/27_day/a.c index a6668af..3df81f5 100644 --- a/27_day/a.c +++ b/27_day/a.c @@ -1,5 +1,4 @@ -void api_putchar(int c); -void api_end(void); +#include "apilib.h" void HariMain(void) { diff --git a/27_day/apilib.h b/27_day/apilib.h new file mode 100644 index 0000000..80ec6e0 --- /dev/null +++ b/27_day/apilib.h @@ -0,0 +1,20 @@ +void api_putchar(int c); +void api_putstr0(char *s); +void api_putstr1(char *s, int l); +void api_end(void); +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_free(char *addr, 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_linewin(int win, int x0, int y0, int x1, int y1, int col); +void api_closewin(int win); +int api_getkey(int mode); +int api_alloctimer(void); +void api_inittimer(int timer, int data); +void api_settimer(int timer, int time); +void api_freetimer(int timer); +void api_beep(int tone); diff --git a/27_day/beepdown.c b/27_day/beepdown.c index db1aa59..d08962c 100644 --- a/27_day/beepdown.c +++ b/27_day/beepdown.c @@ -1,9 +1,4 @@ -void api_end(void); -int api_getkey(int mode); -int api_alloctimer(void); -void api_inittimer(int timer, int data); -void api_settimer(int timer, int time); -void api_beep(int tone); +#include "apilib.h" void HariMain(void) { diff --git a/27_day/color.c b/27_day/color.c index c004c14..ce228e2 100644 --- a/27_day/color.c +++ b/27_day/color.c @@ -1,10 +1,4 @@ -int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title); -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); -int api_getkey(int mode); -void api_end(void); +#include "apilib.h" void HariMain(void) { diff --git a/27_day/color2.c b/27_day/color2.c index c063768..82e3f6a 100644 --- a/27_day/color2.c +++ b/27_day/color2.c @@ -1,10 +1,4 @@ -int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title); -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); -int api_getkey(int mode); -void api_end(void); +#include "apilib.h" unsigned char rgb2pal(int r, int g, int b, int x, int y); @@ -21,7 +15,7 @@ void HariMain(void) } } api_refreshwin(win, 8, 28, 136, 156); - api_getkey(1); /*等待按下任意键*/ + api_getkey(1); /* �Ă��Ƃ��ȃL�[���͂�҂� */ api_end(); } diff --git a/27_day/crack7.nas b/27_day/crack7.nas deleted file mode 100644 index 134090f..0000000 --- a/27_day/crack7.nas +++ /dev/null @@ -1,28 +0,0 @@ -[FORMAT "WCOFF"] -[INSTRSET "i486p"] -[BITS 32] -[FILE "crack7.nas"] - - GLOBAL _HariMain - -[SECTION .text] - -_HariMain: - MOV AX,1005*8 - MOV DS,AX - CMP DWORD [DS:0x0004],'Hari' - JNE fin ; 不是应用程序,因此不执行任何操作 - - MOV ECX,[DS:0x0000] ; 读取该应用程序数据段的大小 - MOV AX,2005*8 - MOV DS,AX - -crackloop: ; 整个用123填充 - ADD ECX,-1 - MOV BYTE [DS:ECX],123 - CMP ECX,0 - JNE crackloop - -fin: ; 结束 - MOV EDX,4 - INT 0x40 diff --git a/27_day/hello.nas b/27_day/hello.nas deleted file mode 100644 index b4e9576..0000000 --- a/27_day/hello.nas +++ /dev/null @@ -1,16 +0,0 @@ -[INSTRSET "i486p"] -[BITS 32] - MOV ECX,msg - MOV EDX,1 -putloop: - MOV AL,[CS:ECX] - CMP AL,0 - JE fin - INT 0x40 - ADD ECX,1 - JMP putloop -fin: - MOV EDX,4 - INT 0x40 -msg: - DB "hello",0 diff --git a/27_day/hello2.nas b/27_day/hello2.nas deleted file mode 100644 index 5e1e58c..0000000 --- a/27_day/hello2.nas +++ /dev/null @@ -1,9 +0,0 @@ -[INSTRSET "i486p"] -[BITS 32] - MOV EDX,2 - MOV EBX,msg - INT 0x40 - MOV EDX,4 - INT 0x40 -msg: - DB "hello",0 diff --git a/27_day/hello3.c b/27_day/hello3.c index 97d3236..f71cedf 100644 --- a/27_day/hello3.c +++ b/27_day/hello3.c @@ -1,5 +1,4 @@ -void api_putchar(int c); -void api_end(void); +#include "apilib.h" void HariMain(void) { diff --git a/27_day/hello4.c b/27_day/hello4.c index 7fb73de..ec04384 100644 --- a/27_day/hello4.c +++ b/27_day/hello4.c @@ -1,5 +1,4 @@ -void api_putstr0(char *s); -void api_end(void); +#include "apilib.h" void HariMain(void) { diff --git a/27_day/lines.c b/27_day/lines.c index 83e7ceb..5217faa 100644 --- a/27_day/lines.c +++ b/27_day/lines.c @@ -1,11 +1,4 @@ -int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title); -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); +#include "apilib.h" void HariMain(void) { diff --git a/27_day/noodle.c b/27_day/noodle.c index 13b9033..108d148 100644 --- a/27_day/noodle.c +++ b/27_day/noodle.c @@ -1,15 +1,5 @@ #include - -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); -int api_getkey(int mode); -int api_alloctimer(void); -void api_inittimer(int timer, int data); -void api_settimer(int timer, int time); -void api_end(void); +#include "apilib.h" void HariMain(void) { diff --git a/27_day/star1.c b/27_day/star1.c index 8d80ffa..6477c2a 100644 --- a/27_day/star1.c +++ b/27_day/star1.c @@ -1,9 +1,4 @@ -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); +#include "apilib.h" void HariMain(void) { diff --git a/27_day/stars.c b/27_day/stars.c index dc38b2b..c8dae64 100644 --- a/27_day/stars.c +++ b/27_day/stars.c @@ -1,9 +1,4 @@ -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); +#include "apilib.h" int rand(void); /*产生0~32767之间的随机数*/ diff --git a/27_day/stars2.c b/27_day/stars2.c index 94a029e..11ec0e1 100644 --- a/27_day/stars2.c +++ b/27_day/stars2.c @@ -1,10 +1,4 @@ -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); +#include "apilib.h" int rand(void); /*产生0~32767的随机数*/ diff --git a/27_day/walk.c b/27_day/walk.c index 6b106b4..4772f8a 100644 --- a/27_day/walk.c +++ b/27_day/walk.c @@ -1,13 +1,4 @@ -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); +#include "apilib.h" void HariMain(void) { diff --git a/27_day/winhelo.c b/27_day/winhelo.c index 6d7fb0a..a56225a 100644 --- a/27_day/winhelo.c +++ b/27_day/winhelo.c @@ -1,5 +1,4 @@ -int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title); -void api_end(void); +#include "apilib.h" char buf[150 * 50]; diff --git a/27_day/winhelo2.c b/27_day/winhelo2.c index f00b007..3cf30c6 100644 --- a/27_day/winhelo2.c +++ b/27_day/winhelo2.c @@ -1,7 +1,4 @@ -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_end(void); +#include "apilib.h" char buf[150 * 50]; diff --git a/27_day/winhelo3.c b/27_day/winhelo3.c index 527ec01..3eafc35 100644 --- a/27_day/winhelo3.c +++ b/27_day/winhelo3.c @@ -1,9 +1,4 @@ -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_end(void); +#include "apilib.h" void HariMain(void) { @@ -16,4 +11,4 @@ void HariMain(void) api_boxfilwin(win, 8, 36, 141, 43, 6); /*浅蓝色*/ api_putstrwin(win, 28, 28, 0 , 12, "hello, world");/*黑色*/ api_end(); -} \ No newline at end of file +}