home *** CD-ROM | disk | FTP | other *** search
- ;/* getaspect.c - Execute me to compile me with SAS C 5.10
- LC -b1 -cfistq -v -y -j73 getaspect.c
- Blink FROM LIB:c.o,getaspect.o TO getaspect LIBRARY LIB:LC.lib,LIB:Amiga.lib
- quit
-
- Gets X/Y pixel aspect of a screen's ViewPort
- */
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <libraries/dos.h>
- #include <intuition/intuition.h>
- #include <intuition/intuitionbase.h>
- #include <graphics/displayinfo.h>
- #include <graphics/gfxbase.h>
-
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/graphics_protos.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
-
- #ifdef LATTICE
- int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
- int chkabort(void) { return(0); } /* really */
- #endif
-
-
- #define MINARGS 1
-
- UBYTE *vers = "\0$VER: getaspect 37.1";
- UBYTE *Copyright =
- "getaspect v37.1\nCopyright (c) 1990-1999 Amiga, Inc. All Rights Reserved";
- UBYTE *usage = "Usage: getaspect";
-
- void bye(UBYTE *s, int e);
- void cleanup(void);
-
- struct Library *IntuitionBase;
- struct Library *GfxBase;
-
- void main(int argc, char **argv)
- {
- struct Screen *first;
- struct ViewPort *vp;
- struct DisplayInfo DI;
- ULONG modeid;
- UBYTE xAspect, yAspect;
-
- if(((argc)&&(argc<MINARGS))||(argv[argc-1][0]=='?'))
- {
- printf("%s\n%s\n",Copyright,usage);
- bye("",RETURN_OK);
- }
-
- /* We will check later to see if we can call V36 functions */
- IntuitionBase = OpenLibrary("intuition.library",34);
- GfxBase = OpenLibrary("graphics.library",34);
- if((!IntuitionBase)||(!GfxBase))
- bye("Can't open intuition or graphics library",RETURN_FAIL);
-
- printf("Using front screen's ViewPort for example purposes only:\n");
-
- first = ((struct IntuitionBase *)IntuitionBase)->FirstScreen;
- vp = &first->ViewPort;
-
- xAspect = 0; /* So we can tell when we've got it */
-
- if(GfxBase->lib_Version >= 36)
- {
- modeid = GetVPModeID(vp);
-
- if(GetDisplayInfoData(NULL, (UBYTE *)&DI, sizeof(struct DisplayInfo),
- DTAG_DISP, modeid))
- {
- printf("Running 2.0, ViewPort modeid is $%08lx\n",modeid);
- xAspect = DI.Resolution.x;
- yAspect = DI.Resolution.y;
- printf("Pixel xAspect=%ld yAspect=%ld\n",xAspect, yAspect);
- printf("PaletteRange is %ld\n",DI.PaletteRange);
- }
- }
-
- if(!xAspect) /* pre-2.0 or GetDisplayInfoData failed */
- {
- modeid = vp->Modes;
- printf("Not running 2.0, ViewPort mode is $%04lx\n",modeid);
- /* default lores pixel ratio */
- xAspect = 44;
- yAspect = ((struct GfxBase *)GfxBase)->DisplayFlags & PAL ? 44 : 52;
- if(modeid & HIRES) xAspect = xAspect >> 1;
- if(modeid & LACE) yAspect = yAspect >> 1;
- printf("Pixel xAspect=%ld yAspect=%ld\n",xAspect, yAspect);
- }
-
- bye("",RETURN_OK);
- }
-
-
- void bye(UBYTE *s, int e)
- {
- cleanup();
- exit(e);
- }
-
- void cleanup()
- {
- if(GfxBase) CloseLibrary(GfxBase);
- if(IntuitionBase) CloseLibrary(IntuitionBase);
- }
-
-