Merge pull request #236 from mjbudd77/master
Qt Debugger Window Copy/Paste Functionality Added. Misc debugger bugfixes for Mac OSX.
This commit is contained in:
commit
2532eca30b
|
@ -15,6 +15,7 @@
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
#include "../../types.h"
|
#include "../../types.h"
|
||||||
#include "../../fceu.h"
|
#include "../../fceu.h"
|
||||||
|
@ -2479,7 +2480,10 @@ void saveGameDebugBreakpoints(void)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getGameDebugBreakpointFileName( stmp );
|
if ( getGameDebugBreakpointFileName( stmp ) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//printf("Debug Save File: '%s' \n", stmp );
|
//printf("Debug Save File: '%s' \n", stmp );
|
||||||
|
|
||||||
|
@ -2615,7 +2619,10 @@ void loadGameDebugBreakpoints(void)
|
||||||
printf("No Debug Windows Open: Skipping loading of breakpoint data\n");
|
printf("No Debug Windows Open: Skipping loading of breakpoint data\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getGameDebugBreakpointFileName( stmp );
|
if ( getGameDebugBreakpointFileName( stmp ) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//printf("Debug Load File: '%s' \n", stmp );
|
//printf("Debug Load File: '%s' \n", stmp );
|
||||||
|
|
||||||
|
@ -2817,6 +2824,13 @@ QAsmView::QAsmView(QWidget *parent)
|
||||||
maxLineOffset = 0;
|
maxLineOffset = 0;
|
||||||
ctxMenuAddr = -1;
|
ctxMenuAddr = -1;
|
||||||
|
|
||||||
|
mouseLeftBtnDown = false;
|
||||||
|
txtHlgtStartChar = -1;
|
||||||
|
txtHlgtStartLine = -1;
|
||||||
|
txtHlgtEndChar = -1;
|
||||||
|
txtHlgtEndLine = -1;
|
||||||
|
|
||||||
|
|
||||||
selAddrLine = -1;
|
selAddrLine = -1;
|
||||||
selAddrChar = 0;
|
selAddrChar = 0;
|
||||||
selAddrWidth = 0;
|
selAddrWidth = 0;
|
||||||
|
@ -2825,6 +2839,12 @@ QAsmView::QAsmView(QWidget *parent)
|
||||||
|
|
||||||
//setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
//setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
|
|
||||||
|
clipboard = QGuiApplication::clipboard();
|
||||||
|
|
||||||
|
//printf("clipboard->supportsSelection() : '%i' \n", clipboard->supportsSelection() );
|
||||||
|
//printf("clipboard->supportsFindBuffer(): '%i' \n", clipboard->supportsFindBuffer() );
|
||||||
|
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
QAsmView::~QAsmView(void)
|
QAsmView::~QAsmView(void)
|
||||||
|
@ -3015,15 +3035,78 @@ QPoint QAsmView::convPixToCursor( QPoint p )
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
bool QAsmView::textIsHighlighted(void)
|
||||||
|
{
|
||||||
|
bool set = false;
|
||||||
|
|
||||||
|
if ( txtHlgtStartLine == txtHlgtEndLine )
|
||||||
|
{
|
||||||
|
set = (txtHlgtStartChar != txtHlgtEndChar);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
set = true;
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void QAsmView::setHighlightEndCoord( int x, int y )
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( txtHlgtAnchorLine < y )
|
||||||
|
{
|
||||||
|
txtHlgtStartLine = txtHlgtAnchorLine;
|
||||||
|
txtHlgtStartChar = txtHlgtAnchorChar;
|
||||||
|
txtHlgtEndLine = y;
|
||||||
|
txtHlgtEndChar = x;
|
||||||
|
}
|
||||||
|
else if ( txtHlgtAnchorLine > y )
|
||||||
|
{
|
||||||
|
txtHlgtStartLine = y;
|
||||||
|
txtHlgtStartChar = x;
|
||||||
|
txtHlgtEndLine = txtHlgtAnchorLine;
|
||||||
|
txtHlgtEndChar = txtHlgtAnchorChar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
txtHlgtStartLine = txtHlgtAnchorLine;
|
||||||
|
txtHlgtEndLine = txtHlgtAnchorLine;
|
||||||
|
|
||||||
|
if ( txtHlgtAnchorChar < x )
|
||||||
|
{
|
||||||
|
txtHlgtStartChar = txtHlgtAnchorChar;
|
||||||
|
txtHlgtEndChar = x;
|
||||||
|
}
|
||||||
|
else if ( txtHlgtAnchorChar > x )
|
||||||
|
{
|
||||||
|
txtHlgtStartChar = x;
|
||||||
|
txtHlgtEndChar = txtHlgtAnchorChar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
txtHlgtStartChar = txtHlgtAnchorChar;
|
||||||
|
txtHlgtEndChar = txtHlgtAnchorChar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
void QAsmView::mouseMoveEvent(QMouseEvent * event)
|
void QAsmView::mouseMoveEvent(QMouseEvent * event)
|
||||||
{
|
{
|
||||||
int line;
|
int line;
|
||||||
QPoint c = convPixToCursor( event->pos() );
|
|
||||||
char txt[256];
|
char txt[256];
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
|
QPoint c = convPixToCursor( event->pos() );
|
||||||
|
|
||||||
line = lineOffset + c.y();
|
line = lineOffset + c.y();
|
||||||
|
|
||||||
|
if ( mouseLeftBtnDown )
|
||||||
|
{
|
||||||
|
//printf("Left Button Move: (%i,%i)\n", c.x(), c.y() );
|
||||||
|
setHighlightEndCoord( c.x(), line );
|
||||||
|
}
|
||||||
|
|
||||||
//printf("c (%i,%i) : Line %i : %04X \n", c.x(), c.y(), line, asmEntry[line]->addr );
|
//printf("c (%i,%i) : Line %i : %04X \n", c.x(), c.y(), line, asmEntry[line]->addr );
|
||||||
|
|
||||||
if ( line < asmEntry.size() )
|
if ( line < asmEntry.size() )
|
||||||
|
@ -3071,12 +3154,112 @@ void QAsmView::mouseMoveEvent(QMouseEvent * event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
void QAsmView::loadClipboard( const char *txt )
|
||||||
|
{
|
||||||
|
clipboard->setText( tr(txt), QClipboard::Clipboard );
|
||||||
|
|
||||||
|
if ( clipboard->supportsSelection() )
|
||||||
|
{
|
||||||
|
clipboard->setText( tr(txt), QClipboard::Selection );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void QAsmView::loadHighlightToClipboard(void)
|
||||||
|
{
|
||||||
|
if ( !textIsHighlighted() )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int l, row, nrow;
|
||||||
|
std::string txt;
|
||||||
|
|
||||||
|
nrow = (viewHeight / pxLineSpacing) + 1;
|
||||||
|
|
||||||
|
if ( nrow < 1 ) nrow = 1;
|
||||||
|
|
||||||
|
for (row=0; row < nrow; row++)
|
||||||
|
{
|
||||||
|
l = lineOffset + row;
|
||||||
|
|
||||||
|
if ( (l >= txtHlgtStartLine) && (l <= txtHlgtEndLine) )
|
||||||
|
{
|
||||||
|
int hlgtXs, hlgtXe, hlgtXd;
|
||||||
|
std::string s;
|
||||||
|
bool addNewLine;
|
||||||
|
|
||||||
|
if ( l == txtHlgtStartLine )
|
||||||
|
{
|
||||||
|
hlgtXs = txtHlgtStartChar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hlgtXs = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( l == txtHlgtEndLine )
|
||||||
|
{
|
||||||
|
hlgtXe = txtHlgtEndChar;
|
||||||
|
addNewLine = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hlgtXe = (viewWidth / pxCharWidth) + 1;
|
||||||
|
addNewLine = true;
|
||||||
|
}
|
||||||
|
hlgtXd = (hlgtXe - hlgtXs);
|
||||||
|
|
||||||
|
if ( hlgtXs < asmEntry[l]->text.size() )
|
||||||
|
{
|
||||||
|
s = asmEntry[l]->text.substr( hlgtXs, hlgtXd );
|
||||||
|
}
|
||||||
|
txt.append(s);
|
||||||
|
|
||||||
|
if ( addNewLine )
|
||||||
|
{
|
||||||
|
txt.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//printf("Load Text to Clipboard:\n%s\n", txt.c_str() );
|
||||||
|
|
||||||
|
loadClipboard( txt.c_str() );
|
||||||
|
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void QAsmView::mouseReleaseEvent(QMouseEvent * event)
|
||||||
|
{
|
||||||
|
int line;
|
||||||
|
QPoint c = convPixToCursor( event->pos() );
|
||||||
|
|
||||||
|
line = lineOffset + c.y();
|
||||||
|
|
||||||
|
if ( event->button() == Qt::LeftButton )
|
||||||
|
{
|
||||||
|
//printf("Left Button Release: (%i,%i)\n", c.x(), c.y() );
|
||||||
|
mouseLeftBtnDown = false;
|
||||||
|
setHighlightEndCoord( c.x(), line );
|
||||||
|
|
||||||
|
loadHighlightToClipboard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
void QAsmView::mousePressEvent(QMouseEvent * event)
|
void QAsmView::mousePressEvent(QMouseEvent * event)
|
||||||
{
|
{
|
||||||
int line;
|
int line;
|
||||||
QPoint c = convPixToCursor( event->pos() );
|
QPoint c = convPixToCursor( event->pos() );
|
||||||
|
|
||||||
line = lineOffset + c.y();
|
line = lineOffset + c.y();
|
||||||
|
|
||||||
|
if ( event->button() == Qt::LeftButton )
|
||||||
|
{
|
||||||
|
//printf("Left Button Pressed: (%i,%i)\n", c.x(), c.y() );
|
||||||
|
mouseLeftBtnDown = true;
|
||||||
|
txtHlgtAnchorChar = c.x();
|
||||||
|
txtHlgtAnchorLine = line;
|
||||||
|
|
||||||
|
setHighlightEndCoord( c.x(), line );
|
||||||
|
}
|
||||||
|
|
||||||
selAddrLine = -1;
|
selAddrLine = -1;
|
||||||
selAddrChar = 0;
|
selAddrChar = 0;
|
||||||
|
@ -3209,6 +3392,10 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
|
||||||
parent->setBookmarkSelectedAddress( addr );
|
parent->setBookmarkSelectedAddress( addr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( selAddrText[0] != 0 )
|
||||||
|
{
|
||||||
|
loadClipboard( selAddrText );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -3260,12 +3447,29 @@ void QAsmView::contextMenuEvent(QContextMenuEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
void QAsmView::drawText( QPainter *painter, int x, int y, const char *txt )
|
||||||
|
{
|
||||||
|
int i=0;
|
||||||
|
char c[2];
|
||||||
|
|
||||||
|
c[0] = 0; c[1] = 0;
|
||||||
|
|
||||||
|
while ( txt[i] != 0 )
|
||||||
|
{
|
||||||
|
c[0] = txt[i];
|
||||||
|
painter->drawText( x, y, tr(c) );
|
||||||
|
i++; x += pxCharWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
void QAsmView::paintEvent(QPaintEvent *event)
|
void QAsmView::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
int x,y,l, row, nrow, selAddr;
|
int x,y,l, row, nrow, selAddr;
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
QColor black("black");
|
QColor white("white"), black("black"), blue("blue");
|
||||||
|
QColor hlgtFG("white"), hlgtBG("blue");
|
||||||
bool forceDarkColor = false;
|
bool forceDarkColor = false;
|
||||||
|
bool txtHlgtSet = false;
|
||||||
|
|
||||||
painter.setFont(font);
|
painter.setFont(font);
|
||||||
viewWidth = event->rect().width();
|
viewWidth = event->rect().width();
|
||||||
|
@ -3302,6 +3506,8 @@ void QAsmView::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
y = pxLineSpacing;
|
y = pxLineSpacing;
|
||||||
|
|
||||||
|
txtHlgtSet = textIsHighlighted();
|
||||||
|
|
||||||
for (row=0; row < nrow; row++)
|
for (row=0; row < nrow; row++)
|
||||||
{
|
{
|
||||||
x = -pxLineXScroll;
|
x = -pxLineXScroll;
|
||||||
|
@ -3334,23 +3540,23 @@ void QAsmView::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
painter.setPen( this->palette().color(QPalette::WindowText));
|
painter.setPen( this->palette().color(QPalette::WindowText));
|
||||||
}
|
}
|
||||||
painter.drawText( x, y, tr(asmEntry[l]->text.c_str()) );
|
drawText( &painter, x, y, asmEntry[l]->text.c_str() );
|
||||||
|
|
||||||
if ( (selAddrLine == l) )
|
if ( (selAddrLine == l) )
|
||||||
{ // Highlight ASM line for selected address.
|
{ // Highlight ASM line for selected address.
|
||||||
if ( (selAddr == selAddrValue) &&
|
if ( !txtHlgtSet && (selAddr == selAddrValue) &&
|
||||||
(asmEntry[l]->text.size() >= (selAddrChar + selAddrWidth) ) &&
|
(asmEntry[l]->text.size() >= (selAddrChar + selAddrWidth) ) &&
|
||||||
( asmEntry[l]->text.compare( selAddrChar, selAddrWidth, selAddrText ) == 0 ) )
|
( asmEntry[l]->text.compare( selAddrChar, selAddrWidth, selAddrText ) == 0 ) )
|
||||||
{
|
{
|
||||||
int ax;
|
int ax;
|
||||||
|
|
||||||
ax = selAddrChar*pxCharWidth;
|
ax = x + selAddrChar*pxCharWidth;
|
||||||
|
|
||||||
painter.fillRect( ax, y - pxLineSpacing + pxLineLead, selAddrWidth*pxCharWidth, pxLineSpacing, QColor("blue") );
|
painter.fillRect( ax, y - pxLineSpacing + pxLineLead, selAddrWidth*pxCharWidth, pxLineSpacing, blue );
|
||||||
|
|
||||||
painter.setPen( QColor("white"));
|
painter.setPen( white );
|
||||||
|
|
||||||
painter.drawText( ax, y, tr(selAddrText) );
|
drawText( &painter, ax, y, selAddrText );
|
||||||
|
|
||||||
painter.setPen( this->palette().color(QPalette::WindowText));
|
painter.setPen( this->palette().color(QPalette::WindowText));
|
||||||
}
|
}
|
||||||
|
@ -3358,6 +3564,56 @@ void QAsmView::paintEvent(QPaintEvent *event)
|
||||||
}
|
}
|
||||||
y += pxLineSpacing;
|
y += pxLineSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
y = pxLineSpacing;
|
||||||
|
|
||||||
|
painter.setPen( hlgtFG );
|
||||||
|
|
||||||
|
if ( txtHlgtSet )
|
||||||
|
{
|
||||||
|
for (row=0; row < nrow; row++)
|
||||||
|
{
|
||||||
|
x = -pxLineXScroll;
|
||||||
|
l = lineOffset + row;
|
||||||
|
|
||||||
|
if ( (l >= txtHlgtStartLine) && (l <= txtHlgtEndLine) )
|
||||||
|
{
|
||||||
|
int ax, hlgtXs, hlgtXe, hlgtXd;
|
||||||
|
std::string s;
|
||||||
|
|
||||||
|
if ( l == txtHlgtStartLine )
|
||||||
|
{
|
||||||
|
hlgtXs = txtHlgtStartChar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hlgtXs = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( l == txtHlgtEndLine )
|
||||||
|
{
|
||||||
|
hlgtXe = txtHlgtEndChar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hlgtXe = (viewWidth / pxCharWidth) + 1;
|
||||||
|
}
|
||||||
|
hlgtXd = (hlgtXe - hlgtXs);
|
||||||
|
|
||||||
|
if ( hlgtXs < asmEntry[l]->text.size() )
|
||||||
|
{
|
||||||
|
s = asmEntry[l]->text.substr( hlgtXs, hlgtXd );
|
||||||
|
}
|
||||||
|
|
||||||
|
ax = x + (hlgtXs * pxCharWidth);
|
||||||
|
|
||||||
|
painter.fillRect( ax, y - pxLineSpacing + pxLineLead, hlgtXd * pxCharWidth, pxLineSpacing, hlgtBG );
|
||||||
|
|
||||||
|
drawText( &painter, ax, y, s.c_str() );
|
||||||
|
}
|
||||||
|
y += pxLineSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// Bookmark Manager Methods
|
// Bookmark Manager Methods
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
#include "Qt/main.h"
|
#include "Qt/main.h"
|
||||||
|
@ -116,18 +117,25 @@ class QAsmView : public QWidget
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
void keyReleaseEvent(QKeyEvent *event);
|
void keyReleaseEvent(QKeyEvent *event);
|
||||||
void mousePressEvent(QMouseEvent * event);
|
void mousePressEvent(QMouseEvent * event);
|
||||||
|
void mouseReleaseEvent(QMouseEvent * event);
|
||||||
void mouseMoveEvent(QMouseEvent * event);
|
void mouseMoveEvent(QMouseEvent * event);
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
|
void loadHighlightToClipboard(void);
|
||||||
|
|
||||||
void calcFontData(void);
|
void calcFontData(void);
|
||||||
QPoint convPixToCursor( QPoint p );
|
QPoint convPixToCursor( QPoint p );
|
||||||
|
bool textIsHighlighted(void);
|
||||||
|
void setHighlightEndCoord( int x, int y );
|
||||||
|
void loadClipboard( const char *txt );
|
||||||
|
void drawText( QPainter *painter, int x, int y, const char *txt );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConsoleDebugger *parent;
|
ConsoleDebugger *parent;
|
||||||
QFont font;
|
QFont font;
|
||||||
QScrollBar *vbar;
|
QScrollBar *vbar;
|
||||||
QScrollBar *hbar;
|
QScrollBar *hbar;
|
||||||
|
QClipboard *clipboard;
|
||||||
|
|
||||||
int ctxMenuAddr;
|
int ctxMenuAddr;
|
||||||
int maxLineLen;
|
int maxLineLen;
|
||||||
|
@ -152,6 +160,13 @@ class QAsmView : public QWidget
|
||||||
int selAddrValue;
|
int selAddrValue;
|
||||||
char selAddrText[128];
|
char selAddrText[128];
|
||||||
|
|
||||||
|
int txtHlgtAnchorChar;
|
||||||
|
int txtHlgtAnchorLine;
|
||||||
|
int txtHlgtStartChar;
|
||||||
|
int txtHlgtStartLine;
|
||||||
|
int txtHlgtEndChar;
|
||||||
|
int txtHlgtEndLine;
|
||||||
|
|
||||||
dbg_asm_entry_t *asmPC;
|
dbg_asm_entry_t *asmPC;
|
||||||
std::vector <dbg_asm_entry_t*> asmEntry;
|
std::vector <dbg_asm_entry_t*> asmEntry;
|
||||||
|
|
||||||
|
@ -159,6 +174,7 @@ class QAsmView : public QWidget
|
||||||
bool displayROMoffsets;
|
bool displayROMoffsets;
|
||||||
bool symbolicDebugEnable;
|
bool symbolicDebugEnable;
|
||||||
bool registerNameEnable;
|
bool registerNameEnable;
|
||||||
|
bool mouseLeftBtnDown;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DebuggerStackDisplay : public QPlainTextEdit
|
class DebuggerStackDisplay : public QPlainTextEdit
|
||||||
|
|
|
@ -16,32 +16,35 @@ nes_shm_t *nes_shm = NULL;
|
||||||
//************************************************************************
|
//************************************************************************
|
||||||
nes_shm_t *open_nes_shm(void)
|
nes_shm_t *open_nes_shm(void)
|
||||||
{
|
{
|
||||||
int shmId;
|
|
||||||
nes_shm_t *vaddr;
|
nes_shm_t *vaddr;
|
||||||
struct shmid_ds ds;
|
|
||||||
|
|
||||||
shmId = shmget( IPC_PRIVATE, sizeof(struct nes_shm_t), IPC_CREAT | S_IRWXU | S_IRWXG );
|
vaddr = (nes_shm_t*)malloc( sizeof(struct nes_shm_t) );
|
||||||
|
|
||||||
if ( shmId == -1 )
|
//int shmId;
|
||||||
{
|
//struct shmid_ds ds;
|
||||||
perror("Error: GL shmget Failed:");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
printf("Created ShmID: %i \n", shmId );
|
|
||||||
|
|
||||||
vaddr = (nes_shm_t*)shmat( shmId, NULL, 0);
|
//shmId = shmget( IPC_PRIVATE, sizeof(struct nes_shm_t), IPC_CREAT | S_IRWXU | S_IRWXG );
|
||||||
|
|
||||||
if ( vaddr == (nes_shm_t*)-1 )
|
//if ( shmId == -1 )
|
||||||
{
|
//{
|
||||||
perror("Error: NES shmat Failed:");
|
// perror("Error: GL shmget Failed:");
|
||||||
return NULL;
|
// return NULL;
|
||||||
}
|
//}
|
||||||
memset( vaddr, 0, sizeof(struct nes_shm_t));
|
//printf("Created ShmID: %i \n", shmId );
|
||||||
|
|
||||||
if ( shmctl( shmId, IPC_RMID, &ds ) != 0 )
|
//vaddr = (nes_shm_t*)shmat( shmId, NULL, 0);
|
||||||
{
|
|
||||||
perror("Error: GLX shmctl IPC_RMID Failed:");
|
//if ( vaddr == (nes_shm_t*)-1 )
|
||||||
}
|
//{
|
||||||
|
// perror("Error: NES shmat Failed:");
|
||||||
|
// return NULL;
|
||||||
|
//}
|
||||||
|
//memset( vaddr, 0, sizeof(struct nes_shm_t));
|
||||||
|
|
||||||
|
//if ( shmctl( shmId, IPC_RMID, &ds ) != 0 )
|
||||||
|
//{
|
||||||
|
// perror("Error: GLX shmctl IPC_RMID Failed:");
|
||||||
|
//}
|
||||||
|
|
||||||
//sem_init( &vaddr->sem, 1, 1 );
|
//sem_init( &vaddr->sem, 1, 1 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue