- Timestamp:
- May 9, 2015, 1:32:38 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 14 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Apps/UClock.pas
r7 r8 25 25 Message: TIPCMessage; 26 26 WindowId: Integer; 27 Angle: Double; 27 28 begin 28 29 Message := TIPCMessage.Create; … … 31 32 while not Task.Terminated do begin 32 33 API.WriteText('test'); 33 API.DrawText(Point(10, 10), 'Text'); 34 API.DrawLine(Point(20, 20), Point(100, 100)); 35 API.Sleep(OneSecond); 34 API.DrawRect(Rect(60, 60, 180, 180), $ffffff); 35 API.DrawText(Point(10, 10), 'Text', 0); 36 Angle := Frac(Now / (10 * OneSecond)) * 2 * Pi; 37 API.DrawLine(Point(120, 120), Point(Trunc(120 + Cos(Angle) * 60), Trunc(120 + Sin(Angle) * 60)), 0); 38 API.Sleep(OneMillisecond * 100); 36 39 //API.ReadMessage(Message); 37 40 end; -
trunk/ChronOS.lpi
r7 r8 66 66 </local> 67 67 </RunParams> 68 <RequiredPackages Count=" 1">68 <RequiredPackages Count="2"> 69 69 <Item1> 70 <PackageName Value="Kernel"/> 71 <DefaultFilename Value="Packages/Kernel/Kernel.lpk" Prefer="True"/> 72 </Item1> 73 <Item2> 70 74 <PackageName Value="LCL"/> 71 </Item 1>75 </Item2> 72 76 </RequiredPackages> 73 <Units Count=" 15">77 <Units Count="7"> 74 78 <Unit0> 75 79 <Filename Value="ChronOS.lpr"/> … … 85 89 </Unit1> 86 90 <Unit2> 87 <Filename Value="System/UKernel.pas"/>88 <IsPartOfProject Value="True"/>89 <UnitName Value="UKernel"/>90 </Unit2>91 <Unit3>92 <Filename Value="UFileSystem.pas"/>93 <IsPartOfProject Value="True"/>94 <UnitName Value="UFileSystem"/>95 </Unit3>96 <Unit4>97 91 <Filename Value="Apps/UClock.pas"/> 98 92 <IsPartOfProject Value="True"/> 99 93 <UnitName Value="UClock"/> 100 </Unit 4>101 <Unit 5>94 </Unit2> 95 <Unit3> 102 96 <Filename Value="Apps/UMemoryManager.pas"/> 103 97 <IsPartOfProject Value="True"/> 104 98 <UnitName Value="UMemoryManager"/> 105 </Unit5> 106 <Unit6> 107 <Filename Value="System/UAPI.pas"/> 108 <IsPartOfProject Value="True"/> 109 <UnitName Value="UAPI"/> 110 </Unit6> 111 <Unit7> 99 </Unit3> 100 <Unit4> 112 101 <Filename Value="Platform/Base/UPlatformBase.pas"/> 113 102 <IsPartOfProject Value="True"/> 114 103 <UnitName Value="UPlatformBase"/> 115 </Unit7> 116 <Unit8> 117 <Filename Value="UList.pas"/> 118 <IsPartOfProject Value="True"/> 119 <UnitName Value="UList"/> 120 </Unit8> 121 <Unit9> 122 <Filename Value="System/UApp.pas"/> 123 <IsPartOfProject Value="True"/> 124 <UnitName Value="UApp"/> 125 </Unit9> 126 <Unit10> 104 </Unit4> 105 <Unit5> 127 106 <Filename Value="UThreadEx.pas"/> 128 107 <IsPartOfProject Value="True"/> 129 108 <UnitName Value="UThreadEx"/> 130 </Unit10> 131 <Unit11> 132 <Filename Value="UMemory.pas"/> 133 <IsPartOfProject Value="True"/> 134 <UnitName Value="UMemory"/> 135 </Unit11> 136 <Unit12> 109 </Unit5> 110 <Unit6> 137 111 <Filename Value="Forms/UFormTerminal.pas"/> 138 112 <IsPartOfProject Value="True"/> … … 141 115 <ResourceBaseClass Value="Form"/> 142 116 <UnitName Value="UFormTerminal"/> 143 </Unit12> 144 <Unit13> 145 <Filename Value="UClasses.pas"/> 146 <IsPartOfProject Value="True"/> 147 <UnitName Value="UClasses"/> 148 </Unit13> 149 <Unit14> 150 <Filename Value="System/UGraphics.pas"/> 151 <IsPartOfProject Value="True"/> 152 <UnitName Value="UGraphics"/> 153 </Unit14> 117 </Unit6> 154 118 </Units> 155 119 </ProjectOptions> … … 161 125 <SearchPaths> 162 126 <IncludeFiles Value="$(ProjOutDir)"/> 163 <OtherUnitFiles Value="Apps;Platform/Base;Forms ;System"/>127 <OtherUnitFiles Value="Apps;Platform/Base;Forms"/> 164 128 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> 165 129 </SearchPaths> … … 180 144 <StackChecks Value="True"/> 181 145 </Checks> 146 <VerifyObjMethodCallValidity Value="True"/> 182 147 </CodeGeneration> 183 148 <Linking> -
trunk/ChronOS.lpr
r7 r8 10 10 {$ENDIF} 11 11 Interfaces, // this includes the LCL widgetset 12 Forms, SysUtils, UFormMain, UKernel, UFileSystem, UClock, UMemoryManager, 13 UAPI, UPlatformBase, UList, UApp, UThreadEx, UMemory, UFormTerminal, UClasses, 14 UGraphics; 12 Forms, SysUtils, UFormMain, UClock, UMemoryManager, 13 UPlatformBase, UThreadEx, UFormTerminal; 15 14 16 15 {$R *.res} -
trunk/Forms/UFormMain.lfm
r7 r8 20 20 Align = alClient 21 21 OnClick = PaintBox1Click 22 OnPaint = PaintBox1Paint 22 23 OnResize = PaintBox1Resize 23 24 end -
trunk/Forms/UFormMain.pas
r7 r8 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ExtCtrls, Menus, ActnList, UKernel, UMemory ;9 ExtCtrls, Menus, ActnList, UKernel, UMemory, UDevice, UPlatformBase, LCLType; 10 10 11 11 type … … 32 32 procedure FormShow(Sender: TObject); 33 33 procedure PaintBox1Click(Sender: TObject); 34 procedure PaintBox1Paint(Sender: TObject); 34 35 procedure PaintBox1Resize(Sender: TObject); 35 36 private 37 VideoDevice: TDeviceVideoBase; 38 SerialDevice: TBaseSerialDevice; 36 39 SerialText: string; 37 40 OriginalBounds: TRect; … … 39 42 ScreenBounds: TRect; 40 43 procedure SerialDeviceReceiveDataSync; 41 procedure SerialDeviceReceiveData( Data: TMemory);44 procedure SerialDeviceReceiveData(Text: string); 42 45 procedure VideoDeviceRedraw(Sender: TObject); 46 procedure VideoDeviceRedrawSync; 43 47 procedure SwitchFullScreen; 48 procedure EraseBackground(DC: HDC); override; 44 49 public 45 50 Kernel: TKernel; … … 52 57 53 58 uses 54 UList, UApp, UAPI, UClock, U PlatformBase, UThreadEx, UFormTerminal;59 UList, UApp, UAPI, UClock, UThreadEx, UFormTerminal; 55 60 56 61 {$R *.lfm} … … 61 66 var 62 67 NewApp: TApp; 63 SerialDevice: TBaseSerialDevice; 64 VideoDevice: TBaseVideoDevice;65 begin 68 begin 69 PaintBox1.ControlStyle := PaintBox1.ControlStyle + [csOpaque]; 70 66 71 Kernel := TKernel.Create; 67 72 Kernel.SchedulerClass := TBaseScheduler; 68 73 Kernel.FileSystemClass := TBaseFileSystem; 74 69 75 SerialDevice := TBaseSerialDevice.Create; 70 76 SerialDevice.Name := 'Serial0'; … … 73 79 Kernel.Devices.Add(SerialDevice); 74 80 75 VideoDevice := T BaseVideoDevice.Create;81 VideoDevice := TDeviceVideoBase.Create; 76 82 VideoDevice.Name := 'Video0'; 77 83 VideoDevice.ClassName := 'Graphic card'; 78 84 VideoDevice.OnRedraw := VideoDeviceRedraw; 79 85 VideoDevice.DPI := Screen.PixelsPerInch; 80 VideoDevice.VideoMemorySize := Point(PaintBox1.Width, PaintBox1.Height);; 86 VideoDevice.VideoMemorySize := Point(PaintBox1.Width, PaintBox1.Height); 87 VideoDevice.OnModeChanged := VideoDeviceRedraw; 81 88 Kernel.Devices.Add(VideoDevice); 82 89 … … 135 142 end; 136 143 144 procedure TFormMain.EraseBackground(DC: HDC); 145 begin 146 //inherited EraseBackground(DC); 147 end; 148 137 149 procedure TFormMain.FormDestroy(Sender: TObject); 138 150 begin … … 156 168 end; 157 169 170 procedure TFormMain.PaintBox1Paint(Sender: TObject); 171 var 172 X, Y: Integer; 173 Bitmap: TBitmap; 174 begin 175 try 176 Bitmap := TBitmap.Create; 177 Bitmap.BeginUpdate; 178 Bitmap.SetSize(PaintBox1.Width, PaintBox1.Height); 179 180 if Assigned(VideoDevice.VideoMemory) then begin 181 for Y := 0 to VideoDevice.VideoMode.Size.Y - 1 do 182 for X := 0 to VideoDevice.VideoMode.Size.X - 1 do begin 183 Bitmap.Canvas.Pixels[X, Y] := PInteger(VideoDevice.VideoMemory + X * VideoDevice.VideoMode.GetBytesPerPixel + 184 Y * VideoDevice.VideoMode.GetBytesPerLine)^ and $ffffff; 185 end; 186 end; 187 finally 188 PaintBox1.Canvas.Draw(0, 0, Bitmap); 189 Bitmap.EndUpdate; 190 Bitmap.Free; 191 end; 192 end; 193 158 194 procedure TFormMain.PaintBox1Resize(Sender: TObject); 159 195 begin … … 165 201 end; 166 202 167 procedure TFormMain.SerialDeviceReceiveData(Data: TMemory); 168 begin 169 SetLength(SerialText, Data.Size); 170 Move(Data.Data^, SerialText[1], Data.Size); 203 procedure TFormMain.SerialDeviceReceiveData(Text: string); 204 begin 205 SerialText := Text; 171 206 TThreadEx.Synchronize(TThreadEx.CurrentThread, SerialDeviceReceiveDataSync); 172 207 end; … … 174 209 procedure TFormMain.VideoDeviceRedraw(Sender: TObject); 175 210 begin 176 211 TThreadEx.Synchronize(TThreadEx.CurrentThread, VideoDeviceRedrawSync); 212 end; 213 214 procedure TFormMain.VideoDeviceRedrawSync; 215 begin 216 PaintBox1.Refresh; 177 217 end; 178 218 -
trunk/Forms/UFormTerminal.lfm
r7 r8 14 14 Width = 320 15 15 Align = alClient 16 ReadOnly = True 17 ScrollBars = ssAutoBoth 16 18 TabOrder = 0 17 19 end -
trunk/Platform/Base/UPlatformBase.pas
r7 r8 7 7 uses 8 8 Classes, SysUtils, UFileSystem, UKernel, syncobjs, UThreadEx, UMemory, 9 DateUtils ;9 DateUtils, UDevice, Contnrs, Graphics, Forms, UScreen; 10 10 11 11 type … … 42 42 end; 43 43 44 TReceiveEvent = procedure( Data: TMemory) of object;44 TReceiveEvent = procedure(Text: string) of object; 45 45 46 46 { TBaseSerialDevice } 47 47 48 TBaseSerialDevice = class(TDevice )48 TBaseSerialDevice = class(TDeviceSerial) 49 49 private 50 50 Lock: TCriticalSection; … … 53 53 constructor Create; override; 54 54 destructor Destroy; override; 55 procedure Service(Index: Integer; DataIn, DataOut: TMemory); override;55 procedure WriteText(Text: string); override; 56 56 property OnReceiveData: TReceiveEvent read FOnReceiveData write FOnReceiveData; 57 57 end; 58 58 59 { T BaseVideoDevice }60 61 T BaseVideoDevice = class(TDevice)59 { TDeviceVideoBase } 60 61 TDeviceVideoBase = class(TDeviceVideo) 62 62 private 63 FOnModeChanged: TNotifyEvent; 63 64 FOnRedraw: TNotifyEvent; 65 OnModeChanged: TNotifyEvent; 66 procedure DoRedraw; 64 67 public 65 68 VideoMemory: PByte; 66 69 VideoMemorySize: TPoint; 67 70 DPI: Integer; 68 constructor Create; override; 69 destructor Destroy; override; 70 procedure Service(Index: Integer; DataIn, DataOut: TMemory); override; 71 Canvas: TCanvas; 72 VideoMode: TVideoMode; 73 procedure SetMode(Mode: TVideoMode); override; 74 procedure GetSupportedModes(Modes: TObjectList); override; 75 function GetVideoMemory: PByte; override; 76 procedure VideoMemoryChange; override; 77 constructor Create; override; 78 destructor Destroy; override; 71 79 property OnRedraw: TNotifyEvent read FOnRedraw write FOnRedraw; 80 property OnModeChanged: TNotifyEvent read FOnModeChanged write FOnModeChanged; 72 81 end; 73 82 74 83 implementation 75 84 76 { TBaseVideoDevice } 77 78 constructor TBaseVideoDevice.Create; 85 { TDeviceVideoBase } 86 87 procedure TDeviceVideoBase.DoRedraw; 88 begin 89 90 end; 91 92 procedure TDeviceVideoBase.SetMode(Mode: TVideoMode); 93 begin 94 if (VideoMode.Size.X <> Mode.Size.X) or 95 (VideoMode.Size.Y <> Mode.Size.Y) or 96 (VideoMode.ColorFormat <> Mode.ColorFormat) then begin 97 VideoMode.Size := Mode.Size; 98 VideoMode.ColorFormat := Mode.ColorFormat; 99 if Assigned(FOnModeChanged) then 100 FOnModeChanged(Self); 101 end; 102 end; 103 104 procedure TDeviceVideoBase.GetSupportedModes(Modes: TObjectList); 105 var 106 NewMode: TVideoMode; 107 begin 108 Modes.Clear; 109 NewMode := TVideoMode.Create; 110 NewMode.Size := Point(320, 240); 111 NewMode.ColorFormat := cfRGBA8; 112 Modes.Add(NewMode); 113 NewMode := TVideoMode.Create; 114 NewMode.Size := Point(640, 480); 115 NewMode.ColorFormat := cfRGBA8; 116 Modes.Add(NewMode); 117 { NewMode := TVideoMode.Create; 118 NewMode.Size := Point(800, 600); 119 NewMode.ColorFormat := cfRGBA8; 120 Modes.Add(NewMode); 121 NewMode := TVideoMode.Create; 122 NewMode.Size := Point(1024, 768); 123 NewMode.ColorFormat := cfRGBA8; 124 Modes.Add(NewMode); 125 NewMode := TVideoMode.Create; 126 NewMode.Size := Point(1278, 1024); 127 NewMode.ColorFormat := cfRGBA8; 128 Modes.Add(NewMode); 129 NewMode := TVideoMode.Create; 130 NewMode.Size := Point(1920, 1080); 131 NewMode.ColorFormat := cfRGBA8; 132 Modes.Add(NewMode); 133 } 134 end; 135 136 function TDeviceVideoBase.GetVideoMemory: PByte; 137 begin 138 VideoMemory := GetMem(VideoMode.GetBytesPerImage); 139 FillDWord(VideoMemory^, VideoMode.GetBytesPerImage div 4, $ffffff); 140 Result := VideoMemory; 141 end; 142 143 procedure TDeviceVideoBase.VideoMemoryChange; 144 begin 145 if Assigned(FOnRedraw) then FOnRedraw(Self); 146 end; 147 148 constructor TDeviceVideoBase.Create; 79 149 begin 80 150 inherited Create; 81 end; 82 83 destructor TBaseVideoDevice.Destroy; 84 begin 85 inherited Destroy; 86 end; 87 88 procedure TBaseVideoDevice.Service(Index: Integer; DataIn, DataOut: TMemory); 89 begin 90 if Index = 0 then begin 91 // Redraw to screen 92 if Assigned(FOnRedraw) then 93 FOnRedraw(Self); 94 end else 95 if Index = 1 then begin 96 // Get video memory 97 VideoMemory := GetMem(VideoMemorySize.X * VideoMemorySize.Y * 4); 98 // DataOut^ := VideoMemory; 99 // DataOut^ := VideoMemory; 100 end else inherited; 151 VideoMode := TVideoMode.Create; 152 end; 153 154 destructor TDeviceVideoBase.Destroy; 155 begin 156 VideoMode.Free; 157 inherited Destroy; 101 158 end; 102 159 … … 116 173 end; 117 174 118 procedure TBaseSerialDevice.Service(Index: Integer; DataIn, DataOut: TMemory); 119 begin 120 if Index = 0 then begin 121 Lock.Acquire; 122 if Assigned(FOnReceiveData) then 123 FOnReceiveData(DataIn); 124 Lock.Release; 125 end else inherited; 175 procedure TBaseSerialDevice.WriteText(Text: string); 176 begin 177 Lock.Acquire; 178 if Assigned(FOnReceiveData) then 179 FOnReceiveData(Text); 180 Lock.Release; 126 181 end; 127 182
Note:
See TracChangeset
for help on using the changeset viewer.