Start of major source tree restructuring and cleanup

This commit is contained in:
rdanbrook 2018-01-14 22:54:56 -05:00
parent ff964e0494
commit 9e22cdac54
45 changed files with 125 additions and 138 deletions

View file

@ -2,12 +2,14 @@
# Definitions #
###############
bin_PROGRAMS = nestopia
nestopia_SOURCES = source/unix/main.cpp
EXTRA_DIST = doc
nestopia_CPPFLAGS = \
-I$(top_srcdir)/source \
-I$(top_srcdir)/source/common \
-I$(top_srcdir)/source/gtkui \
-I$(top_srcdir)/source/sdl \
-DDATADIR=\"$(datadir)/nestopia\" \
-DDATAROOTDIR=\"$(datarootdir)\" \
-DNST_PRAGMA_ONCE \
@ -42,25 +44,25 @@ dist_database_DATA = NstDatabase.xml
# freedesktop.org-specific files
desktopdir = $(datarootdir)/applications
dist_desktop_DATA = source/unix/icons/nestopia.desktop
dist_desktop_DATA = icons/nestopia.desktop
icon32dir = $(datarootdir)/icons/hicolor/32x32/apps
dist_icon32_DATA = source/unix/icons/32/nestopia.png
dist_icon32_DATA = icons/32/nestopia.png
icon48dir = $(datarootdir)/icons/hicolor/48x48/apps
dist_icon48_DATA = source/unix/icons/48/nestopia.png
dist_icon48_DATA = icons/48/nestopia.png
icon64dir = $(datarootdir)/icons/hicolor/64x64/apps
dist_icon64_DATA = source/unix/icons/64/nestopia.png
dist_icon64_DATA = icons/64/nestopia.png
icon96dir = $(datarootdir)/icons/hicolor/96x96/apps
dist_icon96_DATA = source/unix/icons/96/nestopia.png
dist_icon96_DATA = icons/96/nestopia.png
icon128dir = $(datarootdir)/icons/hicolor/128x128/apps
dist_icon128_DATA = source/unix/icons/128/nestopia.png
dist_icon128_DATA = icons/128/nestopia.png
iconsvgdir = $(datarootdir)/icons/hicolor/scalable/apps
dist_iconsvg_DATA = source/unix/icons/svg/nestopia.svg source/unix/icons/svg/nespad.svg
dist_iconsvg_DATA = icons/svg/nestopia.svg icons/svg/nespad.svg
# documentation
dist_doc_DATA = AUTHORS ChangeLog README.md
@ -76,7 +78,7 @@ EXTRA_DIST += \
source/core/NstSoundRenderer.inl \
source/nes_ntsc/nes_ntsc.inl
nestopia_SOURCES += \
nestopia_SOURCES = \
source/core/NstTrackerMovie.hpp \
source/core/NstFile.hpp \
source/core/NstAssert.cpp \
@ -689,44 +691,49 @@ nestopia_SOURCES += \
source/nes_ntsc/nes_ntsc_impl.h \
source/nes_ntsc/nes_ntsc_config.h \
source/nes_ntsc/nes_ntsc.h \
source/nes_ntsc/demo_impl.h \
source/unix/input.cpp \
source/unix/ini.cpp \
source/unix/config.h \
source/unix/png.cpp \
source/unix/png.h \
source/unix/config.cpp \
source/unix/cheats.h \
source/unix/cursor.h \
source/unix/audio.cpp \
source/unix/cli.h \
source/unix/audio.h \
source/unix/video.h \
source/unix/cli.cpp \
source/unix/cursor.cpp \
source/unix/ini.h \
source/unix/font.h \
source/unix/video.cpp \
source/unix/main.h \
source/unix/input.h \
source/unix/cheats.cpp
source/nes_ntsc/demo_impl.h
nestopia_SOURCES += \
source/common/cheats.cpp \
source/common/cheats.h \
source/common/cli.cpp \
source/common/cli.h \
source/common/config.cpp \
source/common/config.h \
source/common/video.cpp \
source/common/video.h \
source/common/font.h \
source/common/ini.cpp \
source/common/ini.h \
source/common/png.cpp \
source/common/png.h
nestopia_SOURCES += \
source/sdl/audio.cpp \
source/sdl/audio.h \
source/sdl/input.cpp \
source/sdl/input.h \
source/sdl/cursor.cpp \
source/sdl/cursor.h \
source/sdl/main.cpp \
source/sdl/main.h
if ENABLE_GUI
nestopia_SOURCES += \
source/unix/gtkui/gtkui_config.h \
source/unix/gtkui/gtkui_archive.h \
source/unix/gtkui/gtkui_cheats.cpp \
source/unix/gtkui/gtkui_callbacks.h \
source/unix/gtkui/gtkui_callbacks.cpp \
source/unix/gtkui/gtkui_dialogs.cpp \
source/unix/gtkui/gtkui_cheats.h \
source/unix/gtkui/gtkui_dialogs.h \
source/unix/gtkui/gtkui_archive.cpp \
source/unix/gtkui/gtkui.cpp \
source/unix/gtkui/gtkui.h \
source/unix/gtkui/gtkui_input.cpp \
source/unix/gtkui/gtkui_input.h \
source/unix/gtkui/gtkui_config.cpp
source/gtkui/gtkui_config.h \
source/gtkui/gtkui_archive.h \
source/gtkui/gtkui_cheats.cpp \
source/gtkui/gtkui_callbacks.h \
source/gtkui/gtkui_callbacks.cpp \
source/gtkui/gtkui_dialogs.cpp \
source/gtkui/gtkui_cheats.h \
source/gtkui/gtkui_dialogs.h \
source/gtkui/gtkui_archive.cpp \
source/gtkui/gtkui.cpp \
source/gtkui/gtkui.h \
source/gtkui/gtkui_input.cpp \
source/gtkui/gtkui_input.h \
source/gtkui/gtkui_config.cpp
endif
# install full HTML suite

