mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-05 19:13:21 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0adab9385e | ||
|
|
73b7421cf2 | ||
|
|
203dd63152 | ||
|
|
9df2b90ad3 |
@@ -21,8 +21,8 @@ haribote.img : haribote/ipl20.bin haribote/haribote.sys Makefile \
|
||||
lines/lines.hrb walk/walk.hrb noodle/noodle.hrb \
|
||||
beepdown/beepdown.hrb color/color.hrb color2/color2.hrb \
|
||||
sosu/sosu.hrb sosu2/sosu2.hrb sosu3/sosu3.hrb \
|
||||
typeipl/typeipl.hrb type/type.hrb iroha/iroha.hrb \
|
||||
chklang/chklang.hrb
|
||||
type/type.hrb iroha/iroha.hrb chklang/chklang.hrb \
|
||||
notrec/notrec.hrb bball/bball.hrb
|
||||
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
|
||||
wbinimg src:haribote/ipl20.bin len:512 from:0 to:0 \
|
||||
copy from:haribote/haribote.sys to:@: \
|
||||
@@ -47,11 +47,12 @@ haribote.img : haribote/ipl20.bin haribote/haribote.sys Makefile \
|
||||
copy from:sosu/sosu.hrb to:@: \
|
||||
copy from:sosu2/sosu2.hrb to:@: \
|
||||
copy from:sosu3/sosu3.hrb to:@: \
|
||||
copy from:typeipl/typeipl.hrb to:@: \
|
||||
copy from:type/type.hrb to:@: \
|
||||
copy from:iroha/iroha.hrb to:@: \
|
||||
copy from:chklang/chklang.hrb to:@: \
|
||||
copy from:euc.txt to:@: \
|
||||
copy from:notrec/notrec.hrb to:@: \
|
||||
copy from:bball/bball.hrb to:@: \
|
||||
copy from:nihongo/nihongo.fnt to:@: \
|
||||
imgout:haribote.img
|
||||
|
||||
@@ -88,10 +89,11 @@ full :
|
||||
$(MAKE) -C sosu
|
||||
$(MAKE) -C sosu2
|
||||
$(MAKE) -C sosu3
|
||||
$(MAKE) -C typeipl
|
||||
$(MAKE) -C type
|
||||
$(MAKE) -C iroha
|
||||
$(MAKE) -C chklang
|
||||
$(MAKE) -C notrec
|
||||
$(MAKE) -C bball
|
||||
$(MAKE) haribote.img
|
||||
|
||||
run_full :
|
||||
@@ -116,57 +118,59 @@ src_only :
|
||||
|
||||
clean_full :
|
||||
$(MAKE) -C haribote clean
|
||||
$(MAKE) -C apilib clean
|
||||
$(MAKE) -C a clean
|
||||
$(MAKE) -C hello3 clean
|
||||
$(MAKE) -C hello4 clean
|
||||
$(MAKE) -C hello5 clean
|
||||
$(MAKE) -C apilib clean
|
||||
$(MAKE) -C a clean
|
||||
$(MAKE) -C hello3 clean
|
||||
$(MAKE) -C hello4 clean
|
||||
$(MAKE) -C hello5 clean
|
||||
$(MAKE) -C winhelo clean
|
||||
$(MAKE) -C winhelo2 clean
|
||||
$(MAKE) -C winhelo3 clean
|
||||
$(MAKE) -C star1 clean
|
||||
$(MAKE) -C stars clean
|
||||
$(MAKE) -C stars2 clean
|
||||
$(MAKE) -C lines clean
|
||||
$(MAKE) -C walk clean
|
||||
$(MAKE) -C noodle clean
|
||||
$(MAKE) -C star1 clean
|
||||
$(MAKE) -C stars clean
|
||||
$(MAKE) -C stars2 clean
|
||||
$(MAKE) -C lines clean
|
||||
$(MAKE) -C walk clean
|
||||
$(MAKE) -C noodle clean
|
||||
$(MAKE) -C beepdown clean
|
||||
$(MAKE) -C color clean
|
||||
$(MAKE) -C color2 clean
|
||||
$(MAKE) -C sosu clean
|
||||
$(MAKE) -C sosu2 clean
|
||||
$(MAKE) -C sosu3 clean
|
||||
$(MAKE) -C typeipl clean
|
||||
$(MAKE) -C type clean
|
||||
$(MAKE) -C iroha clean
|
||||
$(MAKE) -C color clean
|
||||
$(MAKE) -C color2 clean
|
||||
$(MAKE) -C sosu clean
|
||||
$(MAKE) -C sosu2 clean
|
||||
$(MAKE) -C sosu3 clean
|
||||
$(MAKE) -C type clean
|
||||
$(MAKE) -C iroha clean
|
||||
$(MAKE) -C chklang clean
|
||||
$(MAKE) -C notrec clean
|
||||
$(MAKE) -C bball clean
|
||||
|
||||
src_only_full :
|
||||
$(MAKE) -C haribote src_only
|
||||
$(MAKE) -C apilib src_only
|
||||
$(MAKE) -C a src_only
|
||||
$(MAKE) -C hello3 src_only
|
||||
$(MAKE) -C hello4 src_only
|
||||
$(MAKE) -C hello5 src_only
|
||||
$(MAKE) -C apilib src_only
|
||||
$(MAKE) -C a src_only
|
||||
$(MAKE) -C hello3 src_only
|
||||
$(MAKE) -C hello4 src_only
|
||||
$(MAKE) -C hello5 src_only
|
||||
$(MAKE) -C winhelo src_only
|
||||
$(MAKE) -C winhelo2 src_only
|
||||
$(MAKE) -C winhelo3 src_only
|
||||
$(MAKE) -C star1 src_only
|
||||
$(MAKE) -C stars src_only
|
||||
$(MAKE) -C stars2 src_only
|
||||
$(MAKE) -C lines src_only
|
||||
$(MAKE) -C walk src_only
|
||||
$(MAKE) -C noodle src_only
|
||||
$(MAKE) -C star1 src_only
|
||||
$(MAKE) -C stars src_only
|
||||
$(MAKE) -C stars2 src_only
|
||||
$(MAKE) -C lines src_only
|
||||
$(MAKE) -C walk src_only
|
||||
$(MAKE) -C noodle src_only
|
||||
$(MAKE) -C beepdown src_only
|
||||
$(MAKE) -C color src_only
|
||||
$(MAKE) -C color2 src_only
|
||||
$(MAKE) -C sosu src_only
|
||||
$(MAKE) -C sosu2 src_only
|
||||
$(MAKE) -C sosu3 src_only
|
||||
$(MAKE) -C typeipl src_only
|
||||
$(MAKE) -C type src_only
|
||||
$(MAKE) -C iroha src_only
|
||||
$(MAKE) -C color src_only
|
||||
$(MAKE) -C color2 src_only
|
||||
$(MAKE) -C sosu src_only
|
||||
$(MAKE) -C sosu2 src_only
|
||||
$(MAKE) -C sosu3 src_only
|
||||
$(MAKE) -C type src_only
|
||||
$(MAKE) -C iroha src_only
|
||||
$(MAKE) -C chklang src_only
|
||||
$(MAKE) -C notrec src_only
|
||||
$(MAKE) -C bball src_only
|
||||
-$(DEL) haribote.img
|
||||
|
||||
refresh :
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
TOOLPATH = ../../z_tools/
|
||||
INCPATH = ../../z_tools/haribote/
|
||||
APILIBPATH = ../apilib/
|
||||
STDLIBPATH = ../stdlib/
|
||||
HARIBOTEPATH = ../haribote/
|
||||
|
||||
MAKE = $(TOOLPATH)make.exe -r
|
||||
@@ -26,9 +27,13 @@ default :
|
||||
|
||||
#文件生成规则
|
||||
|
||||
$(APP).bim : $(APP).obj $(APILIBPATH)apilib.lib Makefile ../app_make.txt
|
||||
$(APP).bim : $(APP).obj $(APILIBPATH)apilib.lib $(STDLIBPATH)stdlib.lib Makefile ../app_make.txt
|
||||
$(OBJ2BIM) @$(RULEFILE) out:$(APP).bim map:$(APP).map stack:$(STACK) \
|
||||
$(APP).obj $(APILIBPATH)apilib.lib
|
||||
$(APP).obj $(APILIBPATH)apilib.lib $(STDLIBPATH)stdlib.lib
|
||||
|
||||
$(STDAPP).bim : $(APP).obj $(STDLIBPATH)stdlib.lib Makefile ../app_make.txt
|
||||
$(OBJ2BIM) @$(RULEFILE) out:$(APP).bim map:$(APP).map stack:$(STACK) \
|
||||
$(APP).obj $(STDLIBPATH)stdlib.lib
|
||||
|
||||
haribote.img : ../haribote/ipl20.bin ../haribote/haribote.sys $(APP).hrb \
|
||||
Makefile ../app_make.txt
|
||||
@@ -41,7 +46,7 @@ haribote.img : ../haribote/ipl20.bin ../haribote/haribote.sys $(APP).hrb \
|
||||
|
||||
#一般规则
|
||||
|
||||
%.gas : %.c ../apilib.h Makefile ../app_make.txt
|
||||
%.gas : %.c ../apilib.h ../stdlib.h Makefile ../app_make.txt
|
||||
$(CC1) -o $*.gas $*.c
|
||||
|
||||
%.nas : %.gas Makefile ../app_make.txt
|
||||
@@ -65,10 +70,12 @@ run :
|
||||
|
||||
full :
|
||||
$(MAKE) -C $(APILIBPATH)
|
||||
$(MAKE) -C $(STDLIBPATH)
|
||||
$(MAKE) $(APP).hrb
|
||||
|
||||
run_full :
|
||||
$(MAKE) -C $(APILIBPATH)
|
||||
$(MAKE) -C $(STDLIBPATH)
|
||||
$(MAKE) -C ../haribote
|
||||
$(MAKE) run
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
APP = typeipl
|
||||
STACK = 1k
|
||||
APP = bball
|
||||
STACK = 52k
|
||||
MALLOC = 0k
|
||||
|
||||
include ../app_make.txt
|
||||
37
29_day/bball/bball.c
Normal file
37
29_day/bball/bball.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "apilib.h"
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
int win, i, j, dis;
|
||||
char buf[216 * 237];
|
||||
struct POINT {
|
||||
int x, y;
|
||||
};
|
||||
static struct POINT table[16] = {
|
||||
{ 204, 129 }, { 195, 90 }, { 172, 58 }, { 137, 38 }, { 98, 34 },
|
||||
{ 61, 46 }, { 31, 73 }, { 15, 110 }, { 15, 148 }, { 31, 185 },
|
||||
{ 61, 212 }, { 98, 224 }, { 137, 220 }, { 172, 200 }, { 195, 168 },
|
||||
{ 204, 129 }
|
||||
};
|
||||
|
||||
win = api_openwin(buf, 216, 237, -1, "bball");
|
||||
api_boxfilwin(win, 8, 29, 207, 228, 0);
|
||||
for (i = 0; i <= 14; i++) {
|
||||
for (j = i + 1; j <= 15; j++) {
|
||||
dis = j - i; /*两点间的距离*/
|
||||
if (dis >= 8) {
|
||||
dis = 15 - dis; /*逆向计数*/
|
||||
}
|
||||
if (dis != 0) {
|
||||
api_linewin(win, table[i].x, table[i].y, table[j].x, table[j].y, 8 - dis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (api_getkey(1) == 0x0a) {
|
||||
break; /*按下回车键则break; */
|
||||
}
|
||||
}
|
||||
api_end();
|
||||
}
|
||||
@@ -28,9 +28,6 @@ default :
|
||||
|
||||
# 镜像文件生成
|
||||
|
||||
ipl10.bin : ipl10.nas Makefile
|
||||
$(NASK) ipl10.nas ipl10.bin ipl10.lst
|
||||
|
||||
ipl20.bin : ipl20.nas Makefile
|
||||
$(NASK) ipl20.nas ipl20.bin ipl20.lst
|
||||
|
||||
@@ -78,6 +75,5 @@ clean :
|
||||
|
||||
src_only :
|
||||
$(MAKE) clean
|
||||
-$(DEL) ipl10.bin
|
||||
-$(DEL) ipl20.bin
|
||||
-$(DEL) haribote.sys
|
||||
|
||||
@@ -489,6 +489,16 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
|
||||
sht = (struct SHEET *) (ebx & 0xfffffffe);
|
||||
hrb_api_linewin(sht, eax, ecx, esi, edi, ebp);
|
||||
if ((ebx & 1) == 0) {
|
||||
if (eax > esi) {
|
||||
i = eax;
|
||||
eax = esi;
|
||||
esi = i;
|
||||
}
|
||||
if (ecx > edi) {
|
||||
i = ecx;
|
||||
ecx = edi;
|
||||
edi = i;
|
||||
}
|
||||
sheet_refresh(sht, eax, ecx, esi + 1, edi + 1);
|
||||
}
|
||||
} else if (edx == 14) {
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
; haribote-ipl
|
||||
; TAB=4
|
||||
|
||||
CYLS EQU 10 ; 声明CYLS=10
|
||||
|
||||
ORG 0x7c00 ; 指明程序装载地址
|
||||
|
||||
; 标准FAT12格式软盘专用的代码 Stand FAT12 format floppy code
|
||||
|
||||
JMP entry
|
||||
DB 0x90
|
||||
DB "HARIBOTE" ; 启动扇区名称(8字节)
|
||||
DW 512 ; 每个扇区(sector)大小(必须512字节)
|
||||
DB 1 ; 簇(cluster)大小(必须为1个扇区)
|
||||
DW 1 ; FAT起始位置(一般为第一个扇区)
|
||||
DB 2 ; FAT个数(必须为2)
|
||||
DW 224 ; 根目录大小(一般为224项)
|
||||
DW 2880 ; 该磁盘大小(必须为2880扇区1440*1024/512)
|
||||
DB 0xf0 ; 磁盘类型(必须为0xf0)
|
||||
DW 9 ; FAT的长度(必??9扇区)
|
||||
DW 18 ; 一个磁道(track)有几个扇区(必须为18)
|
||||
DW 2 ; 磁头数(必??2)
|
||||
DD 0 ; 不使用分区,必须是0
|
||||
DD 2880 ; 重写一次磁盘大小
|
||||
DB 0,0,0x29 ; 意义不明(固定)
|
||||
DD 0xffffffff ; (可能是)卷标号码
|
||||
DB "HARIBOTEOS " ; 磁盘的名称(必须为11字?,不足填空格)
|
||||
DB "FAT12 " ; 磁盘格式名称(必??8字?,不足填空格)
|
||||
RESB 18 ; 先空出18字节
|
||||
|
||||
; 程序主体
|
||||
|
||||
entry:
|
||||
MOV AX,0 ; 初始化寄存器
|
||||
MOV SS,AX
|
||||
MOV SP,0x7c00
|
||||
MOV DS,AX
|
||||
|
||||
; 读取磁盘
|
||||
|
||||
MOV AX,0x0820
|
||||
MOV ES,AX
|
||||
MOV CH,0 ; 柱面0
|
||||
MOV DH,0 ; 磁头0
|
||||
MOV CL,2 ; 扇区2
|
||||
|
||||
readloop:
|
||||
MOV SI,0 ; 记录失败次数寄存器
|
||||
|
||||
retry:
|
||||
MOV AH,0x02 ; AH=0x02 : 读入磁盘
|
||||
MOV AL,1 ; 1个扇区
|
||||
MOV BX,0
|
||||
MOV DL,0x00 ; A驱动器
|
||||
INT 0x13 ; 调用磁盘BIOS
|
||||
JNC next ; 没出错则跳转到fin
|
||||
ADD SI,1 ; 往SI加1
|
||||
CMP SI,5 ; 比较SI与5
|
||||
JAE error ; SI >= 5 跳转到error
|
||||
MOV AH,0x00
|
||||
MOV DL,0x00 ; A驱动器
|
||||
INT 0x13 ; 重置驱动器
|
||||
JMP retry
|
||||
next:
|
||||
MOV AX,ES ; 把内存地址后移0x200(512/16十六进制转换)
|
||||
ADD AX,0x0020
|
||||
MOV ES,AX ; ADD ES,0x020因为没有ADD ES,只能通过AX进行
|
||||
ADD CL,1 ; 往CL里面加1
|
||||
CMP CL,18 ; 比较CL与18
|
||||
JBE readloop ; CL <= 18 跳转到readloop
|
||||
MOV CL,1
|
||||
ADD DH,1
|
||||
CMP DH,2
|
||||
JB readloop ; DH < 2 跳转到readloop
|
||||
MOV DH,0
|
||||
ADD CH,1
|
||||
CMP CH,CYLS
|
||||
JB readloop ; CH < CYLS 跳转到readloop
|
||||
|
||||
; 读取完毕,跳转到haribote.sys执行!
|
||||
MOV [0x0ff0],CH ; IPLがどこまで読んだのかをメモ
|
||||
JMP 0xc200
|
||||
|
||||
error:
|
||||
MOV SI,msg
|
||||
|
||||
putloop:
|
||||
MOV AL,[SI]
|
||||
ADD SI,1 ; 给SI加1
|
||||
CMP AL,0
|
||||
JE fin
|
||||
MOV AH,0x0e ; 显示一个文字
|
||||
MOV BX,15 ; 指定字符颜色
|
||||
INT 0x10 ; 调用显卡BIOS
|
||||
JMP putloop
|
||||
|
||||
fin:
|
||||
HLT ; 让CPU停止,等待指令
|
||||
JMP fin ; 无限循环
|
||||
|
||||
msg:
|
||||
DB 0x0a, 0x0a ; 换行两次
|
||||
DB "load error"
|
||||
DB 0x0a ; 换行
|
||||
DB 0
|
||||
|
||||
RESB 0x7dfe-$ ; 填写0x00直到0x001fe
|
||||
|
||||
DB 0x55, 0xaa
|
||||
@@ -1,7 +1,7 @@
|
||||
; haribote-ipl
|
||||
; TAB=4
|
||||
|
||||
CYLS EQU 10 ; どこまで読み込むか
|
||||
CYLS EQU 20 ; どこまで読み込むか
|
||||
|
||||
ORG 0x7c00 ; このプログラムがどこに読み込まれるのか
|
||||
|
||||
|
||||
@@ -4,5 +4,5 @@ MALLOC = 0k
|
||||
|
||||
include ../app_make.txt
|
||||
|
||||
$(APP).hrb : $(APP).org Makefile
|
||||
$(STDAPP).hrb : $(APP).org Makefile
|
||||
$(COPY) $(APP).org $(APP).hrb
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "apilib.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
api_putstr0("hello, world\n");
|
||||
api_end();
|
||||
printf("hello, world : %s %d\n", "aaa", 10);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
1
29_day/notrec/!cons_9x.bat
Normal file
1
29_day/notrec/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
||||
command
|
||||
1
29_day/notrec/!cons_nt.bat
Normal file
1
29_day/notrec/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
||||
cmd.exe
|
||||
5
29_day/notrec/Makefile
Normal file
5
29_day/notrec/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
APP = notrec
|
||||
STACK = 11k
|
||||
MALLOC = 0k
|
||||
|
||||
include ../app_make.txt
|
||||
1
29_day/notrec/make.bat
Normal file
1
29_day/notrec/make.bat
Normal file
@@ -0,0 +1 @@
|
||||
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
17
29_day/notrec/notrec.c
Normal file
17
29_day/notrec/notrec.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "apilib.h"
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
int win;
|
||||
char buf[150 * 70];
|
||||
win = api_openwin(buf, 150, 70, 255, "notrec");
|
||||
api_boxfilwin(win, 0, 50, 34, 69, 255);
|
||||
api_boxfilwin(win, 115, 50, 149, 69, 255);
|
||||
api_boxfilwin(win, 50, 30, 99, 49, 255);
|
||||
for (;;) {
|
||||
if (api_getkey(1) == 0x0a) {
|
||||
break; /*按下回车键则break; */
|
||||
}
|
||||
}
|
||||
api_end();
|
||||
}
|
||||
4
29_day/stdlib.h
Normal file
4
29_day/stdlib.h
Normal file
@@ -0,0 +1,4 @@
|
||||
int putchar(int c);
|
||||
void exit(int status);
|
||||
int printf(char *format, ...);
|
||||
void *malloc(int size);
|
||||
1
29_day/stdlib/!cons_9x.bat
Normal file
1
29_day/stdlib/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
||||
command
|
||||
1
29_day/stdlib/!cons_nt.bat
Normal file
1
29_day/stdlib/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
||||
cmd.exe
|
||||
50
29_day/stdlib/Makefile
Normal file
50
29_day/stdlib/Makefile
Normal file
@@ -0,0 +1,50 @@
|
||||
OBJS_API = stdlib.obj
|
||||
|
||||
TOOLPATH = ../../z_tools/
|
||||
INCPATH = ../../z_tools/haribote/
|
||||
|
||||
MAKE = $(TOOLPATH)make.exe -r
|
||||
NASK = $(TOOLPATH)nask.exe
|
||||
CC1 = $(TOOLPATH)cc1.exe -I$(INCPATH) -Os -Wall -quiet
|
||||
GAS2NASK = $(TOOLPATH)gas2nask.exe -a
|
||||
OBJ2BIM = $(TOOLPATH)obj2bim.exe
|
||||
MAKEFONT = $(TOOLPATH)makefont.exe
|
||||
BIN2OBJ = $(TOOLPATH)bin2obj.exe
|
||||
BIM2HRB = $(TOOLPATH)bim2hrb.exe
|
||||
RULEFILE = ../haribote.rul
|
||||
EDIMG = $(TOOLPATH)edimg.exe
|
||||
IMGTOL = $(TOOLPATH)imgtol.com
|
||||
GOLIB = $(TOOLPATH)golib00.exe
|
||||
COPY = copy
|
||||
DEL = del
|
||||
|
||||
#默认动作
|
||||
|
||||
default :
|
||||
$(MAKE) stdlib.lib
|
||||
|
||||
#库生成规则
|
||||
|
||||
stdlib.lib : Makefile $(OBJS_API)
|
||||
$(GOLIB) $(OBJS_API) out:stdlib.lib
|
||||
|
||||
#文件生成规则
|
||||
|
||||
%.gas : %.c ../stdlib.h Makefile
|
||||
$(CC1) -o $*.gas $*.c
|
||||
|
||||
%.nas : %.gas Makefile
|
||||
$(GAS2NASK) $*.gas $*.nas
|
||||
|
||||
%.obj : %.nas Makefile
|
||||
$(NASK) $*.nas $*.obj $*.lst
|
||||
|
||||
#命令
|
||||
|
||||
clean :
|
||||
-$(DEL) *.lst
|
||||
-$(DEL) *.obj
|
||||
|
||||
src_only :
|
||||
$(MAKE) clean
|
||||
-$(DEL) stdlib.lib
|
||||
1
29_day/stdlib/make.bat
Normal file
1
29_day/stdlib/make.bat
Normal file
@@ -0,0 +1 @@
|
||||
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
51
29_day/stdlib/stdlib.c
Normal file
51
29_day/stdlib/stdlib.c
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "../apilib.h"
|
||||
#include "../stdlib.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int putchar(int c)
|
||||
{
|
||||
api_putchar(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
void exit(int status)
|
||||
{
|
||||
api_end();
|
||||
}
|
||||
|
||||
int printf(char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char s[1000];
|
||||
int i;
|
||||
|
||||
va_start(ap, format);
|
||||
i = vsprintf(s, format, ap);
|
||||
api_putstr0(s);
|
||||
va_end(ap);
|
||||
return i;
|
||||
}
|
||||
|
||||
void *malloc(int size)
|
||||
{
|
||||
char *p = api_malloc(size + 16);
|
||||
if (p != 0) {
|
||||
*((int *) p) = size;
|
||||
p += 16;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void free(void *p)
|
||||
{
|
||||
char *q = p;
|
||||
int size;
|
||||
if (q != 0) {
|
||||
q -= 16;
|
||||
size = *((int *) q);
|
||||
api_free(q, size + 16);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#include "apilib.h"
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
int fh;
|
||||
char c;
|
||||
fh = api_fopen("ipl10.nas");
|
||||
if (fh != 0) {
|
||||
for (;;) {
|
||||
if (api_fread(&c, 1, fh) == 0) {
|
||||
break;
|
||||
}
|
||||
api_putchar(c);
|
||||
}
|
||||
}
|
||||
api_end();
|
||||
}
|
||||
Reference in New Issue
Block a user