Commit Graph

213 Commits

Author SHA1 Message Date
byuu def86470f4 Update to bsnes v040 release.
Too much to really name. The biggest news is that the entire user interface has been re-written from scratch. It is now far more polished and professional. To name one example; the cheat code editor now has checkboxes in the list to quickly toggle codes on an off, there is now a global hotkey to toggle all cheat codes, and each cheat code can contain multiple individual Game Genie or Pro Action Replay codes, allowing easy grouping of multi-part codes.
You'll also notice new artwork: a logo created by Derrick Sobodash (note that the logo contest from below is still active — if someone can design a better logo, it can appear in v041), and a new photo-realistic SNES controller graphic by FirebrandX.
I was finally able to utilize MinGW's profile-guided optimizations, which means this release is approximately ~12% faster than v039.
And emulation itself was even improved(!), such as with Jonas Quinn's fix for a sprite overflow bug.
There were many other changes as well: Linux users will be happy to see RGB overlay support for the X-Video driver, many will benefit from greatly enhanced warning messages and tooltips throughout the GUI, Windows users will now be able to access the menu without freezing emulation, etc etc.
2009-03-09 15:17:32 +00:00
byuu 3e7578761a Update to bsnes v039r22? release.
New WIP.

Softened the panel titles a lot, they take less space but still stand
out well enough.

Should I add a checkbox+global hotkey to toggle the cheat code system
itself on and off? Ala the flip switch that's on the real Game Genie.
Not sure if it's as important anymore now that it's easy to group
multiple cheat codes together and toggle them with just one checkbox.
If so, I need a caption for the checkbox widget, eg "Enable cheat code
system", but something more descriptive.

Rewrote a couple chunks of the nall::string library. I had a lot of
problems with casting due to things like this:
    int strdec(const char*);
    string strdec(int);
    string::operator int();
    string::operator const char*();
    string::operator=(int);
    string::operator=(const char*);
    string::operator<<(int);
    string::operator<<(const char*);
    string::string(int);
    string::string(const char*);


It couldn't implicitly determine if string() << 0 should refer 0 as
const char* or int. So I started by dropping the string->integer
implicit conversions, no need for those, use the strTransform(string)
functions instead. More verbose of the format you want anyway (eg
signed or unsigned integer).

Next, rather than try and implement signed+unsigned+signed
short+unsigned short+signed char etc etc for string::operator= +
string::operator<<, I instead wrote them to use templates. Worked
around the limitation that classes can't use explicit template
specialization by using global thunk functions. operator<<, operator=
and lstring::operator<< all share one set of template specialization
functions to perform conversion of any supported type to a string for
assignment or appending. Pass an unsupported type and it will throw a
"template function undefined" error and fail to compile. No run-time
surprises.

I was careful to implement the copy constructor and copy operator= to
stop the compiler from generating its own functions that copy around
the raw pointer (which would lead to memory leaks + double memory
frees.) So it should be 100% leak proof.

I also split strdec(int) into strsigned(signed) and
strunsigned(unsigned); and updated all the other stuff that used the
lib for that (eg nall::config et al), so you can now perform
unsigned->string conversions on UINT_MAX without getting back -1.

Only thing I'm debating now is if I want to trade C compatibility for
speed and store the string lengths inside the string class for O(1)
length + append functions, compared to their O(n) now. Multiple
chained appends raise that to O(n^2), but with ~20 appends at most per
string, it's hardly a bottleneck right now.

I'm hesitant to do this, because if I do, I'll have to remove char*
operator()() to give a raw handle to the string pointer. I use that
for quick libc const char*->string& wrapper functions, and it's also
nice for other functions to use. And char& operator[](size_t) would
take a hell of a speed hit for having to check for '\0' writes to
adjust the length internally.

_Not_ going to allow storing '\0' directly ala std::string, and make
string::c_str() require memory allocation. Fuck that. Use an
appropriate binary container if you want '\0' inside a block of
memory. The whole idea of nall::string is to maintain 100%
compatibility with C89 strings and their functions.

[No archive available]
2009-03-05 11:48:00 +00:00
byuu 45feae8f75 Update to bsnes v039r21? release.
New WIP.

I added FirebrandX's controller image (let me know if you don't have
the WIP link and want to check it out, FB.)

I also added Derrick's SVG logo for now. The contest thing isn't over
yet, and I like DMM's the best so far (sans the aliasing issues.) But
the auto-resizing to exactly what I want is too nice to pass up. I
think I'm going to require SVG for the final submission at this point.
Side note: Qt supports SVG for auto-scaling, but I use a PNG anyway as
not all Qt libs are going to have SVG support built-in. I still want
SVG for website / print purposes.

For belegdol, I added SDL hat support. It only works with the first
hat, as I figured those four-controller-as-one-device cheapass drivers
might not work well if every single players' hat manipulates the same
controller. You'll have to let me know how it works, since SDL doesn't
detect my joypad's hats.

I'd also like it if someone could test the X-Video RGB support. Anyone
with an RGB overlay surface can do so just by selecting the Xv driver.

[No archive available]
2009-03-01 11:09:00 +00:00
byuu 4d10c36870 Update to bsnes v039r20? release.
New WIP. This one's available here:
http://byuu.cinnamonpirate.com/temp/bsn ... ip.tar.bz2
http://byuu.cinnamonpirate.com/temp/qtdlls.zip

Please don't distribute to other news sites.

You will need to extract the Qt run-time DLLs into the same folder as
the bsnes executable. And you'll likely need WinRAR or 7-zip to
extract the WIP archive.

Please report any issues you can find that weren't present in v039.
I'd like for v040's release to be as bug-free as possible.

Changes from wip19:

The new 'current directory' caching mechanism was caching _after_ save
RAM load, so it wasn't loading save files correctly on first run.
Fixed.

I wasn't setting the internal renderer to match the requested video
mode, so PAL mode wasn't showing the extra scanlines. Fixed.

Had to add a 50ms (very conservative) delay when toggling fullscreen
mode to give Xorg enough time to complete the request. Before it was
trying to query the window size too soon and not fully expanding
fullscreen video to fit the screen. Because of this added delay, I
made it clear the video output when toggling modes. Can't help the
slight line redrawing issue in Qt. Not a bug in my code there.

After reading FitzRoy's comments and thinking more about it myself,
I've decided against the 'intelligent' fullscreen auto-menu hide.
Sorry. It'll still remember whether you were in fullscreen mode on the
last run, but the menubar is always visible by default now. It doesn't
change your menu visibility when you toggle fullscreen anymore.

I also added back the aspect adjust settings to the config file. This
time I combined them to floating point values. So instead of the old:
video.ntsc_aspect_x = 54
video.ntsc_aspect_y = 47
You now have:
video.ntscAspectRatio = 1.14893617

It's an advanced feature not in the GUI, so I expect you to know how
to compensate for the 256x224 vs your native monitor's resolution if
you screw with that setting. Maybe someone can make a web script to
calculate it ala those Xorg modeline generators or something.

Lastly, I removed the group boxes. Took advantage of every row having
three options but one, and added a spacer to get everything aligned.
Advanced panel looks a lot better now.

[No archive available]
2009-02-25 12:32:00 +00:00
byuu cca8164005 Update to bsnes v039r19? release.
New WIP.

- added hardware settings group to advanced panel. Lets you control
hardware region and base unit.
- added descriptive tooltips to video and audio settings.
- revised documentation to list filetypes, mention BS-X issues and
generalize unsupported special chip notes
- improved handling of paths: core now keeps track of cartridge path
rather than relying on the current working directory; export data path
now works the same as SRAM / cheats / etc when not selected
- fixed XvRGB15/16 blue color channel glitch; testing would be much
appreciated
- I now set the drivers to "None" when they fail to initialize and
give a warning. Before the app would just crash on cart load if this
failed
- added more options to the config file: allow invalid input, analog
axis resistance, and for the first time ever -- CPU, PPU1 and PPU2
version configuration

Really not happy with the overall look and feel of the advanced panel.
I don't think the group boxes are working there. Also, the filetype
descriptions are very terse, but I like them that way. Don't really
care if someone doesn't know what 'non-volatile' means, that's why god
made Google. Complain and I'll make the complex terms hyperlinks to
Wikipedia :P

I'll look into the fullscreen menubar thing again in a few days or
something.

> The Cpu and DMA approach is the same like in bsnes. The exception
> are the stp and wai opcodes.


Heheh, I bet someone looking at STP without being aware of how the
cothreads work would gasp in horror :D

> You are right it's really hard to jump back from doing a nested hdma
> transfer within a dma. But with my approach such an action is not
> needed.


Yeah, I know it's possible with enslavement to only make the simpler
processor a state machine. In our case, the S-SMP. That's how SNEeSe
does it. I just really hate the idea of enslavement.

I can certainly see why others get so upset with me on this, but
having each module cleanly separated is, to me, more important than
savestates. That it's somewhat faster here is just an added bonus. I'm
sure you can appreciate my S-SMP op_*.b files over those state
machines for maintenance, too ;)

As for your work on rewriting all the S-SMP opcodes, I wish you
would've mentioned this to me earlier ... the cycle labels in those .b
files are used to create the exact same switch(cycle) {} code you
wrote automatically, you just have to use a different generator. Given
I dropped that generator back at ~v017, it should be easy to update /
rewrite. The downside is that they don't directly support the bus hold
delays.

Still overall, really really impressive stuff. Kudos on making
something so cool :D

[No archive available]
2009-02-23 13:45:00 +00:00
byuu 0f83e39d5c Update to bsnes v039r18? release.
New WIP.

Added fix for OAM Yflip overflow bug pointed out by Jonas Quinn.

Re-added QGroupBox controls as per discussion with jensbw, the frame
issue should be fixed with Qt 4.5.

Config file now omits " #" marker when there is no item description.

Main window resizes itself a bit better before showing itself on Linux
for the first time. Not a problem at all on Windows.

Using _wgetcwd instead of getcwd for Windows UTF-8 support.

Finished Cartridge class revisions: load_foo returns boolean success,
unload() doesn't need one so that was removed, dropped redundant
bsx_cart_loaded() as you can tell via mode() == ModeBsx. Still need
bsx_flash_loaded() for register mapping purposes.

Fixed hiro port to compile again.

I also rewrote much of the Xv driver. It now properly finds modes via
XvListImageFormats(), and I added support for more modes. It used to
be YUY2 only, now it supports RGB32, RGB24, RGB16, RGB15, YUY2 and
UYVY (chooses the driver mode in that order.)

Unfortunately I was only able to test YUY2 and UYVY with my driver, so
no idea if the RGB modes even work or not. I know RGB16/RGB15 will
have problems, forgot to mask the blue channel before uploading: for
line 344 and 359, (p >> 3) needs to be ((p >> 3) & 0x1f).

To test each mode, the optimal ones would have to be manually disabled
since there's no external way to select the preferred driver. And the
RGB32 copy is sub-optimal, I'll probably allow direct rendering to its
surface in a future revision.

[No archive available]
2009-02-22 11:22:00 +00:00
byuu ebbcc998d0 Update to bsnes v039r17? release.
New WIP. Posted only for the sake of testing for regressions.

The only real change was adding nall::property as discussed earlier,
and completely revamping the Cartridge class with it. Results:
http://byuu.cinnamonpirate.com/temp/cartridge.hpp

Compared to the old version, it's night and day. All stuff that can be
hidden has been, end-user can't screw with important internal-settings
while emulation is active, as many functions as possible were made
const, ditched char* stuff to replace with string, removed a few
useless structs, simplified the public interface, replaced a memory
duplication in the cart loader that removes the header with a
memmove() instead, blah blah blah.

If I screwed any of this up, it may break the following:
- special chip detection
- RAM / PSRAM / RTC data saving
- UPS patching
- cheat code loading
- relative path stuff
- etc

[No archive available]
2009-02-21 10:39:00 +00:00
byuu 78da6946c6 Update to bsnes v039r16? release.
New WIP. Sorry about the delay in adding your .desktop file, belegdol.
I appreciate you sending it to me.

