6 static inline unsigned int pcnt_get(void)
10 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(val));
17 static inline void pcnt_init(void)
19 #ifdef __ARM_ARCH_7A__
21 asm volatile("mrc p15, 0, %0, c9, c12, 0" : "=r"(v));
22 v |= 5; // master enable, ccnt reset
23 v &= ~8; // ccnt divider 0
24 asm volatile("mcr p15, 0, %0, c9, c12, 0" :: "r"(v));
25 // enable cycle counter
26 asm volatile("mcr p15, 0, %0, c9, c12, 1" :: "r"(1<<31));
30 const unsigned char cmd_lengths[256] =
32 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
33 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34 3, 3, 3, 3, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8, 8, 8, // 20
35 5, 5, 5, 5, 8, 8, 8, 8, 7, 7, 7, 7, 11, 11, 11, 11,
36 2, 2, 2, 2, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, // 40
37 3, 3, 3, 3, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4,
38 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, // 60
39 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2,
40 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80
41 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
42 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // a0
43 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // c0
45 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // e0
47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
50 struct psx_gpu gpu __attribute__((aligned(64)));
54 uint16_t vram[1024 * 512];
55 uint32_t gpu_register[15];
59 static gpu_dump_struct state;
61 int main(int argc, char *argv[])
63 unsigned int start_cycles;
70 if (argc != 3 && argc != 4)
72 printf("usage:\n%s <state> <list> [vram_out]\n", argv[0]);
76 state_file = fopen(argv[1], "rb");
77 fread(&state, 1, sizeof(gpu_dump_struct), state_file);
80 list_file = fopen(argv[2], "rb");
81 fseek(list_file, 0, SEEK_END);
82 size = ftell(list_file);
83 fseek(list_file, 0, SEEK_SET);
85 list = (uint32_t *)malloc(size);
86 fread(list, 1, size, list_file);
91 memcpy(gpu.vram, state.vram, 1024*512*2);
92 if ((state.gpu_register[8] & 0x24) == 0x24)
93 renderer_set_interlace(1, !(state.status >> 31));
95 start_cycles = pcnt_get();
97 do_cmd_list(list, size / 4, &dummy, &dummy);
98 renderer_flush_queues();
100 printf("%u\n", pcnt_get() - start_cycles);
103 out_file = fopen(argv[3], "wb");
104 fwrite(gpu.vram, 1, sizeof(gpu.vram), out_file);