Commit Graph

686 Commits

Author SHA1 Message Date
David Guillen Fandos 64b19d1301 Improve and simplify 16 bit I/O writes too 2023-04-21 22:21:01 +02:00
David Guillen Fandos a53399af58 Simplify I/O byte writes
Can easily be mapped to 16 bit writes.
2023-04-21 21:44:34 +02:00
David Guillen Fandos 2d28451f6c Fix SWI branch mismatch
The mismatch causes one-of errors for instruction 0F000000 (swieq 0)
which results in all sorts of funny errors (branches to bad addresses).
Fixes a couple of games.
2023-04-20 21:08:49 +02:00
David Guillen Fandos 8c6ff8d358 Simplify I/O writes further
Improve FIFO writes, make them a bit faster
2023-04-20 00:52:30 +02:00
David Guillen Fandos 6bf53cf3db Minor I/O write improvements 2023-04-19 23:22:18 +02:00
David Guillen Fandos 6eb1071dec Wrap I/O register reads
This can cause issues in big-endian platforms otherwise
2023-04-19 20:03:11 +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 dec09d465c [aarch64] Fix c-flag setting on rotation immediate
This fixes a couple games and makes it pass the CPU test suite
2023-04-17 19:06:05 +02:00
David Guillen Fandos 3f976c9557 Refine BIOS and unmapped memory accesses
Turns out there's a couple of inaccuracies that do affect a couple of
games. Most of them are buggy games but emulating these accesses
correctly helps jumping over some bugs.
2023-04-15 11:44:48 +02:00
David Guillen Fandos 08372aae64 Add missing DMA side effects on I/O writes 2023-04-15 11:44:02 +02:00
David Guillen Fandos bd39c03992 Improve tracing a bit, also in interpreter mode 2023-04-15 02:02:17 +02:00
David Guillen Fandos 46d8616a9f [x86] Do not corrupt edx since it can also corrupt REG_PC 2023-04-15 01:48:29 +02:00
David Guillen Fandos 11d87b89df Rewrite I/O side effects write and IRQ triggers
This rewrites the way that CPU alerts work, making them a bitmap (since
multiple alerts can happen simultaneously, like SMC and IRQ). This
doesn't really fix many games but improves accuracy overall and improves
performance on some I/O writes (the ones without side effects).
The IRQ raising is now decoupled and explicitely called via a new
function (check_and_raise_interrupts) to avoid issues such as invalid
CPSR values (doesn't seem to bother most games!). There's more side
effects missing, so this just lays the ground for more fixes.
2023-04-14 01:41:55 +02:00
David Guillen Fandos 9ef1a4d7b8 Fix tracing conditional ARM insts 2023-04-14 01:40:51 +02:00
David Guillen Fandos 2bbd77054e Fix pending interrupts not raised on IME/IE writes
Whenever an interrupt is pending and interrupts are disabled (via
IME/IE), an IE/IME write that re-enables IRQs will fail to raise an IRQ.
This makes some games hang. Most games seem to use CPSR.IRQ to enable
and disable interruts, so they are not affected. However some others use
IME/IE (or all of them), causing these deadlocks and some race
conditions.

This fixes a bunch of games that did not crash but would "hang" in some
interesting ways.
2023-04-10 12:58:03 +02:00
David Guillen Fandos f9d7f51ef1 Minor cleanup and fix in DMA code. 2023-04-09 14:16:47 +02:00
David Guillen Fandos dc4ec94cbc [arm64] Remove unused epilogue check 2023-04-08 17:14:39 +02:00
David Guillen Fandos 0e17e13c90 [arm] Fix I/O write epilogue
This fixes many games and brings it closer to what the other dynarecs
do. Without this patch there's register corruption if the memory write
triggers an IRQ (since raise_interrupt mangles the registers that have
not been saved).

At this point there's still an issue with CPSR saving but that affects
aso the other dynarecs.
2023-04-06 10:10:16 +02:00
David Guillen Fandos c0b2f05e1d Fix interpreter bug on store-triggered DMAs
In thumb mode, a store that triggers a DMA and its correspondoing DMA
IRQ (since emulate DMAs being instantanious, which is another can of
worms tho...) overrwrites the PC with the PC-next value (disregarding
the IRQ handler address). This causes quite a few bugs. I'd expect it
causing way more bugs, but it doesnt...?

Anyway this fixes a few games like Buffy, Woody, Medabots, Super
Duper Sumos and Power Rangers
2023-04-03 20:24:17 +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 42c6bb2761 [x86-32] Fix missing function_cc
This messed up timings between the 32 bit version and the 64 bit version
2023-03-03 21:05:12 +01:00
LibretroAdmin 522d44556f
Update .gitlab-ci.yml 2023-02-21 19:04:50 +01:00
libretroadmin 175f00d527 Update libretro-common 2023-02-21 19:01:03 +01:00
LibretroAdmin f0387156b8
Merge pull request #188 from mudlord/patch-1
Use proper VFS version.
2023-02-21 11:49:19 +01:00
mudlord eb7d708d71
Use proper VFS version.
VFS callbacks fail since it requires V2, which includes vfs_truncate. Otherwise it falls back to libretro-common code. Current VFS wrapping code in libretro-common needs V2 since vfs_truncate's callback is set.

https://github.com/libretro/libretro-common/blob/master/streams/file_stream.c#L65

Now VFS callbacks work properly in frontends that support them. Otherwise a hack of setting "cb->required_interface_version = 2" in frontend works. Only cores, according to specs, are meant to set the required version.
2023-01-31 05:39:52 +11:00
andymcca 2fcbdc1d17
MODE_UNDEFINED is 0x1B (not 0x1C) (#184)
In the cpu_modes array, MODE_UNDEFINED is at position 0x1C, but this mode value is actually 0x1B.
2023-01-21 21:44:23 +01:00
David Guillen Fandos 4f3c9a5e58 [all] Fix CPSR and CPU modes
gpsp doesn't differentiate between USER and SYSTEM mode, most likely
cause it is not that important for most games. This implements the modes
correctly and adds checks for privileged operations. Still some
bugs/hacks but it mostly fixes CPSR/SPSR reads/writes.

To implement PSR writes we are using a more refined masks and force mode
bit num. 4 to always be one. Reserved bits are forced to zero (this
needs to be validated on a real device).
2023-01-11 21:26:32 +01:00
libretroadmin ad84141fd6 Set aspect ratio to 3/2 2023-01-09 04:21:23 +01:00
David Guillen Fandos 90170e3389 [arm] Fix usermode "movs pc" causing invalid CPU state
A missing usermode check (present in MIPS and x86) causes user-mode
returns to attempt returning into another CPU mode, which causes a bunch
of issues, mainly going into an invalid CPU state and corrupting some
registers.

This fixes a couple of games only (Colin McRae Rally 2, TOCA World
Touring, Starsky & Hutch ...)
2023-01-05 21:29:20 +01:00
David Guillen Fandos 53ac0814de [x86/64] Fix openbus reads (PC is corrupted) 2023-01-05 21:29:20 +01:00
David Guillen Fandos b552d5eb7e Improve open bus reads on ARM/MIPS 2023-01-05 21:29:20 +01:00
David Guillen Fandos 8c4196d19e Add MIPS codegen tests 2023-01-05 21:29:20 +01:00
LibretroAdmin 81649a2c80
Update .gitlab-ci.yml 2022-07-26 14:28:22 +02:00
LibretroAdmin 03fc2b7dbf
Merge pull request #171 from d30r/patch-1
Pokemon Fire Red germany not booting/ White Screen
2022-05-20 22:18:52 +01:00
d30r 5e71cd14d1
Pokemon Fire Red germany not booting/ White Screen
Wrong Gamepak Code causing Pokemon Fire Red not to boot due to wrong flash size (64k instead of 128k)
2022-05-20 13:41:20 +02:00
twinaphex f0f0b31f9a Cleanups 2022-04-09 08:50:38 +02:00
Autechre d4547baf26
Merge pull request #168 from jSTE0/miyoo-small-cache
platforms/miyoo: Use small translation cache
2022-04-04 00:51:29 +01:00
jSTE0 20c09d773c platforms/miyoo: Use small translation cache
As this platform only has 32MB RAM.
2022-04-03 18:55:48 +01:00
twinaphex e554360dd3 Fix for loop initial declaration errors 2022-01-19 19:00:57 +01:00
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