Commit Graph

711 Commits

Author SHA1 Message Date
David Guillen Fandos 60155e0b81 Add preliminary support for PS2 devices 2021-07-22 18:30:45 +02:00
David Guillen Fandos a77c1c9171 Add overridable memory config knob for low-mem platforms 2021-07-21 00:23:10 +02:00
David Guillen Fandos 3009504613 Fix palette calculation on XBGR1555 mode 2021-07-20 23:09:14 +02:00
David Guillen Fandos a8d99d993f Fix potential MIPS issue on cache alignment 2021-07-19 18:55:42 +02:00
David Guillen Fandos 3eddcf8416 Minor mips dead code cleanup 2021-07-19 00:24:45 +02:00
David Guillen Fandos 72a4a91fda Speed up arm stores 2021-07-15 21:27:38 +02:00
David Guillen Fandos ac3e75a107 Reimplement arm load stubs and fix BIOS handler
This fixes unallowed BIOS accesses (outside from BIOS) which fixes some
games like Silent Scope but also Zelda (fixes rolling as reported by
neonloop!)
2021-07-15 00:40:52 +02:00
David Guillen Fandos 221b8ff115 Partially revert 71ebc49b
Just move the complex lookup to C for simplicity since there's not a lot
of gain to have. This makes it easier for devices with weird jit caches.
2021-07-14 01:59:46 +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 3144d9e277 Rework ram block ptrs to remove second indirection table.
This removes ram_block_ptrs and encodes the pointer directly in the
block tag. Saves ~256KB at no performance cost.
Drawback is that it limits the ram cache size to 512KB (we were using
768KB before). Should not be a problem since most games use less than
32KB of cache anyway.

Fixed ARM routines accordingly.
2021-07-08 21:29:48 +02:00
David Guillen Fandos aded681de2 Add support for native XBGR1555 format
This is the format used by PS2.
This requires fixing the palette conversion routines (and palette writes
in the MIPS dynarec) but also adding support for 555 mode blending
(currently only 565 modes are supported, regardless of whether they are
RGB or BGR).
2021-07-07 00:51:29 +02:00
David Guillen Fandos 3790b233f1 Fix JIT section in MIPS (+ minor cleanup)
This seems to be an issue on some devices, better place it in .bss
unless we are running on Linux.
2021-07-07 00:45:28 +02:00
David Guillen Fandos d41d5a4af4 Shave off 250KB of useless memory by fixing the gba_over structure 2021-07-07 00:43:02 +02:00
David Guillen Fandos 0ca87a4807 Fix conditional ARM instructions at the end of a translation block
This fixes issue #133

The explanation is as follows. Most blocks end on an inconditional
jump/branch, but there's two cases where this doesn't happen:
translation gates and when we hit MAX_EXITS. These are very uncommon
cases and therefore more prone to hidden bugs.

