diff --git a/12_day/bootpack.c b/12_day/bootpack.c index 6d8385c..57324d0 100644 --- a/12_day/bootpack.c +++ b/12_day/bootpack.c @@ -1,4 +1,4 @@ -/* bootpackのメイン */ +/* bootpack*/ #include "bootpack.h" #include @@ -52,9 +52,9 @@ void HariMain(void) shtctl = shtctl_init(memman, binfo->vram, binfo->scrnx, binfo->scrny); sht_back = sheet_alloc(shtctl); sht_mouse = sheet_alloc(shtctl); - sht_win = sheet_alloc(shtctl); + sht_win = sheet_alloc(shtctl); buf_back = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny); - buf_win = (unsigned char *) memman_alloc_4k(memman, 160 * 52); + buf_win = (unsigned char *) memman_alloc_4k(memman, 160 * 52); sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1); /* 没有透明色 */ sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); /* 透明色号99 */ sheet_setbuf(sht_win, buf_win, 160, 52, -1); /* 没有透明色 */ @@ -65,13 +65,14 @@ void HariMain(void) mx = (binfo->scrnx - 16) / 2; /* 按显示在画面中央来计算坐标 */ my = (binfo->scrny - 28 - 16) / 2; sheet_slide(sht_mouse, mx, my); - sheet_slide(sht_win, 80, 72); + sheet_slide(sht_win, 80, 72); sheet_updown(sht_back, 0); - sheet_updown(sht_win, 1); + sheet_updown(sht_win, 1); sheet_updown(sht_mouse, 2); sprintf(s, "(%3d, %3d)", mx, my); putfonts8_asc(buf_back, binfo->scrnx, 0, 0, COL8_FFFFFF, s); - sprintf(s, "memory %dMB free : %dKB", memtotal / (1024 * 1024), memman_total(memman) / 1024); + sprintf(s, "memory %dMB free : %dKB", + memtotal / (1024 * 1024), memman_total(memman) / 1024); putfonts8_asc(buf_back, binfo->scrnx, 0, 32, COL8_FFFFFF, s); sheet_refresh(sht_back, 0, 0, binfo->scrnx, 48); /* 刷新文字 */ @@ -82,7 +83,8 @@ void HariMain(void) sheet_refresh(sht_win, 40, 28, 120, 44); /* 到这里结束 */ io_cli(); - if (fifo8_status(&keyfifo) + fifo8_status(&mousefifo) + fifo8_status(&timerfifo) + fifo8_status(&timerfifo2) + fifo8_status(&timerfifo3)== 0) { + if (fifo8_status(&keyfifo) + fifo8_status(&mousefifo) + fifo8_status(&timerfifo) + + fifo8_status(&timerfifo2) + fifo8_status(&timerfifo3) == 0) { io_sti(); /* 不做HLT */ } else { if (fifo8_status(&keyfifo) != 0) { @@ -176,21 +178,19 @@ void make_window8(unsigned char *buf, int xsize, int ysize, char *title) "O$$$$$$$$$$$$$$@", "@@@@@@@@@@@@@@@@" }; - int x, y; char c; - boxfill8(buf, xsize, COL8_C6C6C6, 0, 0, xsize - 1, 0 ); - boxfill8(buf, xsize, COL8_FFFFFF, 1, 1, xsize - 2, 1 ); - boxfill8(buf, xsize, COL8_C6C6C6, 0, 0, 0, ysize - 1); - boxfill8(buf, xsize, COL8_FFFFFF, 1, 1, 1, ysize - 2); - boxfill8(buf, xsize, COL8_848484, xsize - 2, 1, xsize - 2, ysize - 2); - boxfill8(buf, xsize, COL8_000000, xsize - 1, 0, xsize - 1, ysize - 1); - boxfill8(buf, xsize, COL8_C6C6C6, 2, 2, xsize - 3, ysize - 3); - boxfill8(buf, xsize, COL8_000084, 3, 3, xsize - 4, 20 ); - boxfill8(buf, xsize, COL8_848484, 1, ysize - 2, xsize - 2, ysize - 2); - boxfill8(buf, xsize, COL8_000000, 0, ysize - 1, xsize - 1, ysize - 1); + boxfill8(buf, xsize, COL8_C6C6C6, 0, 0, xsize - 1, 0 ); + boxfill8(buf, xsize, COL8_FFFFFF, 1, 1, xsize - 2, 1 ); + boxfill8(buf, xsize, COL8_C6C6C6, 0, 0, 0, ysize - 1); + boxfill8(buf, xsize, COL8_FFFFFF, 1, 1, 1, ysize - 2); + boxfill8(buf, xsize, COL8_848484, xsize - 2, 1, xsize - 2, ysize - 2); + boxfill8(buf, xsize, COL8_000000, xsize - 1, 0, xsize - 1, ysize - 1); + boxfill8(buf, xsize, COL8_C6C6C6, 2, 2, xsize - 3, ysize - 3); + boxfill8(buf, xsize, COL8_000084, 3, 3, xsize - 4, 20 ); + boxfill8(buf, xsize, COL8_848484, 1, ysize - 2, xsize - 2, ysize - 2); + boxfill8(buf, xsize, COL8_000000, 0, ysize - 1, xsize - 1, ysize - 1); putfonts8_asc(buf, xsize, 24, 4, COL8_FFFFFF, title); - for (y = 0; y < 14; y++) { for (x = 0; x < 16; x++) { c = closebtn[y][x]; diff --git a/12_day/int.c b/12_day/int.c index 7c4226b..c717372 100644 --- a/12_day/int.c +++ b/12_day/int.c @@ -1,6 +1,7 @@ /*初始化关系 */ #include "bootpack.h" +#include void init_pic(void) /* PIC初始化 */ @@ -24,8 +25,6 @@ void init_pic(void) return; } -#define PORT_KEYDAT 0x0060 - void inthandler27(int *esp) /* PIC0中断的不完整策略 */ /* 这个中断在Athlon64X2上通过芯片组提供的便利,只需执行一次 */ diff --git a/12_day/memory.c b/12_day/memory.c index 654e816..54a447a 100644 --- a/12_day/memory.c +++ b/12_day/memory.c @@ -1,11 +1,11 @@ -/* 内存管理 */ +/* �������֌W */ #include "bootpack.h" -#define EFLAGS_AC_BIT 0x00040000 +#define EFLAGS_AC_BIT 0x00040000 #define CR0_CACHE_DISABLE 0x60000000 -unsigned int memtest(unsigned int start, unsigned int end) +unsigned int memtest(unsigned int start, unsigned int end) { char flg486 = 0; unsigned int eflg, cr0, i; @@ -40,7 +40,8 @@ unsigned int memtest(unsigned int start, unsigned int end) return i; } -void memman_init(struct MEMMAN *man){ +void memman_init(struct MEMMAN *man) +{ man->frees = 0; /* 可用信息数目 */ man->maxfrees = 0; /* 用于观察可用状况:frees的最大值 */ man->lostsize = 0; /* 释放失败的内存的大小总和 */ diff --git a/12_day/mouse.c b/12_day/mouse.c index 8979b35..294bde4 100644 --- a/12_day/mouse.c +++ b/12_day/mouse.c @@ -4,7 +4,8 @@ struct FIFO8 mousefifo; -void inthandler2c(int *esp) { +void inthandler2c(int *esp) +{ /* 来自PS/2鼠标的中断 */ unsigned char data; io_out8(PIC1_OCW2, 0x64); /* 通知PIC IRQ-12 已经受理完毕 */ @@ -17,7 +18,8 @@ void inthandler2c(int *esp) { #define KEYCMD_SENDTO_MOUSE 0xd4 #define MOUSECMD_ENABLE 0xf4 -void enable_mouse(struct MOUSE_DEC *mdec) { +void enable_mouse(struct MOUSE_DEC *mdec) +{ /* 鼠标有效 */ wait_KBC_sendready(); io_out8(PORT_KEYCMD, KEYCMD_SENDTO_MOUSE); @@ -28,7 +30,8 @@ void enable_mouse(struct MOUSE_DEC *mdec) { return; } -int mouse_decode(struct MOUSE_DEC *mdec, unsigned char dat) { +int mouse_decode(struct MOUSE_DEC *mdec, unsigned char dat) +{ if (mdec->phase == 0) { /* 等待鼠标的0xfa的阶段 */ if (dat == 0xfa) { diff --git a/12_day/sheet.c b/12_day/sheet.c index 61386c0..102381d 100644 --- a/12_day/sheet.c +++ b/12_day/sheet.c @@ -86,7 +86,7 @@ void sheet_updown(struct SHEET *sht, int height) } ctl->top--; /* 由于显示中的图层减少了一个,所以最上面的图层高度下降 */ sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0); - sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0, old - 1); + sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0, old - 1); } } else if (old < height) { /* 比以前高 */ if (old >= 0) { @@ -130,11 +130,10 @@ void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1, in if (vy0 < 0) { vy0 = 0; } if (vx1 > ctl->xsize) { vx1 = ctl->xsize; } if (vy1 > ctl->ysize) { vy1 = ctl->ysize; } - - for (h = h0; h <= ctl->top; h++) { + for (h = h0; h <= h1; h++) { sht = ctl->sheets[h]; buf = sht->buf; - sid = sht -ctl->sheets0; + sid = sht - ctl->sheets0; /* 使用vx0~vy1,对bx0~by1进行倒推 */ bx0 = vx0 - sht->vx0; @@ -145,7 +144,6 @@ 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++) { @@ -164,12 +162,10 @@ void sheet_refreshmap(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1, in int h, bx, by, vx, vy, bx0, by0, bx1, by1; unsigned char *buf, sid, *map = ctl->map; struct SHEET *sht; - if (vx0 < 0) { vx0 = 0; } if (vy0 < 0) { vy0 = 0; } if (vx1 > ctl->xsize) { vx1 = ctl->xsize; } if (vy1 > ctl->ysize) { vy1 = ctl->ysize; } - for (h = h0; h <= ctl->top; h++) { sht = ctl->sheets[h]; sid = sht - ctl->sheets0; /* 将进行了减法计算的地址作为图层号码使用 */ @@ -182,7 +178,6 @@ void sheet_refreshmap(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++) { diff --git a/12_day/timer.c b/12_day/timer.c index cc773ef..5c46b22 100644 --- a/12_day/timer.c +++ b/12_day/timer.c @@ -2,13 +2,14 @@ #include "bootpack.h" -#define PIT_CTRL 0x0043 -#define PIT_CNT0 0x0040 -#define TIMER_FLAGS_ALLOC 1 /* 已配置状态 */ -#define TIMER_FLAGS_USING 2 /* 定时器运行中 */ +#define PIT_CTRL 0x0043 +#define PIT_CNT0 0x0040 struct TIMERCTL timerctl; +#define TIMER_FLAGS_ALLOC 1 /* 已配置状态 */ +#define TIMER_FLAGS_USING 2 /* 定时器运行中 */ + void init_pit(void) { int i;