Missing dependencies added.
[AROS-Contrib.git] / dopus / Program / main9.c
blob42bc651f5b511967430f6051dff81d63dc19f57c
1 /*
3 Directory Opus 4
4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
31 #include "dopus.h"
33 #ifdef __SASC__
34 bigint bytes(name,total,block)
35 char *name;
36 bigint *total;
37 int *block;
38 #else
39 long long bytes(name,total,block)
40 char *name;
41 long long *total;
42 int *block;
43 #endif
45 struct InfoData __aligned infodata;
46 BPTR mylock,testlock;
47 #ifdef __SASC__
48 bigint free, temp1, ret;
50 free = i64_atoi( "-1" );
51 #else
52 long long free=-1;
53 #endif
55 if (!(mylock=Lock(name,ACCESS_READ))) {
56 #ifdef __SASC__
57 *total = i64_atoi( "0" );
58 *block=0;
59 ret = i64_atoi( "0" );
61 return ret;
62 #else
63 *total=0;
64 *block=0;
65 return(0);
66 #endif
68 Info(mylock,&infodata);
69 if (ramdisk_lock) {
70 testlock=DupLock(mylock);
71 testlock=getrootlock(testlock);
72 if (CompareLock(testlock,ramdisk_lock)==LOCK_SAME)
73 #ifdef __SASC__
74 free = i64_uset( AvailMem( 0 ) );
75 #else
76 free=AvailMem(0);
77 #endif
78 UnLock(testlock);
79 #ifdef __SASC__
80 temp1 = i64_atoi( "-1" );
82 if ( i64_cmp( free, temp1 ) == I64_GREATER )
84 bigint quot, rema;
86 *total = free;
88 temp1 = i64_set( infodata.id_BytesPerBlock );
90 // *block=free/infodata.id_BytesPerBlock;
91 i64_udiv( free, temp1, &quot, &rema );
93 *block = quot.lo;
95 UnLock( mylock );
97 return free;
101 *total = i64_uumul( infodata.id_NumBlocks, infodata.id_BytesPerBlock );
102 // *total=((long long)infodata.id_BytesPerBlock)*infodata.id_NumBlocks;
104 temp1 = i64_uumul( infodata.id_NumBlocksUsed, infodata.id_BytesPerBlock );
106 free = i64_sub( *total, temp1 );
107 // free=*total-(infodata.id_BytesPerBlock*((long long)infodata.id_NumBlocksUsed));
109 #else
110 if (free>-1) {
111 *total=free;
112 *block=free/infodata.id_BytesPerBlock;
113 UnLock(mylock);
114 return(free);
117 *total=((long long)infodata.id_BytesPerBlock)*infodata.id_NumBlocks;
118 free=*total-(infodata.id_BytesPerBlock*((long long)infodata.id_NumBlocksUsed));
119 #endif
120 *block=infodata.id_NumBlocks-infodata.id_NumBlocksUsed;
121 UnLock(mylock);
122 return(free);
125 struct TagItem obtain_tags[]={
126 {OBP_Precision,PRECISION_EXACT},
127 {OBP_FailIfBad,TRUE},
128 {TAG_DONE,0}};
130 void get_colour_table()
132 int a,pen;
133 int num;
134 struct ColorMap *cm;
136 for (a=0;a<16;a++) {
137 screen_pens[a].red=config->new_palette[(a*3)];
138 screen_pens[a].green=config->new_palette[(a*3)+1];
139 screen_pens[a].blue=config->new_palette[(a*3)+2];
140 // screen_pens[a].pen=a;
141 screen_pens[a].alloc=0;
144 num=1<<((config->scrdepth > 4) ? 4 : config->scrdepth);
145 cm=Window->WScreen->ViewPort.ColorMap;
147 for (a=0;a<num;a++) {
148 pen = ObtainBestPenA(cm,
149 screen_pens[a].red,
150 screen_pens[a].green,
151 screen_pens[a].blue,
152 (MainScreen)?obtain_tags:NULL);
153 if (pen == -1) screen_pens[a].pen=FindColor(cm,
154 screen_pens[a].red,
155 screen_pens[a].green,
156 screen_pens[a].blue,
157 -1);
158 else
160 screen_pens[a].pen=pen;
161 screen_pens[a].alloc=1;
163 //D(bug("pen[%lu] = %lu\n",(int)a,(int)screen_pens[a].pen));
167 void free_colour_table()
169 /* if (system_version2>=OSVER_39)*/ {
170 int a;
171 struct ColorMap *cm;
173 cm=Window->WScreen->ViewPort.ColorMap;
175 for (a=0;a<16;a++) {
176 if (screen_pens[a].alloc) {
177 ReleasePen(cm,screen_pens[a].pen);
178 screen_pens[a].alloc=0;
184 void SetDrawModes(r,fg,bg,mode)
185 struct RastPort *r;
186 UBYTE fg,bg,mode;
188 // if (system_version2>=OSVER_39) {
189 SetABPenDrMd(r,
190 screen_pens[fg].pen,
191 screen_pens[bg].pen,
192 mode);
193 /* }
194 else {
195 SetAPen(r,screen_pens[fg].pen);
196 SetBPen(r,screen_pens[bg].pen);
197 SetDrMd(r,mode);
198 } */
201 void do3dbox(r,x,y,w,h)
202 struct RastPort *r;
203 int x,y,w,h;
205 Do3DBox(r,x,y,w,h,screen_pens[config->gadgettopcol].pen,screen_pens[config->gadgetbotcol].pen);