mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-05 02:53:19 +08:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9aa36a0f96 | ||
|
|
9bb71ea5ce | ||
|
|
f8b2930281 | ||
|
|
c462063e0b | ||
|
|
dade193e1f | ||
|
|
670d454b4e | ||
|
|
6ee187a190 | ||
|
|
7d59920a37 | ||
|
|
b308a9e295 | ||
|
|
a28136d3de | ||
|
|
438eeb5135 | ||
|
|
d9d034cf43 | ||
|
|
c8be7ff36f | ||
|
|
140774a293 | ||
|
|
7c2fc66927 | ||
|
|
636c1a8c3d | ||
|
|
c177821913 | ||
|
|
febac10ebf | ||
|
|
0e31ff06ca | ||
|
|
08d19d7512 | ||
|
|
b2d31a8e54 | ||
|
|
72532c8cd7 | ||
|
|
3871740126 | ||
|
|
70b335278d | ||
|
|
2c262f986d | ||
|
|
6b0457bed6 | ||
|
|
0adab9385e | ||
|
|
73b7421cf2 | ||
|
|
203dd63152 | ||
|
|
9df2b90ad3 | ||
|
|
633089d320 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1 +1,5 @@
|
||||
*.hrb
|
||||
*.lst
|
||||
*.map
|
||||
*.bim
|
||||
*.hrb
|
||||
@@ -12,15 +12,15 @@
|
||||
DW 224 ; 根目录大小(一般为224项)
|
||||
DW 2880 ; 该磁盘大小(必须为2880扇区1440*1024/512)
|
||||
DB 0xf0 ; 磁盘类型(必须为0xf0)
|
||||
DW 9 ; FAT的长度(必??9扇区)
|
||||
DW 9 ; FAT的长度(必须是9扇区)
|
||||
DW 18 ; 一个磁道(track)有几个扇区(必须为18)
|
||||
DW 2 ; 磁头数(必??2)
|
||||
DW 2 ; 磁头数(必须是2)
|
||||
DD 0 ; 不使用分区,必须是0
|
||||
DD 2880 ; 重写一次磁盘大小
|
||||
DB 0,0,0x29 ; 意义不明(固定)
|
||||
DD 0xffffffff ; (可能是)卷标号码
|
||||
DB "HELLO-OS " ; 磁盘的名称(必须为11字?,不足填空格)
|
||||
DB "FAT12 " ; 磁盘格式名称(必??8字?,不足填空格)
|
||||
DB "HELLO-OS " ; 磁盘的名称(必须为11字节,不足填空格)
|
||||
DB "FAT12 " ; 磁盘格式名称(必须是8字节,不足填空格)
|
||||
RESB 18 ; 先空出18字节
|
||||
|
||||
; 程序主体
|
||||
@@ -47,4 +47,4 @@
|
||||
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
RESB 4600
|
||||
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
RESB 1469432
|
||||
RESB 1469432
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
; 标准FAT12格式软盘专用的代码 Stand FAT12 format floppy code
|
||||
|
||||
JMP entry
|
||||
DB 0xeb, 0x4e, 0x90
|
||||
DB 0x90
|
||||
DB "HELLOIPL" ; 启动扇区名称(8字节)
|
||||
DW 512 ; 每个扇区(sector)大小(必须512字节)
|
||||
DB 1 ; 簇(cluster)大小(必须为1个扇区)
|
||||
|
||||
@@ -53,7 +53,7 @@ retry:
|
||||
MOV BX,0
|
||||
MOV DL,0x00 ; A驱动器
|
||||
INT 0x13 ; 调用磁盘BIOS
|
||||
JNC next ; 没出错则跳转到fin
|
||||
JNC next ; 没出错则跳转到next
|
||||
ADD SI,1 ; 往SI加1
|
||||
CMP SI,5 ; 比较SI与5
|
||||
JAE error ; SI >= 5 跳转到error
|
||||
|
||||
@@ -15,7 +15,7 @@ VRAM EQU 0x0ff8 ; 图像缓冲区的起始地址
|
||||
|
||||
ORG 0xc200 ; 这个的程序要被装载的内存地址
|
||||
|
||||
; 画面モードを設定
|
||||
; 设置画面模式
|
||||
|
||||
MOV AL,0x13 ; VGA显卡,320x200x8bit
|
||||
MOV AH,0x00
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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 invader/invader.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,13 @@ 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:invader/invader.hrb to:@: \
|
||||
copy from:nihongo/nihongo.fnt to:@: \
|
||||
imgout:haribote.img
|
||||
|
||||
@@ -69,6 +71,7 @@ install :
|
||||
full :
|
||||
$(MAKE) -C haribote
|
||||
$(MAKE) -C apilib
|
||||
$(MAKE) -C stdlib
|
||||
$(MAKE) -C a
|
||||
$(MAKE) -C hello3
|
||||
$(MAKE) -C hello4
|
||||
@@ -88,10 +91,12 @@ 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) -C invader
|
||||
$(MAKE) haribote.img
|
||||
|
||||
run_full :
|
||||
@@ -116,57 +121,63 @@ 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 stdlib 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
|
||||
$(MAKE) -C invader 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 stdlib 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
|
||||
$(MAKE) -C invader src_only
|
||||
-$(DEL) haribote.img
|
||||
|
||||
refresh :
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,7 @@
|
||||
TOOLPATH = ../../z_tools/
|
||||
INCPATH = ../../z_tools/haribote/
|
||||
APILIBPATH = ../apilib/
|
||||
STDLIBPATH = ../stdlib/
|
||||
HARIBOTEPATH = ../haribote/
|
||||
|
||||
MAKE = $(TOOLPATH)make.exe -r
|
||||
@@ -11,6 +12,7 @@ OBJ2BIM = $(TOOLPATH)obj2bim.exe
|
||||
MAKEFONT = $(TOOLPATH)makefont.exe
|
||||
BIN2OBJ = $(TOOLPATH)bin2obj.exe
|
||||
BIM2HRB = $(TOOLPATH)bim2hrb.exe
|
||||
BIM2BIN = $(TOOLPATH)bim2bin.exe
|
||||
RULEFILE = ../haribote.rul
|
||||
EDIMG = $(TOOLPATH)edimg.exe
|
||||
IMGTOL = $(TOOLPATH)imgtol.com
|
||||
@@ -25,24 +27,26 @@ 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
|
||||
|
||||
$(APP).hrb : $(APP).bim Makefile ../app_make.txt
|
||||
$(BIM2HRB) $(APP).bim $(APP).hrb $(MALLOC)
|
||||
$(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/ipl10.bin ../haribote/haribote.sys $(APP).hrb \
|
||||
haribote.img : ../haribote/ipl20.bin ../haribote/haribote.sys $(APP).hrb \
|
||||
Makefile ../app_make.txt
|
||||
$(EDIMG) imgin:../../z_tools/fdimg0at.tek \
|
||||
wbinimg src:../haribote/ipl10.bin len:512 from:0 to:0 \
|
||||
wbinimg src:../haribote/ipl20.bin len:512 from:0 to:0 \
|
||||
copy from:../haribote/haribote.sys to:@: \
|
||||
copy from:$(APP).hrb to:@: \
|
||||
copy from:../nihongo/nihongo.fnt to:@: \
|
||||
imgout:haribote.img
|
||||
|
||||
#一般规则
|
||||
|
||||
%.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
|
||||
@@ -51,6 +55,12 @@ haribote.img : ../haribote/ipl10.bin ../haribote/haribote.sys $(APP).hrb \
|
||||
%.obj : %.nas Makefile ../app_make.txt
|
||||
$(NASK) $*.nas $*.obj $*.lst
|
||||
|
||||
%.org : %.bim Makefile ../app_make.txt
|
||||
$(BIM2HRB) $*.bim $*.org $(MALLOC)
|
||||
|
||||
%.hrb : %.org Makefile ../app_make.txt
|
||||
$(BIM2BIN) -osacmp in:$*.org out:$*.hrb
|
||||
|
||||
#命令
|
||||
|
||||
run :
|
||||
@@ -60,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
|
||||
|
||||
@@ -72,6 +84,7 @@ clean :
|
||||
-$(DEL) *.obj
|
||||
-$(DEL) *.map
|
||||
-$(DEL) *.bim
|
||||
-$(DEL) *.org
|
||||
-$(DEL) haribote.img
|
||||
|
||||
src_only :
|
||||
|
||||
5
29_day/bball/Makefile
Normal file
5
29_day/bball/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
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();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
OBJS_BOOTPACK = bootpack.obj naskfunc.obj hankaku.obj graphic.obj dsctbl.obj \
|
||||
int.obj fifo.obj keyboard.obj mouse.obj memory.obj sheet.obj timer.obj \
|
||||
mtask.obj window.obj console.obj file.obj
|
||||
mtask.obj window.obj console.obj file.obj tek.obj
|
||||
|
||||
TOOLPATH = ../../z_tools/
|
||||
INCPATH = ../../z_tools/haribote/
|
||||
@@ -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
|
||||
|
||||
@@ -106,15 +106,17 @@ void HariMain(void)
|
||||
fifo32_put(&keycmd, key_leds);
|
||||
|
||||
/* 载入nihongo.fnt */
|
||||
nihongo = (unsigned char *) memman_alloc_4k(memman, 16 * 256 + 32 * 94 * 47);
|
||||
fat = (int *) memman_alloc_4k(memman, 4 * 2880);
|
||||
file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200));
|
||||
|
||||
finfo = file_search("nihongo.fnt", (struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224);
|
||||
if (finfo != 0) {
|
||||
file_loadfile(finfo->clustno, finfo->size, nihongo, fat, (char *) (ADR_DISKIMG + 0x003e00));
|
||||
i = finfo->size;
|
||||
nihongo = file_loadfile2(finfo->clustno, &i, fat);
|
||||
} else {
|
||||
nihongo = (unsigned char *) memman_alloc_4k(memman, 16 * 256 + 32 * 94 * 47);
|
||||
for (i = 0; i < 16 * 256; i++) {
|
||||
nihongo[i] = hankaku[i]; /* 没有字库,半角部分直接复制英文字库 */
|
||||
nihongo[i] = hankaku[i]; /*没有字库,半角部分直接复制英文字库*/
|
||||
}
|
||||
for (i = 16 * 256; i < 16 * 256 + 32 * 94 * 47; i++) {
|
||||
nihongo[i] = 0xff; /* 没有字库,全角部分以0xff填充 */
|
||||
|
||||
@@ -286,7 +286,12 @@ struct FILEINFO {
|
||||
void file_readfat(int *fat, unsigned char *img);
|
||||
void file_loadfile(int clustno, int size, char *buf, int *fat, char *img);
|
||||
struct FILEINFO *file_search(char *name, struct FILEINFO *finfo, int max);
|
||||
char *file_loadfile2(int clustno, int *psize, int *fat);
|
||||
|
||||
/* bootpack.c */
|
||||
struct TASK *open_constask(struct SHEET *sht, unsigned int memtotal);
|
||||
struct SHEET *open_console(struct SHTCTL *shtctl, unsigned int memtotal);
|
||||
|
||||
/* tek.c */
|
||||
int tek_getsize(unsigned char *p);
|
||||
int tek_decomp(unsigned char *p, char *q, int size);
|
||||
|
||||
@@ -350,7 +350,7 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
|
||||
struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT;
|
||||
char name[18], *p, *q;
|
||||
struct TASK *task = task_now();
|
||||
int i, segsiz, datsiz, esp, dathrb;
|
||||
int i, segsiz, datsiz, esp, dathrb, appsiz;
|
||||
struct SHTCTL *shtctl;
|
||||
struct SHEET *sht;
|
||||
|
||||
@@ -376,10 +376,10 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
|
||||
}
|
||||
|
||||
if (finfo != 0) {
|
||||
/*找到文件的情况*/
|
||||
p = (char *) memman_alloc_4k(memman, finfo->size);
|
||||
file_loadfile(finfo->clustno, finfo->size, p, fat, (char *) (ADR_DISKIMG + 0x003e00));
|
||||
if (finfo->size >= 36 && strncmp(p + 4, "Hari", 4) == 0 && *p == 0x00) {
|
||||
/*如果找到文件*/
|
||||
appsiz = finfo->size;
|
||||
p = file_loadfile2(finfo->clustno, &appsiz, fat);
|
||||
if (appsiz >= 36 && strncmp(p + 4, "Hari", 4) == 0 && *p == 0x00) {
|
||||
segsiz = *((int *) (p + 0x0000));
|
||||
esp = *((int *) (p + 0x000c));
|
||||
datsiz = *((int *) (p + 0x0010));
|
||||
@@ -412,7 +412,7 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
|
||||
} else {
|
||||
cons_putstr0(cons, ".hrb file format error.\n");
|
||||
}
|
||||
memman_free_4k(memman, (int) p, finfo->size);
|
||||
memman_free_4k(memman, (int) p, appsiz);
|
||||
cons_newline(cons);
|
||||
return 1;
|
||||
}
|
||||
@@ -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) {
|
||||
@@ -566,7 +576,7 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
|
||||
fh->buf = (char *) memman_alloc_4k(memman, finfo->size);
|
||||
fh->size = finfo->size;
|
||||
fh->pos = 0;
|
||||
file_loadfile(finfo->clustno, finfo->size, fh->buf, task->fat, (char *) (ADR_DISKIMG + 0x003e00));
|
||||
file_loadfile2(finfo->clustno, &fh->size, task->fat);
|
||||
}
|
||||
}
|
||||
} else if (edx == 22) {
|
||||
|
||||
@@ -72,3 +72,23 @@ next:
|
||||
}
|
||||
return 0; /*没有找到*/
|
||||
}
|
||||
|
||||
char *file_loadfile2(int clustno, int *psize, int *fat)
|
||||
{
|
||||
int size = *psize, size2;
|
||||
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
||||
char *buf, *buf2;
|
||||
buf = (char *) memman_alloc_4k(memman, size);
|
||||
file_loadfile(clustno, size, buf, fat, (char *) (ADR_DISKIMG + 0x003e00));
|
||||
if (size >= 17) {
|
||||
size2 = tek_getsize(buf);
|
||||
if (size2 > 0) { /*使用tek格式压缩的文件*/
|
||||
buf2 = (char *) memman_alloc_4k(memman, size2);
|
||||
tek_decomp(buf, buf2, size2);
|
||||
memman_free_4k(memman, (int) buf, size);
|
||||
buf = buf2;
|
||||
*psize = size2;
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
; haribote-ipl
|
||||
; TAB=4
|
||||
|
||||
CYLS EQU 10 ; どこまで読み込むか
|
||||
CYLS EQU 20 ; どこまで読み込むか
|
||||
|
||||
ORG 0x7c00 ; このプログラムがどこに読み込まれるのか
|
||||
|
||||
|
||||
646
29_day/haribote/tek.c
Normal file
646
29_day/haribote/tek.c
Normal file
@@ -0,0 +1,646 @@
|
||||
#include "bootpack.h"
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#define NULL 0
|
||||
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned int UINT32;
|
||||
typedef UINT32 tek_TPRB;
|
||||
|
||||
static int tek_decode1(int siz, UCHAR *p, UCHAR *q);
|
||||
static int tek_decode2(int siz, UCHAR *p, UCHAR *q);
|
||||
static int tek_decode5(int siz, UCHAR *p, UCHAR *q);
|
||||
|
||||
static unsigned int tek_getnum_s7s(UCHAR **pp)
|
||||
{
|
||||
unsigned int s = 0;
|
||||
UCHAR *p = *pp;
|
||||
do {
|
||||
s = s << 7 | *p++;
|
||||
} while ((s & 1) == 0);
|
||||
s >>= 1;
|
||||
*pp = p;
|
||||
return s;
|
||||
}
|
||||
|
||||
int tek_getsize(unsigned char *p)
|
||||
{
|
||||
static char header[15] = {
|
||||
0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x4f, 0x53, 0x41, 0x53, 0x4b, 0x43, 0x4d, 0x50
|
||||
};
|
||||
int size = -1;
|
||||
if (memcmp(p + 1, header, 15) == 0 && (*p == 0x83 || *p == 0x85 || *p == 0x89)) {
|
||||
p += 16;
|
||||
size = tek_getnum_s7s(&p);
|
||||
}
|
||||
return size;
|
||||
} /* (注)memcmp和strncmp差不多,这个函数忽略字符串中的0并一直比较到指定的15个字符为止*/
|
||||
|
||||
int tek_decomp(unsigned char *p, char *q, int size)
|
||||
{
|
||||
int err = -1;
|
||||
if (*p == 0x83) {
|
||||
err = tek_decode1(size, p, q);
|
||||
} else if (*p == 0x85) {
|
||||
err = tek_decode2(size, p, q);
|
||||
} else if (*p == 0x89) {
|
||||
err = tek_decode5(size, p, q);
|
||||
}
|
||||
if (err != 0) {
|
||||
return -1; /*失败*/
|
||||
}
|
||||
return 0; /*成功*/
|
||||
}
|
||||
|
||||
static int tek_lzrestore_stk1(int srcsiz, UCHAR *src, int outsiz, UCHAR *q)
|
||||
{
|
||||
int by, lz, cp, ds;
|
||||
UCHAR *q1 = q + outsiz, *s7ptr = src, *q0 = q;
|
||||
do {
|
||||
if ((by = (lz = *s7ptr++) & 0x0f) == 0)
|
||||
by = tek_getnum_s7s(&s7ptr);
|
||||
if ((lz >>= 4) == 0)
|
||||
lz = tek_getnum_s7s(&s7ptr);
|
||||
do {
|
||||
*q++ = *s7ptr++;
|
||||
} while (--by);
|
||||
if (q >= q1)
|
||||
break;
|
||||
do {
|
||||
ds = (cp = *s7ptr++) & 0x0f;
|
||||
if ((ds & 1) == 0) {
|
||||
do {
|
||||
ds = ds << 7 | *s7ptr++;
|
||||
} while ((ds & 1) == 0);
|
||||
}
|
||||
ds = ~(ds >> 1);
|
||||
if ((cp >>= 4) == 0) {
|
||||
do {
|
||||
cp = cp << 7 | *s7ptr++;
|
||||
} while ((cp & 1) == 0);
|
||||
cp >>= 1;
|
||||
}
|
||||
cp++;
|
||||
if (q + ds < q0)
|
||||
goto err;
|
||||
if (q + cp > q1)
|
||||
cp = q1 - q;
|
||||
do {
|
||||
*q = *(q + ds);
|
||||
q++;
|
||||
} while (--cp);
|
||||
} while (--lz);
|
||||
} while (q < q1);
|
||||
return 0;
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tek_decode1(int siz, UCHAR *p, UCHAR *q)
|
||||
{
|
||||
int dsiz, hed, bsiz;
|
||||
UCHAR *p1 = p + siz;
|
||||
p += 16;
|
||||
if ((dsiz = tek_getnum_s7s(&p)) > 0) {
|
||||
hed = tek_getnum_s7s(&p);
|
||||
bsiz = 1 << (((hed >> 1) & 0x0f) + 8);
|
||||
if (dsiz > bsiz || (hed & 0x21) != 0x01)
|
||||
return 1;
|
||||
if (hed & 0x40)
|
||||
tek_getnum_s7s(&p);
|
||||
if (tek_getnum_s7s(&p) != 0)
|
||||
return 1;
|
||||
return tek_lzrestore_stk1(p1 - p, p, dsiz, q);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int tek_getnum_s7(UCHAR **pp)
|
||||
{
|
||||
unsigned int s = 0, b = 0, a = 1;
|
||||
UCHAR *p = *pp;
|
||||
for (;;) {
|
||||
s = s << 7 | *p++;
|
||||
if (s & 1)
|
||||
break;
|
||||
a <<= 7;
|
||||
b += a;
|
||||
}
|
||||
s >>= 1;
|
||||
*pp = p;
|
||||
return s + b;
|
||||
}
|
||||
|
||||
static int tek_lzrestore_stk2(int srcsiz, UCHAR *src, int outsiz, UCHAR *q)
|
||||
{
|
||||
int cp, ds, repdis[4], i, j;
|
||||
UCHAR *q1 = q + outsiz, *s7ptr = src, *q0 = q, bylz, cbylz;
|
||||
for (j = 0; j < 4; j++)
|
||||
repdis[j] = -1 - j;
|
||||
bylz = cbylz = 0;
|
||||
if (outsiz) {
|
||||
if (tek_getnum_s7s(&s7ptr))
|
||||
return 1;
|
||||
do {
|
||||
j = 0;
|
||||
do {
|
||||
j++;
|
||||
if (j >= 17) {
|
||||
j += tek_getnum_s7s(&s7ptr);
|
||||
break;
|
||||
}
|
||||
if (cbylz == 0) {
|
||||
cbylz = 8;
|
||||
bylz = *s7ptr++;
|
||||
}
|
||||
cbylz--;
|
||||
i = bylz & 1;
|
||||
bylz >>= 1;
|
||||
} while (i == 0);
|
||||
do {
|
||||
*q++ = *s7ptr++;
|
||||
} while (--j);
|
||||
if (q >= q1)
|
||||
break;
|
||||
|
||||
j = 0;
|
||||
do {
|
||||
j++;
|
||||
if (j >= 17) {
|
||||
j += tek_getnum_s7s(&s7ptr);
|
||||
break;
|
||||
}
|
||||
if (cbylz == 0) {
|
||||
cbylz = 8;
|
||||
bylz = *s7ptr++;
|
||||
}
|
||||
cbylz--;
|
||||
i = bylz & 1;
|
||||
bylz >>= 1;
|
||||
} while (i == 0);
|
||||
do {
|
||||
i = *s7ptr++;
|
||||
cp = i >> 4;
|
||||
i &= 0x0f;
|
||||
if ((i & 1) == 0)
|
||||
i |= (tek_getnum_s7(&s7ptr) + 1) << 4;
|
||||
i >>= 1;
|
||||
ds = ~(i - 6);
|
||||
if (i < 4)
|
||||
ds = repdis[i];
|
||||
if (i == 4)
|
||||
ds = repdis[0] - tek_getnum_s7(&s7ptr) - 1;
|
||||
if (i == 5)
|
||||
ds = repdis[0] + tek_getnum_s7(&s7ptr) + 1;
|
||||
if (cp == 0)
|
||||
cp = tek_getnum_s7(&s7ptr) + 16;
|
||||
cp++;
|
||||
if (i > 0) {
|
||||
if (i > 1) {
|
||||
if (i > 2)
|
||||
repdis[3] = repdis[2];
|
||||
repdis[2] = repdis[1];
|
||||
}
|
||||
repdis[1] = repdis[0];
|
||||
repdis[0] = ds;
|
||||
}
|
||||
if (q + ds < q0)
|
||||
goto err;
|
||||
if (q + cp > q1)
|
||||
cp = q1 - q;
|
||||
do {
|
||||
*q = *(q + ds);
|
||||
q++;
|
||||
} while (--cp);
|
||||
} while (--j);
|
||||
} while (q < q1);
|
||||
}
|
||||
return 0;
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tek_decode2(int siz, UCHAR *p, UCHAR *q)
|
||||
{
|
||||
UCHAR *p1 = p + siz;
|
||||
int dsiz, hed, bsiz, st = 0;
|
||||
p += 16;
|
||||
if ((dsiz = tek_getnum_s7s(&p)) > 0) {
|
||||
hed = tek_getnum_s7s(&p);
|
||||
bsiz = 1 << (((hed >> 1) & 0x0f) + 8);
|
||||
if (dsiz > bsiz || (hed & 0x21) != 0x01)
|
||||
return 1;
|
||||
if (hed & 0x40)
|
||||
tek_getnum_s7s(&p);
|
||||
st = tek_lzrestore_stk2(p1 - p, p, dsiz, q);
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
static int tek_decmain5(int *work, UCHAR *src, int osiz, UCHAR *q, int lc, int pb, int lp, int flags);
|
||||
|
||||
static int tek_lzrestore_tek5(int srcsiz, UCHAR *src, int outsiz, UCHAR *outbuf)
|
||||
{
|
||||
int wrksiz, lc, lp, pb, flags, *work, prop0, fl;
|
||||
|
||||
if ((fl = (prop0 = *src) & 0x0f) == 0x01) /* 0001 */
|
||||
flags |= -1;
|
||||
else if (fl == 0x05)
|
||||
flags = -2;
|
||||
else if (fl == 0x09)
|
||||
flags &= 0;
|
||||
else
|
||||
return 1;
|
||||
src++;
|
||||
prop0 >>= 4;
|
||||
if (prop0 == 0)
|
||||
prop0 = *src++;
|
||||
else {
|
||||
static UCHAR prop0_table[] = { 0x5d, 0x00 }, prop1_table[] = { 0x00 };
|
||||
if (flags == -1) {
|
||||
if (prop0 >= 3)
|
||||
return 1;
|
||||
prop0 = prop0_table[prop0 - 1];
|
||||
} else {
|
||||
if (prop0 >= 2)
|
||||
return 1;
|
||||
prop0 = prop1_table[prop0 - 1];
|
||||
}
|
||||
}
|
||||
lp = prop0 / (9 * 5);
|
||||
prop0 %= 9 * 5;
|
||||
pb = prop0 / 9;
|
||||
lc = prop0 % 9;
|
||||
if (flags == 0) /* tek5:z2 */
|
||||
flags = *src++;
|
||||
if (flags == -1) { /* stk5 */
|
||||
wrksiz = lp;
|
||||
lp = pb;
|
||||
pb = wrksiz;
|
||||
}
|
||||
wrksiz = 0x180 * sizeof (UINT32) + (0x840 + (0x300 << (lc + lp))) * sizeof (tek_TPRB); /* Å’á15KB, lc+lp=3‚È‚çA36KB */
|
||||
work = (int *) memman_alloc_4k((struct MEMMAN *) MEMMAN_ADDR, wrksiz);
|
||||
if (work == NULL)
|
||||
return -1;
|
||||
flags = tek_decmain5(work, src, outsiz, outbuf, lc, pb, lp, flags);
|
||||
memman_free_4k((struct MEMMAN *) MEMMAN_ADDR, (int) work, wrksiz);
|
||||
return flags;
|
||||
}
|
||||
|
||||
struct tek_STR_BITMODEL {
|
||||
UCHAR t, m, s, dmy;
|
||||
UINT32 prb0, prb1, tmsk, ntm, lt, lt0, dmy4;
|
||||
};
|
||||
|
||||
struct tek_STR_PRB {
|
||||
struct tek_STR_PRB_PB {
|
||||
struct tek_STR_PRB_PBST {
|
||||
tek_TPRB mch, rep0l1;
|
||||
} st[12];
|
||||
tek_TPRB lenlow[2][8], lenmid[2][8];
|
||||
} pb[16];
|
||||
struct tek_STR_PRB_ST {
|
||||
tek_TPRB rep, repg0, repg1, repg2;
|
||||
} st[12];
|
||||
tek_TPRB lensel[2][2], lenhigh[2][256], pslot[4][64], algn[64];
|
||||
tek_TPRB spdis[2][2+4+8+16+32], lenext[2+4+8+16+32];
|
||||
tek_TPRB repg3, fchgprm[2 * 32], tbmt[16], tbmm[16], fchglt;
|
||||
tek_TPRB lit[1];
|
||||
};
|
||||
|
||||
struct tek_STR_RNGDEC {
|
||||
UCHAR *p;
|
||||
UINT32 range, code, rmsk;
|
||||
jmp_buf errjmp;
|
||||
struct tek_STR_BITMODEL bm[32], *ptbm[16];
|
||||
struct tek_STR_PRB probs;
|
||||
};
|
||||
|
||||
static void tek_setbm5(struct tek_STR_BITMODEL *bm, int t, int m)
|
||||
{
|
||||
bm->t = t;
|
||||
bm->m = m;
|
||||
bm->prb1 = -1 << (m + t);
|
||||
bm->prb0 = ~bm->prb1;
|
||||
bm->prb1 |= 1 << t;
|
||||
bm->tmsk = (-1 << t) & 0xffff;
|
||||
bm->prb0 &= bm->tmsk;
|
||||
bm->prb1 &= bm->tmsk;
|
||||
bm->ntm = ~bm->tmsk;
|
||||
return;
|
||||
}
|
||||
|
||||
static int tek_rdget0(struct tek_STR_RNGDEC *rd, int n, int i)
|
||||
{
|
||||
do {
|
||||
while (rd->range < (UINT32) (1 << 24)) {
|
||||
rd->range <<= 8;
|
||||
rd->code = rd->code << 8 | *rd->p++;
|
||||
}
|
||||
rd->range >>= 1;
|
||||
i += i;
|
||||
if (rd->code >= rd->range) {
|
||||
rd->code -= rd->range;
|
||||
i |= 1;
|
||||
}
|
||||
} while (--n);
|
||||
return ~i;
|
||||
}
|
||||
|
||||
static int tek_rdget1(struct tek_STR_RNGDEC *rd, tek_TPRB *prob0, int n, int j, struct tek_STR_BITMODEL *bm)
|
||||
{
|
||||
UINT32 p, i, *prob, nm = n >> 4;
|
||||
n &= 0x0f;
|
||||
prob0 -= j;
|
||||
do {
|
||||
p = *(prob = prob0 + j);
|
||||
if (bm->lt > 0) {
|
||||
if (--bm->lt == 0) {
|
||||
if (tek_rdget1(rd, &rd->probs.fchglt, 0x71, 0, &rd->bm[3]) == 0) {
|
||||
err:
|
||||
longjmp(rd->errjmp, 1);
|
||||
}
|
||||
i = bm - rd->bm;
|
||||
if ((bm->s = tek_rdget1(rd, &rd->probs.fchgprm[i * 2 + bm->s], 0x71, 0, &rd->bm[1])) == 0) {
|
||||
i = tek_rdget1(rd, rd->probs.tbmt, 0x74, 1, &rd->bm[2]) & 15;
|
||||
if (i == 15)
|
||||
goto err;
|
||||
tek_setbm5(bm, i, ((tek_rdget1(rd, rd->probs.tbmm, 0x74, 1, &rd->bm[2]) - 1) & 15) + 1);
|
||||
}
|
||||
bm->lt = bm->lt0;
|
||||
}
|
||||
if (p < bm->prb0) {
|
||||
p = bm->prb0;
|
||||
goto fixprob;
|
||||
}
|
||||
if (p > bm->prb1) {
|
||||
p = bm->prb1;
|
||||
goto fixprob;
|
||||
}
|
||||
if (p & bm->ntm) {
|
||||
p &= bm->tmsk;
|
||||
fixprob:
|
||||
*prob = p;
|
||||
}
|
||||
}
|
||||
|
||||
while (rd->range < (UINT32) (1 << 24)) {
|
||||
rd->range <<= 8;
|
||||
rd->code = rd->code << 8 | *rd->p++;
|
||||
}
|
||||
j += j;
|
||||
i = ((unsigned long long) (rd->range & rd->rmsk) * p) >> 16;
|
||||
if (rd->code < i) {
|
||||
j |= 1;
|
||||
rd->range = i;
|
||||
*prob += ((0x10000 - p) >> bm->m) & bm->tmsk;
|
||||
} else {
|
||||
rd->range -= i;
|
||||
rd->code -= i;
|
||||
*prob -= (p >> bm->m) & bm->tmsk;
|
||||
}
|
||||
--n;
|
||||
if ((n & nm) == 0)
|
||||
bm++;
|
||||
} while (n);
|
||||
return j;
|
||||
}
|
||||
|
||||
static UINT32 tek_revbit(UINT32 data, int len)
|
||||
{
|
||||
UINT32 rev = 0;
|
||||
do {
|
||||
rev += rev + (data & 1);
|
||||
data >>= 1;
|
||||
} while (--len);
|
||||
return rev;
|
||||
}
|
||||
|
||||
static int tek_getlen5(struct tek_STR_RNGDEC *rd, int m, int s_pos, int stk)
|
||||
{
|
||||
int i;
|
||||
if (tek_rdget1(rd, &rd->probs.lensel[m][0], 0x71, 0, rd->ptbm[3]) ^ stk) /* low */
|
||||
i = tek_rdget1(rd, rd->probs.pb[s_pos].lenlow[m], 0x73, 1, rd->ptbm[4]) & 7;
|
||||
else if (tek_rdget1(rd, &rd->probs.lensel[m][1], 0x71, 0, rd->ptbm[3]) ^ stk) /* mid */
|
||||
i = tek_rdget1(rd, rd->probs.pb[s_pos].lenmid[m], 0x73, 1, rd->ptbm[5]);
|
||||
else {
|
||||
/* high */
|
||||
i = tek_rdget1(rd, rd->probs.lenhigh[m], 0x78, 1, rd->ptbm[6]) - (256 + 256 - 8);
|
||||
if (i > 0) {
|
||||
if (i < 6 && stk == 0)
|
||||
i = tek_rdget1(rd, &rd->probs.lenext[(1 << i) - 2], i | 0x70, 1, rd->ptbm[7]) - 1;
|
||||
else
|
||||
i = tek_rdget0(rd, i, ~1) - 1;
|
||||
i = tek_rdget0(rd, i, ~1) - 1;
|
||||
}
|
||||
i += 256 - 8 + 16;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static int tek_decmain5(int *work, UCHAR *src, int osiz, UCHAR *q, int lc, int pb, int lp, int flags)
|
||||
{
|
||||
static int state_table[] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
|
||||
int i, j, k, pmch, rep[4], s, pos, m_pos = (1 << pb) - 1, m_lp = (1 << lp) - 1;
|
||||
int stk = (flags == -1), lcr = 8 - lc, s_pos, lit0cntmsk = 0x78;
|
||||
UINT32 *lit1;
|
||||
struct tek_STR_RNGDEC *rd = (struct tek_STR_RNGDEC *) work;
|
||||
struct tek_STR_PRB *prb = &rd->probs;
|
||||
|
||||
rd->p = &src[4];
|
||||
rd->range |= -1;
|
||||
rd->code = src[0] << 24 | src[1] << 16 | src[2] << 8 | src[3];
|
||||
for (i = 0; i < 4; i++)
|
||||
rep[i] = ~i;
|
||||
if (setjmp(rd->errjmp))
|
||||
goto err;
|
||||
for (i = sizeof (struct tek_STR_PRB) / sizeof (tek_TPRB) + (0x300 << (lc + lp)) - 2; i >= 0; i--)
|
||||
((tek_TPRB *) prb)[i] = 1 << 15;
|
||||
for (i = 0; i < 32; i++) {
|
||||
rd->bm[i].lt = (i >= 4);
|
||||
rd->bm[i].lt0 = (i < 24) ? 16 * 1024 : 8 * 1024;
|
||||
rd->bm[i].s &= 0;
|
||||
rd->bm[i].t = rd->bm[i].m = 5;
|
||||
}
|
||||
lit1 = prb->lit + ((256 << (lc + lp)) - 2);
|
||||
if (stk) {
|
||||
rd->rmsk = -1 << 11;
|
||||
for (i = 0; i < 32; i++)
|
||||
rd->bm[i].lt = 0;
|
||||
for (i = 0; i < 14; i++)
|
||||
rd->ptbm[i] = &rd->bm[0];
|
||||
} else {
|
||||
UCHAR pt[14];
|
||||
static UCHAR pt1[14] = {
|
||||
8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 18, 18, 18, 8
|
||||
};
|
||||
static UCHAR pt2[14] = {
|
||||
8, 8, 10, 11, 12, 12, 14, 15,
|
||||
16, 16, 18, 18, 20, 21
|
||||
};
|
||||
/*
|
||||
0- 7:mch, mch, lit1, lensel, lenlow, lenmid, lenhigh, lenext
|
||||
8-15:pslot, pslot, sdis, sdis, align, rep-repg2
|
||||
*/
|
||||
rd->rmsk |= -1;
|
||||
rd->bm[1].t = 5; rd->bm[1].m = 3; /* for fchgprm */
|
||||
rd->bm[2].t = 9; rd->bm[2].m = 2; /* for tbmt, tbmm */
|
||||
if (flags & 0x40) { /* lt-flag */
|
||||
rd->bm[3].t = 0; rd->bm[3].m = 1;
|
||||
prb->fchglt = 0xffff;
|
||||
}
|
||||
rd->bm[22].t = 0; rd->bm[22].m = 1;
|
||||
prb->repg3 = 0xffff;
|
||||
if (flags == -2) { /* z1 */
|
||||
rd->bm[22].lt = 0;
|
||||
for (i = 0; i < 14; i++)
|
||||
pt[i] = pt1[i];
|
||||
} else {
|
||||
for (i = 0; i < 14; i++)
|
||||
pt[i] = pt2[i];
|
||||
lit0cntmsk = (7 >> (flags & 3)) << 4 | 8;
|
||||
pt[ 1] = 8 + ((flags & 0x04) != 0); /* mch */
|
||||
pt[ 5] = 12 + ((flags & 0x08) != 0); /* llm */
|
||||
pt[ 9] = 16 + ((flags & 0x10) != 0); /* pst */
|
||||
pt[11] = 18 + ((flags & 0x20) != 0); /* sds */
|
||||
}
|
||||
for (i = 0; i < 14; i++)
|
||||
rd->ptbm[i] = &rd->bm[pt[i]];
|
||||
}
|
||||
for (i = 0; i < 32; i++)
|
||||
tek_setbm5(&rd->bm[i], rd->bm[i].t, rd->bm[i].m);
|
||||
|
||||
if ((tek_rdget1(rd, &prb->pb[0].st[0].mch, 0x71, 0, rd->ptbm[0]) ^ stk) == 0)
|
||||
goto err;
|
||||
*q++ = tek_rdget1(rd, prb->lit, lit0cntmsk, 1, &rd->bm[24]) & 0xff;
|
||||
pmch &= 0; s &= 0; pos = 1;
|
||||
while (pos < osiz) {
|
||||
s_pos = pos & m_pos;
|
||||
if (tek_rdget1(rd, &prb->pb[s_pos].st[s].mch, 0x71, 0, rd->ptbm[s > 0]) ^ stk) {
|
||||
i = (q[-1] >> lcr | (pos & m_lp) << lc) << 8;
|
||||
s = state_table[s];
|
||||
if (pmch == 0)
|
||||
*q = tek_rdget1(rd, &prb->lit[i], lit0cntmsk, 1, &rd->bm[24]) & 0xff;
|
||||
else {
|
||||
struct tek_STR_BITMODEL *bm = &rd->bm[24];
|
||||
j = 1;
|
||||
k = 8;
|
||||
pmch = q[rep[0]];
|
||||
do {
|
||||
j += j + tek_rdget1(rd, &lit1[(i + j) << 1 | pmch >> 7], 0x71, 0, rd->ptbm[2]);
|
||||
k--;
|
||||
if ((k & (lit0cntmsk >> 4)) == 0)
|
||||
bm++;
|
||||
if ((((pmch >> 7) ^ j) & 1) != 0 && k != 0) {
|
||||
j = tek_rdget1(rd, &prb->lit[i + j - 1], k | (lit0cntmsk & 0x70), j, bm);
|
||||
break;
|
||||
}
|
||||
pmch <<= 1;
|
||||
} while (k);
|
||||
*q = j & 0xff;
|
||||
pmch &= 0;
|
||||
}
|
||||
pos++;
|
||||
q++;
|
||||
} else { /* lz */
|
||||
pmch |= 1;
|
||||
if (tek_rdget1(rd, &prb->st[s].rep, 0x71, 0, rd->ptbm[13]) ^ stk) { /* len/dis */
|
||||
rep[3] = rep[2];
|
||||
rep[2] = rep[1];
|
||||
rep[1] = rep[0];
|
||||
j = i = tek_getlen5(rd, 0, s_pos, stk);
|
||||
s = s < 7 ? 7 : 10;
|
||||
if (j >= 4)
|
||||
j = 3;
|
||||
rep[0] = j = tek_rdget1(rd, prb->pslot[j], 0x76, 1, rd->ptbm[8 + (j == 3)]) & 0x3f;
|
||||
if (j >= 4) {
|
||||
k = (j >> 1) - 1; /* k = [1, 30] */
|
||||
rep[0] = (2 | (j & 1)) << k;
|
||||
if (j < 14) /* k < 6 */
|
||||
rep[0] |= tek_revbit(tek_rdget1(rd, &prb->spdis[j & 1][(1 << k) - 2], k | 0x70, 1, rd->ptbm[10 + (k >= 4)]), k);
|
||||
else {
|
||||
if (stk == 0) {
|
||||
if (k -= 6)
|
||||
rep[0] |= tek_rdget0(rd, k, ~0) << 6;
|
||||
rep[0] |= tek_revbit(tek_rdget1(rd, prb->algn, 0x76, 1, rd->ptbm[12]), 6);
|
||||
} else {
|
||||
rep[0] |= tek_rdget0(rd, k - 4, ~0) << 4;
|
||||
rep[0] |= tek_revbit(tek_rdget1(rd, prb->algn, 0x74, 1, rd->ptbm[12]), 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
rep[0] = ~rep[0];
|
||||
} else { /* repeat-dis */
|
||||
if (tek_rdget1(rd, &prb->st[s].repg0, 0x71, 0, rd->ptbm[13]) ^ stk) { /* rep0 */
|
||||
i |= -1;
|
||||
if (tek_rdget1(rd, &prb->pb[s_pos].st[s].rep0l1, 0x71, 0, rd->ptbm[13]) == 0) {
|
||||
s = s < 7 ? 9 : 11;
|
||||
goto skip;
|
||||
}
|
||||
} else {
|
||||
if (tek_rdget1(rd, &prb->st[s].repg1, 0x71, 0, rd->ptbm[13]) ^ stk) /* rep1 */
|
||||
i = rep[1];
|
||||
else {
|
||||
if (tek_rdget1(rd, &prb->st[s].repg2, 0x71, 0, rd->ptbm[13]) ^ stk) /* rep2 */
|
||||
i = rep[2];
|
||||
else {
|
||||
if (stk == 0) {
|
||||
if (tek_rdget1(rd, &prb->repg3, 0x71, 0, &rd->bm[22]) == 0)
|
||||
goto err;
|
||||
}
|
||||
i = rep[3]; /* rep3 */
|
||||
rep[3] = rep[2];
|
||||
}
|
||||
rep[2] = rep[1];
|
||||
}
|
||||
rep[1] = rep[0];
|
||||
rep[0] = i;
|
||||
}
|
||||
i = tek_getlen5(rd, 1, s_pos, stk);
|
||||
s = s < 7 ? 8 : 11;
|
||||
}
|
||||
skip:
|
||||
i += 2;
|
||||
if (pos + rep[0] < 0)
|
||||
goto err;
|
||||
if (pos + i > osiz)
|
||||
i = osiz - pos;
|
||||
pos += i;
|
||||
do {
|
||||
*q = q[rep[0]];
|
||||
q++;
|
||||
} while (--i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tek_decode5(int siz, UCHAR *p, UCHAR *q)
|
||||
{
|
||||
UCHAR *p1 = p + siz;
|
||||
int dsiz, hed, bsiz, st = 0;
|
||||
p += 16;
|
||||
if ((dsiz = tek_getnum_s7s(&p)) > 0) {
|
||||
hed = tek_getnum_s7s(&p);
|
||||
if ((hed & 1) == 0)
|
||||
st = tek_lzrestore_tek5(p1 - p + 1, p - 1, dsiz, q);
|
||||
else {
|
||||
bsiz = 1 << (((hed >> 1) & 0x0f) + 8);
|
||||
if (hed & 0x20)
|
||||
return 1;
|
||||
if (bsiz == 256)
|
||||
st = tek_lzrestore_tek5(p1 - p, p, dsiz, q);
|
||||
else {
|
||||
if (dsiz > bsiz)
|
||||
return 1;
|
||||
if (hed & 0x40)
|
||||
tek_getnum_s7s(&p);
|
||||
st = tek_lzrestore_tek5(p1 - p, p, dsiz, q);
|
||||
}
|
||||
}
|
||||
}
|
||||
return st;
|
||||
}
|
||||
@@ -3,3 +3,6 @@ STACK = 1k
|
||||
MALLOC = 0k
|
||||
|
||||
include ../app_make.txt
|
||||
|
||||
$(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);
|
||||
}
|
||||
|
||||
@@ -3,3 +3,6 @@ STACK = 1k
|
||||
MALLOC = 0k
|
||||
|
||||
include ../app_make.txt
|
||||
|
||||
$(APP).hrb : $(APP).org Makefile
|
||||
$(COPY) $(APP).org $(APP).hrb
|
||||
|
||||
1
29_day/invader/!cons_9x.bat
Normal file
1
29_day/invader/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
||||
command
|
||||
1
29_day/invader/!cons_nt.bat
Normal file
1
29_day/invader/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
||||
cmd.exe
|
||||
5
29_day/invader/Makefile
Normal file
5
29_day/invader/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
APP = invader
|
||||
STACK = 90k
|
||||
MALLOC = 0k
|
||||
|
||||
include ../app_make.txt
|
||||
281
29_day/invader/invader.c
Normal file
281
29_day/invader/invader.c
Normal file
@@ -0,0 +1,281 @@
|
||||
#include <stdio.h> /* sprintf */
|
||||
#include <string.h> /* strlen */
|
||||
#include "apilib.h"
|
||||
|
||||
void putstr(int win, char *winbuf, int x, int y, int col, unsigned char *s);
|
||||
void wait(int i, int timer, char *keyflag);
|
||||
|
||||
static unsigned char charset[16 * 8] = {
|
||||
|
||||
/* invader(0) */
|
||||
0x00, 0x00, 0x00, 0x43, 0x5f, 0x5f, 0x5f, 0x7f,
|
||||
0x1f, 0x1f, 0x1f, 0x1f, 0x00, 0x20, 0x3f, 0x00,
|
||||
|
||||
/* invader(1) */
|
||||
0x00, 0x0f, 0x7f, 0xff, 0xcf, 0xcf, 0xcf, 0xff,
|
||||
0xff, 0xe0, 0xff, 0xff, 0xc0, 0xc0, 0xc0, 0x00,
|
||||
|
||||
/* invader(2) */
|
||||
0x00, 0xf0, 0xfe, 0xff, 0xf3, 0xf3, 0xf3, 0xff,
|
||||
0xff, 0x07, 0xff, 0xff, 0x03, 0x03, 0x03, 0x00,
|
||||
|
||||
/* invader(3) */
|
||||
0x00, 0x00, 0x00, 0xc2, 0xfa, 0xfa, 0xfa, 0xfe,
|
||||
0xf8, 0xf8, 0xf8, 0xf8, 0x00, 0x04, 0xfc, 0x00,
|
||||
|
||||
/* fighter(0) */
|
||||
0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x43, 0x47, 0x4f, 0x5f, 0x7f, 0x7f, 0x00,
|
||||
|
||||
/* fighter(1) */
|
||||
0x18, 0x7e, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xff,
|
||||
0xff, 0xff, 0xe7, 0xe7, 0xe7, 0xe7, 0xff, 0x00,
|
||||
|
||||
/* fighter(2) */
|
||||
0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0xc2, 0xe2, 0xf2, 0xfa, 0xfe, 0xfe, 0x00,
|
||||
|
||||
/* laser */
|
||||
0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00
|
||||
};
|
||||
/* invader:"abcd", fighter:"efg", laser:"h" */
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
/*
|
||||
fx:自机的x坐标(fighter_x)
|
||||
lx,ly:等离子炮弹的坐标(laser_x,laser_y)
|
||||
ix,iy:外星人群的坐标(invaders_x,in-vaders_y)
|
||||
idir:外星人群的移动方向(invaders_direc-tion)
|
||||
laserwait:等离子炮弹的剩余充电时间
|
||||
movewait:当这个变量变为0时外星人群前进一步
|
||||
movewait0:movewait的初始值(消灭30只敌人后减少)
|
||||
invline:外星人群的行数(invaders_line)
|
||||
score:当前得分
|
||||
high:最高得分
|
||||
point:得分的增加量(奖金的单价?)
|
||||
invstr:将外星人群的状态显示为字符串的变量
|
||||
*/
|
||||
|
||||
int win, timer, i, j, fx, laserwait, lx = 0, ly;
|
||||
int ix, iy, movewait0, movewait, idir;
|
||||
int invline, score, high, point;
|
||||
char winbuf[336 * 261], invstr[32 * 6], s[12], keyflag[4], *p;
|
||||
static char invstr0[32] = " abcd abcd abcd abcd abcd ";
|
||||
|
||||
win = api_openwin(winbuf, 336, 261, -1, "invader");
|
||||
api_boxfilwin(win, 6, 27, 329, 254, 0);
|
||||
timer = api_alloctimer();
|
||||
api_inittimer(timer, 128);
|
||||
|
||||
high = 0;
|
||||
putstr(win, winbuf, 22, 0, 7, "HIGH:00000000");
|
||||
|
||||
restart:
|
||||
score = 0;
|
||||
point = 1;
|
||||
putstr(win, winbuf, 4, 0, 7, "SCORE:00000000");
|
||||
movewait0 = 20;
|
||||
fx = 18;
|
||||
putstr(win, winbuf, fx, 13, 6, "efg");
|
||||
wait(100, timer, keyflag);
|
||||
|
||||
next_group:
|
||||
wait(100, timer, keyflag);
|
||||
ix = 7;
|
||||
iy = 1;
|
||||
invline = 6;
|
||||
for (i = 0; i < 6; i++) {
|
||||
for (j = 0; j < 27; j++) {
|
||||
invstr[i * 32 + j] = invstr0[j];
|
||||
}
|
||||
putstr(win, winbuf, ix, iy + i, 2, invstr + i * 32);
|
||||
}
|
||||
keyflag[0] = 0;
|
||||
keyflag[1] = 0;
|
||||
keyflag[2] = 0;
|
||||
|
||||
ly = 0; /*不显示*/
|
||||
laserwait = 0;
|
||||
movewait = movewait0;
|
||||
idir = +1;
|
||||
wait(100, timer, keyflag);
|
||||
|
||||
for (;;) {
|
||||
if (laserwait != 0) {
|
||||
laserwait--;
|
||||
keyflag[2 /* space */] = 0;
|
||||
}
|
||||
|
||||
wait(4, timer, keyflag);
|
||||
|
||||
/*自机的处理*/
|
||||
if (keyflag[0 /* left */] != 0 && fx > 0) {
|
||||
fx--;
|
||||
putstr(win, winbuf, fx, 13, 6, "efg ");
|
||||
keyflag[0 /* left */] = 0;
|
||||
}
|
||||
if (keyflag[1 /* right */] != 0 && fx < 37) {
|
||||
putstr(win, winbuf, fx, 13, 6, " efg");
|
||||
fx++;
|
||||
keyflag[1 /* right */] = 0;
|
||||
}
|
||||
if (keyflag[2 /* space */] != 0 && laserwait == 0) {
|
||||
laserwait = 15;
|
||||
lx = fx + 1;
|
||||
ly = 13;
|
||||
}
|
||||
|
||||
/*外星人移动*/
|
||||
if (movewait != 0) {
|
||||
movewait--;
|
||||
} else {
|
||||
movewait = movewait0;
|
||||
if (ix + idir > 14 || ix + idir < 0) {
|
||||
if (iy + invline == 13) {
|
||||
break; /* GAME OVER */
|
||||
}
|
||||
idir = - idir;
|
||||
putstr(win, winbuf, ix + 1, iy, 0, " ");
|
||||
iy++;
|
||||
} else {
|
||||
ix += idir;
|
||||
}
|
||||
for (i = 0; i < invline; i++) {
|
||||
putstr(win, winbuf, ix, iy + i, 2, invstr + i * 32);
|
||||
}
|
||||
}
|
||||
|
||||
/*炮弹处理*/
|
||||
if (ly > 0) {
|
||||
if (ly < 13) {
|
||||
if (ix < lx && lx < ix + 25 && iy <= ly && ly < iy + invline) {
|
||||
putstr(win, winbuf, ix, ly, 2, invstr + (ly - iy) * 32);
|
||||
} else {
|
||||
putstr(win, winbuf, lx, ly, 0, " ");
|
||||
}
|
||||
}
|
||||
ly--;
|
||||
if (ly > 0) {
|
||||
putstr(win, winbuf, lx, ly, 3, "h");
|
||||
} else {
|
||||
point -= 10;
|
||||
if (point <= 0) {
|
||||
point = 1;
|
||||
}
|
||||
}
|
||||
if (ix < lx && lx < ix + 25 && iy <= ly && ly < iy + invline) {
|
||||
p = invstr + (ly - iy) * 32 + (lx - ix);
|
||||
if (*p != ' ') {
|
||||
/* hit ! */
|
||||
score += point;
|
||||
point++;
|
||||
sprintf(s, "%08d", score);
|
||||
putstr(win, winbuf, 10, 0, 7, s);
|
||||
if (high < score) {
|
||||
high = score;
|
||||
putstr(win, winbuf, 27, 0, 7, s);
|
||||
}
|
||||
for (p--; *p != ' '; p--) { }
|
||||
for (i = 1; i < 5; i++) {
|
||||
p[i] = ' ';
|
||||
}
|
||||
putstr(win, winbuf, ix, ly, 2, invstr + (ly - iy) * 32);
|
||||
for (; invline > 0; invline--) {
|
||||
for (p = invstr + (invline - 1) * 32; *p != 0; p++) {
|
||||
if (*p != ' ') {
|
||||
goto alive;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*全部消灭*/
|
||||
movewait0 -= movewait0 / 3;
|
||||
goto next_group;
|
||||
alive:
|
||||
ly = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* GAME OVER */
|
||||
putstr(win, winbuf, 15, 6, 1, "GAME OVER");
|
||||
wait(0, timer, keyflag);
|
||||
for (i = 1; i < 14; i++) {
|
||||
putstr(win, winbuf, 0, i, 0, " ");
|
||||
}
|
||||
goto restart;
|
||||
}
|
||||
|
||||
void putstr(int win, char *winbuf, int x, int y, int col, unsigned char *s)
|
||||
{
|
||||
int c, x0, i;
|
||||
char *p, *q, t[2];
|
||||
x = x * 8 + 8;
|
||||
y = y * 16 + 29;
|
||||
x0 = x;
|
||||
i = strlen(s); /*计算s的字符数*/
|
||||
api_boxfilwin(win + 1, x, y, x + i * 8 - 1, y + 15, 0);
|
||||
q = winbuf + y * 336;
|
||||
t[1] = 0;
|
||||
for (;;) {
|
||||
c = *s;
|
||||
if (c == 0) {
|
||||
break;
|
||||
}
|
||||
if (c != ' ') {
|
||||
if ('a' <= c && c <= 'h') {
|
||||
p = charset + 16 * (c - 'a');
|
||||
q += x;
|
||||
for (i = 0; i < 16; i++) {
|
||||
if ((p[i] & 0x80) != 0) { q[0] = col; }
|
||||
if ((p[i] & 0x40) != 0) { q[1] = col; }
|
||||
if ((p[i] & 0x20) != 0) { q[2] = col; }
|
||||
if ((p[i] & 0x10) != 0) { q[3] = col; }
|
||||
if ((p[i] & 0x08) != 0) { q[4] = col; }
|
||||
if ((p[i] & 0x04) != 0) { q[5] = col; }
|
||||
if ((p[i] & 0x02) != 0) { q[6] = col; }
|
||||
if ((p[i] & 0x01) != 0) { q[7] = col; }
|
||||
q += 336;
|
||||
}
|
||||
q -= 336 * 16 + x;
|
||||
} else {
|
||||
t[0] = *s;
|
||||
api_putstrwin(win + 1, x, y, col, 1, t);
|
||||
}
|
||||
}
|
||||
s++;
|
||||
x += 8;
|
||||
}
|
||||
api_refreshwin(win, x0, y, x, y + 16);
|
||||
return;
|
||||
}
|
||||
|
||||
void wait(int i, int timer, char *keyflag)
|
||||
{
|
||||
int j;
|
||||
if (i > 0) {
|
||||
/*等待一段时间*/
|
||||
api_settimer(timer, i);
|
||||
i = 128;
|
||||
} else {
|
||||
i = 0x0a; /* Enter */
|
||||
}
|
||||
for (;;) {
|
||||
j = api_getkey(1);
|
||||
if (i == j) {
|
||||
break;
|
||||
}
|
||||
if (j == '4') {
|
||||
keyflag[0 /* left */] = 1;
|
||||
}
|
||||
if (j == '6') {
|
||||
keyflag[1 /* right */] = 1;
|
||||
}
|
||||
if (j == ' ') {
|
||||
keyflag[2 /* space */] = 1;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
1
29_day/invader/make.bat
Normal file
1
29_day/invader/make.bat
Normal file
@@ -0,0 +1 @@
|
||||
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
Binary file not shown.
BIN
29_day/nihongo/nihongo.org
Normal file
BIN
29_day/nihongo/nihongo.org
Normal file
Binary file not shown.
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;
|
||||
}
|
||||
649
29_day/tek/autodec_.c
Normal file
649
29_day/tek/autodec_.c
Normal file
@@ -0,0 +1,649 @@
|
||||
#include <stdio.h> /* NULL */
|
||||
#include <stdlib.h> /* malloc, free */
|
||||
#include <setjmp.h>
|
||||
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned int UINT32;
|
||||
typedef UINT32 tek_TPRB;
|
||||
|
||||
static int tek_decode1(int siz, UCHAR *p, UCHAR *q);
|
||||
static int tek_decode2(int siz, UCHAR *p, UCHAR *q);
|
||||
static int tek_decode5(int siz, UCHAR *p, UCHAR *q);
|
||||
|
||||
static unsigned int tek_getnum_s7s(UCHAR **pp)
|
||||
{
|
||||
unsigned int s = 0;
|
||||
UCHAR *p = *pp;
|
||||
do {
|
||||
s = s << 7 | *p++;
|
||||
} while ((s & 1) == 0);
|
||||
s >>= 1;
|
||||
*pp = p;
|
||||
return s;
|
||||
}
|
||||
|
||||
int autodecomp(int siz0, UCHAR *p0, int siz)
|
||||
{
|
||||
unsigned char *b = p0, *c, *c0;
|
||||
int s, i, e = 0;
|
||||
if ((*(int *) &b[0x08] == 0x5341534f) && (*(int *) &b[0x0c] == 0x504d434b)) {
|
||||
if (*(int *) &b[0x04] == 0x00000001) {
|
||||
unsigned int t = *(int *) &b[0x00];
|
||||
e |= 1;
|
||||
if (0xffffff83 <= t && t <= 0xffffff89) {
|
||||
c = &b[0x10];
|
||||
s = tek_getnum_s7s(&c);
|
||||
if (s + siz - 0x10 <= siz0) {
|
||||
c0 = c = b + siz0 - siz;
|
||||
for (i = siz - 1; i >= 0x10; i--)
|
||||
c[i] = b[i];
|
||||
c += 0x10;
|
||||
tek_getnum_s7s(&c);
|
||||
if (t == 0xffffff83)
|
||||
e = tek_decode1(siz, c0, b);
|
||||
if (t == 0xffffff85)
|
||||
e = tek_decode2(siz, c0, b);
|
||||
if (t == 0xffffff89)
|
||||
e = tek_decode5(siz, c0, b);
|
||||
siz = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e)
|
||||
siz |= -1;
|
||||
return siz;
|
||||
}
|
||||
|
||||
static int tek_lzrestore_stk1(int srcsiz, UCHAR *src, int outsiz, UCHAR *q)
|
||||
{
|
||||
int by, lz, cp, ds;
|
||||
UCHAR *q1 = q + outsiz, *s7ptr = src, *q0 = q;
|
||||
do {
|
||||
if ((by = (lz = *s7ptr++) & 0x0f) == 0)
|
||||
by = tek_getnum_s7s(&s7ptr);
|
||||
if ((lz >>= 4) == 0)
|
||||
lz = tek_getnum_s7s(&s7ptr);
|
||||
do {
|
||||
*q++ = *s7ptr++;
|
||||
} while (--by);
|
||||
if (q >= q1)
|
||||
break;
|
||||
do {
|
||||
ds = (cp = *s7ptr++) & 0x0f;
|
||||
if ((ds & 1) == 0) {
|
||||
do {
|
||||
ds = ds << 7 | *s7ptr++;
|
||||
} while ((ds & 1) == 0);
|
||||
}
|
||||
ds = ~(ds >> 1);
|
||||
if ((cp >>= 4) == 0) {
|
||||
do {
|
||||
cp = cp << 7 | *s7ptr++;
|
||||
} while ((cp & 1) == 0);
|
||||
cp >>= 1;
|
||||
}
|
||||
cp++;
|
||||
if (q + ds < q0)
|
||||
goto err;
|
||||
if (q + cp > q1)
|
||||
cp = q1 - q;
|
||||
do {
|
||||
*q = *(q + ds);
|
||||
q++;
|
||||
} while (--cp);
|
||||
} while (--lz);
|
||||
} while (q < q1);
|
||||
return 0;
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tek_decode1(int siz, UCHAR *p, UCHAR *q)
|
||||
{
|
||||
int dsiz, hed, bsiz;
|
||||
UCHAR *p1 = p + siz;
|
||||
p += 16;
|
||||
if ((dsiz = tek_getnum_s7s(&p)) > 0) {
|
||||
hed = tek_getnum_s7s(&p);
|
||||
bsiz = 1 << (((hed >> 1) & 0x0f) + 8);
|
||||
if (dsiz > bsiz || (hed & 0x21) != 0x01)
|
||||
return 1;
|
||||
if (hed & 0x40)
|
||||
tek_getnum_s7s(&p);
|
||||
if (tek_getnum_s7s(&p) != 0)
|
||||
return 1;
|
||||
return tek_lzrestore_stk1(p1 - p, p, dsiz, q);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int tek_getnum_s7(UCHAR **pp)
|
||||
{
|
||||
unsigned int s = 0, b = 0, a = 1;
|
||||
UCHAR *p = *pp;
|
||||
for (;;) {
|
||||
s = s << 7 | *p++;
|
||||
if (s & 1)
|
||||
break;
|
||||
a <<= 7;
|
||||
b += a;
|
||||
}
|
||||
s >>= 1;
|
||||
*pp = p;
|
||||
return s + b;
|
||||
}
|
||||
|
||||
static int tek_lzrestore_stk2(int srcsiz, UCHAR *src, int outsiz, UCHAR *q)
|
||||
{
|
||||
int cp, ds, repdis[4], i, j;
|
||||
UCHAR *q1 = q + outsiz, *s7ptr = src, *q0 = q, bylz, cbylz;
|
||||
for (j = 0; j < 4; j++)
|
||||
repdis[j] = -1 - j;
|
||||
bylz = cbylz = 0;
|
||||
if (outsiz) {
|
||||
if (tek_getnum_s7s(&s7ptr))
|
||||
return 1;
|
||||
do {
|
||||
j = 0;
|
||||
do {
|
||||
j++;
|
||||
if (j >= 17) {
|
||||
j += tek_getnum_s7s(&s7ptr);
|
||||
break;
|
||||
}
|
||||
if (cbylz == 0) {
|
||||
cbylz = 8;
|
||||
bylz = *s7ptr++;
|
||||
}
|
||||
cbylz--;
|
||||
i = bylz & 1;
|
||||
bylz >>= 1;
|
||||
} while (i == 0);
|
||||
do {
|
||||
*q++ = *s7ptr++;
|
||||
} while (--j);
|
||||
if (q >= q1)
|
||||
break;
|
||||
|
||||
j = 0;
|
||||
do {
|
||||
j++;
|
||||
if (j >= 17) {
|
||||
j += tek_getnum_s7s(&s7ptr);
|
||||
break;
|
||||
}
|
||||
if (cbylz == 0) {
|
||||
cbylz = 8;
|
||||
bylz = *s7ptr++;
|
||||
}
|
||||
cbylz--;
|
||||
i = bylz & 1;
|
||||
bylz >>= 1;
|
||||
} while (i == 0);
|
||||
do {
|
||||
i = *s7ptr++;
|
||||
cp = i >> 4;
|
||||
i &= 0x0f;
|
||||
if ((i & 1) == 0)
|
||||
i |= (tek_getnum_s7(&s7ptr) + 1) << 4;
|
||||
i >>= 1;
|
||||
ds = ~(i - 6);
|
||||
if (i < 4)
|
||||
ds = repdis[i];
|
||||
if (i == 4)
|
||||
ds = repdis[0] - tek_getnum_s7(&s7ptr) - 1;
|
||||
if (i == 5)
|
||||
ds = repdis[0] + tek_getnum_s7(&s7ptr) + 1;
|
||||
if (cp == 0)
|
||||
cp = tek_getnum_s7(&s7ptr) + 16;
|
||||
cp++;
|
||||
if (i > 0) {
|
||||
if (i > 1) {
|
||||
if (i > 2)
|
||||
repdis[3] = repdis[2];
|
||||
repdis[2] = repdis[1];
|
||||
}
|
||||
repdis[1] = repdis[0];
|
||||
repdis[0] = ds;
|
||||
}
|
||||
if (q + ds < q0)
|
||||
goto err;
|
||||
if (q + cp > q1)
|
||||
cp = q1 - q;
|
||||
do {
|
||||
*q = *(q + ds);
|
||||
q++;
|
||||
} while (--cp);
|
||||
} while (--j);
|
||||
} while (q < q1);
|
||||
}
|
||||
return 0;
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tek_decode2(int siz, UCHAR *p, UCHAR *q)
|
||||
{
|
||||
UCHAR *p1 = p + siz;
|
||||
int dsiz, hed, bsiz, st = 0;
|
||||
p += 16;
|
||||
if ((dsiz = tek_getnum_s7s(&p)) > 0) {
|
||||
hed = tek_getnum_s7s(&p);
|
||||
bsiz = 1 << (((hed >> 1) & 0x0f) + 8);
|
||||
if (dsiz > bsiz || (hed & 0x21) != 0x01)
|
||||
return 1;
|
||||
if (hed & 0x40)
|
||||
tek_getnum_s7s(&p);
|
||||
st = tek_lzrestore_stk2(p1 - p, p, dsiz, q);
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
static int tek_decmain5(int *work, UCHAR *src, int osiz, UCHAR *q, int lc, int pb, int lp, int flags);
|
||||
|
||||
static int tek_lzrestore_tek5(int srcsiz, UCHAR *src, int outsiz, UCHAR *outbuf)
|
||||
{
|
||||
int wrksiz, lc, lp, pb, flags, *work, prop0, fl;
|
||||
|
||||
if ((fl = (prop0 = *src) & 0x0f) == 0x01) /* 0001 */
|
||||
flags |= -1;
|
||||
else if (fl == 0x05)
|
||||
flags = -2;
|
||||
else if (fl == 0x09)
|
||||
flags &= 0;
|
||||
else
|
||||
return 1;
|
||||
src++;
|
||||
prop0 >>= 4;
|
||||
if (prop0 == 0)
|
||||
prop0 = *src++;
|
||||
else {
|
||||
static UCHAR prop0_table[] = { 0x5d, 0x00 }, prop1_table[] = { 0x00 };
|
||||
if (flags == -1) {
|
||||
if (prop0 >= 3)
|
||||
return 1;
|
||||
prop0 = prop0_table[prop0 - 1];
|
||||
} else {
|
||||
if (prop0 >= 2)
|
||||
return 1;
|
||||
prop0 = prop1_table[prop0 - 1];
|
||||
}
|
||||
}
|
||||
lp = prop0 / (9 * 5);
|
||||
prop0 %= 9 * 5;
|
||||
pb = prop0 / 9;
|
||||
lc = prop0 % 9;
|
||||
if (flags == 0) /* tek5:z2 */
|
||||
flags = *src++;
|
||||
if (flags == -1) { /* stk5 */
|
||||
wrksiz = lp;
|
||||
lp = pb;
|
||||
pb = wrksiz;
|
||||
}
|
||||
wrksiz = 0x180 * sizeof (UINT32) + (0x840 + (0x300 << (lc + lp))) * sizeof (tek_TPRB);
|
||||
work = malloc(wrksiz);
|
||||
if (work == NULL)
|
||||
return -1;
|
||||
flags = tek_decmain5(work, src, outsiz, outbuf, lc, pb, lp, flags);
|
||||
free(work);
|
||||
return flags;
|
||||
}
|
||||
|
||||
struct tek_STR_BITMODEL {
|
||||
UCHAR t, m, s, dmy;
|
||||
UINT32 prb0, prb1, tmsk, ntm, lt, lt0, dmy4;
|
||||
};
|
||||
|
||||
struct tek_STR_PRB {
|
||||
struct tek_STR_PRB_PB {
|
||||
struct tek_STR_PRB_PBST {
|
||||
tek_TPRB mch, rep0l1;
|
||||
} st[12];
|
||||
tek_TPRB lenlow[2][8], lenmid[2][8];
|
||||
} pb[16];
|
||||
struct tek_STR_PRB_ST {
|
||||
tek_TPRB rep, repg0, repg1, repg2;
|
||||
} st[12];
|
||||
tek_TPRB lensel[2][2], lenhigh[2][256], pslot[4][64], algn[64];
|
||||
tek_TPRB spdis[2][2+4+8+16+32], lenext[2+4+8+16+32];
|
||||
tek_TPRB repg3, fchgprm[2 * 32], tbmt[16], tbmm[16], fchglt;
|
||||
tek_TPRB lit[1];
|
||||
};
|
||||
|
||||
struct tek_STR_RNGDEC {
|
||||
UCHAR *p;
|
||||
UINT32 range, code, rmsk;
|
||||
jmp_buf errjmp;
|
||||
struct tek_STR_BITMODEL bm[32], *ptbm[16];
|
||||
struct tek_STR_PRB probs;
|
||||
};
|
||||
|
||||
static void tek_setbm5(struct tek_STR_BITMODEL *bm, int t, int m)
|
||||
{
|
||||
bm->t = t;
|
||||
bm->m = m;
|
||||
bm->prb1 = -1 << (m + t);
|
||||
bm->prb0 = ~bm->prb1;
|
||||
bm->prb1 |= 1 << t;
|
||||
bm->tmsk = (-1 << t) & 0xffff;
|
||||
bm->prb0 &= bm->tmsk;
|
||||
bm->prb1 &= bm->tmsk;
|
||||
bm->ntm = ~bm->tmsk;
|
||||
return;
|
||||
}
|
||||
|
||||
static int tek_rdget0(struct tek_STR_RNGDEC *rd, int n, int i)
|
||||
{
|
||||
do {
|
||||
while (rd->range < (UINT32) (1 << 24)) {
|
||||
rd->range <<= 8;
|
||||
rd->code = rd->code << 8 | *rd->p++;
|
||||
}
|
||||
rd->range >>= 1;
|
||||
i += i;
|
||||
if (rd->code >= rd->range) {
|
||||
rd->code -= rd->range;
|
||||
i |= 1;
|
||||
}
|
||||
} while (--n);
|
||||
return ~i;
|
||||
}
|
||||
|
||||
static int tek_rdget1(struct tek_STR_RNGDEC *rd, tek_TPRB *prob0, int n, int j, struct tek_STR_BITMODEL *bm)
|
||||
{
|
||||
UINT32 p, i, *prob, nm = n >> 4;
|
||||
n &= 0x0f;
|
||||
prob0 -= j;
|
||||
do {
|
||||
p = *(prob = prob0 + j);
|
||||
if (bm->lt > 0) {
|
||||
if (--bm->lt == 0) {
|
||||
if (tek_rdget1(rd, &rd->probs.fchglt, 0x71, 0, &rd->bm[3]) == 0) {
|
||||
err:
|
||||
longjmp(rd->errjmp, 1);
|
||||
}
|
||||
i = bm - rd->bm;
|
||||
if ((bm->s = tek_rdget1(rd, &rd->probs.fchgprm[i * 2 + bm->s], 0x71, 0, &rd->bm[1])) == 0) {
|
||||
i = tek_rdget1(rd, rd->probs.tbmt, 0x74, 1, &rd->bm[2]) & 15;
|
||||
if (i == 15)
|
||||
goto err;
|
||||
tek_setbm5(bm, i, ((tek_rdget1(rd, rd->probs.tbmm, 0x74, 1, &rd->bm[2]) - 1) & 15) + 1);
|
||||
}
|
||||
bm->lt = bm->lt0;
|
||||
}
|
||||
if (p < bm->prb0) {
|
||||
p = bm->prb0;
|
||||
goto fixprob;
|
||||
}
|
||||
if (p > bm->prb1) {
|
||||
p = bm->prb1;
|
||||
goto fixprob;
|
||||
}
|
||||
if (p & bm->ntm) {
|
||||
p &= bm->tmsk;
|
||||
fixprob:
|
||||
*prob = p;
|
||||
}
|
||||
}
|
||||
|
||||
while (rd->range < (UINT32) (1 << 24)) {
|
||||
rd->range <<= 8;
|
||||
rd->code = rd->code << 8 | *rd->p++;
|
||||
}
|
||||
j += j;
|
||||
i = ((unsigned long long) (rd->range & rd->rmsk) * p) >> 16;
|
||||
if (rd->code < i) {
|
||||
j |= 1;
|
||||
rd->range = i;
|
||||
*prob += ((0x10000 - p) >> bm->m) & bm->tmsk;
|
||||
} else {
|
||||
rd->range -= i;
|
||||
rd->code -= i;
|
||||
*prob -= (p >> bm->m) & bm->tmsk;
|
||||
}
|
||||
--n;
|
||||
if ((n & nm) == 0)
|
||||
bm++;
|
||||
} while (n);
|
||||
return j;
|
||||
}
|
||||
|
||||
static UINT32 tek_revbit(UINT32 data, int len)
|
||||
{
|
||||
UINT32 rev = 0;
|
||||
do {
|
||||
rev += rev + (data & 1);
|
||||
data >>= 1;
|
||||
} while (--len);
|
||||
return rev;
|
||||
}
|
||||
|
||||
static int tek_getlen5(struct tek_STR_RNGDEC *rd, int m, int s_pos, int stk)
|
||||
{
|
||||
int i;
|
||||
if (tek_rdget1(rd, &rd->probs.lensel[m][0], 0x71, 0, rd->ptbm[3]) ^ stk) /* low */
|
||||
i = tek_rdget1(rd, rd->probs.pb[s_pos].lenlow[m], 0x73, 1, rd->ptbm[4]) & 7;
|
||||
else if (tek_rdget1(rd, &rd->probs.lensel[m][1], 0x71, 0, rd->ptbm[3]) ^ stk) /* mid */
|
||||
i = tek_rdget1(rd, rd->probs.pb[s_pos].lenmid[m], 0x73, 1, rd->ptbm[5]);
|
||||
else {
|
||||
/* high */
|
||||
i = tek_rdget1(rd, rd->probs.lenhigh[m], 0x78, 1, rd->ptbm[6]) - (256 + 256 - 8);
|
||||
if (i > 0) {
|
||||
if (i < 6 && stk == 0)
|
||||
i = tek_rdget1(rd, &rd->probs.lenext[(1 << i) - 2], i | 0x70, 1, rd->ptbm[7]) - 1;
|
||||
else
|
||||
i = tek_rdget0(rd, i, ~1) - 1;
|
||||
i = tek_rdget0(rd, i, ~1) - 1;
|
||||
}
|
||||
i += 256 - 8 + 16;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static int tek_decmain5(int *work, UCHAR *src, int osiz, UCHAR *q, int lc, int pb, int lp, int flags)
|
||||
{
|
||||
static int state_table[] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
|
||||
int i, j, k, pmch, rep[4], s, pos, m_pos = (1 << pb) - 1, m_lp = (1 << lp) - 1;
|
||||
int stk = (flags == -1), lcr = 8 - lc, s_pos, lit0cntmsk = 0x78;
|
||||
UINT32 *lit1;
|
||||
struct tek_STR_RNGDEC *rd = (struct tek_STR_RNGDEC *) work;
|
||||
struct tek_STR_PRB *prb = &rd->probs;
|
||||
|
||||
rd->p = &src[4];
|
||||
rd->range |= -1;
|
||||
rd->code = src[0] << 24 | src[1] << 16 | src[2] << 8 | src[3];
|
||||
for (i = 0; i < 4; i++)
|
||||
rep[i] = ~i;
|
||||
if (setjmp(rd->errjmp))
|
||||
goto err;
|
||||
for (i = sizeof (struct tek_STR_PRB) / sizeof (tek_TPRB) + (0x300 << (lc + lp)) - 2; i >= 0; i--)
|
||||
((tek_TPRB *) prb)[i] = 1 << 15;
|
||||
for (i = 0; i < 32; i++) {
|
||||
rd->bm[i].lt = (i >= 4);
|
||||
rd->bm[i].lt0 = (i < 24) ? 16 * 1024 : 8 * 1024;
|
||||
rd->bm[i].s &= 0;
|
||||
rd->bm[i].t = rd->bm[i].m = 5;
|
||||
}
|
||||
lit1 = prb->lit + ((256 << (lc + lp)) - 2);
|
||||
if (stk) {
|
||||
rd->rmsk = -1 << 11;
|
||||
for (i = 0; i < 32; i++)
|
||||
rd->bm[i].lt = 0;
|
||||
for (i = 0; i < 14; i++)
|
||||
rd->ptbm[i] = &rd->bm[0];
|
||||
} else {
|
||||
UCHAR pt[14];
|
||||
static UCHAR pt1[14] = {
|
||||
8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 18, 18, 18, 8
|
||||
};
|
||||
static UCHAR pt2[14] = {
|
||||
8, 8, 10, 11, 12, 12, 14, 15,
|
||||
16, 16, 18, 18, 20, 21
|
||||
};
|
||||
/*
|
||||
0- 7:mch, mch, lit1, lensel, lenlow, lenmid, lenhigh, lenext
|
||||
8-15:pslot, pslot, sdis, sdis, align, rep-repg2
|
||||
*/
|
||||
rd->rmsk |= -1;
|
||||
rd->bm[1].t = 5; rd->bm[1].m = 3; /* for fchgprm */
|
||||
rd->bm[2].t = 9; rd->bm[2].m = 2; /* for tbmt, tbmm */
|
||||
if (flags & 0x40) { /* lt-flag */
|
||||
rd->bm[3].t = 0; rd->bm[3].m = 1;
|
||||
prb->fchglt = 0xffff;
|
||||
}
|
||||
rd->bm[22].t = 0; rd->bm[22].m = 1;
|
||||
prb->repg3 = 0xffff;
|
||||
if (flags == -2) { /* z1 */
|
||||
rd->bm[22].lt = 0;
|
||||
for (i = 0; i < 14; i++)
|
||||
pt[i] = pt1[i];
|
||||
} else {
|
||||
for (i = 0; i < 14; i++)
|
||||
pt[i] = pt2[i];
|
||||
lit0cntmsk = (7 >> (flags & 3)) << 4 | 8;
|
||||
pt[ 1] = 8 + ((flags & 0x04) != 0); /* mch */
|
||||
pt[ 5] = 12 + ((flags & 0x08) != 0); /* llm */
|
||||
pt[ 9] = 16 + ((flags & 0x10) != 0); /* pst */
|
||||
pt[11] = 18 + ((flags & 0x20) != 0); /* sds */
|
||||
}
|
||||
for (i = 0; i < 14; i++)
|
||||
rd->ptbm[i] = &rd->bm[pt[i]];
|
||||
}
|
||||
for (i = 0; i < 32; i++)
|
||||
tek_setbm5(&rd->bm[i], rd->bm[i].t, rd->bm[i].m);
|
||||
|
||||
if ((tek_rdget1(rd, &prb->pb[0].st[0].mch, 0x71, 0, rd->ptbm[0]) ^ stk) == 0)
|
||||
goto err;
|
||||
*q++ = tek_rdget1(rd, prb->lit, lit0cntmsk, 1, &rd->bm[24]) & 0xff;
|
||||
pmch &= 0; s &= 0; pos = 1;
|
||||
while (pos < osiz) {
|
||||
s_pos = pos & m_pos;
|
||||
if (tek_rdget1(rd, &prb->pb[s_pos].st[s].mch, 0x71, 0, rd->ptbm[s > 0]) ^ stk) {
|
||||
i = (q[-1] >> lcr | (pos & m_lp) << lc) << 8;
|
||||
s = state_table[s];
|
||||
if (pmch == 0)
|
||||
*q = tek_rdget1(rd, &prb->lit[i], lit0cntmsk, 1, &rd->bm[24]) & 0xff;
|
||||
else {
|
||||
struct tek_STR_BITMODEL *bm = &rd->bm[24];
|
||||
j = 1; /* lit1‚Íʼn‚©‚ç2‚ðŒ¸‚¶‚Ä‚ ‚é */
|
||||
k = 8;
|
||||
pmch = q[rep[0]];
|
||||
do {
|
||||
j += j + tek_rdget1(rd, &lit1[(i + j) << 1 | pmch >> 7], 0x71, 0, rd->ptbm[2]);
|
||||
k--;
|
||||
if ((k & (lit0cntmsk >> 4)) == 0)
|
||||
bm++;
|
||||
if ((((pmch >> 7) ^ j) & 1) != 0 && k != 0) {
|
||||
j = tek_rdget1(rd, &prb->lit[i + j - 1], k | (lit0cntmsk & 0x70), j, bm);
|
||||
break;
|
||||
}
|
||||
pmch <<= 1;
|
||||
} while (k);
|
||||
*q = j & 0xff;
|
||||
pmch &= 0;
|
||||
}
|
||||
pos++;
|
||||
q++;
|
||||
} else { /* lz */
|
||||
pmch |= 1;
|
||||
if (tek_rdget1(rd, &prb->st[s].rep, 0x71, 0, rd->ptbm[13]) ^ stk) { /* len/dis */
|
||||
rep[3] = rep[2];
|
||||
rep[2] = rep[1];
|
||||
rep[1] = rep[0];
|
||||
j = i = tek_getlen5(rd, 0, s_pos, stk);
|
||||
s = s < 7 ? 7 : 10;
|
||||
if (j >= 4)
|
||||
j = 3;
|
||||
rep[0] = j = tek_rdget1(rd, prb->pslot[j], 0x76, 1, rd->ptbm[8 + (j == 3)]) & 0x3f;
|
||||
if (j >= 4) {
|
||||
k = (j >> 1) - 1; /* k = [1, 30] */
|
||||
rep[0] = (2 | (j & 1)) << k;
|
||||
if (j < 14) /* k < 6 */
|
||||
rep[0] |= tek_revbit(tek_rdget1(rd, &prb->spdis[j & 1][(1 << k) - 2], k | 0x70, 1, rd->ptbm[10 + (k >= 4)]), k);
|
||||
else {
|
||||
if (stk == 0) {
|
||||
if (k -= 6)
|
||||
rep[0] |= tek_rdget0(rd, k, ~0) << 6;
|
||||
rep[0] |= tek_revbit(tek_rdget1(rd, prb->algn, 0x76, 1, rd->ptbm[12]), 6);
|
||||
} else {
|
||||
rep[0] |= tek_rdget0(rd, k - 4, ~0) << 4;
|
||||
rep[0] |= tek_revbit(tek_rdget1(rd, prb->algn, 0x74, 1, rd->ptbm[12]), 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
rep[0] = ~rep[0];
|
||||
} else { /* repeat-dis */
|
||||
if (tek_rdget1(rd, &prb->st[s].repg0, 0x71, 0, rd->ptbm[13]) ^ stk) { /* rep0 */
|
||||
i |= -1;
|
||||
if (tek_rdget1(rd, &prb->pb[s_pos].st[s].rep0l1, 0x71, 0, rd->ptbm[13]) == 0) {
|
||||
s = s < 7 ? 9 : 11;
|
||||
goto skip;
|
||||
}
|
||||
} else {
|
||||
if (tek_rdget1(rd, &prb->st[s].repg1, 0x71, 0, rd->ptbm[13]) ^ stk) /* rep1 */
|
||||
i = rep[1];
|
||||
else {
|
||||
if (tek_rdget1(rd, &prb->st[s].repg2, 0x71, 0, rd->ptbm[13]) ^ stk) /* rep2 */
|
||||
i = rep[2];
|
||||
else {
|
||||
if (stk == 0) {
|
||||
if (tek_rdget1(rd, &prb->repg3, 0x71, 0, &rd->bm[22]) == 0)
|
||||
goto err;
|
||||
}
|
||||
i = rep[3]; /* rep3 */
|
||||
rep[3] = rep[2];
|
||||
}
|
||||
rep[2] = rep[1];
|
||||
}
|
||||
rep[1] = rep[0];
|
||||
rep[0] = i;
|
||||
}
|
||||
i = tek_getlen5(rd, 1, s_pos, stk);
|
||||
s = s < 7 ? 8 : 11;
|
||||
}
|
||||
skip:
|
||||
i += 2;
|
||||
if (pos + rep[0] < 0)
|
||||
goto err;
|
||||
if (pos + i > osiz)
|
||||
i = osiz - pos;
|
||||
pos += i;
|
||||
do {
|
||||
*q = q[rep[0]];
|
||||
q++;
|
||||
} while (--i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
int tek_decode5(int siz, UCHAR *p, UCHAR *q)
|
||||
{
|
||||
UCHAR *p1 = p + siz;
|
||||
int dsiz, hed, bsiz, st = 0;
|
||||
p += 16;
|
||||
if ((dsiz = tek_getnum_s7s(&p)) > 0) {
|
||||
hed = tek_getnum_s7s(&p);
|
||||
if ((hed & 1) == 0)
|
||||
st = tek_lzrestore_tek5(p1 - p + 1, p - 1, dsiz, q);
|
||||
else {
|
||||
bsiz = 1 << (((hed >> 1) & 0x0f) + 8);
|
||||
if (hed & 0x20)
|
||||
return 1;
|
||||
if (bsiz == 256)
|
||||
st = tek_lzrestore_tek5(p1 - p, p, dsiz, q);
|
||||
else {
|
||||
if (dsiz > bsiz)
|
||||
return 1;
|
||||
if (hed & 0x40)
|
||||
tek_getnum_s7s(&p);
|
||||
st = tek_lzrestore_tek5(p1 - p, p, dsiz, q);
|
||||
}
|
||||
}
|
||||
}
|
||||
return st;
|
||||
}
|
||||
646
29_day/tek/tek.c
Normal file
646
29_day/tek/tek.c
Normal file
@@ -0,0 +1,646 @@
|
||||
#include "bootpack.h"
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#define NULL 0
|
||||
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned int UINT32;
|
||||
typedef UINT32 tek_TPRB;
|
||||
|
||||
static int tek_decode1(int siz, UCHAR *p, UCHAR *q);
|
||||
static int tek_decode2(int siz, UCHAR *p, UCHAR *q);
|
||||
static int tek_decode5(int siz, UCHAR *p, UCHAR *q);
|
||||
|
||||
static unsigned int tek_getnum_s7s(UCHAR **pp)
|
||||
{
|
||||
unsigned int s = 0;
|
||||
UCHAR *p = *pp;
|
||||
do {
|
||||
s = s << 7 | *p++;
|
||||
} while ((s & 1) == 0);
|
||||
s >>= 1;
|
||||
*pp = p;
|
||||
return s;
|
||||
}
|
||||
|
||||
int tek_getsize(unsigned char *p)
|
||||
{
|
||||
static char header[15] = {
|
||||
0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x4f, 0x53, 0x41, 0x53, 0x4b, 0x43, 0x4d, 0x50
|
||||
};
|
||||
int size = -1;
|
||||
if (memcmp(p + 1, header, 15) == 0 && (*p == 0x83 || *p == 0x85 || *p == 0x89)) {
|
||||
p += 16;
|
||||
size = tek_getnum_s7s(&p);
|
||||
}
|
||||
return size;
|
||||
} /* (注)memcmp和strncmp差不多,这个函数忽略字符串中的0并一直比较到指定的15个字符为止*/
|
||||
|
||||
int tek_decomp(unsigned char *p, char *q, int size)
|
||||
{
|
||||
int err = -1;
|
||||
if (*p == 0x83) {
|
||||
err = tek_decode1(size, p, q);
|
||||
} else if (*p == 0x85) {
|
||||
err = tek_decode2(size, p, q);
|
||||
} else if (*p == 0x89) {
|
||||
err = tek_decode5(size, p, q);
|
||||
}
|
||||
if (err != 0) {
|
||||
return -1; /*失败*/
|
||||
}
|
||||
return 0; /*成功*/
|
||||
}
|
||||
|
||||
static int tek_lzrestore_stk1(int srcsiz, UCHAR *src, int outsiz, UCHAR *q)
|
||||
{
|
||||
int by, lz, cp, ds;
|
||||
UCHAR *q1 = q + outsiz, *s7ptr = src, *q0 = q;
|
||||
do {
|
||||
if ((by = (lz = *s7ptr++) & 0x0f) == 0)
|
||||
by = tek_getnum_s7s(&s7ptr);
|
||||
if ((lz >>= 4) == 0)
|
||||
lz = tek_getnum_s7s(&s7ptr);
|
||||
do {
|
||||
*q++ = *s7ptr++;
|
||||
} while (--by);
|
||||
if (q >= q1)
|
||||
break;
|
||||
do {
|
||||
ds = (cp = *s7ptr++) & 0x0f;
|
||||
if ((ds & 1) == 0) {
|
||||
do {
|
||||
ds = ds << 7 | *s7ptr++;
|
||||
} while ((ds & 1) == 0);
|
||||
}
|
||||
ds = ~(ds >> 1);
|
||||
if ((cp >>= 4) == 0) {
|
||||
do {
|
||||
cp = cp << 7 | *s7ptr++;
|
||||
} while ((cp & 1) == 0);
|
||||
cp >>= 1;
|
||||
}
|
||||
cp++;
|
||||
if (q + ds < q0)
|
||||
goto err;
|
||||
if (q + cp > q1)
|
||||
cp = q1 - q;
|
||||
do {
|
||||
*q = *(q + ds);
|
||||
q++;
|
||||
} while (--cp);
|
||||
} while (--lz);
|
||||
} while (q < q1);
|
||||
return 0;
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tek_decode1(int siz, UCHAR *p, UCHAR *q)
|
||||
{
|
||||
int dsiz, hed, bsiz;
|
||||
UCHAR *p1 = p + siz;
|
||||
p += 16;
|
||||
if ((dsiz = tek_getnum_s7s(&p)) > 0) {
|
||||
hed = tek_getnum_s7s(&p);
|
||||
bsiz = 1 << (((hed >> 1) & 0x0f) + 8);
|
||||
if (dsiz > bsiz || (hed & 0x21) != 0x01)
|
||||
return 1;
|
||||
if (hed & 0x40)
|
||||
tek_getnum_s7s(&p);
|
||||
if (tek_getnum_s7s(&p) != 0)
|
||||
return 1;
|
||||
return tek_lzrestore_stk1(p1 - p, p, dsiz, q);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int tek_getnum_s7(UCHAR **pp)
|
||||
{
|
||||
unsigned int s = 0, b = 0, a = 1;
|
||||
UCHAR *p = *pp;
|
||||
for (;;) {
|
||||
s = s << 7 | *p++;
|
||||
if (s & 1)
|
||||
break;
|
||||
a <<= 7;
|
||||
b += a;
|
||||
}
|
||||
s >>= 1;
|
||||
*pp = p;
|
||||
return s + b;
|
||||
}
|
||||
|
||||
static int tek_lzrestore_stk2(int srcsiz, UCHAR *src, int outsiz, UCHAR *q)
|
||||
{
|
||||
int cp, ds, repdis[4], i, j;
|
||||
UCHAR *q1 = q + outsiz, *s7ptr = src, *q0 = q, bylz, cbylz;
|
||||
for (j = 0; j < 4; j++)
|
||||
repdis[j] = -1 - j;
|
||||
bylz = cbylz = 0;
|
||||
if (outsiz) {
|
||||
if (tek_getnum_s7s(&s7ptr))
|
||||
return 1;
|
||||
do {
|
||||
j = 0;
|
||||
do {
|
||||
j++;
|
||||
if (j >= 17) {
|
||||
j += tek_getnum_s7s(&s7ptr);
|
||||
break;
|
||||
}
|
||||
if (cbylz == 0) {
|
||||
cbylz = 8;
|
||||
bylz = *s7ptr++;
|
||||
}
|
||||
cbylz--;
|
||||
i = bylz & 1;
|
||||
bylz >>= 1;
|
||||
} while (i == 0);
|
||||
do {
|
||||
*q++ = *s7ptr++;
|
||||
} while (--j);
|
||||
if (q >= q1)
|
||||
break;
|
||||
|
||||
j = 0;
|
||||
do {
|
||||
j++;
|
||||
if (j >= 17) {
|
||||
j += tek_getnum_s7s(&s7ptr);
|
||||
break;
|
||||
}
|
||||
if (cbylz == 0) {
|
||||
cbylz = 8;
|
||||
bylz = *s7ptr++;
|
||||
}
|
||||
cbylz--;
|
||||
i = bylz & 1;
|
||||
bylz >>= 1;
|
||||
} while (i == 0);
|
||||
do {
|
||||
i = *s7ptr++;
|
||||
cp = i >> 4;
|
||||
i &= 0x0f;
|
||||
if ((i & 1) == 0)
|
||||
i |= (tek_getnum_s7(&s7ptr) + 1) << 4;
|
||||
i >>= 1;
|
||||
ds = ~(i - 6);
|
||||
if (i < 4)
|
||||
ds = repdis[i];
|
||||
if (i == 4)
|
||||
ds = repdis[0] - tek_getnum_s7(&s7ptr) - 1;
|
||||
if (i == 5)
|
||||
ds = repdis[0] + tek_getnum_s7(&s7ptr) + 1;
|
||||
if (cp == 0)
|
||||
cp = tek_getnum_s7(&s7ptr) + 16;
|
||||
cp++;
|
||||
if (i > 0) {
|
||||
if (i > 1) {
|
||||
if (i > 2)
|
||||
repdis[3] = repdis[2];
|
||||
repdis[2] = repdis[1];
|
||||
}
|
||||
repdis[1] = repdis[0];
|
||||
repdis[0] = ds;
|
||||
}
|
||||
if (q + ds < q0)
|
||||
goto err;
|
||||
if (q + cp > q1)
|
||||
cp = q1 - q;
|
||||
do {
|
||||
*q = *(q + ds);
|
||||
q++;
|
||||
} while (--cp);
|
||||
} while (--j);
|
||||
} while (q < q1);
|
||||
}
|
||||
return 0;
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tek_decode2(int siz, UCHAR *p, UCHAR *q)
|
||||
{
|
||||
UCHAR *p1 = p + siz;
|
||||
int dsiz, hed, bsiz, st = 0;
|
||||
p += 16;
|
||||
if ((dsiz = tek_getnum_s7s(&p)) > 0) {
|
||||
hed = tek_getnum_s7s(&p);
|
||||
bsiz = 1 << (((hed >> 1) & 0x0f) + 8);
|
||||
if (dsiz > bsiz || (hed & 0x21) != 0x01)
|
||||
return 1;
|
||||
if (hed & 0x40)
|
||||
tek_getnum_s7s(&p);
|
||||
st = tek_lzrestore_stk2(p1 - p, p, dsiz, q);
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
static int tek_decmain5(int *work, UCHAR *src, int osiz, UCHAR *q, int lc, int pb, int lp, int flags);
|
||||
|
||||
static int tek_lzrestore_tek5(int srcsiz, UCHAR *src, int outsiz, UCHAR *outbuf)
|
||||
{
|
||||
int wrksiz, lc, lp, pb, flags, *work, prop0, fl;
|
||||
|
||||
if ((fl = (prop0 = *src) & 0x0f) == 0x01) /* 0001 */
|
||||
flags |= -1;
|
||||
else if (fl == 0x05)
|
||||
flags = -2;
|
||||
else if (fl == 0x09)
|
||||
flags &= 0;
|
||||
else
|
||||
return 1;
|
||||
src++;
|
||||
prop0 >>= 4;
|
||||
if (prop0 == 0)
|
||||
prop0 = *src++;
|
||||
else {
|
||||
static UCHAR prop0_table[] = { 0x5d, 0x00 }, prop1_table[] = { 0x00 };
|
||||
if (flags == -1) {
|
||||
if (prop0 >= 3)
|
||||
return 1;
|
||||
prop0 = prop0_table[prop0 - 1];
|
||||
} else {
|
||||
if (prop0 >= 2)
|
||||
return 1;
|
||||
prop0 = prop1_table[prop0 - 1];
|
||||
}
|
||||
}
|
||||
lp = prop0 / (9 * 5);
|
||||
prop0 %= 9 * 5;
|
||||
pb = prop0 / 9;
|
||||
lc = prop0 % 9;
|
||||
if (flags == 0) /* tek5:z2 */
|
||||
flags = *src++;
|
||||
if (flags == -1) { /* stk5 */
|
||||
wrksiz = lp;
|
||||
lp = pb;
|
||||
pb = wrksiz;
|
||||
}
|
||||
wrksiz = 0x180 * sizeof (UINT32) + (0x840 + (0x300 << (lc + lp))) * sizeof (tek_TPRB); /* Å’á15KB, lc+lp=3‚È‚çA36KB */
|
||||
work = (int *) memman_alloc_4k((struct MEMMAN *) MEMMAN_ADDR, wrksiz);
|
||||
if (work == NULL)
|
||||
return -1;
|
||||
flags = tek_decmain5(work, src, outsiz, outbuf, lc, pb, lp, flags);
|
||||
memman_free_4k((struct MEMMAN *) MEMMAN_ADDR, (int) work, wrksiz);
|
||||
return flags;
|
||||
}
|
||||
|
||||
struct tek_STR_BITMODEL {
|
||||
UCHAR t, m, s, dmy;
|
||||
UINT32 prb0, prb1, tmsk, ntm, lt, lt0, dmy4;
|
||||
};
|
||||
|
||||
struct tek_STR_PRB {
|
||||
struct tek_STR_PRB_PB {
|
||||
struct tek_STR_PRB_PBST {
|
||||
tek_TPRB mch, rep0l1;
|
||||
} st[12];
|
||||
tek_TPRB lenlow[2][8], lenmid[2][8];
|
||||
} pb[16];
|
||||
struct tek_STR_PRB_ST {
|
||||
tek_TPRB rep, repg0, repg1, repg2;
|
||||
} st[12];
|
||||
tek_TPRB lensel[2][2], lenhigh[2][256], pslot[4][64], algn[64];
|
||||
tek_TPRB spdis[2][2+4+8+16+32], lenext[2+4+8+16+32];
|
||||
tek_TPRB repg3, fchgprm[2 * 32], tbmt[16], tbmm[16], fchglt;
|
||||
tek_TPRB lit[1];
|
||||
};
|
||||
|
||||
struct tek_STR_RNGDEC {
|
||||
UCHAR *p;
|
||||
UINT32 range, code, rmsk;
|
||||
jmp_buf errjmp;
|
||||
struct tek_STR_BITMODEL bm[32], *ptbm[16];
|
||||
struct tek_STR_PRB probs;
|
||||
};
|
||||
|
||||
static void tek_setbm5(struct tek_STR_BITMODEL *bm, int t, int m)
|
||||
{
|
||||
bm->t = t;
|
||||
bm->m = m;
|
||||
bm->prb1 = -1 << (m + t);
|
||||
bm->prb0 = ~bm->prb1;
|
||||
bm->prb1 |= 1 << t;
|
||||
bm->tmsk = (-1 << t) & 0xffff;
|
||||
bm->prb0 &= bm->tmsk;
|
||||
bm->prb1 &= bm->tmsk;
|
||||
bm->ntm = ~bm->tmsk;
|
||||
return;
|
||||
}
|
||||
|
||||
static int tek_rdget0(struct tek_STR_RNGDEC *rd, int n, int i)
|
||||
{
|
||||
do {
|
||||
while (rd->range < (UINT32) (1 << 24)) {
|
||||
rd->range <<= 8;
|
||||
rd->code = rd->code << 8 | *rd->p++;
|
||||
}
|
||||
rd->range >>= 1;
|
||||
i += i;
|
||||
if (rd->code >= rd->range) {
|
||||
rd->code -= rd->range;
|
||||
i |= 1;
|
||||
}
|
||||
} while (--n);
|
||||
return ~i;
|
||||
}
|
||||
|
||||
static int tek_rdget1(struct tek_STR_RNGDEC *rd, tek_TPRB *prob0, int n, int j, struct tek_STR_BITMODEL *bm)
|
||||
{
|
||||
UINT32 p, i, *prob, nm = n >> 4;
|
||||
n &= 0x0f;
|
||||
prob0 -= j;
|
||||
do {
|
||||
p = *(prob = prob0 + j);
|
||||
if (bm->lt > 0) {
|
||||
if (--bm->lt == 0) {
|
||||
if (tek_rdget1(rd, &rd->probs.fchglt, 0x71, 0, &rd->bm[3]) == 0) {
|
||||
err:
|
||||
longjmp(rd->errjmp, 1);
|
||||
}
|
||||
i = bm - rd->bm;
|
||||
if ((bm->s = tek_rdget1(rd, &rd->probs.fchgprm[i * 2 + bm->s], 0x71, 0, &rd->bm[1])) == 0) {
|
||||
i = tek_rdget1(rd, rd->probs.tbmt, 0x74, 1, &rd->bm[2]) & 15;
|
||||
if (i == 15)
|
||||
goto err;
|
||||
tek_setbm5(bm, i, ((tek_rdget1(rd, rd->probs.tbmm, 0x74, 1, &rd->bm[2]) - 1) & 15) + 1);
|
||||
}
|
||||
bm->lt = bm->lt0;
|
||||
}
|
||||
if (p < bm->prb0) {
|
||||
p = bm->prb0;
|
||||
goto fixprob;
|
||||
}
|
||||
if (p > bm->prb1) {
|
||||
p = bm->prb1;
|
||||
goto fixprob;
|
||||
}
|
||||
if (p & bm->ntm) {
|
||||
p &= bm->tmsk;
|
||||
fixprob:
|
||||
*prob = p;
|
||||
}
|
||||
}
|
||||
|
||||
while (rd->range < (UINT32) (1 << 24)) {
|
||||
rd->range <<= 8;
|
||||
rd->code = rd->code << 8 | *rd->p++;
|
||||
}
|
||||
j += j;
|
||||
i = ((unsigned long long) (rd->range & rd->rmsk) * p) >> 16;
|
||||
if (rd->code < i) {
|
||||
j |= 1;
|
||||
rd->range = i;
|
||||
*prob += ((0x10000 - p) >> bm->m) & bm->tmsk;
|
||||
} else {
|
||||
rd->range -= i;
|
||||
rd->code -= i;
|
||||
*prob -= (p >> bm->m) & bm->tmsk;
|
||||
}
|
||||
--n;
|
||||
if ((n & nm) == 0)
|
||||
bm++;
|
||||
} while (n);
|
||||
return j;
|
||||
}
|
||||
|
||||
static UINT32 tek_revbit(UINT32 data, int len)
|
||||
{
|
||||
UINT32 rev = 0;
|
||||
do {
|
||||
rev += rev + (data & 1);
|
||||
data >>= 1;
|
||||
} while (--len);
|
||||
return rev;
|
||||
}
|
||||
|
||||
static int tek_getlen5(struct tek_STR_RNGDEC *rd, int m, int s_pos, int stk)
|
||||
{
|
||||
int i;
|
||||
if (tek_rdget1(rd, &rd->probs.lensel[m][0], 0x71, 0, rd->ptbm[3]) ^ stk) /* low */
|
||||
i = tek_rdget1(rd, rd->probs.pb[s_pos].lenlow[m], 0x73, 1, rd->ptbm[4]) & 7;
|
||||
else if (tek_rdget1(rd, &rd->probs.lensel[m][1], 0x71, 0, rd->ptbm[3]) ^ stk) /* mid */
|
||||
i = tek_rdget1(rd, rd->probs.pb[s_pos].lenmid[m], 0x73, 1, rd->ptbm[5]);
|
||||
else {
|
||||
/* high */
|
||||
i = tek_rdget1(rd, rd->probs.lenhigh[m], 0x78, 1, rd->ptbm[6]) - (256 + 256 - 8);
|
||||
if (i > 0) {
|
||||
if (i < 6 && stk == 0)
|
||||
i = tek_rdget1(rd, &rd->probs.lenext[(1 << i) - 2], i | 0x70, 1, rd->ptbm[7]) - 1;
|
||||
else
|
||||
i = tek_rdget0(rd, i, ~1) - 1;
|
||||
i = tek_rdget0(rd, i, ~1) - 1;
|
||||
}
|
||||
i += 256 - 8 + 16;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static int tek_decmain5(int *work, UCHAR *src, int osiz, UCHAR *q, int lc, int pb, int lp, int flags)
|
||||
{
|
||||
static int state_table[] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
|
||||
int i, j, k, pmch, rep[4], s, pos, m_pos = (1 << pb) - 1, m_lp = (1 << lp) - 1;
|
||||
int stk = (flags == -1), lcr = 8 - lc, s_pos, lit0cntmsk = 0x78;
|
||||
UINT32 *lit1;
|
||||
struct tek_STR_RNGDEC *rd = (struct tek_STR_RNGDEC *) work;
|
||||
struct tek_STR_PRB *prb = &rd->probs;
|
||||
|
||||
rd->p = &src[4];
|
||||
rd->range |= -1;
|
||||
rd->code = src[0] << 24 | src[1] << 16 | src[2] << 8 | src[3];
|
||||
for (i = 0; i < 4; i++)
|
||||
rep[i] = ~i;
|
||||
if (setjmp(rd->errjmp))
|
||||
goto err;
|
||||
for (i = sizeof (struct tek_STR_PRB) / sizeof (tek_TPRB) + (0x300 << (lc + lp)) - 2; i >= 0; i--)
|
||||
((tek_TPRB *) prb)[i] = 1 << 15;
|
||||
for (i = 0; i < 32; i++) {
|
||||
rd->bm[i].lt = (i >= 4);
|
||||
rd->bm[i].lt0 = (i < 24) ? 16 * 1024 : 8 * 1024;
|
||||
rd->bm[i].s &= 0;
|
||||
rd->bm[i].t = rd->bm[i].m = 5;
|
||||
}
|
||||
lit1 = prb->lit + ((256 << (lc + lp)) - 2);
|
||||
if (stk) {
|
||||
rd->rmsk = -1 << 11;
|
||||
for (i = 0; i < 32; i++)
|
||||
rd->bm[i].lt = 0;
|
||||
for (i = 0; i < 14; i++)
|
||||
rd->ptbm[i] = &rd->bm[0];
|
||||
} else {
|
||||
UCHAR pt[14];
|
||||
static UCHAR pt1[14] = {
|
||||
8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 18, 18, 18, 8
|
||||
};
|
||||
static UCHAR pt2[14] = {
|
||||
8, 8, 10, 11, 12, 12, 14, 15,
|
||||
16, 16, 18, 18, 20, 21
|
||||
};
|
||||
/*
|
||||
0- 7:mch, mch, lit1, lensel, lenlow, lenmid, lenhigh, lenext
|
||||
8-15:pslot, pslot, sdis, sdis, align, rep-repg2
|
||||
*/
|
||||
rd->rmsk |= -1;
|
||||
rd->bm[1].t = 5; rd->bm[1].m = 3; /* for fchgprm */
|
||||
rd->bm[2].t = 9; rd->bm[2].m = 2; /* for tbmt, tbmm */
|
||||
if (flags & 0x40) { /* lt-flag */
|
||||
rd->bm[3].t = 0; rd->bm[3].m = 1;
|
||||
prb->fchglt = 0xffff;
|
||||
}
|
||||
rd->bm[22].t = 0; rd->bm[22].m = 1;
|
||||
prb->repg3 = 0xffff;
|
||||
if (flags == -2) { /* z1 */
|
||||
rd->bm[22].lt = 0;
|
||||
for (i = 0; i < 14; i++)
|
||||
pt[i] = pt1[i];
|
||||
} else {
|
||||
for (i = 0; i < 14; i++)
|
||||
pt[i] = pt2[i];
|
||||
lit0cntmsk = (7 >> (flags & 3)) << 4 | 8;
|
||||
pt[ 1] = 8 + ((flags & 0x04) != 0); /* mch */
|
||||
pt[ 5] = 12 + ((flags & 0x08) != 0); /* llm */
|
||||
pt[ 9] = 16 + ((flags & 0x10) != 0); /* pst */
|
||||
pt[11] = 18 + ((flags & 0x20) != 0); /* sds */
|
||||
}
|
||||
for (i = 0; i < 14; i++)
|
||||
rd->ptbm[i] = &rd->bm[pt[i]];
|
||||
}
|
||||
for (i = 0; i < 32; i++)
|
||||
tek_setbm5(&rd->bm[i], rd->bm[i].t, rd->bm[i].m);
|
||||
|
||||
if ((tek_rdget1(rd, &prb->pb[0].st[0].mch, 0x71, 0, rd->ptbm[0]) ^ stk) == 0)
|
||||
goto err;
|
||||
*q++ = tek_rdget1(rd, prb->lit, lit0cntmsk, 1, &rd->bm[24]) & 0xff;
|
||||
pmch &= 0; s &= 0; pos = 1;
|
||||
while (pos < osiz) {
|
||||
s_pos = pos & m_pos;
|
||||
if (tek_rdget1(rd, &prb->pb[s_pos].st[s].mch, 0x71, 0, rd->ptbm[s > 0]) ^ stk) {
|
||||
i = (q[-1] >> lcr | (pos & m_lp) << lc) << 8;
|
||||
s = state_table[s];
|
||||
if (pmch == 0)
|
||||
*q = tek_rdget1(rd, &prb->lit[i], lit0cntmsk, 1, &rd->bm[24]) & 0xff;
|
||||
else {
|
||||
struct tek_STR_BITMODEL *bm = &rd->bm[24];
|
||||
j = 1;
|
||||
k = 8;
|
||||
pmch = q[rep[0]];
|
||||
do {
|
||||
j += j + tek_rdget1(rd, &lit1[(i + j) << 1 | pmch >> 7], 0x71, 0, rd->ptbm[2]);
|
||||
k--;
|
||||
if ((k & (lit0cntmsk >> 4)) == 0)
|
||||
bm++;
|
||||
if ((((pmch >> 7) ^ j) & 1) != 0 && k != 0) {
|
||||
j = tek_rdget1(rd, &prb->lit[i + j - 1], k | (lit0cntmsk & 0x70), j, bm);
|
||||
break;
|
||||
}
|
||||
pmch <<= 1;
|
||||
} while (k);
|
||||
*q = j & 0xff;
|
||||
pmch &= 0;
|
||||
}
|
||||
pos++;
|
||||
q++;
|
||||
} else { /* lz */
|
||||
pmch |= 1;
|
||||
if (tek_rdget1(rd, &prb->st[s].rep, 0x71, 0, rd->ptbm[13]) ^ stk) { /* len/dis */
|
||||
rep[3] = rep[2];
|
||||
rep[2] = rep[1];
|
||||
rep[1] = rep[0];
|
||||
j = i = tek_getlen5(rd, 0, s_pos, stk);
|
||||
s = s < 7 ? 7 : 10;
|
||||
if (j >= 4)
|
||||
j = 3;
|
||||
rep[0] = j = tek_rdget1(rd, prb->pslot[j], 0x76, 1, rd->ptbm[8 + (j == 3)]) & 0x3f;
|
||||
if (j >= 4) {
|
||||
k = (j >> 1) - 1; /* k = [1, 30] */
|
||||
rep[0] = (2 | (j & 1)) << k;
|
||||
if (j < 14) /* k < 6 */
|
||||
rep[0] |= tek_revbit(tek_rdget1(rd, &prb->spdis[j & 1][(1 << k) - 2], k | 0x70, 1, rd->ptbm[10 + (k >= 4)]), k);
|
||||
else {
|
||||
if (stk == 0) {
|
||||
if (k -= 6)
|
||||
rep[0] |= tek_rdget0(rd, k, ~0) << 6;
|
||||
rep[0] |= tek_revbit(tek_rdget1(rd, prb->algn, 0x76, 1, rd->ptbm[12]), 6);
|
||||
} else {
|
||||
rep[0] |= tek_rdget0(rd, k - 4, ~0) << 4;
|
||||
rep[0] |= tek_revbit(tek_rdget1(rd, prb->algn, 0x74, 1, rd->ptbm[12]), 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
rep[0] = ~rep[0];
|
||||
} else { /* repeat-dis */
|
||||
if (tek_rdget1(rd, &prb->st[s].repg0, 0x71, 0, rd->ptbm[13]) ^ stk) { /* rep0 */
|
||||
i |= -1;
|
||||
if (tek_rdget1(rd, &prb->pb[s_pos].st[s].rep0l1, 0x71, 0, rd->ptbm[13]) == 0) {
|
||||
s = s < 7 ? 9 : 11;
|
||||
goto skip;
|
||||
}
|
||||
} else {
|
||||
if (tek_rdget1(rd, &prb->st[s].repg1, 0x71, 0, rd->ptbm[13]) ^ stk) /* rep1 */
|
||||
i = rep[1];
|
||||
else {
|
||||
if (tek_rdget1(rd, &prb->st[s].repg2, 0x71, 0, rd->ptbm[13]) ^ stk) /* rep2 */
|
||||
i = rep[2];
|
||||
else {
|
||||
if (stk == 0) {
|
||||
if (tek_rdget1(rd, &prb->repg3, 0x71, 0, &rd->bm[22]) == 0)
|
||||
goto err;
|
||||
}
|
||||
i = rep[3]; /* rep3 */
|
||||
rep[3] = rep[2];
|
||||
}
|
||||
rep[2] = rep[1];
|
||||
}
|
||||
rep[1] = rep[0];
|
||||
rep[0] = i;
|
||||
}
|
||||
i = tek_getlen5(rd, 1, s_pos, stk);
|
||||
s = s < 7 ? 8 : 11;
|
||||
}
|
||||
skip:
|
||||
i += 2;
|
||||
if (pos + rep[0] < 0)
|
||||
goto err;
|
||||
if (pos + i > osiz)
|
||||
i = osiz - pos;
|
||||
pos += i;
|
||||
do {
|
||||
*q = q[rep[0]];
|
||||
q++;
|
||||
} while (--i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tek_decode5(int siz, UCHAR *p, UCHAR *q)
|
||||
{
|
||||
UCHAR *p1 = p + siz;
|
||||
int dsiz, hed, bsiz, st = 0;
|
||||
p += 16;
|
||||
if ((dsiz = tek_getnum_s7s(&p)) > 0) {
|
||||
hed = tek_getnum_s7s(&p);
|
||||
if ((hed & 1) == 0)
|
||||
st = tek_lzrestore_tek5(p1 - p + 1, p - 1, dsiz, q);
|
||||
else {
|
||||
bsiz = 1 << (((hed >> 1) & 0x0f) + 8);
|
||||
if (hed & 0x20)
|
||||
return 1;
|
||||
if (bsiz == 256)
|
||||
st = tek_lzrestore_tek5(p1 - p, p, dsiz, q);
|
||||
else {
|
||||
if (dsiz > bsiz)
|
||||
return 1;
|
||||
if (hed & 0x40)
|
||||
tek_getnum_s7s(&p);
|
||||
st = tek_lzrestore_tek5(p1 - p, p, dsiz, q);
|
||||
}
|
||||
}
|
||||
}
|
||||
return st;
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -3,3 +3,7 @@ STACK = 8k
|
||||
MALLOC = 0k
|
||||
|
||||
include ../app_make.txt
|
||||
|
||||
$(APP).hrb : $(APP).org Makefile
|
||||
$(COPY) $(APP).org $(APP).hrb
|
||||
|
||||
1
30_day/!cons_9x.bat
Normal file
1
30_day/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
||||
command
|
||||
1
30_day/!cons_nt.bat
Normal file
1
30_day/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
||||
cmd.exe
|
||||
209
30_day/Makefile
Normal file
209
30_day/Makefile
Normal file
@@ -0,0 +1,209 @@
|
||||
TOOLPATH = ../z_tools/
|
||||
INCPATH = ../z_tools/haribote/
|
||||
|
||||
MAKE = $(TOOLPATH)make.exe -r
|
||||
EDIMG = $(TOOLPATH)edimg.exe
|
||||
IMGTOL = $(TOOLPATH)imgtol.com
|
||||
COPY = copy
|
||||
DEL = del
|
||||
|
||||
#默认动作
|
||||
|
||||
default :
|
||||
$(MAKE) haribote.img
|
||||
|
||||
#文件生成规则
|
||||
|
||||
haribote.img : haribote/ipl10.bin haribote/haribote.sys Makefile \
|
||||
a/a.hrb hello3/hello3.hrb hello4/hello4.hrb hello5/hello5.hrb \
|
||||
winhelo/winhelo.hrb winhelo2/winhelo2.hrb winhelo3/winhelo3.hrb \
|
||||
star1/star1.hrb stars/stars.hrb stars2/stars2.hrb \
|
||||
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 \
|
||||
type/type.hrb iroha/iroha.hrb chklang/chklang.hrb \
|
||||
notrec/notrec.hrb bball/bball.hrb invader/invader.hrb \
|
||||
calc/calc.hrb tview/tview.hrb mmlplay/mmlplay.hrb gview/gview.hrb
|
||||
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
|
||||
wbinimg src:haribote/ipl10.bin len:512 from:0 to:0 \
|
||||
copy from:haribote/haribote.sys to:@: \
|
||||
copy from:haribote/jp.nas to:@: \
|
||||
copy from:make.bat to:@: \
|
||||
copy from:a/a.hrb to:@: \
|
||||
copy from:hello3/hello3.hrb to:@: \
|
||||
copy from:hello4/hello4.hrb to:@: \
|
||||
copy from:hello5/hello5.hrb to:@: \
|
||||
copy from:winhelo/winhelo.hrb to:@: \
|
||||
copy from:winhelo2/winhelo2.hrb to:@: \
|
||||
copy from:winhelo3/winhelo3.hrb to:@: \
|
||||
copy from:star1/star1.hrb to:@: \
|
||||
copy from:stars/stars.hrb to:@: \
|
||||
copy from:stars2/stars2.hrb to:@: \
|
||||
copy from:lines/lines.hrb to:@: \
|
||||
copy from:walk/walk.hrb to:@: \
|
||||
copy from:noodle/noodle.hrb to:@: \
|
||||
copy from:beepdown/beepdown.hrb to:@: \
|
||||
copy from:color/color.hrb to:@: \
|
||||
copy from:color2/color2.hrb to:@: \
|
||||
copy from:sosu/sosu.hrb to:@: \
|
||||
copy from:sosu2/sosu2.hrb to:@: \
|
||||
copy from:sosu3/sosu3.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:invader/invader.hrb to:@: \
|
||||
copy from:calc/calc.hrb to:@: \
|
||||
copy from:tview/tview.hrb to:@: \
|
||||
copy from:mmlplay/mmlplay.hrb to:@: \
|
||||
copy from:mmldata/kirakira.mml to:@: \
|
||||
copy from:mmldata/fujisan.mml to:@: \
|
||||
copy from:mmldata/daigo.mml to:@: \
|
||||
copy from:mmldata/daiku.mml to:@: \
|
||||
copy from:gview/gview.hrb to:@: \
|
||||
copy from:pictdata/fujisan.jpg to:@: \
|
||||
copy from:pictdata/night.bmp to:@: \
|
||||
copy from:nihongo/nihongo.fnt to:@: \
|
||||
imgout:haribote.img
|
||||
|
||||
#命令
|
||||
|
||||
run :
|
||||
$(MAKE) haribote.img
|
||||
$(COPY) haribote.img ..\z_tools\qemu\fdimage0.bin
|
||||
$(MAKE) -C ../z_tools/qemu
|
||||
|
||||
install :
|
||||
$(MAKE) haribote.img
|
||||
$(IMGTOL) w a: haribote.img
|
||||
|
||||
full :
|
||||
$(MAKE) -C haribote
|
||||
$(MAKE) -C apilib
|
||||
$(MAKE) -C stdlib
|
||||
$(MAKE) -C a
|
||||
$(MAKE) -C hello3
|
||||
$(MAKE) -C hello4
|
||||
$(MAKE) -C hello5
|
||||
$(MAKE) -C winhelo
|
||||
$(MAKE) -C winhelo2
|
||||
$(MAKE) -C winhelo3
|
||||
$(MAKE) -C star1
|
||||
$(MAKE) -C stars
|
||||
$(MAKE) -C stars2
|
||||
$(MAKE) -C lines
|
||||
$(MAKE) -C walk
|
||||
$(MAKE) -C noodle
|
||||
$(MAKE) -C beepdown
|
||||
$(MAKE) -C color
|
||||
$(MAKE) -C color2
|
||||
$(MAKE) -C sosu
|
||||
$(MAKE) -C sosu2
|
||||
$(MAKE) -C sosu3
|
||||
$(MAKE) -C type
|
||||
$(MAKE) -C iroha
|
||||
$(MAKE) -C chklang
|
||||
$(MAKE) -C notrec
|
||||
$(MAKE) -C bball
|
||||
$(MAKE) -C invader
|
||||
$(MAKE) -C calc
|
||||
$(MAKE) -C tview
|
||||
$(MAKE) -C mmlplay
|
||||
$(MAKE) -C gview
|
||||
$(MAKE) haribote.img
|
||||
|
||||
run_full :
|
||||
$(MAKE) full
|
||||
$(COPY) haribote.img ..\z_tools\qemu\fdimage0.bin
|
||||
$(MAKE) -C ../z_tools/qemu
|
||||
|
||||
install_full :
|
||||
$(MAKE) full
|
||||
$(IMGTOL) w a: haribote.img
|
||||
|
||||
run_os :
|
||||
$(MAKE) -C haribote
|
||||
$(MAKE) run
|
||||
|
||||
clean :
|
||||
#不执行任何操作
|
||||
|
||||
src_only :
|
||||
$(MAKE) clean
|
||||
-$(DEL) haribote.img
|
||||
|
||||
clean_full :
|
||||
$(MAKE) -C haribote clean
|
||||
$(MAKE) -C apilib clean
|
||||
$(MAKE) -C stdlib 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 beepdown 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
|
||||
$(MAKE) -C invader clean
|
||||
$(MAKE) -C calc clean
|
||||
$(MAKE) -C tview clean
|
||||
$(MAKE) -C mmlplay clean
|
||||
$(MAKE) -C gview clean
|
||||
|
||||
src_only_full :
|
||||
$(MAKE) -C haribote src_only
|
||||
$(MAKE) -C apilib src_only
|
||||
$(MAKE) -C stdlib 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 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 type src_only
|
||||
$(MAKE) -C iroha src_only
|
||||
$(MAKE) -C chklang src_only
|
||||
$(MAKE) -C notrec src_only
|
||||
$(MAKE) -C bball src_only
|
||||
$(MAKE) -C invader src_only
|
||||
$(MAKE) -C calc src_only
|
||||
$(MAKE) -C tview src_only
|
||||
$(MAKE) -C mmlplay src_only
|
||||
$(MAKE) -C gview src_only
|
||||
-$(DEL) haribote.img
|
||||
|
||||
refresh :
|
||||
$(MAKE) full
|
||||
$(MAKE) clean_full
|
||||
-$(DEL) haribote.img
|
||||
1
30_day/a/!cons_9x.bat
Normal file
1
30_day/a/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
||||
command
|
||||
1
30_day/a/!cons_nt.bat
Normal file
1
30_day/a/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
||||
cmd.exe
|
||||
8
30_day/a/Makefile
Normal file
8
30_day/a/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
APP = a
|
||||
STACK = 1k
|
||||
MALLOC = 0k
|
||||
|
||||
include ../app_make.txt
|
||||
|
||||
$(APP).hrb : $(APP).org Makefile
|
||||
$(COPY) $(APP).org $(APP).hrb
|
||||
7
30_day/a/a.c
Normal file
7
30_day/a/a.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "apilib.h"
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
api_putchar('A');
|
||||
api_end();
|
||||
}
|
||||
1
30_day/a/make.bat
Normal file
1
30_day/a/make.bat
Normal file
@@ -0,0 +1 @@
|
||||
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
27
30_day/apilib.h
Normal file
27
30_day/apilib.h
Normal file
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
int api_fopen(char *fname);
|
||||
void api_fclose(int fhandle);
|
||||
void api_fseek(int fhandle, int offset, int mode);
|
||||
int api_fsize(int fhandle, int mode);
|
||||
int api_fread(char *buf, int maxsize, int fhandle);
|
||||
int api_cmdline(char *buf, int maxsize);
|
||||
int api_getlang(void);
|
||||
1
30_day/apilib/!cons_9x.bat
Normal file
1
30_day/apilib/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
||||
command
|
||||
1
30_day/apilib/!cons_nt.bat
Normal file
1
30_day/apilib/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
||||
cmd.exe
|
||||
48
30_day/apilib/Makefile
Normal file
48
30_day/apilib/Makefile
Normal file
@@ -0,0 +1,48 @@
|
||||
OBJS_API = api001.obj api002.obj api003.obj api004.obj api005.obj api006.obj \
|
||||
api007.obj api008.obj api009.obj api010.obj api011.obj api012.obj \
|
||||
api013.obj api014.obj api015.obj api016.obj api017.obj api018.obj \
|
||||
api019.obj api020.obj api021.obj api022.obj api023.obj api024.obj \
|
||||
api025.obj api026.obj api027.obj alloca.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) apilib.lib
|
||||
|
||||
#库生成规则
|
||||
|
||||
apilib.lib : Makefile $(OBJS_API)
|
||||
$(GOLIB) $(OBJS_API) out:apilib.lib
|
||||
|
||||
#文件生成规则
|
||||
|
||||
%.obj : %.nas Makefile
|
||||
$(NASK) $*.nas $*.obj $*.lst
|
||||
|
||||
#命令
|
||||
|
||||
clean :
|
||||
-$(DEL) *.lst
|
||||
-$(DEL) *.obj
|
||||
|
||||
src_only :
|
||||
$(MAKE) clean
|
||||
-$(DEL) apilib.lib
|
||||
13
30_day/apilib/alloca.nas
Normal file
13
30_day/apilib/alloca.nas
Normal file
@@ -0,0 +1,13 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "alloca.nas"]
|
||||
|
||||
GLOBAL __alloca
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
__alloca:
|
||||
ADD EAX,-4
|
||||
SUB ESP,EAX
|
||||
JMP DWORD [ESP+EAX] ; 代替RET
|
||||
14
30_day/apilib/api001.nas
Normal file
14
30_day/apilib/api001.nas
Normal file
@@ -0,0 +1,14 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api001.nas"]
|
||||
|
||||
GLOBAL _api_putchar
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_putchar: ; void api_putchar(int c);
|
||||
MOV EDX,1
|
||||
MOV AL,[ESP+4] ; c
|
||||
INT 0x40
|
||||
RET
|
||||
16
30_day/apilib/api002.nas
Normal file
16
30_day/apilib/api002.nas
Normal file
@@ -0,0 +1,16 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api002.nas"]
|
||||
|
||||
GLOBAL _api_putstr0
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_putstr0: ; void api_putstr0(char *s);
|
||||
PUSH EBX
|
||||
MOV EDX,2
|
||||
MOV EBX,[ESP+8] ; s
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
17
30_day/apilib/api003.nas
Normal file
17
30_day/apilib/api003.nas
Normal file
@@ -0,0 +1,17 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api003.nas"]
|
||||
|
||||
GLOBAL _api_putstr1
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_putstr1: ; void api_putstr1(char *s, int l);
|
||||
PUSH EBX
|
||||
MOV EDX,3
|
||||
MOV EBX,[ESP+ 8] ; s
|
||||
MOV ECX,[ESP+12] ; l
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
12
30_day/apilib/api004.nas
Normal file
12
30_day/apilib/api004.nas
Normal file
@@ -0,0 +1,12 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api004.nas"]
|
||||
|
||||
GLOBAL _api_end
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_end: ; void api_end(void);
|
||||
MOV EDX,4
|
||||
INT 0x40
|
||||
24
30_day/apilib/api005.nas
Normal file
24
30_day/apilib/api005.nas
Normal file
@@ -0,0 +1,24 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api005.nas"]
|
||||
|
||||
GLOBAL _api_openwin
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_openwin: ; int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title);
|
||||
PUSH EDI
|
||||
PUSH ESI
|
||||
PUSH EBX
|
||||
MOV EDX,5
|
||||
MOV EBX,[ESP+16] ; buf
|
||||
MOV ESI,[ESP+20] ; xsiz
|
||||
MOV EDI,[ESP+24] ; ysiz
|
||||
MOV EAX,[ESP+28] ; col_inv
|
||||
MOV ECX,[ESP+32] ; title
|
||||
INT 0x40
|
||||
POP EBX
|
||||
POP ESI
|
||||
POP EDI
|
||||
RET
|
||||
27
30_day/apilib/api006.nas
Normal file
27
30_day/apilib/api006.nas
Normal file
@@ -0,0 +1,27 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api006.nas"]
|
||||
|
||||
GLOBAL _api_putstrwin
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_putstrwin: ; void api_putstrwin(int win, int x, int y, int col, int len, char *str);
|
||||
PUSH EDI
|
||||
PUSH ESI
|
||||
PUSH EBP
|
||||
PUSH EBX
|
||||
MOV EDX,6
|
||||
MOV EBX,[ESP+20] ; win
|
||||
MOV ESI,[ESP+24] ; x
|
||||
MOV EDI,[ESP+28] ; y
|
||||
MOV EAX,[ESP+32] ; col
|
||||
MOV ECX,[ESP+36] ; len
|
||||
MOV EBP,[ESP+40] ; str
|
||||
INT 0x40
|
||||
POP EBX
|
||||
POP EBP
|
||||
POP ESI
|
||||
POP EDI
|
||||
RET
|
||||
27
30_day/apilib/api007.nas
Normal file
27
30_day/apilib/api007.nas
Normal file
@@ -0,0 +1,27 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api007.nas"]
|
||||
|
||||
GLOBAL _api_boxfilwin
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_boxfilwin: ; void api_boxfilwin(int win, int x0, int y0, int x1, int y1, int col);
|
||||
PUSH EDI
|
||||
PUSH ESI
|
||||
PUSH EBP
|
||||
PUSH EBX
|
||||
MOV EDX,7
|
||||
MOV EBX,[ESP+20] ; win
|
||||
MOV EAX,[ESP+24] ; x0
|
||||
MOV ECX,[ESP+28] ; y0
|
||||
MOV ESI,[ESP+32] ; x1
|
||||
MOV EDI,[ESP+36] ; y1
|
||||
MOV EBP,[ESP+40] ; col
|
||||
INT 0x40
|
||||
POP EBX
|
||||
POP EBP
|
||||
POP ESI
|
||||
POP EDI
|
||||
RET
|
||||
20
30_day/apilib/api008.nas
Normal file
20
30_day/apilib/api008.nas
Normal file
@@ -0,0 +1,20 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api008.nas"]
|
||||
|
||||
GLOBAL _api_initmalloc
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_initmalloc: ; void api_initmalloc(void);
|
||||
PUSH EBX
|
||||
MOV EDX,8
|
||||
MOV EBX,[CS:0x0020] ; malloc内存空间的地址
|
||||
MOV EAX,EBX
|
||||
ADD EAX,32*1024 ; 加上32KB
|
||||
MOV ECX,[CS:0x0000] ; 数据段的大小
|
||||
SUB ECX,EAX
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
17
30_day/apilib/api009.nas
Normal file
17
30_day/apilib/api009.nas
Normal file
@@ -0,0 +1,17 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api009.nas"]
|
||||
|
||||
GLOBAL _api_malloc
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_malloc: ; char *api_malloc(int size);
|
||||
PUSH EBX
|
||||
MOV EDX,9
|
||||
MOV EBX,[CS:0x0020]
|
||||
MOV ECX,[ESP+8] ; size
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
18
30_day/apilib/api010.nas
Normal file
18
30_day/apilib/api010.nas
Normal file
@@ -0,0 +1,18 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api010.nas"]
|
||||
|
||||
GLOBAL _api_free
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_free: ; void api_free(char *addr, int size);
|
||||
PUSH EBX
|
||||
MOV EDX,10
|
||||
MOV EBX,[CS:0x0020]
|
||||
MOV EAX,[ESP+ 8] ; addr
|
||||
MOV ECX,[ESP+12] ; size
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
23
30_day/apilib/api011.nas
Normal file
23
30_day/apilib/api011.nas
Normal file
@@ -0,0 +1,23 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api011.nas"]
|
||||
|
||||
GLOBAL _api_point
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_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
|
||||
24
30_day/apilib/api012.nas
Normal file
24
30_day/apilib/api012.nas
Normal file
@@ -0,0 +1,24 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api012.nas"]
|
||||
|
||||
GLOBAL _api_refreshwin
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_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
|
||||
27
30_day/apilib/api013.nas
Normal file
27
30_day/apilib/api013.nas
Normal file
@@ -0,0 +1,27 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api013.nas"]
|
||||
|
||||
GLOBAL _api_linewin
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_linewin: ; void api_linewin(int win, int x0, int y0, int x1, int y1, int col);
|
||||
PUSH EDI
|
||||
PUSH ESI
|
||||
PUSH EBP
|
||||
PUSH EBX
|
||||
MOV EDX,13
|
||||
MOV EBX,[ESP+20] ; win
|
||||
MOV EAX,[ESP+24] ; x0
|
||||
MOV ECX,[ESP+28] ; y0
|
||||
MOV ESI,[ESP+32] ; x1
|
||||
MOV EDI,[ESP+36] ; y1
|
||||
MOV EBP,[ESP+40] ; col
|
||||
INT 0x40
|
||||
POP EBX
|
||||
POP EBP
|
||||
POP ESI
|
||||
POP EDI
|
||||
RET
|
||||
16
30_day/apilib/api014.nas
Normal file
16
30_day/apilib/api014.nas
Normal file
@@ -0,0 +1,16 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api014.nas"]
|
||||
|
||||
GLOBAL _api_closewin
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_closewin: ; void api_closewin(int win);
|
||||
PUSH EBX
|
||||
MOV EDX,14
|
||||
MOV EBX,[ESP+8] ; win
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
14
30_day/apilib/api015.nas
Normal file
14
30_day/apilib/api015.nas
Normal file
@@ -0,0 +1,14 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api015.nas"]
|
||||
|
||||
GLOBAL _api_getkey
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_getkey: ; int api_getkey(int mode);
|
||||
MOV EDX,15
|
||||
MOV EAX,[ESP+4] ; mode
|
||||
INT 0x40
|
||||
RET
|
||||
13
30_day/apilib/api016.nas
Normal file
13
30_day/apilib/api016.nas
Normal file
@@ -0,0 +1,13 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api016.nas"]
|
||||
|
||||
GLOBAL _api_alloctimer
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_alloctimer: ; int api_alloctimer(void);
|
||||
MOV EDX,16
|
||||
INT 0x40
|
||||
RET
|
||||
17
30_day/apilib/api017.nas
Normal file
17
30_day/apilib/api017.nas
Normal file
@@ -0,0 +1,17 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api017.nas"]
|
||||
|
||||
GLOBAL _api_inittimer
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_inittimer: ; void api_inittimer(int timer, int data);
|
||||
PUSH EBX
|
||||
MOV EDX,17
|
||||
MOV EBX,[ESP+ 8] ; timer
|
||||
MOV EAX,[ESP+12] ; data
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
17
30_day/apilib/api018.nas
Normal file
17
30_day/apilib/api018.nas
Normal file
@@ -0,0 +1,17 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api018.nas"]
|
||||
|
||||
GLOBAL _api_settimer
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_settimer: ; void api_settimer(int timer, int time);
|
||||
PUSH EBX
|
||||
MOV EDX,18
|
||||
MOV EBX,[ESP+ 8] ; timer
|
||||
MOV EAX,[ESP+12] ; time
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
16
30_day/apilib/api019.nas
Normal file
16
30_day/apilib/api019.nas
Normal file
@@ -0,0 +1,16 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api019.nas"]
|
||||
|
||||
GLOBAL _api_freetimer
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_freetimer: ; void api_freetimer(int timer);
|
||||
PUSH EBX
|
||||
MOV EDX,19
|
||||
MOV EBX,[ESP+ 8] ; timer
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
14
30_day/apilib/api020.nas
Normal file
14
30_day/apilib/api020.nas
Normal file
@@ -0,0 +1,14 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api020.nas"]
|
||||
|
||||
GLOBAL _api_beep
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_beep: ; void api_beep(int tone);
|
||||
MOV EDX,20
|
||||
MOV EAX,[ESP+4] ; tone
|
||||
INT 0x40
|
||||
RET
|
||||
16
30_day/apilib/api021.nas
Normal file
16
30_day/apilib/api021.nas
Normal file
@@ -0,0 +1,16 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api021.nas"]
|
||||
|
||||
GLOBAL _api_fopen
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_fopen: ; int api_fopen(char *fname);
|
||||
PUSH EBX
|
||||
MOV EDX,21
|
||||
MOV EBX,[ESP+8] ; fname
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
14
30_day/apilib/api022.nas
Normal file
14
30_day/apilib/api022.nas
Normal file
@@ -0,0 +1,14 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api022.nas"]
|
||||
|
||||
GLOBAL _api_fclose
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_fclose: ; void api_fclose(int fhandle);
|
||||
MOV EDX,22
|
||||
MOV EAX,[ESP+4] ; fhandle
|
||||
INT 0x40
|
||||
RET
|
||||
18
30_day/apilib/api023.nas
Normal file
18
30_day/apilib/api023.nas
Normal file
@@ -0,0 +1,18 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api023.nas"]
|
||||
|
||||
GLOBAL _api_fseek
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_fseek: ; void api_fseek(int fhandle, int offset, int mode);
|
||||
PUSH EBX
|
||||
MOV EDX,23
|
||||
MOV EAX,[ESP+8] ; fhandle
|
||||
MOV ECX,[ESP+16] ; mode
|
||||
MOV EBX,[ESP+12] ; offset
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
15
30_day/apilib/api024.nas
Normal file
15
30_day/apilib/api024.nas
Normal file
@@ -0,0 +1,15 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api024.nas"]
|
||||
|
||||
GLOBAL _api_fsize
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_fsize: ; int api_fsize(int fhandle, int mode);
|
||||
MOV EDX,24
|
||||
MOV EAX,[ESP+4] ; fhandle
|
||||
MOV ECX,[ESP+8] ; mode
|
||||
INT 0x40
|
||||
RET
|
||||
18
30_day/apilib/api025.nas
Normal file
18
30_day/apilib/api025.nas
Normal file
@@ -0,0 +1,18 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api025.nas"]
|
||||
|
||||
GLOBAL _api_fread
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_fread: ; int api_fread(char *buf, int maxsize, int fhandle);
|
||||
PUSH EBX
|
||||
MOV EDX,25
|
||||
MOV EAX,[ESP+16] ; fhandle
|
||||
MOV ECX,[ESP+12] ; maxsize
|
||||
MOV EBX,[ESP+8] ; buf
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
17
30_day/apilib/api026.nas
Normal file
17
30_day/apilib/api026.nas
Normal file
@@ -0,0 +1,17 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api026.nas"]
|
||||
|
||||
GLOBAL _api_cmdline
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_cmdline: ; int api_cmdline(char *buf, int maxsize);
|
||||
PUSH EBX
|
||||
MOV EDX,26
|
||||
MOV ECX,[ESP+12] ; maxsize
|
||||
MOV EBX,[ESP+8] ; buf
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
13
30_day/apilib/api027.nas
Normal file
13
30_day/apilib/api027.nas
Normal file
@@ -0,0 +1,13 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "api027.nas"]
|
||||
|
||||
GLOBAL _api_getlang
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_getlang: ; int api_getlang(void);
|
||||
MOV EDX,27
|
||||
INT 0x40
|
||||
RET
|
||||
1
30_day/apilib/make.bat
Normal file
1
30_day/apilib/make.bat
Normal file
@@ -0,0 +1 @@
|
||||
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
92
30_day/app_make.txt
Normal file
92
30_day/app_make.txt
Normal file
@@ -0,0 +1,92 @@
|
||||
TOOLPATH = ../../z_tools/
|
||||
INCPATH = ../../z_tools/haribote/
|
||||
APILIBPATH = ../apilib/
|
||||
STDLIBPATH = ../stdlib/
|
||||
HARIBOTEPATH = ../haribote/
|
||||
|
||||
MAKE = $(TOOLPATH)make.exe -r
|
||||
NASK = $(TOOLPATH)nask.exe
|
||||
CC1 = $(TOOLPATH)cc1.exe -I$(INCPATH) -I../ -Os -Wall -quiet
|
||||
GAS2NASK = $(TOOLPATH)gas2nask.exe -a
|
||||
OBJ2BIM = $(TOOLPATH)obj2bim.exe
|
||||
MAKEFONT = $(TOOLPATH)makefont.exe
|
||||
BIN2OBJ = $(TOOLPATH)bin2obj.exe
|
||||
BIM2HRB = $(TOOLPATH)bim2hrb.exe
|
||||
BIM2BIN = $(TOOLPATH)bim2bin.exe
|
||||
RULEFILE = ../haribote.rul
|
||||
EDIMG = $(TOOLPATH)edimg.exe
|
||||
IMGTOL = $(TOOLPATH)imgtol.com
|
||||
GOLIB = $(TOOLPATH)golib00.exe
|
||||
COPY = copy
|
||||
DEL = del
|
||||
|
||||
#默认动作
|
||||
|
||||
default :
|
||||
$(MAKE) $(APP).hrb
|
||||
|
||||
#文件生成规则
|
||||
|
||||
$(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 $(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/ipl10.bin ../haribote/haribote.sys $(APP).hrb \
|
||||
Makefile ../app_make.txt
|
||||
$(EDIMG) imgin:../../z_tools/fdimg0at.tek \
|
||||
wbinimg src:../haribote/ipl10.bin len:512 from:0 to:0 \
|
||||
copy from:../haribote/haribote.sys to:@: \
|
||||
copy from:$(APP).hrb to:@: \
|
||||
copy from:../nihongo/nihongo.fnt to:@: \
|
||||
imgout:haribote.img
|
||||
|
||||
#一般规则
|
||||
|
||||
%.gas : %.c ../apilib.h ../stdlib.h Makefile ../app_make.txt
|
||||
$(CC1) -o $*.gas $*.c
|
||||
|
||||
%.nas : %.gas Makefile ../app_make.txt
|
||||
$(GAS2NASK) $*.gas $*.nas
|
||||
|
||||
%.obj : %.nas Makefile ../app_make.txt
|
||||
$(NASK) $*.nas $*.obj $*.lst
|
||||
|
||||
%.org : %.bim Makefile ../app_make.txt
|
||||
$(BIM2HRB) $*.bim $*.org $(MALLOC)
|
||||
|
||||
%.hrb : %.org Makefile ../app_make.txt
|
||||
$(BIM2BIN) -osacmp in:$*.org out:$*.hrb
|
||||
|
||||
#命令
|
||||
|
||||
run :
|
||||
$(MAKE) haribote.img
|
||||
$(COPY) haribote.img ..\..\z_tools\qemu\fdimage0.bin
|
||||
$(MAKE) -C ../../z_tools/qemu
|
||||
|
||||
full :
|
||||
$(MAKE) -C $(APILIBPATH)
|
||||
$(MAKE) -C $(STDLIBPATH)
|
||||
$(MAKE) $(APP).hrb
|
||||
|
||||
run_full :
|
||||
$(MAKE) -C $(APILIBPATH)
|
||||
$(MAKE) -C $(STDLIBPATH)
|
||||
$(MAKE) -C ../haribote
|
||||
$(MAKE) run
|
||||
|
||||
clean :
|
||||
-$(DEL) *.lst
|
||||
-$(DEL) *.obj
|
||||
-$(DEL) *.map
|
||||
-$(DEL) *.bim
|
||||
-$(DEL) *.org
|
||||
-$(DEL) haribote.img
|
||||
|
||||
src_only :
|
||||
$(MAKE) clean
|
||||
-$(DEL) $(APP).hrb
|
||||
1
30_day/bball/!cons_9x.bat
Normal file
1
30_day/bball/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
||||
command
|
||||
1
30_day/bball/!cons_nt.bat
Normal file
1
30_day/bball/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
||||
cmd.exe
|
||||
5
30_day/bball/Makefile
Normal file
5
30_day/bball/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
APP = bball
|
||||
STACK = 52k
|
||||
MALLOC = 0k
|
||||
|
||||
include ../app_make.txt
|
||||
37
30_day/bball/bball.c
Normal file
37
30_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();
|
||||
}
|
||||
1
30_day/bball/make.bat
Normal file
1
30_day/bball/make.bat
Normal file
@@ -0,0 +1 @@
|
||||
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
1
30_day/beepdown/!cons_9x.bat
Normal file
1
30_day/beepdown/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
||||
command
|
||||
1
30_day/beepdown/!cons_nt.bat
Normal file
1
30_day/beepdown/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
||||
cmd.exe
|
||||
5
30_day/beepdown/Makefile
Normal file
5
30_day/beepdown/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
APP = beepdown
|
||||
STACK = 1k
|
||||
MALLOC = 40k
|
||||
|
||||
include ../app_make.txt
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user