Merge pull request #2 from alanswx/main

Added File Open
This commit is contained in:
Jim Gregory
2021-06-29 07:27:52 +01:00
committed by GitHub
16 changed files with 6143 additions and 13 deletions

0
build.sh Normal file → Executable file
View File

View File

@@ -490,4 +490,4 @@ void main()
hsync_last = hsync;
vsync_last = vsync;
}
}
}

View File

@@ -57,8 +57,8 @@ V_SRC = \
$(RTL)/system.v \
$(RTL)/dpram.v \
$(RTL)/spram.v \
$(RTL)/JTFRAME/jtframe_vtimer.v
$(RTL)/JTFRAME/jtframe_cen24.v
$(RTL)/JTFRAME/jtframe_vtimer.v \
$(RTL)/JTFRAME/jtframe_cen24.v \
../rtl/tv80/tv80_core.v \
../rtl/tv80/tv80_alu.v \
../rtl/tv80/tv80_mcode.v \
@@ -69,7 +69,7 @@ V_SRC = \
C_SRC = \
sim_main.cpp \
sim/sim_bus.cpp sim/sim_clock.cpp sim/sim_console.cpp sim/sim_video.cpp sim/sim_input.cpp \
sim/imgui/imgui_impl_sdl.cpp sim/imgui/imgui_impl_opengl2.cpp sim/imgui/imgui_draw.cpp sim/imgui/imgui_widgets.cpp sim/imgui/imgui_tables.cpp sim/imgui/imgui.cpp
sim/imgui/imgui_impl_sdl.cpp sim/imgui/imgui_impl_opengl2.cpp sim/imgui/imgui_draw.cpp sim/imgui/imgui_widgets.cpp sim/imgui/imgui_tables.cpp sim/imgui/imgui.cpp sim/imgui/ImGuiFileDialog.cpp
VOUT = obj_dir/Vtop.cpp
all: $(EXE)

View File

@@ -15,12 +15,10 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A2A39241-8334-40A2-8D63-53A6CAEAEA05}.Debug|x64.ActiveCfg = Debug|x64
{A2A39241-8334-40A2-8D63-53A6CAEAEA05}.Debug|x64.Build.0 = Debug|x64
{A2A39241-8334-40A2-8D63-53A6CAEAEA05}.Debug|x86.ActiveCfg = Debug|Win32
{A2A39241-8334-40A2-8D63-53A6CAEAEA05}.Debug|x86.Build.0 = Debug|Win32
{A2A39241-8334-40A2-8D63-53A6CAEAEA05}.Debug|x86.ActiveCfg = Debug|x64
{A2A39241-8334-40A2-8D63-53A6CAEAEA05}.Release|x64.ActiveCfg = Release|x64
{A2A39241-8334-40A2-8D63-53A6CAEAEA05}.Release|x64.Build.0 = Release|x64
{A2A39241-8334-40A2-8D63-53A6CAEAEA05}.Release|x86.ActiveCfg = Release|Win32
{A2A39241-8334-40A2-8D63-53A6CAEAEA05}.Release|x86.Build.0 = Release|Win32
{A2A39241-8334-40A2-8D63-53A6CAEAEA05}.Release|x86.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -60,6 +60,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="sim\imgui\imgui.cpp" />
<ClCompile Include="sim\imgui\ImGuiFileDialog.cpp" />
<ClCompile Include="sim\imgui\imgui_draw.cpp" />
<ClCompile Include="sim\imgui\imgui_impl_dx11.cpp" />
<ClCompile Include="sim\imgui\imgui_impl_win32.cpp" />

View File