When this happens, the last instruction emits a conditional jump (via
arm_conditional_block_header macro) which is patched by a later
instruction via generate_branch_patch_conditional. Typically the last
unconditional branch will trigger the patching condition (which is
aproximately condition != last_condition), but in these two cases it
might not happen, leaving an unpatched branch. This makes x86 and ARM
dynarecs crash in interesting ways (although it might not crash
depending on $stuff and make the bug even harder to track).
2021-07-05 18:19:19 +02:00
David Guillen Fandos 3d874ec5e3 Add palette conversion routine for non-R2 MIPS
Gated MIPS_HAS_R2_INSTS not used at the moment. Tested with qemu.
2021-07-01 12:06:57 +02:00
David Guillen Fandos 836e51b694 Fix some UB behaviour 2021-07-01 12:06:57 +02:00
David G. F 48f1a71fb7
Merge pull request #137 from davidgfnet/master
Enable big-endian devices: gc/wii
2021-06-27 01:30:50 +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 G. F d5ff18d3ce
Merge pull request #136 from davidgfnet/master
Remove macros in dma code
2021-06-25 00:50:19 +02:00
David Guillen Fandos bdf0293980 Remove macros in dma code
This reduces code size more than 20% (which is 200-300KB!).
DMA handling accounts for less than 0.5% the average emulation runtime
which doesn't justify the crazy optimization level that the code has. In
fact it's more than likely that the new code runs faster due to less
I-cache trashing.
2021-06-25 00:44:38 +02:00
David G. F 3221ea0ea8
Merge pull request #135 from davidgfnet/master
Fix CI for OD beta
2021-06-22 23:50:51 +02:00
David Guillen Fandos 8739b97b2d Fix CI for OD beta 2021-06-22 23:50:07 +02:00
David G. F 5bfd9ced9a
Merge pull request #134 from davidgfnet/master
Some MIPS fixes
2021-06-22 00:20:15 +02:00
David Guillen Fandos dbf72e95ef Fix the no-caller-saves bug for MIPS
Seems that ABI mandates that we allocate space for arg0..4 even if we do
pass them as registers. For some reason write_io_register<> functions
write in that stack area (1 word) corrupting the s0 saved register.
This seems to be a new gcc behaviour?
2021-06-22 00:09:44 +02:00
David Guillen Fandos f8d4276e12 Add support for mips64n32
This only needs some support to save/load state with 64 bit registers.
Since pointers remain 32 bit, no extra changes are needed in the
dynarec. Verified with qemu (qemu-mipsn32el) and miniretro.
2021-06-21 19:17:19 +02:00
David Guillen Fandos e0a31952db Add preliminary support for non mips32r2 devices
This is required in PS2 but could also make older dingux devices run
gpsp on retroarch
2021-06-18 18:03:47 +02:00
David Guillen Fandos 34b90277bc Rework patch handlers (MIPS) 2021-06-16 19:35:11 +02:00
David Guillen Fandos a160b6de50 Minor cleanup in MIPS code 2021-06-16 19:12:32 +02:00
David Guillen Fandos 1138636478 Update libretro.h with the new extensions from upstream 2021-06-09 18:13:39 +02:00
David Guillen Fandos 7a642069e3 Cleanup unused stuff 2021-06-09 18:10:26 +02:00
David Guillen Fandos f19f1695a6 Minor mips asm cleanup and fixes 2021-05-20 15:46:04 +02:00
David Guillen Fandos 261b2db9bb Cleanup Makefiles a bit 2021-05-19 20:11:35 +02:00
David Guillen Fandos ea2608812f Minor optimization 2021-05-19 20:11:35 +02:00
Autechre 96b3ed46eb
Merge pull request #130 from jdgleaver/turbo-buttons
Add turbo A/B buttons
2021-05-17 16:12:37 +02:00
jdgleaver d0b35e939c Add turbo A/B buttons 2021-05-17 13:02:41 +01:00
David Guillen Fandos aafde6de7b Add ROM mirroring and fix mult. cycle count
This should correct some minor issues in some games.
2021-05-17 01:16:56 +02:00
David Guillen Fandos 2877886ff1 Fix ARM dynarec unaligned 32 bit loads
This might make a handful games slightly slower (but on the upper side
they work now instead of crashing or restarting).
Also while at it, fix some minor stuff in arm stubs for speed.
2021-05-17 01:16:56 +02:00
Autechre cc1a074621
Merge pull request #86 from jdgleaver/ff-button
Add dedicated RetroPad fast-forward button
2021-05-13 17:16:23 +02:00
jdgleaver 134aba2b37 Add dedicated RetroPad fast-forward button 2021-05-13 16:03:55 +01:00
David Guillen Fandos 37430f22c5 Small optimization (~2-4%) and whitespace cleanup!
Cleans up a ton of whitespace in cpu.c (like 100KB!) and improves
readability of some massive decode statements.

Added an optimization for PC-relative loads (pool load) in ROM (since
it's read only and cannot possibily change) that directly emits an
immediate load. This is way faster, specially in MIPS/x86, ARM can be
even faster if we rewrite the immediate load macros to also use a pool.
2021-05-07 20:41:54 +02:00
David Guillen Fandos 7877a8888b Fix aligned32 reads in interpreter mode
An address check was missing to read aligned 32 (stm/ldm) data from
high mem areas (0xX0000000). This fixes SM4 EU that for some reason has
some weird memory access (perhaps a bug?)
2021-05-05 21:33:48 +02:00
David Guillen Fandos 883f07f487 Fix small buf and add cheat error messages
Some minor formating too
2021-05-05 21:15:27 +02:00
David Guillen Fandos 4fd456e158 Adding Code Breaker cheat support
This works on both interpreter and dynarec.
Tested in MIPS, ARM and x86, still needs some more testing, some edge
cases can be buggy.
2021-05-05 21:15:27 +02:00
negativeExponent 52088a4d10 Fix invalid memory map entries 2021-04-28 01:05:11 +02:00
David Guillen Fandos d83f8fbd25 Fix Vita port and likely some Linux/Android hidden issues
Using an invalid SP makes Vita crash (for an unkown reason) and makes
things like C signal handlers crash (luckily Retroarch doesn't use
them). It is also a violation of the ABI and not a great idea.
Recycled some little used registers to free SP. Perf should be roughly
the same.
2021-04-27 18:39:46 +02:00
David Guillen Fandos ff48af07b0 Fix RTC support for MIPS 2021-04-26 19:42:59 +02:00
David Guillen Fandos a5c06f62d6 Fix palette writes in MIPS
Was not writing to the right address (but decoded memory was working).
Most game worked well except those that depend on modifying the existing
palette bits (instead of copying from ROM/RAM). Fixes several games.
2021-04-04 18:13:15 +02:00
David Guillen Fandos 5bee4d66c2 Do not use stack in mips stubs
No need for it (faster) and avoid mis-aligning it across calls
2021-04-03 23:43:32 +02:00
David Guillen Fandos 5b5a4db6c2 Add instruction tracing, for testing purposes 2021-04-03 00:37:42 +02:00