Compare commits

...

2 Commits

Author SHA1 Message Date
Yourtion
6b0457bed6 外星人游戏 2016-05-19 14:22:52 +08:00
Yourtion
0adab9385e bball 2016-05-19 14:13:37 +08:00
12 changed files with 393 additions and 43 deletions

View File

@@ -21,7 +21,8 @@ haribote.img : haribote/ipl20.bin haribote/haribote.sys Makefile \
lines/lines.hrb walk/walk.hrb noodle/noodle.hrb \
beepdown/beepdown.hrb color/color.hrb color2/color2.hrb \
sosu/sosu.hrb sosu2/sosu2.hrb sosu3/sosu3.hrb \
type/type.hrb iroha/iroha.hrb chklang/chklang.hrb
type/type.hrb iroha/iroha.hrb chklang/chklang.hrb \
notrec/notrec.hrb bball/bball.hrb invader/invader.hrb
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
wbinimg src:haribote/ipl20.bin len:512 from:0 to:0 \
copy from:haribote/haribote.sys to:@: \
@@ -49,8 +50,10 @@ haribote.img : haribote/ipl20.bin haribote/haribote.sys Makefile \
copy from:type/type.hrb to:@: \
copy from:iroha/iroha.hrb to:@: \
copy from:chklang/chklang.hrb to:@: \
copy from:notrec/notrec.hrb to:@: \
copy from:euc.txt to:@: \
copy from:notrec/notrec.hrb to:@: \
copy from:bball/bball.hrb to:@: \
copy from:invader/invader.hrb to:@: \
copy from:nihongo/nihongo.fnt to:@: \
imgout:haribote.img
@@ -68,7 +71,6 @@ install :
full :
$(MAKE) -C haribote
$(MAKE) -C apilib
$(MAKE) -C stdlib
$(MAKE) -C a
$(MAKE) -C hello3
$(MAKE) -C hello4
@@ -92,6 +94,8 @@ full :
$(MAKE) -C iroha
$(MAKE) -C chklang
$(MAKE) -C notrec
$(MAKE) -C bball
$(MAKE) -C invader
$(MAKE) haribote.img
run_full :
@@ -116,59 +120,61 @@ src_only :
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 apilib clean
$(MAKE) -C a clean
$(MAKE) -C hello3 clean
$(MAKE) -C hello4 clean
$(MAKE) -C hello5 clean
$(MAKE) -C winhelo clean
$(MAKE) -C winhelo2 clean
$(MAKE) -C winhelo3 clean
$(MAKE) -C star1 clean
$(MAKE) -C stars clean
$(MAKE) -C stars2 clean
$(MAKE) -C lines clean
$(MAKE) -C walk clean
$(MAKE) -C noodle clean
$(MAKE) -C star1 clean
$(MAKE) -C stars clean
$(MAKE) -C stars2 clean
$(MAKE) -C lines clean
$(MAKE) -C walk clean
$(MAKE) -C noodle clean
$(MAKE) -C beepdown clean
$(MAKE) -C color clean
$(MAKE) -C color2 clean
$(MAKE) -C sosu clean
$(MAKE) -C sosu2 clean
$(MAKE) -C sosu3 clean
$(MAKE) -C type clean
$(MAKE) -C iroha clean
$(MAKE) -C color clean
$(MAKE) -C color2 clean
$(MAKE) -C sosu clean
$(MAKE) -C sosu2 clean
$(MAKE) -C sosu3 clean
$(MAKE) -C type clean
$(MAKE) -C iroha clean
$(MAKE) -C chklang clean
$(MAKE) -C notrec clean
$(MAKE) -C notrec clean
$(MAKE) -C bball clean
$(MAKE) -C invader clean
src_only_full :
$(MAKE) -C haribote src_only
$(MAKE) -C apilib src_only
$(MAKE) -C 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 apilib src_only
$(MAKE) -C a src_only
$(MAKE) -C hello3 src_only
$(MAKE) -C hello4 src_only
$(MAKE) -C hello5 src_only
$(MAKE) -C winhelo src_only
$(MAKE) -C winhelo2 src_only
$(MAKE) -C winhelo3 src_only
$(MAKE) -C star1 src_only
$(MAKE) -C stars src_only
$(MAKE) -C stars2 src_only
$(MAKE) -C lines src_only
$(MAKE) -C walk src_only
$(MAKE) -C noodle src_only
$(MAKE) -C star1 src_only
$(MAKE) -C stars src_only
$(MAKE) -C stars2 src_only
$(MAKE) -C lines src_only
$(MAKE) -C walk src_only
$(MAKE) -C noodle src_only
$(MAKE) -C beepdown src_only
$(MAKE) -C color src_only
$(MAKE) -C color2 src_only
$(MAKE) -C sosu src_only
$(MAKE) -C sosu2 src_only
$(MAKE) -C sosu3 src_only
$(MAKE) -C type src_only
$(MAKE) -C iroha src_only
$(MAKE) -C color src_only
$(MAKE) -C color2 src_only
$(MAKE) -C sosu src_only
$(MAKE) -C sosu2 src_only
$(MAKE) -C sosu3 src_only
$(MAKE) -C type src_only
$(MAKE) -C iroha src_only
$(MAKE) -C chklang src_only
$(MAKE) -C notrec src_only
$(MAKE) -C notrec src_only
$(MAKE) -C bball src_only
$(MAKE) -C invader src_only
-$(DEL) haribote.img
refresh :

View File

@@ -0,0 +1 @@
command

View File

@@ -0,0 +1 @@
cmd.exe

5
29_day/bball/Makefile Normal file
View File

@@ -0,0 +1,5 @@
APP = bball
STACK = 52k
MALLOC = 0k
include ../app_make.txt

37
29_day/bball/bball.c Normal file
View 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
View File

@@ -0,0 +1 @@
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

View File

@@ -489,6 +489,16 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
sht = (struct SHEET *) (ebx & 0xfffffffe);
hrb_api_linewin(sht, eax, ecx, esi, edi, ebp);
if ((ebx & 1) == 0) {
if (eax > esi) {
i = eax;
eax = esi;
esi = i;
}
if (ecx > edi) {
i = ecx;
ecx = edi;
edi = i;
}
sheet_refresh(sht, eax, ecx, esi + 1, edi + 1);
}
} else if (edx == 14) {

View File

@@ -0,0 +1 @@
command

View File

@@ -0,0 +1 @@
cmd.exe

5
29_day/invader/Makefile Normal file
View File

@@ -0,0 +1,5 @@
APP = invader
STACK = 90k
MALLOC = 0k
include ../app_make.txt

281
29_day/invader/invader.c Normal file
View 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时外星人群前进一步
movewait0movewait的初始值消灭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
View File

@@ -0,0 +1 @@
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9