[futurebasic] LowMem accessors (was Gestalt question)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2000 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Sun, 2 Apr 2000 23:14:39 +1200
>In the G3 world, what was once easy has become a little more
>difficult. Here's Apple's explanation with C code that perhaps Robert
>Purves can translate into FB^3 for us:

>It is possible to get the ROM subversion value to determine if the
>logic board is the original Power Macintosh G3 logic board with the
>V4.0 F2 ROM or an enhanced logic board with the V4.5 F1 or V4.5 F2
>ROM. The following prototype example code can be used to get the ROM
>subversion number of the Power Macintosh G3 logic board.


The following says that my G3 iMac has a V4.5 F3 ROM.

In FBII there seems no alternative to the method of peeking into low memory
globals, a practice discouraged by Apple because it won't work in OS X.

WINDOW 1 ' FBII or FB^3 program to display ROM subversion value
PRINT HEX$({[_romBase] + &H12})
DO: UNTIL FN BUTTON



In FB^3 I prefer to follow the original C code and call LMGetROMBase.
LMGetROMBase is a LowMem accessor function, a concept we will have to
become increasingly used to, as OS X gets closer.
The key to the conversion from C is that *(UInt16*) means PEEK WORD. For
completeness, I should mention that it means POKE WORD when applied to the
left side of an assignment.

'-----FB^3 program to display ROM subversion value----
/* original C function
UInt16 GetROMSubversion(void)
{
return *(UInt16*)((UInt32)LMGetROMBase() + 0x12);
}
*/

toolbox fn LMGetROMBase = pointer ` 0x2EB8, 0x02AE
dim romSubVersion as unsigned short
romSubVersion = {fn LMGetROMBase + 0x12}
print "ROM subversion: " hex$(romSubVersion)
'----------------------------------------------------


An more familiar example of a Low Memory accessor is FN TICKCOUNT,
equivalent to the obsolescent PEEK LONG(_ticks).

Robert P.