Commit Graph

563 Commits

Author SHA1 Message Date
David Guillen Fandos 33f1e25099 Emit BIOS SWI entrypoint to ROM arena
This fixes a race condition that happens whenever the ROM cache is flushed but
the RAM one is not, causing any SWI calls (implemented as direct branches) to
jump to random instructions.
The fix could be to flush both caches at the same time (~expensive on
low mem platforms), use indirect jumps (a bit expensive) or emit the SWI
handler below the watermark to ensure it is never flushed. This is cheap
and effective, requires minimal changes.
2021-09-10 00:30:55 +02:00
David Guillen Fandos b431a8a4b6 Merge stub arena into ROM cache for simplicity. 2021-09-09 19:06:15 +02:00
David Guillen Fandos 663767b078 Checking in Normatt's BIOS source code for reference and development. 2021-09-07 00:28:31 +02:00
David Guillen Fandos ad6bf7f24a Minor x86 edits 2021-09-03 18:51:57 +02:00
David Guillen Fandos f51ed9de13 Improve SWI codepaths and implement div&divarm natively 2021-09-03 01:01:37 +02:00
David Guillen Fandos e0708b1dcf x86: Simplify thumb instructions and remove last function calls 2021-09-01 19:34:43 +02:00
David Guillen Fandos 8dda395c54 Implement asr/lsl/ror/lsr operand2 natively
This gives some small perf bump
2021-08-31 21:18:22 +02:00
David Guillen Fandos 66e011b0a3 Write most alu/log x86 operations as emitted code
This is around 8% perf improvement alone.
This also fixes many flag calculation/usage bugs (in corner cases) since
we use the x86 cpu native ALU flags (which are more or less the same as
ARM's). Passes all test ROMs for ALUs and no changes in game compat.
2021-08-31 00:42:47 +02:00
David Guillen Fandos 2295dc4a3a Fix bad ARM code emitter bug
This mis-emits CMN instead of TEQ and TST in the reg-shift operand mode.
This is never used by gpsp directly but translating real tst opcodes,
hence it only affects games using such instruction.

This fixes video players that previously crashed, many games that had
graphical glitches in ARM mode (but not on other CPUs) usually in menus
or other dialogues. Also fixes games that either crashed or went blank
or similar issues. The extent of fixing is hard to determine but could
affect many games in different levels.
2021-08-30 02:07:31 +02:00
David Guillen Fandos 55c6a69ccd Move flag regs to unserialized area
This is only used in x86 (mips and arm use native regs and never spill)
2021-08-28 17:50:25 +02:00
David Guillen Fandos d649fe96cb Fix high/low ram watermark tracking
Fixes negative sized memset calls and some wrap around bugs. Fixes at
least a couple of games.
2021-08-28 16:49:41 +02:00
David Guillen Fandos 1feab54699 Rewrite DMA handlers
Make it cleaner and clearer, also fix an out of bounds issue in high
memory regions.
2021-08-27 21:38:38 +02:00
David Guillen Fandos 8e50b168cb Fix OOO access on last instruction.
Cycle counting is a bit broken, needs some rework.
2021-08-26 13:40:48 +02:00
David Guillen Fandos 8207775256 Fix out of bounds read bug on open bus read
This bug doesn't affect many games but makes sanitizers unhappy.
Also fix some minor FIFO clear bug
2021-08-24 19:55:37 +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 40b3cd51ec Fix sign extension from BG references (broke it in 7f7d06) 2021-08-24 17:13:39 +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 b61bec202f Simplify EEPROM handling and remove some mem aliasing warnings.
This fixes issue #29
2021-08-22 00:23:53 +02:00
David Guillen Fandos fb830447ba Simplify DMA handling 2021-08-21 19:41:52 +02:00
David Guillen Fandos a3377c2ac1 Minor DMA cleanup 2021-08-21 18:10:12 +02:00
David Guillen Fandos 86b365f065 Remove unused variable 2021-08-21 16:59:07 +02:00
David Guillen Fandos 77803adcac Remove more unused stuff 2021-08-20 17:39:35 +02:00
David Guillen Fandos 1409e04629 Remove unused crust 2021-08-16 00:03:24 +02:00
David Guillen Fandos 7f7d066854 Remove video vars serialization
This is not needed at all, since the variables are not updated between
reload and end-of-frame (where we take our savestates). Added a reload
call during gba_load_state() to initialize it from the I/O regs.
2021-08-15 23:30:57 +02:00
David Guillen Fandos 745b2ece2c Fix inifinite loop in the interpreter, fixes ~6 games
Seems that, on IRQ, it is assumed that the PC will change (which happens
most of the time). However if the IRQ is masked it resumes execution.
On masked DMA IRQ the interpreter jumps to alert without incrementing
the instruction pointer (right after).
2021-08-15 23:02:12 +02:00
David Guillen Fandos f5232543f5 Improve tracing prints 2021-08-15 22:48:43 +02:00
David Guillen Fandos 057b80f8cc Fix a bug with BLH (half BL) on ARM
This fixes issues on games from Camelot (GS2 and Mario Golf)
2021-08-15 22:19:40 +02:00
David Guillen Fandos 1b37289890 Fix MIPS instruction tracing 2021-08-15 22:13:33 +02:00
David Guillen Fandos 14bc6e3554 Remove unnecessary check in update stub (arm) 2021-08-15 21:52:26 +02:00
David Guillen Fandos 5be5015338 Rearrange register layout and exclude useless regs from savestat
This changes the savestate format once again.
2021-08-15 21:07:20 +02:00
David Guillen Fandos 2d34d91c64 Fix iwram stack optimization on Kirby
Seems that it break it, probably uses a SP pointer to EWRAM or similar
2021-08-15 20:24:59 +02:00
David Guillen Fandos ce14e2585b Fix and reenable Android arm 32 bit builds
Removed the last bits of text relocations by moving all relevant RAMs to
the stub reachable area. This should be as fast or even faster than
previous code.
2021-07-31 17:45:46 +02:00
David Guillen Fandos b3abefa7d9 Avoid using relocations in arm code 2021-07-31 00:20:18 +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
Autechre 7ba465089c
Merge pull request #145 from Poligraf/retrofw
add retrofw target
2021-07-30 12:16:36 +02:00
Poligraf 80f86535e7
add retrofw target 2021-07-30 20:35:15 +12:00
David Guillen Fandos efee37f82c Re-enable Android x86 builds 2021-07-28 19:14:45 +02:00
David Guillen Fandos ab7d9bb161 Move membuffers close to dynarec area to fix x86 relocs
This essentially makes it easier to get a relocation-free text area for
x86 so that Android loaders are happy.
2021-07-28 19:12:43 +02:00
David Guillen Fandos dec6f50d89 Fix DMA VRAM mirror overflow and small 1-off error
Seems that this could make VRAM overflow big time and overwrite IWRAM
most of the time (since it lives after that buffer). This causes a
variety of errors, some of them hidden if IWRAM not used.
Most games do not use VRAM mirror so it's not a big deal, but some do
have a off-by-one errors that trigger this.
2021-07-28 01:26:19 +02:00
David Guillen Fandos 5fe5121c81 Remove pointer from sound struct, use index instead
This makes serialization possible, previously it was broken.
2021-07-27 21:45:15 +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 19d67af0bd Revert Android 32 bit builds
Working on getting them fixed soon
2021-07-27 21:11:19 +02:00
David Guillen Fandos 8e670a3263 Rewire warning flags (new NDK?) 2021-07-27 01:06:06 +02:00
David Guillen Fandos ae2a656e66 Remove nested functions in arm dynarec
Re-enable Android builds
2021-07-27 00:47:54 +02:00
David Guillen Fandos b0947a1ae1 Promote nested functions to macros, fix clang builds
Add x86 Android builds back to the CI now that it's fixed (tested with
NDK r21)
2021-07-26 21:41:07 +02:00
Autechre 1d8313cc14
Merge pull request #143 from fjtrujy/master
Add PS2 to the CI for compilation
2021-07-25 20:02:34 +02:00
Francisco Javier Trujillo Mata 49d6efa3d1 Add PS2 to the CI for compilation 2021-07-25 20:01:36 +02:00
Autechre 828965d33d
Merge pull request #142 from davidgfnet/master
Add PS2 builds and expand the ROM buffer to 16MB
2021-07-24 17:38:41 +02:00
David Guillen Fandos 8ddfae6bc2 Add PS2 builds and expand the ROM buffer to 16MB
This requires the new PS2 font drive to work, since gskit uses too much
memory.
2021-07-24 02:02:12 +02:00
Autechre d468f473e8
Add RS-90 support to Gitlab 2021-07-23 21:09:17 +02:00