/*	Copyright  (c)	Günter Woigk 2013 - 2013
					mailto:kio@little-bat.de

	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.

	Permission to use, copy, modify, distribute, and sell this software and
	its documentation for any purpose is hereby granted without fee, provided
	that the above copyright notice appear in all copies and that both that
	copyright notice and this permission notice appear in supporting
	documentation, and that the name of the copyright holder not be used
	in advertising or publicity pertaining to distribution of the software
	without specific, written prior permission.  The copyright holder makes no
	representations about the suitability of this software for any purpose.
	It is provided "as is" without express or implied warranty.

	THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
	INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
	EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
	CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
	DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
	TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
	PERFORMANCE OF THIS SOFTWARE.
*/


#ifndef CPUINSPECTOR_H
#define CPUINSPECTOR_H


#include "Inspector.h"
#include "Cpu.h"

class QTimer;
class QPushButton;
class MyLineEdit;
class QLabel;


class CpuInspector : public Inspector
{
	Q_OBJECT

	Cpu*		cpu;

	MyLineEdit*	xtal;

	MyLineEdit*	div_ff;

	MyLineEdit*	areg_ip;
	MyLineEdit*	areg_sp;
	MyLineEdit*	areg_a0;
	MyLineEdit*	areg_a1;
	MyLineEdit*	areg_hp;
	MyLineEdit*	areg_atmp;
	MyLineEdit*	areg_ioaddr;

	MyLineEdit*	dreg_d0;
	MyLineEdit*	dreg_d1;
	MyLineEdit*	dreg_d2;
	MyLineEdit*	dreg_d3;
	MyLineEdit*	dreg_alu;
	MyLineEdit*	dreg_swap;
	MyLineEdit*	dreg_sr;
	MyLineEdit*	dreg_sl;
	MyLineEdit*	dreg_msbit;
	MyLineEdit*	dreg_cmd_lo;
	MyLineEdit*	reg_d2ar;

	MyLineEdit*	mca1;			// microcode address in stage 1
	MyLineEdit*	mca2;			// microcode address in stage 2
	MyLineEdit*	mc1;			// microcode address in stage 1
	MyLineEdit*	mc2;			// microcode address in stage 2

	MyLineEdit*	cc;

	MyLineEdit*	k1bus_select_bits;			// set by io.select		pos. Logik
	MyLineEdit*	k1bus_irpt_enable_bits;		// set by io.wr_irpt	pos. Logik
	MyLineEdit*	k1bus_irpt_pending_bits;	// set by boards 		pos. Logik

	QPushButton* button_pause;
	QPushButton* button_step_over;
	QPushButton* button_step_in;
	QPushButton* button_step_out;

//	MyLineEdit*	breakpoint_read;
//	MyLineEdit*	breakpoint_write;
	MyLineEdit*	breakpoint_exec;
	MyLineEdit*	breakpoint_return;

		int		add_debug_buttons(int x,int y);
		int		add_dregs(int x, int y);
		int		add_aregs(int x,int y);
		int		add_k1bus(int x, int y);
		int		add_breakpoints(int x,int y);
		int		add_mca(int x, int y, int x2);
		void	update_singlestepbuttons();
		uint	old_ssbtn_state;
	MyLineEdit* newMyLineEdit(int x,int y, cstr slot);
	QLabel*		newMyLabel(int x, int y, cstr text);

public:
				CpuInspector(QWidget* parent, Cpu* cpu);

signals:

public slots:

virtual void	update();

		void	slot_run_pause();
		void	slot_step_in();
		void	slot_step_over();
		void	slot_step_out();

		void	slot_xtal();
		void	slot_div_ff();

		void	slot_areg_ip();
		void	slot_areg_sp();
		void	slot_areg_a0();
		void	slot_areg_a1();
		void	slot_areg_hp();
		void	slot_areg_atmp();
		void	slot_areg_ioaddr();

		void	slot_dreg_d0();
		void	slot_dreg_d1();
		void	slot_dreg_d2();
		void	slot_dreg_d3();
		void	slot_dreg_alu();
		void	slot_dreg_swap();
		void	slot_dreg_sr();
		void	slot_dreg_sl();
		void	slot_dreg_msbit();
		void	slot_dreg_cmd_lo();
		void	slot_reg_d2ar();

		void	slot_mca1();
		void	slot_mca2();

		void	slot_cc();

		void	slot_k1bus_select_bits();
		void	slot_k1bus_irpt_enable_bits();
		void	slot_k1bus_irpt_pending_bits();

//		void	slot_breakpoint_read();
//		void	slot_breakpoint_write();
		void	slot_breakpoint_exec();
		void	slot_breakpoint_return();
};

#endif // CPUINSPECTOR_H
