mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-07 12:03:19 +08:00
Compare commits
27 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 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1 +1,5 @@
|
|||||||
*.hrb
|
*.hrb
|
||||||
|
*.lst
|
||||||
|
*.map
|
||||||
|
*.bim
|
||||||
|
*.hrb
|
||||||
@@ -12,15 +12,15 @@
|
|||||||
DW 224 ; 根目录大小(一般为224项)
|
DW 224 ; 根目录大小(一般为224项)
|
||||||
DW 2880 ; 该磁盘大小(必须为2880扇区1440*1024/512)
|
DW 2880 ; 该磁盘大小(必须为2880扇区1440*1024/512)
|
||||||
DB 0xf0 ; 磁盘类型(必须为0xf0)
|
DB 0xf0 ; 磁盘类型(必须为0xf0)
|
||||||
DW 9 ; FAT的长度(必??9扇区)
|
DW 9 ; FAT的长度(必须是9扇区)
|
||||||
DW 18 ; 一个磁道(track)有几个扇区(必须为18)
|
DW 18 ; 一个磁道(track)有几个扇区(必须为18)
|
||||||
DW 2 ; 磁头数(必??2)
|
DW 2 ; 磁头数(必须是2)
|
||||||
DD 0 ; 不使用分区,必须是0
|
DD 0 ; 不使用分区,必须是0
|
||||||
DD 2880 ; 重写一次磁盘大小
|
DD 2880 ; 重写一次磁盘大小
|
||||||
DB 0,0,0x29 ; 意义不明(固定)
|
DB 0,0,0x29 ; 意义不明(固定)
|
||||||
DD 0xffffffff ; (可能是)卷标号码
|
DD 0xffffffff ; (可能是)卷标号码
|
||||||
DB "HELLO-OS " ; 磁盘的名称(必须为11字?,不足填空格)
|
DB "HELLO-OS " ; 磁盘的名称(必须为11字节,不足填空格)
|
||||||
DB "FAT12 " ; 磁盘格式名称(必??8字?,不足填空格)
|
DB "FAT12 " ; 磁盘格式名称(必须是8字节,不足填空格)
|
||||||
RESB 18 ; 先空出18字节
|
RESB 18 ; 先空出18字节
|
||||||
|
|
||||||
; 程序主体
|
; 程序主体
|
||||||
@@ -47,4 +47,4 @@
|
|||||||
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
|
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
RESB 4600
|
RESB 4600
|
||||||
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
|
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
RESB 1469432
|
RESB 1469432
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
; 标准FAT12格式软盘专用的代码 Stand FAT12 format floppy code
|
; 标准FAT12格式软盘专用的代码 Stand FAT12 format floppy code
|
||||||
|
|
||||||
JMP entry
|
JMP entry
|
||||||
DB 0xeb, 0x4e, 0x90
|
DB 0x90
|
||||||
DB "HELLOIPL" ; 启动扇区名称(8字节)
|
DB "HELLOIPL" ; 启动扇区名称(8字节)
|
||||||
DW 512 ; 每个扇区(sector)大小(必须512字节)
|
DW 512 ; 每个扇区(sector)大小(必须512字节)
|
||||||
DB 1 ; 簇(cluster)大小(必须为1个扇区)
|
DB 1 ; 簇(cluster)大小(必须为1个扇区)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ retry:
|
|||||||
MOV BX,0
|
MOV BX,0
|
||||||
MOV DL,0x00 ; A驱动器
|
MOV DL,0x00 ; A驱动器
|
||||||
INT 0x13 ; 调用磁盘BIOS
|
INT 0x13 ; 调用磁盘BIOS
|
||||||
JNC next ; 没出错则跳转到fin
|
JNC next ; 没出错则跳转到next
|
||||||
ADD SI,1 ; 往SI加1
|
ADD SI,1 ; 往SI加1
|
||||||
CMP SI,5 ; 比较SI与5
|
CMP SI,5 ; 比较SI与5
|
||||||
JAE error ; SI >= 5 跳转到error
|
JAE error ; SI >= 5 跳转到error
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ VRAM EQU 0x0ff8 ; 图像缓冲区的起始地址
|
|||||||
|
|
||||||
ORG 0xc200 ; 这个的程序要被装载的内存地址
|
ORG 0xc200 ; 这个的程序要被装载的内存地址
|
||||||
|
|
||||||
; 画面モードを設定
|
; 设置画面模式
|
||||||
|
|
||||||
MOV AL,0x13 ; VGA显卡,320x200x8bit
|
MOV AL,0x13 ; VGA显卡,320x200x8bit
|
||||||
MOV AH,0x00
|
MOV AH,0x00
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -21,7 +21,8 @@ haribote.img : haribote/ipl20.bin haribote/haribote.sys Makefile \
|
|||||||
lines/lines.hrb walk/walk.hrb noodle/noodle.hrb \
|
lines/lines.hrb walk/walk.hrb noodle/noodle.hrb \
|
||||||
beepdown/beepdown.hrb color/color.hrb color2/color2.hrb \
|
beepdown/beepdown.hrb color/color.hrb color2/color2.hrb \
|
||||||
sosu/sosu.hrb sosu2/sosu2.hrb sosu3/sosu3.hrb \
|
sosu/sosu.hrb sosu2/sosu2.hrb sosu3/sosu3.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 \
|
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
|
||||||
wbinimg src:haribote/ipl20.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:haribote/haribote.sys to:@: \
|
||||||
@@ -49,8 +50,10 @@ haribote.img : haribote/ipl20.bin haribote/haribote.sys Makefile \
|
|||||||
copy from:type/type.hrb to:@: \
|
copy from:type/type.hrb to:@: \
|
||||||
copy from:iroha/iroha.hrb to:@: \
|
copy from:iroha/iroha.hrb to:@: \
|
||||||
copy from:chklang/chklang.hrb to:@: \
|
copy from:chklang/chklang.hrb to:@: \
|
||||||
copy from:notrec/notrec.hrb to:@: \
|
|
||||||
copy from:euc.txt 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:@: \
|
copy from:nihongo/nihongo.fnt to:@: \
|
||||||
imgout:haribote.img
|
imgout:haribote.img
|
||||||
|
|
||||||
@@ -92,6 +95,8 @@ full :
|
|||||||
$(MAKE) -C iroha
|
$(MAKE) -C iroha
|
||||||
$(MAKE) -C chklang
|
$(MAKE) -C chklang
|
||||||
$(MAKE) -C notrec
|
$(MAKE) -C notrec
|
||||||
|
$(MAKE) -C bball
|
||||||
|
$(MAKE) -C invader
|
||||||
$(MAKE) haribote.img
|
$(MAKE) haribote.img
|
||||||
|
|
||||||
run_full :
|
run_full :
|
||||||
@@ -116,59 +121,63 @@ src_only :
|
|||||||
|
|
||||||
clean_full :
|
clean_full :
|
||||||
$(MAKE) -C haribote clean
|
$(MAKE) -C haribote clean
|
||||||
$(MAKE) -C apilib clean
|
$(MAKE) -C apilib clean
|
||||||
$(MAKE) -C stdlib clean
|
$(MAKE) -C stdlib clean
|
||||||
$(MAKE) -C a clean
|
$(MAKE) -C a clean
|
||||||
$(MAKE) -C hello3 clean
|
$(MAKE) -C hello3 clean
|
||||||
$(MAKE) -C hello4 clean
|
$(MAKE) -C hello4 clean
|
||||||
$(MAKE) -C hello5 clean
|
$(MAKE) -C hello5 clean
|
||||||
$(MAKE) -C winhelo clean
|
$(MAKE) -C winhelo clean
|
||||||
$(MAKE) -C winhelo2 clean
|
$(MAKE) -C winhelo2 clean
|
||||||
$(MAKE) -C winhelo3 clean
|
$(MAKE) -C winhelo3 clean
|
||||||
$(MAKE) -C star1 clean
|
$(MAKE) -C star1 clean
|
||||||
$(MAKE) -C stars clean
|
$(MAKE) -C stars clean
|
||||||
$(MAKE) -C stars2 clean
|
$(MAKE) -C stars2 clean
|
||||||
$(MAKE) -C lines clean
|
$(MAKE) -C lines clean
|
||||||
$(MAKE) -C walk clean
|
$(MAKE) -C walk clean
|
||||||
$(MAKE) -C noodle clean
|
$(MAKE) -C noodle clean
|
||||||
$(MAKE) -C beepdown clean
|
$(MAKE) -C beepdown clean
|
||||||
$(MAKE) -C color clean
|
$(MAKE) -C color clean
|
||||||
$(MAKE) -C color2 clean
|
$(MAKE) -C color2 clean
|
||||||
$(MAKE) -C sosu clean
|
$(MAKE) -C sosu clean
|
||||||
$(MAKE) -C sosu2 clean
|
$(MAKE) -C sosu2 clean
|
||||||
$(MAKE) -C sosu3 clean
|
$(MAKE) -C sosu3 clean
|
||||||
$(MAKE) -C type clean
|
$(MAKE) -C type clean
|
||||||
$(MAKE) -C iroha clean
|
$(MAKE) -C iroha clean
|
||||||
$(MAKE) -C chklang clean
|
$(MAKE) -C chklang clean
|
||||||
$(MAKE) -C notrec clean
|
$(MAKE) -C notrec clean
|
||||||
|
$(MAKE) -C bball clean
|
||||||
|
$(MAKE) -C invader clean
|
||||||
|
|
||||||
src_only_full :
|
src_only_full :
|
||||||
$(MAKE) -C haribote src_only
|
$(MAKE) -C haribote src_only
|
||||||
$(MAKE) -C apilib src_only
|
$(MAKE) -C apilib src_only
|
||||||
$(MAKE) -C stdlib src_only
|
$(MAKE) -C stdlib src_only
|
||||||
$(MAKE) -C a src_only
|
$(MAKE) -C a src_only
|
||||||
$(MAKE) -C hello3 src_only
|
$(MAKE) -C hello3 src_only
|
||||||
$(MAKE) -C hello4 src_only
|
$(MAKE) -C hello4 src_only
|
||||||
$(MAKE) -C hello5 src_only
|
$(MAKE) -C hello5 src_only
|
||||||
$(MAKE) -C winhelo src_only
|
$(MAKE) -C winhelo src_only
|
||||||
$(MAKE) -C winhelo2 src_only
|
$(MAKE) -C winhelo2 src_only
|
||||||
$(MAKE) -C winhelo3 src_only
|
$(MAKE) -C winhelo3 src_only
|
||||||
$(MAKE) -C star1 src_only
|
$(MAKE) -C star1 src_only
|
||||||
$(MAKE) -C stars src_only
|
$(MAKE) -C stars src_only
|
||||||
$(MAKE) -C stars2 src_only
|
$(MAKE) -C stars2 src_only
|
||||||
$(MAKE) -C lines src_only
|
$(MAKE) -C lines src_only
|
||||||
$(MAKE) -C walk src_only
|
$(MAKE) -C walk src_only
|
||||||
$(MAKE) -C noodle src_only
|
$(MAKE) -C noodle src_only
|
||||||
$(MAKE) -C beepdown src_only
|
$(MAKE) -C beepdown src_only
|
||||||
$(MAKE) -C color src_only
|
$(MAKE) -C color src_only
|
||||||
$(MAKE) -C color2 src_only
|
$(MAKE) -C color2 src_only
|
||||||
$(MAKE) -C sosu src_only
|
$(MAKE) -C sosu src_only
|
||||||
$(MAKE) -C sosu2 src_only
|
$(MAKE) -C sosu2 src_only
|
||||||
$(MAKE) -C sosu3 src_only
|
$(MAKE) -C sosu3 src_only
|
||||||
$(MAKE) -C type src_only
|
$(MAKE) -C type src_only
|
||||||
$(MAKE) -C iroha src_only
|
$(MAKE) -C iroha src_only
|
||||||
$(MAKE) -C chklang src_only
|
$(MAKE) -C chklang src_only
|
||||||
$(MAKE) -C notrec src_only
|
$(MAKE) -C notrec src_only
|
||||||
|
$(MAKE) -C bball src_only
|
||||||
|
$(MAKE) -C invader src_only
|
||||||
-$(DEL) haribote.img
|
-$(DEL) haribote.img
|
||||||
|
|
||||||
refresh :
|
refresh :
|
||||||
|
|||||||
Binary file not shown.
1
29_day/bball/!cons_9x.bat
Normal file
1
29_day/bball/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
command
|
||||||
1
29_day/bball/!cons_nt.bat
Normal file
1
29_day/bball/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cmd.exe
|
||||||
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
29_day/bball/make.bat
Normal file
1
29_day/bball/make.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
@@ -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);
|
sht = (struct SHEET *) (ebx & 0xfffffffe);
|
||||||
hrb_api_linewin(sht, eax, ecx, esi, edi, ebp);
|
hrb_api_linewin(sht, eax, ecx, esi, edi, ebp);
|
||||||
if ((ebx & 1) == 0) {
|
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);
|
sheet_refresh(sht, eax, ecx, esi + 1, edi + 1);
|
||||||
}
|
}
|
||||||
} else if (edx == 14) {
|
} else if (edx == 14) {
|
||||||
|
|||||||
Binary file not shown.
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
|
||||||
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
|
||||||
19
30_day/beepdown/beepdown.c
Normal file
19
30_day/beepdown/beepdown.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "apilib.h"
|
||||||
|
|
||||||
|
void HariMain(void)
|
||||||
|
{
|
||||||
|
int i, timer;
|
||||||
|
timer = api_alloctimer();
|
||||||
|
api_inittimer(timer, 128);
|
||||||
|
for (i = 20000000; i >= 20000; i -= i / 100) {
|
||||||
|
/* 20KHz~20Hz,即人类可以听到的声音范围*/
|
||||||
|
/* i以1%的速度递减*/
|
||||||
|
api_beep(i);
|
||||||
|
api_settimer(timer, 1); /* 0.01秒*/
|
||||||
|
if (api_getkey(1) != 128) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
api_beep(0);
|
||||||
|
api_end();
|
||||||
|
}
|
||||||
1
30_day/beepdown/make.bat
Normal file
1
30_day/beepdown/make.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
1
30_day/calc/!cons_9x.bat
Normal file
1
30_day/calc/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
command
|
||||||
1
30_day/calc/!cons_nt.bat
Normal file
1
30_day/calc/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cmd.exe
|
||||||
5
30_day/calc/Makefile
Normal file
5
30_day/calc/Makefile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
APP = calc
|
||||||
|
STACK = 4k
|
||||||
|
MALLOC = 0k
|
||||||
|
|
||||||
|
include ../app_make.txt
|
||||||
163
30_day/calc/calc.c
Normal file
163
30_day/calc/calc.c
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
#include "apilib.h"
|
||||||
|
#include <stdio.h> /* sprintf */
|
||||||
|
|
||||||
|
#define INVALID -0x7fffffff
|
||||||
|
|
||||||
|
int strtol(char *s, char **endp, int base); /* 标准函数 <stdlib.h> */
|
||||||
|
|
||||||
|
char *skipspace(char *p);
|
||||||
|
int getnum(char **pp, int priority);
|
||||||
|
|
||||||
|
void HariMain(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char s[30], *p;
|
||||||
|
|
||||||
|
api_cmdline(s, 30);
|
||||||
|
for (p = s; *p > ' '; p++) { } /* 一直读到空格为止 */
|
||||||
|
i = getnum(&p, 9);
|
||||||
|
if (i == INVALID) {
|
||||||
|
api_putstr0("error!\n");
|
||||||
|
} else {
|
||||||
|
sprintf(s, "= %d = 0x%x\n", i, i);
|
||||||
|
api_putstr0(s);
|
||||||
|
}
|
||||||
|
api_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
char *skipspace(char *p)
|
||||||
|
{
|
||||||
|
for (; *p == ' '; p++) { } /* 将空格跳过去 */
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getnum(char **pp, int priority)
|
||||||
|
{
|
||||||
|
char *p = *pp;
|
||||||
|
int i = INVALID, j;
|
||||||
|
p = skipspace(p);
|
||||||
|
|
||||||
|
/*单项运算符*/
|
||||||
|
if (*p == '+') {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
i = getnum(&p, 0);
|
||||||
|
} else if (*p == '-') {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
i = getnum(&p, 0);
|
||||||
|
if (i != INVALID) {
|
||||||
|
i = - i;
|
||||||
|
}
|
||||||
|
} else if (*p == '~') {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
i = getnum(&p, 0);
|
||||||
|
if (i != INVALID) {
|
||||||
|
i = ~i;
|
||||||
|
}
|
||||||
|
} else if (*p == '(') { /*括号*/
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
i = getnum(&p, 9);
|
||||||
|
if (*p == ')') {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
} else {
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
} else if ('0' <= *p && *p <= '9') { /*数值*/
|
||||||
|
i = strtol(p, &p, 0);
|
||||||
|
} else { /*错误 */
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*二项运算符*/
|
||||||
|
for (;;) {
|
||||||
|
if (i == INVALID) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p = skipspace(p);
|
||||||
|
if (*p == '+' && priority > 2) {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
j = getnum(&p, 2);
|
||||||
|
if (j != INVALID) {
|
||||||
|
i += j;
|
||||||
|
} else {
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
} else if (*p == '-' && priority > 2) {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
j = getnum(&p, 2);
|
||||||
|
if (j != INVALID) {
|
||||||
|
i -= j;
|
||||||
|
} else {
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
} else if (*p == '*' && priority > 1) {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
j = getnum(&p, 1);
|
||||||
|
if (j != INVALID) {
|
||||||
|
i *= j;
|
||||||
|
} else {
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
} else if (*p == '/' && priority > 1) {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
j = getnum(&p, 1);
|
||||||
|
if (j != INVALID && j != 0) {
|
||||||
|
i /= j;
|
||||||
|
} else {
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
} else if (*p == '%' && priority > 1) {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
j = getnum(&p, 1);
|
||||||
|
if (j != INVALID && j != 0) {
|
||||||
|
i %= j;
|
||||||
|
} else {
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
} else if (*p == '<' && p[1] == '<' && priority > 3) {
|
||||||
|
p = skipspace(p + 2);
|
||||||
|
j = getnum(&p, 3);
|
||||||
|
if (j != INVALID && j != 0) {
|
||||||
|
i <<= j;
|
||||||
|
} else {
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
} else if (*p == '>' && p[1] == '>' && priority > 3) {
|
||||||
|
p = skipspace(p + 2);
|
||||||
|
j = getnum(&p, 3);
|
||||||
|
if (j != INVALID && j != 0) {
|
||||||
|
i >>= j;
|
||||||
|
} else {
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
} else if (*p == '&' && priority > 4) {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
j = getnum(&p, 4);
|
||||||
|
if (j != INVALID) {
|
||||||
|
i &= j;
|
||||||
|
} else {
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
} else if (*p == '^' && priority > 5) {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
j = getnum(&p, 5);
|
||||||
|
if (j != INVALID) {
|
||||||
|
i ^= j;
|
||||||
|
} else {
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
} else if (*p == '|' && priority > 6) {
|
||||||
|
p = skipspace(p + 1);
|
||||||
|
j = getnum(&p, 6);
|
||||||
|
if (j != INVALID) {
|
||||||
|
i |= j;
|
||||||
|
} else {
|
||||||
|
i = INVALID;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = skipspace(p);
|
||||||
|
*pp = p;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
1
30_day/calc/make.bat
Normal file
1
30_day/calc/make.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
1
30_day/chklang/!cons_9x.bat
Normal file
1
30_day/chklang/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
command
|
||||||
1
30_day/chklang/!cons_nt.bat
Normal file
1
30_day/chklang/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cmd.exe
|
||||||
5
30_day/chklang/Makefile
Normal file
5
30_day/chklang/Makefile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
APP = chklang
|
||||||
|
STACK = 1k
|
||||||
|
MALLOC = 0k
|
||||||
|
|
||||||
|
include ../app_make.txt
|
||||||
24
30_day/chklang/chklang.c
Normal file
24
30_day/chklang/chklang.c
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include "apilib.h"
|
||||||
|
|
||||||
|
void HariMain(void)
|
||||||
|
{
|
||||||
|
int langmode = api_getlang();
|
||||||
|
static char s1[23] = { /* 日本語シフトJISモード(日文Shift-JIS模式)*/
|
||||||
|
0x93, 0xfa, 0x96, 0x7b, 0x8c, 0xea, 0x83, 0x56, 0x83, 0x74, 0x83, 0x67,
|
||||||
|
0x4a, 0x49, 0x53, 0x83, 0x82, 0x81, 0x5b, 0x83, 0x68, 0x0a, 0x00
|
||||||
|
};
|
||||||
|
static char s2[17] = { /*日本語EUCモード(日文EUC模式)*/
|
||||||
|
0xc6, 0xfc, 0xcb, 0xdc, 0xb8, 0xec, 0x45, 0x55, 0x43, 0xa5, 0xe2, 0xa1,
|
||||||
|
0xbc, 0xa5, 0xc9, 0x0a, 0x00
|
||||||
|
};
|
||||||
|
if (langmode == 0) {
|
||||||
|
api_putstr0("English ASCII mode\n");
|
||||||
|
}
|
||||||
|
if (langmode == 1) {
|
||||||
|
api_putstr0(s1);
|
||||||
|
}
|
||||||
|
if (langmode == 2) {
|
||||||
|
api_putstr0(s2);
|
||||||
|
}
|
||||||
|
api_end();
|
||||||
|
}
|
||||||
1
30_day/chklang/make.bat
Normal file
1
30_day/chklang/make.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
1
30_day/color/!cons_9x.bat
Normal file
1
30_day/color/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
command
|
||||||
1
30_day/color/!cons_nt.bat
Normal file
1
30_day/color/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cmd.exe
|
||||||
5
30_day/color/Makefile
Normal file
5
30_day/color/Makefile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
APP = color
|
||||||
|
STACK = 1k
|
||||||
|
MALLOC = 56k
|
||||||
|
|
||||||
|
include ../app_make.txt
|
||||||
21
30_day/color/color.c
Normal file
21
30_day/color/color.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include "apilib.h"
|
||||||
|
|
||||||
|
void HariMain(void)
|
||||||
|
{
|
||||||
|
char *buf;
|
||||||
|
int win, x, y, r, g, b;
|
||||||
|
api_initmalloc();
|
||||||
|
buf = api_malloc(144 * 164);
|
||||||
|
win = api_openwin(buf, 144, 164, -1, "color");
|
||||||
|
for (y = 0; y < 128; y++) {
|
||||||
|
for (x = 0; x < 128; x++) {
|
||||||
|
r = x * 2;
|
||||||
|
g = y * 2;
|
||||||
|
b = 0;
|
||||||
|
buf[(x + 8) + (y + 28) * 144] = 16 + (r / 43) + (g / 43) * 6 + (b / 43) * 36;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
api_refreshwin(win, 8, 28, 136, 156);
|
||||||
|
api_getkey(1); /*等待按下任意键*/
|
||||||
|
api_end();
|
||||||
|
}
|
||||||
1
30_day/color/make.bat
Normal file
1
30_day/color/make.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
1
30_day/color2/!cons_9x.bat
Normal file
1
30_day/color2/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
command
|
||||||
1
30_day/color2/!cons_nt.bat
Normal file
1
30_day/color2/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cmd.exe
|
||||||
5
30_day/color2/Makefile
Normal file
5
30_day/color2/Makefile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
APP = color2
|
||||||
|
STACK = 1k
|
||||||
|
MALLOC = 56k
|
||||||
|
|
||||||
|
include ../app_make.txt
|
||||||
36
30_day/color2/color2.c
Normal file
36
30_day/color2/color2.c
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#include "apilib.h"
|
||||||
|
|
||||||
|
unsigned char rgb2pal(int r, int g, int b, int x, int y);
|
||||||
|
|
||||||
|
void HariMain(void)
|
||||||
|
{
|
||||||
|
char *buf;
|
||||||
|
int win, x, y;
|
||||||
|
api_initmalloc();
|
||||||
|
buf = api_malloc(144 * 164);
|
||||||
|
win = api_openwin(buf, 144, 164, -1, "color2");
|
||||||
|
for (y = 0; y < 128; y++) {
|
||||||
|
for (x = 0; x < 128; x++) {
|
||||||
|
buf[(x + 8) + (y + 28) * 144] = rgb2pal(x * 2, y * 2, 0, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
api_refreshwin(win, 8, 28, 136, 156);
|
||||||
|
api_getkey(1); /* <20>Ă<EFBFBD><C482>Ƃ<EFBFBD><C682>ȃL<C883>[<5B><><EFBFBD>͂<EFBFBD>҂<EFBFBD> */
|
||||||
|
api_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char rgb2pal(int r, int g, int b, int x, int y)
|
||||||
|
{
|
||||||
|
static int table[4] = { 3, 1, 0, 2 };
|
||||||
|
int i;
|
||||||
|
x &= 1; /*判断是偶数还是奇数*/
|
||||||
|
y &= 1;
|
||||||
|
i = table[x + y * 2]; /*用来生成中间色的常量*/
|
||||||
|
r = (r * 21) / 256; /* r为0~20*/
|
||||||
|
g = (g * 21) / 256;
|
||||||
|
b = (b * 21) / 256;
|
||||||
|
r = (r + i) / 4; /* r为0~5*/
|
||||||
|
g = (g + i) / 4;
|
||||||
|
b = (b + i) / 4;
|
||||||
|
return 16 + r + g * 6 + b * 36;
|
||||||
|
}
|
||||||
1
30_day/color2/make.bat
Normal file
1
30_day/color2/make.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
1
30_day/euc.txt
Normal file
1
30_day/euc.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
日本語EUCで書いてみたよー
|
||||||
1
30_day/gview/!cons_9x.bat
Normal file
1
30_day/gview/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
command
|
||||||
1
30_day/gview/!cons_nt.bat
Normal file
1
30_day/gview/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cmd.exe
|
||||||
90
30_day/gview/Makefile
Normal file
90
30_day/gview/Makefile
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
APP = gview
|
||||||
|
STACK = 4480k
|
||||||
|
MALLOC = 0k
|
||||||
|
|
||||||
|
TOOLPATH = ../../z_tools/
|
||||||
|
INCPATH = ../../z_tools/haribote/
|
||||||
|
APILIBPATH = ../apilib/
|
||||||
|
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 bmp.obj jpeg.obj $(APILIBPATH)apilib.lib Makefile
|
||||||
|
$(OBJ2BIM) @$(RULEFILE) out:$(APP).bim map:$(APP).map stack:$(STACK) \
|
||||||
|
$(APP).obj jpeg.obj bmp.obj $(APILIBPATH)apilib.lib
|
||||||
|
|
||||||
|
haribote.img : ../haribote/ipl20.bin ../haribote/haribote.sys $(APP).hrb \
|
||||||
|
Makefile
|
||||||
|
$(EDIMG) imgin:../../z_tools/fdimg0at.tek \
|
||||||
|
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
|
||||||
|
$(CC1) -o $*.gas $*.c
|
||||||
|
|
||||||
|
%.nas : %.gas Makefile
|
||||||
|
$(GAS2NASK) $*.gas $*.nas
|
||||||
|
|
||||||
|
%.obj : %.nas Makefile
|
||||||
|
$(NASK) $*.nas $*.obj $*.lst
|
||||||
|
|
||||||
|
%.org : %.bim Makefile
|
||||||
|
$(BIM2HRB) $*.bim $*.org $(MALLOC)
|
||||||
|
|
||||||
|
%.hrb : %.org Makefile
|
||||||
|
$(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) $(APP).hrb
|
||||||
|
|
||||||
|
run_full :
|
||||||
|
$(MAKE) -C $(APILIBPATH)
|
||||||
|
$(MAKE) -C ../haribote
|
||||||
|
$(MAKE) run
|
||||||
|
|
||||||
|
clean :
|
||||||
|
-$(DEL) *.lst
|
||||||
|
-$(DEL) gview.obj
|
||||||
|
-$(DEL) jpeg.obj
|
||||||
|
-$(DEL) *.map
|
||||||
|
-$(DEL) *.bim
|
||||||
|
-$(DEL) *.org
|
||||||
|
-$(DEL) haribote.img
|
||||||
|
|
||||||
|
src_only :
|
||||||
|
$(MAKE) clean
|
||||||
|
-$(DEL) $(APP).hrb
|
||||||
646
30_day/gview/bmp.nasm
Normal file
646
30_day/gview/bmp.nasm
Normal file
@@ -0,0 +1,646 @@
|
|||||||
|
; BMP decode routine by I.Tak. 2003
|
||||||
|
|
||||||
|
section .text align=1
|
||||||
|
[bits 32]
|
||||||
|
;BMP File Structure (I can't understand MS.)
|
||||||
|
|
||||||
|
struc BMP
|
||||||
|
;FILE HEADER
|
||||||
|
.fType: resw 1 ;BM
|
||||||
|
.fSize: resd 1 ;whole file size
|
||||||
|
resd 1 ;reserved
|
||||||
|
.fOffBits: resd 1 ;offset from file top to image
|
||||||
|
;INFO HEADER
|
||||||
|
.iSize: resd 1 ;INFO HEADER size
|
||||||
|
.iWidth: resd 1 ;Image Width in pixels
|
||||||
|
.iHeight: resd 1 ;Image Height in pixels
|
||||||
|
.iPlanes: resw 1 ;must be 1
|
||||||
|
.iBitCount: resw 1 ;BitPerPixel 1, 4, 8, 24 (and 15,16 for new OS/2 ?)
|
||||||
|
.iCompression: resd 1 ;Compress Type. 0 for none, then SizeImage=0
|
||||||
|
.iSizeImage: resd 1 ;Image Size(compressed)
|
||||||
|
.iXPPM: resd 1 ;X Pixel Per Meter
|
||||||
|
.iYPPM: resd 1
|
||||||
|
.iClrUsed: resd 1 ;Number of used ColorQuad (0 for whole Quad)
|
||||||
|
.iClrImportant: resd 1 ;Number of Important ColorQuad.
|
||||||
|
endstruc
|
||||||
|
|
||||||
|
struc BMPOS2
|
||||||
|
;FILE HEADER
|
||||||
|
.fType: resw 1 ;BM
|
||||||
|
.fSize: resd 1 ;whole file size
|
||||||
|
resd 1 ;reserved
|
||||||
|
.fOffBits: resd 1 ;offset from file top to image
|
||||||
|
;CORE HEADER
|
||||||
|
.iSize: resd 1 ;CORE HEADER size
|
||||||
|
.iWidth: resw 1 ;Image Width in pixels
|
||||||
|
.iHeight: resw 1 ;Image Height in pixels
|
||||||
|
.iPlanes: resw 1 ;must be 1
|
||||||
|
.iBitCount: resw 1 ;BitPerPixel 1, 4, 8, 24 (and 15,16 for new OS/2 ?)
|
||||||
|
endstruc
|
||||||
|
|
||||||
|
; B/W bmp can also have palettes. The first for 0, second for 1.
|
||||||
|
|
||||||
|
struc CQuad
|
||||||
|
.b: resb 1
|
||||||
|
.g: resb 1
|
||||||
|
.r: resb 1
|
||||||
|
resb 1 ;reserved
|
||||||
|
endstruc
|
||||||
|
|
||||||
|
|
||||||
|
%if 0
|
||||||
|
int info_BMP(struct DLL_STRPICENV *env, int *info, int size, UCHAR *fp);
|
||||||
|
/* 成功したら1 (非0?), 失敗したら0 */
|
||||||
|
int decode0_BMP(struct DLL_STRPICENV *env, int size, UCHAR *fp,
|
||||||
|
int b_type, UCHAR *buf, int skip);
|
||||||
|
/* エラーコードを返す。とりあえず非0にしてるだけ */
|
||||||
|
envは64KBのワークエリアである。先頭8dwは返り値用になっている。
|
||||||
|
揮発性らしく, インスタンス変数的には使えないようだ。JPEG_initで
|
||||||
|
base_imgを作るのはdecodeのときだけでいいと思う。
|
||||||
|
%endif
|
||||||
|
|
||||||
|
[absolute 0] ;naskなら[section .bss] org 0 かな win32だからダメか
|
||||||
|
bmpinfo:
|
||||||
|
.regs: resd 4
|
||||||
|
.reteip: resd 1
|
||||||
|
.env: resd 1
|
||||||
|
.info: resd 1
|
||||||
|
.size: resd 1
|
||||||
|
.module: resd 1
|
||||||
|
[absolute 0]
|
||||||
|
info:
|
||||||
|
.type: resd 1 ;1 for BMP, 2 for JPEG
|
||||||
|
resd 1 ;0
|
||||||
|
.width: resd 1
|
||||||
|
.height: resd 1
|
||||||
|
[section .text]
|
||||||
|
[global _info_BMP]
|
||||||
|
_info_BMP:
|
||||||
|
push ebx
|
||||||
|
push ebp
|
||||||
|
push esi
|
||||||
|
push edi
|
||||||
|
mov esi, [esp+bmpinfo.module]
|
||||||
|
mov eax, [esp+bmpinfo.size]
|
||||||
|
call bmpHeader
|
||||||
|
test edi, edi
|
||||||
|
jz .ret
|
||||||
|
mov esi, [esp+bmpinfo.info]
|
||||||
|
mov [esi+info.width], eax
|
||||||
|
mov [esi+info.height], ecx
|
||||||
|
mov [esi+info.type], edi ;=1
|
||||||
|
dec edi
|
||||||
|
mov [esi+info.type+4], edi ;=0
|
||||||
|
inc edi
|
||||||
|
.ret: mov eax, edi
|
||||||
|
pop edi
|
||||||
|
pop esi
|
||||||
|
pop ebp
|
||||||
|
pop ebx
|
||||||
|
ret
|
||||||
|
|
||||||
|
;in: esi=module, eax=size
|
||||||
|
;ret:eax=width, ecx=hegiht, edx=paletteSize, ebx=palette
|
||||||
|
; ebp=bpp, esi=endOfImage, edi=successFlag
|
||||||
|
bmpHeader:
|
||||||
|
lea edx, [esi+eax] ;moduleEnd
|
||||||
|
xor edi, edi
|
||||||
|
push edx
|
||||||
|
xor edx, edx
|
||||||
|
|
||||||
|
cmp eax, byte BMP.iSize+4
|
||||||
|
jbe ..@ret ;中継してしまう
|
||||||
|
cmp word[esi],'BM'
|
||||||
|
je .notMAC
|
||||||
|
sub esi, byte -128
|
||||||
|
add eax, byte -128
|
||||||
|
pop ebx
|
||||||
|
push eax
|
||||||
|
cmp eax, byte BMP.iSize+4
|
||||||
|
..@ret: jbe .ret
|
||||||
|
cmp word[esi], 'BM'
|
||||||
|
jne .ret
|
||||||
|
.notMAC:
|
||||||
|
;;MS,OS/2 フォーマット確認
|
||||||
|
mov ecx, [esi +BMP.iSize]
|
||||||
|
cmp ecx, byte 12 ;OS/2 format.
|
||||||
|
jne .MS
|
||||||
|
cmp eax, byte BMPOS2_size
|
||||||
|
jbe .ret ;coreヘッダなし
|
||||||
|
lea ebx, [esi+ecx+14] ;palette
|
||||||
|
movzx eax, word[esi+BMPOS2.iWidth] ;width
|
||||||
|
movzx ecx, word[esi+BMPOS2.iHeight] ;height
|
||||||
|
movzx ebp, word[esi+BMPOS2.iBitCount] ;bpp
|
||||||
|
mov dl, 3 ;paletteSize
|
||||||
|
jmp short .endif
|
||||||
|
.MS: cmp eax, byte BMP_size
|
||||||
|
jbe .ret ;infoヘッダなし
|
||||||
|
lea ebx, [esi+ecx+14]
|
||||||
|
sub ecx,byte 40
|
||||||
|
jne .ret ;unknownFormat
|
||||||
|
cmp ecx, [esi+BMP.iCompression]
|
||||||
|
jne .ret ;Compressed.
|
||||||
|
mov eax, [esi+BMP.iWidth] ;width
|
||||||
|
mov ecx, [esi+BMP.iHeight] ;height
|
||||||
|
movzx ebp, word[esi +BMP.iBitCount] ;bpp
|
||||||
|
mov dl, 4 ;paletteSize
|
||||||
|
.endif:
|
||||||
|
add esi, [esi +BMP.fOffBits]
|
||||||
|
|
||||||
|
;sizeが小さい場合heightを削ってで<E381A6>
|
||||||
|
;読めると答えるべきだろう。今はエラー
|
||||||
|
push edx
|
||||||
|
push eax
|
||||||
|
mul ebp ;eax=width*bpp
|
||||||
|
add eax, byte 7
|
||||||
|
shr eax, 3 ;lineSizeWithoutPudding
|
||||||
|
mov edx, eax
|
||||||
|
add eax, byte 3 ;size<1GBを仮定してedxを無<E38292>
|
||||||
|
and al, -4 ;lineSizeWithPudding
|
||||||
|
sub edx, eax ;-puddingSize
|
||||||
|
push edx
|
||||||
|
mul ecx
|
||||||
|
pop edx
|
||||||
|
add esi, eax
|
||||||
|
add esi, edx ;最終行の最後にはpuddingがないと見るべき
|
||||||
|
cmp esi, [esp+8] ;endOfModule
|
||||||
|
pop eax
|
||||||
|
ja .ret2
|
||||||
|
sub esi, edx ;esi=endOfImage
|
||||||
|
inc edi ;succeeded!
|
||||||
|
.ret2: pop edx
|
||||||
|
.ret: add esp, byte 4
|
||||||
|
ret
|
||||||
|
|
||||||
|
;***************************************************************
|
||||||
|
; 小ささ優先で作っているが, 速さ優先で作った昔のよりいいかも。
|
||||||
|
; 品質最低の高速モードのみ作ってい<E381A6>
|
||||||
|
|
||||||
|
[absolute 0]
|
||||||
|
decode:
|
||||||
|
.regs: resd 4
|
||||||
|
.reteip: resd 1
|
||||||
|
.env: resd 1
|
||||||
|
.size: resd 1
|
||||||
|
.module: resd 1
|
||||||
|
.outputType: resd 1
|
||||||
|
.dest: resd 1
|
||||||
|
.skip: resd 1
|
||||||
|
[section .text]
|
||||||
|
[global _decode0_BMP]
|
||||||
|
_decode0_BMP:
|
||||||
|
push ebx
|
||||||
|
push ebp
|
||||||
|
push esi
|
||||||
|
push edi
|
||||||
|
mov esi, [esp+decode.module]
|
||||||
|
mov eax, [esp+decode.size]
|
||||||
|
call bmpHeader
|
||||||
|
;ret:eax=width, ecx=hegiht, edx=paletteSize, ebx=palette
|
||||||
|
; ebp=bpp, esi=endOfImage, edi=successFlag
|
||||||
|
test edi,edi
|
||||||
|
jz .error
|
||||||
|
mov edi, [esp+decode.dest]
|
||||||
|
push dword[esp+decode.outputType]
|
||||||
|
push dword[esp+4+decode.skip]
|
||||||
|
push ecx ;height
|
||||||
|
push eax
|
||||||
|
push edx
|
||||||
|
mul ebp
|
||||||
|
add eax, byte 31
|
||||||
|
shr eax, 3
|
||||||
|
and al, -4
|
||||||
|
push eax
|
||||||
|
mov edx, ebp
|
||||||
|
mov ebp, esp
|
||||||
|
call bmp2beta ;ecx!=0 for error
|
||||||
|
add esp, byte bb.size
|
||||||
|
mov eax, ecx
|
||||||
|
test ecx, ecx
|
||||||
|
jz .ret
|
||||||
|
.error: push byte 1
|
||||||
|
pop eax
|
||||||
|
.ret: pop edi
|
||||||
|
pop esi
|
||||||
|
pop ebp
|
||||||
|
pop ebx
|
||||||
|
ret
|
||||||
|
|
||||||
|
[absolute -4*2]
|
||||||
|
bb:
|
||||||
|
.col0: resd 1 ;bpp1で使う
|
||||||
|
.reteip: resd 1
|
||||||
|
.sw: resd 1 ;byte
|
||||||
|
.paletteSize: resd 1 ;byte
|
||||||
|
.w: resd 1 ;pixel
|
||||||
|
.h: resd 1
|
||||||
|
.s: resd 1
|
||||||
|
.t: resd 1
|
||||||
|
.size: equ $-$$
|
||||||
|
[section .text]
|
||||||
|
;eax=?, ecx=height, edx=bpp, ebx=palette
|
||||||
|
;ebp=bb, esi=endOfImage, edi=dest
|
||||||
|
bmp2beta:
|
||||||
|
mov al, [ebp+bb.t]
|
||||||
|
and al, 0x7f
|
||||||
|
cmp al, 2
|
||||||
|
je near buf16
|
||||||
|
cmp al, 4
|
||||||
|
je buf32
|
||||||
|
mov ecx, esp ;!=0
|
||||||
|
ret
|
||||||
|
;===============================================================
|
||||||
|
; Buffer mode 4
|
||||||
|
;===============================================================
|
||||||
|
buf32:
|
||||||
|
dec edx
|
||||||
|
je near .bpp1
|
||||||
|
sub edx, byte 4-1
|
||||||
|
je .bpp4
|
||||||
|
sub edx, byte 8-4
|
||||||
|
je .bpp8
|
||||||
|
sub edx, byte 24-8
|
||||||
|
je .bpp24
|
||||||
|
mov ecx, esp ;!=0
|
||||||
|
ret
|
||||||
|
;---------------------------------------------------
|
||||||
|
; 24bpp BMP to 4byte bufer
|
||||||
|
;---------------------------------------------------
|
||||||
|
.bpp24:
|
||||||
|
;ecx=height, edx=0, ebx=palette
|
||||||
|
;esi=endOfImage, edi=destinationBuffer
|
||||||
|
;bb.w=width(pixel), bb.s=skipByte, bb.h=height
|
||||||
|
;bb.t=outputType, bb.sw=sourceWidthByte
|
||||||
|
|
||||||
|
.do24.1:
|
||||||
|
sub esi, [ebp+bb.sw] ;esi=startOfLine
|
||||||
|
push ecx
|
||||||
|
push esi
|
||||||
|
mov ecx, [ebp+bb.w]
|
||||||
|
.do24.2:
|
||||||
|
mov al, [esi]
|
||||||
|
mov [edi+3], dl
|
||||||
|
mov [edi], al
|
||||||
|
mov al, [esi+1]
|
||||||
|
mov [edi+1], al
|
||||||
|
mov al, [esi+2]
|
||||||
|
mov [edi+2], al
|
||||||
|
add esi, byte 3
|
||||||
|
add edi, byte 4
|
||||||
|
dec ecx
|
||||||
|
jnz .do24.2
|
||||||
|
pop esi
|
||||||
|
pop ecx
|
||||||
|
add edi, [ebp+bb.s]
|
||||||
|
dec ecx
|
||||||
|
jnz .do24.1
|
||||||
|
ret
|
||||||
|
|
||||||
|
;---------------------------------------------------
|
||||||
|
; 8bpp BMP to 4byte buffer
|
||||||
|
;---------------------------------------------------
|
||||||
|
.bpp8:
|
||||||
|
;ecx=height, edx=0, ebx=palette
|
||||||
|
;esi=endOfImage, edi=destinationBuffer
|
||||||
|
|
||||||
|
;pallete変換
|
||||||
|
mov dl, 255
|
||||||
|
mov eax, [ebp+bb.paletteSize]
|
||||||
|
sub ebx, eax
|
||||||
|
shl eax, 8
|
||||||
|
add ebx, eax ;ebx += paletteSize*255
|
||||||
|
.do8.1:
|
||||||
|
mov eax, [ebx]
|
||||||
|
sub ebx, [ebp+bb.paletteSize]
|
||||||
|
and eax, 0x00ffffff
|
||||||
|
dec edx
|
||||||
|
push eax
|
||||||
|
jns .do8.1
|
||||||
|
|
||||||
|
.do8.2:
|
||||||
|
sub esi, [ebp+bb.sw] ;esi=firstLineStart
|
||||||
|
push ecx
|
||||||
|
push esi
|
||||||
|
mov ecx, [ebp+bb.w]
|
||||||
|
.do8.3:
|
||||||
|
xor eax, eax
|
||||||
|
add edi, byte 4
|
||||||
|
mov al, [esi]
|
||||||
|
inc esi
|
||||||
|
;AGI stole
|
||||||
|
mov eax, [esp+eax*4+8]
|
||||||
|
dec ecx
|
||||||
|
mov [edi-4], eax
|
||||||
|
jnz .do8.3
|
||||||
|
pop esi
|
||||||
|
pop ecx
|
||||||
|
add edi, [ebp+bb.s]
|
||||||
|
dec ecx
|
||||||
|
jnz .do8.2
|
||||||
|
add esp, 256*4 ;palette
|
||||||
|
ret
|
||||||
|
|
||||||
|
;---------------------------------------------------
|
||||||
|
; 4bpp BMP to 4byte buffer
|
||||||
|
;---------------------------------------------------
|
||||||
|
.bpp4:
|
||||||
|
;ecx=height, edx=0, ebx=palette
|
||||||
|
;esi=endOfImage, edi=destinationBuffer
|
||||||
|
|
||||||
|
;pallete変換
|
||||||
|
mov dl, 16
|
||||||
|
mov eax, [ebp+bb.paletteSize]
|
||||||
|
sub ebx, eax
|
||||||
|
shl eax, 4
|
||||||
|
add ebx, eax ;ebx+=eax*15
|
||||||
|
.do4.1
|
||||||
|
mov eax, [ebx]
|
||||||
|
sub ebx, [ebp+bb.paletteSize]
|
||||||
|
and eax, 0x00ffffff
|
||||||
|
dec edx
|
||||||
|
push eax
|
||||||
|
jnz .do4.1
|
||||||
|
|
||||||
|
.do4.2:
|
||||||
|
sub esi, [ebp+bb.sw] ;esi=firstLineStart
|
||||||
|
push ecx
|
||||||
|
push esi
|
||||||
|
mov ecx, [ebp+bb.w]
|
||||||
|
.do4.3:
|
||||||
|
xor edx, edx
|
||||||
|
mov al, [esi]
|
||||||
|
mov dl, al
|
||||||
|
inc esi
|
||||||
|
shr dl, 4
|
||||||
|
and eax, byte 15
|
||||||
|
add edi, byte 4
|
||||||
|
dec ecx
|
||||||
|
mov edx, [esp+edx*4+8]
|
||||||
|
mov eax, [esp+eax*4+8]
|
||||||
|
mov [edi-4], edx
|
||||||
|
jz .wend
|
||||||
|
mov [edi], eax
|
||||||
|
add edi, byte 4
|
||||||
|
dec ecx
|
||||||
|
jnz .do4.3
|
||||||
|
.wend: pop esi
|
||||||
|
pop ecx
|
||||||
|
add edi, [ebp+bb.s]
|
||||||
|
dec ecx
|
||||||
|
jnz .do4.2
|
||||||
|
add esp, 16*4 ;palette
|
||||||
|
ret
|
||||||
|
|
||||||
|
;---------------------------------------------------
|
||||||
|
; 1bpp BMP to 4byte buffer
|
||||||
|
;---------------------------------------------------
|
||||||
|
.bpp1:
|
||||||
|
;ecx=height, edx=0, ebx=palette
|
||||||
|
;esi=endOfImage, edi=destinationBuffer
|
||||||
|
|
||||||
|
;pallete変換
|
||||||
|
mov eax, [ebx]
|
||||||
|
add ebx, [ebp+bb.paletteSize]
|
||||||
|
and eax, 0x00ffffff
|
||||||
|
mov ebx, [ebx]
|
||||||
|
and ebx, 0x00ffffff
|
||||||
|
xor ebx, eax
|
||||||
|
;push ebx
|
||||||
|
push eax
|
||||||
|
|
||||||
|
.do1.1:
|
||||||
|
sub esi, [ebp+bb.sw] ;esi=firstLineStart
|
||||||
|
push ecx
|
||||||
|
push esi
|
||||||
|
mov ecx, [ebp+bb.w]
|
||||||
|
.do1.2:
|
||||||
|
mov dl, [esi]
|
||||||
|
inc esi
|
||||||
|
push esi
|
||||||
|
mov esi, 8
|
||||||
|
.do1.3:
|
||||||
|
add edi, byte 4
|
||||||
|
add dl, dl
|
||||||
|
sbb eax, eax
|
||||||
|
and eax, ebx
|
||||||
|
xor eax, [ebp+bb.col0]
|
||||||
|
dec ecx
|
||||||
|
mov [edi-4], eax
|
||||||
|
jz .wend1bpp
|
||||||
|
dec esi
|
||||||
|
jnz .do1.3
|
||||||
|
pop esi
|
||||||
|
jmp short .do1.2
|
||||||
|
.wend1bpp:pop ecx
|
||||||
|
pop esi
|
||||||
|
pop ecx
|
||||||
|
add edi, [ebp+bb.s]
|
||||||
|
dec ecx
|
||||||
|
jnz .do1.1
|
||||||
|
pop eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
;===============================================
|
||||||
|
; Buffer mode 2byte
|
||||||
|
;===============================================
|
||||||
|
buf16:
|
||||||
|
dec edx
|
||||||
|
je near .bpp1
|
||||||
|
sub edx, byte 4-1
|
||||||
|
je near .bpp4
|
||||||
|
sub edx, byte 8-4
|
||||||
|
je .bpp8
|
||||||
|
sub edx, byte 24-8
|
||||||
|
je .bpp24
|
||||||
|
mov ecx, esp
|
||||||
|
ret
|
||||||
|
;---------------------------------------------------
|
||||||
|
; 24bpp BMP to 2byte bufer
|
||||||
|
;---------------------------------------------------
|
||||||
|
.bpp24:
|
||||||
|
;ecx=height, edx=0, ebx=palette
|
||||||
|
;esi=endOfImage, edi=destinationBuffer
|
||||||
|
|
||||||
|
.do24.1:
|
||||||
|
sub esi, [ebp+bb.sw] ;esi=startOfLine
|
||||||
|
push ecx
|
||||||
|
push esi
|
||||||
|
mov ecx, [ebp+bb.w]
|
||||||
|
.do24.2:
|
||||||
|
mov al, [esi+2]
|
||||||
|
shl eax, 16
|
||||||
|
mov ax, [esi]
|
||||||
|
add esi, byte 3
|
||||||
|
;減色処理 eax=24bitColor, edx=work, ecx=counter, ebx=work
|
||||||
|
;川合さんの趣味で没ったルーチンを持ってくるもよし(ぉ
|
||||||
|
;誤差拡散ルーチンを持ってくるもよし
|
||||||
|
shr ah, 2 ;???????? RRRRRrrr 00GGGGGG BBBBBbbb
|
||||||
|
inc edi
|
||||||
|
shr eax, 3 ;000????? ???RRRRR rrr00GGG GGGBBBBB
|
||||||
|
shl ax, 5 ;000????? ???RRRRR GGGGGGBB BBB00000
|
||||||
|
inc edi
|
||||||
|
shr eax, 5 ;00000000 ???????? RRRRRGGG GGGBBBBB
|
||||||
|
dec ecx
|
||||||
|
mov [edi-2], ax
|
||||||
|
jnz .do24.2
|
||||||
|
pop esi
|
||||||
|
pop ecx
|
||||||
|
add edi, [ebp+bb.s]
|
||||||
|
dec ecx
|
||||||
|
jnz .do24.1
|
||||||
|
ret
|
||||||
|
|
||||||
|
;---------------------------------------------------
|
||||||
|
; 8bpp BMP to 2byte buffer
|
||||||
|
;---------------------------------------------------
|
||||||
|
.bpp8:
|
||||||
|
;ecx=height, edx=0, ebx=palette
|
||||||
|
;esi=endOfImage, edi=destinationBuffer
|
||||||
|
|
||||||
|
;pallete変換
|
||||||
|
mov dl, 255
|
||||||
|
mov eax, [ebp+bb.paletteSize]
|
||||||
|
sub ebx, eax
|
||||||
|
shl eax, 8
|
||||||
|
add ebx, eax ;ebx += paletteSize*255
|
||||||
|
.do8.1:
|
||||||
|
mov eax, [ebx]
|
||||||
|
sub ebx, [ebp+bb.paletteSize]
|
||||||
|
call .paletteConv
|
||||||
|
dec edx
|
||||||
|
push eax
|
||||||
|
jns .do8.1
|
||||||
|
|
||||||
|
.do8.2:
|
||||||
|
sub esi, [ebp+bb.sw] ;esi=firstLineStart
|
||||||
|
push ecx
|
||||||
|
push esi
|
||||||
|
mov ecx, [ebp+bb.w]
|
||||||
|
.do8.3:
|
||||||
|
xor eax, eax
|
||||||
|
add edi, byte 2
|
||||||
|
mov al, [esi]
|
||||||
|
inc esi
|
||||||
|
;AGI stole
|
||||||
|
mov eax, [esp+eax*4+8]
|
||||||
|
dec ecx
|
||||||
|
mov [edi-2], ax
|
||||||
|
jnz .do8.3
|
||||||
|
pop esi
|
||||||
|
pop ecx
|
||||||
|
add edi, [ebp+bb.s]
|
||||||
|
dec ecx
|
||||||
|
jnz .do8.2
|
||||||
|
add esp, 256*4 ;palette
|
||||||
|
ret
|
||||||
|
|
||||||
|
;---------------------------------------------------
|
||||||
|
; 4bpp BMP to 2byte buffer
|
||||||
|
;---------------------------------------------------
|
||||||
|
.bpp4:
|
||||||
|
;ecx=height, edx=0, ebx=palette
|
||||||
|
;esi=endOfImage, edi=destinationBuffer
|
||||||
|
|
||||||
|
;pallete変換
|
||||||
|
mov dl, 16
|
||||||
|
mov eax, [ebp+bb.paletteSize]
|
||||||
|
sub ebx, eax
|
||||||
|
shl eax, 4
|
||||||
|
add ebx, eax ;ebx+=eax*15
|
||||||
|
.do4.1:
|
||||||
|
mov eax, [ebx]
|
||||||
|
sub ebx, [ebp+bb.paletteSize]
|
||||||
|
call .paletteConv
|
||||||
|
dec edx
|
||||||
|
push eax
|
||||||
|
jnz .do4.1
|
||||||
|
|
||||||
|
.do4.2:
|
||||||
|
sub esi, [ebp+bb.sw] ;esi=firstLineStart
|
||||||
|
push ecx
|
||||||
|
push esi
|
||||||
|
mov ecx, [ebp+bb.w]
|
||||||
|
.do4.3:
|
||||||
|
xor edx, edx
|
||||||
|
mov al, [esi]
|
||||||
|
mov dl, al
|
||||||
|
inc esi
|
||||||
|
shr dl, 4
|
||||||
|
and eax, byte 15
|
||||||
|
add edi, byte 2
|
||||||
|
dec ecx
|
||||||
|
mov edx, [esp+edx*4+8]
|
||||||
|
mov eax, [esp+eax*4+8]
|
||||||
|
mov [edi-2], dx
|
||||||
|
jz .wend
|
||||||
|
mov [edi], ax
|
||||||
|
add edi, byte 2
|
||||||
|
dec ecx
|
||||||
|
jnz .do4.3
|
||||||
|
.wend: pop esi
|
||||||
|
pop ecx
|
||||||
|
add edi, [ebp+bb.s]
|
||||||
|
dec ecx
|
||||||
|
jnz .do4.2
|
||||||
|
add esp, 16*4 ;palette
|
||||||
|
ret
|
||||||
|
|
||||||
|
;---------------------------------------------------
|
||||||
|
; 1bpp BMP to 2byte buffer
|
||||||
|
;---------------------------------------------------
|
||||||
|
.bpp1:
|
||||||
|
;ecx=height, edx=0, ebx=palette
|
||||||
|
;esi=endOfImage, edi=destinationBuffer
|
||||||
|
|
||||||
|
;pallete変換
|
||||||
|
mov eax, [ebx]
|
||||||
|
add ebx, [ebp+bb.paletteSize]
|
||||||
|
call .paletteConv
|
||||||
|
push eax
|
||||||
|
mov eax, [ebx]
|
||||||
|
call .paletteConv
|
||||||
|
pop ebx
|
||||||
|
xchg eax, ebx
|
||||||
|
xor ebx, eax
|
||||||
|
push eax
|
||||||
|
|
||||||
|
.do1.1:
|
||||||
|
sub esi, [ebp+bb.sw] ;esi=firstLineStart
|
||||||
|
push ecx
|
||||||
|
push esi
|
||||||
|
mov ecx, [ebp+bb.w]
|
||||||
|
.do1.2:
|
||||||
|
mov dl, [esi]
|
||||||
|
inc esi
|
||||||
|
push esi
|
||||||
|
mov esi, 8
|
||||||
|
.do1.3:
|
||||||
|
add dl, dl
|
||||||
|
inc edi
|
||||||
|
sbb eax, eax
|
||||||
|
inc edi
|
||||||
|
and eax, ebx
|
||||||
|
xor eax, [ebp+bb.col0]
|
||||||
|
dec ecx
|
||||||
|
mov [edi-2], ax
|
||||||
|
jz .wend1bpp
|
||||||
|
dec esi
|
||||||
|
jnz .do1.3
|
||||||
|
pop esi
|
||||||
|
jmp short .do1.2
|
||||||
|
.wend1bpp:
|
||||||
|
pop ecx
|
||||||
|
pop esi
|
||||||
|
pop ecx
|
||||||
|
add edi, [ebp+bb.s]
|
||||||
|
dec ecx
|
||||||
|
jnz .do1.1
|
||||||
|
pop eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.paletteConv:
|
||||||
|
shr ah, 2
|
||||||
|
shr eax, 3
|
||||||
|
shl ax, 5
|
||||||
|
shr eax, 5
|
||||||
|
ret
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user