Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / reqtools / closewinsafely.asm
blobb72d9a9226116b3c06849d06bdc40f95ebfd8259
2 INCLUDE "libraries/reqtools.i"
3 INCLUDE "intuition/intuition.i"
5 XDEF _CloseWindowSafely
7 TDNestCnt equ $127
9 _LVORemove equ -$fc
10 _LVOCloseWindow equ -$48
11 _LVOModifyIDCMP equ -$96
12 _LVOPermit equ -$8A
13 _LVOReplyMsg equ -$17A
15 * window in A0
16 _CloseWindowSafely:
17 movem.l a0/a2/a5-a6,-(a7)
18 move.l rt_IntuitionBase(a6),a5
19 move.l $4.w,a6
20 addq.b #1,TDNestCnt(a6)
21 lab2:
22 move.l (a7),a0
23 move.l wd_UserPort(a0),d0
24 beq.s exitclosewinsafely
26 movea.l d0,a2
27 move.l MP_MSGLIST+LH_HEAD(a2),a2
29 removemsgloop:
30 move.l a2,a1
31 move.l im_ExecMessage+LN_SUCC(a1),d0
32 beq.b clearport
33 move.l d0,a2
35 move.l (a7),a0
36 cmp.l im_IDCMPWindow(a1),a0
37 bne.b nomsgfromourwin
39 move.l a1,-(a7)
40 jsr _LVORemove(a6)
41 move.l (a7)+,a1
42 jsr _LVOReplyMsg(a6)
44 nomsgfromourwin:
45 bra.b removemsgloop
47 clearport:
48 move.l (a7),a0
49 clr.l wd_UserPort(a0)
50 moveq #0,d0
51 exg.l a5,a6
52 jsr _LVOModifyIDCMP(a6)
53 exg.l a5,a6
55 exitclosewinsafely:
56 movea.l (a7),a0
57 jsr _LVOPermit(a6)
58 exg.l a5,a6
59 jsr _LVOCloseWindow(a6)
60 movem.l (a7)+,a0/a2/a5-a6
61 rts