Skip to content

Commit

Permalink
gba: reading 32-bit ARM instruction from prefetch buffer takes 1 cycle (
Browse files Browse the repository at this point in the history
#1429)

When an instruction is already present in the prefetch buffer, fetching
the instruction should take only one cycle in both ARM and Thumb modes.
Currently, ares uses 1 cycle for each halfword read from the prefetch
buffer, which is correct for Thumb but not ARM. Fixing this discrepancy
allows ares to pass 1890/2020 of the timing tests in the mGBA test suite
(up from 1760/2020).
  • Loading branch information
png183 committed Mar 27, 2024
1 parent 7be6217 commit a04c215
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
1 change: 1 addition & 0 deletions ares/gba/cpu/bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ auto CPU::get(u32 mode, n32 address) -> n32 {
} else if(address & 0x0800'0000) {
if(mode & Prefetch && wait.prefetch) {
prefetchSync(address);
prefetchStep(1);
word = prefetchRead();
if(mode & Word) word |= prefetchRead() << 16;
} else {
Expand Down
1 change: 0 additions & 1 deletion ares/gba/cpu/prefetch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ auto CPU::prefetchReset() -> void {

auto CPU::prefetchRead() -> n16 {
if(prefetch.empty()) prefetchStep(prefetch.wait);
else prefetchStep(1);

if(prefetch.full()) prefetch.wait = _wait(Half | Sequential, prefetch.load);

Expand Down

0 comments on commit a04c215

Please sign in to comment.