Commit Graph

647 Commits

Author SHA1 Message Date
David Guillen Fandos 4eac8e30a8 Add WAITCNT but do nothing for now 2022-01-05 21:43:03 +01:00
David Guillen Fandos dbbefdf021 [arm] Implement movw/movt for ARMv7
This should speed it up a bit on platforms like Vita.
2022-01-05 17:12:35 +01:00
David Guillen Fandos b6ddec8fa0 Simplify lookup/translate logic to make it simpler. 2022-01-05 16:32:42 +01:00
David Guillen Fandos cb9696cb98 Fix blh for arm/mips to use a thumb branch (not dual)
Also fix ARM32 LR offset, was being truncated to 8 bit when it is a 12
bit offset.
2022-01-04 19:11:36 +01:00
David Guillen Fandos f597836abc Implement dual mode (arm/thumb) for RAM positions
(This is similar to 908fb8 but for memory regions)

Removes the weird offset encoding in favour of a metadata structure,
similar to what there was before. However this structure overlaps with
the cache ram itself and grows like a stack. This is to avoid wating
memory since most games only use a few blocks.
Simplify the "dual" block lookup routines too, since they are only an
extrypoint to the other two real modes.
2022-01-04 18:59:07 +01:00
David Guillen Fandos 8036ad5b50 Fix ram flush again! Wrapping mirrors are hard to track
Track PC on every iteration, round up a couple of instructions and align
the base address for speed.
2022-01-04 00:51:48 +01:00
David Guillen Fandos e71290e0ad Fix out of bounds RAM flush.
This can happen whenever the PC wraps around a mirror.
2022-01-03 01:23:51 +01:00
David Guillen Fandos 908fb831e0 Implement dynarec mode check for ROM code
This allows the emulator to recompile the same block as ARM and Thumb.
Some games do execute some code both as ARM and Thumb if you can believe
it! Also the dynarec can be a bit aggressive at pre-compiling some
blocks and can misunderstand branches in the wrong mode.

This fixes NBA Jam 2002 for all dynarec backends.
2022-01-03 01:18:47 +01:00
David Guillen Fandos ef399b9315 [mips] Remove IWRAM stack optimization hack
Converted the hack into another... hopefully better hack.
Check for IW/EWRAM addr bit and handle accesses to EWRAM by correcting
the base addr and the mirroring range.
Assumes that iwram and ewram buffers are at a distance multiple of 64KB
for speed (so that lw/sw offsets can be shared).

This fixes a variety of games that should have been present in
game_config.txt such as Ninja Cop, Star Wars JPB, Medal of Honor,
Spongebob, etc. Some of them were just missing regional versions of the
cart. It also fixes newer games and homebrew such as GoodBoy Galaxy.
2021-12-30 23:39:09 +01:00
David Guillen Fandos 56f00c162e [mips] Improve SP relative accesses 2021-12-30 00:57:16 +01:00
David Guillen Fandos daac3b7d91 Penalize HLE division, it's just too fast :) 2021-12-21 20:06:24 +01:00
David Guillen Fandos f085883ba7 Merge branch 'cycle-remainder' into better_cycles
Account for both DMA cycles and remainder cycles
2021-12-21 20:05:44 +01:00
David Guillen Fandos 3a6ca8d941 Better cycle accounting, taking remainders partially into account 2021-12-21 19:59:33 +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 7b181cb6ff Fix PC calculation for open bus loads
It was pretty much broken in all platforms, just "ok" enough for it to
work on some games though.
2021-12-20 19:31:33 +01:00
David Guillen Fandos 12cd4e0c06 [aarch64] Add I/O write specific path for speed 2021-12-19 22:35:07 +01:00
David Guillen Fandos 5fbbcfe415 [aarch64] Add accelerated palette writes 2021-12-19 21:01:08 +01:00
David Guillen Fandos d0fd474777 [arm] Fix multiply (muls) and 64 bit mul where rlo==rhi
Seems rhi has precedence over rlo
2021-12-17 10:46:45 +01:00
David Guillen Fandos cce51c948d Minor code refactor, no-op 2021-12-15 21:01:05 +01:00
David Guillen Fandos 88454e922f [MIPS] Correctly implement adcs/sbcs/rscs
Also fix C flag calculation for immediates.
Fixes a couple of games.
2021-12-15 19:02:02 +01:00
David Guillen Fandos c30f910fe8 [interpreter] Fix many flag related bugs including Op2 C flag
This fixes a few games and GBA-V too. C flag was neglected on Op2
immediate. Many add/adc related ops were broken due to carry in.
2021-12-14 00:46:37 +01:00
David Guillen Fandos 9b25f26ed8 [x86] Fix division r3 sign value calculation 2021-12-13 22:26:49 +01:00
David Guillen Fandos c6601d8932 [aarch64] Fix cache flushing out of bounds
Seems like some platforms don't like this very much :|
2021-12-13 18:54:21 +01:00
David Guillen Fandos 76ccba445f [aarch64] Fix mov bug that got in in the last minute :D 2021-12-13 18:49:42 +01:00
David Guillen Fandos fae9c7074b Fix dynarec flag optimization in Thumb mode
Usually blocks end with a branch, which also consumes all flags, but in
case the block is aborted early (or any other reason to not finish the
block on a branch), it will result in only a subset of flags being
generated, which causes problems in a couple of games.

