Skip to content

Commit

Permalink
文件压缩
Browse files Browse the repository at this point in the history
  • Loading branch information
yourtion committed May 19, 2016
1 parent 41a0252 commit 633089d
Show file tree
Hide file tree
Showing 14 changed files with 2,000 additions and 16 deletions.
16 changes: 11 additions & 5 deletions 29_day/app_make.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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
Expand All @@ -29,15 +30,13 @@ $(APP).bim : $(APP).obj $(APILIBPATH)apilib.lib Makefile ../app_make.txt
$(OBJ2BIM) @$(RULEFILE) out:$(APP).bim map:$(APP).map stack:$(STACK) \
$(APP).obj $(APILIBPATH)apilib.lib

$(APP).hrb : $(APP).bim Makefile ../app_make.txt
$(BIM2HRB) $(APP).bim $(APP).hrb $(MALLOC)

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

#一般规则
Expand All @@ -51,6 +50,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 :
Expand All @@ -72,6 +77,7 @@ clean :
-$(DEL) *.obj
-$(DEL) *.map
-$(DEL) *.bim
-$(DEL) *.org
-$(DEL) haribote.img

src_only :
Expand Down
2 changes: 1 addition & 1 deletion 29_day/haribote/Makefile
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
8 changes: 5 additions & 3 deletions 29_day/haribote/bootpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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填充 */
Expand Down
5 changes: 5 additions & 0 deletions 29_day/haribote/bootpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
14 changes: 7 additions & 7 deletions 29_day/haribote/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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));
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -566,7 +566,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) {
Expand Down
20 changes: 20 additions & 0 deletions 29_day/haribote/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,23 @@ struct FILEINFO *file_search(char *name, struct FILEINFO *finfo, int max)
}
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;
}
Loading

0 comments on commit 633089d

Please sign in to comment.