From e0a5452e8d199583b214d345ffdf70faf7cf6943 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Mon, 27 Dec 2010 18:29:57 +1100 Subject: [PATCH] Update to v073r01 release. byuu says: While perhaps not perfect, pretty good is better than nothing ... I've added emulation of auto-joypad poll timing. Going off ikari_01's confirmation of what we suspected, that the strobe happens every 256 clocks, I've set up emulation as follows: Upon reset, our clock counter is reset to zero. At the start of each frame, our poll counter is reset to zero. Every 256 clocks, we call the step_auto_joypad_poll() function. If we are at V=225/240+ (based on overscan setting), we check the poll counter. At zero, we poll the actual controller and set the joypad polling flag in $4212.d0 to 1. From zero through fifteen, we read in one bit for each controller and shift it into the register. At sixteen, we turn off the joypad polling flag. The 256-clock divider allows the start point of polling for each frame to fluctuate wildly like real hardware. I count regardless of auto joypad enable, as per $4212.d0's behavior; but only poll when it's actually enabled. I do not consume any actual time from this polling. I honestly don't know if I even should, or if it manages to do it in the background. If it should consume time, then this most likely happens between opcode edges and we'll have to adjust the code a good bit. All commercial games should continue to work fine, but this will likely break some hacks/translations not tested on hardware. Without the timing emulation, reading $4218-421f before V=~228 would basically give you the valid input controller values of the previous frame. Now, like hardware, it should give you a state that is part previous frame, part current frame shifted into it. Button positions won't be reliable and will shift every 256 clocks. I've also removed the Qt GUI, and renamed ui-phoenix to just ui. This removes 400kb of source code (phoenix is a lean 130kb), and drops the archive size from 564KB to 475KB. Combined with the DSP HLE, and we've knocked off ~570KB of source cruft from the entire project. I am looking forward to not having to specify which GUI is included anymore. --- bsnes/Makefile | 6 +- bsnes/snes/cpu/cpu.hpp | 13 +- bsnes/snes/cpu/mmio/mmio.cpp | 34 +- bsnes/snes/cpu/serialization.cpp | 16 +- bsnes/snes/cpu/timing/joypad.cpp | 42 +- bsnes/snes/cpu/timing/timing.cpp | 17 +- bsnes/snes/cpu/timing/timing.hpp | 2 +- bsnes/snes/snes.hpp | 4 +- bsnes/ui-qt/Makefile | 94 --- bsnes/ui-qt/application/application.cpp | 184 ----- bsnes/ui-qt/application/application.moc.hpp | 57 -- bsnes/ui-qt/application/init.cpp | 108 --- bsnes/ui-qt/base/about.cpp | 44 -- bsnes/ui-qt/base/about.moc.hpp | 14 - bsnes/ui-qt/base/base.cpp | 8 - bsnes/ui-qt/base/filebrowser.cpp | 242 ------ bsnes/ui-qt/base/filebrowser.moc.hpp | 39 - bsnes/ui-qt/base/htmlviewer.cpp | 23 - bsnes/ui-qt/base/htmlviewer.moc.hpp | 14 - bsnes/ui-qt/base/loader.cpp | 236 ------ bsnes/ui-qt/base/loader.moc.hpp | 47 -- bsnes/ui-qt/base/main.cpp | 690 ------------------ bsnes/ui-qt/base/main.moc.hpp | 168 ----- bsnes/ui-qt/base/stateselect.cpp | 57 -- bsnes/ui-qt/base/stateselect.moc.hpp | 16 - bsnes/ui-qt/cartridge/cartridge.cpp | 392 ---------- bsnes/ui-qt/cartridge/cartridge.hpp | 42 -- bsnes/ui-qt/config.cpp | 141 ---- bsnes/ui-qt/config.hpp | 109 --- bsnes/ui-qt/data/documentation.html | 81 -- bsnes/ui-qt/data/icons-16x16/folder-new.png | Bin 635 -> 0 bytes bsnes/ui-qt/data/icons-16x16/go-up.png | Bin 652 -> 0 bytes .../ui-qt/data/icons-16x16/item-check-off.png | Bin 209 -> 0 bytes .../ui-qt/data/icons-16x16/item-check-on.png | Bin 266 -> 0 bytes .../ui-qt/data/icons-16x16/item-radio-off.png | Bin 565 -> 0 bytes .../ui-qt/data/icons-16x16/item-radio-on.png | Bin 647 -> 0 bytes bsnes/ui-qt/data/license.html | 77 -- bsnes/ui-qt/data/logo.png | Bin 16733 -> 0 bytes bsnes/ui-qt/debugger/debugger.cpp | 245 ------- bsnes/ui-qt/debugger/debugger.moc.hpp | 50 -- .../ui-qt/debugger/misc/debugger-options.cpp | 29 - .../debugger/misc/debugger-options.moc.hpp | 15 - bsnes/ui-qt/debugger/ppu/cgram-viewer.cpp | 126 ---- bsnes/ui-qt/debugger/ppu/cgram-viewer.moc.hpp | 29 - bsnes/ui-qt/debugger/ppu/oam-viewer.cpp | 127 ---- bsnes/ui-qt/debugger/ppu/oam-viewer.moc.hpp | 24 - bsnes/ui-qt/debugger/ppu/vram-viewer.cpp | 177 ----- bsnes/ui-qt/debugger/ppu/vram-viewer.moc.hpp | 38 - bsnes/ui-qt/debugger/tools/breakpoint.cpp | 80 -- bsnes/ui-qt/debugger/tools/breakpoint.moc.hpp | 30 - bsnes/ui-qt/debugger/tools/disassembler.cpp | 112 --- .../ui-qt/debugger/tools/disassembler.moc.hpp | 29 - bsnes/ui-qt/debugger/tools/memory.cpp | 165 ----- bsnes/ui-qt/debugger/tools/memory.moc.hpp | 36 - bsnes/ui-qt/debugger/tools/properties.cpp | 100 --- bsnes/ui-qt/debugger/tools/properties.moc.hpp | 39 - bsnes/ui-qt/debugger/tracer.cpp | 74 -- bsnes/ui-qt/debugger/tracer.moc.hpp | 26 - bsnes/ui-qt/input/controller.cpp | 385 ---------- bsnes/ui-qt/input/controller.hpp | 112 --- bsnes/ui-qt/input/input.cpp | 272 ------- bsnes/ui-qt/input/input.hpp | 90 --- .../input/userinterface-emulationspeed.cpp | 208 ------ bsnes/ui-qt/input/userinterface-general.cpp | 69 -- bsnes/ui-qt/input/userinterface-states.cpp | 153 ---- bsnes/ui-qt/input/userinterface-system.cpp | 89 --- .../input/userinterface-videosettings.cpp | 148 ---- bsnes/ui-qt/input/userinterface.hpp | 5 - bsnes/ui-qt/interface.cpp | 94 --- bsnes/ui-qt/interface.hpp | 15 - bsnes/ui-qt/link/filter.cpp | 239 ------ bsnes/ui-qt/link/filter.hpp | 54 -- bsnes/ui-qt/link/reader.cpp | 44 -- bsnes/ui-qt/link/reader.hpp | 15 - bsnes/ui-qt/main.cpp | 45 -- bsnes/ui-qt/movie/movie.cpp | 114 --- bsnes/ui-qt/movie/movie.hpp | 20 - bsnes/ui-qt/platform/platform_osx.cpp | 3 - bsnes/ui-qt/platform/platform_win.cpp | 23 - bsnes/ui-qt/platform/platform_x.cpp | 33 - bsnes/ui-qt/resource/resource.qrc | 19 - bsnes/ui-qt/resource/resource.rc | 2 - bsnes/ui-qt/settings/advanced.cpp | 201 ----- bsnes/ui-qt/settings/advanced.moc.hpp | 60 -- bsnes/ui-qt/settings/audio.cpp | 130 ---- bsnes/ui-qt/settings/audio.moc.hpp | 29 - bsnes/ui-qt/settings/input.cpp | 354 --------- bsnes/ui-qt/settings/input.moc.hpp | 44 -- bsnes/ui-qt/settings/paths.cpp | 86 --- bsnes/ui-qt/settings/paths.moc.hpp | 40 - bsnes/ui-qt/settings/profile.cpp | 92 --- bsnes/ui-qt/settings/profile.moc.hpp | 22 - bsnes/ui-qt/settings/settings.cpp | 70 -- bsnes/ui-qt/settings/settings.moc.hpp | 19 - bsnes/ui-qt/settings/video.cpp | 294 -------- bsnes/ui-qt/settings/video.moc.hpp | 66 -- bsnes/ui-qt/state/state.cpp | 111 --- bsnes/ui-qt/state/state.hpp | 25 - bsnes/ui-qt/template/Makefile | 55 -- bsnes/ui-qt/template/check-action.moc.hpp | 41 -- bsnes/ui-qt/template/concept.hpp | 10 - bsnes/ui-qt/template/file-dialog.moc.hpp | 392 ---------- bsnes/ui-qt/template/hex-editor.moc.hpp | 173 ----- bsnes/ui-qt/template/radio-action.moc.hpp | 41 -- bsnes/ui-qt/template/window.moc.hpp | 105 --- bsnes/ui-qt/tools/cheateditor.cpp | 390 ---------- bsnes/ui-qt/tools/cheateditor.moc.hpp | 65 -- bsnes/ui-qt/tools/cheatfinder.cpp | 200 ----- bsnes/ui-qt/tools/cheatfinder.moc.hpp | 41 -- bsnes/ui-qt/tools/effecttoggle.cpp | 143 ---- bsnes/ui-qt/tools/effecttoggle.moc.hpp | 35 - bsnes/ui-qt/tools/statemanager.cpp | 284 ------- bsnes/ui-qt/tools/statemanager.moc.hpp | 40 - bsnes/ui-qt/tools/tools.cpp | 56 -- bsnes/ui-qt/tools/tools.moc.hpp | 17 - bsnes/ui-qt/ui-base.hpp | 93 --- bsnes/ui-qt/utility/system-state.cpp | 101 --- bsnes/ui-qt/utility/utility.cpp | 132 ---- bsnes/ui-qt/utility/utility.hpp | 38 - bsnes/ui-qt/utility/window.cpp | 192 ----- bsnes/{ui-phoenix => ui}/Makefile | 0 bsnes/{ui-phoenix => ui}/base.hpp | 0 .../cartridge/cartridge.cpp | 0 .../cartridge/cartridge.hpp | 0 bsnes/{ui-phoenix => ui}/config.cpp | 0 bsnes/{ui-phoenix => ui}/config.hpp | 0 bsnes/{ui-phoenix => ui}/debugger/console.cpp | 0 bsnes/{ui-phoenix => ui}/debugger/console.hpp | 0 .../debugger/cpu/debugger.cpp | 0 .../debugger/cpu/debugger.hpp | 0 .../{ui-phoenix => ui}/debugger/debugger.cpp | 0 .../{ui-phoenix => ui}/debugger/debugger.hpp | 0 .../debugger/smp/debugger.cpp | 0 .../debugger/smp/debugger.hpp | 0 .../debugger/tools/breakpoint-editor.cpp | 0 .../debugger/tools/breakpoint-editor.hpp | 0 .../debugger/tools/memory-editor.cpp | 0 .../debugger/tools/memory-editor.hpp | 0 .../general/file-browser.cpp | 0 .../general/file-browser.hpp | 0 bsnes/{ui-phoenix => ui}/general/general.cpp | 0 bsnes/{ui-phoenix => ui}/general/general.hpp | 0 .../general/main-window.cpp | 0 .../general/main-window.hpp | 0 .../general/slot-loader.cpp | 0 .../general/slot-loader.hpp | 0 bsnes/{ui-phoenix => ui}/input/hotkeys.cpp | 0 bsnes/{ui-phoenix => ui}/input/input.cpp | 0 bsnes/{ui-phoenix => ui}/input/input.hpp | 0 bsnes/{ui-phoenix => ui}/interface.cpp | 0 bsnes/{ui-phoenix => ui}/interface.hpp | 0 bsnes/{ui-phoenix => ui}/main.cpp | 0 bsnes/{ui-phoenix => ui}/resource.rc | 0 .../{ui-phoenix => ui}/settings/advanced.cpp | 0 .../{ui-phoenix => ui}/settings/advanced.hpp | 0 bsnes/{ui-phoenix => ui}/settings/audio.cpp | 0 bsnes/{ui-phoenix => ui}/settings/audio.hpp | 0 bsnes/{ui-phoenix => ui}/settings/input.cpp | 0 bsnes/{ui-phoenix => ui}/settings/input.hpp | 0 .../{ui-phoenix => ui}/settings/settings.cpp | 0 .../{ui-phoenix => ui}/settings/settings.hpp | 0 bsnes/{ui-phoenix => ui}/settings/video.cpp | 0 bsnes/{ui-phoenix => ui}/settings/video.hpp | 0 .../{ui-phoenix => ui}/tools/cheat-editor.cpp | 0 .../{ui-phoenix => ui}/tools/cheat-editor.hpp | 0 .../tools/state-manager.cpp | 0 .../tools/state-manager.hpp | 0 bsnes/{ui-phoenix => ui}/tools/tools.cpp | 0 bsnes/{ui-phoenix => ui}/tools/tools.hpp | 0 bsnes/{ui-phoenix => ui}/utility/utility.cpp | 0 bsnes/{ui-phoenix => ui}/utility/utility.hpp | 0 171 files changed, 70 insertions(+), 11036 deletions(-) delete mode 100755 bsnes/ui-qt/Makefile delete mode 100755 bsnes/ui-qt/application/application.cpp delete mode 100755 bsnes/ui-qt/application/application.moc.hpp delete mode 100755 bsnes/ui-qt/application/init.cpp delete mode 100755 bsnes/ui-qt/base/about.cpp delete mode 100755 bsnes/ui-qt/base/about.moc.hpp delete mode 100755 bsnes/ui-qt/base/base.cpp delete mode 100755 bsnes/ui-qt/base/filebrowser.cpp delete mode 100755 bsnes/ui-qt/base/filebrowser.moc.hpp delete mode 100755 bsnes/ui-qt/base/htmlviewer.cpp delete mode 100755 bsnes/ui-qt/base/htmlviewer.moc.hpp delete mode 100755 bsnes/ui-qt/base/loader.cpp delete mode 100755 bsnes/ui-qt/base/loader.moc.hpp delete mode 100755 bsnes/ui-qt/base/main.cpp delete mode 100755 bsnes/ui-qt/base/main.moc.hpp delete mode 100755 bsnes/ui-qt/base/stateselect.cpp delete mode 100755 bsnes/ui-qt/base/stateselect.moc.hpp delete mode 100755 bsnes/ui-qt/cartridge/cartridge.cpp delete mode 100755 bsnes/ui-qt/cartridge/cartridge.hpp delete mode 100755 bsnes/ui-qt/config.cpp delete mode 100755 bsnes/ui-qt/config.hpp delete mode 100755 bsnes/ui-qt/data/documentation.html delete mode 100755 bsnes/ui-qt/data/icons-16x16/folder-new.png delete mode 100755 bsnes/ui-qt/data/icons-16x16/go-up.png delete mode 100755 bsnes/ui-qt/data/icons-16x16/item-check-off.png delete mode 100755 bsnes/ui-qt/data/icons-16x16/item-check-on.png delete mode 100755 bsnes/ui-qt/data/icons-16x16/item-radio-off.png delete mode 100755 bsnes/ui-qt/data/icons-16x16/item-radio-on.png delete mode 100755 bsnes/ui-qt/data/license.html delete mode 100755 bsnes/ui-qt/data/logo.png delete mode 100755 bsnes/ui-qt/debugger/debugger.cpp delete mode 100755 bsnes/ui-qt/debugger/debugger.moc.hpp delete mode 100755 bsnes/ui-qt/debugger/misc/debugger-options.cpp delete mode 100755 bsnes/ui-qt/debugger/misc/debugger-options.moc.hpp delete mode 100755 bsnes/ui-qt/debugger/ppu/cgram-viewer.cpp delete mode 100755 bsnes/ui-qt/debugger/ppu/cgram-viewer.moc.hpp delete mode 100755 bsnes/ui-qt/debugger/ppu/oam-viewer.cpp delete mode 100755 bsnes/ui-qt/debugger/ppu/oam-viewer.moc.hpp delete mode 100755 bsnes/ui-qt/debugger/ppu/vram-viewer.cpp delete mode 100755 bsnes/ui-qt/debugger/ppu/vram-viewer.moc.hpp delete mode 100755 bsnes/ui-qt/debugger/tools/breakpoint.cpp delete mode 100755 bsnes/ui-qt/debugger/tools/breakpoint.moc.hpp delete mode 100755 bsnes/ui-qt/debugger/tools/disassembler.cpp delete mode 100755 bsnes/ui-qt/debugger/tools/disassembler.moc.hpp delete mode 100755 bsnes/ui-qt/debugger/tools/memory.cpp delete mode 100755 bsnes/ui-qt/debugger/tools/memory.moc.hpp delete mode 100755 bsnes/ui-qt/debugger/tools/properties.cpp delete mode 100755 bsnes/ui-qt/debugger/tools/properties.moc.hpp delete mode 100755 bsnes/ui-qt/debugger/tracer.cpp delete mode 100755 bsnes/ui-qt/debugger/tracer.moc.hpp delete mode 100755 bsnes/ui-qt/input/controller.cpp delete mode 100755 bsnes/ui-qt/input/controller.hpp delete mode 100755 bsnes/ui-qt/input/input.cpp delete mode 100755 bsnes/ui-qt/input/input.hpp delete mode 100755 bsnes/ui-qt/input/userinterface-emulationspeed.cpp delete mode 100755 bsnes/ui-qt/input/userinterface-general.cpp delete mode 100755 bsnes/ui-qt/input/userinterface-states.cpp delete mode 100755 bsnes/ui-qt/input/userinterface-system.cpp delete mode 100755 bsnes/ui-qt/input/userinterface-videosettings.cpp delete mode 100755 bsnes/ui-qt/input/userinterface.hpp delete mode 100755 bsnes/ui-qt/interface.cpp delete mode 100755 bsnes/ui-qt/interface.hpp delete mode 100755 bsnes/ui-qt/link/filter.cpp delete mode 100755 bsnes/ui-qt/link/filter.hpp delete mode 100755 bsnes/ui-qt/link/reader.cpp delete mode 100755 bsnes/ui-qt/link/reader.hpp delete mode 100755 bsnes/ui-qt/main.cpp delete mode 100755 bsnes/ui-qt/movie/movie.cpp delete mode 100755 bsnes/ui-qt/movie/movie.hpp delete mode 100755 bsnes/ui-qt/platform/platform_osx.cpp delete mode 100755 bsnes/ui-qt/platform/platform_win.cpp delete mode 100755 bsnes/ui-qt/platform/platform_x.cpp delete mode 100755 bsnes/ui-qt/resource/resource.qrc delete mode 100755 bsnes/ui-qt/resource/resource.rc delete mode 100755 bsnes/ui-qt/settings/advanced.cpp delete mode 100755 bsnes/ui-qt/settings/advanced.moc.hpp delete mode 100755 bsnes/ui-qt/settings/audio.cpp delete mode 100755 bsnes/ui-qt/settings/audio.moc.hpp delete mode 100755 bsnes/ui-qt/settings/input.cpp delete mode 100755 bsnes/ui-qt/settings/input.moc.hpp delete mode 100755 bsnes/ui-qt/settings/paths.cpp delete mode 100755 bsnes/ui-qt/settings/paths.moc.hpp delete mode 100755 bsnes/ui-qt/settings/profile.cpp delete mode 100755 bsnes/ui-qt/settings/profile.moc.hpp delete mode 100755 bsnes/ui-qt/settings/settings.cpp delete mode 100755 bsnes/ui-qt/settings/settings.moc.hpp delete mode 100755 bsnes/ui-qt/settings/video.cpp delete mode 100755 bsnes/ui-qt/settings/video.moc.hpp delete mode 100755 bsnes/ui-qt/state/state.cpp delete mode 100755 bsnes/ui-qt/state/state.hpp delete mode 100755 bsnes/ui-qt/template/Makefile delete mode 100755 bsnes/ui-qt/template/check-action.moc.hpp delete mode 100755 bsnes/ui-qt/template/concept.hpp delete mode 100755 bsnes/ui-qt/template/file-dialog.moc.hpp delete mode 100755 bsnes/ui-qt/template/hex-editor.moc.hpp delete mode 100755 bsnes/ui-qt/template/radio-action.moc.hpp delete mode 100755 bsnes/ui-qt/template/window.moc.hpp delete mode 100755 bsnes/ui-qt/tools/cheateditor.cpp delete mode 100755 bsnes/ui-qt/tools/cheateditor.moc.hpp delete mode 100755 bsnes/ui-qt/tools/cheatfinder.cpp delete mode 100755 bsnes/ui-qt/tools/cheatfinder.moc.hpp delete mode 100755 bsnes/ui-qt/tools/effecttoggle.cpp delete mode 100755 bsnes/ui-qt/tools/effecttoggle.moc.hpp delete mode 100755 bsnes/ui-qt/tools/statemanager.cpp delete mode 100755 bsnes/ui-qt/tools/statemanager.moc.hpp delete mode 100755 bsnes/ui-qt/tools/tools.cpp delete mode 100755 bsnes/ui-qt/tools/tools.moc.hpp delete mode 100755 bsnes/ui-qt/ui-base.hpp delete mode 100755 bsnes/ui-qt/utility/system-state.cpp delete mode 100755 bsnes/ui-qt/utility/utility.cpp delete mode 100755 bsnes/ui-qt/utility/utility.hpp delete mode 100755 bsnes/ui-qt/utility/window.cpp rename bsnes/{ui-phoenix => ui}/Makefile (100%) rename bsnes/{ui-phoenix => ui}/base.hpp (100%) rename bsnes/{ui-phoenix => ui}/cartridge/cartridge.cpp (100%) rename bsnes/{ui-phoenix => ui}/cartridge/cartridge.hpp (100%) rename bsnes/{ui-phoenix => ui}/config.cpp (100%) rename bsnes/{ui-phoenix => ui}/config.hpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/console.cpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/console.hpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/cpu/debugger.cpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/cpu/debugger.hpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/debugger.cpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/debugger.hpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/smp/debugger.cpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/smp/debugger.hpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/tools/breakpoint-editor.cpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/tools/breakpoint-editor.hpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/tools/memory-editor.cpp (100%) rename bsnes/{ui-phoenix => ui}/debugger/tools/memory-editor.hpp (100%) rename bsnes/{ui-phoenix => ui}/general/file-browser.cpp (100%) rename bsnes/{ui-phoenix => ui}/general/file-browser.hpp (100%) rename bsnes/{ui-phoenix => ui}/general/general.cpp (100%) rename bsnes/{ui-phoenix => ui}/general/general.hpp (100%) rename bsnes/{ui-phoenix => ui}/general/main-window.cpp (100%) rename bsnes/{ui-phoenix => ui}/general/main-window.hpp (100%) rename bsnes/{ui-phoenix => ui}/general/slot-loader.cpp (100%) rename bsnes/{ui-phoenix => ui}/general/slot-loader.hpp (100%) rename bsnes/{ui-phoenix => ui}/input/hotkeys.cpp (100%) rename bsnes/{ui-phoenix => ui}/input/input.cpp (100%) rename bsnes/{ui-phoenix => ui}/input/input.hpp (100%) rename bsnes/{ui-phoenix => ui}/interface.cpp (100%) rename bsnes/{ui-phoenix => ui}/interface.hpp (100%) rename bsnes/{ui-phoenix => ui}/main.cpp (100%) rename bsnes/{ui-phoenix => ui}/resource.rc (100%) rename bsnes/{ui-phoenix => ui}/settings/advanced.cpp (100%) rename bsnes/{ui-phoenix => ui}/settings/advanced.hpp (100%) rename bsnes/{ui-phoenix => ui}/settings/audio.cpp (100%) rename bsnes/{ui-phoenix => ui}/settings/audio.hpp (100%) rename bsnes/{ui-phoenix => ui}/settings/input.cpp (100%) rename bsnes/{ui-phoenix => ui}/settings/input.hpp (100%) rename bsnes/{ui-phoenix => ui}/settings/settings.cpp (100%) rename bsnes/{ui-phoenix => ui}/settings/settings.hpp (100%) rename bsnes/{ui-phoenix => ui}/settings/video.cpp (100%) rename bsnes/{ui-phoenix => ui}/settings/video.hpp (100%) rename bsnes/{ui-phoenix => ui}/tools/cheat-editor.cpp (100%) rename bsnes/{ui-phoenix => ui}/tools/cheat-editor.hpp (100%) rename bsnes/{ui-phoenix => ui}/tools/state-manager.cpp (100%) rename bsnes/{ui-phoenix => ui}/tools/state-manager.hpp (100%) rename bsnes/{ui-phoenix => ui}/tools/tools.cpp (100%) rename bsnes/{ui-phoenix => ui}/tools/tools.hpp (100%) rename bsnes/{ui-phoenix => ui}/utility/utility.cpp (100%) rename bsnes/{ui-phoenix => ui}/utility/utility.hpp (100%) diff --git a/bsnes/Makefile b/bsnes/Makefile index a820d46f..aba3d8ea 100755 --- a/bsnes/Makefile +++ b/bsnes/Makefile @@ -1,7 +1,7 @@ include nall/Makefile snes := snes -profile := accuracy -ui := ui-phoenix +profile := compatibility +ui := ui # compiler c := $(compiler) -std=gnu99 @@ -90,6 +90,6 @@ clean: ui_clean -@$(call delete,*.manifest) archive-all: - tar -cjf bsnes.tar.bz2 data launcher libco nall obj out phoenix ruby snes ui-phoenix ui-qt Makefile cc.bat clean.bat sync.sh + tar -cjf bsnes.tar.bz2 data launcher libco nall obj out phoenix ruby snes ui Makefile cc.bat clean.bat sync.sh help:; diff --git a/bsnes/snes/cpu/cpu.hpp b/bsnes/snes/cpu/cpu.hpp index 2f498242..c5cc8cc6 100755 --- a/bsnes/snes/cpu/cpu.hpp +++ b/bsnes/snes/cpu/cpu.hpp @@ -71,6 +71,11 @@ private: bool hdma_pending; bool hdma_mode; //0 = init, 1 = run + //auto joypad polling + bool auto_joypad_active; + unsigned auto_joypad_counter; + unsigned auto_joypad_clock; + //MMIO //$2140-217f uint8 port[4]; @@ -111,10 +116,10 @@ private: uint16 rdmpy; //$4218-$421f - uint8 joy1l, joy1h; - uint8 joy2l, joy2h; - uint8 joy3l, joy3h; - uint8 joy4l, joy4h; + uint16 joy1; + uint16 joy2; + uint16 joy3; + uint16 joy4; } status; struct ALU { diff --git a/bsnes/snes/cpu/mmio/mmio.cpp b/bsnes/snes/cpu/mmio/mmio.cpp index 2ae915cb..2d69bcb8 100755 --- a/bsnes/snes/cpu/mmio/mmio.cpp +++ b/bsnes/snes/cpu/mmio/mmio.cpp @@ -175,10 +175,9 @@ uint8 CPU::mmio_r4211() { //0 = JOYPAD acknowledge uint8 CPU::mmio_r4212() { uint8 r = (regs.mdr & 0x3e); - uint16 vs = ppu.overscan() == false ? 225 : 240; - if(vcounter() >= vs && vcounter() <= (vs + 2)) r |= 0x01; //auto joypad polling + if(status.auto_joypad_active) r |= 0x01; if(hcounter() <= 2 || hcounter() >= 1096) r |= 0x40; //hblank - if(vcounter() >= vs) r |= 0x80; //vblank + if(vcounter() >= (ppu.overscan() == false ? 225 : 240)) r |= 0x80; //vblank return r; } @@ -207,15 +206,14 @@ uint8 CPU::mmio_r4217() { return status.rdmpy >> 8; } -//TODO: handle reads during joypad polling (v=225-227) -uint8 CPU::mmio_r4218() { return status.joy1l; } //JOY1L -uint8 CPU::mmio_r4219() { return status.joy1h; } //JOY1H -uint8 CPU::mmio_r421a() { return status.joy2l; } //JOY2L -uint8 CPU::mmio_r421b() { return status.joy2h; } //JOY2H -uint8 CPU::mmio_r421c() { return status.joy3l; } //JOY3L -uint8 CPU::mmio_r421d() { return status.joy3h; } //JOY3H -uint8 CPU::mmio_r421e() { return status.joy4l; } //JOY4L -uint8 CPU::mmio_r421f() { return status.joy4h; } //JOY4H +uint8 CPU::mmio_r4218() { return status.joy1 >> 0; } //JOY1L +uint8 CPU::mmio_r4219() { return status.joy1 >> 8; } //JOY1H +uint8 CPU::mmio_r421a() { return status.joy2 >> 0; } //JOY2L +uint8 CPU::mmio_r421b() { return status.joy2 >> 8; } //JOY2H +uint8 CPU::mmio_r421c() { return status.joy3 >> 0; } //JOY3L +uint8 CPU::mmio_r421d() { return status.joy3 >> 8; } //JOY3H +uint8 CPU::mmio_r421e() { return status.joy4 >> 0; } //JOY4L +uint8 CPU::mmio_r421f() { return status.joy4 >> 8; } //JOY4H //DMAPx uint8 CPU::mmio_r43x0(uint8 i) { @@ -395,14 +393,10 @@ void CPU::mmio_reset() { status.rdmpy = 0x0000; //$4218-$421f - status.joy1l = 0x00; - status.joy1h = 0x00; - status.joy2l = 0x00; - status.joy2h = 0x00; - status.joy3l = 0x00; - status.joy3h = 0x00; - status.joy4l = 0x00; - status.joy4h = 0x00; + status.joy1 = 0x0000; + status.joy2 = 0x0000; + status.joy3 = 0x0000; + status.joy4 = 0x0000; //ALU alu.mpyctr = 0; diff --git a/bsnes/snes/cpu/serialization.cpp b/bsnes/snes/cpu/serialization.cpp index 64f9fe81..76fb061a 100755 --- a/bsnes/snes/cpu/serialization.cpp +++ b/bsnes/snes/cpu/serialization.cpp @@ -44,6 +44,10 @@ void CPU::serialize(serializer &s) { s.integer(status.hdma_pending); s.integer(status.hdma_mode); + s.integer(status.auto_joypad_active); + s.integer(status.auto_joypad_counter); + s.integer(status.auto_joypad_clock); + s.array(status.port); s.integer(status.wram_addr); @@ -73,14 +77,10 @@ void CPU::serialize(serializer &s) { s.integer(status.rddiv); s.integer(status.rdmpy); - s.integer(status.joy1l); - s.integer(status.joy1h); - s.integer(status.joy2l); - s.integer(status.joy2h); - s.integer(status.joy3l); - s.integer(status.joy3h); - s.integer(status.joy4l); - s.integer(status.joy4h); + s.integer(status.joy1); + s.integer(status.joy2); + s.integer(status.joy3); + s.integer(status.joy4); s.integer(alu.mpyctr); s.integer(alu.divctr); diff --git a/bsnes/snes/cpu/timing/joypad.cpp b/bsnes/snes/cpu/timing/joypad.cpp index 26c45f6a..145942e4 100755 --- a/bsnes/snes/cpu/timing/joypad.cpp +++ b/bsnes/snes/cpu/timing/joypad.cpp @@ -1,28 +1,28 @@ #ifdef CPU_CPP -void CPU::run_auto_joypad_poll() { - uint16 joy1 = 0, joy2 = 0, joy3 = 0, joy4 = 0; - for(unsigned i = 0; i < 16; i++) { - uint8 port0 = input.port_read(0); - uint8 port1 = input.port_read(1); +//called every 256 clocks; see CPU::add_clocks() +void CPU::step_auto_joypad_poll() { + if(vcounter() >= (ppu.overscan() == false ? 225 : 240) && status.auto_joypad_counter <= 16) { + if(status.auto_joypad_counter == 0) { + status.auto_joypad_active = true; + input.poll(); + } else if(status.auto_joypad_counter == 16) { + status.auto_joypad_active = false; + return; + } - joy1 |= (port0 & 1) ? (0x8000 >> i) : 0; - joy2 |= (port1 & 1) ? (0x8000 >> i) : 0; - joy3 |= (port0 & 2) ? (0x8000 >> i) : 0; - joy4 |= (port1 & 2) ? (0x8000 >> i) : 0; + status.auto_joypad_counter++; + + if(status.auto_joypad_poll) { + uint8 port0 = input.port_read(0); + uint8 port1 = input.port_read(1); + + status.joy1 = (status.joy1 << 1) | (bool)(port0 & 1); + status.joy2 = (status.joy2 << 1) | (bool)(port1 & 1); + status.joy3 = (status.joy3 << 1) | (bool)(port0 & 2); + status.joy4 = (status.joy4 << 1) | (bool)(port1 & 2); + } } - - status.joy1l = joy1 >> 0; - status.joy1h = joy1 >> 8; - - status.joy2l = joy2 >> 0; - status.joy2h = joy2 >> 8; - - status.joy3l = joy3 >> 0; - status.joy3h = joy3 >> 8; - - status.joy4l = joy4 >> 0; - status.joy4h = joy4 >> 8; } #endif diff --git a/bsnes/snes/cpu/timing/timing.cpp b/bsnes/snes/cpu/timing/timing.cpp index 39dd3a3a..b4b07aa8 100755 --- a/bsnes/snes/cpu/timing/timing.cpp +++ b/bsnes/snes/cpu/timing/timing.cpp @@ -20,6 +20,12 @@ void CPU::add_clocks(unsigned clocks) { step(clocks); + status.auto_joypad_clock += clocks; + if(status.auto_joypad_clock >= 256) { + status.auto_joypad_clock -= 256; + step_auto_joypad_poll(); + } + if(status.dram_refreshed == false && hcounter() >= status.dram_refresh_position) { status.dram_refreshed = true; add_clocks(40); @@ -41,6 +47,8 @@ void CPU::scanline() { //HDMA init triggers once every frame status.hdma_init_position = (cpu_version == 1 ? 12 + 8 - dma_counter() : 12 + dma_counter()); status.hdma_init_triggered = false; + + status.auto_joypad_counter = 0; } //DRAM refresh occurs once every scanline @@ -52,11 +60,6 @@ void CPU::scanline() { status.hdma_position = 1104; status.hdma_triggered = false; } - - if(status.auto_joypad_poll == true && vcounter() == (ppu.overscan() == false ? 227 : 242)) { - input.poll(); - run_auto_joypad_poll(); - } } void CPU::alu_edge() { @@ -190,6 +193,10 @@ void CPU::timing_reset() { status.dma_pending = false; status.hdma_pending = false; status.hdma_mode = 0; + + status.auto_joypad_active = false; + status.auto_joypad_counter = 0; + status.auto_joypad_clock = 0; } #endif diff --git a/bsnes/snes/cpu/timing/timing.hpp b/bsnes/snes/cpu/timing/timing.hpp index c185ea4c..6c225dab 100755 --- a/bsnes/snes/cpu/timing/timing.hpp +++ b/bsnes/snes/cpu/timing/timing.hpp @@ -21,4 +21,4 @@ alwaysinline bool nmi_test(); alwaysinline bool irq_test(); //joypad.cpp -void run_auto_joypad_poll(); +void step_auto_joypad_poll(); diff --git a/bsnes/snes/snes.hpp b/bsnes/snes/snes.hpp index 70521ecd..1da20b2f 100755 --- a/bsnes/snes/snes.hpp +++ b/bsnes/snes/snes.hpp @@ -1,8 +1,8 @@ namespace SNES { namespace Info { static const char Name[] = "bsnes"; - static const char Version[] = "073"; - static const unsigned SerializerVersion = 15; + static const char Version[] = "073.01"; + static const unsigned SerializerVersion = 16; } } diff --git a/bsnes/ui-qt/Makefile b/bsnes/ui-qt/Makefile deleted file mode 100755 index 2e61fa01..00000000 --- a/bsnes/ui-qt/Makefile +++ /dev/null @@ -1,94 +0,0 @@ -qtlibs := $(strip QtCore QtGui $(if $(findstring osx,$(platform)),QtOpenGL)) -include $(ui)/template/Makefile - -ui_objects := ui-main ui-base ui-cartridge ui-debugger ui-input ui-movie ui-settings ui-state ui-tools -ui_objects += ruby -ui_objects += $(if $(call streq,$(platform),win),resource) -link += $(qtlib) - -headers := $(call rwildcard,$(ui)/,%.hpp) -moc_headers := $(call rwildcard,nall/qt/,%.moc.hpp) $(call rwildcard,$(ui)/,%.moc.hpp) -moc_objects := $(foreach f,$(moc_headers),obj/$(notdir $(patsubst %.moc.hpp,%.moc,$f))) -qt_compile = $(call compile,-Iobj $(qtinc)) - -# platform -ifeq ($(platform),x) - ruby := video.glx video.xv video.qtraster video.sdl - ruby += audio.alsa audio.openal audio.oss audio.pulseaudio audio.pulseaudiosimple audio.ao - ruby += input.sdl input.x - - link += $(if $(findstring audio.openal,$(ruby)),-lopenal) -else ifeq ($(platform),osx) - ruby := video.qtopengl video.qtraster - ruby += audio.openal - ruby += input.carbon - - link += $(if $(findstring audio.openal,$(ruby)),-framework OpenAL) -else ifeq ($(platform),win) - ruby := video.direct3d video.wgl video.directdraw video.gdi video.qtraster - ruby += audio.directsound audio.xaudio2 - ruby += input.rawinput input.directinput - - link += $(if $(findstring audio.openal,$(ruby)),-lopenal32) -else - unknown_platform: help; -endif - -# ruby -rubyflags := $(if $(finstring .sdl,$(ruby)),`sdl-config --cflags`) -rubyflags += $(if $(findstring .qt,$(ruby)),$(qtinc)) - -link += $(if $(findstring .sdl,$(ruby)),`sdl-config --libs`) -link += $(if $(findstring video.direct3d,$(ruby)),-ld3d9) -link += $(if $(findstring video.directdraw,$(ruby)),-lddraw) -link += $(if $(findstring video.glx,$(ruby)),-lGL) -link += $(if $(findstring video.wgl,$(ruby)),-lopengl32) -link += $(if $(findstring video.xv,$(ruby)),-lXv) -link += $(if $(findstring audio.alsa,$(ruby)),-lasound) -link += $(if $(findstring audio.ao,$(ruby)),-lao) -link += $(if $(findstring audio.directsound,$(ruby)),-ldsound) -link += $(if $(findstring audio.pulseaudio,$(ruby)),-lpulse) -link += $(if $(findstring audio.pulseaudiosimple,$(ruby)),-lpulse-simple) -link += $(if $(findstring input.directinput,$(ruby)),-ldinput8 -ldxguid) -link += $(if $(findstring input.rawinput,$(ruby)),-ldinput8 -ldxguid) - -rubydef := $(foreach c,$(subst .,_,$(call strupper,$(ruby))),-D$c) - -# rules -objects := $(ui_objects) $(objects) - -# automatically run moc on all .moc.hpp (MOC header) files -%.moc: $<; $(moc) -i $< -o $@ - -# automatically generate %.moc build rules -__list = $(moc_headers) -$(foreach f,$(moc_objects), \ - $(eval __file = $(word 1,$(__list))) \ - $(eval __list = $(wordlist 2,$(words $(__list)),$(__list))) \ - $(eval $f: $(__file)) \ -) - -obj/ui-main.o: $(ui)/main.cpp $(headers) $(wildcard $(ui)/*.cpp) $(wildcard $(ui)/link/*.cpp) $(wildcard $(ui)/platform/*.cpp) $(wildcard $(ui)/utility/*.cpp); $(qt_compile) -obj/ui-base.o: $(ui)/base/base.cpp $(headers) $(wildcard $(ui)/base/*.cpp); $(qt_compile) -obj/ui-cartridge.o: $(ui)/cartridge/cartridge.cpp $(headers) $(wildcard $(ui)/cartridge/*.cpp); $(qt_compile) -obj/ui-debugger.o: $(ui)/debugger/debugger.cpp $(headers) $(call rwildcard,$(ui)/debugger/,%.cpp); $(qt_compile) -obj/ui-input.o: $(ui)/input/input.cpp $(headers) $(wildcard $(ui)/input/*.cpp); $(qt_compile) -obj/ui-movie.o: $(ui)/movie/movie.cpp $(headers) $(wildcard $(ui)/movie/*.cpp); $(qt_compile) -obj/ui-settings.o: $(ui)/settings/settings.cpp $(headers) $(wildcard $(ui)/settings/*.cpp); $(qt_compile) -obj/ui-state.o: $(ui)/state/state.cpp $(headers) $(wildcard $(ui)/state/*.cpp); $(qt_compile) -obj/ui-tools.o: $(ui)/tools/tools.cpp $(headers) $(wildcard $(ui)/tools/*.cpp); $(qt_compile) - -obj/ruby.o: ruby/ruby.cpp $(call rwildcard,ruby/*) - $(call compile,$(rubydef) $(rubyflags)) - -obj/resource.rcc: $(ui)/resource/resource.qrc $(ui)/data/* - $(rcc) $(ui)/resource/resource.qrc -o obj/resource.rcc - -obj/resource.o: $(ui)/resource/resource.rc - windres $(ui)/resource/resource.rc obj/resource.o - -# targets -ui_build: obj/resource.rcc $(moc_objects); -ui_clean: - -@$(call delete,obj/*.rcc) - -@$(call delete,obj/*.moc) diff --git a/bsnes/ui-qt/application/application.cpp b/bsnes/ui-qt/application/application.cpp deleted file mode 100755 index bcab44a4..00000000 --- a/bsnes/ui-qt/application/application.cpp +++ /dev/null @@ -1,184 +0,0 @@ -#include "application.moc" -VideoDisplay display; -Application application; - -#include "init.cpp" - -VideoDisplay::VideoDisplay() { - outputWidth = 0; - outputHeight = 0; - - cropLeft = 0; - cropTop = 0; - cropRight = 0; - cropBottom = 0; -} - -void Application::initPaths(const char *basename) { - char temp[PATH_MAX]; - - if(realpath(basename, temp)) { - //remove program name - strtr(temp, "\\", "/"); - for(signed i = strlen(temp) - 1; i >= 0; i--) { - if(temp[i] == '/') { - temp[i] = 0; - break; - } - } - - if(strend(temp, "/") == false) strcat(temp, "/"); - config().path.base = temp; - } else { - config().path.base = ""; - } - - if(userpath(temp)) { - strtr(temp, "\\", "/"); - if(strend(temp, "/") == false) strcat(temp, "/"); - config().path.user = temp; - } else { - config().path.user = ""; - } - - char cwd[PATH_MAX]; - config().path.startup = getcwd(cwd); -} - -void Application::locateFile(string &filename, bool createDataDirectory) { - //first, check if file exists in executable directory (single-user mode) - string temp = string() << config().path.base << filename; - - if(file::exists(temp) == false) { - //if not, use user data path (multi-user mode) - temp = config().path.user; - temp << ".bsnes"; - if(createDataDirectory) mkdir(temp, 0755); //ensure directory exists - temp << "/" << filename; - } - - filename = temp; -} - -int Application::main(int &argc, char **argv) { - app = new App(argc, argv); - #if !defined(PLATFORM_WIN) - app->setWindowIcon(QIcon(":/bsnes.png")); - #else - //Windows port uses 256x256 icon from resource file - CoInitialize(0); - utf8_args(argc, argv); - #endif - - initPaths(argv[0]); - locateFile(configFilename = "bsnes-qt.cfg", true); - locateFile(styleSheetFilename = "style.qss", false); - - string customStylesheet; - if(customStylesheet.readfile(styleSheetFilename) == true) { - app->setStyleSheet((const char*)customStylesheet); - } else { - app->setStyleSheet(defaultStylesheet); - } - - config().load(configFilename); - mapper().bind(); - init(); - SNES::system.init(&interface); - mainWindow->system_loadSpecial_superGameBoy->setVisible(SNES::supergameboy.opened()); - - if(argc == 2) { - //if valid file was specified on the command-line, attempt to load it now - cartridge.loadNormal(argv[1]); - } - - timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(run())); - timer->start(0); - app->exec(); - - //QbWindow::close() saves window geometry for next run - for(unsigned i = 0; i < windowList.size(); i++) { - windowList[i]->close(); - } - - cartridge.unload(); - config().save(configFilename); - return 0; -} - -void Application::run() { - if(terminate == true) { - timer->stop(); - app->quit(); - return; - } - - QApplication::processEvents(); - utility.updateSystemState(); - mapper().poll(); - - if(config().input.focusPolicy == Configuration::Input::FocusPolicyPauseEmulation) { - bool active = mainWindow->isActive(); - if(!autopause && !active) { - autopause = true; - audio.clear(); - } else if(autopause && active) { - autopause = false; - } - } else { - autopause = false; - } - - if(SNES::cartridge.loaded() && !pause && !autopause && (!debug || debugrun)) { - SNES::system.run(); - #if defined(DEBUGGER) - if(SNES::debugger.break_event != SNES::Debugger::BreakEvent::None) { - debug = true; - debugrun = false; - debugger->synchronize(); - debugger->event(); - SNES::debugger.break_event = SNES::Debugger::BreakEvent::None; - } - #endif - } else { - usleep(20 * 1000); - } - - clock_t currentTime = clock(); - autosaveTime += currentTime - clockTime; - screensaverTime += currentTime - clockTime; - clockTime = currentTime; - - if(autosaveTime >= CLOCKS_PER_SEC * 60) { - //auto-save RAM once per minute in case of emulator crash - autosaveTime = 0; - if(config().system.autoSaveMemory == true) cartridge.saveMemory(); - } - - if(screensaverTime >= CLOCKS_PER_SEC * 30) { - //supress screen saver every 30 seconds so it will not trigger during gameplay - screensaverTime = 0; - supressScreenSaver(); - } -} - -Application::Application() : timer(0) { - terminate = false; - power = false; - pause = false; - autopause = false; - debug = false; - debugrun = false; - - clockTime = clock(); - autosaveTime = 0; - screensaverTime = 0; -} - -Application::~Application() { - delete timer; - - //deleting (QApplication)app will segfault the application upon exit - //delete app; -} diff --git a/bsnes/ui-qt/application/application.moc.hpp b/bsnes/ui-qt/application/application.moc.hpp deleted file mode 100755 index aeae287a..00000000 --- a/bsnes/ui-qt/application/application.moc.hpp +++ /dev/null @@ -1,57 +0,0 @@ -struct VideoDisplay { - unsigned outputWidth; - unsigned outputHeight; - - unsigned cropLeft; - unsigned cropTop; - unsigned cropRight; - unsigned cropBottom; - - VideoDisplay(); -}; - -class Application : public QObject { - Q_OBJECT - -public: - class App : public QApplication { - public: - #if defined(PLATFORM_WIN) - bool winEventFilter(MSG *msg, long *result); - #endif - - App(int &argc, char **argv) : QApplication(argc, argv) {} - } *app; - - QTimer *timer; - - bool terminate; //set to true to terminate main() loop and exit emulator - bool power; - bool pause; - bool autopause; - bool debug; //debugger sets this to true when entered to suspend emulation - bool debugrun; //debugger sets this to true to run emulation to a debug event - - clock_t clockTime; - clock_t autosaveTime; - clock_t screensaverTime; - - string configFilename; - string styleSheetFilename; - - array windowList; - - int main(int &argc, char **argv); - void locateFile(string &filename, bool createDataDirectory = false); - void initPaths(const char *basename); - void init(); - - Application(); - ~Application(); - -public slots: - void run(); -}; - -extern VideoDisplay display; -extern Application application; diff --git a/bsnes/ui-qt/application/init.cpp b/bsnes/ui-qt/application/init.cpp deleted file mode 100755 index db2d041d..00000000 --- a/bsnes/ui-qt/application/init.cpp +++ /dev/null @@ -1,108 +0,0 @@ -void Application::init() { - if(config().system.crashedOnLastRun == true) { - //emulator crashed on last run, disable all drivers - QMessageBox::warning(0, "bsnes Crash Notification", string() << - "

Warning:
bsnes crashed while attempting to initialize device " - "drivers the last time it was run.

" - "

To prevent this from occurring again, all drivers have been disabled. Please " - "go to Settings->Configuration->Advanced and choose new driver settings, and then " - "restart the emulator for the changes to take effect. Video, audio and input " - "will not work until you do this!

" - "

Settings that caused failure on last run:
" - << "Video driver: " << config().system.video << "
" - << "Audio driver: " << config().system.audio << "
" - << "Input driver: " << config().system.input << "

" - ); - - config().system.video = "None"; - config().system.audio = "None"; - config().system.input = "None"; - } - - if(config().system.video == "") config().system.video = video.default_driver(); - if(config().system.audio == "") config().system.audio = audio.default_driver(); - if(config().system.input == "") config().system.input = input.default_driver(); - - mainWindow = new MainWindow; - loaderWindow = new LoaderWindow; - htmlViewerWindow = new HtmlViewerWindow; - aboutWindow = new AboutWindow; - fileBrowser = new FileBrowser; - stateSelectWindow = new StateSelectWindow; - - //window must be onscreen and visible before initializing video interface - utility.updateSystemState(); - utility.resizeMainWindow(); - utility.updateFullscreenState(); - QApplication::processEvents(); - - #if defined(DEBUGGER) - debugger = new Debugger; - #endif - settingsWindow = new SettingsWindow; - toolsWindow = new ToolsWindow; - - //if emulator crashes while initializing drivers, next run will disable them all. - //this will allow user to choose different driver settings. - config().system.crashedOnLastRun = true; - config().save(configFilename); - - video.driver(config().system.video); - video.set(Video::Handle, (uintptr_t)mainWindow->canvas->winId()); - video.set("QWidget", (QWidget*)mainWindow->canvas); - if(video.init() == false) { - QMessageBox::warning(0, "bsnes", string() << - "

Warning: " << config().system.video << " video driver failed to initialize. " - "Video driver has been disabled.

" - "

Please go to Settings->Configuration->Advanced and choose a different driver, and " - "then restart the emulator for the changes to take effect.

" - ); - video.driver("None"); - video.init(); - } - - audio.driver(config().system.audio); - audio.set(Audio::Handle, (uintptr_t)mainWindow->canvas->winId()); - audio.set(Audio::Frequency, config().audio.outputFrequency); - audio.set(Audio::Latency, config().audio.latency); - audio.set(Audio::Volume, config().audio.volume); - if(audio.init() == false) { - QMessageBox::warning(0, "bsnes", string() << - "

Warning: " << config().system.audio << " audio driver failed to initialize. " - "Audio driver has been disabled.

" - "

Please go to Settings->Configuration->Advanced and choose a different driver, and " - "then restart the emulator for the changes to take effect.

" - ); - audio.driver("None"); - audio.init(); - } - - input.driver(config().system.input); - input.set("Handle", (uintptr_t)mainWindow->canvas->winId()); - if(input.init() == false) { - QMessageBox::warning(0, "bsnes", string() << - "

Warning: " << config().system.input << " input driver failed to initialize. " - "Input driver has been disabled.

" - "

Please go to Settings->Configuration->Advanced and choose a different driver, and " - "then restart the emulator for the changes to take effect.

" - ); - input.driver("None"); - input.init(); - } - - //didn't crash, note this in the config file now in case a different kind of crash occurs later - config().system.crashedOnLastRun = false; - config().save(configFilename); - - //hide pixel shader settings if driver does not support them - videoSettingsWindow->synchronizePixelShaderSettings(); - - utility.resizeMainWindow(); - utility.updateAvSync(); - utility.updateColorFilter(); - utility.updatePixelShader(); - utility.updateHardwareFilter(); - utility.updateSoftwareFilter(); - utility.updateEmulationSpeed(); - utility.updateControllers(); -} diff --git a/bsnes/ui-qt/base/about.cpp b/bsnes/ui-qt/base/about.cpp deleted file mode 100755 index e84380a1..00000000 --- a/bsnes/ui-qt/base/about.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "about.moc" -AboutWindow *aboutWindow; - -AboutWindow::AboutWindow() { - setObjectName("about-window"); - setWindowTitle("About"); - setGeometryString(&config().geometry.aboutWindow); - application.windowList.append(this); - - #if defined(DEBUGGER) - setStyleSheet("background: #c0c080"); - #elif defined(PROFILE_ACCURACY) - setStyleSheet("background: #c08080"); - #elif defined(PROFILE_COMPATIBILITY) - setStyleSheet("background: #8080c0"); - #elif defined(PROFILE_PERFORMANCE) - setStyleSheet("background: #80c080"); - #endif - - layout = new QVBoxLayout; - layout->setSizeConstraint(QLayout::SetFixedSize); - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - logo = new Logo; - logo->setFixedSize(600, 106); - layout->addWidget(logo); - - info = new QLabel(string() << - "" - "" - "" - "" - "
Version: " << SNES::Info::Version << "Author: byuuHomepage: http://byuu.org
" - ); - layout->addWidget(info); -} - -void AboutWindow::Logo::paintEvent(QPaintEvent*) { - QPainter painter(this); - QPixmap pixmap(":/logo.png"); - painter.drawPixmap(0, 0, pixmap); -} diff --git a/bsnes/ui-qt/base/about.moc.hpp b/bsnes/ui-qt/base/about.moc.hpp deleted file mode 100755 index f0778c15..00000000 --- a/bsnes/ui-qt/base/about.moc.hpp +++ /dev/null @@ -1,14 +0,0 @@ -class AboutWindow : public Window { - Q_OBJECT - -public: - QVBoxLayout *layout; - struct Logo : public QWidget { - void paintEvent(QPaintEvent*); - } *logo; - QLabel *info; - - AboutWindow(); -}; - -extern AboutWindow *aboutWindow; diff --git a/bsnes/ui-qt/base/base.cpp b/bsnes/ui-qt/base/base.cpp deleted file mode 100755 index 69e9152c..00000000 --- a/bsnes/ui-qt/base/base.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "../ui-base.hpp" - -#include "about.cpp" -#include "filebrowser.cpp" -#include "htmlviewer.cpp" -#include "loader.cpp" -#include "main.cpp" -#include "stateselect.cpp" diff --git a/bsnes/ui-qt/base/filebrowser.cpp b/bsnes/ui-qt/base/filebrowser.cpp deleted file mode 100755 index 3c999087..00000000 --- a/bsnes/ui-qt/base/filebrowser.cpp +++ /dev/null @@ -1,242 +0,0 @@ -#include "filebrowser.moc" -FileBrowser *fileBrowser; - -void FileBrowser::chooseFile() { - if(config().diskBrowser.useCommonDialogs == true) { - audio.clear(); - QString qfilename = QFileDialog::getOpenFileName(0, - windowTitle(), fileSystemModel->rootPath(), "All Files (*)" - ); - string filename = qfilename.toUtf8().constData(); - if(filename != "") onAccept(filename); - return; - } - - showLoad(); -} - -void FileBrowser::chooseFolder() { - if(config().diskBrowser.useCommonDialogs == true) { - audio.clear(); - QString qfilename = QFileDialog::getExistingDirectory(0, - windowTitle(), config().path.current.folder, - QFileDialog::ShowDirsOnly - ); - string filename = qfilename.toUtf8().constData(); - if(filename != "") onAccept(filename); - return; - } - - previewFrame->hide(); - showFolder(); -} - -void FileBrowser::loadCartridge(CartridgeMode mode, signed filterIndex) { - cartridgeMode = mode; - onChange = { &FileBrowser::onChangeCartridge, this }; - onActivate = { &FileBrowser::onAcceptCartridge, this }; - onAccept = { &FileBrowser::onAcceptCartridge, this }; - - string defaultPath = config().path.rom == "" ? config().path.current.cartridge : config().path.rom; - - if(config().diskBrowser.useCommonDialogs == true) { - audio.clear(); - QString qfilename = QFileDialog::getOpenFileName(0, - windowTitle(), defaultPath, string( - "SNES cartridges (*.sfc *.bs *.st *.gb *.sgb *.gbc", reader.extensionList, reader.compressionList, ");;", - "All files (*)" - ) - ); - string filename = qfilename.toUtf8().constData(); - if(filename != "") onAccept(filename); - config().path.current.cartridge = nall::dir(filename); - return; - } - - setPath(defaultPath); - setNameFilters(string() - << "SNES cartridges (*.sfc" << reader.extensionList << reader.compressionList << ")\n" - << "BS-X cartridges (*.bs" << reader.compressionList << ")\n" - << "Sufami Turbo cartridges (*.st" << reader.compressionList << ")\n" - << "Game Boy cartridges (*.gb *.sgb *.gbc" << reader.compressionList << ")\n" - << "All files (*)" - ); - previewFrame->show(); - filterBox->setCurrentIndex(filterIndex == -1 ? config().path.current.filter : filterIndex); - showLoad(); -} - -void FileBrowser::change(const string &path) { - if(onChange) onChange(path); -} - -void FileBrowser::activate(const string &path) { - if(onActivate) onActivate(path); -} - -void FileBrowser::accept(const string &path) { - if(onAccept) onAccept(path); -} - -void FileBrowser::toggleApplyPatch() { - config().file.applyPatches = previewApplyPatch->isChecked(); -} - -FileBrowser::FileBrowser() { - setObjectName("file-browser"); - resize(800, 480); - setGeometryString(&config().geometry.fileBrowser); - application.windowList.append(this); - - previewLayout = new QVBoxLayout; - previewLayout->setAlignment(Qt::AlignTop); - previewFrame->setLayout(previewLayout); - - previewInfo = new QLabel; - previewLayout->addWidget(previewInfo); - - previewImage = new QWidget; - previewImage->setFixedSize(256, 239); - previewLayout->addWidget(previewImage); - - previewSpacer = new QWidget; - previewSpacer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - previewLayout->addWidget(previewSpacer); - - previewApplyPatch = new QCheckBox("Apply Patch"); - previewApplyPatch->setVisible(false); - previewApplyPatch->setChecked(config().file.applyPatches); - previewLayout->addWidget(previewApplyPatch); - - connect(this, SIGNAL(changed(const string&)), this, SLOT(change(const string&))); - connect(this, SIGNAL(activated(const string&)), this, SLOT(activate(const string&))); - connect(this, SIGNAL(accepted(const string&)), this, SLOT(accept(const string&))); - connect(previewApplyPatch, SIGNAL(stateChanged(int)), this, SLOT(toggleApplyPatch())); -} - -// - -string FileBrowser::resolveFilename(const string &path) { - if(QDir(path).exists()) { - string filter; - if(striend(path, ".sfc")) filter = "*.sfc"; - if(striend(path, ".bs" )) filter = "*.bs"; - if(striend(path, ".st" )) filter = "*.st"; - if(striend(path, ".gb" )) filter = "*.gb"; - if(striend(path, ".sgb")) filter = "*.sgb"; - if(striend(path, ".gbc")) filter = "*.gbc"; - if(filter == "") return ""; - - QDir directory(path); - directory.setNameFilters(QStringList() << filter); - QStringList list = directory.entryList(QDir::Files | QDir::NoDotAndDotDot); - if(list.count() == 1) return string() << path << "/" << list[0].toUtf8().constData(); - return ""; - } else { - return path; - } -} - -void FileBrowser::onChangeCartridge(const string &path) { - string filename; - if(QDir(path).exists()) filename = resolveFilename(path); - else filename = path; - - string info; - string image(nall::basename(filename), ".png"); - string patch(filepath(nall::basename(filename), config().path.patch), ".ups"); - - if(file::exists(filename)) { - if(striend(filename, ".sfc")) { - Cartridge::Information cartinfo; - if(cartridge.information(filename, cartinfo)) { - info << ""; - info << ""; - info << ""; - info << ""; - info << "" : info << "None"; - info << "
Title: " << cartinfo.name << "
Region: " << cartinfo.region << "
ROM: " << cartinfo.romSize * 8 / 1024 / 1024 << "mbit
RAM: "; - cartinfo.ramSize ? info << cartinfo.ramSize * 8 / 1024 << "kbit
"; - } - } else if(striend(filename, ".st")) { - unsigned size = file::size(filename); - info << ""; - info << ""; - info << "
ROM: " << size * 8 / 1024 / 1024 << "mbit
"; - } - } - - if(info == "") info = "No preview available"; - previewInfo->setText(info); - previewImage->setStyleSheet(string() << "background: url('" << image << "') center left no-repeat;"); - previewApplyPatch->setVisible(file::exists(patch)); -} - -void FileBrowser::onAcceptCartridge(const string &path) { - string filename; - if(QDir(path).exists()) { - filename = resolveFilename(path); - } else { - filename = path; - } - - if(file::exists(filename)) { - close(); - config().path.current.cartridge = fileSystemModel->rootPath().toUtf8().constData(); - - if(cartridgeMode == LoadDirect) { - config().path.current.filter = filterBox->currentIndex(); - string filter = filterBox->currentText().toUtf8().constData(); - - if(0); - //file extension detection - else if(striend(filename, ".sfc")) acceptNormal(filename); - else if(striend(filename, ".bs")) acceptBsx(filename); - else if(striend(filename, ".st")) acceptSufamiTurbo(filename); - else if(striend(filename, ".gb")) acceptSuperGameBoy(filename); - else if(striend(filename, ".sgb")) acceptSuperGameBoy(filename); - else if(striend(filename, ".gbc")) acceptSuperGameBoy(filename); - //filter detection - else if(strbegin(filter, "SNES cartridges")) acceptNormal(filename); - else if(strbegin(filter, "BS-X cartridges")) acceptBsx(filename); - else if(strbegin(filter, "Sufami Turbo cartridges")) acceptSufamiTurbo(filename); - else if(strbegin(filter, "Game Boy cartridges")) acceptSuperGameBoy(filename); - //fallback behavior - else acceptNormal(filename); - } else if(cartridgeMode == LoadBase) { - loaderWindow->selectBaseCartridge(filename); - } else if(cartridgeMode == LoadSlot1) { - loaderWindow->selectSlot1Cartridge(filename); - } else if(cartridgeMode == LoadSlot2) { - loaderWindow->selectSlot2Cartridge(filename); - } - } -} - -void FileBrowser::acceptNormal(const string &filename) { - cartridge.loadNormal(filename); -} - -void FileBrowser::acceptBsx(const string &filename) { - if(config().path.bsx == "") { - loaderWindow->loadBsxCartridge("", filename); - } else { - cartridge.loadBsx(config().path.bsx, filename); - } -} - -void FileBrowser::acceptSufamiTurbo(const string &filename) { - if(config().path.st == "") { - loaderWindow->loadSufamiTurboCartridge("", filename, ""); - } else { - cartridge.loadSufamiTurbo(config().path.st, filename, ""); - } -} - -void FileBrowser::acceptSuperGameBoy(const string &filename) { - if(config().path.sgb == "") { - loaderWindow->loadSuperGameBoyCartridge("", filename); - } else { - cartridge.loadSuperGameBoy(config().path.sgb, filename); - } -} diff --git a/bsnes/ui-qt/base/filebrowser.moc.hpp b/bsnes/ui-qt/base/filebrowser.moc.hpp deleted file mode 100755 index 1bec80c2..00000000 --- a/bsnes/ui-qt/base/filebrowser.moc.hpp +++ /dev/null @@ -1,39 +0,0 @@ -class FileBrowser : public FileDialog { - Q_OBJECT - -public: - function onChange; - function onActivate; - function onAccept; - - void chooseFile(); - void chooseFolder(); - enum CartridgeMode { LoadDirect, LoadBase, LoadSlot1, LoadSlot2 } cartridgeMode; - void loadCartridge(CartridgeMode, signed = -1); - - FileBrowser(); - -private slots: - void change(const string&); - void activate(const string&); - void accept(const string&); - void toggleApplyPatch(); - -private: - QVBoxLayout *previewLayout; - QLabel *previewInfo; - QWidget *previewImage; - QWidget *previewSpacer; - QCheckBox *previewApplyPatch; - - string resolveFilename(const string&); - void onChangeCartridge(const string&); - void onAcceptCartridge(const string&); - - void acceptNormal(const string &filename); - void acceptBsx(const string &filename); - void acceptSufamiTurbo(const string &filename); - void acceptSuperGameBoy(const string &filename); -}; - -extern FileBrowser *fileBrowser; diff --git a/bsnes/ui-qt/base/htmlviewer.cpp b/bsnes/ui-qt/base/htmlviewer.cpp deleted file mode 100755 index 71cdf111..00000000 --- a/bsnes/ui-qt/base/htmlviewer.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "htmlviewer.moc" -HtmlViewerWindow *htmlViewerWindow; - -HtmlViewerWindow::HtmlViewerWindow() { - setObjectName("html-window"); - resize(560, 480); - setGeometryString(&config().geometry.htmlViewerWindow); - application.windowList.append(this); - - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(0); - setLayout(layout); - - document = new QTextBrowser; - layout->addWidget(document); -} - -void HtmlViewerWindow::show(const char *title, const char *htmlData) { - document->setHtml(string() << htmlData); - setWindowTitle(title); - Window::show(); -} diff --git a/bsnes/ui-qt/base/htmlviewer.moc.hpp b/bsnes/ui-qt/base/htmlviewer.moc.hpp deleted file mode 100755 index dbab4dca..00000000 --- a/bsnes/ui-qt/base/htmlviewer.moc.hpp +++ /dev/null @@ -1,14 +0,0 @@ -class HtmlViewerWindow : public Window { - Q_OBJECT - -public: - QVBoxLayout *layout; - QTextBrowser *document; - - void show(const char *title, const char *htmlData); - HtmlViewerWindow(); - -public slots: -}; - -extern HtmlViewerWindow *htmlViewerWindow; diff --git a/bsnes/ui-qt/base/loader.cpp b/bsnes/ui-qt/base/loader.cpp deleted file mode 100755 index 4553b06f..00000000 --- a/bsnes/ui-qt/base/loader.cpp +++ /dev/null @@ -1,236 +0,0 @@ -#include "loader.moc" -LoaderWindow *loaderWindow; - -LoaderWindow::LoaderWindow() { - setObjectName("loader-window"); - setMinimumWidth(520); - setGeometryString(&config().geometry.loaderWindow); - application.windowList.append(this); - - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - layout->setAlignment(Qt::AlignTop); - setLayout(layout); - - grid = new QGridLayout; - layout->addLayout(grid); - - baseLabel = new QLabel("Base cartridge:"); - grid->addWidget(baseLabel, 0, 0); - - baseFile = new QLineEdit; - baseFile->setReadOnly(true); - grid->addWidget(baseFile, 0, 1); - - baseBrowse = new QPushButton("Browse ..."); - grid->addWidget(baseBrowse, 0, 2); - - baseClear = new QPushButton("Clear"); - grid->addWidget(baseClear, 0, 3); - - slot1Label = new QLabel("Slot A cartridge:"); - grid->addWidget(slot1Label, 1, 0); - - slot1File = new QLineEdit; - slot1File->setReadOnly(true); - grid->addWidget(slot1File, 1, 1); - - slot1Browse = new QPushButton("Browse ..."); - grid->addWidget(slot1Browse, 1, 2); - - slot1Clear = new QPushButton("Clear"); - grid->addWidget(slot1Clear, 1, 3); - - slot2Label = new QLabel("Slot B cartridge:"); - grid->addWidget(slot2Label, 2, 0); - - slot2File = new QLineEdit; - slot2File->setReadOnly(true); - grid->addWidget(slot2File, 2, 1); - - slot2Browse = new QPushButton("Browse ..."); - grid->addWidget(slot2Browse, 2, 2); - - slot2Clear = new QPushButton("Clear"); - grid->addWidget(slot2Clear, 2, 3); - - load = new QPushButton("Load"); - grid->addWidget(load, 3, 2); - - cancel = new QPushButton("Cancel"); - grid->addWidget(cancel, 3, 3); - - connect(baseBrowse, SIGNAL(released()), this, SLOT(selectBaseCartridge())); - connect(baseClear, SIGNAL(released()), this, SLOT(clearBaseCartridge())); - connect(slot1Browse, SIGNAL(released()), this, SLOT(selectSlot1Cartridge())); - connect(slot1Clear, SIGNAL(released()), this, SLOT(clearSlot1Cartridge())); - connect(slot2Browse, SIGNAL(released()), this, SLOT(selectSlot2Cartridge())); - connect(slot2Clear, SIGNAL(released()), this, SLOT(clearSlot2Cartridge())); - connect(load, SIGNAL(released()), this, SLOT(onLoad())); - connect(cancel, SIGNAL(released()), this, SLOT(close())); -} - -void LoaderWindow::syncUi() { - //only allow load when a base file is specified ... - load->setEnabled(baseFile->text().length() > 0); -} - -void LoaderWindow::loadBsxSlottedCartridge(const char *filebase, const char *fileSlot1) { - hide(); - baseLabel->show(), baseFile->show(), baseBrowse->show(), baseClear->show(); - slot1Label->show(), slot1File->show(), slot1Browse->show(), slot1Clear->show(); - slot2Label->hide(), slot2File->hide(), slot2Browse->hide(), slot2Clear->hide(); - - slot1Label->setText("Slot cartridge:"); - - baseFile->setText(filebase); - slot1File->setText(fileSlot1); - - syncUi(); - mode = SNES::Cartridge::Mode::BsxSlotted; - showWindow("Load BS-X Slotted Cartridge"); -} - -void LoaderWindow::loadBsxCartridge(const char *fileBase, const char *fileSlot1) { - hide(); - baseLabel->show(), baseFile->show(), baseBrowse->show(), baseClear->show(); - slot1Label->show(), slot1File->show(), slot1Browse->show(), slot1Clear->show(); - slot2Label->hide(), slot2File->hide(), slot2Browse->hide(), slot2Clear->hide(); - - slot1Label->setText("Slot cartridge:"); - - baseFile->setText(fileBase); - slot1File->setText(fileSlot1); - - syncUi(); - mode = SNES::Cartridge::Mode::Bsx; - showWindow("Load BS-X Cartridge"); -} - -void LoaderWindow::loadSufamiTurboCartridge(const char *fileBase, const char *fileSlot1, const char *fileSlot2) { - hide(); - baseLabel->show(), baseFile->show(), baseBrowse->show(), baseClear->show(); - slot1Label->show(), slot1File->show(), slot1Browse->show(), slot1Clear->show(); - slot2Label->show(), slot2File->show(), slot2Browse->show(), slot2Clear->show(); - - slot1Label->setText("Slot A cartridge:"); - slot2Label->setText("Slot B cartridge:"); - - baseFile->setText(fileBase); - slot1File->setText(fileSlot1); - slot2File->setText(fileSlot2); - - syncUi(); - mode = SNES::Cartridge::Mode::SufamiTurbo; - showWindow("Load Sufami Turbo Cartridge"); -} - -void LoaderWindow::loadSuperGameBoyCartridge(const char *fileBase, const char *fileSlot1) { - hide(); - baseLabel->show(), baseFile->show(), baseBrowse->show(), baseClear->show(); - slot1Label->show(), slot1File->show(), slot1Browse->show(), slot1Clear->show(); - slot2Label->hide(), slot2File->hide(), slot2Browse->hide(), slot2Clear->hide(); - - slot1Label->setText("Game Boy cartridge:"); - - baseFile->setText(fileBase); - slot1File->setText(fileSlot1); - - syncUi(); - mode = SNES::Cartridge::Mode::SuperGameBoy; - showWindow("Load Super Game Boy Cartridge"); -} - -void LoaderWindow::showWindow(const char *title) { - setWindowTitle(title); - show(); - shrink(); - load->setFocus(); -} - -void LoaderWindow::selectBaseCartridge(const char *filename) { - baseFile->setText(string() << filename); - syncUi(); -} - -void LoaderWindow::selectSlot1Cartridge(const char *filename) { - slot1File->setText(string() << filename); - syncUi(); -} - -void LoaderWindow::selectSlot2Cartridge(const char *filename) { - slot2File->setText(string() << filename); - syncUi(); -} - -void LoaderWindow::selectBaseCartridge() { - fileBrowser->setWindowTitle("Load Base Cartridge"); - fileBrowser->loadCartridge(FileBrowser::LoadBase, 0); -} - -void LoaderWindow::clearBaseCartridge() { - baseFile->setText(""); - syncUi(); -} - -void LoaderWindow::selectSlot1Cartridge() { - switch(mode) { - case SNES::Cartridge::Mode::Bsx: - case SNES::Cartridge::Mode::BsxSlotted: - fileBrowser->setWindowTitle("Load BS-X Cartridge"); - fileBrowser->loadCartridge(FileBrowser::LoadSlot1, 1); - break; - case SNES::Cartridge::Mode::SufamiTurbo: - fileBrowser->setWindowTitle("Load Sufami Turbo Cartridge A"); - fileBrowser->loadCartridge(FileBrowser::LoadSlot1, 2); - break; - case SNES::Cartridge::Mode::SuperGameBoy: - fileBrowser->setWindowTitle("Load Game Boy Cartridge"); - fileBrowser->loadCartridge(FileBrowser::LoadSlot1, 3); - break; - } -} - -void LoaderWindow::clearSlot1Cartridge() { - slot1File->setText(""); - syncUi(); -} - -void LoaderWindow::selectSlot2Cartridge() { - fileBrowser->setWindowTitle("Load Sufami Turbo Cartridge B"); - fileBrowser->loadCartridge(FileBrowser::LoadSlot2, 2); -} - -void LoaderWindow::clearSlot2Cartridge() { - slot2File->setText(""); - syncUi(); -} - -void LoaderWindow::onLoad() { - hide(); - string base = baseFile->text().toUtf8().data(); - string slot1 = slot1File->text().toUtf8().data(); - string slot2 = slot2File->text().toUtf8().data(); - - switch(mode) { - case SNES::Cartridge::Mode::BsxSlotted: { - cartridge.loadBsxSlotted(base, slot1); - } break; - - case SNES::Cartridge::Mode::Bsx: { - config().path.bsx = base; - cartridge.loadBsx(base, slot1); - } break; - - case SNES::Cartridge::Mode::SufamiTurbo: { - config().path.st = base; - cartridge.loadSufamiTurbo(base, slot1, slot2); - } break; - - case SNES::Cartridge::Mode::SuperGameBoy: { - config().path.sgb = base; - cartridge.loadSuperGameBoy(base, slot1); - } break; - } -} diff --git a/bsnes/ui-qt/base/loader.moc.hpp b/bsnes/ui-qt/base/loader.moc.hpp deleted file mode 100755 index 946587a2..00000000 --- a/bsnes/ui-qt/base/loader.moc.hpp +++ /dev/null @@ -1,47 +0,0 @@ -class LoaderWindow : public Window { - Q_OBJECT - -public: - QVBoxLayout *layout; - QGridLayout *grid; - QLabel *baseLabel; - QLineEdit *baseFile; - QPushButton *baseBrowse; - QPushButton *baseClear; - QLabel *slot1Label; - QLineEdit *slot1File; - QPushButton *slot1Browse; - QPushButton *slot1Clear; - QLabel *slot2Label; - QLineEdit *slot2File; - QPushButton *slot2Browse; - QPushButton *slot2Clear; - QPushButton *load; - QPushButton *cancel; - - void syncUi(); - void loadBsxSlottedCartridge(const char*, const char*); - void loadBsxCartridge(const char*, const char*); - void loadSufamiTurboCartridge(const char*, const char*, const char*); - void loadSuperGameBoyCartridge(const char*, const char*); - LoaderWindow(); - - void selectBaseCartridge(const char*); - void selectSlot1Cartridge(const char*); - void selectSlot2Cartridge(const char*); - -public slots: - void selectBaseCartridge(); - void clearBaseCartridge(); - void selectSlot1Cartridge(); - void clearSlot1Cartridge(); - void selectSlot2Cartridge(); - void clearSlot2Cartridge(); - void onLoad(); - -private: - SNES::Cartridge::Mode mode; - void showWindow(const char *title); -}; - -extern LoaderWindow *loaderWindow; diff --git a/bsnes/ui-qt/base/main.cpp b/bsnes/ui-qt/base/main.cpp deleted file mode 100755 index a6963578..00000000 --- a/bsnes/ui-qt/base/main.cpp +++ /dev/null @@ -1,690 +0,0 @@ -#include "main.moc" -MainWindow *mainWindow; - -MainWindow::MainWindow() { - setObjectName("main-window"); - setWindowTitle(string() << SNES::Info::Name << " v" << SNES::Info::Version); - setCloseOnEscape(false); - setGeometryString(&config().geometry.mainWindow); - application.windowList.append(this); - - //menu bar - #if defined(PLATFORM_OSX) - menuBar = new QMenuBar(0); - #else - menuBar = new QMenuBar; - #endif - - system = menuBar->addMenu("&System"); - - system_load = system->addAction("Load &Cartridge ..."); - - system_loadSpecial = system->addMenu("Load &Special"); - - system_loadSpecial_bsxSlotted = system_loadSpecial->addAction("Load BS-X &Slotted Cartridge ..."); - - system_loadSpecial_bsx = system_loadSpecial->addAction("Load &BS-X Cartridge ..."); - - system_loadSpecial_sufamiTurbo = system_loadSpecial->addAction("Load Sufami &Turbo Cartridge ..."); - - system_loadSpecial_superGameBoy = system_loadSpecial->addAction("Load Super &Game Boy Cartridge ..."); - - system->addSeparator(); - - system->addAction(system_power = new CheckAction("&Power", 0)); - - system_reset = system->addAction("&Reset"); - - system->addSeparator(); - - system_port1 = system->addMenu("Controller Port &1"); - system_port1->addAction(system_port1_none = new RadioAction("&None", 0)); - system_port1->addAction(system_port1_gamepad = new RadioAction("&Gamepad", 0)); - system_port1->addAction(system_port1_asciipad = new RadioAction("&asciiPad", 0)); - system_port1->addAction(system_port1_multitap = new RadioAction("&Multitap", 0)); - system_port1->addAction(system_port1_mouse = new RadioAction("&Mouse", 0)); - - system_port2 = system->addMenu("Controller Port &2"); - system_port2->addAction(system_port2_none = new RadioAction("&None", 0)); - system_port2->addAction(system_port2_gamepad = new RadioAction("&Gamepad", 0)); - system_port2->addAction(system_port2_asciipad = new RadioAction("&asciiPad", 0)); - system_port2->addAction(system_port2_multitap = new RadioAction("&Multitap", 0)); - system_port2->addAction(system_port2_mouse = new RadioAction("&Mouse", 0)); - system_port2->addAction(system_port2_superscope = new RadioAction("&Super Scope", 0)); - system_port2->addAction(system_port2_justifier = new RadioAction("&Justifier", 0)); - system_port2->addAction(system_port2_justifiers = new RadioAction("Two &Justifiers", 0)); - - #if !defined(PLATFORM_OSX) - system->addSeparator(); - #endif - - system_exit = system->addAction("E&xit"); - system_exit->setMenuRole(QAction::QuitRole); - - settings = menuBar->addMenu("S&ettings"); - - settings_videoMode = settings->addMenu("Video &Mode"); - - settings_videoMode->addAction(settings_videoMode_1x = new RadioAction("Scale &1x", 0)); - - settings_videoMode->addAction(settings_videoMode_2x = new RadioAction("Scale &2x", 0)); - - settings_videoMode->addAction(settings_videoMode_3x = new RadioAction("Scale &3x", 0)); - - settings_videoMode->addAction(settings_videoMode_4x = new RadioAction("Scale &4x", 0)); - - settings_videoMode->addAction(settings_videoMode_5x = new RadioAction("Scale &5x", 0)); - - settings_videoMode->addAction(settings_videoMode_max_normal = new RadioAction("Scale Max - &Normal", 0)); - - settings_videoMode->addAction(settings_videoMode_max_wide = new RadioAction("Scale Max - &Wide", 0)); - - settings_videoMode->addAction(settings_videoMode_max_wideZoom = new RadioAction("Scale Max - Wide &Zoom", 0)); - - settings_videoMode->addSeparator(); - - settings_videoMode->addAction(settings_videoMode_correctAspectRatio = new CheckAction("Correct &Aspect Ratio", 0)); - - settings_videoMode->addSeparator(); - - settings_videoMode->addAction(settings_videoMode_ntsc = new RadioAction("&NTSC", 0)); - settings_videoMode->addAction(settings_videoMode_pal = new RadioAction("&PAL", 0)); - - if(filter.opened()) { - settings_videoFilter = settings->addMenu("Video &Filter"); - - settings_videoFilter_configure = settings_videoFilter->addAction("&Configure Active Filter ..."); - settings_videoFilter->addSeparator(); - - settings_videoFilter->addAction(settings_videoFilter_none = new RadioAction("&None", 0)); - settings_videoFilter_list.append(settings_videoFilter_none); - - lstring filterlist; - filterlist.split(";", filter.dl_supported()); - for(unsigned i = 0; i < filterlist.size(); i++) { - RadioAction *action = new RadioAction(filterlist[i], 0); - settings_videoFilter->addAction(action); - settings_videoFilter_list.append(action); - } - } - - settings->addAction(settings_smoothVideo = new CheckAction("&Smooth Video Output", 0)); - - settings->addSeparator(); - - settings->addAction(settings_muteAudio = new CheckAction("&Mute Audio Output", 0)); - - settings->addSeparator(); - - settings_emulationSpeed = settings->addMenu("Emulation &Speed"); - - settings_emulationSpeed->addAction(settings_emulationSpeed_slowest = new RadioAction("Slowest", 0)); - - settings_emulationSpeed->addAction(settings_emulationSpeed_slow = new RadioAction("Slow", 0)); - - settings_emulationSpeed->addAction(settings_emulationSpeed_normal = new RadioAction("Normal", 0)); - - settings_emulationSpeed->addAction(settings_emulationSpeed_fast = new RadioAction("Fast", 0)); - - settings_emulationSpeed->addAction(settings_emulationSpeed_fastest = new RadioAction("Fastest", 0)); - - settings_emulationSpeed->addSeparator(); - - settings_emulationSpeed->addAction(settings_emulationSpeed_syncVideo = new CheckAction("Sync &Video", 0)); - - settings_emulationSpeed->addAction(settings_emulationSpeed_syncAudio = new CheckAction("Sync &Audio", 0)); - - settings_configuration = settings->addAction("&Configuration ..."); - settings_configuration->setMenuRole(QAction::PreferencesRole); - - tools = menuBar->addMenu("&Tools"); - - tools_movies = tools->addMenu("&Movies"); - - tools_movies_play = tools_movies->addAction("Play Movie ..."); - - tools_movies_stop = tools_movies->addAction("Stop"); - - tools_movies_recordFromPowerOn = tools_movies->addAction("Record Movie (and restart system)"); - - tools_movies_recordFromHere = tools_movies->addAction("Record Movie (starting from here)"); - - tools_captureScreenshot = tools->addAction("&Capture Screenshot"); - - #if 0 - //this will crash on Qt 4.6.0/Windows, because QObject::sender() returns a non-QObject*, non-null pointer - //since we don't know what other Qt toolkits have this bug, it's safer to just disable the feature by default - tools->addSeparator(); - - tools_loadState = tools->addMenu("&Load Quick State"); - for(unsigned i = 0; i < 10; i++) { - QAction *loadAction = new QAction(string("Slot ", i + 1), 0); - loadAction->setData(i); - connect(loadAction, SIGNAL(triggered()), this, SLOT(loadState())); - tools_loadState->addAction(loadAction); - } - - tools_saveState = tools->addMenu("&Save Quick State"); - for(unsigned i = 0; i < 10; i++) { - QAction *saveAction = new QAction(string("Slot ", i + 1), 0); - saveAction->setData(i); - connect(saveAction, SIGNAL(triggered()), this, SLOT(saveState())); - tools_saveState->addAction(saveAction); - } - #endif - - tools->addSeparator(); - - tools_cheatEditor = tools->addAction("Cheat &Editor ..."); - - tools_cheatFinder = tools->addAction("Cheat &Finder ..."); - - tools_stateManager = tools->addAction("&State Manager ..."); - - tools_effectToggle = tools->addAction("Effect &Toggle ..."); - #if !defined(PROFILE_COMPATIBILITY) && !defined(PROFILE_PERFORMANCE) - tools_effectToggle->setVisible(false); - #endif - - tools_debugger = tools->addAction("&Debugger ..."); - #if !defined(DEBUGGER) - tools_debugger->setVisible(false); - #endif - - help = menuBar->addMenu("&Help"); - - help_documentation = help->addAction("&Documentation ..."); - - help_license = help->addAction("&License ..."); - - #if !defined(PLATFORM_OSX) - help->addSeparator(); - #endif - - help_about = help->addAction("&About ..."); - help_about->setMenuRole(QAction::AboutRole); - - //canvas - canvasContainer = new CanvasObject; - canvasContainer->setAcceptDrops(true); { - canvasContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - canvasContainer->setObjectName("backdrop"); - - canvasLayout = new QVBoxLayout; { - canvasLayout->setMargin(0); - canvasLayout->setAlignment(Qt::AlignCenter); - - canvas = new CanvasWidget; - canvas->setAcceptDrops(true); - canvas->setFocusPolicy(Qt::StrongFocus); - canvas->setAttribute(Qt::WA_PaintOnScreen, true); //disable Qt painting on focus / resize - - QPalette palette; - palette.setColor(QPalette::Window, QColor(0, 0, 0)); - - canvas->setPalette(palette); - canvas->setAutoFillBackground(true); - } - canvasLayout->addWidget(canvas); - } - canvasContainer->setLayout(canvasLayout); - - //status bar - statusBar = new QStatusBar; - statusBar->setSizeGripEnabled(false); - statusBar->showMessage(""); - systemState = new QLabel; - statusBar->addPermanentWidget(systemState); - - //layout - layout = new QVBoxLayout; - layout->setMargin(0); - layout->setSpacing(0); - #if !defined(PLATFORM_OSX) - layout->addWidget(menuBar); - #endif - layout->addWidget(canvasContainer); - layout->addWidget(statusBar); - setLayout(layout); - - //slots - connect(system_load, SIGNAL(triggered()), this, SLOT(loadCartridge())); - connect(system_loadSpecial_bsxSlotted, SIGNAL(triggered()), this, SLOT(loadBsxSlottedCartridge())); - connect(system_loadSpecial_bsx, SIGNAL(triggered()), this, SLOT(loadBsxCartridge())); - connect(system_loadSpecial_sufamiTurbo, SIGNAL(triggered()), this, SLOT(loadSufamiTurboCartridge())); - connect(system_loadSpecial_superGameBoy, SIGNAL(triggered()), this, SLOT(loadSuperGameBoyCartridge())); - connect(system_power, SIGNAL(triggered()), this, SLOT(power())); - connect(system_reset, SIGNAL(triggered()), this, SLOT(reset())); - connect(system_port1_none, SIGNAL(triggered()), this, SLOT(setPort1None())); - connect(system_port1_gamepad, SIGNAL(triggered()), this, SLOT(setPort1Gamepad())); - connect(system_port1_asciipad, SIGNAL(triggered()), this, SLOT(setPort1Asciipad())); - connect(system_port1_multitap, SIGNAL(triggered()), this, SLOT(setPort1Multitap())); - connect(system_port1_mouse, SIGNAL(triggered()), this, SLOT(setPort1Mouse())); - connect(system_port2_none, SIGNAL(triggered()), this, SLOT(setPort2None())); - connect(system_port2_gamepad, SIGNAL(triggered()), this, SLOT(setPort2Gamepad())); - connect(system_port2_asciipad, SIGNAL(triggered()), this, SLOT(setPort2Asciipad())); - connect(system_port2_multitap, SIGNAL(triggered()), this, SLOT(setPort2Multitap())); - connect(system_port2_mouse, SIGNAL(triggered()), this, SLOT(setPort2Mouse())); - connect(system_port2_superscope, SIGNAL(triggered()), this, SLOT(setPort2SuperScope())); - connect(system_port2_justifier, SIGNAL(triggered()), this, SLOT(setPort2Justifier())); - connect(system_port2_justifiers, SIGNAL(triggered()), this, SLOT(setPort2Justifiers())); - connect(system_exit, SIGNAL(triggered()), this, SLOT(quit())); - connect(settings_videoMode_1x, SIGNAL(triggered()), this, SLOT(setVideoMode1x())); - connect(settings_videoMode_2x, SIGNAL(triggered()), this, SLOT(setVideoMode2x())); - connect(settings_videoMode_3x, SIGNAL(triggered()), this, SLOT(setVideoMode3x())); - connect(settings_videoMode_4x, SIGNAL(triggered()), this, SLOT(setVideoMode4x())); - connect(settings_videoMode_5x, SIGNAL(triggered()), this, SLOT(setVideoMode5x())); - connect(settings_videoMode_max_normal, SIGNAL(triggered()), this, SLOT(setVideoModeMaxNormal())); - connect(settings_videoMode_max_wide, SIGNAL(triggered()), this, SLOT(setVideoModeMaxWide())); - connect(settings_videoMode_max_wideZoom, SIGNAL(triggered()), this, SLOT(setVideoModeMaxWideZoom())); - connect(settings_videoMode_correctAspectRatio, SIGNAL(triggered()), this, SLOT(toggleAspectCorrection())); - connect(settings_videoMode_ntsc, SIGNAL(triggered()), this, SLOT(setVideoNtsc())); - connect(settings_videoMode_pal, SIGNAL(triggered()), this, SLOT(setVideoPal())); - if(filter.opened()) { - connect(settings_videoFilter_configure, SIGNAL(triggered()), this, SLOT(configureFilter())); - for(unsigned i = 0; i < settings_videoFilter_list.size(); i++) { - connect(settings_videoFilter_list[i], SIGNAL(triggered()), this, SLOT(setFilter())); - } - } - connect(settings_smoothVideo, SIGNAL(triggered()), this, SLOT(toggleSmoothVideo())); - connect(settings_muteAudio, SIGNAL(triggered()), this, SLOT(muteAudio())); - connect(settings_emulationSpeed_slowest, SIGNAL(triggered()), this, SLOT(setSpeedSlowest())); - connect(settings_emulationSpeed_slow, SIGNAL(triggered()), this, SLOT(setSpeedSlow())); - connect(settings_emulationSpeed_normal, SIGNAL(triggered()), this, SLOT(setSpeedNormal())); - connect(settings_emulationSpeed_fast, SIGNAL(triggered()), this, SLOT(setSpeedFast())); - connect(settings_emulationSpeed_fastest, SIGNAL(triggered()), this, SLOT(setSpeedFastest())); - connect(settings_emulationSpeed_syncVideo, SIGNAL(triggered()), this, SLOT(syncVideo())); - connect(settings_emulationSpeed_syncAudio, SIGNAL(triggered()), this, SLOT(syncAudio())); - connect(settings_configuration, SIGNAL(triggered()), this, SLOT(showConfigWindow())); - connect(tools_movies_play, SIGNAL(triggered()), this, SLOT(playMovie())); - connect(tools_movies_stop, SIGNAL(triggered()), this, SLOT(stopMovie())); - connect(tools_movies_recordFromPowerOn, SIGNAL(triggered()), this, SLOT(recordMovieFromPowerOn())); - connect(tools_movies_recordFromHere, SIGNAL(triggered()), this, SLOT(recordMovieFromHere())); - connect(tools_captureScreenshot, SIGNAL(triggered()), this, SLOT(saveScreenshot())); - connect(tools_cheatEditor, SIGNAL(triggered()), this, SLOT(showCheatEditor())); - connect(tools_cheatFinder, SIGNAL(triggered()), this, SLOT(showCheatFinder())); - connect(tools_stateManager, SIGNAL(triggered()), this, SLOT(showStateManager())); - connect(tools_effectToggle, SIGNAL(triggered()), this, SLOT(showEffectToggle())); - connect(tools_debugger, SIGNAL(triggered()), this, SLOT(showDebugger())); - connect(help_documentation, SIGNAL(triggered()), this, SLOT(showDocumentation())); - connect(help_license, SIGNAL(triggered()), this, SLOT(showLicense())); - connect(help_about, SIGNAL(triggered()), this, SLOT(showAbout())); - - syncUi(); -} - -void MainWindow::syncUi() { - system_power->setEnabled(SNES::cartridge.loaded()); - system_power->setChecked(application.power == true); - system_power->setEnabled(SNES::cartridge.loaded()); - system_reset->setEnabled(SNES::cartridge.loaded() && application.power); - - system_port1_none->setChecked (config().input.port1 == ControllerPort1::None); - system_port1_gamepad->setChecked (config().input.port1 == ControllerPort1::Gamepad); - system_port1_asciipad->setChecked (config().input.port1 == ControllerPort1::Asciipad); - system_port1_multitap->setChecked (config().input.port1 == ControllerPort1::Multitap); - system_port1_mouse->setChecked (config().input.port1 == ControllerPort1::Mouse); - - system_port2_none->setChecked (config().input.port2 == ControllerPort2::None); - system_port2_gamepad->setChecked (config().input.port2 == ControllerPort2::Gamepad); - system_port2_asciipad->setChecked (config().input.port2 == ControllerPort2::Asciipad); - system_port2_multitap->setChecked (config().input.port2 == ControllerPort2::Multitap); - system_port2_mouse->setChecked (config().input.port2 == ControllerPort2::Mouse); - system_port2_superscope->setChecked(config().input.port2 == ControllerPort2::SuperScope); - system_port2_justifier->setChecked (config().input.port2 == ControllerPort2::Justifier); - system_port2_justifiers->setChecked(config().input.port2 == ControllerPort2::Justifiers); - - settings_videoMode_1x->setChecked (config().video.context->multiplier == 1); - settings_videoMode_2x->setChecked (config().video.context->multiplier == 2); - settings_videoMode_3x->setChecked (config().video.context->multiplier == 3); - settings_videoMode_4x->setChecked (config().video.context->multiplier == 4); - settings_videoMode_5x->setChecked (config().video.context->multiplier == 5); - settings_videoMode_max_normal->setChecked(config().video.context->multiplier == 6); - settings_videoMode_max_wide->setChecked (config().video.context->multiplier == 7); - settings_videoMode_max_wideZoom->setChecked (config().video.context->multiplier == 8); - - settings_videoMode_max_normal->setVisible(config().video.isFullscreen == true); - settings_videoMode_max_wide->setVisible (config().video.isFullscreen == true); - settings_videoMode_max_wideZoom->setVisible (config().video.isFullscreen == true); - - settings_videoMode_correctAspectRatio->setChecked(config().video.context->correctAspectRatio); - settings_videoMode_ntsc->setChecked(config().video.context->region == 0); - settings_videoMode_pal->setChecked (config().video.context->region == 1); - - if(filter.opened()) { - //only enable configuration option if the active filter supports it ... - settings_videoFilter_configure->setEnabled(filter.settings()); - - for(unsigned i = 0; i < settings_videoFilter_list.size(); i++) { - settings_videoFilter_list[i]->setChecked(config().video.context->swFilter == i); - } - } - - settings_smoothVideo->setChecked(config().video.context->hwFilter == 1); - settings_muteAudio->setChecked(config().audio.mute); - - settings_emulationSpeed_slowest->setChecked(config().system.speed == 0); - settings_emulationSpeed_slow->setChecked (config().system.speed == 1); - settings_emulationSpeed_normal->setChecked (config().system.speed == 2); - settings_emulationSpeed_fast->setChecked (config().system.speed == 3); - settings_emulationSpeed_fastest->setChecked(config().system.speed == 4); - - settings_emulationSpeed_syncVideo->setChecked(config().video.synchronize); - settings_emulationSpeed_syncAudio->setChecked(config().audio.synchronize); - - //movies contian save states to synchronize playback to recorded input - tools_movies->setEnabled(SNES::cartridge.loaded() && cartridge.saveStatesSupported()); - if(tools_movies->isEnabled()) { - tools_movies_play->setEnabled(movie.state == Movie::Inactive); - tools_movies_stop->setEnabled(movie.state != Movie::Inactive); - tools_movies_recordFromPowerOn->setEnabled(movie.state == Movie::Inactive); - tools_movies_recordFromHere->setEnabled(movie.state == Movie::Inactive); - } -} - -bool MainWindow::isActive() { - return isActiveWindow() && !isMinimized(); -} - -void MainWindow::loadCartridge() { - fileBrowser->setWindowTitle("Load Cartridge"); - fileBrowser->loadCartridge(FileBrowser::LoadDirect); -} - -void MainWindow::loadBsxSlottedCartridge() { - loaderWindow->loadBsxSlottedCartridge("", ""); -} - -void MainWindow::loadBsxCartridge() { - loaderWindow->loadBsxCartridge(config().path.bsx, ""); -} - -void MainWindow::loadSufamiTurboCartridge() { - loaderWindow->loadSufamiTurboCartridge(config().path.st, "", ""); -} - -void MainWindow::loadSuperGameBoyCartridge() { - loaderWindow->loadSuperGameBoyCartridge(config().path.sgb, ""); -} - -void MainWindow::power() { - system_power->toggleChecked(); - if(system_power->isChecked()) { - utility.modifySystemState(Utility::PowerOn); - } else { - utility.modifySystemState(Utility::PowerOff); - } -} - -void MainWindow::reset() { - utility.modifySystemState(Utility::Reset); -} - -void MainWindow::setPort1None() { - config().input.port1 = ControllerPort1::None; - SNES::config.controller_port1 = SNES::Input::Device::None; - utility.updateControllers(); -} - -void MainWindow::setPort1Gamepad() { - config().input.port1 = ControllerPort1::Gamepad; - SNES::config.controller_port1 = SNES::Input::Device::Joypad; - utility.updateControllers(); -} - -void MainWindow::setPort1Asciipad() { - config().input.port1 = ControllerPort1::Asciipad; - SNES::config.controller_port1 = SNES::Input::Device::Joypad; - utility.updateControllers(); -} - -void MainWindow::setPort1Multitap() { - config().input.port1 = ControllerPort1::Multitap; - SNES::config.controller_port1 = SNES::Input::Device::Multitap; - utility.updateControllers(); -} - -void MainWindow::setPort1Mouse() { - config().input.port1 = ControllerPort1::Mouse; - SNES::config.controller_port1 = SNES::Input::Device::Mouse; - utility.updateControllers(); -} - -void MainWindow::setPort2None() { - config().input.port2 = ControllerPort2::None; - SNES::config.controller_port2 = SNES::Input::Device::None; - utility.updateControllers(); -} - -void MainWindow::setPort2Gamepad() { - config().input.port2 = ControllerPort2::Gamepad; - SNES::config.controller_port2 = SNES::Input::Device::Joypad; - utility.updateControllers(); -} - -void MainWindow::setPort2Asciipad() { - config().input.port2 = ControllerPort2::Asciipad; - SNES::config.controller_port2 = SNES::Input::Device::Joypad; - utility.updateControllers(); -} - -void MainWindow::setPort2Multitap() { - config().input.port2 = ControllerPort2::Multitap; - SNES::config.controller_port2 = SNES::Input::Device::Multitap; - utility.updateControllers(); -} - -void MainWindow::setPort2Mouse() { - config().input.port2 = ControllerPort2::Mouse; - SNES::config.controller_port2 = SNES::Input::Device::Mouse; - utility.updateControllers(); -} - -void MainWindow::setPort2SuperScope() { - config().input.port2 = ControllerPort2::SuperScope; - SNES::config.controller_port2 = SNES::Input::Device::SuperScope; - utility.updateControllers(); -} - -void MainWindow::setPort2Justifier() { - config().input.port2 = ControllerPort2::Justifier; - SNES::config.controller_port2 = SNES::Input::Device::Justifier; - utility.updateControllers(); -} - -void MainWindow::setPort2Justifiers() { - config().input.port2 = ControllerPort2::Justifiers; - SNES::config.controller_port2 = SNES::Input::Device::Justifiers; - utility.updateControllers(); -} - -void MainWindow::quit() { - hide(); - application.terminate = true; -} - -void MainWindow::setVideoMode1x() { utility.setScale(1); } -void MainWindow::setVideoMode2x() { utility.setScale(2); } -void MainWindow::setVideoMode3x() { utility.setScale(3); } -void MainWindow::setVideoMode4x() { utility.setScale(4); } -void MainWindow::setVideoMode5x() { utility.setScale(5); } -void MainWindow::setVideoModeMaxNormal() { utility.setScale(6); } -void MainWindow::setVideoModeMaxWide() { utility.setScale(7); } -void MainWindow::setVideoModeMaxWideZoom() { utility.setScale(8); } - -void MainWindow::toggleAspectCorrection() { utility.toggleAspectCorrection(); } - -void MainWindow::setVideoNtsc() { utility.setNtscMode(); } -void MainWindow::setVideoPal() { utility.setPalMode(); } - -void MainWindow::toggleSmoothVideo() { utility.toggleSmoothVideoOutput(); } - -void MainWindow::configureFilter() { - QWidget *widget = filter.settings(); - if(widget) { - widget->show(); - widget->activateWindow(); - widget->raise(); - } -} - -void MainWindow::setFilter() { - for(unsigned i = 0; i < settings_videoFilter_list.size(); i++) { - if(sender() == settings_videoFilter_list[i]) { - config().video.context->swFilter = i; - utility.updateSoftwareFilter(); - syncUi(); - return; - } - } -} - -void MainWindow::muteAudio() { - settings_muteAudio->toggleChecked(); - config().audio.mute = settings_muteAudio->isChecked(); -} - -void MainWindow::setSpeedSlowest() { config().system.speed = 0; utility.updateEmulationSpeed(); syncUi(); } -void MainWindow::setSpeedSlow() { config().system.speed = 1; utility.updateEmulationSpeed(); syncUi(); } -void MainWindow::setSpeedNormal() { config().system.speed = 2; utility.updateEmulationSpeed(); syncUi(); } -void MainWindow::setSpeedFast() { config().system.speed = 3; utility.updateEmulationSpeed(); syncUi(); } -void MainWindow::setSpeedFastest() { config().system.speed = 4; utility.updateEmulationSpeed(); syncUi(); } - -void MainWindow::syncVideo() { utility.toggleSynchronizeVideo(); } -void MainWindow::syncAudio() { utility.toggleSynchronizeAudio(); } - -void MainWindow::showConfigWindow() { settingsWindow->show(); } - -void MainWindow::playMovie() { - movie.chooseFile(); - syncUi(); -} - -void MainWindow::stopMovie() { - movie.stop(); - syncUi(); -} - -void MainWindow::recordMovieFromPowerOn() { - utility.modifySystemState(Utility::PowerCycle); - movie.record(); - syncUi(); -} - -void MainWindow::recordMovieFromHere() { - movie.record(); - syncUi(); -} - -void MainWindow::saveScreenshot() { - //tell SNES::Interface to save a screenshot at the next video_refresh() event - interface.saveScreenshot = true; -} - -void MainWindow::loadState() { - QAction *action = dynamic_cast(sender()); - if(action == 0) return; - unsigned slot = action->data().toUInt(); - state.load(slot); -} - -void MainWindow::saveState() { - QAction *action = dynamic_cast(sender()); - if(action == 0) return; - unsigned slot = action->data().toUInt(); - state.save(slot); -} - -void MainWindow::showCheatEditor() { toolsWindow->tab->setCurrentIndex(0); toolsWindow->show(); } -void MainWindow::showCheatFinder() { toolsWindow->tab->setCurrentIndex(1); toolsWindow->show(); } -void MainWindow::showStateManager() { toolsWindow->tab->setCurrentIndex(2); toolsWindow->show(); } -void MainWindow::showEffectToggle() { toolsWindow->tab->setCurrentIndex(3); toolsWindow->show(); } - -void MainWindow::showDebugger() { - #if defined(DEBUGGER) - debugger->show(); - #endif -} - -void MainWindow::showDocumentation() { - QFile file(":/documentation.html"); - if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { - htmlViewerWindow->show("Usage Documentation", file.readAll().constData()); - file.close(); - } -} - -void MainWindow::showLicense() { - QFile file(":/license.html"); - if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { - htmlViewerWindow->show("License Agreement", file.readAll().constData()); - file.close(); - } -} -void MainWindow::showAbout() { - aboutWindow->show(); -} - -void MainWindow::resizeEvent(QResizeEvent *event) { - Window::resizeEvent(event); - QApplication::processEvents(); -} - -void MainWindow::closeEvent(QCloseEvent *event) { - Window::closeEvent(event); - quit(); -} - -//============ -//CanvasObject -//============ - -//implement drag-and-drop support: -//drag cartridge image onto main window canvas area to load - -void CanvasObject::dragEnterEvent(QDragEnterEvent *event) { - if(event->mimeData()->hasUrls()) { - //do not accept multiple files at once - if(event->mimeData()->urls().count() == 1) event->acceptProposedAction(); - } -} - -void CanvasObject::dropEvent(QDropEvent *event) { - if(event->mimeData()->hasUrls()) { - QList list = event->mimeData()->urls(); - if(list.count() == 1) cartridge.loadNormal(list.at(0).toLocalFile().toUtf8().constData()); - } -} - -//accept all key events for this widget to prevent system chime from playing on OS X -//key events are actually handled by Input class - -void CanvasObject::keyPressEvent(QKeyEvent *event) { -} - -void CanvasObject::keyReleaseEvent(QKeyEvent *event) { -} - -//=========== -//CanvasWidget -//============ - -//custom video render and mouse capture functionality - -QPaintEngine* CanvasWidget::paintEngine() const { - if(SNES::cartridge.loaded()) { - video.refresh(); - return 0; - } - return QWidget::paintEngine(); -} - -void CanvasWidget::mouseReleaseEvent(QMouseEvent *event) { - //acquire exclusive mode access to mouse when video output widget is clicked - //(will only acquire if cart is loaded, and mouse / lightgun is in use.) - utility.acquireMouse(); -} - -void CanvasWidget::paintEvent(QPaintEvent *event) { - event->ignore(); -} diff --git a/bsnes/ui-qt/base/main.moc.hpp b/bsnes/ui-qt/base/main.moc.hpp deleted file mode 100755 index e7560fd5..00000000 --- a/bsnes/ui-qt/base/main.moc.hpp +++ /dev/null @@ -1,168 +0,0 @@ -class CanvasObject : public QWidget { -public: - void dragEnterEvent(QDragEnterEvent*); - void dropEvent(QDropEvent*); - void keyPressEvent(QKeyEvent*); - void keyReleaseEvent(QKeyEvent*); -}; - -class CanvasWidget : public CanvasObject { -public: - QPaintEngine* paintEngine() const; - void mouseReleaseEvent(QMouseEvent*); - void paintEvent(QPaintEvent*); -}; - -class MainWindow : public Window { - Q_OBJECT - -public: - QMenuBar *menuBar; - QStatusBar *statusBar; - QVBoxLayout *layout; - QMenu *system; - QAction *system_load; - QMenu *system_loadSpecial; - QAction *system_loadSpecial_bsxSlotted; - QAction *system_loadSpecial_bsx; - QAction *system_loadSpecial_sufamiTurbo; - QAction *system_loadSpecial_superGameBoy; - CheckAction *system_power; - QAction *system_reset; - QMenu *system_port1; - RadioAction *system_port1_none; - RadioAction *system_port1_gamepad; - RadioAction *system_port1_asciipad; - RadioAction *system_port1_multitap; - RadioAction *system_port1_mouse; - QMenu *system_port2; - RadioAction *system_port2_none; - RadioAction *system_port2_gamepad; - RadioAction *system_port2_asciipad; - RadioAction *system_port2_multitap; - RadioAction *system_port2_mouse; - RadioAction *system_port2_superscope; - RadioAction *system_port2_justifier; - RadioAction *system_port2_justifiers; - QAction *system_exit; - QMenu *settings; - QMenu *settings_videoMode; - RadioAction *settings_videoMode_1x; - RadioAction *settings_videoMode_2x; - RadioAction *settings_videoMode_3x; - RadioAction *settings_videoMode_4x; - RadioAction *settings_videoMode_5x; - RadioAction *settings_videoMode_max_normal; - RadioAction *settings_videoMode_max_wide; - RadioAction *settings_videoMode_max_wideZoom; - CheckAction *settings_videoMode_correctAspectRatio; - RadioAction *settings_videoMode_ntsc; - RadioAction *settings_videoMode_pal; - QMenu *settings_videoFilter; - QAction *settings_videoFilter_configure; - RadioAction *settings_videoFilter_none; - array settings_videoFilter_list; - CheckAction *settings_smoothVideo; - CheckAction *settings_muteAudio; - QMenu *settings_emulationSpeed; - RadioAction *settings_emulationSpeed_slowest; - RadioAction *settings_emulationSpeed_slow; - RadioAction *settings_emulationSpeed_normal; - RadioAction *settings_emulationSpeed_fast; - RadioAction *settings_emulationSpeed_fastest; - CheckAction *settings_emulationSpeed_syncVideo; - CheckAction *settings_emulationSpeed_syncAudio; - QAction *settings_configuration; - QMenu *tools; - QMenu *tools_movies; - QAction *tools_movies_play; - QAction *tools_movies_stop; - QAction *tools_movies_recordFromPowerOn; - QAction *tools_movies_recordFromHere; - QAction *tools_captureScreenshot; - QMenu *tools_loadState; - QMenu *tools_saveState; - QAction *tools_cheatEditor; - QAction *tools_cheatFinder; - QAction *tools_stateManager; - QAction *tools_effectToggle; - QAction *tools_debugger; - QMenu *help; - QAction *help_documentation; - QAction *help_license; - QAction *help_about; - - CanvasObject *canvasContainer; - QVBoxLayout *canvasLayout; - CanvasWidget *canvas; - QLabel *systemState; - - void syncUi(); - bool isActive(); - void resizeEvent(QResizeEvent*); - void closeEvent(QCloseEvent*); - MainWindow(); - -public slots: - void loadCartridge(); - void loadBsxSlottedCartridge(); - void loadBsxCartridge(); - void loadSufamiTurboCartridge(); - void loadSuperGameBoyCartridge(); - void power(); - void reset(); - void setPort1None(); - void setPort1Gamepad(); - void setPort1Asciipad(); - void setPort1Multitap(); - void setPort1Mouse(); - void setPort2None(); - void setPort2Gamepad(); - void setPort2Asciipad(); - void setPort2Multitap(); - void setPort2Mouse(); - void setPort2SuperScope(); - void setPort2Justifier(); - void setPort2Justifiers(); - void quit(); - void setVideoMode1x(); - void setVideoMode2x(); - void setVideoMode3x(); - void setVideoMode4x(); - void setVideoMode5x(); - void setVideoModeMaxNormal(); - void setVideoModeMaxWide(); - void setVideoModeMaxWideZoom(); - void toggleAspectCorrection(); - void setVideoNtsc(); - void setVideoPal(); - void configureFilter(); - void setFilter(); - void toggleSmoothVideo(); - void muteAudio(); - void setSpeedSlowest(); - void setSpeedSlow(); - void setSpeedNormal(); - void setSpeedFast(); - void setSpeedFastest(); - void syncVideo(); - void syncAudio(); - void showConfigWindow(); - void playMovie(); - void stopMovie(); - void recordMovieFromPowerOn(); - void recordMovieFromHere(); - void saveScreenshot(); - void loadState(); - void saveState(); - void showCheatEditor(); - void showCheatFinder(); - void showStateManager(); - void showEffectToggle(); - void showDebugger(); - void showDocumentation(); - void showLicense(); - void showAbout(); -}; - -extern MainWindow *mainWindow; diff --git a/bsnes/ui-qt/base/stateselect.cpp b/bsnes/ui-qt/base/stateselect.cpp deleted file mode 100755 index 550ed5f3..00000000 --- a/bsnes/ui-qt/base/stateselect.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "stateselect.moc" -StateSelectWindow *stateSelectWindow; - -void StateSelectWindow::setSlot(unsigned slot) { - state.active = slot; - hide(); - utility.showMessage(string("Quick state ", slot + 1, " selected.")); -} - -void StateSelectWindow::keyReleaseEvent(QKeyEvent *event) { - switch(event->key()) { - case Qt::Key_1: return setSlot(0); - case Qt::Key_2: return setSlot(1); - case Qt::Key_3: return setSlot(2); - case Qt::Key_4: return setSlot(3); - case Qt::Key_5: return setSlot(4); - case Qt::Key_6: return setSlot(5); - case Qt::Key_7: return setSlot(6); - case Qt::Key_8: return setSlot(7); - case Qt::Key_9: return setSlot(8); - case Qt::Key_0: return setSlot(9); - } - return Window::keyReleaseEvent(event); -} - -StateSelectWindow::StateSelectWindow() { - setObjectName("state-select-window"); - setWindowTitle("State Selection"); - setGeometryString(&config().geometry.stateSelectWindow); - - layout = new QGridLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - slot[0] = new QPushButton("Slot &1"); - slot[1] = new QPushButton("Slot &2"); - slot[2] = new QPushButton("Slot &3"); - slot[3] = new QPushButton("Slot &4"); - slot[4] = new QPushButton("Slot &5"); - slot[5] = new QPushButton("Slot &6"); - slot[6] = new QPushButton("Slot &7"); - slot[7] = new QPushButton("Slot &8"); - slot[8] = new QPushButton("Slot &9"); - slot[9] = new QPushButton("Slot 1&0"); - for(unsigned i = 0; i < 10; i++) { - layout->addWidget(slot[i], i / 5, i % 5); - connect(slot[i], SIGNAL(released()), this, SLOT(slotClicked())); - } -} - -void StateSelectWindow::slotClicked() { - QPushButton *s = (QPushButton*)sender(); - for(unsigned i = 0; i < 10; i++) { - if(slot[i] == s) return setSlot(i); - } -} diff --git a/bsnes/ui-qt/base/stateselect.moc.hpp b/bsnes/ui-qt/base/stateselect.moc.hpp deleted file mode 100755 index 12c6e0bd..00000000 --- a/bsnes/ui-qt/base/stateselect.moc.hpp +++ /dev/null @@ -1,16 +0,0 @@ -class StateSelectWindow : public Window { - Q_OBJECT - -public: - QGridLayout *layout; - QPushButton *slot[10]; - - void setSlot(unsigned slot); - void keyReleaseEvent(QKeyEvent*); - StateSelectWindow(); - -public slots: - void slotClicked(); -}; - -extern StateSelectWindow *stateSelectWindow; diff --git a/bsnes/ui-qt/cartridge/cartridge.cpp b/bsnes/ui-qt/cartridge/cartridge.cpp deleted file mode 100755 index 77754d14..00000000 --- a/bsnes/ui-qt/cartridge/cartridge.cpp +++ /dev/null @@ -1,392 +0,0 @@ -#include "../ui-base.hpp" -Cartridge cartridge; - -//================ -//public functions -//================ - -bool Cartridge::information(const char *filename, Cartridge::Information &info) { - if(extension(filename) != "sfc") return false; //do not parse compressed images - - file fp; - if(fp.open(filename, file::mode::read) == false) return false; - - unsigned offset = 0; - if((fp.size() & 0x7fff) == 512) offset = 512; - - uint16_t complement, checksum; - - fp.seek(0x7fdc + offset); - complement = fp.readl(2); - checksum = fp.readl(2); - - unsigned header = offset + (complement + checksum == 65535 ? 0x7fb0 : 0xffb0); - - fp.seek(header + 0x10); - char name[22]; - fp.read((uint8_t*)name, 21); - name[21] = 0; - info.name = decodeShiftJIS(name); - - fp.seek(header + 0x29); - uint8_t region = fp.read(); - info.region = (region <= 1 || region >= 13) ? "NTSC" : "PAL"; - - info.romSize = fp.size() & ~0x7fff; - - fp.seek(header + 0x28); - info.ramSize = fp.readl(1); - if(info.ramSize) info.ramSize = 1024 << (info.ramSize & 7); - - fp.close(); - return true; -} - -bool Cartridge::saveStatesSupported() { - if(SNES::cartridge.mode() == SNES::Cartridge::Mode::Bsx) return false; - - if(SNES::cartridge.has_st0011()) return false; - if(SNES::cartridge.has_st0018()) return false; - if(SNES::cartridge.has_serial()) return false; - - return true; -} - -bool Cartridge::loadNormal(const char *base) { - unload(); - if(loadCartridge(baseName = base, cartridge.baseXml, SNES::memory::cartrom) == false) return false; - SNES::cartridge.basename = nall::basename(baseName); - - SNES::cartridge.load(SNES::Cartridge::Mode::Normal, - lstring() << cartridge.baseXml); - - loadMemory(baseName, ".srm", SNES::memory::cartram); - loadMemory(baseName, ".rtc", SNES::memory::cartrtc); - - fileName = baseName; - name = notdir(nall::basename(baseName)); - - utility.modifySystemState(Utility::LoadCartridge); - return true; -} - -bool Cartridge::loadBsxSlotted(const char *base, const char *slot) { - unload(); - if(loadCartridge(baseName = base, cartridge.baseXml, SNES::memory::cartrom) == false) return false; - loadCartridge(slotAName = slot, cartridge.slotAXml, SNES::memory::bsxflash); - SNES::cartridge.basename = nall::basename(baseName); - - SNES::cartridge.load(SNES::Cartridge::Mode::BsxSlotted, - lstring() << cartridge.baseXml << cartridge.slotAXml); - - loadMemory(baseName, ".srm", SNES::memory::cartram); - loadMemory(baseName, ".rtc", SNES::memory::cartrtc); - - fileName = baseName; - name = notdir(nall::basename(baseName)); - if(*slot) name << " + " << notdir(nall::basename(slotAName)); - - utility.modifySystemState(Utility::LoadCartridge); - return true; -} - -bool Cartridge::loadBsx(const char *base, const char *slot) { - unload(); - if(loadCartridge(baseName = base, cartridge.baseXml, SNES::memory::cartrom) == false) return false; - loadCartridge(slotAName = slot, cartridge.slotAXml, SNES::memory::bsxflash); - SNES::cartridge.basename = nall::basename(baseName); - - SNES::cartridge.load(SNES::Cartridge::Mode::Bsx, - lstring() << cartridge.baseXml << cartridge.slotAXml); - - loadMemory(baseName, ".srm", SNES::memory::bsxram ); - loadMemory(baseName, ".psr", SNES::memory::bsxpram); - - fileName = slotAName; - name = *slot - ? notdir(nall::basename(slotAName)) - : notdir(nall::basename(baseName)); - - utility.modifySystemState(Utility::LoadCartridge); - return true; -} - -bool Cartridge::loadSufamiTurbo(const char *base, const char *slotA, const char *slotB) { - unload(); - if(loadCartridge(baseName = base, cartridge.baseXml, SNES::memory::cartrom) == false) return false; - loadCartridge(slotAName = slotA, cartridge.slotAXml, SNES::memory::stArom); - loadCartridge(slotBName = slotB, cartridge.slotBXml, SNES::memory::stBrom); - SNES::cartridge.basename = nall::basename(baseName); - - SNES::cartridge.load(SNES::Cartridge::Mode::SufamiTurbo, - lstring() << cartridge.baseXml << cartridge.slotAXml << cartridge.slotBXml); - - loadMemory(slotAName, ".srm", SNES::memory::stAram); - loadMemory(slotBName, ".srm", SNES::memory::stBram); - - fileName = slotAName; - if(!*slotA && !*slotB) name = notdir(nall::basename(baseName)); - else if(!*slotB) name = notdir(nall::basename(slotAName)); - else if(!*slotA) name = notdir(nall::basename(slotBName)); - else name = notdir(nall::basename(slotAName)) << " + " << notdir(nall::basename(slotBName)); - - utility.modifySystemState(Utility::LoadCartridge); - return true; -} - -bool Cartridge::loadSuperGameBoy(const char *base, const char *slot) { - unload(); - if(loadCartridge(baseName = base, cartridge.baseXml, SNES::memory::cartrom) == false) return false; - loadCartridge(slotAName = slot, cartridge.slotAXml, SNES::memory::gbrom); - SNES::cartridge.basename = nall::basename(baseName); - - SNES::cartridge.load(SNES::Cartridge::Mode::SuperGameBoy, - lstring() << cartridge.baseXml << cartridge.slotAXml); - - loadMemory(slotAName, ".sav", SNES::memory::gbram); - loadMemory(slotBName, ".rtc", SNES::memory::gbrtc); - - fileName = slotAName; - name = *slot - ? notdir(nall::basename(slotAName)) - : notdir(nall::basename(baseName)); - - utility.modifySystemState(Utility::LoadCartridge); - return true; -} - -void Cartridge::saveMemory() { - if(SNES::cartridge.loaded() == false) return; - - switch(SNES::cartridge.mode()) { - case SNES::Cartridge::Mode::Normal: - case SNES::Cartridge::Mode::BsxSlotted: { - saveMemory(baseName, ".srm", SNES::memory::cartram); - saveMemory(baseName, ".rtc", SNES::memory::cartrtc); - } break; - - case SNES::Cartridge::Mode::Bsx: { - saveMemory(baseName, ".srm", SNES::memory::bsxram ); - saveMemory(baseName, ".psr", SNES::memory::bsxpram); - } break; - - case SNES::Cartridge::Mode::SufamiTurbo: { - saveMemory(slotAName, ".srm", SNES::memory::stAram); - saveMemory(slotBName, ".srm", SNES::memory::stBram); - } break; - - case SNES::Cartridge::Mode::SuperGameBoy: { - saveMemory(slotAName, ".sav", SNES::memory::gbram); - saveMemory(slotAName, ".rtc", SNES::memory::gbrtc); - } break; - } -} - -void Cartridge::unload() { - if(SNES::cartridge.loaded() == false) return; - utility.modifySystemState(Utility::UnloadCartridge); -} - -void Cartridge::loadCheats() { - string name; - name << filepath(nall::basename(baseName), config().path.cheat); - name << ".cht"; - cheatEditorWindow->load(name); -} - -void Cartridge::saveCheats() { - string name; - name << filepath(nall::basename(baseName), config().path.cheat); - name << ".cht"; - cheatEditorWindow->save(name); -} - -//================= -//private functions -//================= - -bool Cartridge::loadCartridge(string &filename, string &xml, SNES::MappedRAM &memory) { - if(file::exists(filename) == false) return false; - - uint8_t *data; - unsigned size; - audio.clear(); - if(reader.load(filename, data, size) == false) return false; - - patchApplied = false; - string name(filepath(nall::basename(filename), config().path.patch), ".ups"); - - file fp; - if(config().file.applyPatches && fp.open(name, file::mode::read)) { - unsigned patchsize = fp.size(); - uint8_t *patchdata = new uint8_t[patchsize]; - fp.read(patchdata, patchsize); - fp.close(); - - uint8_t *outdata = 0; - unsigned outsize = 0; - ups patcher; - if(patcher.apply(patchdata, patchsize, data, size, 0, outsize) == ups::result::target_too_small) { - outdata = new uint8_t[outsize]; - if(patcher.apply(patchdata, patchsize, data, size, outdata, outsize) == ups::result::success) { - delete[] data; - data = outdata; - size = outsize; - patchApplied = true; - } else { - delete[] outdata; - } - } - delete[] patchdata; - } - - name = string(nall::basename(filename), ".xml"); - if(patchApplied == false && file::exists(name)) { - //prefer manually created XML cartridge mapping - xml.readfile(name); - } else { - //generate XML mapping from data via heuristics - xml = SNESCartridge(data, size).xmlMemoryMap; - } - - memory.copy(data, size); - delete[] data; - return true; -} - -bool Cartridge::loadMemory(const char *filename, const char *extension, SNES::MappedRAM &memory) { - if(memory.size() == 0 || memory.size() == -1U) return false; - - string name; - name << filepath(nall::basename(filename), config().path.save); - name << extension; - - file fp; - if(fp.open(name, file::mode::read) == false) return false; - - unsigned size = fp.size(); - uint8_t *data = new uint8_t[size]; - fp.read(data, size); - fp.close(); - - memory.copy(data, size); - delete[] data; - return true; -} - -bool Cartridge::saveMemory(const char *filename, const char *extension, SNES::MappedRAM &memory) { - if(memory.size() == 0 || memory.size() == -1U) return false; - - string name; - name << filepath(nall::basename(filename), config().path.save); - name << extension; - - file fp; - if(fp.open(name, file::mode::write) == false) return false; - - fp.write(memory.data(), memory.size()); - fp.close(); - return true; -} - -string Cartridge::decodeShiftJIS(const char *text) { - unsigned length = strlen(text), offset = 0; - string output; - - for(unsigned i = 0; i < length;) { - unsigned code = 0; - uint8_t n = text[i++]; - - if(n == 0x00) { - //string terminator - break; - } else if(n >= 0x20 && n <= 0x7f) { - //ASCII - code = n; - } else if(n >= 0xa0 && n <= 0xdf) { - //ShiftJIS half-width katakana - unsigned dakuten = 0, handakuten = 0; - - switch(n) { - case 0xa1: code = 0xe38082; break; //(period) - case 0xa2: code = 0xe3808c; break; //(open quote) - case 0xa3: code = 0xe3808d; break; //(close quote) - case 0xa4: code = 0xe38081; break; //(comma) - case 0xa5: code = 0xe383bb; break; //(separator) - case 0xa6: code = 0xe383b2; break; //wo - case 0xa7: code = 0xe382a1; break; //la - case 0xa8: code = 0xe382a3; break; //li - case 0xa9: code = 0xe382a5; break; //lu - case 0xaa: code = 0xe382a7; break; //le - case 0xab: code = 0xe382a9; break; //lo - case 0xac: code = 0xe383a3; break; //lya - case 0xad: code = 0xe383a5; break; //lyu - case 0xae: code = 0xe383a7; break; //lyo - case 0xaf: code = 0xe38383; break; //ltsu - case 0xb0: code = 0xe383bc; break; //- - case 0xb1: code = 0xe382a2; break; //a - case 0xb2: code = 0xe382a4; break; //i - case 0xb3: code = 0xe382a6; break; //u - case 0xb4: code = 0xe382a8; break; //e - case 0xb5: code = 0xe382aa; break; //o - case 0xb6: code = 0xe382ab; dakuten = 0xe382ac; break; //ka, ga - case 0xb7: code = 0xe382ad; dakuten = 0xe382ae; break; //ki, gi - case 0xb8: code = 0xe382af; dakuten = 0xe382b0; break; //ku, gu - case 0xb9: code = 0xe382b1; dakuten = 0xe382b2; break; //ke, ge - case 0xba: code = 0xe382b3; dakuten = 0xe382b4; break; //ko, go - case 0xbb: code = 0xe382b5; dakuten = 0xe382b6; break; //sa, za - case 0xbc: code = 0xe382b7; dakuten = 0xe382b8; break; //shi, zi - case 0xbd: code = 0xe382b9; dakuten = 0xe382ba; break; //su, zu - case 0xbe: code = 0xe382bb; dakuten = 0xe382bc; break; //se, ze - case 0xbf: code = 0xe382bd; dakuten = 0xe382be; break; //so, zo - case 0xc0: code = 0xe382bf; dakuten = 0xe38380; break; //ta, da - case 0xc1: code = 0xe38381; dakuten = 0xe38382; break; //chi, di - case 0xc2: code = 0xe38384; dakuten = 0xe38385; break; //tsu, du - case 0xc3: code = 0xe38386; dakuten = 0xe38387; break; //te, de - case 0xc4: code = 0xe38388; dakuten = 0xe38389; break; //to, do - case 0xc5: code = 0xe3838a; break; //na - case 0xc6: code = 0xe3838b; break; //ni - case 0xc7: code = 0xe3838c; break; //nu - case 0xc8: code = 0xe3838d; break; //ne - case 0xc9: code = 0xe3838e; break; //no - case 0xca: code = 0xe3838f; dakuten = 0xe38390; handakuten = 0xe38391; break; //ha, ba, pa - case 0xcb: code = 0xe38392; dakuten = 0xe38393; handakuten = 0xe38394; break; //hi, bi, pi - case 0xcc: code = 0xe38395; dakuten = 0xe38396; handakuten = 0xe38397; break; //fu, bu, pu - case 0xcd: code = 0xe38398; dakuten = 0xe38399; handakuten = 0xe3839a; break; //he, be, pe - case 0xce: code = 0xe3839b; dakuten = 0xe3839c; handakuten = 0xe3839d; break; //ho, bo, po - case 0xcf: code = 0xe3839e; break; //ma - case 0xd0: code = 0xe3839f; break; //mi - case 0xd1: code = 0xe383a0; break; //mu - case 0xd2: code = 0xe383a1; break; //me - case 0xd3: code = 0xe383a2; break; //mo - case 0xd4: code = 0xe383a4; break; //ya - case 0xd5: code = 0xe383a6; break; //yu - case 0xd6: code = 0xe383a8; break; //yo - case 0xd7: code = 0xe383a9; break; //ra - case 0xd8: code = 0xe383aa; break; //ri - case 0xd9: code = 0xe383ab; break; //ru - case 0xda: code = 0xe383ac; break; //re - case 0xdb: code = 0xe383ad; break; //ro - case 0xdc: code = 0xe383af; break; //wa - case 0xdd: code = 0xe383b3; break; //n - } - - if(dakuten && ((uint8_t)text[i] == 0xde)) { - code = dakuten; - i++; - } else if(handakuten && ((uint8_t)text[i] == 0xdf)) { - code = handakuten; - i++; - } - } - - if(code) { - if((uint8_t)(code >> 16)) output[offset++] = (char)(code >> 16); - if((uint8_t)(code >> 8)) output[offset++] = (char)(code >> 8); - if((uint8_t)(code >> 0)) output[offset++] = (char)(code >> 0); - } - } - - output[offset] = 0; - return output; -} diff --git a/bsnes/ui-qt/cartridge/cartridge.hpp b/bsnes/ui-qt/cartridge/cartridge.hpp deleted file mode 100755 index 0c4c6910..00000000 --- a/bsnes/ui-qt/cartridge/cartridge.hpp +++ /dev/null @@ -1,42 +0,0 @@ -class Cartridge { -public: - string name; //printable name - string fileName; //ideal file name for saving data to disk - string baseName; //physical cartridge file name - string slotAName; //Sufami Turbo slot A file name or BS-X slot file name - string slotBName; //Sufami Turbo slot B file name - bool patchApplied; //true if UPS patch was applied to image - - string baseXml; - string slotAXml; - string slotBXml; - - struct Information { - string name; - string region; - unsigned romSize; - unsigned ramSize; - }; - - bool information(const char*, Information&); - bool saveStatesSupported(); - - bool loadNormal(const char*); - bool loadBsxSlotted(const char*, const char*); - bool loadBsx(const char*, const char*); - bool loadSufamiTurbo(const char*, const char *, const char*); - bool loadSuperGameBoy(const char*, const char*); - void saveMemory(); - void unload(); - - void loadCheats(); - void saveCheats(); - -private: - bool loadCartridge(string&, string&, SNES::MappedRAM&); - bool loadMemory(const char*, const char*, SNES::MappedRAM&); - bool saveMemory(const char*, const char*, SNES::MappedRAM&); - string decodeShiftJIS(const char*); -}; - -extern Cartridge cartridge; diff --git a/bsnes/ui-qt/config.cpp b/bsnes/ui-qt/config.cpp deleted file mode 100755 index 5b18fb27..00000000 --- a/bsnes/ui-qt/config.cpp +++ /dev/null @@ -1,141 +0,0 @@ -Configuration &config() { - static Configuration configuration; - return configuration; -} - -bool Configuration::load(const char *filename) { - if(configuration::load(filename) == false) return false; - SNES::config.superfx.speed = max(0, min(2, SNES::config.superfx.speed)); - video.context = (video.isFullscreen == false) ? &video.windowed : &video.fullscreen; - return true; -} - -Configuration::Configuration() { - //external - attach((unsigned&)(SNES::config.controller_port1 = SNES::Input::Device::Joypad), "snes.controllerPort1"); - attach((unsigned&)(SNES::config.controller_port2 = SNES::Input::Device::Joypad), "snes.controllerPort2"); - attach((unsigned&)(SNES::config.expansion_port = SNES::System::ExpansionPortDevice::BSX), "snes.expansionPort"); - attach((unsigned&)(SNES::config.region = SNES::System::Region::Autodetect), "snes.region"); - - attach(SNES::config.cpu.version = 2, "cpu.version", "Valid version(s) are: 1, 2"); - attach(SNES::config.cpu.ntsc_frequency = 21477272, "cpu.ntscFrequency"); - attach(SNES::config.cpu.pal_frequency = 21281370, "cpu.palFrequency"); - attach(SNES::config.cpu.wram_init_value = 0x55, "cpu.wramInitValue"); - - attach(SNES::config.smp.ntsc_frequency = 24607104, "smp.ntscFrequency"); - attach(SNES::config.smp.pal_frequency = 24607104, "smp.palFrequency"); - - attach(SNES::config.ppu1.version = 1, "ppu1.version", "Valid version(s) are: 1"); - attach(SNES::config.ppu2.version = 3, "ppu2.version", "Valid version(s) are: 1, 2, 3"); - - attach(SNES::config.superfx.speed = 0, "superfx.speed", "0 = Auto-select, 1 = Force 10.74MHz, 2 = Force 21.48MHz"); - - //internal - attach(system.profile = "", "system.profile"); - attach(system.video = "", "system.video"); - attach(system.audio = "", "system.audio"); - attach(system.input = "", "system.input"); - attach(system.crashedOnLastRun = false, "system.crashedOnLastRun"); - attach(system.speed = 2, "system.speed"); - attach(system.speedSlowest = 50, "system.speedSlowest"); - attach(system.speedSlow = 75, "system.speedSlow"); - attach(system.speedNormal = 100, "system.speedNormal"); - attach(system.speedFast = 150, "system.speedFast"); - attach(system.speedFastest = 200, "system.speedFastest"); - attach(system.autoSaveMemory = false, "system.autoSaveMemory", "Automatically save cartridge back-up RAM once every minute"); - attach(system.rewindEnabled = false, "system.rewindEnabled", "Automatically save states periodically to allow auto-rewind support"); - - attach(diskBrowser.useCommonDialogs = false, "diskBrowser.useCommonDialogs"); - attach(diskBrowser.showPanel = true, "diskBrowser.showPanel"); - - attach(file.applyPatches = true, "file.applyPatches"); - - attach(path.rom = "", "path.rom"); - attach(path.save = "", "path.save"); - attach(path.state = "", "path.state"); - attach(path.patch = "", "path.patch"); - attach(path.cheat = "", "path.cheat"); - attach(path.data = "", "path.data"); - attach(path.bsx = "", "path.bsx"); - attach(path.st = "", "path.st"); - attach(path.sgb = "", "path.sgb"); - attach(path.shader = "", "path.shader"); - - attach(path.current.folder = "", "path.current.folder"); - attach(path.current.movie = "", "path.current.movie"); - attach(path.current.shader = "", "path.current.shader"); - attach(path.current.cartridge = "", "path.current.cartridge"); - attach(path.current.filter = 0, "path.current.filter"); - - video.context = &video.windowed; - attach(video.isFullscreen = false, "video.isFullscreen"); - attach(video.synchronize = false, "video.synchronize"); - - attach(video.autoHideFullscreenMenu = false, "video.autoHideFullscreenMenu"); - - attach(video.contrastAdjust = 0, "video.contrastAdjust"); - attach(video.brightnessAdjust = 0, "video.brightnessAdjust"); - attach(video.gammaAdjust = 0, "video.gammaAdjust"); - attach(video.scanlineAdjust = 100, "video.scanlineAdjust"); - attach(video.enableGammaRamp = true, "video.enableGammaRamp"); - - attach(video.ntscAspectRatio = 54.0 / 47.0, "video.ntscAspectRatio", "NTSC aspect ratio (x / y)"); - attach(video.palAspectRatio = 32.0 / 23.0, "video.palAspectRatio", "PAL aspect ratio (x / y)"); - - attach(video.cropLeft = 0, "video.cropLeft"); - attach(video.cropTop = 0, "video.cropTop"); - attach(video.cropRight = 0, "video.cropRight"); - attach(video.cropBottom = 0, "video.cropBottom"); - - attach(video.windowed.correctAspectRatio = true, "video.windowed.correctAspectRatio"); - attach(video.windowed.multiplier = 2, "video.windowed.multiplier"); - attach(video.windowed.region = 0, "video.windowed.region"); - - attach(video.windowed.hwFilter = 1, "video.windowed.hwFilter"); - attach(video.windowed.swFilter = 0, "video.windowed.swFilter"); - - attach(video.fullscreen.correctAspectRatio = true, "video.fullscreen.correctAspectRatio"); - attach(video.fullscreen.multiplier = 9, "video.fullscreen.multiplier"); - attach(video.fullscreen.region = 0, "video.fullscreen.region"); - - attach(video.fullscreen.hwFilter = 1, "video.fullscreen.hwFilter"); - attach(video.fullscreen.swFilter = 0, "video.fullscreen.swFilter"); - - attach(audio.synchronize = true, "audio.synchronize"); - attach(audio.mute = false, "audio.mute"); - - attach(audio.volume = 100, "audio.volume"); - attach(audio.latency = 80, "audio.latency"); - attach(audio.outputFrequency = 48000, "audio.outputFrequency"); - attach(audio.inputFrequency = 32000, "audio.inputFrequency"); - - attach(input.port1 = ControllerPort1::Gamepad, "input.port1"); - attach(input.port2 = ControllerPort2::Gamepad, "input.port2"); - attach(input.focusPolicy = Input::FocusPolicyIgnoreInput, "input.focusPolicy"); - attach(input.allowInvalidInput = false, "input.allowInvalidInput", "Allow up+down / left+right combinations; may trigger bugs in some games"); - attach(input.modifierEnable = true, "input.modifierEnable"); - - attach(debugger.cacheUsageToDisk = false, "debugger.cacheUsageToDisk"); - - attach(geometry.mainWindow = "", "geometry.mainWindow"); - attach(geometry.loaderWindow = "", "geometry.loaderWindow"); - attach(geometry.stateSelectWindow = "", "geometry.stateSelectWindow"); - attach(geometry.htmlViewerWindow = "", "geometry.htmlViewerWindow"); - attach(geometry.aboutWindow = "", "geometry.aboutWindow"); - attach(geometry.fileBrowser = "", "geometry.fileBrowser"); - attach(geometry.folderCreator = "", "geometry.folderCreator"); - attach(geometry.settingsWindow = "", "geometry.settingsWindow"); - attach(geometry.toolsWindow = "", "geometry.toolsWindow"); - attach(geometry.cheatImportWindow = "", "geometry.cheatImportWindow"); - - attach(geometry.debugger = "", "geometry.debugger"); - attach(geometry.disassembler = "", "geometry.disassembler"); - attach(geometry.breakpointEditor = "", "geometry.breakpointEditor"); - attach(geometry.memoryEditor = "", "geometry.memoryEditor"); - attach(geometry.propertiesViewer = "", "geometry.propertiesViewer"); - attach(geometry.layerToggle = "", "geometry.layerToggle"); - attach(geometry.vramViewer = "", "geometry.vramViewer"); - attach(geometry.oamViewer = "", "geometry.oamViewer"); - attach(geometry.cgramViewer = "", "geometry.cgramViewer"); - attach(geometry.debuggerOptions = "", "geometry.debuggerOptions"); -} diff --git a/bsnes/ui-qt/config.hpp b/bsnes/ui-qt/config.hpp deleted file mode 100755 index 3c650cfc..00000000 --- a/bsnes/ui-qt/config.hpp +++ /dev/null @@ -1,109 +0,0 @@ -class Configuration : public configuration { -public: - struct System { - string profile; - string video, audio, input; - bool crashedOnLastRun; - unsigned speed; - unsigned speedSlowest; - unsigned speedSlow; - unsigned speedNormal; - unsigned speedFast; - unsigned speedFastest; - bool autoSaveMemory; - bool rewindEnabled; - } system; - - struct File { - bool applyPatches; - } file; - - struct DiskBrowser { - bool useCommonDialogs; - bool showPanel; - } diskBrowser; - - struct Path { - string base; //binary path - string user; //user profile path (bsnes.cfg, ...) - string startup; //startup path - string rom, save, state, patch, cheat, data; - string bsx, st, sgb; - string shader; - - struct Current { - string folder, movie, shader, cartridge; - unsigned filter; //current active filter for "Load Cartridge" - } current; - } path; - - struct Video { - bool isFullscreen; - bool synchronize; - - bool autoHideFullscreenMenu; - - signed contrastAdjust, brightnessAdjust, gammaAdjust, scanlineAdjust; - bool enableGammaRamp; - double ntscAspectRatio, palAspectRatio; - - unsigned cropLeft; - unsigned cropTop; - unsigned cropRight; - unsigned cropBottom; - - struct Context { - bool correctAspectRatio; - unsigned multiplier, region; - unsigned hwFilter, swFilter; - } *context, windowed, fullscreen; - } video; - - struct Audio { - bool synchronize; - bool mute; - unsigned volume, latency, outputFrequency, inputFrequency; - } audio; - - struct Input { - unsigned port1; - unsigned port2; - enum policy_t { FocusPolicyPauseEmulation, FocusPolicyIgnoreInput, FocusPolicyAllowInput }; - unsigned focusPolicy; - bool allowInvalidInput; - bool modifierEnable; - } input; - - struct Debugger { - bool cacheUsageToDisk; - } debugger; - - struct Geometry { - string mainWindow; - string loaderWindow; - string stateSelectWindow; - string htmlViewerWindow; - string aboutWindow; - string fileBrowser; - string folderCreator; - string settingsWindow; - string toolsWindow; - string cheatImportWindow; - - string debugger; - string disassembler; - string breakpointEditor; - string memoryEditor; - string propertiesViewer; - string layerToggle; - string vramViewer; - string oamViewer; - string cgramViewer; - string debuggerOptions; - } geometry; - - bool load(const char *filename); - Configuration(); -}; - -Configuration &config(); diff --git a/bsnes/ui-qt/data/documentation.html b/bsnes/ui-qt/data/documentation.html deleted file mode 100755 index 6f772618..00000000 --- a/bsnes/ui-qt/data/documentation.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - -

bsnes Usage Documentation


- -bsnes is a Super Nintendo / Super Famicom emulator that strives to provide the -most faithful hardware emulation possible. It focuses on accuracy and clean -code, rather than speed and special features. It is meant as a reference -emulator to document how the underlying hardware works. It is thus very useful -for development and research. And while it can be used for general purpose -gaming, it will require significantly more powerful hardware than a typical -emulator. -
- -

Modes of Operation


- -bsnes is capable of running both in its default multi-user mode, as well as in -single-user mode. -

- -In multi-user mode, configuration data is stored inside the user's home -directory. On Windows, this is located at "%APPDATA%/.bsnes". On other operating -systems, this is located at "~/.bsnes". -

- -To enable single-user mode, create a blank "bsnes.cfg" file inside the same -folder as the bsnes executable. bsnes will then use this file to store -configuration data. -
- -

Supported Filetypes


- -SFC: SNES cartridge — ROM image.
-BS: Satellaview BS-X flash cartridge — EEPROM image.
-ST: Sufami Turbo cartridge — ROM image.
-SRM, PSR: non-volatile memory, often used to save game data — (P)SRAM image.
-RTC: real-time clock non-volatile memory.
-UPS: patch data, used to dynamically modify cartridge of same base filename upon load.
-CHT: plain-text list of "Game Genie" / "Pro Action Replay" codes. -
- -

Known Limitations


- -Satellaview BS-X emulation: this hardware is only partially supported. -This is mostly because the satellite network it used (St. GIGA) has been shut -down. Access to this network would be required to properly reverse engineer much -of the hardware. Working around this would require game-specific hacks, which -are contrary to the design goals of this emulator. As a result, most BS-X -software will not function correctly. -

- -Netplay: internet multiplay is not currently supported nor planned. -
- -

Contributors


-• Andreas Naive
-• anomie
-• _Demo_
-• Derrick Sobodash
-• DMV27
-• FirebrandX
-• FitzRoy
-• GIGO
-• Jonas Quinn
-• kode54
-• krom
-• Matthew Callis
-• Nach
-• neviksti
-• Overload
-• RedDwarf
-• Richard Bannister
-• Shay Green
-• tetsuo55
-• TRAC
-• zones
- - - diff --git a/bsnes/ui-qt/data/icons-16x16/folder-new.png b/bsnes/ui-qt/data/icons-16x16/folder-new.png deleted file mode 100755 index 628f4d50ffc3a350c8cdcbb089b25bcc7139001d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 635 zcmV->0)+jEP)K`lbtXsaQ;_vX7l#~~rDr9s7q55D1?^Pcy->cq+1jZ7wU zlQn3qYkyT=9D4NlK21=UuUwMzXD_T<^nH(qLk}pI%cq|`ef}hzKdJx=2+Z^gX$a(w z9jEZI&}<1~=5GIr#kTnFBp0JiPWk?d?LkQ*GNyW<-J8)xZA^$>*C zq1Y(iRq@)?S0J5PtwTX&lprAhpJoaZL@8vfr+s?gTEz;V*Ee=RvcJHi~u5nQVJ14 z1Y!}QNC=`B9SYSjB8Y@!qIE^U^ISG1t1MPDUl%wcY$LzW`je V_=-2-nyCN)002ovPDHLkV1icx6Sn{W diff --git a/bsnes/ui-qt/data/icons-16x16/go-up.png b/bsnes/ui-qt/data/icons-16x16/go-up.png deleted file mode 100755 index fa9a7d71b5615dde4c5f702f95df533adadd56e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 652 zcmV;70(1R|P)5 zlTT<9K@`TnH@h?0jfHw>O#jh>1nt2m6SAzrkW<%*%=Q}tRboP9pC%r$9&(LA+0sq)ybQD9srhR zz3Fxu)^6aqJl)?FN%nOeOgb)4?+M_zJQ@)DvRBSb2FFH|!GH*69hXP{3*flC1BAti zbJNzAm&ca3iTKDR3xq|-Y2`eKx?tij|4I5$vH1yqf%5H^Fb8J54jK)5$VM-C5%i8b<|k&Kxh=#FG>Ox&>r z4?sb}hlkg>1-vahgJcyDBP0eg&{{(&pkA-x@zeQAv9vj35<}`!ZpEItce&w-qk8xH z6RRw9@QrP7!N5#{!3lE@ZdYYZTfgiFi6Lb!&3aDLCbZTHrTP~zgJ5t59%w*hO|J5M1+Eg zu&{A+*&&w>s~k1qOJ|O>Txd&VFq}1W#*B^94r|ip=qZF5%Q1Ic?zzm6Wct{!!QyOB zj|C4|;B8#_BC{frF_ z4Kt2?H8ucNTFvpzl?xe{y-F6V4G$f0$-=PrZOEJ+E82kQ=GG5Bo0s%O1sR$`Wf zq-3G=fipaX^InE=^PDwTT4!uvWb~+v@r;|qfu%Di3N9B{IJZxrfG<+Q+1O8C!Tsvg z3Emc_k2#rLY=AZjU+FOwNSu|pu-D(183??B+EmXkWMyc}l3%+<#zzV04+c+HKbLh* G2~7ZZW>?w( diff --git a/bsnes/ui-qt/data/icons-16x16/item-radio-off.png b/bsnes/ui-qt/data/icons-16x16/item-radio-off.png deleted file mode 100755 index e17b659f64bbb9d7571f94ccda292360fed6cc7d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 565 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85sC{fp`w%y>D~Efr9KMp1!W^H@TSDH7w=4*}Z_KZ1r?;46!(! zoUlN^;L)TRyC0tT7n`1MJ!j|7mV+*_Z3oXre9b9p=;hpHrB>3owffwfaGuOx^?z=~ zwlip}w!O`L$fLOJ70>c~JEJh5#Qw7LGhbW8ZU9n$wZF|R=GYRJy5Z8a#Dt`zw1l*@ zL?BK}NK8z$DErEJ_!M*aKDNm0c>Xd&!_)*Ia5H=G#e62~&APS-Q)3{|@ZvK5P+Yu0 z)aRzs*N3 z|M~g&|N8j-fBygbd;9-<`}#ls|Ng%Ie}Db|Klh8DJ*z)DVcGu(;UNFE>y1;{*BQv{ z{3EdX?CPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01iz601li1-u9eV00007bV*G`2iXb& z2Pq{JQEEg000IX|L_t(I%f*wiYZGx4$G`Wki#P~6S%P?_F~)Z49Y`^S6l^F(!P=uP zF2$vb62*VOfK+J)g)R=+vQ!Pm)W!4Y1sc@YJ0eD|9#M;2g;ufJrnxjt!_Pr`c(I{_ zgKzx(-uwPO@BO|H_{ZQ{T_n;uO)*Mg-CBYa@F61l-(5Nv3O46a^Fd10H9?NC{K8^b z?mGr`@**zu2cehjl5f7f{k$Y=ndbWt+ zQzwj((~<-L{GS5zj_=;(VQJT5A|ArwgE+8%AEHw;?LSQIhNp!@I;Rhaf?HhY>d@A+ z7%Pt9v7JG+Q3Vm9zo!#tLtRLubDBp$F-qcq*x|nXV&f$q)*irVtKhbI3z?4@5b+=) zoaqfhF-l>Nz^`eyySPa^iEpc`s5lNbYjwn5O@fHPaU6QPk3zSWyuTm?d?_|^D1bg4L46tV6QcTI4tXy%JI&ZP)-A8OsCpPVZ ht{5e8uU+{6@e|UO;YhkJ*VO<3002ovPDHLkV1gbxADI9E diff --git a/bsnes/ui-qt/data/license.html b/bsnes/ui-qt/data/license.html deleted file mode 100755 index 3f3508cb..00000000 --- a/bsnes/ui-qt/data/license.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - -

GNU GENERAL PUBLIC LICENSE
-Version 2, June 1991

-
- -

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION


- -0. -This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".

-Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

- -1. -You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

-You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

- -2. -You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:

-
    -
  • a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
  • -
  • b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
  • -
  • c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
  • -
-These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

-Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

-In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

- -3. -You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: -
    -
  • a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
  • -
  • b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
  • -
  • c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
  • -
-The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

-If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

- -4. -You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

- -5. -You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.

- -6. -Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

- -7. -If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

-If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

-It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

-This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

- -8. -If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.

- -9. -The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

-Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

- -10. -If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

- -NO WARRANTY

- -11. -BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

- -12. -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- -

END OF TERMS AND CONDITIONS

- - - diff --git a/bsnes/ui-qt/data/logo.png b/bsnes/ui-qt/data/logo.png deleted file mode 100755 index e78ef27fc2162e5ea94ac1f85bdc42f8dc73a93c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16733 zcmYkkb97|e^FG|Mt%+^hwkEbGwllG9+nP9;iEZ1~#7;W)n|tr)`&;kowYtwA`}E$Y zPMzBI)brGdQ2Z{50E+_)000oArNop008q`ZV=HLLuWv(HMwPE0$RDzjVt~(oKKY%$ zk^lfeZp>8EexhX?1oGxfW3GLc!+ zPSDW*ou4S0DhXYYlKoU9`;EzDufgm zFSZm->2!;5Ha^mV&Y{RzYB5MG|GR(^8>zeKwm_tDPPo`{yIw^ znx<|Htf487B!zMVP64wol;-_C3;cB=(wpTCJy=so$PgmNjeQU8e};FLZNQ`CO3nkR z8KbNrcjY96qplmPZq)FWCqc!;;npUEWd@RaE59Kt>8nfx2JKW*b&pa8|7TTZ@B(h7 zXQ(ifgNWD29Ak{KrEQN;RlE*)-l_{=++9!XVUo(X9%aNI9c@(88Kr+mbP(bjlNF%< zTRo^F)hPN%_8^Fs&mnCopb}4}SMT8F@ffNJ_zOA3?kFjlkSSL`FE)wSuCLPs5}&ue zA?mG)!$1ie##{M+o)fkap$5aF7yZ50#o?et%73{M9tp0n5+;u>?-r_1gT-QWxD>RC z!iTerBO%bpp~Ue&e>2t2G-pE>d)6RJTW$f$%LdSj*7Iutg>#=S;S8z0NV6H#wtSY@ z9LO(T(sr309V~eoP zE7G28s{V^C2jBe-nvt{g!xUiuH5BzYlrtD?-AB`)Zo$$f@K;H1N{S$ z!7~|4yf-;uDV<#~9jeYwLpp`yb~8|qyXXIwY%5$ALol((VgL>2U}`aF#0y_jLixO=oVl zzJpIQT{_H)`q#OWwSGY*_S;sQl_Nap!(02S{k**jJ=&lB1Cv~$+VL4*l9#D4y%WE^ zqw~M#68NQyU6fj@f(3r2UxEP$*v7X$Mcp{|qLMe8A3yY_0#U zR1VNo`^8^Dcs(}bKTN?UqwdTF^Zgi53dw(q9nBIm_OKF(nPaxdYv zNS2comK2jFY*{zgZxZ?!eDU5}>=|!cMM&IRq!HfB{26$ssdBj&Y~eQcg4rgsSJwEf zDPmk?SB@JB0b5MMngmLqw@*JxmNYWg2!=(ciN=taB109+s1!^QMzvI&Oxt$iLuVS- zl)}f_(CHpZ?EL=b2=NB$j+RA(zkF=6vuIhe;h#n1{@#JbKYCpIUC2{xx#m3g+(@ez zj0rR?0Zs(`5?ou9bD+5>_c_mVjwPc$N*{@w{w*Sm^y+Jh+z7_s*qN{zct3BOqn$!{ z-bMs#JZ(WEHtwj+7Md$bw8wC|)MZpv|sPsC4vy=ruP{lI= z&p|w~d^x&x>FtvLwCZkK|)yQAM)Xa`OeBihv=s3em?fCQ*=b2jS$JoOQltj#8~ozIOmn{UJCsE z9Y~RS3W6L9r)AtKb0VZjoq*0ZIQKhOZriyeb*Qkz*17E?|H|vP+{I6&6Exo>tQ0$Q z+(Ba7UyP0`?inMo8kLJId6f5$*+>fh5XDsoDhX0y#bYV@vDFlUh#;4=;>mQOpq6AH@Y$lKn=ktE!c)W9-ze4G~GfU@wBA)Pj37!=4 zNvWriO65gTI}9$5u!n(C84c9p*K;X3wkpO$%HrZgM;RGwpN9?2T`|l=h(W zBv7yOVG&2GZ|1D2df(CQV>WmVHQ~ViN2dwMsZUcl$=Aq}!&e!Mlu%WR^fdO?>86}H z$&lCkcyG&|;XPYzpctTLH+a;~TIx|x)<&G1A;Of@L=7 z;xg`;z$T}=_ptB1R>HeNz5;K_)6622G8u6k)|XrEJ)Utn4rxP-Kc8m;RhvQI?$mU} zBTHe!HP(aYuXotVjdrRDL5uca;(2u58vE}<4 z7l20ub_J28argi+h>xK?=~geLdlGpu2Vs$>F&iN`$)P^ISUeSKAP=RItGHYSlswlm$vsm-oe zB}}&DPndf%mRiIRiIk>jv0X73DT@3^*Hh;@ z5&IBk?0qG%A6sae^J;7QuFSqbFq0=&gV4>)sbVNLf9s#Hx{Mcoq!H0mPG@Pq;U**` zMk+W{>I6X|)dk3%_EQZr22f zSfOkP7D0jHvhC*$d!8)sw<8}aW&0|KhGgo%*oI2EuI+|+;tGOQf70X={N^TWxF*qY zYC4oncn8ztQGy6MwsJ4_Etqh@D7CrK3H)i!Y`@5k>_|uF&GY;^+0MYDMfq}}fJMHn z;~%@XLp~g3Bh1wDP{w<+WZ#%Lz3sm%Hi6 zbf|r6a_MULMrnW|kX2Mt4ph^-KYQ0>z5o3A_COoSA)_0`{wcdk1=HBRHU|NO<2PCO z0uNcBe@J+B5oVkM@ZBT|yF`8QqM9@+Re=iAVk%!5;gQ!p#rqxwZf=#vpSP=z*5 z79Lr(2i+aq8fYHNTW00fNk0E76*@th9k|eiG~cC1iEqe6v2m=+i3=c60t-Tz6^K#R z3c!`S40g@3XpbLQtxCE|OG6kQ2{7{n?0|DYk3v%6)^uV^y{_;MIRLH4qgGcbT$I!~ zU(pRiqQV9OBwML$$qhhjUU$RpDZe&aV^nk!fCu|wll(0y`!3z4~VGDp+PGmOqc+L9=> zc_%a&{?Mnw^s|VMjKdg99vDfRfp}s+bCgQ(i}>9#?Xk(kAbaQZM1~y3;Z#~K+4lGw zy@lm2jzGHD^3H`nOa#Y(%`-F_{0&d$={b}(x6rfp+dxBZHoAI-lwa3sewOswgNnCY zYi137sLk-?hhT5U2|Uq(F>+$1(!;iWua~!OXJ2Sp;sPmB7ARPqlc4(y^H6@~?w$@C z#IgBerFz8^U8{qUgi0GAZZ>ADrCbKoP)%wpIp-QPOKtKn-Vem%ST+ahAFT1>yZlj{ zEvkG{Phbu+_Yqctx#u%nE7-@W3-EmI$!d_Hb2oTT`AUZ8^PX{FZp(x+dpp&2=?lx4 zj29gS5pq@z&{b#E6g2lk)6(KB^{oJ8xo2t5S|IyV`eGpPgnNIfMV4IfwlT)4hyv0X zNOU%A8VNc#!}$25db4-pw-#dtXl(pFY=<;)bg@0<+h;@DZxKH^%inN-;ZM5+?q$eA z5q3+s?>fu#XX|3iKT)RSFvL8);aj!k_b4_hl@QPm`bzcIhWcs!6~Fxg9WhXvU9RIq ztva|3WG!-a9BR@3+Vd2CFq$D=lo~_!=n*Gd3b!CWYf}FVMmJQ;0LFtT&drqe9>!1W z{gqRxPF&DW&plhsnw6~654Z49wD>_ba+D0W)3=Mu0IgpIq5~uA&R7)!`R*4Ck)Rtf zXDQ&OTU}P9e)1-Cd~w8ir7VFeq;Jj+n#n#YMY0Q z@D0Yqoo9NJ*D9oD^oEK6_?7a-;&vFg?&A6f(m!~-q{!TCmtr|mw$)x zAabB?5#E8dAPzki%7bq^1keKIT>9FQMTXwh)f0Hm*ahr#>E$;S1>92C8Fl_jH>rOw zkVkveeXf;4nz4O|7a48|@y3o!tZ2xY9_G4kK)evaL+msYWiae7iK_d%lO+mTM-$iC zf30sC&@z7*|6OuWPGhsvGYq3gxxC4iTiiMzz^oi%p4A3om9X0qlF=h2cCdEQ^8RN)VfT0E4l2{sl+Z|%t6 zZQxF}p8-#`Z`rX7%B@se0xX$7kyZ2XENCcbo*&||>-G!Jo@)rP8yU$*yVlxld)VJP z(uNjBX04u6X;gxW1Tm=Jj{Ht-2Z%+C0S=& zqCylJ&Bu;|x z=HbIb<3V;j^o#m*TN~nKI{z~(t}ZCU=s2w#m$gYsLr$h8TAx_vLYnUfwQZX<&gQ@x zL=fwC%edq3;S-p6ng?Px+pF4>%4gdT20MT=w-i;puK69NwNgq;j^XaG0eM*2uT5lN zX)ne*-|bnoK--S+e#r8-nNHh4|&{an|U#kS;ypwoa=8Ux@HuLVNY?c-jzThqVOT~`SA zyL0Ww@zZVWkQErLZyIT8f>pipAh2)QmfQQ23nF7Dm1s9TQ$lo8Tl+822HKjOUU3`BL6}Y)2gj>^ zGiEk6W81g*;vZ;Y4T43QU0&F77ZRcF>w9KlA};YGJx z_+Q(|c#Amz;D1N>Q|Y*bv3=hOXg9TYrF)ye*NU$sTu0^<r#t_o?gfooDYY_&0aH)#uW;7Q*mOv-aY|ofU8E=Bt0PE=S`eRaXx6%)v<9< zOCi|dY2l&%!kevjCfy5|^J?tTU#US%j^%(^+9%NQ>^%6<{CpRa2IeaFK2d+QcWDGy z^$1Q$S);&1LX=TKk-zuk6mlAmJ=A9iL10p7*df^oj;cOR%*XC4Pm{z%>IXv#FBF$6O* z2*07QWAxCa7exq%vRWenO>J%(@v14;ou5^bIgzSclip}o{5vE*9>f(X?S@0C8WKaD zhyitri#Vg=qJSF4*VAQqdO#BrRQC5&g*~D!A+TnlOU#0O6V5@po8>B_8LRx7X;-K0 zMKsVe0d?&$n=(aW)6Bnedli9BLjdHXR>#I_C5ZMoUmXqM@x!zgxPtsbj>hq3m9cI% zzdz|&5Fm22v^YDRVpw#`6+!?ouWZuU2|Zh80l@7rd36ea2idPW&}q~>TYTMbHCO?G z8*#S?*Vy<@)AUwOLgO_0&7e1yy=PjP25?IfH&bHkoB1!8uyu!uV0tNF?XJ$@nG3`3 zf&V9y>0YUeASl_hP*U;%3RjbV;9D1S06s-!-^P@fdl>F1yIGk->x$nT7_yQ za*C;E$xqeZ2(H4RE%f3kV{O@QkF%ws{sWqN**3)S$p=iCkC5|^``hRK(@n`&S?|U; z#z8Gj7jTb&yr@M&(Dja9{xxt*PhVTzB(5~IPB4Bd=c}eFa0Z~;Ct`X0n25A+hf@%0 z!7iHU#Dd`qGG6`|=|j8j>FwP52joTp@s@wkh-moKcqheJr>4;M9UB#U1QvVws3LYn zf6`haE6;RQe&dAN?Ww0L#tg4}GuCpAUeWt|rBtwZo;^@=2MXiGVs+4LWG=WPKR`~P zHXoGc-4~v2#0ykW^u9BA5|(Q0r1T^=z~`zHDd+MmvfK%QmNpJ|C<=nU5>MtU8&fbS zmkU0)!8x8^W6569@A3~)uPrNUy?*cORBxY7sIZJfgJn@e>TmTiiwTq>!fL|TqX8^A zDcFmc%02MT{lrT7tWs1)h@1K<&#EEldK}PU#P#hVB420NUJqA&2()h|y3I@al1gVg z_W%dH{sHqm(h97h#%#ik-0$OhyV~B>E1pw>u_p?smTC9yv!yoNm+guY$vit}H%Wwb z1I{GE_~$p#DeHb$KaG?Uz1UC>lgOuvhDq2~bNkw7WuVgVW#{E=czYQPMpmtpTT=78 zt4kjBRV76H^=V5w56fry)kh*cx6SYkQ*^fJ6oReS%)*ewpD~h~j{4gZW3S3n@09~~ zdrnym$Wd%-<^&bEr~Y0;*wdua)|YOMD1+2p6TBD+QgfOk*rA!(%c$NSKg&b~3W@M$ z&RWyGPb~bzX*+i&jr)=Op&Q-cc8(yZGspDT0dzUR&3P#r36_XW*}wyeRt^Otqo&|D zojK~{vQc(?dmyY)jkw0XPhaJEJciY;JmV%hqXJVPGy?vgbJp$ZJUn23%YL$}f*cSp3xQ{=}xb(@{t zk6iCCmH_h0b-m7vixGvJ&%%XfF}8RS-Uk-MXLzsO1~HQJS_{1|lO#ZK{0QG2dR0MY z_1uRFt{9y@+-(%8?Hfb8B1Ne_!s$81%Q;3Mvbx<{VwvSKLH+S7k>Gc^iOm^|iFy{g zlkDs6eh$Msc7%BgfR1VQRjQ>c#7;Z0>zz=AlR|fk10|RCxoanWrfp5Tpqr3SO`9R3 zGD~2qS)5BRwYdLV=P9pp`F#pcowB|uR2L=>5X&`B;|n4(8&2x>+XcDM5Vl#eG zNssa2Pqg)-IE6q;+1xlMb}CS&9Q86;gXD#PYKnvlbcgp@($P79wef3$2Njr5je7Sm z&EolFL_hcfL=_FwH_%#t2mofH(tRox!d+tVUrhN%I);t6 zsVQXWg-5l}vdq#z?YZ(qef1`fZlf6@h!ipFxmAN67)x9wgW6O<7A4~{Rg?3=DpzM^ zT|EwE2LUl;KS(13D+`kEFk-+YuCUgXJCPZwI55w>A(y)m=+D z31JNkzz}v<1JdN#oGFLs)`&TiNgy}{$jiAy7|#re)xBvf&$>+lvX$G1ImYsI+#M+noVyG1m%hdPC;OrB+jApXJ-nn3xdx5V?>biPl$eh$RB={xqP zX0#B`7fo)UPj4_R?nFRZUy_?pm2uDn5jL(DWYe+0-&zGtxbEJ_>I8u82LDW#!If$&Yv^76 zkoSziWisL29Pq`&c*v9Xff!m|MCg+tc-5+r7S%@%c!a!VZ$zFhfcg&EI=6H!MpJc0 zqf<(<)D9nEdAq&mR?4aQ!3Vlz;JhHUc z0NtWZ^&`<;{OtltM|Dim;I!ekgtSbvXM=ds5hK7@hB^Vzk#Q^P6YB z#o@l@_s<~@Z-^upT(USVdqnwZ{lu5J3mSt(&sz0{>a5x7oZbd^cb zBCKw?Mh~E^UVBUUH!DaTX-0ziA)Rn*5WCs__@GeOHc*j&c2=v=IhQXWrXH-ZRuiS{ z0Wd_qCy8z)ScU}#Kfd-YspM=akfm;b*3Jx#rT?O!9g7kC$!v|8=f~nY5o?1OmUDkU zTElO3$Q|cdtKN;V%q-}l+>rwk_#)Lbc95q+Ox< z)!xw!Qoy- zhid3#Y{!j5MBrTp;qv8*!Ecq4N_9pL7X*{BjYrcqD254hS&L|xT7irgiN&tLjNU7?sv0Y!p{td;c7y~8#&pYb_l7Kn z7S9Tbczz@16$iBTN=^vPBbq4eQ**u76zCr9EG8OC!RW0AkV%F~GKeZ6PEjgYjCen_ z=5<(=ek_NuGozFRU-9agyBvSaEav2U-uF+?PSeH-A#iKDtA#8TYlmeP4;8y$ zEI>H3)FVJA;HH$CwMn{Ra-f`o`NR)`aPVu~Ztrp0`160Ny3-#GDitkaw?9w{e1BHb zu@M*=F>Cw_u+*gLB!|C%b>>ME_#%@1jr=9Us6!+mbGNbi+4rm6uAdQ#=F4W&6g>IF z5j~)s@{rd#>e*v+(KuMqAqXx?1#C_wu2`?=NrN{T%}vwKsHC1-nCUbdn{aL34l#W# zM~|bgF1~Q#34+}{fsGDm1JY(A1Nf_a9@O>73Gs9U&eOP6uxii}+ST3}n;4JHGchSy zRtjy}&v=ZM_o|xXUy*PC20fA6yK&Kh;be6^cFtgYZVW)5dqFwtN zQy>rMinDf!gr!Md9w&mRxPI+OqbUqsS-*1yXY_+z_CYOVXlZHoh@dd@K z0ns{_r6HqkygQ(4cie82c)YXXi=N>KbBSzxF(M!s43Li;5Mt#N+N_~p* zV?}KFM)uXVNvJH`Lu>hn@WUepSJ)31o>y=9*4A%Mv*rid!R=qE+uM|iW&`-GLQb&B zyvDItcObOzodvOPt8&hUz$pg;dbo_Y06fS~&4P4Nysxl(fBi6q>?PZiFGERBp@*T~ zu(UQA3|Hsbj)!9QlR1+w?-v{${kJXB!_kPuHkP{3X)!@j`$k&hW02J(W=yQKtl{qU zQ!kXlDql1c#-&Td{^-GbrP%&aV!_x4dNVu4{Zw%BRs09exO1l8`yFIDztQfnZCd%$3zc`*vj(E%g*VNY{ZOn zm62gw-MXJrCG~7z2nfZqS!(k^yaIZZ=@Rkhug0zf0+VOCZwlrTw?q!92>nL}vt~9k zJ&VJ7uPCb2fj`Il_4c?oQsyVaZ0bc~dt384em($~0>90_rLsn@qoqz-lP&LYt1Nx= z#26BP5q;$yi|GPGb2eR63QAxA1LUV#z)ICD!LYdP$VB7|L}{G5&zpcjmazH?Xv~kE z`>bCYHeCeY5By?K?G>w$MVi`9Tf3xaE3iD{L!v#~-=d+|qQ8j*cgj~ULqhdfJt->4 zA`IQ>%@mF&Y~;;m21c6R9X+h?+>AjapSos?@WfyXe~H9K@5DPt3K8%}*K%xu$G~bB zlOdoTnW?(Lob{X{2}K;~K_RO*NbQvt5_x<(X593sM8FJE!20c9qh5_xoS1^m(@Ci%OnjH&}Yg*gVl;`np1jfB&L{9 zo7*=x>+<)ow~Et9UOwIWxw)7WQbDJX7u}rejpJnOa{7mWR+ok9j6&iX5}U=*8B0q_ zCWg+WW4#^ZN4$yE5w11lr zB2m{-eub6MzI%M^>xvl`T$j~&@3;yG_Y&YZ_6-bt!@!XwF9IU8?)yw9qa_Nf-Xy1L z!6Opuyigz+BblS4dz9FLAQ?wyYk_cAS@-swNQdq6-&Y~IQ3Ru2?d~I*l(j%4VC?SQ zOH0mB#w4wTFiYax?KLLGDwuV`qp(+YN|{#J9;?E|iDKhiKK+kL~#;%?c!d+VB3Z`(UL0m64oP z!-X7y=U2t5q3la;<2cjC8AMWC)8KUR5SHNTdy?I|RFTc}qFWw1X5kwFs^g^Yb&atX%NVtKTic}Qibh6FJEyIu-cE2yCCK5M_Evv{-x1c zVFk&H9F`v)9oBgq$Af4aV6D2bEtj+$O(VSvUJm+(4>%sZ;`KjmkEe4(ex{+ty(Hj9 z+@Z`5WSkUdz2dwO_yvNgm8p`*k0G)oaXg@?+z(P@BX5UmOeTE6*?YZDL>Zq$ zwjV6YK|MPC+u6qe&R+Gd)1I@M^EsgKj@xD-j{zjZVFKfft$k_c)ry-dS{|WdLnh__ zh!4V|U<(sT8^IqU4}gI!jVlRd(F8>E(cx37N-KLBxA!ci7T;@|x7wy~7C@9v+)~jm z<1b5)+!oCHevZ44xZu`$v`Zi?u{G8%y(0S&a;V!(aK}hEV7_X6Q0=)-8l!)n<*t+=a?@uD9m-wz8%sP+2 zK)&JB`g;PVPE$!N*PDEKItF#Jb_kqR&^TsD7c$lF9!^%DhN{jda@SaQorD$VXJm79z9dcD$&xs6`Oae4ij~UBeUV;n=ubT_Xl)kSG}iuA_(2Dv%Ks*Q-nUML z@U>D&&|7`efgK;FZL_$?oozIr@ppC_tS)&QB@w=n>*E@bF)slpmzX@gQH-5G5W<$6+#^>7(ZPrSG{=C zToz*2p~7Xtb~j}aHGc6`x-dR>;@h>X>o^##y_#CUhWAgpay)bQ`ebWw_jKhOzcW;c zL%6D``*ZorbEf2h0lCG16z_mmf%kmg{GHPga?BQdW6@Jx#;l+^7Mm7)WyL~J|8)H& zfql&CD*S?O0HEkQtrHylqeGV>&*vcF1N6DJh}->FZ*Rhc~N3OgiV;?;vklh%%mS#&Y2# z)K+5f)DFNF9JQKdp`ypN5iu~Dwks*=ri?k^t5N+h>In~y$!nR`17yAC_vKI1*_Vp5 zM=8crFmDHUU(F1X2srZA#H4eWI3wP?nshY-XzhKD_8^PDzfuns{MzT!WRK0zvQ>8S zuVCdz8%@fAL?QR314#*j(&XOH@#XxpU_Y$xa3y-?(uqkvngx(nHnhEY+2tS-y| z?vv{ks8Id)baKR@k#BSoJ$Um3hM#Ny$Q9{#8cm$V=dW|qGw|qVXoY+bKB+Kv1*cTs zGRDQuIWk}1dn#KZGz>9by7eVt;L(VU;)=k9sis3;i->lPD7cLu}3Rg15j zO9$gGO1r0vC%a!ul>&Zc`{Em!vF0K1OWad*HDCA7lAxy8NwSlPJge8^m(fh4T^=T~ zUT(WRQ8^uMI~gI>!23Ks9}Xlv*+ElL0^1BX>B0~u?RIx*>`>|LhO5omg$XQT2Kwux zIm1JI-VS_k@FZ%QI5ui}oh6XSDuWvp-6lmm0e-tMb%#cBl(qt9+@vt560l{2lRnrd zsn3BYXPScN_6ST$+|smjEA}s%kJ--^D1m1g&fBB7*RHgxTuYaK;IS5_pFu3~3$TLi zaUQkoxz`h14zkufAyan}p}y4>cY+ae(6E1L4urA6;7$0YSpQhYxN@HJsbfG9)cs}d zf9=4RMA$Sc4~bI*6C&i#|3Jf=Q?G8d6i~&albg_n<%gF+BJ+Q2`D^+EqfZp6)q*RG z{&;1sl}P>8koc~`fMdx6q-s#R#`#-#rM}#FlP_~SW^|kJC!s|9V6lC*5{9s-?XTm-% z=&cq=Z~js`8_8AmhheDdBR4rN2L|a$ zE7b+x5J`&RV-w<=tUspwipcUP@se;zpp&Ao=8cW8y*6y0!H!DW5z&l$L9X|~A7z-j zd?FcB$Z9GdxG4C#R)Xpt#t=Rt=8=9uIQ_-s zR)O~=#2b834V`~7_0b!aRGME`pkDhTlNV%Q9sVln{}OtTm3TNCMN*f_sTo&mc$R5D zNG7+1dTOg0{A)+QyypZz<)a{(qU|4Iws40(9gJA~=kT{3?aa4i3Gpse5j75_j}h7p z=M}=s@QRmi0lBeOjOS4b6K7nR{mXVA~1QH`}9HIkUY zSv=iSJ%HQV%K-Bc*q##M=|viddclL+Y}uPGKx(QsWpkxT&tIenpQrDb90Mi2d7Z+` zYMPB}%(A^{5UA!2fGC2_w1e(@gQu>O#o`Ytpi9tPUq!NKU8u1`DgC(~P4D8>Fm2E( zek*xxD3hZH$+)o&kQqv>;7%WV;^H_#`g7CnwBOr1Fkdvy$Id-Mx#}=MT$U6h#uJP< z#gv~d<&#~0%LHb~I%|p1-dq4{i?&KpvnQo;`_1E>qf$HRDewi5re;Z}Q2^NI@_fdB zt#>L1(~RP9VWTmc6M?Er?vxTp{+ahBGXaM}rv3IU({?hmzX%|PUw*IU- zJib8saF%QrK|1-$!dLDqi_!A(mbF%_>jK%L8w=?M#!$sG`fuCIm&PW5Rq;bnryxBaB5^|u~tjY5GYze4t4xd`U03uG&=`-%0D2JO; zjrtQlwDAoBmdRG-y`)Q^^vTINh(biM0k0*5+s#~l_0V<@ayBp2eTe8*fTQG|mTbIZ zq|+mSG2T9ZY!r4wc@Y(pWclJkgux~(>uxh2ct5&02K(xN45~M+;DoGZ!GM|Ge&9!1 zL=Nm>rSHSh&Ee6@z02hrxc1(_Un2oIka;7hBJiXgAQ| z-ks&^x%){ms?b1N#3%1brKWJ1U!P&lJ* zBoKv3s)cF9%SgYbV~~DJLPX!cOj-4r5~o50NUd2Ol0E}5oUShfQ3$6g;vV8O zIxQ*%JBM|w-;Dksse7wTaL@CF+p7QGsAhB_CZ-|jP55F5Y#dvRj4r9g>p%D!uvf- z;4lrTBciS=-}m}vHM@q<`e$pZ!A6UAA_tW9JVo1w8F-g&Bo0GzQJIk!8YJRkNED}w zi3^lEga%{RYA}0+nV5T_OXlx+Tnuw!h$0+p;F|uxdW^mteO=?YrxR@RfwIxt?Op5C z%95v<85prR2DwAS@)Z$;TG32fw1cE?6Oq49D!k>9fP>AA^hxHf!$l<0-?+zGA}XU% zu!v(5E4y@mH4Z-$Zo3Pg`l$aJcT!~0HSEN{-L;X;{bV4l1?axwT!fryEXDRi8GK1% z?b-5l!UVu_$%*Xnm12iHE%P2)POeyg3@%HEo0J+%Z+UrezkC?%{Q;>!?Q(0?2GI== z(h{`ibdE;P#w+ra8Y>n$QwYjwb{>QNWA~Hq`SJ*d9JXRAH;OE-V6|2Zb(<%c70uO$zzvy~y&Lcq8l-cYd%`)iGW%{qi`0@x zFtPW1i0a;zkehe&`zLL1DwvAYVdLg#*RR5ngzXAQ480r+pRV)$w{fJ-N+%j4qS=PHs&&8T3 zmuE7NM?c5Mk&UtFzqromc6QM99H!vzmHopDlHEymsqC>H&s)O-Wb_teZ=yE*o=w!Q zfGe_F&|JOP|IlV(2ETM#_)BXn;gziuxkqL0q0=%k=du5#BPaJ+{nF2mR7*ytrb^kd zVlg_Fs+nKlpO0DbfG{e*vrEalFe>r~Q&dklA6DLWv=+>_&+w^l`NY}}{GgFJ8gI^y z$gZ3Z)WcB^=L~EfrvA|dp1xAqq-XeTSO>1E!qi_(;H*waylTqNjqDo)Rp%GI9^qO; z34z4uCP3H7`4s)tURg2UoU?zHWo^-^&ig$n9ev3akQO8;ygSevs|IdMR9IX?mo~&O zZEDMf2ehU8)kiEi;Ga&#KlEXncA3BJoU|mapYi<@Z=xreuw;TFGKQgT`zs#za2hk~ zO+D=L-YeFg(dIo1d4OQr$L)ogUAq3$4MT?DS#8ANlf`=L)z`vt=$9LH->%4>GeJIs%tBkG50Zx*ebOh z?yu$*8yN^e(XC1?!8v-r%ohUaR;VKIjYCC&%0c@a}8Zh!0pt#(2wD*5|xO$_eVO?j)T6EfkEQw<-`EL{jB-ve!>!9%H9!n*e7q* zLCp3uTL*va^b&2BFR7m1bW*7gr{zG^gmH;C)k+E5r@wWqY(Exc4~xnyK^XRv5H$RK z=;$Qmw#~~cyf*N60yyq~Z-3U928gi;3hzyVoA0g^R0|7Jh(P)~mTym=pL`OhsaFNwpRscm9tyEm zoa_FasMfi!CN?%Ax9F8g&f2NCKt3!71Q5kWxz?nGi?%>J?NxvprB)z=6EG6VLe|y` z&)?kw`3XpD1}ub&lS=zc9HtsLchTIMZi5uR!Fz9L_0m`yqy z7VBVn11BcUF@%gN8fNR+qpmpYJda*2`GAWsmtAE*j`PjWtd*LU13CD3O&-P8u51DGKceR6A!IVTuOBe7X0HeM6_$fyq=ZaqI8O^jwy-wiK?)vqpuk2TPm=Tn30 zt#!Py2!P;`LsLwGfw3DH7J~vrS3|;wSAyGfV(4!vkc#Up`N}~o{{MQ@|LxlTf3GJf di2nq`AUFTv;#FMq^}YmvwD@setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - menu = new QMenuBar; - layout->setMenuBar(menu); - - menu_tools = menu->addMenu("Tools"); - menu_tools_disassembler = menu_tools->addAction("Disassembler ..."); - menu_tools_breakpoint = menu_tools->addAction("Breakpoint Editor ..."); - menu_tools_memory = menu_tools->addAction("Memory Editor ..."); - menu_tools_propertiesViewer = menu_tools->addAction("Properties Viewer ..."); - - menu_ppu = menu->addMenu("S-PPU"); - menu_ppu_vramViewer = menu_ppu->addAction("Video RAM Viewer ..."); - menu_ppu_oamViewer = menu_ppu->addAction("Sprite Viewer ..."); - menu_ppu_cgramViewer = menu_ppu->addAction("Palette Viewer ..."); - - menu_misc = menu->addMenu("Misc"); - menu_misc_clear = menu_misc->addAction("Clear Console"); - menu_misc_options = menu_misc->addAction("Options ..."); - - console = new QTextEdit; - console->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - console->setReadOnly(true); - console->setFont(QFont(Style::Monospace)); - console->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - console->setMinimumWidth((92 + 4) * console->fontMetrics().width(' ')); - console->setMinimumHeight((25 + 1) * console->fontMetrics().height()); - layout->addWidget(console); - - controlLayout = new QVBoxLayout; - controlLayout->setSpacing(0); - layout->addLayout(controlLayout); - - commandLayout = new QHBoxLayout; - controlLayout->addLayout(commandLayout); - - runBreak = new QPushButton("Break"); - commandLayout->addWidget(runBreak); - commandLayout->addSpacing(Style::WidgetSpacing); - - stepInstruction = new QPushButton("Step"); - commandLayout->addWidget(stepInstruction); - - controlLayout->addSpacing(Style::WidgetSpacing); - - stepCPU = new QCheckBox("Step S-CPU"); - controlLayout->addWidget(stepCPU); - - stepSMP = new QCheckBox("Step S-SMP"); - controlLayout->addWidget(stepSMP); - - traceCPU = new QCheckBox("Trace S-CPU opcodes"); - controlLayout->addWidget(traceCPU); - - traceSMP = new QCheckBox("Trace S-SMP opcodes"); - controlLayout->addWidget(traceSMP); - - traceMask = new QCheckBox("Enable trace mask"); - controlLayout->addWidget(traceMask); - - spacer = new QWidget; - spacer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); - controlLayout->addWidget(spacer); - - tracer = new Tracer; - disassembler = new Disassembler; - breakpointEditor = new BreakpointEditor; - memoryEditor = new MemoryEditor; - propertiesViewer = new PropertiesViewer; - vramViewer = new VramViewer; - oamViewer = new OamViewer; - cgramViewer = new CgramViewer; - debuggerOptions = new DebuggerOptions; - - connect(menu_tools_disassembler, SIGNAL(triggered()), disassembler, SLOT(show())); - connect(menu_tools_breakpoint, SIGNAL(triggered()), breakpointEditor, SLOT(show())); - connect(menu_tools_memory, SIGNAL(triggered()), memoryEditor, SLOT(show())); - connect(menu_tools_propertiesViewer, SIGNAL(triggered()), propertiesViewer, SLOT(show())); - - connect(menu_ppu_vramViewer, SIGNAL(triggered()), vramViewer, SLOT(show())); - connect(menu_ppu_oamViewer, SIGNAL(triggered()), oamViewer, SLOT(show())); - connect(menu_ppu_cgramViewer, SIGNAL(triggered()), cgramViewer, SLOT(show())); - - connect(menu_misc_clear, SIGNAL(triggered()), this, SLOT(clear())); - connect(menu_misc_options, SIGNAL(triggered()), debuggerOptions, SLOT(show())); - - connect(runBreak, SIGNAL(released()), this, SLOT(toggleRunStatus())); - connect(stepInstruction, SIGNAL(released()), this, SLOT(stepAction())); - connect(stepCPU, SIGNAL(released()), this, SLOT(synchronize())); - connect(stepSMP, SIGNAL(released()), this, SLOT(synchronize())); - connect(traceCPU, SIGNAL(stateChanged(int)), tracer, SLOT(setCpuTraceState(int))); - connect(traceSMP, SIGNAL(stateChanged(int)), tracer, SLOT(setSmpTraceState(int))); - connect(traceMask, SIGNAL(stateChanged(int)), tracer, SLOT(setTraceMaskState(int))); - - frameCounter = 0; - synchronize(); - resize(855, 425); -} - -void Debugger::modifySystemState(unsigned state) { - string usagefile = filepath(nall::basename(cartridge.fileName), config().path.data); - usagefile << "-usage.bin"; - file fp; - - if(state == Utility::LoadCartridge) { - if(config().debugger.cacheUsageToDisk && fp.open(usagefile, file::mode::read)) { - fp.read(SNES::cpu.usage, 1 << 24); - fp.read(SNES::smp.usage, 1 << 16); - fp.close(); - } else { - memset(SNES::cpu.usage, 0x00, 1 << 24); - memset(SNES::smp.usage, 0x00, 1 << 16); - } - } - - if(state == Utility::UnloadCartridge) { - if(config().debugger.cacheUsageToDisk && fp.open(usagefile, file::mode::write)) { - fp.write(SNES::cpu.usage, 1 << 24); - fp.write(SNES::smp.usage, 1 << 16); - fp.close(); - } - } -} - -void Debugger::synchronize() { - runBreak->setText(application.debug ? "Run" : "Break"); - stepInstruction->setEnabled(SNES::cartridge.loaded() && application.debug && (stepCPU->isChecked() || stepSMP->isChecked())); - SNES::debugger.step_cpu = application.debug && stepCPU->isChecked(); - SNES::debugger.step_smp = application.debug && stepSMP->isChecked(); - - memoryEditor->synchronize(); -} - -void Debugger::echo(const char *message) { - console->moveCursor(QTextCursor::End); - console->insertHtml(message); -} - -void Debugger::clear() { - console->setHtml(""); -} - -void Debugger::toggleRunStatus() { - application.debug = !application.debug; - if(!application.debug) application.debugrun = false; - synchronize(); -} - -void Debugger::stepAction() { - application.debugrun = true; -} - -void Debugger::event() { - char t[256]; - - switch(SNES::debugger.break_event) { - case SNES::Debugger::BreakEvent::BreakpointHit: { - unsigned n = SNES::debugger.breakpoint_hit; - echo(string() << "Breakpoint " << n << " hit (" << SNES::debugger.breakpoint[n].counter << ").
"); - - if(SNES::debugger.breakpoint[n].source == SNES::Debugger::Breakpoint::Source::CPUBus) { - SNES::debugger.step_cpu = true; - SNES::cpu.disassemble_opcode(t, SNES::cpu.opcode_pc); - string s = t; - s.replace(" ", " "); - echo(string() << "" << s << "
"); - disassembler->refresh(Disassembler::CPU, SNES::cpu.opcode_pc); - } - - if(SNES::debugger.breakpoint[n].source == SNES::Debugger::Breakpoint::Source::APURAM) { - SNES::debugger.step_smp = true; - SNES::smp.disassemble_opcode(t, SNES::smp.opcode_pc); - string s = t; - s.replace(" ", " "); - echo(string() << "" << t << "
"); - disassembler->refresh(Disassembler::SMP, SNES::smp.opcode_pc); - } - } break; - - case SNES::Debugger::BreakEvent::CPUStep: { - SNES::cpu.disassemble_opcode(t, SNES::cpu.regs.pc); - string s = t; - s.replace(" ", " "); - echo(string() << "" << s << "
"); - disassembler->refresh(Disassembler::CPU, SNES::cpu.regs.pc); - } break; - - case SNES::Debugger::BreakEvent::SMPStep: { - SNES::smp.disassemble_opcode(t, SNES::smp.regs.pc); - string s = t; - s.replace(" ", " "); - echo(string() << "" << s << "
"); - disassembler->refresh(Disassembler::SMP, SNES::smp.regs.pc); - } break; - } - - autoUpdate(); -} - -//called once every time a video frame is rendered, used to update "auto refresh" tool windows -void Debugger::frameTick() { - if(++frameCounter >= (SNES::system.region() == SNES::System::Region::NTSC ? 60 : 50)) { - frameCounter = 0; - autoUpdate(); - } -} - -void Debugger::autoUpdate() { - memoryEditor->autoUpdate(); - propertiesViewer->autoUpdate(); - vramViewer->autoUpdate(); - oamViewer->autoUpdate(); - cgramViewer->autoUpdate(); -} - -#endif diff --git a/bsnes/ui-qt/debugger/debugger.moc.hpp b/bsnes/ui-qt/debugger/debugger.moc.hpp deleted file mode 100755 index e2b97e90..00000000 --- a/bsnes/ui-qt/debugger/debugger.moc.hpp +++ /dev/null @@ -1,50 +0,0 @@ -class Debugger : public Window { - Q_OBJECT - -public: - QMenuBar *menu; - QMenu *menu_tools; - QAction *menu_tools_disassembler; - QAction *menu_tools_breakpoint; - QAction *menu_tools_memory; - QAction *menu_tools_propertiesViewer; - QMenu *menu_ppu; - QAction *menu_ppu_vramViewer; - QAction *menu_ppu_oamViewer; - QAction *menu_ppu_cgramViewer; - QMenu *menu_misc; - QAction *menu_misc_clear; - QAction *menu_misc_options; - - QHBoxLayout *layout; - QTextEdit *console; - QVBoxLayout *controlLayout; - QHBoxLayout *commandLayout; - QPushButton *runBreak; - QPushButton *stepInstruction; - QCheckBox *stepCPU; - QCheckBox *stepSMP; - QCheckBox *traceCPU; - QCheckBox *traceSMP; - QCheckBox *traceMask; - QWidget *spacer; - - void modifySystemState(unsigned); - void echo(const char *message); - void event(); - void frameTick(); - void autoUpdate(); - Debugger(); - -public slots: - void clear(); - void synchronize(); - - void toggleRunStatus(); - void stepAction(); - -private: - unsigned frameCounter; -}; - -extern Debugger *debugger; diff --git a/bsnes/ui-qt/debugger/misc/debugger-options.cpp b/bsnes/ui-qt/debugger/misc/debugger-options.cpp deleted file mode 100755 index d0627c36..00000000 --- a/bsnes/ui-qt/debugger/misc/debugger-options.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "debugger-options.moc" -DebuggerOptions *debuggerOptions; - -DebuggerOptions::DebuggerOptions() { - setObjectName("debugger-options"); - setWindowTitle("Debugger Options"); - setGeometryString(&config().geometry.debuggerOptions); - application.windowList.append(this); - - layout = new QVBoxLayout; - layout->setSizeConstraint(QLayout::SetFixedSize); - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - cacheUsageBox = new QCheckBox("Cache memory usage table to disk"); - layout->addWidget(cacheUsageBox); - - synchronize(); - connect(cacheUsageBox, SIGNAL(stateChanged(int)), this, SLOT(toggleCacheUsage())); -} - -void DebuggerOptions::synchronize() { - cacheUsageBox->setChecked(config().debugger.cacheUsageToDisk); -} - -void DebuggerOptions::toggleCacheUsage() { - config().debugger.cacheUsageToDisk = cacheUsageBox->isChecked(); -} diff --git a/bsnes/ui-qt/debugger/misc/debugger-options.moc.hpp b/bsnes/ui-qt/debugger/misc/debugger-options.moc.hpp deleted file mode 100755 index 0043c001..00000000 --- a/bsnes/ui-qt/debugger/misc/debugger-options.moc.hpp +++ /dev/null @@ -1,15 +0,0 @@ -class DebuggerOptions : public Window { - Q_OBJECT - -public: - QVBoxLayout *layout; - QCheckBox *cacheUsageBox; - - void synchronize(); - DebuggerOptions(); - -public slots: - void toggleCacheUsage(); -}; - -extern DebuggerOptions *debuggerOptions; diff --git a/bsnes/ui-qt/debugger/ppu/cgram-viewer.cpp b/bsnes/ui-qt/debugger/ppu/cgram-viewer.cpp deleted file mode 100755 index bd31cfd8..00000000 --- a/bsnes/ui-qt/debugger/ppu/cgram-viewer.cpp +++ /dev/null @@ -1,126 +0,0 @@ -#include "cgram-viewer.moc" -CgramViewer *cgramViewer; - -void CgramViewer::show() { - Window::show(); - refresh(); -} - -void CgramViewer::refresh() { - if(SNES::cartridge.loaded() == false) { - canvas->image->fill(0x000000); - colorInfo->setText(""); - canvas->update(); - return; - } - - uint32_t *buffer = (uint32_t*)canvas->image->bits(); - for(unsigned i = 0; i < 256; i++) { - unsigned x = i % 16; - unsigned y = i / 16; - - uint16_t color = SNES::memory::cgram[i * 2 + 0]; - color |= SNES::memory::cgram[i * 2 + 1] << 8; - - uint8_t r = (color >> 0) & 31; - uint8_t g = (color >> 5) & 31; - uint8_t b = (color >> 10) & 31; - - r = (r << 3) | (r >> 2); - g = (g << 3) | (g >> 2); - b = (b << 3) | (b >> 2); - - uint32_t output = (r << 16) | (g << 8) | (b << 0); - - for(unsigned py = 0; py < 16; py++) { - for(unsigned px = 0; px < 16; px++) { - buffer[(y * 16 + py) * (16 * 16) + (x * 16 + px)] = output; - } - } - - if(i != currentSelection) continue; - - //draw a dotted box black-and-white around the selected color - for(unsigned py = 0; py < 16; py++) { - for(unsigned px = 0; px < 16; px++) { - if(py == 0 || py == 15 || px == 0 || px == 15) { - uint32_t color = ((px + py) & 2) ? 0xffffff : 0x000000; - buffer[(y * 16 + py) * (16 * 16) + (x * 16 + px)] = color; - } - } - } - - string text; - char temp[256]; - text << ""; - text << ""; - sprintf(temp, "%.4x", color); - text << ""; - text << ""; - text << ""; - text << ""; - text << "
Index:" << currentSelection << "
Value:0x" << temp << "
Red:" << (unsigned)(r >> 3) << "
Green:" << (unsigned)(g >> 3) << "
Blue:" << (unsigned)(b >> 3) << "
"; - colorInfo->setText(text); - } - - canvas->update(); -} - -void CgramViewer::autoUpdate() { - if(autoUpdateBox->isChecked()) refresh(); -} - -void CgramViewer::setSelection(unsigned index) { - currentSelection = index; - refresh(); -} - -CgramViewer::CgramViewer() { - setObjectName("cgram-viewer"); - setWindowTitle("Palette Viewer"); - setGeometryString(&config().geometry.cgramViewer); - application.windowList.append(this); - - currentSelection = 0; - - layout = new QHBoxLayout; - layout->setSizeConstraint(QLayout::SetFixedSize); - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - canvas = new Canvas; - canvas->setFixedSize(16 * 16, 16 * 16); - layout->addWidget(canvas); - - controlLayout = new QVBoxLayout; - controlLayout->setAlignment(Qt::AlignTop); - controlLayout->setSpacing(0); - layout->addLayout(controlLayout); - - autoUpdateBox = new QCheckBox("Auto update"); - controlLayout->addWidget(autoUpdateBox); - - refreshButton = new QPushButton("Refresh"); - controlLayout->addWidget(refreshButton); - controlLayout->addSpacing(Style::WidgetSpacing); - - colorInfo = new QLabel; - controlLayout->addWidget(colorInfo); - - connect(refreshButton, SIGNAL(released()), this, SLOT(refresh())); -} - -void CgramViewer::Canvas::mousePressEvent(QMouseEvent *event) { - cgramViewer->setSelection((event->y() / 16) * 16 + (event->x() / 16)); -} - -void CgramViewer::Canvas::paintEvent(QPaintEvent*) { - QPainter painter(this); - painter.drawImage(0, 0, *image); -} - -CgramViewer::Canvas::Canvas() { - image = new QImage(16 * 16, 16 * 16, QImage::Format_RGB32); - image->fill(0x000000); -} diff --git a/bsnes/ui-qt/debugger/ppu/cgram-viewer.moc.hpp b/bsnes/ui-qt/debugger/ppu/cgram-viewer.moc.hpp deleted file mode 100755 index eccb51fd..00000000 --- a/bsnes/ui-qt/debugger/ppu/cgram-viewer.moc.hpp +++ /dev/null @@ -1,29 +0,0 @@ -class CgramViewer : public Window { - Q_OBJECT - -public: - QHBoxLayout *layout; - struct Canvas : public QWidget { - QImage *image; - void mousePressEvent(QMouseEvent*); - void paintEvent(QPaintEvent*); - Canvas(); - } *canvas; - QVBoxLayout *controlLayout; - QCheckBox *autoUpdateBox; - QPushButton *refreshButton; - QLabel *colorInfo; - - void setSelection(unsigned); - void autoUpdate(); - CgramViewer(); - -public slots: - void show(); - void refresh(); - -private: - unsigned currentSelection; -}; - -extern CgramViewer *cgramViewer; diff --git a/bsnes/ui-qt/debugger/ppu/oam-viewer.cpp b/bsnes/ui-qt/debugger/ppu/oam-viewer.cpp deleted file mode 100755 index 09ce00a6..00000000 --- a/bsnes/ui-qt/debugger/ppu/oam-viewer.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "oam-viewer.moc" -OamViewer *oamViewer; - -void OamViewer::show() { - Window::show(); - refresh(); -} - -void OamViewer::refresh() { - canvas->image->fill(0x000000); - - QList items = list->findItems("", Qt::MatchContains); - for(unsigned v = 0; v < items.count(); v++) { - QTreeWidgetItem *item = items[v]; - unsigned i = item->data(0, Qt::UserRole).toUInt(); - - uint8_t d0 = SNES::memory::oam[(i << 2) + 0]; - uint8_t d1 = SNES::memory::oam[(i << 2) + 1]; - uint8_t d2 = SNES::memory::oam[(i << 2) + 2]; - uint8_t d3 = SNES::memory::oam[(i << 2) + 3]; - uint8_t d4 = SNES::memory::oam[512 + (i >> 2)]; - bool x = d4 & (1 << ((i & 3) << 1)); - bool size = d4 & (2 << ((i & 3) << 1)); - - //TODO: create method to expose ChipDebugger::property values by name - unsigned width, height; - switch(0 /*SNES::ppu.oam_base_size()*/) { default: - case 0: width = !size ? 8 : 16; height = !size ? 8 : 16; break; - case 1: width = !size ? 8 : 32; height = !size ? 8 : 32; break; - case 2: width = !size ? 8 : 64; height = !size ? 8 : 64; break; - case 3: width = !size ? 16 : 32; height = !size ? 16 : 32; break; - case 4: width = !size ? 16 : 64; height = !size ? 16 : 64; break; - case 5: width = !size ? 32 : 64; height = !size ? 32 : 64; break; - case 6: width = !size ? 16 : 32; height = !size ? 32 : 64; break; - case 7: width = !size ? 16 : 32; height = !size ? 32 : 32; break; - } - - signed xpos = (x << 8) + d0; - if(xpos > 256) xpos = sclip<9>(xpos); - unsigned ypos = d1; - unsigned character = d2; - unsigned priority = (d3 >> 4) & 3; - unsigned palette = (d3 >> 1) & 7; - string flags; - if(d3 & 0x80) flags << "V"; - if(d3 & 0x40) flags << "H"; - if(d3 & 0x01) flags << "N"; - - item->setText(1, string() << width << "x" << height); - item->setText(2, string() << xpos); - item->setText(3, string() << ypos); - item->setText(4, string() << character); - item->setText(5, string() << priority); - item->setText(6, string() << palette); - item->setText(7, flags); - } - - for(unsigned i = 0; i <= 7; i++) list->resizeColumnToContents(i); - canvas->update(); -} - -void OamViewer::autoUpdate() { - if(autoUpdateBox->isChecked()) refresh(); -} - -OamViewer::OamViewer() { - setObjectName("oam-viewer"); - setWindowTitle("Sprite Viewer"); - setGeometryString(&config().geometry.oamViewer); - application.windowList.append(this); - - layout = new QHBoxLayout; - layout->setAlignment(Qt::AlignLeft); - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - list = new QTreeWidget; - list->setColumnCount(8); - list->setHeaderLabels(QStringList() << "#" << "Size" << "X" << "Y" << "Char" << "Pri" << "Pal" << "Flags"); - list->setAllColumnsShowFocus(true); - list->setAlternatingRowColors(true); - list->setRootIsDecorated(false); - list->setSortingEnabled(false); - layout->addWidget(list); - - for(unsigned i = 0; i < 128; i++) { - QTreeWidgetItem *item = new QTreeWidgetItem(list); - item->setData(0, Qt::UserRole, QVariant(i)); - item->setTextAlignment(0, Qt::AlignHCenter); - item->setTextAlignment(1, Qt::AlignHCenter); - item->setTextAlignment(2, Qt::AlignRight); - item->setTextAlignment(3, Qt::AlignRight); - item->setTextAlignment(4, Qt::AlignRight); - item->setTextAlignment(5, Qt::AlignRight); - item->setTextAlignment(6, Qt::AlignRight); - item->setTextAlignment(7, Qt::AlignLeft); - item->setText(0, string() << i); - } - - controlLayout = new QVBoxLayout; - controlLayout->setAlignment(Qt::AlignTop); - controlLayout->setSpacing(0); - layout->addLayout(controlLayout); - - canvas = new Canvas; - canvas->setFixedSize(128, 128); - controlLayout->addWidget(canvas); - - autoUpdateBox = new QCheckBox("Auto update"); - controlLayout->addWidget(autoUpdateBox); - - refreshButton = new QPushButton("Refresh"); - controlLayout->addWidget(refreshButton); - - connect(refreshButton, SIGNAL(released()), this, SLOT(refresh())); -} - -void OamViewer::Canvas::paintEvent(QPaintEvent*) { - QPainter painter(this); - painter.drawImage(0, 0, *image); -} - -OamViewer::Canvas::Canvas() { - image = new QImage(128, 128, QImage::Format_RGB32); - image->fill(0x000000); -} diff --git a/bsnes/ui-qt/debugger/ppu/oam-viewer.moc.hpp b/bsnes/ui-qt/debugger/ppu/oam-viewer.moc.hpp deleted file mode 100755 index cac515d5..00000000 --- a/bsnes/ui-qt/debugger/ppu/oam-viewer.moc.hpp +++ /dev/null @@ -1,24 +0,0 @@ -class OamViewer : public Window { - Q_OBJECT - -public: - QHBoxLayout *layout; - QTreeWidget *list; - QVBoxLayout *controlLayout; - struct Canvas : public QWidget { - QImage *image; - void paintEvent(QPaintEvent*); - Canvas(); - } *canvas; - QCheckBox *autoUpdateBox; - QPushButton *refreshButton; - - void autoUpdate(); - OamViewer(); - -public slots: - void show(); - void refresh(); -}; - -extern OamViewer *oamViewer; diff --git a/bsnes/ui-qt/debugger/ppu/vram-viewer.cpp b/bsnes/ui-qt/debugger/ppu/vram-viewer.cpp deleted file mode 100755 index 8b9f51a9..00000000 --- a/bsnes/ui-qt/debugger/ppu/vram-viewer.cpp +++ /dev/null @@ -1,177 +0,0 @@ -#include "vram-viewer.moc" -VramViewer *vramViewer; - -VramViewer::VramViewer() { - setObjectName("vram-viewer"); - setWindowTitle("Video RAM Viewer"); - setGeometryString(&config().geometry.vramViewer); - application.windowList.append(this); - - layout = new QVBoxLayout; - layout->setSizeConstraint(QLayout::SetFixedSize); - layout->setAlignment(Qt::AlignCenter); - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - controlLayout = new QHBoxLayout; - controlLayout->setSizeConstraint(QLayout::SetMinimumSize); - controlLayout->setAlignment(Qt::AlignRight); - layout->addLayout(controlLayout); - - depth2bpp = new QRadioButton("2 BPP"); - controlLayout->addWidget(depth2bpp); - - depth4bpp = new QRadioButton("4 BPP"); - controlLayout->addWidget(depth4bpp); - - depth8bpp = new QRadioButton("8 BPP"); - controlLayout->addWidget(depth8bpp); - - depthMode7 = new QRadioButton("Mode 7"); - controlLayout->addWidget(depthMode7); - - autoUpdateBox = new QCheckBox("Auto update"); - controlLayout->addWidget(autoUpdateBox); - - refreshButton = new QPushButton("Refresh"); - controlLayout->addWidget(refreshButton); - - canvas = new Canvas; - canvas->setFixedSize(512, 512); - layout->addWidget(canvas); - - bpp = 2; - depth2bpp->setChecked(true); - - connect(refreshButton, SIGNAL(released()), this, SLOT(refresh())); - connect(depth2bpp, SIGNAL(pressed()), this, SLOT(setDepth2bpp())); - connect(depth4bpp, SIGNAL(pressed()), this, SLOT(setDepth4bpp())); - connect(depth8bpp, SIGNAL(pressed()), this, SLOT(setDepth8bpp())); - connect(depthMode7, SIGNAL(pressed()), this, SLOT(setDepthMode7())); -} - -void VramViewer::autoUpdate() { - if(autoUpdateBox->isChecked()) refresh(); -} - -void VramViewer::show() { - Window::show(); - refresh(); -} - -void VramViewer::refresh() { - canvas->image->fill(0x800000); - if(SNES::cartridge.loaded()) { - const uint8_t *source = SNES::memory::vram.data(); - uint32_t *dest = (uint32_t*)canvas->image->bits(); - if(bpp == 2) refresh2bpp (source, dest); - if(bpp == 4) refresh4bpp (source, dest); - if(bpp == 8) refresh8bpp (source, dest); - if(bpp == 7) refreshMode7(source, dest); - } - canvas->update(); -} - -void VramViewer::refresh2bpp(const uint8_t *source, uint32_t *dest) { - for(unsigned ty = 0; ty < 64; ty++) { - for(unsigned tx = 0; tx < 64; tx++) { - for(unsigned py = 0; py < 8; py++) { - uint8_t d0 = source[0]; - uint8_t d1 = source[1]; - for(unsigned px = 0; px < 8; px++) { - uint8_t pixel = 0; - pixel |= (d0 & (0x80 >> px)) ? 1 : 0; - pixel |= (d1 & (0x80 >> px)) ? 2 : 0; - pixel *= 0x55; - dest[(ty * 8 + py) * 512 + (tx * 8 + px)] = (pixel << 16) + (pixel << 8) + pixel; - } - source += 2; - } - } - } -} - -void VramViewer::refresh4bpp(const uint8_t *source, uint32_t *dest) { - for(unsigned ty = 0; ty < 32; ty++) { - for(unsigned tx = 0; tx < 64; tx++) { - for(unsigned py = 0; py < 8; py++) { - uint8_t d0 = source[ 0]; - uint8_t d1 = source[ 1]; - uint8_t d2 = source[16]; - uint8_t d3 = source[17]; - for(unsigned px = 0; px < 8; px++) { - uint8_t pixel = 0; - pixel |= (d0 & (0x80 >> px)) ? 1 : 0; - pixel |= (d1 & (0x80 >> px)) ? 2 : 0; - pixel |= (d2 & (0x80 >> px)) ? 4 : 0; - pixel |= (d3 & (0x80 >> px)) ? 8 : 0; - pixel *= 0x11; - dest[(ty * 8 + py) * 512 + (tx * 8 + px)] = (pixel << 16) + (pixel << 8) + pixel; - } - source += 2; - } - source += 16; - } - } -} - -void VramViewer::refresh8bpp(const uint8_t *source, uint32_t *dest) { - for(unsigned ty = 0; ty < 16; ty++) { - for(unsigned tx = 0; tx < 64; tx++) { - for(unsigned py = 0; py < 8; py++) { - uint8_t d0 = source[ 0]; - uint8_t d1 = source[ 1]; - uint8_t d2 = source[16]; - uint8_t d3 = source[17]; - uint8_t d4 = source[32]; - uint8_t d5 = source[33]; - uint8_t d6 = source[48]; - uint8_t d7 = source[49]; - for(unsigned px = 0; px < 8; px++) { - uint8_t pixel = 0; - pixel |= (d0 & (0x80 >> px)) ? 0x01 : 0; - pixel |= (d1 & (0x80 >> px)) ? 0x02 : 0; - pixel |= (d2 & (0x80 >> px)) ? 0x04 : 0; - pixel |= (d3 & (0x80 >> px)) ? 0x08 : 0; - pixel |= (d4 & (0x80 >> px)) ? 0x10 : 0; - pixel |= (d5 & (0x80 >> px)) ? 0x20 : 0; - pixel |= (d6 & (0x80 >> px)) ? 0x40 : 0; - pixel |= (d7 & (0x80 >> px)) ? 0x80 : 0; - dest[(ty * 8 + py) * 512 + (tx * 8 + px)] = (pixel << 16) + (pixel << 8) + pixel; - } - source += 2; - } - source += 48; - } - } -} - -void VramViewer::refreshMode7(const uint8_t *source, uint32_t *dest) { - for(unsigned ty = 0; ty < 16; ty++) { - for(unsigned tx = 0; tx < 16; tx++) { - for(unsigned py = 0; py < 8; py++) { - for(unsigned px = 0; px < 8; px++) { - uint8_t pixel = source[1]; - dest[(ty * 8 + py) * 512 + (tx * 8 + px)] = (pixel << 16) + (pixel << 8) + pixel; - source += 2; - } - } - } - } -} - -void VramViewer::setDepth2bpp() { bpp = 2; refresh(); } -void VramViewer::setDepth4bpp() { bpp = 4; refresh(); } -void VramViewer::setDepth8bpp() { bpp = 8; refresh(); } -void VramViewer::setDepthMode7() { bpp = 7; refresh(); } - -void VramViewer::Canvas::paintEvent(QPaintEvent*) { - QPainter painter(this); - painter.drawImage(0, 0, *image); -} - -VramViewer::Canvas::Canvas() { - image = new QImage(512, 512, QImage::Format_RGB32); - image->fill(0x800000); -} diff --git a/bsnes/ui-qt/debugger/ppu/vram-viewer.moc.hpp b/bsnes/ui-qt/debugger/ppu/vram-viewer.moc.hpp deleted file mode 100755 index d97ee495..00000000 --- a/bsnes/ui-qt/debugger/ppu/vram-viewer.moc.hpp +++ /dev/null @@ -1,38 +0,0 @@ -class VramViewer : public Window { - Q_OBJECT - -public: - QVBoxLayout *layout; - QHBoxLayout *controlLayout; - QRadioButton *depth2bpp; - QRadioButton *depth4bpp; - QRadioButton *depth8bpp; - QRadioButton *depthMode7; - QCheckBox *autoUpdateBox; - QPushButton *refreshButton; - struct Canvas : public QWidget { - QImage *image; - void paintEvent(QPaintEvent*); - Canvas(); - } *canvas; - - void autoUpdate(); - VramViewer(); - -public slots: - void show(); - void refresh(); - void setDepth2bpp(); - void setDepth4bpp(); - void setDepth8bpp(); - void setDepthMode7(); - -private: - unsigned bpp; - void refresh2bpp(const uint8_t*, uint32_t*); - void refresh4bpp(const uint8_t*, uint32_t*); - void refresh8bpp(const uint8_t*, uint32_t*); - void refreshMode7(const uint8_t*, uint32_t*); -}; - -extern VramViewer *vramViewer; diff --git a/bsnes/ui-qt/debugger/tools/breakpoint.cpp b/bsnes/ui-qt/debugger/tools/breakpoint.cpp deleted file mode 100755 index 94ec117b..00000000 --- a/bsnes/ui-qt/debugger/tools/breakpoint.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "breakpoint.moc" -BreakpointEditor *breakpointEditor; - -BreakpointItem::BreakpointItem(unsigned id_) : id(id_) { - layout = new QHBoxLayout; - layout->setMargin(0); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - enabled = new QCheckBox; - layout->addWidget(enabled); - - addr = new QLineEdit; - addr->setFixedWidth(80); - layout->addWidget(addr); - - data = new QLineEdit; - data->setFixedWidth(40); - layout->addWidget(data); - - mode = new QComboBox; - mode->addItem("Exec"); - mode->addItem("Read"); - mode->addItem("Write"); - layout->addWidget(mode); - - source = new QComboBox; - source->addItem("S-CPU bus"); - source->addItem("S-SMP bus"); - source->addItem("S-PPU VRAM"); - source->addItem("S-PPU OAM"); - source->addItem("S-PPU CGRAM"); - layout->addWidget(source); - - connect(enabled, SIGNAL(stateChanged(int)), this, SLOT(toggle())); -} - -void BreakpointItem::toggle() { - bool state = enabled->isChecked(); - - if(state) { - SNES::debugger.breakpoint[id].enabled = true; - SNES::debugger.breakpoint[id].addr = hex(addr->text().toUtf8().data()) & 0xffffff; - SNES::debugger.breakpoint[id].data = hex(data->text().toUtf8().data()) & 0xff; - if(data->text().length() == 0) SNES::debugger.breakpoint[id].data = -1; - SNES::debugger.breakpoint[id].mode = (SNES::Debugger::Breakpoint::Mode)mode->currentIndex(); - SNES::debugger.breakpoint[id].source = (SNES::Debugger::Breakpoint::Source)source->currentIndex(); - SNES::debugger.breakpoint[id].counter = 0; - - addr->setEnabled(false); - data->setEnabled(false); - mode->setEnabled(false); - source->setEnabled(false); - } else { - SNES::debugger.breakpoint[id].enabled = false; - - addr->setEnabled(true); - data->setEnabled(true); - mode->setEnabled(true); - source->setEnabled(true); - } -} - -BreakpointEditor::BreakpointEditor() { - setObjectName("breakpoint-editor"); - setWindowTitle("Breakpoint Editor"); - setGeometryString(&config().geometry.breakpointEditor); - application.windowList.append(this); - - layout = new QVBoxLayout; - layout->setSizeConstraint(QLayout::SetFixedSize); - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - for(unsigned n = 0; n < SNES::Debugger::Breakpoints; n++) { - breakpoint[n] = new BreakpointItem(n); - layout->addWidget(breakpoint[n]); - } -} diff --git a/bsnes/ui-qt/debugger/tools/breakpoint.moc.hpp b/bsnes/ui-qt/debugger/tools/breakpoint.moc.hpp deleted file mode 100755 index 6c5b2ae6..00000000 --- a/bsnes/ui-qt/debugger/tools/breakpoint.moc.hpp +++ /dev/null @@ -1,30 +0,0 @@ -class BreakpointItem : public QWidget { - Q_OBJECT - -public: - QHBoxLayout *layout; - QCheckBox *enabled; - QLineEdit *addr; - QLineEdit *data; - QComboBox *mode; - QComboBox *source; - BreakpointItem(unsigned id); - -public slots: - void toggle(); - -private: - const unsigned id; -}; - -class BreakpointEditor : public Window { - Q_OBJECT - -public: - QVBoxLayout *layout; - BreakpointItem *breakpoint[SNES::Debugger::Breakpoints]; - - BreakpointEditor(); -}; - -extern BreakpointEditor *breakpointEditor; diff --git a/bsnes/ui-qt/debugger/tools/disassembler.cpp b/bsnes/ui-qt/debugger/tools/disassembler.cpp deleted file mode 100755 index 18098a46..00000000 --- a/bsnes/ui-qt/debugger/tools/disassembler.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "disassembler.moc" -CPUDisassembler *cpuDisassembler; -SMPDisassembler *smpDisassembler; -Disassembler *disassembler; - -CPUDisassembler::CPUDisassembler() { - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - view = new QTextEdit; - view->setReadOnly(true); - view->setFont(QFont(Style::Monospace)); - view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view->setMinimumHeight((25 + 1) * view->fontMetrics().height()); - layout->addWidget(view); -} - -SMPDisassembler::SMPDisassembler() { - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - view = new QTextEdit; - view->setReadOnly(true); - view->setFont(QFont(Style::Monospace)); - view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view->setMinimumHeight((25 + 1) * view->fontMetrics().height()); - layout->addWidget(view); -} - -Disassembler::Disassembler() { - setObjectName("disassembler"); - setWindowTitle("Disassembler"); - setGeometryString(&config().geometry.disassembler); - application.windowList.append(this); - - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - cpuDisassembler = new CPUDisassembler; - smpDisassembler = new SMPDisassembler; - - tab = new QTabWidget; - tab->addTab(cpuDisassembler, "S-CPU"); - tab->addTab(smpDisassembler, "S-SMP"); - layout->addWidget(tab); -} - -void Disassembler::refresh(Source source, unsigned addr) { - uint8_t *usage; - unsigned mask; - if(source == CPU) { usage = SNES::cpu.usage; mask = (1 << 24) - 1; } - if(source == SMP) { usage = SNES::smp.usage; mask = (1 << 16) - 1; } - - int line[25]; - for(unsigned i = 0; i < 25; i++) line[i] = -1; - - line[12] = addr; - - for(signed index = 11; index >= 0; index--) { - int base = line[index + 1]; - if(base == -1) break; - - for(unsigned i = 1; i <= 4; i++) { - if(usage[(base - i) & mask] & 0x20) { - line[index] = base - i; - break; - } - } - } - - for(signed index = 13; index <= 24; index++) { - int base = line[index - 1]; - if(base == -1) break; - - for(unsigned i = 1; i <= 4; i++) { - if(usage[(base + i) & mask] & 0x20) { - line[index] = base + i; - break; - } - } - } - - string output; - for(unsigned i = 0; i < 25; i++) { - if(i < 12) output << ""; - else if(i == 12) output << ""; - else output << ""; - - if(line[i] == -1) { - output << "..."; - } else { - char t[256]; - if(source == CPU) { SNES::cpu.disassemble_opcode(t, line[i]); t[20] = 0; } - if(source == SMP) { SNES::smp.disassemble_opcode(t, line[i]); t[23] = 0; } - string text = rtrim(t); - text.replace(" ", " "); - output << text; - } - - output << ""; - if(i != 24) output << "
"; - } - - if(source == CPU) cpuDisassembler->view->setHtml(output); - if(source == SMP) smpDisassembler->view->setHtml(output); -} diff --git a/bsnes/ui-qt/debugger/tools/disassembler.moc.hpp b/bsnes/ui-qt/debugger/tools/disassembler.moc.hpp deleted file mode 100755 index 9bddd054..00000000 --- a/bsnes/ui-qt/debugger/tools/disassembler.moc.hpp +++ /dev/null @@ -1,29 +0,0 @@ -class CPUDisassembler : public QWidget { -public: - QVBoxLayout *layout; - QTextEdit *view; - CPUDisassembler(); -}; - -class SMPDisassembler : public QWidget { -public: - QVBoxLayout *layout; - QTextEdit *view; - SMPDisassembler(); -}; - -class Disassembler : public Window { - Q_OBJECT - -public: - QVBoxLayout *layout; - QTabWidget *tab; - - enum Source { CPU, SMP }; - void refresh(Source, unsigned); - Disassembler(); -}; - -extern CPUDisassembler *cpuDisassembler; -extern SMPDisassembler *smpDisassembler; -extern Disassembler *disassembler; diff --git a/bsnes/ui-qt/debugger/tools/memory.cpp b/bsnes/ui-qt/debugger/tools/memory.cpp deleted file mode 100755 index ac0c55fc..00000000 --- a/bsnes/ui-qt/debugger/tools/memory.cpp +++ /dev/null @@ -1,165 +0,0 @@ -#include "memory.moc" -MemoryEditor *memoryEditor; - -MemoryEditor::MemoryEditor() { - setObjectName("memory-editor"); - setWindowTitle("Memory Editor"); - setGeometryString(&config().geometry.memoryEditor); - application.windowList.append(this); - - layout = new QHBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - editor = new HexEditor; - editor->reader = { &MemoryEditor::reader, this }; - editor->writer = { &MemoryEditor::writer, this }; - editor->setFont(QFont(Style::Monospace)); - editor->setMinimumWidth((editor->lineWidth() + 3) * editor->fontMetrics().width(' ')); - editor->setMinimumHeight((16 + 1) * editor->fontMetrics().height()); - editor->setSize(16 * 1024 * 1024); - memorySource = SNES::Debugger::MemorySource::CPUBus; - layout->addWidget(editor); - - controlLayout = new QVBoxLayout; - controlLayout->setSpacing(0); - layout->addLayout(controlLayout); - - source = new QComboBox; - source->addItem("S-CPU bus"); - source->addItem("S-APU bus"); - source->addItem("S-PPU VRAM"); - source->addItem("S-PPU OAM"); - source->addItem("S-PPU CGRAM"); - controlLayout->addWidget(source); - controlLayout->addSpacing(2); - - addr = new QLineEdit; - controlLayout->addWidget(addr); - - autoUpdateBox = new QCheckBox("Auto update"); - controlLayout->addWidget(autoUpdateBox); - - refreshButton = new QPushButton("Refresh"); - controlLayout->addWidget(refreshButton); - - spacer = new QWidget; - spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); - controlLayout->addWidget(spacer); - - exportButton = new QPushButton("Export"); - controlLayout->addWidget(exportButton); - - importButton = new QPushButton("Import"); - controlLayout->addWidget(importButton); - - connect(source, SIGNAL(currentIndexChanged(int)), this, SLOT(sourceChanged(int))); - connect(addr, SIGNAL(textEdited(const QString&)), this, SLOT(updateOffset())); - connect(addr, SIGNAL(returnPressed()), this, SLOT(updateOffset())); - connect(refreshButton, SIGNAL(released()), this, SLOT(refresh())); - connect(exportButton, SIGNAL(released()), this, SLOT(exportMemory())); - connect(importButton, SIGNAL(released()), this, SLOT(importMemory())); -} - -void MemoryEditor::autoUpdate() { - if(SNES::cartridge.loaded() && autoUpdateBox->isChecked()) editor->refresh(); -} - -void MemoryEditor::synchronize() { - if(SNES::cartridge.loaded() == false) { - editor->setHtml(""); - source->setEnabled(false); - addr->setEnabled(false); - autoUpdateBox->setEnabled(false); - refreshButton->setEnabled(false); - exportButton->setEnabled(false); - importButton->setEnabled(false); - } else { - source->setEnabled(true); - addr->setEnabled(true); - autoUpdateBox->setEnabled(true); - refreshButton->setEnabled(true); - exportButton->setEnabled(true); - importButton->setEnabled(true); - } -} - -void MemoryEditor::show() { - Window::show(); - refresh(); -} - -void MemoryEditor::sourceChanged(int index) { - switch(index) { default: - case 0: memorySource = SNES::Debugger::MemorySource::CPUBus; editor->setSize(16 * 1024 * 1024); break; - case 1: memorySource = SNES::Debugger::MemorySource::APURAM; editor->setSize(64 * 1024); break; - case 2: memorySource = SNES::Debugger::MemorySource::VRAM; editor->setSize(64 * 1024); break; - case 3: memorySource = SNES::Debugger::MemorySource::OAM; editor->setSize(544); break; - case 4: memorySource = SNES::Debugger::MemorySource::CGRAM; editor->setSize(512); break; - } - - editor->setOffset(hex(addr->text().toUtf8().data())); - editor->refresh(); -} - -void MemoryEditor::refresh() { - if(SNES::cartridge.loaded() == false) { - editor->setHtml(""); - } else { - editor->refresh(); - } -} - -void MemoryEditor::updateOffset() { - editor->setOffset(hex(addr->text().toUtf8().data())); - refresh(); -} - -void MemoryEditor::exportMemory() { - string basename = filepath(nall::basename(cartridge.fileName), config().path.data); - - exportMemory(SNES::memory::cartram, string() << basename << "-sram.bin"); - exportMemory(SNES::memory::wram, string() << basename << "-wram.bin"); - exportMemory(SNES::memory::apuram, string() << basename << "-apuram.bin"); - exportMemory(SNES::memory::vram, string() << basename << "-vram.bin"); - exportMemory(SNES::memory::oam, string() << basename << "-oam.bin"); - exportMemory(SNES::memory::cgram, string() << basename << "-cgram.bin"); -} - -void MemoryEditor::importMemory() { - string basename = filepath(nall::basename(cartridge.fileName), config().path.data); - - importMemory(SNES::memory::cartram, string() << basename << "-sram.bin"); - importMemory(SNES::memory::wram, string() << basename << "-wram.bin"); - importMemory(SNES::memory::apuram, string() << basename << "-apuram.bin"); - importMemory(SNES::memory::vram, string() << basename << "-vram.bin"); - importMemory(SNES::memory::oam, string() << basename << "-oam.bin"); - importMemory(SNES::memory::cgram, string() << basename << "-cgram.bin"); - refresh(); //in case import changed values that are currently being displayed ... -} - -void MemoryEditor::exportMemory(SNES::Memory &memory, const string &filename) const { - file fp; - if(fp.open(filename, file::mode::write)) { - for(unsigned i = 0; i < memory.size(); i++) fp.write(memory.read(i)); - fp.close(); - } -} - -void MemoryEditor::importMemory(SNES::Memory &memory, const string &filename) const { - file fp; - if(fp.open(filename, file::mode::read)) { - unsigned filesize = fp.size(); - for(unsigned i = 0; i < memory.size() && i < filesize; i++) memory.write(i, fp.read()); - fp.close(); - } -} - -uint8_t MemoryEditor::reader(unsigned addr) { - return SNES::debugger.read(memorySource, addr); -} - -void MemoryEditor::writer(unsigned addr, uint8_t data) { - SNES::debugger.write(memorySource, addr, data); -} diff --git a/bsnes/ui-qt/debugger/tools/memory.moc.hpp b/bsnes/ui-qt/debugger/tools/memory.moc.hpp deleted file mode 100755 index a81332e4..00000000 --- a/bsnes/ui-qt/debugger/tools/memory.moc.hpp +++ /dev/null @@ -1,36 +0,0 @@ -class MemoryEditor : public Window { - Q_OBJECT - -public: - QHBoxLayout *layout; - HexEditor *editor; - QVBoxLayout *controlLayout; - QComboBox *source; - QLineEdit *addr; - QCheckBox *autoUpdateBox; - QPushButton *refreshButton; - QWidget *spacer; - QPushButton *exportButton; - QPushButton *importButton; - - void autoUpdate(); - void synchronize(); - - SNES::Debugger::MemorySource memorySource; - uint8_t reader(unsigned addr); - void writer(unsigned addr, uint8_t data); - - MemoryEditor(); - -public slots: - void show(); - void sourceChanged(int); - void refresh(); - void updateOffset(); - void exportMemory(); - void importMemory(); - void exportMemory(SNES::Memory&, const string&) const; - void importMemory(SNES::Memory&, const string&) const; -}; - -extern MemoryEditor *memoryEditor; diff --git a/bsnes/ui-qt/debugger/tools/properties.cpp b/bsnes/ui-qt/debugger/tools/properties.cpp deleted file mode 100755 index b748b745..00000000 --- a/bsnes/ui-qt/debugger/tools/properties.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "properties.moc" -PropertiesWidget *cpuPropertiesTab; -PropertiesWidget *smpPropertiesTab; -PropertiesWidget *ppuPropertiesTab; -PropertiesWidget *dspPropertiesTab; -PropertiesViewer *propertiesViewer; - -void PropertiesWidget::refresh() { - QList items = list->findItems("", Qt::MatchContains); - for(unsigned v = 0; v < items.count(); v++) { - QTreeWidgetItem *item = items[v]; - unsigned id = item->data(0, Qt::UserRole).toUInt(); - string name, value; - object.property(id, name, value); - item->setText(1, value); - } -} - -PropertiesWidget::PropertiesWidget(SNES::ChipDebugger &object) : object(object) { - setMinimumSize(480, 240); - - layout = new QVBoxLayout; - setLayout(layout); - - list = new QTreeWidget; - list->setColumnCount(2); - list->setHeaderLabels(QStringList() << "Name" << "Value"); - list->setAllColumnsShowFocus(true); - list->setAlternatingRowColors(true); - list->setRootIsDecorated(false); - list->setSortingEnabled(false); - layout->addWidget(list); - - unsigned counter = 0; - while(true) { - string name, value; - bool result = object.property(counter, name, value); - if(result == false) break; - - QTreeWidgetItem *item = new QTreeWidgetItem(list); - item->setData(0, Qt::UserRole, QVariant(counter++)); - item->setText(0, name); - } - for(unsigned i = 0; i <= 1; i++) list->resizeColumnToContents(i); -} - -void PropertiesViewer::refresh() { - cpuPropertiesTab->refresh(); - smpPropertiesTab->refresh(); - ppuPropertiesTab->refresh(); - dspPropertiesTab->refresh(); -} - -void PropertiesViewer::show() { - Window::show(); - refresh(); -} - -void PropertiesViewer::autoUpdate() { - if(autoUpdateBox->isChecked()) refresh(); -} - -PropertiesViewer::PropertiesViewer() { - setObjectName("properties-viewer"); - setWindowTitle("Properties"); - setGeometryString(&config().geometry.propertiesViewer); - application.windowList.append(this); - - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - tabWidget = new QTabWidget; - layout->addWidget(tabWidget); - - cpuPropertiesTab = new PropertiesWidget(SNES::cpu); - tabWidget->addTab(cpuPropertiesTab, "S-CPU"); - - smpPropertiesTab = new PropertiesWidget(SNES::smp); - tabWidget->addTab(smpPropertiesTab, "S-SMP"); - - ppuPropertiesTab = new PropertiesWidget(SNES::ppu); - tabWidget->addTab(ppuPropertiesTab, "S-PPU"); - - dspPropertiesTab = new PropertiesWidget(SNES::dsp); - tabWidget->addTab(dspPropertiesTab, "S-DSP"); - - controlLayout = new QHBoxLayout; - controlLayout->setAlignment(Qt::AlignRight); - layout->addLayout(controlLayout); - - autoUpdateBox = new QCheckBox("Auto update"); - controlLayout->addWidget(autoUpdateBox); - - refreshButton = new QPushButton("Refresh"); - controlLayout->addWidget(refreshButton); - - connect(refreshButton, SIGNAL(released()), this, SLOT(refresh())); -} diff --git a/bsnes/ui-qt/debugger/tools/properties.moc.hpp b/bsnes/ui-qt/debugger/tools/properties.moc.hpp deleted file mode 100755 index f1df0fbe..00000000 --- a/bsnes/ui-qt/debugger/tools/properties.moc.hpp +++ /dev/null @@ -1,39 +0,0 @@ -class PropertiesWidget : public QWidget { - Q_OBJECT - -public: - QVBoxLayout *layout; - QTreeWidget *list; - - PropertiesWidget(SNES::ChipDebugger &object); - -public slots: - void refresh(); - -private: - SNES::ChipDebugger &object; -}; - -class PropertiesViewer : public Window { - Q_OBJECT - -public: - QVBoxLayout *layout; - QTabWidget *tabWidget; - QHBoxLayout *controlLayout; - QCheckBox *autoUpdateBox; - QPushButton *refreshButton; - - void autoUpdate(); - PropertiesViewer(); - -public slots: - void refresh(); - void show(); -}; - -extern PropertiesWidget *cpuPropertiesTab; -extern PropertiesWidget *smpPropertiesTab; -extern PropertiesWidget *ppuPropertiesTab; -extern PropertiesWidget *dspPropertiesTab; -extern PropertiesViewer *propertiesViewer; diff --git a/bsnes/ui-qt/debugger/tracer.cpp b/bsnes/ui-qt/debugger/tracer.cpp deleted file mode 100755 index 42898d1c..00000000 --- a/bsnes/ui-qt/debugger/tracer.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "tracer.moc" -Tracer *tracer; - -void Tracer::stepCpu() { - if(traceCpu) { - unsigned addr = SNES::cpu.regs.pc; - if(!traceMask || !(traceMaskCPU[addr >> 3] & (0x80 >> (addr & 7)))) { - char text[256]; - SNES::cpu.disassemble_opcode(text, addr); - tracefile.print(string() << text << "\n"); - } - traceMaskCPU[addr >> 3] |= 0x80 >> (addr & 7); - } -} - -void Tracer::stepSmp() { - if(traceSmp) { - unsigned addr = SNES::smp.regs.pc; - if(!traceMask || !(traceMaskSMP[addr >> 3] & (0x80 >> (addr & 7)))) { - char text[256]; - SNES::smp.disassemble_opcode(text, addr); - tracefile.print(string() << text << "\n"); - } - traceMaskSMP[addr >> 3] |= 0x80 >> (addr & 7); - } -} - -void Tracer::setCpuTraceState(int state) { - traceCpu = (state == Qt::Checked); - - if(traceCpu && !tracefile.open()) { - tracefile.open(string() << config().path.data << "trace.log", file::mode::write); - } else if(!traceCpu && !traceSmp && tracefile.open()) { - tracefile.close(); - } -} - -void Tracer::setSmpTraceState(int state) { - traceSmp = (state == Qt::Checked); - - if(traceSmp && !tracefile.open()) { - tracefile.open(string() << config().path.data << "trace.log", file::mode::write); - } else if(!traceCpu && !traceSmp && tracefile.open()) { - tracefile.close(); - } -} - -void Tracer::setTraceMaskState(int state) { - traceMask = (state == Qt::Checked); - - if(traceMask) { - //flush all bitmasks once enabled - memset(traceMaskCPU, 0x00, (1 << 24) >> 3); - memset(traceMaskSMP, 0x00, (1 << 16) >> 3); - } -} - -Tracer::Tracer() { - traceCpu = false; - traceSmp = false; - traceMask = false; - - traceMaskCPU = new uint8_t[(1 << 24) >> 3](); - traceMaskSMP = new uint8_t[(1 << 16) >> 3](); - - SNES::cpu.step_event = { &Tracer::stepCpu, this }; - SNES::smp.step_event = { &Tracer::stepSmp, this }; -} - -Tracer::~Tracer() { - delete[] traceMaskCPU; - delete[] traceMaskSMP; - if(tracefile.open()) tracefile.close(); -} diff --git a/bsnes/ui-qt/debugger/tracer.moc.hpp b/bsnes/ui-qt/debugger/tracer.moc.hpp deleted file mode 100755 index e67b855f..00000000 --- a/bsnes/ui-qt/debugger/tracer.moc.hpp +++ /dev/null @@ -1,26 +0,0 @@ -class Tracer : public QObject { - Q_OBJECT - -public: - void stepCpu(); - void stepSmp(); - - Tracer(); - ~Tracer(); - -public slots: - void setCpuTraceState(int); - void setSmpTraceState(int); - void setTraceMaskState(int); - -private: - file tracefile; - bool traceCpu; - bool traceSmp; - bool traceMask; - - uint8_t *traceMaskCPU; - uint8_t *traceMaskSMP; -}; - -extern Tracer *tracer; diff --git a/bsnes/ui-qt/input/controller.cpp b/bsnes/ui-qt/input/controller.cpp deleted file mode 100755 index 22d6ab68..00000000 --- a/bsnes/ui-qt/input/controller.cpp +++ /dev/null @@ -1,385 +0,0 @@ -namespace Controllers { - -void TurboInput::cache() { - if(state) { - cachedState = (counter < holdHi ? state : 0); - if(++counter >= holdHi + holdLo) counter = 0; - } else { - cachedState = 0; - counter = 0; - } -} - -TurboInput::TurboInput(const char *label, const char *configName) : -DigitalInput(label, configName) { - holdHi = 2; - holdLo = 2; - counter = 0; -} - -int16_t Gamepad::status(unsigned index, unsigned id) const { - if(config().input.allowInvalidInput == false) { - //block up+down and left+right combinations: - //a real gamepad has a pivot in the D-pad that makes this impossible; - //some software titles will crash if up+down or left+right are detected - if(id == (unsigned)SNES::Input::JoypadID::Down && up.cachedState) return 0; - if(id == (unsigned)SNES::Input::JoypadID::Right && left.cachedState) return 0; - } - - switch(id) { - case SNES::Input::JoypadID::Up: return up.cachedState; - case SNES::Input::JoypadID::Down: return down.cachedState; - case SNES::Input::JoypadID::Left: return left.cachedState; - case SNES::Input::JoypadID::Right: return right.cachedState; - case SNES::Input::JoypadID::A: return a.cachedState | turboA.cachedState; - case SNES::Input::JoypadID::B: return b.cachedState | turboB.cachedState; - case SNES::Input::JoypadID::X: return x.cachedState | turboX.cachedState; - case SNES::Input::JoypadID::Y: return y.cachedState | turboY.cachedState; - case SNES::Input::JoypadID::L: return l.cachedState | turboL.cachedState; - case SNES::Input::JoypadID::R: return r.cachedState | turboR.cachedState; - case SNES::Input::JoypadID::Select: return select.cachedState; - case SNES::Input::JoypadID::Start: return start.cachedState; - } - return 0; -} - -Gamepad::Gamepad(unsigned category, const char *label, const char *configName) : -InputGroup(category, label), -up("Up", string() << "input." << configName << ".up"), -down("Down", string() << "input." << configName << ".down"), -left("Left", string() << "input." << configName << ".left"), -right("Right", string() << "input." << configName << ".right"), -b("B", string() << "input." << configName << ".b"), -a("A", string() << "input." << configName << ".a"), -y("Y", string() << "input." << configName << ".y"), -x("X", string() << "input." << configName << ".x"), -l("L", string() << "input." << configName << ".l"), -r("R", string() << "input." << configName << ".r"), -select("Select", string() << "input." << configName << ".select"), -start("Start", string() << "input." << configName << ".start"), -turboB("Turbo B", string() << "input." << configName << ".turboB"), -turboA("Turbo A", string() << "input." << configName << ".turboA"), -turboY("Turbo Y", string() << "input." << configName << ".turboY"), -turboX("Turbo X", string() << "input." << configName << ".turboX"), -turboL("Turbo L", string() << "input." << configName << ".turboL"), -turboR("Turbo R", string() << "input." << configName << ".turboR") { - attach(&up); attach(&down); attach(&left); attach(&right); - attach(&b); attach(&a); attach(&y); attach(&x); - attach(&l); attach(&r); attach(&select); attach(&start); - attach(&turboB); attach(&turboA); attach(&turboY); attach(&turboX); - attach(&turboL); attach(&turboR); - - if(this == &gamepad1) { - up.name = "KB0::Up"; - down.name = "KB0::Down"; - left.name = "KB0::Left"; - right.name = "KB0::Right"; - b.name = "KB0::Z"; - a.name = "KB0::X"; - y.name = "KB0::A"; - x.name = "KB0::S"; - l.name = "KB0::D"; - r.name = "KB0::C"; - select.name = "KB0::Apostrophe"; - start.name = "KB0::Return"; - } -} - -// - -int16_t Multitap::status(unsigned index, unsigned id) const { - switch(index & 3) { default: - case 0: return port1.status(index, id); - case 1: return port2.status(index, id); - case 2: return port3.status(index, id); - case 3: return port4.status(index, id); - } -} - -Multitap::Multitap(Gamepad &port1_, Gamepad &port2_, Gamepad &port3_, Gamepad &port4_) : -InputGroup(InputCategory::Hidden, "Multitap"), -port1(port1_), port2(port2_), port3(port3_), port4(port4_) { -} - -// - -void AsciiSwitch::poll() { - DigitalInput::poll(); - - //only change state when controller is active - if(!parent) return; - if(parent->category == InputCategory::Port1 && mapper().port1 != parent) return; - if(parent->category == InputCategory::Port2 && mapper().port2 != parent) return; - - if(previousState != state && state) { - switch(mode) { - case Off: mode = Turbo; utility.showMessage(string() << label << " set to turbo."); break; - case Turbo: mode = Auto; utility.showMessage(string() << label << " set to auto."); break; - case Auto: mode = Off; utility.showMessage(string() << label << " set to off."); break; - } - } -} - -AsciiSwitch::AsciiSwitch(const char *label, const char *configName) : -DigitalInput(label, configName) { - mode = Off; -} - -void AsciiInput::cache() { - if(asciiSwitch->mode == AsciiSwitch::Off) { - cachedState = state; - } else if(asciiSwitch->mode == AsciiSwitch::Turbo) { - if(state) { - cachedState = (counter < holdHi ? state : 0); - if(++counter >= holdHi + holdLo) counter = 0; - } else { - cachedState = 0; - counter = 0; - } - } else if(asciiSwitch->mode == AsciiSwitch::Auto) { - cachedState = (counter < holdHi); - if(++counter >= holdHi + holdLo) counter = 0; - } -} - -AsciiInput::AsciiInput(const char *label, const char *configName) : -DigitalInput(label, configName) { - holdHi = 2; - holdLo = 2; - counter = 0; -} - -void AsciiSlowMotion::poll() { - DigitalInput::poll(); - - //only change state when controller is active - if(!parent) return; - if(parent->category == InputCategory::Port1 && mapper().port1 != parent) return; - if(parent->category == InputCategory::Port2 && mapper().port2 != parent) return; - - if(previousState != state && state) { - if(enabled == false) { - enabled = true; - utility.showMessage(string() << label << " enabled."); - } else { - enabled = false; - utility.showMessage(string() << label << " disabled."); - } - } -} - -void AsciiSlowMotion::cache() { - if(enabled == false) { - cachedState = 0; - } else { - cachedState = counter < holdHi; - if(++counter >= holdHi + holdLo) counter = 0; - } -} - -AsciiSlowMotion::AsciiSlowMotion(const char *label, const char *configName) : -DigitalInput(label, configName) { - enabled = false; - holdHi = 2; - holdLo = 2; -} - -int16_t Asciipad::status(unsigned index, unsigned id) const { - if(config().input.allowInvalidInput == false) { - if(id == (unsigned)SNES::Input::JoypadID::Down && up.cachedState) return 0; - if(id == (unsigned)SNES::Input::JoypadID::Right && left.cachedState) return 0; - } - - switch(id) { - case SNES::Input::JoypadID::Up: return up.cachedState; - case SNES::Input::JoypadID::Down: return down.cachedState; - case SNES::Input::JoypadID::Left: return left.cachedState; - case SNES::Input::JoypadID::Right: return right.cachedState; - case SNES::Input::JoypadID::A: return a.cachedState; - case SNES::Input::JoypadID::B: return b.cachedState; - case SNES::Input::JoypadID::X: return x.cachedState; - case SNES::Input::JoypadID::Y: return y.cachedState; - case SNES::Input::JoypadID::L: return l.cachedState; - case SNES::Input::JoypadID::R: return r.cachedState; - case SNES::Input::JoypadID::Select: return select.cachedState; - case SNES::Input::JoypadID::Start: return start.cachedState | slowMotion.cachedState; - } - return 0; -} - -Asciipad::Asciipad(unsigned category, const char *label, const char *configName) : -InputGroup(category, label), -up("Up", string() << "input." << configName << ".up"), -down("Down", string() << "input." << configName << ".down"), -left("Left", string() << "input." << configName << ".left"), -right("Right", string() << "input." << configName << ".right"), -b("B", string() << "input." << configName << ".b"), -a("A", string() << "input." << configName << ".a"), -y("Y", string() << "input." << configName << ".y"), -x("X", string() << "input." << configName << ".x"), -l("L", string() << "input." << configName << ".l"), -r("R", string() << "input." << configName << ".r"), -select("Select", string() << "input." << configName << ".select"), -start("Start", string() << "input." << configName << ".start"), -switchB("B Switch", string() << "input." << configName << ".bSwitch"), -switchA("A Switch", string() << "input." << configName << ".aSwitch"), -switchY("Y Switch", string() << "input." << configName << ".ySwitch"), -switchX("X Switch", string() << "input." << configName << ".xSwitch"), -switchL("L Switch", string() << "input." << configName << ".lSwitch"), -switchR("R Switch", string() << "input." << configName << ".rSwitch"), -slowMotion("Slow Motion", string() << "input." << configName << ".slowMotion") { - b.asciiSwitch = &switchB; - a.asciiSwitch = &switchA; - y.asciiSwitch = &switchY; - x.asciiSwitch = &switchX; - l.asciiSwitch = &switchL; - r.asciiSwitch = &switchR; - - attach(&up); attach(&down); attach(&left); attach(&right); - attach(&b); attach(&a); attach(&y); attach(&x); - attach(&l); attach(&r); attach(&select); attach(&start); - attach(&switchB); attach(&switchA); attach(&switchY); attach(&switchX); - attach(&switchL); attach(&switchR); attach(&slowMotion); - - if(this == &asciipad1) { - up.name = "KB0::Up"; - down.name = "KB0::Down"; - left.name = "KB0::Left"; - right.name = "KB0::Right"; - b.name = "KB0::Z"; - a.name = "KB0::X"; - y.name = "KB0::A"; - x.name = "KB0::S"; - l.name = "KB0::D"; - r.name = "KB0::C"; - select.name = "KB0::Apostrophe"; - start.name = "KB0::Return"; - } -} - -// - -int16_t Mouse::status(unsigned index, unsigned id) const { - switch(id) { - case SNES::Input::MouseID::X: return x.cachedState; - case SNES::Input::MouseID::Y: return y.cachedState; - case SNES::Input::MouseID::Left: return left.cachedState; - case SNES::Input::MouseID::Right: return right.cachedState; - } - return 0; -} - -Mouse::Mouse(unsigned category, const char *label, const char *configName) : -InputGroup(category, label), -x("X-axis", string() << "input." << configName << ".x"), -y("Y-axis", string() << "input." << configName << ".y"), -left("Left Button", string() << "input." << configName << ".left"), -right("Right Button", string() << "input." << configName << ".right") { - attach(&x); attach(&y); attach(&left); attach(&right); - - x.name = "MS0::Xaxis"; - y.name = "MS0::Yaxis"; - left.name = "MS0::Button0"; - right.name = "MS0::Button2"; -} - -// - -int16_t SuperScope::status(unsigned index, unsigned id) const { - switch(id) { - case SNES::Input::SuperScopeID::X: return x.cachedState; - case SNES::Input::SuperScopeID::Y: return y.cachedState; - case SNES::Input::SuperScopeID::Trigger: return trigger.cachedState; - case SNES::Input::SuperScopeID::Cursor: return cursor.cachedState; - case SNES::Input::SuperScopeID::Turbo: return turbo.cachedState; - case SNES::Input::SuperScopeID::Pause: return pause.cachedState; - } - return 0; -} - -SuperScope::SuperScope(unsigned category, const char *label, const char *configName) : -InputGroup(category, label), -x("X-axis", string() << "input." << configName << ".x"), -y("Y-axis", string() << "input." << configName << ".y"), -trigger("Trigger", string() << "input." << configName << ".trigger"), -cursor("Cursor", string() << "input." << configName << ".cursor"), -turbo("Turbo", string() << "input." << configName << ".turbo"), -pause("Pause", string() << "input." << configName << ".pause") { - attach(&x); attach(&y); attach(&trigger); attach(&cursor); - attach(&turbo); attach(&pause); - - x.name = "MS0::Xaxis"; - y.name = "MS0::Yaxis"; - trigger.name = "MS0::Button0"; - cursor.name = "MS0::Button2"; - turbo.name = "KB0::T"; - pause.name = "KB0::P"; -} - -// - -int16_t Justifier::status(unsigned index, unsigned id) const { - switch(id) { - case SNES::Input::JustifierID::X: return x.cachedState; - case SNES::Input::JustifierID::Y: return y.cachedState; - case SNES::Input::JustifierID::Trigger: return trigger.cachedState; - case SNES::Input::JustifierID::Start: return start.cachedState; - } - return 0; -} - -Justifier::Justifier(unsigned category, const char *label, const char *configName) : -InputGroup(category, label), -x("X-axis", string() << "input." << configName << ".x"), -y("Y-axis", string() << "input." << configName << ".y"), -trigger("Trigger", string() << "input." << configName << ".trigger"), -start("Start", string() << "input." << configName << ".start") { - attach(&x); attach(&y); attach(&trigger); attach(&start); - - if(this == &justifier1) { - x.name = "MS0::Xaxis"; - y.name = "MS0::Yaxis"; - trigger.name = "MS0::Button0"; - start.name = "MS0::Button2"; - } -} - -// - -int16_t Justifiers::status(unsigned index, unsigned id) const { - switch(index & 1) { default: - case 0: return port1.status(index, id); - case 1: return port2.status(index, id); - } -} - -Justifiers::Justifiers(Justifier &port1_, Justifier &port2_) : -InputGroup(InputCategory::Hidden, "Justifiers"), -port1(port1_), port2(port2_) { -} - -// - -Gamepad gamepad1(InputCategory::Port1, "Gamepad", "gamepad1"); -Asciipad asciipad1(InputCategory::Port1, "asciiPad", "asciipad1"); -Gamepad multitap1a(InputCategory::Port1, "Multitap - Port 1", "multitap1a"); -Gamepad multitap1b(InputCategory::Port1, "Multitap - Port 2", "multitap1b"); -Gamepad multitap1c(InputCategory::Port1, "Multitap - Port 3", "multitap1c"); -Gamepad multitap1d(InputCategory::Port1, "Multitap - Port 4", "multitap1d"); -Multitap multitap1(multitap1a, multitap1b, multitap1c, multitap1d); -Mouse mouse1(InputCategory::Port1, "Mouse", "mouse1"); - -Gamepad gamepad2(InputCategory::Port2, "Gamepad", "gamepad2"); -Asciipad asciipad2(InputCategory::Port2, "asciiPad", "asciipad2"); -Gamepad multitap2a(InputCategory::Port2, "Multitap - Port 1", "multitap2a"); -Gamepad multitap2b(InputCategory::Port2, "Multitap - Port 2", "multitap2b"); -Gamepad multitap2c(InputCategory::Port2, "Multitap - Port 3", "multitap2c"); -Gamepad multitap2d(InputCategory::Port2, "Multitap - Port 4", "multitap2d"); -Multitap multitap2(multitap2a, multitap2b, multitap2c, multitap2d); -Mouse mouse2(InputCategory::Port2, "Mouse", "mouse2"); -SuperScope superscope(InputCategory::Port2, "Super Scope", "superscope"); -Justifier justifier1(InputCategory::Port2, "Justifier 1", "justifier1"); -Justifier justifier2(InputCategory::Port2, "Justifier 2", "justifier2"); -Justifiers justifiers(justifier1, justifier2); - -} diff --git a/bsnes/ui-qt/input/controller.hpp b/bsnes/ui-qt/input/controller.hpp deleted file mode 100755 index e7920bef..00000000 --- a/bsnes/ui-qt/input/controller.hpp +++ /dev/null @@ -1,112 +0,0 @@ -struct ControllerPort1 { enum { None, Gamepad, Asciipad, Multitap, Mouse }; }; -struct ControllerPort2 { enum { None, Gamepad, Asciipad, Multitap, Mouse, SuperScope, Justifier, Justifiers }; }; - -namespace Controllers { - -struct TurboInput : DigitalInput { - unsigned holdHi; - unsigned holdLo; - unsigned counter; - void cache(); - TurboInput(const char*, const char*); -}; - -struct Gamepad : InputGroup { - DigitalInput up, down, left, right, b, a, y, x, l, r, select, start; - TurboInput turboB, turboA, turboY, turboX, turboL, turboR; - int16_t status(unsigned, unsigned) const; - Gamepad(unsigned, const char*, const char*); -}; - -struct Multitap : InputGroup { - Gamepad &port1, &port2, &port3, &port4; - int16_t status(unsigned, unsigned) const; - Multitap(Gamepad&, Gamepad&, Gamepad&, Gamepad&); -}; - -struct AsciiSwitch : DigitalInput { - enum Mode { Off, Turbo, Auto } mode; - void poll(); - AsciiSwitch(const char*, const char*); -}; - -struct AsciiSlowMotion : DigitalInput { - bool enabled; - unsigned holdHi; - unsigned holdLo; - unsigned counter; - void poll(); - void cache(); - AsciiSlowMotion(const char*, const char*); -}; - -struct AsciiInput : DigitalInput { - AsciiSwitch *asciiSwitch; - unsigned holdHi; - unsigned holdLo; - unsigned counter; - void cache(); - AsciiInput(const char*, const char*); -}; - -struct Asciipad : InputGroup { - DigitalInput up, down, left, right; - AsciiInput b, a, y, x, l, r; - DigitalInput select, start; - AsciiSwitch switchB, switchA, switchY, switchX, switchL, switchR; - AsciiSlowMotion slowMotion; - int16_t status(unsigned, unsigned) const; - Asciipad(unsigned, const char*, const char*); -}; - -struct Mouse : InputGroup { - AnalogInput x, y; - DigitalInput left, right; - int16_t status(unsigned, unsigned) const; - Mouse(unsigned, const char*, const char*); -}; - -struct SuperScope : InputGroup { - AnalogInput x, y; - DigitalInput trigger, cursor, turbo, pause; - int16_t status(unsigned, unsigned) const; - SuperScope(unsigned, const char*, const char*); -}; - -struct Justifier : InputGroup { - AnalogInput x, y; - DigitalInput trigger, start; - int16_t status(unsigned, unsigned) const; - Justifier(unsigned, const char*, const char*); -}; - -struct Justifiers : InputGroup { - Justifier &port1; - Justifier &port2; - int16_t status(unsigned, unsigned) const; - Justifiers(Justifier&, Justifier&); -}; - -extern Gamepad gamepad1; -extern Asciipad asciipad1; -extern Gamepad multitap1a; -extern Gamepad multitap1b; -extern Gamepad multitap1c; -extern Gamepad multitap1d; -extern Multitap multitap1; -extern Mouse mouse1; - -extern Gamepad gamepad2; -extern Asciipad asciipad2; -extern Gamepad multitap2a; -extern Gamepad multitap2b; -extern Gamepad multitap2c; -extern Gamepad multitap2d; -extern Multitap multitap2; -extern Mouse mouse2; -extern SuperScope superscope; -extern Justifier justifier1; -extern Justifier justifier2; -extern Justifiers justifiers; - -} diff --git a/bsnes/ui-qt/input/input.cpp b/bsnes/ui-qt/input/input.cpp deleted file mode 100755 index d6ffd52a..00000000 --- a/bsnes/ui-qt/input/input.cpp +++ /dev/null @@ -1,272 +0,0 @@ -#include "../ui-base.hpp" - -#include "controller.cpp" -#include "userinterface-general.cpp" -#include "userinterface-system.cpp" -#include "userinterface-emulationspeed.cpp" -#include "userinterface-states.cpp" -#include "userinterface-videosettings.cpp" - -void MappedInput::bind() { - lstring part; - part.split("+", name); - - modifier = InputModifier::None; - for(unsigned i = 0; i < part.size(); i++) { - if(part[i] == "Shift") modifier |= InputModifier::Shift; - if(part[i] == "Control") modifier |= InputModifier::Control; - if(part[i] == "Alt") modifier |= InputModifier::Alt; - if(part[i] == "Super") modifier |= InputModifier::Super; - } - - string temp = part[part.size() - 1]; - part.split(".", temp); - scancode = Scancode::decode(part[0]); - specifier = InputSpecifier::None; - if(part[1] == "Up") specifier = InputSpecifier::Up; - if(part[1] == "Down") specifier = InputSpecifier::Down; - if(part[1] == "Left") specifier = InputSpecifier::Left; - if(part[1] == "Right") specifier = InputSpecifier::Right; - if(part[1] == "Lo") specifier = InputSpecifier::Lo; - if(part[1] == "Hi") specifier = InputSpecifier::Hi; - if(part[1] == "Trigger") specifier = InputSpecifier::Trigger; - - //re-encode name, in case previous name was invalid - name = ""; - if(modifier & InputModifier::Shift) name << "Shift+"; - if(modifier & InputModifier::Control) name << "Control+"; - if(modifier & InputModifier::Alt) name << "Alt+"; - if(modifier & InputModifier::Super) name << "Super+"; - name << Scancode::encode(scancode); - if(specifier == InputSpecifier::Up) name << ".Up"; - if(specifier == InputSpecifier::Down) name << ".Down"; - if(specifier == InputSpecifier::Left) name << ".Left"; - if(specifier == InputSpecifier::Right) name << ".Right"; - if(specifier == InputSpecifier::Lo) name << ".Lo"; - if(specifier == InputSpecifier::Hi) name << ".Hi"; - if(specifier == InputSpecifier::Trigger) name << ".Trigger"; -} - -void MappedInput::cache() { - cachedState = state; -} - -MappedInput::MappedInput(const char *label_, const char *configName) : parent(0), label(label_) { - specifier = InputSpecifier::None; - state = 0; - previousState = 0; - cachedState = 0; - config().attach(name = "None", configName); -} - -// - -void DigitalInput::poll() { - previousState = state; - if(modifier == mapper().modifier || !config().input.modifierEnable) { - if(specifier == InputSpecifier::None) { - state = mapper().state(scancode); - } else if(specifier == InputSpecifier::Up) { - state = (bool)(mapper().state(scancode) & Joypad::HatUp); - } else if(specifier == InputSpecifier::Down) { - state = (bool)(mapper().state(scancode) & Joypad::HatDown); - } else if(specifier == InputSpecifier::Left) { - state = (bool)(mapper().state(scancode) & Joypad::HatLeft); - } else if(specifier == InputSpecifier::Right) { - state = (bool)(mapper().state(scancode) & Joypad::HatRight); - } else if(specifier == InputSpecifier::Lo) { - state = mapper().state(scancode) < -16384; - } else if(specifier == InputSpecifier::Hi) { - state = mapper().state(scancode) > +16384; - } else if(specifier == InputSpecifier::Trigger) { - state = mapper().state(scancode) < 0; - } - } else { - state = 0; - } -} - -bool DigitalInput::isPressed() const { return state; } -bool DigitalInput::wasPressed() const { return previousState; } - -DigitalInput::DigitalInput(const char *label, const char *configName) : MappedInput(label, configName) { -} - -// - -void AnalogInput::poll() { - previousState = state; - if(Mouse::isAnyAxis(scancode)) { - if(input.acquired()) { - state = mapper().state(scancode); - } else { - state = 0; - } - } else if(Joypad::isAnyAxis(scancode)) { - state = mapper().state(scancode) / 8192; - } -} - -AnalogInput::AnalogInput(const char *label, const char *configName) : MappedInput(label, configName) { -} - -// - -void HotkeyInput::poll() { - DigitalInput::poll(); - if(mainWindow->isActive() && state != previousState) { - state ? pressed() : released(); - } -} - -HotkeyInput::HotkeyInput(const char *label, const char *configName) : DigitalInput(label, configName) { -} - -// - -void InputGroup::attach(MappedInput *input) { - input->parent = this; - append(input); -} - -void InputGroup::bind() { - for(unsigned i = 0; i < size(); i++) { - (*this)[i]->bind(); - } -} - -void InputGroup::poll() { - for(unsigned i = 0; i < size(); i++) { - (*this)[i]->poll(); - } -} - -void InputGroup::cache() { - for(unsigned i = 0; i < size(); i++) { - (*this)[i]->cache(); - } -} - -void InputGroup::flushCache() { - for(unsigned i = 0; i < size(); i++) { - MappedInput &input = *((*this)[i]); - input.cachedState = 0; - } -} - -InputGroup::InputGroup(unsigned category_, const char *label_) : category(category_), label(label_) { - mapper().append(this); -} - -// - -InputMapper& mapper() { - static InputMapper mapper; - return mapper; -} - -void InputMapper::calibrate() { - calibrated = true; - audio.clear(); - QMessageBox::information(settingsWindow, "Joypad Calibration", - "Joypads must be calibrated prior to mapping. Please ensure that " - "all axes and analog buttons are not pressed or moved in any specific " - "direction, and then press ok." - ); - - poll(); - for(unsigned i = 0; i < Joypad::Count; i++) { - for(unsigned axis = 0; axis < Joypad::Axes; axis++) { - int16_t n = state(joypad(i).axis(axis)); - isTrigger[i][axis] = n < -16384 || n > +16384; - } - } -} - -void InputMapper::bind() { - for(unsigned i = 0; i < size(); i++) { - (*this)[i]->bind(); - } -} - -void InputMapper::poll() { - activeState = !activeState; - input.poll(stateTable[activeState]); - - modifier = 0; - for(unsigned i = 0; i < Keyboard::Count; i++) { - if(state(keyboard(i)[Keyboard::Shift])) modifier |= InputModifier::Shift; - if(state(keyboard(i)[Keyboard::Control])) modifier |= InputModifier::Control; - if(state(keyboard(i)[Keyboard::Alt])) modifier |= InputModifier::Alt; - if(state(keyboard(i)[Keyboard::Super])) modifier |= InputModifier::Super; - } - - for(unsigned i = 0; i < size(); i++) { - (*this)[i]->poll(); - } - - for(unsigned i = 0; i < Scancode::Limit; i++) { - if(state(i) != previousState(i)) { - utility.inputEvent(i); - inputSettingsWindow->inputEvent(i); - } - } -} - -void InputMapper::cache() { - if(config().input.focusPolicy == Configuration::Input::FocusPolicyIgnoreInput && !mainWindow->isActive()) { - for(unsigned i = 0; i < size(); i++) { - InputGroup &group = *((*this)[i]); - group.flushCache(); - } - } else { - for(unsigned i = 0; i < size(); i++) { - InputGroup &group = *((*this)[i]); - if(group.category == InputCategory::Port1 || group.category == InputCategory::Port2) { - group.cache(); - } - } - } -} - -int16_t InputMapper::status(bool port, SNES::Input::Device device, unsigned index, unsigned id) { - int16_t result = 0; - - if(port == InputCategory::Port1 && port1) result = port1->status(index, id); - if(port == InputCategory::Port2 && port2) result = port2->status(index, id); - - if(movie.state == Movie::Playback) { - result = movie.read(); - } else if(movie.state == Movie::Record) { - movie.write(result); - } - - return result; -} - -string InputMapper::modifierString() const { - string name; - if(modifier & InputModifier::Shift) name << "Shift+"; - if(modifier & InputModifier::Control) name << "Control+"; - if(modifier & InputModifier::Alt) name << "Alt+"; - if(modifier & InputModifier::Super) name << "Super+"; - return name; -} - -int16_t InputMapper::state(uint16_t scancode) const { return stateTable[activeState][scancode]; } -int16_t InputMapper::previousState(uint16_t scancode) const { return stateTable[!activeState][scancode]; } -unsigned InputMapper::distance(uint16_t scancode) const { return abs(state(scancode) - previousState(scancode)); } - -InputMapper::InputMapper() : port1(0), port2(0) { - calibrated = false; - for(unsigned i = 0; i < Joypad::Count; i++) { - for(unsigned axis = 0; axis < Joypad::Axes; axis++) { - isTrigger[i][axis] = false; - } - } - - activeState = 0; - for(unsigned i = 0; i < Scancode::Limit; i++) { - stateTable[0][i] = stateTable[1][i] = 0; - } -} diff --git a/bsnes/ui-qt/input/input.hpp b/bsnes/ui-qt/input/input.hpp deleted file mode 100755 index c08271bc..00000000 --- a/bsnes/ui-qt/input/input.hpp +++ /dev/null @@ -1,90 +0,0 @@ -struct InputSpecifier { enum { None, Up, Down, Left, Right, Lo, Hi, Trigger }; }; -struct InputModifier { enum { None = 0, Shift = 1, Control = 2, Alt = 4, Super = 8 }; }; -struct InputCategory { enum { Port1 = 0, Port2 = 1, UserInterface = 2, Hidden = 3 }; }; - -struct InputGroup; - -struct MappedInput { - InputGroup *parent; - string name; - string label; - unsigned specifier; - unsigned modifier; - unsigned scancode; - int16_t state; - int16_t previousState; - int16_t cachedState; - - void bind(); - virtual void poll() = 0; - virtual void cache(); - - MappedInput(const char*, const char*); -}; - -struct DigitalInput : MappedInput { - void poll(); - - bool isPressed() const; - bool wasPressed() const; - - DigitalInput(const char*, const char*); -}; - -struct AnalogInput : MappedInput { - void poll(); - - AnalogInput(const char*, const char*); -}; - -struct HotkeyInput : DigitalInput { - void poll(); - virtual void pressed() {} - virtual void released() {} - - HotkeyInput(const char*, const char*); -}; - -struct InputGroup : public array { - unsigned category; - string label; - - void attach(MappedInput*); - void bind(); - void poll(); - void cache(); - void flushCache(); - virtual int16_t status(unsigned, unsigned) const { return 0; } - - InputGroup(unsigned, const char*); -}; - -struct InputMapper : public array { - InputGroup *port1; - InputGroup *port2; - - bool calibrated; - bool isTrigger[Joypad::Count][Joypad::Axes]; - - bool activeState; - int16_t stateTable[2][Scancode::Limit]; - unsigned modifier; - - void calibrate(); - void bind(); - void poll(); - void cache(); - int16_t status(bool, SNES::Input::Device, unsigned, unsigned); - - string modifierString() const; - int16_t state(uint16_t) const; - int16_t previousState(uint16_t) const; - unsigned distance(uint16_t) const; - - InputMapper(); -}; - -InputMapper& mapper(); - -#include "controller.hpp" -#include "userinterface.hpp" diff --git a/bsnes/ui-qt/input/userinterface-emulationspeed.cpp b/bsnes/ui-qt/input/userinterface-emulationspeed.cpp deleted file mode 100755 index 2ac19c67..00000000 --- a/bsnes/ui-qt/input/userinterface-emulationspeed.cpp +++ /dev/null @@ -1,208 +0,0 @@ -InputGroup userInterfaceEmulationSpeed(InputCategory::UserInterface, "Emulation Speed"); - -namespace UserInterfaceEmulationSpeed { - -//slowdown and speedup do not work well with Vsync enabled, as it locks the -//speed to the monitor refresh rate. thus, when one is pressed, it is disabled -//until the key is released. - -struct Slowdown : HotkeyInput { - bool syncVideo; - bool syncAudio; - - void pressed() { - config().system.speed = 0; - utility.updateEmulationSpeed(); - syncVideo = config().video.synchronize; - syncAudio = config().audio.synchronize; - if(syncVideo) { - config().video.synchronize = false; - utility.updateAvSync(); - } - if(!syncAudio) { - config().audio.synchronize = true; - utility.updateAvSync(); - } - mainWindow->syncUi(); - } - - void released() { - config().system.speed = 2; - utility.updateEmulationSpeed(); - if(syncVideo) { - config().video.synchronize = true; - utility.updateAvSync(); - } - if(!syncAudio) { - config().audio.synchronize = false; - utility.updateAvSync(); - } - mainWindow->syncUi(); - } - - Slowdown() : HotkeyInput("Slowdown", "input.userInterface.emulationSpeed.slowdown") { - name = "Shift+KB0::Tilde"; - userInterfaceEmulationSpeed.attach(this); - } -} slowdown; - -struct Speedup : HotkeyInput { - bool syncVideo; - bool syncAudio; - - void pressed() { - #if defined(PROFILE_COMPATIBILITY) || defined(PROFILE_PERFORMANCE) - SNES::ppu.set_frameskip(9); - #endif - config().system.speed = 4; - utility.updateEmulationSpeed(); - syncVideo = config().video.synchronize; - syncAudio = config().audio.synchronize; - if(syncVideo) { - config().video.synchronize = false; - utility.updateAvSync(); - } - if(syncAudio) { - config().audio.synchronize = false; - utility.updateAvSync(); - } - mainWindow->syncUi(); - } - - void released() { - #if defined(PROFILE_COMPATIBILITY) || defined(PROFILE_PERFORMANCE) - SNES::ppu.set_frameskip(0); - #endif - config().system.speed = 2; - utility.updateEmulationSpeed(); - if(syncVideo) { - config().video.synchronize = true; - utility.updateAvSync(); - } - if(syncAudio) { - config().audio.synchronize = true; - utility.updateAvSync(); - } - mainWindow->syncUi(); - } - - Speedup() : HotkeyInput("Speedup", "input.userInterface.emulationSpeed.speedup") { - name = "KB0::Tilde"; - userInterfaceEmulationSpeed.attach(this); - } -} speedup; - -struct Decrease : HotkeyInput { - void pressed() { - if(config().system.speed > 0) config().system.speed--; - utility.updateEmulationSpeed(); - mainWindow->syncUi(); - } - - Decrease() : HotkeyInput("Decrease", "input.userInterface.emulationSpeed.decrease") { - name = "Control+KB0::Divide"; - userInterfaceEmulationSpeed.attach(this); - } -} decrease; - -struct Increase : HotkeyInput { - void pressed() { - if(config().system.speed < 4) config().system.speed++; - utility.updateEmulationSpeed(); - mainWindow->syncUi(); - } - - Increase() : HotkeyInput("Increase", "input.userInterface.emulationSpeed.increase") { - name = "Control+KB0::Multiply"; - userInterfaceEmulationSpeed.attach(this); - } -} increase; - -struct SetSlowestSpeed : HotkeyInput { - void pressed() { - config().system.speed = 0; - utility.updateEmulationSpeed(); - mainWindow->syncUi(); - } - - SetSlowestSpeed() : HotkeyInput("Set Slowest Speed", "input.userInterface.emulationSpeed.setSlowest") { - name = "Control+KB0::Num1"; - userInterfaceEmulationSpeed.attach(this); - } -} setSlowestSpeed; - -struct SetSlowSpeed : HotkeyInput { - void pressed() { - config().system.speed = 1; - utility.updateEmulationSpeed(); - mainWindow->syncUi(); - } - - SetSlowSpeed() : HotkeyInput("Set Slow Speed", "input.userInterface.emulationSpeed.setSlow") { - name = "Control+KB0::Num2"; - userInterfaceEmulationSpeed.attach(this); - } -} setSlowSpeed; - -struct SetNormalSpeed : HotkeyInput { - void pressed() { - config().system.speed = 2; - utility.updateEmulationSpeed(); - mainWindow->syncUi(); - } - - SetNormalSpeed() : HotkeyInput("Set Normal Speed", "input.userInterface.emulationSpeed.setNormal") { - name = "Control+KB0::Num3"; - userInterfaceEmulationSpeed.attach(this); - } -} setNormalSpeed; - -struct SetFastSpeed : HotkeyInput { - void pressed() { - config().system.speed = 3; - utility.updateEmulationSpeed(); - mainWindow->syncUi(); - } - - SetFastSpeed() : HotkeyInput("Set Fast Speed", "input.userInterface.emulationSpeed.setFast") { - name = "Control+KB0::Num4"; - userInterfaceEmulationSpeed.attach(this); - } -} setFastSpeed; - -struct SetFastestSpeed : HotkeyInput { - void pressed() { - config().system.speed = 4; - utility.updateEmulationSpeed(); - mainWindow->syncUi(); - } - - SetFastestSpeed() : HotkeyInput("Set Fastest Speed", "input.userInterface.emulationSpeed.setFastest") { - name = "Control+KB0::Num5"; - userInterfaceEmulationSpeed.attach(this); - } -} setFastestSpeed; - -struct SynchronizeVideo : HotkeyInput { - void pressed() { - utility.toggleSynchronizeVideo(); - } - - SynchronizeVideo() : HotkeyInput("Synchronize Video", "input.userInterface.emulationSpeed.synchronizeVideo") { - name = "Control+KB0::V"; - userInterfaceEmulationSpeed.attach(this); - } -} synchronizeVideo; - -struct SynchronizeAudio : HotkeyInput { - void pressed() { - utility.toggleSynchronizeAudio(); - } - - SynchronizeAudio() : HotkeyInput("Synchronize Audio", "input.userInterface.emulationSpeed.synchronizeAudio") { - name = "Control+KB0::A"; - userInterfaceEmulationSpeed.attach(this); - } -} synchronizeAudio; - -} diff --git a/bsnes/ui-qt/input/userinterface-general.cpp b/bsnes/ui-qt/input/userinterface-general.cpp deleted file mode 100755 index e8a5d535..00000000 --- a/bsnes/ui-qt/input/userinterface-general.cpp +++ /dev/null @@ -1,69 +0,0 @@ -InputGroup userInterfaceGeneral(InputCategory::UserInterface, "General"); - -namespace UserInterfaceGeneral { - -struct ToggleMenubar : HotkeyInput { - void pressed() { - utility.toggleMenubar(); - } - - ToggleMenubar() : HotkeyInput("Toggle Menubar", "input.userInterface.general.toggleMenubar") { - name = "KB0::Tab"; - userInterfaceGeneral.attach(this); - } -} toggleMenubar; - -struct ToggleStatusbar : HotkeyInput { - void pressed() { - utility.toggleStatusbar(); - } - - ToggleStatusbar() : HotkeyInput("Toggle Statusbar", "input.userInterface.general.toggleStatusbar") { - name = "KB0::Tab"; - userInterfaceGeneral.attach(this); - } -} toggleStatusbar; - -struct ToggleCheatSystem : HotkeyInput { - void pressed() { - //there is a signal attached to cheatEnableBox that will update SNES::cheat.enable(bool); - if(cheatEditorWindow->cheatEnableBox->isChecked() == false) { - cheatEditorWindow->cheatEnableBox->setChecked(true); - utility.showMessage("Cheat system enabled."); - } else { - cheatEditorWindow->cheatEnableBox->setChecked(false); - utility.showMessage("Cheat system disabled."); - } - } - - ToggleCheatSystem() : HotkeyInput("Toggle Cheat System", "input.userInterface.general.toggleCheatSystem") { - userInterfaceGeneral.attach(this); - } -} toggleCheatSystem; - -struct CaptureScreenshot : HotkeyInput { - void pressed() { - //tell SNES::Interface to save a screenshot at the next video_refresh() event - interface.saveScreenshot = true; - } - - CaptureScreenshot() : HotkeyInput("Capture Screenshot", "input.userInterface.general.captureScreenshot") { - userInterfaceGeneral.attach(this); - } -} captureScreenshot; - -//put here instead of in a separate "Audio Settings" group, -//because there is only one audio option at present -struct MuteAudioOutput : HotkeyInput { - void pressed() { - mainWindow->settings_muteAudio->toggleChecked(); - config().audio.mute = mainWindow->settings_muteAudio->isChecked(); - } - - MuteAudioOutput() : HotkeyInput("Mute Audio Output", "input.userInterface.general.muteAudioOutput") { - name = "Shift+KB0::M"; - userInterfaceGeneral.attach(this); - } -} muteAudioOutput; - -} diff --git a/bsnes/ui-qt/input/userinterface-states.cpp b/bsnes/ui-qt/input/userinterface-states.cpp deleted file mode 100755 index 809c928c..00000000 --- a/bsnes/ui-qt/input/userinterface-states.cpp +++ /dev/null @@ -1,153 +0,0 @@ -InputGroup userInterfaceStates(InputCategory::UserInterface, "States"); - -namespace UserInterfaceStates { - -struct Rewind : HotkeyInput { - void pressed() { - ::state.rewind(); - } - - Rewind() : HotkeyInput("Rewind", "input.userInterface.states.rewind") { - name = "KB0::Backspace"; - userInterfaceStates.attach(this); - } -} rewind; - -struct LoadActiveState : HotkeyInput { - void pressed() { - ::state.load(::state.active); - } - - LoadActiveState() : HotkeyInput("Load Active Quick State", "input.userInterface.states.loadActiveQuickState") { - name = "KB0::F4"; - userInterfaceStates.attach(this); - } -} loadActiveState; - -struct SaveActiveState : HotkeyInput { - void pressed() { - ::state.save(::state.active); - } - - SaveActiveState() : HotkeyInput("Save Active Quick State", "input.userInterface.states.saveActiveQuickState") { - name = "KB0::F2"; - userInterfaceStates.attach(this); - } -} saveActiveState; - -struct SelectActiveState : HotkeyInput { - void pressed() { - stateSelectWindow->show(); - } - - SelectActiveState() : HotkeyInput("Select Active Quick State", "input.userInterface.states.selectActiveQuicKState") { - name = "KB0::F3"; - userInterfaceStates.attach(this); - } -} selectActiveState; - -struct DecrementAndLoadState : HotkeyInput { - void pressed() { - ::state.active = (::state.active + 10 - 1) % 10; - ::state.load(::state.active); - } - - DecrementAndLoadState() : HotkeyInput("Decrement and Load State", "input.userInterface.states.decrementAndLoadState") { - userInterfaceStates.attach(this); - } -} decrementAndLoadState; - -struct SaveAndIncrementState : HotkeyInput { - void pressed() { - ::state.save(::state.active); - ::state.active = (::state.active + 10 + 1) % 10; - } - - SaveAndIncrementState() : HotkeyInput("Save and Increment State", "input.userInterface.states.saveAndIncrementState") { - userInterfaceStates.attach(this); - } -} saveAndIncrementState; - -struct DecrementActiveState : HotkeyInput { - void pressed() { - ::state.active = (::state.active + 10 - 1) % 10; - utility.showMessage(string() << "Quick state " << (::state.active + 1) << " selected."); - } - - DecrementActiveState() : HotkeyInput("Decrement Active Quick State Slot", "input.userInterface.states.decrementActiveQuickState") { - userInterfaceStates.attach(this); - } -} decrementActiveState; - -struct IncrementActiveState : HotkeyInput { - void pressed() { - ::state.active = (::state.active + 10 + 1) % 10; - utility.showMessage(string() << "Quick state " << (::state.active + 1) << " selected."); - } - - IncrementActiveState() : HotkeyInput("Increment Active Quick State Slot", "input.userInterface.states.incrementActiveQuickState") { - userInterfaceStates.attach(this); - } -} incrementActiveState; - -struct LoadState1 : HotkeyInput { - void pressed() { - ::state.load(0); - } - - LoadState1() : HotkeyInput("Load Quick State 1", "input.userInterface.states.loadQuickState1") { - userInterfaceStates.attach(this); - } -} loadState1; - -struct LoadState2 : HotkeyInput { - void pressed() { - ::state.load(1); - } - - LoadState2() : HotkeyInput("Load Quick State 2", "input.userInterface.states.loadQuickState2") { - userInterfaceStates.attach(this); - } -} loadState2; - -struct LoadState3 : HotkeyInput { - void pressed() { - ::state.load(2); - } - - LoadState3() : HotkeyInput("Load Quick State 3", "input.userInterface.states.loadQuickState3") { - userInterfaceStates.attach(this); - } -} loadState3; - -struct SaveState1 : HotkeyInput { - void pressed() { - ::state.save(0); - } - - SaveState1() : HotkeyInput("Save Quick State 1", "input.userInterface.states.saveQuickState1") { - userInterfaceStates.attach(this); - } -} saveState1; - -struct SaveState2 : HotkeyInput { - void pressed() { - ::state.save(1); - } - - SaveState2() : HotkeyInput("Save Quick State 2", "input.userInterface.states.saveQuickState2") { - userInterfaceStates.attach(this); - } -} saveState2; - -struct SaveState3 : HotkeyInput { - void pressed() { - ::state.save(2); - } - - SaveState3() : HotkeyInput("Save Quick State 3", "input.userInterface.states.saveQuickState3") { - userInterfaceStates.attach(this); - } -} saveState3; - -} diff --git a/bsnes/ui-qt/input/userinterface-system.cpp b/bsnes/ui-qt/input/userinterface-system.cpp deleted file mode 100755 index c5d4aef4..00000000 --- a/bsnes/ui-qt/input/userinterface-system.cpp +++ /dev/null @@ -1,89 +0,0 @@ -InputGroup userInterfaceSystem(InputCategory::UserInterface, "System"); - -namespace UserInterfaceSystem { - -struct LoadCartridge : HotkeyInput { - void pressed() { - fileBrowser->setWindowTitle("Load Cartridge"); - fileBrowser->loadCartridge(FileBrowser::LoadDirect); - } - - LoadCartridge() : HotkeyInput("Load Cartridge", "input.userInterface.system.loadCartridge") { - name = "Shift+KB0::L"; - userInterfaceSystem.attach(this); - } -} loadCartridge; - -struct LoadBsxSlottedCartridge : HotkeyInput { - void pressed() { - loaderWindow->loadBsxSlottedCartridge("", ""); - } - - LoadBsxSlottedCartridge() : HotkeyInput("Load BS-X Slotted Cartridge", "input.userInterface.system.loadBsxSlottedcartridge") { - userInterfaceSystem.attach(this); - } -} loadBsxSlottedCartridge; - -struct LoadBsxCartridge : HotkeyInput { - void pressed() { - loaderWindow->loadBsxCartridge(config().path.bsx, ""); - } - - LoadBsxCartridge() : HotkeyInput("Load BS-X Cartridge", "input.userInterface.system.loadBsxCartridge") { - userInterfaceSystem.attach(this); - } -} loadBsxCartridge; - -struct LoadSufamiTurboCartridge : HotkeyInput { - void pressed() { - loaderWindow->loadSufamiTurboCartridge(config().path.st, "", ""); - } - - LoadSufamiTurboCartridge() : HotkeyInput("Load Sufami Turbo Cartridge", "input.userInterface.system.loadSufamiTurboCartridge") { - userInterfaceSystem.attach(this); - } -} loadSufamiTurboCartridge; - -struct LoadSuperGameBoyCartridge : HotkeyInput { - void pressed() { - loaderWindow->loadSuperGameBoyCartridge(config().path.sgb, ""); - } - - LoadSuperGameBoyCartridge() : HotkeyInput("Load Super Game Boy Cartridge", "input.userInterface.system.loadSuperGameBoyCartridge") { - userInterfaceSystem.attach(this); - } -} loadSuperGameBoyCartridge; - -struct PowerCycle : HotkeyInput { - void pressed() { - utility.modifySystemState(Utility::PowerCycle); - } - - PowerCycle() : HotkeyInput("Power Cycle", "input.userInterface.system.powerCycle") { - userInterfaceSystem.attach(this); - } -} powerCycle; - -struct Reset : HotkeyInput { - void pressed() { - utility.modifySystemState(Utility::Reset); - } - - Reset() : HotkeyInput("Reset", "input.userInterface.system.reset") { - userInterfaceSystem.attach(this); - } -} reset; - -struct Pause : HotkeyInput { - void pressed() { - application.pause = !application.pause; - if(application.pause) audio.clear(); - } - - Pause() : HotkeyInput("Pause", "input.userInterface.system.pause") { - name = "KB0::Pause"; - userInterfaceSystem.attach(this); - } -} pause; - -} diff --git a/bsnes/ui-qt/input/userinterface-videosettings.cpp b/bsnes/ui-qt/input/userinterface-videosettings.cpp deleted file mode 100755 index 20a55d80..00000000 --- a/bsnes/ui-qt/input/userinterface-videosettings.cpp +++ /dev/null @@ -1,148 +0,0 @@ -InputGroup userInterfaceVideoSettings(InputCategory::UserInterface, "Video Settings"); - -namespace UserInterfaceVideoSettings { - -struct ToggleFullscreen : HotkeyInput { - void pressed() { - utility.toggleFullscreen(); - } - - ToggleFullscreen() : HotkeyInput("Toggle Fullscreen Mode", "input.userInterface.videoSettings.toggleFullscreen") { - name = "Alt+KB0::Return"; - userInterfaceVideoSettings.attach(this); - } -} toggleFullscreen; - -struct SmoothVideoOutput : HotkeyInput { - void pressed() { - utility.toggleSmoothVideoOutput(); - } - - SmoothVideoOutput() : HotkeyInput("Smooth Video Output", "input.userInterface.videoSettings.smoothVideoOutput") { - name = "Shift+KB0::S"; - userInterfaceVideoSettings.attach(this); - } -} smoothVideoOutput; - -struct SetNtscMode : HotkeyInput { - void pressed() { - utility.setNtscMode(); - } - - SetNtscMode() : HotkeyInput("Set NTSC Mode", "input.userInterface.videoSettings.ntscMode") { - name = "Shift+KB0::N"; - userInterfaceVideoSettings.attach(this); - } -} setNtscMode; - -struct SetPalMode : HotkeyInput { - void pressed() { - utility.setPalMode(); - } - - SetPalMode() : HotkeyInput("Set PAL Mode", "input.userInterface.videoSettings.palMode") { - name = "Shift+KB0::P"; - userInterfaceVideoSettings.attach(this); - } -} setPalMode; - -struct AspectCorrection : HotkeyInput { - void pressed() { - utility.toggleAspectCorrection(); - } - - AspectCorrection() : HotkeyInput("Aspect Correction", "input.userInterface.videoSettings.aspectCorrection") { - name = "Shift+KB0::A"; - userInterfaceVideoSettings.attach(this); - } -} aspectCorrection; - -struct Scale1x : HotkeyInput { - void pressed() { - utility.setScale(1); - } - - Scale1x() : HotkeyInput("Scale 1x", "input.userInterface.videoSettings.scale1x") { - name = "Shift+KB0::Num1"; - userInterfaceVideoSettings.attach(this); - } -} scale1x; - -struct Scale2x : HotkeyInput { - void pressed() { - utility.setScale(2); - } - - Scale2x() : HotkeyInput("Scale 2x", "input.userInterface.videoSettings.scale2x") { - name = "Shift+KB0::Num2"; - userInterfaceVideoSettings.attach(this); - } -} scale2x; - -struct Scale3x : HotkeyInput { - void pressed() { - utility.setScale(3); - } - - Scale3x() : HotkeyInput("Scale 3x", "input.userInterface.videoSettings.scale3x") { - name = "Shift+KB0::Num3"; - userInterfaceVideoSettings.attach(this); - } -} scale3x; - -struct Scale4x : HotkeyInput { - void pressed() { - utility.setScale(4); - } - - Scale4x() : HotkeyInput("Scale 4x", "input.userInterface.videoSettings.scale4x") { - name = "Shift+KB0::Num4"; - userInterfaceVideoSettings.attach(this); - } -} scale4x; - -struct Scale5x : HotkeyInput { - void pressed() { - utility.setScale(5); - } - - Scale5x() : HotkeyInput("Scale 5x", "input.userInterface.videoSettings.scale5x") { - name = "Shift+KB0::Num5"; - userInterfaceVideoSettings.attach(this); - } -} scale5x; - -struct ScaleMaxNormal : HotkeyInput { - void pressed() { - if(config().video.isFullscreen) utility.setScale(6); - } - - ScaleMaxNormal() : HotkeyInput("Scale Max - Normal", "input.userInterface.videoSettings.scaleMaxNormal") { - name = "Shift+KB0::Num6"; - userInterfaceVideoSettings.attach(this); - } -} scaleMaxNormal; - -struct ScaleMaxFill : HotkeyInput { - void pressed() { - if(config().video.isFullscreen) utility.setScale(7); - } - - ScaleMaxFill() : HotkeyInput("Scale Max - Fill", "input.userInterface.videoSettings.scaleMaxFill") { - name = "Shift+KB0::Num7"; - userInterfaceVideoSettings.attach(this); - } -} scaleMaxFill; - -struct ScaleMaxSmart : HotkeyInput { - void pressed() { - if(config().video.isFullscreen) utility.setScale(8); - } - - ScaleMaxSmart() : HotkeyInput("Scale Max - Smart", "input.userInterface.videoSettings.scaleMaxSmart") { - name = "Shift+KB0::Num8"; - userInterfaceVideoSettings.attach(this); - } -} scaleMaxSmart; - -} diff --git a/bsnes/ui-qt/input/userinterface.hpp b/bsnes/ui-qt/input/userinterface.hpp deleted file mode 100755 index f291e10a..00000000 --- a/bsnes/ui-qt/input/userinterface.hpp +++ /dev/null @@ -1,5 +0,0 @@ -extern InputGroup userInterfaceGeneral; -extern InputGroup userInterfaceSystem; -extern InputGroup userInterfaceEmulationSpeed; -extern InputGroup userInterfaceStates; -extern InputGroup userInterfaceVideoSettings; diff --git a/bsnes/ui-qt/interface.cpp b/bsnes/ui-qt/interface.cpp deleted file mode 100755 index 0cc4998f..00000000 --- a/bsnes/ui-qt/interface.cpp +++ /dev/null @@ -1,94 +0,0 @@ -Interface interface; - -void Interface::video_refresh(const uint16_t *data, unsigned width, unsigned height) { - bool interlace = (height >= 240); - bool overscan = (height == 239 || height == 478); - unsigned pitch = interlace ? 1024 : 2048; - - //TV resolution and overscan simulation - if(config().video.context->region == 0) { - //NTSC - height = 224; - if(interlace) height <<= 1; - if(overscan) data += 7 * 1024; - } else { - //PAL - height = 239; - if(interlace) height <<= 1; - if(!overscan) data -= 7 * 1024; - } - - //scale display.crop* values from percentage-based (0-100%) to exact pixel sizes (width, height) - unsigned cropLeft = (double)display.cropLeft / 100.0 * width; - unsigned cropTop = (double)display.cropTop / 100.0 * height; - unsigned cropRight = (double)display.cropRight / 100.0 * width; - unsigned cropBottom = (double)display.cropBottom / 100.0 * height; - - width -= (cropLeft + cropRight); - height -= (cropTop + cropBottom); - - uint32_t *output; - unsigned outwidth, outheight, outpitch; - filter.size(outwidth, outheight, width, height); - - if(video.lock(output, outpitch, outwidth, outheight) == true) { - data += cropTop * (pitch >> 1) + cropLeft; - filter.render(output, outpitch, data, pitch, width, height); - video.unlock(); - video.refresh(); - if(saveScreenshot == true) captureScreenshot(output, outpitch, outwidth, outheight); - } - - state.frame(); - #if defined(DEBUGGER) - debugger->frameTick(); - #endif - - //frame counter - static signed frameCount = 0; - static time_t prev, curr; - frameCount++; - - time(&curr); - if(curr != prev) { - framesUpdated = true; - framesExecuted = frameCount; - frameCount = 0; - prev = curr; - } -} - -void Interface::audio_sample(uint16_t left, uint16_t right) { - if(config().audio.mute) left = right = 0; - audio.sample(left, right); -} - -void Interface::input_poll() { - mapper().cache(); -} - -int16_t Interface::input_poll(bool port, SNES::Input::Device device, unsigned index, unsigned id) { - return mapper().status(port, device, index, id); -} - -void Interface::captureScreenshot(uint32_t *data, unsigned pitch, unsigned width, unsigned height) { - saveScreenshot = false; - QImage image((const unsigned char*)data, width, height, pitch, QImage::Format_RGB32); - - string filename = nall::basename(cartridge.fileName); - time_t systemTime = time(0); - tm *currentTime = localtime(&systemTime); - char t[512]; - sprintf(t, "%.4u%.2u%.2u-%.2u%.2u%.2u", - 1900 + currentTime->tm_year, 1 + currentTime->tm_mon, currentTime->tm_mday, - currentTime->tm_hour, currentTime->tm_min, currentTime->tm_sec - ); - filename << "-" << t << ".png"; - - image.save(filepath(filename, config().path.data)); - utility.showMessage("Screenshot saved."); -} - -Interface::Interface() { - saveScreenshot = false; -} diff --git a/bsnes/ui-qt/interface.hpp b/bsnes/ui-qt/interface.hpp deleted file mode 100755 index e85d8aa0..00000000 --- a/bsnes/ui-qt/interface.hpp +++ /dev/null @@ -1,15 +0,0 @@ -class Interface : public SNES::Interface { -public: - void video_refresh(const uint16_t *data, unsigned width, unsigned height); - void audio_sample(uint16_t left, uint16_t right); - void input_poll(); - int16_t input_poll(bool port, SNES::Input::Device device, unsigned index, unsigned id); - - Interface(); - void captureScreenshot(uint32_t*, unsigned, unsigned, unsigned); - bool saveScreenshot; - bool framesUpdated; - unsigned framesExecuted; -}; - -extern Interface interface; diff --git a/bsnes/ui-qt/link/filter.cpp b/bsnes/ui-qt/link/filter.cpp deleted file mode 100755 index 82e3f9cb..00000000 --- a/bsnes/ui-qt/link/filter.cpp +++ /dev/null @@ -1,239 +0,0 @@ -//============== -//ScanlineFilter -//============== - -ScanlineFilter scanlineFilter; - -void ScanlineFilter::size(unsigned &width, unsigned &height) { - if(enabled && height <= 240) height *= 2; -} - -void ScanlineFilter::render( - const uint16_t *&input, unsigned &pitch, - unsigned width, unsigned &height -) { - if(enabled && height <= 240) { - pitch >>= 1; - - const uint16_t *sp = input; - uint16_t *dp = buffer; - for(unsigned y = 0; y < height; y++) { - for(unsigned x = 0; x < width; x++) { - uint16_t color = *sp++; - *(dp + 0) = color; - *(dp + 512) = adjust[color]; - dp++; - } - - sp += pitch - width; - dp += 1024 - width; - } - - input = buffer; - pitch = 1024; - height *= 2; - } -} - -void ScanlineFilter::setIntensity(unsigned intensity) { - if(intensity >= 100) { - enabled = false; - } else { - enabled = true; - - for(unsigned i = 0; i < 32768; i++) { - unsigned r = (i >> 0) & 31; - unsigned g = (i >> 5) & 31; - unsigned b = (i >> 10) & 31; - - r = (double)r * (double)intensity / 100.0; - g = (double)g * (double)intensity / 100.0; - b = (double)b * (double)intensity / 100.0; - - adjust[i] = (r << 0) + (g << 5) + (b << 10); - } - } -} - -ScanlineFilter::ScanlineFilter() { - enabled = false; - adjust = new uint16_t[32768]; - buffer = new uint16_t[512 * 480]; - setIntensity(50); -} - -ScanlineFilter::~ScanlineFilter() { - delete[] adjust; - delete[] buffer; -} - -//====== -//Filter -//====== - -Filter filter; - -const uint8_t Filter::gamma_ramp_table[32] = { - 0x00, 0x01, 0x03, 0x06, 0x0a, 0x0f, 0x15, 0x1c, - 0x24, 0x2d, 0x37, 0x42, 0x4e, 0x5b, 0x69, 0x78, - 0x88, 0x90, 0x98, 0xa0, 0xa8, 0xb0, 0xb8, 0xc0, - 0xc8, 0xd0, 0xd8, 0xe0, 0xe8, 0xf0, 0xf8, 0xff, -}; - -uint8_t Filter::contrast_adjust(uint8_t input) { - signed result = input - contrast + (2 * contrast * input + 127) / 255; - return max(0, min(255, result)); -} - -uint8_t Filter::brightness_adjust(uint8_t input) { - signed result = input + brightness; - return max(0, min(255, result)); -} - -uint8_t Filter::gamma_adjust(uint8_t input) { - signed result = (signed)(pow(((double)input / 255.0), (double)gamma / 100.0) * 255.0 + 0.5); - return max(0, min(255, result)); -} - -void Filter::colortable_update() { - double kr = 0.2126, kb = 0.0722, kg = (1.0 - kr - kb); //luminance weights - - for(unsigned i = 0; i < 32768; i++) { - unsigned color //rgb555->rgb888 conversion - = ((i & 0x7c00) << 9) + ((i & 0x7000) << 4) - + ((i & 0x03e0) << 6) + ((i & 0x0380) << 1) - + ((i & 0x001f) << 3) + ((i & 0x001c) >> 2); - - signed l; - signed r = (color >> 16) & 0xff; - signed g = (color >> 8) & 0xff; - signed b = (color ) & 0xff; - - if(gamma_ramp == true) { - r = gamma_ramp_table[r >> 3]; - g = gamma_ramp_table[g >> 3]; - b = gamma_ramp_table[b >> 3]; - } - - if(contrast != 0) { - r = contrast_adjust(r); - g = contrast_adjust(g); - b = contrast_adjust(b); - } - - if(brightness != 0) { - r = brightness_adjust(r); - g = brightness_adjust(g); - b = brightness_adjust(b); - } - - if(gamma != 100) { - r = gamma_adjust(r); - g = gamma_adjust(g); - b = gamma_adjust(b); - } - - if(sepia == true) { - l = (signed)((double)r * kr + (double)g * kg + (double)b * kb); - l = max(0, min(255, l)); - - r = (signed)((double)l * (1.0 + 0.300)); - g = (signed)((double)l * (1.0 - 0.055)); - b = (signed)((double)l * (1.0 - 0.225)); - - r = max(0, min(255, r)); - g = max(0, min(255, g)); - b = max(0, min(255, b)); - } - - if(grayscale == true) { - l = (signed)((double)r * kr + (double)g * kg + (double)b * kb); - l = max(0, min(255, l)); - r = g = b = l; - } - - if(invert == true) { - r ^= 0xff; - g ^= 0xff; - b ^= 0xff; - } - - colortable[i] = (r << 16) | (g << 8) | (b); - } -} - -void Filter::size(unsigned &outwidth, unsigned &outheight, unsigned width, unsigned height) { - scanlineFilter.size(width, height); - - if(opened() && renderer > 0) { - return dl_size(renderer, outwidth, outheight, width, height); - } - - outwidth = width; - outheight = height; -} - -void Filter::render( - uint32_t *output, unsigned outpitch, - const uint16_t *input, unsigned pitch, unsigned width, unsigned height -) { - scanlineFilter.render(input, pitch, width, height); - - if(opened() && renderer > 0) { - return dl_render(renderer, output, outpitch, input, pitch, width, height); - } - - pitch >>= 1; - outpitch >>= 2; - - for(unsigned y = 0; y < height; y++) { - const uint16_t *in = input + y * pitch; - uint32_t *out = output + y * outpitch; - for(unsigned x = 0; x < width; x++) { - *out++ = colortable[*in++]; - } - } -} - -QWidget* Filter::settings() { - if(opened() && renderer > 0) { - return dl_settings(renderer); - } else { - return 0; - } -} - -Filter::Filter() { - renderer = 0; - - contrast = 0; - brightness = 0; - gamma = 100; - - gamma_ramp = false; - sepia = false; - grayscale = false; - invert = false; - - colortable = new uint32_t[32768]; - colortable_update(); - - if(open("snesfilter")) { - dl_supported = sym("snesfilter_supported"); - dl_colortable = sym("snesfilter_colortable"); - dl_configuration = sym("snesfilter_configuration"); - dl_size = sym("snesfilter_size"); - dl_render = sym("snesfilter_render"); - dl_settings = sym("snesfilter_settings"); - - dl_colortable(colortable); - dl_configuration(config()); - } else { - config().video.windowed.swFilter = 0; - config().video.fullscreen.swFilter = 0; - } -} - -Filter::~Filter() { - delete[] colortable; -} diff --git a/bsnes/ui-qt/link/filter.hpp b/bsnes/ui-qt/link/filter.hpp deleted file mode 100755 index b71c675d..00000000 --- a/bsnes/ui-qt/link/filter.hpp +++ /dev/null @@ -1,54 +0,0 @@ -class ScanlineFilter { -public: - bool enabled; - - void size(unsigned&, unsigned&); - void render(const uint16_t*&, unsigned&, unsigned, unsigned&); - void setIntensity(unsigned); - - ScanlineFilter(); - ~ScanlineFilter(); - -private: - uint16_t *adjust; - uint16_t *buffer; -}; - -class Filter : public library { -public: - function dl_supported; - function dl_colortable; - function dl_configuration; - function dl_size; - function dl_render; - function dl_settings; - - unsigned renderer; - uint32_t *colortable; - - signed contrast; - signed brightness; - signed gamma; - - bool gamma_ramp; - bool sepia; - bool grayscale; - bool invert; - - void colortable_update(); - void size(unsigned&, unsigned&, unsigned, unsigned); - void render(uint32_t*, unsigned, const uint16_t*, unsigned, unsigned, unsigned); - QWidget* settings(); - - Filter(); - ~Filter(); - -private: - static const uint8_t gamma_ramp_table[32]; - uint8_t contrast_adjust(uint8_t input); - uint8_t brightness_adjust(uint8_t input); - uint8_t gamma_adjust(uint8_t input); -}; - -extern ScanlineFilter scanlineFilter; -extern Filter filter; diff --git a/bsnes/ui-qt/link/reader.cpp b/bsnes/ui-qt/link/reader.cpp deleted file mode 100755 index b91040e2..00000000 --- a/bsnes/ui-qt/link/reader.cpp +++ /dev/null @@ -1,44 +0,0 @@ -Reader reader; - -const char* Reader::direct_supported() { - return ""; -} - -bool Reader::direct_load(string &filename, uint8_t *&data, unsigned &size) { - if(file::exists(filename) == false) return false; - - file fp; - if(fp.open(filename, file::mode::read) == false) return false; - - data = new uint8_t[size = fp.size()]; - fp.read(data, size); - fp.close(); - - //remove copier header, if it exists - if((size & 0x7fff) == 512) memmove(data, data + 512, size -= 512); - - return true; -} - -Reader::Reader() { - if(open("snesreader")) { - supported = sym("snesreader_supported"); - load = sym("snesreader_load"); - } - - if(!supported || !load) { - supported = { &Reader::direct_supported, this }; - load = { &Reader::direct_load, this }; - } - - compressionList = supported(); - if(compressionList.length() > 0) compressionList = string() << " " << compressionList; - - if(opened()) { - extensionList = string() - << " *.smc *.swc *.fig" - << " *.ufo *.gd3 *.gd7 *.dx2 *.mgd *.mgh" - << " *.048 *.058 *.068 *.078 *.bin" - << " *.usa *.eur *.jap *.aus *.bsx"; - } -} diff --git a/bsnes/ui-qt/link/reader.hpp b/bsnes/ui-qt/link/reader.hpp deleted file mode 100755 index 1cc93411..00000000 --- a/bsnes/ui-qt/link/reader.hpp +++ /dev/null @@ -1,15 +0,0 @@ -class Reader : public library { -public: - string compressionList; - string extensionList; - - function supported; - function load; - - const char* direct_supported(); - bool direct_load(string&, uint8_t*&, unsigned&); - - Reader(); -}; - -extern Reader reader; diff --git a/bsnes/ui-qt/main.cpp b/bsnes/ui-qt/main.cpp deleted file mode 100755 index 9b813b13..00000000 --- a/bsnes/ui-qt/main.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "ui-base.hpp" -#include "resource.rcc" - -#if defined(PLATFORM_X) - #include "platform/platform_x.cpp" - const char Style::Monospace[64] = "Liberation Mono"; -#elif defined(PLATFORM_OSX) - #include "platform/platform_osx.cpp" - const char Style::Monospace[64] = "Courier New"; -#elif defined(PLATFORM_WIN) - #include "platform/platform_win.cpp" - const char Style::Monospace[64] = "Lucida Console"; -#else - #error "unsupported platform" -#endif - -#include "config.cpp" -#include "interface.cpp" - -const char defaultStylesheet[] = - "#backdrop {" - " background: #000000;" - "}\n"; - -#include "check-action.moc" -#include "file-dialog.moc" -#include "hex-editor.moc" -#include "radio-action.moc" -#include "window.moc" - -#include "application/application.cpp" -#include "link/filter.cpp" -#include "link/reader.cpp" -#include "utility/utility.cpp" - -//override filename's path with filepath, but only if filepath isn't empty -//used for GUI's "path selection" functionality -string filepath(const char *filename, const char *filepath) { - if(!filepath || !*filepath) return filename; - return string() << dir(filepath) << notdir(filename); -} - -int main(int argc, char **argv) { - return application.main(argc, argv); -} diff --git a/bsnes/ui-qt/movie/movie.cpp b/bsnes/ui-qt/movie/movie.cpp deleted file mode 100755 index 0097c297..00000000 --- a/bsnes/ui-qt/movie/movie.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "../ui-base.hpp" - -Movie movie; - -void Movie::chooseFile() { - fileBrowser->onChange.reset(); - fileBrowser->onActivate = { &Movie::play, this }; - fileBrowser->onAccept = { &Movie::play, this }; - fileBrowser->setWindowTitle("Select Movie"); - fileBrowser->setPath(config().path.current.movie); - fileBrowser->setNameFilters("bsnes Movies (*.bsv)"); - fileBrowser->chooseFile(); -} - -void Movie::play(const string &filename) { - if(QDir(filename).exists()) return; //ignore folders - config().path.current.movie = dir(filename); - - if(Movie::state != Inactive) stop(); - - if(fp.open(filename, file::mode::read)) { - if(fp.size() < 32) goto corrupt; - - unsigned signature = fp.readm(4); - if(signature != 0x42535631) goto corrupt; - - unsigned version = fp.readl(4); - if(version != SNES::Info::SerializerVersion) goto corrupt; - - unsigned crc32 = fp.readl(4); - if(crc32 != SNES::cartridge.crc32()) goto corrupt; - - unsigned size = fp.readl(4); - uint8_t *data = new uint8_t[size]; - fp.read(data, size); - serializer state(data, size); - SNES::system.unserialize(state); - - Movie::state = Playback; - mainWindow->syncUi(); - utility.showMessage("Playback started."); - - return; - } - -corrupt: - fp.close(); - utility.showMessage("Movie file is invalid, playback cancelled."); -} - -void Movie::record() { - if(Movie::state != Inactive) { - utility.showMessage("Movie mode already active, recording cancelled."); - } else { - SNES::system.runtosave(); - serializer state = SNES::system.serialize(); - - utility.showMessage("Recording started."); - - Movie::state = Record; - mainWindow->syncUi(); - fp.open(makeFilename(), file::mode::write); - fp.writem(0x42535631, 4); - fp.writel(SNES::Info::SerializerVersion, 4); - fp.writel(SNES::cartridge.crc32(), 4); - fp.writel(state.size(), 4); - fp.write(state.data(), state.size()); - } -} - -void Movie::stop() { - if(Movie::state != Inactive) { - Movie::state = Inactive; - mainWindow->syncUi(); - fp.close(); - utility.showMessage("Recording / playback stopped."); - } -} - -string Movie::makeFilename() const { - string filename = nall::basename(cartridge.fileName); - - time_t systemTime = time(0); - tm *currentTime = localtime(&systemTime); - char t[512]; - sprintf(t, "%.4u%.2u%.2u-%.2u%.2u%.2u", - 1900 + currentTime->tm_year, 1 + currentTime->tm_mon, currentTime->tm_mday, - currentTime->tm_hour, currentTime->tm_min, currentTime->tm_sec - ); - filename << "-" << t << ".bsv"; - - return filepath(filename, config().path.data); -} - -int16_t Movie::read() { - int16_t result = fp.readl(2); - - if(fp.end()) { - Movie::state = Inactive; - mainWindow->syncUi(); - fp.close(); - utility.showMessage("Playback finished."); - } - - return result; -} - -void Movie::write(int16_t value) { - fp.writel(value, 2); -} - -Movie::Movie() { - state = Inactive; -} diff --git a/bsnes/ui-qt/movie/movie.hpp b/bsnes/ui-qt/movie/movie.hpp deleted file mode 100755 index 1312786d..00000000 --- a/bsnes/ui-qt/movie/movie.hpp +++ /dev/null @@ -1,20 +0,0 @@ -class Movie { -public: - enum State { Inactive, Playback, Record } state; - - void chooseFile(); - void play(const string &filename); - void record(); - void stop(); - - Movie(); - -//private: - file fp; - - string makeFilename() const; - int16_t read(); - void write(int16_t value); -}; - -extern Movie movie; diff --git a/bsnes/ui-qt/platform/platform_osx.cpp b/bsnes/ui-qt/platform/platform_osx.cpp deleted file mode 100755 index 7cf4de1d..00000000 --- a/bsnes/ui-qt/platform/platform_osx.cpp +++ /dev/null @@ -1,3 +0,0 @@ -void supressScreenSaver() { -} - diff --git a/bsnes/ui-qt/platform/platform_win.cpp b/bsnes/ui-qt/platform/platform_win.cpp deleted file mode 100755 index 94229703..00000000 --- a/bsnes/ui-qt/platform/platform_win.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -bool Application::App::winEventFilter(MSG *msg, long *result) { - //supress screen saver from activating during gameplay - if(msg->message == WM_SYSCOMMAND) { - if(msg->wParam == SC_SCREENSAVE || msg->wParam == SC_MONITORPOWER) { - *result = 0; - return true; - } - } - - //prevent DirectSound audio buffer from looping during Windows modal events - if(msg->message == WM_ENTERMENULOOP || msg->message == WM_ENTERSIZEMOVE) { - audio.clear(); - } - - return false; -} - -void supressScreenSaver() { - //handled by event filter above -} - diff --git a/bsnes/ui-qt/platform/platform_x.cpp b/bsnes/ui-qt/platform/platform_x.cpp deleted file mode 100755 index 13b88613..00000000 --- a/bsnes/ui-qt/platform/platform_x.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#define None XNone -#define Window XWindow -#include -#undef None -#undef Window - -struct LibXtst : public library { - function XTestFakeKeyEvent; - - LibXtst() { - if(open("Xtst")) { - XTestFakeKeyEvent = sym("XTestFakeKeyEvent"); - } - } -} libXtst; - -void supressScreenSaver() { - if(!libXtst.XTestFakeKeyEvent) return; - - //XSetScreenSaver(timeout = 0) does not work - //XResetScreenSaver() does not work - //XScreenSaverSuspend() does not work - //DPMSDisable() does not work - //XSendEvent(KeyPressMask) does not work - //use XTest extension to send fake keypress every ~20 seconds. - //keycode of 255 does not map to any actual key, - //but it will block screensaver and power management. - Display *display = XOpenDisplay(0); - libXtst.XTestFakeKeyEvent(display, 255, True, 0); - libXtst.XTestFakeKeyEvent(display, 255, False, 0); - XCloseDisplay(display); -} - diff --git a/bsnes/ui-qt/resource/resource.qrc b/bsnes/ui-qt/resource/resource.qrc deleted file mode 100755 index a0254613..00000000 --- a/bsnes/ui-qt/resource/resource.qrc +++ /dev/null @@ -1,19 +0,0 @@ - - - - ../../data/bsnes.png - ../../data/cheats.xml - - ../data/logo.png - ../data/documentation.html - ../data/license.html - - ../data/icons-16x16/item-check-on.png - ../data/icons-16x16/item-check-off.png - ../data/icons-16x16/item-radio-on.png - ../data/icons-16x16/item-radio-off.png - - ../data/icons-16x16/folder-new.png - ../data/icons-16x16/go-up.png - - diff --git a/bsnes/ui-qt/resource/resource.rc b/bsnes/ui-qt/resource/resource.rc deleted file mode 100755 index 63dfef44..00000000 --- a/bsnes/ui-qt/resource/resource.rc +++ /dev/null @@ -1,2 +0,0 @@ -1 24 "data/bsnes.Manifest" -IDI_ICON1 ICON DISCARDABLE "data/bsnes.ico" diff --git a/bsnes/ui-qt/settings/advanced.cpp b/bsnes/ui-qt/settings/advanced.cpp deleted file mode 100755 index acf0c8aa..00000000 --- a/bsnes/ui-qt/settings/advanced.cpp +++ /dev/null @@ -1,201 +0,0 @@ -#include "advanced.moc" -AdvancedSettingsWindow *advancedSettingsWindow; - -AdvancedSettingsWindow::AdvancedSettingsWindow() { - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(0); - layout->setAlignment(Qt::AlignTop); - setLayout(layout); - - driverLayout = new QGridLayout; - driverLayout->setHorizontalSpacing(Style::WidgetSpacing); - layout->addLayout(driverLayout); - layout->addSpacing(Style::WidgetSpacing); - - videoLabel = new QLabel("Video driver:"); - driverLayout->addWidget(videoLabel, 0, 0); - - audioLabel = new QLabel("Audio driver:"); - driverLayout->addWidget(audioLabel, 0, 1); - - inputLabel = new QLabel("Input driver:"); - driverLayout->addWidget(inputLabel, 0, 2); - - videoDriver = new QComboBox; - driverLayout->addWidget(videoDriver, 1, 0); - - audioDriver = new QComboBox; - driverLayout->addWidget(audioDriver, 1, 1); - - inputDriver = new QComboBox; - driverLayout->addWidget(inputDriver, 1, 2); - - driverInfo = new QLabel("Note: driver changes require restart to take effect."); - driverInfo->setStyleSheet("margin-left: -3px; margin-top: 5px;"); - driverLayout->addWidget(driverInfo, 2, 0, 1, 3); - - regionTitle = new QLabel("Hardware region:"); - layout->addWidget(regionTitle); - - regionLayout = new QHBoxLayout; - regionLayout->setSpacing(Style::WidgetSpacing); - layout->addLayout(regionLayout); - layout->addSpacing(Style::WidgetSpacing); - - regionGroup = new QButtonGroup(this); - - regionAuto = new QRadioButton("Auto-detect"); - regionAuto->setToolTip("Automatically select hardware region on cartridge load"); - regionGroup->addButton(regionAuto); - regionLayout->addWidget(regionAuto); - - regionNTSC = new QRadioButton("NTSC"); - regionNTSC->setToolTip("Force NTSC region (Japan, Korea, US)"); - regionGroup->addButton(regionNTSC); - regionLayout->addWidget(regionNTSC); - - regionPAL = new QRadioButton("PAL"); - regionPAL->setToolTip("Force PAL region (Europe, ...)"); - regionGroup->addButton(regionPAL); - regionLayout->addWidget(regionPAL); - - portTitle = new QLabel("Expansion port device:"); - layout->addWidget(portTitle); - - portLayout = new QHBoxLayout; - portLayout->setSpacing(Style::WidgetSpacing); - layout->addLayout(portLayout); - layout->addSpacing(Style::WidgetSpacing); - - portGroup = new QButtonGroup(this); - - portSatellaview = new QRadioButton("Satellaview"); - portGroup->addButton(portSatellaview); - portLayout->addWidget(portSatellaview); - - portNone = new QRadioButton("None"); - portGroup->addButton(portNone); - portLayout->addWidget(portNone); - - portSpacer = new QWidget; - portLayout->addWidget(portSpacer); - - focusTitle = new QLabel("When main window does not have focus:"); - layout->addWidget(focusTitle); - - focusLayout = new QHBoxLayout; - focusLayout->setSpacing(Style::WidgetSpacing); - layout->addLayout(focusLayout); - layout->addSpacing(Style::WidgetSpacing); - - focusButtonGroup = new QButtonGroup(this); - - focusPause = new QRadioButton("Pause emulation"); - focusPause->setToolTip("Ideal for prolonged multi-tasking"); - focusButtonGroup->addButton(focusPause); - focusLayout->addWidget(focusPause); - - focusIgnore = new QRadioButton("Ignore input"); - focusIgnore->setToolTip("Ideal for light multi-tasking when using keyboard"); - focusButtonGroup->addButton(focusIgnore); - focusLayout->addWidget(focusIgnore); - - focusAllow = new QRadioButton("Allow input"); - focusAllow->setToolTip("Ideal for light multi-tasking when using joypad(s)"); - focusButtonGroup->addButton(focusAllow); - focusLayout->addWidget(focusAllow); - - miscTitle = new QLabel("Miscellaneous:"); - layout->addWidget(miscTitle); - - rewindEnable = new QCheckBox("Enable Rewind Support"); - layout->addWidget(rewindEnable); - - useCommonDialogs = new QCheckBox("Use Native OS File Dialogs"); - layout->addWidget(useCommonDialogs); - - initializeUi(); - - connect(videoDriver, SIGNAL(currentIndexChanged(int)), this, SLOT(videoDriverChange(int))); - connect(audioDriver, SIGNAL(currentIndexChanged(int)), this, SLOT(audioDriverChange(int))); - connect(inputDriver, SIGNAL(currentIndexChanged(int)), this, SLOT(inputDriverChange(int))); - connect(regionAuto, SIGNAL(pressed()), this, SLOT(setRegionAuto())); - connect(regionNTSC, SIGNAL(pressed()), this, SLOT(setRegionNTSC())); - connect(regionPAL, SIGNAL(pressed()), this, SLOT(setRegionPAL())); - connect(portSatellaview, SIGNAL(pressed()), this, SLOT(setPortSatellaview())); - connect(portNone, SIGNAL(pressed()), this, SLOT(setPortNone())); - connect(focusPause, SIGNAL(pressed()), this, SLOT(pauseWithoutFocus())); - connect(focusIgnore, SIGNAL(pressed()), this, SLOT(ignoreInputWithoutFocus())); - connect(focusAllow, SIGNAL(pressed()), this, SLOT(allowInputWithoutFocus())); - connect(rewindEnable, SIGNAL(stateChanged(int)), this, SLOT(toggleRewindEnable())); - connect(useCommonDialogs, SIGNAL(stateChanged(int)), this, SLOT(toggleUseCommonDialogs())); -} - -void AdvancedSettingsWindow::initializeUi() { - lstring part; - - part.split(";", video.driver_list()); - for(unsigned i = 0; i < part.size(); i++) { - videoDriver->addItem(part[i]); - if(part[i] == config().system.video) videoDriver->setCurrentIndex(i); - } - - part.split(";", audio.driver_list()); - for(unsigned i = 0; i < part.size(); i++) { - audioDriver->addItem(part[i]); - if(part[i] == config().system.audio) audioDriver->setCurrentIndex(i); - } - - part.split(";", input.driver_list()); - for(unsigned i = 0; i < part.size(); i++) { - inputDriver->addItem(part[i]); - if(part[i] == config().system.input) inputDriver->setCurrentIndex(i); - } - - regionAuto->setChecked(SNES::config.region == SNES::System::Region::Autodetect); - regionNTSC->setChecked(SNES::config.region == SNES::System::Region::NTSC); - regionPAL->setChecked (SNES::config.region == SNES::System::Region::PAL); - - portSatellaview->setChecked(SNES::config.expansion_port == SNES::System::ExpansionPortDevice::BSX); - portNone->setChecked (SNES::config.expansion_port == SNES::System::ExpansionPortDevice::None); - - focusPause->setChecked (config().input.focusPolicy == Configuration::Input::FocusPolicyPauseEmulation); - focusIgnore->setChecked(config().input.focusPolicy == Configuration::Input::FocusPolicyIgnoreInput); - focusAllow->setChecked (config().input.focusPolicy == Configuration::Input::FocusPolicyAllowInput); - - rewindEnable->setChecked(config().system.rewindEnabled); - useCommonDialogs->setChecked(config().diskBrowser.useCommonDialogs); -} - -void AdvancedSettingsWindow::videoDriverChange(int index) { - if(index >= 0) config().system.video = videoDriver->itemText(index).toUtf8().data(); -} - -void AdvancedSettingsWindow::audioDriverChange(int index) { - if(index >= 0) config().system.audio = audioDriver->itemText(index).toUtf8().data(); -} - -void AdvancedSettingsWindow::inputDriverChange(int index) { - if(index >= 0) config().system.input = inputDriver->itemText(index).toUtf8().data(); -} - -void AdvancedSettingsWindow::setRegionAuto() { SNES::config.region = SNES::System::Region::Autodetect; } -void AdvancedSettingsWindow::setRegionNTSC() { SNES::config.region = SNES::System::Region::NTSC; } -void AdvancedSettingsWindow::setRegionPAL() { SNES::config.region = SNES::System::Region::PAL; } - -void AdvancedSettingsWindow::setPortSatellaview() { SNES::config.expansion_port = SNES::System::ExpansionPortDevice::BSX; } -void AdvancedSettingsWindow::setPortNone() { SNES::config.expansion_port = SNES::System::ExpansionPortDevice::None; } - -void AdvancedSettingsWindow::pauseWithoutFocus() { config().input.focusPolicy = Configuration::Input::FocusPolicyPauseEmulation; } -void AdvancedSettingsWindow::ignoreInputWithoutFocus() { config().input.focusPolicy = Configuration::Input::FocusPolicyIgnoreInput; } -void AdvancedSettingsWindow::allowInputWithoutFocus() { config().input.focusPolicy = Configuration::Input::FocusPolicyAllowInput; } - -void AdvancedSettingsWindow::toggleRewindEnable() { - config().system.rewindEnabled = rewindEnable->isChecked(); - state.resetHistory(); -} - -void AdvancedSettingsWindow::toggleUseCommonDialogs() { - config().diskBrowser.useCommonDialogs = useCommonDialogs->isChecked(); -} diff --git a/bsnes/ui-qt/settings/advanced.moc.hpp b/bsnes/ui-qt/settings/advanced.moc.hpp deleted file mode 100755 index 4fdb12ca..00000000 --- a/bsnes/ui-qt/settings/advanced.moc.hpp +++ /dev/null @@ -1,60 +0,0 @@ -class AdvancedSettingsWindow : public QWidget { - Q_OBJECT - -public: - QVBoxLayout *layout; - - QGridLayout *driverLayout; - QLabel *videoLabel; - QLabel *audioLabel; - QLabel *inputLabel; - QComboBox *videoDriver; - QComboBox *audioDriver; - QComboBox *inputDriver; - QLabel *driverInfo; - - QLabel *regionTitle; - QHBoxLayout *regionLayout; - QButtonGroup *regionGroup; - QRadioButton *regionAuto; - QRadioButton *regionNTSC; - QRadioButton *regionPAL; - - QLabel *portTitle; - QHBoxLayout *portLayout; - QButtonGroup *portGroup; - QRadioButton *portSatellaview; - QRadioButton *portNone; - QWidget *portSpacer; - - QLabel *focusTitle; - QHBoxLayout *focusLayout; - QButtonGroup *focusButtonGroup; - QRadioButton *focusPause; - QRadioButton *focusIgnore; - QRadioButton *focusAllow; - - QLabel *miscTitle; - QCheckBox *rewindEnable; - QCheckBox *useCommonDialogs; - - void initializeUi(); - AdvancedSettingsWindow(); - -public slots: - void videoDriverChange(int index); - void audioDriverChange(int index); - void inputDriverChange(int index); - void setRegionAuto(); - void setRegionNTSC(); - void setRegionPAL(); - void setPortSatellaview(); - void setPortNone(); - void pauseWithoutFocus(); - void ignoreInputWithoutFocus(); - void allowInputWithoutFocus(); - void toggleRewindEnable(); - void toggleUseCommonDialogs(); -}; - -extern AdvancedSettingsWindow *advancedSettingsWindow; diff --git a/bsnes/ui-qt/settings/audio.cpp b/bsnes/ui-qt/settings/audio.cpp deleted file mode 100755 index 0b4f4aae..00000000 --- a/bsnes/ui-qt/settings/audio.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "audio.moc" -AudioSettingsWindow *audioSettingsWindow; - -AudioSettingsWindow::AudioSettingsWindow() { - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - layout->setAlignment(Qt::AlignTop); - setLayout(layout); - - boxes = new QHBoxLayout; - layout->addLayout(boxes); - - frequencyLabel = new QLabel("Frequency:"); - frequencyLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - boxes->addWidget(frequencyLabel); - - frequency = new QComboBox; - frequency->addItem("32000hz"); - frequency->addItem("44100hz"); - frequency->addItem("48000hz"); - frequency->addItem("96000hz"); - boxes->addWidget(frequency); - - latencyLabel = new QLabel("Latency:"); - latencyLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - boxes->addWidget(latencyLabel); - - latency = new QComboBox; - latency->addItem("20ms"); - latency->addItem("40ms"); - latency->addItem("60ms"); - latency->addItem("80ms"); - latency->addItem("100ms"); - latency->addItem("120ms"); - boxes->addWidget(latency); - - sliders = new QGridLayout; - layout->addLayout(sliders); - - volumeLabel = new QLabel("Volume:"); - volumeLabel->setToolTip("Warning: any volume other than 100% will result in a slight audio quality loss"); - sliders->addWidget(volumeLabel, 0, 0); - - volumeValue = new QLabel; - volumeValue->setAlignment(Qt::AlignHCenter); - volumeValue->setMinimumWidth(volumeValue->fontMetrics().width("262144hz")); - sliders->addWidget(volumeValue, 0, 1); - - volume = new QSlider(Qt::Horizontal); - volume->setMinimum(0); - volume->setMaximum(200); - sliders->addWidget(volume, 0, 2); - - frequencySkewLabel = new QLabel("Input frequency:"); - frequencySkewLabel->setToolTip( - "Adjusts audio resampling rate.\n" - "When both video sync and audio sync are enabled, use this setting to fine-tune the output.\n" - "Lower the input frequency to clean audio output, eliminating crackling / popping.\n" - "Raise the input frequency to smooth video output, eliminating duplicated frames." - ); - sliders->addWidget(frequencySkewLabel, 1, 0); - - frequencySkewValue = new QLabel; - frequencySkewValue->setAlignment(Qt::AlignHCenter); - sliders->addWidget(frequencySkewValue, 1, 1); - - frequencySkew = new QSlider(Qt::Horizontal); - frequencySkew->setMinimum(31500); - frequencySkew->setMaximum(32500); - sliders->addWidget(frequencySkew, 1, 2); - - connect(frequency, SIGNAL(currentIndexChanged(int)), this, SLOT(frequencyChange(int))); - connect(latency, SIGNAL(currentIndexChanged(int)), this, SLOT(latencyChange(int))); - connect(volume, SIGNAL(valueChanged(int)), this, SLOT(volumeAdjust(int))); - connect(frequencySkew, SIGNAL(valueChanged(int)), this, SLOT(frequencySkewAdjust(int))); - - syncUi(); -} - -void AudioSettingsWindow::syncUi() { - int n; - - n = config().audio.outputFrequency; - if(n <= 32000) frequency->setCurrentIndex(0); - else if(n <= 44100) frequency->setCurrentIndex(1); - else if(n <= 48000) frequency->setCurrentIndex(2); - else if(n <= 96000) frequency->setCurrentIndex(3); - else frequency->setCurrentIndex(0); - - n = config().audio.latency; - latency->setCurrentIndex((n - 20) / 20); - - n = config().audio.volume; - volumeValue->setText(string() << n << "%"); - volume->setSliderPosition(n); - - n = config().audio.inputFrequency; - frequencySkewValue->setText(string() << n << "hz"); - frequencySkew->setSliderPosition(n); -} - -void AudioSettingsWindow::frequencyChange(int value) { - switch(value) { default: - case 0: config().audio.outputFrequency = 32000; break; - case 1: config().audio.outputFrequency = 44100; break; - case 2: config().audio.outputFrequency = 48000; break; - case 3: config().audio.outputFrequency = 96000; break; - } - audio.set(Audio::Frequency, config().audio.outputFrequency); - utility.updateEmulationSpeed(); -} - -void AudioSettingsWindow::latencyChange(int value) { - value = max(0, min(5, value)); - config().audio.latency = 20 + value * 20; - audio.set(Audio::Latency, config().audio.latency); -} - -void AudioSettingsWindow::volumeAdjust(int value) { - config().audio.volume = value; - audio.set(Audio::Volume, config().audio.volume); - syncUi(); -} - -void AudioSettingsWindow::frequencySkewAdjust(int value) { - config().audio.inputFrequency = value; - utility.updateEmulationSpeed(); - syncUi(); -} diff --git a/bsnes/ui-qt/settings/audio.moc.hpp b/bsnes/ui-qt/settings/audio.moc.hpp deleted file mode 100755 index 24b42a9b..00000000 --- a/bsnes/ui-qt/settings/audio.moc.hpp +++ /dev/null @@ -1,29 +0,0 @@ -class AudioSettingsWindow : public QWidget { - Q_OBJECT - -public: - QVBoxLayout *layout; - QHBoxLayout *boxes; - QLabel *frequencyLabel; - QComboBox *frequency; - QLabel *latencyLabel; - QComboBox *latency; - QGridLayout *sliders; - QLabel *volumeLabel; - QLabel *volumeValue; - QSlider *volume; - QLabel *frequencySkewLabel; - QLabel *frequencySkewValue; - QSlider *frequencySkew; - - void syncUi(); - AudioSettingsWindow(); - -public slots: - void frequencyChange(int value); - void latencyChange(int value); - void volumeAdjust(int value); - void frequencySkewAdjust(int value); -}; - -extern AudioSettingsWindow *audioSettingsWindow; diff --git a/bsnes/ui-qt/settings/input.cpp b/bsnes/ui-qt/settings/input.cpp deleted file mode 100755 index 29e1c26d..00000000 --- a/bsnes/ui-qt/settings/input.cpp +++ /dev/null @@ -1,354 +0,0 @@ -#include "input.moc" -InputSettingsWindow *inputSettingsWindow; - -InputSettingsWindow::InputSettingsWindow() { - activeInput = 0; - activeGroup = 0; - groupIndex = 0; - activeMouse = 0; - - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - list = new QTreeWidget; - list->setColumnCount(2); - list->setAllColumnsShowFocus(true); - list->setSortingEnabled(false); - list->header()->hide(); - list->header()->setResizeMode(QHeaderView::ResizeToContents); - layout->addWidget(list); - - controlLayout = new QHBoxLayout; - layout->addLayout(controlLayout); - - message = new QLabel; - message->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - controlLayout->addWidget(message); - - assignButton = new QPushButton("Assign"); - controlLayout->addWidget(assignButton); - - unassignButton = new QPushButton("Unassign"); - controlLayout->addWidget(unassignButton); - - buttonBox = new QLabel("Mouse Button"); - buttonBox->setFrameStyle(QFrame::Panel | QFrame::Raised); - buttonBox->hide(); - controlLayout->addWidget(buttonBox); - - xAxisButton = new QPushButton("Mouse X-axis"); - xAxisButton->hide(); - controlLayout->addWidget(xAxisButton); - - yAxisButton = new QPushButton("Mouse Y-axis"); - yAxisButton->hide(); - controlLayout->addWidget(yAxisButton); - - stopButton = new QPushButton("Stop"); - stopButton->hide(); - controlLayout->addWidget(stopButton); - - connect(list, SIGNAL(itemSelectionChanged()), this, SLOT(synchronize())); - connect(list, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(activateAssign())); - connect(assignButton, SIGNAL(released()), this, SLOT(assign())); - connect(unassignButton, SIGNAL(released()), this, SLOT(unassign())); - connect(xAxisButton, SIGNAL(released()), this, SLOT(xAxisAssign())); - connect(yAxisButton, SIGNAL(released()), this, SLOT(yAxisAssign())); - connect(stopButton, SIGNAL(released()), this, SLOT(stop())); - - //initialize list - - port1 = new QTreeWidgetItem(list); - port1->setData(0, Qt::UserRole, QVariant(-1)); - port1->setText(0, "Controller Port 1"); - - port2 = new QTreeWidgetItem(list); - port2->setData(0, Qt::UserRole, QVariant(-1)); - port2->setText(0, "Controller Port 2"); - - userInterface = new QTreeWidgetItem(list); - userInterface->setData(0, Qt::UserRole, QVariant(-1)); - userInterface->setText(0, "User Interface"); - - for(unsigned i = 0; i < mapper().size(); i++) { - InputGroup &group = *(mapper()[i]); - - QTreeWidgetItem *grandparent = 0; - if(group.category == InputCategory::Port1) { grandparent = port1; } - if(group.category == InputCategory::Port2) { grandparent = port2; } - if(group.category == InputCategory::UserInterface) { grandparent = userInterface; } - if(!grandparent) continue; - - QTreeWidgetItem *parent = new QTreeWidgetItem(grandparent); - parent->setData(0, Qt::UserRole, QVariant(-1)); - parent->setText(0, group.label); - - for(unsigned i = 0; i < group.size(); i++) { - QTreeWidgetItem *child = new QTreeWidgetItem(parent); - child->setData(0, Qt::UserRole, QVariant(inputTable.size())); - inputTable.append(group[i]); - } - } - - updateList(); - synchronize(); -} - -void InputSettingsWindow::synchronize() { - bool enable = false; - - QList items = list->selectedItems(); - if(items.count() > 0) { - QTreeWidgetItem *item = items[0]; - signed index = item->data(0, Qt::UserRole).toInt(); - if(index >= 0) enable = true; - else { - item = item->child(0); - if(item) { - index = item->data(0, Qt::UserRole).toInt(); - if(index >= 0) enable = true; - } - } - } - - assignButton->setEnabled(enable); - unassignButton->setEnabled(enable); -} - -void InputSettingsWindow::setActiveInput(MappedInput *input) { - //flush any pending events to prevent instantaneous assignment of scancodes - activeInput = 0; - mapper().poll(); - activeInput = input; - - if(activeInput) { - assignButton->hide(); - unassignButton->hide(); - if(dynamic_cast(input)) { - buttonBox->show(); - xAxisButton->hide(); - yAxisButton->hide(); - } else { - buttonBox->hide(); - xAxisButton->show(); - yAxisButton->show(); - } - stopButton->show(); - - message->setFocus(); - message->setText(string() << "Set assignment for: " << activeInput->label); - } else { - assignButton->show(); - unassignButton->show(); - buttonBox->hide(); - xAxisButton->hide(); - yAxisButton->hide(); - stopButton->hide(); - - list->setFocus(); - message->setText(""); - } -} - -void InputSettingsWindow::updateList() { - QList all = list->findItems("", Qt::MatchContains); - for(unsigned i = 0; i < all.size(); i++) { - QTreeWidgetItem *grandparent = all[i]; - for(unsigned j = 0; j < grandparent->childCount(); j++) { - QTreeWidgetItem *parent = grandparent->child(j); - for(unsigned k = 0; k < parent->childCount(); k++) { - QTreeWidgetItem *child = parent->child(k); - signed index = child->data(0, Qt::UserRole).toInt(); - if(index == -1) continue; - MappedInput *input = inputTable[index]; - child->setText(0, input->label); - child->setText(1, string() << "= " << input->name); - child->setForeground(1, QBrush(QColor(128, 128, 128))); - } - } - } -} - -void InputSettingsWindow::setAssignment(string name) { - //if all controls in a group are being assigned at once, - //ensure the same keycode is not used more than once - if(activeGroup) { - for(unsigned i = 0; i < groupIndex; i++) { - if((*activeGroup)[i]->name == name) return; - } - } - - activeInput->name = name; - mapper().bind(); - updateList(); - - if(!activeGroup) { - setActiveInput(0); - } else if(++groupIndex >= activeGroup->size()) { - setActiveInput(0); - activeGroup = 0; - } else { - setActiveInput((*activeGroup)[groupIndex]); - } -} - -void InputSettingsWindow::inputEvent(uint16_t scancode) { - if(!activeInput) return; - if(!isActiveWindow() || isMinimized()) return; - int16_t state = mapper().state(scancode); - - if(dynamic_cast(activeInput)) { - if(Keyboard::isAnyKey(scancode) && mapper().state(scancode)) { - for(unsigned i = 0; i < Keyboard::Count; i++) { - //don't map escape key, as it is reserved by the user interface - if(scancode == keyboard(i)[Keyboard::Escape]) return; - } - - setAssignment(string() << mapper().modifierString() << Scancode::encode(scancode)); - } else if(Keyboard::isAnyModifier(scancode) && !config().input.modifierEnable) { - setAssignment(string() << Scancode::encode(scancode)); - } else if(Mouse::isAnyButton(scancode) && !mapper().state(scancode)) { - //ensure button was clicked inside list box - unsigned wx = 0, wy = 0; - QWidget *widget = buttonBox; - while(widget) { - wx += widget->geometry().x(); - wy += widget->geometry().y(); - widget = widget->parentWidget(); - } - unsigned px = QCursor::pos().x(); - unsigned py = QCursor::pos().y(); - if(px < wx || px >= wx + buttonBox->size().width()) return; - if(py < wy || py >= wy + buttonBox->size().height()) return; - - setAssignment(string() << mapper().modifierString() << Scancode::encode(scancode)); - } else if(Joypad::isAnyHat(scancode)) { - string position; - if(state == Joypad::HatUp) position = ".Up"; - else if(state == Joypad::HatDown) position = ".Down"; - else if(state == Joypad::HatLeft) position = ".Left"; - else if(state == Joypad::HatRight) position = ".Right"; - else return; - - setAssignment(string() << mapper().modifierString() << Scancode::encode(scancode) << position); - } else if(Joypad::isAnyAxis(scancode) && mapper().distance(scancode) > 64) { - if(mapper().calibrated == false) { - MappedInput *temp = activeInput; - activeInput = 0; - mapper().calibrate(); - activeInput = temp; - return; - } - - if(mapper().isTrigger[Joypad::numberDecode(scancode)][Joypad::axisDecode(scancode)] == false) { - string position; - if(state < -24576) position = ".Lo"; - else if(state > +24576) position = ".Hi"; - else return; - - setAssignment(string() << mapper().modifierString() << Scancode::encode(scancode) << position); - } else { - if(state >= 0) return; - - setAssignment(string() << mapper().modifierString() << Scancode::encode(scancode) << ".Trigger"); - } - } else if(Joypad::isAnyButton(scancode) && mapper().state(scancode)) { - setAssignment(string() << mapper().modifierString() << Scancode::encode(scancode)); - } - } else if(dynamic_cast(activeInput)) { - if(Mouse::isAnyButton(scancode) && mapper().state(scancode)) { - //actual assignment occurs during (x,y)AxisButton::released() - activeMouse = Mouse::numberDecode(scancode); - } else if(Joypad::isAnyAxis(scancode) && mapper().distance(scancode) > 64) { - if(mapper().calibrated == false) { - MappedInput *temp = activeInput; - activeInput = 0; - mapper().calibrate(); - activeInput = temp; - return; - } - - if(mapper().isTrigger[Joypad::numberDecode(scancode)][Joypad::axisDecode(scancode)] == false) { - if(state < -24576 || state > +24576) { - setAssignment(string() << Scancode::encode(scancode)); - } - } - } - } -} - -//called when double-clicking any list item; -//double-clicking a group expands or collapses it, -//so avoid triggering assign() unless this is not a group -void InputSettingsWindow::activateAssign() { - QTreeWidgetItem *item = list->currentItem(); - if(!item) return; - signed index = item->data(0, Qt::UserRole).toInt(); - if(index >= 0) assign(); -} - -void InputSettingsWindow::assign() { - QTreeWidgetItem *item = list->currentItem(); - if(!item) return; - signed index = item->data(0, Qt::UserRole).toInt(); - if(index == -1) return assignGroup(); - setActiveInput(inputTable[index]); -} - -void InputSettingsWindow::assignGroup() { - QTreeWidgetItem *item = list->currentItem(); - if(!item) return; - item->setExpanded(true); - item = item->child(0); - if(!item) return; - signed index = item->data(0, Qt::UserRole).toInt(); - if(index == -1) return; - - MappedInput *input = inputTable[index]; - activeGroup = input->parent; - setActiveInput((*activeGroup)[groupIndex = 0]); -} - -void InputSettingsWindow::unassign() { - QTreeWidgetItem *item = list->currentItem(); - if(!item) return; - signed index = item->data(0, Qt::UserRole).toInt(); - if(index == -1) return unassignGroup(); - - MappedInput *input = inputTable[index]; - input->name = "None"; - mapper().bind(); - updateList(); -} - -void InputSettingsWindow::unassignGroup() { - QTreeWidgetItem *item = list->currentItem(); - if(!item) return; - item = item->child(0); - if(!item) return; - signed index = item->data(0, Qt::UserRole).toInt(); - if(index == -1) return; - - MappedInput *input = inputTable[index]; - InputGroup &group = *(input->parent); - for(unsigned i = 0; i < group.size(); i++) { - group[i]->name = "None"; - } - mapper().bind(); - updateList(); -} - -void InputSettingsWindow::xAxisAssign() { - setAssignment(string() << Scancode::encode(mouse(activeMouse).axis(0))); -} - -void InputSettingsWindow::yAxisAssign() { - setAssignment(string() << Scancode::encode(mouse(activeMouse).axis(1))); -} - -void InputSettingsWindow::stop() { - setActiveInput(0); - activeGroup = 0; -} diff --git a/bsnes/ui-qt/settings/input.moc.hpp b/bsnes/ui-qt/settings/input.moc.hpp deleted file mode 100755 index 1a328e6b..00000000 --- a/bsnes/ui-qt/settings/input.moc.hpp +++ /dev/null @@ -1,44 +0,0 @@ -class InputSettingsWindow : public QWidget { - Q_OBJECT - -public: - QVBoxLayout *layout; - QTreeWidget *list; - QHBoxLayout *controlLayout; - QLabel *message; - QPushButton *optionButton; - QPushButton *assignButton; - QPushButton *unassignButton; - QLabel *buttonBox; - QPushButton *xAxisButton; - QPushButton *yAxisButton; - QPushButton *stopButton; - - void inputEvent(uint16_t scancode); - InputSettingsWindow(); - -private slots: - void synchronize(); - void activateAssign(); - void assign(); - void assignGroup(); - void unassign(); - void unassignGroup(); - void xAxisAssign(); - void yAxisAssign(); - void stop(); - -private: - QTreeWidgetItem *port1, *port2, *userInterface; - array inputTable; - MappedInput *activeInput; - InputGroup *activeGroup; - unsigned groupIndex; - unsigned activeMouse; - - void updateList(); - void setAssignment(string); - void setActiveInput(MappedInput*); -}; - -extern InputSettingsWindow *inputSettingsWindow; diff --git a/bsnes/ui-qt/settings/paths.cpp b/bsnes/ui-qt/settings/paths.cpp deleted file mode 100755 index 1796194e..00000000 --- a/bsnes/ui-qt/settings/paths.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "paths.moc" -PathSettingsWindow *pathSettingsWindow; - -PathSettingWidget::PathSettingWidget(string &pathValue_, const char *labelText, const char *pathDefaultLabel_, const char *pathBrowseLabel_) : pathValue(pathValue_) { - pathDefaultLabel = pathDefaultLabel_; - pathBrowseLabel = pathBrowseLabel_; - - layout = new QVBoxLayout; - layout->setMargin(0); - layout->setSpacing(0); - setLayout(layout); - - label = new QLabel(labelText); - layout->addWidget(label); - - controlLayout = new QHBoxLayout; - controlLayout->setSpacing(Style::WidgetSpacing); - layout->addLayout(controlLayout); - - path = new QLineEdit; - path->setReadOnly(true); - controlLayout->addWidget(path); - - pathSelect = new QPushButton("Select ..."); - controlLayout->addWidget(pathSelect); - - pathDefault = new QPushButton("Default"); - controlLayout->addWidget(pathDefault); - - connect(pathSelect, SIGNAL(released()), this, SLOT(selectPath())); - connect(pathDefault, SIGNAL(released()), this, SLOT(defaultPath())); - updatePath(); -} - -void PathSettingWidget::acceptPath(const string &newPath) { - fileBrowser->close(); - pathValue = string() << newPath << "/"; - config().path.current.folder = dir(pathValue); - updatePath(); -} - -void PathSettingWidget::updatePath() { - if(pathValue == "") { - path->setStyleSheet("color: #808080"); - path->setText(pathDefaultLabel); - } else { - path->setStyleSheet("color: #000000"); - path->setText(pathValue); - } -} - -void PathSettingWidget::selectPath() { - fileBrowser->onChange.reset(); - fileBrowser->onActivate.reset(); - fileBrowser->onAccept = { &PathSettingWidget::acceptPath, this }; - fileBrowser->setWindowTitle(pathBrowseLabel); - fileBrowser->setPath(config().path.current.folder); - fileBrowser->chooseFolder(); -} - -void PathSettingWidget::defaultPath() { - pathValue = ""; - updatePath(); -} - -PathSettingsWindow::PathSettingsWindow() { - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - layout->setAlignment(Qt::AlignTop); - setLayout(layout); - - gamePath = new PathSettingWidget(config().path.rom, "Games:", "Remember last path", "Default Game Path"); - savePath = new PathSettingWidget(config().path.save, "Save RAM:", "Same as loaded game", "Default Save RAM Path"); - statePath = new PathSettingWidget(config().path.state, "Save states:", "Same as loaded game", "Default Save State Path"); - patchPath = new PathSettingWidget(config().path.patch, "UPS patches:", "Same as loaded game", "Default UPS Patch Path"); - cheatPath = new PathSettingWidget(config().path.cheat, "Cheat codes:", "Same as loaded game", "Default Cheat Code Path"); - dataPath = new PathSettingWidget(config().path.data, "Exported data:", "Same as loaded game", "Default Exported Data Path"); - - layout->addWidget(gamePath); - layout->addWidget(savePath); - layout->addWidget(statePath); - layout->addWidget(patchPath); - layout->addWidget(cheatPath); - layout->addWidget(dataPath); -} diff --git a/bsnes/ui-qt/settings/paths.moc.hpp b/bsnes/ui-qt/settings/paths.moc.hpp deleted file mode 100755 index d9abd7aa..00000000 --- a/bsnes/ui-qt/settings/paths.moc.hpp +++ /dev/null @@ -1,40 +0,0 @@ -class PathSettingWidget : public QWidget { - Q_OBJECT - -public: - QVBoxLayout *layout; - QLabel *label; - QHBoxLayout *controlLayout; - QLineEdit *path; - QPushButton *pathSelect; - QPushButton *pathDefault; - - string &pathValue; - string pathDefaultLabel; - string pathBrowseLabel; - void acceptPath(const string&); - void updatePath(); - - PathSettingWidget(string&, const char*, const char*, const char*); - -public slots: - void selectPath(); - void defaultPath(); -}; - -class PathSettingsWindow : public QWidget { - Q_OBJECT - -public: - QVBoxLayout *layout; - PathSettingWidget *gamePath; - PathSettingWidget *savePath; - PathSettingWidget *statePath; - PathSettingWidget *patchPath; - PathSettingWidget *cheatPath; - PathSettingWidget *dataPath; - - PathSettingsWindow(); -}; - -extern PathSettingsWindow *pathSettingsWindow; diff --git a/bsnes/ui-qt/settings/profile.cpp b/bsnes/ui-qt/settings/profile.cpp deleted file mode 100755 index fd1dc8e4..00000000 --- a/bsnes/ui-qt/settings/profile.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include "profile.moc" -ProfileSettingsWindow *profileSettingsWindow; - -ProfileSettingsWindow::ProfileSettingsWindow() { - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(0); - layout->setAlignment(Qt::AlignTop); - setLayout(layout); - - profileInfo = new QLabel( - "Profiles allow you to balance emulation accuracy against system performance.
" - "Note that you must restart bsnes for profile changes to take effect!
" - "Also, while save RAM is compatible between profiles, save states are not cross-compatible." - ); - layout->addWidget(profileInfo); - layout->addSpacing(Style::WidgetSpacing); - - profileAccuracy = new QRadioButton("Accuracy"); - profileAccuracy->setStyleSheet("font-weight: bold; font-size: 12pt;"); - layout->addWidget(profileAccuracy); - - profileAccuracyInfo = new QLabel( - "System Requirements: A super-computer cooled by LN2.
" - "Maximum accuracy, no matter the cost.
" - "Use this mode for development or research purposes." - ); - profileAccuracyInfo->setStyleSheet("margin-left: 22px;"); - layout->addWidget(profileAccuracyInfo); - layout->addSpacing(Style::WidgetSpacing); - - profileCompatibility = new QRadioButton("Compatibility"); - profileCompatibility->setStyleSheet("font-weight: bold; font-size: 12pt;"); - layout->addWidget(profileCompatibility); - - profileCompatibilityInfo = new QLabel( - "System Requirements: Intel Core Solo or AMD Athlon 64 processor.
" - "Extreme accuracy with reasonable hardware requirements in mind.
" - "Very rarely, slight graphical glitches may appear in a small number of games." - ); - profileCompatibilityInfo->setStyleSheet("margin-left: 22px;"); - layout->addWidget(profileCompatibilityInfo); - layout->addSpacing(Style::WidgetSpacing); - - profilePerformance = new QRadioButton("Performance"); - profilePerformance->setStyleSheet("font-weight: bold; font-size: 12pt;"); - layout->addWidget(profilePerformance); - - profilePerformanceInfo = new QLabel( - "System Requirements: Intel Pentium IV or AMD Athlon processor.
" - "High accuracy with reasonable compromises for performance.
" - "Sacrifices a small degree of compatibility to run full-speed on older hardware.
" - "Use this mode for slower systems, or if you are running on battery power." - ); - profilePerformanceInfo->setStyleSheet("margin-left: 22px;"); - layout->addWidget(profilePerformanceInfo); - - if(config().system.profile == "accuracy") { - profileAccuracy->setChecked(true); - } else if(config().system.profile == "compatibility") { - profileCompatibility->setChecked(true); - } else if(config().system.profile == "performance") { - profilePerformance->setChecked(true); - } else { - config().system.profile = "compatibility"; - profileCompatibility->setChecked(true); - QMessageBox::information(0, "First-Run Notice", - "Note: bsnes contains multiple emulation profiles.

" - "If bsnes runs too slowly, you can greatly increase the speed by using the " - "'Performance' profile; or if you want even more accuracy, you can use the " - "'Accuracy' profile.

" - "Feel free to experiment. You can select different profiles via:
" - "Settings -> Configuration -> Profile" - ); - } - - connect(profileAccuracy, SIGNAL(pressed()), this, SLOT(setAccuracyProfile())); - connect(profileCompatibility, SIGNAL(pressed()), this, SLOT(setCompatibilityProfile())); - connect(profilePerformance, SIGNAL(pressed()), this, SLOT(setPerformanceProfile())); -} - -void ProfileSettingsWindow::setAccuracyProfile() { - config().system.profile = "accuracy"; -} - -void ProfileSettingsWindow::setCompatibilityProfile() { - config().system.profile = "compatibility"; -} - -void ProfileSettingsWindow::setPerformanceProfile() { - config().system.profile = "performance"; -} diff --git a/bsnes/ui-qt/settings/profile.moc.hpp b/bsnes/ui-qt/settings/profile.moc.hpp deleted file mode 100755 index cb156749..00000000 --- a/bsnes/ui-qt/settings/profile.moc.hpp +++ /dev/null @@ -1,22 +0,0 @@ -class ProfileSettingsWindow : public QWidget { - Q_OBJECT - -public: - QVBoxLayout *layout; - QLabel *profileInfo; - QRadioButton *profileAccuracy; - QLabel *profileAccuracyInfo; - QRadioButton *profileCompatibility; - QLabel *profileCompatibilityInfo; - QRadioButton *profilePerformance; - QLabel *profilePerformanceInfo; - - ProfileSettingsWindow(); - -private slots: - void setAccuracyProfile(); - void setCompatibilityProfile(); - void setPerformanceProfile(); -}; - -extern ProfileSettingsWindow *profileSettingsWindow; diff --git a/bsnes/ui-qt/settings/settings.cpp b/bsnes/ui-qt/settings/settings.cpp deleted file mode 100755 index a80f9faf..00000000 --- a/bsnes/ui-qt/settings/settings.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "../ui-base.hpp" - -#include "profile.cpp" -#include "video.cpp" -#include "audio.cpp" -#include "input.cpp" -#include "paths.cpp" -#include "advanced.cpp" - -#include "settings.moc" -SettingsWindow *settingsWindow; - -SettingsWindow::SettingsWindow() { - setObjectName("settings-window"); - setWindowTitle("Configuration Settings"); - resize(600, 360); - setGeometryString(&config().geometry.settingsWindow); - application.windowList.append(this); - - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - profileSettingsWindow = new ProfileSettingsWindow; - videoSettingsWindow = new VideoSettingsWindow; - audioSettingsWindow = new AudioSettingsWindow; - inputSettingsWindow = new InputSettingsWindow; - pathSettingsWindow = new PathSettingsWindow; - advancedSettingsWindow = new AdvancedSettingsWindow; - - profileArea = new QScrollArea; - profileArea->setWidget(profileSettingsWindow); - profileArea->setFrameStyle(0); - profileArea->setWidgetResizable(true); - - videoArea = new QScrollArea; - videoArea->setWidget(videoSettingsWindow); - videoArea->setFrameStyle(0); - videoArea->setWidgetResizable(true); - - audioArea = new QScrollArea; - audioArea->setWidget(audioSettingsWindow); - audioArea->setFrameStyle(0); - audioArea->setWidgetResizable(true); - - inputArea = new QScrollArea; - inputArea->setWidget(inputSettingsWindow); - inputArea->setFrameStyle(0); - inputArea->setWidgetResizable(true); - - pathArea = new QScrollArea; - pathArea->setWidget(pathSettingsWindow); - pathArea->setFrameStyle(0); - pathArea->setWidgetResizable(true); - - advancedArea = new QScrollArea; - advancedArea->setWidget(advancedSettingsWindow); - advancedArea->setFrameStyle(0); - advancedArea->setWidgetResizable(true); - - tab = new QTabWidget; - tab->addTab(profileArea, "Profile"); - tab->addTab(videoArea, "Video"); - tab->addTab(audioArea, "Audio"); - tab->addTab(inputArea, "Input"); - tab->addTab(pathArea, "Paths"); - tab->addTab(advancedArea, "Advanced"); - layout->addWidget(tab); -} diff --git a/bsnes/ui-qt/settings/settings.moc.hpp b/bsnes/ui-qt/settings/settings.moc.hpp deleted file mode 100755 index f337112b..00000000 --- a/bsnes/ui-qt/settings/settings.moc.hpp +++ /dev/null @@ -1,19 +0,0 @@ -class SettingsWindow : public Window { - Q_OBJECT - -public: - QVBoxLayout *layout; - QTabWidget *tab; - QScrollArea *profileArea; - QScrollArea *videoArea; - QScrollArea *audioArea; - QScrollArea *inputArea; - QScrollArea *pathArea; - QScrollArea *advancedArea; - - SettingsWindow(); - -public slots: -}; - -extern SettingsWindow *settingsWindow; diff --git a/bsnes/ui-qt/settings/video.cpp b/bsnes/ui-qt/settings/video.cpp deleted file mode 100755 index 35693abd..00000000 --- a/bsnes/ui-qt/settings/video.cpp +++ /dev/null @@ -1,294 +0,0 @@ -#include "video.moc" -VideoSettingsWindow *videoSettingsWindow; - -VideoSettingsWindow::VideoSettingsWindow() { - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - layout->setAlignment(Qt::AlignTop); - setLayout(layout); - - displayLabel = new QLabel("Display"); - layout->addWidget(displayLabel); - - autoHideFullscreenMenu = new QCheckBox("Auto-hide menus when entering fullscreen mode"); - layout->addWidget(autoHideFullscreenMenu); - - colorLabel = new QLabel("Color Adjustment"); - layout->addWidget(colorLabel); - - colorLayout = new QGridLayout; - layout->addLayout(colorLayout); - - contrastLabel = new QLabel("Contrast adjust:"); - colorLayout->addWidget(contrastLabel, 0, 0); - - contrastValue = new QLabel; - contrastValue->setAlignment(Qt::AlignHCenter); - contrastValue->setMinimumWidth(contrastValue->fontMetrics().width("+100%")); - colorLayout->addWidget(contrastValue, 0, 1); - - contrastSlider = new QSlider(Qt::Horizontal); - contrastSlider->setMinimum(-95); - contrastSlider->setMaximum(+95); - colorLayout->addWidget(contrastSlider, 0, 2); - - brightnessLabel = new QLabel("Brightness adjust:"); - colorLayout->addWidget(brightnessLabel, 1, 0); - - brightnessValue = new QLabel; - brightnessValue->setAlignment(Qt::AlignHCenter); - colorLayout->addWidget(brightnessValue, 1, 1); - - brightnessSlider = new QSlider(Qt::Horizontal); - brightnessSlider->setMinimum(-95); - brightnessSlider->setMaximum(+95); - colorLayout->addWidget(brightnessSlider, 1, 2); - - gammaLabel = new QLabel("Gamma adjust:"); - colorLayout->addWidget(gammaLabel, 2, 0); - - gammaValue = new QLabel; - gammaValue->setAlignment(Qt::AlignHCenter); - colorLayout->addWidget(gammaValue, 2, 1); - - gammaSlider = new QSlider(Qt::Horizontal); - gammaSlider->setMinimum(-95); - gammaSlider->setMaximum(+95); - colorLayout->addWidget(gammaSlider, 2, 2); - - scanlineLabel = new QLabel("Scanline adjust:"); - colorLayout->addWidget(scanlineLabel, 3, 0); - - scanlineValue = new QLabel; - scanlineValue->setAlignment(Qt::AlignHCenter); - colorLayout->addWidget(scanlineValue, 3, 1); - - scanlineSlider = new QSlider(Qt::Horizontal); - scanlineSlider->setMinimum(0); - scanlineSlider->setMaximum(20); - scanlineSlider->setPageStep(4); - colorLayout->addWidget(scanlineSlider, 3, 2); - - options = new QHBoxLayout; - layout->addLayout(options); - - enableGammaRamp = new QCheckBox("Simulate NTSC TV gamma ramp"); - enableGammaRamp->setToolTip("Lower monitor gamma to more accurately match a CRT television"); - options->addWidget(enableGammaRamp); - - cropLabel = new QLabel("Overscan Compensation"); - layout->addWidget(cropLabel); - - cropLayout = new QGridLayout; - layout->addLayout(cropLayout); - - cropLeftLabel = new QLabel("Left:"); - cropLayout->addWidget(cropLeftLabel, 0, 0); - - cropLeftValue = new QLabel; - cropLeftValue->setAlignment(Qt::AlignHCenter); - cropLeftValue->setMinimumWidth(cropLeftValue->fontMetrics().width("+100%")); - cropLayout->addWidget(cropLeftValue, 0, 1); - - cropLeftSlider = new QSlider(Qt::Horizontal); - cropLeftSlider->setMinimum(0); - cropLeftSlider->setMaximum(20); - cropLayout->addWidget(cropLeftSlider, 0, 2); - - cropTopLabel = new QLabel("Top:"); - cropLayout->addWidget(cropTopLabel, 1, 0); - - cropTopValue = new QLabel; - cropTopValue->setAlignment(Qt::AlignHCenter); - cropLayout->addWidget(cropTopValue, 1, 1); - - cropTopSlider = new QSlider(Qt::Horizontal); - cropTopSlider->setMinimum(0); - cropTopSlider->setMaximum(20); - cropLayout->addWidget(cropTopSlider, 1, 2); - - cropRightLabel = new QLabel("Right:"); - cropLayout->addWidget(cropRightLabel, 2, 0); - - cropRightValue = new QLabel; - cropRightValue->setAlignment(Qt::AlignHCenter); - cropLayout->addWidget(cropRightValue, 2, 1); - - cropRightSlider = new QSlider(Qt::Horizontal); - cropRightSlider->setMinimum(0); - cropRightSlider->setMaximum(20); - cropLayout->addWidget(cropRightSlider, 2, 2); - - cropBottomLabel = new QLabel("Bottom:"); - cropLayout->addWidget(cropBottomLabel, 3, 0); - - cropBottomValue = new QLabel; - cropBottomValue->setAlignment(Qt::AlignHCenter); - cropLayout->addWidget(cropBottomValue, 3, 1); - - cropBottomSlider = new QSlider(Qt::Horizontal); - cropBottomSlider->setMinimum(0); - cropBottomSlider->setMaximum(20); - cropLayout->addWidget(cropBottomSlider, 3, 2); - - pixelShaderLabel = new QLabel("Pixel Shader"); - layout->addWidget(pixelShaderLabel); - - pixelShaderLayout = new QGridLayout; - layout->addLayout(pixelShaderLayout); - - shaderValue = new QLineEdit; - pixelShaderLayout->addWidget(shaderValue, 0, 0); - - shaderSelect = new QPushButton("Select ..."); - pixelShaderLayout->addWidget(shaderSelect, 0, 1); - - shaderDefault = new QPushButton("Default"); - pixelShaderLayout->addWidget(shaderDefault, 0, 2); - - connect(autoHideFullscreenMenu, SIGNAL(stateChanged(int)), this, SLOT(autoHideFullscreenMenuToggle())); - connect(contrastSlider, SIGNAL(valueChanged(int)), this, SLOT(contrastAdjust(int))); - connect(brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(brightnessAdjust(int))); - connect(gammaSlider, SIGNAL(valueChanged(int)), this, SLOT(gammaAdjust(int))); - connect(scanlineSlider, SIGNAL(valueChanged(int)), this, SLOT(scanlineAdjust(int))); - connect(enableGammaRamp, SIGNAL(stateChanged(int)), this, SLOT(gammaRampToggle(int))); - connect(cropLeftSlider, SIGNAL(valueChanged(int)), this, SLOT(cropLeftAdjust(int))); - connect(cropTopSlider, SIGNAL(valueChanged(int)), this, SLOT(cropTopAdjust(int))); - connect(cropRightSlider, SIGNAL(valueChanged(int)), this, SLOT(cropRightAdjust(int))); - connect(cropBottomSlider, SIGNAL(valueChanged(int)), this, SLOT(cropBottomAdjust(int))); - connect(shaderSelect, SIGNAL(released()), this, SLOT(selectShader())); - connect(shaderDefault, SIGNAL(released()), this, SLOT(defaultShader())); - - syncUi(); -} - -void VideoSettingsWindow::synchronizePixelShaderSettings() { - if(video.cap(Video::Shader) == false) { - pixelShaderLabel->hide(); - shaderValue->hide(); - shaderSelect->hide(); - shaderDefault->hide(); - } -} - -void VideoSettingsWindow::syncUi() { - int n; - - autoHideFullscreenMenu->setChecked(config().video.autoHideFullscreenMenu); - - n = config().video.contrastAdjust; - contrastValue->setText(string() << (n > 0 ? "+" : "") << n << "%"); - contrastSlider->setSliderPosition(n); - - n = config().video.brightnessAdjust; - brightnessValue->setText(string() << (n > 0 ? "+" : "") << n << "%"); - brightnessSlider->setSliderPosition(n); - - n = config().video.gammaAdjust; - gammaValue->setText(string() << (n > 0 ? "+" : "") << n << "%"); - gammaSlider->setSliderPosition(n); - - n = config().video.scanlineAdjust; - scanlineValue->setText(string() << n << "%"); - scanlineSlider->setSliderPosition(n / 5); - - enableGammaRamp->setChecked(config().video.enableGammaRamp); - - n = config().video.cropLeft; - cropLeftValue->setText(string() << n << "%"); - cropLeftSlider->setSliderPosition(n); - - n = config().video.cropTop; - cropTopValue->setText(string() << n << "%"); - cropTopSlider->setSliderPosition(n); - - n = config().video.cropRight; - cropRightValue->setText(string() << n << "%"); - cropRightSlider->setSliderPosition(n); - - n = config().video.cropBottom; - cropBottomValue->setText(string() << n << "%"); - cropBottomSlider->setSliderPosition(n); - - shaderValue->setText(config().path.shader); -} - -void VideoSettingsWindow::autoHideFullscreenMenuToggle() { - config().video.autoHideFullscreenMenu = autoHideFullscreenMenu->isChecked(); -} - -void VideoSettingsWindow::contrastAdjust(int value) { - config().video.contrastAdjust = value; - syncUi(); - utility.updateColorFilter(); -} - -void VideoSettingsWindow::brightnessAdjust(int value) { - config().video.brightnessAdjust = value; - syncUi(); - utility.updateColorFilter(); -} - -void VideoSettingsWindow::gammaAdjust(int value) { - config().video.gammaAdjust = value; - syncUi(); - utility.updateColorFilter(); -} - -void VideoSettingsWindow::scanlineAdjust(int value) { - config().video.scanlineAdjust = value * 5; - syncUi(); - scanlineFilter.setIntensity(value * 5); -} - -void VideoSettingsWindow::gammaRampToggle(int state) { - config().video.enableGammaRamp = (state == Qt::Checked); - syncUi(); - utility.updateColorFilter(); -} - -void VideoSettingsWindow::cropLeftAdjust(int state) { - config().video.cropLeft = state; - if(config().video.context->multiplier != 8) display.cropLeft = state; - syncUi(); -} - -void VideoSettingsWindow::cropTopAdjust(int state) { - config().video.cropTop = state; - if(config().video.context->multiplier != 8) display.cropTop = state; - syncUi(); -} - -void VideoSettingsWindow::cropRightAdjust(int state) { - config().video.cropRight = state; - if(config().video.context->multiplier != 8) display.cropRight = state; - syncUi(); -} - -void VideoSettingsWindow::cropBottomAdjust(int state) { - config().video.cropBottom = state; - if(config().video.context->multiplier != 8) display.cropBottom = state; - syncUi(); -} - -void VideoSettingsWindow::selectShader() { - fileBrowser->onChange.reset(); - fileBrowser->onActivate = { &VideoSettingsWindow::assignShader, this }; - fileBrowser->onAccept = { &VideoSettingsWindow::assignShader, this }; - fileBrowser->setWindowTitle("Select Pixel Shader"); - fileBrowser->setPath(config().path.current.shader); - fileBrowser->setNameFilters("Shader files (*.shader)"); - fileBrowser->chooseFile(); -} - -void VideoSettingsWindow::defaultShader() { assignShader(""); } - -void VideoSettingsWindow::assignShader(const string &filename) { - if(filename == "" || QDir(filename).exists() == false) { - config().path.shader = filename; - if(filename != "") config().path.current.shader = dir(filename); - syncUi(); - utility.updatePixelShader(); - } -} diff --git a/bsnes/ui-qt/settings/video.moc.hpp b/bsnes/ui-qt/settings/video.moc.hpp deleted file mode 100755 index ac362006..00000000 --- a/bsnes/ui-qt/settings/video.moc.hpp +++ /dev/null @@ -1,66 +0,0 @@ -class VideoSettingsWindow : public QWidget { - Q_OBJECT - -public: - QVBoxLayout *layout; - QLabel *displayLabel; - QCheckBox *autoHideFullscreenMenu; - QLabel *colorLabel; - QGridLayout *colorLayout; - QLabel *contrastLabel; - QLabel *contrastValue; - QSlider *contrastSlider; - QLabel *brightnessLabel; - QLabel *brightnessValue; - QSlider *brightnessSlider; - QLabel *gammaLabel; - QLabel *gammaValue; - QSlider *gammaSlider; - QLabel *scanlineLabel; - QLabel *scanlineValue; - QSlider *scanlineSlider; - QHBoxLayout *options; - QCheckBox *enableGammaRamp; - QLabel *cropLabel; - QGridLayout *cropLayout; - QLabel *cropLeftLabel; - QLabel *cropLeftValue; - QSlider *cropLeftSlider; - QLabel *cropTopLabel; - QLabel *cropTopValue; - QSlider *cropTopSlider; - QLabel *cropRightLabel; - QLabel *cropRightValue; - QSlider *cropRightSlider; - QLabel *cropBottomLabel; - QLabel *cropBottomValue; - QSlider *cropBottomSlider; - QLabel *pixelShaderLabel; - QGridLayout *pixelShaderLayout; - QLineEdit *shaderValue; - QPushButton *shaderSelect; - QPushButton *shaderDefault; - - void synchronizePixelShaderSettings(); - void syncUi(); - VideoSettingsWindow(); - -private slots: - void autoHideFullscreenMenuToggle(); - void contrastAdjust(int); - void brightnessAdjust(int); - void gammaAdjust(int); - void scanlineAdjust(int); - void gammaRampToggle(int); - void cropLeftAdjust(int); - void cropTopAdjust(int); - void cropRightAdjust(int); - void cropBottomAdjust(int); - void selectShader(); - void defaultShader(); - -private: - void assignShader(const string &filename); -}; - -extern VideoSettingsWindow *videoSettingsWindow; diff --git a/bsnes/ui-qt/state/state.cpp b/bsnes/ui-qt/state/state.cpp deleted file mode 100755 index 4b13a76e..00000000 --- a/bsnes/ui-qt/state/state.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include "../ui-base.hpp" -State state; - -bool State::save(unsigned slot) { - if(!allowed()) { - utility.showMessage("Cannot save state."); - return false; - } - - SNES::system.runtosave(); - serializer state = SNES::system.serialize(); - - file fp; - bool result = false; - if(fp.open(name(slot), file::mode::write)) { - fp.write(state.data(), state.size()); - fp.close(); - result = true; - } - - if(result) { - utility.showMessage(string() << "State " << (slot + 1) << " saved."); - } else { - utility.showMessage(string() << "Failed to save state " << (slot + 1) << "."); - } - return result; -} - -bool State::load(unsigned slot) { - if(!allowed()) { - utility.showMessage("Cannot load state."); - return false; - } - - file fp; - bool result = false; - if(fp.open(name(slot), file::mode::read)) { - unsigned size = fp.size(); - uint8_t *data = new uint8_t[size]; - fp.read(data, size); - fp.close(); - serializer state(data, size); - delete[] data; - result = SNES::system.unserialize(state); - } - - if(result) { - utility.showMessage(string() << "State " << (slot + 1) << " loaded."); - resetHistory(); - } else { - utility.showMessage(string() << "Failed to load state " << (slot + 1) << "."); - } - return result; -} - -void State::frame() { - if(!allowed()) return; - if(!config().system.rewindEnabled) return; - - //if a full second has passed, automatically capture state - if(++frameCounter >= (SNES::system.region() == SNES::System::Region::NTSC ? 60 : 50)) { - frameCounter = 0; - historyIndex = (historyIndex + 1) % historySize; - historyCount = min(historyCount + 1, historySize); - SNES::system.runtosave(); - history[historyIndex] = SNES::system.serialize(); - } -} - -void State::resetHistory() { - historyIndex = 0; - historyCount = 0; - frameCounter = 0; -} - -bool State::rewind() { - if(!allowed()) return false; - if(!config().system.rewindEnabled) return false; - - if(historyCount == 0) return false; - serializer state(history[historyIndex].data(), history[historyIndex].size()); - bool result = SNES::system.unserialize(state); - historyIndex = (historyIndex + historySize - 1) % historySize; //add historySize to prevent underflow - historyCount--; - return true; -} - -State::State() { - active = 0; - historySize = 120; - history = new serializer[historySize]; - for(unsigned i = 0; i < historySize; i++) history[i] = 0; -} - -State::~State() { - delete[] history; -} - -// - -bool State::allowed() const { - if(!SNES::cartridge.loaded() || !application.power) return false; - if(movie.state != Movie::Inactive) return false; - return cartridge.saveStatesSupported(); -} - -string State::name(unsigned slot) const { - string name = filepath(nall::basename(cartridge.fileName), config().path.state); - name << "-" << (slot + 1) << ".bst"; - return name; -} diff --git a/bsnes/ui-qt/state/state.hpp b/bsnes/ui-qt/state/state.hpp deleted file mode 100755 index 5bc4d980..00000000 --- a/bsnes/ui-qt/state/state.hpp +++ /dev/null @@ -1,25 +0,0 @@ -class State { -public: - unsigned active; - bool save(unsigned); - bool load(unsigned); - - void frame(); - void resetHistory(); - bool rewind(); - - State(); - ~State(); - -private: - serializer *history; - unsigned historySize; - unsigned historyIndex; - unsigned historyCount; - unsigned frameCounter; - - bool allowed() const; - string name(unsigned slot) const; -}; - -extern State state; diff --git a/bsnes/ui-qt/template/Makefile b/bsnes/ui-qt/template/Makefile deleted file mode 100755 index 69e84960..00000000 --- a/bsnes/ui-qt/template/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# requires nall/Makefile - -# imports: -# $(qtlibs) -- list of Qt components to link against - -# exports the following symbols: -# $(moc) -- meta-object compiler -# $(rcc) -- resource compiler -# $(qtinc) -- includes for compiling -# $(qtlib) -- libraries for linking - -ifeq ($(moc),) -moc := moc -endif - -ifeq ($(rcc),) -rcc := rcc -endif - -ifeq ($(platform),x) - qtinc := `pkg-config --cflags $(qtlibs)` - qtlib := `pkg-config --libs $(qtlibs)` -else ifeq ($(platform),osx) - qtinc := $(foreach lib,$(qtlibs),-I/Library/Frameworks/$(lib).framework/Versions/4/Headers) - - qtlib := -L/Library/Frameworks - qtlib += $(foreach lib,$(qtlibs),-framework $(lib)) - qtlib += -framework Carbon - qtlib += -framework Cocoa - qtlib += -framework OpenGL - qtlib += -framework AppKit - qtlib += -framework ApplicationServices -else ifeq ($(platform),win) - ifeq ($(qtpath),) - # find Qt install directory from PATH environment variable - qtpath := $(foreach path,$(subst ;, ,$(PATH)),$(if $(wildcard $(path)/$(moc).exe),$(path))) - qtpath := $(strip $(qtpath)) - qtpath := $(subst \,/,$(qtpath)) - qtpath := $(patsubst %/bin,%,$(qtpath)) - endif - - qtinc := -I$(qtpath)/include - qtinc += $(foreach lib,$(qtlibs),-I$(qtpath)/include/$(lib)) - - qtlib := -L$(qtpath)/lib - qtlib += -L$(qtpath)/plugins/imageformats - - qtlib += $(foreach lib,$(qtlibs),-l$(lib)4) - qtlib += -lmingw32 -lqtmain -lcomdlg32 -loleaut32 -limm32 -lwinmm - qtlib += -lwinspool -lmsimg32 -lole32 -ladvapi32 -lws2_32 -luuid -lgdi32 - qtlib += $(foreach lib,$(qtlibs),-l$(lib)4) - - # optional image-file support: - # qtlib += -lqjpeg -lqmng -endif diff --git a/bsnes/ui-qt/template/check-action.moc.hpp b/bsnes/ui-qt/template/check-action.moc.hpp deleted file mode 100755 index db378fe9..00000000 --- a/bsnes/ui-qt/template/check-action.moc.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef NALL_QT_CHECKACTION_HPP -#define NALL_QT_CHECKACTION_HPP - -namespace nall { - -class CheckAction : public QAction { - Q_OBJECT - -public: - bool isChecked() const; - void setChecked(bool); - void toggleChecked(); - CheckAction(const QString&, QObject*); - -protected slots: - -protected: - bool checked; -}; - -inline bool CheckAction::isChecked() const { - return checked; -} - -inline void CheckAction::setChecked(bool checked_) { - checked = checked_; - if(checked) setIcon(QIcon(":/16x16/item-check-on.png")); - else setIcon(QIcon(":/16x16/item-check-off.png")); -} - -inline void CheckAction::toggleChecked() { - setChecked(!isChecked()); -} - -inline CheckAction::CheckAction(const QString &text, QObject *parent) : QAction(text, parent) { - setChecked(false); -} - -} - -#endif diff --git a/bsnes/ui-qt/template/concept.hpp b/bsnes/ui-qt/template/concept.hpp deleted file mode 100755 index 51cacef4..00000000 --- a/bsnes/ui-qt/template/concept.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef NALL_QT_CONCEPT_HPP -#define NALL_QT_CONCEPT_HPP - -#include - -namespace nall { - template struct has_count> { enum { value = true }; }; -} - -#endif diff --git a/bsnes/ui-qt/template/file-dialog.moc.hpp b/bsnes/ui-qt/template/file-dialog.moc.hpp deleted file mode 100755 index 34a7655b..00000000 --- a/bsnes/ui-qt/template/file-dialog.moc.hpp +++ /dev/null @@ -1,392 +0,0 @@ -#ifndef NALL_QT_FILEDIALOG_HPP -#define NALL_QT_FILEDIALOG_HPP - -#include -#include -#include "window.moc.hpp" - -namespace nall { - -class FileDialog; - -class NewFolderDialog : public Window { - Q_OBJECT - -public: - void show(); - NewFolderDialog(FileDialog*); - -protected slots: - void createFolderAction(); - -protected: - FileDialog *parent; - QVBoxLayout *layout; - QLineEdit *folderNameEdit; - QHBoxLayout *controlLayout; - QPushButton *okButton; - QPushButton *cancelButton; -}; - -class FileView : public QListView { - Q_OBJECT - -protected: - void keyPressEvent(QKeyEvent*); - -signals: - void changed(const QModelIndex&); - void browseUp(); - -protected slots: - void currentChanged(const QModelIndex&, const QModelIndex&); -}; - -class FileDialog : public Window { - Q_OBJECT - -public: - void showLoad(); - void showSave(); - void showFolder(); - - void setPath(string path); - void setNameFilters(const string &filters); - FileDialog(); - -signals: - void changed(const string&); - void activated(const string&); - void accepted(const string&); - void rejected(); - -protected slots: - void fileViewChange(const QModelIndex&); - void fileViewActivate(const QModelIndex&); - void pathBoxChanged(); - void filterBoxChanged(); - void createNewFolder(); - void browseUp(); - void acceptAction(); - void rejectAction(); - -protected: - NewFolderDialog *newFolderDialog; - QVBoxLayout *layout; - QHBoxLayout *navigationLayout; - QComboBox *pathBox; - QPushButton *newFolderButton; - QPushButton *upFolderButton; - QHBoxLayout *browseLayout; - QFileSystemModel *fileSystemModel; - FileView *fileView; - QGroupBox *previewFrame; - QLineEdit *fileNameEdit; - QHBoxLayout *controlLayout; - QComboBox *filterBox; - QPushButton *optionsButton; - QPushButton *acceptButton; - QPushButton *rejectButton; - bool lock; - void createFolderAction(const string &name); - void closeEvent(QCloseEvent*); - - friend class NewFolderDialog; -}; - -inline void NewFolderDialog::show() { - folderNameEdit->setText(""); - Window::show(); - folderNameEdit->setFocus(); -} - -inline void NewFolderDialog::createFolderAction() { - string name = folderNameEdit->text().toUtf8().constData(); - if(name == "") { - folderNameEdit->setFocus(); - } else { - parent->createFolderAction(name); - close(); - } -} - -inline NewFolderDialog::NewFolderDialog(FileDialog *fileDialog) : parent(fileDialog) { - setMinimumWidth(240); - setWindowTitle("Create New Folder"); - - layout = new QVBoxLayout; - layout->setAlignment(Qt::AlignTop); - layout->setMargin(5); - layout->setSpacing(5); - setLayout(layout); - - folderNameEdit = new QLineEdit; - layout->addWidget(folderNameEdit); - - controlLayout = new QHBoxLayout; - controlLayout->setAlignment(Qt::AlignRight); - layout->addLayout(controlLayout); - - okButton = new QPushButton("Ok"); - controlLayout->addWidget(okButton); - - cancelButton = new QPushButton("Cancel"); - controlLayout->addWidget(cancelButton); - - connect(folderNameEdit, SIGNAL(returnPressed()), this, SLOT(createFolderAction())); - connect(okButton, SIGNAL(released()), this, SLOT(createFolderAction())); - connect(cancelButton, SIGNAL(released()), this, SLOT(close())); -} - -inline void FileView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { - QAbstractItemView::currentChanged(current, previous); - emit changed(current); -} - -inline void FileView::keyPressEvent(QKeyEvent *event) { - //enhance consistency: force OS X to act like Windows and Linux; enter = activate item - if(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { - emit activated(currentIndex()); - return; - } - - //simulate popular file manager behavior; backspace = go up one directory - if(event->key() == Qt::Key_Backspace) { - emit browseUp(); - return; - } - - //fallback: unrecognized keypresses get handled by the widget itself - QListView::keyPressEvent(event); -} - -inline void FileDialog::showLoad() { - acceptButton->setText("Load"); - fileNameEdit->hide(); - filterBox->show(); - show(); -} - -inline void FileDialog::showSave() { - acceptButton->setText("Save"); - fileNameEdit->show(); - filterBox->show(); - show(); -} - -inline void FileDialog::showFolder() { - acceptButton->setText("Choose"); - fileNameEdit->hide(); - filterBox->hide(); - setNameFilters("Folders ()"); - show(); -} - -inline void FileDialog::fileViewChange(const QModelIndex &index) { - string path = fileSystemModel->filePath(index).toUtf8().constData(); - if(path == fileSystemModel->rootPath().toUtf8().constData()) path = ""; - fileNameEdit->setText(notdir(path)); - emit changed(path); -} - -inline void FileDialog::fileViewActivate(const QModelIndex &index) { - string path = fileSystemModel->filePath(index).toUtf8().constData(); - if(fileSystemModel->isDir(index)) { - emit activated(path); - setPath(path); - } else { - emit activated(path); - close(); - } -} - -inline void FileDialog::pathBoxChanged() { - if(lock) return; - setPath(pathBox->currentText().toUtf8().constData()); -} - -inline void FileDialog::filterBoxChanged() { - if(lock) return; - string filters = filterBox->currentText().toUtf8().constData(); - if(filters.length() == 0) { - fileSystemModel->setNameFilters(QStringList() << "*"); - } else { - filters = substr(filters, strpos(filters, "(")()); - filters.ltrim("("); - filters.rtrim(")"); - lstring part; - part.split(" ", filters); - QStringList list; - for(unsigned i = 0; i < part.size(); i++) list << part[i]; - fileSystemModel->setNameFilters(list); - } -} - -inline void FileDialog::createNewFolder() { - newFolderDialog->show(); -} - -inline void FileDialog::browseUp() { - if(pathBox->count() > 1) pathBox->setCurrentIndex(1); -} - -inline void FileDialog::setPath(string path) { - lock = true; - newFolderDialog->close(); - - if(QDir(path).exists()) { - newFolderButton->setEnabled(true); - } else { - newFolderButton->setEnabled(false); - path = ""; - } - - fileSystemModel->setRootPath(path); - fileView->setRootIndex(fileSystemModel->index(path)); - fileView->setCurrentIndex(fileView->rootIndex()); - fileView->setFocus(); - - pathBox->clear(); - if(path.length() > 0) { - QDir directory(path); - while(true) { - pathBox->addItem(directory.absolutePath()); - if(directory.isRoot()) break; - directory.cdUp(); - } - } - pathBox->addItem(""); - fileNameEdit->setText(""); - - lock = false; -} - -inline void FileDialog::setNameFilters(const string &filters) { - lock = true; - - lstring list; - list.split("\n", filters); - - filterBox->clear(); - for(unsigned i = 0; i < list.size(); i++) { - filterBox->addItem(list[i]); - } - - lock = false; - filterBoxChanged(); -} - -inline void FileDialog::acceptAction() { - string path = fileSystemModel->rootPath().toUtf8().constData(); - path << "/" << notdir(fileNameEdit->text().toUtf8().constData()); - path.rtrim("/"); - if(QDir(path).exists()) { - emit accepted(path); - setPath(path); - } else { - emit accepted(path); - close(); - } -} - -inline void FileDialog::rejectAction() { - emit rejected(); - close(); -} - -inline void FileDialog::createFolderAction(const string &name) { - string path = fileSystemModel->rootPath().toUtf8().constData(); - path << "/" << notdir(name); - mkdir(path, 0755); -} - -inline void FileDialog::closeEvent(QCloseEvent *event) { - newFolderDialog->close(); - Window::closeEvent(event); -} - -inline FileDialog::FileDialog() { - newFolderDialog = new NewFolderDialog(this); - resize(640, 360); - - layout = new QVBoxLayout; - layout->setMargin(5); - layout->setSpacing(5); - setLayout(layout); - - navigationLayout = new QHBoxLayout; - layout->addLayout(navigationLayout); - - pathBox = new QComboBox; - pathBox->setEditable(true); - pathBox->setMinimumContentsLength(16); - pathBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); - pathBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - navigationLayout->addWidget(pathBox); - - newFolderButton = new QPushButton; - newFolderButton->setIconSize(QSize(16, 16)); - newFolderButton->setIcon(QIcon(":/16x16/folder-new.png")); - navigationLayout->addWidget(newFolderButton); - - upFolderButton = new QPushButton; - upFolderButton->setIconSize(QSize(16, 16)); - upFolderButton->setIcon(QIcon(":/16x16/go-up.png")); - navigationLayout->addWidget(upFolderButton); - - browseLayout = new QHBoxLayout; - layout->addLayout(browseLayout); - - fileSystemModel = new QFileSystemModel; - fileSystemModel->setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); - fileSystemModel->setNameFilterDisables(false); - - fileView = new FileView; - fileView->setMinimumWidth(320); - fileView->setModel(fileSystemModel); - fileView->setIconSize(QSize(16, 16)); - browseLayout->addWidget(fileView); - - previewFrame = new QGroupBox; - previewFrame->hide(); - browseLayout->addWidget(previewFrame); - - fileNameEdit = new QLineEdit; - layout->addWidget(fileNameEdit); - - controlLayout = new QHBoxLayout; - controlLayout->setAlignment(Qt::AlignRight); - layout->addLayout(controlLayout); - - filterBox = new QComboBox; - filterBox->setMinimumContentsLength(16); - filterBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); - filterBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - controlLayout->addWidget(filterBox); - - optionsButton = new QPushButton("Options"); - optionsButton->hide(); - controlLayout->addWidget(optionsButton); - - acceptButton = new QPushButton("Ok"); - controlLayout->addWidget(acceptButton); - - rejectButton = new QPushButton("Cancel"); - controlLayout->addWidget(rejectButton); - - lock = false; - connect(pathBox, SIGNAL(currentIndexChanged(int)), this, SLOT(pathBoxChanged())); - connect(newFolderButton, SIGNAL(released()), this, SLOT(createNewFolder())); - connect(upFolderButton, SIGNAL(released()), this, SLOT(browseUp())); - connect(fileView, SIGNAL(changed(const QModelIndex&)), this, SLOT(fileViewChange(const QModelIndex&))); - connect(fileView, SIGNAL(activated(const QModelIndex&)), this, SLOT(fileViewActivate(const QModelIndex&))); - connect(fileView, SIGNAL(browseUp()), this, SLOT(browseUp())); - connect(fileNameEdit, SIGNAL(returnPressed()), this, SLOT(acceptAction())); - connect(filterBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterBoxChanged())); - connect(acceptButton, SIGNAL(released()), this, SLOT(acceptAction())); - connect(rejectButton, SIGNAL(released()), this, SLOT(rejectAction())); -} - -} - -#endif diff --git a/bsnes/ui-qt/template/hex-editor.moc.hpp b/bsnes/ui-qt/template/hex-editor.moc.hpp deleted file mode 100755 index d59f4be9..00000000 --- a/bsnes/ui-qt/template/hex-editor.moc.hpp +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef NALL_QT_HEXEDITOR_HPP -#define NALL_QT_HEXEDITOR_HPP - -#include -#include -#include - -namespace nall { - -class HexEditor : public QTextEdit { - Q_OBJECT - -public: - function reader; - function writer; - - void setColumns(unsigned columns); - void setRows(unsigned rows); - void setOffset(unsigned offset); - void setSize(unsigned size); - unsigned lineWidth() const; - void refresh(); - - HexEditor(); - -protected slots: - void scrolled(); - -protected: - QHBoxLayout *layout; - QScrollBar *scrollBar; - unsigned editorColumns; - unsigned editorRows; - unsigned editorOffset; - unsigned editorSize; - bool lock; - - void keyPressEvent(QKeyEvent*); -}; - -inline void HexEditor::keyPressEvent(QKeyEvent *event) { - QTextCursor cursor = textCursor(); - unsigned x = cursor.position() % lineWidth(); - unsigned y = cursor.position() / lineWidth(); - - int hexCode = -1; - switch(event->key()) { - case Qt::Key_0: hexCode = 0; break; - case Qt::Key_1: hexCode = 1; break; - case Qt::Key_2: hexCode = 2; break; - case Qt::Key_3: hexCode = 3; break; - case Qt::Key_4: hexCode = 4; break; - case Qt::Key_5: hexCode = 5; break; - case Qt::Key_6: hexCode = 6; break; - case Qt::Key_7: hexCode = 7; break; - case Qt::Key_8: hexCode = 8; break; - case Qt::Key_9: hexCode = 9; break; - case Qt::Key_A: hexCode = 10; break; - case Qt::Key_B: hexCode = 11; break; - case Qt::Key_C: hexCode = 12; break; - case Qt::Key_D: hexCode = 13; break; - case Qt::Key_E: hexCode = 14; break; - case Qt::Key_F: hexCode = 15; break; - } - - if(cursor.hasSelection() == false && hexCode != -1) { - bool cursorOffsetValid = (x >= 11 && ((x - 11) % 3) != 2); - if(cursorOffsetValid) { - bool nibble = (x - 11) % 3; //0 = top nibble, 1 = bottom nibble - unsigned cursorOffset = y * editorColumns + ((x - 11) / 3); - unsigned effectiveOffset = editorOffset + cursorOffset; - if(effectiveOffset >= editorSize) effectiveOffset %= editorSize; - - uint8_t data = reader ? reader(effectiveOffset) : 0x00; - data &= (nibble == 0 ? 0x0f : 0xf0); - data |= (nibble == 0 ? (hexCode << 4) : (hexCode << 0)); - if(writer) writer(effectiveOffset, data); - refresh(); - - cursor.setPosition(y * lineWidth() + x + 1); //advance cursor - setTextCursor(cursor); - } - } else { - //allow navigation keys to move cursor, but block text input - setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); - QTextEdit::keyPressEvent(event); - setTextInteractionFlags(Qt::TextEditorInteraction); - } -} - -inline void HexEditor::setColumns(unsigned columns) { - editorColumns = columns; -} - -inline void HexEditor::setRows(unsigned rows) { - editorRows = rows; - scrollBar->setPageStep(editorRows); -} - -inline void HexEditor::setOffset(unsigned offset) { - lock = true; - editorOffset = offset; - scrollBar->setSliderPosition(editorOffset / editorColumns); - lock = false; -} - -inline void HexEditor::setSize(unsigned size) { - editorSize = size; - bool indivisible = (editorSize % editorColumns) != 0; //add one for incomplete row - scrollBar->setRange(0, editorSize / editorColumns + indivisible - editorRows); -} - -inline unsigned HexEditor::lineWidth() const { - return 11 + 3 * editorColumns; -} - -inline void HexEditor::refresh() { - string output; - char temp[256]; - unsigned offset = editorOffset; - - for(unsigned y = 0; y < editorRows; y++) { - if(offset >= editorSize) break; - sprintf(temp, "%.4x:%.4x", (offset >> 16) & 0xffff, (offset >> 0) & 0xffff); - output << "" << temp << "  "; - - for(unsigned x = 0; x < editorColumns; x++) { - if(offset >= editorSize) break; - sprintf(temp, "%.2x", reader ? reader(offset) : 0x00); - offset++; - output << "" << temp << ""; - if(x != (editorColumns - 1)) output << " "; - } - - if(y != (editorRows - 1)) output << "
"; - } - - setHtml(output); -} - -inline void HexEditor::scrolled() { - if(lock) return; - unsigned offset = scrollBar->sliderPosition(); - editorOffset = offset * editorColumns; - refresh(); -} - -inline HexEditor::HexEditor() { - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - layout = new QHBoxLayout; - layout->setAlignment(Qt::AlignRight); - layout->setMargin(0); - layout->setSpacing(0); - setLayout(layout); - - scrollBar = new QScrollBar(Qt::Vertical); - scrollBar->setSingleStep(1); - layout->addWidget(scrollBar); - - lock = false; - connect(scrollBar, SIGNAL(actionTriggered(int)), this, SLOT(scrolled())); - - setColumns(16); - setRows(16); - setSize(0); - setOffset(0); -} - -} - -#endif diff --git a/bsnes/ui-qt/template/radio-action.moc.hpp b/bsnes/ui-qt/template/radio-action.moc.hpp deleted file mode 100755 index a2bbca48..00000000 --- a/bsnes/ui-qt/template/radio-action.moc.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef NALL_QT_RADIOACTION_HPP -#define NALL_QT_RADIOACTION_HPP - -namespace nall { - -class RadioAction : public QAction { - Q_OBJECT - -public: - bool isChecked() const; - void setChecked(bool); - void toggleChecked(); - RadioAction(const QString&, QObject*); - -protected slots: - -protected: - bool checked; -}; - -inline bool RadioAction::isChecked() const { - return checked; -} - -inline void RadioAction::setChecked(bool checked_) { - checked = checked_; - if(checked) setIcon(QIcon(":/16x16/item-radio-on.png")); - else setIcon(QIcon(":/16x16/item-radio-off.png")); -} - -inline void RadioAction::toggleChecked() { - setChecked(!isChecked()); -} - -inline RadioAction::RadioAction(const QString &text, QObject *parent) : QAction(text, parent) { - setChecked(false); -} - -} - -#endif diff --git a/bsnes/ui-qt/template/window.moc.hpp b/bsnes/ui-qt/template/window.moc.hpp deleted file mode 100755 index 0d3bf390..00000000 --- a/bsnes/ui-qt/template/window.moc.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef NALL_QT_WINDOW_HPP -#define NALL_QT_WINDOW_HPP - -#include -#include - -namespace nall { - -class Window : public QWidget { - Q_OBJECT - -public: - void setGeometryString(string *geometryString); - void setCloseOnEscape(bool); - void show(); - void hide(); - void shrink(); - - Window(); - -protected slots: - -protected: - string *geometryString; - bool closeOnEscape; - void keyReleaseEvent(QKeyEvent *event); - void closeEvent(QCloseEvent *event); -}; - -inline void Window::setGeometryString(string *geometryString_) { - geometryString = geometryString_; - if(geometryString && isVisible() == false) { - uint8_t *data; - unsigned length; - base64::decode(data, length, *geometryString); - QByteArray array((const char*)data, length); - delete[] data; - restoreGeometry(array); - } -} - -inline void Window::setCloseOnEscape(bool value) { - closeOnEscape = value; -} - -inline void Window::show() { - if(geometryString && isVisible() == false) { - uint8_t *data; - unsigned length; - base64::decode(data, length, *geometryString); - QByteArray array((const char*)data, length); - delete[] data; - restoreGeometry(array); - } - QWidget::show(); - QApplication::processEvents(); - activateWindow(); - raise(); -} - -inline void Window::hide() { - if(geometryString && isVisible() == true) { - char *data; - QByteArray geometry = saveGeometry(); - base64::encode(data, (const uint8_t*)geometry.data(), geometry.length()); - *geometryString = data; - delete[] data; - } - QWidget::hide(); -} - -inline void Window::shrink() { - if(isFullScreen()) return; - - for(unsigned i = 0; i < 2; i++) { - resize(0, 0); - usleep(2000); - QApplication::processEvents(); - } -} - -inline void Window::keyReleaseEvent(QKeyEvent *event) { - if(closeOnEscape && (event->key() == Qt::Key_Escape)) close(); - QWidget::keyReleaseEvent(event); -} - -inline void Window::closeEvent(QCloseEvent *event) { - if(geometryString) { - char *data; - QByteArray geometry = saveGeometry(); - base64::encode(data, (const uint8_t*)geometry.data(), geometry.length()); - *geometryString = data; - delete[] data; - } - QWidget::closeEvent(event); -} - -inline Window::Window() { - geometryString = 0; - closeOnEscape = true; -} - -} - -#endif diff --git a/bsnes/ui-qt/tools/cheateditor.cpp b/bsnes/ui-qt/tools/cheateditor.cpp deleted file mode 100755 index 93a461fc..00000000 --- a/bsnes/ui-qt/tools/cheateditor.cpp +++ /dev/null @@ -1,390 +0,0 @@ -#include "cheateditor.moc" -CheatEditorWindow *cheatEditorWindow; -CheatImportWindow *cheatImportWindow; - -CheatEditorWindow::CheatEditorWindow() { - lock = false; - document = 0; - - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - list = new QTreeWidget; - list->setColumnCount(3); - list->setHeaderLabels(QStringList() << "Slot" << "Code" << "Description"); - list->setColumnWidth(1, list->fontMetrics().width(" 89AB-CDEF+... ")); - list->setAllColumnsShowFocus(true); - list->sortByColumn(0, Qt::AscendingOrder); - list->setRootIsDecorated(false); - list->setSelectionMode(QAbstractItemView::ExtendedSelection); - list->resizeColumnToContents(0); - layout->addWidget(list); - - gridLayout = new QGridLayout; - layout->addLayout(gridLayout); - - codeLabel = new QLabel("Code(s):"); - codeLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); - gridLayout->addWidget(codeLabel, 0, 0); - - codeEdit = new QLineEdit; - gridLayout->addWidget(codeEdit, 0, 1); - - descLabel = new QLabel("Description:"); - descLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); - gridLayout->addWidget(descLabel, 1, 0); - - descEdit = new QLineEdit; - gridLayout->addWidget(descEdit, 1, 1); - - controlLayout = new QHBoxLayout; - layout->addLayout(controlLayout); - - cheatEnableBox = new QCheckBox("Enable Cheat Engine"); - cheatEnableBox->setToolTip("Unchecking this disables all cheat codes"); - cheatEnableBox->setChecked(SNES::cheat.enabled()); - controlLayout->addWidget(cheatEnableBox); - - spacer = new QWidget; - spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - controlLayout->addWidget(spacer); - - findButton = new QPushButton("Find Cheat Codes ..."); - controlLayout->addWidget(findButton); - - clearButton = new QPushButton("Clear Selected"); - controlLayout->addWidget(clearButton); - - cheatImportWindow = new CheatImportWindow; - synchronize(); - - connect(list, SIGNAL(itemSelectionChanged()), this, SLOT(listChanged())); - connect(list, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(bind())); - connect(codeEdit, SIGNAL(textEdited(const QString&)), this, SLOT(codeEdited())); - connect(descEdit, SIGNAL(textEdited(const QString&)), this, SLOT(descEdited())); - connect(cheatEnableBox, SIGNAL(stateChanged(int)), this, SLOT(toggleCheatEnable())); - connect(findButton, SIGNAL(released()), this, SLOT(findCheatCodes())); - connect(clearButton, SIGNAL(released()), this, SLOT(clearSelected())); -} - -void CheatEditorWindow::synchronize() { - auto items = list->selectedItems(); - if(items.count() == 1) { - descEdit->setEnabled(true); - codeEdit->setEnabled(true); - } else { - descEdit->setText(""); - codeEdit->setText(""); - descEdit->setEnabled(false); - codeEdit->setEnabled(false); - } - clearButton->setEnabled(items.count() > 0); - findButton->setEnabled(SNES::cartridge.loaded()); - if(SNES::cartridge.loaded() == false && cheatImportWindow->isVisible()) cheatImportWindow->close(); -} - -void CheatEditorWindow::load(const char *filename) { - lock = true; - list->clear(); - list->setSortingEnabled(false); - SNES::cheat.reset(); - - string data; - lstring line; - - if(data.readfile(filename)) { - data.replace("\r", ""); - line.split("\n", data); - } - - for(unsigned i = 0; i < 128; i++) { - lstring part; - if(line.size() > i) part.qsplit(",", line[i]); - for(unsigned n = 0; n <= 2; n++) { - part[n].trim(" "); - part[n].trim("\""); - } - part[2].replace("\\q", "\""); - - auto item = new QTreeWidgetItem(list); - item->setData(0, Qt::UserRole, QVariant(i)); - item->setText(0, decimal<3, ' '>(i + 1)); - item->setCheckState(0, part[0] == "enabled" ? Qt::Checked : Qt::Unchecked); - item->setText(1, part[1]); - item->setText(2, part[2]); - } - - list->resizeColumnToContents(0); - list->setSortingEnabled(true); - list->header()->setSortIndicatorShown(false); - - lock = false; - bind(); - update(); -} - -void CheatEditorWindow::save(const char *filename) { - bool empty = true; - string data[128]; - - auto items = list->findItems("", Qt::MatchContains); - foreach(item, items) { - unsigned index = item->data(0, Qt::UserRole).toUInt(); - string code = item->text(1).toUtf8().constData(); - string desc = item->text(2).toUtf8().constData(); - desc.replace("\"", "\\q"); - if((code != "") || (desc != "")) empty = false; - - data[index] << "\"" << (item->checkState(0) == Qt::Checked ? "enabled" : "disabled") << "\","; - data[index] << "\"" << code << "\","; - data[index] << "\"" << desc << "\"\r\n"; - } - - if(empty == true) { - unlink(filename); - } else { - file fp; - if(fp.open(filename, file::mode::write)) { - //determine how many rows from the bottom up are empty, and exclude them from the file - //eg if only the first three slots are used, don't save the last 125 empty slots - unsigned last = 127; - do { - if(data[last] != "\"disabled\",\"\",\"\"\r\n") break; - } while(--last); - - for(unsigned i = 0; i <= last; i++) fp.print(data[i]); - fp.close(); - } - } - - list->clear(); - SNES::cheat.reset(); - SNES::cheat.synchronize(); -} - -void CheatEditorWindow::update() { - auto items = list->findItems("", Qt::MatchContains); - foreach(item, items) { - string code = item->text(1).toUtf8().constData(); - string desc = item->text(2).toUtf8().constData(); - if((code != "") || (desc != "")) { - item->setForeground(0, QBrush(QColor(0, 0, 0))); - } else { - //highlight empty slots in gray - item->setForeground(0, QBrush(QColor(128, 128, 128))); - } - unsigned index = item->data(0, Qt::UserRole).toUInt(); - if(SNES::cheat[index].addr.size() > 0) { - item->setForeground(1, QBrush(QColor(0, 0, 0))); - } else { - //highlight invalid codes in red - //(this will also highlight empty codes, but as there is no text, it's not an issue) - item->setForeground(1, QBrush(QColor(255, 0, 0))); - } - } -} - -void CheatEditorWindow::bind() { - if(lock) return; - - auto items = list->findItems("", Qt::MatchContains); - foreach(item, items) { - unsigned index = item->data(0, Qt::UserRole).toUInt(); - SNES::cheat[index] = item->text(1).toUtf8().constData(); - SNES::cheat[index].enabled = item->checkState(0) == Qt::Checked; - } - SNES::cheat.synchronize(); -} - -void CheatEditorWindow::listChanged() { - if(lock) return; - - auto items = list->selectedItems(); - if(items.count() > 0) { - auto item = items[0]; - codeEdit->setText(item->text(1)); - descEdit->setText(item->text(2)); - } - synchronize(); -} - -void CheatEditorWindow::codeEdited() { - if(lock) return; - - auto items = list->selectedItems(); - if(items.count() == 1) { - auto item = items[0]; - item->setText(1, codeEdit->text()); - } - bind(); - update(); -} - -void CheatEditorWindow::descEdited() { - if(lock) return; - - auto items = list->selectedItems(); - if(items.count() == 1) { - auto item = items[0]; - item->setText(2, descEdit->text()); - } - update(); -} - -void CheatEditorWindow::toggleCheatEnable() { - SNES::cheat.enable(cheatEnableBox->isChecked()); -} - -void CheatEditorWindow::findCheatCodes() { - string data; - QFile file(":/cheats.xml"); - if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { - data = file.readAll().constData(); - file.close(); - } - - if(auto position = strpos(data, SNES::cartridge.sha256())) { - const char *block = (const char*)data + position() - 19; - if(position = strpos(block, "")) { - xml_element document = xml_parse(substr(block, 0, position() + 12)); - if(document.element.size() == 0) return; - - cheatImportWindow->refresh(document.element[0]); - cheatImportWindow->show(); - return; - } - } - - audio.clear(); - QMessageBox::information(toolsWindow, "Cheat Code Importer", - "Sorry, no cheat codes were found for the currently loaded cartridge." - ); -} - -void CheatEditorWindow::clearSelected() { - if(lock) return; - - auto items = list->selectedItems(); - foreach(item, items) { - item->setCheckState(0, Qt::Unchecked); - item->setText(1, ""); - item->setText(2, ""); - } - codeEdit->setText(""); - descEdit->setText(""); - bind(); - update(); -} - -//================= -//CheatImportWindow -//================= - -void CheatImportWindow::refresh(xml_element &root) { - list->clear(); - - foreach(node, root.element) { - if(node.name == "name") { - title->setText(string() << "Name: " << node.parse()); - } else if(node.name == "cheat") { - string description = ""; - string code = ""; - - foreach(leaf, node.element) { - if(leaf.name == "description") { - description = leaf.parse(); - } else if(leaf.name == "code") { - if(code != "") code << "+"; - code << leaf.content; - } - } - - auto item = new QTreeWidgetItem(list); - item->setCheckState(0, Qt::Unchecked); - item->setText(0, string() << description); - QString qcode = code; - item->setData(0, Qt::UserRole, QVariant(qcode)); - } - } -} - -CheatImportWindow::CheatImportWindow() { - resize(640, 360); - - setObjectName("cheat-import-window"); - setWindowTitle("Cheat Code Importer"); - setGeometryString(&config().geometry.cheatImportWindow); - application.windowList.append(this); - - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - title = new QLabel("Test"); - layout->addWidget(title); - - list = new QTreeWidget; - list->setColumnCount(1); - list->setAllColumnsShowFocus(true); - list->setRootIsDecorated(false); - list->setHeaderHidden(true); - layout->addWidget(list); - - controlLayout = new QHBoxLayout; - layout->addLayout(controlLayout); - - selectAllButton = new QPushButton("Select All"); - controlLayout->addWidget(selectAllButton); - - clearAllButton = new QPushButton("Clear All"); - controlLayout->addWidget(clearAllButton); - - spacer = new QWidget; - spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - controlLayout->addWidget(spacer); - - okButton = new QPushButton("Ok"); - controlLayout->addWidget(okButton); - - cancelButton = new QPushButton("Cancel"); - controlLayout->addWidget(cancelButton); - - connect(selectAllButton, SIGNAL(released()), this, SLOT(selectAllCodes())); - connect(clearAllButton, SIGNAL(released()), this, SLOT(clearAllCodes())); - connect(okButton, SIGNAL(released()), this, SLOT(addSelectedCodes())); - connect(cancelButton, SIGNAL(released()), this, SLOT(close())); -} - -void CheatImportWindow::selectAllCodes() { - auto items = list->findItems("", Qt::MatchContains); - foreach(item, items) item->setCheckState(0, Qt::Checked); -} - -void CheatImportWindow::clearAllCodes() { - auto items = list->findItems("", Qt::MatchContains); - foreach(item, items) item->setCheckState(0, Qt::Unchecked); -} - -void CheatImportWindow::addSelectedCodes() { - auto items = list->findItems("", Qt::MatchContains); - foreach(item, items) { - if(item->checkState(0) == Qt::Checked) { - auto codeslots = cheatEditorWindow->list->findItems("", Qt::MatchContains); - foreach(codeslot, codeslots) { - if(codeslot->text(1) == "" && codeslot->text(2) == "") { - codeslot->setCheckState(0, Qt::Unchecked); - codeslot->setText(1, item->data(0, Qt::UserRole).toString()); - codeslot->setText(2, item->text(0)); - break; - } - } - } - } - - cheatEditorWindow->bind(); - cheatEditorWindow->update(); - close(); -} diff --git a/bsnes/ui-qt/tools/cheateditor.moc.hpp b/bsnes/ui-qt/tools/cheateditor.moc.hpp deleted file mode 100755 index 6b8b9a3f..00000000 --- a/bsnes/ui-qt/tools/cheateditor.moc.hpp +++ /dev/null @@ -1,65 +0,0 @@ -class CheatEditorWindow : public QWidget { - Q_OBJECT - -public: - QVBoxLayout *layout; - QTreeWidget *list; - QGridLayout *gridLayout; - QLabel *codeLabel; - QLineEdit *codeEdit; - QLabel *descLabel; - QLineEdit *descEdit; - QHBoxLayout *controlLayout; - QCheckBox *cheatEnableBox; - QWidget *spacer; - QPushButton *findButton; - QPushButton *clearButton; - - void load(const char *filename); - void save(const char *filename); - void update(); - - void synchronize(); - CheatEditorWindow(); - -private slots: - void bind(); - void listChanged(); - void codeEdited(); - void descEdited(); - void toggleCheatEnable(); - void findCheatCodes(); - void clearSelected(); - -private: - bool lock; - xml_element *document; - friend class CheatImportWindow; -}; - -class CheatImportWindow : public Window { - Q_OBJECT - -public: - QVBoxLayout *layout; - QLabel *title; - QTreeWidget *list; - QHBoxLayout *controlLayout; - QPushButton *selectAllButton; - QPushButton *clearAllButton; - QWidget *spacer; - QPushButton *okButton; - QPushButton *cancelButton; - - void refresh(xml_element&); - - CheatImportWindow(); - -private slots: - void selectAllCodes(); - void clearAllCodes(); - void addSelectedCodes(); -}; - -extern CheatEditorWindow *cheatEditorWindow; -extern CheatImportWindow *cheatImportWindow; diff --git a/bsnes/ui-qt/tools/cheatfinder.cpp b/bsnes/ui-qt/tools/cheatfinder.cpp deleted file mode 100755 index a259a4bd..00000000 --- a/bsnes/ui-qt/tools/cheatfinder.cpp +++ /dev/null @@ -1,200 +0,0 @@ -#include "cheatfinder.moc" -CheatFinderWindow *cheatFinderWindow; - -CheatFinderWindow::CheatFinderWindow() { - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - list = new QTreeWidget; - list->setColumnCount(3); - list->setHeaderLabels(QStringList() << "Address" << "Current Value" << "Previous Value"); - list->setAllColumnsShowFocus(true); - list->sortByColumn(0, Qt::AscendingOrder); - list->setRootIsDecorated(false); - layout->addWidget(list); - - controlLayout = new QGridLayout; - controlLayout->setVerticalSpacing(0); - layout->addLayout(controlLayout); - - sizeLabel = new QLabel("Data size:"); - controlLayout->addWidget(sizeLabel, 0, 0); - - sizeGroup = new QButtonGroup(this); - - size8bit = new QRadioButton("8-bit"); - size8bit->setChecked(true); - sizeGroup->addButton(size8bit); - controlLayout->addWidget(size8bit, 0, 1); - - size16bit = new QRadioButton("16-bit"); - sizeGroup->addButton(size16bit); - controlLayout->addWidget(size16bit, 0, 2); - - size24bit = new QRadioButton("24-bit"); - sizeGroup->addButton(size24bit); - controlLayout->addWidget(size24bit, 0, 3); - - size32bit = new QRadioButton("32-bit"); - sizeGroup->addButton(size32bit); - controlLayout->addWidget(size32bit, 0, 4); - - compareLabel = new QLabel("Compare mode:"); - controlLayout->addWidget(compareLabel, 1, 0); - - compareGroup = new QButtonGroup(this); - - compareEqual = new QRadioButton("Equal to"); - compareEqual->setChecked(true); - compareGroup->addButton(compareEqual); - controlLayout->addWidget(compareEqual, 1, 1); - - compareNotEqual = new QRadioButton("Not equal to"); - compareGroup->addButton(compareNotEqual); - controlLayout->addWidget(compareNotEqual, 1, 2); - - compareLessThan = new QRadioButton("Less than"); - compareGroup->addButton(compareLessThan); - controlLayout->addWidget(compareLessThan, 1, 3); - - compareGreaterThan = new QRadioButton("Greater than"); - compareGroup->addButton(compareGreaterThan); - controlLayout->addWidget(compareGreaterThan, 1, 4); - - valueLabel = new QLabel("Search value:"); - controlLayout->addWidget(valueLabel, 2, 0); - - actionLayout = new QHBoxLayout; - actionLayout->setSpacing(Style::WidgetSpacing); - controlLayout->addLayout(actionLayout, 2, 1, 1, 4); - - valueEdit = new QLineEdit; - actionLayout->addWidget(valueEdit); - - searchButton = new QPushButton("Search"); - actionLayout->addWidget(searchButton); - - resetButton = new QPushButton("Reset"); - actionLayout->addWidget(resetButton); - - connect(valueEdit, SIGNAL(returnPressed()), this, SLOT(searchMemory())); - connect(searchButton, SIGNAL(released()), this, SLOT(searchMemory())); - connect(resetButton, SIGNAL(released()), this, SLOT(resetSearch())); - synchronize(); -} - -void CheatFinderWindow::synchronize() { - if(SNES::cartridge.loaded() == false || application.power == false) { - list->clear(); - for(unsigned n = 0; n < 3; n++) list->resizeColumnToContents(n); - valueEdit->setEnabled(false); - valueEdit->setText(""); - searchButton->setEnabled(false); - resetButton->setEnabled(false); - } else { - valueEdit->setEnabled(true); - searchButton->setEnabled(true); - resetButton->setEnabled(true); - } -} - -void CheatFinderWindow::refreshList() { - list->clear(); - list->setSortingEnabled(false); - - unsigned size = 0; - if(size16bit->isChecked()) size = 1; - if(size24bit->isChecked()) size = 2; - if(size32bit->isChecked()) size = 3; - - for(unsigned i = 0; i < addrList.size() && i < 256; i++) { - QTreeWidgetItem *item = new QTreeWidgetItem(list); - - unsigned addr = addrList[i]; - unsigned data = read(addr, size); - unsigned prev = dataList[i]; - - char temp[256]; - - sprintf(temp, "%.6x", 0x7e0000 + addr); - item->setText(0, temp); - - sprintf(temp, "%u (0x%x)", data, data); - item->setText(1, temp); - - sprintf(temp, "%u (0x%x)", prev, prev); - item->setText(2, temp); - } - - list->setSortingEnabled(true); - list->header()->setSortIndicatorShown(false); - for(unsigned n = 0; n < 3; n++) list->resizeColumnToContents(n); -} - -void CheatFinderWindow::searchMemory() { - unsigned size = 0; - if(size16bit->isChecked()) size = 1; - if(size24bit->isChecked()) size = 2; - if(size32bit->isChecked()) size = 3; - - unsigned data; - string text = valueEdit->text().toUtf8().constData(); - - //auto-detect input data type - if(strbegin(text, "0x")) data = hex((const char*)text + 2); - else if(strbegin(text, "-")) data = integer(text); - else data = decimal(text); - - if(addrList.size() == 0) { - //search for the first time: enqueue all possible values so they are all searched - for(unsigned addr = 0; addr < SNES::memory::wram.size(); addr++) { - addrList.append(addr); - dataList.append(read(addr, size)); - } - } - - array newAddrList, newDataList, oldDataList; - - for(unsigned i = 0; i < addrList.size(); i++) { - unsigned thisAddr = addrList[i]; - unsigned thisData = read(thisAddr, size); - - if((compareEqual->isChecked() && thisData == data) - || (compareNotEqual->isChecked() && thisData != data) - || (compareLessThan->isChecked() && thisData < data) - || (compareGreaterThan->isChecked() && thisData > data) - ) { - newAddrList.append(thisAddr); - newDataList.append(thisData); - oldDataList.append(dataList[i]); - } - } - - //first refresh the list with the old data values (for the previous value column) - addrList = newAddrList; - dataList = oldDataList; - refreshList(); - - //and now update the list with the new data values (for the next search) - dataList = newDataList; -} - -void CheatFinderWindow::resetSearch() { - addrList.reset(); - dataList.reset(); - refreshList(); -} - -//size = 0 (8-bit), 1 (16-bit), 2 (24-bit), 3 (32-bit) -unsigned CheatFinderWindow::read(unsigned addr, unsigned size) { - unsigned data = 0; - - for(unsigned n = 0; n <= size; n++) { - if(addr + n >= SNES::memory::wram.size()) break; - data |= SNES::memory::wram[addr + n] << (n << 3); - } - - return data; -} diff --git a/bsnes/ui-qt/tools/cheatfinder.moc.hpp b/bsnes/ui-qt/tools/cheatfinder.moc.hpp deleted file mode 100755 index 69222cec..00000000 --- a/bsnes/ui-qt/tools/cheatfinder.moc.hpp +++ /dev/null @@ -1,41 +0,0 @@ -class CheatFinderWindow : public QWidget { - Q_OBJECT - -public: - QVBoxLayout *layout; - QTreeWidget *list; - QGridLayout *controlLayout; - QLabel *sizeLabel; - QButtonGroup *sizeGroup; - QRadioButton *size8bit; - QRadioButton *size16bit; - QRadioButton *size24bit; - QRadioButton *size32bit; - QLabel *compareLabel; - QButtonGroup *compareGroup; - QRadioButton *compareEqual; - QRadioButton *compareNotEqual; - QRadioButton *compareLessThan; - QRadioButton *compareGreaterThan; - QLabel *valueLabel; - QHBoxLayout *actionLayout; - QLineEdit *valueEdit; - QPushButton *searchButton; - QPushButton *resetButton; - - void synchronize(); - void refreshList(); - CheatFinderWindow(); - -public slots: - void searchMemory(); - void resetSearch(); - -private: - array addrList; - array dataList; - - unsigned read(unsigned addr, unsigned size); -}; - -extern CheatFinderWindow *cheatFinderWindow; diff --git a/bsnes/ui-qt/tools/effecttoggle.cpp b/bsnes/ui-qt/tools/effecttoggle.cpp deleted file mode 100755 index a2a6f062..00000000 --- a/bsnes/ui-qt/tools/effecttoggle.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "effecttoggle.moc" -EffectToggleWindow *effectToggleWindow; - -EffectToggleWindow::EffectToggleWindow() { - layout = new QGridLayout; - layout->setAlignment(Qt::AlignTop | Qt::AlignLeft); - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - ppuLabel = new QLabel("S-PPU (Video)"); - layout->addWidget(ppuLabel, 0, 0); - - bg1pri0 = new QCheckBox("BG1 Priority 0"); - bg1pri0->setChecked(true); - layout->addWidget(bg1pri0, 1, 0, 1, 4); - - bg1pri1 = new QCheckBox("BG1 Priority 1"); - bg1pri1->setChecked(true); - layout->addWidget(bg1pri1, 1, 1); - - bg2pri0 = new QCheckBox("BG2 Priority 0"); - bg2pri0->setChecked(true); - layout->addWidget(bg2pri0, 2, 0); - - bg2pri1 = new QCheckBox("BG2 Priority 1"); - bg2pri1->setChecked(true); - layout->addWidget(bg2pri1, 2, 1); - - bg3pri0 = new QCheckBox("BG3 Priority 0"); - bg3pri0->setChecked(true); - layout->addWidget(bg3pri0, 3, 0); - - bg3pri1 = new QCheckBox("BG3 Priority 1"); - bg3pri1->setChecked(true); - layout->addWidget(bg3pri1, 3, 1); - - bg4pri0 = new QCheckBox("BG4 Priority 0"); - bg4pri0->setChecked(true); - layout->addWidget(bg4pri0, 4, 0); - - bg4pri1 = new QCheckBox("BG4 Priority 1"); - bg4pri1->setChecked(true); - layout->addWidget(bg4pri1, 4, 1); - - oampri0 = new QCheckBox("OAM Priority 0"); - oampri0->setChecked(true); - layout->addWidget(oampri0, 5, 0); - - oampri1 = new QCheckBox("OAM Priority 1"); - oampri1->setChecked(true); - layout->addWidget(oampri1, 5, 1); - - oampri2 = new QCheckBox("OAM Priority 2"); - oampri2->setChecked(true); - layout->addWidget(oampri2, 5, 2); - - oampri3 = new QCheckBox("OAM Priority 3"); - oampri3->setChecked(true); - layout->addWidget(oampri3, 5, 3); - - dspLabel = new QLabel("S-DSP (Audio)"); - layout->addWidget(dspLabel, 6, 0, 1, 4); - - channel0 = new QCheckBox("Channel 0"); - channel0->setChecked(true); - layout->addWidget(channel0, 7, 0); - - channel1 = new QCheckBox("Channel 1"); - channel1->setChecked(true); - layout->addWidget(channel1, 7, 1); - - channel2 = new QCheckBox("Channel 2"); - channel2->setChecked(true); - layout->addWidget(channel2, 7, 2); - - channel3 = new QCheckBox("Channel 3"); - channel3->setChecked(true); - layout->addWidget(channel3, 7, 3); - - channel4 = new QCheckBox("Channel 4"); - channel4->setChecked(true); - layout->addWidget(channel4, 8, 0); - - channel5 = new QCheckBox("Channel 5"); - channel5->setChecked(true); - layout->addWidget(channel5, 8, 1); - - channel6 = new QCheckBox("Channel 6"); - channel6->setChecked(true); - layout->addWidget(channel6, 8, 2); - - channel7 = new QCheckBox("Channel 7"); - channel7->setChecked(true); - layout->addWidget(channel7, 8, 3); - - connect(bg1pri0, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(bg1pri1, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(bg2pri0, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(bg2pri1, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(bg3pri0, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(bg3pri1, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(bg4pri0, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(bg4pri1, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(oampri0, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(oampri1, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(oampri2, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(oampri3, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(channel0, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(channel1, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(channel2, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(channel3, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(channel4, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(channel5, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(channel6, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); - connect(channel7, SIGNAL(stateChanged(int)), this, SLOT(synchronize())); -} - -void EffectToggleWindow::synchronize() { - #if defined(PROFILE_COMPATIBILITY) || defined(PROFILE_PERFORMANCE) - SNES::ppu.layer_enable(0, 0, bg1pri0->isChecked()); - SNES::ppu.layer_enable(0, 1, bg1pri1->isChecked()); - SNES::ppu.layer_enable(1, 0, bg2pri0->isChecked()); - SNES::ppu.layer_enable(1, 1, bg2pri1->isChecked()); - SNES::ppu.layer_enable(2, 0, bg3pri0->isChecked()); - SNES::ppu.layer_enable(2, 1, bg3pri1->isChecked()); - SNES::ppu.layer_enable(3, 0, bg4pri0->isChecked()); - SNES::ppu.layer_enable(3, 1, bg4pri1->isChecked()); - SNES::ppu.layer_enable(4, 0, oampri0->isChecked()); - SNES::ppu.layer_enable(4, 1, oampri1->isChecked()); - SNES::ppu.layer_enable(4, 2, oampri2->isChecked()); - SNES::ppu.layer_enable(4, 3, oampri3->isChecked()); - - SNES::dsp.channel_enable(0, channel0->isChecked()); - SNES::dsp.channel_enable(1, channel1->isChecked()); - SNES::dsp.channel_enable(2, channel2->isChecked()); - SNES::dsp.channel_enable(3, channel3->isChecked()); - SNES::dsp.channel_enable(4, channel4->isChecked()); - SNES::dsp.channel_enable(5, channel5->isChecked()); - SNES::dsp.channel_enable(6, channel6->isChecked()); - SNES::dsp.channel_enable(7, channel7->isChecked()); - #endif -} diff --git a/bsnes/ui-qt/tools/effecttoggle.moc.hpp b/bsnes/ui-qt/tools/effecttoggle.moc.hpp deleted file mode 100755 index 5cb8317a..00000000 --- a/bsnes/ui-qt/tools/effecttoggle.moc.hpp +++ /dev/null @@ -1,35 +0,0 @@ -class EffectToggleWindow : public QWidget { - Q_OBJECT - -public: - QGridLayout *layout; - QLabel *ppuLabel; - QCheckBox *bg1pri0; - QCheckBox *bg1pri1; - QCheckBox *bg2pri0; - QCheckBox *bg2pri1; - QCheckBox *bg3pri0; - QCheckBox *bg3pri1; - QCheckBox *bg4pri0; - QCheckBox *bg4pri1; - QCheckBox *oampri0; - QCheckBox *oampri1; - QCheckBox *oampri2; - QCheckBox *oampri3; - QLabel *dspLabel; - QCheckBox *channel0; - QCheckBox *channel1; - QCheckBox *channel2; - QCheckBox *channel3; - QCheckBox *channel4; - QCheckBox *channel5; - QCheckBox *channel6; - QCheckBox *channel7; - - EffectToggleWindow(); - -public slots: - void synchronize(); -}; - -extern EffectToggleWindow *effectToggleWindow; diff --git a/bsnes/ui-qt/tools/statemanager.cpp b/bsnes/ui-qt/tools/statemanager.cpp deleted file mode 100755 index 1c2845a9..00000000 --- a/bsnes/ui-qt/tools/statemanager.cpp +++ /dev/null @@ -1,284 +0,0 @@ -#include "statemanager.moc" -StateManagerWindow *stateManagerWindow; - -StateManagerWindow::StateManagerWindow() { - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - list = new QTreeWidget; - list->setColumnCount(2); - list->setHeaderLabels(QStringList() << "Slot" << "Description"); - list->setAllColumnsShowFocus(true); - list->sortByColumn(0, Qt::AscendingOrder); - list->setRootIsDecorated(false); - list->resizeColumnToContents(0); - layout->addWidget(list); - - infoLayout = new QHBoxLayout; - layout->addLayout(infoLayout); - - descriptionLabel = new QLabel("Description:"); - infoLayout->addWidget(descriptionLabel); - - descriptionText = new QLineEdit; - infoLayout->addWidget(descriptionText); - - controlLayout = new QHBoxLayout; - layout->addLayout(controlLayout); - - spacer = new QWidget; - spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - controlLayout->addWidget(spacer); - - loadButton = new QPushButton("Load"); - controlLayout->addWidget(loadButton); - - saveButton = new QPushButton("Save"); - controlLayout->addWidget(saveButton); - - eraseButton = new QPushButton("Erase"); - controlLayout->addWidget(eraseButton); - - connect(list, SIGNAL(itemSelectionChanged()), this, SLOT(synchronize())); - connect(list, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(loadAction())); - connect(descriptionText, SIGNAL(textEdited(const QString&)), this, SLOT(writeDescription())); - connect(loadButton, SIGNAL(released()), this, SLOT(loadAction())); - connect(saveButton, SIGNAL(released()), this, SLOT(saveAction())); - connect(eraseButton, SIGNAL(released()), this, SLOT(eraseAction())); - - synchronize(); -} - -void StateManagerWindow::reload() { - list->clear(); - list->setSortingEnabled(false); - - if(SNES::cartridge.loaded() && cartridge.saveStatesSupported()) { - for(unsigned n = 0; n < StateCount; n++) { - QTreeWidgetItem *item = new QTreeWidgetItem(list); - item->setData(0, Qt::UserRole, QVariant(n)); - char slot[16]; - sprintf(slot, "%2u", n + 1); - item->setText(0, slot); - } - update(); - } - - list->setSortingEnabled(true); - list->header()->setSortIndicatorShown(false); - synchronize(); -} - -void StateManagerWindow::update() { - //iterate all list items - QList items = list->findItems("", Qt::MatchContains); - for(unsigned i = 0; i < items.count(); i++) { - QTreeWidgetItem *item = items[i]; - unsigned n = item->data(0, Qt::UserRole).toUInt(); - if(isStateValid(n) == false) { - item->setForeground(0, QBrush(QColor(128, 128, 128))); - item->setForeground(1, QBrush(QColor(128, 128, 128))); - item->setText(1, "Empty"); - } else { - item->setForeground(0, QBrush(QColor(0, 0, 0))); - item->setForeground(1, QBrush(QColor(0, 0, 0))); - item->setText(1, getStateDescription(n)); - } - } - - for(unsigned n = 0; n <= 1; n++) list->resizeColumnToContents(n); -} - -void StateManagerWindow::synchronize() { - QList items = list->selectedItems(); - if(items.count() > 0) { - QTreeWidgetItem *item = items[0]; - unsigned n = item->data(0, Qt::UserRole).toUInt(); - - if(isStateValid(n)) { - descriptionText->setText(getStateDescription(n)); - descriptionText->setEnabled(true); - loadButton->setEnabled(true); - eraseButton->setEnabled(true); - } else { - descriptionText->setText(""); - descriptionText->setEnabled(false); - loadButton->setEnabled(false); - eraseButton->setEnabled(false); - } - saveButton->setEnabled(true); - } else { - descriptionText->setText(""); - descriptionText->setEnabled(false); - loadButton->setEnabled(false); - saveButton->setEnabled(false); - eraseButton->setEnabled(false); - } -} - -void StateManagerWindow::writeDescription() { - QList items = list->selectedItems(); - if(items.count() > 0) { - QTreeWidgetItem *item = items[0]; - unsigned n = item->data(0, Qt::UserRole).toUInt(); - string description = descriptionText->text().toUtf8().constData(); - setStateDescription(n, description); - update(); - } -} - -void StateManagerWindow::loadAction() { - QList items = list->selectedItems(); - if(items.count() > 0) { - QTreeWidgetItem *item = items[0]; - unsigned n = item->data(0, Qt::UserRole).toUInt(); - loadState(n); - } -} - -void StateManagerWindow::saveAction() { - QList items = list->selectedItems(); - if(items.count() > 0) { - QTreeWidgetItem *item = items[0]; - unsigned n = item->data(0, Qt::UserRole).toUInt(); - saveState(n); - writeDescription(); - synchronize(); - descriptionText->setFocus(); - } -} - -void StateManagerWindow::eraseAction() { - QList items = list->selectedItems(); - if(items.count() > 0) { - QTreeWidgetItem *item = items[0]; - unsigned n = item->data(0, Qt::UserRole).toUInt(); - eraseState(n); - update(); - synchronize(); - } -} - -string StateManagerWindow::filename() const { - string name = filepath(nall::basename(cartridge.fileName), config().path.state); - name << ".bsa"; - return name; -} - -bool StateManagerWindow::isStateValid(unsigned slot) { - if(SNES::cartridge.loaded() == false) return false; - file fp; - if(fp.open(filename(), file::mode::read) == false) return false; - if(fp.size() < (slot + 1) * SNES::system.serialize_size()) { fp.close(); return false; } - fp.seek(slot * SNES::system.serialize_size()); - uint32_t signature = fp.readl(4); - if(signature == 0) { fp.close(); return false; } - uint32_t version = fp.readl(4); - if(version != SNES::Info::SerializerVersion) { fp.close(); return false; } - fp.readl(4); //skip CRC32 - char profile[16]; - fp.read((uint8_t*)profile, 16); - if(strcmp(profile, SNES::Info::Profile)) { fp.close(); return false; } - fp.close(); - return true; -} - -string StateManagerWindow::getStateDescription(unsigned slot) { - if(isStateValid(slot) == false) return ""; - file fp; - fp.open(filename(), file::mode::read); - char description[512]; - fp.seek(slot * SNES::system.serialize_size() + 28); - fp.read((uint8_t*)description, 512); - fp.close(); - description[511] = 0; - return description; -} - -void StateManagerWindow::setStateDescription(unsigned slot, const string &text) { - if(isStateValid(slot) == false) return; - file fp; - fp.open(filename(), file::mode::readwrite); - char description[512]; - memset(&description, 0, sizeof description); - strncpy(description, text, 512); - fp.seek(slot * SNES::system.serialize_size() + 28); - fp.write((uint8_t*)description, 512); - fp.close(); -} - -void StateManagerWindow::loadState(unsigned slot) { - if(isStateValid(slot) == false) return; - file fp; - fp.open(filename(), file::mode::read); - fp.seek(slot * SNES::system.serialize_size()); - unsigned size = SNES::system.serialize_size(); - uint8_t *data = new uint8_t[size]; - fp.read(data, size); - fp.close(); - - serializer state(data, size); - delete[] data; - - if(SNES::system.unserialize(state) == true) { - //toolsWindow->close(); - } -} - -void StateManagerWindow::saveState(unsigned slot) { - file fp; - if(file::exists(filename()) == false) { - //try and create the file, bail out on failure (eg read-only device) - if(fp.open(filename(), file::mode::write) == false) return; - fp.close(); - } - - SNES::system.runtosave(); - serializer state = SNES::system.serialize(); - - fp.open(filename(), file::mode::readwrite); - - //user may save to slot #2 when slot #1 is empty; pad file to current slot if needed - unsigned stateOffset = SNES::system.serialize_size() * slot; - fp.seek(fp.size()); - while(fp.size() < stateOffset) fp.write(0x00); - - fp.seek(stateOffset); - fp.write(state.data(), state.size()); - fp.close(); -} - -void StateManagerWindow::eraseState(unsigned slot) { - if(isStateValid(slot) == false) return; - file fp; - fp.open(filename(), file::mode::readwrite); - unsigned size = SNES::system.serialize_size(); - fp.seek(slot * size); - for(unsigned i = 0; i < size; i++) fp.write(0x00); - fp.close(); - - //shrink state archive as much as possible: - //eg if only slot #2 and slot #31 were valid, but slot #31 was erased, - //file can be resized to only hold blank slot #1 + valid slot #2 - signed lastValidState = -1; - for(signed i = StateCount - 1; i >= 0; i--) { - if(isStateValid(i)) { - lastValidState = i; - break; - } - } - - if(lastValidState == -1) { - //no states used, remove empty file - unlink(filename()); - } else { - unsigned neededFileSize = (lastValidState + 1) * SNES::system.serialize_size(); - file fp; - if(fp.open(filename(), file::mode::readwrite)) { - if(fp.size() > neededFileSize) fp.truncate(neededFileSize); - fp.close(); - } - } -} diff --git a/bsnes/ui-qt/tools/statemanager.moc.hpp b/bsnes/ui-qt/tools/statemanager.moc.hpp deleted file mode 100755 index be02653e..00000000 --- a/bsnes/ui-qt/tools/statemanager.moc.hpp +++ /dev/null @@ -1,40 +0,0 @@ -class StateManagerWindow : public QWidget { - Q_OBJECT - -public: - enum { StateCount = 32 }; - - QVBoxLayout *layout; - QTreeWidget *list; - QHBoxLayout *infoLayout; - QLabel *descriptionLabel; - QLineEdit *descriptionText; - QHBoxLayout *controlLayout; - QWidget *spacer; - QPushButton *loadButton; - QPushButton *saveButton; - QPushButton *eraseButton; - - void reload(); - void update(); - - StateManagerWindow(); - -public slots: - void synchronize(); - void writeDescription(); - void loadAction(); - void saveAction(); - void eraseAction(); - -private: - string filename() const; - bool isStateValid(unsigned slot); - string getStateDescription(unsigned slot); - void setStateDescription(unsigned slot, const string&); - void loadState(unsigned slot); - void saveState(unsigned slot); - void eraseState(unsigned slot); -}; - -extern StateManagerWindow *stateManagerWindow; diff --git a/bsnes/ui-qt/tools/tools.cpp b/bsnes/ui-qt/tools/tools.cpp deleted file mode 100755 index 61564c08..00000000 --- a/bsnes/ui-qt/tools/tools.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "../ui-base.hpp" - -#include "tools.moc" -ToolsWindow *toolsWindow; - -#include "cheateditor.cpp" -#include "cheatfinder.cpp" -#include "statemanager.cpp" -#include "effecttoggle.cpp" - -ToolsWindow::ToolsWindow() { - setObjectName("tools-window"); - setWindowTitle("Tools"); - resize(600, 360); - setGeometryString(&config().geometry.toolsWindow); - application.windowList.append(this); - - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(Style::WidgetSpacing); - setLayout(layout); - - cheatEditorWindow = new CheatEditorWindow; - cheatFinderWindow = new CheatFinderWindow; - stateManagerWindow = new StateManagerWindow; - effectToggleWindow = new EffectToggleWindow; - - cheatEditorArea = new QScrollArea; - cheatEditorArea->setWidget(cheatEditorWindow); - cheatEditorArea->setFrameStyle(0); - cheatEditorArea->setWidgetResizable(true); - - cheatFinderArea = new QScrollArea; - cheatFinderArea->setWidget(cheatFinderWindow); - cheatFinderArea->setFrameStyle(0); - cheatFinderArea->setWidgetResizable(true); - - stateManagerArea = new QScrollArea; - stateManagerArea->setWidget(stateManagerWindow); - stateManagerArea->setFrameStyle(0); - stateManagerArea->setWidgetResizable(true); - - effectToggleArea = new QScrollArea; - effectToggleArea->setWidget(effectToggleWindow); - effectToggleArea->setFrameStyle(0); - effectToggleArea->setWidgetResizable(true); - - tab = new QTabWidget; - tab->addTab(cheatEditorArea, "Cheat Editor"); - tab->addTab(cheatFinderArea, "Cheat Finder"); - tab->addTab(stateManagerArea, "State Manager"); - #if defined(PROFILE_COMPATIBILITY) || defined(PROFILE_PERFORMANCE) - tab->addTab(effectToggleArea, "Effect Toggle"); - #endif - layout->addWidget(tab); -} diff --git a/bsnes/ui-qt/tools/tools.moc.hpp b/bsnes/ui-qt/tools/tools.moc.hpp deleted file mode 100755 index 593adc45..00000000 --- a/bsnes/ui-qt/tools/tools.moc.hpp +++ /dev/null @@ -1,17 +0,0 @@ -class ToolsWindow : public Window { - Q_OBJECT - -public: - QVBoxLayout *layout; - QTabWidget *tab; - QScrollArea *cheatEditorArea; - QScrollArea *cheatFinderArea; - QScrollArea *stateManagerArea; - QScrollArea *effectToggleArea; - - ToolsWindow(); - -public slots: -}; - -extern ToolsWindow *toolsWindow; diff --git a/bsnes/ui-qt/ui-base.hpp b/bsnes/ui-qt/ui-base.hpp deleted file mode 100755 index b8d0fc37..00000000 --- a/bsnes/ui-qt/ui-base.hpp +++ /dev/null @@ -1,93 +0,0 @@ -#define UNICODE -#define QT_NO_DEBUG -#define QT_THREAD_SUPPORT - -#include -#include -//Q_IMPORT_PLUGIN(QJpegPlugin) -//Q_IMPORT_PLUGIN(QMngPlugin) - -#include - -#include -#include -#include -#include -#include -#include "template/concept.hpp" -#include "template/check-action.moc.hpp" -#include "template/file-dialog.moc.hpp" -#include "template/hex-editor.moc.hpp" -#include "template/radio-action.moc.hpp" -#include "template/window.moc.hpp" -using namespace nall; - -#include -using namespace ruby; - -#include "config.hpp" -#include "interface.hpp" - -#include "application/application.moc.hpp" - -#include "base/about.moc.hpp" -#include "base/filebrowser.moc.hpp" -#include "base/htmlviewer.moc.hpp" -#include "base/loader.moc.hpp" -#include "base/main.moc.hpp" -#include "base/stateselect.moc.hpp" - -#include "cartridge/cartridge.hpp" - -#if defined(DEBUGGER) - #include "debugger/debugger.moc.hpp" - #include "debugger/tracer.moc.hpp" - - #include "debugger/tools/disassembler.moc.hpp" - #include "debugger/tools/breakpoint.moc.hpp" - #include "debugger/tools/memory.moc.hpp" - #include "debugger/tools/properties.moc.hpp" - - #include "debugger/ppu/vram-viewer.moc.hpp" - #include "debugger/ppu/oam-viewer.moc.hpp" - #include "debugger/ppu/cgram-viewer.moc.hpp" - - #include "debugger/misc/debugger-options.moc.hpp" -#endif - -#include "input/input.hpp" - -#include "link/filter.hpp" -#include "link/reader.hpp" - -#include "movie/movie.hpp" - -#include "settings/settings.moc.hpp" -#include "settings/profile.moc.hpp" -#include "settings/video.moc.hpp" -#include "settings/audio.moc.hpp" -#include "settings/input.moc.hpp" -#include "settings/paths.moc.hpp" -#include "settings/advanced.moc.hpp" - -#include "state/state.hpp" - -#include "tools/tools.moc.hpp" -#include "tools/cheateditor.moc.hpp" -#include "tools/cheatfinder.moc.hpp" -#include "tools/statemanager.moc.hpp" -#include "tools/effecttoggle.moc.hpp" - -#include "utility/utility.hpp" - -struct Style { - static const char Monospace[64]; - - enum { - WindowMargin = 5, - WidgetSpacing = 5, - SeparatorSpacing = 5, - }; -}; - -extern string filepath(const char *filename, const char *filepath); diff --git a/bsnes/ui-qt/utility/system-state.cpp b/bsnes/ui-qt/utility/system-state.cpp deleted file mode 100755 index c4afb4b0..00000000 --- a/bsnes/ui-qt/utility/system-state.cpp +++ /dev/null @@ -1,101 +0,0 @@ -void Utility::modifySystemState(system_state_t systemState) { - fileBrowser->close(); //avoid edge case oddities (eg movie playback window still open from previous game) - state.resetHistory(); //do not allow rewinding past a destructive system action - movie.stop(); //movies cannot continue to record after destructive system actions - - video.clear(); - audio.clear(); - - switch(systemState) { - case LoadCartridge: { - //must call cartridge.load_cart_...() before calling modifySystemState(LoadCartridge) - if(SNES::cartridge.loaded() == false) break; - cartridge.loadCheats(); - - application.power = true; - application.pause = false; - SNES::system.power(); - - //warn if unsupported hardware detected - string chip; - if(0); - else if(SNES::cartridge.has_st0011()) chip = "ST-0011"; - else if(SNES::cartridge.has_st0018()) chip = "ST-0018"; - if(chip != "") { - QMessageBox::warning(mainWindow, "Warning", string() - << "

Warning:
The " << chip << " chip was detected, which is not fully emulated yet.
" - << "It is unlikely that this title will work properly.

"); - } - - showMessage(string() - << "Loaded " << cartridge.name - << (cartridge.patchApplied ? ", and applied UPS patch." : ".")); - mainWindow->setWindowTitle(string() << cartridge.name << " - " << SNES::Info::Name << " v" << SNES::Info::Version); - #if defined(DEBUGGER) - debugger->echo(string() << "Loaded " << cartridge.name << ".
"); - #endif - } break; - - case UnloadCartridge: { - if(SNES::cartridge.loaded() == false) break; //no cart to unload? - cartridge.saveCheats(); - - SNES::system.unload(); //flush all memory to memory::* devices - cartridge.saveMemory(); //save memory to disk - SNES::cartridge.unload(); //deallocate memory - - application.power = false; - application.pause = true; - - showMessage(string() << "Unloaded " << cartridge.name << "."); - mainWindow->setWindowTitle(string() << SNES::Info::Name << " v" << SNES::Info::Version); - } break; - - case PowerOn: { - if(SNES::cartridge.loaded() == false || application.power == true) break; - - application.power = true; - application.pause = false; - SNES::system.power(); - - showMessage("Power on."); - } break; - - case PowerOff: { - if(SNES::cartridge.loaded() == false || application.power == false) break; - - application.power = false; - application.pause = true; - - showMessage("Power off."); - } break; - - case PowerCycle: { - if(SNES::cartridge.loaded() == false) break; - - application.power = true; - application.pause = false; - SNES::system.power(); - - showMessage("System power was cycled."); - } break; - - case Reset: { - if(SNES::cartridge.loaded() == false || application.power == false) break; - - application.pause = false; - SNES::system.reset(); - - showMessage("System was reset."); - } break; - } - - mainWindow->syncUi(); - #if defined(DEBUGGER) - debugger->modifySystemState(systemState); - debugger->synchronize(); - #endif - cheatEditorWindow->synchronize(); - cheatFinderWindow->synchronize(); - stateManagerWindow->reload(); -} diff --git a/bsnes/ui-qt/utility/utility.cpp b/bsnes/ui-qt/utility/utility.cpp deleted file mode 100755 index 28dd19ff..00000000 --- a/bsnes/ui-qt/utility/utility.cpp +++ /dev/null @@ -1,132 +0,0 @@ -Utility utility; - -#include "system-state.cpp" -#include "window.cpp" - -void Utility::inputEvent(uint16_t scancode) { - //release mouse capture if escape key is pressed on any keyboard - for(unsigned i = 0; i < Keyboard::Count; i++) { - if(scancode == keyboard(i)[Keyboard::Escape] && mapper().state(scancode)) { - if(mainWindow->isActive() && input.acquired()) { - input.unacquire(); - return; - } - } - } -} - -//display message in main window statusbar area for three seconds -void Utility::showMessage(const char *message) { - mainWindow->statusBar->showMessage(string() << message, 3000); -} - -//updates system state text at bottom-right of main window statusbar -void Utility::updateSystemState() { - string text; - - if(SNES::cartridge.loaded() == false) { - text = "No cartridge loaded"; - } else if(application.power == false) { - text = "Power off"; - } else if(application.pause == true || application.autopause == true) { - text = "Paused"; - } else if(interface.framesUpdated == true) { - interface.framesUpdated = false; - text << interface.framesExecuted; - text << " fps"; - } else { - //nothing to update - return; - } - - mainWindow->systemState->setText(string() << " " << text << " "); -} - -void Utility::acquireMouse() { - if(SNES::cartridge.loaded()) { - if(SNES::config.controller_port1 == SNES::Input::Device::Mouse - || SNES::config.controller_port2 == SNES::Input::Device::Mouse - || SNES::config.controller_port2 == SNES::Input::Device::SuperScope - || SNES::config.controller_port2 == SNES::Input::Device::Justifier - || SNES::config.controller_port2 == SNES::Input::Device::Justifiers - ) input.acquire(); - } -} - -void Utility::unacquireMouse() { - input.unacquire(); -} - -void Utility::updateAvSync() { - video.set(Video::Synchronize, config().video.synchronize); - audio.set(Audio::Synchronize, config().audio.synchronize); -} - -void Utility::updateColorFilter() { - filter.contrast = config().video.contrastAdjust; - filter.brightness = config().video.brightnessAdjust; - filter.gamma = 100 + config().video.gammaAdjust; - filter.gamma_ramp = config().video.enableGammaRamp; - filter.colortable_update(); -} - -void Utility::updatePixelShader() { - string filedata; - - if(filedata.readfile(config().path.shader)) { - video.set(Video::Shader, (const char*)filedata); - } else { - video.set(Video::Shader, (const char*)0); - } -} - -void Utility::updateHardwareFilter() { - video.set(Video::Filter, config().video.context->hwFilter); -} - -void Utility::updateSoftwareFilter() { - filter.renderer = config().video.context->swFilter; -} - -void Utility::updateEmulationSpeed() { - config().system.speed = max(0, min(4, (signed)config().system.speed)); - - double scale[] = { - config().system.speedSlowest / 100.0, - config().system.speedSlow / 100.0, - config().system.speedNormal / 100.0, - config().system.speedFast / 100.0, - config().system.speedFastest / 100.0, - }; - unsigned outfreq = config().audio.outputFrequency; - unsigned infreq = config().audio.inputFrequency * scale[config().system.speed] + 0.5; - - audio.set(Audio::Resample, true); //always resample (required for volume adjust + frequency scaler) - audio.set(Audio::ResampleRatio, (double)infreq / (double)outfreq); -} - -void Utility::updateControllers() { - SNES::input.port_set_device(0, SNES::config.controller_port1); - SNES::input.port_set_device(1, SNES::config.controller_port2); - - switch(config().input.port1) { default: - case ControllerPort1::None: mapper().port1 = 0; break; - case ControllerPort1::Gamepad: mapper().port1 = &Controllers::gamepad1; break; - case ControllerPort1::Asciipad: mapper().port1 = &Controllers::asciipad1; break; - case ControllerPort1::Multitap: mapper().port1 = &Controllers::multitap1; break; - case ControllerPort1::Mouse: mapper().port1 = &Controllers::mouse1; break; - } - - switch(config().input.port2) { default: - case ControllerPort2::None: mapper().port2 = 0; break; - case ControllerPort2::Gamepad: mapper().port2 = &Controllers::gamepad2; break; - case ControllerPort2::Asciipad: mapper().port2 = &Controllers::asciipad2; break; - case ControllerPort2::Multitap: mapper().port2 = &Controllers::multitap2; break; - case ControllerPort2::Mouse: mapper().port2 = &Controllers::mouse2; break; - case ControllerPort2::SuperScope: mapper().port2 = &Controllers::superscope; break; - case ControllerPort2::Justifier: mapper().port2 = &Controllers::justifier1; break; - case ControllerPort2::Justifiers: mapper().port2 = &Controllers::justifiers; break; - } - - mainWindow->syncUi(); -} diff --git a/bsnes/ui-qt/utility/utility.hpp b/bsnes/ui-qt/utility/utility.hpp deleted file mode 100755 index 5ed0edd8..00000000 --- a/bsnes/ui-qt/utility/utility.hpp +++ /dev/null @@ -1,38 +0,0 @@ -class Utility { -public: - //utility.cpp - void inputEvent(uint16_t scancode); - void showMessage(const char *message); - void updateSystemState(); - void acquireMouse(); - void unacquireMouse(); - - void updateAvSync(); - void updateColorFilter(); - void updatePixelShader(); - void updateHardwareFilter(); - void updateSoftwareFilter(); - void updateEmulationSpeed(); - void updateControllers(); - - //system-state.cpp - enum system_state_t { LoadCartridge, UnloadCartridge, PowerOn, PowerOff, PowerCycle, Reset }; - void modifySystemState(system_state_t state); - - //window.cpp - void updateFullscreenState(); - void constrainSize(unsigned &x, unsigned &y, unsigned max); - void resizeMainWindow(); - void toggleSynchronizeVideo(); - void toggleSynchronizeAudio(); - void setNtscMode(); - void setPalMode(); - void toggleSmoothVideoOutput(); - void toggleAspectCorrection(); - void setScale(unsigned); - void toggleFullscreen(); - void toggleMenubar(); - void toggleStatusbar(); -}; - -extern Utility utility; diff --git a/bsnes/ui-qt/utility/window.cpp b/bsnes/ui-qt/utility/window.cpp deleted file mode 100755 index 28dcded6..00000000 --- a/bsnes/ui-qt/utility/window.cpp +++ /dev/null @@ -1,192 +0,0 @@ -void Utility::updateFullscreenState() { - video.clear(); - - if(config().video.isFullscreen == false) { - config().video.context = &config().video.windowed; - mainWindow->showNormal(); - mainWindow->menuBar->setVisible(true); - mainWindow->statusBar->setVisible(true); - } else { - config().video.context = &config().video.fullscreen; - mainWindow->showFullScreen(); - mainWindow->menuBar->setVisible(config().video.autoHideFullscreenMenu == false); - mainWindow->statusBar->setVisible(config().video.autoHideFullscreenMenu == false); - } - - QApplication::processEvents(); - #if defined(PLATFORM_X) - //Xlib requires time to propogate fullscreen state change message to window manager; - //if window is resized before this occurs, canvas may not resize correctly - usleep(50000); - #endif - - //refresh options that are unique to each video context - updateHardwareFilter(); - updateSoftwareFilter(); - mainWindow->syncUi(); -} - -//if max exceeds x: x is set to max, and y is scaled down to keep proportion to x -void Utility::constrainSize(unsigned &x, unsigned &y, unsigned max) { - if(x > max) { - double scalar = (double)max / (double)x; - y = (unsigned)((double)y * (double)scalar); - x = max; - } -} - -void Utility::resizeMainWindow() { - //process all pending events to ensure window size is correct (after fullscreen state change, etc) - usleep(2000); - QApplication::processEvents(); - - unsigned screenWidth, screenHeight; - if(config().video.isFullscreen == false) { - screenWidth = QApplication::desktop()->availableGeometry(mainWindow).width(); - screenHeight = QApplication::desktop()->availableGeometry(mainWindow).height(); - } else { - screenWidth = mainWindow->canvasContainer->size().width(); - screenHeight = mainWindow->canvasContainer->size().height(); - } - - unsigned region = config().video.context->region; - unsigned multiplier = config().video.context->multiplier; - unsigned &width = display.outputWidth; - unsigned &height = display.outputHeight; - width = 256 * multiplier; - height = (region == 0 ? 224 : 239) * multiplier; - - if(config().video.context->correctAspectRatio) { - if(region == 0) { - width = (double)width * config().video.ntscAspectRatio + 0.5; //NTSC adjust - } else { - width = (double)width * config().video.palAspectRatio + 0.5; //PAL adjust - } - } - - display.cropLeft = config().video.cropLeft; - display.cropTop = config().video.cropTop; - display.cropRight = config().video.cropRight; - display.cropBottom = config().video.cropBottom; - - //ensure window size will not be larger than viewable desktop area - constrainSize(height, width, screenHeight); - constrainSize(width, height, screenWidth); - - if(config().video.isFullscreen == false) { - mainWindow->canvas->setFixedSize(width, height); - mainWindow->show(); - } else { - if(multiplier == 6) { - //Scale Max - Normal - width = (double)width * (double)screenHeight / (double)height; - height = screenHeight; - } - - if(multiplier == 7) { - //Scale Max - Wide - width = screenWidth; - height = screenHeight; - } - - if(multiplier == 8) { - //Scale Max - Wide Zoom - //1. scale width and height proportionally until width of screen is completely filled - //2. determine how much height goes out of screen by - //3. cut half of the above value out of the visible input display region - //this results in a 50% compromise between correct aspect ratio and fill mode; - //while cropping out only 50% as much height as a fully proportional zoom would - width = (double)width * (double)screenHeight / (double)height; - height = screenHeight; - unsigned widthDifference = screenWidth - width; - unsigned adjustedHeight = (double)height * (double)(width + widthDifference) / (double)(width); - unsigned heightDifference = adjustedHeight - height; - width = screenWidth; - display.cropLeft = 0; - display.cropTop = 100.0 / (double)height * (heightDifference / 4); - display.cropRight = 0; - display.cropBottom = 100.0 / (double)height * (heightDifference / 4); - } - - mainWindow->canvas->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - mainWindow->canvas->setFixedSize(width, height); - mainWindow->canvas->setMinimumSize(0, 0); - } - - //workaround for Qt/Xlib bug: - //if window resize occurs with cursor over it, Qt shows Qt::Size*DiagCursor; - //so force it to show Qt::ArrowCursor, as expected - mainWindow->setCursor(Qt::ArrowCursor); - mainWindow->canvasContainer->setCursor(Qt::ArrowCursor); - mainWindow->canvas->setCursor(Qt::ArrowCursor); - - //workaround for DirectSound(?) bug: - //window resizing sometimes breaks audio sync, this call re-initializes it - updateAvSync(); -} - -void Utility::toggleSynchronizeVideo() { - mainWindow->settings_emulationSpeed_syncVideo->toggleChecked(); - config().video.synchronize = mainWindow->settings_emulationSpeed_syncVideo->isChecked(); - updateAvSync(); -} - -void Utility::toggleSynchronizeAudio() { - mainWindow->settings_emulationSpeed_syncAudio->toggleChecked(); - config().audio.synchronize = mainWindow->settings_emulationSpeed_syncAudio->isChecked(); - updateAvSync(); -} - -void Utility::setNtscMode() { - config().video.context->region = 0; - resizeMainWindow(); - mainWindow->shrink(); - mainWindow->syncUi(); -} - -void Utility::setPalMode() { - config().video.context->region = 1; - resizeMainWindow(); - mainWindow->shrink(); - mainWindow->syncUi(); -} - -void Utility::toggleSmoothVideoOutput() { - mainWindow->settings_smoothVideo->toggleChecked(); - config().video.context->hwFilter = mainWindow->settings_smoothVideo->isChecked(); - updateHardwareFilter(); - mainWindow->syncUi(); -} - -void Utility::toggleAspectCorrection() { - mainWindow->settings_videoMode_correctAspectRatio->toggleChecked(); - config().video.context->correctAspectRatio = mainWindow->settings_videoMode_correctAspectRatio->isChecked(); - resizeMainWindow(); - mainWindow->shrink(); -} - -void Utility::setScale(unsigned scale) { - config().video.context->multiplier = scale; - resizeMainWindow(); - mainWindow->shrink(); - mainWindow->syncUi(); -} - -void Utility::toggleFullscreen() { - config().video.isFullscreen = !config().video.isFullscreen; - updateFullscreenState(); - resizeMainWindow(); - mainWindow->syncUi(); -} - -void Utility::toggleMenubar() { - mainWindow->menuBar->setVisible(!mainWindow->menuBar->isVisibleTo(mainWindow)); - resizeMainWindow(); - mainWindow->shrink(); -} - -void Utility::toggleStatusbar() { - mainWindow->statusBar->setVisible(!mainWindow->statusBar->isVisibleTo(mainWindow)); - resizeMainWindow(); - mainWindow->shrink(); -} diff --git a/bsnes/ui-phoenix/Makefile b/bsnes/ui/Makefile similarity index 100% rename from bsnes/ui-phoenix/Makefile rename to bsnes/ui/Makefile diff --git a/bsnes/ui-phoenix/base.hpp b/bsnes/ui/base.hpp similarity index 100% rename from bsnes/ui-phoenix/base.hpp rename to bsnes/ui/base.hpp diff --git a/bsnes/ui-phoenix/cartridge/cartridge.cpp b/bsnes/ui/cartridge/cartridge.cpp similarity index 100% rename from bsnes/ui-phoenix/cartridge/cartridge.cpp rename to bsnes/ui/cartridge/cartridge.cpp diff --git a/bsnes/ui-phoenix/cartridge/cartridge.hpp b/bsnes/ui/cartridge/cartridge.hpp similarity index 100% rename from bsnes/ui-phoenix/cartridge/cartridge.hpp rename to bsnes/ui/cartridge/cartridge.hpp diff --git a/bsnes/ui-phoenix/config.cpp b/bsnes/ui/config.cpp similarity index 100% rename from bsnes/ui-phoenix/config.cpp rename to bsnes/ui/config.cpp diff --git a/bsnes/ui-phoenix/config.hpp b/bsnes/ui/config.hpp similarity index 100% rename from bsnes/ui-phoenix/config.hpp rename to bsnes/ui/config.hpp diff --git a/bsnes/ui-phoenix/debugger/console.cpp b/bsnes/ui/debugger/console.cpp similarity index 100% rename from bsnes/ui-phoenix/debugger/console.cpp rename to bsnes/ui/debugger/console.cpp diff --git a/bsnes/ui-phoenix/debugger/console.hpp b/bsnes/ui/debugger/console.hpp similarity index 100% rename from bsnes/ui-phoenix/debugger/console.hpp rename to bsnes/ui/debugger/console.hpp diff --git a/bsnes/ui-phoenix/debugger/cpu/debugger.cpp b/bsnes/ui/debugger/cpu/debugger.cpp similarity index 100% rename from bsnes/ui-phoenix/debugger/cpu/debugger.cpp rename to bsnes/ui/debugger/cpu/debugger.cpp diff --git a/bsnes/ui-phoenix/debugger/cpu/debugger.hpp b/bsnes/ui/debugger/cpu/debugger.hpp similarity index 100% rename from bsnes/ui-phoenix/debugger/cpu/debugger.hpp rename to bsnes/ui/debugger/cpu/debugger.hpp diff --git a/bsnes/ui-phoenix/debugger/debugger.cpp b/bsnes/ui/debugger/debugger.cpp similarity index 100% rename from bsnes/ui-phoenix/debugger/debugger.cpp rename to bsnes/ui/debugger/debugger.cpp diff --git a/bsnes/ui-phoenix/debugger/debugger.hpp b/bsnes/ui/debugger/debugger.hpp similarity index 100% rename from bsnes/ui-phoenix/debugger/debugger.hpp rename to bsnes/ui/debugger/debugger.hpp diff --git a/bsnes/ui-phoenix/debugger/smp/debugger.cpp b/bsnes/ui/debugger/smp/debugger.cpp similarity index 100% rename from bsnes/ui-phoenix/debugger/smp/debugger.cpp rename to bsnes/ui/debugger/smp/debugger.cpp diff --git a/bsnes/ui-phoenix/debugger/smp/debugger.hpp b/bsnes/ui/debugger/smp/debugger.hpp similarity index 100% rename from bsnes/ui-phoenix/debugger/smp/debugger.hpp rename to bsnes/ui/debugger/smp/debugger.hpp diff --git a/bsnes/ui-phoenix/debugger/tools/breakpoint-editor.cpp b/bsnes/ui/debugger/tools/breakpoint-editor.cpp similarity index 100% rename from bsnes/ui-phoenix/debugger/tools/breakpoint-editor.cpp rename to bsnes/ui/debugger/tools/breakpoint-editor.cpp diff --git a/bsnes/ui-phoenix/debugger/tools/breakpoint-editor.hpp b/bsnes/ui/debugger/tools/breakpoint-editor.hpp similarity index 100% rename from bsnes/ui-phoenix/debugger/tools/breakpoint-editor.hpp rename to bsnes/ui/debugger/tools/breakpoint-editor.hpp diff --git a/bsnes/ui-phoenix/debugger/tools/memory-editor.cpp b/bsnes/ui/debugger/tools/memory-editor.cpp similarity index 100% rename from bsnes/ui-phoenix/debugger/tools/memory-editor.cpp rename to bsnes/ui/debugger/tools/memory-editor.cpp diff --git a/bsnes/ui-phoenix/debugger/tools/memory-editor.hpp b/bsnes/ui/debugger/tools/memory-editor.hpp similarity index 100% rename from bsnes/ui-phoenix/debugger/tools/memory-editor.hpp rename to bsnes/ui/debugger/tools/memory-editor.hpp diff --git a/bsnes/ui-phoenix/general/file-browser.cpp b/bsnes/ui/general/file-browser.cpp similarity index 100% rename from bsnes/ui-phoenix/general/file-browser.cpp rename to bsnes/ui/general/file-browser.cpp diff --git a/bsnes/ui-phoenix/general/file-browser.hpp b/bsnes/ui/general/file-browser.hpp similarity index 100% rename from bsnes/ui-phoenix/general/file-browser.hpp rename to bsnes/ui/general/file-browser.hpp diff --git a/bsnes/ui-phoenix/general/general.cpp b/bsnes/ui/general/general.cpp similarity index 100% rename from bsnes/ui-phoenix/general/general.cpp rename to bsnes/ui/general/general.cpp diff --git a/bsnes/ui-phoenix/general/general.hpp b/bsnes/ui/general/general.hpp similarity index 100% rename from bsnes/ui-phoenix/general/general.hpp rename to bsnes/ui/general/general.hpp diff --git a/bsnes/ui-phoenix/general/main-window.cpp b/bsnes/ui/general/main-window.cpp similarity index 100% rename from bsnes/ui-phoenix/general/main-window.cpp rename to bsnes/ui/general/main-window.cpp diff --git a/bsnes/ui-phoenix/general/main-window.hpp b/bsnes/ui/general/main-window.hpp similarity index 100% rename from bsnes/ui-phoenix/general/main-window.hpp rename to bsnes/ui/general/main-window.hpp diff --git a/bsnes/ui-phoenix/general/slot-loader.cpp b/bsnes/ui/general/slot-loader.cpp similarity index 100% rename from bsnes/ui-phoenix/general/slot-loader.cpp rename to bsnes/ui/general/slot-loader.cpp diff --git a/bsnes/ui-phoenix/general/slot-loader.hpp b/bsnes/ui/general/slot-loader.hpp similarity index 100% rename from bsnes/ui-phoenix/general/slot-loader.hpp rename to bsnes/ui/general/slot-loader.hpp diff --git a/bsnes/ui-phoenix/input/hotkeys.cpp b/bsnes/ui/input/hotkeys.cpp similarity index 100% rename from bsnes/ui-phoenix/input/hotkeys.cpp rename to bsnes/ui/input/hotkeys.cpp diff --git a/bsnes/ui-phoenix/input/input.cpp b/bsnes/ui/input/input.cpp similarity index 100% rename from bsnes/ui-phoenix/input/input.cpp rename to bsnes/ui/input/input.cpp diff --git a/bsnes/ui-phoenix/input/input.hpp b/bsnes/ui/input/input.hpp similarity index 100% rename from bsnes/ui-phoenix/input/input.hpp rename to bsnes/ui/input/input.hpp diff --git a/bsnes/ui-phoenix/interface.cpp b/bsnes/ui/interface.cpp similarity index 100% rename from bsnes/ui-phoenix/interface.cpp rename to bsnes/ui/interface.cpp diff --git a/bsnes/ui-phoenix/interface.hpp b/bsnes/ui/interface.hpp similarity index 100% rename from bsnes/ui-phoenix/interface.hpp rename to bsnes/ui/interface.hpp diff --git a/bsnes/ui-phoenix/main.cpp b/bsnes/ui/main.cpp similarity index 100% rename from bsnes/ui-phoenix/main.cpp rename to bsnes/ui/main.cpp diff --git a/bsnes/ui-phoenix/resource.rc b/bsnes/ui/resource.rc similarity index 100% rename from bsnes/ui-phoenix/resource.rc rename to bsnes/ui/resource.rc diff --git a/bsnes/ui-phoenix/settings/advanced.cpp b/bsnes/ui/settings/advanced.cpp similarity index 100% rename from bsnes/ui-phoenix/settings/advanced.cpp rename to bsnes/ui/settings/advanced.cpp diff --git a/bsnes/ui-phoenix/settings/advanced.hpp b/bsnes/ui/settings/advanced.hpp similarity index 100% rename from bsnes/ui-phoenix/settings/advanced.hpp rename to bsnes/ui/settings/advanced.hpp diff --git a/bsnes/ui-phoenix/settings/audio.cpp b/bsnes/ui/settings/audio.cpp similarity index 100% rename from bsnes/ui-phoenix/settings/audio.cpp rename to bsnes/ui/settings/audio.cpp diff --git a/bsnes/ui-phoenix/settings/audio.hpp b/bsnes/ui/settings/audio.hpp similarity index 100% rename from bsnes/ui-phoenix/settings/audio.hpp rename to bsnes/ui/settings/audio.hpp diff --git a/bsnes/ui-phoenix/settings/input.cpp b/bsnes/ui/settings/input.cpp similarity index 100% rename from bsnes/ui-phoenix/settings/input.cpp rename to bsnes/ui/settings/input.cpp diff --git a/bsnes/ui-phoenix/settings/input.hpp b/bsnes/ui/settings/input.hpp similarity index 100% rename from bsnes/ui-phoenix/settings/input.hpp rename to bsnes/ui/settings/input.hpp diff --git a/bsnes/ui-phoenix/settings/settings.cpp b/bsnes/ui/settings/settings.cpp similarity index 100% rename from bsnes/ui-phoenix/settings/settings.cpp rename to bsnes/ui/settings/settings.cpp diff --git a/bsnes/ui-phoenix/settings/settings.hpp b/bsnes/ui/settings/settings.hpp similarity index 100% rename from bsnes/ui-phoenix/settings/settings.hpp rename to bsnes/ui/settings/settings.hpp diff --git a/bsnes/ui-phoenix/settings/video.cpp b/bsnes/ui/settings/video.cpp similarity index 100% rename from bsnes/ui-phoenix/settings/video.cpp rename to bsnes/ui/settings/video.cpp diff --git a/bsnes/ui-phoenix/settings/video.hpp b/bsnes/ui/settings/video.hpp similarity index 100% rename from bsnes/ui-phoenix/settings/video.hpp rename to bsnes/ui/settings/video.hpp diff --git a/bsnes/ui-phoenix/tools/cheat-editor.cpp b/bsnes/ui/tools/cheat-editor.cpp similarity index 100% rename from bsnes/ui-phoenix/tools/cheat-editor.cpp rename to bsnes/ui/tools/cheat-editor.cpp diff --git a/bsnes/ui-phoenix/tools/cheat-editor.hpp b/bsnes/ui/tools/cheat-editor.hpp similarity index 100% rename from bsnes/ui-phoenix/tools/cheat-editor.hpp rename to bsnes/ui/tools/cheat-editor.hpp diff --git a/bsnes/ui-phoenix/tools/state-manager.cpp b/bsnes/ui/tools/state-manager.cpp similarity index 100% rename from bsnes/ui-phoenix/tools/state-manager.cpp rename to bsnes/ui/tools/state-manager.cpp diff --git a/bsnes/ui-phoenix/tools/state-manager.hpp b/bsnes/ui/tools/state-manager.hpp similarity index 100% rename from bsnes/ui-phoenix/tools/state-manager.hpp rename to bsnes/ui/tools/state-manager.hpp diff --git a/bsnes/ui-phoenix/tools/tools.cpp b/bsnes/ui/tools/tools.cpp similarity index 100% rename from bsnes/ui-phoenix/tools/tools.cpp rename to bsnes/ui/tools/tools.cpp diff --git a/bsnes/ui-phoenix/tools/tools.hpp b/bsnes/ui/tools/tools.hpp similarity index 100% rename from bsnes/ui-phoenix/tools/tools.hpp rename to bsnes/ui/tools/tools.hpp diff --git a/bsnes/ui-phoenix/utility/utility.cpp b/bsnes/ui/utility/utility.cpp similarity index 100% rename from bsnes/ui-phoenix/utility/utility.cpp rename to bsnes/ui/utility/utility.cpp diff --git a/bsnes/ui-phoenix/utility/utility.hpp b/bsnes/ui/utility/utility.hpp similarity index 100% rename from bsnes/ui-phoenix/utility/utility.hpp rename to bsnes/ui/utility/utility.hpp