override public Boolean Handle(CPUData systemData) { // Sets I to the address NNN. systemData.IndexRegister = (ushort)(mOpCode & 0x0FFF); systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { // Sets I to the location of the sprite for the character in VX. Characters 0-F (in hexadecimal) are represented by a 4x5 font. systemData.IndexRegister = (ushort)(systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] * 0x5); systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { // Sets the sound timer to VX. systemData.SoundTimer = systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8]; systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { // Sets VX to the value of the delay timer. systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] = systemData.DelayTimer; systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { // Draws a sprite at coordinate (VX, VY) that has a width of 8 pixels and a height of N pixels. // Each row of 8 pixels is read as bit-coded starting from memory location I; I value doesn’t change after the execution of this instruction. // As described above, VF is set to 1 if any screen pixels are flipped from set to unset when the sprite is drawn, and to 0 if that doesn’t happen // TODO: Must implement this after I have a solution to drawing return(true); }
override public Boolean Handle(CPUData systemData) { //Sets vX to the value of vY systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] = systemData.CpuRegisters[(mOpCode & 0x00F0) >> 4]; //Jump to next Instr systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { //Returns from a Subroutine, Program Counter should increase systemData.ProgramCounter = systemData.SystemStack.PopStack(); // Increment the program counter (2 bytes per instruction) systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { // TODO: This instruction might be wrong and want vX on 0xF instead of vY and vX shifted into vX // Shifts VY left by one and copies the result to VX. VF is set to the value of the most significant bit of VY before the shift. systemData.CpuRegisters[0xF] = (Byte)(systemData.CpuRegisters[(mOpCode & 0x00F0) >> 4] >> 7); systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] = (Byte)(systemData.CpuRegisters[(mOpCode & 0x00F0) >> 4] << 1); systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { // Shifts VY right by one and stores the result to VX (VY remains unchanged). // VF is set to the value of the least significant bit of VY before the shift systemData.CpuRegisters[0xF] = (Byte)(systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] & 0x1); systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] >>= 1; systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { // Sets VX to the result of a bitwise AND operation on a random number (Typically: 0 to 255) and NN. Random rand = new Random(); systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] = (Byte)((mOpCode & 0x00FF) & rand.Next(0, 255)); systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { //Sets VX to NN systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] = (Byte)(mOpCode & 0x00FF); //Jump to next Instr systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { //Sets VX to VX AND VY. (Bitwise OR operation) systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] = (Byte)(systemData.CpuRegisters[(mOpCode & 0x00F0) >> 4] & systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8]); //Jump to next Instr systemData.ProgramCounter += 2; return(true); }
public static void cpuParser(ManagementObjectSearcher searcher) { CPUList myList = new CPUList(); foreach (ManagementObject queryObj in searcher.Get()) { CPU currentItem = new CPU(queryObj); myList.cpuList.Add(currentItem); } CPUData.EventHandler(myList); }
public override void UpdateData() { //int currentsp = GetCpuClockSpeed(); //int loadPercentage = GetLoadPercentage(); CPUData cpuData = GetCPUData(); if ((cpuData.clockSpeed != -1) && cpuData.load != -1) //((currentsp != -1) && (loadPercentage != -1)) { this.load.Data = ((float)cpuData.load) / 100f; //((float)loadPercentage) / 100f; //values between 0 and 1 this.frequency.Data = ((float)cpuData.clockSpeed) / 1000f; //((float)currentsp) / 1000f; //GHz } }
override public Boolean Handle(CPUData systemData) { // Calls subroutine at NNN //Push current location on stack and jump to NNN if (systemData.SystemStack.PushStack(systemData.ProgramCounter)) { //Jump to NNN systemData.ProgramCounter = (ushort)(mOpCode & 0x0FFF); return(true); } // Stack Overflow, Fail return(false); }
override public Boolean Handle(CPUData systemData) { // Stores the binary-coded decimal representation of VX, with the most significant of three digits at the address in I, // the middle digit at I plus 1, and the least significant digit at I plus 2. // (In other words, take the decimal representation of VX, place the hundreds digit in memory at location in I, // the tens digit at location I+1, and the ones digit at location I+2.) systemData.SystemMemory[systemData.IndexRegister] = (Byte)(systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] / 100); systemData.SystemMemory[systemData.IndexRegister + 1] = (Byte)((systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] / 10) % 10); systemData.SystemMemory[systemData.IndexRegister + 2] = (Byte)((systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] % 100) % 10); systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { // Skips the next instruction if VX doesn't equal VY. (Usually the next instruction is a jump to skip a code block) if (systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] != systemData.CpuRegisters[(mOpCode & 0x00F0)] >> 4) { systemData.ProgramCounter += 4; } else { systemData.ProgramCounter += 2; } return(true); }
override public Boolean Handle(CPUData systemData) { // Fills V0 to VX (including VX) with values from memory starting at address I. I is increased by 1 for each value written. for (int i = 0; i < ((mOpCode & 0x0F00) >> 8); i++) { systemData.CpuRegisters[i] = systemData.SystemMemory[systemData.IndexRegister + i]; } systemData.ProgramCounter += 2; //Move I to the end, not all emulators do this //TODO: maybe remove this systemData.IndexRegister += (ushort)(((mOpCode & 0x0F00) >> 8) + 1); return(true); }
override public Boolean Handle(CPUData systemData) { //Must shift 8 in CpuRegister to make if X instead of X0000000 for the index //Skips the next instruction if vX == NN if (systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] == (mOpCode & 0x00FF)) { //Skip(4 bytes instead of 2) systemData.ProgramCounter += 4; return(true); } //Don't Skipp systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { //Must shift 8 in CpuRegister to make if X instead of X0000000 for the index //Must shift 4 in 2nd CPURegister since we are pull one digit closeer to the right //Skips the next instruction if vX == vY if (systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] == systemData.CpuRegisters[(mOpCode & 0x00F0) >> 4]) { //Skip(4 bytes instead of 2) systemData.ProgramCounter += 4; return(true); } //Don't Skipp systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { // Adds VX to I. // VF is set to 1 when range overflow (I+VX>0xFFF), and 0 when there isn't. if (systemData.IndexRegister + systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] > 0xFFF) { systemData.CpuRegisters[0xF] = 1; } else { systemData.CpuRegisters[0xF] = 0; } //Add.. systemData.IndexRegister += systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8]; systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { // Sets VX to VY minus VX. VF is set to 0 when there's a borrow, and 1 when there isn't. if (systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] > systemData.CpuRegisters[(mOpCode & 0x00F0) >> 4]) { // set the borrow here systemData.CpuRegisters[0xF] = 0; } else { //no borrow, continue on systemData.CpuRegisters[0xF] = 1; } // subtract here systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] = (Byte)(systemData.CpuRegisters[(mOpCode & 0x00F0) >> 4] - systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8]); systemData.ProgramCounter += 2; return(true); }
/// <summary> /// Generates a random CPU item. /// </summary> /// <returns></returns> public CPU LoadSingleItem() { CommonData commonData = new CommonData(); CPUData cpuData = new CPUData(); int brandIndex = Faker.Number.RandomNumber(0, cpuData.Brands.Count); CPU cpu = new CPU(); cpu.Brand = cpuData.Brands[brandIndex]; cpu.Name = cpuData.Names[brandIndex][Faker.Number.RandomNumber(0, cpuData.Names[brandIndex].Count)]; cpu.Description = "Some CPU description"; cpu.Condition = commonData.Conditions[Faker.Number.RandomNumber(0, commonData.Conditions.Length)]; cpu.Stock = Faker.Number.RandomNumber(0, 51); cpu.Price = Faker.Number.RandomNumber(30, 450); cpu.SocketType = cpuData.Sockets[brandIndex][Faker.Number.RandomNumber(0, cpuData.Sockets[brandIndex].Count)]; cpu.CoresAmount = cpuData.CoresAmount[Faker.Number.RandomNumber(0, cpuData.CoresAmount.Length)]; cpu.Frequency = Faker.Number.RandomNumber(1, 5); return(cpu); }
override public Boolean Handle(CPUData systemData) { // VY is subtracted from VX. VF is set to 0 when there's a borrow, and 1 when there isn't if (systemData.CpuRegisters[(mOpCode & 0x00F0) >> 4] > systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8]) { // set the borrow here systemData.CpuRegisters[0xF] = 0; } else { //no borrow, continue on systemData.CpuRegisters[0xF] = 1; } // subtract here systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] -= systemData.CpuRegisters[(mOpCode & 0x00F0) >> 4]; systemData.ProgramCounter += 2; return(true); }
override public Boolean Handle(CPUData systemData) { // Adds VY to VX. VF is set to 1 when there's a carry, and to 0 when there isn't. //0xF(16) - Call location in memory if (systemData.CpuRegisters[(mOpCode & 0x00F0) >> 4] > (0xFF - systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8])) { //Set carry to 1 systemData.CpuRegisters[0xF] = 1; } else { //Set carry to 0 systemData.CpuRegisters[0xF] = 0; } //add the memory locations systemData.CpuRegisters[(mOpCode & 0x0F00) >> 8] += systemData.CpuRegisters[(mOpCode & 0x00F0) >> 4]; systemData.ProgramCounter += 2; return(true); }
private CPUData GetCPUData() { CPUData cpuData = new CPUData(); try { foreach (ManagementObject queryObj in searcher.Get()) { cpuData.clockSpeed = Convert.ToInt32(queryObj["CurrentClockSpeed"]); cpuData.load = Convert.ToInt32(queryObj["LoadPercentage"]); return(cpuData); } } catch (Exception) { cpuData.load = -1; cpuData.clockSpeed = -1; return(cpuData); } cpuData.load = -1; cpuData.clockSpeed = -1; return(cpuData); }
override public Boolean Handle(CPUData systemData) { return(true); }
abstract public Boolean Handle(CPUData systemData);
private void ReportAppPerf() { WebRTC.UpdateCPUUsage(CPUData.GetCPUUsage()); WebRTC.UpdateMemUsage(MEMData.GetMEMUsage()); }
override public Boolean Handle(CPUData systemData) { // the next instruction if the key stored in VX isn't pressed. (Usually the next instruction is a jump to skip a code block) // TODO: comeback to this once input is figured out return(true); }