@@ -22,7 +22,7 @@
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="obj_dir\Vtop__Dpi.cpp">
<Filter>Source Files</Filter>
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="obj_dir\Vtop__Syms.cpp">
<Filter>Source Files</Filter>
@@ -69,6 +69,9 @@
<ClCompile Include="sim\sim_clock.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sim\imgui\ImGuiFileDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="sim\imgui\imconfig.h">

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,70 @@
#pragma once
// uncomment and modify defines under for customize ImGuiFileDialog
//#define MAX_FILE_DIALOG_NAME_BUFFER 1024
//#define MAX_PATH_BUFFER_SIZE 1024
//#define USE_EXPLORATION_BY_KEYS
// this mapping by default is for GLFW but you can use another
//#include <GLFW/glfw3.h>
// Up key for explore to the top
//#define IGFD_KEY_UP GLFW_KEY_UP
// Down key for explore to the bottom
//#define IGFD_KEY_DOWN GLFW_KEY_DOWN
// Enter key for open directory
//#define IGFD_KEY_ENTER GLFW_KEY_ENTER
// BackSpace for comming back to the last directory
//#define IGFD_KEY_BACKSPACE GLFW_KEY_BACKSPACE
// widget
// filter combobox width
//#define FILTER_COMBO_WIDTH 120.0f
// button widget use for compose path
//#define IMGUI_PATH_BUTTON ImGui::Button
// standard button
//#define IMGUI_BUTTON ImGui::Button
// locales string
//#define createDirButtonString "+"
//#define okButtonString " OK"
//#define cancelButtonString " Cancel"
//#define resetButtonString "R"
//#define drivesButtonString "Drives"
//#define searchString "Search"
//#define dirEntryString "[DIR] "
//#define linkEntryString "[LINK] "
//#define fileEntryString "[FILE] "
//#define fileNameString "File Name : "
//#define dirNameString "Directory Path :"
//#define buttonResetSearchString "Reset search"
//#define buttonDriveString "Drives"
//#define buttonResetPathString "Reset to current directory"
//#define buttonCreateDirString "Create Directory"
//#define OverWriteDialogTitleString "The file Already Exist !"
//#define OverWriteDialogMessageString "Would you like to OverWrite it ?"
//#define OverWriteDialogConfirmButtonString "Confirm"
//#define OverWriteDialogCancelButtonString "Cancel"
// DateTimeFormat
// see strftime functionin <ctime> for customize
// "%Y/%m/%d %H:%M" give 2021:01:22 11:47
// "%Y/%m/%d %i:%M%p" give 2021:01:22 11:45PM
//#define DateTimeFormat "%Y/%m/%d %i:%M%p"
// theses icons will appear in table headers
//#define USE_CUSTOM_SORTING_ICON
//#define tableHeaderAscendingIcon "A|"
//#define tableHeaderDescendingIcon "D|"
//#define tableHeaderFileNameString " File name"
//#define tableHeaderFileTypeString " Type"
//#define tableHeaderFileSizeString " Size"
//#define tableHeaderFileDateTimeString " Date"
//#define USE_BOOKMARK
//#define bookmarkPaneWith 150.0f
//#define IMGUI_TOGGLE_BUTTON ToggleButton
//#define bookmarksButtonString "Bookmark"
//#define bookmarksButtonHelpString "Bookmark"
//#define addBookmarkButtonString "+"
//#define removeBookmarkButtonString "-"

View File

