diff --git a/Asuro.iso b/Asuro.iso index b3b22a6c..51937ad6 100644 Binary files a/Asuro.iso and b/Asuro.iso differ diff --git a/bin/kernel.bin b/bin/kernel.bin index e6061a94..556af1e6 100755 Binary files a/bin/kernel.bin and b/bin/kernel.bin differ diff --git a/iso/boot/asuro.bin b/iso/boot/asuro.bin index e6061a94..556af1e6 100755 Binary files a/iso/boot/asuro.bin and b/iso/boot/asuro.bin differ diff --git a/lib/kernel.ppu b/lib/kernel.ppu index dcf95976..7eacc37b 100644 Binary files a/lib/kernel.ppu and b/lib/kernel.ppu differ diff --git a/lib/libpconsole.a b/lib/libpconsole.a index e11fd65c..c101caa2 100644 Binary files a/lib/libpconsole.a and b/lib/libpconsole.a differ diff --git a/lib/libpmultiboot.a b/lib/libpmultiboot.a index 0ca8e3a3..b3ddea31 100644 Binary files a/lib/libpmultiboot.a and b/lib/libpmultiboot.a differ diff --git a/lib/libpsystem.a b/lib/libpsystem.a index a1f68357..cde51e53 100644 Binary files a/lib/libpsystem.a and b/lib/libpsystem.a differ diff --git a/lib/mouse.ppu b/lib/mouse.ppu index 0431f89c..c68d16ef 100644 Binary files a/lib/mouse.ppu and b/lib/mouse.ppu differ diff --git a/src/driver/hid/mouse.pas b/src/driver/hid/mouse.pas index 5f6fae7a..706471e8 100644 --- a/src/driver/hid/mouse.pas +++ b/src/driver/hid/mouse.pas @@ -40,6 +40,7 @@ type end; procedure init(); +procedure DrawCursor; implementation @@ -51,12 +52,18 @@ var Mouse_Byte : Array[0..2] of uint8; Packet : uint32; Registered : Boolean = false; + NeedsRedraw : Boolean = false; procedure DrawCursor; var x, y : uint32; + nx, ny : uint32; -begin +begin + nx:= Current.x; + ny:= Current.y; + if not NeedsRedraw then exit; + NeedsRedraw:= false; if not FirstDraw then begin for y:=0 to 1 do begin for x:=0 to 1 do begin @@ -64,23 +71,23 @@ begin end; end; end; - Last.x:= Current.x; - Last.y:= Current.y; + Last.x:= nx; + Last.y:= ny; 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); + BackPixels[x][y]:= GetPixel(nx + x, ny + y); + DrawPixel(nx + x, ny + y, $FFFF); end; end; FirstDraw:= false; end; -procedure mouse_wait(w_type : uint8); +function mouse_wait(w_type : uint8) : boolean; var timeout : uint32; begin - timeout:= 100000; + timeout:= 100; if (w_type = 0) then begin while (timeout > 0) do begin if ((inb($64) AND $01) = $01) then break; @@ -92,6 +99,7 @@ begin timeout := timeout - 1; end; end; + mouse_wait:= timeout > 0; end; procedure mouse_write(value : uint8); @@ -118,67 +126,54 @@ var r : pchar; begin - push_trace('mouse.main'); - b:= mouse_read; - if Cycle = 0 then begin - if (b AND $08) = $08 then begin - Mouse_Byte[Cycle]:= b; - Inc(Cycle); - end; - end else begin - If Cycle = 1 then begin - Mouse_Byte[Cycle]:= b; - Inc(Cycle); + //push_trace('mouse.main'); + while mouse_wait(0) do begin + b:= mouse_read; + if Cycle = 0 then begin + if (b AND $08) = $08 then begin + Mouse_Byte[Cycle]:= b; + Inc(Cycle); + end; end else begin Mouse_Byte[Cycle]:= b; Inc(Cycle); end; - end; - 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, (Packet.x_movement div 4)); - end else begin - Dec(Current.x, (Packet.x_movement div 4)); + 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 %00010000) = %00010000; + Packet.y_sign:= (f AND %00100000) = %00100000; + 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) and (Packet.x_movement > 0) then begin + dec(Current.x); end; - end; - if y32 <> 0 then begin - if y32 < 0 then begin - inc(Current.y, (Packet.y_movement div 4)); - end else begin - dec(Current.y, (Packet.y_movement div 4)) + If not(Packet.x_sign) and (Packet.x_movement > 0) then begin + inc(Current.x); end; + If not(Packet.y_sign) and (Packet.y_movement > 0) then begin + dec(Current.y); + end; + If (Packet.y_sign) and (Packet.y_movement > 0) then begin + inc(Current.y); + 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; + //console.writestring('Mouse X: '); + //console.writeintln(current.x); + //console.writestring('Mouse Y: '); + //console.writeintln(current.y); + //DrawCursor; 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; - DrawCursor; + Cycle:= 0; + NeedsRedraw:= true; 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; end; - pop_trace; end; function load(ptr : void) : boolean; diff --git a/src/kernel.pas b/src/kernel.pas index 9de3d301..2e43d9a8 100644 --- a/src/kernel.pas +++ b/src/kernel.pas @@ -246,7 +246,7 @@ begin tracer.push_trace('kmain.DEVDRV'); console.outputln('KERNEL', 'DEVICE DRIVERS: INIT BEGIN.'); keyboard.init(keyboard_layout); - //mouse.init(); + mouse.init(); testdriver.init(); E1000.init(); IDE.init(); @@ -286,7 +286,12 @@ begin tracer.pop_trace; tracer.push_trace('kmain.END'); - util.halt_and_dont_catch_fire; + + while true do begin + mouse.DrawCursor(); + end; + + //util.halt_and_dont_catch_fire; end; end.