- worked around a cursor bug in Qt/Xlib: if you started the app and
your mouse cursor was on top of where the window appeared, it gave you
the "resize window" grip cursor, and it would stay like that. The
resize function now ensures you always get the normal cursor.
- worked around a bug in Qt/QGtkStyle: if you pass a default path of
"", it throws all kinds of errors at you on the terminal window, I
implemented a current working directory system for both folder path
selection and file selection (when no default game path is selected.)
It starts in your program startup directory (via getcwd()), and will
update whenever you choose a valid file or folder without canceling
the window.
- icon is now stored in $(prefix)/share/pixmaps instead of
$(prefix)/share/icons
- added belegdol's bsnes.desktop. If I can figure out how to get the
one from Derrick, his has stuff that makes it auto-suggest bsnes for
.SFC files and such. I'll probably add his extensions to it later.
This file installs to $(prefix)/share/applications, and bsnes shows up
under 'games' now.
- updated src/cart a bit, merged some 5x ~800 byte files to a general
cart_loader.cpp file, renamed the functions to be clearer:
cartridge.load_cart_bsc() -> cartridge.load_bsx_slotted();
cartridge.unload_cart_st() -> cartridge.unload_sufami_turbo();

- resized HTML viewer, was too small before, but I think it's too wide
now, meh.
- readme was renamed to documentation. I don't care that it's not
verbose enough to warrant the name right now. I intend to expand upon
it in the future and have it be the general sort of "help"
functionality, hence the name change.
- both the documentation and license are now stored inside src/data as
HTML files. These are embedded with Qt's resource compiler into the
final binary. Easier to edit, and the HTML files can stand on their
own.
- I've partially revamped the documentation. It's somewhat of a
compromise between my ideas and FitzRoy's. I may expand on it a bit,
but I like how it is now, so don't expect many more changes there
please.
- Revamped the license stuff a good deal, removed a lot of cruft.
Grant of Rights section remains the same, so no legal changes.

> bsnes could detect the computer's time zone, and switch to purple if
> necessary.


The US SNES is an eyesore. Both the console and especially the
controller. Fuck it, if they want to see that they can look it up on
Google Images :P

[No archive available]
2009-02-17 12:56:00 +00:00
byuu 4d31452bca Update to bsnes v039r15? release.
Okay, new WIP. To my knowledge, the Qt port now matches or exceeds the
feature-set / quality of the hiro port in every regard, sans things
I've intentionally removed.

- added back all the UI shortcut keys
- started using Qt's resource compiler, rcc, to embed files into the
binary on all platforms; not as efficient as my base56+LZSS method,
but much more standardized and avoids string length limits in Visual
C++
- Linux port now sets the program icon from bsnes.png @ 48x48 (any
larger and the filtering makes it look bad)
- Windows port uses embedded 16x16, 32x32, 48x48 or 256x256 icon as
before
- all windows now rise to the top when they are shown
- replaced about screen -- it's just a placeholder for now so that
it's not modal. Want to put the logo on there, with the rest of the
info and a webpage link below
- removed 'Ok' button from document viewer window
- killed icon48.h and controller.h, ~100kb worth of source. Right now,
hiro port shows black boxes in their place. I'll do something nice
with it later; but I don't want to grow the source that big for the
non-standard target
- added .zip, .gz and .jma to filter, based on compilation flags

Thinking about killing src/data, putting the necessary stuff in each
platform folder. Just a slight issue with windres taking a relative
path to the working directory, so it won't allow easy renaming of the
ui folder names if I do that. Can work around it with 'cd' command in
the Makefile, I suppose.

Would be nice to take advantage of rcc a bit more: it's very easy to
use 16x16 / 32x32 icons inside the UI for eg menu and config panel
list icons. Just going to be tough to make nice icons for them.

Stuff removed from hiro:
- controller graphic:
I love this graphic and want to have it in the official binary, but it
looks really odd when it's only there for one controller type ...
should we keep it anyway? If so, I'll embed it with rcc.
- trace logging hotkeys:
Want to replace these with a real debugger that will have buttons for
them. That will be a long-term goal, of course. May add shortcut keys
for the debugger functions too at that time.
- frameskipping:
Probably the biggest one, I didn't want to re-add this as the new PPU
will make it pointless anyway. If we do add this back for the fast
PPU, I'll probably keep the option hidden from the UI side.

> SFT was the acronym used for the catalog codes. For example, Poi Poi
> Ninja World had SFT-0103 on the cartridge. So there is some historic
> precedent for it at least. BSX, not so sure, but I figured
> everything else was three letters.


Sounds good, but I'd like to check with Nach first. He seems to be on
extended leave at the moment.

> Exhaust Heat 2 still bug out


Wasn't aware ST-0010 had any problems. Not sure if it's bit-perfect or
not anymore, but it definitely has no DSP timing.

[No archive available]
2009-02-15 08:23:00 +00:00
byuu eb1eca4a6d Update to bsnes v039r14? release.
Okay, another new WIP.

Drag-and-drop is in, and it works in Windows and Linux. Tested with
Thunar under Xfce, but it should be fine with any freedesktop.org-
compatible app/WM.

Worked around the Qt bug ... either
qtreewidget->currentItem()->isSelected() returns the true current item
and the Xlib port has a bug, or it returns the previous and the
Windows port has a bug. I'm using
qtreewidget->selectedItems().count()==1 in its place. Works on Windows
and Linux, so the cheat editor should be fine now.

Forgot to add assign / unassign key disable in the last WIP, so I took
care of that this time.

Added back the readme and license viewers. Used QTextBrowser, which
lets me use HTML formatting plus anchor hyperlinks. Not terribly
useful with such small documents, but meh. We can grow "readme" into
"documentation" in the future. Maybe even add a section listbox on the
left ala CHM files. Throw in a custom CSS stylesheet to make it
prettier. Whatever, not worried about it right now, but we'll get it
ironed out before v040 official.

Got too tired (Red Bull having no effect either), forgot to add the
.zip,.gz,.jma file extensions; and didn't check if cheat codes are
saving on Linux. Also need to work on getting window show commands to
put the windows in the foreground. If they're already visible, they
aren't raising to the top / gaining focus.

Still need to add a bunch of GUI hotkey bindings back, and I think
that'll do it for the rewrite. From there it's all adding stuff the
hiro port lacked.

[No archive available]
2009-02-14 10:05:00 +00:00
byuu 07c9df31a6 Update to bsnes v039r11? release.
Finally, a new WIP.

I redid the spacing / margins on all windows, it should match the old
bsnes/hiro port better now.

Removed all instances of QGroupBox, to work around the problem with
QGtkStyle ignoring the frame entirely, as well as getting around the
ridiculously large margin-top in it that you can't remove. Using
horizontal spacers in its place. Quite a bit more annoying to code
for, but it looks better than even the working frame, at least in my
opinion.

Modified the config panel listbox trigger to use currentRowChanged()
instead of itemSelectionChanged(). This fixes an annoying glitch where
if you clicked down on an item and dragged the mouse, it'd be off-by-
one in the list.

The code editor and cheat code panel both disable buttons when actions
aren't allowed, ala bsnes/hiro. There seems to be a bug in
QTreeWidget::itemSelectionChanged() on Linux, the returned
QTreeWidgetItem::isSelected() value is inverted. Too tired to work
around that tonight.

Improved automatic window resize for the input config and ROM add-on
cart loader windows. They should fully shrink as much as possible now,
rather than leaving blank space.

Dropped the Segoe Print font for titles, as it only looks good on
Vista+.

Removed the sort stuff from the cheat core class and hiro UI, since
the Qt UI can sort by header clicks.

Scale Nx items are checked again according to config file setting.

Stuff left to do:
- work around Qt/Linux bug on edit/delete enable on cheat code panel
- cheat codes don't seem to be saving to disk
- need to re-add screensaver disable code

FitzRoy, it's hard to show you the Qt rendering issues on GNOME, if
you're not familiar with how it should look ...

http://byuu.cinnamonpirate.com/temp/clearlooks.png
http://byuu.cinnamonpirate.com/temp/qgtkstyle.png

Clearlooks is the KDE default style. Looks good, but doesn't match
GTK+ apps.

QGtkStyle is the Qt wrapper that tries to use your GTK+ theme. Biggest
annoyance would be the buttons. There's this red box in the middle
that shows up when a button has focus. With the real GTK+, the entire
button turns red (no border) when you click it, but with just focus
alone it shouldn't have any color. The fonts are also much uglier,
like it has really poor anti-aliasing and slightly wrong sizes.

[No archive available]
2009-02-13 08:20:00 +00:00
byuu c64232a479 Update to bsnes v039r10? release.
New WIP adds a ton of refinement.

I feel it's exceeded the old UI in quality already, so I added the
platform-functions (realpath, userpath, ...), so now it'll look for
the multi-user config file, falling back on single-user. If you use an
old config, most settings from v039 will be lost, but some will be
pulled in. It now looks for bsnes.cfg and style.qss (for theming.)
Slight issue with relative paths and realpath() on Linux. New
initargs() function adds back support for non-ANSI paths.

Path window shows <startup path (/path/used)> rather than just
<startup path>.

All buttons trigger on release (mouse up / off) rather than press
(mouse down).

Revamped the centering code. All windows respect the reserved screen
areas (taskbar, dock, etc) and center perfectly. They only center on
the first show, after that they will remember where you placed them.

Completely rewrote the windowed / fullscreen handling code. It works
properly even on Linux now. Scale max is great, perfect fit to the
edges of your screen sans reserved areas. If menu+status toggle are
bound to the same key, it'll only refresh the window once to reflect
the new state now.

Going back to the forced size thing. I need to re-add the menu checks.
You can't shrink the window smaller than your current settings, and if
you make it bigger, you get black borders (since I can't disable the
resize reliably on all platforms.) Makes more sense this way anyway,
the menu options should reflect what you see, not what the startup
state is.

It remembers the fullscreen setting automatically now. I took it a bit
further, though. If you have no ROM loaded, it will show the
menu+status in fullscreen to alert you there's no cart and give you a
chance to select one. I also re-added command-line loading, and if you
successfully load a game there, it will turn off the menu+status for
you. There was a slight delay there. You see, loading a game calls
snes.init() which needs the interface (video, etc drivers) setup.
Those drivers rely on the UI being created. So we have to make the UI,
setting the menubar visibility, before we can verify that we're going
to load a game.

_Yes, I can work around this!_ Add a first-run boolean and validate
the command-line path is valid, or separate cart load from SNES init
so I can load, setup GUI then start, etc etc. It's just annoying, not
sure if it's worth the effort to hide the menubar 2ms sooner.

ROM slot loader and cheat path windows now both disable buttons when
no cart is loaded. Major work in progress, lots of stuff left to do
here. When you pick a file with the ROM loader, it doesn't steal focus
to the main window anymore. When you pick a path, it clears the audio
buffer to prevent audio looping. Not sure if I want to hook move /
resize events, since Linux doesn't block as much as Windows. Maybe
I'll #ifdef it.

Qt 4.4 has a bug with GTK+ file open, if you give it a blank path it
spits out lots of errors. It needs a fully-qualified path. Going to
make my old-style "remember last selected path" thing that I used in
hiro/gtk to fix it later.

[No archive available]
2009-02-05 11:23:00 +00:00
byuu 85b08fd24b Update to bsnes v039r09? release.
New WIP re-adds the multi-part ROM loader. For some reason that took
way too long, all I got finished.

A bit different this time, one window for all three modes (bs-x
slotted, bs-x and sufami turbo.) It auto adjusts based on what you
want. Much more compact now that I can put the labels on the same line
as the controls.

It otherwise works the same. In the future, I'll be adding a Date/Time
control when loading pure BS-X carts. Makes no sense adding it to the
UI before the core supports it.

> [X] Pause emulation when main window does not have focus
> [X] Ignore input when main window does not have focus


For the hundredth time, that creates four states instead of three.
What's the difference between pause on + ignore on and pause on +
ignore off?

I'll most likely use a QScrollArea to put a scrollbar on the right if
we end up with too many advanced options for one page.

[No archive available]
2009-02-03 09:05:00 +00:00
byuu 3b3214d1be Update to bsnes v039r08? release.
New WIP.

I guess we've tested the container resize enough, at least for
Windows. Set fullscreen container color to pure black.

To avoid the accidental mouse assignments from v039 and earlier, I
went with UI buttons to assign mouse axes / buttons. Keyboard and
joypads assign the same as before. The extra 1-3 buttons are for six-
button mice like my MX518.

Also re-added mouse capture: load a game, and have a mouse/scope set
as an input device, click in the window and it captures. Press escape
to release. I blocked mouse buttons without capture now, too. That was
allowing a fire shot to go through in previous versions without it
when you first gained focus.

