mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-04-26 11:41:24 +08:00
画直线
This commit is contained in:
@@ -134,9 +134,17 @@ stars2.bim : stars2.obj a_nask.obj Makefile
|
|||||||
stars2.hrb : stars2.bim Makefile
|
stars2.hrb : stars2.bim Makefile
|
||||||
$(BIM2HRB) stars2.bim stars2.hrb 47k
|
$(BIM2HRB) stars2.bim stars2.hrb 47k
|
||||||
|
|
||||||
|
lines.bim : lines.obj a_nask.obj Makefile
|
||||||
|
$(OBJ2BIM) @$(RULEFILE) out:lines.bim stack:1k map:lines.map \
|
||||||
|
lines.obj a_nask.obj
|
||||||
|
|
||||||
|
lines.hrb : lines.bim Makefile
|
||||||
|
$(BIM2HRB) lines.bim lines.hrb 48k
|
||||||
|
|
||||||
haribote.img : ipl10.bin haribote.sys Makefile \
|
haribote.img : ipl10.bin haribote.sys Makefile \
|
||||||
hello.hrb hello2.hrb a.hrb hello3.hrb hello4.hrb hello5.hrb \
|
hello.hrb hello2.hrb a.hrb hello3.hrb hello4.hrb hello5.hrb \
|
||||||
winhelo.hrb winhelo2.hrb winhelo3.hrb star1.hrb stars.hrb stars2.hrb
|
winhelo.hrb winhelo2.hrb winhelo3.hrb star1.hrb stars.hrb stars2.hrb \
|
||||||
|
lines.hrb
|
||||||
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
|
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
|
||||||
wbinimg src:ipl10.bin len:512 from:0 to:0 \
|
wbinimg src:ipl10.bin len:512 from:0 to:0 \
|
||||||
copy from:haribote.sys to:@: \
|
copy from:haribote.sys to:@: \
|
||||||
@@ -154,8 +162,9 @@ haribote.img : ipl10.bin haribote.sys Makefile \
|
|||||||
copy from:star1.hrb to:@: \
|
copy from:star1.hrb to:@: \
|
||||||
copy from:stars.hrb to:@: \
|
copy from:stars.hrb to:@: \
|
||||||
copy from:stars2.hrb to:@: \
|
copy from:stars2.hrb to:@: \
|
||||||
|
copy from:lines.hrb to:@: \
|
||||||
imgout:haribote.img
|
imgout:haribote.img
|
||||||
|
|
||||||
# 其他指令
|
# 其他指令
|
||||||
|
|
||||||
%.gas : %.c bootpack.h Makefile
|
%.gas : %.c bootpack.h Makefile
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
GLOBAL _api_free
|
GLOBAL _api_free
|
||||||
GLOBAL _api_point
|
GLOBAL _api_point
|
||||||
GLOBAL _api_refreshwin
|
GLOBAL _api_refreshwin
|
||||||
|
GLOBAL _api_linewin
|
||||||
|
|
||||||
[SECTION .text]
|
[SECTION .text]
|
||||||
|
|
||||||
@@ -150,3 +151,22 @@ _api_refreshwin: ; void api_refreshwin(int win, int x0, int y0, int x1, int y1);
|
|||||||
POP ESI
|
POP ESI
|
||||||
POP EDI
|
POP EDI
|
||||||
RET
|
RET
|
||||||
|
|
||||||
|
_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
|
||||||
|
|||||||
@@ -367,6 +367,12 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
|
|||||||
} else if (edx == 12) {
|
} else if (edx == 12) {
|
||||||
sht = (struct SHEET *) ebx;
|
sht = (struct SHEET *) ebx;
|
||||||
sheet_refresh(sht, eax, ecx, esi, edi);
|
sheet_refresh(sht, eax, ecx, esi, edi);
|
||||||
|
} else if (edx == 13) {
|
||||||
|
sht = (struct SHEET *) (ebx & 0xfffffffe);
|
||||||
|
hrb_api_linewin(sht, eax, ecx, esi, edi, ebp);
|
||||||
|
if ((ebx & 1) == 0) {
|
||||||
|
sheet_refresh(sht, eax, ecx, esi + 1, edi + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -392,3 +398,52 @@ int *inthandler0d(int *esp)
|
|||||||
cons_putstr0(cons, s);
|
cons_putstr0(cons, s);
|
||||||
return &(task->tss.esp0); /*强制结束程序*/
|
return &(task->tss.esp0); /*强制结束程序*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hrb_api_linewin(struct SHEET *sht, int x0, int y0, int x1, int y1, int col)
|
||||||
|
{
|
||||||
|
int i, x, y, len, dx, dy;
|
||||||
|
|
||||||
|
dx = x1 - x0;
|
||||||
|
dy = y1 - y0;
|
||||||
|
x = x0 << 10;
|
||||||
|
y = y0 << 10;
|
||||||
|
if (dx < 0) {
|
||||||
|
dx = - dx;
|
||||||
|
}
|
||||||
|
if (dy < 0) {
|
||||||
|
dy = - dy;
|
||||||
|
}
|
||||||
|
if (dx >= dy) {
|
||||||
|
len = dx + 1;
|
||||||
|
if (x0 > x1) {
|
||||||
|
dx = -1024;
|
||||||
|
} else {
|
||||||
|
dx = 1024;
|
||||||
|
}
|
||||||
|
if (y0 <= y1) {
|
||||||
|
dy = ((y1 - y0 + 1) << 10) / len;
|
||||||
|
} else {
|
||||||
|
dy = ((y1 - y0 - 1) << 10) / len;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
len = dy + 1;
|
||||||
|
if (y0 > y1) {
|
||||||
|
dy = -1024;
|
||||||
|
} else {
|
||||||
|
dy = 1024;
|
||||||
|
}
|
||||||
|
if (x0 <= x1) {
|
||||||
|
dx = ((x1 - x0 + 1) << 10) / len;
|
||||||
|
} else {
|
||||||
|
dx = ((x1 - x0 - 1) << 10) / len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
sht->buf[(y >> 10) * sht->bxsize + (x >> 10)] = col;
|
||||||
|
x += dx;
|
||||||
|
y += dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|||||||
21
23_day/lines.c
Normal file
21
23_day/lines.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title);
|
||||||
|
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_end(void);
|
||||||
|
|
||||||
|
void HariMain(void)
|
||||||
|
{
|
||||||
|
char *buf;
|
||||||
|
int win, i;
|
||||||
|
api_initmalloc();
|
||||||
|
buf = api_malloc(160 * 100);
|
||||||
|
win = api_openwin(buf, 160, 100, -1, "lines");
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
api_linewin(win + 1, 8, 26, 77, i * 9 + 26, i);
|
||||||
|
api_linewin(win + 1, 88, 26, i * 9 + 88, 89, i);
|
||||||
|
}
|
||||||
|
api_refreshwin(win, 6, 26, 154, 90);
|
||||||
|
api_end();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user