From 01b06fbde1262e48eb159edf9da4cd813750ca62 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 8 Jan 2019 21:54:08 +0100 Subject: [PATCH] Various doc and profile downloader updates --- Makefile | 2 +- README.md | 38 +++++++++++++++++++++++++------------- flips.cpp | 30 ++++++++++++++++++++++++++++++ make.sh | 12 +++++++----- profile/download.sh | 7 +++++-- 5 files changed, 68 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 76f9e68..690b115 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ ifeq ($(TARGET),gtk) ifeq ($(GTKFLAGS),) $(warning pkg-config can't find gtk+-3.0, or pkg-config itself can't be found) $(warning if you have the needed files installed, specify their locations and names with `make GTKFLAGS='-I/usr/include' GTKLIBS='-L/usr/lib -lgtk'') - $(warning if not, the package name under Debian and derivates is `libgtk-3-dev'; for other distros, consult a search engine) + $(warning if not, the package names under Debian and derivates are `pkg-config libgtk-3-dev'; for other distros, consult a search engine) TARGET := cli ifeq ($(TARGET),gtk) $(warning build will now fail) diff --git a/README.md b/README.md index da73c77..0ebdfcc 100644 --- a/README.md +++ b/README.md @@ -5,28 +5,40 @@ Features: - Creates the smallest IPS patches of any known tool in existence, too (but only a little smaller, Lunar IPS is quite good) - Fully-featured GUIs under Windows and GTK+, including command line support; can also be a pure command line program - Can apply multiple patches to the same ROM, creating a huge pile of ROMs (GUI only) -- Remembers which ROMs you've used, and will use them again if it thinks it's correct (BPS only, GUI only) -- Can launch other programs after patching the ROMs, allowing you to double click a BPS to launch an emulator (GUI only) +- Can remembers which ROMs you've used, and use them again if it thinks it's correct (BPS only, GUI only) +- Can launch other programs after patching the ROMs; together with the above, this allows you to double click a BPS to launch an emulator (GUI only) -Planned: -- Automatically enable ROM guesser (open a message box the first time it guesses a ROM, asking if you want that) -- Different emulators for different filetypes (check the extension, or default to the OS default handler?) +Planned features: +- Better autodetection for CLI apply/create; if the first one is a patch, apply, else create - Better support for ROM database in CLI; the -d flag, or DB enabling from the GUI (for pure-CLI, existence of flipsdb.bin file beside Flips), will store ROMs in the database; the filename "." will read from it, and "wrong ROM" will look for the right one (but not automatically use it) - Use path of patch as output filename, not the ROM path -- Better autodetection for command line; if the first two files have same extension, create, else apply +- Replace Settings button with Advanced, which switches to a different UI +- Remove emulator chooser, use OS file associations instead +- Automatic source ROM chooser for creation Not planned (if your plans are different, send a PR): - OSX GUI support; there's a third-party fork [here](https://github.com/covarianttensor/QtFloatingIPS), and MultiPatch exists and the Windows version works in Wine. I can't test OSX stuff well enough to merge that fork, so pick your favorite. - Qt GUI support; my distro prefers GTK+, and all distros I've seen can run both GTK+ and Qt, not worth the effort (and QString's UTF-16 irritates me) -To compile (Linux): -- Install g++ and build-essential (names may vary on non-Debian-based distros). If you want a GUI, install libgtk-3-dev and pkg-config as well. -- To build an optimized binary, use `./make.sh`; for development, use `make CFLAGS=-g` +Compilation - Linux (Debian/Ubuntu): +- `sudo apt-get install g++ build-essential`; for GUI support, also `sudo apt-get install libgtk-3-dev pkg-config` +- `./make.sh` to build an optimized binary; for development, use `make CFLAGS=-g` -To compile (other Unix): -- Install make and a C++ compiler, then use `make CXX=clang++ CFLAGS=-O3` (may require GNU make, not tested; `./make.sh` may work, not tested) +Compilation - other Linux: +- Install make and g++; for GUI support, also install pkg-config and GTK+ 3 headers; for profiling support, also install curl or wget +- `./make.sh` to build an optimized binary; for development, use `make CFLAGS=-g` -To compile (Windows): +Compilation - OSX and other Unix: +- Install a C++ compiler +- `clang++ *.c *.cpp -O3 -o flips` (with changes as appropriate) +- For GTK GUI support, use some suitable variant of `clang++ *.c *.cpp -O3 -o flips -DFLIPS_GTK -lgtk3` +- For better optimizations (profiling/etc), extract the appropriate commands from Makefile and make.sh + +Compilation - Windows: - Install [mingw-w64](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.2.0/threads-win32/seh/) -- `mingw32-make CFLAGS=-O3` +- `mingw32-make CFLAGS=-O3` (GUI is automatically enabled), or extract the appropriate optimization commands from make.sh - Alternatively, [here's a binary](https://www.smwcentral.net/?p=section&a=details&id=11474). + +Usage: +- If GUI is enabled, just run the program. File pickers' window titles tell what they want; Enable automatic ROM picker and Run in Emulator can cause file pickers to appear and disappear depending on the chosen patch, making usage less predictable, so it's disabled by default. +- For CLI use, see `./flips --help`. Available both with or without GUI support (though Windows CLI use from interactive prompts is slightly screwy, due to OS limitations). diff --git a/flips.cpp b/flips.cpp index 85a1c99..e184ffc 100644 --- a/flips.cpp +++ b/flips.cpp @@ -13,6 +13,36 @@ void operator delete(void * p) { free(p); } extern "C" void __cxa_pure_virtual() { abort(); } #endif +//TODO: source ROM chooser +//given a target, from all known source ROMs with same extension, find the most similar +// read 1MB from each; check how many bytes are same and same location as target +// (only counting offsets where both source and target bytes are different from previous, to avoid false positives on long runs of 00) +// if one is >80% same (not counting repeated runs), and all others are <20%, use that +//if no match, multiple matches, or one or more half-matches: +// read first 64K from each of the listed sources, create BPS, and see if one is <20% of size of bps with blank source, while others are >70% +//if still nothing unambiguous: +// fail +//this goes on a separate thread + +//TODO: advanced GUI +// has three text fields, for patch / source / target, and 'pick' buttons nearby that open file dialogs +// also Create / Apply / ApplyRun buttons at the bottom +//auto selection (only if target field is blank): +// patch -> source (crc32 database) +// target -> source (algorithm above) +// target -> patch (set extension to bps) +// (source&patch) -> target (source extension, name/path from patch; also happens if triggering patch->source) +//all text fields are scrolled to the end on creation +//no auto selection in simple UI +//applying or creating clears patch/target, but keeps source +//ips creation is allowed, but only by changing filetype in picker, or editing text field; it does not keep last used type +// ips application remains unchanged +// multi-patching is allowed, each filename is wrapped in <>; if filename doesn't start or end with right char, it's a single name +// colon-separated or semicolon-separated are more common, but they're plausible (uncommon, but possible) in filenames +// (Super Mario World 2: Yoshi's Island, or Marios;Gate, for example), and I don't want to fail on that +// multi-creation is not allowed; technically feasible, but super rare, should probably be CLI instead +// if first file isn't found, it tries using the entire field as filename, in case it actually contains semicolon + //TODO: delete struct mem ReadWholeFile(LPCWSTR filename) diff --git a/make.sh b/make.sh index eb6ff15..da32b58 100755 --- a/make.sh +++ b/make.sh @@ -18,10 +18,12 @@ case "$i" in ;; --profile=no) echo n > profile/choice + rm profile/firefox-10.0esr.tar + rm profile/firefox-17.0esr.tar ;; --profile=yes) if [ ! -e profile/firefox-10.0esr.tar ]; then - profile/download.sh + profile/download.sh || exit $? fi ;; *) # unknown option @@ -42,16 +44,16 @@ if [ ! -e profile/choice ]; then while true; do read -p "Do you wish to use profile-guided optimization? This will download 40MB data from the internet and use 90MB disk space, and 800MB RAM during compilation. (y/n)" yn case $yn in - [Yy]* ) profile/download.sh; break;; - [Nn]* ) echo n > profile/choice; break;; - * ) echo "Please answer yes or no."; exit 1;; + [Yy]*) profile/download.sh || exit $?; break;; + [Nn]*) echo n > profile/choice; break;; + *) echo "Please answer yes or no.";; esac done fi #if download was aborted, resume it if [ -e profile/firefox-10.0esr.tar ]; then - profile/download.sh + profile/download.sh || exit $? fi #clean up diff --git a/profile/download.sh b/profile/download.sh index b955b4f..dbca5a4 100755 --- a/profile/download.sh +++ b/profile/download.sh @@ -1,5 +1,8 @@ #!/bin/sh +#why firefox? I need two large, freely available, mostly similar, binary files; two versions of an executable would be a good choice +#why 10/17? older firefoxes are smaller, so profiling needs less RAM; but I also want to skip a few versions, +# to ensure they're not too similar; and I want something chosen with a minimum of arbitrariness. The oldest ESRs satisfy those constraints. SRC=profile/firefox-10.0esr.tar DST=profile/firefox-17.0esr.tar SRCSIZE=39526400 @@ -8,10 +11,10 @@ SRCURL=https://ftp.mozilla.org/pub/firefox/releases/10.0esr/linux-x86_64/en-US/f DSTURL=https://ftp.mozilla.org/pub/firefox/releases/17.0esr/linux-x86_64/en-US/firefox-17.0esr.tar.bz2 if [ ! -f $SRC ] || [ $(wc -c <$SRC) -lt $SRCSIZE ]; then - wget $SRCURL -O- | bzcat > $SRC || exit $? + wget $SRCURL -O- | bzcat > $SRC || curl $SRCURL | bzcat > $SRC || exit $? fi if [ ! -f $DST ] || [ $(wc -c <$DST) -lt $DSTSIZE ]; then - wget $DSTURL -O- | bzcat > $DST || exit $? + wget $DSTURL -O- | bzcat > $DST || curl $DSTURL | bzcat > $DST || exit $? fi echo y > profile/choice