2015-04-21 11:51:57 +00:00
|
|
|
StateManager::StateManager(TabFrame* parent) : TabFrameItem(parent) {
|
2016-01-07 08:14:33 +00:00
|
|
|
setIcon(Icon::Application::FileManager);
|
2015-04-21 11:51:57 +00:00
|
|
|
setText("State Manager");
|
|
|
|
|
|
|
|
layout.setMargin(5);
|
2016-05-04 10:07:13 +00:00
|
|
|
stateList.append(TableViewHeader().setVisible()
|
|
|
|
.append(TableViewColumn().setText("Slot").setForegroundColor({0, 128, 0}).setAlignment(1.0))
|
|
|
|
.append(TableViewColumn().setText("Description").setExpandable())
|
Update to v094r40 release.
byuu says:
Changelog:
- updated to newest hiro API
- SFC performance profile builds once again
- hiro: Qt port completed
Errata 1: the hiro/Qt target won't run tomoko just yet. Starts by
crashing inside InputSettings because hiro/Qt isn't forcefully selecting
the first item added to a ComboButton just yet. Even with a monkey patch
to get around that, the UI is incredibly unstable. Lots of geometry
calculation bugs, and a crash when you try and access certain folders in
the browser dialog. Lots of work left to be done there, sadly.
Errata 2: the hiro/Windows port has black backgrounds on all ListView
items. It's because I need to test for unassigned colors and grab the
default Windows brush colors in those cases.
Note: alternating row colors on multi-column ListView widgets is gone
now. Not a bug. May add it back later, but I'm not sure. It doesn't
interact nicely with per-cell background colors.
Things left to do:
First, I have to fix the Windows and Qt target bugs.
Next, I need to go through and revise the hiro API even more (nothing
too major.)
Next, I need to update icarus to use the new hiro API, and add support
for the SFC games database.
Next, I have to rewrite my TSV->BML cheat code tool.
Next, I need to post a final WIP of higan+icarus publicly and wait a few
days.
Next, I need to fix any bugs reported from the final WIP that I can.
Finally, I should be able to release v095.
2015-08-18 10:18:00 +00:00
|
|
|
);
|
2015-06-12 13:14:38 +00:00
|
|
|
for(auto slot : range(Slots)) {
|
2016-05-04 10:07:13 +00:00
|
|
|
stateList.append(TableViewItem()
|
|
|
|
.append(TableViewCell().setText(1 + slot))
|
|
|
|
.append(TableViewCell())
|
2015-06-12 13:14:38 +00:00
|
|
|
);
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
stateList.onActivate([&] { doLoad(); });
|
2015-06-18 10:48:53 +00:00
|
|
|
stateList.onChange([&] { doChangeSelected(); });
|
2015-04-21 11:51:57 +00:00
|
|
|
descriptionLabel.setText("Description:");
|
2015-06-18 10:48:53 +00:00
|
|
|
descriptionValue.onChange([&] { doChangeDescription(); });
|
2015-04-21 11:51:57 +00:00
|
|
|
saveButton.setText("Save").onActivate([&] { doSave(); });
|
|
|
|
loadButton.setText("Load").onActivate([&] { doLoad(); });
|
|
|
|
resetButton.setText("Reset").onActivate([&] { doReset(); });
|
|
|
|
eraseButton.setText("Erase").onActivate([&] { doErase(); });
|
2015-07-02 10:22:24 +00:00
|
|
|
|
|
|
|
doUpdateControls();
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto StateManager::doUpdateControls() -> void {
|
2016-02-16 09:27:55 +00:00
|
|
|
vector<uint8_t> buffer;
|
2015-04-21 11:51:57 +00:00
|
|
|
if(auto item = stateList.selected()) {
|
2015-06-18 10:48:53 +00:00
|
|
|
buffer = file::read(program->stateName(1 + item.offset(), true));
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(buffer.size() >= 584) {
|
2015-06-18 10:48:53 +00:00
|
|
|
descriptionValue.setEnabled(true);
|
2015-04-21 11:51:57 +00:00
|
|
|
loadButton.setEnabled(true);
|
|
|
|
eraseButton.setEnabled(true);
|
|
|
|
} else {
|
2015-07-02 10:22:24 +00:00
|
|
|
descriptionValue.setEnabled(false).setText("");
|
2015-04-21 11:51:57 +00:00
|
|
|
loadButton.setEnabled(false);
|
|
|
|
eraseButton.setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto StateManager::doChangeSelected() -> void {
|
2016-02-16 09:27:55 +00:00
|
|
|
vector<uint8_t> buffer;
|
2015-06-18 10:48:53 +00:00
|
|
|
if(auto item = stateList.selected()) {
|
|
|
|
buffer = file::read(program->stateName(1 + item.offset(), true));
|
2015-07-02 10:22:24 +00:00
|
|
|
if(buffer.size() >= 584) {
|
|
|
|
string description;
|
|
|
|
description.reserve(512);
|
2015-08-02 06:23:13 +00:00
|
|
|
memory::copy(description.get(), buffer.data() + 72, 512);
|
2015-07-02 10:22:24 +00:00
|
|
|
description.resize(description.length());
|
|
|
|
descriptionValue.setEnabled(true).setText(description);
|
|
|
|
return doUpdateControls();
|
|
|
|
}
|
2015-06-18 10:48:53 +00:00
|
|
|
}
|
|
|
|
|
2015-07-02 10:22:24 +00:00
|
|
|
descriptionValue.setEnabled(false).setText("");
|
2015-06-18 10:48:53 +00:00
|
|
|
doUpdateControls();
|
|
|
|
}
|
|
|
|
|
2015-04-21 11:51:57 +00:00
|
|
|
auto StateManager::doRefresh() -> void {
|
2015-06-18 10:48:53 +00:00
|
|
|
for(auto slot : range(Slots)) {
|
2015-04-21 11:51:57 +00:00
|
|
|
auto buffer = file::read(program->stateName(1 + slot, true));
|
|
|
|
if(buffer.size() >= 584) {
|
|
|
|
string description;
|
|
|
|
description.reserve(512);
|
2015-08-02 06:23:13 +00:00
|
|
|
memory::copy(description.get(), buffer.data() + 72, 512);
|
2015-04-21 11:51:57 +00:00
|
|
|
description.resize(description.length());
|
2015-06-18 10:48:53 +00:00
|
|
|
stateList.item(slot).cell(1).setText(description).setForegroundColor({0, 0, 0});
|
2015-04-21 11:51:57 +00:00
|
|
|
} else {
|
Update to v106r35 release.
byuu says:
Changelog:
- sfc/ppu-fast: fixed overscan crash
- sfc/ppu-fast: fixed direct color mode
- sfc: reconnected MSU1 support
- higan: game.sfc/msu1/data.rom, game.sfc/msu1/track-#.pcm
- bsnes: game.msu, game-#.pcm
- bsnes: added cheat code editor
- bsnes: added cheat code database support
- sfc/ppu-fast: clear overscan lines when overscan disabled
- sfc: output 223/239 lines instead of 224/240 lines
- bsnes: fix aspect correction calculation
- bsnes: crop line 224 when overscan masking is enabled
- bsnes: exposed Expansion Port menu; but hid “21fx” from the list of
devices
- bsnes: tools menu is hidden until a game is loaded
- ruby/input/keyboard/quartz: fixed compilation error
So only bsnes the automated overscan cropping option. In higan, you can
crop however many lines you like from the top or bottom of the image.
But for bsnes, it automatically eats sixteen lines. My view right now is
that if bsnes is meant to be the casual gaming emulator, that it should
eat line 224 in this mode. Most games show content here, but because of
the way the SNES PPU works, the very last line ends up on its very own
tile row (line 0 isn't rendered), if the scroll registers don't account
for it. There's a small number of games that will draw junk data to the
very last scanline of the frame as a result of this. So I chose, at
least for now, to hide it. Users can obviously disable overscan cropping
to see this scanline. I'm open to being convinced not to do this, if
someone has a compelling reason.
We're pretty much screwed one way or the other with no overscan masking.
If we output 239 lines, then most games will render 7 blank lines + 224
drawn lines + 8 blank lines, and the black top and bottom aren't
centered. But if we output 240 lines to get 8 + 224 + 8, then games that
do use overscan will have a blank line at the very bottom of the window.
I'm also trying out a modified cheat code file format. It's been forever
since I bothered to look at it, and the “cartridge” parent node doesn't
match what I'm doing with trying to rename “cartridge” to “game” in
manifests. And indeed, the idea of requiring a root node is rather
superfluous for a cheat code file. Current format looks like this:
cheat
description: foo
code: 7e2000=20+7e2001=30?40
enabled
cheat
description: bar
code: 7e4000=80
Open to discussing this, and I'd like to sync up with Snes9X before they
push out a new release, and I'll agree to finalize and never change this
format again.
I chose to use .cht for the extension when using game files (eg
gamename.cht)
2018-06-03 13:14:42 +00:00
|
|
|
stateList.item(slot).cell(1).setText("<empty>").setForegroundColor({128, 128, 128});
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto StateManager::doChangeDescription() -> void {
|
2015-04-21 11:51:57 +00:00
|
|
|
if(auto item = stateList.selected()) {
|
2015-06-18 10:48:53 +00:00
|
|
|
auto buffer = file::read(program->stateName(1 + item.offset(), true));
|
2015-04-21 11:51:57 +00:00
|
|
|
if(buffer.size() >= 584) {
|
|
|
|
string description = descriptionValue.text();
|
|
|
|
description.reserve(512);
|
|
|
|
memory::copy(buffer.data() + 72, description.data(), 512);
|
2015-06-18 10:48:53 +00:00
|
|
|
file::write(program->stateName(1 + item.offset(), true), buffer);
|
2015-04-21 11:51:57 +00:00
|
|
|
doRefresh();
|
2015-06-18 10:48:53 +00:00
|
|
|
doUpdateControls();
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto StateManager::doLoad() -> void {
|
|
|
|
if(auto item = stateList.selected()) {
|
2015-06-18 10:48:53 +00:00
|
|
|
program->loadState(1 + item.offset(), true);
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto StateManager::doSave() -> void {
|
|
|
|
if(auto item = stateList.selected()) {
|
2015-06-18 10:48:53 +00:00
|
|
|
program->saveState(1 + item.offset(), true);
|
2015-04-21 11:51:57 +00:00
|
|
|
doRefresh();
|
2015-06-18 10:48:53 +00:00
|
|
|
doUpdateControls();
|
|
|
|
descriptionValue.setText("").setFocused();
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto StateManager::doReset() -> void {
|
Update to v106r35 release.
byuu says:
Changelog:
- sfc/ppu-fast: fixed overscan crash
- sfc/ppu-fast: fixed direct color mode
- sfc: reconnected MSU1 support
- higan: game.sfc/msu1/data.rom, game.sfc/msu1/track-#.pcm
- bsnes: game.msu, game-#.pcm
- bsnes: added cheat code editor
- bsnes: added cheat code database support
- sfc/ppu-fast: clear overscan lines when overscan disabled
- sfc: output 223/239 lines instead of 224/240 lines
- bsnes: fix aspect correction calculation
- bsnes: crop line 224 when overscan masking is enabled
- bsnes: exposed Expansion Port menu; but hid “21fx” from the list of
devices
- bsnes: tools menu is hidden until a game is loaded
- ruby/input/keyboard/quartz: fixed compilation error
So only bsnes the automated overscan cropping option. In higan, you can
crop however many lines you like from the top or bottom of the image.
But for bsnes, it automatically eats sixteen lines. My view right now is
that if bsnes is meant to be the casual gaming emulator, that it should
eat line 224 in this mode. Most games show content here, but because of
the way the SNES PPU works, the very last line ends up on its very own
tile row (line 0 isn't rendered), if the scroll registers don't account
for it. There's a small number of games that will draw junk data to the
very last scanline of the frame as a result of this. So I chose, at
least for now, to hide it. Users can obviously disable overscan cropping
to see this scanline. I'm open to being convinced not to do this, if
someone has a compelling reason.
We're pretty much screwed one way or the other with no overscan masking.
If we output 239 lines, then most games will render 7 blank lines + 224
drawn lines + 8 blank lines, and the black top and bottom aren't
centered. But if we output 240 lines to get 8 + 224 + 8, then games that
do use overscan will have a blank line at the very bottom of the window.
I'm also trying out a modified cheat code file format. It's been forever
since I bothered to look at it, and the “cartridge” parent node doesn't
match what I'm doing with trying to rename “cartridge” to “game” in
manifests. And indeed, the idea of requiring a root node is rather
superfluous for a cheat code file. Current format looks like this:
cheat
description: foo
code: 7e2000=20+7e2001=30?40
enabled
cheat
description: bar
code: 7e4000=80
Open to discussing this, and I'd like to sync up with Snes9X before they
push out a new release, and I'll agree to finalize and never change this
format again.
I chose to use .cht for the extension when using game files (eg
gamename.cht)
2018-06-03 13:14:42 +00:00
|
|
|
if(MessageDialog().setParent(*toolsManager).setText("Permanently erase all states?").question() == "Yes") {
|
2015-04-21 11:51:57 +00:00
|
|
|
for(auto slot : range(Slots)) file::remove(program->stateName(1 + slot, true));
|
|
|
|
doRefresh();
|
2015-06-18 10:48:53 +00:00
|
|
|
doUpdateControls();
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto StateManager::doErase() -> void {
|
|
|
|
if(auto item = stateList.selected()) {
|
2015-06-18 10:48:53 +00:00
|
|
|
file::remove(program->stateName(1 + item.offset(), true));
|
2015-04-21 11:51:57 +00:00
|
|
|
doRefresh();
|
2015-06-18 10:48:53 +00:00
|
|
|
doUpdateControls();
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|