2013-03-15 13:11:33 +00:00
|
|
|
namespace phoenix {
|
|
|
|
|
2011-02-24 09:27:21 +00:00
|
|
|
static bool HexEdit_keyPress(GtkWidget *widget, GdkEventKey *event, HexEdit *self) {
|
|
|
|
return self->p.keyPress(event->keyval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool HexEdit_scroll(GtkRange *range, GtkScrollType scroll, gdouble value, HexEdit *self) {
|
|
|
|
self->p.scroll((unsigned)value);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Update to higan v091r14 and ananke v00r03 releases.
byuu says:
higan changelog:
- generates title displayed in emulator window by asking the core
- core builds title solely from "information/title" ... if it's not
there, you don't get a title at all
- sub-system load menu is gone ... since there are multiple revisions of
the SGB, this never really worked well anyway
- to load an SGB, BS-X or ST cartridge, load the base cartridge first
- "File->Load Game" moved to "Load->Import Game" ... may cause a bit of
confusion to new users, but I don't like having a single-item menu,
we'll just have to explain it to new users
- browser window redone to look like ananke
- home button here goes to ~/Emulation rather than just ~ like ananke,
since this is the home of game folders
- game folder icon is now the executable icon for the Tango theme
(orange diamond), meant to represent a complete game rather than
a game file or archive
ananke changelog:
- outputs GBC games to "Game Boy Color/" instead of "Game Boy/"
- adds the file basename to "information/title"
Known issues:
- using ananke to load a GB game trips the Super Famicom SGB mode and
fails (need to make the full-path auto-detection ignore non-bootable
systems)
- need to dump and test some BS-X media before releasing
- ananke lacks BS-X Satellaview cartridge support
- v092 isn't going to let you retarget the ananke/higan game folder path
of ~/Emulation, you will have to wait for a future version if that
bothers you so greatly
[Later, after the v092 release, byuu posted this additional changelog:
- kill laevateinn
- add title()
- add bootable, remove load
- combine file, library
- combine [][][] paths
- fix SFC subtype handling XML->BML
- update file browser to use buttons
- update file browser keyboard handling
- update system XML->BML
- fix sufami turbo hashing
- remove Cartridge::manifest
]
2012-12-25 05:31:55 +00:00
|
|
|
bool pHexEdit::focused() {
|
|
|
|
return GTK_WIDGET_HAS_FOCUS(subWidget);
|
|
|
|
}
|
|
|
|
|
2011-02-24 09:27:21 +00:00
|
|
|
void pHexEdit::setColumns(unsigned columns) {
|
|
|
|
setScroll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHexEdit::setLength(unsigned length) {
|
|
|
|
setScroll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHexEdit::setOffset(unsigned offset) {
|
|
|
|
setScroll();
|
|
|
|
updateScroll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHexEdit::setRows(unsigned rows) {
|
|
|
|
setScroll();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHexEdit::update() {
|
|
|
|
if(!hexEdit.onRead) {
|
|
|
|
gtk_text_buffer_set_text(textBuffer, "", -1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned position = cursorPosition();
|
|
|
|
|
|
|
|
string output;
|
|
|
|
unsigned offset = hexEdit.state.offset;
|
|
|
|
for(unsigned row = 0; row < hexEdit.state.rows; row++) {
|
|
|
|
output.append(hex<8>(offset));
|
|
|
|
output.append(" ");
|
|
|
|
|
|
|
|
string hexdata;
|
|
|
|
string ansidata = " ";
|
|
|
|
for(unsigned column = 0; column < hexEdit.state.columns; column++) {
|
|
|
|
if(offset < hexEdit.state.length) {
|
|
|
|
uint8_t data = hexEdit.onRead(offset++);
|
|
|
|
hexdata.append(hex<2>(data));
|
|
|
|
hexdata.append(" ");
|
|
|
|
char buffer[2] = { data >= 0x20 && data <= 0x7e ? (char)data : '.', 0 };
|
|
|
|
ansidata.append(buffer);
|
|
|
|
} else {
|
|
|
|
hexdata.append(" ");
|
|
|
|
ansidata.append(" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
output.append(hexdata);
|
|
|
|
output.append(ansidata);
|
|
|
|
if(offset >= hexEdit.state.length) break;
|
|
|
|
if(row != hexEdit.state.rows - 1) output.append("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_text_buffer_set_text(textBuffer, output, -1);
|
|
|
|
if(position == 0) position = 10; //start at first position where hex values can be entered
|
|
|
|
setCursorPosition(position);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHexEdit::constructor() {
|
|
|
|
gtkWidget = gtk_hbox_new(false, 0);
|
|
|
|
|
|
|
|
container = gtk_scrolled_window_new(0, 0);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(container), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
|
|
|
|
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(container), GTK_SHADOW_ETCHED_IN);
|
|
|
|
|
|
|
|
subWidget = gtk_text_view_new();
|
|
|
|
gtk_text_view_set_editable(GTK_TEXT_VIEW(subWidget), false);
|
|
|
|
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(subWidget), GTK_WRAP_NONE);
|
|
|
|
gtk_container_add(GTK_CONTAINER(container), subWidget);
|
|
|
|
g_signal_connect(G_OBJECT(subWidget), "key-press-event", G_CALLBACK(HexEdit_keyPress), (gpointer)&hexEdit);
|
|
|
|
|
|
|
|
scrollBar = gtk_vscrollbar_new((GtkAdjustment*)0);
|
|
|
|
gtk_range_set_range(GTK_RANGE(scrollBar), 0, 255);
|
|
|
|
gtk_range_set_increments(GTK_RANGE(scrollBar), 1, 16);
|
|
|
|
gtk_widget_set_sensitive(scrollBar, false);
|
|
|
|
g_signal_connect(G_OBJECT(scrollBar), "change-value", G_CALLBACK(HexEdit_scroll), (gpointer)&hexEdit);
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(gtkWidget), container, true, true, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(gtkWidget), scrollBar, false, false, 1);
|
|
|
|
|
|
|
|
textBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(subWidget));
|
|
|
|
textCursor = gtk_text_buffer_get_mark(textBuffer, "insert");
|
|
|
|
|
|
|
|
gtk_widget_show(scrollBar);
|
|
|
|
gtk_widget_show(subWidget);
|
|
|
|
gtk_widget_show(container);
|
2011-09-05 03:48:23 +00:00
|
|
|
|
|
|
|
setColumns(hexEdit.state.columns);
|
|
|
|
setRows(hexEdit.state.rows);
|
|
|
|
setLength(hexEdit.state.length);
|
|
|
|
setOffset(hexEdit.state.offset);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHexEdit::destructor() {
|
|
|
|
gtk_widget_destroy(scrollBar);
|
|
|
|
gtk_widget_destroy(subWidget);
|
|
|
|
gtk_widget_destroy(container);
|
|
|
|
gtk_widget_destroy(gtkWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHexEdit::orphan() {
|
|
|
|
destructor();
|
|
|
|
constructor();
|
2011-02-24 09:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned pHexEdit::cursorPosition() {
|
|
|
|
GtkTextIter iter;
|
|
|
|
gtk_text_buffer_get_iter_at_mark(textBuffer, &iter, textCursor);
|
|
|
|
return gtk_text_iter_get_offset(&iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool pHexEdit::keyPress(unsigned scancode) {
|
|
|
|
if(!hexEdit.onRead) return false;
|
|
|
|
|
|
|
|
unsigned position = cursorPosition();
|
|
|
|
unsigned lineWidth = 10 + (hexEdit.state.columns * 3) + 1 + hexEdit.state.columns + 1;
|
|
|
|
unsigned cursorY = position / lineWidth;
|
|
|
|
unsigned cursorX = position % lineWidth;
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
if(scancode == GDK_Home) {
|
2011-02-24 09:27:21 +00:00
|
|
|
setCursorPosition(cursorY * lineWidth + 10);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
if(scancode == GDK_End) {
|
2011-02-24 09:27:21 +00:00
|
|
|
setCursorPosition(cursorY * lineWidth + 10 + (hexEdit.state.columns * 3 - 1));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
if(scancode == GDK_Up) {
|
2011-02-24 09:27:21 +00:00
|
|
|
if(cursorY != 0) return false;
|
|
|
|
|
|
|
|
signed newOffset = hexEdit.state.offset - hexEdit.state.columns;
|
|
|
|
if(newOffset >= 0) {
|
|
|
|
hexEdit.setOffset(newOffset);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
if(scancode == GDK_Down) {
|
2011-02-24 09:27:21 +00:00
|
|
|
if(cursorY != hexEdit.state.rows - 1) return false;
|
|
|
|
|
|
|
|
signed newOffset = hexEdit.state.offset + hexEdit.state.columns;
|
|
|
|
if(newOffset + hexEdit.state.columns * hexEdit.state.rows - (hexEdit.state.columns - 1) <= hexEdit.state.length) {
|
|
|
|
hexEdit.setOffset(newOffset);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
if(scancode == GDK_Page_Up) {
|
2011-02-24 09:27:21 +00:00
|
|
|
signed newOffset = hexEdit.state.offset - hexEdit.state.columns * hexEdit.state.rows;
|
|
|
|
if(newOffset >= 0) {
|
|
|
|
hexEdit.setOffset(newOffset);
|
|
|
|
} else {
|
|
|
|
hexEdit.setOffset(0);
|
|
|
|
}
|
|
|
|
update();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
if(scancode == GDK_Page_Down) {
|
2011-02-24 09:27:21 +00:00
|
|
|
signed newOffset = hexEdit.state.offset + hexEdit.state.columns * hexEdit.state.rows;
|
|
|
|
for(unsigned n = 0; n < hexEdit.state.rows; n++) {
|
|
|
|
if(newOffset + hexEdit.state.columns * hexEdit.state.rows - (hexEdit.state.columns - 1) <= hexEdit.state.length) {
|
|
|
|
hexEdit.setOffset(newOffset);
|
|
|
|
update();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
newOffset -= hexEdit.state.columns;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//convert scancode to hex nibble
|
|
|
|
if(scancode >= '0' && scancode <= '9') scancode = scancode - '0';
|
|
|
|
else if(scancode >= 'A' && scancode <= 'F') scancode = scancode - 'A' + 10;
|
|
|
|
else if(scancode >= 'a' && scancode <= 'f') scancode = scancode - 'a' + 10;
|
|
|
|
else return false; //not a valid hex value
|
|
|
|
|
|
|
|
if(cursorX >= 10) {
|
|
|
|
//not on an offset
|
|
|
|
cursorX -= 10;
|
|
|
|
if((cursorX % 3) != 2) {
|
|
|
|
//not on a space
|
|
|
|
bool cursorNibble = (cursorX % 3) == 1; //0 = high, 1 = low
|
|
|
|
cursorX /= 3;
|
|
|
|
if(cursorX < hexEdit.state.columns) {
|
|
|
|
//not in ANSI region
|
|
|
|
unsigned offset = hexEdit.state.offset + (cursorY * hexEdit.state.columns + cursorX);
|
|
|
|
|
|
|
|
if(offset >= hexEdit.state.length) return false; //do not edit past end of data
|
|
|
|
uint8_t data = hexEdit.onRead(offset);
|
|
|
|
|
|
|
|
//write modified value
|
|
|
|
if(cursorNibble == 1) {
|
|
|
|
data = (data & 0xf0) | (scancode << 0);
|
|
|
|
} else {
|
|
|
|
data = (data & 0x0f) | (scancode << 4);
|
|
|
|
}
|
|
|
|
if(hexEdit.onWrite) hexEdit.onWrite(offset, data);
|
|
|
|
|
|
|
|
//auto-advance cursor to next nibble/byte
|
|
|
|
position++;
|
|
|
|
if(cursorNibble && cursorX != hexEdit.state.columns - 1) position++;
|
|
|
|
setCursorPosition(position);
|
|
|
|
|
|
|
|
//refresh output to reflect modified data
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHexEdit::scroll(unsigned position) {
|
|
|
|
unsigned rows = hexEdit.state.length / hexEdit.state.columns;
|
|
|
|
if(position >= rows) position = rows - 1;
|
|
|
|
hexEdit.setOffset(position * hexEdit.state.columns);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHexEdit::setCursorPosition(unsigned position) {
|
|
|
|
GtkTextIter iter;
|
|
|
|
gtk_text_buffer_get_iter_at_mark(textBuffer, &iter, textCursor);
|
|
|
|
|
|
|
|
//GTK+ will throw many errors to the terminal if you set iterator past end of buffer
|
|
|
|
GtkTextIter endIter;
|
|
|
|
gtk_text_buffer_get_end_iter(textBuffer, &iter);
|
|
|
|
unsigned endPosition = gtk_text_iter_get_offset(&iter);
|
|
|
|
|
|
|
|
gtk_text_iter_set_offset(&iter, min(position, endPosition));
|
|
|
|
gtk_text_buffer_place_cursor(textBuffer, &iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHexEdit::setScroll() {
|
|
|
|
unsigned rows = hexEdit.state.length / hexEdit.state.columns;
|
|
|
|
if(rows) rows--;
|
|
|
|
if(rows) {
|
|
|
|
gtk_range_set_range(GTK_RANGE(scrollBar), 0, rows);
|
|
|
|
gtk_widget_set_sensitive(scrollBar, true);
|
|
|
|
} else {
|
|
|
|
gtk_widget_set_sensitive(scrollBar, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHexEdit::updateScroll() {
|
|
|
|
unsigned row = hexEdit.state.offset / hexEdit.state.columns;
|
|
|
|
gtk_range_set_value(GTK_RANGE(scrollBar), row);
|
|
|
|
}
|
2013-03-15 13:11:33 +00:00
|
|
|
|
|
|
|
}
|