git-svn-id: https://spexeah.com:8443/svn/Asuro@527 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c

This commit is contained in:
kieron 2018-04-14 22:46:34 +00:00
parent 2feff08097
commit b626d8c207
65 changed files with 193 additions and 65 deletions

BIN
Asuro.iso

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -15,7 +15,8 @@ uses
util, util,
bios_data_area, bios_data_area,
multiboot, multiboot,
fonts; fonts,
tracer;
type type
TColor = ( Black = $0, TColor = ( Black = $0,
@ -96,6 +97,8 @@ procedure _safeincrement_x();
procedure _newline(); procedure _newline();
procedure outputChar(c : char; x : uint8; y : uint8; fgcolor : uint16; bgcolor : uint16); procedure outputChar(c : char; x : uint8; y : uint8; fgcolor : uint16; bgcolor : uint16);
function getPixel(x : uint32; y : uint32) : uint16;
procedure drawPixel(x : uint32; y : uint32; color : uint16);
implementation implementation
@ -131,6 +134,32 @@ var
Console_Cursor : TCoord; Console_Cursor : TCoord;
Ready : Boolean = false; Ready : Boolean = false;
function getPixel(x : uint32; y : uint32) : uint16;
var
dest : puint16;
begin
//push_trace('console.getPixel');
if not ready then exit;
dest:= puint16(multibootinfo^.framebuffer_addr);
dest:= dest + (y * 1280) + x;
getPixel:= dest^;
//pop_trace;
end;
procedure drawPixel(x : uint32; y : uint32; color : uint16);
var
dest : puint16;
begin
//push_trace('console.drawPixel');
if not ready then exit;
dest:= puint16(multibootinfo^.framebuffer_addr);
dest:= dest + (y * 1280) + x;
dest^:= color;
//pop_trace;
end;
procedure outputChar(c : char; x : uint8; y : uint8; fgcolor : uint16; bgcolor : uint16); procedure outputChar(c : char; x : uint8; y : uint8; fgcolor : uint16; bgcolor : uint16);
var var
dest : puint16; dest : puint16;

View File

@ -15,9 +15,9 @@ uses
tracer, tracer,
console, console,
util, util,
PS2_MOUSE_ISR,
lmemorymanager, lmemorymanager,
strings, strings,
isrmanager,
drivermanagement; drivermanagement;
type type
@ -34,85 +34,177 @@ type
LMB_Down : Boolean; LMB_Down : Boolean;
end; end;
TMousePos = record
x : sint32;
y : sint32;
end;
procedure init(); procedure init();
implementation implementation
procedure callback(raw : void);
var var
packet : PMousePacket; Current, Last : TMousePos;
FirstDraw : boolean = true;
BackPixels : Array[0..1] of Array[0..1] of uint16;
Cycle : uint32 = 0;
Mouse_Byte : Array[0..2] of uint8;
Packet : uint32;
Registered : Boolean = false;
procedure DrawCursor;
var
x, y : uint32;
begin
if not FirstDraw then begin
for y:=0 to 1 do begin
for x:=0 to 1 do begin
DrawPixel(Last.x + x, Last.y + y, BackPixels[x][y]);
end;
end;
end;
Last.x:= Current.x;
Last.y:= Current.y;
for y:=0 to 1 do begin
for x:=0 to 1 do begin
BackPixels[x][y]:= GetPixel(Current.x + x, Current.y + y);
DrawPixel(Current.x + x, Current.y + y, $FFFF);
end;
end;
FirstDraw:= false;
end;
procedure mouse_wait(w_type : uint8);
var
timeout : uint32;
begin
timeout:= 100000;
if (w_type = 0) then begin
while (timeout > 0) do begin
if ((inb($64) AND $01) = $01) then break;
timeout:= timeout-1;
end;
end else begin
while (timeout > 0) do begin
if ((inb($64) AND 2) = 0) then break;
timeout := timeout - 1;
end;
end;
end;
procedure mouse_write(value : uint8);
begin
mouse_wait(1);
outb($64, $D4);
mouse_wait(1);
outb($60, value);
end;
function mouse_read : uint8;
begin
mouse_wait(0);
mouse_read:= inb($60);
end;
procedure main();
var
i : integer;
b : byte;
packet : TMousePacket;
x, y, f : byte; x, y, f : byte;
x32, y32 : sint32;
r : pchar; r : pchar;
begin begin
push_trace('mouse.callback'); push_trace('mouse.main');
packet:= PMousePacket(kalloc(sizeof(TMousePacket))); b:= mouse_read;
f:= (uint32(raw) AND $FF000000) SHR 24; if Cycle = 0 then begin
x:= (uint32(raw) AND $00FF0000) SHR 16; if (b AND $08) = $08 then begin
y:= (uint32(raw) AND $0000FF00) SHR 8; Mouse_Byte[Cycle]:= b;
packet^.x_movement:= x; Inc(Cycle);
packet^.y_movement:= y; end;
packet^.y_overflow:= (f AND $80) = $80; end else begin
packet^.x_overflow:= (f AND $40) = $40; If Cycle = 1 then begin
packet^.y_sign:= (f AND $20) = $20; Mouse_Byte[Cycle]:= b;
packet^.x_sign:= (f AND $10) = $10; Inc(Cycle);
packet^.MMB_Down:= (f AND $4) = $4; end else begin
packet^.RMB_Down:= (f AND $2) = $2; Mouse_Byte[Cycle]:= b;
packet^.LMB_Down:= (f AND $1) = $1; Inc(Cycle);
//Do Hook here end;
// console.writestring('X Movement: '); end;
// console.writeintln(packet^.x_movement); if Cycle = 3 then begin
//Process
f:= Mouse_Byte[0];
Packet.x_movement:= Mouse_Byte[1];
Packet.y_movement:= Mouse_Byte[2];
Packet.x_sign:= (f AND $10) = $10;
Packet.y_sign:= (f AND $20) = $20;
Packet.x_overflow:= (f AND $40) = $40;
Packet.y_overflow:= (f AND $80) = $80;
if not(Packet.x_overflow) and not(Packet.y_overflow) then begin
//if Packet.x_sign then Current.x:= Current.x - Packet.x_movement else Current.x:= Current.x + Packet.x_movement;
//if Packet.y_sign then Current.y:= Current.y - Packet.y_movement else Current.y:= Current.y + Packet.y_movement;
x32:= Packet.x_movement;
if Packet.x_sign then x32:= x32 OR $FFFFFF00;
y32:= Packet.y_movement;
if Packet.y_sign then y32:= y32 OR $FFFFFF00;
if x32 <> 0 then begin
if x32 > 0 then begin
inc(Current.x);
end else begin
Dec(Current.x);
end;
end;
if y32 <> 0 then begin
if y32 > 0 then begin
inc(Current.y);
end else begin
dec(Current.y)
end;
end;
if Current.x < 0 then Current.x:= 0;
if Current.y < 0 then Current.y:= 0;
if Current.x > 1279 then Current.x:= 1279;
if Current.y > 1023 then Current.y:= 1023;
end;
{console.writestring('Packet[0]: ');
console.writeintln(Mouse_Byte[0]);
console.writestring('Packet[1]: ');
console.writeintln(Mouse_Byte[1]);
console.writestring('Packet[2]: ');
console.writeintln(Mouse_Byte[2]);}
Cycle:= 0;
// console.writestring('Y Movement: '); DrawCursor;
// console.writeintln(packet^.y_movement); end;
// console.writestring('Y Overflow: ');
// r:= boolToString(packet^.y_overflow, true);
// console.writestringln(r);
// kfree(void(r));
// console.writestring('X Overflow: ');
// r:= boolToString(packet^.x_overflow, true);
// console.writestringln(r);
// kfree(void(r));
// console.writestring('Y Sign: ');
// r:= boolToString(packet^.y_sign, true);
// console.writestringln(r);
// kfree(void(r));
// console.writestring('X Sign: ');
// r:= boolToString(packet^.x_sign, true);
// console.writestringln(r);
// kfree(void(r));
// console.writestring('Middle Button Down: ');
// r:= boolToString(packet^.MMB_Down, true);
// console.writestringln(r);
// kfree(void(r));
// console.writestring('Right Button Down: ');
// r:= boolToString(packet^.RMB_Down, true);
// console.writestringln(r);
// kfree(void(r));
// console.writestring('Left Button Down: ');
// r:= boolToString(packet^.LMB_Down, true);
// console.writestringln(r);
// kfree(void(r));
kfree(void(packet));
//console.writestring('Mouse Packet: ');
//console.writehexln(DWORD(raw));
pop_trace; pop_trace;
end; end;
function load(ptr : void) : boolean; function load(ptr : void) : boolean;
var
status : uint8;
begin begin
push_trace('mouse.load'); push_trace('mouse.load');
PS2_MOUSE_ISR.register(); mouse_wait(1);
PS2_MOUSE_ISR.hook(uint32(@callback)); outb($64, $A8);
console.outputln('PS/2 MOUSE', 'LOADED.'); mouse_wait(1);
outb($64, $20);
mouse_wait(0);
status:= inb($60) OR $02;
mouse_wait(1);
outb($64, $60);
mouse_wait(1);
outb($60, status);
mouse_write($F6);
mouse_read();
mouse_write($F4);
mouse_read();
isrmanager.registerISR(44, @Main);
console.outputln('PS/2 MOUSE', 'LOADED.');
console.output('PS/2 MOUSE', 'Memory: ');
console.writehexln(uint32(@current));
load:= true; load:= true;
pop_trace; pop_trace;
end; end;
@ -131,6 +223,10 @@ begin
devid.id3:= 0; devid.id3:= 0;
devid.id4:= 0; devid.id4:= 0;
devid.ex:= nil; devid.ex:= nil;
Current.x:= 0;
Current.y:= 0;
Last.x:= 0;
Last.y:= 0;
drivermanagement.register_driver_ex('PS/2 Mouse', @devid, @load, true); drivermanagement.register_driver_ex('PS/2 Mouse', @devid, @load, true);
console.outputln('PS/2 MOUSE', 'INIT END.'); console.outputln('PS/2 MOUSE', 'INIT END.');
pop_trace; pop_trace;

View File

@ -101,6 +101,8 @@ begin
outb($71, prev OR $40); outb($71, prev OR $40);
STI; STI;
outb($70, $00); outb($70, $00);
inb($71);
isrmanager.registerISR(32 + 8, @update); isrmanager.registerISR(32 + 8, @update);
//TMR_0_ISR.hook(uint32(@update)); //TMR_0_ISR.hook(uint32(@update));
end; end;

View File

@ -195,6 +195,7 @@ end;
procedure help(params : PParamList); procedure help(params : PParamList);
var var
i : uint32; i : uint32;
begin begin
console.writestringln('Registered Commands: '); console.writestringln('Registered Commands: ');