1 unstable release
0.1.0 | Feb 19, 2023 |
---|
#221 in Emulators
28KB
422 lines
Chip 8 emulator writen in rust
steps:
- import the chip_8_cpu_emulator.
chip_8_cpu_emulator = "0.0.1"
(or)
chip_8_cpu_emulator = "*"
- then use in your project, by adding
use chip_8_cpu_emulator::cpu::CPU
- configure the cpu and run.
let mut cpu = CPU {
registers: [0; 16],
memory: [0; 0x1000],
pc: 0,
sp: 0,
stack: [0; 16],
i_reg: 0,
};
/* initializing the registers */
cpu.registers[0] = 5;
cpu.registers[1] = 10;
cpu.registers[2] = 10;
cpu.registers[3] = 10;
/* store the program in memory */
cpu.memory[0] = 0x81; cpu.memory[1] = 0x18; // left shift reg_x
cpu.memory[2] = 0x80; cpu.memory[3] = 0x08; // left shift reg_x
cpu.memory[4] = 0x00; cpu.memory[5] = 0x00; // end of the program
- Finally run the cpu with method.
cpu.run();
Dependencies
~310KB