mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-04 18:43:25 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
591fa69b74 | ||
|
|
041e2a4b52 | ||
|
|
8de80dcee7 |
@@ -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
|
||||
|
||||
# 其他指令
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
GLOBAL _api_point
|
||||
GLOBAL _api_refreshwin
|
||||
GLOBAL _api_linewin
|
||||
GLOBAL _api_closewin
|
||||
GLOBAL _api_getkey
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
@@ -170,3 +172,17 @@ _api_linewin: ; void api_linewin(int win, int x0, int y0, int x1, int y1, int c
|
||||
POP ESI
|
||||
POP EDI
|
||||
RET
|
||||
|
||||
_api_closewin: ; void api_closewin(int win);
|
||||
PUSH EBX
|
||||
MOV EDX,14
|
||||
MOV EBX,[ESP+8] ; win
|
||||
INT 0x40
|
||||
POP EBX
|
||||
RET
|
||||
|
||||
_api_getkey: ; int api_getkey(int mode);
|
||||
MOV EDX,15
|
||||
MOV EAX,[ESP+4] ; mode
|
||||
INT 0x40
|
||||
RET
|
||||
|
||||
@@ -237,6 +237,7 @@ void make_wtitle8(unsigned char *buf, int xsize, char *title, char act);
|
||||
struct CONSOLE {
|
||||
struct SHEET *sht;
|
||||
int cur_x, cur_y, cur_c;
|
||||
struct TIMER *timer;
|
||||
};
|
||||
void console_task(struct SHEET *sheet, unsigned int memtotal);
|
||||
void cons_putchar(struct CONSOLE *cons, int chr, char move);
|
||||
|
||||
@@ -321,6 +321,8 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
|
||||
/*强行改写通过PUSHAD保存的值*/
|
||||
/* reg[0] : EDI, reg[1] : ESI, reg[2] : EBP, reg[3] : ESP */
|
||||
/* reg[4] : EBX, reg[5] : EDX, reg[6] : ECX, reg[7] : EAX */
|
||||
int i;
|
||||
|
||||
if (edx == 1) {
|
||||
cons_putchar(cons, eax & 0xff, 1);
|
||||
} else if (edx == 2) {
|
||||
@@ -373,6 +375,38 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
|
||||
if ((ebx & 1) == 0) {
|
||||
sheet_refresh(sht, eax, ecx, esi + 1, edi + 1);
|
||||
}
|
||||
} else if (edx == 14) {
|
||||
sheet_free((struct SHEET *) ebx);
|
||||
} else if (edx == 15) {
|
||||
for (;;) {
|
||||
io_cli();
|
||||
if (fifo32_status(&task->fifo) == 0) {
|
||||
if (eax != 0) {
|
||||
task_sleep(task); /* FIFO为空,休眠并等待*/
|
||||
} else {
|
||||
io_sti();
|
||||
reg[7] = -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
i = fifo32_get(&task->fifo);
|
||||
io_sti();
|
||||
if (i <= 1) { /*光标用定时器*/
|
||||
/*应用程序运行时不需要显示光标,因此总是将下次显示用的值置为1*/
|
||||
timer_init(cons->timer, &task->fifo, 1); /*下次置为1*/
|
||||
timer_settime(cons->timer, 50);
|
||||
}
|
||||
if (i == 2) { /*光标ON */
|
||||
cons->cur_c = COL8_FFFFFF;
|
||||
}
|
||||
if (i == 3) { /*光标OFF */
|
||||
cons->cur_c = -1;
|
||||
}
|
||||
if (256 <= i && i <= 511) { /*键盘数据(通过任务A)*/
|
||||
reg[7] = i - 256;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ 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)
|
||||
@@ -17,5 +19,11 @@ void HariMain(void)
|
||||
api_linewin(win + 1, 88, 26, i * 9 + 88, 89, i);
|
||||
}
|
||||
api_refreshwin(win, 6, 26, 154, 90);
|
||||
for (;;) {
|
||||
if (api_getkey(1) == 0x0a) {
|
||||
break; /*按下回车键则break; */
|
||||
}
|
||||
}
|
||||
api_closewin(win);
|
||||
api_end();
|
||||
}
|
||||
|
||||
35
23_day/walk.c
Normal file
35
23_day/walk.c
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user