add casts to zune macros to silence some warnings
[tangerine.git] / workbench / libs / locale / locrawdofmt.c
blob66243c18a2de76b4919ab6aefb1344ff8ca7c775
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Locale_RawDoFmt - locale.library's private replacement
6 of exec.library/RawDoFmt function. IPrefs will install
7 the patch.
9 Lang: english
12 #include <exec/types.h>
13 #include <proto/exec.h>
14 #include <proto/locale.h>
15 #include "locale_intern.h"
16 #include <aros/asmcall.h>
19 #ifdef __MORPHOS__
21 /* move.b d0,(a3)+
22 rts
24 #define ARRAY_FUNC 0x16c04e75
26 /* KPutChar
27 MOVE.L A6,-(SP) ;2F0E
28 MOVEA.L (4).L,A6 ;2C7900000004
29 JSR (-$0204,A6) ;4EAEFDFC
30 MOVEA.L (SP)+,A6 ;2C5F
31 RTS ;4E75
34 #define SERIAL_FUNC0 0x2f0e2c79
35 #define SERIAL_FUNC1 0x00000004
36 #define SERIAL_FUNC2 0x4eaefdfc
37 #define SERIAL_FUNC3 0x2c5f4e75
39 struct HookData
41 char *PutChData;
42 ULONG OldA4;
45 /* Quick reg layout function
47 #if 0
48 char *_PPCCallM68k_RawDoFmt(char MyChar,
49 char *(*PutChProc)(char*,char),
50 char *PutChData,
51 ULONG OldA4,
52 struct ExecBase *sysBase);
54 char *PPCCallM68k_RawDoFmt(char MyChar,
55 char *(*PutChProc)(char*,char),
56 char *PutChData,
57 ULONG OldA4,
58 struct ExecBase *sysBase)
60 /* As we call a *QUICK REG LAYOUT* function
61 * below we must make sure that this function backups/restores
62 * all registers
64 asm volatile (""
67 : "r13");
69 return _PPCCallM68k_RawDoFmt(MyChar,
70 PutChProc,
71 PutChData,
72 OldA4,
73 sysBase);
75 #else
76 char *PPCCallM68k_RawDoFmt(char MyChar,
77 char *(*PutChProc)(char*,char),
78 char *PutChData,
79 ULONG OldA4,
80 struct ExecBase *sysBase);
82 /* Shitty workaround for release/cisc - ignores r13 clobber */
84 __asm(".section \".text\"\n\t"
85 ".align 2\n\t"
86 ".globl PPCCallM68k_RawDoFmt\n\t"
87 ".type PPCCallM68k_RawDoFmt, @function\n"
88 "PPCCallM68k_RawDoFmt:\n\t"
89 "stwu 1, -96(1)\n\t"
90 "mflr 0\n\t"
91 "stmw 13, 20(1)\n\t"
92 "stw 0, 100(1)\n\t"
93 "bl _PPCCallM68k_RawDoFmt\n\t"
94 "lwz 0, 100(1)\n\t"
95 "mtlr 0\n\t"
96 "lmw 13, 20(1)\n\t"
97 "la 1, 96(1)\n\t"
98 "blr\n"
99 ".LfeN:\n\t"
100 ".size PPCCallM68k_RawDoFmt, .LfeN - PPCCallM68k_RawDoFmt"
102 #endif
104 #endif
107 AROS_UFH3(VOID, LocRawDoFmtFormatStringFunc,
108 AROS_UFHA(struct Hook *, hook, A0),
109 AROS_UFHA(struct Locale *, locale, A2),
110 AROS_UFHA(char, fill, A1))
112 AROS_USERFUNC_INIT
115 #ifdef __MORPHOS__
116 struct HookData *data = hook->h_Data;
118 switch ((ULONG) hook->h_SubEntry)
120 case 0:
121 /* Standard Array Function */
122 *data->PutChData++ = fill;
123 break;
124 case 1:
125 /* Standard Serial Function */
126 dprintf("%c",fill);
127 break;
128 default:
129 data->PutChData = PPCCallM68k_RawDoFmt(fill,
130 hook->h_SubEntry,
131 data->PutChData,
132 data->OldA4,
133 SysBase);
134 break;
136 #else
138 #ifdef __mc68000__
139 register char *pdata asm("a3") = hook->h_Data;
140 #else
141 char *pdata = hook->h_Data;
142 #endif
144 if (hook->h_SubEntry)
146 AROS_UFC3(void, hook->h_SubEntry,
147 AROS_UFCA(char, fill, D0),
148 AROS_UFCA(APTR, pdata, A3),
149 AROS_UFCA(struct ExecBase *, SysBase, A6));
151 else
153 *pdata++ = fill;
156 hook->h_Data = pdata;
157 #endif
159 AROS_USERFUNC_EXIT
162 #undef LocaleBase
164 /*****************************************************************************
166 NAME */
167 #include <proto/locale.h>
169 AROS_PLH4(APTR, LocRawDoFmt,
171 /* SYNOPSIS */
172 AROS_LHA(CONST_STRPTR, FormatString, A0),
173 AROS_LHA(APTR , DataStream, A1),
174 AROS_LHA(VOID_FUNC , PutChProc, A2),
175 AROS_LHA(APTR , PutChData, A3),
177 /* LOCATION */
178 struct ExecBase *, SysBase, 31, Locale)
180 /* FUNCTION
181 See exec.library/RawDoFmt
183 INPUTS
184 See exec.library/RawDoFmt
186 RESULT
188 NOTES
189 This function is not called by apps directly. Instead dos.library/DosGet-
190 LocalizedString is patched to use this function. This means, that the
191 LocaleBase parameter above actually points to SysBase, so we make use of
192 the global LocaleBase variable. This function is marked as private,
193 thus the headers generator won't mind the different basename in the header.
195 EXAMPLE
197 BUGS
199 SEE ALSO
200 RawDoFmt(), FormatString().
202 INTERNALS
204 HISTORY
205 27-11-96 digulla automatically created from
206 locale_lib.fd and clib/locale_protos.h
208 *****************************************************************************/
210 AROS_LIBFUNC_INIT
212 struct Hook hook;
213 APTR retval;
215 #ifdef __MORPHOS__
216 struct HookData data;
218 if ((ULONG) PutChProc > 1)
220 if (*((ULONG*) PutChProc) == ARRAY_FUNC)
222 PutChProc = 0;
224 #if 0
226 * This is the job of exec
228 else if ((((ULONG*) PutChProc)[0] == SERIAL_FUNC0) &&
229 (((ULONG*) PutChProc)[1] == SERIAL_FUNC1) &&
230 (((ULONG*) PutChProc)[2] == SERIAL_FUNC2) &&
231 (((ULONG*) PutChProc)[3] == SERIAL_FUNC3))
233 PutChProc = (APTR) 1;
235 #endif
238 hook.h_Entry = (HOOKFUNC)AROS_ASMSYMNAME(LocRawDoFmtFormatStringFunc);
239 hook.h_SubEntry = (HOOKFUNC)PutChProc;
240 hook.h_Data = &data;
241 data.PutChData = PutChData;
242 data.OldA4 = REG_A4;
244 #else
246 hook.h_Entry = (HOOKFUNC)AROS_ASMSYMNAME(LocRawDoFmtFormatStringFunc);
247 hook.h_SubEntry = (HOOKFUNC)PutChProc;
248 hook.h_Data = PutChData;
250 #endif
252 //kprintf("LocRawDoFmt: FormatString = \"%s\"\n", FormatString);
254 REPLACEMENT_LOCK;
256 retval = FormatString(&(IntLB(LocaleBase)->lb_CurrentLocale->il_Locale),
257 (STRPTR)FormatString,
258 DataStream,
259 &hook);
261 REPLACEMENT_UNLOCK;
263 //kprintf("LocRawDoFmt: FormatString: returning %x\n", retval);
265 return retval;
267 AROS_LIBFUNC_EXIT
269 } /* LocRawDoFmt */