Detecting if this is a Falcon.

I realised the other day when asked by an STe programmer, that it isn't clear how to detect whether the machine that a program is running on is a Falcon - eg. to add extra sound, or disable something which causes it to crash... so here are two methods...

1) Test if OS version < 4.00 - If so, then not a Falcon.

It might be possible for someone to severly hack the Falcon TOS and make an ST work with > 4.00, but I doubt it...

I don't know whether this method would work under MagicMac etc. as it directly reads an OS variable (but I guess it would, as lots of progs access this)

detect_falcon:
	move.l	$4f2,a0		; get OS version
	move.w	2(a0),d1
	cmpi.w	#$400,d1
	blt	nope
yep:

2) Check for the cookie '_MCH' and check its value.

If the cookie value = $30000 then the machine is a Falcon.

check_MCHcookie

	move.l	$5a0,a0				address of cookie jar
	beq	not_falc			if 0 no cookie jar

* now loop round reading each pair of longwords until
* the empty longword is reached

.loop	move.l	(a0)+,d0			cookie name
	move.l	(a0)+,d1			cookie value 
	cmp.l	#0,d0				check for empty longword
	beq	not_falc			if empty finished

	cmp.l	#'_MCH',d0			check for cookie
	bne.s	.loop				get next cookie

	cmpi.l	#$3000,d1
	bne	not_falc
is_falc
If you are writting a GEM application, you should probably not use either of these methods, but simply test the AES version - global[0]. AES 3.30 or greater means it has a Falcon capable AES (but not necessarily a Falcon).


Back to the programmers page...
Back to the index.

Anthony Jacques - jacquesa@zetnet.co.uk