Fix all warnings during build
Ran cargo-fix to automatically fix most of the build warnings, Cleaned up dead code, and fix the rest manually Former-commit-id: f35faba46b40eaf9c047efb8ab1e77ffa24d41b6
This commit is contained in:
parent
0c2da2ae46
commit
b03fe3567e
|
@ -10,7 +10,7 @@ use super::{AluOpCode, ArmCond, ArmHalfwordTransferType};
|
|||
use crate::core::arm7tdmi::*;
|
||||
|
||||
impl fmt::Display for ArmCond {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use ArmCond::*;
|
||||
match self {
|
||||
EQ => write!(f, "eq"),
|
||||
|
@ -33,7 +33,7 @@ impl fmt::Display for ArmCond {
|
|||
}
|
||||
|
||||
impl fmt::Display for AluOpCode {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use AluOpCode::*;
|
||||
match self {
|
||||
AND => write!(f, "and"),
|
||||
|
@ -57,7 +57,7 @@ impl fmt::Display for AluOpCode {
|
|||
}
|
||||
|
||||
impl fmt::Display for BarrelShiftOpCode {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use BarrelShiftOpCode::*;
|
||||
match self {
|
||||
LSL => write!(f, "lsl"),
|
||||
|
@ -69,7 +69,7 @@ impl fmt::Display for BarrelShiftOpCode {
|
|||
}
|
||||
|
||||
impl fmt::Display for ArmHalfwordTransferType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use ArmHalfwordTransferType::*;
|
||||
match self {
|
||||
UnsignedHalfwords => write!(f, "h"),
|
||||
|
@ -87,7 +87,7 @@ fn is_lsl0(shift: &ShiftedRegister) -> bool {
|
|||
}
|
||||
|
||||
impl fmt::Display for ShiftedRegister {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let reg = reg_string(self.reg).to_string();
|
||||
if !is_lsl0(&self) {
|
||||
write!(f, "{}", reg)
|
||||
|
@ -104,11 +104,11 @@ impl fmt::Display for ShiftedRegister {
|
|||
|
||||
#[cfg(feature = "debugger")]
|
||||
impl ArmInstruction {
|
||||
fn fmt_bx(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_bx(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "bx\t{Rn}", Rn = reg_string(self.rn()))
|
||||
}
|
||||
|
||||
fn fmt_branch(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_branch(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"b{link}{cond}\t{ofs:#x}",
|
||||
|
@ -126,7 +126,7 @@ impl ArmInstruction {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_operand2(&self, f: &mut fmt::Formatter) -> Result<Option<u32>, fmt::Error> {
|
||||
fn fmt_operand2(&self, f: &mut fmt::Formatter<'_>) -> Result<Option<u32>, fmt::Error> {
|
||||
let operand2 = self.operand2();
|
||||
match operand2 {
|
||||
BarrelShifterValue::RotatedImmediate(_, _) => {
|
||||
|
@ -142,7 +142,7 @@ impl ArmInstruction {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_data_processing(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_data_processing(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use AluOpCode::*;
|
||||
|
||||
let opcode = self.opcode().unwrap();
|
||||
|
@ -186,7 +186,7 @@ impl ArmInstruction {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_rn_offset(&self, f: &mut fmt::Formatter, offset: BarrelShifterValue) -> fmt::Result {
|
||||
fn fmt_rn_offset(&self, f: &mut fmt::Formatter<'_>, offset: BarrelShifterValue) -> fmt::Result {
|
||||
write!(f, "[{Rn}", Rn = reg_string(self.rn()))?;
|
||||
let (ofs_string, comment) = match offset {
|
||||
BarrelShifterValue::ImmediateValue(value) => {
|
||||
|
@ -224,7 +224,7 @@ impl ArmInstruction {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_ldr_str(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_ldr_str(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{mnem}{B}{T}{cond}\t{Rd}, ",
|
||||
|
@ -242,7 +242,7 @@ impl ArmInstruction {
|
|||
self.fmt_rn_offset(f, self.ldr_str_offset())
|
||||
}
|
||||
|
||||
fn fmt_ldm_stm(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_ldm_stm(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{mnem}{inc_dec}{pre_post}{cond}\t{Rn}{auto_inc}, {{",
|
||||
|
@ -279,7 +279,7 @@ impl ArmInstruction {
|
|||
}
|
||||
|
||||
/// MRS - transfer PSR contents to a register
|
||||
fn fmt_mrs(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_mrs(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"mrs{cond}\t{Rd}, {psr}",
|
||||
|
@ -290,7 +290,7 @@ impl ArmInstruction {
|
|||
}
|
||||
|
||||
/// MSR - transfer register contents to PSR
|
||||
fn fmt_msr_reg(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_msr_reg(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"msr{cond}\t{psr}, {Rm}",
|
||||
|
@ -300,7 +300,7 @@ impl ArmInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_msr_flags(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_msr_flags(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"msr{cond}\t{psr}, ",
|
||||
|
@ -321,7 +321,7 @@ impl ArmInstruction {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn fmt_mul_mla(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_mul_mla(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if self.accumulate_flag() {
|
||||
write!(
|
||||
f,
|
||||
|
@ -354,7 +354,7 @@ impl ArmInstruction {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_mull_mlal(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_mull_mlal(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{sign}{mnem}{S}{cond}\t{RdLo}, {RdHi}, {Rm}, {Rs}",
|
||||
|
@ -373,7 +373,7 @@ impl ArmInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_ldr_str_hs(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_ldr_str_hs(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if let Ok(transfer_type) = self.halfword_data_transfer_type() {
|
||||
write!(
|
||||
f,
|
||||
|
@ -389,7 +389,7 @@ impl ArmInstruction {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_swi(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_swi(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"swi{cond}\t#{comm:#x}",
|
||||
|
@ -398,7 +398,7 @@ impl ArmInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_swp(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_swp(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"swp{B}{cond}\t{Rd}, {Rm}, [{Rn}]",
|
||||
|
@ -413,7 +413,7 @@ impl ArmInstruction {
|
|||
|
||||
#[cfg(feature = "debugger")]
|
||||
impl fmt::Display for ArmInstruction {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use ArmFormat::*;
|
||||
match self.fmt {
|
||||
BX => self.fmt_bx(f),
|
||||
|
|
|
@ -166,7 +166,7 @@ impl Core {
|
|||
|
||||
self.S_cycle32(sb, self.pc);
|
||||
let mut op1 = if insn.rn() == REG_PC {
|
||||
(insn.pc + 8)
|
||||
insn.pc + 8
|
||||
} else {
|
||||
self.get_reg(insn.rn())
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@ pub mod exec;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::alu::*;
|
||||
use crate::core::arm7tdmi::{Addr, InstructionDecoder, InstructionDecoderError};
|
||||
use crate::core::arm7tdmi::{Addr, InstructionDecoder};
|
||||
|
||||
use crate::bit::BitIndex;
|
||||
use crate::byteorder::{LittleEndian, ReadBytesExt};
|
||||
|
@ -214,7 +214,7 @@ impl ArmInstruction {
|
|||
}
|
||||
|
||||
pub fn branch_offset(&self) -> i32 {
|
||||
(((self.raw.bit_range(0..24) << 8) as i32) >> 6)
|
||||
((self.raw.bit_range(0..24) << 8) as i32) >> 6
|
||||
}
|
||||
|
||||
pub fn load_flag(&self) -> bool {
|
||||
|
@ -288,7 +288,7 @@ impl ArmInstruction {
|
|||
let ofs = if self.add_offset_flag() {
|
||||
ofs as u32
|
||||
} else {
|
||||
(-(ofs as i32) as u32)
|
||||
-(ofs as i32) as u32
|
||||
};
|
||||
BarrelShifterValue::ImmediateValue(ofs)
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ use std::fmt;
|
|||
pub use super::exception::Exception;
|
||||
use super::CpuAction;
|
||||
use super::{
|
||||
arm::*, psr::RegPSR, thumb::ThumbInstruction, Addr, CpuMode, CpuResult, CpuState,
|
||||
DecodedInstruction, InstructionDecoder,
|
||||
arm::*, psr::RegPSR, thumb::ThumbInstruction, Addr, CpuMode, CpuState, DecodedInstruction,
|
||||
InstructionDecoder,
|
||||
};
|
||||
|
||||
use crate::core::bus::Bus;
|
||||
|
@ -51,8 +51,6 @@ pub struct Core {
|
|||
pub trace_exceptions: bool,
|
||||
}
|
||||
|
||||
pub type CpuExecResult = CpuResult<()>;
|
||||
|
||||
impl Core {
|
||||
pub fn new() -> Core {
|
||||
let cpsr = RegPSR::new(0x0000_00D3);
|
||||
|
@ -401,7 +399,7 @@ impl Core {
|
|||
|
||||
#[cfg(feature = "debugger")]
|
||||
impl fmt::Display for Core {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
writeln!(f, "ARM7TDMI Core Status:")?;
|
||||
writeln!(f, "\tCycles: {}", self.cycles)?;
|
||||
writeln!(f, "\tCPSR: {}", self.cpsr)?;
|
||||
|
|
|
@ -6,8 +6,8 @@ use serde::{Deserialize, Serialize};
|
|||
pub mod arm;
|
||||
pub mod thumb;
|
||||
|
||||
use arm::{ArmDecodeError, ArmInstruction};
|
||||
use thumb::{ThumbDecodeError, ThumbInstruction};
|
||||
use arm::ArmInstruction;
|
||||
use thumb::ThumbInstruction;
|
||||
|
||||
pub mod cpu;
|
||||
pub use cpu::*;
|
||||
|
@ -45,7 +45,7 @@ impl DecodedInstruction {
|
|||
|
||||
#[cfg(feature = "debugger")]
|
||||
impl fmt::Display for DecodedInstruction {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
DecodedInstruction::Arm(a) => write!(f, "{}", a),
|
||||
DecodedInstruction::Thumb(t) => write!(f, "{}", t),
|
||||
|
@ -53,25 +53,6 @@ impl fmt::Display for DecodedInstruction {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum InstructionDecoderError {
|
||||
ArmDecodeError(ArmDecodeError),
|
||||
ThumbDecodeError(ThumbDecodeError),
|
||||
IoError(std::io::ErrorKind),
|
||||
}
|
||||
|
||||
impl From<ArmDecodeError> for InstructionDecoderError {
|
||||
fn from(e: ArmDecodeError) -> InstructionDecoderError {
|
||||
InstructionDecoderError::ArmDecodeError(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ThumbDecodeError> for InstructionDecoderError {
|
||||
fn from(e: ThumbDecodeError) -> InstructionDecoderError {
|
||||
InstructionDecoderError::ThumbDecodeError(e)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait InstructionDecoder: Sized {
|
||||
type IntType: Num;
|
||||
|
||||
|
@ -97,7 +78,7 @@ pub enum CpuState {
|
|||
}
|
||||
|
||||
impl fmt::Display for CpuState {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use CpuState::*;
|
||||
match self {
|
||||
ARM => write!(f, "ARM"),
|
||||
|
@ -142,7 +123,7 @@ impl CpuMode {
|
|||
}
|
||||
|
||||
impl fmt::Display for CpuMode {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use CpuMode::*;
|
||||
match self {
|
||||
User => write!(f, "USR"),
|
||||
|
@ -155,54 +136,3 @@ impl fmt::Display for CpuMode {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum CpuError {
|
||||
DecodeError(InstructionDecoderError),
|
||||
IllegalInstruction,
|
||||
UnimplementedCpuInstruction(Addr, u32, DecodedInstruction),
|
||||
}
|
||||
|
||||
impl From<InstructionDecoderError> for CpuError {
|
||||
fn from(e: InstructionDecoderError) -> CpuError {
|
||||
CpuError::DecodeError(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ArmDecodeError> for CpuError {
|
||||
fn from(e: ArmDecodeError) -> CpuError {
|
||||
CpuError::DecodeError(InstructionDecoderError::ArmDecodeError(e))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ThumbDecodeError> for CpuError {
|
||||
fn from(e: ThumbDecodeError) -> CpuError {
|
||||
CpuError::DecodeError(InstructionDecoderError::ThumbDecodeError(e))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for CpuError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
CpuError::DecodeError(InstructionDecoderError::ArmDecodeError(e)) => write!(
|
||||
f,
|
||||
"arm decoding error at address @0x{:08x} (instruction 0x{:08x}): {:?}",
|
||||
e.addr, e.insn, e.kind
|
||||
),
|
||||
CpuError::DecodeError(InstructionDecoderError::ThumbDecodeError(e)) => write!(
|
||||
f,
|
||||
"thumb decoding error at address @0x{:08x} (instruction 0x{:08x}): {:?}",
|
||||
e.addr, e.insn, e.kind
|
||||
),
|
||||
CpuError::UnimplementedCpuInstruction(addr, raw, d) => write!(
|
||||
f,
|
||||
"unimplemented instruction: 0x{:08x}:\t0x{:08x}\t{:?}",
|
||||
addr, raw, d
|
||||
),
|
||||
CpuError::IllegalInstruction => write!(f, "illegal instruction"),
|
||||
e => write!(f, "error: {:#x?}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type CpuResult<T> = Result<T, CpuError>;
|
||||
|
|
|
@ -135,7 +135,7 @@ impl RegPSR {
|
|||
}
|
||||
|
||||
impl fmt::Display for RegPSR {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let disabled_string = |disabled: bool| -> ColoredString {
|
||||
if disabled {
|
||||
"disabled".bright_red()
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::core::arm7tdmi::*;
|
|||
|
||||
#[cfg(feature = "debugger")]
|
||||
impl ThumbInstruction {
|
||||
fn fmt_thumb_move_shifted_reg(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_move_shifted_reg(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{op}\t{Rd}, {Rs}, #{Offset5}",
|
||||
|
@ -20,7 +20,7 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_data_process_imm(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_data_process_imm(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{op}\t{Rd}, #{Offset8:#x}",
|
||||
|
@ -30,7 +30,7 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_alu_ops(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_alu_ops(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{op}\t{Rd}, {Rs}",
|
||||
|
@ -40,7 +40,7 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_high_reg_op_or_bx(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_high_reg_op_or_bx(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let op = self.format5_op();
|
||||
let dst_reg = if self.flag(ThumbInstruction::FLAG_H1) {
|
||||
self.rd() + 8
|
||||
|
@ -65,7 +65,7 @@ impl ThumbInstruction {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_thumb_ldr_pc(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_ldr_pc(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"ldr\t{Rd}, [pc, #{Imm:#x}] ; = #{effective:#x}",
|
||||
|
@ -75,7 +75,7 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_ldr_str_reg_offset(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_ldr_str_reg_offset(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{op}{b}\t{Rd}, [{Rb}, {Ro}]",
|
||||
|
@ -91,7 +91,7 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_ldr_str_shb(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_ldr_str_shb(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{op}\t{Rd}, [{Rb}, {Ro}]",
|
||||
|
@ -112,7 +112,7 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_ldr_str_imm_offset(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_ldr_str_imm_offset(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{op}{b}\t{Rd}, [{Rb}, #{imm:#x}]",
|
||||
|
@ -135,7 +135,7 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_ldr_str_halfword(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_ldr_str_halfword(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{op}\t{Rd}, [{Rb}, #{imm:#x}]",
|
||||
|
@ -146,7 +146,7 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_ldr_str_sp(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_ldr_str_sp(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{op}\t{Rd}, [sp, #{Imm:#x}]",
|
||||
|
@ -156,7 +156,7 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_load_address(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_load_address(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"add\t{Rd}, {r}, #{Imm:#x}",
|
||||
|
@ -170,7 +170,7 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_add_sub(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_add_sub(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let operand = if self.is_immediate_operand() {
|
||||
format!("#{:x}", self.raw.bit_range(6..9))
|
||||
} else {
|
||||
|
@ -187,11 +187,11 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_add_sp(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_add_sp(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "add\tsp, #{imm:x}", imm = self.sword7())
|
||||
}
|
||||
|
||||
fn fmt_register_list(&self, f: &mut fmt::Formatter, rlist: u8) -> fmt::Result {
|
||||
fn fmt_register_list(&self, f: &mut fmt::Formatter<'_>, rlist: u8) -> fmt::Result {
|
||||
let mut has_first = false;
|
||||
for i in 0..8 {
|
||||
if rlist.bit(i) {
|
||||
|
@ -206,7 +206,7 @@ impl ThumbInstruction {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn fmt_thumb_push_pop(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_push_pop(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}\t{{", if self.is_load() { "pop" } else { "push" })?;
|
||||
let rlist = self.register_list();
|
||||
self.fmt_register_list(f, rlist)?;
|
||||
|
@ -221,7 +221,7 @@ impl ThumbInstruction {
|
|||
write!(f, "}}")
|
||||
}
|
||||
|
||||
fn fmt_thumb_ldm_stm(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_ldm_stm(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{op}\t{Rb}!, {{",
|
||||
|
@ -232,7 +232,7 @@ impl ThumbInstruction {
|
|||
write!(f, "}}")
|
||||
}
|
||||
|
||||
fn fmt_thumb_branch_with_cond(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_branch_with_cond(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"b{cond}\t{addr:#x}",
|
||||
|
@ -244,11 +244,11 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_swi(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_swi(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "swi\t{value:#x}", value = self.raw & 0xff,)
|
||||
}
|
||||
|
||||
fn fmt_thumb_branch(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_branch(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"b\t{addr:#x}",
|
||||
|
@ -259,7 +259,7 @@ impl ThumbInstruction {
|
|||
)
|
||||
}
|
||||
|
||||
fn fmt_thumb_branch_long_with_link(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt_thumb_branch_long_with_link(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "bl\t#0x{:08x}", {
|
||||
let offset11 = self.offset11();
|
||||
if self.flag(ThumbInstruction::FLAG_LOW_OFFSET) {
|
||||
|
@ -273,7 +273,7 @@ impl ThumbInstruction {
|
|||
|
||||
#[cfg(feature = "debugger")]
|
||||
impl fmt::Display for ThumbInstruction {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.fmt {
|
||||
ThumbFormat::MoveShiftedReg => self.fmt_thumb_move_shifted_reg(f),
|
||||
ThumbFormat::AddSub => self.fmt_thumb_add_sub(f),
|
||||
|
@ -299,7 +299,7 @@ impl fmt::Display for ThumbInstruction {
|
|||
}
|
||||
|
||||
impl fmt::Display for OpFormat3 {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
OpFormat3::MOV => write!(f, "mov"),
|
||||
OpFormat3::CMP => write!(f, "cmp"),
|
||||
|
@ -310,7 +310,7 @@ impl fmt::Display for OpFormat3 {
|
|||
}
|
||||
|
||||
impl fmt::Display for OpFormat5 {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
OpFormat5::ADD => write!(f, "add"),
|
||||
OpFormat5::CMP => write!(f, "cmp"),
|
||||
|
@ -321,7 +321,7 @@ impl fmt::Display for OpFormat5 {
|
|||
}
|
||||
|
||||
impl fmt::Display for ThumbAluOps {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use ThumbAluOps::*;
|
||||
match self {
|
||||
AND => write!(f, "and"),
|
||||
|
|
|
@ -1,40 +1,14 @@
|
|||
use std::io;
|
||||
|
||||
use crate::bit::BitIndex;
|
||||
use crate::byteorder::{LittleEndian, ReadBytesExt};
|
||||
use crate::num::FromPrimitive;
|
||||
|
||||
use super::alu::*;
|
||||
use super::arm::*;
|
||||
use super::{Addr, InstructionDecoder, InstructionDecoderError};
|
||||
use super::{Addr, InstructionDecoder};
|
||||
|
||||
pub mod display;
|
||||
pub mod exec;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum ThumbDecodeErrorKind {
|
||||
UnknownInstructionFormat,
|
||||
IoError(io::ErrorKind),
|
||||
}
|
||||
use ThumbDecodeErrorKind::*;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ThumbDecodeError {
|
||||
pub kind: ThumbDecodeErrorKind,
|
||||
pub insn: u16,
|
||||
pub addr: Addr,
|
||||
}
|
||||
|
||||
impl ThumbDecodeError {
|
||||
fn new(kind: ThumbDecodeErrorKind, insn: u16, addr: Addr) -> ThumbDecodeError {
|
||||
ThumbDecodeError {
|
||||
kind: kind,
|
||||
insn: insn,
|
||||
addr: addr,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq)]
|
||||
pub enum ThumbFormat {
|
||||
/// Format 1
|
||||
|
|
|
@ -46,7 +46,7 @@ impl<'de> Deserialize<'de> for BackupFile {
|
|||
impl<'de> Visitor<'de> for BackupFileVisitor {
|
||||
type Value = BackupFile;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
formatter.write_str("struct BackupFile")
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use super::{BackupFile, BackupMemoryInterface};
|
||||
|
||||
use bytesize;
|
||||
use num::FromPrimitive;
|
||||
use serde::{Deserialize, Serialize};
|
||||
extern crate bytesize;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::fs;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/// Struct containing everything
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
@ -188,7 +187,6 @@ mod tests {
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use super::super::arm7tdmi;
|
||||
use super::super::bus::Bus;
|
||||
use super::super::cartridge::GamepakBuilder;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ impl Default for Scanline {
|
|||
}
|
||||
|
||||
impl fmt::Debug for Scanline {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "...")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::layer::{RenderLayer, RenderLayerKind};
|
||||
use super::layer::RenderLayer;
|
||||
use super::sfx::BldMode;
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::core::Bus;
|
|||
|
||||
impl Gpu {
|
||||
pub(in super::super) fn render_mode3(&mut self, bg: usize) {
|
||||
let y = self.vcount;
|
||||
let _y = self.vcount;
|
||||
|
||||
let pa = self.bg_aff[bg - 2].pa as i32;
|
||||
let pc = self.bg_aff[bg - 2].pc as i32;
|
||||
|
@ -37,7 +37,7 @@ impl Gpu {
|
|||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let y = self.vcount;
|
||||
let _y = self.vcount;
|
||||
|
||||
let pa = self.bg_aff[bg - 2].pa as i32;
|
||||
let pc = self.bg_aff[bg - 2].pc as i32;
|
||||
|
|
|
@ -53,7 +53,7 @@ impl Window {
|
|||
pub fn contains_y(&self, y: usize) -> bool {
|
||||
let top = self.top();
|
||||
let bottom = self.bottom();
|
||||
(y >= top && y < bottom)
|
||||
y >= top && y < bottom
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -371,14 +371,14 @@ pub mod consts {
|
|||
pub const REG_TM2CNT_H: Addr = 0x0400_010A; // 2 R/W Timer 2 Control
|
||||
pub const REG_TM3CNT_L: Addr = 0x0400_010C; // 2 R/W Timer 3 Counter/Reload
|
||||
pub const REG_TM3CNT_H: Addr = 0x0400_010E; // 2 R/W Timer 3 Control
|
||||
pub const REG_SIODATA32: Addr = 0x0400_0120; // 4 R/W SIO Data (Normal-32bit Mode; shared with below)
|
||||
pub const REG_SIOMULTI0: Addr = 0x0400_0120; // 2 R/W SIO Data 0 (Parent) (Multi-Player Mode)
|
||||
pub const REG_SIOMULTI1: Addr = 0x0400_0122; // 2 R/W SIO Data 1 (1st Child) (Multi-Player Mode)
|
||||
pub const REG_SIOMULTI2: Addr = 0x0400_0124; // 2 R/W SIO Data 2 (2nd Child) (Multi-Player Mode)
|
||||
pub const REG_SIOMULTI3: Addr = 0x0400_0126; // 2 R/W SIO Data 3 (3rd Child) (Multi-Player Mode)
|
||||
pub const REG_SIOCNT: Addr = 0x0400_0128; // 2 R/W SIO Control Register
|
||||
pub const REG_SIOMLT_SEND: Addr = 0x0400_012A; // 2 R/W SIO Data (Local of MultiPlayer; shared below)
|
||||
pub const REG_SIODATA8: Addr = 0x0400_012A; // 2 R/W SIO Data (Normal-8bit and UART Mode)
|
||||
// pub const REG_SIODATA32: Addr = 0x0400_0120; // 4 R/W SIO Data (Normal-32bit Mode; shared with below)
|
||||
// pub const REG_SIOMULTI0: Addr = 0x0400_0120; // 2 R/W SIO Data 0 (Parent) (Multi-Player Mode)
|
||||
// pub const REG_SIOMULTI1: Addr = 0x0400_0122; // 2 R/W SIO Data 1 (1st Child) (Multi-Player Mode)
|
||||
// pub const REG_SIOMULTI2: Addr = 0x0400_0124; // 2 R/W SIO Data 2 (2nd Child) (Multi-Player Mode)
|
||||
// pub const REG_SIOMULTI3: Addr = 0x0400_0126; // 2 R/W SIO Data 3 (3rd Child) (Multi-Player Mode)
|
||||
// pub const REG_SIOCNT: Addr = 0x0400_0128; // 2 R/W SIO Control Register
|
||||
// pub const REG_SIOMLT_SEND: Addr = 0x0400_012A; // 2 R/W SIO Data (Local of MultiPlayer; shared below)
|
||||
// pub const REG_SIODATA8: Addr = 0x0400_012A; // 2 R/W SIO Data (Normal-8bit and UART Mode)
|
||||
pub const REG_KEYINPUT: Addr = 0x0400_0130; // 2 R Key Status
|
||||
pub const REG_KEYCNT: Addr = 0x0400_0132; // 2 R/W Key Interrupt Control
|
||||
pub const REG_RCNT: Addr = 0x0400_0134; // 2 R/W SIO Mode Select/General Purpose Data
|
||||
|
@ -479,14 +479,14 @@ pub fn io_reg_string(addr: u32) -> &'static str {
|
|||
REG_TM2CNT_H => "REG_TM2CNT_H",
|
||||
REG_TM3CNT_L => "REG_TM3CNT_L",
|
||||
REG_TM3CNT_H => "REG_TM3CNT_H",
|
||||
REG_SIODATA32 => "REG_SIODATA32",
|
||||
REG_SIOMULTI0 => "REG_SIOMULTI0",
|
||||
REG_SIOMULTI1 => "REG_SIOMULTI1",
|
||||
REG_SIOMULTI2 => "REG_SIOMULTI2",
|
||||
REG_SIOMULTI3 => "REG_SIOMULTI3",
|
||||
REG_SIOCNT => "REG_SIOCNT",
|
||||
REG_SIOMLT_SEND => "REG_SIOMLT_SEND",
|
||||
REG_SIODATA8 => "REG_SIODATA8",
|
||||
// REG_SIODATA32 => "REG_SIODATA32",
|
||||
// REG_SIOMULTI0 => "REG_SIOMULTI0",
|
||||
// REG_SIOMULTI1 => "REG_SIOMULTI1",
|
||||
// REG_SIOMULTI2 => "REG_SIOMULTI2",
|
||||
// REG_SIOMULTI3 => "REG_SIOMULTI3",
|
||||
// REG_SIOCNT => "REG_SIOCNT",
|
||||
// REG_SIOMLT_SEND => "REG_SIOMLT_SEND",
|
||||
// REG_SIODATA8 => "REG_SIODATA8",
|
||||
REG_KEYINPUT => "REG_KEYINPUT",
|
||||
REG_KEYCNT => "REG_KEYCNT",
|
||||
REG_RCNT => "REG_RCNT",
|
||||
|
|
|
@ -29,7 +29,6 @@ use std::fmt;
|
|||
#[derive(Debug)]
|
||||
pub enum GBAError {
|
||||
IO(::std::io::Error),
|
||||
CpuError(arm7tdmi::CpuError),
|
||||
CartridgeLoadError(String),
|
||||
#[cfg(feature = "debugger")]
|
||||
DebuggerError(debugger::DebuggerError),
|
||||
|
@ -55,12 +54,6 @@ impl From<::std::io::Error> for GBAError {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<arm7tdmi::CpuError> for GBAError {
|
||||
fn from(err: arm7tdmi::CpuError) -> GBAError {
|
||||
GBAError::CpuError(err)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "debugger")]
|
||||
impl From<debugger::DebuggerError> for GBAError {
|
||||
fn from(err: debugger::DebuggerError) -> GBAError {
|
||||
|
@ -69,7 +62,7 @@ impl From<debugger::DebuggerError> for GBAError {
|
|||
}
|
||||
|
||||
impl From<zip::result::ZipError> for GBAError {
|
||||
fn from(err: zip::result::ZipError) -> GBAError {
|
||||
fn from(_err: zip::result::ZipError) -> GBAError {
|
||||
GBAError::IO(::std::io::Error::from(::std::io::ErrorKind::InvalidInput))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use super::dma::DmaController;
|
||||
use super::iodev::consts::*;
|
||||
use super::iodev::io_reg_string;
|
||||
|
||||
use crate::{AudioInterface, StereoSample};
|
||||
|
||||
mod fifo;
|
||||
|
@ -62,8 +62,7 @@ type AudioDeviceRcRefCell = Rc<RefCell<dyn AudioInterface>>;
|
|||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct SoundController {
|
||||
sample_rate_to_cpu_freq: usize, // how many "cycles" are a sample?
|
||||
cycles: usize, // cycles count when we last provided a new sample.
|
||||
cycles: usize, // cycles count when we last provided a new sample.
|
||||
|
||||
mse: bool,
|
||||
|
||||
|
@ -105,7 +104,6 @@ impl SoundController {
|
|||
pub fn new(audio_device_sample_rate: f32) -> SoundController {
|
||||
let resampler = CosineResampler::new(32768_f32, audio_device_sample_rate);
|
||||
SoundController {
|
||||
sample_rate_to_cpu_freq: 12345,
|
||||
cycles: 0,
|
||||
mse: false,
|
||||
left_volume: 0,
|
||||
|
@ -294,7 +292,7 @@ impl SoundController {
|
|||
&mut self,
|
||||
dmac: &mut DmaController,
|
||||
timer_id: usize,
|
||||
num_overflows: usize,
|
||||
_num_overflows: usize,
|
||||
) {
|
||||
if !self.mse {
|
||||
return;
|
||||
|
@ -384,9 +382,3 @@ fn cbit(idx: u8, value: bool) -> u16 {
|
|||
fn bit(idx: u8) -> u16 {
|
||||
1 << idx
|
||||
}
|
||||
|
||||
fn rate_to_freq(rate: u16) -> usize {
|
||||
assert!(rate < 2048);
|
||||
|
||||
(2 << 17) as usize / (2048 - rate) as usize
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ pub enum MemoryAccessType {
|
|||
}
|
||||
|
||||
impl fmt::Display for MemoryAccessType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
|
@ -69,7 +69,7 @@ impl Add<MemoryAccessWidth> for MemoryAccessType {
|
|||
pub struct MemoryAccess(pub MemoryAccessType, pub MemoryAccessWidth);
|
||||
|
||||
impl fmt::Display for MemoryAccess {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}-Cycle ({:?})", self.0, self.1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::time;
|
||||
|
||||
use crate::core::arm7tdmi::arm::ArmInstruction;
|
||||
use crate::core::arm7tdmi::thumb::ThumbInstruction;
|
||||
use crate::core::arm7tdmi::CpuState;
|
||||
use crate::core::GBAError;
|
||||
use crate::core::{Addr, Bus};
|
||||
use crate::disass::Disassembler;
|
||||
use crate::util::{read_bin_file, write_bin_file};
|
||||
|
@ -18,7 +15,6 @@ use super::{parser::Value, Debugger, DebuggerError, DebuggerResult};
|
|||
|
||||
use ansi_term::Colour;
|
||||
|
||||
use colored::*;
|
||||
use hexdump;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||
|
@ -70,6 +66,7 @@ pub enum Command {
|
|||
impl Debugger {
|
||||
pub fn run_command(&mut self, command: Command) {
|
||||
use Command::*;
|
||||
#[allow(unreachable_patterns)]
|
||||
match command {
|
||||
Info => {
|
||||
println!("{}", self.gba.cpu);
|
||||
|
@ -124,13 +121,12 @@ impl Debugger {
|
|||
}
|
||||
}
|
||||
Frame(count) => {
|
||||
use super::time::PreciseTime;
|
||||
let start = PreciseTime::now();
|
||||
let start = time::Instant::now();
|
||||
for _ in 0..count {
|
||||
self.gba.frame();
|
||||
}
|
||||
let end = PreciseTime::now();
|
||||
println!("that took {:?} seconds", start.to(end));
|
||||
let end = time::Instant::now();
|
||||
println!("that took {:?} seconds", end - start);
|
||||
}
|
||||
HexDump(addr, nbytes) => {
|
||||
let bytes = self.gba.sysbus.get_bytes(addr..addr + nbytes);
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
extern crate ctrlc;
|
||||
use std::fs::File;
|
||||
use std::io::{prelude::*, BufReader};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
||||
use ctrlc;
|
||||
use rustyline::error::ReadlineError;
|
||||
use rustyline::Editor;
|
||||
|
||||
use colored::*;
|
||||
|
||||
use super::core::arm7tdmi::CpuError;
|
||||
use super::core::GameBoyAdvance;
|
||||
use super::core::{Addr, Bus};
|
||||
|
||||
|
@ -21,24 +20,16 @@ use command::Command;
|
|||
|
||||
mod palette_view;
|
||||
mod tile_view;
|
||||
extern crate time;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum DebuggerError {
|
||||
ParsingError(String),
|
||||
CpuError(CpuError),
|
||||
InvalidCommand(String),
|
||||
InvalidArgument(String),
|
||||
InvalidCommandFormat(String),
|
||||
IoError(::std::io::Error),
|
||||
}
|
||||
|
||||
impl From<CpuError> for DebuggerError {
|
||||
fn from(e: CpuError) -> DebuggerError {
|
||||
DebuggerError::CpuError(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<::std::io::Error> for DebuggerError {
|
||||
fn from(e: ::std::io::Error) -> DebuggerError {
|
||||
DebuggerError::IoError(e)
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use super::core::arm7tdmi::{InstructionDecoder, InstructionDecoderError};
|
||||
use super::core::arm7tdmi::InstructionDecoder;
|
||||
use super::core::Addr;
|
||||
use std::io::ErrorKind;
|
||||
|
||||
pub struct Disassembler<'a, D>
|
||||
where
|
||||
|
@ -20,7 +19,7 @@ impl<'a, D> Disassembler<'a, D>
|
|||
where
|
||||
D: InstructionDecoder,
|
||||
{
|
||||
pub fn new(base: Addr, bytes: &'a [u8]) -> Disassembler<D> {
|
||||
pub fn new(base: Addr, bytes: &'a [u8]) -> Disassembler<'_, D> {
|
||||
Disassembler {
|
||||
base: base as Addr,
|
||||
pos: 0,
|
||||
|
|
24
src/lib.rs
24
src/lib.rs
|
@ -1,41 +1,25 @@
|
|||
#![warn(unused_extern_crates)]
|
||||
#![feature(asm)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(exclusive_range_pattern)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde;
|
||||
extern crate bincode;
|
||||
|
||||
#[macro_use]
|
||||
extern crate debug_stub_derive;
|
||||
|
||||
#[macro_use]
|
||||
extern crate enum_primitive_derive;
|
||||
extern crate num;
|
||||
extern crate num_traits;
|
||||
use num;
|
||||
use num_traits;
|
||||
|
||||
extern crate bit;
|
||||
use bit;
|
||||
#[macro_use]
|
||||
extern crate bitfield;
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
extern crate bit_set;
|
||||
|
||||
extern crate byteorder;
|
||||
|
||||
#[cfg(feature = "debugger")]
|
||||
extern crate rustyline;
|
||||
|
||||
#[cfg(feature = "debugger")]
|
||||
extern crate nom;
|
||||
|
||||
extern crate ansi_term;
|
||||
extern crate colored; // not needed in Rust 2018
|
||||
|
||||
extern crate zip;
|
||||
|
||||
extern crate memmem;
|
||||
use byteorder;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
|
|
@ -13,9 +13,8 @@ use rustboyadvance_ng::core::keypad;
|
|||
use rustboyadvance_ng::prelude::*;
|
||||
use rustboyadvance_ng::util::FpsCounter;
|
||||
|
||||
extern crate bit;
|
||||
use bit::BitIndex;
|
||||
extern crate minifb;
|
||||
use minifb;
|
||||
use minifb::{Key, Window, WindowOptions};
|
||||
|
||||
struct MiniFb {
|
||||
|
|
|
@ -3,7 +3,7 @@ use sdl2::audio::{AudioCallback, AudioDevice, AudioSpec, AudioSpecDesired};
|
|||
|
||||
use rustboyadvance_ng::{AudioInterface, StereoSample};
|
||||
|
||||
extern crate ringbuf;
|
||||
use ringbuf;
|
||||
use ringbuf::{Consumer, Producer, RingBuffer};
|
||||
|
||||
struct GbaAudioCallback {
|
||||
|
|
|
@ -3,7 +3,7 @@ use sdl2::keyboard::Keycode;
|
|||
use rustboyadvance_ng::core::keypad as gba_keypad;
|
||||
use rustboyadvance_ng::InputInterface;
|
||||
|
||||
extern crate bit;
|
||||
use bit;
|
||||
use bit::BitIndex;
|
||||
|
||||
pub struct Sdl2Input {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
extern crate sdl2;
|
||||
use sdl2;
|
||||
use sdl2::event::Event;
|
||||
use sdl2::image::{InitFlag, LoadTexture};
|
||||
use sdl2::keyboard::Keycode;
|
||||
use sdl2::pixels::Color;
|
||||
use sdl2::rect::Rect;
|
||||
|
||||
use sdl2::EventPump;
|
||||
|
||||
extern crate bytesize;
|
||||
extern crate spin_sleep;
|
||||
use bytesize;
|
||||
use spin_sleep;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
@ -24,7 +24,7 @@ extern crate clap;
|
|||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate flexi_logger;
|
||||
use flexi_logger;
|
||||
use flexi_logger::*;
|
||||
|
||||
mod audio;
|
||||
|
@ -35,7 +35,6 @@ use audio::create_audio_player;
|
|||
use input::create_input;
|
||||
use video::{create_video_interface, SCREEN_HEIGHT, SCREEN_WIDTH};
|
||||
|
||||
extern crate rustboyadvance_ng;
|
||||
use rustboyadvance_ng::core::cartridge::BackupType;
|
||||
use rustboyadvance_ng::prelude::*;
|
||||
use rustboyadvance_ng::util::FpsCounter;
|
||||
|
@ -48,7 +47,7 @@ fn get_savestate_path(rom_filename: &Path) -> PathBuf {
|
|||
|
||||
/// Waits for the user to drag a rom file to window
|
||||
fn wait_for_rom(event_pump: &mut EventPump) -> String {
|
||||
'running: loop {
|
||||
loop {
|
||||
for event in event_pump.poll_iter() {
|
||||
match event {
|
||||
Event::DropFile { filename, .. } => {
|
||||
|
@ -62,7 +61,7 @@ fn wait_for_rom(event_pump: &mut EventPump) -> String {
|
|||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
fs::create_dir(LOG_DIR);
|
||||
fs::create_dir(LOG_DIR).expect(&format!("could not create log directory ({})", LOG_DIR));
|
||||
flexi_logger::Logger::with_env_or_str("info")
|
||||
.log_to_file()
|
||||
.directory(LOG_DIR)
|
||||
|
|
|
@ -56,6 +56,7 @@ macro_rules! index2d {
|
|||
};
|
||||
}
|
||||
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! host_breakpoint {
|
||||
() => {
|
||||
#[cfg(debug_assertions)]
|
||||
|
|
Reference in a new issue