dilwyn wrote:In Norman's DJToolkit, his LEVEL2 extension (which checks for Level 2 filing systems) simply calls the IOF_XINF (get extended information, trap #3 with d0=$4F or dec. 79) and if this returns an error assumes that it is a level 1 (i.e. no hard directories) filing system.
I've not looked at the extension in detail (just returned from hospital after eye surgery so don't want to spend too long on computer to irritate the eye), but knowing Norman it'll be spot on!
Hope they eye gets better soon. And thanks fr the vote of confidence, maybe you are correct!
Here's the code. There are a couple of bits missing, check_hash checks for the hash separator bit in the name table entry for the first parameter.
Integer_d1 takes the word in d1 and puts it on the maths stack and sets the return type ready to exit back to SuperBasic. It makes sure that d2 bytes are available on the stack first.
Integer_bv returns err_BP via the maths stack and has to make room for it as the stack, at the time called, has not yet been used so there may not be pace for the error code.
Other than that it should be easy enough to follow. Apart from the formatting which has been botched by the Android editor I used to extract the code with.
Code: Select all
*====================================================================*
* LEVEL2 = Test to see if the level 2 drivers are present or not. *
*--------------------------------------------------------------------*
* There must be 1 parameter preceeded by a hash. Return 1 if there *
* are level 2 drivers on the connected device, zero if not. *
*--------------------------------------------------------------------*
* Stack uses 4 bytes and requires 2 for the result. *
*====================================================================*
level2 bsr count_pars There should be 1
moveq #2,d2 Assume an error will occur
subq.w #1,d0 Was there 1 ?
beq.s l2_1_ok Yes
l2_badpar moveq #ERR_BP,d1 Bad parameter
bra integer_bv Quit via an unused stack
l2_error rts Quit
l2_1_ok bsr check_hash Test for the hash (#)
beq.s l2_badpar Not there, quit & complain
moveq #64,d1 This big
bsr mtalchp Allocate it (preserves D2)
bne.s l2_ret_err Oops...
move.l a0,d5 Save buffer address
moveq #get_long,d0 Get 1 long please
bsr get_params Go get it
bne.s l2_error Oops...
move.l 0(a6,a1.l),d0 Get channel number
addq.l #2,a1 Tidy stack but leave room for a word
bsr get_chan Convert to id in A0 for trap
bne.s l2_ret_d0 Oops...
move.l a1,d7 A1 gets corrupted
moveq #IOF_XINF,d0 Use extended trap
moveq #0,d1 Must be, why ?
moveq #0,d2 Interrogate mode
moveq #timeout,d3 Infinity rules ok ?
move.l d5,a1 Buffer address in A1 for trap
trap #3 Do extended trap, A0 & A1 preserved
move.l d0,d6 Store error code
moveq #MT_RECHP,d0 Trap is set
move.l a1,a0 Buffer address
trap #1 Release buffer, no errors
moveq #0,d2 I don't need any extra space
move.l d7,a1 Restore maths stack
move.l d6,d1 Restore previous error code
beq.s l2_ret_1 Level 2 is present
moveq #0,d1 Level 2 drivers not found
bra integer_d1 Back to SuperBasic
l2_ret_d0 moveq #0,d2 Stack is fine
l2_ret_err move.l d0,d1 Get error code
bra integer_d1 Return it as result
l2_ret_1 moveq #1,d1 Flag found level 2 drivers
bra integer_d1 And finished