Import backup from 2003-10-06

This commit is contained in:
Josh Holtrop 2003-10-06 22:00:00 -04:00
parent 7a0351e123
commit 5da602b162
5 changed files with 61 additions and 14 deletions

View File

@ -68,7 +68,7 @@ void k_init()
}
mm_init();
mouse_enableData();
mouse_init();
enable_ints();
printf("Memory available to OS: %d MB (Bytes: %d)\n", mm_totalmem/0x100000, mm_totalmem);
pic1_mask(0); //unmask IRQ's 0-7
@ -94,7 +94,7 @@ void isr(dword num)
isr_keyboard(); //isr_keybard() takes care of calling eoi()
break;
case 0x2C: // IRQ12 - PS/2 mouse
printf("InB: %x, %x, %x", inportb(0x60), inportb(0x60), inportb(0x60));
isr_mouse();
eoi2();
break;
default:

51
mouse.c
View File

@ -3,17 +3,54 @@
// Author: Josh Holtrop
void mouse_enableData()
void mouse_init()
{
outportb(0x64, 0x60);
outportb(0x60, 0x03);
outportb(0x64, 0x20); //tell keyboard controller we are going to read keyboard controller command byte
byte temp = inportb(0x60); //read keyboard controller command byte
outportb(0x64, 0x60); //tell keyboard controller we are going to write keyboard controller command byte
outportb(0x60, 0x03 | (temp&0x40)); //write keyboard controller command byte: enable mouse/keyboard ints, include original XLATE bit from temp (bit6)
outportb(0x64, 0xA8); //enable mouse port
outportb(0x64, 0xD4); //send command to mouse, not kbd
outportb(0x60, 0xF4); //enable data reporting
// outportb(0x60, 0xFA);
// inportb(0x60); //get ACK off 0x60 port
// outportb(0x60, 0xFF); //mouse reset
//outportb(0x64, 0xD4);
//outportb(0x60, 0xE7); //scaling 2:1
}
void isr_mouse()
{
byte inb = inportb(0x60); //read mouse byte
//printf("InB: %x\n", inb);
//return;
if ((inb == 0xFA) && (mouse_bytesRead < 1)) //ACK
return;
mouse_inbuffer[mouse_bytesRead] = inb;
mouse_bytesRead++;
if (mouse_bytesRead == 3) //complete packet received
{
mouse_bytesRead = 0;
int adjx = (char) mouse_inbuffer[1];
int adjy = (char) mouse_inbuffer[2];
mouse_x += adjx;
mouse_y -= adjy; //-= because screen y coordinates are opposite mouse y coordinates
if (mouse_inbuffer[0] & 0x01) //left button
{
video_pset(VXR/2+mouse_x, VYR/2+mouse_y, 0x00FFFFFF);
printf("X: %d, Y: %d\n", mouse_x, mouse_y);
}
else
{
video_pset(VXR/2+mouse_x, VYR/2+mouse_y, 0x00000000);
printf("X: %d, Y: %d\n", mouse_x, mouse_y);
}
}
}

View File

@ -3,7 +3,14 @@
// Author: Josh Holtrop
void mouse_enableData();
int mouse_x = 0;
int mouse_y = 0;
int mouse_bytesRead = 0;
byte mouse_inbuffer[16];
void mouse_init();
void isr_mouse();

View File

@ -1,10 +1,6 @@
//video.c
// 08/13/03 Josh Holtrop
ModeInfoBlock video_mode;
byte *vid_ptr24;
word *vid_ptr16;
dword *vid_ptr32;
void video_init(ModeInfoBlock *mib)
{

View File

@ -1,6 +1,7 @@
//video.h
// 08/18/03 Josh Holtrop
void video_init();
void video_horiz(int y, int x1, int x2, dword color);
void video_vert(int x, int y1, int y2, dword color);
@ -52,6 +53,12 @@ typedef struct{
byte Reserved[206];
} ModeInfoBlock;
ModeInfoBlock video_mode;
byte *vid_ptr24;
word *vid_ptr16;
dword *vid_ptr32;