3 ; Original GPL release version 4.12
4 ; Copyright 1993-2000 Jonathan Potter
6 ; This program is free software; you can redistribute it and/or
7 ; modify it under the terms of the GNU General Public License
8 ; as published by the Free Software Foundation; either version 2
9 ; of the License, or (at your option) any later version.
11 ; This program is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ; GNU General Public License for more details.
16 ; You should have received a copy of the GNU General Public License
17 ; along with this program; if not, write to the Free Software
18 ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 ; All users of Directory Opus 4 (including versions distributed
21 ; under the GPL) are entitled to upgrade to the latest version of
22 ; Directory Opus version 5 at a reduced price. Please see
23 ; http://www.gpsoft.com.au for more information.
25 ; The release of Directory Opus 4 under the GPL in NO WAY affects
26 ; the existing commercial status of Directory Opus 5.
31 extern ULONG RangeSeed
;
33 void __saveds
GetWBScreen(register struct Screen
*screen
__asm("a0"))
37 D(bug("GetWBScreen()\n");/*Delay(50);*/)
38 if ((scr
= LockPubScreen(NULL
/*"Workbench"*/)))
40 CopyMem(scr
,screen
,sizeof(struct Screen
));
41 UnlockPubScreen(NULL
,scr
);
45 void __saveds
Seed(register int seed
__asm("d0"))
47 D(bug("Seed()\n");/*Delay(50);*/)
48 RangeSeed
= FastRand(seed
);
51 UWORD
/*__saveds*/ Random(register UWORD limit
__asm("d0"))
53 D(bug("Random()\n");/*Delay(50);*/)
54 return RangeRand(limit
+1);
57 void /*__saveds*/ BtoCStr(register BSTR bstr
__asm("a0"), register char *cstr
__asm("a1"), register int len
__asm("d0"))
60 char *c
= (char *)BADDR(bstr
);
63 //D(bug("BtoCStr()\n"));
68 for(i
=0;i
<len
;i
++) *(cstr
++)=*(c
++);
73 l
= AROS_BSTR_strlen(bstr
);
76 CopyMem(AROS_BSTR_ADDR(bstr
), cstr
, l
);
81 void SwapMem(register char *src
__asm("a0"), register char *dst
__asm("a1"), register int size
__asm("d0"))
85 //D(bug("SwapMem()\n");/*Delay(50);*/)
95 void stuffChar(register char c
__asm("d0"), register char **buf
__asm("a3"))
97 //asm("moveb %d0,%a3@+");
104 #include <exec/rawfmt.h>
106 #include <clib/alib_stdio_protos.h>
109 void __saveds __stdargs
LSprintf(char *buf
, char *fmt
, ...)
113 //D(bug("LSprintf()\n");/*Delay(50);*/)
115 // movem.l a2/a3/a6,-(sp)
119 // lea.l stuffChar(pc),a2
121 // jsr _LVORawDoFmt(a6)
123 VNewRawDoFmt(fmt
,RAWFMTFUNC_STRING
,buf
,args
);
125 RawDoFmt(fmt
,args
,stuffChar
,&buf2
);
127 // sprintf(buf,fmt,args);
129 // movem.l (sp)+,a2/a3/a6
133 unsigned char __saveds
LToUpper(register unsigned char c
__asm("d0"))
135 //D(bug("LToUpper()\n");/*Delay(50);*/)
139 unsigned char __saveds
LToLower(register unsigned char c
__asm("d0"))
141 //D(bug("LToLower()\n");/*Delay(50);*/)
145 void __saveds
StrToUpper(register unsigned char *src
__asm("a0"), register unsigned char *dst
__asm("a1"))
147 //D(bug("LStrToUpper()\n");/*Delay(50);*/)
148 while((*dst
++ = ToUpper(*src
++)));
151 void __saveds
StrToLower(register unsigned char *src
__asm("a0"), register unsigned char *dst
__asm("a1"))
153 //D(bug("LStrToLower()\n");/*Delay(50);*/)
154 while((*dst
++ = ToLower(*src
++)));
157 void /*__saveds*/ LStrnCat(register char *s1
__asm("a0"), register char *s2
__asm("a1"), register int len
__asm("d0"))
160 D(bug("LStrnCat()\n");/*Delay(50);*/)
170 void /*__saveds*/ LStrCat(register char *s1
__asm("a0"), register char *s2
__asm("a1"))
173 D(bug("LStrCat()\n");/*Delay(50);*/)
174 LStrnCat(s1
,s2
,0xffff);
177 void /*__saveds*/ LStrCpy(register char *dst
__asm("a0"), register const char *src
__asm("a1"))
180 //char *d=dst,*s=src;
181 while((*dst
++ = *src
++));
182 //D(bug("LStrCpy(%s,%s)\n",d,s);Delay(25);)
188 void /*__saveds*/ LStrnCpy(register char *dst
__asm("a0"), register const char *src
__asm("a1"), register int len
__asm("d0"))
193 //D(bug("LStrnCpy()\n");Delay(50);)
202 //strncpy(dst,src,len);
205 int __saveds
LStrnCmpI(register char *s1
__asm("a0"), register char *s2
__asm("a1"), register int len
__asm("d0"))
208 register char c1
,c2
,diff
;
209 //D(bug("LStrnCmpI()\n");/*Delay(50);*/)
218 if (diff
>0) return 1;
219 else if (diff
<0) return -1;
220 else if ((c1
==0) || (len
== 0)) break;
226 int /*__saveds*/ LStrCmpI(register char *s1
__asm("a0"), register char *s2
__asm("a1"))
229 //D(bug("LStrCmpI()\n");/*Delay(50);*/)
230 return LStrnCmpI(s1
,s2
,0x7fff);
233 int /*__saveds*/ LStrnCmp(register char *s1
__asm("a0"), register char *s2
__asm("a1"), register int len
__asm("d0"))
236 register char c1
,c2
,diff
;
238 //D(bug("LStrnCmp()\n");/*Delay(50);*/)
246 if (diff
>0) return 1;
247 else if (diff
<0) return -1;
248 else if ((c1
==0) || (len
== 0)) break;
254 int /*__saveds*/ LStrCmp(register char *s1
__asm("a0"),
255 register char *s2
__asm("a1"))
258 //D(bug("LStrCmp()\n");/*Delay(50);*/)
259 return LStrnCmp(s1
,s2
,0x7fff);
262 int atoi(const char *str
)
266 //D(bug("atoi()\n");Delay(50);)