Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Darren Thompson <[email protected]>
  • Loading branch information
LukeUsher and DiscoStarslayer authored Jan 11, 2025
1 parent aeef2d8 commit 1edf83b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ares/n64/aleck64/aleck64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct Aleck64 : Memory::RCP<Aleck64> {

template<u32 Size>
auto writeBurst(u32 address, u32 *value, const char *peripheral) -> void {
address = address & 0x00ff'ffff;
if (address >= size) return;
Memory::Writable::write<Word>(address | 0x00, value[0]);
Memory::Writable::write<Word>(address | 0x04, value[1]);
Expand All @@ -23,6 +24,7 @@ struct Aleck64 : Memory::RCP<Aleck64> {

template<u32 Size>
auto readBurst(u32 address, u32 *value, const char *peripheral) -> void {
address = address & 0x00ff'ffff

Check failure on line 27 in ares/n64/aleck64/aleck64.hpp

View workflow job for this annotation

GitHub Actions / ares-macos-universal

expected ';' after expression
if (address >= size) {
value[0] = value[1] = value[2] = value[3] = 0;
if (Size == ICache)
Expand Down
19 changes: 16 additions & 3 deletions ares/n64/aleck64/io.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
auto Aleck64::readWord(u32 address, Thread& thread) -> u32 {
if(address <= 0xc07f'ffff) {
return sdram.read<Word>(address);
return sdram.read<Word>(address & 0x00ff'ffff);
}

controls.poll();
Expand All @@ -9,6 +9,7 @@ auto Aleck64::readWord(u32 address, Thread& thread) -> u32 {
case 0xc080'0000: return readPort1();
case 0xc080'0004: return readPort2();
case 0xc080'0008: return readPort3();
case 0xc080'0100: return readPort4(); // can just be a stub for now, game is happy without it
}
}

Expand All @@ -18,12 +19,13 @@ auto Aleck64::readWord(u32 address, Thread& thread) -> u32 {

auto Aleck64::writeWord(u32 address, u32 data, Thread& thread) -> void {
if(address <= 0xc07f'ffff) {
return sdram.write<Word>(address, data);
return sdram.write<Word>(address & 0x00ff'ffff, data);
}

if(address <= 0xc080'0fff) {
switch (address & 0xffff'fffc) {
case 0xc080'0008: return writePort3(data);
case 0xc080'0100: return writePort4(data);
}
}

Expand Down Expand Up @@ -56,4 +58,15 @@ auto Aleck64::writePort3(n32 data) -> void {
if(gameConfig) return gameConfig->writeExpansionPort(data);
//debug(unusual, "[Aleck64::writePort3] ", hex(data, 8L));
print("[Aleck64::writePort3] ", hex(data, 8L), "\n");
}
}

auto Aleck64::readPort4() -> u32 {
//debug(unimplemented, "[Aleck64::readPort4]");
print("[Aleck64::readPort4]\n");
return 0x0;
}

auto Aleck64::writePort4(n32 data) -> void {
// debug(unimplemented, "[Aleck64::writePort3] ", hex(data, 8L));
print("[Aleck64::writePort4] ", hex(data, 8L), "\n");
}
12 changes: 9 additions & 3 deletions ares/n64/memory/bus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ inline auto Bus::read(u32 address, Thread& thread, const char *peripheral) -> u6
if(address <= 0x1fbf'ffff) return pi.read<Size>(address, thread);
if(address <= 0x1fcf'ffff) return si.read<Size>(address, thread);
if(address <= 0x7fff'ffff) return pi.read<Size>(address, thread);
if(Model::Aleck64()) return aleck64.read<Size>(address, thread);
if(Model::Aleck64()) {
if(address <= 0xbfff'ffff) return freezeUnmapped(address), 0;
if(address <= 0xc0800'fff) return aleck64.read<Size>(address, thread);
}
return freezeUnmapped(address), 0;
}

Expand All @@ -46,7 +49,7 @@ inline auto Bus::readBurst(u32 address, u32 *data, Thread& thread) -> void {

if(Model::Aleck64()) {
if(address <= 0xbfff'ffff) return freezeUncached(address);
if(address <= 0xc07f'ffff) return aleck64.sdram.writeBurst<Size>(address, data, "CPU");
if(address <= 0xc07f'ffff) return aleck64.sdram.readBurst<Size>(address, data, "CPU");
}

return freezeUncached(address);
Expand Down Expand Up @@ -77,7 +80,10 @@ inline auto Bus::write(u32 address, u64 data, Thread& thread, const char *periph
if(address <= 0x1fbf'ffff) return pi.write<Size>(address, data, thread);
if(address <= 0x1fcf'ffff) return si.write<Size>(address, data, thread);
if(address <= 0x7fff'ffff) return pi.write<Size>(address, data, thread);
if(Model::Aleck64()) return aleck64.write<Size>(address, data, thread);
if(Model::Aleck64()) {
if(address <= 0xbfff'ffff) return freezeUnmapped(address);
if(address <= 0xc0800'fff) return aleck64.write<Size>(address, data, thread);
}
return freezeUnmapped(address);
}

Expand Down

0 comments on commit 1edf83b

Please sign in to comment.