source: buchla-68k/orig/BUCHLA/VSDDCALC.C@ 4b63bf3

Last change on this file since 4b63bf3 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 5.6 KB
Line 
1/*
2 =============================================================================
3 vsddcalc.c -- calculate some VSDD values
4 Version 8 -- 1989-01-25 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "stdio.h"
9#include "stddefs.h"
10
11#define PSA 0 /* value for psa */
12#define HRS 1 /* value for hrs */
13
14#define VCK 12800000L /* value for video clock (Hz) */
15
16#define HC0 3 /* width of HSYNC (GCLKs - 1) */
17#define HC1 5 /* AHZ start (GCLKs - 1) */
18#define HC2 37 /* AHZ stop (GCLKs - 1) */
19#define HC3 40 /* horizontal sweep (GCLKs - 1) */
20
21#define VC0 8 /* width of VSYNC (lines - 1) */
22#define VC1 10 /* AVZ start (lines - 1) */
23#define VC2 360 /* AVZ stop (lines - 1) */
24#define VC3 362 /* vertical sweep (lines - 1) */
25
26/*
27
28*/
29
30short hrs = HRS, /* High Resolution Select */
31 psa = PSA, /* Pre-Scaler Active */
32 ahp, /* active horizontal period (GCLKs) */
33 avl, /* active vertical lines */
34 gpix, /* pixels per GCLK */
35 hpix, /* active pixels per line */
36 hc0 = HC0 + 1, /* width of HSYNC (GCLKs) */
37 hc1 = HC1 + 1, /* AHZ start (GCLKs) */
38 hc2 = HC2 + 1, /* AHZ stop (GCLKs) */
39 hc3 = HC3 + 1, /* horizontal sweep (GCLKs) */
40 hc4, /* 1/2 horizontal sweep (GCLKs) */
41 hrate, /* horizontal sweep rate (Hz) */
42 ihp, /* inactive horizontal period (GCLKs) */
43 ivl, /* inactive vertical lines */
44 vc0 = VC0 + 1, /* width of VSYNC (lines) */
45 vc1 = VC1 + 1, /* AVZ start (lines) */
46 vc2 = VC2 + 1, /* AVZ stop (lines) */
47 vc3 = VC3 + 1, /* vertical sweep (lines) */
48 vrate; /* vertical sweep rate (Hz) */
49
50long gclk, /* general clock (Hz) */
51 gclkn, /* general clock (nanoseconds) */
52 vck = VCK, /* video clock (Hz) */
53 pixclk, /* pixel clock (Hz) */
54 vph, /* sync gnerator clock (Hz) */
55 ahz, /* active horizontal zone time (nanoseconds) */
56 avz, /* active vertical zone time (nanoseconds) */
57 hsweep, /* horizontal sweep time (nanoseconds) */
58 hsync, /* horizontal sync time (nanoseconds) */
59 vsweep, /* vertical sweep time (nanoseconds) */
60 vsync; /* vertical sync time (nanoseconds) */
61
62/*
63
64*/
65
66main()
67{
68 /* check horizontal constants */
69
70 if (hc0 GE hc1) {
71
72 printf("ERROR: hc0 {%d} must be < hc1 {%d}\n", hc0, hc1);
73 exit(1);
74 }
75
76 hc4 = hc3 >> 1;
77
78 if (hc1 GE hc4) {
79
80 printf("ERROR: hc1 {%d} must be < (hc3 / 2) {%d}\n", hc1, hc4);
81 exit(1);
82 }
83
84 if (hc4 GE hc2) {
85
86 printf("ERROR: hc2 {%d} must be > (hc3 / 2) {%d}\n", hc2, hc4);
87 exit(1);
88 }
89
90 if (hc2 GE hc3) {
91
92 printf("ERROR: hc2 {%d} must be < hc3 {%d}\n", hc2, hc3);
93 exit(1);
94 }
95
96 /* check vertical constants */
97
98 if (vc0 GE vc1) {
99
100 printf("ERROR: vc0 {%d} must be < vc1 {%d}\n", vc0, vc1);
101 exit(1);
102 }
103
104 if (vc1 GE vc2) {
105
106 printf("ERROR: vc1 {%d} must be < vc2 {%d}\n", vc1, vc2);
107 exit(1);
108 }
109
110 if (vc2 GE vc3) {
111
112 printf("ERROR: vc2 {%d} must be < vc3 {%d}\n", vc2, vc3);
113 exit(1);
114 }
115
116/*
117
118*/
119 /* caluclate pixel clock */
120
121 if (hrs)
122 pixclk = vck;
123 else
124 pixclk = vck >> 1;
125
126 /* calculate internal clock */
127
128 if (psa)
129 vph = vck >> 2;
130 else
131 vph = vck >> 1;
132
133 /* check internal clock limit */
134
135 if (vph > 8000000L) {
136
137 printf("\nERROR: Calculated vph {%ld} is > 8000000\n", vph);
138
139 if (psa)
140 printf(" Try a lower value for vck {%ld}\n", vck);
141 else
142 printf(" Try psa = 1\n");
143
144 exit(1);
145 }
146
147 /* calculate general clock */
148
149 gclk = vph >> 3;
150 gclkn = (1000000000L / (gclk / 1000)) / 1000;
151
152 gpix = pixclk / gclk;
153
154 /* calculate horizontal timings */
155
156 ahp = hc2 - hc1;
157 ihp = hc3 - ahp;
158 hsync = hc0 * gclkn;
159 hsweep = hc3 * gclkn;
160 ahz = ahp * gclkn;
161 hpix = ahp * gpix;
162 hrate = 1000000000L / hsweep;
163
164 /* calculate vertical timings */
165
166 avl = vc2 - vc1;
167 ivl = vc3 - avl;
168 vsync = vc0 * hsweep;
169 vsweep = vc3 * hsweep;
170 avz = avl * hsweep;
171 vrate = 1000000000L / vsweep;
172
173/*
174
175*/
176 /* print the results */
177
178 printf("82716 VSDD Timing Calculations\n");
179 printf("------------------------------\n\n");
180
181 printf(" with HRS = %d and PSA = %d\n\n", hrs, psa);
182
183 printf("Clock values\n");
184 printf("------------\n\n");
185
186 printf("VCK = %8ld Hz Master clock\n", vck);
187 printf("PIXCLK = %8ld Hz Pixel clock\n", pixclk);
188 printf("VPH = %8ld Hz Internal clock\n", vph);
189 printf("GCLK = %8ld Hz General clock (%ld nanoseconds)\n\n",
190 gclk, gclkn);
191
192
193 printf("Horizontal values Vertical values\n");
194 printf("----------------- ---------------\n\n");
195
196 printf("HC0 = %8d GCLKs VC0 = %8d lines sync\n",
197 hc0, vc0);
198
199 printf("HC1 = %8d GCLKs VC1 = %8d lines start\n",
200 hc1, vc1);
201
202 printf("HC2 = %8d GCLKs VC2 = %8d lines stop\n",
203 hc2, vc2);
204
205 printf("HC3 = %8d GCLKs VC3 = %8d lines sweep\n\n",
206 hc3, vc3);
207
208 printf("AHP = %8d GCLKs AVL = %8d lines active\n",
209 ahp, avl);
210
211 printf("IHP = %8d GCLKs IVL = %8d lines inactive\n\n",
212 ihp, ivl);
213
214
215 printf("HSYNC = %8ld nanoseconds VSYNC = %8ld nanoseconds\n",
216 hsync, vsync);
217
218 printf("HSWEEP = %8ld nanoseconds VSWEEP = %8ld nanoseconds\n",
219 hsweep, vsweep);
220
221 printf("AHZ = %8ld nanoseconds AVZ = %8ld nanoseconds\n\n",
222 ahz, avz);
223
224
225 printf("Miscellaneous values\n");
226 printf("--------------------\n\n");
227
228 printf("GPIX = %8d pixels / GCLK HPIX = %8d pixels displayed\n",
229 gpix, hpix);
230
231 printf("HRATE = %8d Hz VRATE = %8d Hz\n\n",
232 hrate, vrate);
233
234 exit(0);
235}
Note: See TracBrowser for help on using the repository browser.