Make `speedup_frame_skip` and `speedup_throttle` independent settings,
with `speedup_frame_skip == 0` when `speedup_throttle` is not in effect,
and `speedup_throttle == 100` when `speedup_frame_skip` is in effect.
This fixes a previously introduced bug where `speedup == true &&
speedup_frame_skip = X` was never enabled.
This also allows `speedup_throttle == 0` for no throttle and no frame
skip during speedup.
Also set the upper bound on `throttle` and `speedup_throttle` to `450`
instead of `600`, as the DirectSound driver does not support values
higher than that.
In the DirectSound implementation of `setThrottle`, for `throttle == 0`
use a `throttle == 450` frequency multiplier, because a zero frequency
does nothing.
- Fix#719.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
- Allow key shortcuts to run with loaded game.
For example, when we set `CTRL+A` for `load most recent save state` and
use `A` for some input command, holding `CTRL` and then pressing `A`
will not execute the shortcut. Instead, the key press `A` will be used
only as the input and nothing else.
With this, we use both the input and shortcut key.
- Isolate function to get keyboard key codes.
As explained on [1]:
"Using `GetUnicodeKey()` is in general the right thing to do if you are
interested in the characters typed by the user, `GetKeyCode()` should
be only used for special keys (for which `GetUnicodeKey()` returns
`WXK_NONE`)."
We also allow special keys to be mapped, hence the requirement of using
both functions.
[1] https://docs.wxwidgets.org/3.1/classwx_key_event.html
- Allow use of unicode keys for input and shortcut.
Use format `KeyCode:Modifier` for saving/loading unicode keys.
`WxWidgets=3.{0,1}` does not create an accelerator from strings with
unicode keys such as `ç` (`FromString` function). It fails with an
assertion error and stops execution. At the same time, we use the keys'
strings that are known for WxWidgets, such as `A`, `CTRL+O`,
`PAGEUP` etc.
Use both `EVT_KEY_DOWN` and `EVT_CHAR`.
`EVT_CHAR` is better than `EVT_KEY_DOWN` here because it is where the
raw key events will have been cooked using whatever recipes are in
effect from the os, locale, international keyboard settings, etc.
- Enable SDL joysticks input as key shortcuts.
Start/Stop polling joysticks on Unload/load game.
Our main loop already polls the joystick, we don't need the timer
while a game is running.
- Create function `str_split_with_sep` and use it.
For when we parse strings that may include the sep string, such as
game input and key shortcuts.
It is not needed to set `throttle` on neither case. There is actually a
bug when using turbo/speedup and closing the emulator. The test case
is the following:
https://github.com/visualboyadvance-m/visualboyadvance-m/issues/627
On Windows:
1. use opengl;
2. load GBA game;
3. set throttle to `100%`;
4. set turbo throttle to `200%`;
5. enable turbo on menu;
6. save game;
7. close emulator && open emulator;
8. load GBA game;
==>
throttle is `200%`.
This is definitely not expected.
In the Turbo config dialog, remove the selection list for entering the
value and leave only the spin control. Allow values above 600%, up to
4000%.
Reintroduce the speedup_frame_skip config variable, defaulting to 9, use
it for turbo selection values > 600%, with speedup_throttle == 0.
The rationale for this is that on average modern hardware, throttle
values above 500% or 600% will not be effective.
The default is now shown as 1000%, which is:
frame_skip == 9 && speedup == 1,
where:
speedup == 1 is equivalent to throttle == 0,
as was the case before the turbo config changes.
Values above 600% are automatically rounded up or down to the nearest
100%, on entry and on click of the up/down arrows of the spin control.
The frame skip checkbox is cleared and disabled for the "Unlimited"
setting (throttle == 0), and set and disabled for values > 600%, to
reflect the mechanism to the user.
When the value again enters the modifiable range in the spin control,
the previous value of the checkbox is restored.
Misc:
- Turn off translation of percentage values in the xrc.
- Remove the size element for the throttle selection list in the general
config dialog xrc, it breaks the layout on GTK3.
- Add a note about passing wxWidgets_CONFIG_EXECUTABLE to cmake to
select wxWidgets version to README.md.
Hopefully this will reduce confusion and present a nicer UI.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
MBC30 is a variant of MBC3 with a 4MiB ROM size and a larger RAM size.
https://gekkio.fi/files/gb-docs/gbctr.pdf
Allow addressing 4MiB of the ROM in MBC3 ROM bank select if the ROM size
is 4MiB.
Fix provided by roytam1.
- Fix#652.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
We have some issues when trying to open files on Windows that contains
characters not included in the current codepage. Using `fopen` fails
when that happens.
One example is using the `pt_BR` codepage and then using a name with
japanese chars for the battery file.
The games and BIOS work since they use `blargg_open`. It converts a
`const char *` to `const wchat_t *` and uses `_wfopen` for windows.
(doing a multibyte to widechar conversion)
Since we want to avoid doing many code changes on our cores, we need
some `util*` functions for the matter.
Replace `mb_fn_str` by UTF-8 strings.
Replace all occurrences of `fopen` for `utilOpenFile` on GBA core.
Replace all occurrences of `fopen` for `utilOpenFile` on GBA e-reader.
Adjust e-readers calls on wx frontend.
Replace all occurrences of `fopen` for `utilOpenFile` on Patcher files.
Always apply UTF-8 when dealing with path strings.
On our wx frontend we should always send UTF-8 `char *` to our cores
functions. This way we can have consistency when dealing with them for
each platform.
On Windows, we will convert all multibyte to wide chars and use proper
functions for I/O operation.
Create function to deal with unicode calls of `gzopen`.
We use `gzopen_w` (`zlib>=1.27`).
Replace all occurrences of `fopen` for `utilOpenFile` on Config Manager.
Replace all occurrences of `fopen` for `utilOpenFile` on Cheat files.
Use proper functions for unicode on GB core.
Use function instead of macro for `UTF8()`.
Use `nullptr` instead of `NULL`.
Print wide char strings on status bar.
Fix throttle=0 (unlimited speed) settings for both the Speedup/Turbo
config panel and the general throttle setting and make 100 the default.
Replace the speedup frame skip option with a "Frame skip" checkbox,
which enables skipping the appropriate number of frames if vsync or very
low system performance is in effect. The systemFrameSkip (under video
config) is added to this value.
With speedup_throttle=100, the old speedup behavior is used with 9
frames skipped.
With speedup_throttle == 0 && speedup_throttle_frame_skip, skip 9
frames at full speed, which is exactly the same as the old behavior,
since throttle == 0 is equivalent to speedup == true.
Hopefully these changes will make the turbo config dialog more useful
for users, by default frame skipping to work around vsync will be
enabled, and users can uncheck the "Frame skip" checkbox for a smoother
experience.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
When we skip frames, we just don't draw them on our frontend. The
function `systemDrawScreen` also send the video frames to be recorded,
but only when called from the core.
Our solution creates a auxiliary `systemSendScreen` that only adds the
frame to the recording. It is called when the core decides to skip a
frame. This way we can get the video frame for recording, just like
audio ones are always sent.
We do not allow to skip frames while recording. The resulting length
will be extended compared to using turbo/speedup modes, because the
recording will be normal time (as in running without turbo/speedup).
Similar update to GBA which does the following:
- reduces input lag by 1 frame by reading user input at beginning of cpu loop
- audio and video timing update, which sends audio and video at every frame possible
- add missing sound state variable, soundTicks for gb and gba
The MBC3 and TAMA5 battery formats save the RTC data including a
`time_t` field which is the last field.
Since `time_t` is 32 bits for 32 bit builds and 64 bits for 64 bit
builds, pad it in the two battery structs with a `uint64_t` and detect
the 4 byte shorter saves made by older 32 bit builds.
Also remove some pointless code in save state reading that also uses
`sizeof(time_t)`.
Add two new constants for RTC data size in gbMemory.h and use them.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Conditionally compile out the code for the feature implemented in
16dd5d40 (which is the throttle and frame skip configuration for the
speedup button) for libretro, and use the old behavior of skipping 9
frames.
Affects GBA.cpp and GB.cpp .
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Add Speedup / Turbo configuration panel which allows setting the
throttle or number of frames to skip for when the speed key is pressed
or turbo is enabled (which just presses the speed key.)
Throttle and frame-skip are mutually exclusive, throttle must be 0 (no
throttle) when number of frames to skip is non-zero. The dialog controls
handle this.
This is implemented in the core in GBA.cpp, GB.cpp and ConfigManager.
Two new options are added both in ConfigManager and in the wx options,
speedup_throttle and speedup_frame_skip, the defaults are:
```
speedup_throttle = 0 (no throttle)
speedup_frame_skip = 9
```
this was the original behavior.
Add support for unsigned ints to wx/opts.cpp for these and for throttle,
this requires a new validator wxUIntValidator to use them in spin
controls.
Clean up appearance of the throttle spin control in the General dialog.
Maximum throttle and speedup_throttle is 600, values much over 500 will
not behave differently from 0 on modern hardware.
Maximum frame skip is 30 at the moment.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Gb,gbc and sgb enhanced version of roms and savestates working. Bios loading for gb/gbc works too. No save ram / battery handling yet.
Fix offset and pitch issues with vba rendering and when borders are enabled.
Make a custom cstdint.h header file that includes <tr1/cstdint> if
<cstdint> is not available, because the clang 3.x used on Lion does not
have it. Change all references to <cstdint> to use it instead.
Add missing OpenGL header for older OS X in sdl/SDL.cpp .
When calling HiDPI methods, use respondsToSelector: to check if the
methods are available first.
Fix the bundling/linking script to support multiple copies of the same
dylib with different versions. Necessary to include both the Lion system
libpng and the brew libpng. Including the system libpng is necessary
because it is removed in later versions of OS X.