Compare commits

..

2 Commits

Author SHA1 Message Date
Yourtion
698022572a 强制结束并关闭窗口 2016-05-10 17:44:30 +08:00
Yourtion
591fa69b74 用键盘输入来消遣一下 2016-05-10 16:03:19 +08:00
5 changed files with 57 additions and 1 deletions

View File

@@ -141,10 +141,17 @@ lines.bim : lines.obj a_nask.obj Makefile
lines.hrb : lines.bim Makefile
$(BIM2HRB) lines.bim lines.hrb 48k
walk.bim : walk.obj a_nask.obj Makefile
$(OBJ2BIM) @$(RULEFILE) out:walk.bim stack:1k map:walk.map \
walk.obj a_nask.obj
walk.hrb : walk.bim Makefile
$(BIM2HRB) walk.bim walk.hrb 48k
haribote.img : ipl10.bin haribote.sys Makefile \
hello.hrb hello2.hrb a.hrb hello3.hrb hello4.hrb hello5.hrb \
winhelo.hrb winhelo2.hrb winhelo3.hrb star1.hrb stars.hrb stars2.hrb \
lines.hrb
lines.hrb walk.hrb
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
wbinimg src:ipl10.bin len:512 from:0 to:0 \
copy from:haribote.sys to:@: \
@@ -163,6 +170,7 @@ haribote.img : ipl10.bin haribote.sys Makefile \
copy from:stars.hrb to:@: \
copy from:stars2.hrb to:@: \
copy from:lines.hrb to:@: \
copy from:walk.hrb to:@: \
imgout:haribote.img
# 其他指令

View File

@@ -156,6 +156,7 @@ struct SHEET {
unsigned char *buf;
int bxsize, bysize, vx0, vy0, col_inv, height, flags;
struct SHTCTL *ctl;
struct TASK *task;
};
struct SHTCTL {
unsigned char *vram, *map;

View File

@@ -259,6 +259,8 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
char name[18], *p, *q;
struct TASK *task = task_now();
int i, segsiz, datsiz, esp, dathrb;
struct SHTCTL *shtctl;
struct SHEET *sht;
/*根据命令行生成文件名*/
for (i = 0; i < 13; i++) {
@@ -298,6 +300,14 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
q[esp + i] = p[dathrb + i];
}
start_app(0x1b, 1003 * 8, esp, 1004 * 8, &(task->tss.esp0));
shtctl = (struct SHTCTL *) *((int *) 0x0fe4);
for (i = 0; i < MAX_SHEETS; i++) {
sht = &(shtctl->sheets0[i]);
if (sht->flags != 0 && sht->task == task) {
/*找到被应用程序遗留的窗口*/
sheet_free(sht); /*关闭*/
}
}
memman_free_4k(memman, (int) q, segsiz);
} else {
cons_putstr0(cons, ".hrb file format error.\n");
@@ -333,6 +343,7 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
return &(task->tss.esp0);
} else if (edx == 5) {
sht = sheet_alloc(shtctl);
sht->task = task;
sheet_setbuf(sht, (char *) ebx + ds_base, esi, edi, eax);
make_window8((char *) ebx + ds_base, esi, edi, (char *) ecx + ds_base, 0);
sheet_slide(sht, 100, 50);

View File

@@ -38,6 +38,7 @@ struct SHEET *sheet_alloc(struct SHTCTL *ctl)
sht = &ctl->sheets0[i];
sht->flags = SHEET_USE; /* 标记为正在使用*/
sht->height = -1; /* 隐藏 */
sht->task = 0; /*不使用自动关闭功能*/
return sht;
}
}

35
23_day/walk.c Normal file
View File

@@ -0,0 +1,35 @@
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_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);
void api_end(void);
void HariMain(void)
{
char *buf;
int win, i, x, y;
api_initmalloc();
buf = api_malloc(160 * 100);
win = api_openwin(buf, 160, 100, -1, "walk");
api_boxfilwin(win, 4, 24, 155, 95, 0);/*黑色*/
x = 76;
y = 56;
api_putstrwin(win, x, y, 3, 1, "*");/*黄色*/
for (;;) {
i = api_getkey(1);
api_putstrwin(win, x, y, 0 , 1, "*"); /*用黑色擦除*/
if (i == '4' && x > 4) { x -= 8; }
if (i == '6' && x < 148) { x += 8; }
if (i == '8' && y > 24) { y -= 8; }
if (i == '2' && y < 80) { y += 8; }
if (i == 0x0a) { break; } /*按回车键结束*/
api_putstrwin(win, x, y, 3 , 1, "*");/*黄色*/
}
api_closewin(win);
api_end();
}