Fixed up hiro/GTK+ to compile again. Should give GNOME/Xfce/Qt4.4
distro packagers some reprieve for a while. Not going to be improving
it anymore, though.

Qt/Linux now uses pkg-config, rather than hard-coded paths. No such
luck for Windows users. There's a Win port of pkg-config, but not many
will have it so the path to Qt will remain hard-coded.

Ditched a few more global nall::string functions (count, find,
(q)replace, (q)split) and moved them inside classes. Fixed the
resultant compile errors in bsnes, hiro and xkas.

The rest of the nall::string functions are also useful on char*
arrays, eg strtr, strlcpy, trim, etc; so it doesn't make a lot of
sense to put them inside the string class.

Not entirely impressed with how the code looks mixing class functions
and global functions, but meh. At least it will reduce mistakes in
trying to pass char*s to string-only functions like replace.

[No archive available]
2009-02-02 08:56:00 +00:00
byuu b5a38d2a07 Update to bsnes v039r07? release.
New WIP. Adds menubar/statusbar toggle, defaults fullscreen to max
scale with no menu/status (you can change the scale and it will
remember your settings in the future), and I re-added all the audio
panel options.

That leaves a few more GUI shortcut key assignments, mouse support +
binding, BS-X / ST ROM loaders, readme/license windows, and a few new
controls to replace the old Firefox-style advanced screen with
something more user-friendly. After that, the rewrite should be
complete.

Trying to move my string lib to a more OO-approach: removed overloaded
strcpy,strcat in favor of =,<< or .assign,.append. Will be trying to
remove more global functions (replace(foo -> foo.replace(, etc) in the
future. Taking it slow so I don't break xkas too badly.

I also want to shave as much excess functionality as I can from it.
Its main purpose is to be a streamable, implicit-castable alternative
to std::string with a few built-in special functions unique to my
needs (eg qsplit,qreplace.)

[No archive available]
2009-02-01 08:35:00 +00:00
byuu 94004f86ec Update to bsnes v039r06? release.
New WIP, looking for feedback on these changes.

First, I switched from a standard QWidget to a more semantically-
correct QMainWindow. Not much difference, except it adds an automatic
menubar and statusbar, no need to make my own. One advantage was free
status hint support without having to catch the event. So I took that
and redesigned the status system.

First, the game name on the status bar ate up too much space for
nothing. I moved it to the titlebar: bsnes v0.nnn - Game Title (U)

Second, I merged the FPS counter with the system state and put it on
the right-hand side of the status bar. It shows "No cartridge loaded",
"Power off", "Paused" and the framerate. This is persistent and always
visible. FPS doesn't show ideal FPS next to it anymore. That just
wastes space.

Third, the new left-hand stuff. It uses the native QStatusBar support
for timed messages. I use that to pump power state changes ("System
was reset.", "Loaded Star Ocean (J), and applied UPS patch.", etc.)
They go away after ~3 seconds. Unsupported special chip warnings now
pop up a modal dialog box instead of showing in the status bar.

Fourth, we can now set special menu group / item descriptions that
appear when the items are hovered. For instance, mouse over
settings->video mode->ntsc and it explains that the setting affects
the perceived video output size, rather than the core emulator mode.
The descriptions there now suck, but it shows off the concept. We'll
leave them off for all the obvious items.

With all of that, I was able to kill off the "Status" class, ~4kb of
nasty code that polled the time constantly and maintained an internal
string queue for statusbar messages.

Also new to this WIP ... it's apparently not trivial to set a fixed
window size with Qt on Xlib. My MinimizeWindowHint that worked on
Windows was making the window top-most on Xfce, and breaking
fullscreen mode.

So, I tried again to write code that could properly switch between
windowed and fullscreen mode. For some reason, this always causes tons
of problems. Window managers like to take their sweet ass time
updating internal states, so rapid geometry changes often fail,
leaving the window in odd positions and sizes.

It took quite a while, but I have it working, hopefully, 100% on
Windows. I even account for the desk area (ignoring the taskbar and
such) and the window decorations. Centering should be truly perfect,
and scale max should be a pixel-perfect fit to all available screen
size, while maintaining the ratio.

Linux support is still kind of flaky, though. Long shot, but any
knowledgeable help here would be appreciated.

    void Utility::updateFullscreenState() {
      if(config.video.isFullscreen == false) {
        config.video.context = &config.video.windowed;
        winMain->window->showNormal();
        application.processEvents();
      } else {
        config.video.context = &config.video.fullscreen;
        winMain->window->showFullScreen();
        application.processEvents();
      }

      //refresh options that are unique to each video context
      for(unsigned i = 0; i < 2; i++) resizeMainWindow();  //call
    twice as Xlib drops window messages sometimes
      updateHardwareFilter();
      updateSoftwareFilter();
    }

    //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;
      }
    }

    //0 = use config file value, 1+ = override with new multiplier
    void Utility::resizeMainWindow(unsigned multiplier /* = 0 */) {
      if(multiplier != 0) config.video.context->multiplier =
    multiplier;
      else multiplier = config.video.context->multiplier;

      unsigned width  = 256 * config.video.context->multiplier;
      unsigned height = (config.video.context->region == 0 ? 224 :
    239) * config.video.context->multiplier;

      if(config.video.context->correctAspectRatio) {
        if(config.video.context->region == 0) {
          width = (double)width * 54.0 / 47.0 + 0.5;  //NTSC adjust
        } else {
          width = (double)width * 32.0 / 23.0 + 0.5;  //PAL adjust
        }
      }

      QDesktopWidget *desktop = QApplication::desktop();

      if(config.video.isFullscreen == false) {
        //get effective desktop work area region (ignore Windows
    taskbar, OS X doc, etc.)
        QRect deskRect = desktop->availableGeometry();
        unsigned deskWidth  = (deskRect.right() - deskRect.left() +
    1);
        unsigned deskHeight = (deskRect.bottom() - deskRect.top() +
    1);

        //place window offscreen so resize events do not cause
    flickering
        winMain->window->move(desktop->width(), desktop->height());
        application.processEvents();

        //shrink window as much as possible to compute frame + menubar
    + statusbar size
        winMain->canvas->setFixedSize(0, 0);
        winMain->canvasContainer->resize(0, 0);
        application.processEvents();
        winMain->window->resize(0, 0);
        application.processEvents();
        QRect frameRect = winMain->window->frameGeometry();

        //constrain window so that it will fit inside desktop work
    area
        constrainSize(height, width, deskHeight - (frameRect.bottom()
    - frameRect.top() + 1));
        constrainSize(width, height, deskWidth  - (frameRect.right() -
    frameRect.left() + 1));

        //resize canvas to desired size
        winMain->canvas->setFixedSize(width, height);
        application.processEvents();

        //shrink window so that it contains all of canvas, but is no
    larger
        winMain->window->resize(width, height);

        //allow canvas to be resized along with window by user
        winMain->canvas->setMinimumSize(256,
    config.video.context->region == 0 ? 224 : 239);
        winMain->canvas->setMaximumSize(desktop->width(),
    desktop->height());
        winMain->canvas->setSizePolicy(QSizePolicy::Expanding,
    QSizePolicy::Expanding);
        application.processEvents();

        //force window size change to take effect
        winMain->window->resize(width, height);
        application.processEvents();

        //center window onscreen:
        //take desktop work area and window frame decorations into
    account
        QRect windowRect = winMain->window->frameGeometry();
        unsigned windowWidth  = (windowRect.right() -
    windowRect.left() + 1);
        unsigned windowHeight = (windowRect.bottom() -
    windowRect.top() + 1);

        winMain->window->move(
          deskRect.left() + (deskWidth  - windowWidth ) / 2,
          deskRect.top () + (deskHeight - windowHeight) / 2
        );
      } else {
        constrainSize(height, width,
    winMain->canvasContainer->size().height());
        constrainSize(width, height,
    winMain->canvasContainer->size().width());
        winMain->canvas->setFixedSize(width, height);
      }
    }


If anyone wanted to get stupid, a style for QWidget.backdrop {
background: url(border.png); } when designed for a specific resolution
+ scaling mode would allow Super Gameboy-style borders :P

Let's see ... properly subclassed the generic input binding pools for
clarity, and added user interface key binding support again. So far
only for exit emu + toggle fullscreen, but the rest should be easy
now.

I can't reduce the space for the QFrameWidgets. Only setMargin works,
but it reduces margins on all sides where only the top is bad. I may
have to revert it back to a section label + horizontal separator
between each area. Probably a good idea, QGtkStyle doesn't support
QFrameWidget's decoration anyway. Looks terrible on GNOME.

Finally, fixed ui_hiro for Windows. Still need to fix up the Linux
target. They share the same Makefile, so additional targets should be
easy, eg a pure SDL port or whatever.

> Darn. Oh well, guess I could keep whatever I concoct to myself.


Or tell me what you want to do, as I probably won't mind :P

[No archive available]
2009-01-27 07:24:00 +00:00
byuu 148bbddb1a Update to bsnes v039r05? release.
Man, I don't have time to read all that ... >_>;

