Skip to content

Commit

Permalink
Removed deprecated format traits (rust-lang/rust#18904)
Browse files Browse the repository at this point in the history
  • Loading branch information
reima committed Nov 21, 2014
1 parent 68323cf commit 2b18005
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
14 changes: 7 additions & 7 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn disassemble<M: Mem>(mem: &mut M, addr: u16) {
for a in range(start_addr, end_addr) {
print!(" {:02X}", mem.loadb(a));
}
println!("\t{:s}", instr);
println!("\t{}", instr);
}
}

Expand Down Expand Up @@ -60,7 +60,7 @@ fn print_mem<M: Mem>(mem: &mut M, addr: u16) {
}

fn print_regs<M>(cpu: &cpu::Cpu<M>) {
println!("AF={:02X}{:02X} BC={:02X}{:02X} DE={:02X}{:02X} HL={:02X}{:02X} SP={:04X} PC={:04X} CY={:u}",
println!("AF={:02X}{:02X} BC={:02X}{:02X} DE={:02X}{:02X} HL={:02X}{:02X} SP={:04X} PC={:04X} CY={}",
cpu.regs.a, cpu.regs.f,
cpu.regs.b, cpu.regs.c,
cpu.regs.d, cpu.regs.e,
Expand All @@ -83,7 +83,7 @@ fn expand_tile_row(tile: &[u8], palette: u8, row: uint, pixels: &mut [u8]) {
fn write_pgm(path: &Path, width: uint, height: uint, data: &[u8]) -> IoResult<()> {
let mut output = File::create(path).unwrap();
try!(output.write_line("P5"));
try!(output.write_line(format!("{:u} {:u}", width, height).as_slice()));
try!(output.write_line(format!("{} {}", width, height).as_slice()));
try!(output.write_line("3"));
try!(output.write(data));

Expand Down Expand Up @@ -228,7 +228,7 @@ impl Debugger {
if words.len() >= 2 {
match parse_addr(words[1]) {
Some(addr) => print_mem(&mut cpu.mem, addr),
None => error!("Invalid address: {:s}", words[1]),
None => error!("Invalid address: {}", words[1]),
}
}
None
Expand All @@ -238,7 +238,7 @@ impl Debugger {
if words.len() >= 2 {
match parse_addr(words[1]) {
Some(a) => addr = a,
None => error!("Invalid address: {:s}", words[1]),
None => error!("Invalid address: {}", words[1]),
}
}
disassemble(&mut cpu.mem, addr);
Expand All @@ -263,7 +263,7 @@ impl Debugger {
self.remove_breakpoint(addr);
}
},
None => error!("Invalid address: {:s}", words[1]),
None => error!("Invalid address: {}", words[1]),
}
}
None
Expand All @@ -283,7 +283,7 @@ impl Debugger {
None
},
_ => {
error!("Unknown command: {:s}", command);
error!("Unknown command: {}", command);
None
}
}
Expand Down
26 changes: 13 additions & 13 deletions src/disasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ fn cond_to_str(cond: Cond) -> &'static str {
fn with_cond(mnemonic: &str, cond: Cond) -> String {
match cond {
Cond::None => mnemonic.to_string(),
_ => format!("{:s} {:s},", mnemonic, cond_to_str(cond)),
_ => format!("{} {},", mnemonic, cond_to_str(cond)),
}
}

fn unary8(mnemonic: &str, addr: Addr8) -> String {
format!("{:s} {:s}", mnemonic, addr8_to_str(addr))
format!("{} {}", mnemonic, addr8_to_str(addr))
}

fn binary8(mnemonic: &str, addr1: Addr8, addr2: Addr8) -> String {
format!("{:s} {:s}, {:s}", mnemonic, addr8_to_str(addr1), addr8_to_str(addr2))
format!("{} {}, {}", mnemonic, addr8_to_str(addr1), addr8_to_str(addr2))
}

fn unary16(mnemonic: &str, addr: Addr16) -> String {
format!("{:s} {:s}", mnemonic, addr16_to_str(addr))
format!("{} {}", mnemonic, addr16_to_str(addr))
}

fn binary16(mnemonic: &str, addr1: Addr16, addr2: Addr16) -> String {
format!("{:s} {:s}, {:s}", mnemonic, addr16_to_str(addr1), addr16_to_str(addr2))
format!("{} {}, {}", mnemonic, addr16_to_str(addr1), addr16_to_str(addr2))
}

impl<'a, M: mem::Mem> Decoder<String> for Disasm<'a, M> {
Expand All @@ -74,31 +74,31 @@ impl<'a, M: mem::Mem> Decoder<String> for Disasm<'a, M> {
fn di (&mut self) -> String { "DI".to_string() }

fn halt(&mut self) -> String { "HALT".to_string() }
fn stop(&mut self, val: u8) -> String { format!("STOP {:u}", val) }
fn stop(&mut self, val: u8) -> String { format!("STOP {}", val) }

// Jump/call
fn jp (&mut self, cond: Cond, addr: Addr16) -> String { unary16(with_cond("JP", cond).as_slice(), addr) }
fn jr (&mut self, cond: Cond, rel: i8) -> String { format!("{:s} {:d}", with_cond("JR", cond), rel) }
fn jr (&mut self, cond: Cond, rel: i8) -> String { format!("{} {}", with_cond("JR", cond), rel) }

fn call(&mut self, cond: Cond, addr: Addr16) -> String { unary16(with_cond("CALL", cond).as_slice(), addr) }
fn rst (&mut self, addr: u8) -> String { format!("RST ${:02X}", addr) }

fn ret (&mut self, cond: Cond) -> String { format!("RET {:s}", cond_to_str(cond)) }
fn ret (&mut self, cond: Cond) -> String { format!("RET {}", cond_to_str(cond)) }
fn reti(&mut self) -> String { "RETI".to_string() }

// Load/store/move
fn ld8 (&mut self, dst: Addr8, src: Addr8) -> String { binary8 ("LD", dst, src) }
fn ld16(&mut self, dst: Addr16, src: Addr16) -> String { binary16("LD", dst, src) }
fn ldh (&mut self, dst: Addr8, src: Addr8) -> String { binary8 ("LDH", dst, src) }
fn ldhl(&mut self, rel: i8) -> String { format! ("LDHL SP, {:d}", rel) }
fn ldhl(&mut self, rel: i8) -> String { format! ("LDHL SP, {}", rel) }

fn push(&mut self, src: Addr16) -> String { unary16 ("PUSH", src) }
fn pop (&mut self, dst: Addr16) -> String { unary16 ("POP", dst) }

// Arithmetic/logic
fn add8 (&mut self, src: Addr8) -> String { unary8 ("ADD A,", src) }
fn add16(&mut self, dst: Addr16, src: Addr16) -> String { binary16("ADD", dst, src) }
fn addsp(&mut self, rel: i8) -> String { format! ("ADD SP, {:d}", rel) }
fn addsp(&mut self, rel: i8) -> String { format! ("ADD SP, {}", rel) }
fn adc (&mut self, src: Addr8) -> String { unary8 ("ADC A,", src) }

fn sub (&mut self, src: Addr8) -> String { unary8 ("SUB", src) }
Expand Down Expand Up @@ -137,9 +137,9 @@ impl<'a, M: mem::Mem> Decoder<String> for Disasm<'a, M> {
fn sra (&mut self, dst: Addr8) -> String { unary8 ("SRA", dst) }
fn srl (&mut self, dst: Addr8) -> String { unary8 ("SRL", dst) }

fn bit (&mut self, bit: u8, src: Addr8) -> String { format!("BIT {:u}, {:s}", bit, addr8_to_str(src)) }
fn res (&mut self, bit: u8, dst: Addr8) -> String { format!("RES {:u}, {:s}", bit, addr8_to_str(dst)) }
fn set (&mut self, bit: u8, dst: Addr8) -> String { format!("SET {:u}, {:s}", bit, addr8_to_str(dst)) }
fn bit (&mut self, bit: u8, src: Addr8) -> String { format!("BIT {}, {}", bit, addr8_to_str(src)) }
fn res (&mut self, bit: u8, dst: Addr8) -> String { format!("RES {}, {}", bit, addr8_to_str(dst)) }
fn set (&mut self, bit: u8, dst: Addr8) -> String { format!("SET {}, {}", bit, addr8_to_str(dst)) }

fn swap(&mut self, dst: Addr8) -> String { unary8 ("SWAP", dst) }

Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ enum State {
fn main() {
let args = std::os::args();
if args.len() != 2 && !(args.len() == 3 && args[1] == "-d".to_string()) {
println!("Usage: {:s} [-d] rom.gb", args[0]);
println!("Usage: {} [-d] rom.gb", args[0]);
return;
}

Expand All @@ -183,13 +183,13 @@ fn main() {
let mut d = disasm::Disasm { mem: &mut *cart, pc: 0 };
while d.pc <= 0x7fff {
let pc = d.pc;
println!("${:04X}\t{:s}", pc, cpu::decode(&mut d));
println!("${:04X}\t{}", pc, cpu::decode(&mut d));
}
return;
}

println!("Name: {:s}", cart.title);
println!("Type: {:u}", cart.cartridge_type);
println!("Name: {}", cart.title);
println!("Type: {}", cart.cartridge_type);

let memmap = MemMap {
cart: cart,
Expand Down Expand Up @@ -218,7 +218,7 @@ fn main() {
let mut last_fps_update = last_frame_start_count;
let mut frames = 0;

println!("c/s: {:u}; c/f: {:u}", counts_per_sec, counts_per_frame);
println!("c/s: {}; c/f: {}", counts_per_sec, counts_per_frame);

while state != State::Done {
if state == State::Paused || state == State::Step {
Expand Down

0 comments on commit 2b18005

Please sign in to comment.