本文整理汇总了C++中Memory::SetPPU方法的典型用法代码示例。如果您正苦于以下问题:C++ Memory::SetPPU方法的具体用法?C++ Memory::SetPPU怎么用?C++ Memory::SetPPU使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memory
的用法示例。
在下文中一共展示了Memory::SetPPU方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
// Initialize
Cartridge *cartridge = new Cartridge();
if (cartridge->LoadNESFile("nestest.nes") == false)
{
LOGI("Invalid NES file");
return 1;
}
Mapper *mapper = Mapper::GetMapper(cartridge);
if (mapper == NULL)
{
LOGI("We haven't supported this mapper");
return 1;
}
Memory *memoryPPU = new MemoryPPU();
memoryPPU->SetMapper(mapper);
PPU *ppu = new PPU(memoryPPU);
Memory *memoryCPU = new MemoryCPU();
memoryCPU->SetMapper(mapper);
memoryCPU->SetPPU(ppu);
CPU *cpu = new CPU(memoryCPU);
ppu->SetCPU(cpu);
cpu->PC = 0xC000;
uint32_t count = 0;
unsigned int A, X, Y, P, SP, CYC, SL, PC;
char opcodeName[4];
std::ifstream file("nestest.log");
std::string line;
if (!file.is_open())
{
LOGI("Can't open log file");
return 1;
}
opcodeName[3] = '\0';
while(getline (file, line))
{
++count;
sscanf(line.c_str(), "%x", &PC);
sscanf(&line.c_str()[48], "A:%x X:%x Y:%x P:%x SP:%x CYC:%u SL:%u", &A, &X, &Y, &P, &SP, &CYC, &SL);
opcodeName[0] = line.c_str()[16];
opcodeName[1] = line.c_str()[17];
opcodeName[2] = line.c_str()[18];
if (cpu->A != A || cpu->X != X || cpu->Y != Y || cpu->P.byte != P || cpu->SP != SP || cpu->PC != PC)
{
LOGI("=======================================================");
LOGI("PC: %x A: %x X: %x Y: %x P: %x SP: %x", PC, A, X, Y, P, SP);
LOGI("PC: %x A: %x X: %x Y: %x P: %x SP: %x", cpu->PC, cpu->A, cpu->X, cpu->Y, cpu->P.byte, cpu->SP);
LOGI("%d", count);
getch();
}
if (SL == -1)
{
SL = 261;
}
if (ppu->cycles != CYC || ppu->scanline != SL)
{
LOGI("=======================================================");
LOGI("CYC: %d SL: %d", ppu->cycles, ppu->scanline);
LOGI("CYC: %d SL: %d", CYC, SL);
LOGI("%d", count);
getch();
}
uint8_t cpuCycles = cpu->Step();
uint8_t ppuCycles = cpuCycles * 3;
for (uint8_t i = 0; i < ppuCycles; ++i)
{
ppu->Step();
}
}
LOGI("Done!");
// Deallocate
file.close();
SAFE_DEL(cartridge);
SAFE_DEL(mapper);
SAFE_DEL(memoryPPU);
SAFE_DEL(ppu);
SAFE_DEL(memoryCPU);
SAFE_DEL(cpu);
return 0;
}