New WIP. Lots of UI refinements.
- re-added power on / power off / reset to main menu (expansion port /
region won't be coming back here)
- re-added status message system
- figured out a way to hide the child indicators in list boxes, as
well as enable sorting while starting with default ordering (so
headers are now clickable to sort, you can even rearrange them)
- merged driver settings and input focus policy into advanced panel
- old advanced panel list is dead, driver panel is dead
- replaced scale 5x with scale max; minor help to 1920x1200+
resolutions
- re-added smart scaling + window size clamping
- Linux port should build out-of-the-box, but there's definitely some
issues in regards to window sizing (even Qt has trouble with this)
- new $(ui)/Makefile system -- as if I weren't abusing GNU make enough
before, new automoc rules are madness -- fear:
    # automatically generate .moc files from .hpp files whenever:
    # - they don't exist
    # - .hpp file was modified after .moc file
    %.moc: $<; $(moc) $(patsubst %.moc,%.hpp,$@) -o $@
    $(foreach object,$(moc_objects),$(eval $(object): $(patsubst
    %.moc,%.hpp,$(object))))
    ui_build: $(moc_objects);
    ui_clean:; -$(foreach object,$(moc_objects),@$(call
    delete,$(object)))

- lots of other crap

http://byuu.cinnamonpirate.com/images/b ... 090126.png

Now to update the locales for v039 finally ...

[No archive available]
2009-01-26 09:59:00 +00:00
byuu e5b2e87ff8 Update to bsnes v039r04? release.
Well that wore me out ... the UI went from 45kb to 109kb in one night,
with no copy/pasting.

New WIP:
- re-added the InputManager + InputDevicePool classes. The latter is
very complicated, but impressive
- re-added Input Configuration Editor
- re-added Cheat Code Editor
- re-designed individual cheat code editor
- re-added Path Editor
- stopped subclassing QWidget w/Q_OBJECT to work around Qt stylesheet
bug
- re-added controller port selections

Sorting by column header clicking is screwy. It has to be manually
enabled, and the second you do that it re-orders everything. This is
really bad when you want the default order, eg "up, down, left ..." or
your default cheat ordering; so I had to leave it off. Would be too
tacky to add a numeral ID column to work around that.

Seems Qt also has a ridiculously complex tree view (MVC-based), but
thankfully they added a simplified version that works well enough,
QTreeWidget. Only problem is I can't seem to make it hide the child
expander space at the very left-most side. This creates an annoying
little gap. Anyone know how to hide those with Qt?

Even got checkboxes inside the list to toggle cheat codes.
Documentation could've been clearer there.

Speaking of which, I was able to use child nodes on the cheat code
list to show each individual cheat code, but it just didn't look right
to me. There was a ton of blank space on the sides. I can actually
fill in multi-line descriptions as well here, but it still looks
really tacky in my opinion.

Thought about using add code + append code + delete code and putting
the textboxes back, but that just seems tacky and error prone, too.
I'm not adding individual descriptions for each code sub-part.

Only way I can think to make it work that way would be to replace the
multi-code method with a grouping affinity (eg group codes 1+3 into a
set), but then we're getting really complex, with a minimum of 5-6
buttons on the window and 3 text boxes. I think the learning curve
would be too high to be worth it.

So, I used the old method, but instead of a textbox to paste in codes,
I went with a slightly less error prone method of a textbox for the
description and a listbox for each code part. Threw in add / delete /
delete all for the code list. Takes a bit longer if you're trying to
copy/paste codes off the web, but the increased intuitiveness and
consistency is worth it in my opinion.

New cheat code editor (description typo due to extreme fatigue)

There's a lot of rough edges and few safety checks, so if you try to
break things you probably can.

Overall, really having fun with the Qt API. It can be awkward at
times, but it's definitely the most straight-forward API I've seen so
far.

[No archive available]
2009-01-25 08:16:00 +00:00
byuu 67318297dd Update to bsnes v039 release.
Changelog:
    - Recovered ~10% speed loss from last release via S-CPU IRQ timing optimizations
    - Implemented O(1) binary-heap priority queue for event scheduling
    - Fixed a bug where BS-X slotted carts were never mapping SRAM
    - Fixed a bug where invalid controller input was always being allowed
    - Fixed all compilation warnings with GCC 4.3 and Visual C++ 9.0
    - Added advanced options to control S-CPU ALU hardware delays
    - S-RTC and SPC7110 timers updated to handle time_t overflow (Y2k38) gracefully
    - Cheat codes can now have multiple codes per entry, and multiple lines per description
    - Rewrote config file parser; removed config/ class from emulator core
    - Windows: added 256x256 image to program icon set
    - Linux: fixed Xorg keysym mapping, key names should show correctly in all cases now
    - UI: updated video panel, added fullscreen-on-startup and NTSC merge fields options
    - UI: simplified audio panel
    - UI: boolean options on advanced panel can be toggled via double-click
    - Lots of code cleanup, especially for S-CPU IRQ handling and nall template library
2009-01-18 10:21:22 +00:00
byuu 1a6de37454 Update to bsnes v038r13? release.
<edit: removed outdated WIP>

**Delta queue support**

First up, I've added a binary min-heap delta queue. I converted all
events except IRQ/NMI test and hold. If we can convert these to use
the delta queue, there should be a speedup of 30-40% or so -- pretty
much the biggest low-hanging fruit there is. And the thing that has
plagued me for 12-18 months in the past before the major speed hit
v0.018 when I gave up and went with testing IRQ/NMI on every single
clock tick.

But it won't be easy: the delta queue works by adding an event when
you know its going to trigger. But we cannot _know_ if an IRQ or NMI
interrupt will trigger until we're at the current time. One can
literally disable or change these 2 clocks before they occur, which
would leave a bad trigger event in our queue.

IRQ/NMI hold also needs to be scheduled exactly four clocks after
IRQ/NMI trigger. Unless we queue these at least ~16 clocks in advance
of the trigger, then we may not be able to trip them exactly when
needed.

Since the test/hold are in the same inner loop, before or after the
delta queue time update, we can't just enqueue the hold and not the
test.

So, in the WIP I've included my insanely rigorous test ROMs for IRQ,
NMI and HDMA timing, and I'm asking for help. If anyone could please
help in merging sCPU::add_clocks() IRQ testing into the delta queue,
I'd be greatly in their debt.

Relevant code is at src/cpu/scpu/timing/[timing.cpp, irq.cpp] and
src/cpu/scpu/deltaqueue.cpp.

I'll be working on it as well, of course.

Note: removing events not at the top of the heap is not supported.
_If_ this is needed, it would probably be best to do an O(n) search
for the event, and overwrite the event code with 0 (meaning ignored)
than to try and pull out the event and renormalize the heap. IRQ/NMI
hold edge cases are very rare, so O(n) time shouldn't hurt speed.

**ALU delay**

Since there's no speed hit anymore, I added back hardware ALU (mul /
div) delays. While we still don't emulate the proper partial
calculation results, we should at least return 0 when reading too
soon.

The exact delay varies based upon the calculation, however. We ran
into problems with Taz-Mania in the past. So for this WIP only, I've
added settings to the advanced panel:
"temp.alu_mul_delay" + "temp.alu_div_delay"

The value has to be a _multiple of 2_ (2, 4, ... 32, 34, ...), and the
goal is to find the _highest_ possible value that will not cause any
bugs in games.

What I'm asking is for people to just set the value to something and
test a few games. If you spot a bug that's not in v038, try lowering
the value until it goes away. Then post the values here. We'll keep
lowering the current number until we find the best setting for future
releases.

Let's start with really high values that will definitely cause bugs:
ALU mul delay = 104
ALU div delay = 208

For example, pick any game ... say Zelda 3. Note how the triforces
won't render now. Lower the value until it works, post what numbers
you needed here plus the game name. Then everyone will use those
values and test other games. Rinse and repeat.

_Important note:_ you have to reset the game after changing these
values in the GUI for them to take effect.

**Fullscreen on startup**

I've added "video.start_in_fullscreen_mode". Because there's no way to
exit other than a keyboard shortcut, I've unhid the "Exit" option for
now. We can discuss the UI design stuff in the main v038 talk thread,
just stick to mentioning if you hit any bugs with it for this thread.

Thanks to all in advance for any help here!

[No archive available]
2009-01-02 12:01:00 +00:00
byuu de47a2c7de Update to bsnes v038r12? release.
New WIP adds nothing new, but fixes Visual C++ compilation issues.
Stopped windows.h from defining min/max again, disabled (bool)intmax_t
stupidity, added a default: so VC doesn't assume a function has a
blank return path, omitted -static on libco, and reverted to always
using windres over rc. Express Edition lacks rc, and you already need
GNU make anyway, so why bother supporting rc, too?

> Can you tell me what I should include?


It looks like the taskbar is only 32x32 ... yet the result looks
really weird. Almost like the .ico file only has a 1-bit transparency
mask or something :/

Image

As you can see, all the other icons look much sharper.

> I always wondered why the entire line of an entry doesn't highlight.


I have no idea ... don't see any other listview styles I can use
that'd highlight the whole thing :/

[No archive available]
2009-01-13 15:12:00 +00:00
byuu 25ad9701ab Update to bsnes v038r11? release.
New WIP.

- invalid input is blocked again when input.allow_invalid_input ==
false
- vertical scrollbar only appears when needed in multi-line textboxes
- cheat editor properly encodes / decodes quotes and line breaks
- advanced panel now allows double clicking boolean items to toggle
their state
- cleaned up all of the nall template library
- nall::array was missing copy constructor, causing swap/sort to fail
- moved start in fullscreen to advanced panel for now
- renamed most of the options FitzRoy asked for

> Invalid input is always allowed in bsnes. The config file option
> doesn't change that.


Thank you very much, that was a huge oversight.

> In the latest WIP I've notice Pro Action Replay codes aren't working
> anymore. For example, try these codes for Super Mario World (U);


Those work fine for me ... maybe try the next WIP?

> Here's a couple of boolean advanced options I'd like to see:

> misc.minimize_to_system_tray
> misc.run_at_system_startup


System tray control is probably something the GUI library needs
anyway, but its value is completely lost for Windows 7 -- the taskbar
works similar to the system tray + quick launch. In fact, by default
tray items are hidden and require you to go through a menu to get to
them.

Run at startup would be tricky. I could only get that working on
Windows, and it's really something the user should do externally. Drag
it to the startup folder, put it in the registry, use MS config,
whatever. Also seems very niche, no? You'd still have to load a game
for it to be useful.

> maybe the two file ones as well, not sure what use those have


One is for OS X users. Some of them don't understand file extensions.
The other is for ROM hackers. It'd be needed to multi-chain UPS
patches in the future, as well.

> I'd also like a minor change in the system menu: flip the power
> settings with the controller settings.


Why? Seems arbitrary, and I like the current ordering. We can even
make up some crazy stuff to support the current ordering:

1) Looking at an SNES from top to bottom, you have the cart slot, then
power / reset, then controllers.

2) Group options that affect carts, then group options that affect
input.

> Let me know when you're ready to talk about the readme overhaul.


Will probably release v039 next weekend. Can work on the readme for
v040, I guess.

[No archive available]
2009-01-12 14:44:00 +00:00
byuu 9a5a3b8246 Update to bsnes v038r10? release.
Probably a mapping issue. Wish we could've spotted it less than 21
versions ago, would've been easier to find the regression. Ah well, at
least we found it now.

New WIP completes the multi-part cheat codes. I changed the file
format, and it may change again, so backup your old .cht files first.

Went with the unified textbox thing to allow infinite number of codes
per cheat item, though the textbox itself will stop parsing after
1,024 bytes at the moment. Really ... you're doing something wrong if
you need more than ~120 parts for one cheat code entry.

It will parse and treat spaces, +&|,;{tab} and {linefeed} as
separators for codes. You will lose the space formatting after you
okay the code and go back to edit it again.

Also one glitch if you toggle cheat status, it won't clip the extra
cheat parts as it should. Will fix it later, ran out of time. Don't
try multi-line descriptions or commas for separators just yet. Need to
iron proof that so it won't corrupt the file format.

Any testing of this new feature would be greatly appreciated.

Design questions:

- should we change the order of desc/code/enablestate on either the
main cheat window or the cheat sub-editing window? If so, why? Be
verbose, use examples.
- should we change the .cht file format? Again, please clarify what
the advantage would be.
- should we change the text labels for the sub cheat editor to
something more clear?
- should the default separator be changed from " + " to something
else? Maybe linefeed?

[No archive available]
2009-01-09 16:18:00 +00:00
byuu daac76858b Update to bsnes v038r09? release.
Damn, absolutely loving this Aftershock I just picked up. Scary stuff
-- 80 proof and it tastes like a malt beverage.

New WIP, added the cheat code editor UI changes. The cheat code class
in the back-end still doesn't actually support multiple codes just
yet, but it will.

Image

Need to decide how many codes we should allow. A real Game Genie
didn't allow more than five, so I think we should go with either four
or six.

Also not shown, when a code you're editing is incomplete / bad,
there's a grayed out text label that appears on the right to tell you
that the code is invalid. It also disables the ok button during this
time.

I wouldn't try entering a multi-line description just yet. I don't
parse that at all. Worst case, it'll corrupt your cheat file. My plan
is to only show the first text line in the listbox, but allow extra
lines for more verbose comments.

I'm being lazy and disabling the add/edit/delete buttons from the main
window when the sub editor window is open. Prevents abuses like
deleting the code you're editing, then trying to update it.

[No archive available]
2009-01-06 15:58:00 +00:00
byuu c63df7e009 Update to bsnes v038r08? release.
Another WIP, but nothing visible to end users. Still get it if you
don't have 07 for the nice speedup.

Mostly source-cleaning stuff.
- removed 'uint' type, replaced all instances with the proper unsigned
int.
- removed as many headers as I could from the global interface.hpp
file, including only in the cores that need each of them. Should help
compile time. Though I still have a lot of global header includes due
to needing ultra-hot sections of code inlined.
- added include protection bumpers to the CPU+SMP opcode core
generated files
- added const-correctness to a few more classes.
- updated S-RTC and SPC7110 time to handle time_t overflow: it's now
Y2K38 proof even on 32-bit signed time_t systems, and the file format
remains unchanged. But it adds one limitation that you'll lose your
time if you wait ~34 years before loading your last save game. I think
that's reasonable for now. Once 64-bit time_t systems are ubiquitous,
we should be able to trivially expand that without breaking old saves.

Relevant code (I tested with int16_t, uint16_t, int32_t, uint32_t,
int64_t and uint64_t):

      time_t diff
      = (current_time >= rtc_time)
      ? (current_time - rtc_time)
      : (std::numeric_limits<time_t>::max() - rtc_time + current_time
    + 1);  //compensate for overflow
      if(diff > std::numeric_limits<time_t>::max() / 2) diff = 0;
    //compensate for underflow


Avoided the obvious (y-x)&<time_t>::max() just in case there's some
crazy platform where the value != (some power of 2)-1. Modulus
(max()+1) won't work there either, as it'll overflow if
sizeof(unsigned) == sizeof(time_t). The +1 might throw it off by a
second on one's complement system, but I don't really care :P

Anyone with GCC 4.3 want to try something for me? Try modifying
src/lib/nall/platform.hpp and change #define alwaysinline
__attribute__((always_inline)) to:
    #define alwaysinline __attribute__((always_inline))
    __attribute__((hot))


... and let me know the FPS difference you get in some arbitrary game,
please :D

It's supposed to be like manual-PGO.

[No archive available]
2009-01-05 12:33:00 +00:00
byuu 3908890072 Update to bsnes v038r05? release.
New WIP, this one's fairly big as nightlies go.

