本文整理汇总了C++中CPU::run_next_instruction方法的典型用法代码示例。如果您正苦于以下问题:C++ CPU::run_next_instruction方法的具体用法?C++ CPU::run_next_instruction怎么用?C++ CPU::run_next_instruction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPU
的用法示例。
在下文中一共展示了CPU::run_next_instruction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
if (argc != 2) {
std::cout << "Usage: nes <iNES ROM file>" << std::endl;
return EXIT_FAILURE;
}
CPU cpu;
std::string filenameIn = argv[1];
std::ifstream in(filenameIn);
std::cout << "Reading header..." << std::endl;
in.seekg(4);
uint8_t PRGROM_size = in.get();
uint8_t CHRROM_size = in.get();
in.seekg(16);
in.read((char*)cpu.memmap+0x8000, 0x4000);
in.read((char*)cpu.memmap+0xC000, 0x4000);
in.close();
cpu.reset();
signal(SIGINT, finish);
initscr();
start_color();
cbreak();
noecho();
init_pair(1, COLOR_BLACK, COLOR_WHITE);
refresh();
WINDOW *mem_win;
mem_win = newwin(23, 32, 0, 0);
box(mem_win, 0, 0);
mvwaddstr(mem_win, 0, 1, "Mem");
// for (uint16_t i=0; i<=20; ++i) {
// uint16_t pc = cpu.PC + i - 10;
// if (pc == cpu.PC) { wattron(mem_win, COLOR_PAIR(1)); }
// mvwprintw(mem_win, i+1, 1, "%04x:\t%02x", pc, cpu.read_mem_val(pc));
// if (pc == cpu.PC) { wattroff(mem_win, COLOR_PAIR(1)); }
// }
// wrefresh(mem_win);
WINDOW *a_win;
a_win = newwin(3, 4, 0, 32);
box(a_win, 0, 0);
mvwaddstr(a_win, 0, 1, "A");
// mvwprintw(a_win, 1, 1, "%02x", cpu.A);
// wrefresh(a_win);
WINDOW *x_win;
x_win = newwin(3, 4, 3, 32);
box(x_win, 0, 0);
mvwaddstr(x_win, 0, 1, "X");
// mvwprintw(x_win, 1, 1, "%02x", cpu.X);
// wrefresh(x_win);
WINDOW *y_win;
y_win = newwin(3, 4, 6, 32);
box(y_win, 0, 0);
mvwaddstr(y_win, 0, 1, "Y");
// mvwprintw(y_win, 1, 1, "%02x", cpu.Y);
// wrefresh(y_win);
WINDOW *p_win;
p_win = newwin(4, 10, 9, 32);
box(p_win, 0, 0);
mvwaddstr(p_win, 0, 1, "P");
// mvwprintw(p_win, 1, 1, std::bitset(cpu.P)"%02x", cpu.P);
// wrefresh(p_win);
WINDOW *sp_win;
sp_win = newwin(3, 4, 13, 32);
box(sp_win, 0, 0);
mvwaddstr(sp_win, 0, 1, "SP");
// mvwprintw(sp_win, 1, 1, "%02x", cpu.SP);
// wrefresh(sp_win);
update_view(cpu, mem_win, a_win, x_win, y_win, p_win, sp_win);
for (;;) {
if (getch() == ' ') {
cpu.run_next_instruction();
update_view(cpu, mem_win, a_win, x_win, y_win, p_win, sp_win);
}
}
finish(EXIT_SUCCESS);
}