main
test_int_timing.c
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
9int headless = 1;
10
11uint32_t render_map_color(uint8_t r, uint8_t g, uint8_t b)
12{
13 return 0;
14}
15
16uint16_t read_dma_value(uint32_t address)
17{
18 return 0;
19}
20
21uint32_t *render_get_video_buffer(uint8_t which, int *pitch)
22{
23 *pitch = 0;
24 return NULL;
25}
26
27void render_video_buffer_updated(uint8_t which, int width)
28{
29}
30
31void warning(char *format, ...)
32{
33}
34
35
36int main(int argc, char **argv)
37{
38 vdp_context context;
39 int ret = 0;
40 init_vdp_context(&context, 0);
41 vdp_control_port_write(&context, 0x8000 | BIT_PAL_SEL);
42 vdp_control_port_write(&context, 0x8100 | BIT_DISP_EN | BIT_VINT_EN | BIT_MODE_5);
43 puts("Testing H32 Mode");
44 while (!(context.flags2 & FLAG2_VINT_PENDING))
45 {
46 vdp_run_context(&context, context.cycles + 1);
47 }
48 vdp_int_ack(&context);
49 uint32_t vint_cycle = vdp_next_vint(&context);
50 while (!(context.flags2 & FLAG2_VINT_PENDING))
51 {
52 vdp_run_context(&context, context.cycles + 1);
53 uint32_t vint_cycle2 = vdp_next_vint(&context);
54 if (vint_cycle2 != vint_cycle) {
55 printf("VINT Cycle changed from %d to %d @ line %d, slot %d\n", vint_cycle, vint_cycle2, context.vcounter, context.hslot);;
56 ret = 1;
57 vint_cycle = vint_cycle2;
58 }
59 }
60 vdp_int_ack(&context);
61 puts("Testing H40 Mode");
62 vdp_control_port_write(&context, 0x8C81);
63 while (!(context.flags2 & FLAG2_VINT_PENDING))
64 {
65 vdp_run_context(&context, context.cycles + 1);
66 }
67 vdp_int_ack(&context);
68 vint_cycle = vdp_next_vint(&context);
69 while (!(context.flags2 & FLAG2_VINT_PENDING))
70 {
71 vdp_run_context(&context, context.cycles + 1);
72 uint32_t vint_cycle2 = vdp_next_vint(&context);
73 if (vint_cycle2 != vint_cycle) {
74 printf("VINT Cycle changed from %d to %d @ line %d, slot %d\n", vint_cycle, vint_cycle2, context.vcounter, context.hslot);;
75 ret = 1;
76 vint_cycle = vint_cycle2;
77 }
78 }
79 vdp_int_ack(&context);
80 puts("Testing Mode 4");
81 vdp_control_port_write(&context, 0x8C00);
82 vdp_control_port_write(&context, 0x8100 | BIT_DISP_EN | BIT_VINT_EN);
83 while (!(context.flags2 & FLAG2_VINT_PENDING))
84 {
85 vdp_run_context(&context, context.cycles + 1);
86 }
87 context.flags2 &= ~FLAG2_VINT_PENDING;
88 vint_cycle = vdp_next_vint(&context);
89 while (!(context.flags2 & FLAG2_VINT_PENDING))
90 {
91 vdp_run_context(&context, context.cycles + 1);
92 uint32_t vint_cycle2 = vdp_next_vint(&context);
93 if (vint_cycle2 != vint_cycle) {
94 printf("VINT Cycle changed from %d to %d @ line %d, slot %d\n", vint_cycle, vint_cycle2, context.vcounter, context.hslot);;
95 ret = 1;
96 vint_cycle = vint_cycle2;
97 }
98 }
99 printf("Result: %s\n", ret ? "failure" : "success");
100 return ret;
101}