with self- modifying code • Easiest Static translation • Translate native code to target • Compile time • Limited use with self-modifying code • Harder Dynamic translation • Like static, but runtime • Capabilities of target used best • Hardest to implement High level emulation • Use native hardware to emulate old API or electronics as soon as possible • Limited use
{ public abstract void Initialize(); public abstract void Reset(); public abstract ulong Execute(int instructionsToExecute); public abstract object SignalInterrupt(InterruptType interrupt, params object[] details); } public byte A; // Accumulator (8 bits) public byte X; // X index register (8 bits) public byte Y; // Y index register (8 bits) public byte SP; // Stack Pointer (8 bits) public byte ProcessorStatus public byte Opcode; // Instruction opcode (8 bits) public ushort Address; // Instruction operand address public byte Data; // Instruction data public ushort PC; // Program Counter (16 bits)
= new byte[dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(250))]; emulator.Mikey.AudioFilter.BufferReady += new EventHandler<BufferEventArgs>(OnAudioFilterBufferReady); dynamicSound.Play(); }
== ButtonState.Pressed) joystick |= JoystickStates.Down; if (gamePad.DPad.Up == ButtonState.Pressed) joystick |= JoystickStates.Up; if (gamePad.DPad.Left == ButtonState.Pressed) joystick |= JoystickStates.Left; if (gamePad.DPad.Right == ButtonState.Pressed) joystick |= JoystickStates.Right; Transfer input device state to emulator core Analog versus digital [Flags] public enum JoystickStates { Up = 0x80, Down = 0x40, Left = 0x20, Right = 0x10 }