Mercurial > repos > blastem
comparison test_int_timing.c @ 1172:14eb8ff4fb03
Added synthetic test for tracking down interrupt timing issues
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 16 Jan 2017 21:38:49 -0800 |
parents | |
children | aa6e0914dcd7 |
comparison
equal
deleted
inserted
replaced
1171:43fa92976ff2 | 1172:14eb8ff4fb03 |
---|---|
1 /* | |
2 Copyright 2017 Michael Pavone | |
3 This file is part of BlastEm. | |
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. | |
5 */ | |
6 #include <stdio.h> | |
7 #include "vdp.h" | |
8 | |
9 int headless = 1; | |
10 | |
11 uint32_t render_map_color(uint8_t r, uint8_t g, uint8_t b) | |
12 { | |
13 return 0; | |
14 } | |
15 | |
16 uint16_t read_dma_value(uint32_t address) | |
17 { | |
18 return 0; | |
19 } | |
20 | |
21 | |
22 int main(int argc, char **argv) | |
23 { | |
24 vdp_context context; | |
25 int ret = 0; | |
26 init_vdp_context(&context, 0); | |
27 vdp_control_port_write(&context, 0x8000 | BIT_PAL_SEL); | |
28 vdp_control_port_write(&context, 0x8100 | BIT_DISP_EN | BIT_VINT_EN | BIT_MODE_5); | |
29 puts("Testing H32 Mode"); | |
30 while (!(context.flags2 & FLAG2_VINT_PENDING)) | |
31 { | |
32 vdp_run_context(&context, context.cycles + 1); | |
33 } | |
34 vdp_int_ack(&context); | |
35 uint32_t vint_cycle = vdp_next_vint(&context); | |
36 while (!(context.flags2 & FLAG2_VINT_PENDING)) | |
37 { | |
38 vdp_run_context(&context, context.cycles + 1); | |
39 uint32_t vint_cycle2 = vdp_next_vint(&context); | |
40 if (vint_cycle2 != vint_cycle) { | |
41 printf("VINT Cycle changed from %d to %d @ line %d, slot %d\n", vint_cycle, vint_cycle2, context.vcounter, context.hslot);; | |
42 ret = 1; | |
43 vint_cycle = vint_cycle2; | |
44 } | |
45 } | |
46 vdp_int_ack(&context); | |
47 puts("Testing H40 Mode"); | |
48 vdp_control_port_write(&context, 0x8C81); | |
49 while (!(context.flags2 & FLAG2_VINT_PENDING)) | |
50 { | |
51 vdp_run_context(&context, context.cycles + 1); | |
52 } | |
53 vdp_int_ack(&context); | |
54 vint_cycle = vdp_next_vint(&context); | |
55 while (!(context.flags2 & FLAG2_VINT_PENDING)) | |
56 { | |
57 vdp_run_context(&context, context.cycles + 1); | |
58 uint32_t vint_cycle2 = vdp_next_vint(&context); | |
59 if (vint_cycle2 != vint_cycle) { | |
60 printf("VINT Cycle changed from %d to %d @ line %d, slot %d\n", vint_cycle, vint_cycle2, context.vcounter, context.hslot);; | |
61 ret = 1; | |
62 vint_cycle = vint_cycle2; | |
63 } | |
64 } | |
65 vdp_int_ack(&context); | |
66 puts("Testing Mode 4"); | |
67 vdp_control_port_write(&context, 0x8C00); | |
68 vdp_control_port_write(&context, 0x8100 | BIT_DISP_EN | BIT_VINT_EN); | |
69 while (!(context.flags2 & FLAG2_VINT_PENDING)) | |
70 { | |
71 vdp_run_context(&context, context.cycles + 1); | |
72 } | |
73 context.flags2 &= ~FLAG2_VINT_PENDING; | |
74 vint_cycle = vdp_next_vint(&context); | |
75 while (!(context.flags2 & FLAG2_VINT_PENDING)) | |
76 { | |
77 vdp_run_context(&context, context.cycles + 1); | |
78 uint32_t vint_cycle2 = vdp_next_vint(&context); | |
79 if (vint_cycle2 != vint_cycle) { | |
80 printf("VINT Cycle changed from %d to %d @ line %d, slot %d\n", vint_cycle, vint_cycle2, context.vcounter, context.hslot);; | |
81 ret = 1; | |
82 vint_cycle = vint_cycle2; | |
83 } | |
84 } | |
85 printf("Result: %s\n", ret ? "failure" : "success"); | |
86 return ret; | |
87 } |