Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail -> panic #1

Merged
merged 1 commit into from
Oct 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cartridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Cartridge {
match cartridge_type {
0x00 => None,
0x01 => Some(MBC1),
_ => fail!("unsupported cartridge type: 0x{:02X}", cartridge_type)
_ => panic!("unsupported cartridge type: 0x{:02X}", cartridge_type)
};

let rom_size = header[0x48];
Expand All @@ -48,7 +48,7 @@ impl Cartridge {
0x52 => 72,
0x53 => 80,
0x54 => 96,
_ => fail!("unsupported ROM size: 0x{:02X}", rom_size),
_ => panic!("unsupported ROM size: 0x{:02X}", rom_size),
};
let mut rom_banks = Vec::with_capacity(rom_bank_count);

Expand All @@ -62,7 +62,7 @@ impl Cartridge {

let ram_size = header[0x49];
if ram_size != 0x00 {
fail!("unsupported RAM size: 0x{:02X}", ram_size);
panic!("unsupported RAM size: 0x{:02X}", ram_size);
}

let cart = Cartridge {
Expand Down
12 changes: 6 additions & 6 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl Addr8 {
_ => ()
}
}
_ => fail!("invalid addressing mode for 8-bit store")
_ => panic!("invalid addressing mode for 8-bit store")
}
}
}
Expand Down Expand Up @@ -209,7 +209,7 @@ impl Addr16 {
match *self {
Ind16(addr) => cpu.mem.storew(addr, val),
Reg16Dir(r) => r.store(cpu, val),
_ => fail!("invalid addressing mode for 16-bit store")
_ => panic!("invalid addressing mode for 16-bit store")
}
}
}
Expand Down Expand Up @@ -329,7 +329,7 @@ fn decode_addr(code: u8) -> Addr8 {
0x05 => Reg8Dir(L),
0x06 => Reg16Ind8(HL),
0x07 => Reg8Dir(A),
_ => fail!("logic error"),
_ => panic!("logic error"),
}
}

Expand Down Expand Up @@ -472,7 +472,7 @@ pub fn decode<R, D: Decoder<R>>(d: &mut D) -> R {
d.res((extra >> 3) & 0b111, addr),
0xc0...0xf8 =>
d.set((extra >> 3) & 0b111, addr),
_ => fail!("logic error")
_ => panic!("logic error")
}
}
0xcc => { let imm = fetchw(d); d.call(CondZ, Imm16(imm)) }
Expand Down Expand Up @@ -687,7 +687,7 @@ impl<M: mem::Mem> Decoder<u8> for Cpu<M> {
}

fn stop(&mut self, val: u8) -> u8 {
//fail!("instruction not implemented: stop")
//panic!("instruction not implemented: stop")
4
}

Expand Down Expand Up @@ -1149,6 +1149,6 @@ impl<M: mem::Mem> Decoder<u8> for Cpu<M> {

// Undefined/illegal
fn undef(&mut self, opcode: u8) -> u8 {
fail!("illegal instruction: {:02X}", opcode)
panic!("illegal instruction: {:02X}", opcode)
}
}
4 changes: 2 additions & 2 deletions src/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ impl mem::Mem for InterruptCtrl {
match addr {
0xff0f => self.flag,
0xffff => self.enable,
_ => fail!("invalid interrupt register"),
_ => panic!("invalid interrupt register"),
}
}

fn storeb(&mut self, addr: u16, val: u8) {
match addr {
0xff0f => self.flag = val,
0xffff => self.enable = val,
_ => fail!("invalid interrupt register"),
_ => panic!("invalid interrupt register"),
}
}
}
4 changes: 2 additions & 2 deletions src/joypad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ impl Joypad {
impl mem::Mem for Joypad {
fn loadb(&mut self, addr: u16) -> u8 {
if addr != 0xff00 {
fail!("invalid joypad register");
panic!("invalid joypad register");
}

self.p1
}

fn storeb(&mut self, addr: u16, val: u8) {
if addr != 0xff00 {
fail!("invalid joypad register");
panic!("invalid joypad register");
}

self.p1 = (val & SELECT_MASK) | (self.p1 & !SELECT_MASK);
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ impl VideoOut {
window_height,
sdl2::video::RESIZABLE) {
Ok(renderer) => renderer,
Err(err) => fail!("Failed to create renderer: {}", err)
Err(err) => panic!("Failed to create renderer: {}", err)
};

let texture = match renderer.create_texture(sdl2::pixels::ARGB8888,
sdl2::render::AccessStreaming,
video::SCREEN_WIDTH as int,
video::SCREEN_HEIGHT as int) {
Ok(texture) => texture,
Err(err) => fail!("Failed to create texture: {}", err),
Err(err) => panic!("Failed to create texture: {}", err),
};

VideoOut { renderer: box renderer, texture: box texture }
Expand Down Expand Up @@ -172,7 +172,7 @@ fn main() {

let mut cart = match cartridge::Cartridge::from_path(&Path::new(path.as_slice())) {
Ok(cart) => box cart,
Err(e) => fail!("I/O error: {}", e),
Err(e) => panic!("I/O error: {}", e),
};

if disassemble {
Expand Down
2 changes: 1 addition & 1 deletion src/ram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl WorkRam {
0xc000...0xdfff => addr - 0xc000, // WRAM
0xe000...0xfdff => addr - 0xe000, // WRAM echo
0xff80...0xfffe => addr - 0xff80 + 0x2000, // HRAM
_ => fail!("invalid WRAM address: 0x{:04X}", addr),
_ => panic!("invalid WRAM address: 0x{:04X}", addr),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'a> mem::Mem for SerialIO<'a> {
match addr {
0xff01 => self.data,
0xff02 => self.control,
_ => fail!("invalid serial I/O register"),
_ => panic!("invalid serial I/O register"),
}
}

Expand All @@ -48,7 +48,7 @@ impl<'a> mem::Mem for SerialIO<'a> {
self.control &= !SERIAL_TRANSFER_FLAG;
}
}
_ => fail!("invalid serial I/O register"),
_ => panic!("invalid serial I/O register"),
}
}
}
4 changes: 2 additions & 2 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl mem::Mem for Timer {
0xff05 => self.tima, // TIMA register
0xff06 => self.tma, // TMA register
0xff07 => self.tac, // TAC register
_ => fail!("invalid timer register"),
_ => panic!("invalid timer register"),
}
}

Expand All @@ -77,7 +77,7 @@ impl mem::Mem for Timer {
0xff05 => self.tima = val, // TODO: is this correct?
0xff06 => self.tma = val,
0xff07 => { self.tac = val; self.tima_cycles_mod = 0 },
_ => fail!("invalid timer register"),
_ => panic!("invalid timer register"),
}
}
}
4 changes: 2 additions & 2 deletions src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl mem::Mem for Video {
0xff49 => self.obp1,
0xff4a => self.wy,
0xff4b => self.wx,
_ => fail!("invalid video address: ${:04X}", addr),
_ => panic!("invalid video address: ${:04X}", addr),
}
}

Expand All @@ -384,7 +384,7 @@ impl mem::Mem for Video {
0xff49 => self.obp1 = val,
0xff4a => self.wy = val,
0xff4b => self.wx = val,
_ => fail!("invalid video address: ${:04X}", addr),
_ => panic!("invalid video address: ${:04X}", addr),
}
}
}
Expand Down