Added ASM view cursor position label logic to Qt debug window.
This commit is contained in:
parent
fc81335cc0
commit
1a05b2d7d0
|
@ -1757,7 +1757,9 @@ QAsmView::QAsmView(QWidget *parent)
|
|||
pal.setColor(QPalette::Background, bg );
|
||||
pal.setColor(QPalette::WindowText, fg );
|
||||
|
||||
this->parent = (ConsoleDebugger*)parent;
|
||||
this->setPalette(pal);
|
||||
this->setMouseTracking(true);
|
||||
|
||||
calcFontData();
|
||||
|
||||
|
@ -1866,6 +1868,99 @@ void QAsmView::keyReleaseEvent(QKeyEvent *event)
|
|||
//assignHotkey( event );
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
QPoint QAsmView::convPixToCursor( QPoint p )
|
||||
{
|
||||
QPoint c(0,0);
|
||||
|
||||
if ( p.x() < 0 )
|
||||
{
|
||||
c.setX(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
float x = (float)p.x() / pxCharWidth;
|
||||
|
||||
c.setX( (int)x );
|
||||
}
|
||||
|
||||
if ( p.y() < 0 )
|
||||
{
|
||||
c.setY( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
float ly = ( (float)pxLineLead / (float)pxLineSpacing );
|
||||
float py = ( (float)p.y() ) / (float)pxLineSpacing;
|
||||
float ry = fmod( py, 1.0 );
|
||||
|
||||
if ( ry < ly )
|
||||
{
|
||||
c.setY( ((int)py) - 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
c.setY( (int)py );
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void QAsmView::mouseMoveEvent(QMouseEvent * event)
|
||||
{
|
||||
int line;
|
||||
QPoint c = convPixToCursor( event->pos() );
|
||||
char txt[256];
|
||||
std::string s;
|
||||
|
||||
line = lineOffset + c.y();
|
||||
|
||||
//printf("c (%i,%i) : Line %i : %04X \n", c.x(), c.y(), line, asmEntry[line]->addr );
|
||||
|
||||
if ( line < asmEntry.size() )
|
||||
{
|
||||
int addr;
|
||||
|
||||
addr = asmEntry[line]->addr;
|
||||
|
||||
if (addr >= 0x8000)
|
||||
{
|
||||
int bank, romOfs;
|
||||
bank = getBank(addr);
|
||||
romOfs = GetNesFileAddress(addr);
|
||||
|
||||
sprintf( txt, "CPU Address: %02X:%04X", bank, addr);
|
||||
|
||||
s.assign( txt );
|
||||
|
||||
if (romOfs != -1)
|
||||
{
|
||||
const char *fileName;
|
||||
|
||||
fileName = iNesShortFName();
|
||||
|
||||
if ( fileName == NULL )
|
||||
{
|
||||
fileName = "...";
|
||||
}
|
||||
sprintf( txt, ", Offset 0x%06X in File \"%s\" (NL file: %X)", romOfs, fileName, bank);
|
||||
|
||||
s.append( txt );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( txt, "CPU Address: %04X", addr);
|
||||
|
||||
s.assign( txt );
|
||||
}
|
||||
}
|
||||
|
||||
if ( parent != NULL )
|
||||
{
|
||||
parent->asmLineSelLbl->setText( tr(s.c_str()) );
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void QAsmView::mousePressEvent(QMouseEvent * event)
|
||||
{
|
||||
// TODO QPoint c = convPixToCursor( event->pos() );
|
||||
|
|
|
@ -50,6 +50,8 @@ struct dbg_asm_entry_t
|
|||
}
|
||||
};
|
||||
|
||||
class ConsoleDebugger;
|
||||
|
||||
class QAsmView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -70,12 +72,15 @@ class QAsmView : public QWidget
|
|||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *event);
|
||||
void mousePressEvent(QMouseEvent * event);
|
||||
void mouseMoveEvent(QMouseEvent * event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
|
||||
void calcFontData(void);
|
||||
QPoint convPixToCursor( QPoint p );
|
||||
|
||||
private:
|
||||
ConsoleDebugger *parent;
|
||||
QFont font;
|
||||
QScrollBar *vbar;
|
||||
QScrollBar *hbar;
|
||||
|
@ -113,6 +118,7 @@ class ConsoleDebugger : public QDialog
|
|||
void updateRegisterView(void);
|
||||
void breakPointNotify(int bpNum);
|
||||
|
||||
QLabel *asmLineSelLbl;
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
//void keyPressEvent(QKeyEvent *event);
|
||||
|
@ -154,7 +160,6 @@ class ConsoleDebugger : public QDialog
|
|||
QCheckBox *autoOpenChkBox;
|
||||
QCheckBox *debFileChkBox;
|
||||
QCheckBox *idaFontChkBox;
|
||||
QLabel *asmLineSelLbl;
|
||||
QLabel *emuStatLbl;
|
||||
QLabel *ppuLbl;
|
||||
QLabel *spriteLbl;
|
||||
|
|
|
@ -1002,7 +1002,7 @@ int iNesSaveAs(const char* name)
|
|||
}
|
||||
|
||||
//para edit: added function below
|
||||
char *iNesShortFName() {
|
||||
char *iNesShortFName(void) {
|
||||
char *ret;
|
||||
|
||||
if (!(ret = strrchr(LoadedRomFName, '\\')))
|
||||
|
|
|
@ -46,6 +46,7 @@ extern uint8 *ExtraNTARAM;
|
|||
extern int iNesSave(void); //bbit Edited: line added
|
||||
extern int iNesSaveAs(const char* name);
|
||||
extern char LoadedRomFName[2048]; //bbit Edited: line added
|
||||
extern char *iNesShortFName(void);
|
||||
extern const TMasterRomInfo* MasterRomInfo;
|
||||
extern TMasterRomInfoParams MasterRomInfoParams;
|
||||
|
||||
|
|
Loading…
Reference in New Issue