当前位置: 首页>>代码示例>>C++>>正文


C++ CPU::run_next_instruction方法代码示例

本文整理汇总了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);
}
开发者ID:ackien,项目名称:nes,代码行数:89,代码来源:nes.cpp


注:本文中的CPU::run_next_instruction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。