Commit Graph

45 Commits

Author SHA1 Message Date
David Guillen Fandos 9632dedf90 Implement EEPROM save override.
Disabled SRAM/FLASH when EEPROM saves have been attempted. Allows to
override games via gba_over too
2023-09-23 18:13:18 +02:00
David Guillen Fandos ae048beb9c Rework RTC and break it into GPIO, with RTC and Rumble (GPIO3)
This adds Rumble support for GPIO3-enabled games (Drill Dozer).
2023-09-20 22:46:06 +02:00
David Guillen Fandos f0bacff91a Remove gpsp savegame method in favour of libretro's one
This generates 128KB save files (instead of variable sized ones) to
prevent truncated savegames under some circumstances. Most other
emulators have no trouble loading them (and the unused data is simply
ignored).

Remove also config txt file that's now unused.
2023-09-19 20:36:56 +02:00
David Guillen Fandos 2352adcc50 Improve savestate loading to avoid corrupting the current state
It should not happen since the magic value and version would normally
discard incompatible savestates, however it's preferrable to check
before loading the state (it's just some minor sanity check).
2023-09-07 20:26:44 +02:00
David Guillen Fandos 7906413f28 Define more I/O registers 2023-08-29 23:07:58 +02:00
David Guillen Fandos a5429384fe Add missing register 2023-07-29 20:51:47 +02:00
David Guillen Fandos 11f56eb1d1 Implement text background affine rendering 2023-07-20 23:28:25 +02:00
David Guillen Fandos dc4c312ca7 Rewrite tile rendering base functions 2023-07-18 23:04:56 +02:00
David Guillen Fandos b88f0c0135 Rewrite window code without macros 2023-07-14 22:39:47 +02:00
David Guillen Fandos 1d972ec7ff Improve GBC sound by fixing its deferred rendering
This fixes many games that use the PSG, particuarly the noise generator.
It is very noticeable in explosion/collision sounds with Sonic and Kirby
games, where the noise channel is rapidly tweaked.
2023-07-14 00:37:33 +02:00
David Guillen Fandos 2391496432 Some video cleanups for better readability 2023-07-11 23:11:27 +02:00
David Guillen Fandos 84c347edad [interp] Improve interpreter timings and honor WAITCNT
This fixes a few games and makes the interpreter faster (since it
doesn't run an overclocked CPU anymore).
2023-06-07 19:40:27 +02:00
David Guillen Fandos 6bf53cf3db Minor I/O write improvements 2023-04-19 23:22:18 +02:00
David Guillen Fandos 413157dedd Fix timer bug regression, introduced at 0bc2a11
Thanks andy for finding the fix!
2023-04-19 20:00:28 +02:00
David Guillen Fandos 541adc9e1c Fix ROM swapping capabilities
This fixes ROM swapping for x86/64, arm32 and arm64. On top of that it
improves speed by removing unnecessary slow paths on small ROMs for
arm32 and mips. If the ROM can fit in RAM, it will emit more efficient
code that assumes the ROM is fully loaded.

For low-memory Linux platforms it would be better to use some mmap'ed
ROM, that way the OS would transparently handle page swapping, which is
perhaps faster. Will investigate and follow up on this in a separate
commit.
2023-03-03 21:05:12 +01:00
David Guillen Fandos b552d5eb7e Improve open bus reads on ARM/MIPS 2023-01-05 21:29:20 +01:00
David Guillen Fandos 4eac8e30a8 Add WAITCNT but do nothing for now 2022-01-05 21:43:03 +01:00
David Guillen Fandos bc8c07272b Add DMA cycle accounting for H/V blank and sound DMA
This is just responsible for a few cycles every frame (could be around 1
and 2% depending on the game usage) but makes emulation a bit more
accurate and potentially faster.
2021-12-21 12:02:48 +01:00
David Guillen Fandos 44ccdb3d25 Minor mem handler fixes (pretty much a no-op) 2021-11-03 21:33:29 +00:00
David Guillen Fandos 6a59c71d55 Get rid of enums (to u32) for better compat
Serialization code needs u32 to ensure compatiblity. In platforms with
short enums this goes very wrong. Fixes issues on 3DS platform.
2021-10-15 21:28:40 +02:00
David Guillen Fandos 7068cbc95b New savestate implementation
This uses BSON as savestate format, to allow external tools to parse it
(so that we can add proper test of the states). The BSON is not 100%
correct according to spec (no ordered keys) but can be parsed by most
libraries.

This fixes also a bug in the savestate palette color recalculation that
was wrongly overwritting the original palette (which could cause some
problems on some games).

Also fixes some potential issues by serializing some more stuff and
cleans up unused stuff.

Testing shows that states look good and there's only minor differences
in audio ticks, related to buffer sizes (since buffer flushes are
de-synced from video frames due to different frequency).
2021-08-24 17:15:27 +02:00
David Guillen Fandos 1e976fb312 Remove unused stuff and fix const variables
Trying to figure out what needs to be part of a savestate :)
2021-08-24 10:57:30 +02:00
David Guillen Fandos a3377c2ac1 Minor DMA cleanup 2021-08-21 18:10:12 +02:00
David Guillen Fandos da5ec48982 Rework I/O mappings
Mirrors exist at 64KB boundary (not 0x400) but works nevertheless
2021-07-30 00:18:02 +02:00
David Guillen Fandos ba51aa6a1c Fix pointer serialization in the memory system
This makes savestates potentially unstable under certain conditions (and
definitely not portable)
2021-07-27 21:18:15 +02:00
David Guillen Fandos 84cd7b2934 Rewrite ROM buffer allocation
This improves the existing on-demand ROM paging and also breaks down ROM
buffers into 1MB blocks for platforms with memory fragmentation issues.

Fixed some potential RTC reg issue in said platforms too.
Fixed page pinning on interpreter (would crash due to LRU evictions).
2021-07-14 01:20:30 +02:00
David Guillen Fandos c9421e6929 Some small cleanup to make the code more C++ conformant 2021-07-11 13:35:21 +02:00
David Guillen Fandos 8dbf5f6c17 Enable big-endian devices: gc/wii
This patch adds big-endian compatibility in gpsp (in general but only
for the interpreter). There's no performance hit for little-endian
platforms (should be a no-op) and only add a small overhead in memory
accesses for big-endian platforms.

Most memory accesses are wrapped with a byteswap instruction and I/O reg
accesses are also rewired for proper access (using macros). Video
rendering has been fixed to also do byteswaps but there's a couple of
games and rendering modes that still seem broken (but they amount to
less than 20 games in my tests with 1K ROMs).

This also adds build rules and CI for NGC/WII/WIIU (untested)
2021-06-27 01:16:28 +02:00
David Guillen Fandos 7a642069e3 Cleanup unused stuff 2021-06-09 18:10:26 +02:00
David Guillen Fandos 11ec213c99 Make ewram memory lineal
This saves a few cycles in MIPS and simplifies a bit the core.
Removed the write map, only affects interpreter performance very
minimally. Rewired ARM and x86 handlers to support direct access to
I/EWRAM (and VRAM on ARM) to compensate. Overall performance is slightly
better but code is cleaner and allows for further improvements in the
dynarecs.
2021-03-23 19:09:56 +01:00
David Guillen Fandos f6f3a91039 Adding Normmatt's BIOS as a built-in BIOS
Add options to select whether to boot from BIOS (default is no, as it is
now) and whether to use the original bios or the builtin one (default is
auto, which tries to use the official but falls back to the builtin if
not found).
2021-03-22 21:45:52 +01:00
David Guillen Fandos fb7ca09b01 Remove BIOS reserved translation area
This is not really necessary since it can share area with ROM.
Performance impact should be very minimal (haven't noticed it myself)
and could be compensated (even by a positive offset) if we bump the ROM
cache area size.
Tested with several dynarecs.
2021-03-17 18:33:02 +01:00
David Guillen Fandos 34e672ed25 Simplify open load handling for MIPS and fix other arches
Also rewrite a bit memory handlers for smaller functions.
2021-03-16 22:58:58 +01:00
David Guillen Fandos 5ffd2832e8 Rewrite of the MIPS dynarec stubs
This allows us to emit the handlers directly in a more efficient manner.
At the same time it allows for an easy fix to emit PIC code, which is
necessary for libretro. This also enables more platform specific
optimizations and variations, perhaps even run-time multiplatform
support.
2021-03-16 22:58:58 +01:00
David Guillen Fandos 56dc6ecb70 Remove libco
This removes libco and all the usages of it (+pthreads).
Rewired all dynarecs and interpreter to return after every frame so that
libretro can process events. This required to make dynarec re-entrant.

Dynarecs were updated to check for new frame on every update (IRQ, cycle
exhaustion, I/O write, etc). The performance impact of doing so should
be minimal (and definitely outweight the libco gains). While at it,
fixed small issues to get a bit more perf: arm dynarec was not idling
correctly, mips was using stack when not needed, etc.

Tested on PSP (mips), OGA (armv7), Linux (x86 and interpreter). Not
tested on Android though.
2021-03-08 18:44:03 +01:00
David Guillen Fandos 3d558413fd Fix x86 dynarec, broken by d10c4afe
The dynarec expects function args to be located in registers instead of
the stack, which is not the default calling convetion in GCC/clang.
2021-03-06 21:15:22 +01:00
David Guillen Fandos ed3ba2c18b More cleanups (mostly whitespace and unused stuff) 2021-02-15 21:51:49 +01:00
negativeExponent d8225bb313 Add optional battery save using libretro save api
- Adds core option to allow battery saves using the libretro api
  (retro_get_memory_data/size)
- Initial save size set at 128KB and actual size is automatically
  determined internally by gba.
- This will always assume that a save file is supported since save
  size or type cannot be determined until gba tries to write to backup memory.
- A 128KB block of memory is used as buffer, similar method to VBA
  Next/Beetle GBA workarounds.

Fix https://github.com/libretro/gpsp/issues/72
2020-09-05 20:47:59 +08:00
Twinaphex d10c4afea2 Get rid of function_cc 2014-12-20 09:14:38 +01:00
twinaphex ba834beeb1 Change load_gamepak signature 2014-12-20 08:35:53 +01:00
aliaspider a3201b066d increase savestate size, was smaller than what was required for 64-bit
builds.
2014-12-12 02:54:41 +01:00
twinaphex 7a0b0cba45 Style nits 2014-12-10 15:47:19 +01:00
aliaspider 41484cd73c use correct save directory. 2014-12-10 12:00:12 +01:00
aliaspider ad485d434a implement retro_serialize/unserialize 2014-12-10 11:06:17 +01:00
aliaspider afff31b508 fix arm target compile errors. 2014-12-10 01:03:14 +01:00
Renamed from memory.h (Browse further)