Commit Graph

110 Commits

Author SHA1 Message Date
Flyinghead 7adeb53aee arm64 rec: fix typo in FTRC implementation
Issue #1905
2025-05-20 08:52:09 +02:00
Flyinghead b70c2791b2 dynarec: proper ftrc implem. (arm32/64) Use double for fipr/ftrv
Use double for canonical FIPR and FTRV on all platforms.
Fix interpreter implementation of FTRC.
Fix canonical implementation of cvt_f2i (FTRC).
arm32: use Vfma instead of Vmla for FMAC. Vfma does not a fused
muliply-add, Vmla doesn't.
arm32: Use canonical implementations of FIPR and FTRV.
arm32,arm64: Correct implemetation of cvt_f2i (FTRC)

Fixes desync with NBA 2k1/2k2 online games.
2025-01-27 17:30:06 +01:00
Flyinghead 354d649ebd Merge remote-tracking branch 'origin/master' into dev 2024-12-07 20:38:55 +01:00
Flyinghead 129673a84b dynarec: use sh4 ctx to get register pointers. prefer offset
Move restoreHostRoundingMode() into Sh4Context
2024-11-09 18:44:51 +01:00
Flyinghead 7c1c5817d3 sh4: move sqWrite func into sh4 context. Simplify usage
Allow passing sh4 context to dynarec canonical implementations
Reduce FPCB padding to PAGE_SIZE except on arm32
2024-11-09 16:54:47 +01:00
Flyinghead e394840344 sh4: pass sh4 context to dynarecs, sh4cycles and caches
Reorder RuntimeBlockInfo members to save space
2024-11-09 13:25:55 +01:00
Flyinghead db846ca933 sh4: pass context to interpreter funcs. get rid of sh4 regs #define 2024-11-08 18:36:08 +01:00
Flyinghead 9cb7d9e5d5 rec-arm64: fix Store Queue write handlers 2024-11-08 18:27:52 +01:00
Flyinghead e03e11b8a9 arm64: mask value operand when calling a write mem handler
AppleClang doesn't mask the operand in the callee. This must be done in
the dynarec.
See 6115a918b2
Tentative fix for barcode reader not working on macOS/arm
2024-11-07 14:10:02 +01:00
Flyinghead 52df0133f0 sh4: pass sh4 context to sq write handlers 2024-11-06 23:27:20 +01:00
Flyinghead d5aeb482d9 sh4: move sq_buffer into sh4 context 2024-11-06 22:11:27 +01:00
Flyinghead 9793e54646 avoid deadlock when sh4 cpu is restarted while emu is being stopped
The sh4 cpu is stopped/restarted during a soft reset, and dynarec code
reset (arm64, arm, x86). If the emulator is stopped concurrently, the
call may hang. Use a mutex-protected method to restart the cpu only if
the emu is still running.
2024-10-12 17:31:58 +02:00
Wunkolo 56fe3b9c9d Fix `arm64_unwind.h` include-order
`sh4_core.h` has defines for symbols like `r` and `pr` which conflict with the variable names in `arm64_unwind.h` and cause even deeper errors over in `wingdi.h(4954)` and `wincrypt.h(4741)`.

Swapping the include order avoids this collision.
2024-10-07 18:48:26 +02:00
Flyinghead b99b3450c8 sh4: compute fsrra as 1/sqrt(x) instead of sqrt(1/x)
Fixes invisible chaos emerald in Sonic Adventure cutscene after Emerald
Coast.
Partial revert of ec3ad9b.
Issue #1600
2024-08-20 21:12:05 +02:00
Flyinghead ec3ad9b328 sh4: use double for fipr and ftrv. divide before sqrt for fsrra. ssa fix
dynarec: use double to implement fipr and ftrv except on arm32
interpreter: always use double for fipr and ftrv
fsrra: perform division before square root
fmac: use std::fma or native fma op
get rid of unused dynarec op shop_swap
ssa: dead register pass must assume interpreter fallback modifies all
registers
ssa: replace reg+0 address by reg in constant propagation pass
decoder: replace address offset 0 by null param for indexed mem access
2024-06-12 10:54:15 +02:00
Flyinghead fe429ec01e move holly interrupts out of types.h 2023-12-16 23:04:39 +01:00
Flyinghead 2a364dee67 dynarec: check null codeBuffer in rewrite() if called before init
Fixes MINIDUMP-1VN, MINIDUMP-1X1, MINIDUMP-1XD
2023-10-13 11:41:18 +02:00
Flyinghead 60f3d718ac arm64 rec: fix crash with some naomi games (regression)
Fixes crash with doa2a and doa2m and some atomiswave conversions.
Regression due to b47f4f56ef
Fixes MINIDUMP-1TY, MINIDUMP-1TD, MINIDUMP-16Q, MINIDUMP-1AC
2023-10-01 19:31:18 +02:00
Flyinghead 2445739c0e arm,arm64 rec: check fault location before attempting to rewrite
Ignore fault if pc isn't in the dynarec code buffer.

