Added a cartdridge view menu
authorJean-Paul Mari <djipi.mari@gmail.com>
Sun, 28 Oct 2018 10:33:03 +0000 (06:33 -0400)
committerJean-Paul Mari <djipi.mari@gmail.com>
Sun, 28 Oct 2018 10:33:03 +0000 (06:33 -0400)
Win-VS2017/virtualjaguar.vcxproj
Win-VS2017/virtualjaguar.vcxproj.filters
docs/vj_HistoryNotes.txt
src/debugger/CartFilesListWin.cpp [new file with mode: 0644]
src/debugger/CartFilesListWin.h [new file with mode: 0644]
src/gui/mainwin.cpp
src/gui/mainwin.h
virtualjaguar.pro

index 7a8c8ca..44d1a70 100644 (file)
     <ClCompile Include="..\src\crc32.cpp" />\r
     <ClCompile Include="..\src\debugger\BreakpointsWin.cpp" />\r
     <ClCompile Include="..\src\debugger\callstackbrowser.cpp" />\r
+    <ClCompile Include="..\src\debugger\CartFilesListWin.cpp" />\r
     <ClCompile Include="..\src\debugger\exceptionvectortablebrowser.cpp" />\r
     <ClCompile Include="..\src\debugger\FilesrcListWin.cpp" />\r
     <ClCompile Include="..\src\debugger\localbrowser.cpp" />\r
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>\r
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>\r
     </ClCompile>\r
+    <ClCompile Include="GeneratedFiles\Debug\moc_CartFilesListWin.cpp">\r
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>\r
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>\r
+    </ClCompile>\r
     <ClCompile Include="GeneratedFiles\Debug\moc_configdialog.cpp">\r
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>\r
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>\r
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>\r
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>\r
     </ClCompile>\r
+    <ClCompile Include="GeneratedFiles\Release\moc_CartFilesListWin.cpp">\r
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>\r
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>\r
+    </ClCompile>\r
     <ClCompile Include="GeneratedFiles\Release\moc_configdialog.cpp">\r
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>\r
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>\r
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>\r
       <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp"  -D_CRT_SECURE_NO_WARNINGS -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -D__GCCWIN32__ -DQT_NO_DEBUG -DQT_OPENGL_LIB -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -D_UNICODE "-I." "-I.\..\src" "-I.\..\src\gui" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtOpenGL" "-IC:\SDK\OpenGL\include" "-IC:\SDK\SDL\SDL-1.2.15\include" "-IC:\SDK\DWARF\libdwarf-VS2015\include" "-IC:\SDK\Elf\libelf-0.8.13\include" "-IC:\SDK\zlib\zlib-1.2.11\include" "-I.\GeneratedFiles\$(ConfigurationName)\."</Command>\r
     </CustomBuild>\r
+    <CustomBuild Include="..\src\debugger\CartFilesListWin.h">\r
+      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>\r
+      <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing %(Identity)...</Message>\r
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>\r
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp"  -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -D__GCCWIN32__ -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_OPENGL_LIB "-I." "-I.\..\src" "-I.\..\src\gui" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include\QtOpenGL" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include\QtWidgets" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include\QtGui" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include\QtANGLE" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include\QtCore" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\mkspecs\win32-msvc2015" "-IC:\SDK\SDL-1.2.15\include" "-IC:\SDK\mesa-11.2.0-rc4\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtOpenGL" "-I.\GeneratedFiles\$(ConfigurationName)\."</Command>\r
+      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>\r
+      <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Moc%27ing %(Identity)...</Message>\r
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>\r
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp"  -D_CRT_SECURE_NO_WARNINGS -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -D__GCCWIN32__ -DQT_OPENGL_LIB -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -D_UNICODE "-I." "-I.\..\src" "-I.\..\src\gui" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtOpenGL" "-IC:\SDK\SDL\SDL-1.2.15\include" "-IC:\SDK\DWARF\libdwarf-VS2015\include" "-IC:\SDK\Elf\libelf-0.8.13\include" "-IC:\SDK\zlib\zlib-1.2.8\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-IC:\SDK\OpenGL\include"</Command>\r
+      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>\r
+      <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Moc%27ing %(Identity)...</Message>\r
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>\r
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp"  -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -D__GCCWIN32__ -DQT_NO_DEBUG -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_OPENGL_LIB "-I." "-I.\..\src" "-I.\..\src\gui" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include\QtOpenGL" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include\QtWidgets" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include\QtGui" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include\QtANGLE" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\include\QtCore" "-I.\..\..\..\Qt\Qt5.5.1\msvc2015_64\mkspecs\win32-msvc2015" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtOpenGL" "-I.\GeneratedFiles\$(ConfigurationName)\."</Command>\r
+      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>\r
+      <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Moc%27ing %(Identity)...</Message>\r
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>\r
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp"  -D_CRT_SECURE_NO_WARNINGS -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -D__GCCWIN32__ -DQT_NO_DEBUG -DQT_OPENGL_LIB -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -D_UNICODE "-I." "-I.\..\src" "-I.\..\src\gui" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtOpenGL" "-IC:\SDK\OpenGL\include" "-IC:\SDK\SDL\SDL-1.2.15\include" "-IC:\SDK\DWARF\libdwarf-VS2015\include" "-IC:\SDK\Elf\libelf-0.8.13\include" "-IC:\SDK\zlib\zlib-1.2.11\include" "-I.\GeneratedFiles\$(ConfigurationName)\."</Command>\r
+    </CustomBuild>\r
     <ClInclude Include="..\src\file.h" />\r
     <CustomBuild Include="..\src\gui\keybindingstab.h">\r
       <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing keybindingstab.h...</Message>\r
