1 /* f2r Frame to refresh converter */
2 /* 1993 Nye Liu */
3
4 #include <stdio.h>
5
6 #define RoundTo8(x) ((int)(x) & ~((int)7))
7
main(int argc,char * argv[])8 main(int argc, char *argv[])
9 {
10 char *mode, *temp;
11 float ClockFreq;
12 float HorizontalRefresh, VerticalRefresh;
13 int HorizontalFrame, VerticalFrame;
14
15 for (mode=argv[0]+strlen(argv[0])-1; mode!=argv[0] && *(mode-1)!='/'; mode--);
16 printf("%s\n",mode);
17
18 printf("VGA Clock Rate (MHz) ? ");
19 scanf("%f",&ClockFreq);
20 ClockFreq *= 1e6;
21 if(strcmp(mode,"r2f")==0) {
22 printf("Enter desired H refresh (kHz): ");
23 scanf("%f",&HorizontalRefresh);
24 HorizontalFrame=RoundTo8(ClockFreq/HorizontalRefresh/1e3);
25 printf("Horizontal Frame: %d\n", HorizontalFrame);
26
27 printf("Enter desired V refresh (Hz): ");
28 scanf("%f",&VerticalRefresh);
29 printf("Vertical Frame: %d\n",
30 (int)(ClockFreq/HorizontalFrame/VerticalRefresh));
31 }
32 else {
33 printf("Enter HF: ");
34 scanf("%d",&HorizontalFrame);
35 HorizontalFrame=RoundTo8(HorizontalFrame);
36 printf("Horizontal refresh rate: %.1fkHz\n",
37 ClockFreq/HorizontalFrame/1e3);
38
39 printf("Enter VF: ");
40 scanf("%d",&VerticalFrame);
41 printf("Vertical refresh rate: %.1f Hz\n",
42 ClockFreq/HorizontalFrame/VerticalFrame);
43 }
44 }
45