mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-05 02:53:19 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2fc0dc0f5 | ||
|
|
e4a94836dd | ||
|
|
68781eba2a | ||
|
|
883213696f |
@@ -124,7 +124,7 @@ void HariMain(void)
|
||||
|
||||
for (;;) {
|
||||
if (fifo32_status(&keycmd) > 0 && keycmd_wait < 0) {
|
||||
/* <EFBFBD>L<EFBFBD>[<5B>{<7B>[<5B>h<EFBFBD>R<EFBFBD><52><EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD>ɑ<EFBFBD><C991><EFBFBD>f<EFBFBD>[<5B>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<CE81><41><EFBFBD><EFBFBD> */
|
||||
/* 如果存在向键盘控制器发送的数据,则发送它 */
|
||||
keycmd_wait = fifo32_get(&keycmd);
|
||||
wait_KBC_sendready();
|
||||
io_out8(PORT_KEYDAT, keycmd_wait);
|
||||
|
||||
@@ -15,7 +15,7 @@ void HariMain(void)
|
||||
char s[40];
|
||||
struct FIFO32 fifo, keycmd;
|
||||
int fifobuf[128], keycmd_buf[32], *cons_fifo[2];
|
||||
int mx, my, i;
|
||||
int mx, my, i, new_mx = -1, new_my = 0, new_wx = 0x7fffffff, new_wy = 0;
|
||||
unsigned int memtotal;
|
||||
struct MOUSE_DEC mdec;
|
||||
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
||||
@@ -43,7 +43,7 @@ void HariMain(void)
|
||||
0, 0, 0, '_', 0, 0, 0, 0, 0, 0, 0, 0, 0, '|', 0, 0
|
||||
};
|
||||
int key_shift = 0, key_leds = (binfo->leds >> 4) & 7, keycmd_wait = -1;
|
||||
int j, x, y, mmx = -1, mmy = -1;
|
||||
int j, x, y, mmx = -1, mmy = -1, mmx2 = 0;
|
||||
struct SHEET *sht = 0, *key_win;
|
||||
|
||||
init_gdtidt();
|
||||
@@ -124,15 +124,26 @@ void HariMain(void)
|
||||
|
||||
for (;;) {
|
||||
if (fifo32_status(&keycmd) > 0 && keycmd_wait < 0) {
|
||||
/* <EFBFBD>L<EFBFBD>[<5B>{<7B>[<5B>h<EFBFBD>R<EFBFBD><52><EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD>ɑ<EFBFBD><C991><EFBFBD>f<EFBFBD>[<5B>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<CE81><41><EFBFBD><EFBFBD> */
|
||||
/* 如果存在向键盘控制器发送的数据,则发送它 */
|
||||
keycmd_wait = fifo32_get(&keycmd);
|
||||
wait_KBC_sendready();
|
||||
io_out8(PORT_KEYDAT, keycmd_wait);
|
||||
}
|
||||
io_cli();
|
||||
if (fifo32_status(&fifo) == 0) {
|
||||
task_sleep(task_a);
|
||||
io_sti();
|
||||
/* FIFO为空,当存在搁置的绘图操作时立即执行*/
|
||||
if (new_mx >= 0) {
|
||||
io_sti();
|
||||
sheet_slide(sht_mouse, new_mx, new_my);
|
||||
new_mx = -1;
|
||||
} else if (new_wx != 0x7fffffff) {
|
||||
io_sti();
|
||||
sheet_slide(sht, new_wx, new_wy);
|
||||
new_wx = 0x7fffffff;
|
||||
} else {
|
||||
task_sleep(task_a);
|
||||
io_sti();
|
||||
}
|
||||
} else {
|
||||
i = fifo32_get(&fifo);
|
||||
io_sti();
|
||||
@@ -232,7 +243,8 @@ void HariMain(void)
|
||||
if (my > binfo->scrny - 1) {
|
||||
my = binfo->scrny - 1;
|
||||
}
|
||||
sheet_slide(sht_mouse, mx, my);/* 包含sheet_refresh含sheet_refresh */
|
||||
new_mx = mx;
|
||||
new_my = my;
|
||||
if ((mdec.btn & 0x01) != 0) { /* 按下左键 */
|
||||
if (mmx < 0) {
|
||||
/*如果处于通常模式*/
|
||||
@@ -252,6 +264,8 @@ void HariMain(void)
|
||||
if (3 <= x && x < sht->bxsize - 3 && 3 <= y && y < 21) {
|
||||
mmx = mx; /*进入窗口移动模式*/
|
||||
mmy = my;
|
||||
mmx2 = sht->vx0;
|
||||
new_wy = sht->vy0;
|
||||
}
|
||||
if (sht->bxsize - 21 <= x && x < sht->bxsize - 5 && 5 <= y && y < 19) {
|
||||
/*点击“×”按钮*/
|
||||
@@ -270,15 +284,19 @@ void HariMain(void)
|
||||
}
|
||||
} else {
|
||||
/*如果处于窗口移动模式*/
|
||||
x = mx - mmx; /*计算鼠标的移动距离*/
|
||||
x = mx - mmx; /*计算鼠标指针移动量*/
|
||||
y = my - mmy;
|
||||
sheet_slide(sht, sht->vx0 + x, sht->vy0 + y);
|
||||
mmx = mx; /*更新为移动后的坐标*/
|
||||
new_wx = (mmx2 + x + 2) & ~3;
|
||||
new_wy = new_wy + y;
|
||||
mmy = my;
|
||||
}
|
||||
} else {
|
||||
/*没有按下左键*/
|
||||
mmx = -1; /*返回通常模式*/
|
||||
mmx = -1; /*切换到一般模式*/
|
||||
if (new_wx != 0x7fffffff) {
|
||||
sheet_slide(sht, new_wx, new_wy); /*固定图层位置*/
|
||||
new_wx = 0x7fffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
|
||||
sht->flags |= 0x10;
|
||||
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, (shtctl->xsize - esi) / 2, (shtctl->ysize - edi) / 2);
|
||||
sheet_slide(sht, ((shtctl->xsize - esi) / 2) & ~3, (shtctl->ysize - edi) / 2);
|
||||
sheet_updown(sht, shtctl->top); /*将窗口图层高度指定为当前鼠标所在图层的高度,鼠标移到上层*/
|
||||
reg[7] = (int) sht;
|
||||
} else if (edx == 6) {
|
||||
|
||||
@@ -56,7 +56,7 @@ void sheet_setbuf(struct SHEET *sht, unsigned char *buf, int xsize, int ysize, i
|
||||
|
||||
void sheet_refreshmap(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1, int h0)
|
||||
{
|
||||
int h, bx, by, vx, vy, bx0, by0, bx1, by1;
|
||||
int h, bx, by, vx, vy, bx0, by0, bx1, by1, sid4, *p;;
|
||||
unsigned char *buf, sid, *map = ctl->map;
|
||||
struct SHEET *sht;
|
||||
if (vx0 < 0) { vx0 = 0; }
|
||||
@@ -76,12 +76,26 @@ void sheet_refreshmap(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1, in
|
||||
if (bx1 > sht->bxsize) { bx1 = sht->bxsize; }
|
||||
if (by1 > sht->bysize) { by1 = sht->bysize; }
|
||||
if (sht->col_inv == -1) {
|
||||
/*无透明色图层专用的高速版*/
|
||||
for (by = by0; by < by1; by++) {
|
||||
vy = sht->vy0 + by;
|
||||
for (bx = bx0; bx < bx1; bx++) {
|
||||
vx = sht->vx0 + bx;
|
||||
map[vy * ctl->xsize + vx] = sid;
|
||||
if ((sht->vx0 & 3) == 0 && (bx0 & 3) == 0 && (bx1 & 3) == 0) {
|
||||
/*无透明色图层专用的高速版(4字节型)*/
|
||||
bx1 = (bx1 - bx0) / 4; /* MOV次数*/
|
||||
sid4 = sid | sid << 8 | sid << 16 | sid << 24;
|
||||
for (by = by0; by < by1; by++) {
|
||||
vy = sht->vy0 + by;
|
||||
vx = sht->vx0 + bx0;
|
||||
p = (int *) &map[vy * ctl->xsize + vx];
|
||||
for (bx = 0; bx < bx1; bx++) {
|
||||
p[bx] = sid4;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*无透明色图层专用的高速版(1字节型)*/
|
||||
for (by = by0; by < by1; by++) {
|
||||
vy = sht->vy0 + by;
|
||||
for (bx = bx0; bx < bx1; bx++) {
|
||||
vx = sht->vx0 + bx;
|
||||
map[vy * ctl->xsize + vx] = sid;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -102,7 +116,7 @@ void sheet_refreshmap(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1, in
|
||||
|
||||
void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1, int h0, int h1)
|
||||
{
|
||||
int h, bx, by, vx, vy, bx0, by0, bx1, by1;
|
||||
int h, bx, by, vx, vy, bx0, by0, bx1, by1, bx2, sid4, i, i1, *p, *q, *r;
|
||||
unsigned char *buf, *vram = ctl->vram, *map = ctl->map, sid;
|
||||
struct SHEET *sht;
|
||||
|
||||
@@ -125,12 +139,63 @@ void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1, in
|
||||
if (by0 < 0) { by0 = 0; }
|
||||
if (bx1 > sht->bxsize) { bx1 = sht->bxsize; } /* 应对不同的重叠方式 */
|
||||
if (by1 > sht->bysize) { by1 = sht->bysize; }
|
||||
for (by = by0; by < by1; by++) {
|
||||
vy = sht->vy0 + by;
|
||||
for (bx = bx0; bx < bx1; bx++) {
|
||||
if ((sht->vx0 & 3) == 0) {
|
||||
/* 4字节型*/
|
||||
i = (bx0 + 3) / 4; /* bx0除以4(小数进位)*/
|
||||
i1 = bx1 / 4; /* bx1除以4(小数舍去)*/
|
||||
i1 = i1 - i;
|
||||
sid4 = sid | sid << 8 | sid << 16 | sid << 24;
|
||||
for (by = by0; by < by1; by++) {
|
||||
vy = sht->vy0 + by;
|
||||
for (bx = bx0; bx < bx1 && (bx & 3) != 0; bx++) {
|
||||
/*前面被4除多余的部分逐个字节写入*/
|
||||
vx = sht->vx0 + bx;
|
||||
if (map[vy * ctl->xsize + vx] == sid) {
|
||||
vram[vy * ctl->xsize + vx] = buf[by * sht->bxsize + bx];
|
||||
}
|
||||
}
|
||||
vx = sht->vx0 + bx;
|
||||
if (map[vy * ctl->xsize + vx] == sid) {
|
||||
vram[vy * ctl->xsize + vx] = buf[by * sht->bxsize + bx];
|
||||
p = (int *) &map[vy * ctl->xsize + vx];
|
||||
q = (int *) &vram[vy * ctl->xsize + vx];
|
||||
r = (int *) &buf[by * sht->bxsize + bx];
|
||||
for (i = 0; i < i1; i++) {
|
||||
/* 4的倍数部分*/
|
||||
if (p[i] == sid4) {
|
||||
q[i] = r[i]; /*估计大多数会是这种情况,因此速度会变快*/
|
||||
} else {
|
||||
bx2 = bx + i * 4;
|
||||
vx = sht->vx0 + bx2;
|
||||
if (map[vy * ctl->xsize + vx + 0] == sid) {
|
||||
vram[vy * ctl->xsize + vx + 0] = buf[by * sht->bxsize + bx2 + 0];
|
||||
}
|
||||
if (map[vy * ctl->xsize + vx + 1] == sid) {
|
||||
vram[vy * ctl->xsize + vx + 1] = buf[by * sht->bxsize + bx2 + 1];
|
||||
}
|
||||
if (map[vy * ctl->xsize + vx + 2] == sid) {
|
||||
vram[vy * ctl->xsize + vx + 2] = buf[by * sht->bxsize + bx2 + 2];
|
||||
}
|
||||
if (map[vy * ctl->xsize + vx + 3] == sid) {
|
||||
vram[vy * ctl->xsize + vx + 3] = buf[by * sht->bxsize + bx2 + 3];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (bx += i1 * 4; bx < bx1; bx++) {
|
||||
/*后面被4除多余的部分逐个字节写入*/
|
||||
vx = sht->vx0 + bx;
|
||||
if (map[vy * ctl->xsize + vx] == sid) {
|
||||
vram[vy * ctl->xsize + vx] = buf[by * sht->bxsize + bx];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* 1字节型*/
|
||||
for (by = by0; by < by1; by++) {
|
||||
vy = sht->vy0 + by;
|
||||
for (bx = bx0; bx < bx1; bx++) {
|
||||
vx = sht->vx0 + bx;
|
||||
if (map[vy * ctl->xsize + vx] == sid) {
|
||||
vram[vy * ctl->xsize + vx] = buf[by * sht->bxsize + bx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user