home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------------
- --
- -- MonitorInfo.C
- --
- -- A small program to display a monitor's properties
- --
- -- author: Gregor S. M. Kuhlmann
- -- version: 37.4
- -- created: 1994-Apr-01
- --
- -- revision history:
- -- 1994-Apr-01 37.0 created
- -- 1994-Apr-02 37.1 added analogsignal period output in microseconds
- -- 1994-Apr-03 37.2 added ms_Flags interpretation
- -- 1994-Apr-04 37.3 added LIST option
- -- 1994-Apr-09 37.4 added RAW option
- --
- -------------------------------------------------------------------------*/
-
- #define __USE_SYSBASE
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <exec/types.h>
- #include <exec/execbase.h>
- #include <graphics/monitor.h>
- #include <graphics/gfxbase.h>
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <proto/graphics.h>
-
- #define BOLD_ON "\x1b[1m"
- #define BOLD_OFF "\x1b[22m"
- #define UNDERLINE_ON "\x1b[4m"
- #define UNDERLINE_OFF "\x1b[24m"
-
- extern long __oslibversion = 37;
-
- static char version[] = "$VER: MonitorInfo V37.4 (1994-04-09)";
-
- static char *beamcon0defs[16] =
- {
- "HSYNCTRUE - horizontal sync true",
- "VSYNCTRUE - vertical sync true",
- "CSYNCTRUE - composite sync true",
- "CSBLANK - composite blank out to /CSY pin (ECS), unused (AA)",
- "VARCSYNC - variable composite sync enabled",
- "DISPLAYPAL - uses PAL color encoding",
- "DISPLAYDUAL - uses both UHRES and standard pointers",
- "VARBEAM - variable beam counter enabled",
- "VARHSYNC - variable horizontal sync enabled",
- "VARVSYNC - variable vertical sync enabled",
- "CSCBLANKEN - redirect composite sync",
- "LOLDIS - long display lines disabled",
- "VARVBLANK - variable vertical blank enabled",
- "LPENDIS - disable lightpen position latch",
- "HARDDIS - disable hardwired display window limits",
- NULL
- };
-
- void main(void)
- {
- struct MonitorSpec *mspec;
- struct SpecialMonitor *sm;
- float base_frequency, v_freq;
- float ratioh, ratiov;
- float color_clock;
- UWORD i,j;
- char **monitorName;
- int numMonitors = 0;
- BOOL rawmode = FALSE;
- static char template[] = "MONITORS/M,LIST/S,RAW/S";
- LONG values[3] = {0,0,0};
- struct RDArgs *ra;
- long rc = RETURN_OK;
-
- printf("\n" BOLD_ON "%s" BOLD_OFF " by Gregor S. M. Kuhlmann\n\n",&version[6]);
-
- if (ra=ReadArgs(template,values,0))
- {
- if ((values[1]) || (values[0]==NULL))
- {
- ObtainSemaphoreShared(GfxBase->MonitorListSemaphore);
- printf(BOLD_ON UNDERLINE_ON "Currently installed monitors:" BOLD_OFF UNDERLINE_OFF "\n");
- mspec = (struct MonitorSpec *)GfxBase->MonitorList.lh_Head;
- while (mspec->ms_Node.xln_Succ)
- {
- numMonitors++;
- printf("%s\n",mspec->ms_Node.xln_Name);
- mspec=(struct MonitorSpec *)mspec->ms_Node.xln_Succ;
- }
- if (numMonitors==0)
- {
- printf("< NONE >\n");
- }
- printf("\n");
- ReleaseSemaphore(GfxBase->MonitorListSemaphore);
- }
- else
- {
- if (values[2])
- {
- rawmode=TRUE;
- }
- monitorName=(char**)values[0];
- while(*monitorName)
- {
- if (mspec=OpenMonitor(*monitorName,0L))
- {
- printf(BOLD_ON UNDERLINE_ON "Information for '%s':" BOLD_OFF UNDERLINE_OFF "\n\n",*monitorName);
- /*--- determine color clock period display mode ---*/
- color_clock = 1.0 / (5 * SysBase->ex_EClockFrequency);
- /*--- print scan rates ---*/
- printf(BOLD_ON "Display scan rates:" BOLD_OFF "\n");
- base_frequency = 1.0 / (mspec->total_colorclocks * color_clock);
- ratioh=mspec->ratioh/16.0;
- ratiov=mspec->ratiov/16.0;
- v_freq = base_frequency / mspec->total_rows;
- printf("horizontal sweep rate = %.2f kHz (scanline period = %.2f µs)\n",
- base_frequency / 1000.0, (1.0 / base_frequency) * 1e6);
- printf("vertical sweep rate = %.2f Hz\n",v_freq);
- printf("lores pixel aspect ratio (w/h) = %.3f\n\n",ratiov/ratioh);
- /*--- print analogsignal properties ---*/
- if (sm=mspec->ms_Special)
- {
- if (rawmode)
- {
- printf(BOLD_ON "hardware sync/blank values:" BOLD_OFF "\n");
- printf("HBSTRT=%d, HSSTRT=%d, HSSTOP=%d, HBSTOP=%d\n",
- sm->hblank.asi_Start,sm->hsync.asi_Start,sm->hsync.asi_Stop,sm->hblank.asi_Stop);
- printf("VBSTRT=%d, VSSTRT=%d, VSSTOP=%d, VBSTOP=%d\n\n",
- sm->vblank.asi_Start,sm->vsync.asi_Start,sm->vsync.asi_Stop,sm->vblank.asi_Stop);
- }
- else
- {
- printf(BOLD_ON "special signal timing info:" BOLD_OFF "\n");
- printf("horizontal blanking period: %.2f µs\n",
- (sm->hblank.asi_Stop-sm->hblank.asi_Start) * color_clock * 1e6);
- printf("horizontal sync period: %.2f µs (delay = %.2f µs)\n",
- (sm->hsync.asi_Stop-sm->hsync.asi_Start) * color_clock * 1e6,
- (sm->hsync.asi_Start - sm->hblank.asi_Start) * color_clock * 1e6);
- printf("vertical blanking period: %.2f µs\n",
- (sm->vblank.asi_Stop-sm->vblank.asi_Start) * color_clock * 1e6);
- printf("vertical sync period: %.2f µs (delay = %.2f µs)\n\n",
- (sm->vsync.asi_Stop-sm->vsync.asi_Start ) * color_clock * 1e6,
- (sm->vsync.asi_Start - sm->vblank.asi_Start) * color_clock * 1e6);
- }
- }
- /*--- print beamcon properties ---*/
- printf(BOLD_ON "signal properties" BOLD_OFF " (0x%0.4x):\n",mspec->BeamCon0);
- for (i=0;i<16;i++)
- {
- if (mspec->BeamCon0 & (1<<i))
- {
- if (beamcon0defs[i])
- printf("%s\n",beamcon0defs[i]);
- else
- printf("(#%d)\n",i);
- }
- }
- printf("\n");
- CloseMonitor(mspec);
- }
- else
- {
- printf("ERROR: Couldn't open monitor '%s'\n",*monitorName);
- break;
- }
- monitorName++;
- }
- }
- }
- else
- {
- printf("ERROR: Arguments not suitable for template:\n%s\n",template);
- rc=RETURN_ERROR;
- }
- exit(rc);
- }
-