home *** CD-ROM | disk | FTP | other *** search
- /* ts;4 */
- /*
- lc -v -O -cs FixScreenMode
- asm -ILATTICE:asm/ NewOpenScreenTagList.asm
- blink from FixScreenMode.o NewOpenScreenTagList.o TO FixScreenMode SC SD ND
- */
- #include <exec/types.h>
- #include <exec/alerts.h>
- #include <exec/execbase.h>
- #include <exec/libraries.h>
- #include <dos/dosextens.h>
- #include <utility/tagitem.h>
- #include <graphics/gfxbase.h>
- #include <intuition/screens.h>
- #include <intuition/intuition.h>
- #include <intuition/intuitionbase.h>
-
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/utility_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/intuition_protos.h>
-
- #define LIB_2_0 36
- #define ABSEXECBASE ((struct ExecBase **) 0x4)
-
- #include <pragma/exec_lib.fd.h>
- #include <pragma/dos_lib.fd.h>
- #include <pragma/utility_lib.fd.h>
- #include <pragma/graphics_lib.fd.h>
- #include <pragma/intuition_lib.fd.h>
-
- #define DOSNAME "dos.library"
- #define UTILITYNAME "utility.library"
- #define GRAPHICSNAME "graphics.library"
- #define INTUITIONNAME "intuition.library"
-
- extern struct ExecBase *ExecBase;
- extern struct DosLibrary *DOSBase;
- extern struct Library *far UtilityBase;
- extern struct IntuitionBase *IntuitionBase;
- extern struct GfxBase *GfxBase;
-
- extern struct TagItem far ScreenTags[];
- extern LONG EasyRequestStub(
- struct Window *Window,
- struct EasyStruct *EasyStruct,
- ULONG *IdcmpPtr,
- ...
- );
-
- #define OPENSCREENTAGLIST (-612)
- extern APTR far OldOpenScreenTagList;
- extern ULONG far NewOpenScreenTagList();
-
- #define WIDTH_TAG 0
- #define HEIGTH_TAG WIDTH_TAG + 1
- #define DISPALYID_TAG HEIGTH_TAG + 1
-
- extern char NewName[];
- extern struct EasyStruct EasyStruct;
-
- #define DONE 0
- __saveds LONG Start()
- {
- register LONG RetVal = !DONE;
-
- register struct Process *Process;
- register struct CommandLineInterface *CLI;
- register struct Message *Message;
- register struct Task *Task;
- register char *OldName;
- register struct Screen *WorkBench;
-
- ExecBase = (*ABSEXECBASE);
- if(ExecBase->LibNode.lib_Version < LIB_2_0)
- {
- Alert(AG_OpenLib | AO_ExecLib);
- goto NoExecBase;
- }
-
- if(!(DOSBase = (struct DosLibrary *)
- OpenLibrary(DOSNAME, LIB_2_0)))
- {
- Alert(AG_OpenLib | AO_DOSLib);
- goto NoDOSBase;
- }
-
- if(!(UtilityBase = (struct Library *)
- OpenLibrary(UTILITYNAME, LIB_2_0))
- )
- {
- Alert(AG_OpenLib | AO_UtilityLib);
- goto NoUtilityBase;
- }
-
- if(!(GfxBase = (struct GfxBase *)
- OpenLibrary(GRAPHICSNAME, LIB_2_0))
- )
- {
- Alert(AG_OpenLib | AO_GraphicsLib);
- goto NoGfxBase;
- }
-
- if(!(IntuitionBase = (struct IntuitionBase *)
- OpenLibrary(INTUITIONNAME, LIB_2_0))
- )
- {
- Alert(AG_OpenLib | AO_Intuition);
- goto NoIntuitionBase;
- }
-
- Process = (struct Process *) ExecBase->ThisTask;
- if(!(CLI = Cli()))
- {
- WaitPort(&Process->pr_MsgPort);
- Message = GetMsg(&Process->pr_MsgPort);
- }
-
- if(!(Task = FindTask(NewName)))
- goto FirstTime;
-
- RetVal = DONE;
-
- Signal(Task, SIGBREAKF_CTRL_C);
-
- EasyRequestStub(NULL, &EasyStruct, NULL, "OFF");
-
- goto SecondTime;
- FirstTime:
- Task = (struct Task *) Process;
- OldName = Task->tc_Node.ln_Name;
- Task->tc_Node.ln_Name = NewName;
-
- if(!(WorkBench = LockPubScreen("Workbench")))
- goto NoWorkbench;
-
- ScreenTags[WIDTH_TAG].ti_Data = (ULONG) WorkBench->Width;
- ScreenTags[HEIGTH_TAG].ti_Data = (ULONG) WorkBench->Height;
- ScreenTags[DISPALYID_TAG].ti_Data = (ULONG) GetVPModeID(&WorkBench->ViewPort);
-
- UnlockPubScreen(NULL, WorkBench);
-
- if(!
- (OldOpenScreenTagList =
- SetFunction(
- (struct Library *) IntuitionBase,
- (LONG) OPENSCREENTAGLIST,
- (ULONG (*)()) NewOpenScreenTagList
- )
- )
- )
- goto NoSetOpenScreenTagList;
-
- EasyRequestStub(NULL, &EasyStruct, NULL, "ON");
-
- Wait(SIGBREAKF_CTRL_C);
-
- RetVal = DONE;
-
- SetFunction(
- (struct Library *) IntuitionBase,
- (LONG) OPENSCREENTAGLIST,
- (ULONG (*)()) OldOpenScreenTagList
- );
-
- NoSetOpenScreenTagList:
-
- NoWorkbench:
-
- Task->tc_Node.ln_Name = OldName;
- SecondTime:
-
- if(!CLI)
- {
- Forbid();
- ReplyMsg(Message);
- }
-
- CloseLibrary((struct Library *) IntuitionBase);
- NoIntuitionBase:
-
- CloseLibrary((struct Library *) GfxBase);
- NoGfxBase:
-
- CloseLibrary((struct Library *) UtilityBase);
- NoUtilityBase:
-
- CloseLibrary((struct Library *) DOSBase);
- NoDOSBase:
-
- NoExecBase:
-
- return(RetVal);
- }
-
- static char Version[] = "\0$VER: FixScreenMode 1.0 (10.20.92)";
-
- struct ExecBase *ExecBase;
- struct DosLibrary *DOSBase;
- struct Library *far UtilityBase;
- struct IntuitionBase *IntuitionBase;
- struct GfxBase *GfxBase;
-
- struct TagItem far ScreenTags[] =
- {
- {SA_Width, (ULONG) 0}, /* WorkBench->Width */
- {SA_Height, (ULONG) 0}, /* WorkBench->Height */
- {SA_DisplayID, (ULONG) 0}, /* GetVPModeID(&WorkBench->ViewPort) */
- {TAG_MORE, (ULONG) 0} /* original ScreenTags */
- };
-
- APTR far OldOpenScreenTagList;
-
- LONG EasyRequestStub(
- struct Window *Window,
- struct EasyStruct *EasyStruct,
- ULONG *IdcmpPtr,
- ...
- )
- {
- return(
- EasyRequestArgs(
- Window,
- EasyStruct,
- IdcmpPtr,
- (UWORD *) (&IdcmpPtr + 1)
- )
- );
- }
-
- char NewName[] = "FixScreenMode-Task";
- struct EasyStruct EasyStruct =
- {
- sizeof(struct EasyStruct),
- 0,
- "Version 1.0",
- "FixScreenMode\nSwitched %s\n",
- "OK!|OK!"
- };
-