rla@julius.uucp (Richard L. Altman) (08/17/89)
I am presently trying to identify which of the slots in my Mac II have cards in them. I have read through Inside Mac V, and although I have seen the data structures that would most certainly solve my problem, I can't figure out how to assign them to an active slot (or one with a card). Am I approaching this incorrectly? Is there an easier way to figure out which slots have cards in them? Could someone post a few lines of code that would straighten me out? Thanks. -Rich ________________________ rla@princeton.edu justone@cs.brandeis.edu
MAC.ROMOS@applelink.apple.com (Eric Ulevik) (08/17/89)
In article <18671@princeton.Princeton.EDU> rla@julius.uucp (Richard L. Altman) writes: > I am presently trying to identify which of the slots in my Mac II have cards in them. #include <Slots.h> #include <Errors.h> // Return true if there is a card in slot 'slotID'. Boolean isSlotUsed(short slotID) { SpBlock s; s.spSlot = slotID; return (!(SCkCardStat(&s) == smCkStatusErr)); } This is for MPW C 3.0. Hope this helps! Eric Ulevik email: MAC.ROMOS@applelink.apple.com voice: (408) 974-0662 -- These writings are mine, not Apple's. That's the way I like it. --
amanda@intercon.uu.net (Amanda Walker) (08/17/89)
Here's some slightly more interesting code: it will not only tell you what slots have cards in them, but what those cards are. This will compile into an MPW tool under MPW C 3.0: ------------------------- #include <stdio.h> #include <slots.h> #include <ROMDefs.h> main() { int i; SpBlock spb; long l; for (i = 0; i < 16; i++) { // for each possible slot: spb.spSlot = i; spb.spID = 1; spb.spExtDev = 0; if (!SRsrcInfo(&spb)) { // if there is anything there, printf("Slot %d:\n", i); // tell us which slot we're on. spb.spID = sRsrcName; if (!SGetCString(&spb)) { // if it has a name, print it. printf(" %s\n", (char *) spb.spResult); } spb.spID = vendorInfo; if (!SFindStruct(&spb)) { // print vendor info spb.spID = vendorId; if (!SGetCString(&spb)) { // print the vendor name printf(" Vendor: %s\n", (char *) spb.spResult); } spb.spID = serialNum; if (!SGetCString(&spb)) { printf(" Serial Number: %s\n", (char *) spb.spResult); } spb.spID = revLevel; if (!SGetCString(&spb)) { printf(" Revision: %s\n", (char *) spb.spResult); } spb.spID = partNum; if (!SGetCString(&spb)) { printf(" Part Number: %s\n", (char *) spb.spResult); } spb.spID = date; if (!SGetCString(&spb)) { printf(" Revision Date: %s\n", (char *) spb.spResult); } } } } } ------------------------- Enjoy, -- Amanda Walker InterCon Systems Corporation -- amanda@intercon.uu.net | ...!uunet!intercon!amanda
pmercer@apple.com (Paul Mercer) (08/17/89)
Wouldn't checking for smEmptySlot be better? Paul Mercer Finder Team Apple Computer, Inc. I'm responsible for my thoughts
amanda@intercon.uu.net (Amanda Walker) (08/17/89)
In article <3643@internal.Apple.COM>, pmercer@apple.com (Paul Mercer) writes: > Wouldn't checking for smEmptySlot be better? Hmm. Probably; the code in question was a one-off program to make sure I understood how to locate card resources, and at the time I figured I'd just skip any slot that got a non-zero return value... -- Amanda Walker InterCon Systems Corporation -- amanda@intercon.uu.net | ...!uunet!intercon!amanda
john@trigraph.uucp (John Chew) (08/18/89)
In article <1376@intercon.UUCP> Amanda Walker <amanda@intercon.uu.net> writes: >Here's some slightly more interesting code: it will not only tell you what >slots have cards in them, but what those cards are. This will compile into >an MPW tool under MPW C 3.0: [code deleted] Here's what you need to add to Amanda's code to get it to compile under THINK C 3.0: ----- /* defines from MPW <ROMdefs.h> */ #define sRsrcName 2 #define venderInfo 36 #define vendorID 1 #define serialNum 2 #define revLevel 3 #define partNum 4 #define date 5 /* glue for SGetCString() not found in MacTraps */ pascal OSErr SGetCString(spBlkPtr) SpBlockPtr spBlkPtr; { #define sGetCString 3 asm { move.l spBlkPtr, A0 move.l #sGetCString, D0 _SlotManager return } } ----- John Newsgroups: comp.sys.mac.programmer Subject: Re: Slot Manager/Active Slots References: <18671@princeton.Princeton.EDU> <3610@internal.Apple.COM> <1376@intercon.UUCP> Sender: john@trigraph.UUCP (John Chew) Reply-To: poslfit@gpu.UTCS.UToronto.CA (John Chew) Organization: Trigraph Inc., Toronto, Canada In article <1376@intercon.UUCP> Amanda Walker <amanda@intercon.uu.net> writes: >Here's some slightly more interesting code: it will not only tell you what >slots have cards in them, but what those cards are. This will compile into >an MPW tool under MPW C 3.0: [code deleted] Here's what you need to add to Amanda's code to get it to compile under THINK C 3.0: ----- /* defines from MPW <ROMdefs.h> */ #define sRsrcName 2 #define venderInfo 36 #define vendorID 1 #define serialNum 2 #define revLevel 3 #define partNum 4 #define date 5 /* glue for SGetCString() not found in MacTraps */ pascal OSErr SGetCString(spBlkPtr) SpBlockPtr spBlkPtr; { #define sGetCString 3 asm { move.l spBlkPtr, A0 move.l #sGetCString, D0 _SlotManager return } } ----- John -- john j. chew, iii phone: +1 416 425 3818 AppleLink: CDA0329 trigraph, inc., toronto, canada {uunet!utai!utcsri,utgpu,utzoo}!trigraph!john dept. of math., u. of toronto poslfit@{utorgpu.bitnet,gpu.utcs.utoronto.ca}