2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
5 Desc: Locale_RawDoFmt - locale.library's private replacement
6 of exec.library/RawDoFmt function. IPrefs will install
12 #include <exec/rawfmt.h>
13 #include <exec/types.h>
14 #include <proto/exec.h>
15 #include <proto/locale.h>
16 #include "locale_intern.h"
17 #include <aros/asmcall.h>
25 #define ARRAY_FUNC 0x16c04e75
29 MOVEA.L (4).L,A6 ;2C7900000004
30 JSR (-$0204,A6) ;4EAEFDFC
31 MOVEA.L (SP)+,A6 ;2C5F
35 #define SERIAL_FUNC0 0x2f0e2c79
36 #define SERIAL_FUNC1 0x00000004
37 #define SERIAL_FUNC2 0x4eaefdfc
38 #define SERIAL_FUNC3 0x2c5f4e75
46 /* Quick reg layout function
49 char *_PPCCallM68k_RawDoFmt(char MyChar
,
50 char *(*PutChProc
)(char*,char),
53 struct ExecBase
*sysBase
);
55 char *PPCCallM68k_RawDoFmt(char MyChar
,
56 char *(*PutChProc
)(char*,char),
59 struct ExecBase
*sysBase
)
61 /* As we call a *QUICK REG LAYOUT* function
62 * below we must make sure that this function backups/restores
70 return _PPCCallM68k_RawDoFmt(MyChar
,
77 char *PPCCallM68k_RawDoFmt(char MyChar
,
78 char *(*PutChProc
)(char*,char),
81 struct ExecBase
*sysBase
);
83 /* Shitty workaround for release/cisc - ignores r13 clobber */
85 __asm(".section \".text\"\n\t"
87 ".globl PPCCallM68k_RawDoFmt\n\t"
88 ".type PPCCallM68k_RawDoFmt, @function\n"
89 "PPCCallM68k_RawDoFmt:\n\t"
94 "bl _PPCCallM68k_RawDoFmt\n\t"
101 ".size PPCCallM68k_RawDoFmt, .LfeN - PPCCallM68k_RawDoFmt"
108 AROS_UFH3(VOID
, LocRawDoFmtFormatStringFunc
,
109 AROS_UFHA(struct Hook
*, hook
, A0
),
110 AROS_UFHA(struct Locale
*, locale
, A2
),
111 AROS_UFHA(char, fill
, A1
))
116 register char *pdata
asm("a3") = hook
->h_Data
;
118 char *pdata
= hook
->h_Data
;
121 switch ((IPTR
)hook
->h_SubEntry
)
123 case (IPTR
)RAWFMTFUNC_STRING
:
124 /* Standard Array Function */
127 case (IPTR
)RAWFMTFUNC_SERIAL
:
128 /* Standard Serial Function */
131 case (IPTR
)RAWFMTFUNC_COUNT
:
132 /* Standard Count Function */
133 (*((ULONG
*)pdata
))++;
136 AROS_UFC3(void, hook
->h_SubEntry
,
137 AROS_UFCA(char, fill
, D0
),
138 AROS_UFCA(APTR
, pdata
, A3
),
139 AROS_UFCA(struct ExecBase
*, SysBase
, A6
));
141 hook
->h_Data
= pdata
;
148 /*****************************************************************************
151 #include <proto/locale.h>
153 AROS_PLH4(APTR
, LocRawDoFmt
,
156 AROS_LHA(CONST_STRPTR
, FormatString
, A0
),
157 AROS_LHA(APTR
, DataStream
, A1
),
158 AROS_LHA(VOID_FUNC
, PutChProc
, A2
),
159 AROS_LHA(APTR
, PutChData
, A3
),
162 struct ExecBase
*, SysBase
, 31, Locale
)
165 See exec.library/RawDoFmt
168 See exec.library/RawDoFmt
173 This function is not called by apps directly. Instead dos.library/DosGet-
174 LocalizedString is patched to use this function. This means, that the
175 LocaleBase parameter above actually points to SysBase, so we make use of
176 the global LocaleBase variable. This function is marked as private,
177 thus the headers generator won't mind the different basename in the header.
184 RawDoFmt(), FormatString().
189 27-11-96 digulla automatically created from
190 locale_lib.fd and clib/locale_protos.h
192 *****************************************************************************/
200 struct HookData data
;
202 if ((ULONG
) PutChProc
> 1)
204 if (*((ULONG
*) PutChProc
) == ARRAY_FUNC
)
210 * This is the job of exec
212 else if ((((ULONG
*) PutChProc
)[0] == SERIAL_FUNC0
) &&
213 (((ULONG
*) PutChProc
)[1] == SERIAL_FUNC1
) &&
214 (((ULONG
*) PutChProc
)[2] == SERIAL_FUNC2
) &&
215 (((ULONG
*) PutChProc
)[3] == SERIAL_FUNC3
))
217 PutChProc
= (APTR
) 1;
222 hook
.h_Entry
= (HOOKFUNC
)AROS_ASMSYMNAME(LocRawDoFmtFormatStringFunc
);
223 hook
.h_SubEntry
= (HOOKFUNC
)PutChProc
;
225 data
.PutChData
= PutChData
;
230 hook
.h_Entry
= (HOOKFUNC
)AROS_ASMSYMNAME(LocRawDoFmtFormatStringFunc
);
231 hook
.h_SubEntry
= (HOOKFUNC
)PutChProc
;
232 hook
.h_Data
= PutChData
;
236 //kprintf("LocRawDoFmt: FormatString = \"%s\"\n", FormatString);
240 retval
= FormatString(&(IntLB(LocaleBase
)->lb_CurrentLocale
->il_Locale
),
241 (STRPTR
)FormatString
,
247 //kprintf("LocRawDoFmt: FormatString: returning %x\n", retval);