index 0fea985..1a08a62 100644 (file)
     <Filter Include="Source Files\gui\tab">\r
       <UniqueIdentifier>{3764368c-2eb6-49e9-a11a-a49b210d6297}</UniqueIdentifier>\r
     </Filter>\r
+    <Filter Include="Header Files\debugger\View">\r
+      <UniqueIdentifier>{e33caa2f-f4da-4d11-a399-c61abae9129c}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\debugger\View">\r
+      <UniqueIdentifier>{6a9b2983-c30d-47db-8c30-73c1ec7d029d}</UniqueIdentifier>\r
+    </Filter>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClCompile Include="GeneratedFiles\qrc_virtualjaguar.cpp">\r
     <ClCompile Include="..\src\debugger\NewFnctBreakpointWin.cpp">\r
       <Filter>Source Files\debugger</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="GeneratedFiles\Debug\moc_CartFilesListWin.cpp">\r
+      <Filter>Generated Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="GeneratedFiles\Release\moc_CartFilesListWin.cpp">\r
+      <Filter>Generated Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\src\debugger\CartFilesListWin.cpp">\r
+      <Filter>Source Files\debugger\View</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\src\debugger\DWARFManager.h">\r
     <CustomBuild Include="..\src\debugger\NewFnctBreakpointWin.h">\r
       <Filter>Header Files\debugger</Filter>\r
     </CustomBuild>\r
+    <CustomBuild Include="..\src\debugger\CartFilesListWin.h">\r
+      <Filter>Header Files\debugger\View</Filter>\r
+    </CustomBuild>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ResourceCompile Include="..\res\vj.rc">\r
index af829eb..a1dba82 100644 (file)
@@ -76,6 +76,9 @@ Git commit: TBD
 40) Added the return address information in the call stack
 41) Added multiple breakpoints feature and their key bindings
 -- For functions only
+42) Added timer initialisation for the SDL setup
+43) Added a cartdridge view menu
+-- Added a window to display my own directory and his files list
 
 Release 3 (13th November 2017)
 ------------------------------
@@ -198,6 +201,7 @@ Known issues
 -- User must perform an operation, such code tracing, to see the breakpoints list update
 16) Some ASCII characters may be not displayed correctly
 -- It depend how the text is displayed, this is related to the QT/HTML encoding done when reading DWARF file
+17) Potential legacy crash when leaving emulator in pause mode for a long period of time
 
 Cosmetic / UX issues
 ====================
