OK, so translated to roughly plain english for us lesser mortals,
would I be on the right track using code like this to write a pair of
extension functions for SuperBASIC like this:
pointer_environment = PTR_ENV(#channel)
gd2_drivers = GD2(#channel)
PTR_ENV being a function to return 1 if PE present, 0 if not.
move.w #-1,d3 ;timeout
;find channel ID for window number passed and put in a0
move.w #$70,d0
trap #3 ;iop.pinf
;d0=0 means ptr env installed - return value of 1
;d0=err.bp (bad parameter) no pointer environment - return value of 0
GD2 being a function to return 1 if GD2 installed, 0 if no GD2, so
after a call to PTR_ENV
IF PTR_ENV(#0) = 1 THEN
gd2_drivers = GD2(#0)
END IF
clr.w d0 ;position in linkage to set
clr.w d2 ;no bytes to be set (read only)
moveq.w #-1,d3 ;infinite timeout
;find channel ID for window number passed and put in a0
clr.l a1 ;pointer to data to set, in this case none as it's read only
move.w #$6f,d0 ;iop.slnk ($6f=dec.111)
trap #3
tst.w d0 ;any error such as channel not open
bne.s oops ;oh dear, an error
move.w #$128,d7 ;offset $128 in PE linkage block
move.l 0(a1,d7.w),d6
cmpi.l #"PTR2",d6
bne.s no_gd2
yes_gd2 ;return value of 1 to S*BASIC
no_gd2 ;return value of 0 to S*BASIC
oops rts ;return to S*BASIC with error message
This is completely off the top of my head with no testing, no real
knowledge of what i'm doing, but filled with hope someone will read
this and either complete it into something workable or at least tell
me what i'm doing wrong!
Norman...instead of being out in the snow, here's your next QLT
assembler project!
(Having written the original display_code extensions for QL Today
giving S*BASIC programmers a means of testing for extended resolutions
etc, I hope this can be turned into an extension of that project
perhaps, as that contains the necessary assembler routines for finding
channel IDs and returning function values...hopefully wouldn't be too
difficult!)
Dilwyn, methinks you are definitely following the correct route. Add a default #channel=0 and you have the two functions I have already written for QWord (almost verbatim, except I used the simpler:
MOVE.L $128(a1),d7
instead of:
move.w #$128,d7 ;offset $128 in PE linkage block
move.l 0(a1,d7.w),d6
Kind Regards
--
Rich Mellor
RWAP Software
35 Chantry Croft, Kinsley, Pontefract, West Yorkshire, WF9 5JH
TEL: 01977 610509
http://hometown.aol.co.uk/rwapsoftware