@@ -0,0 +1,129 @@
2018-05-08 Toni Rönkkö
* Version 1.23.2: fixes bad scandir prototype.
2017-08-27 Toni Rönkkö
* Version 1.23: support readdir_r and scandir functions.
2017-07-18 Toni Rönkkö
* Created release branches v1.22 and v1.21 to Git. Published version
1.22 at softagalleria.net.
2016-09-11 Toni Rönkkö
* Version 1.22: added support for CMake. Thanks to Paul Fultz II.
2014-09-25 Toni Rönkkö
* Version 1.21: compiles correctly under Open Watcom. Thanks to
Virgil Banowetz for a patch!
2014-04-07 Toni Rönkkö
* Version 1.20.1: the zip file from the previous version did not open
correctly with Microsoft's compressed folders. Thanks to Alexandre
for info!
2014-03-17 Toni Ronkko
* Version 1.20: dirent.h compiles correctly in 64-bit architecture.
Thanks to Aaron Simmons!
2014-03-03 Toni Ronkko
* Version 1.13.2: define DT_LNK for compatibility with Unix
programs. Thanks to Joel Bruick for suggestion!
2013-01-27 Toni Ronkko
* Version 1.13.1: patch from Edward Berner fixes set_errno() on
Windows NT 4.0.
* Revised wcstombs() and mbstowcs() wrappers to make sure that they do
not write past their target string.
* PATH_MAX from windows.h includes zero terminator so there is no
need to add one extra byte to variables and structures.
2012-12-12 Toni Ronkko
* Version 1.13: use the traditional 8+3 file naming scheme if a file
name cannot be represented in the default ANSI code page. Now
compiles again with MSVC 6.0. Thanks to Konstantin Khomoutov for
testing.
2012-10-01 Toni Ronkko
* Version 1.12.1: renamed wide-character DIR structure _wDIR to
_WDIR (with capital W) in order to maintain compatibility with MingW.
2012-09-30 Toni Ronkko
* Version 1.12: define PATH_MAX and NAME_MAX. Added wide-character
variants _wDIR, _wdirent, _wopendir(), _wreaddir(), _wclosedir() and
_wrewinddir(). Thanks to Edgar Buerkle and Jan Nijtmans for ideas
and code.
* Now avoiding windows.h. This allows dirent.h to be integrated
more easily into programs using winsock. Thanks to Fernando
Azaldegui.
2011-03-15 Toni Ronkko
* Version 1.11: defined FILE_ATTRIBUTE_DEVICE for MSVC 6.0.
2010-08-11 Toni Ronkko
* Version 1.10: added d_type and d_namlen fields to dirent structure.
The former is especially useful for determining whether directory
entry represents a file or a directory. For more information, see
http://www.delorie.com/gnu/docs/glibc/libc_270.html
* Improved conformance to the standards. For example, errno is now
set properly on failure and assert() is never used. Thanks to Peter
Brockam for suggestions.
* Fixed a bug in rewinddir(): when using relative directory names,
change of working directory no longer causes rewinddir() to fail.
2009-12-15 John Cunningham
* Version 1.9: added rewinddir member function
2008-01-18 Toni Ronkko
* Version 1.8: Using FindFirstFileA and WIN32_FIND_DATAA to avoid
converting string between multi-byte and unicode representations.
This makes the code simpler and also allows the code to be compiled
under MingW. Thanks to Azriel Fasten for the suggestion.
2007-03-04 Toni Ronkko
* Bug fix: due to the strncpy_s() function this file only compiled in
Visual Studio 2005. Using the new string functions only when the
compiler version allows.
2006-11-02 Toni Ronkko
* Major update: removed support for Watcom C, MS-DOS and Turbo C to
simplify the file, updated the code to compile cleanly on Visual
Studio 2005 with both unicode and multi-byte character strings,
removed rewinddir() as it had a bug.
2006-08-20 Toni Ronkko
* Removed all remarks about MSVC 1.0, which is antiqued now.
Simplified comments by removing SGML tags.
2002-05-14 Toni Ronkko
* Embedded the function definitions directly to the header so that no
source modules need to be included in the Visual Studio project.
Removed all the dependencies to other projects so that this header
file can be used independently.
1998-05-28 Toni Ronkko
* First version.

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 1998-2019 Toni Ronkko
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,96 @@
# Dirent
Dirent is a C/C++ programming interface that allows programmers to retrieve
information about files and directories under Linux/UNIX. This project
provides Linux compatible Dirent interface for Microsoft Windows.
# Installation
Download the latest Dirent installation package from
[GitHub](https://github.com/tronkko/dirent/releases) and
unpack the installation file with 7-zip, for example. The installation
package contains dirent.h file as well as a few example programs and
tests.
## Install Dirent for All Programs
To make dirent.h available for all C/C++ programs, simply copy the
``include/dirent.h`` file to the system include directory. System include
directory contains header files such as assert.h and windows.h. In Visual
Studio 2008, for example, the system include may be found at
``C:\Program Files\Microsoft Visual Studio 9.0\VC\include``.
Everything you need is included in the single dirent.h file, and you can
start using Dirent immediately -- there is no need to add files to your
Visual Studio project.
## Embed Dirent into Your Own Project
If you wish to distribute dirent.h alongside with your own source code, then
copy ``include/dirent.h`` file to a new sub-directory within your project and
add that directory to include path on Windows while omitting the directory
under Linux/UNIX. This allows your project to be compiled against native
dirent.h on Linux/UNIX while substituting the functionality on Microsoft
Windows.
## Examples
The installation package contains four example programs:
Program | Purpose
-------- | -----------------------------------------------------------------
ls | List files in a directory, e.g. ls "c:\Program Files"
find | Find files in subdirectories, e.g. find "c:\Program Files\CMake"
updatedb | Build database of files in a drive, e.g. updatedb c:\
locate | Locate a file from database, e.g. locate notepad.exe
To build the example programs, first install [CMake](https://cmake.org/).
Then, with CMake installed, open command prompt and create a temporary
directory ``c:\temp\dirent`` for the build files as
```
c:\
mkdir temp
mkdir temp\dirent
cd temp\dirent
```
Generate build files as
```
cmake d:\dirent
```
where ``d:\dirent`` is the root directory of the Dirent package (containing
this README.md and LICENSE file).
Once CMake is finished, open Visual Studio, load the generated dirent.sln file
from the build directory and build the solution. Once the build completes, run
the example programs from the command prompt as
```
cd Debug
ls .
find .
updatedb c:\
locate cmd.exe
```
# Copying
Dirent may be freely distributed under the MIT license. See the
[LICENSE](LICENSE) file for details.
# Alternatives to Dirent
I ported Dirent to Microsoft Windows in 1998 when only a few alternatives
were available. However, the situation has changed since then and nowadays
both [Cygwin](http://www.cygwin.com) and [MingW](http://www.mingw.org)
allow you to compile a great number of UNIX programs in Microsoft Windows.
They both provide a full dirent API as well as many other UNIX APIs. MingW
can even be used for commercial applications!

File diff suppressed because it is too large Load Diff

View File

@@ -33,7 +33,10 @@ void SimBus::QueueDownload(std::string file, int index) {
SimBus_DownloadChunk chunk = SimBus_DownloadChunk(file, index);
downloadQueue.push(chunk);
}
void SimBus::QueueDownload(std::string file, int index, bool restart) {
SimBus_DownloadChunk chunk = SimBus_DownloadChunk(file, index, restart);
downloadQueue.push(chunk);
}
bool SimBus::HasQueue() {
return downloadQueue.size() > 0;
}
@@ -50,7 +53,9 @@ void SimBus::BeforeEval()
// If last index differs from this one then reset the addresses
if (currentDownload.index != *ioctl_index) { ioctl_next_addr = -1; }
// if we want to restart the ioctl_addr then reset it
// leave it the same if we want to be able to load two roms sequentially
if (currentDownload.restart) { ioctl_next_addr = -1; }
// Set address and index
*ioctl_addr = ioctl_next_addr;
*ioctl_index = currentDownload.index;
@@ -117,4 +122,4 @@ SimBus::SimBus(DebugConsole c) {
SimBus::~SimBus() {
}
}

View File

@@ -14,6 +14,7 @@ struct SimBus_DownloadChunk {
public:
std::string file;
int index;
bool restart;
SimBus_DownloadChunk() {
file = "";
@@ -21,6 +22,10 @@ public:
}
SimBus_DownloadChunk(std::string file, int index) {
SimBus_DownloadChunk(file, index, false);
}
SimBus_DownloadChunk(std::string file, int index, bool restart) {
this->restart = restart;
this->file = std::string(file);
this->index = index;
}
@@ -41,6 +46,7 @@ public:
void BeforeEval(void);
void AfterEval(void);
void QueueDownload(std::string file, int index);
void QueueDownload(std::string file, int index, bool restart);
bool HasQueue();
SimBus(DebugConsole c);

View File

@@ -18,6 +18,7 @@
#include "sim_clock.h"
#include "../imgui/imgui_memory_editor.h"
#include "../imgui/ImGuiFileDialog.h"
// Debug GUI
// ---------
@@ -104,7 +105,7 @@ int verilate() {
}
// Output pixels on rising edge of pixel clock
if (clk_sys.IsRising() && top->top__DOT__system__DOT__ce_pix) {
if (clk_sys.IsRising() && top->top__DOT__ce_pix ) {
uint32_t colour = 0xFF000000 | top->VGA_B << 16 | top->VGA_G << 8 | top->VGA_R;
video.Clock(top->VGA_HB, top->VGA_VB, top->VGA_HS, top->VGA_VS, colour);
}
@@ -220,6 +221,8 @@ int main(int argc, char** argv, char** env) {
if (ImGui::Button("RESET")) { resetSim(); } ImGui::SameLine();
if (ImGui::Button("START")) { run_enable = 1; } ImGui::SameLine();
if (ImGui::Button("STOP")) { run_enable = 0; } ImGui::SameLine();
if (ImGui::Button("LOAD"))
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".bin", ".");
ImGui::Checkbox("RUN", &run_enable);
ImGui::SliderInt("Batch size", &batchSize, 1, 250000);
@@ -259,6 +262,22 @@ int main(int argc, char** argv, char** env) {
//mem_edit_3.DrawContents(top->top__DOT__system__DOT__colram__DOT__mem, 2048, 0);
//ImGui::End();
// File Dialog to load rom
if (ImGuiFileDialog::Instance()->Display("ChooseFileDlgKey"))
{
// action if OK
if (ImGuiFileDialog::Instance()->IsOk())
{
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
// action
bus.QueueDownload(filePathName, 0, true);
}
// close
ImGuiFileDialog::Instance()->Close();
}
ImGui::Begin("CPU Registers");
ImGui::Spacing();
ImGui::Text("PC 0x%04X", top->top__DOT__system__DOT__T80x__DOT__i_tv80_core__DOT__PC);