diff --git a/src/debugger/CartFilesListWin.cpp b/src/debugger/CartFilesListWin.cpp
new file mode 100644 (file)
index 0000000..26ae7ae
--- /dev/null
@@ -0,0 +1,373 @@
+//
+// CartFilesListWin.cpp - List files in the cartdridge
+//
+// by Jean-Paul Mari
+//
+// JPM = Jean-Paul Mari <djipi.mari@gmail.com>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JPM  10/26/2018  Created this file
+//
+
+// TO DO:
+// To allow file opening / viewing
+// Remove/modify the 1st information, named '1', at the top
+// To add a filter
+//
+
+#include "debugger/CartFilesListWin.h"
+#include "memory.h"
+#include "settings.h"
+#include "debugger/DBGManager.h"
+
+
+//
+CartFilesListWindow::CartFilesListWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),
+TableView(new QTableView),
+model(new QStandardItemModel),
+layout(new QVBoxLayout),
+treeView(new QTreeView),
+standardModel(new QStandardItemModel),
+rootNode(new QStandardItem),
+CartDirectory(NULL),
+statusbar(new QStatusBar),
+fileItems(NULL),
+nbItem(0),
+CartUsedBytes(0),
+CartDirType(CFL_NOTYPE)
+{
+       setWindowTitle(tr("Cartdridge directory & files"));
+
+       // Set the font
+       QFont fixedFont("Lucida Console", 8, QFont::Normal);
+       fixedFont.setStyleHint(QFont::TypeWriter);
+
+       // Set the new layout with proper identation and readibility
+#ifdef CFL_BUFFERTREAM
+       model->setColumnCount(5);
+#else
+       model->setColumnCount(4);
+#endif
+       model->setHeaderData(0, Qt::Horizontal, QObject::tr("File"));
+       model->setHeaderData(1, Qt::Horizontal, QObject::tr("Address"));
+       model->setHeaderData(2, Qt::Horizontal, QObject::tr("Size"));
+       model->setHeaderData(3, Qt::Horizontal, QObject::tr("Seek"));
+#ifdef CFL_BUFFERTREAM
+       model->setHeaderData(4, Qt::Horizontal, QObject::tr("Stream"));
+#endif
+       // Information table
+       TableView->setModel(model);
+       TableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+       TableView->setShowGrid(0);
+       TableView->setFont(fixedFont);
+       TableView->verticalHeader()->setDefaultSectionSize(TableView->verticalHeader()->minimumSectionSize());
+       TableView->verticalHeader()->setDefaultAlignment(Qt::AlignRight);
+       layout->addWidget(TableView);
+
+       // Setup root
+       rootNode = standardModel->invisibleRootItem();
+       //register the model
+       treeView->setModel(standardModel);
+       treeView->expandAll();
+       layout->addWidget(treeView);
+
+       // Status bar
+       layout->addWidget(statusbar);
+       setLayout(layout);
+}
+
+
+//
+CartFilesListWindow::~CartFilesListWindow(void)
+{
+}
+
+
+//
+void CartFilesListWindow::Reset(void)
+{
+       standardModel->setRowCount(0);
+       model->setRowCount(0);
+       free(CartDirectory);
+       free(fileItems);
+       fileItems = NULL;
+       CartDirectory = NULL;
+       CartUsedBytes = CartNbrFiles = CartDirType = nbItem = 0;
+}
+
+
+//
+void CartFilesListWindow::RefreshContents(void)
+{
+       size_t Error;
+       char msg[1024];
+
+       if (isVisible())
+       {
+               if (!CartDirectory)
+               {
+                       if (CartDirType = GetDirType())
+                       {
+                               if ((CartNbrFiles = GetNbrFiles()))
+                               {
+                                       if ((CartDirectory = (CARTDIRINFO *)CreateInfos()))
+                                       {
+                                               UpdateInfos();
+                                               sprintf(msg, "%u files | %u bytes in cartdridge", (unsigned int)CartNbrFiles, (unsigned int)CartUsedBytes);
+                                               Error = CFL_NOERROR;
+                                       }
+                                       else
+                                       {
+                                               sprintf(msg, "Cannot use directory");
+                                               Error = CFL_NODIRUSE;
+                                       }
+                               }
+                               else
+                               {
+                                       sprintf(msg, "No files");
+                                       Error = CFL_NOFILESLIST;
+                               }
+                       }
+                       else
+                       {
+                               sprintf(msg, "No directory found");
+                               Error = CFL_NODIRECTORYLIST;
+                       }
+
+                       // Display status bar
+                       if (Error)
+                       {
+                               if ((Error & CFL_WARNING))
+                               {
+                                       statusbar->setStyleSheet("background-color: lightyellow; font: bold");
+                               }
+                               else
+                               {
+                                       statusbar->setStyleSheet("background-color: tomato; font: bold");
+                               }
+                       }
+                       else
+                       {
+                               statusbar->setStyleSheet("background-color: lightgreen; font: bold");
+                       }
+                       statusbar->showMessage(QString(msg));
+               }
+               else
+               {
+                       UpdateInfos();
+               }
+       }
+}
+
+
+// Get files number in the directory
+size_t CartFilesListWindow::GetNbrFiles(void)
+{
+       switch (CartDirType)
+       {
+       case CFL_OSJAGTYPE:
+               return ((DBGManager_GetAdrFromSymbolName((char *)"OSJAG_Directory_End") - DBGManager_GetAdrFromSymbolName((char *)"OSJAG_Directory_Deb"))) / sizeof(long);
+               break;
+
+       default:
+               return 0;
+               break;
+       }
+}
+
+
+// Get directory type
+size_t CartFilesListWindow::GetDirType(void)
+{
+       if (DBGManager_GetAdrFromSymbolName((char *)"OSJAG_Directory"))
+       {
+               return CFL_OSJAGTYPE;
+       }
+       else
+       {
+               return CFL_NOTYPE;
+       }
+}
+
+
+// Get filename from index (starting from 0)
+void CartFilesListWindow::GetFileInfos(CARTDIRINFO *Ptr, size_t index)
+{
+       OSJAGDir *Adr;
+       size_t Offset;
+
+       switch (CartDirType)
+       {
+       case CFL_OSJAGTYPE:
+               Offset = DBGManager_GetAdrFromSymbolName((char *)"OSJAG_Directory_Deb") + (index * sizeof(long));
+               Adr = (OSJAGDir *)&jagMemSpace[Offset = GET32(jagMemSpace, Offset)];
+               if (strlen(Adr->Filename))
+               {
+                       Ptr->PtrFilename = Adr->Filename;
+                       Ptr->valid = true;
+               }
+               else
+               {
+                       Ptr->PtrFilename = (char *)"(null)";
+               }
+               Ptr->PtrDataFile = GET32(jagMemSpace, Offset);
+               Ptr->SizeFile = GET32(jagMemSpace, (Offset + sizeof(long)));
+               break;
+
+       default:
+               break;
+       }
+}
+
+
+// Create information from the directory information
+void *CartFilesListWindow::CreateInfos(void)
+{
+       CARTDIRINFO *Ptr = (CARTDIRINFO *)calloc(CartNbrFiles, sizeof(CARTDIRINFO));
+       model->setRowCount(0);
+
+       for (int i = 0; i < CartNbrFiles; i++)
+       {
+               GetFileInfos(&Ptr[i], i);
+               AddFilename(Ptr[i].PtrFilename, rootNode, 0);
+               // Display row content
+               model->insertRow(i);
+               model->setItem(i, 0, new QStandardItem(QString("%1").arg(Ptr[i].PtrFilename)));
+               if (!Ptr[i].SizeFile)
+               {
+                       //model->setItem(i, 1, new QStandardItem(QString("%1").arg("")));
+                       //model->setItem(i, 2, new QStandardItem(QString("%1").arg("")));
+               }
+               else
+               {
+                       model->setItem(i, 1, new QStandardItem(QString("0x%1").arg(Ptr[i].PtrDataFile, 6, 16, QChar('0'))));
+                       model->setItem(i, 2, new QStandardItem(QString("0x%1").arg(Ptr[i].SizeFile, 6, 16, QChar('0'))));
+               }
+               CartUsedBytes += Ptr[i].SizeFile;
+       }
+
+       return Ptr;
+}
+
+
+// Update the variables information (seek and stream buffer)
+void CartFilesListWindow::UpdateInfos(void)
+{
+       size_t Offset;
+
+       for (int i = 0; i < CartNbrFiles; i++)
+       {
+               // Check if file validity (exitence)
+               if (CartDirectory[i].valid)
+               {
+                       // Get the current seek and tentatively check validity (must be included in the ram zone)
+                       Offset = DBGManager_GetAdrFromSymbolName((char *)"OSJAG_SeekPosition") + (i * sizeof(long));
+                       if ((CartDirectory[i].CurrentSeek = GET32(jagMemSpace, Offset)) < vjs.DRAM_size)
+                       {
+                               model->setItem(i, 3, new QStandardItem(QString("0x%1").arg(CartDirectory[i].CurrentSeek, 6, 16, QChar('0'))));
+                       }
+                       else
+                       {
+                               //model->setItem(i, 3, new QStandardItem(QString("%1").arg("")));
+                       }
+
+                       // Get stream buffer address and check validity (must be included in the ram zone)
+                       Offset = DBGManager_GetAdrFromSymbolName((char *)"OSJAG_PtrBuffer") + (i * sizeof(long));
+                       if (((CartDirectory[i].PtrBufferStream = GET32(jagMemSpace, Offset)) < vjs.DRAM_size) && CartDirectory[i].PtrBufferStream)
+                       {
+#ifdef CFL_BUFFERTREAM
+                               model->setItem(i, 4, new QStandardItem(QString("0x%1").arg(CartDirectory[i].PtrBufferStream, 6, 16, QChar('0'))));
+#else
+                               if (!CartDirectory[i].SizeFile)
+                               {
+                                       model->setItem(i, 1, new QStandardItem(QString("0x%1").arg(CartDirectory[i].PtrBufferStream, 6, 16, QChar('0'))));
+                               }
+#endif
+                       }
+                       else
+                       {
+#ifdef CFL_BUFFERTREAM
+                               model->setItem(i, 4, new QStandardItem(QString("%1").arg("")));
+#else
+                               if (!CartDirectory[i].SizeFile)
+                               {
+                                       model->setItem(i, 1, new QStandardItem(QString("%1").arg("")));
+                               }
+#endif
+                       }
+               }
+       }
+}
+
+
+// Add source code filename in the list
+void CartFilesListWindow::AddFilename(char *FileName, QStandardItem *root, size_t ItemPos)
+{
+       char *Ptr = FileName;
+       Sfileitem *PtrNewFile;
+       char Buffer[255];
+       char a;
+
+       while ((a = *Ptr++) && ((a != '\\') && (a != '/')));
+
+       if (a)
+       {
+               strncpy(Buffer, FileName, (Ptr - FileName - 1));
+               Buffer[(Ptr - FileName - 1)] = 0;
+       }
+       else
+       {
+               strcpy(Buffer, FileName);
+       }
+       PtrNewFile = (Sfileitem *)AddItem(Buffer, ItemPos);
+       if (!PtrNewFile->PreviousItem)
+       {
+               PtrNewFile->PreviousItem = root;
+               root->appendRow(PtrNewFile->Item);
+               PtrNewFile->Item->setEditable(false);
+       }
+
+       if (a)
+       {
+               return (AddFilename(Ptr, PtrNewFile->Item, (ItemPos + 1)));
+       }
+}
+
+
+// Add item to the list
+// Return void * on new item or already existing one
+void *CartFilesListWindow::AddItem(char *ItemName, size_t ItemPos)
+{
+       Sfileitem *Ptr = fileItems;
+
+       // Look for already existing item
+       for (size_t i = 0; i < nbItem; i++)
+       {
+               if ((Ptr->column == ItemPos) && !strcmp(Ptr->Item->text().toLocal8Bit().constData(), ItemName))
+               {
+                       return Ptr;
+               }
+               else
+               {
+                       Ptr++;
+               }
+       }
+
+       // Add item in the list
+       fileItems = (Sfileitem *)realloc(fileItems, (sizeof(Sfileitem) * ++nbItem));
+       (fileItems + (nbItem - 1))->column = ItemPos;
+       (fileItems + (nbItem - 1))->PreviousItem = NULL;
+       (fileItems + (nbItem - 1))->Item = new QStandardItem(ItemName);
+       return (fileItems + (nbItem - 1));
+}
+
+
+// 
+void CartFilesListWindow::keyPressEvent(QKeyEvent * e)
+{
+       if (e->key() == Qt::Key_Escape)
+       {
+               hide();
+       }
+}
diff --git a/src/debugger/CartFilesListWin.h b/src/debugger/CartFilesListWin.h
new file mode 100644 (file)
index 0000000..e504d17
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// CartFilesListWin.h: List files from directory
+//
+// by Jean-Paul Mari
+//
+
+#ifndef __CARTFILESLISTWIN_H__
+#define __CARTFILESLISTWIN_H__
+
+#include <QtWidgets>
+#include <stdint.h>
+
+//
+//#define CFL_BUFFERTREAM                              // Display the buffer stream
+
+// Error code definitions
+#define        CFL_NOERROR                             0x00
+#define        CFL_ERROR                               0x80
+#define        CFL_WARNING                             0x40
+#define        CFL_NOFILESLIST                 (0x01 | CFL_WARNING)
+#define        CFL_NODIRECTORYLIST             (0x02 | CFL_WARNING)
+#define CFL_NODIRUSE                   (0x04 | CFL_WARNING)
+
+// Cart directory type
+#define CFL_NOTYPE             0x00
+#define CFL_OSJAGTYPE  0x01
+
+
+// 
+class CartFilesListWindow: public QWidget
+{
+       Q_OBJECT
+
+       typedef struct _fileitem
+       {
+               size_t column;
+               QStandardItem *PreviousItem;
+               QStandardItem *Item;
+       }Sfileitem;
+
+       typedef struct S_CARTDIRINFO
+       {
+               bool valid;
+               char *PtrFilename;
+               size_t SizeFile;
+               size_t PtrDataFile;
+               size_t CurrentSeek;
+               size_t PtrBufferStream;
+       }
+       CARTDIRINFO;
+
+       typedef struct S_OSJAGDir
+       {
+               long PtrDataFile;
+               long SizeFile;
+               char Filename[];
+       }
+       OSJAGDir;
+
+       public:
+               CartFilesListWindow(QWidget *parent = 0);
+               ~CartFilesListWindow(void);
+               void RefreshContents(void);
+               void Reset(void);
+
+       private:
+               void *AddItem(char *ItemName, size_t ItemPos);
+               void AddFilename(char *FileName, QStandardItem *root, size_t ItemPos);
+               void UpdateInfos(void);
+               void *CreateInfos(void);
+               size_t GetDirType(void);
+               size_t GetNbrFiles(void);
+               void GetFileInfos(CARTDIRINFO *Ptr, size_t index);
+
+       protected:
+               void keyPressEvent(QKeyEvent * e);
+
+       private:
+               size_t nbItem, CartDirType, CartNbrFiles, CartUsedBytes;
+               QVBoxLayout *layout;
+               QTreeView *treeView;
+               QStandardItemModel *standardModel;
+               QStandardItem *rootNode;
+               CARTDIRINFO *CartDirectory;
+               QStatusBar *statusbar;
+               Sfileitem *fileItems;
+               QStandardItemModel *model;
+               QTableView *TableView;
+};
+
+#endif // __CARTFILESLISTWIN_H__
index 031e6e3..352d580 100644 (file)
@@ -20,7 +20,7 @@
 // JPM  11/04/2017  Added the local window\r
 // JPM  08/31/2018  Added the call stack window\r
 // JPM  Sept./2018  Added the new Models and BIOS handler, a screenshot feature and source code files browsing\r
