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


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

本文整理汇总了C++中CPU::resetCPU方法的典型用法代码示例。如果您正苦于以下问题:C++ CPU::resetCPU方法的具体用法?C++ CPU::resetCPU怎么用?C++ CPU::resetCPU使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPU的用法示例。


在下文中一共展示了CPU::resetCPU方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SDL_main

int SDL_main(int argc, char* argv[])
{
    SDL_Init( SDL_INIT_EVERYTHING );
    atexit(SDL_Quit);
    
    std::string romFileName;
    
    if (argc > 1)
    {
        romFileName = std::string(argv[1]);
    }
    
    std::cout << "FireGB Emulator v1.0" << std::endl;
    std::cout << "Usage fgb romName" << std::endl;
    std::cout << "Keys:" << std::endl << "Arrow Keys" << std::endl << "A: Z "<< std::endl << "B: X" << std::endl;
    std::cout << "Start: Enter, A" << std::endl << "Select: Backspace, S" << std::endl;
    std::cout << "Speed Mode: Space Bar" << std::endl;
    std::cout << "Fullscreen: F" << std::endl;
    std::cout << "Scale Screen: 1, 2, 3, 4, 5, 6, 7, 8" << std::endl;
    std::cout << "Mute: m" << std::endl;
    std::cout << "Have fun!" << std::endl;
    
    ourCPU.loadrom(romFileName);
    ourCPU.resetCPU();
    
    ourVideo.startScreen();
    
    std::string windowTitle;
    windowTitle.append("FireGB - ");
    windowTitle.append(romFileName);
    windowTitle.at(windowTitle.size()-3) = '\0';
    
    SDL_SetWindowTitle(ourVideo.screenwindow,windowTitle.c_str());
    
    int running = 1;
    
    ourMenu.load();
    
    while (running)
    {
        currentTick = SDL_GetTicks();
        
        if (ourMemory.ready) //Is a gameboy rom loaded?
        {
            ourCPU.cpucycle(); //Blocks until Gameboy VSync
            ourMemory.saveRAM(); //Create a save file
        }
        else
        {
            ourVideo.vSync(); //cpucycle calls this automatically when a rom is loaded
        }
            
        //Keyboard Input
        SDL_Event event;
        while(SDL_PollEvent(&event))
        {
            // check for messages
            switch (event.type)
            {
                case SDL_QUIT:
                    running = 0;
                    break;
                
                case SDL_MOUSEBUTTONDOWN:
                    ourMenu.mouseClick((SDL_MouseButtonEvent*)&event);
                    break;
                    
                case SDL_KEYDOWN:
                    
                    switch( event.key.keysym.sym )
                {
                        
                    case SDLK_LEFT:
                        ourCPU.keyLeft = 0;
                        ourCPU.stop = 0;
                        if ((ourCPU.keyboardselect&32) != 0) {ourCPU.keyInterrupt = 1;}
                        break;
                        
                    case SDLK_RIGHT:
                        ourCPU.keyRight = 0;
                        ourCPU.stop = 0;
                        if ((ourCPU.keyboardselect&32) != 0) {ourCPU.keyInterrupt = 1;}
                        break;
                        
                    case SDLK_UP:
                        ourCPU.keyUp = 0;
                        ourCPU.stop = 0;
                        if ((ourCPU.keyboardselect&32) != 0) {ourCPU.keyInterrupt = 1;}
                        break;
                        
                    case SDLK_DOWN:
                        ourCPU.keyDown = 0;
                        ourCPU.stop = 0;
                        if ((ourCPU.keyboardselect&32) != 0) {ourCPU.keyInterrupt = 1;}
                        break;
                        
                    case SDLK_x:
                        ourCPU.keyB = 0;
                        ourCPU.stop = 0;
                        if ((ourCPU.keyboardselect&16) != 0) {ourCPU.keyInterrupt = 1;}
//.........这里部分代码省略.........
开发者ID:Frankablu,项目名称:FireGB,代码行数:101,代码来源:main.cpp


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