A.D.A. Amiga Demoscene Archive

        Welcome guest!

  

  

  

log in with SceneID

  

Demos Amiga Demoscene Archive Forum / Coding / Detecting SetPatch

 

Author Message
Blueberry
Member
#1 - Posted: 10 Feb 2008 11:55
Reply Quote
Is there a simple way for a program to query which version of SetPatch has been run?
StingRay
Member
#2 - Posted: 12 Feb 2008 12:06 - Edited
Reply Quote
I had the same problem some days ago (in some versions of the Kickstart IEEESPMul is just not implemented, will be fixed by SetPatch >= v43.6). Anyway, I don't think (at least I couldn't come up with any) there's an easy approach to detect the SetPatch version. Detecting SetPatch is easy enough by using Exec's FindSemaphore() like this:


move.l $4.w,a6
lea .name(pc),a1
jsr _LVOFindSemaphore(a6) ; -594
tst.l d0
beq.b .nosetpatch

; setpatch has been installed

....

.nosetpatch
rts

.name DC.B '« SetPatch »',0


However, this only tells if SetPatch has been started, not which version of SetPatch. The only idea I have here is to load the C:SetPatch executable and scan the version string once FindSemaphore() returns success. Obviously this is anything but foolproof though. :/
StingRay
Member
#3 - Posted: 14 Feb 2008 14:47 - Edited
Reply Quote
Ok, I found a solution. :) Only 2 additional lines of code are required. :)

	incdir	sources:include/
	include	exec/semaphore s.i
	include	sources:include/lvos.i

	move.l	$4.w, a6
	lea	name(pc),a1
	jsr	_LVOFindSemaphore(a6)
	ts t.l	d0
	beq.b	.nosetpatch
	move.l	d0,a0
	move.l	SS _SIZE+MLH_SIZE(a0),d0	; upper 16 bit: v 
ersion, lower ; 16 bit rev .nosetpatch rts name DC.B '« SetPatch »',0


d0.l will contain version|revision then. :)

Edit: How the hell is it possible to post nicely formatted code here? ;)
Blueberry
Member
#4 - Posted: 14 Feb 2008 15:52 - Edited
Reply Quote
Nice! Thanks! I suspected it would be something like that, though it didn't occur to me that a semaphore was the right thing to search for.

A related issue is how to detect which version of 68060.library was installed by SetPatch. This can be crucial to performance, since the chip ram is set to imprecise mode (ala speedychip) in version 42 and above but to precise in versions before that.

The question is, will it do to simply try to open 68060.library version 42, i.e.
move.l  $4.w,a6
lea     name(pc),a1
moveq.l #42,d0
jsr     _LVOOpenLibrary(a6)
tst.l   d0
...
name:   dc.b '68060.library',0

What will happen if SetPatch was not run, or if it for some reason did not initialize the 68060.library, or if there is no 060 but 68060.library was present anyway?

For posting code, try the pre-tags. ;)
StingRay
Member
#5 - Posted: 14 Feb 2008 16:20
Reply Quote
Thanks for the tip with the "pre" tags. :) They seem to be a bit buggy though. :D But it looks a lot better anway. :)
As for the 060 library thing, I'm gonna do some tests and post the results here. :)
z5_
Member
#6 - Posted: 14 Feb 2008 16:56
Reply Quote
off-topic but the pre-tag solution is indeed buggy at best :(
doom
Member
#7 - Posted: 15 Feb 2008 01:22
Reply Quote
Off the top of my head, couldn't you try repeatedly opening 68060.library and decrementing the minimum version (d0) until OpenLibrary() succeeds? Or just try to open the versions you're checking for (versions 0+ and 42+ would be enough in the example you mention).

I don't know if the library available to OpenLibrary() is guaranteed to be the one SetPatch has initialised, though. If SetPatch didn't initialise it at all but it's still present in LIBS: I guess you'd still be able to open it.

You could check for it in memory by scanning the library list, but then it might be present because it's been opened by, say, some demo system trying to figure out what version was loaded by SetPatch.

I suppose if you can find where the exception handler for any 000-040-but-not-060 instruction is installed, and if that happens to fall inside a memory block allocated by a 68060.library, that should tell you something.
StingRay
Member
#8 - Posted: 15 Feb 2008 12:40 - Edited
Reply Quote
Off the top of my head, couldn't you try repeatedly opening 68060.library and decrementing the minimum version (d0) until OpenLibrary() succeeds? Or just try to open the versions you're checking for (versions 0+ and 42+ would be enough in the example you mention).

Don't know (my A4k is still not fully working so I couldn't check yet) if that's a fool-proof approach. There are libraries that can be opened without any problems even though the required HW is not present. Stupid? Yes! But they do exist. :) I'd like to give cybergraphics.library as a bloody good example here. You can call OpenLibrary and it will return the library pointer even though you don't have any graphics card in your system. Dunno if it's the same with the 68040/060 libraries, hopefully not. :)

 

  Please log in to comment

  

  

  

 

A.D.A. Amiga Demoscene Archive, Version 3.0