2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
5 Desc: Change some internal options of cybergraphics.library.
8 /*****************************************************************************
16 PREVENT_DIRECT_BITMAP_ACCESS=PDBA/S,
17 ALLOW_DIRECT_BITMAP_ACCESS=ADBA/S,
26 Change some internal options of cybergraphics.library
30 PREVENT_DIRECT_BITMAP_ACCESS -- Causes LockBitMapTagList() calls to
33 ALLOW_DIRECT_BITMAP_ACCESS -- Allow LocKBitMapTagList() to go to
34 gfx driver which may or may not
37 DUMP -- Show current settings
41 Standard DOS return codes.
49 ******************************************************************************/
51 #include <dos/dosextens.h>
52 #include <proto/alib.h>
53 #include <proto/exec.h>
54 #include <proto/dos.h>
56 /****************************************************************************************/
58 #define PORT_NAME "GfxControl"
60 #define ARG_TEMPLATE "PREVENT_DIRECT_BITMAP_ACCESS=PDBA/S,ALLOW_DIRECT_BITMAP_ACCESS=ADBA/S,DUMP/S"
66 /****************************************************************************************/
68 AROS_UFH3(APTR
, MyLockBitMapTagList
,
69 AROS_UFHA(struct BitMap
*, bitmap
, A0
),
70 AROS_UFHA(struct TagItem
*, tags
, A1
),
71 AROS_UFHA(struct Library
*, CyberGfxBase
, A6
))
80 /****************************************************************************************/
82 AROS_ENTRY(LONG
, PatchTask
,
83 AROS_UFHA(char *, argstr
, A0
),
84 AROS_UFHA(ULONG
, argsize
, D0
),
85 struct ExecBase
*, SysBase
)
89 struct Library
*CyberGfxBase
;
93 /* Our process opens the library by itself in order to prevent it from being expunged */
94 CyberGfxBase
= OpenLibrary("cybergraphics.library", 0);
98 port
= CreateMsgPort();
100 port
->mp_Node
.ln_Name
= PORT_NAME
;
102 orig_func
= SetFunction(CyberGfxBase
, -28 * (WORD
)LIB_VECTSIZE
, MyLockBitMapTagList
);
104 /* Just wait for a signal from the port. There's no need to look at message contents */
106 SetFunction(CyberGfxBase
, -28 * (WORD
)LIB_VECTSIZE
, orig_func
);
111 CloseLibrary(CyberGfxBase
);
117 /****************************************************************************************/
119 __startup
static AROS_ENTRY(int, Start
,
120 AROS_UFHA(char *, argstr
, A0
),
121 AROS_UFHA(ULONG
, argsize
, D0
),
122 struct ExecBase
*, SysBase
)
126 struct RDArgs
*myargs
;
127 IPTR args
[NUM_ARGS
] = {0};
129 struct MsgPort
*port
;
130 struct CommandLineInterface
*cli
;
131 struct DosLibrary
*DOSBase
;
133 DOSBase
= (struct DosLibrary
*)OpenLibrary("dos.library", 36);
139 /* TODO: Is it possible to run without CLI? For example
140 if we were started via "Run command..."? */
142 PutStr("This program must be run from CLI\n");
143 CloseLibrary((struct Library
*)DOSBase
);
147 myargs
= ReadArgs(ARG_TEMPLATE
, args
, 0);
149 port
= FindPort(PORT_NAME
);
151 if (args
[ARG_PDBA
]) {
153 PutStr("Direct bitmap access already disabled\n");
155 if (CreateNewProcTags(NP_Seglist
, cli
->cli_Module
, NP_Entry
, PatchTask
, NP_Name
, "GfxControl patch", TAG_DONE
))
156 cli
->cli_Module
= BNULL
;
158 PrintFault(IoErr(), "GfxControl");
164 if (args
[ARG_ADBA
]) {
166 /* We do a very basic thing: just send a message. The message has no additional data
167 and therefore does not need to be freed. We even don't look at its contents in the
173 PutStr("Direct bitmap access already enabled\n");
177 Printf("Prevent Direct BitMap Access: %s\n", port
? "YES" : "NO");
181 PrintFault(IoErr(), "GfxControl");
185 CloseLibrary((struct Library
*)DOSBase
);