-// JPM   Oct./2018  Added search paths in the settings, breakpoints feature\r
+// JPM   Oct./2018  Added search paths in the settings, breakpoints feature, cartdridge view menu\r
 //\r
 \r
 // FIXED:\r
@@ -99,6 +99,7 @@
 #include "debugger/localbrowser.h"\r
 #include "debugger/heapallocatorbrowser.h"\r
 #include "debugger/callstackbrowser.h"\r
+#include "debugger/CartFilesListWin.h"\r
 \r
 \r
 // According to SebRmv, this header isn't seen on Arch Linux either... :-/\r
@@ -199,6 +200,7 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
                NewFunctionBreakpointWin = new NewFnctBreakpointWindow(this);\r
                exceptionvectortableBrowseWin = new ExceptionVectorTableBrowserWindow(this);\r
                CallStackBrowseWin = new CallStackBrowserWindow(this);\r
+               CartFilesListWin = new CartFilesListWindow(this);\r
 \r
                mem1BrowseWin = (Memory1BrowserWindow **)calloc(vjs.nbrmemory1browserwindow, sizeof(Memory1BrowserWindow));\r
 #ifdef _MSC_VER\r
@@ -447,6 +449,11 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
                CallStackBrowseAct->setStatusTip(tr("Shows Call Stack browser window"));\r
                connect(CallStackBrowseAct, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));\r
 \r
