本文整理汇总了C++中CPU::cpucycle方法的典型用法代码示例。如果您正苦于以下问题:C++ CPU::cpucycle方法的具体用法?C++ CPU::cpucycle怎么用?C++ CPU::cpucycle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPU
的用法示例。
在下文中一共展示了CPU::cpucycle方法的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;}
//.........这里部分代码省略.........