From a92566dfc5be59dcc9376dedbcbb880e2d15b250 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Fri, 7 Aug 2015 21:29:03 -0700 Subject: [PATCH] More style. --- src/xenia/app/emulator_window.cc | 10 +- src/xenia/base/delegate.h | 4 +- src/xenia/base/logging.cc | 4 +- src/xenia/cpu/backend/x64/x64_sequences.cc | 16 +- .../compiler/passes/context_promotion_pass.h | 1 + .../passes/data_flow_analysis_pass.cc | 4 +- .../cpu/compiler/passes/finalization_pass.cc | 2 +- .../passes/register_allocation_pass.cc | 3 +- .../passes/register_allocation_pass.h | 3 +- .../cpu/compiler/passes/validation_pass.cc | 2 +- .../compiler/passes/value_reduction_pass.cc | 8 +- src/xenia/cpu/frontend/context_info.h | 6 +- src/xenia/cpu/frontend/ppc_context.h | 6 +- src/xenia/cpu/frontend/ppc_disasm.cc | 530 +++++++++--------- src/xenia/cpu/frontend/ppc_disasm.h | 8 +- src/xenia/cpu/frontend/ppc_emit-private.h | 8 +- src/xenia/cpu/frontend/ppc_emit.h | 6 +- src/xenia/cpu/frontend/ppc_emit_altivec.cc | 34 +- src/xenia/cpu/frontend/ppc_frontend.h | 6 +- src/xenia/cpu/frontend/ppc_hir_builder.cc | 2 +- src/xenia/cpu/frontend/ppc_hir_builder.h | 8 +- src/xenia/cpu/frontend/ppc_instr.h | 8 +- src/xenia/cpu/frontend/ppc_instr_tables.h | 134 ++--- src/xenia/cpu/frontend/ppc_scanner.h | 8 +- src/xenia/cpu/frontend/ppc_translator.cc | 7 +- src/xenia/cpu/frontend/ppc_translator.h | 8 +- src/xenia/cpu/hir/block.h | 6 +- src/xenia/cpu/hir/hir_builder.cc | 4 +- src/xenia/cpu/hir/hir_builder.h | 6 +- src/xenia/cpu/hir/instr.h | 6 +- src/xenia/cpu/hir/label.h | 6 +- src/xenia/cpu/hir/opcodes.cc | 2 - src/xenia/cpu/hir/opcodes.h | 45 +- src/xenia/cpu/hir/value.h | 14 +- src/xenia/cpu/testing/permute_test.cc | 8 +- src/xenia/cpu/testing/swizzle_test.cc | 6 +- src/xenia/cpu/testing/util.h | 8 +- src/xenia/cpu/xex_module.cc | 3 +- src/xenia/debug/debug_client.cc | 2 +- src/xenia/debug/debug_client.h | 2 + src/xenia/debug/debug_server.cc | 7 +- src/xenia/debug/debug_server.h | 4 +- src/xenia/debug/debugger.cc | 11 +- src/xenia/debug/debugger.h | 4 +- src/xenia/debug/proto/packet_reader.h | 2 +- src/xenia/debug/proto/packet_writer.h | 2 +- src/xenia/debug/proto/varint.h | 2 +- src/xenia/debug/ui/main_window.cc | 8 +- src/xenia/debug/ui/main_window.h | 2 +- src/xenia/debug/ui/model/module.h | 2 +- src/xenia/debug/ui/model/system.cc | 2 +- src/xenia/debug/ui/view.h | 2 +- src/xenia/debug/ui/views/cpu/cpu_view.cc | 6 +- src/xenia/debug/ui/views/gpu/gpu_view.cc | 2 +- src/xenia/gpu/gl4/command_processor.cc | 108 ++-- src/xenia/gpu/gl4/command_processor.h | 7 +- src/xenia/gpu/gl4/draw_batcher.cc | 8 +- src/xenia/gpu/gl4/draw_batcher.h | 10 +- src/xenia/gpu/gl4/gl4_graphics_system.cc | 5 +- src/xenia/gpu/gl4/gl4_graphics_system.h | 4 +- src/xenia/gpu/gl4/gl4_shader.cc | 2 +- src/xenia/gpu/gl4/gl4_shader_translator.cc | 173 +++--- src/xenia/gpu/gl4/texture_cache.cc | 3 +- src/xenia/gpu/gl4/trace_viewer_main.cc | 40 +- src/xenia/gpu/graphics_system.h | 2 +- src/xenia/gpu/register_file.cc | 2 +- src/xenia/gpu/texture_info.cc | 2 +- src/xenia/gpu/tracing.h | 2 +- src/xenia/gpu/ucode_disassembler.cc | 28 +- src/xenia/hid/input_driver.h | 4 +- src/xenia/hid/input_system.h | 8 +- src/xenia/hid/nop/nop_input_driver.h | 2 +- src/xenia/hid/winkey/winkey_input_driver.h | 8 +- src/xenia/hid/xinput/xinput_input_driver.cc | 2 +- src/xenia/hid/xinput/xinput_input_driver.h | 8 +- src/xenia/kernel/apps/xgi_app.h | 2 +- src/xenia/kernel/apps/xlivebase_app.h | 2 +- src/xenia/kernel/apps/xmp_app.h | 2 +- src/xenia/kernel/content_manager.h | 2 +- src/xenia/kernel/dispatcher.h | 2 +- src/xenia/kernel/kernel_state.cc | 6 +- src/xenia/kernel/kernel_state.h | 3 +- src/xenia/kernel/native_list.h | 2 +- src/xenia/kernel/object_table.cc | 8 +- src/xenia/kernel/object_table.h | 5 +- src/xenia/kernel/objects/xevent.cc | 6 +- src/xenia/kernel/objects/xevent.h | 4 +- src/xenia/kernel/objects/xfile.cc | 5 +- src/xenia/kernel/objects/xfile.h | 7 +- src/xenia/kernel/objects/xmutant.cc | 2 +- src/xenia/kernel/objects/xmutant.h | 4 +- src/xenia/kernel/objects/xnotify_listener.h | 2 +- src/xenia/kernel/objects/xsemaphore.cc | 2 +- src/xenia/kernel/objects/xsemaphore.h | 4 +- src/xenia/kernel/objects/xthread.cc | 17 +- src/xenia/kernel/objects/xtimer.h | 4 +- src/xenia/kernel/objects/xuser_module.cc | 126 +++-- src/xenia/kernel/util/shim_utils.h | 55 +- src/xenia/kernel/xam_input.cc | 17 +- src/xenia/kernel/xam_module.cc | 2 + src/xenia/kernel/xam_module.h | 8 +- src/xenia/kernel/xam_net.cc | 4 +- src/xenia/kernel/xam_ui.cc | 12 +- src/xenia/kernel/xam_user.cc | 23 +- src/xenia/kernel/xboxkrnl_audio_xma.cc | 7 +- src/xenia/kernel/xboxkrnl_crypt.cc | 18 +- src/xenia/kernel/xboxkrnl_debug.cc | 9 +- src/xenia/kernel/xboxkrnl_io.cc | 12 +- src/xenia/kernel/xboxkrnl_memory.cc | 3 +- src/xenia/kernel/xboxkrnl_module.cc | 2 + src/xenia/kernel/xboxkrnl_module.h | 6 +- src/xenia/kernel/xboxkrnl_modules.cc | 6 +- src/xenia/kernel/xboxkrnl_ordinals.h | 6 +- src/xenia/kernel/xboxkrnl_private.h | 7 +- src/xenia/kernel/xboxkrnl_rtl.cc | 16 +- src/xenia/kernel/xboxkrnl_rtl.h | 6 +- src/xenia/kernel/xboxkrnl_threading.cc | 12 +- src/xenia/kernel/xboxkrnl_video.cc | 6 +- src/xenia/kernel/xobject.cc | 8 +- src/xenia/kernel/xobject.h | 15 +- src/xenia/ui/gl/gl_profiler_display.cc | 38 +- src/xenia/ui/loop.h | 2 +- src/xenia/ui/loop_win.cc | 2 +- src/xenia/ui/menu_item.cc | 2 +- src/xenia/ui/menu_item.h | 2 +- src/xenia/ui/window.cc | 108 ++-- src/xenia/ui/window.h | 68 +-- src/xenia/ui/window_win.cc | 30 +- src/xenia/ui/window_win.h | 2 +- third_party/elemental-forms | 2 +- xenia-build | 26 +- 131 files changed, 1141 insertions(+), 1056 deletions(-) diff --git a/src/xenia/app/emulator_window.cc b/src/xenia/app/emulator_window.cc index 7af4dec9d..b7c983565 100644 --- a/src/xenia/app/emulator_window.cc +++ b/src/xenia/app/emulator_window.cc @@ -60,18 +60,18 @@ bool EmulatorWindow::Initialize() { UpdateTitle(); - window_->on_closed.AddListener([this](UIEvent& e) { + window_->on_closed.AddListener([this](UIEvent* e) { loop_->Quit(); // TODO(benvanik): proper exit. XELOGI("User-initiated death!"); exit(1); }); - loop_->on_quit.AddListener([this](UIEvent& e) { window_.reset(); }); + loop_->on_quit.AddListener([this](UIEvent* e) { window_.reset(); }); - window_->on_key_down.AddListener([this](KeyEvent& e) { + window_->on_key_down.AddListener([this](KeyEvent* e) { bool handled = true; - switch (e.key_code()) { + switch (e->key_code()) { case 0x6A: { // numpad * CpuTimeScalarReset(); } break; @@ -111,7 +111,7 @@ bool EmulatorWindow::Initialize() { default: { handled = false; } break; } - e.set_handled(handled); + e->set_handled(handled); }); // Main menu. diff --git a/src/xenia/base/delegate.h b/src/xenia/base/delegate.h index 8ecc5cf74..3aa699192 100644 --- a/src/xenia/base/delegate.h +++ b/src/xenia/base/delegate.h @@ -21,7 +21,7 @@ namespace xe { template class Delegate { public: - typedef std::function Listener; + typedef std::function Listener; void AddListener(Listener const& listener) { std::lock_guard guard(lock_); @@ -33,7 +33,7 @@ class Delegate { listeners_.clear(); } - void operator()(Args&... args) { + void operator()(Args... args) { std::lock_guard guard(lock_); for (auto& listener : listeners_) { listener(args...); diff --git a/src/xenia/base/logging.cc b/src/xenia/base/logging.cc index 977910250..72cd0a1cc 100644 --- a/src/xenia/base/logging.cc +++ b/src/xenia/base/logging.cc @@ -42,7 +42,9 @@ void format_log_line(char* buffer, size_t buffer_capacity, *(buffer_ptr++) = level_char; *(buffer_ptr++) = '>'; *(buffer_ptr++) = ' '; - buffer_ptr += sprintf(buffer_ptr, "%.4X", xe::threading::current_thread_id()); + buffer_ptr += + std::snprintf(buffer_ptr, buffer_capacity - (buffer_ptr - buffer), "%.4X", + xe::threading::current_thread_id()); *(buffer_ptr++) = ' '; // Scribble args into the print buffer. diff --git a/src/xenia/cpu/backend/x64/x64_sequences.cc b/src/xenia/cpu/backend/x64/x64_sequences.cc index 17d0ed315..7825e092c 100644 --- a/src/xenia/cpu/backend/x64/x64_sequences.cc +++ b/src/xenia/cpu/backend/x64/x64_sequences.cc @@ -24,6 +24,7 @@ #include "xenia/cpu/backend/x64/x64_sequences.h" +#include #include #include @@ -47,8 +48,10 @@ namespace x64 { using namespace Xbyak; // TODO(benvanik): direct usings. -using namespace xe::cpu::hir; using namespace xe::cpu; +using namespace xe::cpu::hir; + +using xe::cpu::hir::Instr; typedef bool (*SequenceSelectFn)(X64Emitter&, const Instr*); std::unordered_map sequence_table; @@ -653,7 +656,7 @@ template void Register() { Register(); Register(); -}; +} #define EMITTER_OPCODE_TABLE(name, ...) \ void Register_##name() { Register<__VA_ARGS__>(); } @@ -5447,8 +5450,8 @@ struct VECTOR_SHR_V128 } } - // We've reached here if we don't have AVX2 and it's a variable shift - // TODO: native version + // We've reached here if we don't have AVX2 and it's a variable shift. + // TODO(benvanik): native version. if (i.src2.is_constant) { e.LoadConstantXmm(e.xmm0, i.src2.constant()); e.lea(e.r9, e.StashXmm(1, e.xmm0)); @@ -5535,8 +5538,7 @@ struct VECTOR_SHA_V128 } e.vpsravd(i.dest, i.src1, e.xmm0); } else { - // Emulated for now... - // TODO: Native version + // TODO(benvanik): native version. if (i.src2.is_constant) { e.LoadConstantXmm(e.xmm0, i.src2.constant()); e.lea(e.r9, e.StashXmm(1, e.xmm0)); @@ -5684,7 +5686,7 @@ struct VECTOR_ROTATE_LEFT_V128 // Merge: e.vpor(i.dest, e.xmm1); } else { - // TODO: Non-AVX2 native version + // TODO(benvanik): non-AVX2 native version. e.lea(e.r8, e.StashXmm(0, i.src1)); e.lea(e.r9, e.StashXmm(1, i.src2)); e.CallNativeSafe(reinterpret_cast(EmulateVectorRotateLeftI32)); diff --git a/src/xenia/cpu/compiler/passes/context_promotion_pass.h b/src/xenia/cpu/compiler/passes/context_promotion_pass.h index 5e36f9b39..970c39fb2 100644 --- a/src/xenia/cpu/compiler/passes/context_promotion_pass.h +++ b/src/xenia/cpu/compiler/passes/context_promotion_pass.h @@ -11,6 +11,7 @@ #define XENIA_CPU_COMPILER_PASSES_CONTEXT_PROMOTION_PASS_H_ #include +#include #include "xenia/base/platform.h" #include "xenia/cpu/compiler/compiler_pass.h" diff --git a/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc b/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc index 5548d03ef..82454b55f 100644 --- a/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc +++ b/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc @@ -71,8 +71,8 @@ void DataFlowAnalysisPass::AnalyzeFlow(HIRBuilder* builder, // Stash for value map. We may want to maintain this during building. auto arena = builder->arena(); - Value** value_map = - (Value**)arena->Alloc(sizeof(Value*) * max_value_estimate); + auto value_map = reinterpret_cast( + arena->Alloc(sizeof(Value*) * max_value_estimate)); // Allocate incoming bitvectors for use by blocks. We don't need outgoing // because they are only used during the block iteration. diff --git a/src/xenia/cpu/compiler/passes/finalization_pass.cc b/src/xenia/cpu/compiler/passes/finalization_pass.cc index 29fd643a7..553a912d3 100644 --- a/src/xenia/cpu/compiler/passes/finalization_pass.cc +++ b/src/xenia/cpu/compiler/passes/finalization_pass.cc @@ -44,7 +44,7 @@ bool FinalizationPass::Run(HIRBuilder* builder) { while (label) { if (!label->name) { const size_t label_len = 6 + 4 + 1; - char* name = (char*)arena->Alloc(label_len); + char* name = reinterpret_cast(arena->Alloc(label_len)); snprintf(name, label_len, "_label%d", label->id); label->name = name; } diff --git a/src/xenia/cpu/compiler/passes/register_allocation_pass.cc b/src/xenia/cpu/compiler/passes/register_allocation_pass.cc index 5fdfef8c2..ea996b1e2 100644 --- a/src/xenia/cpu/compiler/passes/register_allocation_pass.cc +++ b/src/xenia/cpu/compiler/passes/register_allocation_pass.cc @@ -180,7 +180,8 @@ void RegisterAllocationPass::DumpUsage(const char* name) { auto usage_set = usage_sets_.all_sets[i]; if (usage_set) { fprintf(stdout, "set %s:\n", usage_set->set->name); - fprintf(stdout, " avail: %s\n", usage_set->availability.to_string().c_str()); + fprintf(stdout, " avail: %s\n", + usage_set->availability.to_string().c_str()); fprintf(stdout, " upcoming uses:\n"); for (auto it = usage_set->upcoming_uses.begin(); it != usage_set->upcoming_uses.end(); ++it) { diff --git a/src/xenia/cpu/compiler/passes/register_allocation_pass.h b/src/xenia/cpu/compiler/passes/register_allocation_pass.h index 135241ffe..f14c41dc6 100644 --- a/src/xenia/cpu/compiler/passes/register_allocation_pass.h +++ b/src/xenia/cpu/compiler/passes/register_allocation_pass.h @@ -12,6 +12,7 @@ #include #include +#include #include #include "xenia/cpu/backend/machine_info.h" @@ -24,7 +25,7 @@ namespace passes { class RegisterAllocationPass : public CompilerPass { public: - RegisterAllocationPass(const backend::MachineInfo* machine_info); + explicit RegisterAllocationPass(const backend::MachineInfo* machine_info); ~RegisterAllocationPass() override; bool Run(hir::HIRBuilder* builder) override; diff --git a/src/xenia/cpu/compiler/passes/validation_pass.cc b/src/xenia/cpu/compiler/passes/validation_pass.cc index 6da9f142a..512b2e43e 100644 --- a/src/xenia/cpu/compiler/passes/validation_pass.cc +++ b/src/xenia/cpu/compiler/passes/validation_pass.cc @@ -37,7 +37,7 @@ bool ValidationPass::Run(HIRBuilder* builder) { #if 0 StringBuffer str; builder->Dump(&str); - printf(str.GetString()); + printf("%s", str.GetString()); fflush(stdout); str.Reset(); #endif // 0 diff --git a/src/xenia/cpu/compiler/passes/value_reduction_pass.cc b/src/xenia/cpu/compiler/passes/value_reduction_pass.cc index 69d6d86db..ff142cac4 100644 --- a/src/xenia/cpu/compiler/passes/value_reduction_pass.cc +++ b/src/xenia/cpu/compiler/passes/value_reduction_pass.cc @@ -79,10 +79,10 @@ bool ValueReductionPass::Run(HIRBuilder* builder) { instr = block->instr_head; while (instr) { const OpcodeInfo* info = instr->opcode; - OpcodeSignatureType dest_type = GET_OPCODE_SIG_TYPE_DEST(info->signature); - OpcodeSignatureType src1_type = GET_OPCODE_SIG_TYPE_SRC1(info->signature); - OpcodeSignatureType src2_type = GET_OPCODE_SIG_TYPE_SRC2(info->signature); - OpcodeSignatureType src3_type = GET_OPCODE_SIG_TYPE_SRC3(info->signature); + auto dest_type = GET_OPCODE_SIG_TYPE_DEST(info->signature); + auto src1_type = GET_OPCODE_SIG_TYPE_SRC1(info->signature); + auto src2_type = GET_OPCODE_SIG_TYPE_SRC2(info->signature); + auto src3_type = GET_OPCODE_SIG_TYPE_SRC3(info->signature); if (src1_type == OPCODE_SIG_TYPE_V) { auto v = instr->src1.value; if (!v->last_use) { diff --git a/src/xenia/cpu/frontend/context_info.h b/src/xenia/cpu/frontend/context_info.h index 48ce4b0a4..7ce06e181 100644 --- a/src/xenia/cpu/frontend/context_info.h +++ b/src/xenia/cpu/frontend/context_info.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_FRONTEND_CONTEXT_INFO_H_ -#define XENIA_FRONTEND_CONTEXT_INFO_H_ +#ifndef XENIA_CPU_FRONTEND_CONTEXT_INFO_H_ +#define XENIA_CPU_FRONTEND_CONTEXT_INFO_H_ #include #include @@ -38,4 +38,4 @@ class ContextInfo { } // namespace cpu } // namespace xe -#endif // XENIA_FRONTEND_CONTEXT_INFO_H_ +#endif // XENIA_CPU_FRONTEND_CONTEXT_INFO_H_ diff --git a/src/xenia/cpu/frontend/ppc_context.h b/src/xenia/cpu/frontend/ppc_context.h index df4c98bb3..e2a18d913 100644 --- a/src/xenia/cpu/frontend/ppc_context.h +++ b/src/xenia/cpu/frontend/ppc_context.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_FRONTEND_PPC_CONTEXT_H_ -#define XENIA_FRONTEND_PPC_CONTEXT_H_ +#ifndef XENIA_CPU_FRONTEND_PPC_CONTEXT_H_ +#define XENIA_CPU_FRONTEND_PPC_CONTEXT_H_ #include @@ -229,4 +229,4 @@ static_assert(sizeof(PPCContext) % 64 == 0, "64b padded"); } // namespace cpu } // namespace xe -#endif // XENIA_FRONTEND_PPC_CONTEXT_H_ +#endif // XENIA_CPU_FRONTEND_PPC_CONTEXT_H_ diff --git a/src/xenia/cpu/frontend/ppc_disasm.cc b/src/xenia/cpu/frontend/ppc_disasm.cc index f2f0c762d..0de8073ac 100644 --- a/src/xenia/cpu/frontend/ppc_disasm.cc +++ b/src/xenia/cpu/frontend/ppc_disasm.cc @@ -17,117 +17,121 @@ namespace xe { namespace cpu { namespace frontend { -void Disasm_0(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s ???", i.type->name); +void Disasm_0(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s ???", i->type->name); } -void Disasm__(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s", i.type->name); +void Disasm__(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s", i->type->name); } -void Disasm_X_FRT_FRB(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s f%d, f%d", i.X.Rc ? -7 : -8, i.type->name, - i.X.Rc ? "." : "", i.X.RT, i.X.RB); +void Disasm_X_FRT_FRB(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s f%d, f%d", i->X.Rc ? -7 : -8, i->type->name, + i->X.Rc ? "." : "", i->X.RT, i->X.RB); } -void Disasm_A_FRT_FRB(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s f%d, f%d", i.A.Rc ? -7 : -8, i.type->name, - i.A.Rc ? "." : "", i.A.FRT, i.A.FRB); +void Disasm_A_FRT_FRB(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s f%d, f%d", i->A.Rc ? -7 : -8, i->type->name, + i->A.Rc ? "." : "", i->A.FRT, i->A.FRB); } -void Disasm_A_FRT_FRA_FRB(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s f%d, f%d, f%d", i.A.Rc ? -7 : -8, i.type->name, - i.A.Rc ? "." : "", i.A.FRT, i.A.FRA, i.A.FRB); +void Disasm_A_FRT_FRA_FRB(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s f%d, f%d, f%d", i->A.Rc ? -7 : -8, i->type->name, + i->A.Rc ? "." : "", i->A.FRT, i->A.FRA, i->A.FRB); } -void Disasm_A_FRT_FRA_FRB_FRC(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s f%d, f%d, f%d, f%d", i.A.Rc ? -7 : -8, i.type->name, - i.A.Rc ? "." : "", i.A.FRT, i.A.FRA, i.A.FRB, i.A.FRC); +void Disasm_A_FRT_FRA_FRB_FRC(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s f%d, f%d, f%d, f%d", i->A.Rc ? -7 : -8, + i->type->name, i->A.Rc ? "." : "", i->A.FRT, i->A.FRA, + i->A.FRB, i->A.FRC); } -void Disasm_X_RT_RA_RB(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s r%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB); +void Disasm_X_RT_RA_RB(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s r%d, r%d, r%d", i->type->name, i->X.RT, i->X.RA, + i->X.RB); } -void Disasm_X_RT_RA0_RB(InstrData& i, StringBuffer* str) { - if (i.X.RA) { - str->AppendFormat("%-8s r%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, - i.X.RB); +void Disasm_X_RT_RA0_RB(InstrData* i, StringBuffer* str) { + if (i->X.RA) { + str->AppendFormat("%-8s r%d, r%d, r%d", i->type->name, i->X.RT, i->X.RA, + i->X.RB); } else { - str->AppendFormat("%-8s r%d, 0, r%d", i.type->name, i.X.RT, i.X.RB); + str->AppendFormat("%-8s r%d, 0, r%d", i->type->name, i->X.RT, i->X.RB); } } -void Disasm_X_FRT_RA_RB(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s f%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB); +void Disasm_X_FRT_RA_RB(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s f%d, r%d, r%d", i->type->name, i->X.RT, i->X.RA, + i->X.RB); } -void Disasm_X_FRT_RA0_RB(InstrData& i, StringBuffer* str) { - if (i.X.RA) { - str->AppendFormat("%-8s f%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, - i.X.RB); +void Disasm_X_FRT_RA0_RB(InstrData* i, StringBuffer* str) { + if (i->X.RA) { + str->AppendFormat("%-8s f%d, r%d, r%d", i->type->name, i->X.RT, i->X.RA, + i->X.RB); } else { - str->AppendFormat("%-8s f%d, 0, r%d", i.type->name, i.X.RT, i.X.RB); + str->AppendFormat("%-8s f%d, 0, r%d", i->type->name, i->X.RT, i->X.RB); } } -void Disasm_D_RT_RA_I(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s r%d, r%d, %d", i.type->name, i.D.RT, i.D.RA, - (int32_t)(int16_t)XEEXTS16(i.D.DS)); +void Disasm_D_RT_RA_I(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s r%d, r%d, %d", i->type->name, i->D.RT, i->D.RA, + (int32_t)(int16_t)XEEXTS16(i->D.DS)); } -void Disasm_D_RT_RA0_I(InstrData& i, StringBuffer* str) { - if (i.D.RA) { - str->AppendFormat("%-8s r%d, r%d, %d", i.type->name, i.D.RT, i.D.RA, - (int32_t)(int16_t)XEEXTS16(i.D.DS)); +void Disasm_D_RT_RA0_I(InstrData* i, StringBuffer* str) { + if (i->D.RA) { + str->AppendFormat("%-8s r%d, r%d, %d", i->type->name, i->D.RT, i->D.RA, + (int32_t)(int16_t)XEEXTS16(i->D.DS)); } else { - str->AppendFormat("%-8s r%d, 0, %d", i.type->name, i.D.RT, - (int32_t)(int16_t)XEEXTS16(i.D.DS)); + str->AppendFormat("%-8s r%d, 0, %d", i->type->name, i->D.RT, + (int32_t)(int16_t)XEEXTS16(i->D.DS)); } } -void Disasm_D_FRT_RA_I(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s f%d, r%d, %d", i.type->name, i.D.RT, i.D.RA, - (int32_t)(int16_t)XEEXTS16(i.D.DS)); +void Disasm_D_FRT_RA_I(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s f%d, r%d, %d", i->type->name, i->D.RT, i->D.RA, + (int32_t)(int16_t)XEEXTS16(i->D.DS)); } -void Disasm_D_FRT_RA0_I(InstrData& i, StringBuffer* str) { - if (i.D.RA) { - str->AppendFormat("%-8s f%d, r%d, %d", i.type->name, i.D.RT, i.D.RA, - (int32_t)(int16_t)XEEXTS16(i.D.DS)); +void Disasm_D_FRT_RA0_I(InstrData* i, StringBuffer* str) { + if (i->D.RA) { + str->AppendFormat("%-8s f%d, r%d, %d", i->type->name, i->D.RT, i->D.RA, + (int32_t)(int16_t)XEEXTS16(i->D.DS)); } else { - str->AppendFormat("%-8s f%d, 0, %d", i.type->name, i.D.RT, - (int32_t)(int16_t)XEEXTS16(i.D.DS)); + str->AppendFormat("%-8s f%d, 0, %d", i->type->name, i->D.RT, + (int32_t)(int16_t)XEEXTS16(i->D.DS)); } } -void Disasm_DS_RT_RA_I(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s r%d, r%d, %d", i.type->name, i.DS.RT, i.DS.RA, - (int32_t)(int16_t)XEEXTS16(i.DS.DS << 2)); +void Disasm_DS_RT_RA_I(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s r%d, r%d, %d", i->type->name, i->DS.RT, i->DS.RA, + (int32_t)(int16_t)XEEXTS16(i->DS.DS << 2)); } -void Disasm_DS_RT_RA0_I(InstrData& i, StringBuffer* str) { - if (i.DS.RA) { - str->AppendFormat("%-8s r%d, r%d, %d", i.type->name, i.DS.RT, i.DS.RA, - (int32_t)(int16_t)XEEXTS16(i.DS.DS << 2)); +void Disasm_DS_RT_RA0_I(InstrData* i, StringBuffer* str) { + if (i->DS.RA) { + str->AppendFormat("%-8s r%d, r%d, %d", i->type->name, i->DS.RT, i->DS.RA, + (int32_t)(int16_t)XEEXTS16(i->DS.DS << 2)); } else { - str->AppendFormat("%-8s r%d, 0, %d", i.type->name, i.DS.RT, - (int32_t)(int16_t)XEEXTS16(i.DS.DS << 2)); + str->AppendFormat("%-8s r%d, 0, %d", i->type->name, i->DS.RT, + (int32_t)(int16_t)XEEXTS16(i->DS.DS << 2)); } } -void Disasm_D_RA(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s r%d", i.type->name, i.D.RA); +void Disasm_D_RA(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s r%d", i->type->name, i->D.RA); } -void Disasm_X_RA_RB(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s r%d, r%d", i.type->name, i.X.RA, i.X.RB); +void Disasm_X_RA_RB(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s r%d, r%d", i->type->name, i->X.RA, i->X.RB); } -void Disasm_XO_RT_RA_RB(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s%s r%d, r%d, r%d", i.XO.Rc ? -7 : -8, i.type->name, - i.XO.OE ? "o" : "", i.XO.Rc ? "." : "", i.XO.RT, i.XO.RA, - i.XO.RB); +void Disasm_XO_RT_RA_RB(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s%s r%d, r%d, r%d", i->XO.Rc ? -7 : -8, i->type->name, + i->XO.OE ? "o" : "", i->XO.Rc ? "." : "", i->XO.RT, + i->XO.RA, i->XO.RB); } -void Disasm_XO_RT_RA(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s%s r%d, r%d", i.XO.Rc ? -7 : -8, i.type->name, - i.XO.OE ? "o" : "", i.XO.Rc ? "." : "", i.XO.RT, i.XO.RA); +void Disasm_XO_RT_RA(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s%s r%d, r%d", i->XO.Rc ? -7 : -8, i->type->name, + i->XO.OE ? "o" : "", i->XO.Rc ? "." : "", i->XO.RT, + i->XO.RA); } -void Disasm_X_RA_RT_RB(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s r%d, r%d, r%d", i.X.Rc ? -7 : -8, i.type->name, - i.X.Rc ? "." : "", i.X.RA, i.X.RT, i.X.RB); +void Disasm_X_RA_RT_RB(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s r%d, r%d, r%d", i->X.Rc ? -7 : -8, i->type->name, + i->X.Rc ? "." : "", i->X.RA, i->X.RT, i->X.RB); } -void Disasm_D_RA_RT_I(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-7s. r%d, r%d, %.4Xh", i.type->name, i.D.RA, i.D.RT, - i.D.DS); +void Disasm_D_RA_RT_I(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-7s. r%d, r%d, %.4Xh", i->type->name, i->D.RA, i->D.RT, + i->D.DS); } -void Disasm_X_RA_RT(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s r%d, r%d", i.X.Rc ? -7 : -8, i.type->name, - i.X.Rc ? "." : "", i.X.RA, i.X.RT); +void Disasm_X_RA_RT(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s r%d, r%d", i->X.Rc ? -7 : -8, i->type->name, + i->X.Rc ? "." : "", i->X.RA, i->X.RT); } #define OP(x) ((((uint32_t)(x)) & 0x3f) << 26) @@ -139,90 +143,90 @@ void Disasm_X_RA_RT(InstrData& i, StringBuffer* str) { #define VX128_5(op, xop) (OP(op) | (((uint32_t)(xop)) & 0x10)) #define VX128_P(op, xop) (OP(op) | (((uint32_t)(xop)) & 0x630)) -#define VX128_VD128 (i.VX128.VD128l | (i.VX128.VD128h << 5)) +#define VX128_VD128 (i->VX128.VD128l | (i->VX128.VD128h << 5)) #define VX128_VA128 \ - (i.VX128.VA128l | (i.VX128.VA128h << 5) | (i.VX128.VA128H << 6)) -#define VX128_VB128 (i.VX128.VB128l | (i.VX128.VB128h << 5)) -#define VX128_1_VD128 (i.VX128_1.VD128l | (i.VX128_1.VD128h << 5)) -#define VX128_2_VD128 (i.VX128_2.VD128l | (i.VX128_2.VD128h << 5)) + (i->VX128.VA128l | (i->VX128.VA128h << 5) | (i->VX128.VA128H << 6)) +#define VX128_VB128 (i->VX128.VB128l | (i->VX128.VB128h << 5)) +#define VX128_1_VD128 (i->VX128_1.VD128l | (i->VX128_1.VD128h << 5)) +#define VX128_2_VD128 (i->VX128_2.VD128l | (i->VX128_2.VD128h << 5)) #define VX128_2_VA128 \ - (i.VX128_2.VA128l | (i.VX128_2.VA128h << 5) | (i.VX128_2.VA128H << 6)) -#define VX128_2_VB128 (i.VX128_2.VB128l | (i.VX128_2.VB128h << 5)) -#define VX128_2_VC (i.VX128_2.VC) -#define VX128_3_VD128 (i.VX128_3.VD128l | (i.VX128_3.VD128h << 5)) -#define VX128_3_VB128 (i.VX128_3.VB128l | (i.VX128_3.VB128h << 5)) -#define VX128_3_IMM (i.VX128_3.IMM) -#define VX128_4_VD128 (i.VX128_4.VD128l | (i.VX128_4.VD128h << 5)) -#define VX128_4_VB128 (i.VX128_4.VB128l | (i.VX128_4.VB128h << 5)) -#define VX128_5_VD128 (i.VX128_5.VD128l | (i.VX128_5.VD128h << 5)) + (i->VX128_2.VA128l | (i->VX128_2.VA128h << 5) | (i->VX128_2.VA128H << 6)) +#define VX128_2_VB128 (i->VX128_2.VB128l | (i->VX128_2.VB128h << 5)) +#define VX128_2_VC (i->VX128_2.VC) +#define VX128_3_VD128 (i->VX128_3.VD128l | (i->VX128_3.VD128h << 5)) +#define VX128_3_VB128 (i->VX128_3.VB128l | (i->VX128_3.VB128h << 5)) +#define VX128_3_IMM (i->VX128_3.IMM) +#define VX128_4_VD128 (i->VX128_4.VD128l | (i->VX128_4.VD128h << 5)) +#define VX128_4_VB128 (i->VX128_4.VB128l | (i->VX128_4.VB128h << 5)) +#define VX128_5_VD128 (i->VX128_5.VD128l | (i->VX128_5.VD128h << 5)) #define VX128_5_VA128 \ - (i.VX128_5.VA128l | (i.VX128_5.VA128h << 5)) | (i.VX128_5.VA128H << 6) -#define VX128_5_VB128 (i.VX128_5.VB128l | (i.VX128_5.VB128h << 5)) -#define VX128_5_SH (i.VX128_5.SH) -#define VX128_R_VD128 (i.VX128_R.VD128l | (i.VX128_R.VD128h << 5)) + (i->VX128_5.VA128l | (i->VX128_5.VA128h << 5)) | (i->VX128_5.VA128H << 6) +#define VX128_5_VB128 (i->VX128_5.VB128l | (i->VX128_5.VB128h << 5)) +#define VX128_5_SH (i->VX128_5.SH) +#define VX128_R_VD128 (i->VX128_R.VD128l | (i->VX128_R.VD128h << 5)) #define VX128_R_VA128 \ - (i.VX128_R.VA128l | (i.VX128_R.VA128h << 5) | (i.VX128_R.VA128H << 6)) -#define VX128_R_VB128 (i.VX128_R.VB128l | (i.VX128_R.VB128h << 5)) + (i->VX128_R.VA128l | (i->VX128_R.VA128h << 5) | (i->VX128_R.VA128H << 6)) +#define VX128_R_VB128 (i->VX128_R.VB128l | (i->VX128_R.VB128h << 5)) -void Disasm_X_VX_RA0_RB(InstrData& i, StringBuffer* str) { - if (i.X.RA) { - str->AppendFormat("%-8s v%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, - i.X.RB); +void Disasm_X_VX_RA0_RB(InstrData* i, StringBuffer* str) { + if (i->X.RA) { + str->AppendFormat("%-8s v%d, r%d, r%d", i->type->name, i->X.RT, i->X.RA, + i->X.RB); } else { - str->AppendFormat("%-8s v%d, 0, r%d", i.type->name, i.X.RT, i.X.RB); + str->AppendFormat("%-8s v%d, 0, r%d", i->type->name, i->X.RT, i->X.RB); } } -void Disasm_VX1281_VD_RA0_RB(InstrData& i, StringBuffer* str) { +void Disasm_VX1281_VD_RA0_RB(InstrData* i, StringBuffer* str) { const uint32_t vd = VX128_1_VD128; - if (i.VX128_1.RA) { - str->AppendFormat("%-8s v%d, r%d, r%d", i.type->name, vd, i.VX128_1.RA, - i.VX128_1.RB); + if (i->VX128_1.RA) { + str->AppendFormat("%-8s v%d, r%d, r%d", i->type->name, vd, i->VX128_1.RA, + i->VX128_1.RB); } else { - str->AppendFormat("%-8s v%d, 0, r%d", i.type->name, vd, i.VX128_1.RB); + str->AppendFormat("%-8s v%d, 0, r%d", i->type->name, vd, i->VX128_1.RB); } } -void Disasm_VX1283_VD_VB(InstrData& i, StringBuffer* str) { +void Disasm_VX1283_VD_VB(InstrData* i, StringBuffer* str) { const uint32_t vd = VX128_3_VD128; const uint32_t vb = VX128_3_VB128; - str->AppendFormat("%-8s v%d, v%d", i.type->name, vd, vb); + str->AppendFormat("%-8s v%d, v%d", i->type->name, vd, vb); } -void Disasm_VX1283_VD_VB_I(InstrData& i, StringBuffer* str) { +void Disasm_VX1283_VD_VB_I(InstrData* i, StringBuffer* str) { const uint32_t vd = VX128_VD128; const uint32_t va = VX128_VA128; - const uint32_t uimm = i.VX128_3.IMM; - str->AppendFormat("%-8s v%d, v%d, %.2Xh", i.type->name, vd, va, uimm); + const uint32_t uimm = i->VX128_3.IMM; + str->AppendFormat("%-8s v%d, v%d, %.2Xh", i->type->name, vd, va, uimm); } -void Disasm_VX_VD_VA_VB(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s v%d, v%d, v%d", i.type->name, i.VX.VD, i.VX.VA, - i.VX.VB); +void Disasm_VX_VD_VA_VB(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s v%d, v%d, v%d", i->type->name, i->VX.VD, i->VX.VA, + i->VX.VB); } -void Disasm_VX128_VD_VA_VB(InstrData& i, StringBuffer* str) { +void Disasm_VX128_VD_VA_VB(InstrData* i, StringBuffer* str) { const uint32_t vd = VX128_VD128; const uint32_t va = VX128_VA128; const uint32_t vb = VX128_VB128; - str->AppendFormat("%-8s v%d, v%d, v%d", i.type->name, vd, va, vb); + str->AppendFormat("%-8s v%d, v%d, v%d", i->type->name, vd, va, vb); } -void Disasm_VX128_VD_VA_VD_VB(InstrData& i, StringBuffer* str) { +void Disasm_VX128_VD_VA_VD_VB(InstrData* i, StringBuffer* str) { const uint32_t vd = VX128_VD128; const uint32_t va = VX128_VA128; const uint32_t vb = VX128_VB128; - str->AppendFormat("%-8s v%d, v%d, v%d, v%d", i.type->name, vd, va, vd, vb); + str->AppendFormat("%-8s v%d, v%d, v%d, v%d", i->type->name, vd, va, vd, vb); } -void Disasm_VX1282_VD_VA_VB_VC(InstrData& i, StringBuffer* str) { +void Disasm_VX1282_VD_VA_VB_VC(InstrData* i, StringBuffer* str) { const uint32_t vd = VX128_2_VD128; const uint32_t va = VX128_2_VA128; const uint32_t vb = VX128_2_VB128; - const uint32_t vc = i.VX128_2.VC; - str->AppendFormat("%-8s v%d, v%d, v%d, v%d", i.type->name, vd, va, vb, vc); + const uint32_t vc = i->VX128_2.VC; + str->AppendFormat("%-8s v%d, v%d, v%d, v%d", i->type->name, vd, va, vb, vc); } -void Disasm_VXA_VD_VA_VB_VC(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s v%d, v%d, v%d, v%d", i.type->name, i.VXA.VD, i.VXA.VA, - i.VXA.VB, i.VXA.VC); +void Disasm_VXA_VD_VA_VB_VC(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s v%d, v%d, v%d, v%d", i->type->name, i->VXA.VD, + i->VXA.VA, i->VXA.VB, i->VXA.VC); } -void Disasm_sync(InstrData& i, StringBuffer* str) { +void Disasm_sync(InstrData* i, StringBuffer* str) { const char* name; - int L = i.X.RT & 3; + int L = i->X.RT & 3; switch (L) { case 0: name = "hwsync"; @@ -239,9 +243,9 @@ void Disasm_sync(InstrData& i, StringBuffer* str) { str->AppendFormat("%-8s %.2X", name, L); } -void Disasm_dcbf(InstrData& i, StringBuffer* str) { +void Disasm_dcbf(InstrData* i, StringBuffer* str) { const char* name; - switch (i.X.RT & 3) { + switch (i->X.RT & 3) { case 0: name = "dcbf"; break; @@ -258,90 +262,90 @@ void Disasm_dcbf(InstrData& i, StringBuffer* str) { name = "dcbf.??"; break; } - str->AppendFormat("%-8s r%d, r%d", name, i.X.RA, i.X.RB); + str->AppendFormat("%-8s r%d, r%d", name, i->X.RA, i->X.RB); } -void Disasm_dcbz(InstrData& i, StringBuffer* str) { +void Disasm_dcbz(InstrData* i, StringBuffer* str) { // or dcbz128 0x7C2007EC - if (i.X.RA) { - str->AppendFormat("%-8s r%d, r%d", i.type->name, i.X.RA, i.X.RB); + if (i->X.RA) { + str->AppendFormat("%-8s r%d, r%d", i->type->name, i->X.RA, i->X.RB); } else { - str->AppendFormat("%-8s 0, r%d", i.type->name, i.X.RB); + str->AppendFormat("%-8s 0, r%d", i->type->name, i->X.RB); } } -void Disasm_fcmp(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s cr%d, f%d, f%d", i.type->name, i.X.RT >> 2, i.X.RA, - i.X.RB); +void Disasm_fcmp(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s cr%d, f%d, f%d", i->type->name, i->X.RT >> 2, i->X.RA, + i->X.RB); } -void Disasm_mffsx(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s f%d, FPSCR", i.X.Rc ? -7 : -8, i.type->name, - i.X.Rc ? "." : "", i.X.RT); +void Disasm_mffsx(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s f%d, FPSCR", i->X.Rc ? -7 : -8, i->type->name, + i->X.Rc ? "." : "", i->X.RT); } -void Disasm_bx(InstrData& i, StringBuffer* str) { - const char* name = i.I.LK ? "bl" : "b"; +void Disasm_bx(InstrData* i, StringBuffer* str) { + const char* name = i->I.LK ? "bl" : "b"; uint32_t nia; - if (i.I.AA) { - nia = (uint32_t)XEEXTS26(i.I.LI << 2); + if (i->I.AA) { + nia = (uint32_t)XEEXTS26(i->I.LI << 2); } else { - nia = (uint32_t)(i.address + XEEXTS26(i.I.LI << 2)); + nia = (uint32_t)(i->address + XEEXTS26(i->I.LI << 2)); } str->AppendFormat("%-8s %.8X", name, nia); // TODO(benvanik): resolve target name? } -void Disasm_bcx(InstrData& i, StringBuffer* str) { - const char* s0 = i.B.LK ? "lr, " : ""; +void Disasm_bcx(InstrData* i, StringBuffer* str) { + const char* s0 = i->B.LK ? "lr, " : ""; const char* s1; - if (!select_bits(i.B.BO, 2, 2)) { + if (!select_bits(i->B.BO, 2, 2)) { s1 = "ctr, "; } else { s1 = ""; } char s2[8] = {0}; - if (!select_bits(i.B.BO, 4, 4)) { - snprintf(s2, xe::countof(s2), "cr%d, ", i.B.BI >> 2); + if (!select_bits(i->B.BO, 4, 4)) { + snprintf(s2, xe::countof(s2), "cr%d, ", i->B.BI >> 2); } uint32_t nia; - if (i.B.AA) { - nia = (uint32_t)XEEXTS16(i.B.BD << 2); + if (i->B.AA) { + nia = (uint32_t)XEEXTS16(i->B.BD << 2); } else { - nia = (uint32_t)(i.address + XEEXTS16(i.B.BD << 2)); + nia = (uint32_t)(i->address + XEEXTS16(i->B.BD << 2)); } - str->AppendFormat("%-8s %s%s%s%.8X", i.type->name, s0, s1, s2, nia); + str->AppendFormat("%-8s %s%s%s%.8X", i->type->name, s0, s1, s2, nia); // TODO(benvanik): resolve target name? } -void Disasm_bcctrx(InstrData& i, StringBuffer* str) { +void Disasm_bcctrx(InstrData* i, StringBuffer* str) { // TODO(benvanik): mnemonics - const char* s0 = i.XL.LK ? "lr, " : ""; + const char* s0 = i->XL.LK ? "lr, " : ""; char s2[8] = {0}; - if (!select_bits(i.XL.BO, 4, 4)) { - snprintf(s2, xe::countof(s2), "cr%d, ", i.XL.BI >> 2); + if (!select_bits(i->XL.BO, 4, 4)) { + snprintf(s2, xe::countof(s2), "cr%d, ", i->XL.BI >> 2); } - str->AppendFormat("%-8s %s%sctr", i.type->name, s0, s2); + str->AppendFormat("%-8s %s%sctr", i->type->name, s0, s2); // TODO(benvanik): resolve target name? } -void Disasm_bclrx(InstrData& i, StringBuffer* str) { +void Disasm_bclrx(InstrData* i, StringBuffer* str) { const char* name = "bclr"; - if (i.code == 0x4E800020) { + if (i->code == 0x4E800020) { name = "blr"; } const char* s1; - if (!select_bits(i.XL.BO, 2, 2)) { + if (!select_bits(i->XL.BO, 2, 2)) { s1 = "ctr, "; } else { s1 = ""; } char s2[8] = {0}; - if (!select_bits(i.XL.BO, 4, 4)) { - snprintf(s2, xe::countof(s2), "cr%d, ", i.XL.BI >> 2); + if (!select_bits(i->XL.BO, 4, 4)) { + snprintf(s2, xe::countof(s2), "cr%d, ", i->XL.BI >> 2); } str->AppendFormat("%-8s %s%s", name, s1, s2); } -void Disasm_mfcr(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s r%d, cr", i.type->name, i.X.RT); +void Disasm_mfcr(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s r%d, cr", i->type->name, i->X.RT); } const char* Disasm_spr_name(uint32_t n) { const char* reg = "???"; @@ -358,154 +362,154 @@ const char* Disasm_spr_name(uint32_t n) { } return reg; } -void Disasm_mfspr(InstrData& i, StringBuffer* str) { - const uint32_t n = ((i.XFX.spr & 0x1F) << 5) | ((i.XFX.spr >> 5) & 0x1F); +void Disasm_mfspr(InstrData* i, StringBuffer* str) { + const uint32_t n = ((i->XFX.spr & 0x1F) << 5) | ((i->XFX.spr >> 5) & 0x1F); const char* reg = Disasm_spr_name(n); - str->AppendFormat("%-8s r%d, %s", i.type->name, i.XFX.RT, reg); + str->AppendFormat("%-8s r%d, %s", i->type->name, i->XFX.RT, reg); } -void Disasm_mtspr(InstrData& i, StringBuffer* str) { - const uint32_t n = ((i.XFX.spr & 0x1F) << 5) | ((i.XFX.spr >> 5) & 0x1F); +void Disasm_mtspr(InstrData* i, StringBuffer* str) { + const uint32_t n = ((i->XFX.spr & 0x1F) << 5) | ((i->XFX.spr >> 5) & 0x1F); const char* reg = Disasm_spr_name(n); - str->AppendFormat("%-8s %s, r%d", i.type->name, reg, i.XFX.RT); + str->AppendFormat("%-8s %s, r%d", i->type->name, reg, i->XFX.RT); } -void Disasm_mftb(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s r%d, tb", i.type->name, i.XFX.RT); +void Disasm_mftb(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s r%d, tb", i->type->name, i->XFX.RT); } -void Disasm_mfmsr(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s r%d", i.type->name, i.X.RT); +void Disasm_mfmsr(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s r%d", i->type->name, i->X.RT); } -void Disasm_mtmsr(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s r%d, %d", i.type->name, i.X.RT, - (i.X.RA & 16) ? 1 : 0); +void Disasm_mtmsr(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s r%d, %d", i->type->name, i->X.RT, + (i->X.RA & 16) ? 1 : 0); } -void Disasm_cmp(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s cr%d, %.2X, r%d, r%d", i.type->name, i.X.RT >> 2, - i.X.RT & 1, i.X.RA, i.X.RB); +void Disasm_cmp(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s cr%d, %.2X, r%d, r%d", i->type->name, i->X.RT >> 2, + i->X.RT & 1, i->X.RA, i->X.RB); } -void Disasm_cmpi(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s cr%d, %.2X, r%d, %d", i.type->name, i.D.RT >> 2, - i.D.RT & 1, i.D.RA, XEEXTS16(i.D.DS)); +void Disasm_cmpi(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s cr%d, %.2X, r%d, %d", i->type->name, i->D.RT >> 2, + i->D.RT & 1, i->D.RA, XEEXTS16(i->D.DS)); } -void Disasm_cmpli(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s cr%d, %.2X, r%d, %.2X", i.type->name, i.D.RT >> 2, - i.D.RT & 1, i.D.RA, XEEXTS16(i.D.DS)); +void Disasm_cmpli(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s cr%d, %.2X, r%d, %.2X", i->type->name, i->D.RT >> 2, + i->D.RT & 1, i->D.RA, XEEXTS16(i->D.DS)); } -void Disasm_rld(InstrData& i, StringBuffer* str) { - if (i.MD.idx == 0) { +void Disasm_rld(InstrData* i, StringBuffer* str) { + if (i->MD.idx == 0) { // XEDISASMR(rldiclx, 0x78000000, MD ) - str->AppendFormat("%*s%s r%d, r%d, %d, %d", i.MD.Rc ? -7 : -8, "rldicl", - i.MD.Rc ? "." : "", i.MD.RA, i.MD.RT, - (i.MD.SH5 << 5) | i.MD.SH, (i.MD.MB5 << 5) | i.MD.MB); - } else if (i.MD.idx == 1) { + str->AppendFormat("%*s%s r%d, r%d, %d, %d", i->MD.Rc ? -7 : -8, "rldicl", + i->MD.Rc ? "." : "", i->MD.RA, i->MD.RT, + (i->MD.SH5 << 5) | i->MD.SH, (i->MD.MB5 << 5) | i->MD.MB); + } else if (i->MD.idx == 1) { // XEDISASMR(rldicrx, 0x78000004, MD ) - str->AppendFormat("%*s%s r%d, r%d, %d, %d", i.MD.Rc ? -7 : -8, "rldicr", - i.MD.Rc ? "." : "", i.MD.RA, i.MD.RT, - (i.MD.SH5 << 5) | i.MD.SH, (i.MD.MB5 << 5) | i.MD.MB); - } else if (i.MD.idx == 2) { + str->AppendFormat("%*s%s r%d, r%d, %d, %d", i->MD.Rc ? -7 : -8, "rldicr", + i->MD.Rc ? "." : "", i->MD.RA, i->MD.RT, + (i->MD.SH5 << 5) | i->MD.SH, (i->MD.MB5 << 5) | i->MD.MB); + } else if (i->MD.idx == 2) { // XEDISASMR(rldicx, 0x78000008, MD ) - uint32_t sh = (i.MD.SH5 << 5) | i.MD.SH; - uint32_t mb = (i.MD.MB5 << 5) | i.MD.MB; + uint32_t sh = (i->MD.SH5 << 5) | i->MD.SH; + uint32_t mb = (i->MD.MB5 << 5) | i->MD.MB; const char* name = (mb == 0x3E) ? "sldi" : "rldic"; - str->AppendFormat("%*s%s r%d, r%d, %d, %d", i.MD.Rc ? -7 : -8, name, - i.MD.Rc ? "." : "", i.MD.RA, i.MD.RT, sh, mb); - } else if (i.MDS.idx == 8) { + str->AppendFormat("%*s%s r%d, r%d, %d, %d", i->MD.Rc ? -7 : -8, name, + i->MD.Rc ? "." : "", i->MD.RA, i->MD.RT, sh, mb); + } else if (i->MDS.idx == 8) { // XEDISASMR(rldclx, 0x78000010, MDS) - str->AppendFormat("%*s%s r%d, r%d, %d, %d", i.MDS.Rc ? -7 : -8, "rldcl", - i.MDS.Rc ? "." : "", i.MDS.RA, i.MDS.RT, i.MDS.RB, - (i.MDS.MB5 << 5) | i.MDS.MB); - } else if (i.MDS.idx == 9) { + str->AppendFormat("%*s%s r%d, r%d, %d, %d", i->MDS.Rc ? -7 : -8, "rldcl", + i->MDS.Rc ? "." : "", i->MDS.RA, i->MDS.RT, i->MDS.RB, + (i->MDS.MB5 << 5) | i->MDS.MB); + } else if (i->MDS.idx == 9) { // XEDISASMR(rldcrx, 0x78000012, MDS) - str->AppendFormat("%*s%s r%d, r%d, %d, %d", i.MDS.Rc ? -7 : -8, "rldcr", - i.MDS.Rc ? "." : "", i.MDS.RA, i.MDS.RT, i.MDS.RB, - (i.MDS.MB5 << 5) | i.MDS.MB); - } else if (i.MD.idx == 3) { + str->AppendFormat("%*s%s r%d, r%d, %d, %d", i->MDS.Rc ? -7 : -8, "rldcr", + i->MDS.Rc ? "." : "", i->MDS.RA, i->MDS.RT, i->MDS.RB, + (i->MDS.MB5 << 5) | i->MDS.MB); + } else if (i->MD.idx == 3) { // XEDISASMR(rldimix, 0x7800000C, MD ) - str->AppendFormat("%*s%s r%d, r%d, %d, %d", i.MD.Rc ? -7 : -8, "rldimi", - i.MD.Rc ? "." : "", i.MD.RA, i.MD.RT, - (i.MD.SH5 << 5) | i.MD.SH, (i.MD.MB5 << 5) | i.MD.MB); + str->AppendFormat("%*s%s r%d, r%d, %d, %d", i->MD.Rc ? -7 : -8, "rldimi", + i->MD.Rc ? "." : "", i->MD.RA, i->MD.RT, + (i->MD.SH5 << 5) | i->MD.SH, (i->MD.MB5 << 5) | i->MD.MB); } else { assert_always(); } } -void Disasm_rlwim(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s r%d, r%d, %d, %d, %d", i.M.Rc ? -7 : -8, - i.type->name, i.M.Rc ? "." : "", i.M.RA, i.M.RT, i.M.SH, - i.M.MB, i.M.ME); +void Disasm_rlwim(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s r%d, r%d, %d, %d, %d", i->M.Rc ? -7 : -8, + i->type->name, i->M.Rc ? "." : "", i->M.RA, i->M.RT, + i->M.SH, i->M.MB, i->M.ME); } -void Disasm_rlwnmx(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s r%d, r%d, r%d, %d, %d", i.M.Rc ? -7 : -8, - i.type->name, i.M.Rc ? "." : "", i.M.RA, i.M.RT, i.M.SH, - i.M.MB, i.M.ME); +void Disasm_rlwnmx(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s r%d, r%d, r%d, %d, %d", i->M.Rc ? -7 : -8, + i->type->name, i->M.Rc ? "." : "", i->M.RA, i->M.RT, + i->M.SH, i->M.MB, i->M.ME); } -void Disasm_srawix(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s r%d, r%d, %d", i.X.Rc ? -7 : -8, i.type->name, - i.X.Rc ? "." : "", i.X.RA, i.X.RT, i.X.RB); +void Disasm_srawix(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s r%d, r%d, %d", i->X.Rc ? -7 : -8, i->type->name, + i->X.Rc ? "." : "", i->X.RA, i->X.RT, i->X.RB); } -void Disasm_sradix(InstrData& i, StringBuffer* str) { - str->AppendFormat("%*s%s r%d, r%d, %d", i.XS.Rc ? -7 : -8, i.type->name, - i.XS.Rc ? "." : "", i.XS.RA, i.XS.RT, - (i.XS.SH5 << 5) | i.XS.SH); +void Disasm_sradix(InstrData* i, StringBuffer* str) { + str->AppendFormat("%*s%s r%d, r%d, %d", i->XS.Rc ? -7 : -8, i->type->name, + i->XS.Rc ? "." : "", i->XS.RA, i->XS.RT, + (i->XS.SH5 << 5) | i->XS.SH); } -void Disasm_vpermwi128(InstrData& i, StringBuffer* str) { - const uint32_t vd = i.VX128_P.VD128l | (i.VX128_P.VD128h << 5); - const uint32_t vb = i.VX128_P.VB128l | (i.VX128_P.VB128h << 5); - str->AppendFormat("%-8s v%d, v%d, %.2X", i.type->name, vd, vb, - i.VX128_P.PERMl | (i.VX128_P.PERMh << 5)); +void Disasm_vpermwi128(InstrData* i, StringBuffer* str) { + const uint32_t vd = i->VX128_P.VD128l | (i->VX128_P.VD128h << 5); + const uint32_t vb = i->VX128_P.VB128l | (i->VX128_P.VB128h << 5); + str->AppendFormat("%-8s v%d, v%d, %.2X", i->type->name, vd, vb, + i->VX128_P.PERMl | (i->VX128_P.PERMh << 5)); } -void Disasm_vrfin128(InstrData& i, StringBuffer* str) { +void Disasm_vrfin128(InstrData* i, StringBuffer* str) { const uint32_t vd = VX128_3_VD128; const uint32_t vb = VX128_3_VB128; - str->AppendFormat("%-8s v%d, v%d", i.type->name, vd, vb); + str->AppendFormat("%-8s v%d, v%d", i->type->name, vd, vb); } -void Disasm_vrlimi128(InstrData& i, StringBuffer* str) { +void Disasm_vrlimi128(InstrData* i, StringBuffer* str) { const uint32_t vd = VX128_4_VD128; const uint32_t vb = VX128_4_VB128; - str->AppendFormat("%-8s v%d, v%d, %.2X, %.2X", i.type->name, vd, vb, - i.VX128_4.IMM, i.VX128_4.z); + str->AppendFormat("%-8s v%d, v%d, %.2X, %.2X", i->type->name, vd, vb, + i->VX128_4.IMM, i->VX128_4.z); } -void Disasm_vsldoi128(InstrData& i, StringBuffer* str) { +void Disasm_vsldoi128(InstrData* i, StringBuffer* str) { const uint32_t vd = VX128_5_VD128; const uint32_t va = VX128_5_VA128; const uint32_t vb = VX128_5_VB128; - const uint32_t sh = i.VX128_5.SH; - str->AppendFormat("%-8s v%d, v%d, v%d, %.2X", i.type->name, vd, va, vb, sh); + const uint32_t sh = i->VX128_5.SH; + str->AppendFormat("%-8s v%d, v%d, v%d, %.2X", i->type->name, vd, va, vb, sh); } -void Disasm_vspltb(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s v%d, v%d, %.2X", i.type->name, i.VX.VD, i.VX.VB, - i.VX.VA & 0xF); +void Disasm_vspltb(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s v%d, v%d, %.2X", i->type->name, i->VX.VD, i->VX.VB, + i->VX.VA & 0xF); } -void Disasm_vsplth(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s v%d, v%d, %.2X", i.type->name, i.VX.VD, i.VX.VB, - i.VX.VA & 0x7); +void Disasm_vsplth(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s v%d, v%d, %.2X", i->type->name, i->VX.VD, i->VX.VB, + i->VX.VA & 0x7); } -void Disasm_vspltw(InstrData& i, StringBuffer* str) { - str->AppendFormat("%-8s v%d, v%d, %.2X", i.type->name, i.VX.VD, i.VX.VB, - i.VX.VA); +void Disasm_vspltw(InstrData* i, StringBuffer* str) { + str->AppendFormat("%-8s v%d, v%d, %.2X", i->type->name, i->VX.VD, i->VX.VB, + i->VX.VA); } -void Disasm_vspltisb(InstrData& i, StringBuffer* str) { +void Disasm_vspltisb(InstrData* i, StringBuffer* str) { // 5bit -> 8bit sign extend - int8_t simm = (i.VX.VA & 0x10) ? (i.VX.VA | 0xF0) : i.VX.VA; - str->AppendFormat("%-8s v%d, %.2X", i.type->name, i.VX.VD, simm); + int8_t simm = (i->VX.VA & 0x10) ? (i->VX.VA | 0xF0) : i->VX.VA; + str->AppendFormat("%-8s v%d, %.2X", i->type->name, i->VX.VD, simm); } -void Disasm_vspltish(InstrData& i, StringBuffer* str) { +void Disasm_vspltish(InstrData* i, StringBuffer* str) { // 5bit -> 16bit sign extend - int16_t simm = (i.VX.VA & 0x10) ? (i.VX.VA | 0xFFF0) : i.VX.VA; - str->AppendFormat("%-8s v%d, %.4X", i.type->name, i.VX.VD, simm); + int16_t simm = (i->VX.VA & 0x10) ? (i->VX.VA | 0xFFF0) : i->VX.VA; + str->AppendFormat("%-8s v%d, %.4X", i->type->name, i->VX.VD, simm); } -void Disasm_vspltisw(InstrData& i, StringBuffer* str) { +void Disasm_vspltisw(InstrData* i, StringBuffer* str) { // 5bit -> 32bit sign extend - int32_t simm = (i.VX.VA & 0x10) ? (i.VX.VA | 0xFFFFFFF0) : i.VX.VA; - str->AppendFormat("%-8s v%d, %.8X", i.type->name, i.VX.VD, simm); + int32_t simm = (i->VX.VA & 0x10) ? (i->VX.VA | 0xFFFFFFF0) : i->VX.VA; + str->AppendFormat("%-8s v%d, %.8X", i->type->name, i->VX.VD, simm); } -int DisasmPPC(InstrData& i, StringBuffer* str) { - if (!i.type) { +int DisasmPPC(InstrData* i, StringBuffer* str) { + if (!i->type) { str->Append("???"); } else { - i.type->disasm(i, str); + i->type->disasm(i, str); } return 0; } diff --git a/src/xenia/cpu/frontend/ppc_disasm.h b/src/xenia/cpu/frontend/ppc_disasm.h index 8414068e0..147084c5d 100644 --- a/src/xenia/cpu/frontend/ppc_disasm.h +++ b/src/xenia/cpu/frontend/ppc_disasm.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_FRONTEND_PPC_DISASM_H_ -#define XENIA_FRONTEND_PPC_DISASM_H_ +#ifndef XENIA_CPU_FRONTEND_PPC_DISASM_H_ +#define XENIA_CPU_FRONTEND_PPC_DISASM_H_ #include "xenia/base/string_buffer.h" #include "xenia/cpu/frontend/ppc_instr.h" @@ -17,10 +17,10 @@ namespace xe { namespace cpu { namespace frontend { -int DisasmPPC(InstrData& i, StringBuffer* str); +int DisasmPPC(InstrData* i, StringBuffer* str); } // namespace frontend } // namespace cpu } // namespace xe -#endif // XENIA_FRONTEND_PPC_DISASM_H_ +#endif // XENIA_CPU_FRONTEND_PPC_DISASM_H_ diff --git a/src/xenia/cpu/frontend/ppc_emit-private.h b/src/xenia/cpu/frontend/ppc_emit-private.h index 6d7d9734a..00c6780d8 100644 --- a/src/xenia/cpu/frontend/ppc_emit-private.h +++ b/src/xenia/cpu/frontend/ppc_emit-private.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_FRONTEND_PPC_EMIT_PRIVATE_H_ -#define XENIA_FRONTEND_PPC_EMIT_PRIVATE_H_ +#ifndef XENIA_CPU_FRONTEND_PPC_EMIT_PRIVATE_H_ +#define XENIA_CPU_FRONTEND_PPC_EMIT_PRIVATE_H_ #include "xenia/cpu/frontend/ppc_emit.h" #include "xenia/cpu/frontend/ppc_instr.h" @@ -22,12 +22,10 @@ namespace frontend { #define XEREGISTERINSTR(name, opcode) \ RegisterInstrEmit(opcode, (InstrEmitFn)InstrEmit_##name); -//#define XEINSTRNOTIMPLEMENTED() #define XEINSTRNOTIMPLEMENTED() assert_always("Instruction not implemented"); -//#define XEINSTRNOTIMPLEMENTED() __debugbreak() } // namespace frontend } // namespace cpu } // namespace xe -#endif // XENIA_FRONTEND_PPC_EMIT_PRIVATE_H_ +#endif // XENIA_CPU_FRONTEND_PPC_EMIT_PRIVATE_H_ diff --git a/src/xenia/cpu/frontend/ppc_emit.h b/src/xenia/cpu/frontend/ppc_emit.h index cbf5ceff1..f6c128363 100644 --- a/src/xenia/cpu/frontend/ppc_emit.h +++ b/src/xenia/cpu/frontend/ppc_emit.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_FRONTEND_PPC_EMIT_H_ -#define XENIA_FRONTEND_PPC_EMIT_H_ +#ifndef XENIA_CPU_FRONTEND_PPC_EMIT_H_ +#define XENIA_CPU_FRONTEND_PPC_EMIT_H_ #include "xenia/cpu/frontend/ppc_instr.h" @@ -26,4 +26,4 @@ void RegisterEmitCategoryMemory(); } // namespace cpu } // namespace xe -#endif // XENIA_FRONTEND_PPC_EMIT_H_ +#endif // XENIA_CPU_FRONTEND_PPC_EMIT_H_ diff --git a/src/xenia/cpu/frontend/ppc_emit_altivec.cc b/src/xenia/cpu/frontend/ppc_emit_altivec.cc index 4aee9cda7..39165e1d0 100644 --- a/src/xenia/cpu/frontend/ppc_emit_altivec.cc +++ b/src/xenia/cpu/frontend/ppc_emit_altivec.cc @@ -987,7 +987,7 @@ int InstrEmit_vmrghw_(PPCHIRBuilder& f, uint32_t vd, uint32_t va, uint32_t vb) { // (VD.z) = (VA.y) // (VD.w) = (VB.y) Value* v = - f.Permute(f.LoadConstantUint32(PERMUTE_MASK(0, 0, 1, 0, 0, 1, 1, 1)), + f.Permute(f.LoadConstantUint32(MakePermuteMask(0, 0, 1, 0, 0, 1, 1, 1)), f.LoadVR(va), f.LoadVR(vb), INT32_TYPE); f.StoreVR(vd, v); return 0; @@ -1028,7 +1028,7 @@ int InstrEmit_vmrglw_(PPCHIRBuilder& f, uint32_t vd, uint32_t va, uint32_t vb) { // (VD.z) = (VA.w) // (VD.w) = (VB.w) Value* v = - f.Permute(f.LoadConstantUint32(PERMUTE_MASK(0, 2, 1, 2, 0, 3, 1, 3)), + f.Permute(f.LoadConstantUint32(MakePermuteMask(0, 2, 1, 2, 0, 3, 1, 3)), f.LoadVR(va), f.LoadVR(vb), INT32_TYPE); f.StoreVR(vd, v); return 0; @@ -1206,7 +1206,7 @@ XEEMITTER(vpermwi128, VX128_P(6, 528), VX128_P)(PPCHIRBuilder& f, const uint32_t vd = i.VX128_P.VD128l | (i.VX128_P.VD128h << 5); const uint32_t vb = i.VX128_P.VB128l | (i.VX128_P.VB128h << 5); uint32_t uimm = i.VX128_P.PERMl | (i.VX128_P.PERMh << 5); - uint32_t mask = SWIZZLE_MASK(uimm >> 6, uimm >> 4, uimm >> 2, uimm >> 0); + uint32_t mask = MakeSwizzleMask(uimm >> 6, uimm >> 4, uimm >> 2, uimm >> 0); Value* v = f.Swizzle(f.LoadVR(vb), INT32_TYPE, mask); f.StoreVR(vd, v); return 0; @@ -1347,7 +1347,7 @@ XEEMITTER(vrlimi128, VX128_4(6, 1808), VX128_4)(PPCHIRBuilder& f, } else { v = f.LoadVR(vb); } - if (blend_mask != PERMUTE_IDENTITY) { + if (blend_mask != kIdentityPermuteMask) { v = f.Permute(f.LoadConstantUint32(blend_mask), v, f.LoadVR(vd), INT32_TYPE); } @@ -2053,22 +2053,22 @@ XEEMITTER(vpkd3d128, VX128_4(6, 1552), VX128_4)(PPCHIRBuilder& f, } // http://hlssmod.net/he_code/public/pixelwriter.h // control = prev:0123 | new:4567 - uint32_t control = PERMUTE_IDENTITY; // original + uint32_t control = kIdentityPermuteMask; // original switch (pack) { case 1: // VPACK_32 // VPACK_32 & shift = 3 puts lower 32 bits in x (leftmost slot). switch (shift) { case 0: - control = PERMUTE_MASK(0, 0, 0, 1, 0, 2, 1, 3); + control = MakePermuteMask(0, 0, 0, 1, 0, 2, 1, 3); break; case 1: - control = PERMUTE_MASK(0, 0, 0, 1, 1, 3, 0, 3); + control = MakePermuteMask(0, 0, 0, 1, 1, 3, 0, 3); break; case 2: - control = PERMUTE_MASK(0, 0, 1, 3, 0, 2, 0, 3); + control = MakePermuteMask(0, 0, 1, 3, 0, 2, 0, 3); break; case 3: - control = PERMUTE_MASK(1, 3, 0, 1, 0, 2, 0, 3); + control = MakePermuteMask(1, 3, 0, 1, 0, 2, 0, 3); break; default: assert_unhandled_case(shift); @@ -2078,16 +2078,16 @@ XEEMITTER(vpkd3d128, VX128_4(6, 1552), VX128_4)(PPCHIRBuilder& f, case 2: // 64bit switch (shift) { case 0: - control = PERMUTE_MASK(0, 0, 0, 1, 1, 2, 1, 3); + control = MakePermuteMask(0, 0, 0, 1, 1, 2, 1, 3); break; case 1: - control = PERMUTE_MASK(0, 0, 1, 2, 1, 3, 0, 3); + control = MakePermuteMask(0, 0, 1, 2, 1, 3, 0, 3); break; case 2: - control = PERMUTE_MASK(1, 2, 1, 3, 0, 2, 0, 3); + control = MakePermuteMask(1, 2, 1, 3, 0, 2, 0, 3); break; case 3: - control = PERMUTE_MASK(1, 3, 0, 1, 0, 2, 0, 3); + control = MakePermuteMask(1, 3, 0, 1, 0, 2, 0, 3); break; default: assert_unhandled_case(shift); @@ -2097,16 +2097,16 @@ XEEMITTER(vpkd3d128, VX128_4(6, 1552), VX128_4)(PPCHIRBuilder& f, case 3: // 64bit switch (shift) { case 0: - control = PERMUTE_MASK(0, 0, 0, 1, 1, 2, 1, 3); + control = MakePermuteMask(0, 0, 0, 1, 1, 2, 1, 3); break; case 1: - control = PERMUTE_MASK(0, 0, 1, 2, 1, 3, 0, 3); + control = MakePermuteMask(0, 0, 1, 2, 1, 3, 0, 3); break; case 2: - control = PERMUTE_MASK(1, 2, 1, 3, 0, 2, 0, 3); + control = MakePermuteMask(1, 2, 1, 3, 0, 2, 0, 3); break; case 3: - control = PERMUTE_MASK(0, 0, 0, 1, 0, 2, 1, 2); + control = MakePermuteMask(0, 0, 0, 1, 0, 2, 1, 2); break; default: assert_unhandled_case(shift); diff --git a/src/xenia/cpu/frontend/ppc_frontend.h b/src/xenia/cpu/frontend/ppc_frontend.h index 0f374457c..262c2b374 100644 --- a/src/xenia/cpu/frontend/ppc_frontend.h +++ b/src/xenia/cpu/frontend/ppc_frontend.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_FRONTEND_PPC_FRONTEND_H_ -#define XENIA_FRONTEND_PPC_FRONTEND_H_ +#ifndef XENIA_CPU_FRONTEND_PPC_FRONTEND_H_ +#define XENIA_CPU_FRONTEND_PPC_FRONTEND_H_ #include #include @@ -64,4 +64,4 @@ class PPCFrontend { } // namespace cpu } // namespace xe -#endif // XENIA_FRONTEND_PPC_FRONTEND_H_ +#endif // XENIA_CPU_FRONTEND_PPC_FRONTEND_H_ diff --git a/src/xenia/cpu/frontend/ppc_hir_builder.cc b/src/xenia/cpu/frontend/ppc_hir_builder.cc index ebd2dfa4c..e691669ab 100644 --- a/src/xenia/cpu/frontend/ppc_hir_builder.cc +++ b/src/xenia/cpu/frontend/ppc_hir_builder.cc @@ -106,7 +106,7 @@ bool PPCHIRBuilder::Emit(GuestFunction* function, uint32_t flags) { } comment_buffer_.Reset(); comment_buffer_.AppendFormat("%.8X %.8X ", address, i.code); - DisasmPPC(i, &comment_buffer_); + DisasmPPC(&i, &comment_buffer_); Comment(comment_buffer_); first_instr = last_instr(); } diff --git a/src/xenia/cpu/frontend/ppc_hir_builder.h b/src/xenia/cpu/frontend/ppc_hir_builder.h index 7d1900d92..d4c0b9ee3 100644 --- a/src/xenia/cpu/frontend/ppc_hir_builder.h +++ b/src/xenia/cpu/frontend/ppc_hir_builder.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_FRONTEND_PPC_HIR_BUILDER_H_ -#define XENIA_FRONTEND_PPC_HIR_BUILDER_H_ +#ifndef XENIA_CPU_FRONTEND_PPC_HIR_BUILDER_H_ +#define XENIA_CPU_FRONTEND_PPC_HIR_BUILDER_H_ #include "xenia/base/string_buffer.h" #include "xenia/cpu/hir/hir_builder.h" @@ -26,7 +26,7 @@ class PPCHIRBuilder : public hir::HIRBuilder { using Value = xe::cpu::hir::Value; public: - PPCHIRBuilder(PPCFrontend* frontend); + explicit PPCHIRBuilder(PPCFrontend* frontend); ~PPCHIRBuilder() override; void Reset() override; @@ -109,4 +109,4 @@ class PPCHIRBuilder : public hir::HIRBuilder { } // namespace cpu } // namespace xe -#endif // XENIA_FRONTEND_PPC_HIR_BUILDER_H_ +#endif // XENIA_CPU_FRONTEND_PPC_HIR_BUILDER_H_ diff --git a/src/xenia/cpu/frontend/ppc_instr.h b/src/xenia/cpu/frontend/ppc_instr.h index 1067f0351..99a61a4b2 100644 --- a/src/xenia/cpu/frontend/ppc_instr.h +++ b/src/xenia/cpu/frontend/ppc_instr.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_FRONTEND_PPC_INSTR_H_ -#define XENIA_FRONTEND_PPC_INSTR_H_ +#ifndef XENIA_CPU_FRONTEND_PPC_INSTR_H_ +#define XENIA_CPU_FRONTEND_PPC_INSTR_H_ #include #include @@ -497,7 +497,7 @@ class InstrDisasm { void Dump(std::string& out_str, size_t pad = 13); }; -typedef void (*InstrDisasmFn)(InstrData& i, StringBuffer* str); +typedef void (*InstrDisasmFn)(InstrData* i, StringBuffer* str); typedef void* InstrEmitFn; class InstrType { @@ -522,4 +522,4 @@ int RegisterInstrEmit(uint32_t code, InstrEmitFn emit); } // namespace cpu } // namespace xe -#endif // XENIA_FRONTEND_PPC_INSTR_H_ +#endif // XENIA_CPU_FRONTEND_PPC_INSTR_H_ diff --git a/src/xenia/cpu/frontend/ppc_instr_tables.h b/src/xenia/cpu/frontend/ppc_instr_tables.h index 6ddae920d..f5dfb5fc4 100644 --- a/src/xenia/cpu/frontend/ppc_instr_tables.h +++ b/src/xenia/cpu/frontend/ppc_instr_tables.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_FRONTEND_PPC_INSTR_TABLES_H_ -#define XENIA_FRONTEND_PPC_INSTR_TABLES_H_ +#ifndef XENIA_CPU_FRONTEND_PPC_INSTR_TABLES_H_ +#define XENIA_CPU_FRONTEND_PPC_INSTR_TABLES_H_ #include @@ -20,76 +20,76 @@ namespace xe { namespace cpu { namespace frontend { -void Disasm_0(InstrData& i, StringBuffer* str); -void Disasm__(InstrData& i, StringBuffer* str); -void Disasm_X_FRT_FRB(InstrData& i, StringBuffer* str); -void Disasm_A_FRT_FRB(InstrData& i, StringBuffer* str); -void Disasm_A_FRT_FRA_FRB(InstrData& i, StringBuffer* str); -void Disasm_A_FRT_FRA_FRB_FRC(InstrData& i, StringBuffer* str); -void Disasm_X_RT_RA_RB(InstrData& i, StringBuffer* str); -void Disasm_X_RT_RA0_RB(InstrData& i, StringBuffer* str); -void Disasm_X_FRT_RA_RB(InstrData& i, StringBuffer* str); -void Disasm_X_FRT_RA0_RB(InstrData& i, StringBuffer* str); -void Disasm_D_RT_RA_I(InstrData& i, StringBuffer* str); -void Disasm_D_RT_RA0_I(InstrData& i, StringBuffer* str); -void Disasm_D_FRT_RA_I(InstrData& i, StringBuffer* str); -void Disasm_D_FRT_RA0_I(InstrData& i, StringBuffer* str); -void Disasm_DS_RT_RA_I(InstrData& i, StringBuffer* str); -void Disasm_DS_RT_RA0_I(InstrData& i, StringBuffer* str); -void Disasm_D_RA(InstrData& i, StringBuffer* str); -void Disasm_X_RA_RB(InstrData& i, StringBuffer* str); -void Disasm_XO_RT_RA_RB(InstrData& i, StringBuffer* str); -void Disasm_XO_RT_RA(InstrData& i, StringBuffer* str); -void Disasm_X_RA_RT_RB(InstrData& i, StringBuffer* str); -void Disasm_D_RA_RT_I(InstrData& i, StringBuffer* str); -void Disasm_X_RA_RT(InstrData& i, StringBuffer* str); -void Disasm_X_VX_RA0_RB(InstrData& i, StringBuffer* str); -void Disasm_VX1281_VD_RA0_RB(InstrData& i, StringBuffer* str); -void Disasm_VX1283_VD_VB(InstrData& i, StringBuffer* str); -void Disasm_VX1283_VD_VB_I(InstrData& i, StringBuffer* str); -void Disasm_VX_VD_VA_VB(InstrData& i, StringBuffer* str); -void Disasm_VX128_VD_VA_VB(InstrData& i, StringBuffer* str); -void Disasm_VX128_VD_VA_VD_VB(InstrData& i, StringBuffer* str); -void Disasm_VX1282_VD_VA_VB_VC(InstrData& i, StringBuffer* str); -void Disasm_VXA_VD_VA_VB_VC(InstrData& i, StringBuffer* str); +void Disasm_0(InstrData* i, StringBuffer* str); +void Disasm__(InstrData* i, StringBuffer* str); +void Disasm_X_FRT_FRB(InstrData* i, StringBuffer* str); +void Disasm_A_FRT_FRB(InstrData* i, StringBuffer* str); +void Disasm_A_FRT_FRA_FRB(InstrData* i, StringBuffer* str); +void Disasm_A_FRT_FRA_FRB_FRC(InstrData* i, StringBuffer* str); +void Disasm_X_RT_RA_RB(InstrData* i, StringBuffer* str); +void Disasm_X_RT_RA0_RB(InstrData* i, StringBuffer* str); +void Disasm_X_FRT_RA_RB(InstrData* i, StringBuffer* str); +void Disasm_X_FRT_RA0_RB(InstrData* i, StringBuffer* str); +void Disasm_D_RT_RA_I(InstrData* i, StringBuffer* str); +void Disasm_D_RT_RA0_I(InstrData* i, StringBuffer* str); +void Disasm_D_FRT_RA_I(InstrData* i, StringBuffer* str); +void Disasm_D_FRT_RA0_I(InstrData* i, StringBuffer* str); +void Disasm_DS_RT_RA_I(InstrData* i, StringBuffer* str); +void Disasm_DS_RT_RA0_I(InstrData* i, StringBuffer* str); +void Disasm_D_RA(InstrData* i, StringBuffer* str); +void Disasm_X_RA_RB(InstrData* i, StringBuffer* str); +void Disasm_XO_RT_RA_RB(InstrData* i, StringBuffer* str); +void Disasm_XO_RT_RA(InstrData* i, StringBuffer* str); +void Disasm_X_RA_RT_RB(InstrData* i, StringBuffer* str); +void Disasm_D_RA_RT_I(InstrData* i, StringBuffer* str); +void Disasm_X_RA_RT(InstrData* i, StringBuffer* str); +void Disasm_X_VX_RA0_RB(InstrData* i, StringBuffer* str); +void Disasm_VX1281_VD_RA0_RB(InstrData* i, StringBuffer* str); +void Disasm_VX1283_VD_VB(InstrData* i, StringBuffer* str); +void Disasm_VX1283_VD_VB_I(InstrData* i, StringBuffer* str); +void Disasm_VX_VD_VA_VB(InstrData* i, StringBuffer* str); +void Disasm_VX128_VD_VA_VB(InstrData* i, StringBuffer* str); +void Disasm_VX128_VD_VA_VD_VB(InstrData* i, StringBuffer* str); +void Disasm_VX1282_VD_VA_VB_VC(InstrData* i, StringBuffer* str); +void Disasm_VXA_VD_VA_VB_VC(InstrData* i, StringBuffer* str); -void Disasm_sync(InstrData& i, StringBuffer* str); -void Disasm_dcbf(InstrData& i, StringBuffer* str); -void Disasm_dcbz(InstrData& i, StringBuffer* str); -void Disasm_fcmp(InstrData& i, StringBuffer* str); +void Disasm_sync(InstrData* i, StringBuffer* str); +void Disasm_dcbf(InstrData* i, StringBuffer* str); +void Disasm_dcbz(InstrData* i, StringBuffer* str); +void Disasm_fcmp(InstrData* i, StringBuffer* str); -void Disasm_bx(InstrData& i, StringBuffer* str); -void Disasm_bcx(InstrData& i, StringBuffer* str); -void Disasm_bcctrx(InstrData& i, StringBuffer* str); -void Disasm_bclrx(InstrData& i, StringBuffer* str); +void Disasm_bx(InstrData* i, StringBuffer* str); +void Disasm_bcx(InstrData* i, StringBuffer* str); +void Disasm_bcctrx(InstrData* i, StringBuffer* str); +void Disasm_bclrx(InstrData* i, StringBuffer* str); -void Disasm_mfcr(InstrData& i, StringBuffer* str); -void Disasm_mfspr(InstrData& i, StringBuffer* str); -void Disasm_mtspr(InstrData& i, StringBuffer* str); -void Disasm_mftb(InstrData& i, StringBuffer* str); -void Disasm_mfmsr(InstrData& i, StringBuffer* str); -void Disasm_mtmsr(InstrData& i, StringBuffer* str); +void Disasm_mfcr(InstrData* i, StringBuffer* str); +void Disasm_mfspr(InstrData* i, StringBuffer* str); +void Disasm_mtspr(InstrData* i, StringBuffer* str); +void Disasm_mftb(InstrData* i, StringBuffer* str); +void Disasm_mfmsr(InstrData* i, StringBuffer* str); +void Disasm_mtmsr(InstrData* i, StringBuffer* str); -void Disasm_cmp(InstrData& i, StringBuffer* str); -void Disasm_cmpi(InstrData& i, StringBuffer* str); -void Disasm_cmpli(InstrData& i, StringBuffer* str); +void Disasm_cmp(InstrData* i, StringBuffer* str); +void Disasm_cmpi(InstrData* i, StringBuffer* str); +void Disasm_cmpli(InstrData* i, StringBuffer* str); -void Disasm_rld(InstrData& i, StringBuffer* str); -void Disasm_rlwim(InstrData& i, StringBuffer* str); -void Disasm_rlwnmx(InstrData& i, StringBuffer* str); -void Disasm_srawix(InstrData& i, StringBuffer* str); -void Disasm_sradix(InstrData& i, StringBuffer* str); +void Disasm_rld(InstrData* i, StringBuffer* str); +void Disasm_rlwim(InstrData* i, StringBuffer* str); +void Disasm_rlwnmx(InstrData* i, StringBuffer* str); +void Disasm_srawix(InstrData* i, StringBuffer* str); +void Disasm_sradix(InstrData* i, StringBuffer* str); -void Disasm_vpermwi128(InstrData& i, StringBuffer* str); -void Disasm_vrfin128(InstrData& i, StringBuffer* str); -void Disasm_vrlimi128(InstrData& i, StringBuffer* str); -void Disasm_vsldoi128(InstrData& i, StringBuffer* str); -void Disasm_vspltb(InstrData& i, StringBuffer* str); -void Disasm_vsplth(InstrData& i, StringBuffer* str); -void Disasm_vspltw(InstrData& i, StringBuffer* str); -void Disasm_vspltisb(InstrData& i, StringBuffer* str); -void Disasm_vspltish(InstrData& i, StringBuffer* str); -void Disasm_vspltisw(InstrData& i, StringBuffer* str); +void Disasm_vpermwi128(InstrData* i, StringBuffer* str); +void Disasm_vrfin128(InstrData* i, StringBuffer* str); +void Disasm_vrlimi128(InstrData* i, StringBuffer* str); +void Disasm_vsldoi128(InstrData* i, StringBuffer* str); +void Disasm_vspltb(InstrData* i, StringBuffer* str); +void Disasm_vsplth(InstrData* i, StringBuffer* str); +void Disasm_vspltw(InstrData* i, StringBuffer* str); +void Disasm_vspltisb(InstrData* i, StringBuffer* str); +void Disasm_vspltish(InstrData* i, StringBuffer* str); +void Disasm_vspltisw(InstrData* i, StringBuffer* str); namespace tables { @@ -1097,4 +1097,4 @@ static InstrType instr_table_scan[] = { } // namespace cpu } // namespace xe -#endif // XENIA_FRONTEND_PPC_INSTR_TABLES_H_ +#endif // XENIA_CPU_FRONTEND_PPC_INSTR_TABLES_H_ diff --git a/src/xenia/cpu/frontend/ppc_scanner.h b/src/xenia/cpu/frontend/ppc_scanner.h index b2c893d46..f83520265 100644 --- a/src/xenia/cpu/frontend/ppc_scanner.h +++ b/src/xenia/cpu/frontend/ppc_scanner.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_FRONTEND_PPC_SCANNER_H_ -#define XENIA_FRONTEND_PPC_SCANNER_H_ +#ifndef XENIA_CPU_FRONTEND_PPC_SCANNER_H_ +#define XENIA_CPU_FRONTEND_PPC_SCANNER_H_ #include @@ -28,7 +28,7 @@ struct BlockInfo { class PPCScanner { public: - PPCScanner(PPCFrontend* frontend); + explicit PPCScanner(PPCFrontend* frontend); ~PPCScanner(); bool Scan(GuestFunction* function, DebugInfo* debug_info); @@ -45,4 +45,4 @@ class PPCScanner { } // namespace cpu } // namespace xe -#endif // XENIA_FRONTEND_PPC_SCANNER_H_ +#endif // XENIA_CPU_FRONTEND_PPC_SCANNER_H_ diff --git a/src/xenia/cpu/frontend/ppc_translator.cc b/src/xenia/cpu/frontend/ppc_translator.cc index 03eb5e3b4..cbde6d8fc 100644 --- a/src/xenia/cpu/frontend/ppc_translator.cc +++ b/src/xenia/cpu/frontend/ppc_translator.cc @@ -33,9 +33,6 @@ namespace xe { namespace cpu { namespace frontend { -// TODO(benvanik): remove when enums redefined. -using namespace xe::cpu; - using xe::cpu::backend::Backend; using xe::cpu::compiler::Compiler; namespace passes = xe::cpu::compiler::passes; @@ -208,7 +205,7 @@ bool PPCTranslator::Translate(GuestFunction* function, } return true; -}; +} void PPCTranslator::DumpSource(GuestFunction* function, StringBuffer* string_buffer) { @@ -239,7 +236,7 @@ void PPCTranslator::DumpSource(GuestFunction* function, } string_buffer->AppendFormat("%.8X %.8X ", address, i.code); - DisasmPPC(i, string_buffer); + DisasmPPC(&i, string_buffer); string_buffer->Append('\n'); } } diff --git a/src/xenia/cpu/frontend/ppc_translator.h b/src/xenia/cpu/frontend/ppc_translator.h index 7aaccf6b9..dd1489387 100644 --- a/src/xenia/cpu/frontend/ppc_translator.h +++ b/src/xenia/cpu/frontend/ppc_translator.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_FRONTEND_PPC_TRANSLATOR_H_ -#define XENIA_FRONTEND_PPC_TRANSLATOR_H_ +#ifndef XENIA_CPU_FRONTEND_PPC_TRANSLATOR_H_ +#define XENIA_CPU_FRONTEND_PPC_TRANSLATOR_H_ #include @@ -27,7 +27,7 @@ class PPCScanner; class PPCTranslator { public: - PPCTranslator(PPCFrontend* frontend); + explicit PPCTranslator(PPCFrontend* frontend); ~PPCTranslator(); bool Translate(GuestFunction* function, uint32_t debug_info_flags); @@ -48,4 +48,4 @@ class PPCTranslator { } // namespace cpu } // namespace xe -#endif // XENIA_FRONTEND_PPC_TRANSLATOR_H_ +#endif // XENIA_CPU_FRONTEND_PPC_TRANSLATOR_H_ diff --git a/src/xenia/cpu/hir/block.h b/src/xenia/cpu/hir/block.h index 83feb7f2a..f4fb21105 100644 --- a/src/xenia/cpu/hir/block.h +++ b/src/xenia/cpu/hir/block.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_HIR_BLOCK_H_ -#define XENIA_HIR_BLOCK_H_ +#ifndef XENIA_CPU_HIR_BLOCK_H_ +#define XENIA_CPU_HIR_BLOCK_H_ #include "xenia/base/arena.h" @@ -70,4 +70,4 @@ class Block { } // namespace cpu } // namespace xe -#endif // XENIA_HIR_BLOCK_H_ +#endif // XENIA_CPU_HIR_BLOCK_H_ diff --git a/src/xenia/cpu/hir/hir_builder.cc b/src/xenia/cpu/hir/hir_builder.cc index 1795b5faf..6b409c8ff 100644 --- a/src/xenia/cpu/hir/hir_builder.cc +++ b/src/xenia/cpu/hir/hir_builder.cc @@ -21,7 +21,7 @@ #include "xenia/profiling.h" // Will scribble arena memory to hopefully find use before clears. -//#define SCRIBBLE_ARENA_ON_RESET +// #define SCRIBBLE_ARENA_ON_RESET namespace xe { namespace cpu { @@ -243,7 +243,7 @@ void HIRBuilder::Dump(StringBuffer* str) { continue; } if (i->opcode == &OPCODE_COMMENT_info) { - str->AppendFormat(" ; %s\n", (char*)i->src1.offset); + str->AppendFormat(" ; %s\n", reinterpret_cast(i->src1.offset)); i = i->next; continue; } diff --git a/src/xenia/cpu/hir/hir_builder.h b/src/xenia/cpu/hir/hir_builder.h index 1e0966d9a..fb4ad489a 100644 --- a/src/xenia/cpu/hir/hir_builder.h +++ b/src/xenia/cpu/hir/hir_builder.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_HIR_HIR_BUILDER_H_ -#define XENIA_HIR_HIR_BUILDER_H_ +#ifndef XENIA_CPU_HIR_HIR_BUILDER_H_ +#define XENIA_CPU_HIR_HIR_BUILDER_H_ #include @@ -272,4 +272,4 @@ class HIRBuilder { } // namespace cpu } // namespace xe -#endif // XENIA_HIR_HIR_BUILDER_H_ +#endif // XENIA_CPU_HIR_HIR_BUILDER_H_ diff --git a/src/xenia/cpu/hir/instr.h b/src/xenia/cpu/hir/instr.h index 6c9ad9731..67fe47ede 100644 --- a/src/xenia/cpu/hir/instr.h +++ b/src/xenia/cpu/hir/instr.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_HIR_INSTR_H_ -#define XENIA_HIR_INSTR_H_ +#ifndef XENIA_CPU_HIR_INSTR_H_ +#define XENIA_CPU_HIR_INSTR_H_ #include "xenia/cpu/hir/opcodes.h" #include "xenia/cpu/hir/value.h" @@ -65,4 +65,4 @@ class Instr { } // namespace cpu } // namespace xe -#endif // XENIA_HIR_INSTR_H_ +#endif // XENIA_CPU_HIR_INSTR_H_ diff --git a/src/xenia/cpu/hir/label.h b/src/xenia/cpu/hir/label.h index fa86ff535..c57fd0154 100644 --- a/src/xenia/cpu/hir/label.h +++ b/src/xenia/cpu/hir/label.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_HIR_LABEL_H_ -#define XENIA_HIR_LABEL_H_ +#ifndef XENIA_CPU_HIR_LABEL_H_ +#define XENIA_CPU_HIR_LABEL_H_ namespace xe { namespace cpu { @@ -32,4 +32,4 @@ class Label { } // namespace cpu } // namespace xe -#endif // XENIA_HIR_LABEL_H_ +#endif // XENIA_CPU_HIR_LABEL_H_ diff --git a/src/xenia/cpu/hir/opcodes.cc b/src/xenia/cpu/hir/opcodes.cc index 0e4ae6ffd..bbfe0cebe 100644 --- a/src/xenia/cpu/hir/opcodes.cc +++ b/src/xenia/cpu/hir/opcodes.cc @@ -9,8 +9,6 @@ #include "xenia/cpu/hir/opcodes.h" -using namespace xe::cpu::hir; - namespace xe { namespace cpu { namespace hir { diff --git a/src/xenia/cpu/hir/opcodes.h b/src/xenia/cpu/hir/opcodes.h index 99d34ab5d..83b6a77a6 100644 --- a/src/xenia/cpu/hir/opcodes.h +++ b/src/xenia/cpu/hir/opcodes.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_HIR_OPCODES_H_ -#define XENIA_HIR_OPCODES_H_ +#ifndef XENIA_CPU_HIR_OPCODES_H_ +#define XENIA_CPU_HIR_OPCODES_H_ #include @@ -20,10 +20,12 @@ enum CallFlags { CALL_TAIL = (1 << 1), CALL_POSSIBLE_RETURN = (1 << 2), }; + enum BranchFlags { BRANCH_LIKELY = (1 << 1), BRANCH_UNLIKELY = (1 << 2), }; + enum RoundMode { // to zero/nearest/etc ROUND_TO_ZERO = 0, @@ -31,31 +33,45 @@ enum RoundMode { ROUND_TO_MINUS_INFINITY, ROUND_TO_POSITIVE_INFINITY, }; + enum LoadStoreFlags { LOAD_STORE_BYTE_SWAP = 1 << 0, }; + enum PrefetchFlags { PREFETCH_LOAD = (1 << 1), PREFETCH_STORE = (1 << 2), }; + enum ArithmeticFlags { ARITHMETIC_UNSIGNED = (1 << 2), ARITHMETIC_SATURATE = (1 << 3), }; -#define PERMUTE_MASK(sel_x, x, sel_y, y, sel_z, z, sel_w, w) \ - ((((x)&0x3) << 0) | (sel_x << 2) | (((y)&0x3) << 8) | (sel_y << 10) | \ - (((z)&0x3) << 16) | (sel_z << 18) | (((w)&0x3) << 24) | (sel_w << 26)) -enum Permutes { - PERMUTE_IDENTITY = PERMUTE_MASK(0, 0, 0, 1, 0, 2, 0, 3), + +constexpr uint32_t MakePermuteMask(uint32_t sel_x, uint32_t x, uint32_t sel_y, + uint32_t y, uint32_t sel_z, uint32_t z, + uint32_t sel_w, uint32_t w) { + return ((x & 0x3) << 0) | (sel_x << 2) | ((y & 0x3) << 8) | (sel_y << 10) | + ((z & 0x3) << 16) | (sel_z << 18) | ((w & 0x3) << 24) | (sel_w << 26); +} + +enum PermuteMasks : uint32_t { + kIdentityPermuteMask = MakePermuteMask(0, 0, 0, 1, 0, 2, 0, 3), }; -#define SWIZZLE_MASK(x, y, z, w) \ - ((((x)&0x3) << 0) | (((y)&0x3) << 2) | (((z)&0x3) << 4) | (((w)&0x3) << 6)) + +constexpr uint32_t MakeSwizzleMask(uint32_t x, uint32_t y, uint32_t z, + uint32_t w) { + return ((x & 0x3) << 0) | ((y & 0x3) << 2) | ((z & 0x3) << 4) | + ((w & 0x3) << 6); +} + enum Swizzles { - SWIZZLE_XYZW_TO_XYZW = SWIZZLE_MASK(0, 1, 2, 3), - SWIZZLE_XYZW_TO_YZWX = SWIZZLE_MASK(1, 2, 3, 0), - SWIZZLE_XYZW_TO_ZWXY = SWIZZLE_MASK(2, 3, 0, 1), - SWIZZLE_XYZW_TO_WXYZ = SWIZZLE_MASK(3, 0, 1, 2), + SWIZZLE_XYZW_TO_XYZW = MakeSwizzleMask(0, 1, 2, 3), + SWIZZLE_XYZW_TO_YZWX = MakeSwizzleMask(1, 2, 3, 0), + SWIZZLE_XYZW_TO_ZWXY = MakeSwizzleMask(2, 3, 0, 1), + SWIZZLE_XYZW_TO_WXYZ = MakeSwizzleMask(3, 0, 1, 2), }; + enum PackType : uint16_t { // Special types: PACK_TYPE_D3DCOLOR = 0, @@ -82,6 +98,7 @@ enum PackType : uint16_t { PACK_TYPE_OUT_UNSATURATE = 0 << 15, PACK_TYPE_OUT_SATURATE = 1 << 15, }; + inline bool IsPackToHi(uint32_t flags) { return (flags & PACK_TYPE_TO_HI) == PACK_TYPE_TO_HI; } @@ -284,4 +301,4 @@ typedef struct { } // namespace cpu } // namespace xe -#endif // XENIA_HIR_OPCODES_H_ +#endif // XENIA_CPU_HIR_OPCODES_H_ diff --git a/src/xenia/cpu/hir/value.h b/src/xenia/cpu/hir/value.h index cc593c995..c078983bb 100644 --- a/src/xenia/cpu/hir/value.h +++ b/src/xenia/cpu/hir/value.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_HIR_VALUE_H_ -#define XENIA_HIR_VALUE_H_ +#ifndef XENIA_CPU_HIR_VALUE_H_ +#define XENIA_CPU_HIR_VALUE_H_ #include "xenia/base/arena.h" #include "xenia/base/assert.h" @@ -105,14 +105,6 @@ class Value { Use* AddUse(Arena* arena, Instr* instr); void RemoveUse(Use* use); - int8_t get_constant(int8_t) const { return constant.i8; } - int16_t get_constant(int16_t) const { return constant.i16; } - int32_t get_constant(int32_t) const { return constant.i32; } - int64_t get_constant(int64_t) const { return constant.i64; } - float get_constant(float) const { return constant.f32; } - double get_constant(double) const { return constant.f64; } - vec128_t get_constant(vec128_t&) const { return constant.v128; } - void set_zero(TypeName new_type) { type = new_type; flags |= VALUE_IS_CONSTANT; @@ -511,4 +503,4 @@ class Value { } // namespace cpu } // namespace xe -#endif // XENIA_HIR_VALUE_H_ +#endif // XENIA_CPU_HIR_VALUE_H_ diff --git a/src/xenia/cpu/testing/permute_test.cc b/src/xenia/cpu/testing/permute_test.cc index 88fd848ab..6c9ee6ecc 100644 --- a/src/xenia/cpu/testing/permute_test.cc +++ b/src/xenia/cpu/testing/permute_test.cc @@ -17,7 +17,7 @@ using xe::cpu::frontend::PPCContext; TEST_CASE("PERMUTE_V128_BY_INT32_CONSTANT", "[instr]") { { - uint32_t mask = PERMUTE_MASK(0, 0, 0, 1, 0, 2, 0, 3); + uint32_t mask = MakePermuteMask(0, 0, 0, 1, 0, 2, 0, 3); TestFunction([mask](HIRBuilder& b) { StoreVR(b, 3, b.Permute(b.LoadConstantUint32(mask), LoadVR(b, 4), LoadVR(b, 5), INT32_TYPE)); @@ -34,7 +34,7 @@ TEST_CASE("PERMUTE_V128_BY_INT32_CONSTANT", "[instr]") { }); } { - uint32_t mask = PERMUTE_MASK(1, 0, 1, 1, 1, 2, 1, 3); + uint32_t mask = MakePermuteMask(1, 0, 1, 1, 1, 2, 1, 3); TestFunction([mask](HIRBuilder& b) { StoreVR(b, 3, b.Permute(b.LoadConstantUint32(mask), LoadVR(b, 4), LoadVR(b, 5), INT32_TYPE)); @@ -51,7 +51,7 @@ TEST_CASE("PERMUTE_V128_BY_INT32_CONSTANT", "[instr]") { }); } { - uint32_t mask = PERMUTE_MASK(0, 3, 0, 2, 0, 1, 0, 0); + uint32_t mask = MakePermuteMask(0, 3, 0, 2, 0, 1, 0, 0); TestFunction([mask](HIRBuilder& b) { StoreVR(b, 3, b.Permute(b.LoadConstantUint32(mask), LoadVR(b, 4), LoadVR(b, 5), INT32_TYPE)); @@ -68,7 +68,7 @@ TEST_CASE("PERMUTE_V128_BY_INT32_CONSTANT", "[instr]") { }); } { - uint32_t mask = PERMUTE_MASK(1, 3, 1, 2, 1, 1, 1, 0); + uint32_t mask = MakePermuteMask(1, 3, 1, 2, 1, 1, 1, 0); TestFunction([mask](HIRBuilder& b) { StoreVR(b, 3, b.Permute(b.LoadConstantUint32(mask), LoadVR(b, 4), LoadVR(b, 5), INT32_TYPE)); diff --git a/src/xenia/cpu/testing/swizzle_test.cc b/src/xenia/cpu/testing/swizzle_test.cc index ae534939f..4245fdbf0 100644 --- a/src/xenia/cpu/testing/swizzle_test.cc +++ b/src/xenia/cpu/testing/swizzle_test.cc @@ -18,7 +18,7 @@ using xe::cpu::frontend::PPCContext; TEST_CASE("SWIZZLE_V128", "[instr]") { TestFunction([](HIRBuilder& b) { StoreVR(b, 3, - b.Swizzle(LoadVR(b, 4), INT32_TYPE, SWIZZLE_MASK(0, 1, 2, 3))); + b.Swizzle(LoadVR(b, 4), INT32_TYPE, MakeSwizzleMask(0, 1, 2, 3))); b.Return(); }) .Run([](PPCContext* ctx) { ctx->v[4] = vec128i(0, 1, 2, 3); }, @@ -28,7 +28,7 @@ TEST_CASE("SWIZZLE_V128", "[instr]") { }); TestFunction([](HIRBuilder& b) { StoreVR(b, 3, - b.Swizzle(LoadVR(b, 4), INT32_TYPE, SWIZZLE_MASK(3, 2, 1, 0))); + b.Swizzle(LoadVR(b, 4), INT32_TYPE, MakeSwizzleMask(3, 2, 1, 0))); b.Return(); }) .Run([](PPCContext* ctx) { ctx->v[4] = vec128i(0, 1, 2, 3); }, @@ -38,7 +38,7 @@ TEST_CASE("SWIZZLE_V128", "[instr]") { }); TestFunction([](HIRBuilder& b) { StoreVR(b, 3, - b.Swizzle(LoadVR(b, 4), INT32_TYPE, SWIZZLE_MASK(1, 1, 2, 2))); + b.Swizzle(LoadVR(b, 4), INT32_TYPE, MakeSwizzleMask(1, 1, 2, 2))); b.Return(); }) .Run([](PPCContext* ctx) { ctx->v[4] = vec128i(0, 1, 2, 3); }, diff --git a/src/xenia/cpu/testing/util.h b/src/xenia/cpu/testing/util.h index 9db88dd10..efe51842b 100644 --- a/src/xenia/cpu/testing/util.h +++ b/src/xenia/cpu/testing/util.h @@ -7,8 +7,10 @@ ****************************************************************************** */ -#ifndef XENIA_TESTING_UTIL_H_ -#define XENIA_TESTING_UTIL_H_ +#ifndef XENIA_CPU_TESTING_UTIL_H_ +#define XENIA_CPU_TESTING_UTIL_H_ + +#include #include "xenia/base/main.h" #include "xenia/cpu/backend/x64/x64_backend.h" @@ -114,4 +116,4 @@ inline void StoreVR(hir::HIRBuilder& b, int reg, hir::Value* value) { } // namespace cpu } // namespace xe -#endif // XENIA_TESTING_UTIL_H_ +#endif // XENIA_CPU_TESTING_UTIL_H_ diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 9026b0cea..cd6aad2f1 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -56,7 +56,8 @@ bool XexModule::GetOptHeader(const xex2_header* header, xe_xex2_header_keys key, } break; case 0x01: { // Pointer to the value on the optional header. - *out_ptr = (void*)&opt_header.value; + *out_ptr = const_cast( + reinterpret_cast(&opt_header.value)); } break; default: { // Pointer to the header. diff --git a/src/xenia/debug/debug_client.cc b/src/xenia/debug/debug_client.cc index db2de2eca..fe6daa2ac 100644 --- a/src/xenia/debug/debug_client.cc +++ b/src/xenia/debug/debug_client.cc @@ -15,7 +15,7 @@ namespace xe { namespace debug { -using namespace xe::debug::proto; +using namespace xe::debug::proto; // NOLINT(build/namespaces) constexpr size_t kReceiveBufferSize = 1 * 1024 * 1024; constexpr size_t kTransmitBufferSize = 1 * 1024 * 1024; diff --git a/src/xenia/debug/debug_client.h b/src/xenia/debug/debug_client.h index ae704f2e9..318a4e560 100644 --- a/src/xenia/debug/debug_client.h +++ b/src/xenia/debug/debug_client.h @@ -12,6 +12,8 @@ #include #include +#include +#include #include "xenia/base/socket.h" #include "xenia/base/threading.h" diff --git a/src/xenia/debug/debug_server.cc b/src/xenia/debug/debug_server.cc index 1ae2f35ff..49ebd7c99 100644 --- a/src/xenia/debug/debug_server.cc +++ b/src/xenia/debug/debug_server.cc @@ -24,8 +24,11 @@ DEFINE_int32(debug_server_port, 9002, "Debugger XDP server TCP port."); namespace xe { namespace debug { -using namespace xe::debug::proto; -using namespace xe::kernel; +using namespace xe::debug::proto; // NOLINT(build/namespaces) + +using xe::kernel::XModule; +using xe::kernel::XObject; +using xe::kernel::XThread; constexpr size_t kReceiveBufferSize = 32 * 1024; constexpr size_t kReadBufferSize = 1 * 1024 * 1024; diff --git a/src/xenia/debug/debug_server.h b/src/xenia/debug/debug_server.h index dccf1cc01..f038bac71 100644 --- a/src/xenia/debug/debug_server.h +++ b/src/xenia/debug/debug_server.h @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include "xenia/base/socket.h" #include "xenia/base/threading.h" @@ -31,7 +33,7 @@ class Debugger; class DebugServer { public: - DebugServer(Debugger* debugger); + explicit DebugServer(Debugger* debugger); ~DebugServer(); Debugger* debugger() const { return debugger_; } diff --git a/src/xenia/debug/debugger.cc b/src/xenia/debug/debugger.cc index 636b713a9..3e9667ba4 100644 --- a/src/xenia/debug/debugger.cc +++ b/src/xenia/debug/debugger.cc @@ -12,6 +12,7 @@ #include #include +#include #include "xenia/base/filesystem.h" #include "xenia/base/logging.h" @@ -44,9 +45,9 @@ DEFINE_bool(exit_with_debugger, true, "Exit whe the debugger disconnects."); namespace xe { namespace debug { -using namespace xe::kernel; - using xe::cpu::ThreadState; +using xe::kernel::XObject; +using xe::kernel::XThread; Breakpoint::Breakpoint(Type type, uint32_t address) : type_(type), address_(address) {} @@ -235,10 +236,10 @@ int Debugger::RemoveBreakpoint(Breakpoint* breakpoint) { } void Debugger::FindBreakpoints(uint32_t address, - std::vector& out_breakpoints) { + std::vector* out_breakpoints) { std::lock_guard lock(mutex_); - out_breakpoints.clear(); + out_breakpoints->clear(); auto range = breakpoints_.equal_range(address); if (range.first == range.second) { @@ -247,7 +248,7 @@ void Debugger::FindBreakpoints(uint32_t address, for (auto it = range.first; it != range.second; ++it) { Breakpoint* breakpoint = it->second; - out_breakpoints.push_back(breakpoint); + out_breakpoints->push_back(breakpoint); } } diff --git a/src/xenia/debug/debugger.h b/src/xenia/debug/debugger.h index b52d51774..d23fa8191 100644 --- a/src/xenia/debug/debugger.h +++ b/src/xenia/debug/debugger.h @@ -46,7 +46,7 @@ enum class ExecutionState { class Debugger { public: - Debugger(Emulator* emulator); + explicit Debugger(Emulator* emulator); ~Debugger(); Emulator* emulator() const { return emulator_; } @@ -69,7 +69,7 @@ class Debugger { int AddBreakpoint(Breakpoint* breakpoint); int RemoveBreakpoint(Breakpoint* breakpoint); void FindBreakpoints(uint32_t address, - std::vector& out_breakpoints); + std::vector* out_breakpoints); // TODO(benvanik): utility functions for modification (make function ignored, // etc). diff --git a/src/xenia/debug/proto/packet_reader.h b/src/xenia/debug/proto/packet_reader.h index 9a51e378c..26639fd9c 100644 --- a/src/xenia/debug/proto/packet_reader.h +++ b/src/xenia/debug/proto/packet_reader.h @@ -26,7 +26,7 @@ namespace proto { class PacketReader { public: - PacketReader(size_t buffer_capacity) : buffer_(buffer_capacity) {} + explicit PacketReader(size_t buffer_capacity) : buffer_(buffer_capacity) {} const uint8_t* buffer() { return buffer_.data(); } size_t buffer_capacity() const { return buffer_.size(); } diff --git a/src/xenia/debug/proto/packet_writer.h b/src/xenia/debug/proto/packet_writer.h index c5c854234..d19959606 100644 --- a/src/xenia/debug/proto/packet_writer.h +++ b/src/xenia/debug/proto/packet_writer.h @@ -25,7 +25,7 @@ namespace proto { class PacketWriter { public: - PacketWriter(size_t buffer_capacity) : buffer_(buffer_capacity) {} + explicit PacketWriter(size_t buffer_capacity) : buffer_(buffer_capacity) {} uint8_t* buffer() { return buffer_.data(); } size_t buffer_capacity() const { return buffer_.size(); } diff --git a/src/xenia/debug/proto/varint.h b/src/xenia/debug/proto/varint.h index c6e5658a7..67a021c97 100644 --- a/src/xenia/debug/proto/varint.h +++ b/src/xenia/debug/proto/varint.h @@ -18,7 +18,7 @@ namespace proto { struct varint_t { varint_t() = default; - varint_t(uint64_t value) : value_(value) {} + varint_t(uint64_t value) : value_(value) {} // NOLINT(runtime/explicit) varint_t(const varint_t& other) : value_(other.value_) {} operator uint64_t() const { return value_; } diff --git a/src/xenia/debug/ui/main_window.cc b/src/xenia/debug/ui/main_window.cc index 15e47886b..adc06f971 100644 --- a/src/xenia/debug/ui/main_window.cc +++ b/src/xenia/debug/ui/main_window.cc @@ -42,9 +42,9 @@ bool MainWindow::Initialize() { window_->on_closed.AddListener(std::bind(&MainWindow::OnClose, this)); - window_->on_key_down.AddListener([this](xe::ui::KeyEvent& e) { + window_->on_key_down.AddListener([this](xe::ui::KeyEvent* e) { bool handled = true; - switch (e.key_code()) { + switch (e->key_code()) { case 0x1B: { // VK_ESCAPE // Allow users to escape fullscreen (but not enter it). if (window_->is_fullscreen()) { @@ -58,7 +58,7 @@ bool MainWindow::Initialize() { default: { handled = false; } break; } - e.set_handled(handled); + e->set_handled(handled); }); // Main menu. @@ -93,7 +93,7 @@ bool MainWindow::Initialize() { } void MainWindow::BuildUI() { - using namespace el::dsl; + using namespace el::dsl; // NOLINT(build/namespaces) el::AnimationBlocker animation_blocker; auto root_element = window_->root_element(); diff --git a/src/xenia/debug/ui/main_window.h b/src/xenia/debug/ui/main_window.h index eb9dc3353..c3410f027 100644 --- a/src/xenia/debug/ui/main_window.h +++ b/src/xenia/debug/ui/main_window.h @@ -24,7 +24,7 @@ namespace ui { class MainWindow { public: - MainWindow(Application* app); + explicit MainWindow(Application* app); ~MainWindow(); Application* app() const { return app_; } diff --git a/src/xenia/debug/ui/model/module.h b/src/xenia/debug/ui/model/module.h index ec66ec040..efbc62b7e 100644 --- a/src/xenia/debug/ui/model/module.h +++ b/src/xenia/debug/ui/model/module.h @@ -24,7 +24,7 @@ class System; class Module { public: - Module(System* system) : system_(system) {} + explicit Module(System* system) : system_(system) {} bool is_dead() const { return is_dead_; } void set_dead(bool is_dead) { is_dead_ = is_dead; } diff --git a/src/xenia/debug/ui/model/system.cc b/src/xenia/debug/ui/model/system.cc index 64a60f6be..a3ec9628f 100644 --- a/src/xenia/debug/ui/model/system.cc +++ b/src/xenia/debug/ui/model/system.cc @@ -16,7 +16,7 @@ namespace debug { namespace ui { namespace model { -using namespace xe::debug::proto; +using namespace xe::debug::proto; // NOLINT(build/namespaces) System::System(xe::ui::Loop* loop, DebugClient* client) : loop_(loop), client_(client) { diff --git a/src/xenia/debug/ui/view.h b/src/xenia/debug/ui/view.h index 8ef335589..f093a9c00 100644 --- a/src/xenia/debug/ui/view.h +++ b/src/xenia/debug/ui/view.h @@ -36,7 +36,7 @@ class View { virtual void Setup(xe::debug::DebugClient* client) = 0; protected: - View(std::string name) : name_(name) {} + explicit View(std::string name) : name_(name) {} std::string name_; el::LayoutBox root_element_; diff --git a/src/xenia/debug/ui/views/cpu/cpu_view.cc b/src/xenia/debug/ui/views/cpu/cpu_view.cc index 850bea932..9e5a1a511 100644 --- a/src/xenia/debug/ui/views/cpu/cpu_view.cc +++ b/src/xenia/debug/ui/views/cpu/cpu_view.cc @@ -22,7 +22,7 @@ CpuView::CpuView() : View("CPU") {} CpuView::~CpuView() = default; el::Element* CpuView::BuildUI() { - using namespace el::dsl; + using namespace el::dsl; // NOLINT(build/namespaces) el::AnimationBlocker animation_blocker; auto functions_node = @@ -197,7 +197,7 @@ void CpuView::UpdateModuleList() { module_items->push_back(std::move(item)); } if (is_first) { - module_dropdown->set_value(int(module_items->size() - 1)); + module_dropdown->set_value(static_cast(module_items->size() - 1)); } } @@ -237,7 +237,7 @@ void CpuView::UpdateThreadList() { thread_items->push_back(std::move(item)); } if (is_first) { - thread_dropdown->set_value(int(thread_items->size() - 1)); + thread_dropdown->set_value(static_cast(thread_items->size() - 1)); } } diff --git a/src/xenia/debug/ui/views/gpu/gpu_view.cc b/src/xenia/debug/ui/views/gpu/gpu_view.cc index 20fbb78ea..cdbd2704b 100644 --- a/src/xenia/debug/ui/views/gpu/gpu_view.cc +++ b/src/xenia/debug/ui/views/gpu/gpu_view.cc @@ -21,7 +21,7 @@ GpuView::GpuView() : View("GPU") {} GpuView::~GpuView() = default; el::Element* GpuView::BuildUI() { - using namespace el::dsl; + using namespace el::dsl; // NOLINT(build/namespaces) el::AnimationBlocker animation_blocker; auto node = LabelNode("TODO"); diff --git a/src/xenia/gpu/gl4/command_processor.cc b/src/xenia/gpu/gl4/command_processor.cc index acab07181..6edb79b5e 100644 --- a/src/xenia/gpu/gl4/command_processor.cc +++ b/src/xenia/gpu/gl4/command_processor.cc @@ -483,7 +483,8 @@ void CommandProcessor::EnableReadPointerWriteBack(uint32_t ptr, // CP_RB_CNTL Ring Buffer Control 0x704 // block_size = RB_BLKSZ, number of quadwords read between updates of the // read pointer. - read_ptr_update_freq_ = (uint32_t)pow(2.0, (double)block_size) / 4; + read_ptr_update_freq_ = + static_cast(pow(2.0, static_cast(block_size)) / 4); } void CommandProcessor::UpdateWritePointer(uint32_t value) { @@ -1595,22 +1596,22 @@ bool CommandProcessor::IssueDraw() { return true; } -bool CommandProcessor::SetShadowRegister(uint32_t& dest, +bool CommandProcessor::SetShadowRegister(uint32_t* dest, uint32_t register_name) { uint32_t value = register_file_->values[register_name].u32; - if (dest == value) { + if (*dest == value) { return false; } - dest = value; + *dest = value; return true; } -bool CommandProcessor::SetShadowRegister(float& dest, uint32_t register_name) { +bool CommandProcessor::SetShadowRegister(float* dest, uint32_t register_name) { float value = register_file_->values[register_name].f32; - if (dest == value) { + if (*dest == value) { return false; } - dest = value; + *dest = value; return true; } @@ -1628,9 +1629,9 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateShaders( register_file_->values[XE_GPU_REG_SQ_PS_CONST].u32 == 0x00000000); bool dirty = false; - dirty |= - SetShadowRegister(regs.pa_su_sc_mode_cntl, XE_GPU_REG_PA_SU_SC_MODE_CNTL); - dirty |= SetShadowRegister(regs.sq_program_cntl, XE_GPU_REG_SQ_PROGRAM_CNTL); + dirty |= SetShadowRegister(®s.pa_su_sc_mode_cntl, + XE_GPU_REG_PA_SU_SC_MODE_CNTL); + dirty |= SetShadowRegister(®s.sq_program_cntl, XE_GPU_REG_SQ_PROGRAM_CNTL); dirty |= regs.vertex_shader != active_vertex_shader_; dirty |= regs.pixel_shader != active_pixel_shader_; dirty |= regs.prim_type != prim_type; @@ -1769,17 +1770,17 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateRenderTargets() { auto& regs = update_render_targets_regs_; bool dirty = false; - dirty |= SetShadowRegister(regs.rb_modecontrol, XE_GPU_REG_RB_MODECONTROL); - dirty |= SetShadowRegister(regs.rb_surface_info, XE_GPU_REG_RB_SURFACE_INFO); - dirty |= SetShadowRegister(regs.rb_color_info, XE_GPU_REG_RB_COLOR_INFO); - dirty |= SetShadowRegister(regs.rb_color1_info, XE_GPU_REG_RB_COLOR1_INFO); - dirty |= SetShadowRegister(regs.rb_color2_info, XE_GPU_REG_RB_COLOR2_INFO); - dirty |= SetShadowRegister(regs.rb_color3_info, XE_GPU_REG_RB_COLOR3_INFO); - dirty |= SetShadowRegister(regs.rb_color_mask, XE_GPU_REG_RB_COLOR_MASK); - dirty |= SetShadowRegister(regs.rb_depthcontrol, XE_GPU_REG_RB_DEPTHCONTROL); + dirty |= SetShadowRegister(®s.rb_modecontrol, XE_GPU_REG_RB_MODECONTROL); + dirty |= SetShadowRegister(®s.rb_surface_info, XE_GPU_REG_RB_SURFACE_INFO); + dirty |= SetShadowRegister(®s.rb_color_info, XE_GPU_REG_RB_COLOR_INFO); + dirty |= SetShadowRegister(®s.rb_color1_info, XE_GPU_REG_RB_COLOR1_INFO); + dirty |= SetShadowRegister(®s.rb_color2_info, XE_GPU_REG_RB_COLOR2_INFO); + dirty |= SetShadowRegister(®s.rb_color3_info, XE_GPU_REG_RB_COLOR3_INFO); + dirty |= SetShadowRegister(®s.rb_color_mask, XE_GPU_REG_RB_COLOR_MASK); + dirty |= SetShadowRegister(®s.rb_depthcontrol, XE_GPU_REG_RB_DEPTHCONTROL); dirty |= - SetShadowRegister(regs.rb_stencilrefmask, XE_GPU_REG_RB_STENCILREFMASK); - dirty |= SetShadowRegister(regs.rb_depth_info, XE_GPU_REG_RB_DEPTH_INFO); + SetShadowRegister(®s.rb_stencilrefmask, XE_GPU_REG_RB_STENCILREFMASK); + dirty |= SetShadowRegister(®s.rb_depth_info, XE_GPU_REG_RB_DEPTH_INFO); if (!dirty) { return UpdateStatus::kCompatible; } @@ -1893,30 +1894,30 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateViewportState() { auto& regs = update_viewport_state_regs_; bool dirty = false; - // dirty |= SetShadowRegister(state_regs.pa_cl_clip_cntl, + // dirty |= SetShadowRegister(&state_regs.pa_cl_clip_cntl, // XE_GPU_REG_PA_CL_CLIP_CNTL); - dirty |= SetShadowRegister(regs.rb_surface_info, XE_GPU_REG_RB_SURFACE_INFO); - dirty |= SetShadowRegister(regs.pa_cl_vte_cntl, XE_GPU_REG_PA_CL_VTE_CNTL); - dirty |= - SetShadowRegister(regs.pa_su_sc_mode_cntl, XE_GPU_REG_PA_SU_SC_MODE_CNTL); - dirty |= SetShadowRegister(regs.pa_sc_window_offset, + dirty |= SetShadowRegister(®s.rb_surface_info, XE_GPU_REG_RB_SURFACE_INFO); + dirty |= SetShadowRegister(®s.pa_cl_vte_cntl, XE_GPU_REG_PA_CL_VTE_CNTL); + dirty |= SetShadowRegister(®s.pa_su_sc_mode_cntl, + XE_GPU_REG_PA_SU_SC_MODE_CNTL); + dirty |= SetShadowRegister(®s.pa_sc_window_offset, XE_GPU_REG_PA_SC_WINDOW_OFFSET); - dirty |= SetShadowRegister(regs.pa_sc_window_scissor_tl, + dirty |= SetShadowRegister(®s.pa_sc_window_scissor_tl, XE_GPU_REG_PA_SC_WINDOW_SCISSOR_TL); - dirty |= SetShadowRegister(regs.pa_sc_window_scissor_br, + dirty |= SetShadowRegister(®s.pa_sc_window_scissor_br, XE_GPU_REG_PA_SC_WINDOW_SCISSOR_BR); - dirty |= SetShadowRegister(regs.pa_cl_vport_xoffset, + dirty |= SetShadowRegister(®s.pa_cl_vport_xoffset, XE_GPU_REG_PA_CL_VPORT_XOFFSET); - dirty |= SetShadowRegister(regs.pa_cl_vport_yoffset, + dirty |= SetShadowRegister(®s.pa_cl_vport_yoffset, XE_GPU_REG_PA_CL_VPORT_YOFFSET); - dirty |= SetShadowRegister(regs.pa_cl_vport_zoffset, + dirty |= SetShadowRegister(®s.pa_cl_vport_zoffset, XE_GPU_REG_PA_CL_VPORT_ZOFFSET); - dirty |= - SetShadowRegister(regs.pa_cl_vport_xscale, XE_GPU_REG_PA_CL_VPORT_XSCALE); - dirty |= - SetShadowRegister(regs.pa_cl_vport_yscale, XE_GPU_REG_PA_CL_VPORT_YSCALE); - dirty |= - SetShadowRegister(regs.pa_cl_vport_zscale, XE_GPU_REG_PA_CL_VPORT_ZSCALE); + dirty |= SetShadowRegister(®s.pa_cl_vport_xscale, + XE_GPU_REG_PA_CL_VPORT_XSCALE); + dirty |= SetShadowRegister(®s.pa_cl_vport_yscale, + XE_GPU_REG_PA_CL_VPORT_YSCALE); + dirty |= SetShadowRegister(®s.pa_cl_vport_zscale, + XE_GPU_REG_PA_CL_VPORT_ZSCALE); // Much of this state machine is extracted from: // https://github.com/freedreno/mesa/blob/master/src/mesa/drivers/dri/r200/r200_state.c @@ -2051,13 +2052,13 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateRasterizerState() { auto& regs = update_rasterizer_state_regs_; bool dirty = false; - dirty |= - SetShadowRegister(regs.pa_su_sc_mode_cntl, XE_GPU_REG_PA_SU_SC_MODE_CNTL); - dirty |= SetShadowRegister(regs.pa_sc_screen_scissor_tl, + dirty |= SetShadowRegister(®s.pa_su_sc_mode_cntl, + XE_GPU_REG_PA_SU_SC_MODE_CNTL); + dirty |= SetShadowRegister(®s.pa_sc_screen_scissor_tl, XE_GPU_REG_PA_SC_SCREEN_SCISSOR_TL); - dirty |= SetShadowRegister(regs.pa_sc_screen_scissor_br, + dirty |= SetShadowRegister(®s.pa_sc_screen_scissor_br, XE_GPU_REG_PA_SC_SCREEN_SCISSOR_BR); - dirty |= SetShadowRegister(regs.multi_prim_ib_reset_index, + dirty |= SetShadowRegister(®s.multi_prim_ib_reset_index, XE_GPU_REG_VGT_MULTI_PRIM_IB_RESET_INDX); if (!dirty) { return UpdateStatus::kCompatible; @@ -2149,17 +2150,17 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateBlendState() { bool dirty = false; dirty |= - SetShadowRegister(regs.rb_blendcontrol[0], XE_GPU_REG_RB_BLENDCONTROL_0); + SetShadowRegister(®s.rb_blendcontrol[0], XE_GPU_REG_RB_BLENDCONTROL_0); dirty |= - SetShadowRegister(regs.rb_blendcontrol[1], XE_GPU_REG_RB_BLENDCONTROL_1); + SetShadowRegister(®s.rb_blendcontrol[1], XE_GPU_REG_RB_BLENDCONTROL_1); dirty |= - SetShadowRegister(regs.rb_blendcontrol[2], XE_GPU_REG_RB_BLENDCONTROL_2); + SetShadowRegister(®s.rb_blendcontrol[2], XE_GPU_REG_RB_BLENDCONTROL_2); dirty |= - SetShadowRegister(regs.rb_blendcontrol[3], XE_GPU_REG_RB_BLENDCONTROL_3); - dirty |= SetShadowRegister(regs.rb_blend_rgba[0], XE_GPU_REG_RB_BLEND_RED); - dirty |= SetShadowRegister(regs.rb_blend_rgba[1], XE_GPU_REG_RB_BLEND_GREEN); - dirty |= SetShadowRegister(regs.rb_blend_rgba[2], XE_GPU_REG_RB_BLEND_BLUE); - dirty |= SetShadowRegister(regs.rb_blend_rgba[3], XE_GPU_REG_RB_BLEND_ALPHA); + SetShadowRegister(®s.rb_blendcontrol[3], XE_GPU_REG_RB_BLENDCONTROL_3); + dirty |= SetShadowRegister(®s.rb_blend_rgba[0], XE_GPU_REG_RB_BLEND_RED); + dirty |= SetShadowRegister(®s.rb_blend_rgba[1], XE_GPU_REG_RB_BLEND_GREEN); + dirty |= SetShadowRegister(®s.rb_blend_rgba[2], XE_GPU_REG_RB_BLEND_BLUE); + dirty |= SetShadowRegister(®s.rb_blend_rgba[3], XE_GPU_REG_RB_BLEND_ALPHA); if (!dirty) { return UpdateStatus::kCompatible; } @@ -2234,9 +2235,9 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateDepthStencilState() { auto& regs = update_depth_stencil_state_regs_; bool dirty = false; - dirty |= SetShadowRegister(regs.rb_depthcontrol, XE_GPU_REG_RB_DEPTHCONTROL); + dirty |= SetShadowRegister(®s.rb_depthcontrol, XE_GPU_REG_RB_DEPTHCONTROL); dirty |= - SetShadowRegister(regs.rb_stencilrefmask, XE_GPU_REG_RB_STENCILREFMASK); + SetShadowRegister(®s.rb_stencilrefmask, XE_GPU_REG_RB_STENCILREFMASK); if (!dirty) { return UpdateStatus::kCompatible; } @@ -2891,7 +2892,8 @@ bool CommandProcessor::IssueCopy() { if (depth_clear_enabled && depth_target != kAnyTarget) { // Clear the current depth buffer. // TODO(benvanik): verify format. - GLfloat depth = {(copy_depth_clear & 0xFFFFFF00) / float(0xFFFFFF00)}; + GLfloat depth = {(copy_depth_clear & 0xFFFFFF00) / + static_cast(0xFFFFFF00)}; GLint stencil = copy_depth_clear & 0xFF; GLboolean old_depth_mask; GLint old_stencil_mask; diff --git a/src/xenia/gpu/gl4/command_processor.h b/src/xenia/gpu/gl4/command_processor.h index 4c8d052ba..0073851cf 100644 --- a/src/xenia/gpu/gl4/command_processor.h +++ b/src/xenia/gpu/gl4/command_processor.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -64,7 +65,7 @@ enum class SwapMode { class CommandProcessor { public: - CommandProcessor(GL4GraphicsSystem* graphics_system); + explicit CommandProcessor(GL4GraphicsSystem* graphics_system); ~CommandProcessor(); uint32_t counter() const { return counter_; } @@ -299,8 +300,8 @@ class CommandProcessor { xe::ui::gl::CircularBuffer scratch_buffer_; private: - bool SetShadowRegister(uint32_t& dest, uint32_t register_name); - bool SetShadowRegister(float& dest, uint32_t register_name); + bool SetShadowRegister(uint32_t* dest, uint32_t register_name); + bool SetShadowRegister(float* dest, uint32_t register_name); struct UpdateRenderTargetsRegisters { uint32_t rb_modecontrol; uint32_t rb_surface_info; diff --git a/src/xenia/gpu/gl4/draw_batcher.cc b/src/xenia/gpu/gl4/draw_batcher.cc index dcd81b307..b2028a1cd 100644 --- a/src/xenia/gpu/gl4/draw_batcher.cc +++ b/src/xenia/gpu/gl4/draw_batcher.cc @@ -155,7 +155,7 @@ bool DrawBatcher::BeginDraw() { GLsizei header_size = sizeof(CommonHeader); - // TODO(benvanik); consts sizing. + // TODO(benvanik): consts sizing. // GLsizei float_consts_size = sizeof(float4) * 512; // GLsizei bool_consts_size = sizeof(uint32_t) * 8; // GLsizei loop_consts_size = sizeof(uint32_t) * 32; @@ -286,9 +286,9 @@ bool DrawBatcher::Flush(FlushMode mode) { case PrimitiveType::kRectangleList: prim_type = GL_TRIANGLES; // Rect lists aren't culled. There may be other things they skip too. - // assert_true((register_file_->values[XE_GPU_REG_PA_SU_SC_MODE_CNTL].u32 - // & - // 0x3) == 0); + // assert_true( + // (register_file_->values[XE_GPU_REG_PA_SU_SC_MODE_CNTL].u32 + // & 0x3) == 0); break; case PrimitiveType::kQuadList: prim_type = GL_LINES_ADJACENCY; diff --git a/src/xenia/gpu/gl4/draw_batcher.h b/src/xenia/gpu/gl4/draw_batcher.h index 4630d8f97..87657c2fb 100644 --- a/src/xenia/gpu/gl4/draw_batcher.h +++ b/src/xenia/gpu/gl4/draw_batcher.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_GPU_GL4_GL4_STATE_DATA_BUILDER_H_ -#define XENIA_GPU_GL4_GL4_STATE_DATA_BUILDER_H_ +#ifndef XENIA_GPU_GL4_DRAW_BATCHER_H_ +#define XENIA_GPU_GL4_DRAW_BATCHER_H_ #include "xenia/gpu/gl4/gl4_shader.h" #include "xenia/gpu/register_file.h" @@ -53,7 +53,7 @@ class DrawBatcher { kReconfigure, }; - DrawBatcher(RegisterFile* register_file); + explicit DrawBatcher(RegisterFile* register_file); bool Initialize(CircularBuffer* array_data_buffer); void Shutdown(); @@ -72,7 +72,7 @@ class DrawBatcher { } void set_alpha_test(bool enabled, uint32_t func, float ref) { active_draw_.header->alpha_test.x = enabled ? 1.0f : 0.0f; - active_draw_.header->alpha_test.y = float(func); + active_draw_.header->alpha_test.y = static_cast(func); active_draw_.header->alpha_test.z = ref; } void set_texture_sampler(int index, GLuint64 handle) { @@ -159,4 +159,4 @@ class DrawBatcher { } // namespace gpu } // namespace xe -#endif // XENIA_GPU_GL4_GL4_STATE_DATA_BUILDER_H_ +#endif // XENIA_GPU_GL4_DRAW_BATCHER_H_ diff --git a/src/xenia/gpu/gl4/gl4_graphics_system.cc b/src/xenia/gpu/gl4/gl4_graphics_system.cc index 5d341a811..32d7fe0c4 100644 --- a/src/xenia/gpu/gl4/gl4_graphics_system.cc +++ b/src/xenia/gpu/gl4/gl4_graphics_system.cc @@ -9,6 +9,7 @@ #include "xenia/gpu/gl4/gl4_graphics_system.h" +#include #include #include "xenia/base/clock.h" @@ -74,7 +75,7 @@ X_STATUS GL4GraphicsSystem::Setup(cpu::Processor* processor, // Watch for paint requests to do our swap. target_window->on_painting.AddListener( - [this](xe::ui::UIEvent& e) { Swap(e); }); + [this](xe::ui::UIEvent* e) { Swap(e); }); // Create rendering control. // This must happen on the UI thread. @@ -290,7 +291,7 @@ void GL4GraphicsSystem::MarkVblank() { DispatchInterruptCallback(0, 2); } -void GL4GraphicsSystem::Swap(xe::ui::UIEvent& e) { +void GL4GraphicsSystem::Swap(xe::ui::UIEvent* e) { // Check for pending swap. auto& swap_state = command_processor_->swap_state(); { diff --git a/src/xenia/gpu/gl4/gl4_graphics_system.h b/src/xenia/gpu/gl4/gl4_graphics_system.h index 672fae514..1256ef4b3 100644 --- a/src/xenia/gpu/gl4/gl4_graphics_system.h +++ b/src/xenia/gpu/gl4/gl4_graphics_system.h @@ -24,7 +24,7 @@ namespace gl4 { class GL4GraphicsSystem : public GraphicsSystem { public: - GL4GraphicsSystem(Emulator* emulator); + explicit GL4GraphicsSystem(Emulator* emulator); ~GL4GraphicsSystem() override; std::unique_ptr CreateContext( @@ -51,7 +51,7 @@ class GL4GraphicsSystem : public GraphicsSystem { private: void MarkVblank(); - void Swap(xe::ui::UIEvent& e); + void Swap(xe::ui::UIEvent* e); uint32_t ReadRegister(uint32_t addr); void WriteRegister(uint32_t addr, uint32_t value); diff --git a/src/xenia/gpu/gl4/gl4_shader.cc b/src/xenia/gpu/gl4/gl4_shader.cc index 8fd849680..023c99b87 100644 --- a/src/xenia/gpu/gl4/gl4_shader.cc +++ b/src/xenia/gpu/gl4/gl4_shader.cc @@ -20,7 +20,7 @@ namespace xe { namespace gpu { namespace gl4 { -using namespace xe::gpu::xenos; +using xe::gpu::xenos::VertexFormat; GL4Shader::GL4Shader(ShaderType shader_type, uint64_t data_hash, const uint32_t* dword_ptr, uint32_t dword_count) diff --git a/src/xenia/gpu/gl4/gl4_shader_translator.cc b/src/xenia/gpu/gl4/gl4_shader_translator.cc index 54317f176..3c6d82240 100644 --- a/src/xenia/gpu/gl4/gl4_shader_translator.cc +++ b/src/xenia/gpu/gl4/gl4_shader_translator.cc @@ -9,6 +9,8 @@ #include "xenia/gpu/gl4/gl4_shader_translator.h" +#include + #include "xenia/base/assert.h" #include "xenia/base/logging.h" #include "xenia/base/math.h" @@ -19,7 +21,8 @@ namespace gpu { namespace gl4 { using namespace xe::gpu::ucode; -using namespace xe::gpu::xenos; + +using xe::gpu::xenos::VertexFormat; #define Append(...) output_.AppendFormat(__VA_ARGS__) @@ -68,7 +71,8 @@ void GL4ShaderTranslator::Reset(GL4Shader* shader) { } std::string GL4ShaderTranslator::TranslateVertexShader( - GL4Shader* vertex_shader, const xe_gpu_program_cntl_t& program_cntl) { + GL4Shader* vertex_shader, + const xenos::xe_gpu_program_cntl_t& program_cntl) { Reset(vertex_shader); // Normal shaders only, for now. @@ -105,13 +109,13 @@ std::string GL4ShaderTranslator::TranslateVertexShader( #if FLOW_CONTROL // Add temporary integer registers for loops that we may use. - // Each loop uses an address, counter, and constant - // TODO: Implement only for the used loops in the shader + // Each loop uses an address, counter, and constant. + // TODO(benvanik): Implement only for the used loops in the shader. for (uint32_t n = 0; n < 32; n++) { Append(" int i%d_cnt = 0;\n", n); Append(" int i%d_addr = 0;\n", n); } -#endif +#endif // FLOW_CONTROL Append(" vec4 t;\n"); Append(" vec4 pv;\n"); // Previous Vector result. @@ -127,7 +131,7 @@ std::string GL4ShaderTranslator::TranslateVertexShader( } std::string GL4ShaderTranslator::TranslatePixelShader( - GL4Shader* pixel_shader, const xe_gpu_program_cntl_t& program_cntl) { + GL4Shader* pixel_shader, const xenos::xe_gpu_program_cntl_t& program_cntl) { Reset(pixel_shader); // We need an input VS to make decisions here. @@ -161,7 +165,7 @@ std::string GL4ShaderTranslator::TranslatePixelShader( return output_.to_string(); } -void GL4ShaderTranslator::AppendSrcReg(const instr_alu_t& op, int i) { +void GL4ShaderTranslator::AppendSrcReg(const ucode::instr_alu_t& op, int i) { switch (i) { case 1: { int const_slot = 0; @@ -184,9 +188,10 @@ void GL4ShaderTranslator::AppendSrcReg(const instr_alu_t& op, int i) { } } -void GL4ShaderTranslator::AppendSrcReg(const instr_alu_t& op, uint32_t num, - uint32_t type, uint32_t swiz, - uint32_t negate, int const_slot) { +void GL4ShaderTranslator::AppendSrcReg(const ucode::instr_alu_t& op, + uint32_t num, uint32_t type, + uint32_t swiz, uint32_t negate, + int const_slot) { if (negate) { Append("-"); } @@ -271,7 +276,7 @@ void GL4ShaderTranslator::PrintSrcReg(uint32_t num, uint32_t type, } } -void GL4ShaderTranslator::PrintVectorDstReg(const instr_alu_t& alu) { +void GL4ShaderTranslator::PrintVectorDstReg(const ucode::instr_alu_t& alu) { Append("%s%u", alu.export_data ? "export" : "R", alu.vector_dest); auto mask = alu.scalar_write_mask; if (mask != 0xf) { @@ -283,7 +288,7 @@ void GL4ShaderTranslator::PrintVectorDstReg(const instr_alu_t& alu) { } } -void GL4ShaderTranslator::PrintScalarDstReg(const instr_alu_t& alu) { +void GL4ShaderTranslator::PrintScalarDstReg(const ucode::instr_alu_t& alu) { Append("%s%u", alu.export_data ? "export" : "R", alu.export_data ? alu.vector_dest : alu.scalar_dest); auto mask = alu.scalar_write_mask; @@ -494,7 +499,7 @@ void GL4ShaderTranslator::AppendOpDestRegName(const ucode::instr_alu_t& op, } } -bool GL4ShaderTranslator::TranslateALU_ADDv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_ADDv(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); AppendVectorOpSrcReg(alu, 1); Append(" + "); @@ -503,7 +508,7 @@ bool GL4ShaderTranslator::TranslateALU_ADDv(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_MULv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_MULv(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); AppendVectorOpSrcReg(alu, 1); Append(" * "); @@ -512,7 +517,7 @@ bool GL4ShaderTranslator::TranslateALU_MULv(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_MAXv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_MAXv(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); if (alu.src1_reg == alu.src2_reg && alu.src1_sel == alu.src2_sel && alu.src1_swiz == alu.src2_swiz && @@ -530,7 +535,7 @@ bool GL4ShaderTranslator::TranslateALU_MAXv(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_MINv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_MINv(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); Append("min("); AppendVectorOpSrcReg(alu, 1); @@ -541,7 +546,7 @@ bool GL4ShaderTranslator::TranslateALU_MINv(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_SETXXv(const instr_alu_t& alu, +bool GL4ShaderTranslator::TranslateALU_SETXXv(const ucode::instr_alu_t& alu, const char* op) { BeginAppendVectorOp(alu); Append("vec4(("); @@ -564,20 +569,20 @@ bool GL4ShaderTranslator::TranslateALU_SETXXv(const instr_alu_t& alu, EndAppendVectorOp(alu); return true; } -bool GL4ShaderTranslator::TranslateALU_SETEv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SETEv(const ucode::instr_alu_t& alu) { return TranslateALU_SETXXv(alu, "=="); } -bool GL4ShaderTranslator::TranslateALU_SETGTv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SETGTv(const ucode::instr_alu_t& alu) { return TranslateALU_SETXXv(alu, ">"); } -bool GL4ShaderTranslator::TranslateALU_SETGTEv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SETGTEv(const ucode::instr_alu_t& alu) { return TranslateALU_SETXXv(alu, ">="); } -bool GL4ShaderTranslator::TranslateALU_SETNEv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SETNEv(const ucode::instr_alu_t& alu) { return TranslateALU_SETXXv(alu, "!="); } -bool GL4ShaderTranslator::TranslateALU_FRACv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_FRACv(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); Append("fract("); AppendVectorOpSrcReg(alu, 1); @@ -586,7 +591,7 @@ bool GL4ShaderTranslator::TranslateALU_FRACv(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_TRUNCv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_TRUNCv(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); Append("trunc("); AppendVectorOpSrcReg(alu, 1); @@ -595,7 +600,7 @@ bool GL4ShaderTranslator::TranslateALU_TRUNCv(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_FLOORv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_FLOORv(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); Append("floor("); AppendVectorOpSrcReg(alu, 1); @@ -604,7 +609,7 @@ bool GL4ShaderTranslator::TranslateALU_FLOORv(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_MULADDv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_MULADDv(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); Append("("); AppendVectorOpSrcReg(alu, 1); @@ -616,7 +621,7 @@ bool GL4ShaderTranslator::TranslateALU_MULADDv(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_CNDXXv(const instr_alu_t& alu, +bool GL4ShaderTranslator::TranslateALU_CNDXXv(const ucode::instr_alu_t& alu, const char* op) { BeginAppendVectorOp(alu); // TODO(benvanik): check argument order - could be 3 as compare and 1 and 2 as @@ -649,17 +654,17 @@ bool GL4ShaderTranslator::TranslateALU_CNDXXv(const instr_alu_t& alu, EndAppendVectorOp(alu); return true; } -bool GL4ShaderTranslator::TranslateALU_CNDEv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_CNDEv(const ucode::instr_alu_t& alu) { return TranslateALU_CNDXXv(alu, "=="); } -bool GL4ShaderTranslator::TranslateALU_CNDGTEv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_CNDGTEv(const ucode::instr_alu_t& alu) { return TranslateALU_CNDXXv(alu, ">="); } -bool GL4ShaderTranslator::TranslateALU_CNDGTv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_CNDGTv(const ucode::instr_alu_t& alu) { return TranslateALU_CNDXXv(alu, ">"); } -bool GL4ShaderTranslator::TranslateALU_DOT4v(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_DOT4v(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); Append("dot("); AppendVectorOpSrcReg(alu, 1); @@ -670,7 +675,7 @@ bool GL4ShaderTranslator::TranslateALU_DOT4v(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_DOT3v(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_DOT3v(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); Append("dot(vec4("); AppendVectorOpSrcReg(alu, 1); @@ -681,7 +686,7 @@ bool GL4ShaderTranslator::TranslateALU_DOT3v(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_DOT2ADDv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_DOT2ADDv(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); Append("dot(vec4("); AppendVectorOpSrcReg(alu, 1); @@ -694,7 +699,7 @@ bool GL4ShaderTranslator::TranslateALU_DOT2ADDv(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_CUBEv(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_CUBEv(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); Append("cube("); AppendVectorOpSrcReg(alu, 1); @@ -705,7 +710,7 @@ bool GL4ShaderTranslator::TranslateALU_CUBEv(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_MAX4v(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_MAX4v(const ucode::instr_alu_t& alu) { BeginAppendVectorOp(alu); Append("max("); Append("max("); @@ -793,7 +798,7 @@ bool GL4ShaderTranslator::TranslateALU_MOVAv(const ucode::instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_ADDs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_ADDs(const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); AppendScalarOpSrcReg(alu, 3); Append(".x + "); @@ -803,7 +808,8 @@ bool GL4ShaderTranslator::TranslateALU_ADDs(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_ADD_PREVs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_ADD_PREVs( + const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); AppendSrcReg(alu, 3); Append(".x + ps"); @@ -811,7 +817,7 @@ bool GL4ShaderTranslator::TranslateALU_ADD_PREVs(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_MULs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_MULs(const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); AppendScalarOpSrcReg(alu, 3); Append(".x * "); @@ -821,7 +827,8 @@ bool GL4ShaderTranslator::TranslateALU_MULs(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_MUL_PREVs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_MUL_PREVs( + const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); AppendSrcReg(alu, 3); Append(".x * ps"); @@ -831,7 +838,7 @@ bool GL4ShaderTranslator::TranslateALU_MUL_PREVs(const instr_alu_t& alu) { // ... -bool GL4ShaderTranslator::TranslateALU_MAXs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_MAXs(const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); if ((alu.src3_swiz & 0x3) == (((alu.src3_swiz >> 2) + 1) & 0x3)) { // This is a mov. @@ -847,7 +854,7 @@ bool GL4ShaderTranslator::TranslateALU_MAXs(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_MINs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_MINs(const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); Append("min("); AppendScalarOpSrcReg(alu, 3); @@ -858,7 +865,7 @@ bool GL4ShaderTranslator::TranslateALU_MINs(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_SETXXs(const instr_alu_t& alu, +bool GL4ShaderTranslator::TranslateALU_SETXXs(const ucode::instr_alu_t& alu, const char* op) { BeginAppendScalarOp(alu); Append("("); @@ -867,16 +874,16 @@ bool GL4ShaderTranslator::TranslateALU_SETXXs(const instr_alu_t& alu, EndAppendScalarOp(alu); return true; } -bool GL4ShaderTranslator::TranslateALU_SETEs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SETEs(const ucode::instr_alu_t& alu) { return TranslateALU_SETXXs(alu, "=="); } -bool GL4ShaderTranslator::TranslateALU_SETGTs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SETGTs(const ucode::instr_alu_t& alu) { return TranslateALU_SETXXs(alu, ">"); } -bool GL4ShaderTranslator::TranslateALU_SETGTEs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SETGTEs(const ucode::instr_alu_t& alu) { return TranslateALU_SETXXs(alu, ">="); } -bool GL4ShaderTranslator::TranslateALU_SETNEs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SETNEs(const ucode::instr_alu_t& alu) { return TranslateALU_SETXXs(alu, "!="); } @@ -907,7 +914,7 @@ bool GL4ShaderTranslator::TranslateALU_FLOORs(const ucode::instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_EXP_IEEE(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_EXP_IEEE(const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); Append("pow(2.0, "); AppendScalarOpSrcReg(alu, 3); @@ -936,7 +943,8 @@ bool GL4ShaderTranslator::TranslateALU_LOG_IEEE(const ucode::instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_RECIP_CLAMP(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_RECIP_CLAMP( + const ucode::instr_alu_t& alu) { // if result == -inf result = -flt_max // if result == +inf result = flt_max BeginAppendScalarOp(alu); @@ -946,7 +954,7 @@ bool GL4ShaderTranslator::TranslateALU_RECIP_CLAMP(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_RECIP_FF(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_RECIP_FF(const ucode::instr_alu_t& alu) { // if result == -inf result = -zero // if result == +inf result = zero BeginAppendScalarOp(alu); @@ -956,7 +964,8 @@ bool GL4ShaderTranslator::TranslateALU_RECIP_FF(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_RECIP_IEEE(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_RECIP_IEEE( + const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); Append("1.0 / "); AppendScalarOpSrcReg(alu, 3); @@ -1037,7 +1046,7 @@ bool GL4ShaderTranslator::TranslateALU_MOVA_FLOORs( return true; } -bool GL4ShaderTranslator::TranslateALU_SUBs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SUBs(const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); AppendScalarOpSrcReg(alu, 3); Append(".x - "); @@ -1056,8 +1065,8 @@ bool GL4ShaderTranslator::TranslateALU_SUB_PREVs( return true; } -bool GL4ShaderTranslator::TranslateALU_PRED_SETXXs(const instr_alu_t& alu, - const char* op) { +bool GL4ShaderTranslator::TranslateALU_PRED_SETXXs( + const ucode::instr_alu_t& alu, const char* op) { Append(" p = "); AppendScalarOpSrcReg(alu, 3); Append(".x %s 0.0;\n", op); @@ -1066,16 +1075,20 @@ bool GL4ShaderTranslator::TranslateALU_PRED_SETXXs(const instr_alu_t& alu, EndAppendScalarOp(alu); return true; } -bool GL4ShaderTranslator::TranslateALU_PRED_SETEs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_PRED_SETEs( + const ucode::instr_alu_t& alu) { return TranslateALU_PRED_SETXXs(alu, "=="); } -bool GL4ShaderTranslator::TranslateALU_PRED_SETNEs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_PRED_SETNEs( + const ucode::instr_alu_t& alu) { return TranslateALU_PRED_SETXXs(alu, "!="); } -bool GL4ShaderTranslator::TranslateALU_PRED_SETGTs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_PRED_SETGTs( + const ucode::instr_alu_t& alu) { return TranslateALU_PRED_SETXXs(alu, ">"); } -bool GL4ShaderTranslator::TranslateALU_PRED_SETGTEs(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_PRED_SETGTEs( + const ucode::instr_alu_t& alu) { return TranslateALU_PRED_SETXXs(alu, ">="); } @@ -1105,7 +1118,8 @@ bool GL4ShaderTranslator::TranslateALU_PRED_SET_POPs( return true; } -bool GL4ShaderTranslator::TranslateALU_SQRT_IEEE(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SQRT_IEEE( + const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); Append("sqrt("); AppendScalarOpSrcReg(alu, 3); @@ -1114,7 +1128,8 @@ bool GL4ShaderTranslator::TranslateALU_SQRT_IEEE(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_MUL_CONST_0(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_MUL_CONST_0( + const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); uint32_t src3_swiz = alu.src3_swiz & ~0x3C; uint32_t swiz_a = ((src3_swiz >> 6) - 1) & 0x3; @@ -1130,11 +1145,13 @@ bool GL4ShaderTranslator::TranslateALU_MUL_CONST_0(const instr_alu_t& alu) { EndAppendScalarOp(alu); return true; } -bool GL4ShaderTranslator::TranslateALU_MUL_CONST_1(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_MUL_CONST_1( + const ucode::instr_alu_t& alu) { return TranslateALU_MUL_CONST_0(alu); } -bool GL4ShaderTranslator::TranslateALU_ADD_CONST_0(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_ADD_CONST_0( + const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); uint32_t src3_swiz = alu.src3_swiz & ~0x3C; uint32_t swiz_a = ((src3_swiz >> 6) - 1) & 0x3; @@ -1150,11 +1167,13 @@ bool GL4ShaderTranslator::TranslateALU_ADD_CONST_0(const instr_alu_t& alu) { EndAppendScalarOp(alu); return true; } -bool GL4ShaderTranslator::TranslateALU_ADD_CONST_1(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_ADD_CONST_1( + const ucode::instr_alu_t& alu) { return TranslateALU_ADD_CONST_0(alu); } -bool GL4ShaderTranslator::TranslateALU_SUB_CONST_0(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SUB_CONST_0( + const ucode::instr_alu_t& alu) { BeginAppendScalarOp(alu); uint32_t src3_swiz = alu.src3_swiz & ~0x3C; uint32_t swiz_a = ((src3_swiz >> 6) - 1) & 0x3; @@ -1170,7 +1189,8 @@ bool GL4ShaderTranslator::TranslateALU_SUB_CONST_0(const instr_alu_t& alu) { EndAppendScalarOp(alu); return true; } -bool GL4ShaderTranslator::TranslateALU_SUB_CONST_1(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_SUB_CONST_1( + const ucode::instr_alu_t& alu) { // Handled as switch on scalar_opc. return TranslateALU_SUB_CONST_0(alu); } @@ -1193,7 +1213,8 @@ bool GL4ShaderTranslator::TranslateALU_COS(const ucode::instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_RETAIN_PREV(const instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_RETAIN_PREV( + const ucode::instr_alu_t& alu) { // TODO(benvanik): figure out how this is used. // It seems like vector writes to export regs will use this to write 1's to // components (like w in position). @@ -1203,7 +1224,7 @@ bool GL4ShaderTranslator::TranslateALU_RETAIN_PREV(const instr_alu_t& alu) { return true; } -typedef bool (GL4ShaderTranslator::*TranslateFn)(const instr_alu_t& alu); +typedef bool (GL4ShaderTranslator::*TranslateFn)(const ucode::instr_alu_t& alu); typedef struct { uint32_t num_srcs; const char* name; @@ -1214,7 +1235,8 @@ typedef struct { #define ALU_INSTR_IMPL(opc, num_srcs) \ { num_srcs, #opc, &GL4ShaderTranslator::TranslateALU_##opc } -bool GL4ShaderTranslator::TranslateALU(const instr_alu_t* alu, int sync) { +bool GL4ShaderTranslator::TranslateALU(const ucode::instr_alu_t* alu, + int sync) { static TranslateInfo vector_alu_instrs[0x20] = { ALU_INSTR_IMPL(ADDv, 2), // 0 ALU_INSTR_IMPL(MULv, 2), // 1 @@ -1446,8 +1468,8 @@ bool GL4ShaderTranslator::TranslateBlocks(GL4Shader* shader) { #endif // FLOW_CONTROL // Process all execution blocks. - instr_cf_t cfa; - instr_cf_t cfb; + ucode::instr_cf_t cfa; + ucode::instr_cf_t cfb; auto data = shader->data(); bool needs_break = false; for (uint32_t idx = 0; idx < shader->dword_count(); idx += 3) { @@ -1496,7 +1518,7 @@ bool GL4ShaderTranslator::TranslateBlocks(GL4Shader* shader) { else if (cfb.opc == LOOP_END) { TranslateLoopEnd(cfb.loop); } -#endif +#endif // FLOW_CONTROL if (cfa.opc == EXEC_END || cfb.opc == EXEC_END) { break; @@ -1545,7 +1567,7 @@ static const struct { #undef INSTR }; -bool GL4ShaderTranslator::TranslateExec(const instr_cf_exec_t& cf) { +bool GL4ShaderTranslator::TranslateExec(const ucode::instr_cf_exec_t& cf) { Append(" // %s ADDR(0x%x) CNT(0x%x)", cf_instructions[cf.opc].name, cf.address, cf.count); if (cf.yeild) { @@ -1616,7 +1638,8 @@ bool GL4ShaderTranslator::TranslateExec(const instr_cf_exec_t& cf) { break; } } else { - const instr_alu_t* alu = (const instr_alu_t*)(dwords_ + alu_off * 3); + const ucode::instr_alu_t* alu = + (const ucode::instr_alu_t*)(dwords_ + alu_off * 3); AppendPredPre(cf.is_cond_exec(), cf.pred_condition, alu->pred_select, alu->pred_condition); if (!TranslateALU(alu, sync)) { @@ -1702,8 +1725,8 @@ bool GL4ShaderTranslator::TranslateLoopEnd(const ucode::instr_cf_loop_t& cf) { return true; } -bool GL4ShaderTranslator::TranslateVertexFetch(const instr_fetch_vtx_t* vtx, - int sync) { +bool GL4ShaderTranslator::TranslateVertexFetch( + const ucode::instr_fetch_vtx_t* vtx, int sync) { static const struct { const char* name; } fetch_types[0xff] = { @@ -1834,8 +1857,8 @@ bool GL4ShaderTranslator::TranslateVertexFetch(const instr_fetch_vtx_t* vtx, return true; } -bool GL4ShaderTranslator::TranslateTextureFetch(const instr_fetch_tex_t* tex, - int sync) { +bool GL4ShaderTranslator::TranslateTextureFetch( + const ucode::instr_fetch_tex_t* tex, int sync) { int src_component_count = 0; const char* sampler_type; switch (tex->dimension) { diff --git a/src/xenia/gpu/gl4/texture_cache.cc b/src/xenia/gpu/gl4/texture_cache.cc index 6938aa749..e33fe7ec7 100644 --- a/src/xenia/gpu/gl4/texture_cache.cc +++ b/src/xenia/gpu/gl4/texture_cache.cc @@ -9,6 +9,7 @@ #include "xenia/gpu/gl4/texture_cache.h" +#include #include #include "xenia/base/assert.h" @@ -22,7 +23,7 @@ namespace xe { namespace gpu { namespace gl4 { -using namespace xe::gpu::xenos; +using xe::gpu::xenos::Endian; struct TextureConfig { TextureFormat texture_format; diff --git a/src/xenia/gpu/gl4/trace_viewer_main.cc b/src/xenia/gpu/gl4/trace_viewer_main.cc index 4b1020e41..346e61495 100644 --- a/src/xenia/gpu/gl4/trace_viewer_main.cc +++ b/src/xenia/gpu/gl4/trace_viewer_main.cc @@ -2201,12 +2201,12 @@ int trace_viewer_main(const std::vector& args) { exit(1); } }); - window->on_closed.AddListener([&loop](xe::ui::UIEvent& e) { + window->on_closed.AddListener([&loop](xe::ui::UIEvent* e) { loop->Quit(); XELOGI("User-initiated death!"); exit(1); }); - loop->on_quit.AddListener([&window](xe::ui::UIEvent& e) { window.reset(); }); + loop->on_quit.AddListener([&window](xe::ui::UIEvent* e) { window.reset(); }); window->Resize(1920, 1200); X_STATUS result = emulator->Setup(window.get()); @@ -2246,21 +2246,21 @@ int trace_viewer_main(const std::vector& args) { return 1; } - window->on_key_char.AddListener([graphics_system](xe::ui::KeyEvent& e) { + window->on_key_char.AddListener([graphics_system](xe::ui::KeyEvent* e) { auto& io = ImGui::GetIO(); - if (e.key_code() > 0 && e.key_code() < 0x10000) { - if (e.key_code() == 0x74 /* VK_F5 */) { + if (e->key_code() > 0 && e->key_code() < 0x10000) { + if (e->key_code() == 0x74 /* VK_F5 */) { graphics_system->ClearCaches(); } else { - io.AddInputCharacter(e.key_code()); + io.AddInputCharacter(e->key_code()); } } - e.set_handled(true); + e->set_handled(true); }); - window->on_mouse_down.AddListener([](xe::ui::MouseEvent& e) { + window->on_mouse_down.AddListener([](xe::ui::MouseEvent* e) { auto& io = ImGui::GetIO(); - io.MousePos = ImVec2(float(e.x()), float(e.y())); - switch (e.button()) { + io.MousePos = ImVec2(float(e->x()), float(e->y())); + switch (e->button()) { case xe::ui::MouseEvent::Button::kLeft: io.MouseDown[0] = true; break; @@ -2269,14 +2269,14 @@ int trace_viewer_main(const std::vector& args) { break; } }); - window->on_mouse_move.AddListener([](xe::ui::MouseEvent& e) { + window->on_mouse_move.AddListener([](xe::ui::MouseEvent* e) { auto& io = ImGui::GetIO(); - io.MousePos = ImVec2(float(e.x()), float(e.y())); + io.MousePos = ImVec2(float(e->x()), float(e->y())); }); - window->on_mouse_up.AddListener([](xe::ui::MouseEvent& e) { + window->on_mouse_up.AddListener([](xe::ui::MouseEvent* e) { auto& io = ImGui::GetIO(); - io.MousePos = ImVec2(float(e.x()), float(e.y())); - switch (e.button()) { + io.MousePos = ImVec2(float(e->x()), float(e->y())); + switch (e->button()) { case xe::ui::MouseEvent::Button::kLeft: io.MouseDown[0] = false; break; @@ -2285,13 +2285,13 @@ int trace_viewer_main(const std::vector& args) { break; } }); - window->on_mouse_wheel.AddListener([](xe::ui::MouseEvent& e) { + window->on_mouse_wheel.AddListener([](xe::ui::MouseEvent* e) { auto& io = ImGui::GetIO(); - io.MousePos = ImVec2(float(e.x()), float(e.y())); - io.MouseWheel += float(e.dy() / 120.0f); + io.MousePos = ImVec2(float(e->x()), float(e->y())); + io.MouseWheel += float(e->dy() / 120.0f); }); - window->on_painting.AddListener([&](xe::ui::UIEvent& e) { + window->on_painting.AddListener([&](xe::ui::UIEvent* e) { static bool imgui_setup = false; if (!imgui_setup) { ImImpl_Setup(); @@ -2305,7 +2305,7 @@ int trace_viewer_main(const std::vector& args) { last_ticks = current_ticks; io.DisplaySize = - ImVec2(float(e.target()->width()), float(e.target()->height())); + ImVec2(float(e->target()->width()), float(e->target()->height())); BYTE keystate[256]; GetKeyboardState(keystate); diff --git a/src/xenia/gpu/graphics_system.h b/src/xenia/gpu/graphics_system.h index 5556da33c..509e8c86e 100644 --- a/src/xenia/gpu/graphics_system.h +++ b/src/xenia/gpu/graphics_system.h @@ -62,7 +62,7 @@ class GraphicsSystem { virtual void ClearCaches() {} protected: - GraphicsSystem(Emulator* emulator); + explicit GraphicsSystem(Emulator* emulator); Emulator* emulator_ = nullptr; Memory* memory_ = nullptr; diff --git a/src/xenia/gpu/register_file.cc b/src/xenia/gpu/register_file.cc index 3da80a4ac..9346fde52 100644 --- a/src/xenia/gpu/register_file.cc +++ b/src/xenia/gpu/register_file.cc @@ -31,7 +31,7 @@ const RegisterInfo* RegisterFile::GetRegisterInfo(uint32_t index) { #undef XE_GPU_REGISTER default: return nullptr; - }; + } } } // namespace gpu diff --git a/src/xenia/gpu/texture_info.cc b/src/xenia/gpu/texture_info.cc index 5b63e7783..f5d427a98 100644 --- a/src/xenia/gpu/texture_info.cc +++ b/src/xenia/gpu/texture_info.cc @@ -9,10 +9,10 @@ #include "xenia/gpu/texture_info.h" +#include #include #include "third_party/xxhash/xxhash.h" - #include "xenia/base/math.h" namespace xe { diff --git a/src/xenia/gpu/tracing.h b/src/xenia/gpu/tracing.h index b1f9622ea..2f63ae096 100644 --- a/src/xenia/gpu/tracing.h +++ b/src/xenia/gpu/tracing.h @@ -82,7 +82,7 @@ struct EventCommand { class TraceWriter { public: - TraceWriter(uint8_t* membase); + explicit TraceWriter(uint8_t* membase); ~TraceWriter(); bool is_open() const { return file_ != nullptr; } diff --git a/src/xenia/gpu/ucode_disassembler.cc b/src/xenia/gpu/ucode_disassembler.cc index 81fa3f3ee..a150b99a9 100644 --- a/src/xenia/gpu/ucode_disassembler.cc +++ b/src/xenia/gpu/ucode_disassembler.cc @@ -149,13 +149,13 @@ void print_export_comment(StringBuffer* output, uint32_t num, ShaderType type) { } } +#define INSTR(opc, num_srcs) \ + { num_srcs, #opc } struct { uint32_t num_srcs; const char* name; } vector_instructions[0x20] = { -#define INSTR(opc, num_srcs) \ - { num_srcs, #opc } INSTR(ADDv, 2), // 0 INSTR(MULv, 2), // 1 INSTR(MAXv, 2), // 2 @@ -167,7 +167,7 @@ struct { INSTR(FRACv, 1), // 8 INSTR(TRUNCv, 1), // 9 INSTR(FLOORv, 1), // 10 - INSTR(MULADDv, 3), // 111 + INSTR(MULADDv, 3), // 11 INSTR(CNDEv, 3), // 12 INSTR(CNDGTEv, 3), // 13 INSTR(CNDGTv, 3), // 14 @@ -229,16 +229,16 @@ struct { INSTR(KILLNEs, 1), // 38 INSTR(KILLONEs, 1), // 39 INSTR(SQRT_IEEE, 1), // 40 - {0, 0}, - INSTR(MUL_CONST_0, 2), // 42 - INSTR(MUL_CONST_1, 2), // 43 - INSTR(ADD_CONST_0, 2), // 44 - INSTR(ADD_CONST_1, 2), // 45 - INSTR(SUB_CONST_0, 2), // 46 - INSTR(SUB_CONST_1, 2), // 47 - INSTR(SIN, 1), // 48 - INSTR(COS, 1), // 49 - INSTR(RETAIN_PREV, 1), // 50 + {0, 0}, // + INSTR(MUL_CONST_0, 2), // 42 + INSTR(MUL_CONST_1, 2), // 43 + INSTR(ADD_CONST_0, 2), // 44 + INSTR(ADD_CONST_1, 2), // 45 + INSTR(SUB_CONST_0, 2), // 46 + INSTR(SUB_CONST_1, 2), // 47 + INSTR(SIN, 1), // 48 + INSTR(COS, 1), // 49 + INSTR(RETAIN_PREV, 1), // 50 #undef INSTR }; @@ -701,7 +701,7 @@ struct { static void print_cf(StringBuffer* output, const instr_cf_t* cf, int level) { output->Append(levels[level]); - const uint16_t* words = (uint16_t*)cf; + auto words = reinterpret_cast(cf); output->AppendFormat(" %04x %04x %04x \t", words[0], words[1], words[2]); diff --git a/src/xenia/hid/input_driver.h b/src/xenia/hid/input_driver.h index b768c5965..510c14c0b 100644 --- a/src/xenia/hid/input_driver.h +++ b/src/xenia/hid/input_driver.h @@ -33,9 +33,9 @@ class InputDriver { X_INPUT_KEYSTROKE* out_keystroke) = 0; protected: - InputDriver(InputSystem* input_system); + explicit InputDriver(InputSystem* input_system); - InputSystem* input_system_; + InputSystem* input_system_ = nullptr; }; } // namespace hid diff --git a/src/xenia/hid/input_system.h b/src/xenia/hid/input_system.h index 6bb8ef72e..987b6f847 100644 --- a/src/xenia/hid/input_system.h +++ b/src/xenia/hid/input_system.h @@ -29,7 +29,7 @@ class InputDriver; class InputSystem { public: - InputSystem(Emulator* emulator); + explicit InputSystem(Emulator* emulator); ~InputSystem(); static std::unique_ptr Create(Emulator* emulator); @@ -50,9 +50,9 @@ class InputSystem { X_INPUT_KEYSTROKE* out_keystroke); private: - Emulator* emulator_; - Memory* memory_; - cpu::Processor* processor_; + Emulator* emulator_ = nullptr; + Memory* memory_ = nullptr; + cpu::Processor* processor_ = nullptr; std::vector> drivers_; }; diff --git a/src/xenia/hid/nop/nop_input_driver.h b/src/xenia/hid/nop/nop_input_driver.h index 30529ed4d..3609a1317 100644 --- a/src/xenia/hid/nop/nop_input_driver.h +++ b/src/xenia/hid/nop/nop_input_driver.h @@ -18,7 +18,7 @@ namespace nop { class NopInputDriver : public InputDriver { public: - NopInputDriver(InputSystem* input_system); + explicit NopInputDriver(InputSystem* input_system); ~NopInputDriver() override; X_STATUS Setup() override; diff --git a/src/xenia/hid/winkey/winkey_input_driver.h b/src/xenia/hid/winkey/winkey_input_driver.h index a833811b6..550e99f70 100644 --- a/src/xenia/hid/winkey/winkey_input_driver.h +++ b/src/xenia/hid/winkey/winkey_input_driver.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_HID_WINKEY_WINKEY_DRIVER_H_ -#define XENIA_HID_WINKEY_WINKEY_DRIVER_H_ +#ifndef XENIA_HID_WINKEY_WINKEY_INPUT_DRIVER_H_ +#define XENIA_HID_WINKEY_WINKEY_INPUT_DRIVER_H_ #include "xenia/hid/input_driver.h" @@ -18,7 +18,7 @@ namespace winkey { class WinKeyInputDriver : public InputDriver { public: - WinKeyInputDriver(InputSystem* input_system); + explicit WinKeyInputDriver(InputSystem* input_system); ~WinKeyInputDriver() override; X_STATUS Setup() override; @@ -38,4 +38,4 @@ class WinKeyInputDriver : public InputDriver { } // namespace hid } // namespace xe -#endif // XENIA_HID_WINKEY_WINKEY_DRIVER_H_ +#endif // XENIA_HID_WINKEY_WINKEY_INPUT_DRIVER_H_ diff --git a/src/xenia/hid/xinput/xinput_input_driver.cc b/src/xenia/hid/xinput/xinput_input_driver.cc index 3d19817fb..e18ddef77 100644 --- a/src/xenia/hid/xinput/xinput_input_driver.cc +++ b/src/xenia/hid/xinput/xinput_input_driver.cc @@ -11,7 +11,7 @@ // Must be included before xinput.h to avoid windows.h conflicts: #include "xenia/base/platform_win.h" -#include +#include // NOLINT(build/include_order) #include "xenia/hid/hid_flags.h" diff --git a/src/xenia/hid/xinput/xinput_input_driver.h b/src/xenia/hid/xinput/xinput_input_driver.h index 56f3ffa7f..e206dd3c0 100644 --- a/src/xenia/hid/xinput/xinput_input_driver.h +++ b/src/xenia/hid/xinput/xinput_input_driver.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_HID_XINPUT_XINPUT_DRIVER_H_ -#define XENIA_HID_XINPUT_XINPUT_DRIVER_H_ +#ifndef XENIA_HID_XINPUT_XINPUT_INPUT_DRIVER_H_ +#define XENIA_HID_XINPUT_XINPUT_INPUT_DRIVER_H_ #include "xenia/hid/input_driver.h" @@ -18,7 +18,7 @@ namespace xinput { class XInputInputDriver : public InputDriver { public: - XInputInputDriver(InputSystem* input_system); + explicit XInputInputDriver(InputSystem* input_system); ~XInputInputDriver() override; X_STATUS Setup() override; @@ -37,4 +37,4 @@ class XInputInputDriver : public InputDriver { } // namespace hid } // namespace xe -#endif // XENIA_HID_XINPUT_XINPUT_DRIVER_H_ +#endif // XENIA_HID_XINPUT_XINPUT_INPUT_DRIVER_H_ diff --git a/src/xenia/kernel/apps/xgi_app.h b/src/xenia/kernel/apps/xgi_app.h index bd971697d..ff525e2e3 100644 --- a/src/xenia/kernel/apps/xgi_app.h +++ b/src/xenia/kernel/apps/xgi_app.h @@ -19,7 +19,7 @@ namespace apps { class XXGIApp : public XApp { public: - XXGIApp(KernelState* kernel_state); + explicit XXGIApp(KernelState* kernel_state); X_RESULT DispatchMessageSync(uint32_t message, uint32_t buffer_ptr, uint32_t buffer_length) override; diff --git a/src/xenia/kernel/apps/xlivebase_app.h b/src/xenia/kernel/apps/xlivebase_app.h index 8b630337c..b9d71d621 100644 --- a/src/xenia/kernel/apps/xlivebase_app.h +++ b/src/xenia/kernel/apps/xlivebase_app.h @@ -19,7 +19,7 @@ namespace apps { class XXLiveBaseApp : public XApp { public: - XXLiveBaseApp(KernelState* kernel_state); + explicit XXLiveBaseApp(KernelState* kernel_state); X_RESULT DispatchMessageSync(uint32_t message, uint32_t buffer_ptr, uint32_t buffer_length) override; diff --git a/src/xenia/kernel/apps/xmp_app.h b/src/xenia/kernel/apps/xmp_app.h index 537d64ba8..03420c009 100644 --- a/src/xenia/kernel/apps/xmp_app.h +++ b/src/xenia/kernel/apps/xmp_app.h @@ -66,7 +66,7 @@ class XXMPApp : public XApp { std::vector> songs; }; - XXMPApp(KernelState* kernel_state); + explicit XXMPApp(KernelState* kernel_state); X_RESULT XMPGetStatus(uint32_t status_ptr); diff --git a/src/xenia/kernel/content_manager.h b/src/xenia/kernel/content_manager.h index 80bd74f98..a142a8eca 100644 --- a/src/xenia/kernel/content_manager.h +++ b/src/xenia/kernel/content_manager.h @@ -33,7 +33,7 @@ struct XCONTENT_DATA { std::string file_name; XCONTENT_DATA() = default; - XCONTENT_DATA(const uint8_t* ptr) { + explicit XCONTENT_DATA(const uint8_t* ptr) { device_id = xe::load_and_swap(ptr + 0); content_type = xe::load_and_swap(ptr + 4); display_name = xe::load_and_swap(ptr + 8); diff --git a/src/xenia/kernel/dispatcher.h b/src/xenia/kernel/dispatcher.h index c03cbe23c..991653a2b 100644 --- a/src/xenia/kernel/dispatcher.h +++ b/src/xenia/kernel/dispatcher.h @@ -23,7 +23,7 @@ class NativeList; class Dispatcher { public: - Dispatcher(KernelState* kernel_state); + explicit Dispatcher(KernelState* kernel_state); virtual ~Dispatcher(); KernelState* kernel_state() const { return kernel_state_; } diff --git a/src/xenia/kernel/kernel_state.cc b/src/xenia/kernel/kernel_state.cc index ee865a423..2ac398199 100644 --- a/src/xenia/kernel/kernel_state.cc +++ b/src/xenia/kernel/kernel_state.cc @@ -11,6 +11,8 @@ #include +#include + #include "xenia/base/assert.h" #include "xenia/base/string.h" #include "xenia/cpu/processor.h" @@ -337,8 +339,8 @@ object_ref KernelState::LoadUserModule(const char* raw_name) { void KernelState::TerminateTitle(bool from_guest_thread) { std::lock_guard lock(object_mutex_); - // First: Call terminate routines - // TODO: These might take arguments + // First: call terminate routines. + // TODO(benvanik): these might take arguments. // FIXME: Calling these will send some threads into kernel code and they'll // hold the lock when terminated! Do we need to wait for all threads to exit? /* diff --git a/src/xenia/kernel/kernel_state.h b/src/xenia/kernel/kernel_state.h index 1b6cbac4f..dadfdb38c 100644 --- a/src/xenia/kernel/kernel_state.h +++ b/src/xenia/kernel/kernel_state.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "xenia/base/mutex.h" #include "xenia/cpu/export_resolver.h" @@ -86,7 +87,7 @@ struct TerminateNotification { class KernelState { public: - KernelState(Emulator* emulator); + explicit KernelState(Emulator* emulator); ~KernelState(); static KernelState* shared(); diff --git a/src/xenia/kernel/native_list.h b/src/xenia/kernel/native_list.h index 699c31165..d787985ce 100644 --- a/src/xenia/kernel/native_list.h +++ b/src/xenia/kernel/native_list.h @@ -28,7 +28,7 @@ namespace kernel { class NativeList { public: - NativeList(Memory* memory); + explicit NativeList(Memory* memory); void Insert(uint32_t list_entry_ptr); bool IsQueued(uint32_t list_entry_ptr); diff --git a/src/xenia/kernel/object_table.cc b/src/xenia/kernel/object_table.cc index f34ab1d44..383eefbf3 100644 --- a/src/xenia/kernel/object_table.cc +++ b/src/xenia/kernel/object_table.cc @@ -61,8 +61,8 @@ X_STATUS ObjectTable::FindFreeSlot(uint32_t* out_slot) { uint32_t new_table_capacity = std::max(16 * 1024u, table_capacity_ * 2); size_t new_table_size = new_table_capacity * sizeof(ObjectTableEntry); size_t old_table_size = table_capacity_ * sizeof(ObjectTableEntry); - ObjectTableEntry* new_table = - (ObjectTableEntry*)realloc(table_, new_table_size); + auto new_table = + reinterpret_cast(realloc(table_, new_table_size)); if (!new_table) { return X_STATUS_NO_MEMORY; } @@ -235,14 +235,14 @@ XObject* ObjectTable::LookupObject(X_HANDLE handle, bool already_locked) { } void ObjectTable::GetObjectsByType(XObject::Type type, - std::vector>& results) { + std::vector>* results) { std::lock_guard lock(table_mutex_); for (uint32_t slot = 0; slot < table_capacity_; ++slot) { auto& entry = table_[slot]; if (entry.object) { if (entry.object->type() == type) { entry.object->Retain(); - results.push_back(object_ref(entry.object)); + results->push_back(object_ref(entry.object)); } } } diff --git a/src/xenia/kernel/object_table.h b/src/xenia/kernel/object_table.h index 97e922284..d006a4ca5 100644 --- a/src/xenia/kernel/object_table.h +++ b/src/xenia/kernel/object_table.h @@ -13,6 +13,7 @@ #include #include #include +#include #include "xenia/base/mutex.h" #include "xenia/kernel/xobject.h" @@ -46,7 +47,7 @@ class ObjectTable { std::vector> GetObjectsByType(XObject::Type type) { std::vector> results; GetObjectsByType( - type, *reinterpret_cast>*>(&results)); + type, reinterpret_cast>*>(&results)); return results; } @@ -59,7 +60,7 @@ class ObjectTable { ObjectTableEntry* LookupTable(X_HANDLE handle); XObject* LookupObject(X_HANDLE handle, bool already_locked); void GetObjectsByType(XObject::Type type, - std::vector>& results); + std::vector>* results); X_HANDLE TranslateHandle(X_HANDLE handle); X_STATUS FindFreeSlot(uint32_t* out_slot); diff --git a/src/xenia/kernel/objects/xevent.cc b/src/xenia/kernel/objects/xevent.cc index f5de20e23..63108ef4c 100644 --- a/src/xenia/kernel/objects/xevent.cc +++ b/src/xenia/kernel/objects/xevent.cc @@ -27,11 +27,11 @@ void XEvent::Initialize(bool manual_reset, bool initial_state) { } } -void XEvent::InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header) { +void XEvent::InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header) { assert_false(event_); bool manual_reset; - switch (header.type) { + switch (header->type) { case 0x00: // EventNotificationObject (manual reset) manual_reset = true; break; @@ -43,7 +43,7 @@ void XEvent::InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header) { return; } - bool initial_state = header.signal_state ? true : false; + bool initial_state = header->signal_state ? true : false; Initialize(manual_reset, initial_state); } diff --git a/src/xenia/kernel/objects/xevent.h b/src/xenia/kernel/objects/xevent.h index fc1143f7b..b17c76586 100644 --- a/src/xenia/kernel/objects/xevent.h +++ b/src/xenia/kernel/objects/xevent.h @@ -24,11 +24,11 @@ struct X_KEVENT { class XEvent : public XObject { public: - XEvent(KernelState* kernel_state); + explicit XEvent(KernelState* kernel_state); ~XEvent() override; void Initialize(bool manual_reset, bool initial_state); - void InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header); + void InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header); int32_t Set(uint32_t priority_increment, bool wait); int32_t Pulse(uint32_t priority_increment, bool wait); diff --git a/src/xenia/kernel/objects/xfile.cc b/src/xenia/kernel/objects/xfile.cc index 898157121..8cb3e7d3f 100644 --- a/src/xenia/kernel/objects/xfile.cc +++ b/src/xenia/kernel/objects/xfile.cc @@ -60,9 +60,10 @@ X_STATUS XFile::QueryDirectory(X_FILE_DIRECTORY_INFORMATION* out_info, } } - auto end = (uint8_t*)out_info + length; + auto end = reinterpret_cast(out_info) + length; const auto& entry_name = entry->name(); - if (((uint8_t*)&out_info->file_name[0]) + entry_name.size() > end) { + if (reinterpret_cast(&out_info->file_name[0]) + entry_name.size() > + end) { assert_always("Buffer overflow?"); return X_STATUS_NO_SUCH_FILE; } diff --git a/src/xenia/kernel/objects/xfile.h b/src/xenia/kernel/objects/xfile.h index efa3560ee..8fa9c5e9d 100644 --- a/src/xenia/kernel/objects/xfile.h +++ b/src/xenia/kernel/objects/xfile.h @@ -10,12 +10,13 @@ #ifndef XENIA_KERNEL_OBJECTS_XFILE_H_ #define XENIA_KERNEL_OBJECTS_XFILE_H_ +#include + #include "xenia/base/filesystem.h" #include "xenia/kernel/objects/xevent.h" #include "xenia/kernel/xobject.h" #include "xenia/vfs/device.h" #include "xenia/vfs/entry.h" - #include "xenia/xbox.h" namespace xe { @@ -53,10 +54,10 @@ class X_FILE_DIRECTORY_INFORMATION { void Write(uint8_t* base, uint32_t p) { uint8_t* dst = base + p; - uint8_t* src = (uint8_t*)this; + uint8_t* src = reinterpret_cast(this); X_FILE_DIRECTORY_INFORMATION* info; do { - info = (X_FILE_DIRECTORY_INFORMATION*)src; + info = reinterpret_cast(src); xe::store_and_swap(dst, info->next_entry_offset); xe::store_and_swap(dst + 4, info->file_index); xe::store_and_swap(dst + 8, info->creation_time); diff --git a/src/xenia/kernel/objects/xmutant.cc b/src/xenia/kernel/objects/xmutant.cc index 6455b456c..f9dba8ec4 100644 --- a/src/xenia/kernel/objects/xmutant.cc +++ b/src/xenia/kernel/objects/xmutant.cc @@ -23,7 +23,7 @@ void XMutant::Initialize(bool initial_owner) { mutant_ = xe::threading::Mutant::Create(initial_owner); } -void XMutant::InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header) { +void XMutant::InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header) { assert_false(mutant_); // Haven't seen this yet, but it's possible. diff --git a/src/xenia/kernel/objects/xmutant.h b/src/xenia/kernel/objects/xmutant.h index 06725c2f1..0d41eb6a9 100644 --- a/src/xenia/kernel/objects/xmutant.h +++ b/src/xenia/kernel/objects/xmutant.h @@ -19,11 +19,11 @@ namespace kernel { class XMutant : public XObject { public: - XMutant(KernelState* kernel_state); + explicit XMutant(KernelState* kernel_state); ~XMutant() override; void Initialize(bool initial_owner); - void InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header); + void InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header); X_STATUS ReleaseMutant(uint32_t priority_increment, bool abandon, bool wait); diff --git a/src/xenia/kernel/objects/xnotify_listener.h b/src/xenia/kernel/objects/xnotify_listener.h index 27e38ce18..7a9638771 100644 --- a/src/xenia/kernel/objects/xnotify_listener.h +++ b/src/xenia/kernel/objects/xnotify_listener.h @@ -23,7 +23,7 @@ namespace kernel { class XNotifyListener : public XObject { public: - XNotifyListener(KernelState* kernel_state); + explicit XNotifyListener(KernelState* kernel_state); ~XNotifyListener() override; uint64_t mask() const { return mask_; } diff --git a/src/xenia/kernel/objects/xsemaphore.cc b/src/xenia/kernel/objects/xsemaphore.cc index 00a94888b..abf86eb5a 100644 --- a/src/xenia/kernel/objects/xsemaphore.cc +++ b/src/xenia/kernel/objects/xsemaphore.cc @@ -25,7 +25,7 @@ void XSemaphore::Initialize(int32_t initial_count, int32_t maximum_count) { semaphore_ = xe::threading::Semaphore::Create(initial_count, maximum_count); } -void XSemaphore::InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header) { +void XSemaphore::InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header) { assert_false(semaphore_); auto semaphore = reinterpret_cast(native_ptr); diff --git a/src/xenia/kernel/objects/xsemaphore.h b/src/xenia/kernel/objects/xsemaphore.h index cb63b539f..2cdb0fcd6 100644 --- a/src/xenia/kernel/objects/xsemaphore.h +++ b/src/xenia/kernel/objects/xsemaphore.h @@ -24,11 +24,11 @@ struct X_KSEMAPHORE { class XSemaphore : public XObject { public: - XSemaphore(KernelState* kernel_state); + explicit XSemaphore(KernelState* kernel_state); ~XSemaphore() override; void Initialize(int32_t initial_count, int32_t maximum_count); - void InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header); + void InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header); int32_t ReleaseSemaphore(int32_t release_count); diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index e634b19a5..e06c0947e 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -34,8 +34,6 @@ DEFINE_bool(ignore_thread_affinities, true, namespace xe { namespace kernel { -using namespace xe::cpu; - uint32_t next_xthread_id = 0; thread_local XThread* current_thread_tls = nullptr; xe::mutex critical_region_; @@ -220,9 +218,9 @@ X_STATUS XThread::Create() { // Allocate processor thread state. // This is thread safe. - thread_state_ = new ThreadState(kernel_state()->processor(), thread_id_, - ThreadStackType::kUserStack, 0, - creation_params_.stack_size, pcr_address_); + thread_state_ = new cpu::ThreadState( + kernel_state()->processor(), thread_id_, cpu::ThreadStackType::kUserStack, + 0, creation_params_.stack_size, pcr_address_); XELOGI("XThread%04X (%X) Stack: %.8X-%.8X", handle(), thread_state_->thread_id(), thread_state_->stack_limit(), thread_state_->stack_base()); @@ -352,7 +350,7 @@ X_STATUS XThread::Exit(int exit_code) { // This may only be called on the thread itself. assert_true(XThread::GetCurrentThread() == this); - // TODO(benvanik); dispatch events? waiters? etc? + // TODO(benvanik): dispatch events? waiters? etc? RundownAPCs(); // Set exit code. @@ -380,7 +378,7 @@ X_STATUS XThread::Exit(int exit_code) { } X_STATUS XThread::Terminate(int exit_code) { - // TODO: Inform the profiler that this thread is exiting. + // TODO(benvanik): inform the profiler that this thread is exiting. // Set exit code. X_KTHREAD* thread = guest_object(); @@ -426,8 +424,9 @@ void XThread::Execute() { } else { // Run user code. uint64_t args[] = {creation_params_.start_context}; - exit_code = (int)kernel_state()->processor()->Execute( - thread_state_, creation_params_.start_address, args, xe::countof(args)); + exit_code = static_cast(kernel_state()->processor()->Execute( + thread_state_, creation_params_.start_address, args, + xe::countof(args))); // If we got here it means the execute completed without an exit being // called. // Treat the return code as an implicit exit code. diff --git a/src/xenia/kernel/objects/xtimer.h b/src/xenia/kernel/objects/xtimer.h index b2b5a0c24..1bb40aa96 100644 --- a/src/xenia/kernel/objects/xtimer.h +++ b/src/xenia/kernel/objects/xtimer.h @@ -19,7 +19,7 @@ namespace kernel { class XTimer : public XObject { public: - XTimer(KernelState* kernel_state); + explicit XTimer(KernelState* kernel_state); ~XTimer() override; void Initialize(uint32_t timer_type); @@ -41,4 +41,4 @@ class XTimer : public XObject { } // namespace kernel } // namespace xe -#endif // XENIA_KERNEL_OBJECTS_TIMER_H_ +#endif // XENIA_KERNEL_OBJECTS_XTIMER_H_ diff --git a/src/xenia/kernel/objects/xuser_module.cc b/src/xenia/kernel/objects/xuser_module.cc index c803ef0ce..9526c6f77 100644 --- a/src/xenia/kernel/objects/xuser_module.cc +++ b/src/xenia/kernel/objects/xuser_module.cc @@ -9,6 +9,8 @@ #include "xenia/kernel/objects/xuser_module.h" +#include + #include "xenia/base/logging.h" #include "xenia/cpu/processor.h" #include "xenia/cpu/xex_module.h" @@ -19,8 +21,6 @@ namespace xe { namespace kernel { -using namespace xe::cpu; - XUserModule::XUserModule(KernelState* kernel_state, const char* path) : XModule(kernel_state, ModuleType::kUserModule, path) {} @@ -74,11 +74,11 @@ X_STATUS XUserModule::LoadFromFile(std::string path) { } X_STATUS XUserModule::LoadFromMemory(const void* addr, const size_t length) { - Processor* processor = kernel_state()->processor(); + auto processor = kernel_state()->processor(); // Prepare the module for execution. // Runtime takes ownership. - auto xex_module = std::make_unique(processor, kernel_state()); + auto xex_module = std::make_unique(processor, kernel_state()); if (!xex_module->Load(name_, path_, addr, length)) { return X_STATUS_UNSUCCESSFUL; } @@ -136,8 +136,8 @@ uint32_t XUserModule::GetProcAddressByName(const char* name) { X_STATUS XUserModule::GetSection(const char* name, uint32_t* out_section_data, uint32_t* out_section_size) { xex2_opt_resource_info* resource_header = nullptr; - if (!XexModule::GetOptHeader(xex_header(), XEX_HEADER_RESOURCE_INFO, - &resource_header)) { + if (!cpu::XexModule::GetOptHeader(xex_header(), XEX_HEADER_RESOURCE_INFO, + &resource_header)) { // No resources. return X_STATUS_UNSUCCESSFUL; } @@ -198,11 +198,14 @@ X_STATUS XUserModule::GetOptHeader(uint8_t* membase, const xex2_header* header, break; case 0x01: // Return pointer to data stored in header value. - field_value = uint32_t((uint8_t*)&opt_header.value - membase); + field_value = static_cast( + reinterpret_cast(&opt_header.value) - membase); break; default: // Data stored at offset to header. - field_value = uint32_t((uint8_t*)header - membase) + opt_header.offset; + field_value = static_cast( + reinterpret_cast(header) - membase) + + opt_header.offset; break; } break; @@ -275,12 +278,13 @@ void XUserModule::Dump() { auto& opt_header = header->headers[i]; // Stash a pointer (although this isn't used in every case) - void* opt_header_ptr = (uint8_t*)header + opt_header.offset; + auto opt_header_ptr = + reinterpret_cast(header) + opt_header.offset; switch (opt_header.key) { case XEX_HEADER_RESOURCE_INFO: { printf(" XEX_HEADER_RESOURCE_INFO:\n"); auto opt_resource_info = - reinterpret_cast(opt_header_ptr); + reinterpret_cast(opt_header_ptr); uint32_t count = (opt_resource_info->size - 4) / 16; for (uint32_t j = 0; j < count; j++) { @@ -304,7 +308,7 @@ void XUserModule::Dump() { } break; case XEX_HEADER_BOUNDING_PATH: { auto opt_bound_path = - reinterpret_cast(opt_header_ptr); + reinterpret_cast(opt_header_ptr); printf(" XEX_HEADER_BOUNDING_PATH: %s\n", opt_bound_path->path); } break; case XEX_HEADER_ORIGINAL_BASE_ADDRESS: { @@ -343,15 +347,14 @@ void XUserModule::Dump() { } } - auto libraries = (uint8_t*)opt_import_libraries + - opt_import_libraries->string_table_size + 12; + auto libraries = + reinterpret_cast(opt_import_libraries) + + opt_import_libraries->string_table_size + 12; uint32_t library_offset = 0; for (uint32_t l = 0; l < opt_import_libraries->library_count; l++) { - auto library = reinterpret_cast( - (uint8_t*)libraries + library_offset); + auto library = reinterpret_cast( + libraries + library_offset); auto name = string_table[library->name_index]; - - // Okay. Dump it. printf(" %s - %d imports\n", name, (uint16_t)library->count); // Manually byteswap these because of the bitfields. @@ -372,7 +375,7 @@ void XUserModule::Dump() { } break; case XEX_HEADER_ORIGINAL_PE_NAME: { auto opt_pe_name = - reinterpret_cast(opt_header_ptr); + reinterpret_cast(opt_header_ptr); printf(" XEX_HEADER_ORIGINAL_PE_NAME: %s\n", opt_pe_name->name); } break; case XEX_HEADER_STATIC_LIBRARIES: { @@ -383,10 +386,11 @@ void XUserModule::Dump() { uint32_t count = (opt_static_libraries->size - 4) / 0x10; for (uint32_t l = 0; l < count; l++) { auto& library = opt_static_libraries->libraries[l]; - printf( - " %-8s : %d.%d.%d.%d\n", library.name, - (uint16_t)library.version_major, (uint16_t)library.version_minor, - (uint16_t)library.version_build, (uint16_t)library.version_qfe); + printf(" %-8s : %d.%d.%d.%d\n", library.name, + static_cast(library.version_major), + static_cast(library.version_minor), + static_cast(library.version_build), + static_cast(library.version_qfe)); } } break; case XEX_HEADER_TLS_INFO: { @@ -395,42 +399,46 @@ void XUserModule::Dump() { reinterpret_cast(opt_header_ptr); printf(" Slot Count: %d\n", - (uint32_t)opt_tls_info->slot_count); + static_cast(opt_tls_info->slot_count)); printf(" Raw Data Address: %.8X\n", - (uint32_t)opt_tls_info->raw_data_address); - printf(" Data Size: %d\n", (uint32_t)opt_tls_info->data_size); + static_cast(opt_tls_info->raw_data_address)); + printf(" Data Size: %d\n", + static_cast(opt_tls_info->data_size)); printf(" Raw Data Size: %d\n", - (uint32_t)opt_tls_info->raw_data_size); + static_cast(opt_tls_info->raw_data_size)); } break; case XEX_HEADER_DEFAULT_STACK_SIZE: { printf(" XEX_HEADER_DEFAULT_STACK_SIZE: %d\n", - (uint32_t)opt_header.value); + static_cast(opt_header.value)); } break; case XEX_HEADER_DEFAULT_FILESYSTEM_CACHE_SIZE: { printf(" XEX_HEADER_DEFAULT_FILESYSTEM_CACHE_SIZE: %d\n", - (uint32_t)opt_header.value); + static_cast(opt_header.value)); } break; case XEX_HEADER_DEFAULT_HEAP_SIZE: { printf(" XEX_HEADER_DEFAULT_HEAP_SIZE: %d\n", - (uint32_t)opt_header.value); + static_cast(opt_header.value)); } break; case XEX_HEADER_PAGE_HEAP_SIZE_AND_FLAGS: { printf(" XEX_HEADER_PAGE_HEAP_SIZE_AND_FLAGS (TODO):\n"); } break; case XEX_HEADER_SYSTEM_FLAGS: { - printf(" XEX_HEADER_SYSTEM_FLAGS: %.8X\n", (uint32_t)opt_header.value); + printf(" XEX_HEADER_SYSTEM_FLAGS: %.8X\n", + static_cast(opt_header.value)); } break; case XEX_HEADER_EXECUTION_INFO: { printf(" XEX_HEADER_EXECUTION_INFO:\n"); auto opt_exec_info = reinterpret_cast(opt_header_ptr); - printf(" Media ID: %.8X\n", (uint32_t)opt_exec_info->media_id); - printf(" Title ID: %.8X\n", (uint32_t)opt_exec_info->title_id); - printf(" Savegame ID: %.8X\n", (uint32_t)opt_exec_info->title_id); - printf(" Disc Number / Total: %d / %d\n", - (uint8_t)opt_exec_info->disc_number, - (uint8_t)opt_exec_info->disc_count); + printf(" Media ID: %.8X\n", + static_cast(opt_exec_info->media_id)); + printf(" Title ID: %.8X\n", + static_cast(opt_exec_info->title_id)); + printf(" Savegame ID: %.8X\n", + static_cast(opt_exec_info->title_id)); + printf(" Disc Number / Total: %d / %d\n", opt_exec_info->disc_number, + opt_exec_info->disc_count); } break; case XEX_HEADER_TITLE_WORKSPACE_SIZE: { printf(" XEX_HEADER_TITLE_WORKSPACE_SIZE: %d\n", @@ -463,23 +471,21 @@ void XUserModule::Dump() { auto exe_address = xex_module()->xex_security_info()->load_address; auto e = memory()->TranslateVirtual( exe_address + dir->offset); + auto e_base = reinterpret_cast(e); // e->AddressOfX RVAs are relative to the IMAGE_EXPORT_DIRECTORY! - uint32_t* function_table = - (uint32_t*)((uint64_t)e + e->AddressOfFunctions); - - // Names relative to directory - uint32_t* name_table = (uint32_t*)((uint64_t)e + e->AddressOfNames); - - // Table of ordinals (by name) - uint16_t* ordinal_table = - (uint16_t*)((uint64_t)e + e->AddressOfNameOrdinals); - + auto function_table = + reinterpret_cast(e_base + e->AddressOfFunctions); + // Names relative to directory. + auto name_table = + reinterpret_cast(e_base + e->AddressOfNames); + // Table of ordinals (by name). + auto ordinal_table = reinterpret_cast( + e_base + e->AddressOfNameOrdinals); for (uint32_t n = 0; n < e->NumberOfNames; n++) { - const char* name = (const char*)((uint8_t*)e + name_table[n]); + auto name = reinterpret_cast(e_base + name_table[n]); uint16_t ordinal = ordinal_table[n]; uint32_t addr = exe_address + function_table[ordinal]; - printf(" %-28s - %.3X - %.8X\n", name, ordinal, addr); } } break; @@ -515,14 +521,14 @@ void XUserModule::Dump() { uint32_t start_address = security_info->load_address + (page * page_size); uint32_t end_address = start_address + (page_descriptor.size * page_size); - printf(" %3d %s %3d pages %.8X - %.8X (%d bytes)\n", (int)page, type, - page_descriptor.size, (int)start_address, (int)end_address, + printf(" %3u %s %3u pages %.8X - %.8X (%d bytes)\n", page, type, + page_descriptor.size, start_address, end_address, page_descriptor.size * page_size); page += page_descriptor.size; } // Print out imports. - // TODO: Figure out a way to remove dependency on old xex header. + // TODO(benvanik): figure out a way to remove dependency on old xex header. auto old_header = xe_xex2_get_header(xex_module()->xex()); printf("Imports:\n"); @@ -533,7 +539,7 @@ void XUserModule::Dump() { size_t import_info_count; if (!xe_xex2_get_import_infos(xex_module()->xex(), library, &import_infos, &import_info_count)) { - printf(" %s - %d imports\n", library->name, (int)import_info_count); + printf(" %s - %lld imports\n", library->name, import_info_count); printf(" Version: %d.%d.%d.%d\n", library->version.major, library->version.minor, library->version.build, library->version.qfe); @@ -582,12 +588,13 @@ void XUserModule::Dump() { } } } - printf(" Total: %4u\n", uint32_t(import_info_count)); + float total_count = static_cast(import_info_count) * 100.0f; + printf(" Total: %4llu\n", import_info_count); printf(" Known: %3d%% (%d known, %d unknown)\n", - (int)(known_count / (float)import_info_count * 100.0f), - known_count, unknown_count); + static_cast(known_count / total_count), known_count, + unknown_count); printf(" Implemented: %3d%% (%d implemented, %d unimplemented)\n", - (int)(impl_count / (float)import_info_count * 100.0f), impl_count, + static_cast(impl_count / total_count), impl_count, unimpl_count); printf("\n"); @@ -597,7 +604,7 @@ void XUserModule::Dump() { const char* name = "UNKNOWN"; bool implemented = false; - Export* kernel_export = nullptr; + cpu::Export* kernel_export = nullptr; if (kernel_state_->IsKernelModule(library->name)) { kernel_export = export_resolver->GetExportByOrdinal(library->name, info->ordinal); @@ -608,11 +615,12 @@ void XUserModule::Dump() { } else { auto module = kernel_state_->GetModule(library->name); if (module && module->GetProcAddressByOrdinal(info->ordinal)) { - // TODO: Name lookup + // TODO(benvanik): name lookup. implemented = true; } } - if (kernel_export && kernel_export->type == Export::Type::kVariable) { + if (kernel_export && + kernel_export->type == cpu::Export::Type::kVariable) { printf(" V %.8X %.3X (%3d) %s %s\n", info->value_address, info->ordinal, info->ordinal, implemented ? " " : "!!", name); } else if (info->thunk_address) { diff --git a/src/xenia/kernel/util/shim_utils.h b/src/xenia/kernel/util/shim_utils.h index d623c004f..edfd524ce 100644 --- a/src/xenia/kernel/util/shim_utils.h +++ b/src/xenia/kernel/util/shim_utils.h @@ -11,6 +11,7 @@ #define XENIA_KERNEL_UTIL_SHIM_UTILS_H_ #include +#include #include "xenia/base/byte_order.h" #include "xenia/base/memory.h" @@ -313,51 +314,51 @@ using pointer_result_t = shim::Result; namespace shim { -inline void AppendParam(StringBuffer& string_buffer, int_t param) { - string_buffer.AppendFormat("%d", int32_t(param)); +inline void AppendParam(StringBuffer* string_buffer, int_t param) { + string_buffer->AppendFormat("%d", int32_t(param)); } -inline void AppendParam(StringBuffer& string_buffer, dword_t param) { - string_buffer.AppendFormat("%.8X", uint32_t(param)); +inline void AppendParam(StringBuffer* string_buffer, dword_t param) { + string_buffer->AppendFormat("%.8X", uint32_t(param)); } -inline void AppendParam(StringBuffer& string_buffer, qword_t param) { - string_buffer.AppendFormat("%.16llX", uint64_t(param)); +inline void AppendParam(StringBuffer* string_buffer, qword_t param) { + string_buffer->AppendFormat("%.16llX", uint64_t(param)); } -inline void AppendParam(StringBuffer& string_buffer, float_t param) { - string_buffer.AppendFormat("%G", static_cast(param)); +inline void AppendParam(StringBuffer* string_buffer, float_t param) { + string_buffer->AppendFormat("%G", static_cast(param)); } -inline void AppendParam(StringBuffer& string_buffer, double_t param) { - string_buffer.AppendFormat("%G", static_cast(param)); +inline void AppendParam(StringBuffer* string_buffer, double_t param) { + string_buffer->AppendFormat("%G", static_cast(param)); } -inline void AppendParam(StringBuffer& string_buffer, lpvoid_t param) { - string_buffer.AppendFormat("%.8X", uint32_t(param)); +inline void AppendParam(StringBuffer* string_buffer, lpvoid_t param) { + string_buffer->AppendFormat("%.8X", uint32_t(param)); } -inline void AppendParam(StringBuffer& string_buffer, lpdword_t param) { - string_buffer.AppendFormat("%.8X", param.guest_address()); +inline void AppendParam(StringBuffer* string_buffer, lpdword_t param) { + string_buffer->AppendFormat("%.8X", param.guest_address()); if (param) { - string_buffer.AppendFormat("(%.8X)", param.value()); + string_buffer->AppendFormat("(%.8X)", param.value()); } } -inline void AppendParam(StringBuffer& string_buffer, lpqword_t param) { - string_buffer.AppendFormat("%.8X", param.guest_address()); +inline void AppendParam(StringBuffer* string_buffer, lpqword_t param) { + string_buffer->AppendFormat("%.8X", param.guest_address()); if (param) { - string_buffer.AppendFormat("(%.16llX)", param.value()); + string_buffer->AppendFormat("(%.16llX)", param.value()); } } -inline void AppendParam(StringBuffer& string_buffer, lpfloat_t param) { - string_buffer.AppendFormat("%.8X", param.guest_address()); +inline void AppendParam(StringBuffer* string_buffer, lpfloat_t param) { + string_buffer->AppendFormat("%.8X", param.guest_address()); if (param) { - string_buffer.AppendFormat("(%G)", param.value()); + string_buffer->AppendFormat("(%G)", param.value()); } } -inline void AppendParam(StringBuffer& string_buffer, lpdouble_t param) { - string_buffer.AppendFormat("%.8X", param.guest_address()); +inline void AppendParam(StringBuffer* string_buffer, lpdouble_t param) { + string_buffer->AppendFormat("%.8X", param.guest_address()); if (param) { - string_buffer.AppendFormat("(%G)", param.value()); + string_buffer->AppendFormat("(%G)", param.value()); } } template -void AppendParam(StringBuffer& string_buffer, pointer_t param) { - string_buffer.AppendFormat("%.8X", param.guest_address()); +void AppendParam(StringBuffer* string_buffer, pointer_t param) { + string_buffer->AppendFormat("%.8X", param.guest_address()); } enum class KernelModuleId { @@ -379,7 +380,7 @@ template string_buffer.Append(", "); } auto param = std::get(params); - AppendParam(string_buffer, param); + AppendParam(&string_buffer, param); AppendKernelCallParams(string_buffer, export_entry, params); } diff --git a/src/xenia/kernel/xam_input.cc b/src/xenia/kernel/xam_input.cc index 8f1a23c38..1221fd914 100644 --- a/src/xenia/kernel/xam_input.cc +++ b/src/xenia/kernel/xam_input.cc @@ -19,7 +19,10 @@ namespace xe { namespace kernel { -using namespace xe::hid; +using xe::hid::X_INPUT_CAPABILITIES; +using xe::hid::X_INPUT_KEYSTROKE; +using xe::hid::X_INPUT_STATE; +using xe::hid::X_INPUT_VIBRATION; constexpr uint32_t XINPUT_FLAG_GAMEPAD = 0x01; constexpr uint32_t XINPUT_FLAG_ANY_USER = 1 << 30; @@ -69,7 +72,7 @@ SHIM_CALL XamInputGetCapabilities_shim(PPCContext* ppc_context, user_index = 0; } - InputSystem* input_system = kernel_state->emulator()->input_system(); + auto input_system = kernel_state->emulator()->input_system(); auto caps = SHIM_STRUCT(X_INPUT_CAPABILITIES, caps_ptr); X_RESULT result = input_system->GetCapabilities(user_index, flags, caps); @@ -100,7 +103,7 @@ SHIM_CALL XamInputGetCapabilitiesEx_shim(PPCContext* ppc_context, user_index = 0; } - InputSystem* input_system = kernel_state->emulator()->input_system(); + auto input_system = kernel_state->emulator()->input_system(); auto caps = SHIM_STRUCT(X_INPUT_CAPABILITIES, caps_ptr); X_RESULT result = input_system->GetCapabilities(user_index, flags, caps); @@ -128,7 +131,7 @@ SHIM_CALL XamInputGetState_shim(PPCContext* ppc_context, user_index = 0; } - InputSystem* input_system = kernel_state->emulator()->input_system(); + auto input_system = kernel_state->emulator()->input_system(); auto input_state = SHIM_STRUCT(X_INPUT_STATE, state_ptr); X_RESULT result = input_system->GetState(user_index, input_state); @@ -153,7 +156,7 @@ SHIM_CALL XamInputSetState_shim(PPCContext* ppc_context, user_index = 0; } - InputSystem* input_system = kernel_state->emulator()->input_system(); + auto input_system = kernel_state->emulator()->input_system(); auto vibration = SHIM_STRUCT(X_INPUT_VIBRATION, vibration_ptr); X_RESULT result = input_system->SetState(user_index, vibration); @@ -188,7 +191,7 @@ SHIM_CALL XamInputGetKeystroke_shim(PPCContext* ppc_context, user_index = 0; } - InputSystem* input_system = kernel_state->emulator()->input_system(); + auto input_system = kernel_state->emulator()->input_system(); auto keystroke = SHIM_STRUCT(X_INPUT_KEYSTROKE, keystroke_ptr); X_RESULT result = input_system->GetKeystroke(user_index, flags, keystroke); @@ -221,7 +224,7 @@ SHIM_CALL XamInputGetKeystrokeEx_shim(PPCContext* ppc_context, user_index = 0; } - InputSystem* input_system = kernel_state->emulator()->input_system(); + auto input_system = kernel_state->emulator()->input_system(); auto keystroke = SHIM_STRUCT(X_INPUT_KEYSTROKE, keystroke_ptr); X_RESULT result = input_system->GetKeystroke(user_index, flags, keystroke); diff --git a/src/xenia/kernel/xam_module.cc b/src/xenia/kernel/xam_module.cc index aa9e297d7..d66e29fa2 100644 --- a/src/xenia/kernel/xam_module.cc +++ b/src/xenia/kernel/xam_module.cc @@ -9,6 +9,8 @@ #include "xenia/kernel/xam_module.h" +#include + #include "xenia/base/math.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/xam_private.h" diff --git a/src/xenia/kernel/xam_module.h b/src/xenia/kernel/xam_module.h index 50897457e..fa0181dae 100644 --- a/src/xenia/kernel/xam_module.h +++ b/src/xenia/kernel/xam_module.h @@ -7,8 +7,10 @@ ****************************************************************************** */ -#ifndef XENIA_KERNEL_XAM_H_ -#define XENIA_KERNEL_XAM_H_ +#ifndef XENIA_KERNEL_XAM_MODULE_H_ +#define XENIA_KERNEL_XAM_MODULE_H_ + +#include #include "xenia/cpu/export_resolver.h" #include "xenia/kernel/objects/xkernel_module.h" @@ -41,4 +43,4 @@ class XamModule : public XKernelModule { } // namespace kernel } // namespace xe -#endif // XENIA_KERNEL_XAM_H_ +#endif // XENIA_KERNEL_XAM_MODULE_H_ diff --git a/src/xenia/kernel/xam_net.cc b/src/xenia/kernel/xam_net.cc index ada406b41..d78db6b9b 100644 --- a/src/xenia/kernel/xam_net.cc +++ b/src/xenia/kernel/xam_net.cc @@ -20,7 +20,7 @@ // NOTE: must be included last as it expects windows.h to already be included. #define _WINSOCK_DEPRECATED_NO_WARNINGS // inet_addr -#include +#include // NOLINT(build/include_order) namespace xe { namespace kernel { @@ -190,7 +190,7 @@ SHIM_CALL NetDll_WSAStartup_shim(PPCContext* ppc_context, XELOGD("NetDll_WSAStartup(%d, %.4X, %.8X)", caller, version, data_ptr); - // TODO: Abstraction layer needed + // TODO(benvanik): abstraction layer needed. WSADATA wsaData; ZeroMemory(&wsaData, sizeof(WSADATA)); int ret = WSAStartup(version, &wsaData); diff --git a/src/xenia/kernel/xam_ui.cc b/src/xenia/kernel/xam_ui.cc index e4fc36397..986bf24bd 100644 --- a/src/xenia/kernel/xam_ui.cc +++ b/src/xenia/kernel/xam_ui.cc @@ -27,7 +27,7 @@ SHIM_CALL XamIsUIActive_shim(PPCContext* ppc_context, class MessageBoxWindow : public el::ModalForm { public: - MessageBoxWindow(xe::threading::Fence* fence) + explicit MessageBoxWindow(xe::threading::Fence* fence) : ModalForm([fence]() { fence->Signal(); }) {} ~MessageBoxWindow() override = default; @@ -51,7 +51,7 @@ class MessageBoxWindow : public el::ModalForm { protected: void BuildUI() override { - using namespace el::dsl; + using namespace el::dsl; // NOLINT(build/namespaces) set_text(xe::to_string(title_)); @@ -170,7 +170,7 @@ SHIM_CALL XamShowMessageBoxUI_shim(PPCContext* ppc_context, class KeyboardInputWindow : public el::ModalForm { public: - KeyboardInputWindow(xe::threading::Fence* fence) + explicit KeyboardInputWindow(xe::threading::Fence* fence) : ModalForm([fence]() { fence->Signal(); }) {} ~KeyboardInputWindow() override = default; @@ -196,7 +196,7 @@ class KeyboardInputWindow : public el::ModalForm { protected: void BuildUI() override { - using namespace el::dsl; + using namespace el::dsl; // NOLINT(build/namespaces) set_text(xe::to_string(title_)); @@ -343,13 +343,13 @@ DECLARE_XAM_EXPORT(XamShowDeviceSelectorUI, ExportTag::kImplemented); class DirtyDiscWindow : public el::ModalForm { public: - DirtyDiscWindow(xe::threading::Fence* fence) + explicit DirtyDiscWindow(xe::threading::Fence* fence) : ModalForm([fence]() { fence->Signal(); }) {} ~DirtyDiscWindow() override = default; protected: void BuildUI() override { - using namespace el::dsl; + using namespace el::dsl; // NOLINT(build/namespaces) set_text("Disc Read Error"); diff --git a/src/xenia/kernel/xam_user.cc b/src/xenia/kernel/xam_user.cc index a7902a44e..e3d8fd537 100644 --- a/src/xenia/kernel/xam_user.cc +++ b/src/xenia/kernel/xam_user.cc @@ -72,8 +72,8 @@ SHIM_CALL XamUserGetSigninInfo_shim(PPCContext* ppc_context, SHIM_SET_MEM_32(info_ptr + 12, user_profile->signin_state()); SHIM_SET_MEM_32(info_ptr + 16, 0); // ? SHIM_SET_MEM_32(info_ptr + 20, 0); // ? - char* buffer = (char*)SHIM_MEM_ADDR(info_ptr + 24); - strcpy(buffer, user_profile->name().data()); + char* buffer = reinterpret_cast(SHIM_MEM_ADDR(info_ptr + 24)); + std::strcpy(buffer, user_profile->name().data()); SHIM_SET_RETURN_32(0); } else { SHIM_SET_RETURN_32(X_ERROR_NO_SUCH_USER); @@ -90,8 +90,8 @@ SHIM_CALL XamUserGetName_shim(PPCContext* ppc_context, if (user_index == 0) { const auto& user_profile = kernel_state->user_profile(); - char* buffer = (char*)SHIM_MEM_ADDR(buffer_ptr); - strcpy(buffer, user_profile->name().data()); + char* buffer = reinterpret_cast(SHIM_MEM_ADDR(buffer_ptr)); + std::strcpy(buffer, user_profile->name().data()); SHIM_SET_RETURN_32(0); } else { SHIM_SET_RETURN_32(X_ERROR_NO_SUCH_USER); @@ -210,12 +210,13 @@ SHIM_CALL XamUserReadProfileSettings_shim(PPCContext* ppc_context, return; } - auto out_header = (X_USER_READ_PROFILE_SETTINGS*)SHIM_MEM_ADDR(buffer_ptr); + auto out_header = reinterpret_cast( + SHIM_MEM_ADDR(buffer_ptr)); out_header->setting_count = setting_count; out_header->settings_ptr = buffer_ptr + 8; - auto out_setting = - (X_USER_READ_PROFILE_SETTING*)SHIM_MEM_ADDR(out_header->settings_ptr); + auto out_setting = reinterpret_cast( + SHIM_MEM_ADDR(out_header->settings_ptr)); size_t buffer_offset = base_size_needed; for (uint32_t n = 0; n < setting_count; ++n) { @@ -231,9 +232,11 @@ SHIM_CALL XamUserReadProfileSettings_shim(PPCContext* ppc_context, buffer_offset = setting->Append(&out_setting->setting_data[0], SHIM_MEM_ADDR(buffer_ptr), buffer_ptr, buffer_offset); - } /*else { + } + // TODO(benvanik): why did I do this? + /*else { std::memset(&out_setting->setting_data[0], 0, - sizeof(out_setting->setting_data)); + sizeof(out_setting->setting_data)); }*/ ++out_setting; } @@ -280,7 +283,7 @@ SHIM_CALL XamUserWriteProfileSettings_shim(PPCContext* ppc_context, return; } - // TODO: Update and save settings. + // TODO(benvanik): update and save settings. // const auto& user_profile = kernel_state->user_profile(); if (overlapped_ptr) { diff --git a/src/xenia/kernel/xboxkrnl_audio_xma.cc b/src/xenia/kernel/xboxkrnl_audio_xma.cc index 0cbadf113..61ff6f381 100644 --- a/src/xenia/kernel/xboxkrnl_audio_xma.cc +++ b/src/xenia/kernel/xboxkrnl_audio_xma.cc @@ -18,11 +18,11 @@ #include "xenia/kernel/xboxkrnl_private.h" #include "xenia/xbox.h" -using namespace xe::apu; - namespace xe { namespace kernel { +using xe::apu::XMA_CONTEXT_DATA; + // See audio_system.cc for implementation details. // // XMA details: @@ -164,7 +164,8 @@ SHIM_CALL XMASetLoopData_shim(PPCContext* ppc_context, XELOGD("XMASetLoopData(%.8X, %.8X)", context_ptr, loop_data_ptr); XMA_CONTEXT_DATA context(SHIM_MEM_ADDR(context_ptr)); - auto loop_data = (XMA_CONTEXT_DATA*)SHIM_MEM_ADDR(loop_data_ptr); + auto loop_data = + reinterpret_cast(SHIM_MEM_ADDR(loop_data_ptr)); context.loop_start = loop_data->loop_start; context.loop_end = loop_data->loop_end; diff --git a/src/xenia/kernel/xboxkrnl_crypt.cc b/src/xenia/kernel/xboxkrnl_crypt.cc index e46eb08f4..8865d5f22 100644 --- a/src/xenia/kernel/xboxkrnl_crypt.cc +++ b/src/xenia/kernel/xboxkrnl_crypt.cc @@ -24,22 +24,22 @@ typedef struct { uint8_t buffer[64]; // 0x18 } XECRYPT_SHA_STATE; -void InitSha1(sha1::SHA1& sha, const XECRYPT_SHA_STATE* state) { +void InitSha1(sha1::SHA1* sha, const XECRYPT_SHA_STATE* state) { uint32_t digest[5]; for (int i = 0; i < 5; i++) { digest[i] = state->state[i]; } - sha.init(digest, state->buffer, state->count); + sha->init(digest, state->buffer, state->count); } -void StoreSha1(sha1::SHA1& sha, XECRYPT_SHA_STATE* state) { +void StoreSha1(sha1::SHA1* sha, XECRYPT_SHA_STATE* state) { for (int i = 0; i < 5; i++) { - state->state[i] = sha.getDigest()[i]; + state->state[i] = sha->getDigest()[i]; } - state->count = (uint32_t)sha.getByteCount(); - std::memcpy(state->buffer, sha.getBlock(), sha.getBlockByteIndex()); + state->count = static_cast(sha->getByteCount()); + std::memcpy(state->buffer, sha->getBlock(), sha->getBlockByteIndex()); } void XeCryptShaInit(pointer_t sha_state) { @@ -56,18 +56,18 @@ DECLARE_XBOXKRNL_EXPORT(XeCryptShaInit, ExportTag::kImplemented); void XeCryptShaUpdate(pointer_t sha_state, lpvoid_t input, dword_t input_size) { sha1::SHA1 sha; - InitSha1(sha, sha_state); + InitSha1(&sha, sha_state); sha.processBytes(input, input_size); - StoreSha1(sha, sha_state); + StoreSha1(&sha, sha_state); } DECLARE_XBOXKRNL_EXPORT(XeCryptShaUpdate, ExportTag::kImplemented); void XeCryptShaFinal(pointer_t sha_state, pointer_t> out, dword_t out_size) { sha1::SHA1 sha; - InitSha1(sha, sha_state); + InitSha1(&sha, sha_state); uint32_t digest[5]; sha.finalize(digest); diff --git a/src/xenia/kernel/xboxkrnl_debug.cc b/src/xenia/kernel/xboxkrnl_debug.cc index 0158b1dda..360716250 100644 --- a/src/xenia/kernel/xboxkrnl_debug.cc +++ b/src/xenia/kernel/xboxkrnl_debug.cc @@ -40,10 +40,10 @@ typedef struct { xe::be exception_information[15]; } X_EXCEPTION_RECORD; static_assert_size(X_EXCEPTION_RECORD, 0x50); -void AppendParam(StringBuffer& string_buffer, +void AppendParam(StringBuffer* string_buffer, pointer_t record) { - string_buffer.AppendFormat("%.8X(%.8X)", record.guest_address(), - uint32_t(record->exception_code)); + string_buffer->AppendFormat("%.8X(%.8X)", record.guest_address(), + uint32_t(record->exception_code)); } void RtlRaiseException(pointer_t record) { @@ -51,7 +51,8 @@ void RtlRaiseException(pointer_t record) { // SetThreadName. FFS. // https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx - // TODO: check record->number_parameters to make sure it's a correct size + // TODO(benvanik): check record->number_parameters to make sure it's a + // correct size. auto thread_info = reinterpret_cast(&record->exception_information[0]); diff --git a/src/xenia/kernel/xboxkrnl_io.cc b/src/xenia/kernel/xboxkrnl_io.cc index e8729c9f7..2408de12f 100644 --- a/src/xenia/kernel/xboxkrnl_io.cc +++ b/src/xenia/kernel/xboxkrnl_io.cc @@ -23,8 +23,6 @@ namespace xe { namespace kernel { -using namespace xe::vfs; - // http://msdn.microsoft.com/en-us/library/windows/hardware/ff540287.aspx class X_FILE_FS_VOLUME_INFORMATION { public: @@ -123,7 +121,7 @@ dword_result_t NtCreateFile(lpdword_t handle_out, dword_t desired_access, // Attempt open (or create). object_ref file; - FileAction file_action; + xe::vfs::FileAction file_action; X_STATUS result = kernel_state()->file_system()->OpenFile( kernel_state(), target_path, xe::vfs::FileDisposition((uint32_t)creation_disposition), desired_access, @@ -152,7 +150,8 @@ dword_result_t NtOpenFile(lpdword_t handle_out, dword_t desired_access, dword_t open_options) { return NtCreateFile(handle_out, desired_access, object_attributes, io_status_block, nullptr, 0, 0, - (uint32_t)FileDisposition::kOpen, open_options); + static_cast(xe::vfs::FileDisposition::kOpen), + open_options); } DECLARE_XBOXKRNL_EXPORT(NtOpenFile, ExportTag::kImplemented); @@ -212,7 +211,7 @@ dword_result_t NtReadFile(dword_t file_handle, dword_t event_handle, // we have written the info out. signal_event = true; } else { - // TODO: Async. + // TODO(benvanik): async. // X_STATUS_PENDING if not returning immediately. // XFile is waitable and signalled after each async req completes. @@ -454,10 +453,9 @@ dword_result_t NtQueryInformationFile( */ result = X_STATUS_UNSUCCESSFUL; info = 0; - } break; case XFileSectorInformation: - // TODO: Return sector this file's on. + // TODO(benvanik): return sector this file's on. assert_true(length == 4); result = X_STATUS_UNSUCCESSFUL; diff --git a/src/xenia/kernel/xboxkrnl_memory.cc b/src/xenia/kernel/xboxkrnl_memory.cc index e700c6c06..9a1fe8795 100644 --- a/src/xenia/kernel/xboxkrnl_memory.cc +++ b/src/xenia/kernel/xboxkrnl_memory.cc @@ -420,7 +420,8 @@ SHIM_CALL MmQueryStatistics_shim(PPCContext* ppc_context, const uint32_t size = sizeof(X_MM_QUERY_STATISTICS_RESULT); - auto stats = (X_MM_QUERY_STATISTICS_RESULT*)SHIM_MEM_ADDR(stats_ptr); + auto stats = + reinterpret_cast(SHIM_MEM_ADDR(stats_ptr)); if (stats->size != size) { SHIM_SET_RETURN_32(X_STATUS_BUFFER_TOO_SMALL); return; diff --git a/src/xenia/kernel/xboxkrnl_module.cc b/src/xenia/kernel/xboxkrnl_module.cc index 399feaf46..29b3938d4 100644 --- a/src/xenia/kernel/xboxkrnl_module.cc +++ b/src/xenia/kernel/xboxkrnl_module.cc @@ -11,6 +11,8 @@ #include +#include + #include "xenia/base/clock.h" #include "xenia/base/logging.h" #include "xenia/base/math.h" diff --git a/src/xenia/kernel/xboxkrnl_module.h b/src/xenia/kernel/xboxkrnl_module.h index 3d2d54d59..922e440aa 100644 --- a/src/xenia/kernel/xboxkrnl_module.h +++ b/src/xenia/kernel/xboxkrnl_module.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_KERNEL_MODULE_H_ -#define XENIA_KERNEL_MODULE_H_ +#ifndef XENIA_KERNEL_XBOXKRNL_MODULE_H_ +#define XENIA_KERNEL_XBOXKRNL_MODULE_H_ #include @@ -41,4 +41,4 @@ class XboxkrnlModule : public XKernelModule { } // namespace kernel } // namespace xe -#endif // XENIA_KERNEL_MODULE_H_ +#endif // XENIA_KERNEL_XBOXKRNL_MODULE_H_ diff --git a/src/xenia/kernel/xboxkrnl_modules.cc b/src/xenia/kernel/xboxkrnl_modules.cc index ebb0f60a5..6ad16bc71 100644 --- a/src/xenia/kernel/xboxkrnl_modules.cc +++ b/src/xenia/kernel/xboxkrnl_modules.cc @@ -319,10 +319,10 @@ SHIM_CALL XexGetProcedureAddress_shim(PPCContext* ppc_context, SHIM_SET_RETURN_32(result); } -void AppendParam(StringBuffer& string_buffer, +void AppendParam(StringBuffer* string_buffer, pointer_t reg) { - string_buffer.AppendFormat("%.8X(%.8X, %.8X)", reg.guest_address(), - reg->notification_routine, reg->priority); + string_buffer->AppendFormat("%.8X(%.8X, %.8X)", reg.guest_address(), + reg->notification_routine, reg->priority); } void ExRegisterTitleTerminateNotification( diff --git a/src/xenia/kernel/xboxkrnl_ordinals.h b/src/xenia/kernel/xboxkrnl_ordinals.h index f9acd6c66..26ba98251 100644 --- a/src/xenia/kernel/xboxkrnl_ordinals.h +++ b/src/xenia/kernel/xboxkrnl_ordinals.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_KERNEL_ORDINALS_H_ -#define XENIA_KERNEL_ORDINALS_H_ +#ifndef XENIA_KERNEL_XBOXKRNL_ORDINALS_H_ +#define XENIA_KERNEL_XBOXKRNL_ORDINALS_H_ #include "xenia/cpu/export_resolver.h" @@ -21,4 +21,4 @@ enum { } // namespace ordinals #include "xenia/kernel/util/ordinal_table_post.inc" -#endif // XENIA_KERNEL_ORDINALS_H_ +#endif // XENIA_KERNEL_XBOXKRNL_ORDINALS_H_ diff --git a/src/xenia/kernel/xboxkrnl_private.h b/src/xenia/kernel/xboxkrnl_private.h index 34f123be6..56ecdb16f 100644 --- a/src/xenia/kernel/xboxkrnl_private.h +++ b/src/xenia/kernel/xboxkrnl_private.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_KERNEL_PRIVATE_H_ -#define XENIA_KERNEL_PRIVATE_H_ +#ifndef XENIA_KERNEL_XBOXKRNL_PRIVATE_H_ +#define XENIA_KERNEL_XBOXKRNL_PRIVATE_H_ #include "xenia/kernel/xboxkrnl_ordinals.h" @@ -54,8 +54,7 @@ void RegisterUsbcamExports(xe::cpu::ExportResolver* export_resolver, void RegisterVideoExports(xe::cpu::ExportResolver* export_resolver, KernelState* kernel_state); } // namespace xboxkrnl - } // namespace kernel } // namespace xe -#endif // XENIA_KERNEL_PRIVATE_H_ +#endif // XENIA_KERNEL_XBOXKRNL_PRIVATE_H_ diff --git a/src/xenia/kernel/xboxkrnl_rtl.cc b/src/xenia/kernel/xboxkrnl_rtl.cc index 00be9aa83..bb06867c3 100644 --- a/src/xenia/kernel/xboxkrnl_rtl.cc +++ b/src/xenia/kernel/xboxkrnl_rtl.cc @@ -10,6 +10,7 @@ #include "xenia/kernel/xboxkrnl_rtl.h" #include +#include #include "xenia/base/atomic.h" #include "xenia/base/logging.h" @@ -219,7 +220,8 @@ SHIM_CALL RtlMultiByteToUnicodeN_shim(PPCContext* ppc_context, uint32_t copy_len = destination_len >> 1; copy_len = copy_len < source_len ? copy_len : source_len; - // TODO: maybe use MultiByteToUnicode on Win32? would require swapping + // TODO(benvanik): maybe use MultiByteToUnicode on Win32? would require + // swapping. for (uint32_t i = 0; i < copy_len; i++) { xe::store_and_swap( @@ -245,10 +247,10 @@ SHIM_CALL RtlUnicodeToMultiByteN_shim(PPCContext* ppc_context, uint32_t copy_len = source_len >> 1; copy_len = copy_len < destination_len ? copy_len : destination_len; - // TODO: maybe use UnicodeToMultiByte on Win32? + // TODO(benvanik): maybe use UnicodeToMultiByte on Win32? - auto source = (uint16_t*)SHIM_MEM_ADDR(source_ptr); - auto destination = (uint8_t*)SHIM_MEM_ADDR(destination_ptr); + auto source = reinterpret_cast(SHIM_MEM_ADDR(source_ptr)); + auto destination = reinterpret_cast(SHIM_MEM_ADDR(destination_ptr)); for (uint32_t i = 0; i < copy_len; i++) { uint16_t c = xe::byte_swap(*source++); *destination++ = c < 256 ? (uint8_t)c : '?'; @@ -360,7 +362,7 @@ SHIM_CALL RtlEnterCriticalSection_shim(PPCContext* ppc_context, uint32_t thread_id = XThread::GetCurrentThreadId(); - auto cs = (X_RTL_CRITICAL_SECTION*)SHIM_MEM_ADDR(cs_ptr); + auto cs = reinterpret_cast(SHIM_MEM_ADDR(cs_ptr)); uint32_t spin_wait_remaining = cs->spin_count_div_256 * 256; spin: @@ -401,7 +403,7 @@ SHIM_CALL RtlTryEnterCriticalSection_shim(PPCContext* ppc_context, uint32_t thread_id = XThread::GetCurrentThreadId(); - auto cs = (X_RTL_CRITICAL_SECTION*)SHIM_MEM_ADDR(cs_ptr); + auto cs = reinterpret_cast(SHIM_MEM_ADDR(cs_ptr)); uint32_t result = 0; if (xe::atomic_cas(-1, 0, &cs->lock_count)) { @@ -428,7 +430,7 @@ SHIM_CALL RtlLeaveCriticalSection_shim(PPCContext* ppc_context, // FYI: No need to check if the owning thread is calling this, as that should // be the only case. - auto cs = (X_RTL_CRITICAL_SECTION*)SHIM_MEM_ADDR(cs_ptr); + auto cs = reinterpret_cast(SHIM_MEM_ADDR(cs_ptr)); // Drop recursion count - if we are still not zero'ed return. int32_t recursion_count = --cs->recursion_count; diff --git a/src/xenia/kernel/xboxkrnl_rtl.h b/src/xenia/kernel/xboxkrnl_rtl.h index a5a256ca9..102d5ffb0 100644 --- a/src/xenia/kernel/xboxkrnl_rtl.h +++ b/src/xenia/kernel/xboxkrnl_rtl.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef XENIA_KERNEL_RTL_H_ -#define XENIA_KERNEL_RTL_H_ +#ifndef XENIA_KERNEL_XBOXKRNL_RTL_H_ +#define XENIA_KERNEL_XBOXKRNL_RTL_H_ #include "xenia/xbox.h" @@ -26,4 +26,4 @@ X_STATUS xeRtlInitializeCriticalSectionAndSpinCount(X_RTL_CRITICAL_SECTION* cs, } // namespace kernel } // namespace xe -#endif // XENIA_KERNEL_RTL_H_ +#endif // XENIA_KERNEL_XBOXKRNL_RTL_H_ diff --git a/src/xenia/kernel/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl_threading.cc index ea0c0a966..6917bd9f2 100644 --- a/src/xenia/kernel/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl_threading.cc @@ -441,9 +441,10 @@ DECLARE_XBOXKRNL_EXPORT(KeInitializeEvent, dword_result_t KeSetEvent(pointer_t event_ptr, dword_t increment, dword_t wait) { - // Update dispatch header - xe::atomic_exchange(xe::byte_swap(1), - (uint32_t*)&event_ptr->header.signal_state); + // Update dispatch header. + xe::atomic_exchange( + xe::byte_swap(1), + reinterpret_cast(&event_ptr->header.signal_state)); auto ev = XObject::GetNativeObject(kernel_state(), event_ptr); if (!ev) { @@ -469,8 +470,9 @@ dword_result_t KePulseEvent(pointer_t event_ptr, dword_t increment, DECLARE_XBOXKRNL_EXPORT(KePulseEvent, ExportTag::kImplemented); dword_result_t KeResetEvent(pointer_t event_ptr) { - // Update dispatch header - xe::atomic_exchange(0, (uint32_t*)&event_ptr->header.signal_state); + // Update dispatch header. + xe::atomic_exchange( + 0, reinterpret_cast(&event_ptr->header.signal_state)); auto ev = XObject::GetNativeObject(kernel_state(), event_ptr); if (!ev) { diff --git a/src/xenia/kernel/xboxkrnl_video.cc b/src/xenia/kernel/xboxkrnl_video.cc index bc73b29ce..cd4bce86f 100644 --- a/src/xenia/kernel/xboxkrnl_video.cc +++ b/src/xenia/kernel/xboxkrnl_video.cc @@ -113,7 +113,7 @@ void VdGetCurrentDisplayInformation(pointer_t display_info) { DECLARE_XBOXKRNL_EXPORT(VdGetCurrentDisplayInformation, ExportTag::kVideo); void VdQueryVideoMode(pointer_t video_mode) { - // TODO: get info from actual display + // TODO(benvanik): get info from actual display. video_mode.Zero(); video_mode->display_width = 1280; video_mode->display_height = 720; @@ -273,8 +273,8 @@ struct BufferScaling { xe::be bb_width; xe::be bb_height; }; -void AppendParam(StringBuffer& string_buffer, pointer_t param) { - string_buffer.AppendFormat( +void AppendParam(StringBuffer* string_buffer, pointer_t param) { + string_buffer->AppendFormat( "%.8X(scale %dx%d -> %dx%d))", param.guest_address(), uint16_t(param->bb_width), uint16_t(param->bb_height), uint16_t(param->fb_width), uint16_t(param->fb_height)); diff --git a/src/xenia/kernel/xobject.cc b/src/xenia/kernel/xobject.cc index 1f5272d1d..93e1938fe 100644 --- a/src/xenia/kernel/xobject.cc +++ b/src/xenia/kernel/xobject.cc @@ -9,6 +9,8 @@ #include "xenia/kernel/xobject.h" +#include + #include "xenia/base/clock.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xevent.h" @@ -311,19 +313,19 @@ object_ref XObject::GetNativeObject(KernelState* kernel_state, case 1: // EventSynchronizationObject { auto ev = new XEvent(kernel_state); - ev->InitializeNative(native_ptr, *header); + ev->InitializeNative(native_ptr, header); object = ev; } break; case 2: // MutantObject { auto mutant = new XMutant(kernel_state); - mutant->InitializeNative(native_ptr, *header); + mutant->InitializeNative(native_ptr, header); object = mutant; } break; case 5: // SemaphoreObject { auto sem = new XSemaphore(kernel_state); - sem->InitializeNative(native_ptr, *header); + sem->InitializeNative(native_ptr, header); object = sem; } break; case 3: // ProcessObject diff --git a/src/xenia/kernel/xobject.h b/src/xenia/kernel/xobject.h index b366a4894..4488d5b17 100644 --- a/src/xenia/kernel/xobject.h +++ b/src/xenia/kernel/xobject.h @@ -10,14 +10,16 @@ #ifndef XENIA_KERNEL_XOBJECT_H_ #define XENIA_KERNEL_XOBJECT_H_ +#include #include +#include #include "xenia/base/threading.h" +#include "xenia/memory.h" #include "xenia/xbox.h" namespace xe { class Emulator; -class Memory; } // namespace xe namespace xe { @@ -206,7 +208,8 @@ template class object_ref { public: object_ref() noexcept : value_(nullptr) {} - object_ref(nullptr_t) noexcept : value_(nullptr) {} + object_ref(nullptr_t) noexcept : value_(nullptr) { + } // NOLINT(runtime/explicit) object_ref& operator=(nullptr_t) noexcept { reset(); return (*this); @@ -238,12 +241,12 @@ class object_ref { } object_ref& operator=(const object_ref& right) noexcept { - object_ref(right).swap(*this); + object_ref(right).swap(*this); // NOLINT(runtime/explicit): misrecognized? return (*this); } template object_ref& operator=(const object_ref& right) noexcept { - object_ref(right).swap(*this); + object_ref(right).swap(*this); // NOLINT(runtime/explicit): misrecognized? return (*this); } @@ -296,12 +299,12 @@ class object_ref { template bool operator==(const object_ref<_Ty>& _Left, nullptr_t) noexcept { - return (_Left.get() == (_Ty*)0); + return (_Left.get() == reinterpret_cast<_Ty*>(0)); } template bool operator==(nullptr_t, const object_ref<_Ty>& _Right) noexcept { - return ((_Ty*)0 == _Right.get()); + return (reinterpret_cast<_Ty*>(0) == _Right.get()); } template diff --git a/src/xenia/ui/gl/gl_profiler_display.cc b/src/xenia/ui/gl/gl_profiler_display.cc index 5825247fe..0912a4aad 100644 --- a/src/xenia/ui/gl/gl_profiler_display.cc +++ b/src/xenia/ui/gl/gl_profiler_display.cc @@ -144,51 +144,51 @@ GLProfilerDisplay::GLProfilerDisplay(xe::ui::Window* window) assert_always(); } - window_->on_painted.AddListener([this](UIEvent& e) { Profiler::Present(); }); + window_->on_painted.AddListener([this](UIEvent* e) { Profiler::Present(); }); // Pass through mouse events. - window_->on_mouse_down.AddListener([this](xe::ui::MouseEvent& e) { + window_->on_mouse_down.AddListener([this](MouseEvent* e) { if (Profiler::is_visible()) { - Profiler::OnMouseDown(e.button() == xe::ui::MouseEvent::Button::kLeft, - e.button() == xe::ui::MouseEvent::Button::kRight); - e.set_handled(true); + Profiler::OnMouseDown(e->button() == MouseEvent::Button::kLeft, + e->button() == MouseEvent::Button::kRight); + e->set_handled(true); window_->Invalidate(); } }); - window_->on_mouse_up.AddListener([this](xe::ui::MouseEvent& e) { + window_->on_mouse_up.AddListener([this](MouseEvent* e) { if (Profiler::is_visible()) { Profiler::OnMouseUp(); - e.set_handled(true); + e->set_handled(true); window_->Invalidate(); } }); - window_->on_mouse_move.AddListener([this](xe::ui::MouseEvent& e) { + window_->on_mouse_move.AddListener([this](MouseEvent* e) { if (Profiler::is_visible()) { - Profiler::OnMouseMove(e.x(), e.y()); - e.set_handled(true); + Profiler::OnMouseMove(e->x(), e->y()); + e->set_handled(true); window_->Invalidate(); } }); - window_->on_mouse_wheel.AddListener([this](xe::ui::MouseEvent& e) { + window_->on_mouse_wheel.AddListener([this](MouseEvent* e) { if (Profiler::is_visible()) { - Profiler::OnMouseWheel(e.x(), e.y(), -e.dy()); - e.set_handled(true); + Profiler::OnMouseWheel(e->x(), e->y(), -e->dy()); + e->set_handled(true); window_->Invalidate(); } }); // Watch for toggle/mode keys and such. - window_->on_key_down.AddListener([this](xe::ui::KeyEvent& e) { + window_->on_key_down.AddListener([this](KeyEvent* e) { if (Profiler::is_visible()) { - Profiler::OnKeyDown(e.key_code()); - e.set_handled(true); + Profiler::OnKeyDown(e->key_code()); + e->set_handled(true); window_->Invalidate(); } }); - window_->on_key_up.AddListener([this](xe::ui::KeyEvent& e) { + window_->on_key_up.AddListener([this](KeyEvent* e) { if (Profiler::is_visible()) { - Profiler::OnKeyUp(e.key_code()); - e.set_handled(true); + Profiler::OnKeyUp(e->key_code()); + e->set_handled(true); window_->Invalidate(); } }); diff --git a/src/xenia/ui/loop.h b/src/xenia/ui/loop.h index 4310e1330..67f63ad20 100644 --- a/src/xenia/ui/loop.h +++ b/src/xenia/ui/loop.h @@ -38,7 +38,7 @@ class Loop { virtual void Quit() = 0; virtual void AwaitQuit() = 0; - Delegate on_quit; + Delegate on_quit; }; } // namespace ui diff --git a/src/xenia/ui/loop_win.cc b/src/xenia/ui/loop_win.cc index 0ce1a59d2..e21d61c61 100644 --- a/src/xenia/ui/loop_win.cc +++ b/src/xenia/ui/loop_win.cc @@ -84,7 +84,7 @@ void Win32Loop::ThreadMain() { } UIEvent e(nullptr); - on_quit(e); + on_quit(&e); } void Win32Loop::Post(std::function fn) { diff --git a/src/xenia/ui/menu_item.cc b/src/xenia/ui/menu_item.cc index 630189e1d..da3195105 100644 --- a/src/xenia/ui/menu_item.cc +++ b/src/xenia/ui/menu_item.cc @@ -63,7 +63,7 @@ void MenuItem::RemoveChild(MenuItem* child_item) { MenuItem* MenuItem::child(size_t index) { return children_[index].get(); } -void MenuItem::OnSelected(UIEvent& e) { +void MenuItem::OnSelected(UIEvent* e) { if (callback_) { callback_(); } diff --git a/src/xenia/ui/menu_item.h b/src/xenia/ui/menu_item.h index 5df2c5e00..e1364d6b6 100644 --- a/src/xenia/ui/menu_item.h +++ b/src/xenia/ui/menu_item.h @@ -58,7 +58,7 @@ class MenuItem { virtual void OnChildAdded(MenuItem* child_item) {} virtual void OnChildRemoved(MenuItem* child_item) {} - virtual void OnSelected(UIEvent& e); + virtual void OnSelected(UIEvent* e); Type type_; MenuItem* parent_item_; diff --git a/src/xenia/ui/window.cc b/src/xenia/ui/window.cc index 6e99aabdc..4b9a4e13a 100644 --- a/src/xenia/ui/window.cc +++ b/src/xenia/ui/window.cc @@ -150,9 +150,9 @@ bool Window::MakeReady() { void Window::OnMainMenuChange() {} void Window::OnClose() { - auto e = UIEvent(this); - on_closing(e); - on_closed(e); + UIEvent e(this); + on_closing(&e); + on_closed(&e); } void Window::OnDestroy() { @@ -173,15 +173,15 @@ bool Window::LoadSkin(std::string filename) { } void Window::Layout() { - auto e = UIEvent(this); - OnLayout(e); + UIEvent e(this); + OnLayout(&e); } void Window::Invalidate() {} -void Window::OnResize(UIEvent& e) { on_resize(e); } +void Window::OnResize(UIEvent* e) { on_resize(e); } -void Window::OnLayout(UIEvent& e) { +void Window::OnLayout(UIEvent* e) { on_layout(e); if (!root_element()) { return; @@ -190,7 +190,7 @@ void Window::OnLayout(UIEvent& e) { root_element()->set_rect({0, 0, width(), height()}); } -void Window::OnPaint(UIEvent& e) { +void Window::OnPaint(UIEvent* e) { if (!renderer()) { return; } @@ -260,13 +260,13 @@ void Window::OnPaint(UIEvent& e) { } } -void Window::OnVisible(UIEvent& e) { on_visible(e); } +void Window::OnVisible(UIEvent* e) { on_visible(e); } -void Window::OnHidden(UIEvent& e) { on_hidden(e); } +void Window::OnHidden(UIEvent* e) { on_hidden(e); } -void Window::OnGotFocus(UIEvent& e) { on_got_focus(e); } +void Window::OnGotFocus(UIEvent* e) { on_got_focus(e); } -void Window::OnLostFocus(UIEvent& e) { +void Window::OnLostFocus(UIEvent* e) { modifier_shift_pressed_ = false; modifier_cntrl_pressed_ = false; modifier_alt_pressed_ = false; @@ -292,13 +292,13 @@ el::ModifierKeys Window::GetModifierKeys() { return modifiers; } -void Window::OnKeyPress(KeyEvent& e, bool is_down, bool is_char) { +void Window::OnKeyPress(KeyEvent* e, bool is_down, bool is_char) { if (!root_element()) { return; } auto special_key = el::SpecialKey::kUndefined; if (!is_char) { - switch (e.key_code()) { + switch (e->key_code()) { case 38: special_key = el::SpecialKey::kUp; break; @@ -382,7 +382,7 @@ void Window::OnKeyPress(KeyEvent& e, bool is_down, bool is_char) { el::Event ev(el::EventType::kContextMenu); ev.modifierkeys = GetModifierKeys(); el::Element::focused_element->InvokeEvent(ev); - e.set_handled(true); + e->set_handled(true); return; } break; @@ -405,24 +405,24 @@ void Window::OnKeyPress(KeyEvent& e, bool is_down, bool is_char) { if (!CheckShortcutKey(e, special_key, is_down)) { int key_code = 0; if (is_char) { - key_code = e.key_code(); + key_code = e->key_code(); if (key_code < 32 || (key_code > 126 && key_code < 160)) { key_code = 0; } } - e.set_handled(root_element()->InvokeKey(key_code, special_key, - GetModifierKeys(), is_down)); + e->set_handled(root_element()->InvokeKey(key_code, special_key, + GetModifierKeys(), is_down)); } } -bool Window::CheckShortcutKey(KeyEvent& e, el::SpecialKey special_key, +bool Window::CheckShortcutKey(KeyEvent* e, el::SpecialKey special_key, bool is_down) { bool shortcut_key = modifier_cntrl_pressed_; if (!el::Element::focused_element || !is_down || !shortcut_key) { return false; } bool reverse_key = modifier_shift_pressed_; - int upper_key = e.key_code(); + int upper_key = e->key_code(); if (upper_key >= 'a' && upper_key <= 'z') { upper_key += 'A' - 'a'; } @@ -464,47 +464,47 @@ bool Window::CheckShortcutKey(KeyEvent& e, el::SpecialKey special_key, if (!el::Element::focused_element->InvokeEvent(ev)) { return false; } - e.set_handled(true); + e->set_handled(true); return true; } -void Window::OnKeyDown(KeyEvent& e) { +void Window::OnKeyDown(KeyEvent* e) { on_key_down(e); - if (e.is_handled()) { + if (e->is_handled()) { return; } OnKeyPress(e, true, false); } -void Window::OnKeyUp(KeyEvent& e) { +void Window::OnKeyUp(KeyEvent* e) { on_key_up(e); - if (e.is_handled()) { + if (e->is_handled()) { return; } OnKeyPress(e, false, false); } -void Window::OnKeyChar(KeyEvent& e) { +void Window::OnKeyChar(KeyEvent* e) { OnKeyPress(e, true, true); OnKeyPress(e, false, true); } -void Window::OnMouseDown(MouseEvent& e) { +void Window::OnMouseDown(MouseEvent* e) { on_mouse_down(e); - if (e.is_handled()) { + if (e->is_handled()) { return; } if (!root_element()) { return; } // TODO(benvanik): more button types. - if (e.button() == MouseEvent::Button::kLeft) { + if (e->button() == MouseEvent::Button::kLeft) { // Simulated click count support. // TODO(benvanik): move into Control? uint64_t now = xe::Clock::QueryHostUptimeMillis(); if (now < last_click_time_ + kDoubleClickDelayMillis) { - double distance_moved = std::sqrt(std::pow(e.x() - last_click_x_, 2.0) + - std::pow(e.y() - last_click_y_, 2.0)); + double distance_moved = std::sqrt(std::pow(e->x() - last_click_x_, 2.0) + + std::pow(e->y() - last_click_y_, 2.0)); if (distance_moved < kDoubleClickDistance) { ++last_click_counter_; } else { @@ -513,62 +513,64 @@ void Window::OnMouseDown(MouseEvent& e) { } else { last_click_counter_ = 1; } - last_click_x_ = e.x(); - last_click_y_ = e.y(); + last_click_x_ = e->x(); + last_click_y_ = e->y(); last_click_time_ = now; - e.set_handled(root_element()->InvokePointerDown( - e.x(), e.y(), last_click_counter_, GetModifierKeys(), kTouch)); + e->set_handled(root_element()->InvokePointerDown( + e->x(), e->y(), last_click_counter_, GetModifierKeys(), kTouch)); } } -void Window::OnMouseMove(MouseEvent& e) { +void Window::OnMouseMove(MouseEvent* e) { on_mouse_move(e); - if (e.is_handled()) { + if (e->is_handled()) { return; } if (!root_element()) { return; } - root_element()->InvokePointerMove(e.x(), e.y(), GetModifierKeys(), kTouch); - e.set_handled(true); + root_element()->InvokePointerMove(e->x(), e->y(), GetModifierKeys(), kTouch); + e->set_handled(true); } -void Window::OnMouseUp(MouseEvent& e) { +void Window::OnMouseUp(MouseEvent* e) { on_mouse_up(e); - if (e.is_handled()) { + if (e->is_handled()) { return; } if (!root_element()) { return; } - if (e.button() == MouseEvent::Button::kLeft) { - e.set_handled(root_element()->InvokePointerUp(e.x(), e.y(), - GetModifierKeys(), kTouch)); - } else if (e.button() == MouseEvent::Button::kRight) { - root_element()->InvokePointerMove(e.x(), e.y(), GetModifierKeys(), kTouch); + if (e->button() == MouseEvent::Button::kLeft) { + e->set_handled(root_element()->InvokePointerUp(e->x(), e->y(), + GetModifierKeys(), kTouch)); + } else if (e->button() == MouseEvent::Button::kRight) { + root_element()->InvokePointerMove(e->x(), e->y(), GetModifierKeys(), + kTouch); if (el::Element::hovered_element) { - int x = e.x(); - int y = e.y(); + int x = e->x(); + int y = e->y(); el::Element::hovered_element->ConvertFromRoot(x, y); el::Event ev(el::EventType::kContextMenu, x, y, kTouch, GetModifierKeys()); el::Element::hovered_element->InvokeEvent(ev); } - e.set_handled(true); + e->set_handled(true); } } -void Window::OnMouseWheel(MouseEvent& e) { +void Window::OnMouseWheel(MouseEvent* e) { on_mouse_wheel(e); - if (e.is_handled()) { + if (e->is_handled()) { return; } if (!root_element()) { return; } - e.set_handled(root_element()->InvokeWheel( - e.x(), e.y(), e.dx(), -e.dy() / kMouseWheelDetent, GetModifierKeys())); + e->set_handled(root_element()->InvokeWheel(e->x(), e->y(), e->dx(), + -e->dy() / kMouseWheelDetent, + GetModifierKeys())); } } // namespace ui diff --git a/src/xenia/ui/window.h b/src/xenia/ui/window.h index 1e71e2d9b..e4961c8e2 100644 --- a/src/xenia/ui/window.h +++ b/src/xenia/ui/window.h @@ -87,31 +87,31 @@ class Window { virtual void Close() = 0; public: - Delegate on_closing; - Delegate on_closed; + Delegate on_closing; + Delegate on_closed; Delegate on_command; - Delegate on_resize; - Delegate on_layout; - Delegate on_painting; - Delegate on_paint; - Delegate on_painted; + Delegate on_resize; + Delegate on_layout; + Delegate on_painting; + Delegate on_paint; + Delegate on_painted; - Delegate on_visible; - Delegate on_hidden; + Delegate on_visible; + Delegate on_hidden; - Delegate on_got_focus; - Delegate on_lost_focus; + Delegate on_got_focus; + Delegate on_lost_focus; - Delegate on_key_down; - Delegate on_key_up; - Delegate on_key_char; + Delegate on_key_down; + Delegate on_key_up; + Delegate on_key_char; - Delegate on_mouse_down; - Delegate on_mouse_move; - Delegate on_mouse_up; - Delegate on_mouse_wheel; + Delegate on_mouse_down; + Delegate on_mouse_move; + Delegate on_mouse_up; + Delegate on_mouse_wheel; protected: Window(Loop* loop, const std::wstring& title); @@ -123,28 +123,28 @@ class Window { virtual void OnClose(); virtual void OnDestroy(); - virtual void OnResize(UIEvent& e); - virtual void OnLayout(UIEvent& e); - virtual void OnPaint(UIEvent& e); + virtual void OnResize(UIEvent* e); + virtual void OnLayout(UIEvent* e); + virtual void OnPaint(UIEvent* e); - virtual void OnVisible(UIEvent& e); - virtual void OnHidden(UIEvent& e); + virtual void OnVisible(UIEvent* e); + virtual void OnHidden(UIEvent* e); - virtual void OnGotFocus(UIEvent& e); - virtual void OnLostFocus(UIEvent& e); + virtual void OnGotFocus(UIEvent* e); + virtual void OnLostFocus(UIEvent* e); - virtual void OnKeyDown(KeyEvent& e); - virtual void OnKeyUp(KeyEvent& e); - virtual void OnKeyChar(KeyEvent& e); + virtual void OnKeyDown(KeyEvent* e); + virtual void OnKeyUp(KeyEvent* e); + virtual void OnKeyChar(KeyEvent* e); - virtual void OnMouseDown(MouseEvent& e); - virtual void OnMouseMove(MouseEvent& e); - virtual void OnMouseUp(MouseEvent& e); - virtual void OnMouseWheel(MouseEvent& e); + virtual void OnMouseDown(MouseEvent* e); + virtual void OnMouseMove(MouseEvent* e); + virtual void OnMouseUp(MouseEvent* e); + virtual void OnMouseWheel(MouseEvent* e); el::ModifierKeys GetModifierKeys(); - void OnKeyPress(KeyEvent& e, bool is_down, bool is_char); - bool CheckShortcutKey(KeyEvent& e, el::SpecialKey special_key, bool is_down); + void OnKeyPress(KeyEvent* e, bool is_down, bool is_char); + bool CheckShortcutKey(KeyEvent* e, el::SpecialKey special_key, bool is_down); Loop* loop_ = nullptr; std::unique_ptr main_menu_; diff --git a/src/xenia/ui/window_win.cc b/src/xenia/ui/window_win.cc index c9ae7be4f..57558caf5 100644 --- a/src/xenia/ui/window_win.cc +++ b/src/xenia/ui/window_win.cc @@ -260,7 +260,7 @@ void Win32Window::Resize(int32_t left, int32_t top, int32_t right, TRUE); } -void Win32Window::OnResize(UIEvent& e) { +void Win32Window::OnResize(UIEvent* e) { RECT client_rect; GetClientRect(hwnd_, &client_rect); int32_t width = client_rect.right - client_rect.left; @@ -354,14 +354,14 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, break; case WM_SIZE: { auto e = UIEvent(this); - OnResize(e); + OnResize(&e); break; } case WM_PAINT: { ValidateRect(hwnd_, nullptr); auto e = UIEvent(this); - OnPaint(e); + OnPaint(&e); return 0; // Ignored because of custom paint. break; } @@ -374,10 +374,10 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, case WM_SHOWWINDOW: { if (wParam == TRUE) { auto e = UIEvent(this); - OnVisible(e); + OnVisible(&e); } else { auto e = UIEvent(this); - OnHidden(e); + OnHidden(&e); } break; } @@ -385,13 +385,13 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, case WM_KILLFOCUS: { has_focus_ = false; auto e = UIEvent(this); - OnLostFocus(e); + OnLostFocus(&e); break; } case WM_SETFOCUS: { has_focus_ = true; auto e = UIEvent(this); - OnGotFocus(e); + OnGotFocus(&e); break; } @@ -419,7 +419,7 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, reinterpret_cast(parent_item->child(wParam)); assert_not_null(child_item); UIEvent e(this); - child_item->OnSelected(e); + child_item->OnSelected(&e); } break; } @@ -484,19 +484,19 @@ bool Win32Window::HandleMouse(UINT message, WPARAM wParam, LPARAM lParam) { case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: case WM_XBUTTONDOWN: - OnMouseDown(e); + OnMouseDown(&e); break; case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: case WM_XBUTTONUP: - OnMouseUp(e); + OnMouseUp(&e); break; case WM_MOUSEMOVE: - OnMouseMove(e); + OnMouseMove(&e); break; case WM_MOUSEWHEEL: - OnMouseWheel(e); + OnMouseWheel(&e); break; } return e.is_handled(); @@ -506,13 +506,13 @@ bool Win32Window::HandleKeyboard(UINT message, WPARAM wParam, LPARAM lParam) { auto e = KeyEvent(this, static_cast(wParam)); switch (message) { case WM_KEYDOWN: - OnKeyDown(e); + OnKeyDown(&e); break; case WM_KEYUP: - OnKeyUp(e); + OnKeyUp(&e); break; case WM_CHAR: - OnKeyChar(e); + OnKeyChar(&e); break; } return e.is_handled(); diff --git a/src/xenia/ui/window_win.h b/src/xenia/ui/window_win.h index fa7236eb1..ec2a8a976 100644 --- a/src/xenia/ui/window_win.h +++ b/src/xenia/ui/window_win.h @@ -54,7 +54,7 @@ class Win32Window : public Window { void OnDestroy() override; void OnClose() override; - void OnResize(UIEvent& e) override; + void OnResize(UIEvent* e) override; static LRESULT CALLBACK WndProcThunk(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/third_party/elemental-forms b/third_party/elemental-forms index 54ccef6df..2c5b58821 160000 --- a/third_party/elemental-forms +++ b/third_party/elemental-forms @@ -1 +1 @@ -Subproject commit 54ccef6df50a7d92a1869c6b54ae4b1f57356933 +Subproject commit 2c5b58821f4fd94d890d2d3126bee6169232e52c diff --git a/xenia-build b/xenia-build index e7457f48a..c28e5088f 100755 --- a/xenia-build +++ b/xenia-build @@ -955,23 +955,19 @@ class StyleCommand(Command): *args, **kwargs) def execute(self, args, pass_args, cwd): - all_files = find_all_source_files() + all_files = [file_path for file_path in find_all_source_files() + if not file_path.endswith('_test.cc')] print('- cpplint [%d files]' % (len(all_files))) - any_errors = False - for file_path in all_files: - ret = shell_call([ - 'python', - 'build_tools/third_party/google-styleguide/cpplint/cpplint.py', - '--output=vs7', - '--linelength=80', - '--filter=-build/c++11', - '--root=src', - file_path, - ], throw_on_error=False) - if ret: - any_errors = True + ret = shell_call([ + 'python', + 'build_tools/third_party/google-styleguide/cpplint/cpplint.py', + '--output=vs7', + '--linelength=80', + '--filter=-build/c++11', + '--root=src', + ] + all_files, throw_on_error=False) print('') - if any_errors: + if ret: print('ERROR: 1+ cpplint calls failed.') return 1 else: