Rename simulator -> emulator

This commit is contained in:
Thomas Edvalson
2014-05-25 23:19:21 -04:00
parent c6cb313ca7
commit fc785702a6
52 changed files with 516 additions and 1475 deletions
+1 -2
View File
@@ -4,8 +4,7 @@ build/
lib/
*.bin
include/cpp3ds/Simulator/simulator-res.h
src/sim3ds/Simulator/simulator-res.cpp
include/cpp3ds/Emulator/ui-emulator.h
# Eclipse
*.pydevproject
+8 -8
View File
@@ -39,12 +39,12 @@ endif()
# Fetch all source files
FILE(GLOB_RECURSE SRC ${SRCROOT}/cpp3ds/*.cpp)
FILE(GLOB_RECURSE SRC_SIM ${SRCROOT}/sim3ds/*.cpp)
FILE(GLOB_RECURSE SRC_EMU ${SRCROOT}/emu3ds/*.cpp)
set(SRC_ARM ${SRC})
set(SRC_TEST ${SRC})
# Remove duplicate files for simulator
foreach(test1 ${SRC_SIM})
# Remove duplicate files for emulator
foreach(test1 ${SRC_EMU})
get_filename_component(filename1 ${test1} NAME)
foreach(test2 ${SRC})
get_filename_component(filename2 ${test2} NAME)
@@ -53,9 +53,9 @@ foreach(test1 ${SRC_SIM})
endif()
endforeach(test2)
endforeach(test1)
list(APPEND SRC_SIM ${SRC})
list(REMOVE_ITEM SRC_SIM ${SRCROOT}/cpp3ds/syscalls.cpp)
list(REMOVE_ITEM SRC_SIM ${SRCROOT}/cpp3ds/cpp3ds.cpp)
list(APPEND SRC_EMU ${SRC})
list(REMOVE_ITEM SRC_EMU ${SRCROOT}/cpp3ds/syscalls.cpp)
list(REMOVE_ITEM SRC_EMU ${SRCROOT}/cpp3ds/cpp3ds.cpp)
list(REMOVE_ITEM SRC_TEST ${SRCROOT}/cpp3ds/cpp3ds.cpp)
#source_group("" FILES ${SRC})
@@ -85,7 +85,7 @@ set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib")
set(CPP3DS_ARM_FLAGS "-Wall -pedantic -O3 -march=armv6 -fdata-sections -fno-rtti -fno-exceptions")
set(CPP3DS_TEST_FLAGS "-g -Wall -pedantic -O0 -fno-rtti -fno-exceptions")
set(CPP3DS_SIM_FLAGS "-g -Wall -pedantic -O0")
set(CPP3DS_EMU_FLAGS "-g -Wall -pedantic -O0")
if(CPP3DS_BUILD_EXAMPLES)
@@ -93,5 +93,5 @@ if(CPP3DS_BUILD_EXAMPLES)
endif()
add_subdirectory(cmake/arm)
add_subdirectory(cmake/sim)
add_subdirectory(cmake/emu)
add_subdirectory(cmake/test)
+2 -2
View File
@@ -16,10 +16,10 @@ Requirements
- GCC 4.8 (arm-none-eabi)
- [Universal Tween Engine port](https://github.com/cpp3ds/universal-tween-engine-cpp)
For simulator:
For emulator:
- [SFML 2.1](http://www.sfml-dev.org/index.php)
- [gtkmm 3](http://www.gtkmm.org/)
- [Qt 5](https://qt-project.org/)
For unit tests:
+38
View File
@@ -0,0 +1,38 @@
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(ui_header ${CMAKE_CURRENT_SOURCE_DIR}/../../include/cpp3ds/Emulator/ui_emulator.h)
add_custom_command(
OUTPUT ${ui_header}
COMMAND uic ${CMAKE_CURRENT_SOURCE_DIR}/../../res/emu/emulator.ui -o ${ui_header}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../../res/emu/emulator.ui
COMMENT "Generating ui_emulator.h"
)
qt5_wrap_cpp(tst_hdr_moc ${CMAKE_CURRENT_SOURCE_DIR}/../../include/cpp3ds/Emulator/Emulator.hpp)
#qt5_wrap_ui(tst_form_hdr ${CMAKE_CURRENT_SOURCE_DIR}/../../res/emu/emulator.ui)
qt5_add_resources(RESOURCE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/../../res/emu/emulator.qrc)
#include_directories( ${GTKMM_INCLUDE_DIRS} )
#link_directories( ${GTKMM_LIBRARY_DIRS} )
add_library(cpp3ds-emu STATIC
${SRC_EMU}
${tst_hdr_moc}
${tst_form_hdr}
${RESOURCE_HEADER}
)
set_target_properties(cpp3ds-emu PROPERTIES COMPILE_DEFINITIONS "EMULATION")
set_target_properties(cpp3ds-emu PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${CPP3DS_EMU_FLAGS}")
#set_target_properties(cpp3ds-emu PROPERTIES LINK_FLAGS "${CMAKE_CXX_FLAGS} ${CPP3DS_EMU_FLAGS}")
add_custom_target(ui ALL DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/../../include/cpp3ds/Emulator/ui_emulator.h
)
add_dependencies(cpp3ds-emu ui)
qt5_use_modules(cpp3ds-emu Core Gui Widgets)
#target_link_libraries(cpp3ds-emu ${GTKMM_LIBRARIES})
-58
View File
@@ -1,58 +0,0 @@
# Used for GResource.
#
# resource_dir: Directory where the .gresource.xml is located.
# resource_file: Filename of the .gresource.xml file (just the filename, not the complete path).
# source_output_dir: Directory where the C output file is written.
# header_output_dir: Directory where the H output file is written.
# output_source: This variable will be set with the complete path of the output C file.
# output_header: This variable will be set with the complete path of the output H file.
function (gresource resource_dir resource_file source_output_dir header_output_dir output_source output_header)
_pkgconfig_invoke("glib-2.0" GLIB2 PREFIX
"" "--variable=prefix")
find_program(GLIB_COMPILE_RESOURCES
NAMES glib-compile-resources
HINTS ${GLIB2_PREFIX})
if (NOT GLIB_COMPILE_RESOURCES)
message(FATAL "Could not find glib-compile-resources")
endif()
# Get the output file path
get_filename_component (resource_name ${resource_file} NAME_WE)
set (output_c "${source_output_dir}/${resource_name}-res.cpp")
set (output_h "${header_output_dir}/${resource_name}-res.h")
set (${output_source} ${output_c} PARENT_SCOPE)
set (${output_header} ${output_h} PARENT_SCOPE)
# Get the dependencies of the gresource
execute_process (
OUTPUT_VARIABLE _files
WORKING_DIRECTORY ${resource_dir}
COMMAND ${GLIB_COMPILE_RESOURCES} --generate-dependencies ${resource_file}
)
string (REPLACE "\n" ";" files ${_files})
set (depends "")
foreach (cur_file ${files})
list (APPEND depends "${resource_dir}/${cur_file}")
endforeach ()
# Command to compile the resources
add_custom_command (
OUTPUT ${output_c}
DEPENDS "${resource_dir}/${resource_file}" ${depends}
WORKING_DIRECTORY ${resource_dir}
COMMAND ${GLIB_COMPILE_RESOURCES} --generate-source --target=${output_c} ${resource_file}
)
# Command to compile the resources
add_custom_command (
OUTPUT ${output_h}
DEPENDS "${resource_dir}/${resource_file}" ${depends}
WORKING_DIRECTORY ${resource_dir}
COMMAND ${GLIB_COMPILE_RESOURCES} --generate-header --target=${output_h} ${resource_file}
)
endfunction ()
-37
View File
@@ -1,37 +0,0 @@
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(ui_header ${CMAKE_CURRENT_SOURCE_DIR}/../../include/cpp3ds/Simulator/ui_emulator.h)
add_custom_command(
OUTPUT ${ui_header}
COMMAND uic ${CMAKE_CURRENT_SOURCE_DIR}/../../res/sim/emulator.ui -o ${ui_header}
COMMENT "Generating ui_emulator.h"
)
qt5_wrap_cpp(tst_hdr_moc ${CMAKE_CURRENT_SOURCE_DIR}/../../include/cpp3ds/Simulator/Simulator.hpp)
#qt5_wrap_ui(tst_form_hdr ${CMAKE_CURRENT_SOURCE_DIR}/../../res/sim/emulator.ui)
qt5_add_resources(RESOURCE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/../../res/sim/emulator.qrc)
#include_directories( ${GTKMM_INCLUDE_DIRS} )
#link_directories( ${GTKMM_LIBRARY_DIRS} )
add_library(cpp3ds-sim STATIC
${SRC_SIM}
${tst_hdr_moc}
${tst_form_hdr}
${RESOURCE_HEADER}
)
set_target_properties(cpp3ds-sim PROPERTIES COMPILE_DEFINITIONS "SIMULATION")
set_target_properties(cpp3ds-sim PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${CPP3DS_SIM_FLAGS}")
#set_target_properties(cpp3ds-sim PROPERTIES LINK_FLAGS "${CMAKE_CXX_FLAGS} ${CPP3DS_SIM_FLAGS}")
add_custom_target(ui ALL DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/../../include/cpp3ds/Simulator/ui_emulator.h
)
add_dependencies(cpp3ds-sim ui)
qt5_use_modules(cpp3ds-sim Core Gui Widgets)
#target_link_libraries(cpp3ds-sim ${GTKMM_LIBRARIES})
+3 -3
View File
@@ -37,8 +37,8 @@ set(SOURCE_FILES
add_executable(${PROJECT} ${SOURCE_FILES})
qt5_use_modules(${PROJECT} Core Gui Widgets)
target_link_libraries(${PROJECT} cpp3ds-sim tween-test sfml-graphics sfml-window sfml-system)
target_link_libraries(${PROJECT} cpp3ds-emu tween-test sfml-graphics sfml-window sfml-system)
set_target_properties(${PROJECT} PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -O3")
set_target_properties(${PROJECT} PROPERTIES COMPILE_DEFINITIONS "SIMULATION")
#set_target_properties(${PROJECT} PROPERTIES LINK_FLAGS "${CMAKE_CXX_FLAGS} ${CPP3DS_SIM_FLAGS}")
set_target_properties(${PROJECT} PROPERTIES COMPILE_DEFINITIONS "EMULATION")
#set_target_properties(${PROJECT} PROPERTIES LINK_FLAGS "${CMAKE_CXX_FLAGS} ${CPP3DS_EMU_FLAGS}")
+15
View File
@@ -0,0 +1,15 @@
#ifndef CPP3DS_EMULATOR_HPP
#define CPP3DS_EMULATOR_HPP
#include <cpp3ds/Config.hpp>
#include <cpp3ds/Emulator/Emulator.hpp>
#endif
////////////////////////////////////////////////////////////
/// \defgroup system Emulator module
///
/// Module for emulator case base.
///
////////////////////////////////////////////////////////////
+69
View File
@@ -0,0 +1,69 @@
#ifndef CPP3DS_EMULATOR_EMU_HPP
#define CPP3DS_EMULATOR_EMU_HPP
#include <QtWidgets>
#include <SFML/Graphics.hpp>
#include <cpp3ds/Emulator/ui_emulator.h>
#include <cpp3ds/Emulator/SFMLWidget.hpp>
#define EMU_OUTLINE_THICKNESS 1
extern void cpp3ds_main();
namespace cpp3ds {
enum EmulatorState {
EMU_PLAYING,
EMU_PAUSED,
EMU_STOPPED
};
class Emulator : public QMainWindow, private Ui::MainWindow{
Q_OBJECT
private:
QSlider* slider3D;
QWidget* spacer;
sf::Thread* thread;
sf::Mutex mutex;
sf::Texture pausedFrameTexture;
sf::Sprite pausedFrame;
EmulatorState state = EMU_STOPPED;
bool initialized = false;
void runGame();
void checkThreadState();
void saveScreenshot();
void drawPausedFrame();
private slots:
void on_pushButton_clicked();
void on_toolBar_orientationChanged(Qt::Orientation orientation);
public:
QSFMLCanvas *screen;
bool isThreadRunning = false;
Emulator(QWidget *parent = 0);
~Emulator();
void run();
void play();
void pause();
void stop();
float get_slider3d();
void updatePausedFrame();
EmulatorState getState(){ return state; }
};
// Emulator global to be accessed in-game
extern Emulator* _emulator;
}
#endif
@@ -1,6 +1,7 @@
#ifndef CPP3DS_SFMLWIDGET_HPP
#define CPP3DS_SFMLWIDGET_HPP
#include <queue>
#include <SFML/Graphics.hpp>
#include <QWidget>
#include <QTimer>
@@ -12,9 +13,10 @@ public :
sf::RenderTexture topLeftScreen, topRightScreen, bottomScreen;
QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime = 0);
virtual ~QSFMLCanvas();
bool pollMouseEvent(sf::Event& event);
private :
// virtual void OnInit();
@@ -24,11 +26,16 @@ private :
virtual QPaintEngine* paintEngine() const;
virtual void showEvent(QShowEvent*);
virtual void paintEvent(QPaintEvent*);
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual void mouseMoveEvent(QMouseEvent* event);
void pushMouseEvent(const sf::Event& event);
QTimer myTimer;
bool myInitialized;
std::queue<sf::Event> m_events;
};
#endif
-15
View File
@@ -1,15 +0,0 @@
#ifndef CPP3DS_SIMULATOR_HPP
#define CPP3DS_SIMULATOR_HPP
#include <cpp3ds/Config.hpp>
#include <cpp3ds/Simulator/Simulator.hpp>
#endif
////////////////////////////////////////////////////////////
/// \defgroup system Simulator module
///
/// Module for simulator case base.
///
////////////////////////////////////////////////////////////
-86
View File
@@ -1,86 +0,0 @@
#ifndef CPP3DS_SIMULATOR_SIM_HPP
#define CPP3DS_SIMULATOR_SIM_HPP
//#include <gtkmm.h>
#include <QtWidgets>
#include <SFML/Graphics.hpp>
#include <cpp3ds/Simulator/ui_emulator.h>
#include <cpp3ds/Simulator/SFMLWidget.hpp>
#define SIM_OUTLINE_THICKNESS 1
extern void cpp3ds_main();
namespace cpp3ds {
enum SimulatorState {
SIM_PLAYING,
SIM_PAUSED,
SIM_STOPPED
};
class Simulator : public QMainWindow, private Ui::MainWindow{
Q_OBJECT
private:
// Glib::RefPtr<Gtk::Application> application;
// Gtk::Window *window;
// Gtk::Image *imageLogo;
// Gtk::MenuItem *menuAbout;
// Gtk::AboutDialog *aboutDialog;
// Gtk::FileChooserDialog *saveDialog;
// Gtk::Box *boxSFML;
// Gtk::ToolButton *buttonScreenshot, *buttonPlayPause, *buttonStop, *buttonTest;
// Gtk::ToggleToolButton *buttonToggle3D;
// Gtk::Scale *scale3D;
sf::Thread* thread;
sf::Mutex mutex;
sf::Texture pausedFrameTexture;
sf::Sprite pausedFrame;
SimulatorState state = SIM_STOPPED;
bool initialized = false;
void runGame();
void checkThreadState();
void saveScreenshot();
void drawPausedFrame();
// void on_sfml_size_allocate(Gtk::Allocation& allocation);
// bool on_my_delete_event(GdkEventAny* event);
// void on_about_response(int response_id);
// void on_playpause_clicked();
// void on_stop_clicked();
// void on_toggle3d_clicked();
// void on_about_clicked();
// void on_test_clicked();
private slots:
void on_pushButton_clicked();
public:
QSFMLCanvas *screen;
bool isThreadRunning = false;
Simulator(QWidget *parent = 0);
~Simulator();
void run();
void play();
void pause();
void stop();
float get_slider3d();
void updatePausedFrame();
SimulatorState getState(){ return state; }
};
// Simulator global to be accessed in-game
extern Simulator* _simulator;
}
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
#ifdef SIMULATION
#include <cpp3ds/System/utils_sim.hpp>
#ifdef EMULATION
#include <cpp3ds/System/utils_emu.hpp>
#endif
#ifndef CPP3DS_UTILS_HPP
+2 -2
View File
@@ -1,5 +1,5 @@
#ifdef SIMULATION
#include <cpp3ds/Window/BottomScreen_sim.hpp>
#ifdef EMULATION
#include <cpp3ds/Window/BottomScreen_emu.hpp>
#endif
#ifndef CPP3DS_BOTTOMSCREEN_HPP
@@ -1,11 +1,11 @@
#ifndef CPP3DS_BOTTOMSCREEN_HPP
#define CPP3DS_BOTTOMSCREEN_HPP
#include <cpp3ds/Simulator/Simulator.hpp>
#include <cpp3ds/Emulator/Emulator.hpp>
#include <cpp3ds/Window/Screen.hpp>
#define BOTTOM_X ((400-320)/2)
#define BOTTOM_Y (240 + SIM_OUTLINE_THICKNESS*2)
#define BOTTOM_Y (240 + EMU_OUTLINE_THICKNESS*2)
#define BOTTOM_WIDTH 320
#define BOTTOM_HEIGHT 240
+1 -1
View File
@@ -1,4 +1,4 @@
#ifdef SIMULATION
#ifdef EMULATION
#include <cpp3ds/Window/Input_sim_.hpp>
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
#ifdef SIMULATION
#include <cpp3ds/Window/Keyboard_sim.hpp>
#ifdef EMULATION
#include <cpp3ds/Window/Keyboard_emu.hpp>
#endif
#ifndef CPP3DS_KEYBOARD_HPP
+2 -2
View File
@@ -1,5 +1,5 @@
#ifdef SIMULATION
#include <cpp3ds/Window/Screen_sim.hpp>
#ifdef EMULATION
#include <cpp3ds/Window/Screen_emu.hpp>
#endif
#ifndef CPP3DS_SCREEN_HPP

Some files were not shown because too many files have changed in this diff Show More