+               // Cart files list\r
+               CartFilesListAct = new QAction(QIcon(""), tr("Directory and files"), this);\r
+               CartFilesListAct->setStatusTip(tr("List of the files in the cartdridge's directory"));\r
+               connect(CartFilesListAct, SIGNAL(triggered()), this, SLOT(ShowCartFilesListWin()));\r
+\r
                // Memory windows\r
                mem1BrowseAct = (QAction **)calloc(vjs.nbrmemory1browserwindow, sizeof(QAction));\r
                QSignalMapper *signalMapper = new QSignalMapper(this);\r
@@ -517,11 +524,25 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
        fileMenu->addSeparator();\r
        fileMenu->addAction(quitAppAct);\r
 \r
+       // Alpine and debugger menus\r
        if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)\r
        {\r
+               // Create debug & view menu\r
                debugMenu = menuBar()->addMenu(tr("&Debug"));\r
+               viewMenu = menuBar()->addMenu(tr("&View"));\r
+\r
+               // Create debugger menu\r
                if (vjs.softTypeDebugger)\r
                {\r
+                       // Cart menu\r
+                       viewCartMenu = viewMenu->addMenu(tr("&Cartridge"));\r
+                       viewCartMenu->addAction(CartFilesListAct);\r
+#if 0\r
+                       viewCartMenu->addSeparator();\r
+                       viewCartMenu->addAction(CartStreamsAct);\r
+#endif\r
+\r
+                       // Windows menu\r
                        debugWindowsMenu = debugMenu->addMenu(tr("&Windows"));\r
                        debugWindowsMenu->addAction(BreakpointsAct);\r
                        debugWindowExceptionMenu = debugWindowsMenu->addMenu(tr("&Exception"));\r
@@ -565,11 +586,14 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
                        debugNewBreakpointMenu->addAction(newFunctionBreakpointAct);\r
                        debugMenu->addAction(deleteAllBreakpointsAct);\r
                        debugMenu->addAction(disableAllBreakpointsAct);\r
-                       //debugMenu->addSeparator();\r
-                       //debugMenu->addAction(DasmAct);\r
+#if 0\r
+                       debugMenu->addSeparator();\r
+                       debugMenu->addAction(DasmAct);\r
+#endif\r
                }\r
                else\r
                {\r
+                       // Create alpine menu\r
                        debugMenu->addAction(memBrowseAct);\r
                        debugMenu->addAction(stackBrowseAct);\r
                        debugMenu->addAction(cpuBrowseAct);\r
@@ -1489,6 +1513,14 @@ void MainWin::ShowNewFunctionBreakpointWin(void)
 }\r
 \r
 \r
+// \r
+void MainWin::ShowCartFilesListWin(void)\r
+{\r
+       CartFilesListWin->show();\r
+       CartFilesListWin->RefreshContents();\r
+}\r
+\r
+\r
 // Step Into trace\r
 void MainWin::DebuggerTraceStepInto(void)\r
 {\r
@@ -2023,6 +2055,13 @@ void MainWin::ReadUISettings(void)
                size = settings.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();\r
                CallStackBrowseWin->resize(size);\r
 \r
+               // Cartdridge directory and files\r
+               pos = settings.value("CartFilesListWinPos", QPoint(200, 200)).toPoint();\r
+               CartFilesListWin->move(pos);\r
+               settings.value("CartFilesListWinIsVisible", false).toBool() ? ShowCartFilesListWin() : void();\r
+               size = settings.value("CartFilesListWinSize", QSize(400, 400)).toSize();\r
+               CartFilesListWin->resize(size);\r
+\r
                // Breakpoints UI information\r
                pos = settings.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();\r
                BreakpointsWin->move(pos);\r
@@ -2242,6 +2281,10 @@ void MainWin::WriteUISettings(void)
                settings.setValue("NewFunctionBreakpointWinPos", NewFunctionBreakpointWin->pos());\r
                settings.setValue("NewFunctionBreakpointWinIsVisible", NewFunctionBreakpointWin->isVisible());\r
                settings.setValue("NewFunctionBreakpointWinSize", NewFunctionBreakpointWin->size());\r
+               settings.setValue("CartFilesListWinPos", CartFilesListWin->pos());\r
+               settings.setValue("CartFilesListWinIsVisible", CartFilesListWin->isVisible());\r
+               settings.setValue("CartFilesListWinSize", CartFilesListWin->size());\r
+\r
                for (i = 0; i < vjs.nbrmemory1browserwindow; i++)\r
                {\r
                        sprintf(mem1Name, "mem1BrowseWinPos[%i]", (unsigned int)i);\r
@@ -2270,6 +2313,13 @@ void MainWin::AlpineRefreshWindows(void)
 }\r
 \r
 \r
+// Reset soft view windows\r
+void MainWin::ViewResetWindows(void)\r
+{\r
+       CartFilesListWin->Reset();\r
+}\r
+\r
+\r
 // Reset soft debugger windows\r
 void MainWin::DebuggerResetWindows(void)\r
 {\r
@@ -2279,12 +2329,19 @@ void MainWin::DebuggerResetWindows(void)
                allWatchBrowseWin->Reset();\r
                heapallocatorBrowseWin->Reset();\r
                BreakpointsWin->Reset();\r
-\r
                //ResetAlpineWindows();\r
+               ViewResetWindows();\r
        }\r
 }\r
 \r
 \r
+// Refresh view windows\r
+void MainWin::ViewRefreshWindows(void)\r
+{\r
+       CartFilesListWin->RefreshContents();\r
+}\r
+\r
+\r
 // Refresh soft debugger & alpine debug windows\r
 void MainWin::DebuggerRefreshWindows(void)\r
 {\r
@@ -2307,6 +2364,7 @@ void MainWin::DebuggerRefreshWindows(void)
                }\r
 \r
                AlpineRefreshWindows();\r
+               ViewRefreshWindows();\r
        }\r
 }\r
 \r
