1 /*
2  *	Open a package for use by the application
3  *
4  *	Supply 0 to check package handling is installed
5  *
6  *	djm 12/1/2000
7  */
8 
9 #include <z88.h>
10 
QueryPackage(int which,int major,int minor)11 bool_t QueryPackage(int which, int major,int minor)
12 {
13 #pragma asm
14 	INCLUDE "packages.def"
15 	call_pkg(pkg_ayt)		;preserves ix
16 	jr	c,openfail
17 	ld	hl,6
18 	add	hl,sp	;points to library number
19 	ld	a,(hl)
20 	ld	c,a
21 	and	a	;0=just check packages
22 	jr	z,opensuc
23 ;bc holds library, c holds code, so load b with ayt
24 	ld	b,$2	;ayt
25 	push	bc	;keep bc for later
26 	push	bc
27 	pop	iy
28 	rst	16	;call package thru iy
29 	pop	iy	;get bc back into iy
30 	jr	c,openfail
31 ; Check to see if we need to check the version
32 ; If we or the two together and end up with 0 then we were
33 ; given 0,0 i.e. any will do
34 	ld	hl,4
35 	add	hl,sp
36 	ld	a,(hl)	;major
37 	dec	hl
38 	dec	hl
39 	or	(hl)	;minor
40 	jr	z,opensuc
41 ; Now check the version
42 	ld	iyh,$0	;inf
43 	rst	16		;version in de
44 	ld	hl,4
45 	add	hl,sp		;points to major required
46 	ld	a,(hl)
47 	cp	d
48 	jr	c,openfail	;major < required
49 	jr	z,ckminor	;major = required
50 .opensuc
51 	ld	hl,1		;success
52 	and	a
53 	ret
54 
55 .ckminor
56 	dec	hl
57 	dec	hl		;points to minor required
58 	ld	a,(hl)
59 	cp	e		;package minor
60 	jr	nc,opensuc
61 
62 .openfail
63 	ld	hl,0
64 	scf
65 
66 #endasm
67 
68 
69 }
70 
71 
72 
73 /* End of file */
74 
75 
76