From d0674cc98bfa5729168274cde62a4e69343f8524 Mon Sep 17 00:00:00 2001
From: bunnei <ericbunnie@gmail.com>
Date: Tue, 8 Apr 2014 20:38:33 -0400
Subject: [PATCH] fixed licensing and updated code style naming for
 arm_interface/arm_interpreter frontend module

---
 src/core/arm/arm_interface.h                 | 20 +++--
 src/core/arm/interpreter/arm_interpreter.cpp | 93 ++++++++------------
 src/core/arm/interpreter/arm_interpreter.h   | 38 ++------
 3 files changed, 57 insertions(+), 94 deletions(-)

diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h
index e5df2d9710..dafde83682 100644
--- a/src/core/arm/arm_interface.h
+++ b/src/core/arm/arm_interface.h
@@ -11,7 +11,7 @@
 class ARM_Interface {
 public:
     ARM_Interface() {
-        num_instructions_ = 0;
+        m_num_instructions = 0;
     }
 
     ~ARM_Interface() {
@@ -20,7 +20,7 @@ public:
     /// Step CPU by one instruction
     void Step() {
         ExecuteInstruction();
-        num_instructions_++;
+        m_num_instructions++;
     }
  
     /**
@@ -33,36 +33,38 @@ public:
      * Get the current Program Counter
      * @return Returns current PC
      */
-    virtual u32 PC() = 0;
+    virtual u32 GetPC() const = 0;
 
     /**
      * Get an ARM register
      * @param index Register index (0-15)
      * @return Returns the value in the register
      */
-    virtual u32 Reg(int index) = 0;
+    virtual u32 GetReg(int index) const = 0;
 
     /**
      * Get the current CPSR register
      * @return Returns the value of the CPSR register
      */
-    virtual u32 CPSR() = 0;  
+    virtual u32 GetCPSR() const = 0;  
 
     /**
      * Returns the number of clock ticks since the last rese
      * @return Returns number of clock ticks
      */
-    virtual u64 GetTicks() = 0;
+    virtual u64 GetTicks() const = 0;
 
-    /// Getter for num_instructions_
-    u64 num_instructions() { return num_instructions_; }
+    /// Getter for m_num_instructions
+    u64 GetNumInstructions() {
+        return m_num_instructions;
+    }
 
 private:
     
     /// Execture next instruction
     virtual void ExecuteInstruction() = 0;
 
-    u64 num_instructions_;  ///< Number of instructions executed
+    u64 m_num_instructions;                     ///< Number of instructions executed
 
     DISALLOW_COPY_AND_ASSIGN(ARM_Interface);
 };
diff --git a/src/core/arm/interpreter/arm_interpreter.cpp b/src/core/arm/interpreter/arm_interpreter.cpp
index a74aa26cc4..81f38f0169 100644
--- a/src/core/arm/interpreter/arm_interpreter.cpp
+++ b/src/core/arm/interpreter/arm_interpreter.cpp
@@ -1,26 +1,6 @@
-/**
- * Copyright (C) 2013 Citrus Emulator
- *
- * @file    arm_interpreter.h
- * @author  bunnei
- * @date    2014-04-04
- * @brief   ARM interface instance for SkyEye interprerer
- *
- * @section LICENSE
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details at
- * http://www.gnu.org/copyleft/gpl.html
- *
- * Official project repository can be found at:
- * http://code.google.com/p/gekko-gc-emu/
- */
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.  
 
 #include "arm_interpreter.h"
 
@@ -29,58 +9,61 @@ const static cpu_config_t s_arm11_cpu_info = {
 };
 
 ARM_Interpreter::ARM_Interpreter()  {
-
-    state = new ARMul_State;
+    m_state = new ARMul_State;
 
     ARMul_EmulateInit();
-    ARMul_NewState(state);
+    ARMul_NewState(m_state);
 
-    state->abort_model = 0;
-    state->cpu = (cpu_config_t*)&s_arm11_cpu_info;
-    state->bigendSig = LOW;
+    m_state->abort_model = 0;
+    m_state->cpu = (cpu_config_t*)&s_arm11_cpu_info;
+    m_state->bigendSig = LOW;
 
-    ARMul_SelectProcessor(state, ARM_v6_Prop | ARM_v5_Prop | ARM_v5e_Prop);
-    state->lateabtSig = LOW;
-    mmu_init(state);
+    ARMul_SelectProcessor(m_state, ARM_v6_Prop | ARM_v5_Prop | ARM_v5e_Prop);
+    m_state->lateabtSig = LOW;
+    mmu_init(m_state);
 
     // Reset the core to initial state
-    ARMul_Reset(state);
-    state->NextInstr = 0;
-    state->Emulate = 3;
+    ARMul_Reset(m_state);
+    m_state->NextInstr = 0;
+    m_state->Emulate = 3;
 
-    state->pc = state->Reg[15] = 0x00000000;
-    state->Reg[13] = 0x10000000; // Set stack pointer to the top of the stack
+    m_state->pc = m_state->Reg[15] = 0x00000000;
+    m_state->Reg[13] = 0x10000000; // Set stack pointer to the top of the stack
 }
 
 void ARM_Interpreter::SetPC(u32 pc) {
-    state->pc = state->Reg[15] = pc;
+    m_state->pc = m_state->Reg[15] = pc;
 }
 
-u32 ARM_Interpreter::PC() {
-    return state->pc;
+u32 ARM_Interpreter::GetPC() const {
+    return m_state->pc;
 }
 
-u32 ARM_Interpreter::Reg(int index){
-    return state->Reg[index];
+u32 ARM_Interpreter::GetReg(int index) const {
+    return m_state->Reg[index];
 }
 
-u32 ARM_Interpreter::CPSR() {
-    return state->Cpsr;
+u32 ARM_Interpreter::GetCPSR() const {
+    return m_state->Cpsr;
+}
+
+u64 ARM_Interpreter::GetTicks() const {
+    return ARMul_Time(m_state);
 }
 
 ARM_Interpreter::~ARM_Interpreter() {
-    delete state;
+    delete m_state;
 }
 
 void ARM_Interpreter::ExecuteInstruction() {
-    state->step++;
-    state->cycle++;
-    state->EndCondition = 0;
-    state->stop_simulator = 0;
-    state->NextInstr = RESUME;
-    state->last_pc = state->Reg[15];
-    state->Reg[15] = ARMul_DoInstr(state);
-    state->Cpsr = ((state->Cpsr & 0x0fffffdf) | (state->NFlag << 31) | (state->ZFlag << 30) | 
-                   (state->CFlag << 29) | (state->VFlag << 28) | (state->TFlag << 5));
-    FLUSHPIPE;
+    m_state->step++;
+    m_state->cycle++;
+    m_state->EndCondition = 0;
+    m_state->stop_simulator = 0;
+    m_state->NextInstr = RESUME;
+    m_state->last_pc = m_state->Reg[15];
+    m_state->Reg[15] = ARMul_DoInstr(m_state);
+    m_state->Cpsr = ((m_state->Cpsr & 0x0fffffdf) | (m_state->NFlag << 31) | (m_state->ZFlag << 30) | 
+                   (m_state->CFlag << 29) | (m_state->VFlag << 28) | (m_state->TFlag << 5));
+    m_state->NextInstr |= PRIMEPIPE; // Flush pipe
 }
diff --git a/src/core/arm/interpreter/arm_interpreter.h b/src/core/arm/interpreter/arm_interpreter.h
index 03b781c6d3..932046d9a5 100644
--- a/src/core/arm/interpreter/arm_interpreter.h
+++ b/src/core/arm/interpreter/arm_interpreter.h
@@ -1,26 +1,6 @@
-/**
-* Copyright (C) 2013 Citrus Emulator
-*
-* @file    arm_interpreter.h
-* @author  bunnei
-* @date    2014-04-04
-* @brief   ARM interface instance for SkyEye interprerer
-*
-* @section LICENSE
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful, but
-* WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* General Public License for more details at
-* http://www.gnu.org/copyleft/gpl.html
-*
-* Official project repository can be found at:
-* http://code.google.com/p/gekko-gc-emu/
-*/
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.  
 
 #pragma once
 
@@ -39,18 +19,16 @@ public:
 
     void SetPC(u32 pc);
 
-    u32 PC();
+    u32 GetPC() const;
 
-    u32 Reg(int index);
+    u32 GetReg(int index) const;
 
-    u32 CPSR();
+    u32 GetCPSR() const;
 
-    u64 GetTicks() {
-        return ARMul_Time(state);
-    }
+    u64 GetTicks() const;
 
 private:
-    ARMul_State* state;
+    ARMul_State* m_state;
 
     DISALLOW_COPY_AND_ASSIGN(ARM_Interpreter);
 };