When using a big sprite with a tile at the end of the 32KB VRAM block it
might end up reading past the 32KB block. This is not an "issue" since
the VRAM wraps around within the 32KB block.
This fixes many games that use the PSG, particuarly the noise generator.
It is very noticeable in explosion/collision sounds with Sonic and Kirby
games, where the noise channel is rapidly tweaked.
On a reset bios_swi_entrypoint can end up pointing to code over the
watermark, due to block_lookup_address_arm looking up the function
instead of translating it.
Fix it by making flush and init different functions (albeit similar).
Tested by running and resetting games automatically, causing ~10% of
games to crash.
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.
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.
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.
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.
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.