/*
    CaPriCe Forever - Amstrad CPC 464/664/6128 emulator
    Copyright (C) 2014-2019 by Frédéric Coste

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef TFormINOUTEditorH
#define TFormINOUTEditorH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Vcl.ExtCtrls.hpp>
#include "TFormEditValue.h"
#include "..\Emulator\TEmulator.h"
#include "..\Settings\TSettings.h"
#include <Vcl.ComCtrls.hpp>
//---------------------------------------------------------------------------
class TFormINOUTEditor : public TForm
{
__published:	// Composants gérés par l'EDI
  TGroupBox *GroupBoxPort;
  TPanel *PanelCheckPortA15;
  TPanel *PanelCheckPortA14;
  TPanel *PanelCheckPortA13;
  TPanel *PanelCheckPortA12;
  TPanel *PanelCheckPortA11;
  TPanel *PanelCheckPortA10;
  TPanel *PanelCheckPortA9;
  TPanel *PanelCheckPortA8;
  TPanel *PanelCheckPortA7;
  TPanel *PanelCheckPortA6;
  TPanel *PanelCheckPortA5;
  TPanel *PanelCheckPortA4;
  TPanel *PanelCheckPortA3;
  TPanel *PanelCheckPortA2;
  TPanel *PanelCheckPortA1;
  TPanel *PanelCheckPortA0;
  TGroupBox *GroupBoxInstruction;
  TComboBox *ComboBoxINOUT;
  TPanel *PanelInstructionPort;
  TPanel *PanelInstructionValue;
  TLabel *LabelInstructionPort;
  TLabel *LabelInstructionVal;
  TLabel *LabelPortA15;
  TLabel *LabelPortA0;
  TLabel *LabelPortA12;
  TLabel *LabelPortA11;
  TLabel *LabelPortA8;
  TLabel *LabelPortA7;
  TLabel *LabelPortA4;
  TLabel *LabelPortA3;
  TGroupBox *GroupBoxOperations;
  TGroupBox *GroupBoxValue;
  TLabel *LabelDataD7;
  TPanel *PanelCheckDataD7;
  TPanel *PanelCheckDataD6;
  TPanel *PanelCheckDataD5;
  TPanel *PanelCheckDataD4;
  TLabel *LabelDataD4;
  TLabel *LabelDataD3;
  TPanel *PanelCheckDataD3;
  TPanel *PanelCheckDataD2;
  TPanel *PanelCheckDataD1;
  TPanel *PanelCheckDataD0;
  TLabel *LabelDataD0;
  TPanel *PanelButtonPeekPC;
  TRichEdit *RichEditOperations;
  void __fastcall FormShow(TObject *Sender);
  void __fastcall FormHide(TObject *Sender);
  void __fastcall FormResize(TObject *Sender);
  void __fastcall PanelCheckPortClick(TObject *Sender);
  void __fastcall ComboBoxINOUTChange(TObject *Sender);
  void __fastcall FormDestroy(TObject *Sender);
  void __fastcall PanelInstructionPortClick(TObject *Sender);
  void __fastcall PanelInstructionValueClick(TObject *Sender);
  void __fastcall PanelButtonMouseDown(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);
  void __fastcall PanelButtonPeekPCClick(TObject *Sender);
  void __fastcall PanelCheckDataClick(TObject *Sender);
  void __fastcall PanelButtonMouseUp(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);

private:	// Déclarations utilisateur
  //
  // Members
  //
  TEmulator* mEmulatorP;
  TSettings* mSettingsP;
  tUShort mPort;
  tUChar mVal;
  TFormEditValue* mFormEditValue;
  //
  // Methods
  //
  void __fastcall WMMove(TMessage &Message);
  inline void __fastcall SetEmulator(TEmulator* Value) { mEmulatorP=Value; };
  void __fastcall SetSettings(TSettings* Value);
  inline tUShort __fastcall GetPort(void) { return mPort; };
  void __fastcall SetPort(tUShort Port);
  inline tUChar __fastcall GetVal(void) { return mVal; };
  void __fastcall SetVal(tUChar value);
  void __fastcall UpdateOperations(void);
  void __fastcall DisplayGateArrayOutput(void);
  void __fastcall DisplayCRTCOutput(void);
  void __fastcall DisplayCRTCInput(void);
  void __fastcall DisplayPPIOutput(void);
  void __fastcall DisplayPPIInput(void);
	void __fastcall DisplayIDEOutput(void);
	void __fastcall DisplayIDEInput(void);
	//
  // Properties
  //
  __property tUShort Port = { read=GetPort, write=SetPort };
  __property tUChar Val = { read=GetVal, write=SetVal };


public:		// Déclarations utilisateur
  //
  // Properties
  //
  __property TEmulator* Emulator = { write=SetEmulator };
  __property TSettings* Settings = { write=SetSettings };
  //
  // API
  //
  __fastcall TFormINOUTEditor(TComponent* Owner);

#pragma option push -vi-
BEGIN_MESSAGE_MAP
  MESSAGE_HANDLER(WM_MOVE, TMessage, WMMove);
END_MESSAGE_MAP(TForm)
#pragma option pop
};
//---------------------------------------------------------------------------
extern PACKAGE TFormINOUTEditor *FormINOUTEditor;
//---------------------------------------------------------------------------
#endif
