mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-05 19:13:21 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96a714a9be | ||
|
|
9096191855 | ||
|
|
22bda5f82c |
@@ -1,31 +1,47 @@
|
||||
/* bootpack */
|
||||
/* bootpackのメイン */
|
||||
|
||||
#include "bootpack.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern struct KEYBUF keybuf;
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
|
||||
char s[40], mcursor[256];
|
||||
int mx, my;
|
||||
int mx, my, i, j;
|
||||
|
||||
init_gdtidt();
|
||||
init_pic();
|
||||
io_sti(); /* IDT/PICの初期化が終わったのでCPUの割り込み禁止を解除 */
|
||||
|
||||
io_out8(PIC0_IMR, 0xf9); /* PIC1とキーボードを許可(11111001) */
|
||||
io_out8(PIC1_IMR, 0xef); /* マウスを許可(11101111) */
|
||||
|
||||
init_palette();
|
||||
init_screen8(binfo->vram, binfo->scrnx, binfo->scrny);
|
||||
mx = (binfo->scrnx - 16) / 2; /* 计算画面的中心坐标*/
|
||||
mx = (binfo->scrnx - 16) / 2; /* 计算画面中心坐标 */
|
||||
my = (binfo->scrny - 28 - 16) / 2;
|
||||
init_mouse_cursor8(mcursor, COL8_008484);
|
||||
putblock8_8(binfo->vram, binfo->scrnx, 16, 16, mx, my, mcursor, 16);
|
||||
sprintf(s, "(%d, %d)", mx, my);
|
||||
putfonts8_asc(binfo->vram, binfo->scrnx, 0, 0, COL8_FFFFFF, s);
|
||||
|
||||
io_out8(PIC0_IMR, 0xf9); /* PIC1とキーボードを許可(11111001) */
|
||||
io_out8(PIC1_IMR, 0xef); /* マウスを許可(11101111) */
|
||||
|
||||
for (;;) {
|
||||
io_hlt();
|
||||
io_cli();
|
||||
if (keybuf.len == 0) {
|
||||
io_stihlt();
|
||||
} else {
|
||||
i = keybuf.data[keybuf.next_r];
|
||||
keybuf.len--;
|
||||
keybuf.next_r++;
|
||||
if (keybuf.next_r == 32) {
|
||||
keybuf.next_r = 0;
|
||||
}
|
||||
io_sti();
|
||||
sprintf(s, "%02X", i);
|
||||
boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31);
|
||||
putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,10 @@ void set_gatedesc(struct GATE_DESCRIPTOR *gd, int offset, int selector, int ar);
|
||||
#define AR_INTGATE32 0x008e
|
||||
|
||||
/* int.c */
|
||||
struct KEYBUF {
|
||||
unsigned char data[32];
|
||||
int next_r, next_w, len;
|
||||
};
|
||||
void init_pic(void);
|
||||
void inthandler21(int *esp);
|
||||
void inthandler27(int *esp);
|
||||
|
||||
19
07_day/int.c
19
07_day/int.c
@@ -24,18 +24,25 @@ void init_pic(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#define PORT_KEYDAT 0x0060
|
||||
|
||||
struct KEYBUF keybuf;
|
||||
|
||||
void inthandler21(int *esp)
|
||||
/* 来自PS/2键盘的中断 */
|
||||
{
|
||||
struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
|
||||
unsigned char data, s[4];
|
||||
io_out8(PIC0_OCW2, 0x61); /* IRQ-01受付完了をPICに通知 */
|
||||
io_out8(PIC0_OCW2, 0x61); /* 通知PIC IRQ-01 已经受理完毕 */
|
||||
data = io_in8(PORT_KEYDAT);
|
||||
|
||||
sprintf(s, "%02X", data);
|
||||
boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31);
|
||||
putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s);
|
||||
|
||||
if (keybuf.len < 32) {
|
||||
keybuf.data[keybuf.next_w] = data;
|
||||
keybuf.len++;
|
||||
keybuf.next_w++;
|
||||
if (keybuf.next_w == 32) {
|
||||
keybuf.next_w = 0;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user