index a7d36af..4d07906 100644 (file)
@@ -47,6 +47,7 @@ class BreakpointsWindow;
 class NewFnctBreakpointWindow;\r
 class ExceptionVectorTableBrowserWindow;\r
 class FilesrcListWindow;\r
+class CartFilesListWindow;\r
 \r
 \r
 // \r
@@ -61,8 +62,10 @@ class MainWin: public QMainWindow
                void LoadFile(QString);\r
                void SyncUI(void);\r
                void DebuggerRefreshWindows(void);\r
-               void DebuggerResetWindows(void);\r
+               void ViewRefreshWindows(void);\r
                void AlpineRefreshWindows(void);\r
+               void DebuggerResetWindows(void);\r
+               void ViewResetWindows(void);\r
 \r
        protected:\r
                void closeEvent(QCloseEvent *);\r
@@ -105,8 +108,11 @@ class MainWin: public QMainWindow
                void ShowBreakpointsWin(void);\r
                void DeleteAllBreakpoints(void);\r
                void DisableAllBreakpoints(void);\r
-               //void ShowVideoOutputWin(void);\r
-               //void ShowDasmWin(void);\r
+#if 0\r
+               void ShowVideoOutputWin(void);\r
+               void ShowDasmWin(void);\r
+#endif\r
+               void ShowCartFilesListWin(void);\r
                // Alpine\r
                void ShowMemoryBrowserWin(void);\r
                void ShowStackBrowserWin(void);\r
