diff --git a/Asuro.iso b/Asuro.iso index 34395131..85b5f8fc 100644 Binary files a/Asuro.iso and b/Asuro.iso differ diff --git a/bin/kernel.bin b/bin/kernel.bin index 19c8395c..d6353d9c 100755 Binary files a/bin/kernel.bin and b/bin/kernel.bin differ diff --git a/compile.sh b/compile.sh index da8991f3..1d1e0104 100755 --- a/compile.sh +++ b/compile.sh @@ -26,11 +26,11 @@ if [ "$1" = "-d" ] then echo "Compiling Debug FPC Sources..." echo " " - fpc -Aelf -gw -n -va -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/* src/kernel.pas + fpc -Aelf -gw -n -va -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/* src/kernel.pas else echo "Compiling FPC Sources..." echo " " - fpc -Aelf -gw -n -va -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/* -Fusrc/driver/net/* src/kernel.pas + fpc -Aelf -gw -n -va -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/* -Fusrc/driver/net/* src/kernel.pas fi if [ $? -ne 0 ] diff --git a/iso/boot/asuro.bin b/iso/boot/asuro.bin index 19c8395c..d6353d9c 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 5aa56429..c64a42a9 100644 Binary files a/lib/ACE.ppu and b/lib/ACE.ppu differ diff --git a/lib/BPE.ppu b/lib/BPE.ppu index f36e6a94..675492cd 100644 Binary files a/lib/BPE.ppu and b/lib/BPE.ppu differ diff --git a/lib/BTSSE.ppu b/lib/BTSSE.ppu index 4e00df2e..4f200fc2 100644 Binary files a/lib/BTSSE.ppu and b/lib/BTSSE.ppu differ diff --git a/lib/CFE.ppu b/lib/CFE.ppu index 394fd4dc..513e9242 100644 Binary files a/lib/CFE.ppu and b/lib/CFE.ppu differ diff --git a/lib/CSOE.ppu b/lib/CSOE.ppu index 2c369548..80b11722 100644 Binary files a/lib/CSOE.ppu and b/lib/CSOE.ppu differ diff --git a/lib/DBGE.ppu b/lib/DBGE.ppu index 74d65137..9ede75a6 100644 Binary files a/lib/DBGE.ppu and b/lib/DBGE.ppu differ diff --git a/lib/DBZ.ppu b/lib/DBZ.ppu index 31be1515..79b59bd0 100644 Binary files a/lib/DBZ.ppu and b/lib/DBZ.ppu differ diff --git a/lib/DFE.ppu b/lib/DFE.ppu index 961517d5..1b8fb9db 100644 Binary files a/lib/DFE.ppu and b/lib/DFE.ppu differ diff --git a/lib/E1000.ppu b/lib/E1000.ppu index cc300149..7735f03e 100644 Binary files a/lib/E1000.ppu and b/lib/E1000.ppu differ diff --git a/lib/GPF.ppu b/lib/GPF.ppu index 76f9e39e..097168bd 100644 Binary files a/lib/GPF.ppu and b/lib/GPF.ppu differ diff --git a/lib/IDE.ppu b/lib/IDE.ppu index 35bf1401..ff0848ae 100644 Binary files a/lib/IDE.ppu and b/lib/IDE.ppu differ diff --git a/lib/IDOE.ppu b/lib/IDOE.ppu index 5bf1051a..6c6d1bef 100644 Binary files a/lib/IDOE.ppu and b/lib/IDOE.ppu differ diff --git a/lib/IOPE.ppu b/lib/IOPE.ppu index 3e76d164..c95dce02 100644 Binary files a/lib/IOPE.ppu and b/lib/IOPE.ppu differ diff --git a/lib/MCE.ppu b/lib/MCE.ppu index fffc785d..8a3523b0 100644 Binary files a/lib/MCE.ppu and b/lib/MCE.ppu differ diff --git a/lib/NCE.ppu b/lib/NCE.ppu index c662e636..58ee364a 100644 Binary files a/lib/NCE.ppu and b/lib/NCE.ppu differ diff --git a/lib/NMIE.ppu b/lib/NMIE.ppu index c73d9905..94698c2f 100644 Binary files a/lib/NMIE.ppu and b/lib/NMIE.ppu differ diff --git a/lib/OOBE.ppu b/lib/OOBE.ppu index 1e7b57d4..95ea3695 100644 Binary files a/lib/OOBE.ppu and b/lib/OOBE.ppu differ diff --git a/lib/PCI.ppu b/lib/PCI.ppu index 18cd37ec..5264561a 100644 Binary files a/lib/PCI.ppu and b/lib/PCI.ppu differ diff --git a/lib/PF.ppu b/lib/PF.ppu index d31cca0c..2ff461ce 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 20292fd8..44a9c7d5 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 eb3c13a8..e2f7ccf2 100644 Binary files a/lib/RTC.ppu and b/lib/RTC.ppu differ diff --git a/lib/SFE.ppu b/lib/SFE.ppu index acc1ba4a..e731a091 100644 Binary files a/lib/SFE.ppu and b/lib/SFE.ppu differ diff --git a/lib/SNPE.ppu b/lib/SNPE.ppu index ee36d969..093f6516 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 b9261d00..5e38e3c3 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 14e234bc..8eb624d4 100644 Binary files a/lib/UIE.ppu and b/lib/UIE.ppu differ diff --git a/lib/USB.ppu b/lib/USB.ppu index 2fb2d934..a23f5998 100644 Binary files a/lib/USB.ppu and b/lib/USB.ppu differ diff --git a/lib/arp.ppu b/lib/arp.ppu index f1e33462..e1670b47 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 c6ddef36..0f6e0be0 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 b17a6085..7e0217f7 100644 Binary files a/lib/console.o and b/lib/console.o differ diff --git a/lib/console.ppu b/lib/console.ppu index f27255a7..e70b52cd 100644 Binary files a/lib/console.ppu and b/lib/console.ppu differ diff --git a/lib/drivermanagement.ppu b/lib/drivermanagement.ppu index e3cb62d8..349ac860 100644 Binary files a/lib/drivermanagement.ppu and b/lib/drivermanagement.ppu differ diff --git a/lib/eth2.ppu b/lib/eth2.ppu index 3fa29d20..28a016a7 100644 Binary files a/lib/eth2.ppu and b/lib/eth2.ppu differ diff --git a/lib/fat32.ppu b/lib/fat32.ppu index 95edbc84..0f9da424 100644 Binary files a/lib/fat32.ppu and b/lib/fat32.ppu differ diff --git a/lib/gdt.ppu b/lib/gdt.ppu index 3dbae7cc..802e7274 100644 Binary files a/lib/gdt.ppu and b/lib/gdt.ppu differ diff --git a/lib/idt.ppu b/lib/idt.ppu index 85cc5414..108a773f 100644 Binary files a/lib/idt.ppu and b/lib/idt.ppu differ diff --git a/lib/ipv4.ppu b/lib/ipv4.ppu index 1148362d..f4550ee6 100644 Binary files a/lib/ipv4.ppu and b/lib/ipv4.ppu differ diff --git a/lib/irq.ppu b/lib/irq.ppu index 1fad96d6..e309ecee 100644 Binary files a/lib/irq.ppu and b/lib/irq.ppu differ diff --git a/lib/isr.ppu b/lib/isr.ppu index 2c1d0dbf..f3859417 100644 Binary files a/lib/isr.ppu and b/lib/isr.ppu differ diff --git a/lib/kernel.ppu b/lib/kernel.ppu index 2ae5b69a..5c647f4b 100644 Binary files a/lib/kernel.ppu and b/lib/kernel.ppu differ diff --git a/lib/keyboard.ppu b/lib/keyboard.ppu index d6feeca8..018aeb73 100644 Binary files a/lib/keyboard.ppu and b/lib/keyboard.ppu differ diff --git a/lib/libpconsole.a b/lib/libpconsole.a index c3c8a690..3f9742d3 100644 Binary files a/lib/libpconsole.a and b/lib/libpconsole.a differ diff --git a/lib/libpmultiboot.a b/lib/libpmultiboot.a index 5e3f08fd..8d0bd23d 100644 Binary files a/lib/libpmultiboot.a and b/lib/libpmultiboot.a differ diff --git a/lib/libpsystem.a b/lib/libpsystem.a index a742783a..b8bf5746 100644 Binary files a/lib/libpsystem.a and b/lib/libpsystem.a differ diff --git a/lib/lists.ppu b/lib/lists.ppu index 66be8c3e..17cc0476 100644 Binary files a/lib/lists.ppu and b/lib/lists.ppu differ diff --git a/lib/lmemorymanager.ppu b/lib/lmemorymanager.ppu index 1cd28bc1..a656ec23 100644 Binary files a/lib/lmemorymanager.ppu and b/lib/lmemorymanager.ppu differ diff --git a/lib/mouse.ppu b/lib/mouse.ppu index 379be4bb..08eacef4 100644 Binary files a/lib/mouse.ppu and b/lib/mouse.ppu differ diff --git a/lib/net.ppu b/lib/net.ppu index a2424268..797ad5e5 100644 Binary files a/lib/net.ppu and b/lib/net.ppu differ diff --git a/lib/netutils.ppu b/lib/netutils.ppu index b627a7a6..71f7403f 100644 Binary files a/lib/netutils.ppu and b/lib/netutils.ppu differ diff --git a/lib/pmemorymanager.ppu b/lib/pmemorymanager.ppu index 814bc061..16add03d 100644 Binary files a/lib/pmemorymanager.ppu and b/lib/pmemorymanager.ppu differ diff --git a/lib/scheduler.ppu b/lib/scheduler.ppu index 983a5b81..6e7952cd 100644 Binary files a/lib/scheduler.ppu and b/lib/scheduler.ppu differ diff --git a/lib/storagemanagement.ppu b/lib/storagemanagement.ppu index d75be257..d4e73b56 100644 Binary files a/lib/storagemanagement.ppu and b/lib/storagemanagement.ppu differ diff --git a/lib/strings.ppu b/lib/strings.ppu index 0df1f3ef..6d486297 100644 Binary files a/lib/strings.ppu and b/lib/strings.ppu differ diff --git a/lib/system.ppu b/lib/system.ppu index a7ad9af5..191f4a9e 100644 Binary files a/lib/system.ppu and b/lib/system.ppu differ diff --git a/lib/terminal.ppu b/lib/terminal.ppu index c9361c0e..8070fbcd 100644 Binary files a/lib/terminal.ppu and b/lib/terminal.ppu differ diff --git a/lib/testdriver.ppu b/lib/testdriver.ppu index d48a855c..3c1c5d6a 100644 Binary files a/lib/testdriver.ppu and b/lib/testdriver.ppu differ diff --git a/lib/tracer.ppu b/lib/tracer.ppu index 20719948..d3ca016d 100644 Binary files a/lib/tracer.ppu and b/lib/tracer.ppu differ diff --git a/lib/tss.ppu b/lib/tss.ppu index 62f1fe89..f8a3860f 100644 Binary files a/lib/tss.ppu and b/lib/tss.ppu differ diff --git a/lib/util.ppu b/lib/util.ppu index c4d737f2..a1bb9312 100644 Binary files a/lib/util.ppu and b/lib/util.ppu differ diff --git a/lib/vmemorymanager.ppu b/lib/vmemorymanager.ppu index 327cdd55..322e8c4f 100644 Binary files a/lib/vmemorymanager.ppu and b/lib/vmemorymanager.ppu differ diff --git a/src/console.pas b/src/console.pas index 9f638c31..23cae020 100644 --- a/src/console.pas +++ b/src/console.pas @@ -107,11 +107,17 @@ procedure drawPixel32(x : uint32; y : uint32; pixel : uint32); function getPixel64(x : uint32; y : uint32) : uint64; procedure drawPixel64(x : uint32; y : uint32; pixel : uint64); +procedure setMousePosition(x : uint32; y : uint32); + +procedure redrawWindows; implementation uses - lmemorymanager; + lmemorymanager, strings; + +const + MAX_WINDOWS = 5; type TConsoleProperties = record @@ -120,7 +126,8 @@ type TCharacter = bitpacked record Character : Char; - attributes: uint32; + attributes : uint32; + visible : boolean; end; PCharacter = ^TCharacter; @@ -130,16 +137,217 @@ type T2DVideoMemory = Array[0..63] of Array[0..159] of TCharacter; P2DVideoMemory = ^T2DVideoMemory; + TMouseCoord = record + X : sint32; + Y : sint32; + end; + TCoord = record X : Byte; Y : Byte; end; + TWindow = record + visible : boolean; + buffer : T2DVideoMemory; + row_dirty : Array[0..63] of Boolean; + WND_X : uint32; + WND_Y : uint32; + WND_W : uint32; + WND_H : uint32; + Cursor : TCoord; + WND_NAME : PChar; + end; + + TWindows = Array[0..MAX_WINDOWS-1] of TWindow; + + TWindowManager = record + Windows : TWindows; + MousePos : TMouseCoord; + MousePrev : TMouseCoord; + end; + + TMouseDirt = record + TopLeft : TMouseCoord; + BottomRight : TMouseCoord; + end; + var - Console_Properties : TConsoleProperties; - Console_Matrix : T2DVideoMemory; - Console_Cursor : TCoord; - Ready : Boolean = false; + Console_Properties : TConsoleProperties; //Generic Properties + Console_Real : T2DVideoMemory; //The real state of the Console/TUI + Console_Matrix : T2DVideoMemory; //The next buffer to be written + Console_Cursor : TCoord; //The text cursor position + WindowManager : TWindowManager; //Window Manager + Ready : Boolean = false; //Is the unit ready for use? + FocusedWND : uint32 = 0; //The currently focused Window for printing + MouseDrawActive : Boolean = false; //Is the Mouse currently being updated? + mouse_dirt : TMouseDirt; //Character Cell(s) the mouse occupies, these need to be rewritten on mouse move. + Window_Border : TCharacter; + Default_Char : TCharacter; + +procedure drawMouse; +var + x, y : uint32; + MX, MY : uint32; + +begin + MouseDrawActive:= true; + MX:= WindowManager.MousePos.X; + MY:= WindowManager.MousePos.Y; + WindowManager.MousePrev.x:= MX; + WindowManager.MousePrev.y:= MY; + mouse_dirt.TopLeft.x:= (MX div 8) - 2; + mouse_dirt.TopLeft.y:= (MY div 16) - 2; + mouse_dirt.BottomRight.x:= (MX div 8) + 2; + mouse_dirt.BottomRight.y:= (MY div 16) + 2; + if mouse_dirt.TopLeft.x < 0 then mouse_dirt.TopLeft.x:= 0; + if mouse_dirt.TopLeft.y < 0 then mouse_dirt.TopLeft.y:= 0; + if mouse_dirt.BottomRight.x > 159 then mouse_dirt.BottomRight.x:= 159; + if mouse_dirt.BottomRight.y > 63 then mouse_dirt.BottomRight.y:= 63; + MouseDrawActive:= false; +end; + +procedure redrawMatrix; +var + x, y, w: uint32; + +begin + if (WindowManager.MousePos.x <> WindowManager.MousePrev.x) OR (WindowManager.MousePos.y <> WindowManager.MousePrev.y) then begin + for y:=mouse_dirt.TopLeft.y to mouse_dirt.BottomRight.y do begin + for x:=mouse_dirt.TopLeft.x to mouse_dirt.BottomRight.x do begin + Console_Real[y][x].character:= char(1); + end; + end; + drawMouse; + end; + for y:=0 to 63 do begin + for x:=0 to 159 do begin + if (Console_Matrix[y][x].character <> Console_Real[y][x].character) or (Console_Matrix[y][x].attributes <> Console_Real[y][x].attributes) then begin + OutputChar(Console_Matrix[y][x].Character, x, y, Console_Matrix[y][x].Attributes SHR 16, Console_Matrix[y][x].Attributes AND $FFFF); + Console_Real[y][x]:= Console_Matrix[y][x]; + end; + end; + end; + outputCharToScreenSpace(char(0), WindowManager.MousePrev.x, WindowManager.MousePrev.y, $FFFF); +end; + +procedure setMousePosition(x : uint32; y : uint32); +begin + if MouseDrawActive then exit; + WindowManager.MousePos.X:= x; + WindowManager.MousePos.Y:= y; +end; + +procedure redrawWindows; +var + x, y, w : uint32; + WXL, WYL : sint32; + WXR, WYR : sint32; + STRC : uint32; + MIDP, STARTP : uint32; + +begin + for y:=0 to 63 do begin + for x:=0 to 159 do begin + Console_Matrix[y][x]:= Default_Char; + end; + end; + for w:=0 to MAX_WINDOWS-1 do begin + If WindowManager.Windows[w].visible then begin + if w <> 0 then begin + WXL:= WindowManager.Windows[w].WND_X - 1; + WYL:= WindowManager.Windows[w].WND_Y - 1; + WXR:= WindowManager.Windows[w].WND_X + WindowManager.Windows[w].WND_W + 1; + WYR:= WindowManager.Windows[w].WND_Y + WindowManager.Windows[w].WND_H + 1; + for y:=WYL to WYR do begin + Console_Matrix[y][WXL]:= Window_Border; + Console_Matrix[y][WXL-1]:= Window_Border; + Console_Matrix[y][WXR]:= Window_Border; + Console_Matrix[y][WXR+1]:= Window_Border; + Console_Real[y][WXL].Character:= char(3); + Console_Real[y][WXL-1].Character:= char(3); + Console_Real[y][WXR].Character:= char(3); + Console_Real[y][WXR+1].Character:= char(3); + end; + STRC:= 0; + MIDP:= (WXR + WXL) div 2; + STARTP:= MIDP - (StringSize(WindowManager.Windows[w].WND_NAME) div 2) - 1; + for x:=WXL to WXR do begin + Console_Matrix[WYL][x]:= Window_Border; + if (x >= STARTP) and (STRC < StringSize(WindowManager.Windows[w].WND_NAME)) then begin + Console_Matrix[WYL][x].character:= WindowManager.Windows[w].WND_NAME[STRC]; + inc(STRC); + end; + if x = WXR then begin + Console_Matrix[WYL][x].character:= 'x'; + end; + Console_Matrix[WYR][x]:= Window_Border; + Console_Real[WYL][x].Character:= char(3); + Console_Real[WYR][x].Character:= char(3); + end; + end; + for y:=WindowManager.Windows[w].WND_Y to WindowManager.Windows[w].WND_Y + WindowManager.Windows[w].WND_H do begin + if y > 63 then break; + for x:=WindowManager.Windows[w].WND_X to WindowManager.Windows[w].WND_X + WindowManager.Windows[w].WND_W do begin + if x > 159 then break; + Console_Matrix[y][x]:= WindowManager.Windows[w].buffer[y - WindowManager.Windows[w].WND_Y][x - WindowManager.Windows[w].WND_X]; + end; + end; + end; + end; + redrawMatrix; +end; + +procedure initWindows; +var + x, y, w : uint32; + +begin + Default_Char.Character:= ' '; + Default_Char.attributes:= Console_Properties.Default_Attribute; + Default_Char.visible:= true; + + Window_Border.Character:= ' '; + Window_Border.Attributes:= $0000FFFF; + Window_Border.visible:= true; + + for w:=0 to MAX_WINDOWS-1 do begin + WindowManager.Windows[w].visible:= false; + for y:=0 to 63 do begin + for x:=0 to 159 do begin + WindowManager.Windows[w].Buffer[y][x].visible:= true; + WindowManager.Windows[w].Buffer[y][x].character:= ' '; + WindowManager.Windows[w].Buffer[y][x].attributes:= Console_Properties.Default_Attribute; + Console_Real[y][x].character:= char(1); + end; + end; + end; + + WindowManager.Windows[0].visible:= true; + WindowManager.Windows[0].WND_X:= 0; + WindowManager.Windows[0].WND_Y:= 0; + WindowManager.Windows[0].WND_H:= 63; + WindowManager.Windows[0].WND_W:= 159; + for y:=0 to 63 do begin + for x:=0 to 159 do begin + WindowManager.Windows[0].Buffer[y][x].visible:= true; + WindowManager.Windows[0].Buffer[y][x].character:= ' '; + end; + end; + + WindowManager.Windows[1].visible:= true; + WindowManager.Windows[1].WND_X:= 50; + WindowManager.Windows[1].WND_W:= 50; + WindowManager.Windows[1].WND_Y:= 20; + WindowManager.Windows[1].WND_H:= 20; + WindowManager.Windows[1].WND_NAME:= 'Test Window'; + for y:=0 to 63 do begin + for x:=0 to 159 do begin + WindowManager.Windows[1].Buffer[y][x].visible:= true; + WindowManager.Windows[1].Buffer[y][x].character:= ' '; + end; + end; +end; function getPixel(x : uint32; y : uint32) : uint16; var @@ -169,6 +377,7 @@ var dest32 : puint32; begin + if not ready then exit; dest:= puint16(multibootinfo^.framebuffer_addr); dest:= dest + (y * 1280) + x; dest32:= puint32(dest); @@ -181,6 +390,7 @@ var dest32 : puint32; begin + if not ready then exit; dest:= puint16(multibootinfo^.framebuffer_addr); dest:= dest + (y * 1280) + x; dest32:= puint32(dest); @@ -193,6 +403,7 @@ var dest64 : puint64; begin + if not ready then exit; dest:= puint16(multibootinfo^.framebuffer_addr); dest:= dest + (y * 1280) + x; dest64:= puint64(dest); @@ -205,6 +416,7 @@ var dest64 : puint64; begin + if not ready then exit; dest:= puint16(multibootinfo^.framebuffer_addr); dest:= dest + (y * 1280) + x; dest64:= puint64(dest); @@ -224,6 +436,7 @@ begin fgcolor32:= fgcolor OR (fgcolor SHL 16); mask:= puint32(@Std_Mask[uint32(c) * (16 * 8)]); dest:= puint16(multibootinfo^.framebuffer_addr); + //dest:= puint16(windowmanager.getBuffer(0)); dest:= dest + (y * 1280) + x; dest32:= puint32(dest); for i:=0 to 15 do begin @@ -232,6 +445,7 @@ begin dest32[(i*640)+2]:= (dest32[(i*640)+2] AND NOT(mask[(i*4)+2])) OR (fgcolor32 AND mask[(i*4)+2]); dest32[(i*640)+3]:= (dest32[(i*640)+3] AND NOT(mask[(i*4)+3])) OR (fgcolor32 AND mask[(i*4)+3]); end; + //windowmanager.redraw; end; procedure outputCharTransparent(c : char; x : uint8; y : uint8; fgcolor : uint16); @@ -247,6 +461,7 @@ begin fgcolor32:= fgcolor OR (fgcolor SHL 16); mask:= puint32(@Std_Mask[uint32(c) * (16 * 8)]); dest:= puint16(multibootinfo^.framebuffer_addr); + //dest:= puint16(windowmanager.getBuffer(0)); dest:= dest + (y*(1280 * 16)) + (x * 8); dest32:= puint32(dest); for i:=0 to 15 do begin @@ -255,6 +470,7 @@ begin dest32[(i*640)+2]:= (dest32[(i*640)+2] AND NOT(mask[(i*4)+2])) OR (fgcolor32 AND mask[(i*4)+2]); dest32[(i*640)+3]:= (dest32[(i*640)+3] AND NOT(mask[(i*4)+3])) OR (fgcolor32 AND mask[(i*4)+3]); end; + //windowmanager.redraw; end; procedure outputChar(c : char; x : uint8; y : uint8; fgcolor : uint16; bgcolor : uint16); @@ -271,6 +487,7 @@ begin bgcolor32:= bgcolor OR (bgcolor SHL 16); mask:= puint32(@Std_Mask[uint32(c) * (16 * 8)]); dest:= puint16(multibootinfo^.framebuffer_addr); + //dest:= puint16(windowmanager.getBuffer(0)); dest:= dest + (y*(1280 * 16)) + (x * 8); dest32:= puint32(dest); for i:=0 to 15 do begin @@ -279,6 +496,7 @@ begin dest32[(i*640)+2]:= (bgcolor32 AND NOT(mask[(i*4)+2])) OR (fgcolor32 AND mask[(i*4)+2]); dest32[(i*640)+3]:= (bgcolor32 AND NOT(mask[(i*4)+3])) OR (fgcolor32 AND mask[(i*4)+3]); end; + //windowmanager.redraw; end; procedure disable_cursor; @@ -294,6 +512,7 @@ var Begin fb:= puint32(uint32(multibootinfo^.framebuffer_addr)); kpalloc(uint32(fb)); + initWindows; Console_Properties.Default_Attribute:= console.combinecolors($FFFF, $0000); console.clear(); Ready:= True; @@ -306,13 +525,19 @@ var begin for y:=0 to 63 do begin for x:=0 to 159 do begin - Console_Matrix[y][x].Character:= ' '; - Console_Matrix[y][x].Attributes:= Console_Properties.Default_Attribute; - OutputChar(Console_Matrix[y][x].Character, x, y, Console_Matrix[y][x].Attributes SHR 16, Console_Matrix[y][x].Attributes AND $FFFF); - end; + WindowManager.Windows[FocusedWND].Buffer[y][x].Character:= ' '; + WindowManager.Windows[FocusedWND].Buffer[y][x].Attributes:= Console_Properties.Default_Attribute; + WindowManager.Windows[FocusedWND].row_dirty[y]:= true; + //Console_Matrix[y][x].Character:= ' '; + //Console_Matrix[y][x].Attributes:= Console_Properties.Default_Attribute; + //OutputChar(Console_Matrix[y][x].Character, x, y, Console_Matrix[y][x].Attributes SHR 16, Console_Matrix[y][x].Attributes AND $FFFF); + end; end; - Console_Cursor.X:= 0; - Console_Cursor.Y:= 0; + WindowManager.Windows[FocusedWND].Cursor.X:= 0; + WindowManager.Windows[FocusedWND].Cursor.Y:= 0; + redrawWindows; + //Console_Cursor.X:= 0; + //Console_Cursor.Y:= 0; end; procedure writebin8ex(b : uint8; attributes: uint32); @@ -450,10 +675,13 @@ end; procedure writecharex(character: char; attributes: uint32); [public, alias: 'console_writecharex']; begin - outputChar(character, Console_Cursor.X, Console_Cursor.Y, attributes SHR 16, attributes AND $FFFF); - Console_Matrix[Console_Cursor.Y][Console_Cursor.X].Character:= character; - Console_Matrix[Console_Cursor.Y][Console_Cursor.X].Attributes:= attributes; - console._safeincrement_x(); + WindowManager.Windows[FocusedWND].Buffer[WindowManager.Windows[FocusedWND].Cursor.Y][WindowManager.Windows[FocusedWND].Cursor.X].Character:= character; + WindowManager.Windows[FocusedWND].Buffer[WindowManager.Windows[FocusedWND].Cursor.Y][WindowManager.Windows[FocusedWND].Cursor.X].Attributes:= attributes; + //outputChar(character, Console_Cursor.X, Console_Cursor.Y, attributes SHR 16, attributes AND $FFFF); + //Console_Matrix[Console_Cursor.Y][Console_Cursor.X].Character:= character; + //Console_Matrix[Console_Cursor.Y][Console_Cursor.X].Attributes:= attributes; + WindowManager.Windows[FocusedWND].row_dirty[WindowManager.Windows[FocusedWND].Cursor.Y]:= true; + console._safeincrement_x(); end; procedure writehexpair(b : uint8); @@ -655,58 +883,80 @@ var b : byte; begin - pos:= (Console_Cursor.Y * 80) + Console_Cursor.X; - outb($3D4, $0F); - b:= pos and $00FF; - outb($3D5, b); - outb($3D4, $0E); - b:= pos shr 8; - outb($3D5, b); + //pos:= (Console_Cursor.Y * 80) + Console_Cursor.X; + //outb($3D4, $0F); + //b:= pos and $00FF; + //outb($3D5, b); + //outb($3D4, $0E); + //b:= pos shr 8; + //outb($3D5, b); + redrawWindows; end; procedure backspace; begin - Dec(Console_Cursor.X); + Dec(WindowManager.Windows[FocusedWND].Cursor.X); writechar(' '); - Dec(Console_Cursor.X); + Dec(WindowManager.Windows[FocusedWND].Cursor.X); _update_cursor(); end; procedure _increment_x(); [public, alias: '_console_increment_x']; begin - Console_Cursor.X:= Console_Cursor.X+1; - If Console_Cursor.X > 159 then Console_Cursor.X:= 0; + WindowManager.Windows[FocusedWND].Cursor.X:= WindowManager.Windows[FocusedWND].Cursor.X+1; + If WindowManager.Windows[FocusedWND].Cursor.X > WindowManager.Windows[FocusedWND].WND_W-1 then WindowManager.Windows[FocusedWND].Cursor.X:= 0; console._update_cursor; + //Console_Cursor.X:= Console_Cursor.X+1; + //If Console_Cursor.X > 159 then Console_Cursor.X:= 0; + //console._update_cursor; end; procedure _increment_y(); [public, alias: '_console_increment_y']; begin - Console_Cursor.Y:= Console_Cursor.Y+1; - If Console_Cursor.Y > 63 then begin - console._newline(); - Console_Cursor.Y:= 63; + WindowManager.Windows[FocusedWND].Cursor.Y:= WindowManager.Windows[FocusedWND].Cursor.Y+1; + If WindowManager.Windows[FocusedWND].Cursor.Y > WindowManager.Windows[FocusedWND].WND_H-1 then begin + console._newline(); + WindowManager.Windows[FocusedWND].Cursor.Y:= WindowManager.Windows[FocusedWND].WND_H-1; end; console._update_cursor; + //Console_Cursor.Y:= Console_Cursor.Y+1; + //If Console_Cursor.Y > 63 then begin + // console._newline(); + // Console_Cursor.Y:= 63; + //end; + //console._update_cursor; end; procedure _safeincrement_x(); [public, alias: '_console_safeincrement_x']; begin - Console_Cursor.X:= Console_Cursor.X+1; - If Console_Cursor.X > 159 then begin + WindowManager.Windows[FocusedWND].Cursor.X:= WindowManager.Windows[FocusedWND].Cursor.X+1; + if WindowManager.Windows[FocusedWND].Cursor.X > WindowManager.Windows[FocusedWND].WND_W-1 then begin console._safeincrement_y(); end; console._update_cursor; + //Console_Cursor.X:= Console_Cursor.X+1; + //If Console_Cursor.X > 159 then begin + // console._safeincrement_y(); + //end; + //console._update_cursor; end; procedure _safeincrement_y(); [public, alias: '_console_safeincrement_y']; begin - Console_Cursor.Y:= Console_Cursor.Y+1; - If Console_Cursor.Y > 63 then begin - console._newline(); - Console_Cursor.Y:= 63; + WindowManager.Windows[FocusedWND].Cursor.Y:= WindowManager.Windows[FocusedWND].Cursor.Y+1; + if WindowManager.Windows[FocusedWND].Cursor.Y > WindowManager.Windows[FocusedWND].WND_H-1 then begin + console._newline(); + WindowManager.Windows[FocusedWND].Cursor.Y:= WindowManager.Windows[FocusedWND].WND_H-1; end; - Console_Cursor.X:= 0; + WindowManager.Windows[FocusedWND].Cursor.X:= 0; console._update_cursor; + //Console_Cursor.Y:= Console_Cursor.Y+1; + //If Console_Cursor.Y > 63 then begin + // console._newline(); + // Console_Cursor.Y:= 63; + //end; + //Console_Cursor.X:= 0; + //console._update_cursor; end; procedure _newline(); [public, alias: '_console_newline']; @@ -714,20 +964,26 @@ var x, y : byte; begin - for x:=0 to 159 do begin - for y:=0 to 63 do begin - Console_Matrix[y][x]:= Console_Matrix[y+1][x]; + if WindowManager.Windows[FocusedWND].WND_W = 0 then exit; + if WindowManager.Windows[FocusedWND].WND_H = 0 then exit; + for x:=0 to WindowManager.Windows[FocusedWND].WND_W do begin + for y:=0 to WindowManager.Windows[FocusedWND].WND_H-1 do begin + WindowManager.Windows[FocusedWND].buffer[y][x]:= WindowManager.Windows[FocusedWND].buffer[y+1][x]; + WindowManager.Windows[FocusedWND].row_dirty[y]:= true; + //Console_Matrix[y][x]:= Console_Matrix[y+1][x]; end; end; - for x:=0 to 159 do begin - Console_Matrix[63][x].Character:= ' '; - Console_Matrix[63][x].Attributes:= $FFFF0000; - end; - for y:=0 to 63 do begin - for x:=0 to 159 do begin - OutputChar(Console_Matrix[y][x].Character, x, y, Console_Matrix[y][x].Attributes SHR 16, Console_Matrix[y][x].Attributes AND $FFFF); - end; + for x:=0 to WindowManager.Windows[FocusedWND].WND_W do begin + WindowManager.Windows[FocusedWND].buffer[WindowManager.Windows[FocusedWND].WND_H-1][x].Character:= ' '; + WindowManager.Windows[FocusedWND].buffer[WindowManager.Windows[FocusedWND].WND_H-1][x].Attributes:= $FFFF0000; + //Console_Matrix[63][x].Character:= ' '; + //Console_Matrix[63][x].Attributes:= $FFFF0000; end; + //for y:=0 to 63 do begin + // for x:=0 to 159 do begin + // OutputChar(Console_Matrix[y][x].Character, x, y, Console_Matrix[y][x].Attributes SHR 16, Console_Matrix[y][x].Attributes AND $FFFF); + // end; + //end; console._update_cursor; end; diff --git a/src/driver/hid/mouse.pas b/src/driver/hid/mouse.pas index 3b28ad82..4124c7c6 100644 --- a/src/driver/hid/mouse.pas +++ b/src/driver/hid/mouse.pas @@ -155,7 +155,7 @@ begin if Current.y > 1015 then Current.y:= 1015; end; Cycle:= 0; - NeedsRedraw:= true; + console.setMousePosition(Current.x, Current.y); end; end; end; diff --git a/src/kernel.pas b/src/kernel.pas index db3509c7..cdef9a59 100644 --- a/src/kernel.pas +++ b/src/kernel.pas @@ -218,6 +218,7 @@ begin { Graphics Mode Test Stuff } //GraphicsTesting(); { Console Init } + //windowmanager.init(); console.init(); { Call Tracer } @@ -290,7 +291,9 @@ begin //outputCharToScreenSpace(char(0), 10, 10, $FFFF); while true do begin - mouse.DrawCursor(); + console.redrawWindows; + //windowmanager.redraw(); + //mouse.DrawCursor(); end; //util.halt_and_dont_catch_fire; diff --git a/src/lmemorymanager.pas b/src/lmemorymanager.pas index 151bdc41..49b60a4f 100644 --- a/src/lmemorymanager.pas +++ b/src/lmemorymanager.pas @@ -57,13 +57,13 @@ var i : integer; begin - push_trace('lmemorymanager.new_lmm_page'); + //push_trace('lmemorymanager.new_lmm_page'); i:= KERNEL_PAGE_NUMBER + 4; while not vmemorymanager.new_page(i) do begin i:= i + 1; end; new_lmm_page:= i SHL 22; - pop_trace; + //pop_trace; end; function new_heap_page(CurrentPage : PHeapPage) : PHeapPage; @@ -71,7 +71,7 @@ var i : integer; begin - push_trace('lmemorymanager.new_heap_page'); + //push_trace('lmemorymanager.new_heap_page'); new_heap_page:= PHeapPage(new_lmm_page); if CurrentPage <> nil then CurrentPage^.Next_Page:= uint32(new_heap_page); new_heap_page^.Next_Page:= 0; @@ -83,7 +83,7 @@ begin Last:= False; end; end; - pop_trace; + //pop_trace; end; procedure init; @@ -91,7 +91,7 @@ var i : uint32; begin - push_trace('lmemorymanager.init'); + //push_trace('lmemorymanager.init'); console.outputln('LMM','INIT BEGIN.'); Root_Page:= PHeapPage(new_lmm_page); Search_Page:= Root_Page; @@ -103,7 +103,7 @@ begin Root_Page^.Entries[i].Last:= False; end; console.outputln('LMM','INIT END.'); - pop_trace; + //pop_trace; end; function kpalloc(address : uint32) : void; @@ -111,12 +111,12 @@ var block : uint16; begin - push_trace('lmemorymanager.kpalloc'); + //push_trace('lmemorymanager.kpalloc'); block:= address SHR 22; force_alloc_block(block, 0); map_page(block, block); kpalloc:= void(block SHL 22); - pop_trace; + //pop_trace; end; function kalloc(size : uint32) : void; @@ -127,7 +127,7 @@ var miss : boolean; begin - push_trace('lmemorymanager.kalloc'); + //push_trace('lmemorymanager.kalloc'); Heap_Entries:= size div 8; If sint32(size-(Heap_Entries*8)) > 0 then Heap_Entries:= Heap_Entries + 1; hp:= Search_Page; @@ -163,7 +163,7 @@ begin Search_Page:= hp; end; end; - pop_trace; + //pop_trace; end; procedure kfree(area : void); @@ -172,7 +172,7 @@ var entry : uint32; begin - push_trace('lmemorymanager.kfree'); + //push_trace('lmemorymanager.kfree'); hp:= PHeapPage((uint32(area) SHR 22) SHL 22); entry:= (uint32(area) - DATA_OFFSET - uint32(hp)) div 8; if hp^.Entries[entry].Present then begin @@ -192,7 +192,7 @@ begin end else begin GPF; end; - pop_trace; + //pop_trace; end; end. \ No newline at end of file