6 ; Miscellaneous assembly stuff.
8 ; (C) Copyright 1998 Manuel Lemos.
9 ; (C) Copyright 1996-1997 Ian J. Einman.
10 ; (C) Copyright 1993-1996 Jaba Development.
11 ; (C) Copyright 1993-1996 Jan van den Baard.
12 ; All Rights Reserved.
15 ; Revision 42.1 2000/08/08 14:08:00 chodorowski
16 ; Minor fixes to make BGUI compile on Amiga.
18 ; Revision 42.0 2000/05/09 22:09:45 mlemos
19 ; Bumped to revision 42.0 before handing BGUI to AROS team
21 ; Revision 41.11 2000/05/09 19:54:47 mlemos
22 ; Merged with the branch Manuel_Lemos_fixes.
24 ; Revision 41.10.2.4 1998/12/14 05:04:36 mlemos
25 ; Moved the method dispatcher to a C function in classes.c .
27 ; Revision 41.10.2.3 1998/10/01 04:28:50 mlemos
28 ; Made the global class dispatcher function get BGUI global data pointer into
29 ; register a4 and class global data pointer to a5 exchanging registers before
30 ; calling the method function.
32 ; Revision 41.10.2.2 1998/09/12 02:18:19 mlemos
33 ; Added Janne patch to call the stack extension code.
35 ; Revision 41.10.2.1 1998/02/27 03:32:08 mlemos
36 ; Moved funcdef.i include to exec_lib.i
38 ; Revision 41.10 1998/02/25 21:12:42 mlemos
41 ; Revision 1.1 1998/02/25 17:09:11 mlemos
47 XDEF _DisplayAGuideInfo
50 XREF _UtilityBase
,_GfxBase
,_IntuitionBase
52 XREF _EnsureStack
,_RevertStack
62 include "include:exec/exec_lib.i"
63 include "include:utility/hooks.i"
64 include "include:utility/utility_lib.i"
65 include "include:intuition/classes.i"
66 include "include:intuition/cghooks.i"
67 include "include:intuition/intuition_lib.i"
68 include "include:graphics/graphics_lib.i"
69 include "include:libraries/amigaguide_lib.i"
71 ;makeproto __stdargs BOOL DisplayAGuideInfo(struct NewAmigaGuide *, Tag, ...);
74 movem.l a2
/a6
,-(a7
) ; save regs
75 move.l
4.w
,A6
; SysBase to a6
76 lea aguideName
(pc
),a1
; libname to a1
77 moveq #
0,D0
; any version
80 beq.s noSuccess
; Noop!
81 move.l d0
,a6
; move base to a6
82 move.l
12(a7
),a0
; nag to a0
83 lea 16(a7
),a1
; attr pointer to a1
87 move.l d0
,a0
; move to a0
90 moveq #
1,d0
; TRUE 4 success
91 movem.l
(a7
)+,a2
/a6
; pop regs
94 noSuccess moveq #
0,d0
; FALSE 4 failure
97 LibClose move.l a6
,a1
; base to a1
98 move.l
4.w
,a6
; SysBase to a6
102 ;makeproto ASM ULONG ScaleWeight(REG(d2) ULONG e, REG(d3) ULONG f, REG(d4) ULONG a);
104 _ScaleWeight move.l a6
,-(a7
)
105 move.l _UtilityBase
(a4
),a6
117 XDEF _SPrintfA
,_StrLenfA
119 ; len = StrLenfA(format, args);
121 ; Returns the length of the formatted string.
122 ; The length returned is including the terminating
125 ;makeproto __stdargs ASM ULONG StrLenfA(REG(a0) UBYTE *, REG(a1) ULONG *);
127 _StrLenfA movem.l a2
-a3
/a6
,-(a7
)
128 suba.l a3
,a3
; Counter in a3
129 lea incCnt
(pc
),a2
; Counter routine in a2
132 move.l a3
,d0
; Counter as return code
133 movem.l
(a7
)+,a2
-a3
/a6
; Pop registers
135 incCnt addq.l #
1,a3
; Increase the counter by one
139 ; SPrintfA( buffer, format, args );
141 ; Perform fomatted output into a buffer.
143 ;makeproto __stdargs ASM VOID SPrintfA(REG(a3) UBYTE *, REG(a0) UBYTE *, REG(a1) ULONG *);
145 _SPrintfA movem.l a2
-a3
/a6
,-(a7
)
146 lea putChar
(pc
),a2
; Byte copy routine in a2
149 movem.l
(a7
)+,a2
-a3
/a6
; Pop registers
151 putChar move.b d0
,(a3
)+ ; Put formatted char in buffer
155 XDEF _LHook_Format
,_LHook_Count
157 ;makeproto ASM VOID LHook_Count(REG(a0) struct Hook *hook, REG(a1) ULONG chr, REG(a2) struct Locale *loc);
159 _LHook_Count addq.l #
1,h_Data
(a0
)
162 ;makeproto ASM VOID LHook_Format(REG(a0) struct Hook *hook, REG(a1) ULONG chr, REG(a2) struct Locale *loc);
164 _LHook_Format move.l a1
,d0
170 ;------------------ Method Functions --------------------------------
172 XDEF _AsmDoMethod
,_AsmDoMethodA
173 XDEF _AsmCoerceMethod
,_AsmCoerceMethodA
174 XDEF _AsmDoSuperMethod
,_AsmDoSuperMethodA
176 ;makeproto ULONG AsmDoMethod( Object *, ... );
178 _AsmDoMethod move.l a2
,-(a7
)
179 lea 8(a7
),a1
; Msg pointer in A1
180 move.l
(a1
)+,a2
; Object to A2
181 bra.s doMethod
; Call method
183 ;makeproto ULONG AsmDoSuperMethod( Class *, Object *, ... );
185 _AsmDoSuperMethod move.l a2
,-(a7
)
186 lea 8(a7
),a1
; Msg pointer in A1
187 movem.l
(a1
)+,a0
/a2
; Class in A0, Object to A2
190 ;makeproto ULONG AsmCoerceMethod( Class *, Object *, ... );
192 _AsmCoerceMethod move.l a2
,-(a7
)
193 lea 8(a7
),a1
; Msg pointer in A1
194 movem.l
(a1
)+,a0
/a2
; Class in A0, Object to A2
195 bra.s doCoerce
; Call method
197 ;makeproto ASM ULONG AsmDoMethodA( REG(a2) Object *, REG(a1) Msg );
199 _AsmDoMethodA move.l a2
,-(a7
)
200 doMethod move.l
-4(a2
),a0
; Object class to A0
201 bra.s doCoerce
; Call method
203 ;makeproto ASM ULONG AsmDoSuperMethodA( REG(a0) Class *, REG(a2) Object *, REG(a1) Msg );
205 _AsmDoSuperMethodA move.l a2
,-(a7
)
206 doSuper move.l
24(a0
),a0
; cl_Super to A0
209 ;makeproto ASM ULONG AsmCoerceMethodA( REG(a0) Class *, REG(a2) Object *, REG(a1) Msg );
211 _AsmCoerceMethodA move.l a2
,-(a7
)
212 doCoerce pea .rts
(pc
) ; Push method return address
213 move.l
8(a0
),-(a7
) ; Push class h_Entry
214 rts
; Jump to class dispatcher
215 .rts move.l
(a7
)+,a2
; Restore A2
220 XDEF _BGUI_ObtainGIRPort
222 ; This routine will prevent
223 ; BGUI to lockup when used
224 ; with hacks like MagicMenu.
227 ;makeproto ASM struct RastPort *BGUI_ObtainGIRPort( REG(a0) struct GadgetInfo * );
230 movem.l a3
/a6
,-(a7
) ; save a6
233 beq.s .no.gi
; NULL gadget info, call intuition.
234 movem.l a0
/a5
,-(a7
) ; save some regs.
235 move.l ggi_Window
(a0
),d0
238 move.l wd_UserData
(a5
),a3
239 .no.win move.l _GfxBase
(a4
),a6
240 move.l ggi_Layer
(a0
),a5
242 beq.s .no.layer
; no layer, call intuition.
245 beq.s .no.
lock ; no lock, return NULL
247 .no.layer movem.l
(a7
)+,a0
/a5
248 .no.gi move.l _IntuitionBase
(a4
),a6
253 move.l a3
,rp_RP_User
(a0
)
254 .no.rp movem.l
(a7
)+,a3
/a6
256 .no.
lock movem.l
(a7
)+,a0
/a5
261 aguideName dc.b
'amigaguide.library',0