/*	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 MICROCODEINSPECTOR_H
#define MICROCODEINSPECTOR_H


#include "Inspector.h"
#include "kio/kio.h"
#include "SimpleTerminal.h"
#include "Templates/StrArray.h"
#include <QScrollBar>


class Cpu;
class QTimer;


#define trace_len	10



class MicrocodeInspector : public Inspector
{
	Q_OBJECT

	SimpleTerminal*	textview;
	MyScrollBar*	scrollbar;
	int				scrollbar_width;			// for convenience

	Cpu*		cpu;

	uint		mca2;					// last updated mca2
	uint		row0;					// scroll position of screen
	uint		highlighted_mcas[trace_len];

	cstr		sourcefile;
	StrArray	source;					// source from file "combined.log"
	uint		source_ptr[0x8000];		// ref from mca to line in source[]


		void	print_highlight_mcas();
		void	update_scrollbar();
		void	print_line(uint);
		void	print_line(uint,int);

protected:
virtual void	resizeEvent	(QResizeEvent*);
//virtual void	paintEvent(QPaintEvent*);
virtual void	wheelEvent(QWheelEvent*);
//virtual void	mousePressEvent(QMouseEvent*);
//virtual bool	event(QEvent*);
//virtual void	keyPressEvent(QKeyEvent*);
//virtual void	keyReleaseEvent(QKeyEvent*);

public:
				MicrocodeInspector	(QWidget* parent, Cpu* cpu, cstr sourcefile);
				~MicrocodeInspector	();
signals:

public slots:
		void	update_all();
		void	scroll_to(int row);
virtual void	update();
};

#endif // MICROCODEINSPECTOR_H






