First, moved the priority queue to a generic implementation so I can
re-use it elsewhere in the future. Took a ~1% speed hit or so by using
functors for the callback and using the signed math trick to avoid the
need for a normalize() function. Sadly it gets up to 3% slower if the
priorityqueue class code isn't placed right next to the CPU core.

Second, while I failed miserably at using the queues for IRQ / NMI
testing, I did come up with a neat compromise. NMI is only tested once
per scanline, IRQs only have PPU dot precision (every 4 clocks), the
hold time for both is four clock cycles, and scanlines for both NTSC
and PAL, even on the short colorburst scanline, are always evenly
divisible by four.
... so testing every 2 clock cycles was kind of pointless, as it'd
always be false. Since the delays between the PPU counter and CPU
trigger for NMI is 2, and IRQ is 10, they even align again with an
offset of 2.
... hence, I can call poll_interrupts() half as often by using
if(ppu.hcounter() & 2). I reverse that for the Super Scope / Justifier
dot testing and cut their overhead in half as well.

That gives us a nice ~10-15% speedup. Nowhere near the idealistic
~30-40% for range tested IRQs, because that only actually tests once
per scanline (~1364 cycles). This just cuts ~682 tests down to ~341
tests. Still, it's pretty close to half as good while still being
super clean and easy. It greatly diminishes the value of a range-based
IRQ tester, as that will only offer a ~15-20% speedup now at best.
Getting PGO working again is the new lowest-hanging fruit.

I also eked out a tiny bit more speed by adding some previous missed
"else" statements in the irq_valid testing part.

With the newfound speed, I gave a tiny bit up (1-2%) to simplify and
improve some old edge cases. It's known that IRQs won't trigger on the
very last dot of each field. It's due to the way the V and H counters
are misaligned, that we can't easily emulate.

So before I had a bunch of cruft to support that, update_interrupts()
was called at the start of each scanline, which would call irq_valid()
to run a bunch of tests to make sure the latch positions would
actually work on hardware. Writes to $4207-420a would also call the
update_interrupts() proc.

I killed all that, and now compute the HTIME position inline in
poll_interrupts(), and perform the last dot check there. Since testing
is ten clocks behind anyway, then we need only check to see if VTIME >
0 and ppu.vcounter(-6 clocks) == 0 to know that it was set for the
last dot on any given field.

This gives us two nice perks for free: one, no more need to hard-code
scanlines/frame inside the CPU core; and two, the old version was
missing an edge case in interlace mode where odd fields would allow an
IRQ on the last dot, which was simply because my old irq_valid() test
didn't have a third condition for that.

All that said, I'm getting ~157.5fps instead of ~137.5fps now in Zelda
3.

Third, I removed grayscale/sepia/invert from the video settings panel,
and stuck them in advanced. Used the new space to add checkboxes for
NTSC merge fields and the start in fullscreen thing.

Reference:
    //called once every four clock cycles;
    //as NMI steps by scanlines (divisible by 4) and IRQ by PPU
    4-cycle dots.
    //
    //ppu.(vh)counter(n) returns the value of said counters n-clocks
    before current time;
    //it is used to emulate hardware communication delay between
    opcode and interrupt units.
    alwaysinline void sCPU::poll_interrupts() {
      //NMI hold
      if(status.nmi_hold) {
        status.nmi_hold = false;
        if(status.nmi_enabled) status.nmi_transition = true;
      }

      //NMI test
      bool nmi_valid = (ppu.vcounter(2) >= (!ppu.overscan() ? 225 :
    240));
      if(!status.nmi_valid && nmi_valid) {
        //0->1 edge sensitive transition
        status.nmi_line = true;
        status.nmi_hold = true;  //hold /NMI for four cycles
      } else if(status.nmi_valid && !nmi_valid) {
        //1->0 edge sensitive transition
        status.nmi_line = false;
      }
      status.nmi_valid = nmi_valid;

      //IRQ hold
      status.irq_hold = false;
      if(status.irq_line) {
        if(status.virq_enabled || status.hirq_enabled)
    status.irq_transition = true;
      }

      //IRQ test (unrolling the duplicate Nirq_enabled tests causes
    speed hit)
      bool irq_valid = (status.virq_enabled || status.hirq_enabled);
      if(irq_valid) {
        if((status.virq_enabled && ppu.vcounter(10) !=
    (status.virq_pos))
        || (status.hirq_enabled && ppu.hcounter(10) !=
    (status.hirq_pos + 1) * 4)
        || (status.virq_pos && ppu.vcounter(6) == 0)  //IRQs cannot
    trigger on last dot of field
        ) irq_valid = false;
      }
      if(!status.irq_valid && irq_valid) {
        //0->1 edge sensitive transition
        status.irq_line = true;
        status.irq_hold = true;  //hold /IRQ for four cycles
      }
      status.irq_valid = irq_valid;
    }

[No archive available]
2009-01-04 15:41:00 +00:00
byuu 155b4fbfcd Update to bsnes v038r04? release.
New private WIP. Nothing worth downloading it over, really.
- fixed first scanline DRAM refresh event (passes irq.smc and nmi.smc
again)
- fixed PPUcounter to initialize before CPU; not that it affected
anything as-is, but it's nice for future proofing to do it right
- optimized priority queue thing to move instead of swap; didn't
affect overall emu speed sadly (still infinitesimally faster than the
last official release), but I still like the model for timing events
that will occur no matter what
- made the ALU delays more permanent advanced config options; 32 and
48 were still screwing with taz-mania ... not even a whole opcode on
the mul -- that game literally reads the regs immediately. We can't
get things any better than we already have until we emulate the
formula; so I set them both to 2 clock cycles for now, they're at
least there for hobbyist devs, who can set them fairly high to
guarantee their code would work on hardware
- removed a bit of cruft

> * RSA-1024 is busted


Really? What are its factors, then? Please tell me in private so I can
claim the $100,000 bounty when it's offered again :D
(they've only broken a 200-decimal digit one with the equivalent of 75
PC work-years, RSA-1024 has 309 and the problem is exponential, not
linear.)

[No archive available]
2009-01-03 15:26:00 +00:00
byuu 02ca0f1e69 Update to bsnes v038r05 release.
[No changelog available]
2009-01-02 20:13:50 +00:00
byuu 6cacb2517a Update to bsnes v038r03? release.
I haven't posted the new WIP, just updating on the status of it.

First, I noticed that Xorg changed the keycodes, at least for Kubuntu
8.10. belegdol, the other person at RPM fusion was mentioning that he
was getting weird key mappings like page_down for left, etc -- this
would be why. Didn't realize they were variable like that. I went back
and made a lookup table to convert the official keysyms to keycodes,
so this issue should now be fixed. Anyone packaging bsnes is free to
update to the latest WIPs to fix this if they like.

Second, I added "adjust" to brightness/contrast/gamma, and they all
start at 0% centered, go to -95% and +95%. Still not sure what to name
"Frequency adjust", so I left that alone for now.

Third, I updated the ~400 or so %0.nx sprintf statements to %.x, so
that GCC 4.2+ will shut the hell up.

Lastly, I can't come up with a good double->string conversion routine
(causes subtle rounding errors with the obvious approach), so I
wrapped strdouble() around snprintf. bsnes doesn't even use it yet,
but at least it can now ...

> How would dropdowns be better than what ZSNES is currently using?


The WIP link on Rapidshare is dead ... what are they using? If it
doesn't involve tab panels, then I can do that.

> Wouldn't these just be hardware filters like NTSC that simulate the
> lossy characteristics of certain type of analog output?


These are settings _for_ the NTSC filter to affect its quality. They
don't affect any other filters.

> There's no fundamental difference between a coprocessor and central
> processor in the scheme of emulation. That the coprocessor happened
> to be located on what we would physically categorize as the
> "cartridge" is immaterial.


There's quite a large distinction between something inside the SNES
and outside. I understand where you're coming from, but we shouldn't
pretend as though the SNES contains all these chips, either.

Sheesh, I don't even know what we're discussing here anymore :P

> You'd be crazy to externalize all your code just to allow people to
> create imaginary 10ft boards with 2ghz GPUs.


What I wouldn't give for just one person to make such a board ... :D

> The only invaluable option in that entire section is overload's
> gamma curve, everything else about the image can be destroyed in my
> video driver or monitor settings.


Haven't we covered this in the past? SNES games were played with
gamma, etc settings calibrated to NTSC / PAL televisions. Monitors are
calibrated very differently. I doubt anyone wants to go into their
driver control panels to adjust these settings every time they start
and close the emulator. And cheaper drivers (especially on Linux) may
not have these options at all.

Not saying we have to go crazy here ... I'm happy to leave out
hue/saturation settings.

> I am aware that any changes made to WIP releases are posted here on
> this forum, but maybe it's an idea to start including those as well
> on the WIP download page?


I _could_ ... but it's easier to type things up here later on at my
convenience :/

[No archive available]
2008-12-28 09:55:00 +00:00
byuu 9a8203b3c3 Update to bsnes v038r02? release.
New WIP.

- defaults are now centered for video settings panel sliders, modified
default gamma to 100 with gamma curve enabled.
- removed all the preset buttons, it looks terrible with just one.
- fixes 99% of the useless bullshit warnings with GCC 4.3, still
didn't change all the "%0.2x->%.2x" strings in the disassemblers
though.
- fixed up the double->nall::string conversion, but it still has some
rounding issues, so I can't use it yet. About ready to just implement
that as a wrapper around sprintf.

> Byuu i would like to request support for the following audio
> renderers.


Sure, you can post them here when you're done and I'll include them in
the source. If they don't cause missing driver errors on a clean
install of Win2k SP4 or newer (this is why Win/OpenAL is disabled),
then I'll enable them in the default binary as well.

[No archive available]
2008-12-22 13:20:00 +00:00
byuu 9c7ac24ff7 Update to bsnes v038r01? release.
New WIP. Audio panel was revised, it's now the same both in regular
and advanced mode.

Volume, Frequency and Latency all appear on one row and are all combo
boxes with sane defaults. Advanced mode gives them additional options.

Frequency adjust remains a slider. Given that 1 tick can mean the
difference between frame stuttering once a minute and once an hour, I
think it's worth keeping the precision.

Code-wise, I merged the ppucounter object into the PPU class (through
inheritance). This results in the following code simplification:

Before:
    ppucounter.vcounter()     //S-CPU time
    ppucounter.ppuvcounter()  //S-PPU time


After:
    ppu.vcounter()  //S-CPU time
    ivcounter()     //S-PPU time (called inside its own class, no need
    for ppu. prefix)


i just stands for "internal". It was that or slow things down with a
co_active() check inside the counter read calls.

Man, it feels weird editing C++ code after all of that CSS magic. I
find myself wanting to write a pattern-matching rule ...

    uint16 PPUcounter::vcounter() {
      return cpu_vcounter();
    }

    uint16 PPUcounter::vcounter() [class="PPU"] {
      return ppu_vcounter();
    }


> I probably would have stuck it in a carefully-styled <SPAN> rather
> than an attribute, but I notice your approach is sanctioned by HTML5
> (or at least it would be if you called it "data-date" instead of
> "date").


    <h3><span>2008-12-20</span>Title</h3>
    <blockquote><p>All that is necessary for the triumph of evil is
    that good men do nothing<span>Edmund Burke</span></p></blockquote>


Could work ... looks weird, though. Adding a class type to the spans
to state what they are makes it even more bloated, but perhaps worth
it ... hmm.

HTML5 approach looks cool, too. data- prefix isn't too bad. A good
indicator that it's not a real tag.

EDIT: oops, looks like I forgot that IE6 can't handle the text-align
attribute properly, either. Eh, I'll fix it tomorrow. Tired now.

[No archive available]
2008-12-20 11:36:00 +00:00
byuu c13ae98863 Update to bsnes v038 release.
- eliminated S-DD1 DMA enslavement to the S-CPU; this allows the S-DD1 to behave more like the real chip, and it also simplifies the S-CPU DMA module
    - eliminated S-PPU enslavement to the S-CPU; all processor cores now run independently of each other
    - added cycle-level S-PPU timing for OAM address reset and OBSEL; fixes scanline glitches in Mega Lo Mania and Winter Olympics
    - removed ppu.hack.* settings; as they are no longer needed due to above changes
    - corrected VRAM tiledata cache bug; fixes Super Buster Bros v1.0 reset glitch
    - added memory export and trace logging key bindings to user interface
    - removed WAV logging (to trim the emulation core)
    - embedded readme and license texts inside executable
    - simplified S-CPU, S-SMP flag register handling
    - source code cleanup for S-CPU timing module
    - GUI-Linux: added style improvements to the listbox and combo box controls
    - GUI-Linux: finally added filetype filter support to the file open dialog
    - GUI-all: shrunk configuration panel [FitzRoy]
    - GUI-all: modified paths panel descriptions for clarity [FitzRoy]
