Beispiel #1
0
int main(int argc, char * argv[]) {
    if (argc < 4) {
	printf("%s mat1 mat2 tmat [seed]\n", argv[0]);
	return -1;
    }
    tinymt32_t tinymt;
    tinymt.mat1 = strtoul(argv[1], NULL, 16);
    tinymt.mat2 = strtoul(argv[2], NULL, 16);
    tinymt.tmat = strtoul(argv[3], NULL, 16);
    int seed = 1;
    uint32_t seed_array[4];

    if (argc >= 5) {
	seed = strtol(argv[4], NULL, 0);
    }
    printf("tinymt32 0x%08"PRIx32, tinymt.mat1);
    printf(" 0x%08"PRIx32, tinymt.mat2);
    printf(" 0x%08"PRIx32, tinymt.tmat);
    for (int n = 0; n < 4; n++) {
        seed_array[n] = seed + n;
    }
    printf(" seed array = [%d, %d, %d, %d]\n", 
        seed_array[0],
        seed_array[1],
        seed_array[2],
        seed_array[3]);
    tinymt32_init_by_array(&tinymt, seed_array, 4);
    state_dump(&tinymt);
    printf("mat1 %u ", tinymt.mat1);
    printf("mat2 %u ", tinymt.mat2);
    printf("tmat %u\n", tinymt.tmat);
    for (int i = 0; i < 10; i++) {
	    printf("%"PRIu32"\n", tinymt32_generate_uint32(&tinymt));
	    state_dump(&tinymt);
    }
}
Beispiel #2
0
Datei: vm.c Projekt: benhardy/vm2
void trace_it(int32_t ip) {
  int opcode = _code[ip];
  state_dump();
  printf("    REGS: ip=%d, sp=%d, fp=%d\n", ip, sp, fp);
  printf("%04x %10s ", ip, instructions[opcode]);
  int arg_count = args[opcode];
  if (arg_count >= 1) {
    printf("%4d", _code[ip+1]);
  } else {
    printf("    ");
  }
  if (arg_count >= 2) {
    printf(", %4d", _code[ip+2]);
  } else {
    printf("      ");
  }
  puts("\n");
}
Beispiel #3
0
static void display(void) {
    Trace::Call *call;

    while ((call = parser.parse_call())) {
        const std::string &name = call->name();

        if ((name[0] == 'w' && name[1] == 'g' && name[2] == 'l') ||
            (name[0] == 'g' && name[1] == 'l' && name[2] == 'X')) {
            // XXX: We ignore the majority of the OS-specific calls for now
            if (name == "glXSwapBuffers" ||
                name == "wglSwapBuffers") {
                if (retrace::verbosity >= 1) {
                    std::cout << *call;
                    std::cout.flush();
                };
                frame_complete();
                if (double_buffer)
                    drawable->swapBuffers();
                else
                    glFlush();
            } else if (name == "glXMakeCurrent" ||
                       name == "wglMakeCurrent") {
                glFlush();
                if (!double_buffer) {
                    frame_complete();
                }
            } else {
                continue;
            }
        }

        if (name == "glFlush") {
            glFlush();
            if (!double_buffer) {
                frame_complete();
            }
        }
        
        retrace::retrace_call(*call);

        if (!insideGlBeginEnd && call->no >= dump_state) {
            state_dump(std::cout);
            exit(0);
        }

        delete call;
    }

    // Reached the end of trace
    glFlush();

    long long endTime = OS::GetTime();
    float timeInterval = (endTime - startTime) * 1.0E-6;

    if (retrace::verbosity >= -1) { 
        std::cout << 
            "Rendered " << frame << " frames"
            " in " <<  timeInterval << " secs,"
            " average of " << (frame/timeInterval) << " fps\n";
    }

    if (wait) {
        while (ws->processEvents()) {}
    } else {
        exit(0);
    }
}