{$IFDEF INTERFACE} TGDevice = class private FOnWrite: TWriteEvent; FOnRead: TReadEvent; procedure DoWrite(Address: QWord; Data: QWord); function DoRead(Address: QWord): QWord; public {$IF TGDeviceWidth>=8} function Read8(Address: TGDeviceData): Byte; procedure Write8(Address: TGDeviceData; Data: Byte); {$ENDIF} {$IF TGDeviceWidth>=16} function Read16(Address: TGDeviceData): Word; procedure Write16(Address: TGDeviceData; Data: Word); {$ENDIF} {$IF TGDeviceWidth>=32} function Read32(Address: TGDeviceData): DWord; procedure Write32(Address: TGDeviceData; Data: DWord); {$ENDIF} {$IF TGDeviceWidth>=64} function Read64(Address: TGDeviceData): QWord; procedure Write64(Address: TGDeviceData; Data: QWord); {$ENDIF} procedure SetDataBus(Channel: TGDeviceAddrChannel); property OnWrite: TWriteEvent read FOnWrite write FOnWrite; property OnRead: TReadEvent read FOnRead write FOnRead; end; {$UNDEF INTERFACE} {$ENDIF} {$IFDEF IMPLEMENTATION} procedure TGDevice.DoWrite(Address: QWord; Data: QWord); begin if Assigned(FOnWrite) then FOnWrite(Address, Data); end; function TGDevice.DoRead(Address: QWord): QWord; begin if Assigned(FOnRead) then Result := FOnRead(Address) else Result := 0; end; procedure TGDevice.SetDataBus(Channel: TGDeviceAddrChannel); begin {$IF TGDeviceWidth>=8} Channel.Read8 := Read8; Channel.Write8 := Write8; {$ENDIF} {$IF TGDeviceWidth>=16} Channel.Read16 := Read16; Channel.Write16 := Write16; {$ENDIF} {$IF TGDeviceWidth>=32} Channel.Read32 := Read32; Channel.Write32 := Write32; {$ENDIF} {$IF TGDeviceWidth>=64} Channel.Read64 := Read64; Channel.Write64 := Write64; {$ENDIF} end; {$IF TGDeviceWidth>=8} function TGDevice.Read8(Address: TGDeviceData): Byte; begin Result := DoRead(Address); end; procedure TGDevice.Write8(Address: TGDeviceData; Data: Byte); begin DoWrite(Address, Data); end; {$ENDIF} {$IF TGDeviceWidth>=16} function TGDevice.Read16(Address: TGDeviceData): Word; begin Result := DoRead(Address); end; procedure TGDevice.Write16(Address: TGDeviceData; Data: Word); begin DoWrite(Address, Data); end; {$ENDIF} {$IF TGDeviceWidth>=32} function TGDevice.Read32(Address: TGDeviceData): DWord; begin Result := DoRead(Address); end; procedure TGDevice.Write32(Address: TGDeviceData; Data: DWord); begin DoWrite(Address, Data); end; {$ENDIF} {$IF TGDeviceWidth>=64} function TGDevice.Read64(Address: TGDeviceData): QWord; begin Result := DoRead(Address); end; procedure TGDevice.Write64(Address: TGDeviceData; Data: QWord); begin DoWrite(Address, Data); end; {$ENDIF} {$UNDEF IMPLEMENTATION} {$ENDIF}