@@ -155,6 +161,7 @@ class MainWin: public QMainWindow
                FilesrcListWindow *FilesrcListWin;\r
                BreakpointsWindow *BreakpointsWin;\r
                NewFnctBreakpointWindow *NewFunctionBreakpointWin;\r
+               CartFilesListWindow *CartFilesListWin;\r
                QTimer *timer;\r
                bool running;\r
                int zoomLevel;\r
@@ -187,6 +194,7 @@ class MainWin: public QMainWindow
                QMenu *fileMenu;\r
                QMenu *helpMenu;\r
                QMenu *debugMenu, *debugWindowsMenu, *debugWindowsBrowsesMenu, *debugWindowsWatchMenu, *debugWindowOutputMenu, *debugWindowExceptionMenu, *debugWindowsMemoryMenu, *debugNewBreakpointMenu;\r
+               QMenu *viewMenu, *viewCartMenu;\r
                QToolBar * toolbar;\r
                QToolBar * debugbar;\r
                QToolBar * debuggerbar;\r
@@ -237,6 +245,7 @@ class MainWin: public QMainWindow
                QAction *deleteAllBreakpointsAct;\r
                QAction *disableAllBreakpointsAct;\r
                QAction *exceptionVectorTableBrowseAct;\r
+               QAction *CartFilesListAct;\r
 \r
                QIcon powerGreen;\r
                QIcon powerRed;\r
index 788be89..d7e70de 100644 (file)
@@ -126,6 +126,7 @@ HEADERS = \
        src/debugger/callstackbrowser.h \\r
        src/debugger/exceptionvectortablebrowser.h \\r
        src/debugger/NewFnctBreakpointWin.h \\r
+       src/debugger/CartFilesListWin.h \\r
        src/log.h \\r
        src/unzip.h \\r
        src/crc32.h \\r
@@ -179,6 +180,7 @@ SOURCES = \
        src/debugger/exceptionvectortablebrowser.cpp \\r
        src/debugger/callstackbrowser.cpp \\r
        src/debugger/NewFnctBreakpointWin.cpp \\r
+       src/debugger/CartFilesListWin.cpp \\r
        src/log.cpp \\r
        src/unzip.cpp \\r
        src/crc32.cpp \\r