VideoInterface: Fix warning: declaration of ‘state’ shadows a previous local

This commit is contained in:
Pokechu22 2023-02-02 15:17:33 -08:00
parent 49a84cbc4c
commit 72b4675c8f
1 changed files with 48 additions and 48 deletions

View File

@ -277,38 +277,38 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
// XFB related MMIOs that require special handling on writes. // XFB related MMIOs that require special handling on writes.
mmio->Register(base | VI_FB_LEFT_TOP_HI, MMIO::DirectRead<u16>(&state.xfb_info_top.Hi), mmio->Register(base | VI_FB_LEFT_TOP_HI, MMIO::DirectRead<u16>(&state.xfb_info_top.Hi),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
state.xfb_info_top.Hi = val; state_.xfb_info_top.Hi = val;
if (state.xfb_info_top.CLRPOFF) if (state_.xfb_info_top.CLRPOFF)
state.xfb_info_top.POFF = 0; state_.xfb_info_top.POFF = 0;
})); }));
mmio->Register(base | VI_FB_LEFT_BOTTOM_HI, MMIO::DirectRead<u16>(&state.xfb_info_bottom.Hi), mmio->Register(base | VI_FB_LEFT_BOTTOM_HI, MMIO::DirectRead<u16>(&state.xfb_info_bottom.Hi),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
state.xfb_info_bottom.Hi = val; state_.xfb_info_bottom.Hi = val;
if (state.xfb_info_bottom.CLRPOFF) if (state_.xfb_info_bottom.CLRPOFF)
state.xfb_info_bottom.POFF = 0; state_.xfb_info_bottom.POFF = 0;
})); }));
mmio->Register(base | VI_FB_RIGHT_TOP_HI, MMIO::DirectRead<u16>(&state.xfb_3d_info_top.Hi), mmio->Register(base | VI_FB_RIGHT_TOP_HI, MMIO::DirectRead<u16>(&state.xfb_3d_info_top.Hi),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
state.xfb_3d_info_top.Hi = val; state_.xfb_3d_info_top.Hi = val;
if (state.xfb_3d_info_top.CLRPOFF) if (state_.xfb_3d_info_top.CLRPOFF)
state.xfb_3d_info_top.POFF = 0; state_.xfb_3d_info_top.POFF = 0;
})); }));
mmio->Register(base | VI_FB_RIGHT_BOTTOM_HI, MMIO::DirectRead<u16>(&state.xfb_3d_info_bottom.Hi), mmio->Register(base | VI_FB_RIGHT_BOTTOM_HI, MMIO::DirectRead<u16>(&state.xfb_3d_info_bottom.Hi),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
state.xfb_3d_info_bottom.Hi = val; state_.xfb_3d_info_bottom.Hi = val;
if (state.xfb_3d_info_bottom.CLRPOFF) if (state_.xfb_3d_info_bottom.CLRPOFF)
state.xfb_3d_info_bottom.POFF = 0; state_.xfb_3d_info_bottom.POFF = 0;
})); }));
// MMIOs with unimplemented writes that trigger warnings. // MMIOs with unimplemented writes that trigger warnings.
mmio->Register( mmio->Register(
base | VI_VERTICAL_BEAM_POSITION, MMIO::ComplexRead<u16>([](Core::System& system, u32) { base | VI_VERTICAL_BEAM_POSITION, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
return 1 + (state.half_line_count) / 2; return 1 + (state_.half_line_count) / 2;
}), }),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
WARN_LOG_FMT( WARN_LOG_FMT(
@ -317,12 +317,12 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
})); }));
mmio->Register( mmio->Register(
base | VI_HORIZONTAL_BEAM_POSITION, MMIO::ComplexRead<u16>([](Core::System& system, u32) { base | VI_HORIZONTAL_BEAM_POSITION, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
u16 value = static_cast<u16>( u16 value = static_cast<u16>(
1 + state.h_timing_0.HLW * 1 + state_.h_timing_0.HLW *
(system.GetCoreTiming().GetTicks() - state.ticks_last_line_start) / (system.GetCoreTiming().GetTicks() - state_.ticks_last_line_start) /
(GetTicksPerHalfLine())); (GetTicksPerHalfLine()));
return std::clamp<u16>(value, 1, state.h_timing_0.HLW * 2); return std::clamp<u16>(value, 1, state_.h_timing_0.HLW * 2);
}), }),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
WARN_LOG_FMT( WARN_LOG_FMT(
@ -335,50 +335,50 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
// on writes. // on writes.
mmio->Register(base | VI_PRERETRACE_HI, MMIO::DirectRead<u16>(&state.interrupt_register[0].Hi), mmio->Register(base | VI_PRERETRACE_HI, MMIO::DirectRead<u16>(&state.interrupt_register[0].Hi),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
state.interrupt_register[0].Hi = val; state_.interrupt_register[0].Hi = val;
UpdateInterrupts(); UpdateInterrupts();
})); }));
mmio->Register(base | VI_POSTRETRACE_HI, MMIO::DirectRead<u16>(&state.interrupt_register[1].Hi), mmio->Register(base | VI_POSTRETRACE_HI, MMIO::DirectRead<u16>(&state.interrupt_register[1].Hi),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
state.interrupt_register[1].Hi = val; state_.interrupt_register[1].Hi = val;
UpdateInterrupts(); UpdateInterrupts();
})); }));
mmio->Register(base | VI_DISPLAY_INTERRUPT_2_HI, mmio->Register(base | VI_DISPLAY_INTERRUPT_2_HI,
MMIO::DirectRead<u16>(&state.interrupt_register[2].Hi), MMIO::DirectRead<u16>(&state.interrupt_register[2].Hi),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
state.interrupt_register[2].Hi = val; state_.interrupt_register[2].Hi = val;
UpdateInterrupts(); UpdateInterrupts();
})); }));
mmio->Register(base | VI_DISPLAY_INTERRUPT_3_HI, mmio->Register(base | VI_DISPLAY_INTERRUPT_3_HI,
MMIO::DirectRead<u16>(&state.interrupt_register[3].Hi), MMIO::DirectRead<u16>(&state.interrupt_register[3].Hi),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
state.interrupt_register[3].Hi = val; state_.interrupt_register[3].Hi = val;
UpdateInterrupts(); UpdateInterrupts();
})); }));
// Unknown anti-aliasing related MMIO register: puts a warning on log and // Unknown anti-aliasing related MMIO register: puts a warning on log and
// needs to shift/mask when reading/writing. // needs to shift/mask when reading/writing.
mmio->Register(base | VI_UNK_AA_REG_HI, MMIO::ComplexRead<u16>([](Core::System& system, u32) { mmio->Register(base | VI_UNK_AA_REG_HI, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
return state.unknown_aa_register >> 16; return state_.unknown_aa_register >> 16;
}), }),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
state.unknown_aa_register = state_.unknown_aa_register =
(state.unknown_aa_register & 0x0000FFFF) | ((u32)val << 16); (state_.unknown_aa_register & 0x0000FFFF) | ((u32)val << 16);
WARN_LOG_FMT(VIDEOINTERFACE, "Writing to the unknown AA register (hi)"); WARN_LOG_FMT(VIDEOINTERFACE, "Writing to the unknown AA register (hi)");
})); }));
mmio->Register(base | VI_UNK_AA_REG_LO, MMIO::ComplexRead<u16>([](Core::System& system, u32) { mmio->Register(base | VI_UNK_AA_REG_LO, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
return state.unknown_aa_register & 0xFFFF; return state_.unknown_aa_register & 0xFFFF;
}), }),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
state.unknown_aa_register = (state.unknown_aa_register & 0xFFFF0000) | val; state_.unknown_aa_register = (state_.unknown_aa_register & 0xFFFF0000) | val;
WARN_LOG_FMT(VIDEOINTERFACE, "Writing to the unknown AA register (lo)"); WARN_LOG_FMT(VIDEOINTERFACE, "Writing to the unknown AA register (lo)");
})); }));
@ -387,21 +387,21 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
mmio->Register(base | VI_CONTROL_REGISTER, mmio->Register(base | VI_CONTROL_REGISTER,
MMIO::DirectRead<u16>(&state.display_control_register.Hex), MMIO::DirectRead<u16>(&state.display_control_register.Hex),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) { MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& state = system.GetVideoInterfaceState().GetData(); auto& state_ = system.GetVideoInterfaceState().GetData();
UVIDisplayControlRegister tmpConfig(val); UVIDisplayControlRegister tmpConfig(val);
state.display_control_register.ENB = tmpConfig.ENB; state_.display_control_register.ENB = tmpConfig.ENB;
state.display_control_register.NIN = tmpConfig.NIN; state_.display_control_register.NIN = tmpConfig.NIN;
state.display_control_register.DLR = tmpConfig.DLR; state_.display_control_register.DLR = tmpConfig.DLR;
state.display_control_register.LE0 = tmpConfig.LE0; state_.display_control_register.LE0 = tmpConfig.LE0;
state.display_control_register.LE1 = tmpConfig.LE1; state_.display_control_register.LE1 = tmpConfig.LE1;
state.display_control_register.FMT = tmpConfig.FMT; state_.display_control_register.FMT = tmpConfig.FMT;
if (tmpConfig.RST) if (tmpConfig.RST)
{ {
// shuffle2 clear all data, reset to default vals, and enter idle mode // shuffle2 clear all data, reset to default vals, and enter idle mode
state.display_control_register.RST = 0; state_.display_control_register.RST = 0;
state.interrupt_register = {}; state_.interrupt_register = {};
UpdateInterrupts(); UpdateInterrupts();
} }