use crate::verbose_println; use std::ops::{BitAnd, BitOr, BitXor}; use super::{as_signed, res, set, swap_nibbles, CPU, FLAGS}; impl CPU { #[allow(dead_code)] pub fn run_opcode(&mut self, opcode: u8) { match opcode { 0x0 => { // noop } _ => { undefined(opcode); } } } // fn cb_subop(&mut self, subop: u8) { // match subop { // 0x00 => unsafe { self.state.bc.as_u8s.left = self.rlc(self.state.bc.as_u8s.left) }, // 0x01 => unsafe { self.state.bc.as_u8s.right = self.rlc(self.state.bc.as_u8s.right) }, // 0x02 => unsafe { self.state.de.as_u8s.left = self.rlc(self.state.de.as_u8s.left) }, // 0x03 => unsafe { self.state.de.as_u8s.right = self.rlc(self.state.de.as_u8s.right) }, // 0x04 => unsafe { self.state.hl.as_u8s.left = self.rlc(self.state.hl.as_u8s.left) }, // 0x05 => unsafe { self.state.hl.as_u8s.right = self.rlc(self.state.hl.as_u8s.right) }, // 0x06 => unsafe { // let rotated = self.rlc(self.memory.get(self.state.hl.as_u16)); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x07 => unsafe { self.state.af.as_u8s.left = self.rlc(self.state.af.as_u8s.left) }, // 0x08 => unsafe { self.state.bc.as_u8s.left = self.rrc(self.state.bc.as_u8s.left) }, // 0x09 => unsafe { self.state.bc.as_u8s.right = self.rrc(self.state.bc.as_u8s.right) }, // 0x0A => unsafe { self.state.de.as_u8s.left = self.rrc(self.state.de.as_u8s.left) }, // 0x0B => unsafe { self.state.de.as_u8s.right = self.rrc(self.state.de.as_u8s.right) }, // 0x0C => unsafe { self.state.hl.as_u8s.left = self.rrc(self.state.hl.as_u8s.left) }, // 0x0D => unsafe { self.state.hl.as_u8s.right = self.rrc(self.state.hl.as_u8s.right) }, // 0x0E => unsafe { // let rotated = self.rrc(self.memory.get(self.state.hl.as_u16)); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x0F => unsafe { self.state.af.as_u8s.left = self.rrc(self.state.af.as_u8s.left) }, // 0x10 => unsafe { self.state.bc.as_u8s.left = self.rl(self.state.bc.as_u8s.left) }, // 0x11 => unsafe { self.state.bc.as_u8s.right = self.rl(self.state.bc.as_u8s.right) }, // 0x12 => unsafe { self.state.de.as_u8s.left = self.rl(self.state.de.as_u8s.left) }, // 0x13 => unsafe { self.state.de.as_u8s.right = self.rl(self.state.de.as_u8s.right) }, // 0x14 => unsafe { self.state.hl.as_u8s.left = self.rl(self.state.hl.as_u8s.left) }, // 0x15 => unsafe { self.state.hl.as_u8s.right = self.rl(self.state.hl.as_u8s.right) }, // 0x16 => unsafe { // let rotated = self.rl(self.memory.get(self.state.hl.as_u16)); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x17 => unsafe { self.state.af.as_u8s.left = self.rl(self.state.af.as_u8s.left) }, // 0x18 => unsafe { self.state.bc.as_u8s.left = self.rr(self.state.bc.as_u8s.left) }, // 0x19 => unsafe { self.state.bc.as_u8s.right = self.rr(self.state.bc.as_u8s.right) }, // 0x1A => unsafe { self.state.de.as_u8s.left = self.rr(self.state.de.as_u8s.left) }, // 0x1B => unsafe { self.state.de.as_u8s.right = self.rr(self.state.de.as_u8s.right) }, // 0x1C => unsafe { self.state.hl.as_u8s.left = self.rr(self.state.hl.as_u8s.left) }, // 0x1D => unsafe { self.state.hl.as_u8s.right = self.rr(self.state.hl.as_u8s.right) }, // 0x1E => unsafe { // let rotated = self.rr(self.memory.get(self.state.hl.as_u16)); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x1F => unsafe { self.state.af.as_u8s.left = self.rr(self.state.af.as_u8s.left) }, // 0x20 => unsafe { self.state.bc.as_u8s.left = self.sla(self.state.bc.as_u8s.left) }, // 0x21 => unsafe { self.state.bc.as_u8s.right = self.sla(self.state.bc.as_u8s.right) }, // 0x22 => unsafe { self.state.de.as_u8s.left = self.sla(self.state.de.as_u8s.left) }, // 0x23 => unsafe { self.state.de.as_u8s.right = self.sla(self.state.de.as_u8s.right) }, // 0x24 => unsafe { self.state.hl.as_u8s.left = self.sla(self.state.hl.as_u8s.left) }, // 0x25 => unsafe { self.state.hl.as_u8s.right = self.sla(self.state.hl.as_u8s.right) }, // 0x26 => unsafe { // let rotated = self.sla(self.memory.get(self.state.hl.as_u16)); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x27 => unsafe { self.state.af.as_u8s.left = self.sla(self.state.af.as_u8s.left) }, // 0x28 => unsafe { self.state.bc.as_u8s.left = self.sra(self.state.bc.as_u8s.left) }, // 0x29 => unsafe { self.state.bc.as_u8s.right = self.sra(self.state.bc.as_u8s.right) }, // 0x2A => unsafe { self.state.de.as_u8s.left = self.sra(self.state.de.as_u8s.left) }, // 0x2B => unsafe { self.state.de.as_u8s.right = self.sra(self.state.de.as_u8s.right) }, // 0x2C => unsafe { self.state.hl.as_u8s.left = self.sra(self.state.hl.as_u8s.left) }, // 0x2D => unsafe { self.state.hl.as_u8s.right = self.sra(self.state.hl.as_u8s.right) }, // 0x2E => unsafe { // let rotated = self.sra(self.memory.get(self.state.hl.as_u16)); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x2F => unsafe { self.state.af.as_u8s.left = self.sra(self.state.af.as_u8s.left) }, // 0x30 => unsafe { self.state.bc.as_u8s.left = swap_nibbles(self.state.bc.as_u8s.left) }, // 0x31 => unsafe { // self.state.bc.as_u8s.right = swap_nibbles(self.state.bc.as_u8s.right) // }, // 0x32 => unsafe { self.state.de.as_u8s.left = swap_nibbles(self.state.de.as_u8s.left) }, // 0x33 => unsafe { // self.state.de.as_u8s.right = swap_nibbles(self.state.de.as_u8s.right) // }, // 0x34 => unsafe { self.state.hl.as_u8s.left = swap_nibbles(self.state.hl.as_u8s.left) }, // 0x35 => unsafe { // self.state.hl.as_u8s.right = swap_nibbles(self.state.hl.as_u8s.right) // }, // 0x36 => unsafe { // let rotated = swap_nibbles(self.memory.get(self.state.hl.as_u16)); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x37 => unsafe { self.state.af.as_u8s.left = swap_nibbles(self.state.af.as_u8s.left) }, // 0x38 => unsafe { self.state.bc.as_u8s.left = self.srl(self.state.bc.as_u8s.left) }, // 0x39 => unsafe { self.state.bc.as_u8s.right = self.srl(self.state.bc.as_u8s.right) }, // 0x3A => unsafe { self.state.de.as_u8s.left = self.srl(self.state.de.as_u8s.left) }, // 0x3B => unsafe { self.state.de.as_u8s.right = self.srl(self.state.de.as_u8s.right) }, // 0x3C => unsafe { self.state.hl.as_u8s.left = self.srl(self.state.hl.as_u8s.left) }, // 0x3D => unsafe { self.state.hl.as_u8s.right = self.srl(self.state.hl.as_u8s.right) }, // 0x3E => unsafe { // let rotated = self.srl(self.memory.get(self.state.hl.as_u16)); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x3F => unsafe { self.state.af.as_u8s.left = self.srl(self.state.af.as_u8s.left) }, // 0x40 => unsafe { self.bit(self.state.bc.as_u8s.left, 0) }, // 0x41 => unsafe { self.bit(self.state.bc.as_u8s.right, 0) }, // 0x42 => unsafe { self.bit(self.state.de.as_u8s.left, 0) }, // 0x43 => unsafe { self.bit(self.state.de.as_u8s.right, 0) }, // 0x44 => unsafe { self.bit(self.state.hl.as_u8s.left, 0) }, // 0x45 => unsafe { self.bit(self.state.hl.as_u8s.right, 0) }, // 0x46 => unsafe { // self.bit(self.memory.get(self.state.hl.as_u16), 0); // }, // 0x47 => unsafe { self.bit(self.state.af.as_u8s.left, 1) }, // 0x48 => unsafe { self.bit(self.state.bc.as_u8s.left, 1) }, // 0x49 => unsafe { self.bit(self.state.bc.as_u8s.right, 1) }, // 0x4A => unsafe { self.bit(self.state.de.as_u8s.left, 1) }, // 0x4B => unsafe { self.bit(self.state.de.as_u8s.right, 1) }, // 0x4C => unsafe { self.bit(self.state.hl.as_u8s.left, 1) }, // 0x4D => unsafe { self.bit(self.state.hl.as_u8s.right, 1) }, // 0x4E => unsafe { // self.bit(self.memory.get(self.state.hl.as_u16), 1); // }, // 0x4F => unsafe { self.bit(self.state.af.as_u8s.left, 1) }, // 0x50 => unsafe { self.bit(self.state.bc.as_u8s.left, 2) }, // 0x51 => unsafe { self.bit(self.state.bc.as_u8s.right, 2) }, // 0x52 => unsafe { self.bit(self.state.de.as_u8s.left, 2) }, // 0x53 => unsafe { self.bit(self.state.de.as_u8s.right, 2) }, // 0x54 => unsafe { self.bit(self.state.hl.as_u8s.left, 2) }, // 0x55 => unsafe { self.bit(self.state.hl.as_u8s.right, 2) }, // 0x56 => unsafe { // self.bit(self.memory.get(self.state.hl.as_u16), 2); // }, // 0x57 => unsafe { self.bit(self.state.af.as_u8s.left, 3) }, // 0x58 => unsafe { self.bit(self.state.bc.as_u8s.left, 3) }, // 0x59 => unsafe { self.bit(self.state.bc.as_u8s.right, 3) }, // 0x5A => unsafe { self.bit(self.state.de.as_u8s.left, 3) }, // 0x5B => unsafe { self.bit(self.state.de.as_u8s.right, 3) }, // 0x5C => unsafe { self.bit(self.state.hl.as_u8s.left, 3) }, // 0x5D => unsafe { self.bit(self.state.hl.as_u8s.right, 3) }, // 0x5E => unsafe { // self.bit(self.memory.get(self.state.hl.as_u16), 3); // }, // 0x5F => unsafe { self.bit(self.state.af.as_u8s.left, 3) }, // 0x60 => unsafe { self.bit(self.state.bc.as_u8s.left, 4) }, // 0x61 => unsafe { self.bit(self.state.bc.as_u8s.right, 4) }, // 0x62 => unsafe { self.bit(self.state.de.as_u8s.left, 4) }, // 0x63 => unsafe { self.bit(self.state.de.as_u8s.right, 4) }, // 0x64 => unsafe { self.bit(self.state.hl.as_u8s.left, 4) }, // 0x65 => unsafe { self.bit(self.state.hl.as_u8s.right, 4) }, // 0x66 => unsafe { // self.bit(self.memory.get(self.state.hl.as_u16), 4); // }, // 0x67 => unsafe { self.bit(self.state.af.as_u8s.left, 5) }, // 0x68 => unsafe { self.bit(self.state.bc.as_u8s.left, 5) }, // 0x69 => unsafe { self.bit(self.state.bc.as_u8s.right, 5) }, // 0x6A => unsafe { self.bit(self.state.de.as_u8s.left, 5) }, // 0x6B => unsafe { self.bit(self.state.de.as_u8s.right, 5) }, // 0x6C => unsafe { self.bit(self.state.hl.as_u8s.left, 5) }, // 0x6D => unsafe { self.bit(self.state.hl.as_u8s.right, 5) }, // 0x6E => unsafe { // self.bit(self.memory.get(self.state.hl.as_u16), 5); // }, // 0x6F => unsafe { self.bit(self.state.af.as_u8s.left, 5) }, // 0x70 => unsafe { self.bit(self.state.bc.as_u8s.left, 6) }, // 0x71 => unsafe { self.bit(self.state.bc.as_u8s.right, 6) }, // 0x72 => unsafe { self.bit(self.state.de.as_u8s.left, 6) }, // 0x73 => unsafe { self.bit(self.state.de.as_u8s.right, 6) }, // 0x74 => unsafe { self.bit(self.state.hl.as_u8s.left, 6) }, // 0x75 => unsafe { self.bit(self.state.hl.as_u8s.right, 6) }, // 0x76 => unsafe { // self.bit(self.memory.get(self.state.hl.as_u16), 6); // }, // 0x77 => unsafe { self.bit(self.state.af.as_u8s.left, 7) }, // 0x78 => unsafe { self.bit(self.state.bc.as_u8s.left, 7) }, // 0x79 => unsafe { self.bit(self.state.bc.as_u8s.right, 7) }, // 0x7A => unsafe { self.bit(self.state.de.as_u8s.left, 7) }, // 0x7B => unsafe { self.bit(self.state.de.as_u8s.right, 7) }, // 0x7C => unsafe { self.bit(self.state.hl.as_u8s.left, 7) }, // 0x7D => unsafe { self.bit(self.state.hl.as_u8s.right, 7) }, // 0x7E => unsafe { // self.bit(self.memory.get(self.state.hl.as_u16), 7); // }, // 0x7F => unsafe { self.bit(self.state.af.as_u8s.left, 7) }, // 0x80 => unsafe { self.state.bc.as_u8s.left = res(self.state.bc.as_u8s.left, 0) }, // 0x81 => unsafe { self.state.bc.as_u8s.right = res(self.state.bc.as_u8s.right, 0) }, // 0x82 => unsafe { self.state.de.as_u8s.left = res(self.state.de.as_u8s.left, 0) }, // 0x83 => unsafe { self.state.de.as_u8s.right = res(self.state.de.as_u8s.right, 0) }, // 0x84 => unsafe { self.state.hl.as_u8s.left = res(self.state.hl.as_u8s.left, 0) }, // 0x85 => unsafe { self.state.hl.as_u8s.right = res(self.state.hl.as_u8s.right, 0) }, // 0x86 => unsafe { // let rotated = res(self.memory.get(self.state.hl.as_u16), 0); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x87 => unsafe { self.state.af.as_u8s.left = res(self.state.af.as_u8s.left, 0) }, // 0x88 => unsafe { self.state.bc.as_u8s.left = res(self.state.bc.as_u8s.left, 1) }, // 0x89 => unsafe { self.state.bc.as_u8s.right = res(self.state.bc.as_u8s.right, 1) }, // 0x8A => unsafe { self.state.de.as_u8s.left = res(self.state.de.as_u8s.left, 1) }, // 0x8B => unsafe { self.state.de.as_u8s.right = res(self.state.de.as_u8s.right, 1) }, // 0x8C => unsafe { self.state.hl.as_u8s.left = res(self.state.hl.as_u8s.left, 1) }, // 0x8D => unsafe { self.state.hl.as_u8s.right = res(self.state.hl.as_u8s.right, 1) }, // 0x8E => unsafe { // let rotated = res(self.memory.get(self.state.hl.as_u16), 1); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x8F => unsafe { self.state.af.as_u8s.left = res(self.state.af.as_u8s.left, 1) }, // 0x90 => unsafe { self.state.bc.as_u8s.left = res(self.state.bc.as_u8s.left, 2) }, // 0x91 => unsafe { self.state.bc.as_u8s.right = res(self.state.bc.as_u8s.right, 2) }, // 0x92 => unsafe { self.state.de.as_u8s.left = res(self.state.de.as_u8s.left, 2) }, // 0x93 => unsafe { self.state.de.as_u8s.right = res(self.state.de.as_u8s.right, 2) }, // 0x94 => unsafe { self.state.hl.as_u8s.left = res(self.state.hl.as_u8s.left, 2) }, // 0x95 => unsafe { self.state.hl.as_u8s.right = res(self.state.hl.as_u8s.right, 2) }, // 0x96 => unsafe { // let rotated = res(self.memory.get(self.state.hl.as_u16), 2); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x97 => unsafe { self.state.af.as_u8s.left = res(self.state.af.as_u8s.left, 2) }, // 0x98 => unsafe { self.state.bc.as_u8s.left = res(self.state.bc.as_u8s.left, 3) }, // 0x99 => unsafe { self.state.bc.as_u8s.right = res(self.state.bc.as_u8s.right, 3) }, // 0x9A => unsafe { self.state.de.as_u8s.left = res(self.state.de.as_u8s.left, 3) }, // 0x9B => unsafe { self.state.de.as_u8s.right = res(self.state.de.as_u8s.right, 3) }, // 0x9C => unsafe { self.state.hl.as_u8s.left = res(self.state.hl.as_u8s.left, 3) }, // 0x9D => unsafe { self.state.hl.as_u8s.right = res(self.state.hl.as_u8s.right, 3) }, // 0x9E => unsafe { // let rotated = res(self.memory.get(self.state.hl.as_u16), 3); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0x9F => unsafe { self.state.af.as_u8s.left = res(self.state.af.as_u8s.left, 3) }, // 0xA0 => unsafe { self.state.bc.as_u8s.left = res(self.state.bc.as_u8s.left, 4) }, // 0xA1 => unsafe { self.state.bc.as_u8s.right = res(self.state.bc.as_u8s.right, 4) }, // 0xA2 => unsafe { self.state.de.as_u8s.left = res(self.state.de.as_u8s.left, 4) }, // 0xA3 => unsafe { self.state.de.as_u8s.right = res(self.state.de.as_u8s.right, 4) }, // 0xA4 => unsafe { self.state.hl.as_u8s.left = res(self.state.hl.as_u8s.left, 4) }, // 0xA5 => unsafe { self.state.hl.as_u8s.right = res(self.state.hl.as_u8s.right, 4) }, // 0xA6 => unsafe { // let rotated = res(self.memory.get(self.state.hl.as_u16), 4); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xA7 => unsafe { self.state.af.as_u8s.left = res(self.state.af.as_u8s.left, 4) }, // 0xA8 => unsafe { self.state.bc.as_u8s.left = res(self.state.bc.as_u8s.left, 5) }, // 0xA9 => unsafe { self.state.bc.as_u8s.right = res(self.state.bc.as_u8s.right, 5) }, // 0xAA => unsafe { self.state.de.as_u8s.left = res(self.state.de.as_u8s.left, 5) }, // 0xAB => unsafe { self.state.de.as_u8s.right = res(self.state.de.as_u8s.right, 5) }, // 0xAC => unsafe { self.state.hl.as_u8s.left = res(self.state.hl.as_u8s.left, 5) }, // 0xAD => unsafe { self.state.hl.as_u8s.right = res(self.state.hl.as_u8s.right, 5) }, // 0xAE => unsafe { // let rotated = res(self.memory.get(self.state.hl.as_u16), 5); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xAF => unsafe { self.state.af.as_u8s.left = res(self.state.af.as_u8s.left, 5) }, // 0xB0 => unsafe { self.state.bc.as_u8s.left = res(self.state.bc.as_u8s.left, 6) }, // 0xB1 => unsafe { self.state.bc.as_u8s.right = res(self.state.bc.as_u8s.right, 6) }, // 0xB2 => unsafe { self.state.de.as_u8s.left = res(self.state.de.as_u8s.left, 6) }, // 0xB3 => unsafe { self.state.de.as_u8s.right = res(self.state.de.as_u8s.right, 6) }, // 0xB4 => unsafe { self.state.hl.as_u8s.left = res(self.state.hl.as_u8s.left, 6) }, // 0xB5 => unsafe { self.state.hl.as_u8s.right = res(self.state.hl.as_u8s.right, 6) }, // 0xB6 => unsafe { // let rotated = res(self.memory.get(self.state.hl.as_u16), 6); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xB7 => unsafe { self.state.af.as_u8s.left = res(self.state.af.as_u8s.left, 6) }, // 0xB8 => unsafe { self.state.bc.as_u8s.left = res(self.state.bc.as_u8s.left, 7) }, // 0xB9 => unsafe { self.state.bc.as_u8s.right = res(self.state.bc.as_u8s.right, 7) }, // 0xBA => unsafe { self.state.de.as_u8s.left = res(self.state.de.as_u8s.left, 7) }, // 0xBB => unsafe { self.state.de.as_u8s.right = res(self.state.de.as_u8s.right, 7) }, // 0xBC => unsafe { self.state.hl.as_u8s.left = res(self.state.hl.as_u8s.left, 7) }, // 0xBD => unsafe { self.state.hl.as_u8s.right = res(self.state.hl.as_u8s.right, 7) }, // 0xBE => unsafe { // let rotated = res(self.memory.get(self.state.hl.as_u16), 7); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xBF => unsafe { self.state.af.as_u8s.left = res(self.state.af.as_u8s.left, 7) }, // 0xC0 => unsafe { self.state.bc.as_u8s.left = set(self.state.bc.as_u8s.left, 0) }, // 0xC1 => unsafe { self.state.bc.as_u8s.right = set(self.state.bc.as_u8s.right, 0) }, // 0xC2 => unsafe { self.state.de.as_u8s.left = set(self.state.de.as_u8s.left, 0) }, // 0xC3 => unsafe { self.state.de.as_u8s.right = set(self.state.de.as_u8s.right, 0) }, // 0xC4 => unsafe { self.state.hl.as_u8s.left = set(self.state.hl.as_u8s.left, 0) }, // 0xC5 => unsafe { self.state.hl.as_u8s.right = set(self.state.hl.as_u8s.right, 0) }, // 0xC6 => unsafe { // let rotated = set(self.memory.get(self.state.hl.as_u16), 0); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xC7 => unsafe { self.state.af.as_u8s.left = set(self.state.af.as_u8s.left, 0) }, // 0xC8 => unsafe { self.state.bc.as_u8s.left = set(self.state.bc.as_u8s.left, 1) }, // 0xC9 => unsafe { self.state.bc.as_u8s.right = set(self.state.bc.as_u8s.right, 1) }, // 0xCA => unsafe { self.state.de.as_u8s.left = set(self.state.de.as_u8s.left, 1) }, // 0xCB => unsafe { self.state.de.as_u8s.right = set(self.state.de.as_u8s.right, 1) }, // 0xCC => unsafe { self.state.hl.as_u8s.left = set(self.state.hl.as_u8s.left, 1) }, // 0xCD => unsafe { self.state.hl.as_u8s.right = set(self.state.hl.as_u8s.right, 1) }, // 0xCE => unsafe { // let rotated = set(self.memory.get(self.state.hl.as_u16), 1); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xCF => unsafe { self.state.af.as_u8s.left = set(self.state.af.as_u8s.left, 1) }, // 0xD0 => unsafe { self.state.bc.as_u8s.left = set(self.state.bc.as_u8s.left, 2) }, // 0xD1 => unsafe { self.state.bc.as_u8s.right = set(self.state.bc.as_u8s.right, 2) }, // 0xD2 => unsafe { self.state.de.as_u8s.left = set(self.state.de.as_u8s.left, 2) }, // 0xD3 => unsafe { self.state.de.as_u8s.right = set(self.state.de.as_u8s.right, 2) }, // 0xD4 => unsafe { self.state.hl.as_u8s.left = set(self.state.hl.as_u8s.left, 2) }, // 0xD5 => unsafe { self.state.hl.as_u8s.right = set(self.state.hl.as_u8s.right, 2) }, // 0xD6 => unsafe { // let rotated = set(self.memory.get(self.state.hl.as_u16), 2); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xD7 => unsafe { self.state.af.as_u8s.left = set(self.state.af.as_u8s.left, 2) }, // 0xD8 => unsafe { self.state.bc.as_u8s.left = set(self.state.bc.as_u8s.left, 3) }, // 0xD9 => unsafe { self.state.bc.as_u8s.right = set(self.state.bc.as_u8s.right, 3) }, // 0xDA => unsafe { self.state.de.as_u8s.left = set(self.state.de.as_u8s.left, 3) }, // 0xDB => unsafe { self.state.de.as_u8s.right = set(self.state.de.as_u8s.right, 3) }, // 0xDC => unsafe { self.state.hl.as_u8s.left = set(self.state.hl.as_u8s.left, 3) }, // 0xDD => unsafe { self.state.hl.as_u8s.right = set(self.state.hl.as_u8s.right, 3) }, // 0xDE => unsafe { // let rotated = set(self.memory.get(self.state.hl.as_u16), 3); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xDF => unsafe { self.state.af.as_u8s.left = set(self.state.af.as_u8s.left, 3) }, // 0xE0 => unsafe { self.state.bc.as_u8s.left = set(self.state.bc.as_u8s.left, 4) }, // 0xE1 => unsafe { self.state.bc.as_u8s.right = set(self.state.bc.as_u8s.right, 4) }, // 0xE2 => unsafe { self.state.de.as_u8s.left = set(self.state.de.as_u8s.left, 4) }, // 0xE3 => unsafe { self.state.de.as_u8s.right = set(self.state.de.as_u8s.right, 4) }, // 0xE4 => unsafe { self.state.hl.as_u8s.left = set(self.state.hl.as_u8s.left, 4) }, // 0xE5 => unsafe { self.state.hl.as_u8s.right = set(self.state.hl.as_u8s.right, 4) }, // 0xE6 => unsafe { // let rotated = set(self.memory.get(self.state.hl.as_u16), 4); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xE7 => unsafe { self.state.af.as_u8s.left = set(self.state.af.as_u8s.left, 4) }, // 0xE8 => unsafe { self.state.bc.as_u8s.left = set(self.state.bc.as_u8s.left, 5) }, // 0xE9 => unsafe { self.state.bc.as_u8s.right = set(self.state.bc.as_u8s.right, 5) }, // 0xEA => unsafe { self.state.de.as_u8s.left = set(self.state.de.as_u8s.left, 5) }, // 0xEB => unsafe { self.state.de.as_u8s.right = set(self.state.de.as_u8s.right, 5) }, // 0xEC => unsafe { self.state.hl.as_u8s.left = set(self.state.hl.as_u8s.left, 5) }, // 0xED => unsafe { self.state.hl.as_u8s.right = set(self.state.hl.as_u8s.right, 5) }, // 0xEE => unsafe { // let rotated = set(self.memory.get(self.state.hl.as_u16), 5); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xEF => unsafe { self.state.af.as_u8s.left = set(self.state.af.as_u8s.left, 5) }, // 0xF0 => unsafe { self.state.bc.as_u8s.left = set(self.state.bc.as_u8s.left, 6) }, // 0xF1 => unsafe { self.state.bc.as_u8s.right = set(self.state.bc.as_u8s.right, 6) }, // 0xF2 => unsafe { self.state.de.as_u8s.left = set(self.state.de.as_u8s.left, 6) }, // 0xF3 => unsafe { self.state.de.as_u8s.right = set(self.state.de.as_u8s.right, 6) }, // 0xF4 => unsafe { self.state.hl.as_u8s.left = set(self.state.hl.as_u8s.left, 6) }, // 0xF5 => unsafe { self.state.hl.as_u8s.right = set(self.state.hl.as_u8s.right, 6) }, // 0xF6 => unsafe { // let rotated = set(self.memory.get(self.state.hl.as_u16), 6); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xF7 => unsafe { self.state.af.as_u8s.left = set(self.state.af.as_u8s.left, 6) }, // 0xF8 => unsafe { self.state.bc.as_u8s.left = set(self.state.bc.as_u8s.left, 7) }, // 0xF9 => unsafe { self.state.bc.as_u8s.right = set(self.state.bc.as_u8s.right, 7) }, // 0xFA => unsafe { self.state.de.as_u8s.left = set(self.state.de.as_u8s.left, 7) }, // 0xFB => unsafe { self.state.de.as_u8s.right = set(self.state.de.as_u8s.right, 7) }, // 0xFC => unsafe { self.state.hl.as_u8s.left = set(self.state.hl.as_u8s.left, 7) }, // 0xFD => unsafe { self.state.hl.as_u8s.right = set(self.state.hl.as_u8s.right, 7) }, // 0xFE => unsafe { // let rotated = set(self.memory.get(self.state.hl.as_u16), 7); // self.memory.set(self.state.hl.as_u16, rotated) // }, // 0xFF => unsafe { self.state.af.as_u8s.left = set(self.state.af.as_u8s.left, 7) }, // } // } #[allow(dead_code)] fn instruction_length(&self, _opcode: u8) -> u8 { 1 } } fn undefined(opcode: u8) { panic!("Undefined behaviour: opcode {:#X}", opcode); }