Mercurial > repos > blastem
annotate test.c @ 951:fec4a59ae5d7
Merge
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 11 Apr 2016 20:56:54 -0700 |
parents | 15d9359fd771 |
children |
rev | line source |
---|---|
720
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include <stdint.h> |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include <stdlib.h> |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #include <string.h> |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 #include <stdio.h> |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 #include "vdp.h" |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 int headless = 1; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 uint16_t read_dma_value(uint32_t address) |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 { |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 return 0; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 } |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 uint32_t render_map_color(uint8_t r, uint8_t g, uint8_t b) |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 { |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 return 0; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 } |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 void render_alloc_surfaces(vdp_context * context) |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 { |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 context->oddbuf = context->framebuf = malloc(512 * 256 * 4 * 2); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 memset(context->oddbuf, 0, 512 * 256 * 4 * 2); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 context->evenbuf = ((char *)context->oddbuf) + 512 * 256 * 4; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 } |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 int check_hint_time(vdp_context * v_context) |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 { |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 uint32_t orig_hint_cycle = vdp_next_hint(v_context); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 uint32_t cur_hint_cycle; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 printf("hint cycle is %d at vcounter: %d, hslot: %d\n", orig_hint_cycle, v_context->vcounter, v_context->hslot); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 int res = 1; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 while ((cur_hint_cycle = vdp_next_hint(v_context)) > v_context->cycles) |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 { |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 if (cur_hint_cycle != orig_hint_cycle) { |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 fprintf(stderr, "ERROR: hint cycle changed to %d at vcounter: %d, hslot: %d\n", cur_hint_cycle, v_context->vcounter, v_context->hslot); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 orig_hint_cycle = cur_hint_cycle; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 res = 0; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 } |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 vdp_run_context(v_context, v_context->cycles + 1); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 } |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 printf("hint fired at cycle: %d, vcounter: %d, hslot: %d\n", cur_hint_cycle, v_context->vcounter, v_context->hslot); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 vdp_int_ack(v_context, 4); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 return res; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 } |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 int main(int argc, char ** argv) |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 { |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 vdp_context v_context; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 init_vdp_context(&v_context, 0); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 vdp_control_port_write(&v_context, 0x8144); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 vdp_control_port_write(&v_context, 0x8C81); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 vdp_control_port_write(&v_context, 0x8A7F); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 vdp_control_port_write(&v_context, 0x8014); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 v_context.hint_counter = 0x7F; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 v_context.vcounter = 128; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 v_context.hslot = 165; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 //check single shot behavior |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 int res = check_hint_time(&v_context); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 //check every line behavior |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 while (v_context.vcounter < 225) |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 { |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 vdp_run_context(&v_context, v_context.cycles + 1); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 } |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 vdp_control_port_write(&v_context, 0x8A00); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 int hint_count = 0; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 while (res && v_context.vcounter != 224) |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 { |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 res = res && check_hint_time(&v_context); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 hint_count++; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 } |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 if (res && hint_count != 225) { |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 fprintf(stderr, "ERROR: hint count should be 225 but was %d instead\n", hint_count); |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 res = 0; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 } |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 return 0; |
15d9359fd771
Add some tests for hint timing and fix it properly this time.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 } |