{$IFDEF INTERFACE} TGFrameBuffer = class private FMemory: TGFrameBufferMemory; FOnChange: TNotifyEvent; procedure DoChange; public Mode: TScreenMode; Width: TGFrameBufferData; Height: TGFrameBufferData; {$IF TGFrameBufferWidth>=8} function Read8(Address: TGFrameBufferData): Byte; procedure Write8(Address: TGFrameBufferData; Data: Byte); {$ENDIF} {$IF TGFrameBufferWidth>=16} function Read16(Address: TGFrameBufferData): Word; procedure Write16(Address: TGFrameBufferData; Data: Word); {$ENDIF} {$IF TGFrameBufferWidth>=32} function Read32(Address: TGFrameBufferData): DWord; procedure Write32(Address: TGFrameBufferData; Data: DWord); {$ENDIF} {$IF TGFrameBufferWidth>=64} function Read64(Address: TGFrameBufferData): QWord; procedure Write64(Address: TGFrameBufferData; Data: QWord); {$ENDIF} procedure UpdateMode; procedure SetDataBus(Channel: TGFrameBufferAddrChannel); constructor Create; destructor Destroy; override; property OnChange: TNotifyEvent read FOnChange write FOnChange; end; {$UNDEF INTERFACE} {$ENDIF} {$IFDEF IMPLEMENTATION} procedure TGFrameBuffer.DoChange; begin if Assigned(FOnChange) then FOnChange(Self); end; procedure TGFrameBuffer.UpdateMode; begin case Mode of smText: FMemory.Size := Width * Height; smGraphic1: FMemory.Size := (Width div 8) * Height; smGraphic8: FMemory.Size := Width * Height; smGraphic16: FMemory.Size := Width * 2 * Height; smGraphic32: FMemory.Size := Width * 4 * Height; smGraphic64: FMemory.Size := Width * 8 * Height; end; FMemory.Clean; end; constructor TGFrameBuffer.Create; begin FMemory := TGFrameBufferMemory.Create; Width := 20; Height := 12; Mode := smText; UpdateMode; end; destructor TGFrameBuffer.Destroy; begin FreeAndNil(FMemory); inherited; end; procedure TGFrameBuffer.SetDataBus(Channel: TGFrameBufferAddrChannel); begin {$IF TGFrameBufferWidth>=8} Channel.Read8 := Read8; Channel.Write8 := Write8; {$ENDIF} {$IF TGFrameBufferWidth>=16} Channel.Read16 := Read16; Channel.Write16 := Write16; {$ENDIF} {$IF TGFrameBufferWidth>=32} Channel.Read32 := Read32; Channel.Write32 := Write32; {$ENDIF} {$IF TGFrameBufferWidth>=64} Channel.Read64 := Read64; Channel.Write64 := Write64; {$ENDIF} end; {$IF TGFrameBufferWidth>=8} function TGFrameBuffer.Read8(Address: TGFrameBufferData): Byte; begin case Address of 0: Result := FMemory.ReadPos8; 1: Result := FMemory.Position; 2: Result := Width; 3: Result := Height; 4: Result := Byte(Mode); end; end; procedure TGFrameBuffer.Write8(Address: TGFrameBufferData; Data: Byte); begin case Address of 0: FMemory.WritePos8(Data); 1: FMemory.Position := Data; 2: Width := Data; 3: Height := Data; 4: Mode := TScreenMode(Data); end; end; {$ENDIF} {$IF TGFrameBufferWidth>=16} function TGFrameBuffer.Read16(Address: TGFrameBufferData): Word; begin case Address of 0: Result := FMemory.ReadPos16; 1: Result := FMemory.Position; 2: Result := Width; 3: Result := Height; 4: Result := Word(Mode); end; end; procedure TGFrameBuffer.Write16(Address: TGFrameBufferData; Data: Word); begin case Address of 0: FMemory.WritePos16(Data); 1: FMemory.Position := Data; 2: Width := Data; 3: Height := Data; 4: Mode := TScreenMode(Data); end; end; {$ENDIF} {$IF TGFrameBufferWidth>=32} function TGFrameBuffer.Read32(Address: TGFrameBufferData): DWord; begin case Address of 0: Result := FMemory.ReadPos32; 1: Result := FMemory.Position; 2: Result := Width; 3: Result := Height; 4: Result := DWord(Mode); end; end; procedure TGFrameBuffer.Write32(Address: TGFrameBufferData; Data: DWord); begin case Address of 0: FMemory.WritePos32(Data); 1: FMemory.Position := Data; 2: Width := Data; 3: Height := Data; 4: Mode := TScreenMode(Data); end; end; {$ENDIF} {$IF TGFrameBufferWidth>=64} function TGFrameBuffer.Read64(Address: TGFrameBufferData): QWord; begin case Address of 0: Result := FMemory.ReadPos64; 1: Result := FMemory.Position; 2: Result := Width; 3: Result := Height; 4: Result := QWord(Mode); end; end; procedure TGFrameBuffer.Write64(Address: TGFrameBufferData; Data: QWord); begin case Address of 0: FMemory.WritePos64(Data); 1: FMemory.Position := Data; 2: Width := Data; 3: Height := Data; 4: Mode := TScreenMode(Data); end; end; {$ENDIF} {$UNDEF IMPLEMENTATION} {$ENDIF}