diff --git a/Asuro.iso b/Asuro.iso index 9e135cdc..c4881fdc 100644 Binary files a/Asuro.iso and b/Asuro.iso differ diff --git a/bin/kernel.bin b/bin/kernel.bin index 7eb6ab49..7f0632de 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 7eb6ab49..7f0632de 100755 Binary files a/iso/boot/asuro.bin and b/iso/boot/asuro.bin differ diff --git a/lib/ACE.ppu b/lib/ACE.ppu index b83650be..a65270e3 100644 Binary files a/lib/ACE.ppu and b/lib/ACE.ppu differ diff --git a/lib/BPE.ppu b/lib/BPE.ppu index 954cbbf9..1c1edc83 100644 Binary files a/lib/BPE.ppu and b/lib/BPE.ppu differ diff --git a/lib/BTSSE.ppu b/lib/BTSSE.ppu index d94f0e42..e7bdc96f 100644 Binary files a/lib/BTSSE.ppu and b/lib/BTSSE.ppu differ diff --git a/lib/CFE.ppu b/lib/CFE.ppu index 3beb6184..fda5f7ca 100644 Binary files a/lib/CFE.ppu and b/lib/CFE.ppu differ diff --git a/lib/CSOE.ppu b/lib/CSOE.ppu index ea6798d7..3d7e0824 100644 Binary files a/lib/CSOE.ppu and b/lib/CSOE.ppu differ diff --git a/lib/DBGE.ppu b/lib/DBGE.ppu index 903539db..d1147c34 100644 Binary files a/lib/DBGE.ppu and b/lib/DBGE.ppu differ diff --git a/lib/DBZ.ppu b/lib/DBZ.ppu index 7efa1f78..0ddaa1d3 100644 Binary files a/lib/DBZ.ppu and b/lib/DBZ.ppu differ diff --git a/lib/DFE.ppu b/lib/DFE.ppu index e3df03b2..55c4d25e 100644 Binary files a/lib/DFE.ppu and b/lib/DFE.ppu differ diff --git a/lib/E1000.ppu b/lib/E1000.ppu index 8351a44e..bd48c422 100644 Binary files a/lib/E1000.ppu and b/lib/E1000.ppu differ diff --git a/lib/GPF.ppu b/lib/GPF.ppu index 289ae976..069af8f6 100644 Binary files a/lib/GPF.ppu and b/lib/GPF.ppu differ diff --git a/lib/IDE.ppu b/lib/IDE.ppu index 2cf83c84..07d0cc2f 100644 Binary files a/lib/IDE.ppu and b/lib/IDE.ppu differ diff --git a/lib/IDOE.ppu b/lib/IDOE.ppu index 25c6fe9f..9341fabc 100644 Binary files a/lib/IDOE.ppu and b/lib/IDOE.ppu differ diff --git a/lib/IOPE.ppu b/lib/IOPE.ppu index 01284100..cba1b4d6 100644 Binary files a/lib/IOPE.ppu and b/lib/IOPE.ppu differ diff --git a/lib/MCE.ppu b/lib/MCE.ppu index 657519e3..e16124f4 100644 Binary files a/lib/MCE.ppu and b/lib/MCE.ppu differ diff --git a/lib/NCE.ppu b/lib/NCE.ppu index ef4aa095..3746d960 100644 Binary files a/lib/NCE.ppu and b/lib/NCE.ppu differ diff --git a/lib/NMIE.ppu b/lib/NMIE.ppu index 43250ec9..41c7c8e6 100644 Binary files a/lib/NMIE.ppu and b/lib/NMIE.ppu differ diff --git a/lib/OOBE.ppu b/lib/OOBE.ppu index b16c9c0c..a725b11a 100644 Binary files a/lib/OOBE.ppu and b/lib/OOBE.ppu differ diff --git a/lib/PCI.ppu b/lib/PCI.ppu index 364675ba..d3b9fd4f 100644 Binary files a/lib/PCI.ppu and b/lib/PCI.ppu differ diff --git a/lib/PF.ppu b/lib/PF.ppu index 9827f23c..393664cc 100644 Binary files a/lib/PF.ppu and b/lib/PF.ppu differ diff --git a/lib/PS2_KEYBOARD_ISR.ppu b/lib/PS2_KEYBOARD_ISR.ppu index e76a4936..f3ce7388 100644 Binary files a/lib/PS2_KEYBOARD_ISR.ppu and b/lib/PS2_KEYBOARD_ISR.ppu differ diff --git a/lib/RTC.ppu b/lib/RTC.ppu index beb95f5a..7f11bbe7 100644 Binary files a/lib/RTC.ppu and b/lib/RTC.ppu differ diff --git a/lib/SFE.ppu b/lib/SFE.ppu index aa9c0c35..912e8949 100644 Binary files a/lib/SFE.ppu and b/lib/SFE.ppu differ diff --git a/lib/SNPE.ppu b/lib/SNPE.ppu index 8bb95b44..3cb4a442 100644 Binary files a/lib/SNPE.ppu and b/lib/SNPE.ppu differ diff --git a/lib/TMR_0_ISR.ppu b/lib/TMR_0_ISR.ppu index fffe39aa..bb0aba8e 100644 Binary files a/lib/TMR_0_ISR.ppu and b/lib/TMR_0_ISR.ppu differ diff --git a/lib/UIE.ppu b/lib/UIE.ppu index f8c2db3f..80c1b304 100644 Binary files a/lib/UIE.ppu and b/lib/UIE.ppu differ diff --git a/lib/USB.ppu b/lib/USB.ppu index 14c1edb0..fc53dbe3 100644 Binary files a/lib/USB.ppu and b/lib/USB.ppu differ diff --git a/lib/arp.ppu b/lib/arp.ppu index 43472822..8e27ce89 100644 Binary files a/lib/arp.ppu and b/lib/arp.ppu differ diff --git a/lib/bios_data_area.ppu b/lib/bios_data_area.ppu index 3d8e4ebc..05da09e4 100644 Binary files a/lib/bios_data_area.ppu and b/lib/bios_data_area.ppu differ diff --git a/lib/console.o b/lib/console.o index 29540489..35dd79dc 100644 Binary files a/lib/console.o and b/lib/console.o differ diff --git a/lib/console.ppu b/lib/console.ppu index d1a99cfd..f2bdb5bb 100644 Binary files a/lib/console.ppu and b/lib/console.ppu differ diff --git a/lib/drivermanagement.ppu b/lib/drivermanagement.ppu index 1e3af954..53c87866 100644 Binary files a/lib/drivermanagement.ppu and b/lib/drivermanagement.ppu differ diff --git a/lib/eth2.ppu b/lib/eth2.ppu index 44db447a..5723578a 100644 Binary files a/lib/eth2.ppu and b/lib/eth2.ppu differ diff --git a/lib/fat32.ppu b/lib/fat32.ppu index d10802c9..89236434 100644 Binary files a/lib/fat32.ppu and b/lib/fat32.ppu differ diff --git a/lib/gdt.ppu b/lib/gdt.ppu index 3c8c7550..91351363 100644 Binary files a/lib/gdt.ppu and b/lib/gdt.ppu differ diff --git a/lib/idt.ppu b/lib/idt.ppu index d29d1b44..383c11e7 100644 Binary files a/lib/idt.ppu and b/lib/idt.ppu differ diff --git a/lib/ipv4.ppu b/lib/ipv4.ppu index d5827b92..5cb4cde2 100644 Binary files a/lib/ipv4.ppu and b/lib/ipv4.ppu differ diff --git a/lib/irq.ppu b/lib/irq.ppu index 33497d13..5e79c1db 100644 Binary files a/lib/irq.ppu and b/lib/irq.ppu differ diff --git a/lib/isr.ppu b/lib/isr.ppu index aaa3f074..26efb8d0 100644 Binary files a/lib/isr.ppu and b/lib/isr.ppu differ diff --git a/lib/kernel.ppu b/lib/kernel.ppu index c2f0f176..181fcac3 100644 Binary files a/lib/kernel.ppu and b/lib/kernel.ppu differ diff --git a/lib/keyboard.ppu b/lib/keyboard.ppu index 0fdb62dc..98482f93 100644 Binary files a/lib/keyboard.ppu and b/lib/keyboard.ppu differ diff --git a/lib/libpconsole.a b/lib/libpconsole.a index cacf436a..051cab51 100644 Binary files a/lib/libpconsole.a and b/lib/libpconsole.a differ diff --git a/lib/libpmultiboot.a b/lib/libpmultiboot.a index 8356ded6..14c0e539 100644 Binary files a/lib/libpmultiboot.a and b/lib/libpmultiboot.a differ diff --git a/lib/libpsystem.a b/lib/libpsystem.a index 8a6cbf07..a86a2ba5 100644 Binary files a/lib/libpsystem.a and b/lib/libpsystem.a differ diff --git a/lib/lists.ppu b/lib/lists.ppu index c270f3a1..c6feec79 100644 Binary files a/lib/lists.ppu and b/lib/lists.ppu differ diff --git a/lib/lmemorymanager.ppu b/lib/lmemorymanager.ppu index bfc8a533..8aa33ac5 100644 Binary files a/lib/lmemorymanager.ppu and b/lib/lmemorymanager.ppu differ diff --git a/lib/mouse.ppu b/lib/mouse.ppu index 8d25081f..e4466003 100644 Binary files a/lib/mouse.ppu and b/lib/mouse.ppu differ diff --git a/lib/net.ppu b/lib/net.ppu index a03ad572..8d26dfb1 100644 Binary files a/lib/net.ppu and b/lib/net.ppu differ diff --git a/lib/netutils.ppu b/lib/netutils.ppu index 120c7530..c0dcb3b2 100644 Binary files a/lib/netutils.ppu and b/lib/netutils.ppu differ diff --git a/lib/pmemorymanager.ppu b/lib/pmemorymanager.ppu index 7028a010..5457d281 100644 Binary files a/lib/pmemorymanager.ppu and b/lib/pmemorymanager.ppu differ diff --git a/lib/scheduler.ppu b/lib/scheduler.ppu index a53c597d..691a1b78 100644 Binary files a/lib/scheduler.ppu and b/lib/scheduler.ppu differ diff --git a/lib/storagemanagement.ppu b/lib/storagemanagement.ppu index 47ec6014..09a5003d 100644 Binary files a/lib/storagemanagement.ppu and b/lib/storagemanagement.ppu differ diff --git a/lib/strings.ppu b/lib/strings.ppu index 306b06b3..070f372b 100644 Binary files a/lib/strings.ppu and b/lib/strings.ppu differ diff --git a/lib/terminal.ppu b/lib/terminal.ppu index 721fe605..bd5470fc 100644 Binary files a/lib/terminal.ppu and b/lib/terminal.ppu differ diff --git a/lib/testdriver.ppu b/lib/testdriver.ppu index 300f6906..12721199 100644 Binary files a/lib/testdriver.ppu and b/lib/testdriver.ppu differ diff --git a/lib/tracer.ppu b/lib/tracer.ppu index 59cd36c2..f46049b6 100644 Binary files a/lib/tracer.ppu and b/lib/tracer.ppu differ diff --git a/lib/tss.ppu b/lib/tss.ppu index bb99392d..985018ef 100644 Binary files a/lib/tss.ppu and b/lib/tss.ppu differ diff --git a/lib/util.ppu b/lib/util.ppu index aa1e991c..6c6fa975 100644 Binary files a/lib/util.ppu and b/lib/util.ppu differ diff --git a/lib/vmemorymanager.ppu b/lib/vmemorymanager.ppu index 4d498656..8a3d8530 100644 Binary files a/lib/vmemorymanager.ppu and b/lib/vmemorymanager.ppu differ diff --git a/src/console.pas b/src/console.pas index 10db606d..80d51a59 100644 --- a/src/console.pas +++ b/src/console.pas @@ -15,7 +15,8 @@ uses util, bios_data_area, multiboot, - fonts; + fonts, + tracer; type TColor = ( Black = $0, @@ -96,6 +97,8 @@ procedure _safeincrement_x(); procedure _newline(); 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 @@ -131,6 +134,32 @@ var Console_Cursor : TCoord; 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); var dest : puint16; diff --git a/src/driver/hid/mouse.pas b/src/driver/hid/mouse.pas index 86308dca..bce8a510 100644 --- a/src/driver/hid/mouse.pas +++ b/src/driver/hid/mouse.pas @@ -15,9 +15,9 @@ uses tracer, console, util, - PS2_MOUSE_ISR, lmemorymanager, strings, + isrmanager, drivermanagement; type @@ -34,85 +34,177 @@ type LMB_Down : Boolean; end; + TMousePos = record + x : sint32; + y : sint32; + end; + procedure init(); implementation -procedure callback(raw : void); 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; + x32, y32 : sint32; r : pchar; begin - push_trace('mouse.callback'); - packet:= PMousePacket(kalloc(sizeof(TMousePacket))); - f:= (uint32(raw) AND $FF000000) SHR 24; - x:= (uint32(raw) AND $00FF0000) SHR 16; - y:= (uint32(raw) AND $0000FF00) SHR 8; - packet^.x_movement:= x; - packet^.y_movement:= y; - packet^.y_overflow:= (f AND $80) = $80; - packet^.x_overflow:= (f AND $40) = $40; - packet^.y_sign:= (f AND $20) = $20; - packet^.x_sign:= (f AND $10) = $10; - packet^.MMB_Down:= (f AND $4) = $4; - packet^.RMB_Down:= (f AND $2) = $2; - packet^.LMB_Down:= (f AND $1) = $1; - //Do Hook here - // console.writestring('X Movement: '); - // console.writeintln(packet^.x_movement); + 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); + 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); + 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: '); - // console.writeintln(packet^.y_movement); - - // 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)); + DrawCursor; + end; pop_trace; end; function load(ptr : void) : boolean; +var + status : uint8; begin push_trace('mouse.load'); - PS2_MOUSE_ISR.register(); - PS2_MOUSE_ISR.hook(uint32(@callback)); - console.outputln('PS/2 MOUSE', 'LOADED.'); + mouse_wait(1); + outb($64, $A8); + 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; pop_trace; end; @@ -131,6 +223,10 @@ begin devid.id3:= 0; devid.id4:= 0; 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); console.outputln('PS/2 MOUSE', 'INIT END.'); pop_trace; diff --git a/src/driver/timers/RTC.pas b/src/driver/timers/RTC.pas index bfb25987..ff94426b 100644 --- a/src/driver/timers/RTC.pas +++ b/src/driver/timers/RTC.pas @@ -101,6 +101,8 @@ begin outb($71, prev OR $40); STI; outb($70, $00); + inb($71); + isrmanager.registerISR(32 + 8, @update); //TMR_0_ISR.hook(uint32(@update)); end; diff --git a/src/terminal.pas b/src/terminal.pas index aa8401f9..771df795 100644 --- a/src/terminal.pas +++ b/src/terminal.pas @@ -195,6 +195,7 @@ end; procedure help(params : PParamList); var + i : uint32; begin console.writestringln('Registered Commands: ');