supermario/base/SuperMarioProj.1994-02-09/Toolbox/CommToolbox/CommResourceMgr/CommResourceMgr.a

357 lines
11 KiB
Plaintext
Raw Normal View History

2019-06-29 15:17:50 +00:00
;
; File: CommResourceMgr.a
;
; Contains: Entry to the CommResourceManager
;
; Written by: Jerry Godes, and Byron Han
;
; Copyright: © 1988-1991, 1993 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <SM3> 9/28/93 PN Adding two new calls AddStdPort and RemoveStdPort to the
; CommResourceManager from DBLite gibbly.
; <2> 8/12/93 kc <mb>: I deleted all of the "TheFuture" conditionals in all of
; the CommToolbox files per Mike Bell's instructions. I also
; deleted the code that was compiled under the "CubeE"
; conditional.
; <10> 10/4/91 JSM Change PsychoticFarmerOrLater conditionals to TheFuture.
; <9> 10/2/91 DTY Conditionalise <6> through <8> so they dont get built for
; CubeE.
; <8> 7/9/91 BH added __CRMGetToolNamedResource
; <7> 7/3/91 BH added entry for CRMParseCAPSResource
; <6> 7/2/91 BH use routines prefixed with __ to avoid glue conflicts;
; discovered that CRMGetHeader never worked...
; <5> 7/10/90 dba add __ to distinguish routines from glue
; <4> 7/2/90 kaz Code shrinkage/cleanup. Changed BRA table to an offset table.
; Removed CRMDumpResChain.
; <3> 4/9/90 BBH use CRMFindCommunications that is in CommResourceMgr.c instead
; of _CRMFindCommunications in CommResourceMgrUtilities.a
; <2> 3/16/90 BBH made it compile
; <1> 3/14/90 BBH first checked in
;
; Pre-BBS Modification History
; 4/26/89 BBH Added CRMGetIndToolName and CRMIsDriverOpen routines
; 5/10/89 JNG New Glue/Entry
; 7/27/89 JNG Many routines now in assembler, they just grab parms off of a0
; 8/14/89 BBH Now get version of the CRM from constant in CRMIntf.a
;
; 1/25/90 BBH Renamed some routines to be underscore to prevent glue/code conflicts
;
INCLUDE 'Traps.a'
INCLUDE 'CommResources.a'
CRMEntry MAIN EXPORT
IMPORT __InitCRM, __CRMGetHeader, __CRMInstall, __CRMRemove, \
__CRMSearch, \
CRMGet10Resource, \
CRMGet10IndResource, \
CRMGet10NamedResource, \
__CRMReleaseResource, __CRMGetIndex, \
__CRMCreateCommunications, \
__CRMParseRefNum, \
__CRMLocalToRealID, __CRMRealToLocalID, \
__CRMIsDriverOpen, __CRMCheckTool, \
__CRMFindCommunications;
IMPORT __CRMOpenRFPerm, __CRMReserveRF, __CRMReleaseRF, __CRMGetRFCount, __CRMToolPreflight, \
__CRMToolPostflight, __CRMCountFiles, __CRMGetIndFile, \
__CRMGetIndToolName
IMPORT __CRMGetToolResource, __CRMReleaseToolResource
Import __CRMParseCAPSResource, __CRMGetToolNamedResource
IMPORT AddPort, RemovePort
BRA.S RealEntry
Version
DC.W curCRMversion ; version 2
RealEntry
MOVE.W (A0), D1 ; routine selector
ANDI.W #$FF, D1 ; bump the high byte
SUB.W #1, D1 ; make it 0 based
ADD.W D1, D1 ; 2 bytes per offset
LEA CRMStart, A1 ; point to offset table
ADD.W 0(A1,D1.W), A1 ; add the offset
JMP (A1) ; go there
CRMStart
DC.W @InitCRM - CRMStart ; 1
DC.W @CRMGetHeader - CRMStart ; 2
DC.W @CRMInstall - CRMStart ; 3
DC.W @CRMRemove - CRMStart ; 4
DC.W @CRMSearch - CRMStart ; 5
DC.W @CRMGetCRMVersion - CRMStart ; 6
DC.W @CRMGetResource - CRMStart ; 7
DC.W @CRMGet1Resource - CRMStart ; 8
DC.W @CRMGetIndResource - CRMStart ; 9
DC.W @CRMGet1IndResource - CRMStart ; A
DC.W @CRMGetNamedResource - CRMStart ; B
DC.W @CRMGet1NamedResource - CRMStart ; C
DC.W @CRMReleaseResource - CRMStart ; D
DC.W @CRMGetIndex - CRMStart ; E
DC.W @CRMLocalToRealID - CRMStart ; F
DC.W @CRMRealToLocalID - CRMStart ; 10
DC.W __CRMGetIndToolName - CRMStart ; 11
; private routines
DC.W __CRMOpenRFPerm - CRMStart ; 12
DC.W __CRMReserveRF - CRMStart ; 13
DC.W __CRMReleaseRF - CRMStart ; 14
DC.W __CRMGetRFCount - CRMStart ; 15
DC.W @none - CRMStart ; 16
DC.W @none - CRMStart ; 17
DC.W @none - CRMStart ; 18
DC.W @CRMCreateCommunications - CRMStart ; 19
DC.W @CRMFindCommunications - CRMStart ; 1A -- published for 1.0.1
DC.W __CRMCountFiles - CRMStart ; 1B
DC.W __CRMGetIndFile - CRMStart ; 1C
DC.W @CRMParseRefNum - CRMStart ; 1D
; end privates
; Was Debugging routine
DC.W @none - CRMStart ; 1E
DC.W __CRMToolPreflight - CRMStart ; 1F
DC.W __CRMToolPostflight - CRMStart ; 20
DC.W @CRMIsDriverOpen - CRMStart ; 21
DC.W @CRMCheckTool - CRMStart ; 22
; new for 1.0.1
DC.W @CRMGetToolResource - CRMStart ; 23
DC.W @CRMReleaseToolResource - CRMStart ; 24
DC.W @CRMParseCAPSResource - CRMStart ; 25
DC.W @CRMGetToolNamedResource - CRMStart ; 26
DC.W @CRMAddStdPort - CRMStart ; 27
DC.W @CRMRemoveStdPort - CRMStart ; 28
@None
RTS
@InitCRM ; 0x01
CLR.W -(SP) ; make space for return value
JSR __InitCRM
MOVE.W (SP)+, D0 ; get return value
RTS
@CRMGetHeader ; 0x02
CLR.L -(SP) ; make space for return value
JSR __CRMGetHeader
MOVE.L (SP)+, D0 ; get return value
RTS
@CRMInstall ; 0x03
MOVE.L 2(A0), -(SP) ; crmReqPtr
JSR __CRMInstall
RTS
@CRMRemove ; 0x04
CLR.W -(SP) ; make space for return value
MOVE.L 2(A0), -(SP) ; crmReqPtr
JSR __CRMRemove
MOVE.W (SP)+, D0 ; get return value
RTS
@CRMSearch ; 0x05
CLR.L -(SP) ; make space for return value
MOVE.L 2(A0), -(SP) ; crmReqPtr
JSR __CRMSearch
MOVE.L (SP)+, D0 ; get return value
RTS
@CRMGetCRMVersion ; 0x06
LEA Version, A0 ; get version
MOVE.W (A0), D0 ; return
RTS ; and return
;-------------------------------------------------------
;Resource Getting Analogues
;
;We share glue setup with 0 depth and 1 depth res calls
;-------------------------------------------------------
@CRMGetResource ; 0x07
MOVEQ #0, D0 ; 0 means not 1 deep
BRA.S @DoGetOne ; downto shared glue
@CRMGet1Resource ; 0x08
MOVEQ #1, D0 ; 1 means 1 deep
; falls thru to shared glue
@DoGetOne
CLR.L -(SP) ; return value
MOVE.L 4(A0), -(SP) ; theType
MOVE.W 2(A0), -(SP) ; theID
MOVE.W D0, -(SP) ; res search depth
JSR CRMGet10Resource
MOVE.L (SP)+,D0 ; get return value
RTS
@CRMGetIndResource ; 0x09
MOVEQ #0, D0 ; 0 means not 1 deep
BRA.S @DoGetIndex
@CRMGet1IndResource ; 0x0A
MOVEQ #1, D0 ; 1 means 1 deep
@DoGetIndex
CLR.L -(SP) ; return value
MOVE.L 4(A0), -(SP) ; theType
MOVE.W 2(A0), -(SP) ; theIndex
MOVE.W D0, -(SP) ; 0 means not 1 deep
JSR CRMGet10IndResource
MOVE.L (SP)+,D0 ; get return value
RTS
@CRMGetNamedResource ; 0x0B
MOVEQ #0, D0 ; 0 means not 1 deep
BRA.S @DoGetNamed
@CRMGet1NamedResource ; 0x0C
MOVEQ #1, D0 ; 1 means 1 deep
@DoGetNamed
CLR.L -(SP) ; return value
MOVE.L 6(A0), -(SP) ; theType
MOVE.L 2(A0), -(SP) ; name
MOVE.W D0, -(SP) ; 0 means not 1 deep
JSR CRMGet10NamedResource
MOVE.L (SP)+,D0 ; get return value
RTS
;----------------------------------------------------------
@CRMReleaseResource ; 0x0D
MOVE.L 2(A0), -(SP) ; resource handle
JSR __CRMReleaseResource
RTS
@CRMGetIndex ; 0x0E
CLR.L -(SP) ; return value
MOVE.L 2(A0), -(SP) ; resource handle
JSR __CRMGetIndex
MOVE.L (SP)+,D0 ; get return value
RTS
@CRMCreateCommunications ; 0x16
CLR.W -(SP) ; return value
MOVE.L 6(A0), -(SP) ; vRefNum (ptr to)
MOVE.L 2(A0), -(SP) ; dirID (ptr to)
JSR __CRMCreateCommunications
MOVE.W (SP)+,D0 ; get return value
RTS
@CRMFindCommunications ; 0x17
CLR.W -(SP) ; return value
MOVE.L 6(A0), -(SP) ; vRefNum (ptr to)
MOVE.L 2(A0), -(SP) ; dirID (ptr to)
JSR __CRMFindCommunications
MOVE.W (SP)+,D0 ; get return value
RTS
@CRMCheckTool ; 0x22
CLR.B -(SP) ; return value
MOVE.L 12(A0), -(SP) ; fName
MOVE.L 8(A0), -(SP) ; fType
MOVE.W 6(A0), -(SP) ; vRefNum
MOVE.L 2(A0), -(SP) ; dirID
JSR __CRMCheckTool
MOVE.B (SP)+,D0 ; get return value
RTS
@CRMParseRefNum ; 0x1A
CLR.W -(SP) ; return value
MOVE.W 10(A0), -(SP) ; refNum
MOVE.L 6(A0), -(SP) ; fName
MOVE.L 2(A0), -(SP) ; vRefNum (ptr to)
JSR __CRMParseRefNum
MOVE.W (SP)+,D0 ; get return value
RTS
@CRMLocalToRealID ; 0x1B
CLR.W -(SP) ; make room
MOVE.L 10(A0), -(SP) ; resType
MOVE.W 8(A0), -(SP) ; toolID
MOVE.L 4(A0), -(SP) ; theKind
MOVE.W 2(A0), -(SP) ; localID
JSR __CRMLocalToRealID
MOVE.W (SP)+, D0
RTS
@CRMRealToLocalID ; 0x1C
CLR.W -(SP) ; make room
MOVE.L 10(A0), -(SP) ; resType
MOVE.W 8(A0), -(SP) ; toolID
MOVE.L 4(A0), -(SP) ; theKind
MOVE.W 2(A0), -(SP) ; localID
JSR __CRMRealToLocalID
MOVE.W (SP)+, D0
RTS
@CRMIsDriverOpen ; 21
CLR.B -(SP) ; space for return value
MOVE.L 2(A0),-(SP) ; driver name
JSR __CRMIsDriverOpen ; call it
MOVE.B (SP)+,D0 ; get the return value
RTS
@CRMGetToolResource ; 23
CLR.L -(SP) ; space for return value
MOVE.W 8(A0), -(SP) ; procID
MOVE.L 4(A0), -(SP) ; theType
MOVE.W 2(A0), -(SP) ; theID
JSR __CRMGetToolResource ; call it
MOVE.L (SP)+,D0 ; get the return value
RTS
@CRMReleaseToolResource ; 24
MOVE.W 6(A0), -(SP) ; procID
MOVE.L 2(A0), -(SP) ; theHandle
JSR __CRMReleaseToolResource ; call it
RTS
@CRMParseCAPSResource ; 25
CLR.W -(SP) ; make space for return value
MOVE.L 10(A0),-(SP) ; value
MOVE.L 6(A0), -(SP) ; selector
MOVE.L 2(A0), -(SP) ; theHandle
JSR __CRMParseCAPSResource ; call it
MOVE.W (SP)+,D0 ; get the return value
RTS
@CRMGetToolNamedResource ; 26
CLR.L -(SP) ; make space for return value
MOVE.W 10(A0),-(SP) ; procID
MOVE.L 6(A0), -(SP) ; type
MOVE.L 2(A0), -(SP) ; name
JSR __CRMGetToolNamedResource ; call it
MOVE.L (SP)+,D0 ; get the return value
RTS
@CRMAddStdPort ; 27
CLR.L -(SP) ; make space for return value
MOVE.W 10(A0),-(SP) ; procID
MOVE.L 6(A0), -(SP) ; type
MOVE.L 2(A0), -(SP) ; name
JSR AddPort ; call it
MOVE.L (SP)+,D0 ; get the return value
RTS
@CRMRemoveStdPort ; 28
CLR.L -(SP) ; make space for return value
MOVE.W 10(A0),-(SP) ; procID
MOVE.L 6(A0), -(SP) ; type
MOVE.L 2(A0), -(SP) ; name
JSR RemovePort ; call it
MOVE.L (SP)+,D0 ; get the return value
RTS
END