MacOS CD-ROM patch

I got a report from someone trying to run GLTron on a 8.1 system. Turns out
that some Low Memory (LM*) functions are not defined in InterfaceLib on
these older system versions. This function should be added to the CD-ROM
code:

cdrom:macos:SDL_syscdrom.c:

#if defined(powerc) || defined (__powerc)
pascal short LMGetUnitTableEntryCount()
{
return *(short *)0x01D2;
}
#endif

It will generate a link warning for the newer version of InterfaceLib, but
that is OK. I suppose we could rename the function so that the warning does
not occur, which is probably a wise thing to do.

I got a report from someone trying to run GLTron on a 8.1 system. Turns out
that some Low Memory (LM*) functions are not defined in InterfaceLib on
these older system versions. This function should be added to the CD-ROM
code:

cdrom:macos:SDL_syscdrom.c:

#if defined(powerc) || defined (__powerc)
pascal short LMGetUnitTableEntryCount()
{
return *(short *)0x01D2;
}
#endif

It will generate a link warning for the newer version of InterfaceLib, but
that is OK. I suppose we could rename the function so that the warning does
not occur, which is probably a wise thing to do.

It should probably be protected with some other guard, as this may not
work on some newer systems. Is there a way to dynamically detect the
LM* functions at runtime?

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

It should probably be protected with some other guard, as this may not
work on some newer systems. Is there a way to dynamically detect the
LM* functions at runtime?

Well, we have to use the CFM to search for the symbols, and set some
function pointers up.

Matt Slot has a function in FastTimes.c that can do this:

static Ptr FindFunctionInSharedLib(StringPtr libName, StringPtr funcName) {

}

So in this case we would have something like this:

static (short* LMGetUnitTableEntryCountPtr)() = NULL;

Ptr ptr = FindFunctionInSharedLib
("\pInterfaceLib", "\pLMGetUnitTableEntryCount")

if (ptr == NULL)
  LMGetUnitTableEntryCountPtr = ptr;
else
  LMGetUnitTableEntryCountPtr = MyLMGetUnitTableEntryCount;

I think this would work.

I think this would work.

Can you submit a tested patch?

Thanks!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

At 10:26 Uhr -0800 25.02.2001, Sam Lantinga wrote:

I think this would work.

Can you submit a tested patch?

Also, accessing this LM directly would fail on Carbon, hence we
should in any case check via CFM if the call is available.

Max–

Max Horn
C/C++ Developer

email: mailto:Max_Horn
phone: (+49) 6151-494890

Does the CDROM code work on Carbon yet?> From: Max Horn

Reply-To: sdl at lokigames.com
Date: Sun, 25 Feb 2001 19:49:30 +0100
To: sdl at lokigames.com
Subject: Re: [SDL] MacOS CD-ROM patch

At 10:26 Uhr -0800 25.02.2001, Sam Lantinga wrote:

I think this would work.

Can you submit a tested patch?

Also, accessing this LM directly would fail on Carbon, hence we
should in any case check via CFM if the call is available.

Max


Max Horn
C/C++ Developer

email: <mailto:max at quendi.de>
phone: (+49) 6151-494890

When I need this LowMem on a PowerPC, I don’t bother grabbing the symbol
from InterfaceLib – I just access the lowmem directly from a macro. This
avoids the (albeit benign) link error and doesn’t cause any problems on
older InterfaceLib runtimes.

#include <LowMem.h>

#if !defined(LMGetUnitTableEntryCount)
#define LMGetUnitTableEntryCount() *(short *)0x01D2
#endif

There are a couple other rare symbols for which this is true as well.—

Also, accessing this LM directly would fail on Carbon, hence we
should in any case check via CFM if the call is available.

This call, and the rest of the Device Manager, are not available under
OSX or the Carbon APIs. These are 2 different issues.

Under OSX, CD-ROM and other devices are accessed using IOKit. That API
is not part of Carbon since it isn’t available on OS9 or earlier.

When running from Carbon, you need to manually load the device APIs for
the current system (IOKit on OSX or Device Manager on OS7-9). Note that
the LowMems will work on OS7-9, even if the macros aren’t defined by the
the compiler.

Matt

/* Matt Slot * Bitwise Operator * http://www.ambrosiasw.com/~fprefect/ *

  • "Did I do something wrong today or has the world always been like this *
  • and I’ve been too wrapped up in myself to notice?" - Arthur Dent/H2G2 */

When I need this LowMem on a PowerPC, I don’t bother grabbing the symbol
from InterfaceLib – I just access the lowmem directly from a macro. This
avoids the (albeit benign) link error and doesn’t cause any problems on
older InterfaceLib runtimes.

#include <LowMem.h>

#if !defined(LMGetUnitTableEntryCount)
#define LMGetUnitTableEntryCount() *(short *)0x01D2
#endif

There are a couple other rare symbols for which this is true as well.

Thanks! I added this to the code. :slight_smile:

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software