2008-12-15 16:19:04 +00:00
byuu e370a35d7d Update to bsnes v037r07? release.
New WIP.

The biggest news is that I've implemented what I was discussing
earlier, and it worked perfectly. The S-PPU enslavement to the S-CPU
is no more.

As of this point, all four processor cores, and all three of their
shared relationships, run completely independently of one another.

This required moving the inline timing code from the absolute most
timing-sensitive section of the emulator, to an entirely new external
class. It also required logging more state data, adding ~100k/second
more context switches, etc. It was unavoidable that the new approach
would be slower, but I was able to greatly mitigate the speed loss.
Right now, it stands at a ~6-8% speed loss from the previous release.

But there is good news:
1) aside from SuperFX / SA-1 support, which will require additional
processing inside the emulator core, no other changes should slow down
the emulator again. It can only get faster from here. Most
importantly, a range-based IRQ tester would offer a major speedup.
2) this approach will allow both a scanline-based and cycle-based
S-PPU core to work with only one S-CPU core. No need to subclass and
duplicate the timing code + scheduler as I was planning to before.
3) with this change, I was finally able to convert the scanline-based
S-PPU renderer to a hybrid that I've talked about with FitzRoy in the
past: this allowed me to finally cache OBSEL writes at (roughly) the
appropriate position, while still rendering the screen at a different
point. I render the screen at H=512, and cache OBSEL at H=1152. May
not be hardware accurate, but it allows Adv. of Dr. Franken + Winter
Olympics + Mega Lo Mania to all work as expected, all at the same
time.

It wasn't 100% exactly how I wanted to do things ... but I'm really
happy about this de-coupling. I've always been a purist when it comes
to implementing processor cores independently of one another, and it's
always bothered me greatly the way the CPU controlled the PPU and its
counters.

With the above changes, I've eliminated the four ppu.hack config
settings. I don't see much of a need for them.

I've also embedded the readme and license text files. FitzRoy, I
haven't had a chance to revise the readme as you were suggesting yet.
Not ignoring you there, it's just low on my priority list right now.

Lastly, I took FitzRoy's advice, and removed the WAV logger entirely.
I'm also going to leave the screenshot capture out. At least for now
... the UI is starting to get a bit too bloated for my tastes.

This is also the first uploaded WIP with the new debugging key-
bindings (tracing and memory export.) I don't expect anyone here to
have much use for them.

Anyway, testing would be appreciated. It's very likely that the OBSEL
cache position needs to be tweaked further. I recall LotR or something
also had issues with caching in the past ... but I couldn't find the
game at ::ahem:: the used game shop ... to test it.

I think there were other games that had different behavior based on
the old obsel_cache setting, too. Would be good to make sure they all
work as expected.

EDIT: Ah, "JRR Tolkein's LotR", bah. Yeah, no sprite flickering with
the new WIP. Also, speed hit only seems to affect Core 2's. No frame
drop on my Athlon. Probably something to do with locality of reference
or somesuch. Modern processors are too damned complicated :P

So then, assuming nobody spots any bugs ... how about a new release
tomorrow?

[No archive available]
2008-12-14 05:31:00 +00:00
byuu a721c7e91b Update to bsnes v037r06? release.
What about calling the "Default" button on the paths window "Auto"
instead?

And no, label text does not wrap. That's why I have the forced line
breaks.

New WIP:
- fixes the tiledata cache glitch for Super Buster Bros V1.0; possibly
others
- adds updated nall templates: copy constructor vector class with
amortized constant growth being the most notable change. Resisted the
CC approach before because it's slower; but the amortized growth
avoids most of the overhead, and I'd rather do things through the CC
than possibly change the internal object memory base address
transparently (invalidating self-pointers and such.)
- adds snes.hide_light_cursors or something similar for Panzer88

Panzer88, I'd appreciate input on the last one. My fear is that
because the system is 100% relative, if you move your Wii remote too
far to the side, it will appear to "throw off" the alignment after the
cursor sticks to one end. Only way around that would be to use
absolute positioning.

It'd be really difficult to support both relative and absolute systems
at the same time, due to the way the drivers work. Absolute cannot
work with the mouse by its very design, and it'd be sketchy with
different window sizes and such for the light guns. And even if no
game uses it -- it _is_ possible to use a mouse on port 1, and a scope
on port 2.

[No archive available]
2008-11-25 15:05:00 +00:00
byuu 14bd3077e5 Update to bsnes v037r02? release.
New WIP.

If anyone on Linux uses this one, be careful. I'm not entirely sure,
but I think my style changes may be affecting the entire theme and not
just bsnes. I looked at example code of other popular apps that do the
same thing, though.

I'm not sure if it's just my imagination. Audacious' file open dialog
seems narrower, but every app still has the menu-style combo-boxes ...
so I don't know.

But if it is changing it -- I don't know how to revert it. Not like
it's a major change, anyway.

F-3582, cool thanks. You have the WIP URL, right?

henke37, it can't do point filtering when upscaling the image (eg the
image always gets blurry.)

[No archive available]
2008-11-03 09:16:00 +00:00
byuu 7236499e2f Update to bsnes v037r01? release.
New WIP.

For Linux users, this adds a PulseAudio driver, using
<pulse/simple.h>. Debian / Ubuntu users will need to add libpulse-dev,
or remove "audio.pulseaudio" from the ruby= line in the Makefile to
compile now.

I wasn't able to test the driver at all -- I get "Connection refused"
when I call pa_simple_new(). It appears that despite having Xubuntu
8.04, it doesn't come with PulseAudio installed. Guess they lied about
it on their website or something ...
I could install the packages, but hearing horror stories from others
-- I'd rather not.

If anyone can test for me, that'd be great. Check the console for
error messages.

Next, I finally got around to re-doing the S-DD1 driver to eliminate
the need to hook DMA transfers inside the S-CPU core to recognize
decompression events. That violated my strict feelings regarding
separation of cores and avoiding enslavement, even when it adds
significant overhead.

I'm now going with a radically different approach, that's hopefully
much more like the real hardware. It explains the way $4800 / $4801
behave, as well as why fixed transfers are required, but it may not be
faithful.

