8 INCLUDE "exec/funcdef.i"
9 INCLUDE "lvo/exec_lib.i"
10 INCLUDE "exec/nodes.i"
11 INCLUDE "exec/lists.i"
12 INCLUDE "exec/alerts.i"
13 INCLUDE "exec/libraries.i"
14 INCLUDE "exec/memory.i"
16 INCLUDE "lvo/dos_lib.i"
18 INCLUDE "graphics/gfxbase.i"
19 INCLUDE "intuition/intuition.i"
20 INCLUDE "intuition/classes.i"
21 INCLUDE "intuition/classusr.i"
22 INCLUDE "intuition/screens.i"
23 INCLUDE "lvo/intuition_lib.i"
24 INCLUDE "utility/hooks.i"
26 INCLUDE "libraries/reqtools.i"
27 INCLUDE "lvo/reqtools_lib.i"
29 INCLUDE "boopsigads.i"
31 XREF _myBoopsiDispatch
32 XREF _FreeReqToolsFonts
39 dc.l ReqToolsBase_SIZE
47 dc.b
"intuition.library",0
49 dc.b
"graphics.library",0
51 dc.b
"gadtools.library",0
53 dc.b
"utility.library",0
55 dc.b
"layers.library",0
57 dc.b
"locale.library",0
59 dc.b
"console.device",0
63 dc.b
"ReqTools.prefs",0
65 ; dc.l __BSSLEN ; we need this line for Blink to generate BSS!
69 *****************************************************************************
71 ; D1 must hold default size, A1 is advanced, D1 is preserved
73 move.l d1
,(a0
)+ ; rtrd_Size
74 moveq #REQPOS_TOPLEFTSCR
,d0
75 move.l d0
,(a0
)+ ; rtrd_ReqPos
76 InitReqDefs_NoSizeNoReqPos:
78 move.w d0
,(a0
)+ ; rtrd_LeftOffset
80 move.w d0
,(a0
)+ ; rtrd_TopOffset
82 move.w d0
,(a0
)+ ; rtrd_MinEntries
84 move.w d0
,(a0
)+ ; rtrd_MaxEntries
88 ; d0 = library pointer, a0 = seglist, a6 = sysbase
89 ; -> d0 = non zero if lib must be linked in the system list
91 movem.l d2
/a2
/a4
-a6
,-(a7
) ; MUST BE SAME AS EXPUNGELIB !!!!!
94 move.l d0
,(a4
) ; our base to be used in C routines
95 move.l a6
,_SysBase
-_ReqToolsBase
(a4
)
96 move.l a0
,rt_SegList
(a5
)
98 move.w #ReqToolsBase_SIZE
,d0
; set everything private to 0
99 sub.w #rt_RealOpenCnt
+1,d0
100 lea rt_RealOpenCnt
(a5
),a0
105 ; Fill in preference size
106 move.l #RTPREFS_SIZE
,rt_ReqToolsPrefs
+rtpr_PrefsSize
(a5
)
108 ; Initialize prefs semaphore
109 lea rt_ReqToolsPrefs
+rtpr_PrefsSemaphore
(a5
),a0
110 jsr _LVOInitSemaphore
(a6
)
112 ; Set default preferences
113 lea rt_ReqToolsPrefs
+rtpr_ReqDefaults
(a5
),a0
115 bsr.b InitReqDefaults
; RTPREF_FILEREQ
116 move.w #
10,-4(a0
) ; set min entries to 10
117 move.w #
50,-2(a0
) ; set max entries to 50
119 bsr.b InitReqDefaults
; RTPREF_FONTREQ
120 bsr.b InitReqDefaults
; RTPREF_PALETTEREQ, size ignored
121 bsr.b InitReqDefaults
; RTPREF_SCREENMODEREQ
122 bsr.b InitReqDefaults
; RTPREF_VOLUMEREQ
124 bsr.b InitReqDefs_NoSizeNoReqPos
; RTPREF_OTHERREQ
127 jsr _LVOOldOpenLibrary
(a6
)
128 move.l d0
,_IntuitionBase
-_ReqToolsBase
(a4
)
129 move.l d0
,rt_IntuitionBase
(a5
)
134 cmp.w LIB_VERSION
(a0
),d0
; is version >= 37
137 lea kickalertstr
(PC
),a0
141 jsr _LVODisplayAlert
(a6
)
147 lea imageclass
(PC
),a1
152 jsr _LVOMakeClass
(a6
)
154 move.l d0
,_ButtonImgClass
-_ReqToolsBase
(a4
)
155 beq errorinitlib
; A6 MUST hold IntuitionBase!
158 move.l #_myBoopsiDispatch
,cl_Dispatcher
+h_Entry
(a1
)
162 jsr _LVOOldOpenLibrary
(a6
)
163 move.l d0
,_GadToolsBase
-_ReqToolsBase
(a4
)
164 move.l d0
,rt_GadToolsBase
(a5
)
167 jsr _LVOOldOpenLibrary
(a6
)
168 move.l d0
,_DOSBase
-_ReqToolsBase
(a4
)
169 move.l d0
,rt_DOSBase
(a5
)
171 ; Get current ReqTools preferences (D0 = DOSBase)
172 movem.l d2
-d4
/a6
,-(a7
)
176 lea rt_ReqToolsPrefs
+rtpr_Flags
(a5
),a0
178 move.l rt_ReqToolsPrefs
+rtpr_PrefsSize
(a5
),d3
179 move.l #GVF_BINARY_VAR
!GVF_GLOBAL_ONLY
!LV_VAR
,d4
181 movem.l
(a7
)+,d2
-d4
/a6
184 jsr _LVOOldOpenLibrary
(a6
)
185 move.l d0
,_GfxBase
-_ReqToolsBase
(a4
)
186 move.l d0
,rt_GfxBase
(a5
)
190 jsr _LVOOldOpenLibrary
(a6
)
191 move.l d0
,_UtilityBase
-_ReqToolsBase
(a4
)
192 move.l d0
,rt_UtilityBase
(a5
)
194 lea layersName
(PC
),a1
195 jsr _LVOOldOpenLibrary
(a6
)
196 move.l d0
,_LayersBase
-_ReqToolsBase
(a4
)
198 lea localeName
(PC
),a1
199 jsr _LVOOldOpenLibrary
(a6
)
200 move.l d0
,_LocaleBase
-_ReqToolsBase
(a4
)
202 lea consoleName
(PC
),a0
203 lea iorequest
-_ReqToolsBase
(a4
),a1
206 jsr _LVOOpenDevice
(a6
)
207 move.l iorequest
-_ReqToolsBase
+IO_DEVICE
(a4
),d0
208 move.l d0
,_ConsoleDevice
-_ReqToolsBase
(a4
)
211 movem.l
(a7
)+,d2
/a2
/a4
-a6
216 dc.b
"This version of reqtools.library needs Kickstart 2.0 V37+",0,0
221 ; d0 = version, a6 = ptr to lib
224 ; addq.w #1,LIB_OPENCNT(a6)
225 addq.w #
1,rt_RealOpenCnt
(a6
)
226 ; bclr.b #LIBB_DELEXP,rt_RTFlags(a6) ; Prevent delayed expunges
232 ; -> d0 = return seglist if lib is completely closed and delayed expunge
235 ; subq.w #1,LIB_OPENCNT(a6)
236 subq.w #
1,rt_RealOpenCnt
(a6
)
239 ; btst #LIBB_DELEXP,rt_RTFlags(a6)
244 ; Expunge the library
246 ; -> d0 = seglist if library is no longer open
248 movem.l d2
/a2
/a4
-a6
,-(a7
) ; MUST BE SAME AS INITLIB !!!!!
252 tst.w rt_AvailFontsLock
(a5
)
255 jsr _FreeReqToolsFonts
(PC
)
258 ; tst.w LIB_OPENCNT(a5)
259 tst.w rt_RealOpenCnt
(a5
)
262 ; bset.b #LIBB_DELEXP,rt_RTFlags(a5) ; still open, set delayed expunge flag
267 move.l rt_SegList
(a5
),d2
269 jsr _LVORemove
(a6
) ; remove lib
271 jsr _LVOCloseDevice
(a6
) ; close console.device
272 move.l rt_DOSBase
(a5
),a1
273 jsr _LVOCloseLibrary
(a6
) ; close DOS
274 move.l rt_GadToolsBase
(a5
),a1
275 jsr _LVOCloseLibrary
(a6
) ; close GadTools
276 move.l rt_GfxBase
(a5
),a1
277 jsr _LVOCloseLibrary
(a6
) ; close Gfx
278 move.l rt_UtilityBase
(a5
),a1
279 jsr _LVOCloseLibrary
(a6
) ; close Utility
280 move.l _LayersBase
,a1
281 jsr _LVOCloseLibrary
(a6
)
282 move.l _LocaleBase
,a1
283 jsr _LVOCloseLibrary
(a6
)
284 move.l rt_IntuitionBase
(a5
),a6
285 move.l _ButtonImgClass
,a0
286 jsr _LVOFreeClass
(a6
) ; free image class
290 jsr _LVOCloseLibrary
(a6
) ; close Intuition
294 move.w LIB_NEGSIZE
(a5
),d0
296 add.w LIB_POSSIZE
(a5
),d0
297 jsr _LVOFreeMem
(a6
) ; free our mem
298 move.l d2
,d0
; seglist
300 movem.l
(a7
)+,d2
/a2
/a4
-a6
303 ; Do nothing function
308 ******************************************************************************
312 ******************************************************************************
320 XREF _PaletteRequestA
322 XREF _CloseWindowSafely
339 dc.l rtInternalGetPasswordA
; private
340 dc.l rtInternalEnterPasswordA
; private
341 dc.l _FileRequestA
; = _FontRequestA!
342 dc.l _PaletteRequestA
344 dc.l rtSetWaitPointer
346 dc.l rtSetReqPosition
348 dc.l rtScreenToFrontSafely
349 dc.l _FileRequestA
; rtScreenModeRequestA
350 dc.l _CloseWindowSafely
353 ; private funcs for preferences
358 *----------------------------------------------------------------------------*
360 * struct ReqToolsPrefs
*rtLockPrefs
(void
);
365 lea rt_ReqToolsPrefs
+rtpr_PrefsSemaphore
(a6
),a0
367 jsr _LVOObtainSemaphore
(a6
)
369 lea rt_ReqToolsPrefs
(a6
),a0
373 *----------------------------------------------------------------------------*
375 * void rtUnlockPrefs
(void
);
379 lea rt_ReqToolsPrefs
+rtpr_PrefsSemaphore
(a6
),a0
381 jsr _LVOReleaseSemaphore
(a6
)
393 *----------------------------------------------------------------------------*
395 * BOOL rtInternalEnterPasswordA
(UBYTE
*, char
*(*)(), struct TagItem
*);
398 rtInternalEnterPasswordA:
399 movem.l d2
-d4
/a2
,-(a7
)
400 moveq #ENTER_PASSWORD
,d3
403 *----------------------------------------------------------------------------*
405 * BOOL rtInternalGetPasswordA
(UBYTE
*, ULONG
, char
*(*)(), struct TagItem
*);
408 rtInternalGetPasswordA:
409 movem.l d2
-d4
/a2
,-(a7
)
410 moveq #CHECK_PASSWORD
,d3
416 bra.b GetStr_PopD2toD4_A2_RTS
422 *----------------------------------------------------------------------------*
424 * (UBYTE
*, ULONG
, char
*, struct rtReqInfo
*, struct TagItem
*);
427 XREF _CheckStackCallFunc
430 movem.l d2
-d4
/a2
,-(a7
)
431 moveq #ENTER_STRING
,d3
432 GetStr_PopD2toD4_A2_RTS:
436 jsr _CheckStackCallFunc
(PC
)
438 movem.l
(a7
)+,d2
-d4
/a2
441 *----------------------------------------------------------------------------*
443 * (char
*, char
*, struct rtReqInfo
*, APTR
, struct TagItem
*);
447 movem.l d2
-d4
/a2
,-(a7
)
449 moveq #IS_EZREQUEST
,d3
450 bra.b GetStr_PopD2toD4_A2_RTS
452 *----------------------------------------------------------------------------*
453 * BOOL rtGetLongA
(ULONG
*, char
*, struct rtReqInfo
*, struct TagItem
*);
457 movem.l d2
-d4
/a2
,-(a7
)
459 moveq #ENTER_NUMBER
,d3
460 bra.b GetStr_PopD2toD4_A2_RTS
462 *----------------------------------------------------------------------------*
463 * ULONG rtReqHandlerA
(APTR
, ULONG
*, struct TagItem
*);
469 move.l
(a1
),-(a7
) ; first longword holds real function address!
472 *----------------------------------------------------------------------------*
473 * void rtSetWaitPointer
(struct Window
*);
479 movem.l d2
/d3
/a6
,-(a7
)
482 cmp.w LIB_VERSION
(a1
),d0
; is version >= 39
489 move.l rt_IntuitionBase
(a6
),a6
490 jsr _LVOSetPointer
(a6
)
491 bra.b .endsetwaitpointer
493 lea setpointertaglist
(PC
),a1
494 move.l rt_IntuitionBase
(a6
),a6
495 jsr _LVOSetWindowPointerA
(a6
)
497 movem.l
(a7
)+,d2
/d3
/a6
501 dc.l WA_BusyPointer
,1,TAG_DONE
503 *----------------------------------------------------------------------------*
504 * APTR rtLockWindow
(struct Window
*);
507 STRUCTURE rtWindowLock
,0
508 * requester structure
(MUST BE FIRST ITEM
!!!)
509 STRUCT rtwl_Requester
,rq_SIZEOF
511 ULONG rtwl_RequesterPtr
513 ULONG rtwl_ReqInstalled
514 * same as
in Window structure
(same order as well
!)
526 LOCKWINMAGIC
equ 'rtLW'
529 movem.l d2
/d3
/a0
/a2
/a6
,-(a7
) ; DON'T CHANGE THIS WITHOUT THINKING!!
531 * First see if we already locked
this window.
532 move.l wd_FirstRequest
(a0
),a1
537 move.l rtwl_Magic
(a1
),d0
538 cmp.l #LOCKWINMAGIC
,d0
541 cmp.l rtwl_RequesterPtr
(a1
),a1
548 * If the window was already locked increase
lock-count
551 addq.l #
1,rtwl_LockCount
(a1
)
552 move.l a1
,d0
; return window lock
557 move.l #rtwl_SIZEOF
,d0
558 move.l #MEMF_CLEAR
,d1
567 move.l d0
,rtwl_RequesterPtr
(a2
)
568 move.l #LOCKWINMAGIC
,rtwl_Magic
(a2
)
570 move.l rt_IntuitionBase
(a6
),a6
572 move.l
8(a7
),a0
; A0 on stack + 8 = window ptr
573 lea rtwl_MinWidth
(a2
),a1
574 move.l wd_MinWidth
(a0
),(a1
)+ ; remember wd_MinWidth and wd_MinHeight
575 move.l wd_MaxWidth
(a0
),(a1
)+ ; remember wd_MaxWidth and wd_MaxHeight
577 move.w wd_Width
(a0
),d0
579 move.w wd_Height
(a0
),d1
582 jsr _LVOWindowLimits
(a6
) ; set window limits to current size
585 jsr _LVOInitRequester
(a6
)
587 move.l
8(a7
),a1
; A0 on stack + 8 = window ptr
590 move.l d0
,rtwl_ReqInstalled
(a2
)
594 lea rtwl_Pointer
(a2
),a1
595 move.l wd_Pointer
(a0
),(a1
)+ ; remember wd_Pointer
596 move.l wd_PtrHeight
(a0
),(a1
)+ ; remember wd_PtrHeight, wd_PtrWidth,...
597 jsr _LVOrtSetWaitPointer
(a6
)
601 movem.l
(a7
)+,d2
/d3
/a0
/a2
/a6
604 *----------------------------------------------------------------------------*
605 * ULONG rtUnLockWindow
(struct Window
*, APTR
lock);
609 movem.l d2
/d3
/a0
/a1
/a6
,-(a7
)
613 move.l rtwl_LockCount
(a1
),d0
616 subq.l #
1,rtwl_LockCount
(a1
)
620 * restore old window pointer
621 move.l rt_IntuitionBase
(a6
),a6
622 tst.l rtwl_Pointer
(a1
)
626 move.b rtwl_PtrHeight
(a1
),d0
628 move.b rtwl_PtrWidth
(a1
),d1
629 move.b rtwl_XOffset
(a1
),d2
632 move.b rtwl_YOffset
(a1
),d3
635 move.l rtwl_Pointer
(a1
),a1
636 jsr _LVOSetPointer
(a6
)
639 jsr _LVOClearPointer
(a6
)
643 tst.l rtwl_ReqInstalled
(a1
)
647 jsr _LVOEndRequest
(a6
)
651 * restore wd_MinWidth
, wd_MinHeight
, wd_MaxWidth
and wd_MaxHeight
653 move.w rtwl_MinWidth
(a1
),d0
655 move.w rtwl_MinHeight
(a1
),d1
657 move.w rtwl_MaxWidth
(a1
),d2
659 move.w rtwl_MaxHeight
(a1
),d3
660 jsr _LVOWindowLimits
(a6
) ; reset window limits
668 movem.l
(a7
)+,d2
/d3
/a0
/a1
/a6
671 *----------------------------------------------------------------------------*
672 * void rtSpread
(ULONG
*, ULONG
*, ULONG
, ULONG
, ULONG
, ULONG
);
673 * (pos
, width, length, x1
, x2
, num
);
674 * D0 A0 A1 D0 D1 D2 D3
677 movem.l d2
/d3
/d4
/d5
,-(a7
)
680 clr.w d5
; gadpos (D5) = x1 << 16
681 move.l d3
,d4
; num-- (D4)
688 clr.w d3
; gadgap (D3) = ((x2-x1-totwidth) / num) << 16
689 moveq #
0,d0
; i (D0) = 0
695 move.l d2
,d1
; pos[i] = x2 - width[i]
699 move.l d5
,d1
; pos[i] = gadpos >> 16
704 move.l
(a1
)+,d1
; gadpos += (width[i] << 16) + gadgap
713 movem.l
(a7
)+,d2
/d3
/d4
/d5
716 *----------------------------------------------------------------------------*
717 * void rtScreenToFrontSafely
(struct Screen
*);
720 rtScreenToFrontSafely:
722 move.l rt_IntuitionBase
(a6
),a1
724 jsr _LVOForbid
(a6
) ; a1 will be preserved
726 move.l ib_FirstScreen
(a6
),a1
734 move.l
(a1
),a1
; == move.l sc_NextScreen(a1),a1
737 jsr _LVOScreenToFront
(a6
)
744 *----------------------------------------------------------------------------*
745 * void rtSetReqPosition
746 * (ULONG
, struct NewWindow
*, struct Screen
*, struct Window
*);
749 ;void __asm SetReqPosition (
750 ; register __d0 int reqpos,
751 ; register __a0 struct NewWindow *nw,
752 ; register __a1 struct Screen *scr,
753 ; register __a2 struct Window *win)
755 ; int mx, my, val, leftedge, topedge;
756 ; int scrwidth, scrheight;
757 ; int width, height, left, top;
759 ; rtGetVScreenSize (scr, &scrwidth, &scrheight);
760 ; leftedge = -scr->LeftEdge;
761 ; if (leftedge < 0) leftedge = 0;
762 ; topedge = -scr->TopEdge;
763 ; if (topedge < 0) topedge = 0;
765 ; left = leftedge; top = topedge;
766 ; width = scrwidth; height = scrheight;
768 ; case REQPOS_DEFAULT:
772 ; case REQPOS_POINTER:
773 ; mx = scr->MouseX; my = scr->MouseY;
775 ; case REQPOS_CENTERWIN:
777 ; left = win->LeftEdge; top = win->TopEdge;
778 ; width = win->Width; height = win->Height;
780 ; case REQPOS_CENTERSCR:
781 ; mx = (width - nw->Width) / 2 + left;
782 ; my = (height - nw->Height) / 2 + top;
784 ; case REQPOS_TOPLEFTWIN:
786 ; left = win->LeftEdge;
787 ; top = win->TopEdge;
789 ; case REQPOS_TOPLEFTSCR:
791 ; mx = left; my = top;
795 ; /* keep window completely visible */
796 ; mx += nw->LeftEdge; my += nw->TopEdge;
797 ; val = leftedge + scrwidth - nw->Width;
798 ; if (mx < leftedge) mx = leftedge;
799 ; else if (mx > val) mx = val;
800 ; val = topedge + scrheight - nw->Height;
801 ; if (my < topedge) my = topedge;
802 ; else if (my > val) my = val;
804 ; nw->LeftEdge = mx; nw->TopEdge = my;
807 REQPOS_DEFAULT
equ $FFFF
810 movem.l d2
-d7
/a2
-a5
,-(a7
)
811 move.l a0
,a4
; a4 = newwindow
812 move.l a1
,a3
; a3 = screen
813 move.l a2
,a5
; a5 = win
820 jsr _LVOrtGetVScreenSize
(a6
)
822 move.l
(a7
)+,d7
; d7 = scrheight
823 move.l
(a7
)+,d6
; d6 = scrwidth
825 move.w sc_LeftEdge
(a3
),d1
827 neg.l d1
; d1 = leftedge
833 move.w sc_TopEdge
(a3
),d2
835 neg.l d2
; d2 = topedge
840 move.l d1
,d3
; d3 = left
841 move.l d2
,d4
; d4 = top
842 move.l d6
,a1
; a1 = width
843 move.l d7
,a2
; a2 = height
845 cmp.l #REQPOS_DEFAULT
,d0
; is d0 == REQPOS_DEFAULT
848 ; case REQPOS_DEFAULT:
850 move.w d0
,(a4
) ; == move.w d5,nw_LeftEdge(a4)
852 move.w d0
,nw_TopEdge
(a4
)
859 ; case REQPOS_POINTER:
860 move.w sc_MouseX
(a3
),d3
; mx = scr->MouseX
861 move.w sc_MouseY
(a3
),d4
; my = scr->MouseY
868 ; case REQPOS_CENTERWIN:
872 move.w wd_LeftEdge
(a5
),d3
; left = win->LeftEdge
873 move.w wd_TopEdge
(a5
),d4
; top = win->TopEdge
874 move.w wd_Width
(a5
),a1
; width = win->Width
875 move.w wd_Height
(a5
),a2
; height = win->Height
882 ; case REQPOS_CENTERSCR:
886 move.w nw_Width
(a4
),d5
889 add.l d0
,d3
; mx = (width - nw->Width) / 2 + left
891 move.w nw_Height
(a4
),d5
894 add.l d0
,d4
; my = (height - nw->Height) / 2 + top
901 ; case REQPOS_TOPLEFTWIN:
905 move.w wd_LeftEdge
(a5
),d3
; left = win->LeftEdge
906 move.w wd_TopEdge
(a5
),d4
; top = win->TopEdge
913 ; case REQPOS_TOPLEFTSCR:
915 * move.l d3
,d3
; mx = left
916 * move.l d4
,d4
; my = top
920 add.w
(a4
),d3
; == add.w nw_LeftEdge(a4),d3
927 sub.w nw_Width
(a4
),d1
; leftedge + scrwidth - nw->Width
934 add.w nw_TopEdge
(a4
),d4
941 sub.w nw_Height
(a4
),d2
; leftedge + scrwidth - nw->Width
948 move.w d3
,(a4
) ; == move.w d3,nw_LeftEdge(a4)
949 move.w d4
,nw_TopEdge
(a4
)
951 movem.l
(a7
)+,d2
-d7
/a2
-a5
969 _ReqToolsBase: ds.b
4
971 _IntuitionBase: ds.b
4
972 _GadToolsBase: ds.b
4
978 _ConsoleDevice: ds.b
4
979 _ButtonImgClass: ds.b
4
980 iorequest: ds.b IOSTD_SIZE