Triforce: Warning silencing and other minor cleanups.

This commit is contained in:
Jordan Woyak
2026-02-15 20:14:14 -06:00
parent 56ed7817de
commit 95442a2b6a
5 changed files with 77 additions and 142 deletions
+13 -16
View File
@@ -4,7 +4,6 @@
#include "Core/HW/DVD/AMMediaboard.h" #include "Core/HW/DVD/AMMediaboard.h"
#include <algorithm> #include <algorithm>
#include <cstdint>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
@@ -33,8 +32,6 @@
#include "Core/Movie.h" #include "Core/Movie.h"
#include "Core/System.h" #include "Core/System.h"
#include "DiscIO/DirectoryBlob.h"
#if defined(__linux__) or defined(__APPLE__) or defined(__FreeBSD__) or defined(__NetBSD__) or \ #if defined(__linux__) or defined(__APPLE__) or defined(__FreeBSD__) or defined(__NetBSD__) or \
defined(__HAIKU__) defined(__HAIKU__)
@@ -215,14 +212,14 @@ static bool SafeCopyToEmu(Memory::MemoryManager& memory, u32 address, const u8*
memory.CopyToEmu(address, source + offset, length); memory.CopyToEmu(address, source + offset, length);
return true; return true;
} }
static bool SafeCopyFromEmu(Memory::MemoryManager& memory, u8* destionation, u32 address, static bool SafeCopyFromEmu(Memory::MemoryManager& memory, u8* destination, u32 address,
u64 destionation_size, u32 offset, u32 length) u64 destination_size, u32 offset, u32 length)
{ {
if (offset > destionation_size || length > destionation_size - offset) if (offset > destination_size || length > destination_size - offset)
{ {
ERROR_LOG_FMT(AMMEDIABOARD, ERROR_LOG_FMT(AMMEDIABOARD,
"GC-AM: Write overflow: offset=0x{:08x}, length={}, destionation_size={}", offset, "GC-AM: Write overflow: offset=0x{:08x}, length={}, destination_size={}", offset,
length, destionation_size); length, destination_size);
return false; return false;
} }
@@ -235,13 +232,13 @@ static bool SafeCopyFromEmu(Memory::MemoryManager& memory, u8* destionation, u32
return false; return false;
} }
memory.CopyFromEmu(destionation + offset, address, length); memory.CopyFromEmu(destination + offset, address, length);
return true; return true;
} }
static SOCKET socket_(int af, int type, int protocol) static SOCKET socket_(int af, int type, int protocol)
{ {
for (u32 i = 1; i < 64; ++i) for (u32 i = 1; i < std::size(s_sockets); ++i)
{ {
if (s_sockets[i] == SOCKET_ERROR) if (s_sockets[i] == SOCKET_ERROR)
{ {
@@ -256,7 +253,7 @@ static SOCKET socket_(int af, int type, int protocol)
static SOCKET accept_(int fd, sockaddr* addr, socklen_t* len) static SOCKET accept_(int fd, sockaddr* addr, socklen_t* len)
{ {
for (u32 i = 1; i < 64; ++i) for (u32 i = 1; i < std::size(s_sockets); ++i)
{ {
if (s_sockets[i] == SOCKET_ERROR) if (s_sockets[i] == SOCKET_ERROR)
{ {
@@ -711,8 +708,8 @@ u32 ExecuteCommand(std::array<u32, 3>& dicmd_buf, u32* diimm_buf, u32 address, u
{ {
INFO_LOG_FMT(AMMEDIABOARD, "GC-AM: Read All.Net Buffer ({:08x},{})", offset, length); INFO_LOG_FMT(AMMEDIABOARD, "GC-AM: Read All.Net Buffer ({:08x},{})", offset, length);
// Fake reply // Fake reply
SafeCopyToEmu(memory, address, (u8*)s_allnet_reply, sizeof(s_allnet_reply), SafeCopyToEmu(memory, address, reinterpret_cast<const u8*>(s_allnet_reply),
offset - AllNetBuffer, sizeof(s_allnet_reply)); sizeof(s_allnet_reply), offset - AllNetBuffer, sizeof(s_allnet_reply));
return 0; return 0;
} }
@@ -1239,8 +1236,8 @@ u32 ExecuteCommand(std::array<u32, 3>& dicmd_buf, u32* diimm_buf, u32 address, u
// Firmware memory (2MB) // Firmware memory (2MB)
if ((offset >= 0x00400000) && (offset <= 0x600000)) if ((offset >= 0x00400000) && (offset <= 0x600000))
{ {
const u32 fwoffset = offset - 0x00400000; const u32 fw_offset = offset - 0x00400000;
memory.CopyFromEmu(s_firmware + fwoffset, address, length); memory.CopyFromEmu(s_firmware + fw_offset, address, length);
return 0; return 0;
} }
} }
@@ -1843,7 +1840,7 @@ void Shutdown()
s_dimm_disc.clear(); s_dimm_disc.clear();
// Close all sockets // Close all sockets
for (u32 i = 1; i < 64; ++i) for (u32 i = 1; i < std::size(s_sockets); ++i)
{ {
if (s_sockets[i] != SOCKET_ERROR) if (s_sockets[i] != SOCKET_ERROR)
{ {
+1 -1
View File
@@ -321,7 +321,7 @@ void DVDInterface::ResetDrive(bool spinup)
else if (!spinup) else if (!spinup)
{ {
// Wii hardware tests indicate that this is used when ejecting and inserting a new disc, or // Wii hardware tests indicate that this is used when ejecting and inserting a new disc, or
// performing a reset without spin up. // performing a reset without spin-up.
SetDriveState(DriveState::DiscChangeDetected); SetDriveState(DriveState::DiscChangeDetected);
} }
else else
+13 -76
View File
@@ -4,6 +4,7 @@
#include "Core/HW/SI/SI_DeviceAMBaseboard.h" #include "Core/HW/SI/SI_DeviceAMBaseboard.h"
#include <algorithm> #include <algorithm>
#include <numeric>
#include <string> #include <string>
#include <fmt/format.h> #include <fmt/format.h>
@@ -41,7 +42,6 @@
namespace SerialInterface namespace SerialInterface
{ {
void JVSIOMessage::Start(int node) void JVSIOMessage::Start(int node)
{ {
m_last_start = m_pointer; m_last_start = m_pointer;
@@ -89,7 +89,7 @@ void JVSIOMessage::AddData(const u8* dst, std::size_t len, int sync = 0)
void JVSIOMessage::AddData(const void* data, std::size_t len) void JVSIOMessage::AddData(const void* data, std::size_t len)
{ {
AddData((const u8*)data, len); AddData(static_cast<const u8*>(data), len);
} }
void JVSIOMessage::AddData(const char* data) void JVSIOMessage::AddData(const char* data)
@@ -117,21 +117,14 @@ void JVSIOMessage::End()
} }
} }
static u8 CheckSumXOR(u8* data, u32 length) static constexpr u8 CheckSumXOR(const u8* data, u32 length)
{ {
u8 check = 0; return std::accumulate(data, data + length, u8{}, std::bit_xor());
for (u32 i = 0; i < length; i++)
{
check ^= data[i];
} }
return check; static constexpr char s_cdr_program_version[] = {" Version 1.22,2003/09/19,171-8213B"};
} static constexpr char s_cdr_boot_version[] = {" Version 1.04,2003/06/17,171-8213B"};
static constexpr u8 s_cdr_card_data[] = {
static const char s_cdr_program_version[] = {" Version 1.22,2003/09/19,171-8213B"};
static const char s_cdr_boot_version[] = {" Version 1.04,2003/06/17,171-8213B"};
static const u8 s_cdr_card_data[] = {
0x00, 0x6E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07, 0x00, 0x00, 0x0B, 0x00, 0x6E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07, 0x00, 0x00, 0x0B,
0x00, 0x00, 0x0E, 0x00, 0x00, 0x10, 0x00, 0x00, 0x17, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x10, 0x00, 0x00, 0x17, 0x00, 0x00, 0x19, 0x00, 0x00,
0x1A, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x20, 0x00, 0x1A, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x20, 0x00,
@@ -139,7 +132,7 @@ static const u8 s_cdr_card_data[] = {
0x00, 0x00, 0x2C, 0x00, 0x00, 0x2F, 0x00, 0x00, 0x34, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x2F, 0x00, 0x00, 0x34, 0x00, 0x00, 0x35, 0x00, 0x00,
0x37, 0x00, 0x00, 0x38, 0x00, 0x00, 0x39, 0x00, 0x00, 0x3D, 0x00}; 0x37, 0x00, 0x00, 0x38, 0x00, 0x00, 0x39, 0x00, 0x00, 0x3D, 0x00};
const static u8 s_region_flags[] = "\x00\x00\x30\x00" const constexpr u8 s_region_flags[] = "\x00\x00\x30\x00"
// "\x01\xfe\x00\x00" // JAPAN // "\x01\xfe\x00\x00" // JAPAN
"\x02\xfd\x00\x00" // USA "\x02\xfd\x00\x00" // USA
//"\x03\xfc\x00\x00" // export //"\x03\xfc\x00\x00" // export
@@ -149,19 +142,6 @@ CSIDevice_AMBaseboard::CSIDevice_AMBaseboard(Core::System& system, SIDevices dev
int device_number) int device_number)
: ISIDevice(system, device, device_number) : ISIDevice(system, device, device_number)
{ {
std::ranges::fill(m_coin, 0);
// Setup IC-card
m_ic_card_state = 0x20;
m_ic_card_status = ICCARDStatus::Okay;
m_ic_card_session = 0x23;
m_ic_write_size = 0;
m_ic_write_offset = 0;
memset(m_ic_write_buffer, 0, sizeof(m_ic_write_buffer));
memset(m_ic_card_data, 0, sizeof(m_ic_card_data));
// Card ID // Card ID
m_ic_card_data[0x20] = 0x95; m_ic_card_data[0x20] = 0x95;
m_ic_card_data[0x21] = 0x71; m_ic_card_data[0x21] = 0x71;
@@ -180,44 +160,6 @@ CSIDevice_AMBaseboard::CSIDevice_AMBaseboard(Core::System& system, SIDevices dev
// Use count // Use count
m_ic_card_data[0x28] = 0xFF; m_ic_card_data[0x28] = 0xFF;
m_ic_card_data[0x29] = 0xFF; m_ic_card_data[0x29] = 0xFF;
// Setup CARD
m_card_memory_size = 0;
m_card_is_inserted = false;
m_card_offset = 0;
m_card_command = 0;
m_card_clean = 0;
m_card_write_length = 0;
m_card_wrote = 0;
m_card_read_length = 0;
m_card_read = 0;
m_card_bit = 0;
m_card_shutter = true; // Open
m_card_state_call_count = 0;
// Serial
m_wheel_init = 0;
m_motor_init = 0;
m_motor_force_y = 0;
m_fzdx_seatbelt = true;
m_fzdx_motion_stop = false;
m_fzdx_sensor_right = false;
m_fzdx_sensor_left = false;
m_rx_reply = 0xF0;
m_fzcc_seatbelt = true;
m_fzcc_sensor = false;
m_fzcc_emergency = false;
m_fzcc_service = false;
memset(m_motor_reply, 0, sizeof(m_motor_reply));
} }
constexpr u32 SI_XFER_LENGTH_MASK = 0x7f; constexpr u32 SI_XFER_LENGTH_MASK = 0x7f;
@@ -1177,7 +1119,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* buffer, int request_length)
if (m_card_state_call_count > 10) if (m_card_state_call_count > 10)
{ {
if (m_card_bit & 2) if (m_card_bit & 2)
m_card_bit &= ~2; m_card_bit &= ~2u;
else else
m_card_bit |= 2; m_card_bit |= 2;
@@ -1400,10 +1342,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* buffer, int request_length)
u8 jvs_buf[0x80]; u8 jvs_buf[0x80];
if (frame_len > sizeof(jvs_buf)) frame_len = std::min<u32>(frame_len, sizeof(jvs_buf));
{
frame_len = sizeof(jvs_buf);
}
memcpy(jvs_buf, frame, frame_len); memcpy(jvs_buf, frame, frame_len);
@@ -1555,7 +1494,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* buffer, int request_length)
case JVSIOCommand::MainID: case JVSIOCommand::MainID:
while (*jvs_io++) while (*jvs_io++)
{ {
}; }
message.AddData(StatusOkay); message.AddData(StatusOkay);
break; break;
case JVSIOCommand::SwitchesInput: case JVSIOCommand::SwitchesInput:
@@ -2099,7 +2038,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* buffer, int request_length)
NOTICE_LOG_FMT(SERIALINTERFACE_JVSIO, "JVS-IO: Command 0xF1, SetAddress: node={}", NOTICE_LOG_FMT(SERIALINTERFACE_JVSIO, "JVS-IO: Command 0xF1, SetAddress: node={}",
node); node);
message.AddData(node == 1); message.AddData(node == 1);
dip_switch_1 &= ~1; dip_switch_1 &= ~1u;
break; break;
default: default:
ERROR_LOG_FMT(SERIALINTERFACE_JVSIO, "JVS-IO: Unhandled: node={}, command={:02x}", ERROR_LOG_FMT(SERIALINTERFACE_JVSIO, "JVS-IO: Unhandled: node={}, command={:02x}",
@@ -2180,13 +2119,11 @@ CSIDevice_AMBaseboard::EButtonCombo
CSIDevice_AMBaseboard::HandleButtonCombos(const GCPadStatus& pad_status) CSIDevice_AMBaseboard::HandleButtonCombos(const GCPadStatus& pad_status)
{ {
// Keep track of the special button combos (embedded in controller hardware... :( ) // Keep track of the special button combos (embedded in controller hardware... :( )
EButtonCombo temp_combo; EButtonCombo temp_combo = COMBO_NONE;
if ((pad_status.button & 0xff00) == (PAD_BUTTON_Y | PAD_BUTTON_X | PAD_BUTTON_START)) if ((pad_status.button & 0xff00) == (PAD_BUTTON_Y | PAD_BUTTON_X | PAD_BUTTON_START))
temp_combo = COMBO_ORIGIN; temp_combo = COMBO_ORIGIN;
else if ((pad_status.button & 0xff00) == (PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_START)) else if ((pad_status.button & 0xff00) == (PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_START))
temp_combo = COMBO_RESET; temp_combo = COMBO_RESET;
else
temp_combo = COMBO_NONE;
if (temp_combo != m_last_button_combo) if (temp_combo != m_last_button_combo)
{ {
+46 -40
View File
@@ -241,7 +241,7 @@ private:
union ICCommand union ICCommand
{ {
u8 data[81 + 4 + 4 + 4]; u8 data[81 + 4 + 4 + 4] = {};
struct struct
{ {
@@ -258,55 +258,61 @@ private:
}; };
}; };
u8 m_last[2][0x80]; u8 m_last[2][0x80] = {};
u32 m_lastptr[2]; u32 m_lastptr[2] = {};
u16 m_coin[2]; u16 m_coin[2] = {};
u32 m_coin_pressed[2]; u32 m_coin_pressed[2] = {};
u8 m_ic_card_data[2048]; u8 m_ic_card_data[2048] = {};
u16 m_ic_card_state;
u16 m_ic_card_status; // Setup IC-card
u16 m_ic_card_session; u16 m_ic_card_state = 0x20;
u8 m_ic_write_buffer[512]; u16 m_ic_card_status = ICCARDStatus::Okay;
u32 m_ic_write_offset; u16 m_ic_card_session = 0x23;
u32 m_ic_write_size;
u8 m_card_memory[0xD0]; u8 m_ic_write_buffer[512] = {};
u8 m_card_read_packet[0xDB]; u32 m_ic_write_offset = 0;
u8 m_card_buffer[0x100]; u32 m_ic_write_size = 0;
u32 m_card_memory_size;
bool m_card_is_inserted;
u32 m_card_command;
u32 m_card_clean;
u32 m_card_write_length;
u32 m_card_wrote;
u32 m_card_read_length;
u32 m_card_read;
u32 m_card_bit;
bool m_card_shutter;
u32 m_card_state_call_count;
u8 m_card_offset;
u32 m_wheel_init; u8 m_card_memory[0xD0] = {};
u8 m_card_read_packet[0xDB] = {};
u8 m_card_buffer[0x100] = {};
u32 m_motor_init; // Setup CARD
u8 m_motor_reply[64]; u32 m_card_memory_size = 0;
s16 m_motor_force_y; bool m_card_is_inserted = false;
u32 m_card_command = 0;
u32 m_card_clean = 0;
u32 m_card_write_length = 0;
u32 m_card_wrote = 0;
u32 m_card_read_length = 0;
u32 m_card_read = 0;
u32 m_card_bit = 0;
bool m_card_shutter = true; // Open
u32 m_card_state_call_count = 0;
u8 m_card_offset = 0;
// Serial
u32 m_wheel_init = 0;
u32 m_motor_init = 0;
u8 m_motor_reply[64] = {};
s16 m_motor_force_y = 0;
// F-Zero AX (DX) // F-Zero AX (DX)
bool m_fzdx_seatbelt; bool m_fzdx_seatbelt = true;
bool m_fzdx_motion_stop; bool m_fzdx_motion_stop = false;
bool m_fzdx_sensor_right; bool m_fzdx_sensor_right = false;
bool m_fzdx_sensor_left; bool m_fzdx_sensor_left = false;
u8 m_rx_reply; u8 m_rx_reply = 0xF0;
// F-Zero AX (CyCraft) // F-Zero AX (CyCraft)
bool m_fzcc_seatbelt; bool m_fzcc_seatbelt = true;
bool m_fzcc_sensor; bool m_fzcc_sensor = false;
bool m_fzcc_emergency; bool m_fzcc_emergency = false;
bool m_fzcc_service; bool m_fzcc_service = false;
void ICCardSendReply(ICCommand* iccommand, u8* buffer, u32* length); void ICCardSendReply(ICCommand* iccommand, u8* buffer, u32* length);
}; };
-5
View File
@@ -250,12 +250,7 @@ MainWindow::MainWindow(Core::System& system, std::unique_ptr<BootParameters> boo
}); });
#endif #endif
connect(m_cheats_manager, &CheatsManager::OpenGeneralSettings, this,
&MainWindow::ShowGeneralWindow);
#ifdef USE_RETRO_ACHIEVEMENTS #ifdef USE_RETRO_ACHIEVEMENTS
connect(m_cheats_manager, &CheatsManager::OpenAchievementSettings, this,
&MainWindow::ShowAchievementSettings);
connect(m_game_list, &GameList::OpenAchievementSettings, this, connect(m_game_list, &GameList::OpenAchievementSettings, this,
&MainWindow::ShowAchievementSettings); &MainWindow::ShowAchievementSettings);
#endif // USE_RETRO_ACHIEVEMENTS #endif // USE_RETRO_ACHIEVEMENTS