View file

@ -3,7 +3,7 @@ AC_PREREQ([2.69])
AC_INIT(
[nestopia],
[1.49-WIP])
AC_CONFIG_SRCDIR([source/unix/main.cpp])
AC_CONFIG_SRCDIR([source])
AC_LANG([C++])

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View file

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View file

Before

Width:  |  Height:  |  Size: 319 KiB

After

Width:  |  Height:  |  Size: 319 KiB

View file

@ -1,7 +1,7 @@
/*
* Nestopia UE
*
* Copyright (C) 2012-2016 R. Danbrook
* Copyright (C) 2012-2018 R. Danbrook
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,23 +23,18 @@
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include "main.h"
#include "cheats.h"
extern Emulator emulator;
extern nstpaths_t nstpaths;
void cheats_init() {
void nst_cheats_init(const char *cheatpath) {
// Initialize cheat engine
Cheats cheats(emulator);
Xml xml;
cheats.ClearCodes();
std::ifstream cheatfile(nstpaths.cheatpath, std::ifstream::in|std::ifstream::binary);
std::ifstream cheatfile(cheatpath, std::ifstream::in|std::ifstream::binary);
if (cheatfile.is_open()) {
xml.Read(cheatfile);
@ -54,15 +49,15 @@ void cheats_init() {
if (node.GetAttribute(L"enabled").IsValue(L"1")) {
if (node.GetChild(L"genie")) { // Game Genie
cheats_code_gg_add(node.GetChild(L"genie").GetValue());
nst_cheats_code_gg_add(node.GetChild(L"genie").GetValue());
}
else if (node.GetChild(L"rocky")) { // Pro Action Rocky
cheats_code_par_add(node.GetChild(L"rocky").GetValue());
nst_cheats_code_par_add(node.GetChild(L"rocky").GetValue());
}
else if (node.GetChild(L"address")) { // Raw
cheats_code_raw_add(node);
nst_cheats_code_raw_add(node);
}
//fprintf(stderr, "Cheat: %ls\n", node.GetChild(L"description").GetValue());
@ -74,7 +69,7 @@ void cheats_init() {
}
}
/*void cheats_list() {
/*void nst_cheats_list() {
// List the active cheats
Cheats cheats(emulator);
Cheats::Code code;
@ -89,7 +84,7 @@ void cheats_init() {
}
}*/
void cheats_code_gg_add(const wchar_t *data) {
void nst_cheats_code_gg_add(const wchar_t *data) {
// Add a Game Genie code
Cheats cheats(emulator);
Cheats::Code code;
@ -101,7 +96,7 @@ void cheats_code_gg_add(const wchar_t *data) {
cheats.SetCode(code);
}
void cheats_code_par_add(const wchar_t *data) {
void nst_cheats_code_par_add(const wchar_t *data) {
// Add a Pro Action Rocky code
Cheats cheats(emulator);
Cheats::Code code;
@ -113,7 +108,7 @@ void cheats_code_par_add(const wchar_t *data) {
cheats.SetCode(code);
}
void cheats_code_raw_add(Xml::Node node) {
void nst_cheats_code_raw_add(Xml::Node node) {
// Add a Raw code
Cheats cheats(emulator);
Cheats::Code code;
@ -132,14 +127,11 @@ void cheats_code_raw_add(Xml::Node node) {
}
// DIP Switches
void dip_handle() {
void nst_dip_handle(const char *dippath) {
// Handle the DIP switch file
DipSwitches dipswitches(emulator);
Xml xml;
char dippath[512];
snprintf(dippath, sizeof(dippath), "%s%s.dip", nstpaths.savedir, nstpaths.gamename);
std::ifstream dipfile(dippath, std::ifstream::in|std::ifstream::binary);
if (dipfile.is_open()) {

View file

@ -11,12 +11,12 @@ using namespace Nes::Api;
typedef Nes::Core::Xml Xml;
void cheats_init();
void cheats_code_gg_add(const wchar_t *data);
void cheats_code_par_add(const wchar_t *data);
void cheats_code_raw_add(Xml::Node node);
void nst_cheats_init(const char *cheatpath);
void nst_cheats_code_gg_add(const wchar_t *data);
void nst_cheats_code_par_add(const wchar_t *data);
void nst_cheats_code_raw_add(Xml::Node node);
// DIP Switches
void dip_handle();
void nst_dip_handle(const char *dippath);
#endif

View file

@ -24,12 +24,9 @@
#include <stdlib.h>
#include <getopt.h>
#include "main.h"
#include "cli.h"
#include "config.h"
extern settings_t conf;
void cli_error(const char *message) {
cli_show_usage();
fprintf(stderr, "%s\n", message);

View file

@ -24,28 +24,28 @@
#include <stdlib.h>
#include <string.h>
#include "main.h"
#include "config.h"
#include "ini.h"
settings_t conf;
char confpath[256];
extern nstpaths_t nstpaths;
void config_file_read() {
void config_file_read(const char *nstdir) {
// Read the config file
snprintf(confpath, sizeof(confpath), "%snestopia.conf", nstpaths.nstdir);
char confpath[256];
snprintf(confpath, sizeof(confpath), "%snestopia.conf", nstdir);
if (ini_parse(confpath, config_match, &conf) < 0) {
fprintf(stderr, "Failed to read config file %s: Using defaults.\n", confpath);
}
}
void config_file_write() {
void config_file_write(const char *nstdir) {
// Write the config file
char confpath[256];
snprintf(confpath, sizeof(confpath), "%snestopia.conf", nstdir);
FILE *fp = fopen(confpath, "w");
if (fp != NULL) {
// Video

View file

@ -65,8 +65,10 @@ typedef struct {
bool misc_overclock;
} settings_t;
void config_file_read();
void config_file_write();
void config_file_read(const char *nstdir);
void config_file_write(const char *nstdir);
void config_set_default();
static int config_match(void* user, const char* section, const char* name, const char* value);
extern settings_t conf;
#endif

View file

@ -2,7 +2,7 @@
* Nestopia UE
*
* Copyright (C) 2007-2008 R. Belmont
* Copyright (C) 2012-2017 R. Danbrook
* Copyright (C) 2012-2018 R. Danbrook
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -39,7 +39,7 @@
#include "png.h"
#ifdef _GTK
#include "gtkui/gtkui.h"
#include "gtkui.h"
#endif
using namespace Nes::Api;
@ -65,7 +65,6 @@ dimensions_t basesize, rendersize, screensize;
extern void *custompalette;
extern bool playing, nst_nsf, nst_pal;
extern settings_t conf;
extern nstpaths_t nstpaths;
extern Emulator emulator;

View file

@ -1,7 +1,7 @@
/*
* Nestopia UE
*
* Copyright (C) 2012-2017 R. Danbrook
* Copyright (C) 2012-2018 R. Danbrook
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,9 +24,9 @@
#include <stdlib.h>
#include <sys/stat.h>
#include "../main.h"
#include "../config.h"
#include "../video.h"
#include "main.h"
#include "config.h"
#include "video.h"
#include "gtkui.h"
#include "gtkui_callbacks.h"
@ -45,7 +45,6 @@ char iconpath[512];
char padpath[512];
extern dimensions_t basesize, rendersize;
extern settings_t conf;
extern int nst_quit;
gpointer gtkui_emuloop(gpointer data) {
@ -459,7 +458,7 @@ GtkWidget *gtkui_about() {
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(aboutdialog), VERSION);
gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(aboutdialog), "Cycle-Accurate Nintendo Entertainment System Emulator");
gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(aboutdialog), "http://0ldsk00l.ca/nestopia/");
gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(aboutdialog), "(c) 2012-2017, R. Danbrook\n(c) 2007-2008, R. Belmont\n(c) 2003-2008, Martin Freij\n\nIcon based on art from Trollekop");
gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(aboutdialog), "(c) 2012-2018, R. Danbrook\n(c) 2007-2008, R. Belmont\n(c) 2003-2008, Martin Freij\n\nIcon based on art from Trollekop");
gtk_dialog_run(GTK_DIALOG(aboutdialog));
gtk_widget_destroy(aboutdialog);
@ -474,10 +473,10 @@ void gtkui_image_paths() {
// Load the SVG from local source dir if make install hasn't been done
struct stat svgstat;
if (stat(iconpath, &svgstat) == -1) {
snprintf(iconpath, sizeof(iconpath), "source/unix/icons/nestopia.svg");
snprintf(iconpath, sizeof(iconpath), "icons/nestopia.svg");
}
if (stat(padpath, &svgstat) == -1) {
snprintf(padpath, sizeof(padpath), "source/unix/icons/nespad.svg");
snprintf(padpath, sizeof(padpath), "icons/nespad.svg");
}
}

View file

@ -24,17 +24,15 @@
#include <archive.h>
#include <archive_entry.h>
#include "../main.h"
#include "../config.h"
#include "main.h"
#include "config.h"
#include "gtkui.h"
#include "gtkui_archive.h"
bool windowopen, cancelled;
static bool windowopen, cancelled;
GtkWidget *archivewindow;
extern settings_t conf;
static GtkWidget *archivewindow;
bool gtkui_archive_handle(const char *filename, char *reqfile, size_t reqsize) {
// Select a filename to pull out of the archive

View file

@ -22,15 +22,14 @@
#include <SDL.h>
#include "../main.h"
#include "../config.h"
#include "../video.h"
#include "../input.h"
#include "main.h"
#include "config.h"
#include "video.h"
#include "input.h"
#include "gtkui.h"
#include "gtkui_callbacks.h"
extern settings_t conf;
extern bool playing, kbactivate, confrunning;
//// Menu ////

View file

@ -25,16 +25,15 @@
#include <stdlib.h>
#include "../main.h"
#include "../config.h"
#include "../cheats.h"
#include "main.h"
#include "config.h"
#include "cheats.h"
#include "gtkui.h"
#include "gtkui_callbacks.h"
#include "gtkui_cheats.h"
#include "gtkui_dialogs.h"
extern settings_t conf;
extern nstpaths_t nstpaths;
extern Emulator emulator;
@ -350,7 +349,7 @@ void gtkui_cheats_fill_tree(char *filename) {
1, codebuf,
4, descbuf,
-1);
if (enabled) { cheats_code_gg_add(node.GetChild(L"genie").GetValue()); }
if (enabled) { nst_cheats_code_gg_add(node.GetChild(L"genie").GetValue()); }
}
else if (node.GetChild(L"rocky")) { // Pro Action Rocky
@ -361,7 +360,7 @@ void gtkui_cheats_fill_tree(char *filename) {
2, codebuf,
4, descbuf,
-1);
if (enabled) { cheats_code_par_add(node.GetChild(L"rocky").GetValue()); }
if (enabled) { nst_cheats_code_par_add(node.GetChild(L"rocky").GetValue()); }
}
else if (node.GetChild(L"address")) { // Raw
@ -378,7 +377,7 @@ void gtkui_cheats_fill_tree(char *filename) {
3, rawbuf,
4, descbuf,
-1);
if (enabled) { cheats_code_raw_add(node); }
if (enabled) { nst_cheats_code_raw_add(node); }
}
node = node.GetNextSibling();

View file

@ -24,17 +24,16 @@
#include <stdlib.h>
#include <string.h>
#include "../main.h"
#include "../config.h"
#include "../audio.h"
#include "../input.h"
#include "main.h"
#include "config.h"
#include "audio.h"
#include "input.h"
#include "gtkui.h"
#include "gtkui_callbacks.h"
#include "gtkui_config.h"
#include "gtkui_input.h"
extern settings_t conf;
extern gamepad_t player[NUMGAMEPADS];
extern gpad_t pad[NUMGAMEPADS];
extern char padpath[512];

View file

@ -20,15 +20,14 @@
*
*/
#include "../main.h"
#include "../video.h"
#include "../config.h"
#include "main.h"
#include "video.h"
#include "config.h"
#include "gtkui.h"
#include "gtkui_cheats.h"
extern nstpaths_t nstpaths;
extern settings_t conf;
extern GtkWidget *gtkwindow;
void gtkui_file_open() {

View file

@ -20,12 +20,11 @@
*
*/
#include "../main.h"
#include "../config.h"
#include "../input.h"
#include "../video.h"
#include "../audio.h"
#include "../ini.h"
#include "main.h"
#include "input.h"
#include "video.h"
#include "audio.h"
#include "ini.h"
#include "gtkui.h"
#include "gtkui_input.h"
@ -36,7 +35,6 @@ gpad_t pad[NUMGAMEPADS];
static char inputconfpath[256];
//extern settings_t conf;
extern nstpaths_t nstpaths;
extern Input::Controllers *cNstPads;

View file

@ -48,7 +48,6 @@ static bool jack_ready = false;
const size_t jack_sample_size = sizeof(jack_default_audio_sample_t);
#endif
extern settings_t conf;
extern Emulator emulator;
extern bool nst_pal;

View file

@ -38,7 +38,6 @@
#include "input.h"
#include "ini.h"
extern settings_t conf;
extern nstpaths_t nstpaths;
extern dimensions_t rendersize, screensize;
extern Emulator emulator;

View file

@ -2,7 +2,7 @@
* Nestopia UE
*
* Copyright (C) 2007-2008 R. Belmont
* Copyright (C) 2012-2017 R. Danbrook
* Copyright (C) 2012-2018 R. Danbrook
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -60,9 +60,9 @@
#include "cheats.h"
#ifdef _GTK
#include "gtkui/gtkui.h"
#include "gtkui/gtkui_archive.h"
#include "gtkui/gtkui_input.h"
#include "gtkui.h"
#include "gtkui_archive.h"
#include "gtkui_input.h"
#endif
using namespace Nes::Api;
@ -97,8 +97,6 @@ void (*nst_inputloop)();
extern void (*audio_deinit)();
extern settings_t conf;
extern int drawtext;
extern char textbuf[32];
@ -331,7 +329,10 @@ void nst_dipswitch() {
fprintf(stderr, " %d: %s\n", j, dipswitches.GetValueName(i, j));
}
}
dip_handle();
char dippath[512];
snprintf(dippath, sizeof(dippath), "%s%s.dip", nstpaths.savedir, nstpaths.gamename);
nst_dip_handle(dippath);
}
}
@ -430,7 +431,7 @@ void nst_play() {
video_init();
audio_init();
input_init();
cheats_init();
nst_cheats_init(nstpaths.cheatpath);
#ifdef _GTK
if (!conf.misc_disable_gui) { gtkui_signals_init(); }
@ -998,7 +999,7 @@ int main(int argc, char *argv[]) {
config_set_default();
// Read the config file and override defaults
config_file_read();
config_file_read(nstpaths.nstdir);
// Exit if there is no CLI argument
#ifdef _GTK
@ -1119,7 +1120,7 @@ int main(int argc, char *argv[]) {
if (!conf.misc_disable_gui) { gtkui_input_config_write(); }
#endif
// Write the config file
config_file_write();
config_file_write(nstpaths.nstdir);
return 0;
}