Fix for MINIDUMP-1S0, MINIDUMP-1RS
2023-09-20 17:25:09 +02:00
Flyinghead 0f4c903fed ios build fix 2023-09-12 19:06:59 +02:00
Flyinghead 0ac483acfc sh4 dynarec refactoring
sh4 code buffer class
dynarec interface and implementations
2023-09-12 16:52:25 +02:00
scribam 40953b17c4 uwp: add support for arm64 2023-07-30 18:03:32 +02:00
scribam daf8230cca deps: update vixl 2023-07-03 11:37:42 +02:00
Flyinghead ac2637286b Merge remote-tracking branch 'origin/master' into dev 2023-05-13 15:55:47 +02:00
Flyinghead c8a45d95a7 dynarec: fix mov64 edge case when registers must be swapped
Handle case where mov64 must swap its operands depending on register
allocation.
Fix canonical call for FSCA when return operands are register-allocated.

Issue #1020
2023-04-24 17:38:49 +02:00
Flyinghead 0b1f69bfd2 dynarec: more accurate cycle counting. limit code duplication
arm, arm64, x86: only account for current block cycles if block is
executed. Test cycle_counter before updating it.
arm, arm64: use function for mmu block check (vaddr and FPU ops) to
reduce host code size per block.
2023-03-08 19:24:49 +01:00
Flyinghead 5bfbcb210c dynarec: refactor imm mem r/w and store queue handlers. clean up mmu
Eliminate duplicate code for immediate memory read/write in all dynarecs
Simplify PREF to use do_sqw_nommu even for simple SQ remap
Check for address errors before mmu translation
Get rid of unneeded template params in mmu translation funcs
2023-02-18 13:33:38 +01:00
scribam d8137a967c
C++17 (#926)
* cmake: use c++17

* Use std::size

* Use std::make_unique

* Use std::clamp

* Use structured binding

* Use [[fallthrough]]

* Use enable_if_t/is_enum_v/is_integral_v/is_same_v

* Use if constexpr

* Use try_emplace

* Use auto for iterators

* Use inline variables
2023-02-18 13:24:34 +01:00
Flyinghead 53dab29ddb iOS and Switch build fixes 2023-01-30 11:10:14 +01:00
Flyinghead 143073b61d rename _vmem to addrspace and move platform vmem stuff to virtmem ns
use namespaces
simplify names
no functional changes
2023-01-29 18:48:33 +01:00
Flyinghead 1149d499a8 x86: windows ce support in dynarec
clean up some unused methods and return values
2023-01-28 19:22:36 +01:00
Flyinghead 06c5ba7f0e sh4: simplify exceptions 2023-01-11 20:42:33 +01:00
Flyinghead c04c696ba6 arm64 dynarec: pad link section with nop to allow full mmu relink
fix literal pool being overwritten
Fix for MINIDUMP-18
2023-01-05 14:36:23 +01:00
Flyinghead 9ef37d9776 arm[64] dynarec: xtrct can have immediate operands
Fixes MINIDUMP-15
Sakura Taisen 2 crash
2023-01-03 15:15:13 +01:00
Flyinghead 62085539a7 dynarec: reg alloc 64-bit regs. avoid some interpreter fallbacks
Option to reg alloc 64-bit regs in two host regs. Used when FPSCR.SZ ==
1 (64-bit reg and memory transfers.) Enabled for arm, arm64 and x64
(windows only) dynarecs.
Don't fallback to interpreter when FPSCR.PR==1 (double precision) for
FMOV, FLDS and FLTS.
2022-12-23 16:06:54 +01:00
Flyinghead 599bc8a823 arm64 dynarec: need up to 5 ops for mem accesses
Issue #837
2022-12-22 14:55:42 +01:00
Flyinghead 2800927fa1 arm64 dynarec: can't rely on faultAddress with 512 MB vmem
Use x0 instead
2022-12-16 20:40:23 +01:00
Flyinghead 32e3e7d9c5 vmem: no more 4GB vmem mode. only map elan RAM in naomi2 mode
Do not attempt to reserve 4GM of virtual space on 64-bit hosts. Use
512MB everywhere.
Don't map elan RAM if not needed and dont protect/unprotect it in
memwatch.
2022-12-09 17:37:49 +01:00
scribam f6532ca27a fix some warnings 2022-11-19 12:52:26 +01:00
Flyinghead bc3be1029c fix sh4 scheduler. use common cycle counter in sh4 context
scheduler reset and unregister
schedule requests during reset(), not init()
preserve cntx.sh4_sched_next on sh4 reset
Use cntx.cycle_counter in dynarecs and interpreter
Fixes Confidential Mission hang at boot with HLE
2021-10-07 16:18:32 +02:00
Flyinghead 77e7c25e9c iOS support. Work in progress 2021-08-06 10:30:30 +02:00
Flyinghead 6bb4575c95 Merge remote-tracking branch 'origin/master' into libretro 2021-08-05 18:17:30 +02:00
Flyinghead 9d6c548730 naomi: close cart on reset. sh4: replace some verify by throw
Close naomi/aw cart on reset. Reset input mapping/button names
Get rid of ngen_GetFeatures()
throw exception instead of failing verify if not internal error
catch sh4 exceptions in dynarecs and throw fatal error
2021-08-03 09:47:13 +02:00
Flyinghead 7561ce753a unwind info for arm64. use static c++ lib for android
include oboe static libs
get rid of old regalloc
2021-07-29 17:46:46 +02:00
vkedwardli 3c483c61e7
Support Apple Silicon (macOS ARM Universal Binary) (#253)
* Add audio arm64 cpp into Xcode project

* Build universal binary for SDL2 also

* Add vixl aarch64 dependency + build arm64 in cmake

* hardcode pagesize for M1 CPU

* Use `MAP_JIT` and toggle between RX and RW

* add pthread.h for cmake

* Disable audio dynarec temporary

* Enable aica arm dynarec

* Supports `br` with condition

* Dynamic linker flag for libSDL2.a since Homebrew path is different on arm (for xcodeproj)

* Fallback path for Intel

* de-dup for arm64, allow cross compilation on both Intel and Apple Silicon Mac

* Rename WriteProtect() to JITWriteProtect(), Move JITWriteProtect from arm7_rec to arm7_rec_arm64

* Remove CodeCache memset

* Remove keyboard_device.cpp from xcodeproj

* Use hard tab

* Update libchdr to support compiling on M1 (thanks @scribam)
2021-07-23 22:34:12 +02:00
Flyinghead de060d66ab don't save flash if no game started. libretro: fix notifications
compilation warnings, non-functional changes
2021-07-20 19:21:11 +02:00
Flyinghead 8dee648d01 arm64 rec: put ngen_FailedToFindBlock at a fixed address
transitioning to MMU will fail it this function's address changes
happens if vmem is disabled (switch)
2021-07-14 21:03:02 +02:00
scribam d6545b253b Misc cleanup 2021-06-06 11:15:06 +02:00
Flyinghead 373dffc65a wince: ditch vmem32. use address LUT in dynarec. finer grained flush 2021-05-17 11:59:34 +02:00
Flyinghead 025b447a9c arm32: replace old arm emitter with vixl 2021-05-15 11:41:00 +02:00