// Exported to the tester app. ANGLE_LIBTESTER_EXPORT int deqp_libtester_main(int argc, const char *argv[]) { if (!InitPlatform(argc, argv)) { tcu::die("Could not initialize the dEQP platform"); } try { de::UniquePtr<tcu::App> app(new tcu::App(*g_platform, *g_archive, *g_log, *g_cmdLine)); // Main loop. for (;;) { if (!app->iterate()) break; } } catch (const std::exception &e) { deqp_libtester_shutdown_platform(); tcu::die("%s", e.what()); } deqp_libtester_shutdown_platform(); return 0; }
ANGLE_LIBTESTER_EXPORT bool deqp_libtester_run(const char *caseName) { const char *emptyString = ""; if (g_platform == nullptr && !InitPlatform(1, &emptyString)) { tcu::die("Failed to initialize platform."); } try { // Poll platform events const bool platformOk = g_platform->processEvents(); if (platformOk) { const tcu::TestStatus &result = g_executor->execute(caseName); switch (result.getCode()) { case QP_TEST_RESULT_PASS: case QP_TEST_RESULT_NOT_SUPPORTED: return true; case QP_TEST_RESULT_QUALITY_WARNING: std::cout << "Quality warning! " << result.getDescription() << std::endl; return true; case QP_TEST_RESULT_COMPATIBILITY_WARNING: std::cout << "Compatiblity warning! " << result.getDescription() << std::endl; return true; default: return false; } } else { std::cout << "Aborted test!" << std::endl; } } catch (const std::exception &e) { std::cout << "Exception running test: " << e.what() << std::endl; } return false; }
int main(int argc, char **argv) { InitPlatform(argc, argv); MIPS_R3000 Cpu; SignalProcessor *SP = new SignalProcessor(); FILE *f = fopen("n64_ipl.bin", "rb"); if (!f) { printf("Could not find n64_ipl.bin\n"); return -1; } fseek(f, 0, SEEK_END); long fsize = ftell(f); fseek(f, 0, SEEK_SET); u8 *BiosBuffer = (u8 *)linearAlloc(0x800); fread(BiosBuffer, fsize, 1, f); fclose(f); memset(BiosBuffer + 0x7C0, 0, 64); u8 *CartBuffer = (u8 *)linearAlloc(0x01000000); z64 Z64Cart; if (!Z64Open(&Z64Cart, Z64_FLAG_MIDDLE_ENDIAN, "cart.v64")) { printf("Couldn't open cart.v64"); return -1; } Z64Read(&Z64Cart, CartBuffer, Z64GetCartSize(&Z64Cart)); Z64Close(&Z64Cart); MapMemoryRegion(&Cpu, (mmm) {linearAlloc(0x400000), 0x00000000, 0x400000, MEM_REGION_RW}); // RDRAM MapMemoryRegion(&Cpu, (mmm) {BiosBuffer, 0x1FC00000, 0x07C0, MEM_REGION_READ}); // PIF ROM MapMemoryRegion(&Cpu, (mmm) {BiosBuffer + 0x7C0, 0x1FC007C0, 64, MEM_REGION_RW}); // PIF RAM MapMemoryRegion(&Cpu, (mmm) {linearAlloc(sizeof(VideoInterface)), 0x04400000, sizeof(VideoInterface), MEM_REGION_RW}); // VI MapMemoryRegion(&Cpu, (mmm) {CartBuffer, 0x10000000, 0x01000000, MEM_REGION_READ}); MapMemoryRegion(&Cpu, (mmm) {SP, 0xA4040000, sizeof(SignalProcessor), MEM_REGION_RW}); MapMemoryRegion(&Cpu, (mmm) {linearAlloc(0x1000), 0xA4000000, 0x1000, MEM_REGION_RW}); // SP_DMEM MapMemoryRegion(&Cpu, (mmm) {linearAlloc(0x1000), 0xA4001000, 0x1000, MEM_REGION_RW}); // SP_IMEM MapMemoryRegion(&Cpu, (mmm) {linearAlloc(sizeof(PeripheralInterface)), 0x4600000, sizeof(PeripheralInterface), MEM_REGION_RW}); WriteMemWordRaw(&Cpu, 0x10000000 + 0x40 + 0x062C, 0); WriteMemWordRaw(&Cpu, 0x10000000 + 0x40 + 0x0638, 0); PIFConfig PIF = {(u8 *)MapVirtualAddress(&Cpu, 0x1FC007C0, MEM_REGION_RW), nullptr, 0}; PIFStartThread(&PIF); VIStartThread(&Cpu, (VideoInterface *)MapVirtualAddress(&Cpu, 0x04400000, MEM_REGION_RW)); PIStartThread(&Cpu, (PeripheralInterface *)MapVirtualAddress(&Cpu, 0x04600000, MEM_REGION_RW)); ResetCpu(&Cpu); bool Step = false; int CyclesToRun = 10000; bool AutoStep = false; u32 IRQ0Steps = 0; if (PlatformHasDebugger()) { CyclesToRun = 1; AutoStep = false; PlatformAttachDebugger(&Cpu); } while (MainLoopPlatform()) { #ifdef _3DS // @TODO this should be moved out to the platform layer until we develop a proper UI and way to exit // u32 KeysDown = hidKeysDown(); // if (KeysDown & KEY_START) // break; #endif if (Step || AutoStep) { Step = false; StepCpu(&Cpu, CyclesToRun); IRQ0Steps += CyclesToRun; // if (IRQ0Steps >= 50000) // { // C0GenerateException(&Cpu, C0_CAUSE_INT, Cpu.pc - 4); // IRQ0Steps = 0; // InterruptMask |= 1; // } } SwapBuffersPlatform(); } PICloseThread(); VICloseThread(); PIFCloseThread(); ExitPlatform(); return 0; }
int main(int argc, char **argv) { InitPlatform(argc, argv); HsfOpen(&HSF, "puzzle.hsf"); MIPS_R3000 Cpu; GPU Gpu; Cpu.CP1 = &Gpu; MapRegister(&Cpu, (mmr) {GPU_GP0, &Gpu, GpuGp0, empty_ret}); MapRegister(&Cpu, (mmr) {GPU_GP1, &Gpu, GpuGp1, GpuStat}); MapRegister(&Cpu, (mmr) {0x1F802064, &Cpu, std_out_putchar, empty_ret}); MapRegister(&Cpu, (mmr) {0x1F802068, &Cpu, CTRXFileOpen, CTRXFileOpenReturn}); MapRegister(&Cpu, (mmr) {0x1F802070, &Cpu, CTRXFileRead, CTRXFileReadReturn}); MapRegister(&Cpu, (mmr) {0x1F802074, &Cpu, CTRXFileSeek, CTRXFileSeekReturn}); MapRegister(&Cpu, (mmr) {0x1F802078, &Cpu, CTRXFirstFile, CTRXFirstFileReturn}); MapRegister(&Cpu, (mmr) {0x1F8010A0, &Cpu, DMA2Trigger, empty_ret}); MapRegister(&Cpu, (mmr) {JOY_TX_DATA, nullptr, JoyTxWrite, JoyRxRead}); MapRegister(&Cpu, (mmr) {0x1F801070, nullptr, empty_write, CTRXInterruptRegisterRead}); MapRegister(&Cpu, (mmr) {0x1F801070, nullptr, CTRXInterruptRegisterWrite, empty_ret}); FILE *f = fopen("psx_bios.bin", "rb"); fseek(f, 0, SEEK_END); long fsize = ftell(f); fseek(f, 0, SEEK_SET); u8 *BiosBuffer = (u8 *)linearAlloc(fsize + 1); fread(BiosBuffer, fsize, 1, f); fclose(f); for (int i = 0; i < fsize; ++i) { WriteMemByteRaw(&Cpu, RESET_VECTOR + i, BiosBuffer[i]); } linearFree(BiosBuffer); ResetCpu(&Cpu); bool Step = false; int CyclesToRun = 10000; bool EnableDisassembler = false; bool AutoStep = true; u32 IRQ0Steps = 0; while (MainLoopPlatform()) { #ifdef _3DS u32 KeysDown = hidKeysDown(); if (KeysDown & KEY_START) break; #endif if (Step || AutoStep) { StepCpu(&Cpu, CyclesToRun); IRQ0Steps += CyclesToRun; if (IRQ0Steps >= 50000) { C0GenerateException(&Cpu, C0_CAUSE_INT, Cpu.pc - 4); IRQ0Steps = 0; InterruptMask |= 1; } } if (EnableDisassembler) { printf("\x1b[0;0H"); DisassemblerPrintRange(&Cpu, Cpu.pc - (13 * 4), 29, Cpu.pc); } SwapBuffersPlatform(); } HsfClose(&HSF); ExitPlatform(); return 0; }