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_PROCH(PatchTask
, argstr
, argsize
, SysBase
)
86 struct Library
*CyberGfxBase
;
90 /* Our process opens the library by itself in order to prevent it from being expunged */
91 CyberGfxBase
= OpenLibrary("cybergraphics.library", 0);
95 port
= CreateMsgPort();
97 port
->mp_Node
.ln_Name
= PORT_NAME
;
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 */
103 SetFunction(CyberGfxBase
, -28 * (WORD
)LIB_VECTSIZE
, orig_func
);
108 CloseLibrary(CyberGfxBase
);
114 /****************************************************************************************/
116 __startup
static AROS_PROCH(Start
, argstr
, argsize
, SysBase
)
120 struct RDArgs
*myargs
;
121 IPTR args
[NUM_ARGS
] = {0};
123 struct MsgPort
*port
;
124 struct CommandLineInterface
*cli
;
125 struct DosLibrary
*DOSBase
;
127 DOSBase
= (struct DosLibrary
*)OpenLibrary("dos.library", 36);
133 /* TODO: Is it possible to run without CLI? For example
134 if we were started via "Run command..."? */
136 PutStr("This program must be run from CLI\n");
137 CloseLibrary((struct Library
*)DOSBase
);
141 myargs
= ReadArgs(ARG_TEMPLATE
, args
, 0);
143 port
= FindPort(PORT_NAME
);
145 if (args
[ARG_PDBA
]) {
147 PutStr("Direct bitmap access already disabled\n");
149 if (CreateNewProcTags(NP_Seglist
, cli
->cli_Module
, NP_Entry
, PatchTask
, NP_Name
, "GfxControl patch", TAG_DONE
))
150 cli
->cli_Module
= BNULL
;
152 PrintFault(IoErr(), "GfxControl");
158 if (args
[ARG_ADBA
]) {
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
167 PutStr("Direct bitmap access already enabled\n");
171 Printf("Prevent Direct BitMap Access: %s\n", port
? "YES" : "NO");
175 PrintFault(IoErr(), "GfxControl");
179 CloseLibrary((struct Library
*)DOSBase
);