What I do is have the S-DD1 chip spy on $43x2-$43x6, and cache the
values internally. Then, whenever you read from $c0-ff:0000-ffff, it
will test if $4800 & $4801 != 0. If that's the case, we look at the
address requested, if it matches one of the active S-DD1 channels (eg
$4800 & $4801 & (1 << channel#) != 0), then we hijack the read with
decompressed data.

In my implementation, I decompress the entire block on the first read,
then stream from the buffer. On real hardware, it most likely starts
streaming on $4801.dN enable, but that's not too feasible for a few
reasons for me. Most notably the S-DD1 lib requires a size parameter.
It doesn't really matter, since we know the size from $43x5,6; so it
doesn't suffer the same problems the SPC7110 did.

Anyway, once all the data is transferred, it will clear the channel
bit from $4801. There may be some hardware differences here -- can you
perform two transfers at the same time? What happens if HDMA
terminates the DMA channel? These things never happen in Star Ocean or
SFA2, so they'll have to be tested manually.

If no channels are active or there are no address fetch matches, it
invokes the MMC to return raw ROM data.

All of that gives a ~1.5% speedup both to regular games and S-DD1
games. The former because DMA transfers don't have to test for the
S-DD1 during every transfer; the latter because I'm using a quick
lookup table (slower per fetch) in place of re-mapping the whole banks
on writes to the MMC (very slow per write.) The latter was much
cleaner and simpler, but I need the former to hook the decompression
stuff natively.

Windows binary is included, I'd appreciate if anyone could play some
Star Ocean / SFA2 and look for regressions from v037a.

> I'm just so used to seeing everyone having a "Close" button in their
> configuration dialogs I figured bsnes would have one. It just now
> that I looked around that I realised that only some of the
> configuration "panels" actually have buttons.


Ah, I see what you mean. Sorry. I can add one if you want, I suppose.

[No archive available]
2008-10-31 11:05:00 +00:00
byuu 9b03874f32 Update to bsnes v037a release.
[No changelog available]
2008-10-27 15:02:10 +00:00
byuu a9bff19b5b Update to bsnes v037 release.
This release adds support for the SNES mouse, Super Scope and Justifier peripherals. It also simplifies cartridge loading and refines the user interface. Lastly, GZ and ZIP archives can now contain non-ANSI characters (Chinese, Japanese, Russian, ...) This support existed in the last release for all uncompressed files. Together, this means only JMA support on Windows lacks support for loading non-ANSI filenames. This is due to the library itself (really, it's more Windows' fault), and licensing issues prevent me from patching libjma as I did with zlib (bsnes is not GPL compatible.) I'm planning to work with Nach to fix this in a future release.
About the cartridge loading changes ... the emulator now determines what kind of cartridge is being loaded (eg normal, BS-X BIOS, Sufami Turbo cart, etc) by looking inside the file itself. If it detects a cart type that requires more than one ROM image to load, it will present you with the appropriate specialized load menu automatically. Aside from being more intuitive, this method also allows loading of BS-X and Sufami Turbo games from the command-line or via file association.
Changelog:
    - added mouse support to DirectInput and SDL input drivers
    - up to 96 buttons per controller; 8 buttons per mouse (5 per mouse on Linux) can be mapped now
    - added SNES mouse support (does not support speed setting yet)
    - added Super Scope support
    - added Justifier support (supports both Justifiers)
    - input management system almost completely rewritten to support new controllers
    - "Load Special" menu removed, all cart loading merged to "Load Cartridge ..." option
    - replaced "Power Cycle" and "Unload Cartridge" with "Power" -> "On" / "Off"
    - when video exceeds screen size and is scaled down, aspect ratio is now maintained [Ver Greeneyes]
    - zlib modified to support non-ANSI characters
    - cheat code count was limited to 1,024 codes before; it now supports unlimited codes per game
    - added sort by description setting for cheat code list
    - polished listbox control interaction (disable buttons when nothing selected, etc)
    - cleaned up OBC-1 chip emulation (code is functionally identical to v036)
    - added option to toggle fullscreen mode to settings menu
    - added advanced mode options to toggle base unit (none, Satellaview) and system region (Auto-detect, NTSC, PAL)
2008-10-26 19:59:04 +00:00
byuu 20be19f876 Update to bsnes v036r15? release.
Got the EP / Region stuff hidden in standard UI mode, and added the
text label to the audio panel. Didn't post the WIP, not much point in
testing that.

I think I'll just take it slow, wait another week or so, make sure no
bugs pop up; rather than rush a release this weekend.

> If there is a problem with it, please let me know as I just spent a
> while thinking about it


Yeah, I wasn't sure about the math. That's why I put the height scale
first. I think your code should be fine, too. If someone can
definitively show them to be the same, we can use that just because
it's smaller, which is nice.

> By the way, is it just me or has the NTSC filter's intentional
> glitchyness gotten erratic and unpleasant? It's like it randomly
> gets a seizure


I believe I turned off the NTSC filter's merge fields setting, now
that we have vsync. It needs to have its own panel just for that
filter, I'm just really lazy and don't want to add the hooks to
libfilter to allow modifying NTSC filter settings :/

The merge fields thing looks good when not running at perfect 60hz,
but it's less faithful. I figured more people would be using that
filter with the idea of faithfulness, and thus vsync, enabled.

> Oh, I wasn't bugging you about those again, they're years away from
> feasible.


Just stemming off the inevitable. I do wish it was quick and easy to
add those, like with the other chips. So far the Cx4 has been the
worst (thanks to Andreas Naive and neviksti's awesome S-DD1, SPC7110
and DSP-1 libraries, and Overload's DSP page for the rest.) And I even
had at least half of the Cx4 done by Nach.

> I'll just focus on the next two versions before I ask you if you're
> interested in contributing to something on the game management end
> of things.


I hear game-specific settings are in high-demand. But that's a
difficult thing to get working right. But yeah, thanks; we'll cover
that in a future release.

> 1. I noticed that you may have forgotten to remove video sync from
> the advanced section after it was added as a functional menu option.


Kay, we'll add that to the list.

> 2. What happens when someone uses multiple mice? You currently don't
> list the mapping as mouse00, just mouse. Will this ever pose a
> problem?


Both DirectInput and Xlib only support one mouse. If you plug in two,
they both return input to the same device. You'd need something like
ManyMouse to support multiple mice. I didn't bother as I didn't want
to add another library dependency, and really -- how many people
really have multiple mice on one PC?

It's definitely a really neat feature in ZSNES, and the library itself
is definitely awesome. But I think the analog joystick mapping should
cover people who really want to use dual justifiers / mice for bsnes.

If not, we can always add it in a future release. The guy's license is
really permissive (zlib), which is awesome.

EDIT: this _may_ pose some problems, too ...

> On Windows, ManyMouse requires Windows XP or later to function,
> since it
> relies on APIs that are new to XP...it uses LoadLibrary() on
> User32.dll and
> GetProcAddress() to get all the Windows entry points it uses, so on
> pre-XP
> systems, it will run, but fail to find any mice in ManyMouse_Init().

> ...

> Please note that using DirectInput at the same time
> as ManyMouse can cause problems; ManyMouse does not use DirectInput,
> due
> to DI8's limitations, but its parallel use seems to prevent
> ManyMouse from
> getting mouse input anyhow.

> ...

> (XInput code isn't finished yet, but in the future this note will be
> true.)


Mmm ... those are what I use now. But I think ZSNES uses DirectInput,
too; so who knows.

[No archive available]
2008-10-20 03:23:00 +00:00
byuu f748a34e49 Update to bsnes v036r14? release.
New WIP. Couple of changes here.

Ran into that damn char *argv[] crushing Unicode on Windows thing
again with the MOTHER 3 patcher. Before I had to #ifdef the main()
entry point and add all kinds of magic to rebuild the command-line
string as UTF-8. So I moved all of that inside of hiro. Linux users
can now use GTK+ command-line arguments as a result, too. And
ui/main.cpp loses a bunch of platform-specific wrappers.

Moved realpath(), userpath() and mkdir() wrappers inside hiro; as they
all need UTF-8 <> UTF-16 stuff anyway. That cuts bbase.h to ~1.5kb.
Very close to killing it off now.

And probably most importantly, added VG's scaling changes. But I redid
the code to support the same effect in windowed mode. I also made sure
it works on portrait monitors, too (eg width is too big; scale height
instead). That was a messy section before. Please test it out and let
me know if it doesn't work as you guys were wanting.

I want to get a new release out shortly. Release-stoppers right now
are:
- axis sensitivity sucks; mouse maps too fast, joypad axes don't map
at all on Windows.
- need to swap mouse.button01 with mouse.button02 so Linux and Windows
use the same IDs; then I need to set defaults for the mouse / SS /
Justifiers.
- need to hide expansion port / region in simple UI mode.
- still need to add that skew help message to the audio settings
panel.

If I'm missing anything serious in the above, eg you know of some
critical bug or something, please let me know now.

I'm going to put off the video panel discussion and ROM PCB mapping
stuff until the next release or so. Too much to cover, and they'd take
too long at this point.

> That saddens me a little, not because I don't think you'd do a great
> job, but because there are far more people rom hacking than there
> are writing emulators or improving emulation.


And what have we been improving for the last two years? :/
It's been 95% GUI polishing and minor bug fixes. The only major change
I can think of off-hand was the HDMA timing improvements.

I'm really starting to doubt that it's possible to simultaneously
allow both the scanline and cycle-based PPUs. I try and come up with
something every other week, and nothing I think of will avoid a major
speed hit to the scanline renderer.

And I really don't personally care about the SuperFX / SA-1. Yes, I
know a lot of you do, and I'll hopefully get around to adding them.
But if I'm going to start a months-long RE task, it's going to be the
PPU first, sorry. And I'm at a major impasse there.

[No archive available]
2008-10-19 08:49:00 +00:00
byuu 0af5703c47 Update to bsnes v036r13? release.
New WIP finally adds non-ANSI filename support for GZ and ZIP
archives. That plus the existing support for uncompressed filenames
means it works with everything now but JMA archives. Compression
support was enabled with this WIP for testing.

I used Nach's suggestion with gzdOpen() for GZ, but I had to modify
ioapi.c for ZIP support, as there was no unzOpen() that took a file
descriptor. No big deal, it was only a four-line change and it works
great.

I noticed that the Windows hiro port wasn't sending the -1 position
for when no items in a listbox were selected. That turned out to an
absolutely major pain in the ass to support, thanks to the way Windows
works. Say you switch from item #3 to no item, it will send "item 3
lost focus", but nothing for the fact that no item has focus. Easy
enough, but then if you switch from item #3 to item #4, it sends "item
3 lost focus", followed by "item 4 gained focus." Since you can't tell
after the first message if a second message will occur, you don't know
whether or not to send a "no items selected" message; and if you try
and wait and there is no message, you won't get a chance to send it
again.

Took a lot of evil state tricks, but I got it working. That'll make
the input config, cheat editor and advanced panel buttons gray out
when nothing in the list is selected. Please let me know if you spot
any oddities with that.

That ate up nearly all of my time ... with only an hour left, I fixed
the input mapping once a cart was loaded; but I didn't have time to
fix the Windows joypad axis mapping bug, which should be the only bug
left at this point.

> Your website got foobared somehow, I can't navigate to places.


I knew what it was before even looking, based on your description.
Derrick's host turned off PHP register globals. Apparently we can't
have nice things because a few dumb fucks can't remember to initialize
variables. Whatever, it's fixed now.

[No archive available]
2008-10-17 14:02:00 +00:00
byuu f73d0908c4 Update to bsnes v036r12? release.
New WIP, doesn't do much.

The core no longer scales axis values at all; and the platform input
manager scales joypad axes only by 4096. Mice are unscaled here.
Meaning you can use joypads and mice together at the same time now.

Also updated the input config panel to add all the new input devices.
Assignment is still sketchy. My idea is to separate axis movement from
button movement, and allow fast mouse movements (+/- 20 in a given
direction) or strong joypad axis movements (~50% tolerance+) to assign
axis stuff. For buttons, they'd work as before, but you can also click
a mouse button with the mouse over the input capture window.

Disabled Xlib mouse acceleration during capture mode. I don't notice a
difference, but I may as well leave it in case it matters somewhere.
Sadly, it looks like buttons 4/5 are never set via XQueryPointer(),
and you can only get buttons 6-9 with event callbacks. Since the input
wrapper doesn't own the window (in actuality, GTK+ does), I can't
safely bind the XEvents to capture those. So left, middle, right click
only on Linux.

After that's done, we should start polishing for the next release.

> gtk_tree_selection_get_selected() returns items from the underlying
> unsorted list rather than indexes into the sorted list.


Really? That's interesting. Not sure I like that. If I call
listbox.set_selection(0), I would expect it to select the first entry,
not the eleventh.

It does sound very convenient 99.9% of the time, though; I agree.

> (imagine porting to Mac OS X's Cocoa GUI which tries to do even more
> work for you...)


Oh geez, let me guess. You can drag a listbox item out of one app, and
drop it into another, and the other app can now invoke your callback
functions for activate / change with it? :P

> Since the X11 protocol only really supports three buttons, two
> button mice generally have buttons 0 and 2, and button 1 is emulated
> by clicking both 0 and 2 together (this is controlled by the
> Emulate3Buttons option in xorg.conf).


Excellent, very good to know, thank you. You sir, are a treasure trove
of knowledge! :D

So, should I go the Windows way for the majority; or the Xlib way
since it's a bit cleaner? At least, when you consider most mice have
three buttons these days.

[No archive available]
2008-10-14 12:45:00 +00:00
byuu 18389cb8f7 Update to bsnes v036r11? release.
Another WIP.

A few changes here; I added on_change notifications to both Windows
and Linux textboxes. I use that to only enable the "Add Code" button
on the cheat code screen when a valid GG/PAR code is entered. A bit
nicer than just not doing anything when you click "Add Code". Also
disabled toggle / delete code when one is not selected. Minor touches.

Added on_input mouse capture to the canvas widget for Linux. Needed
for the input.acquire() mouse capture hook.

Tried to use SDL_WM_GrabInput and SDL_GetRelativeMouseState ...
doesn't work at all. Unless SDL creates the window itself, it doesn't
give you any mouse info. SDL_WINDOWID hack doesn't work here either,
same issue with the keyboard input and why I had to use raw Xlib
there.

So, I use XGrabPointer + XQueryPointer + XWarpPointer and some magic
to make my own invisible cursor. Major pain in the ass. It works okay,
but it feels a bit too jumpy ... I'm going to try screwing around with
the acceleration controls to see if I can smooth it out a bit.

And hooray, more fucking cross-platform headache:
Windows: button 1 = right, 2 = middle
Linux: button 1 = middle, 2 = right

I had to completely disable the scale for this build to get the mouse
to work well on Linux, so no joypad axes for this one. I'd be
interested to see how the mouse performs for FitzRoy; where the last
one was too slow, this should be 5x faster. Surprisingly still
playable for me, but a bit too fast for my tastes.

The scalar of 1 feels great for Windows with the cheapo 400dpi mouse
here, too. I think this is a reasonable default.

-----

Detecting listbox column header clicks was easy enough on Windows:

    if(((LPNMHDR)lparam)->code == LVN_COLUMNCLICK) {
      printf("%d\n", ((LPNMLISTVIEW)lparam)->iSubItem);
    }


And of course, there's no obvious way to do the same with GTK+:

http://www.gtk.org/api/2.6/gtk/GtkTreeView.html
http://www.gtk.org/api/2.6/gtk/GtkTreeViewColumn.html
http://www.gtk.org/api/2.6/gtk/TreeWidget.html

I have a couple of hangups about a column sort click, anyway.

1) there's no logical reason to sort by code (they're technically
gibberish, especially encoded Game Genie codes), status (you want the
list to change around when you toggle the status? yuck), or by reverse
description (scroll to the bottom and read up, same thing.)
2) it won't save the setting across runs; each time you load a new
game, you'll have to re-click to sort the list.
3) there'd be no way to stop sorting completely.

But again, we can make this a hidden option like deep filetype
detection if it's too obscure.

[No archive available]
2008-10-13 13:31:00 +00:00
byuu 448a8336b1 Update to bsnes v036r10? release.
Sorry, was a bit under the weather lately.

Anyway, new WIP, very little changed.

Updated nall::sort from insertion sort to merge sort* [O(n log n)],
and then used that to add a "Keep cheat code list sorted by
description" checkbox to the cheat code editor. I'll admit this
probably isn't very useful, I really just wanted an excuse to
implement a proper sorting algorithm and get rid of the embarassing
O(n^2) sorting code I had in my template library. It's actually the
first time in 11 years of programming that I've ever used a sort
function in an application, believe it or not. I'll make it an
advanced mode option if it really bothers people (eg as feature
bloat.) It was only ~12 extra lines of code.
(* not using quick sort as I need a stable sort for my purposes (eg
two descriptions that are the same, but with different codes -- it
shouldn't bounce around every time the list changes or you toggle the
sort option), and it's nice avoiding the worst-case O(n^2) issue with
quick sort.)

Updated the mouse acquired check to work, but only on mouse input. Not
that it matters much since I still don't have a method for
distinguishing between mouse and joypad movement deltas. Eg this build
only works with joypads, not mice.

Moved the endian stuff from bsnes/src/lib/bbase.h to nall/endian.hpp.
I've been trying to eliminate bbase.h for quite a while now. Getting
pretty close, just some Windows POSIX wrappers and typedefs left.

Hid a bunch of the new config file options from the advanced panel.
The idea, of course, is to hide anything that can already be
controlled from the GUI anyway.

Sigh, no way I can make an October 14th release this year. Way too
much stuff is broken.

Dullaron, no, that's not the problem at all. See the input driver
thread for more info.

FitzRoy, wow, 1800dpi. Yeah, my mouse can do that, too; but I leave it
at 1000dpi. That's odd, the work mouse is only 400dpi and its slower
there than my 1000dpi. I'd have expected 1800dpi to be way too fast
for you. I'm at a loss, maybe I'll take a look at how other emulators
handle mouse movement ...

