Changeset 9 for branches/ByteArray/Devices/FrameBuffer.pas
- Timestamp:
- Aug 6, 2024, 10:31:16 PM (2 months ago)
- Location:
- branches/ByteArray
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ByteArray
-
Property svn:ignore
set to
lib
heaptrclog.trc
ByteArray
ByteArray.dbg
ByteArray.lps
ByteArray.res
-
Property svn:ignore
set to
-
branches/ByteArray/Devices/FrameBuffer.pas
r5 r9 4 4 5 5 uses 6 Classes, SysUtils, Device, Channel, Memory, BigInt;6 Classes, SysUtils, Device, Channel, Memory, Int; 7 7 8 8 type … … 15 15 FOnChange: TNotifyEvent; 16 16 procedure DoChange; 17 function ReadData(Size: TIntSize): TInt; 18 function ReadPosition(Size: TIntSize): TInt; 19 function ReadWidth(Size: TIntSize): TInt; 20 function ReadHeight(Size: TIntSize): TInt; 21 function ReadMode(Size: TIntSize): TInt; 22 procedure WriteData(Size: TIntSize; Value: TInt); 23 procedure WritePosition(Size: TIntSize; Value: TInt); 24 procedure WriteWidth(Size: TIntSize; Value: TInt); 25 procedure WriteHeight(Size: TIntSize; Value: TInt); 26 procedure WriteMode(Size: TIntSize; Value: TInt); 17 27 public 18 28 Memory: TMemory; … … 22 32 Mode: TScreenMode; 23 33 procedure UpdateMode; 24 function Read(Address: TBigInt; Size: TBigIntSize): TBigInt; 25 procedure Write(Address: TBigInt; Size: TBigIntSize; Value: TBigInt); 26 function GetAddressCount: Integer; override; 27 procedure SetChannel(Channel: TChannel); override; 34 function GetHandlers: THandlers; override; 28 35 constructor Create; 29 36 destructor Destroy; override; … … 41 48 end; 42 49 50 function TFrameBuffer.ReadData(Size: TIntSize): TInt; 51 begin 52 Result := Memory.Read(Position, Size); 53 Inc(Position, Size); 54 end; 55 56 function TFrameBuffer.ReadPosition(Size: TIntSize): TInt; 57 begin 58 Result := Position; 59 end; 60 61 function TFrameBuffer.ReadWidth(Size: TIntSize): TInt; 62 begin 63 Result := Width; 64 end; 65 66 function TFrameBuffer.ReadHeight(Size: TIntSize): TInt; 67 begin 68 Result := Height; 69 end; 70 71 function TFrameBuffer.ReadMode(Size: TIntSize): TInt; 72 begin 73 Result := Byte(Mode); 74 end; 75 76 procedure TFrameBuffer.WriteData(Size: TIntSize; Value: TInt); 77 begin 78 Memory.Write(Position, Size, Value); 79 Inc(Position, Size); 80 end; 81 82 procedure TFrameBuffer.WritePosition(Size: TIntSize; Value: TInt); 83 begin 84 Position := Value; 85 end; 86 87 procedure TFrameBuffer.WriteWidth(Size: TIntSize; Value: TInt); 88 begin 89 Width := Value; 90 UpdateMode; 91 end; 92 93 procedure TFrameBuffer.WriteHeight(Size: TIntSize; Value: TInt); 94 begin 95 Height := Value; 96 UpdateMode; 97 end; 98 99 procedure TFrameBuffer.WriteMode(Size: TIntSize; Value: TInt); 100 begin 101 Mode := TScreenMode(Integer(Value)); 102 UpdateMode; 103 end; 104 43 105 procedure TFrameBuffer.UpdateMode; 44 106 begin … … 47 109 end; 48 110 49 function TFrameBuffer. Read(Address: TBigInt; Size: TBigIntSize): TBigInt;111 function TFrameBuffer.GetHandlers: THandlers; 50 112 begin 51 case Integer(Address) of 52 0: begin 53 Result := Memory.Read(Position, Size); 54 Inc(Position, Size); 55 end; 56 1: Result := Position; 57 2: Result := Width; 58 3: Result := Height; 59 4: Result := Byte(Mode); 60 end; 61 end; 62 63 procedure TFrameBuffer.Write(Address: TBigInt; Size: TBigIntSize; Value: TBigInt); 64 begin 65 case Integer(Address) of 66 0: begin 67 Memory.Write(Position, Size, Value); 68 Inc(Position, Size); 69 end; 70 1: Position := Value; 71 2: begin 72 Width := Value; 73 UpdateMode; 74 end; 75 3: begin 76 Height := Value; 77 UpdateMode; 78 end; 79 4: begin 80 Mode := TScreenMode(Integer(Value)); 81 UpdateMode; 82 end; 83 end; 84 DoChange; 85 end; 86 87 function TFrameBuffer.GetAddressCount: Integer; 88 begin 89 Result := 5; 90 end; 91 92 procedure TFrameBuffer.SetChannel(Channel: TChannel); 93 begin 94 Channel.Read := Read; 95 Channel.Write := Write; 113 Result := THandlers.Create; 114 Result.ReadHandlers.Add(ReadData); 115 Result.ReadHandlers.Add(ReadPosition); 116 Result.ReadHandlers.Add(ReadWidth); 117 Result.ReadHandlers.Add(ReadHeight); 118 Result.ReadHandlers.Add(ReadMode); 119 Result.WriteHandlers.Add(WriteData); 120 Result.WriteHandlers.Add(WritePosition); 121 Result.WriteHandlers.Add(WriteWidth); 122 Result.WriteHandlers.Add(WriteHeight); 123 Result.WriteHandlers.Add(WriteMode); 96 124 end; 97 125
Note:
See TracChangeset
for help on using the changeset viewer.