This performs an out of bounds flag read, which is incorrect
2021-12-13 18:42:06 +01:00
David Guillen Fandos 09cab16654 [x86] Do not generate unnecessary flags (optimization) 2021-12-13 18:31:01 +01:00
David Guillen Fandos bcd3d1ca29 [aarch64] Adding new aarch64 dynarec!
This is based on the MIPS dynarec (more or less) with some ARM
borrowings. Seems to be quite fast (under my testing fixed results:
faster than ARM on A1 but not a lot faster than the interpreter on
Android Snapdragon 845) but still some optimizations are missing at the
moment.

Seems to pass my testing suite and compatibility wise is very similar to
arm.
2021-12-12 13:18:13 +01:00
David Guillen Fandos 2419b77b28 Add reg tracing capability (for devs) 2021-12-11 11:27:59 +01:00
David Guillen Fandos 31451d16ff [mips] Fix CPSR store bug during IRQ
Similarly to 61ef776, this fixes the bug for MIPS.
2021-12-10 19:28:06 +01:00
David Guillen Fandos 61ef776fed [x86] Fix CPSR store bug in LR register
There's a race condition on CPSR store (only if mode is changed) where,
if an IRQ is pending, the IRQ will be served, but the saved LR value
will be wrong (will skip the return instruction).
Fixed this and improved the logic a bit to make it faster and not use
unnecessary save slots.
2021-12-10 19:09:20 +01:00
David Guillen Fandos 1667597a43 Fix MIPS s16 unaligned load (although it does not fix any game) 2021-12-09 20:04:56 +01:00
David Guillen Fandos a435c712f8 [x86] Fix multiplication flags for 64 bit muls
This fixes a couple of games.
2021-12-06 18:15:56 +01:00
Autechre be3fdfd0b4
Merge pull request #165 from jdgleaver/audio-sample-pacing
Send audio samples to frontend with correct pacing
2021-11-30 12:03:19 +01:00
jdgleaver 20bd7c111b Calculate number of audio samples to read per frame deterministically 2021-11-29 17:45:06 +00:00
jdgleaver f8359a74d3 Send audio samples to frontend with correct pacing 2021-11-29 15:10:38 +00:00
David Guillen Fandos bc0a3cf2c1 Fix big endian targets state unserialize
Converted palette was missing a byte swap after state unserialization
This should likely fix WiiU graphics when using rewind and similar
techniques that rely on states.
2021-11-20 11:00:42 +01:00
David Guillen Fandos a2aa78733d Further simplify stubs, remove unnecessary masking 2021-11-14 22:40:03 +01:00
David Guillen Fandos 1955336a2b Fix color conversion on interpreter
This causes the MSB to be copied into the green channe LSB, causing a
very subtle (almost imposible to see) color distortion.
Dynarecs use their own code path so are not afected.
2021-11-14 13:19:23 +01:00
David Guillen Fandos 6c4ffc4db2 [arm] Improve external stores and make them faster
While at it, speed up palette writes too.
2021-11-14 13:19:20 +01:00
David Guillen Fandos fda42c959f More mips dead code cleanup 2021-11-14 13:19:02 +01:00
Salvador a384d653c2
Miyoo (#162)
Add Miyoo target
2021-11-14 09:58:26 +01:00
David Guillen Fandos c2c57a6cf0 [MIPS] Minor cleanup 2021-11-07 19:24:02 +01:00
David Guillen Fandos 186950d0ad [x86] Minor simplifications 2021-11-07 19:19:19 +01:00
David Guillen Fandos e8eb753a73 [mips] Minor cleanup and remove a couple of nested functions 2021-11-06 22:31:42 +01:00
David Guillen Fandos 92180d5d7e Minor unused stuff cleanup 2021-11-06 21:49:08 +01:00
David Guillen Fandos c0804fa48d [x64] Enable Android x86-64 support (not tested!) 2021-11-06 12:39:16 +01:00
David Guillen Fandos aa52f960c8 Fix Makefile arch detection support
x86/64 detection only enabled for unix platforms, since other platforms
have hardcoded rules (including windows).
2021-11-06 12:32:20 +01:00
David Guillen Fandos e3d5ca8419 [x86/x64] Add support for x86-64 and improve 32 bit mode too.
This adds support for x86-64 dynarec both on Windows and Linux. Since
they have different requirements there's some macro magic in the stubs
file.

This also fixes x86 support in some cases: stack alignment requirements
where violated all over. This allows the usage of clang as a compiler
(which has a tendency to use SSE instructions more often than gcc does).

To support this I also reworked the mmap/VirtualAlloc magic to make sure
JIT arena stays close to .text.

Fixed some other minor issues and removed some unnecessary JIT code here
and there. clang tends to do some (wrong?) assumptions about global
symbols alignment.
2021-11-06 12:17:50 +01:00
David Guillen Fandos d63fea580c Oops printf there! 2021-11-05 23:15:08 +01:00
David Guillen Fandos 3a7fedb8fb Simplify MMAP machinery for Win/Lin/Mac/Android
This gets rid of the bloated memmap_win32.c in favour of a much simpler
wrapper. This will be needed in the future since the wrapper does not
support MAP_FIXED maps (necessary for some platforms)
2021-11-05 18:23:05 +01:00