[No archive available]
2008-10-12 10:27:00 +00:00
byuu 233e645772 Update to bsnes v036r09? release.
I fixed up the SDL and X input drivers to work with the new model, so
the Linux port builds again.

For the sake of testing, this WIP disables the "mouse acquired"
requirement, and raises the divider on motion to 5000 from 5. In other
words, this release will work with gamepad thumb sticks, but not with
mice.

Having a _lot_ of trouble coming up with a way to get both working
cleanly. But yeah, you can at least see how it works now.

You want to set the X axes to "joypad00.axis00", and Y axes to
"joypad00.axis01". Use the config file, input assignment is still
screwed.

> I can't get bsnes to recognize thumbstick 2.


DIJOYSTATE2 has lX and lY, but that's it. I guess making that an array
would be too easy. I'll have to dig through and hope one of the 20
other oddly named variables (lHX, lRX, lRLX, etc) refer to the other
analog stick.

You think that's stupid ... the scroll wheel increments in ticks of
120 per one physical tick of the mouse. Always 120, it's a fixed
constant. Using DIPROP_GRANULARITY to get it from the mouse tells you
the driver doesn't support that operation, but there's a Windows
#define called WHEEL_DELTA for it.

Seriously, what's the point of an arbitrary, fixed-value multipler for
something, anyway?

> An idea that I had that would get these things working for everyone
> and every platform, would be to create 4 mappable directions that
> could be assigned to a dpad


If we could come up with some way to map both analog bi-directional
inputs and single push button controls together, then yes we could do
something like that. I think it would be too difficult to play like
that, but whatever. The flexibility would be nice at any rate.

[No archive available]
2008-10-09 17:00:00 +00:00
byuu f0627239bb Update to bsnes v036r08? release.
New WIP. Not really worth grabbing if you have a previous one,
progress is very slow but steady here.

First, I kept the just-in-time cycle-accurate Super Scope / Justifier
latching support; but optimized things to reduce the overhead even
more. It's now ~0.5% speed hit with no light gun, and ~1.2-1.5% with.

Next, I rewrote ruby::input and the DirectInput driver to scan at O(1)
instead of O(n). With that, I increased the max # of joypad buttons
per controller to 128 (the # doesn't affect speed anymore -- 128 is
just a hard limit with DirectInput), and gained a ~2% speedup over the
old method.

Renamed the mouse axes again, to just "mouse.x" and "mouse.y", sorry.

Added a blocker for mouse.button00, but as the new input system merges
key_down/key_up/axis into one single-pass scan, it's now mapping mouse
motions, and if not that, lousy analog joypads that return sporadic
values.

Hey, it's a WIP release for a reason, right? Getting there, my idea is
to have the input driver return information about what "type" of input
each symcode is, and then pass masks from the input configuration
mapping to control which types of input are considered valid for each
of the different types of controls.

Not sure if I want to allow the Mouse/SS/Justifier axes to be mapped
by swinging the mouse fast in a given direction (the threshold now is
any movement at all, I'd make mapping it require +100/-100 in any
direction so you have to move it fast to map it), or use a dropdown
box for that.

Oh, and I added the glow shadow I was talking about earlier to the
light gun cursors. If you do decide to try out the WIP, let me know
what you think of that.

The Linux port is pretty much 100% busted at this point. I have to
port all of the SDL / X input drivers over to the new system.

Ah, and if anyone's bored and has a five button mouse, try mapping top
thumb to left, bottom thumb to right, left click to B, right click to
Y, and middle click to start; and then play Super Mario All Stars -
Mario 1. 100% control via mouse alone = good times :D
I made it to 4-2 on my first life.

> The speed at which the mouse moves is so slow


The scale is based on my gaming optical mouse (it was the only
5-button mouse I could find without a tilt wheel; fuck those things),
so the DPI scaling I use is pretty high. I'm having trouble getting it
to move at the speed of your regular mouse universally, because I
don't know what the speed of the mouse is to interpret the mouse
movement results.

[No archive available]
2008-10-08 11:14:00 +00:00
byuu ae67f268a8 Update to bsnes v036r07? release.
New WIP.

This adds all the aforementioned fixes. I got the speed hit to ~1%
with no light gun, and ~7% with.

All three light gun modes allow you to go offscreen by 16 pixels in
either direction, and Super Scope's offscreen flag is now supported.
Mouse still needs the speed bits supported.

I also modified the cursor just a bit by adding dots to each side of
the circle. Makes it look a lot better. Not sure if I should add a
shadow around the cursor or not. It really helps on red screens, but
it seems kind of obtrusive to the view everywhere else.

Oh, and the cursor works as expected in hires and/or interlace modes
now.

Also, x_axis, y_axis, button_NN is now mouse.x_axis, mouse.y_axis,
mouse.buttonNN. joypadNN.button_NN and joypadNN.axis_NN are now
joypadNN.buttonNN and joypadNN.axisNN. So be sure to update the config
file again. Hopefully for the last time.

I have not added the new input changes just yet, so the mouse button 0
still auto-assigns in the GUI. Use the spacebar or enter to bring up
the assignment window for now. That also means that joypad analog axes
won't work well for mouse simulation still.

Other than what I mentioned above, please let me know if you spot any
bugs this time around. Especially regarding the shots not going where
you expect them to. I didn't test Yoshi's Safari myself, but it should
be fine now.

[No archive available]
2008-10-07 10:41:00 +00:00
byuu b2331ddb85 Update to bsnes v036r06? release.
New WIP. About 12 hours of non-stop programming ...

I've added full mouse support to nall::input, hiro and
ruby::DirectInput. With that, I added some really hacked-together
support for the mouse, super scope and justifiers. Yes, all there --
now _please_ stop bugging me about this already.

Caveats:
- Mouse support doesn't honor the speed setting.
- Super Scope doesn't currently let you go offscreen, which I should
allow by at least a few pixels to allow the offscreen flag to be set
for any games that might need it.
- Dual Justifier mode is fucked. I don't understand where PIO is
supposed to be raised, and I used a hack to get the "shoot offscreen
to reload" thing to work for the single Justifier mode for now. The
dual one tends to desync when you go offscreen and stuff, not very
pleasant.
- I'm not going to support SS / Justifiers in port 1. Since they can't
latch counters anyway, and no games make use of them, I don't see much
point in cluttering the menu more and confusing new people. Both
multitap and mouse have games that can use port 1, so they stay.
- There's no input config panel to map buttons. You have to edit the
config file directly.
- The mouse delta absolutely sucks. It's just a simple div 5, so
moving the mouse really slowly won't even register, and moving it fast
has only a linear curve. This one's going to be a real pain in the ass
to get right on everyone's system, as the ranges DirectInput gives for
mice tends to vary based on resolution, software and hardware mouse
speed settings.
- Joystick delta range is -32768 to +32767, so div 5 means it'll be
pretty much unplayable with the joystick.
- Input capture window binds mouse clicks now. This needs to be
expanded quite a lot to support selective axis and mouse assignment.
- The software-rendered cursor doesn't work right in hires / interlace
modes.
- To get the PIO latching behavior 100% correct without a dead spot
during DRAM refresh, I'd have to test the cursor coordinates every
single clock cycle. That would be way too damn slow, so I used a huge
hack instead. I just test once per scanline and fake the latch
counters to the cursor position. This is really shitty, and some
timing-sensitive code that was looking for this could easily detect
the emulator because of this, but it's either a ~10-20% speed hit, or
no speed hit at all and hacky SS / Justifier support. Since it seems
to work with all the games anyway, I'll go with the latter for now.
- No Linux support for any of this stuff yet, sorry.

If you want to try it, the config file keysyms are:
"x_axis" - mouse x axis
"y_axis" - ...
"button_00" - "button_07" - mouse buttons; hope you have the side
buttons on your mouse for the Super Scope, otherwise have fun using a
keyboard + mouse at the same time.
"joypad00.axis_00" - "joypad00.axis_03" - joypad axes (only 0,1 work
with DirectInput; 0-3 for SDL.)

Yes, I'll rename the mouse ones to "mouse.foo" in the future.

Aside from all that, not really looking for bug reports at the moment.
Way too preliminary for that.

Oh, and you have to click inside the video output to acquire the
mouse. You'll know as the mouse cursor goes away. You can release the
mouse by pressing escape on the keyboard.

If the mouse is acquired, escape overrides any GUI key assignment to
that button. You can also toggle fullscreen mode and the mouse will
stay acquired.

You can't acquire the mouse unless you have a mouse/SS/justifier
attached to a controller port, and a game loaded.

[No archive available]
2008-10-05 15:08:00 +00:00
byuu 2a2f50a8bc Update to bsnes v036r05? release.
New WIP.

I was really hesitant to even do this much, but ... biggest feature:
Image

Lots of caveats here. The biggest one being that it isn't controlled
via the mouse, as I don't have any mouse driver code written; and I
really have no idea how to bind the mouse to the bsnes window region,
nor do I really want to do that.

I also can't map it to standard on/off keys, as there's no delta
response to them. It would be uncontrollable like that. Instead, I've
mapped it to the analog axis sticks on gamepads. The further you press
the gamepad axis stick, the faster the mouse moves in said direction.
Mouse left+right can be mapped to keyboard or gamepad buttons.

I know, I know, not everyone has analog gamepads. Sorry, this is the
best I can do for now.

Does it work well? Honestly ... not so much. I can clear the first
stage of the fly swatter game in Mario Paint, but that's about it. The
only real advantage is you don't need ManyMouse to emulate two mice at
the same time. It also works pretty good in the text games, like
Tokimeki Memorial.

Also, the documentation out there for the mouse absolutely _sucks_. I
have no idea how the speed bits are supposed to work, so they aren't
emulated at all. Thus, the mouse speed settings in games do nothing.
It also fails the SNES mouse electronics test. But it is usable.

Anyway, how to use it ... run the new WIP, then edit the config file.
You have to manually set it up as there's no GUI for configuring it
yet.

Look for "input.mouse(1, 2).(x, y, l, r)". Here, you want to set x, y
to axes, eg "joypad00.axis_00", and l, r to buttons, eg
"joypad00.button_00". This only maps four axes for now, so limit the
axis range from 0-3. Buttons can be 0-15.

**Please do not bug me to improve this!** This was just a functional
demonstration. It's going to be many months before proper mouse
support is added, it may never even be added, who knows ... I have a
_ton_ of complicated problems that must be overcome before I can get
real mouse support in there. If you want to actually help with the
programming side of things, then we can certainly talk about that.

Also, **please do not bug me to add the Super Scope / Justifier
next!** I can't even do it with the gamepad trick, because these two
are supposed to trip interrupts at exact points, which is really
difficult for me to do at this time. The SS would also require a
software cursor to be drawn on-screen, another technical challenge.

[No archive available]
2008-10-02 07:28:00 +00:00
byuu 30b19613d5 Update to bsnes v036r04? release.
New WIP. Quite a bit of neat stuff this time.

First, BS-X and ST BIOS detection is in. Attempting to load them will
bring up the multi-cart loader window with the BIOS fields filled in.
So now it doesn't matter what image the user tries to load, it'll just
work.

Next, added the expansion menu per FitzRoy. You can choose between
"None" and "Satellaview BS-X". I also added a new menu there, for
region selection. There's "Auto-detect" (base off the cart type),
"NTSC" and "PAL". Admittedly not very useful, but I figure since we
aren't automatically selecting the expansion unit, we should make it
possible to manually specify the SNES type. Looks like some games work
in either region, eg the SNES Test Program - Electronics Test. That
kind of surprised me.

I was thinking it might be best to hide expansion port + region when
advanced mode is disabled, since it's something I imagine 99% of users
will never need to touch.

Also, it's set up so that you can only change the settings when the
power is off, or no cart is loaded. This is very much intentional!
It's impossible to change the SNES console without a mod-switch while
it's on, and it'd be really stupid to try hot-swapping the BS-X base
unit while it's running. You can still expand the menu to see what is
currently selected, unlike power. I figured there wasn't much point in
seeing the power-on state with no cart loaded. It's obviously off in
that case.

Speaking of which, updated hiro to support MenuGroup::disable()
properly on Windows.

Fixed the minor cosmetic Y start offset on the drivers panel.

And I cleaned up the cart loading a bit more. Still need to do a bit
more work on that, but it's looking pretty good so far.

[No archive available]
2008-09-26 10:30:00 +00:00