only generate the default.properties file when we are actually doing an android build.
[AROS.git] / workbench / c / GfxControl.c
blob4a5dbba6cfe77af0b2f47b29943d8da70a491451
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Change some internal options of cybergraphics.library.
6 Lang: English
7 */
8 /*****************************************************************************
10 NAME
12 GfxControl
14 SYNOPSIS
16 PREVENT_DIRECT_BITMAP_ACCESS=PDBA/S,
17 ALLOW_DIRECT_BITMAP_ACCESS=ADBA/S,
18 DUMP/S
20 LOCATION
24 FUNCTION
26 Change some internal options of cybergraphics.library
28 INPUTS
30 PREVENT_DIRECT_BITMAP_ACCESS -- Causes LockBitMapTagList() calls to
31 always fail
33 ALLOW_DIRECT_BITMAP_ACCESS -- Allow LocKBitMapTagList() to go to
34 gfx driver which may or may not
35 support it. (default)
37 DUMP -- Show current settings
39 RESULT
41 Standard DOS return codes.
43 NOTES
44 By default
45 BUGS
47 INTERNALS
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"
61 #define ARG_PDBA 0
62 #define ARG_ADBA 1
63 #define ARG_DUMP 2
64 #define NUM_ARGS 3
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))
73 AROS_USERFUNC_INIT
75 return NULL;
77 AROS_USERFUNC_EXIT
80 /****************************************************************************************/
82 AROS_PROCH(PatchTask, argstr, argsize, SysBase)
84 AROS_PROCFUNC_INIT
86 struct Library *CyberGfxBase;
87 struct MsgPort *port;
88 APTR orig_func;
90 /* Our process opens the library by itself in order to prevent it from being expunged */
91 CyberGfxBase = OpenLibrary("cybergraphics.library", 0);
92 if (!CyberGfxBase)
93 return 0;
95 port = CreateMsgPort();
96 if (port) {
97 port->mp_Node.ln_Name = PORT_NAME;
98 AddPort(port);
99 orig_func = SetFunction(CyberGfxBase, -28 * (WORD)LIB_VECTSIZE, MyLockBitMapTagList);
101 /* Just wait for a signal from the port. There's no need to look at message contents */
102 WaitPort(port);
103 SetFunction(CyberGfxBase, -28 * (WORD)LIB_VECTSIZE, orig_func);
104 RemPort(port);
105 DeleteMsgPort(port);
108 CloseLibrary(CyberGfxBase);
109 return 0;
111 AROS_PROCFUNC_EXIT
114 /****************************************************************************************/
116 __startup static AROS_PROCH(Start, argstr, argsize, SysBase)
118 AROS_PROCFUNC_INIT
120 struct RDArgs *myargs;
121 IPTR args[NUM_ARGS] = {0};
122 int rc = RETURN_OK;
123 struct MsgPort *port;
124 struct CommandLineInterface *cli;
125 struct DosLibrary *DOSBase;
127 DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 36);
128 if (!DOSBase)
129 return RETURN_FAIL;
131 cli = Cli();
133 /* TODO: Is it possible to run without CLI? For example
134 if we were started via "Run command..."? */
135 if (!cli) {
136 PutStr("This program must be run from CLI\n");
137 CloseLibrary((struct Library *)DOSBase);
138 return RETURN_FAIL;
141 myargs = ReadArgs(ARG_TEMPLATE, args, 0);
142 if (myargs) {
143 port = FindPort(PORT_NAME);
145 if (args[ARG_PDBA]) {
146 if (port)
147 PutStr("Direct bitmap access already disabled\n");
148 else {
149 if (CreateNewProcTags(NP_Seglist, cli->cli_Module, NP_Entry, PatchTask, NP_Name, "GfxControl patch", TAG_DONE))
150 cli->cli_Module = BNULL;
151 else {
152 PrintFault(IoErr(), "GfxControl");
153 rc = RETURN_FAIL;
158 if (args[ARG_ADBA]) {
159 if (port) {
160 /* We do a very basic thing: just send a message. The message has no additional data
161 and therefore does not need to be freed. We even don't look at its contents in the
162 patch process */
163 struct Message msg;
165 PutMsg(port, &msg);
166 } else
167 PutStr("Direct bitmap access already enabled\n");
170 if (args[ARG_DUMP])
171 Printf("Prevent Direct BitMap Access: %s\n", port ? "YES" : "NO");
173 FreeArgs(myargs);
174 } else {
175 PrintFault(IoErr(), "GfxControl");
176 rc = RETURN_FAIL;
179 CloseLibrary((struct Library *)DOSBase);
180 return rc;
182 AROS_PROCFUNC_EXIT