mac-rom/Toolbox/CommToolbox/CommToolboxUtilities/CommToolboxUtilities.a
Elliot Nunn 0ba83392d4 Bring in CubeE sources
Resource forks are included only for .rsrc files. These are DeRezzed into their data fork. 'ckid' resources, from the Projector VCS, are not included.

The Tools directory, containing mostly junk, is also excluded.
2017-09-20 18:04:16 +08:00

568 lines
16 KiB
Plaintext

;
; File: CommToolboxUtilities.a
;
; Contains: Assembly entry point for CommToolbox Utilities
;
; Written by: Byron Han and Jerry Godes
;
; Copyright: © 1988-1990 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <4> 10/5/90 kaz Changing BRA table to offset table; Removed _CTBKeystrokeFilter.
; <jng>
; <3> 7/10/90 dba add __ to distinguish routines from glue
; <2> 3/15/90 BBH fixed constants and includes
; <1> 3/14/90 BBH first checked in to BBS
;
; To Do:
;
; Pre-BBS Modification History :
;
; 2/15/90 BBH Added CTBGetErrorString
; 7/25/89 CL Added spcifiedStr to CTBKeyStrokekFilter
; 7/4/89 JNG Fixed Byron's bug in NuLookup's entry code - he forgot a # infront of
; the nulookup ID constant
; 6/21/89 BBH Added CTBPChoose
; 6/2/89 JNG New Glue/Entry interface
; 5/5/89 BBH Moved CTBValidate to CTBCore.c
; Fixed bug in CTBValidate glue (do a Move.B instead of Move.W)
; 4/27/89 BBH Added CTBKeystrokeFilter to CTBUtilities.c
; 4/24/89 JNG Added CTBResume CTBEvent CTBMenu CTBAbort CTBActivate CTBIdle CTBReset
; to ctbcore
; 4/20/89 BBH Save different registers for CTBValidate. Was saving D0-D3/A0-A3.
; Now saving D0-D7/A1-A4. A0 is used for the internal dispatch record
; CTBGetVersion now takes mgrsel as a parameter
; 4/18/89 BBH Added entry for CTBSetupSetup, Cleanup, Preflight, Postflight, Item, Filter
; Added entry for CTBIntlToEnglish, EnglishToIntl, GetConfig, SetConfig
; Added entry for CTBGetProcID.
; 4/17/89 JNG Added CTBValidate. We can now use the macro from MPW sample
; app for debugger names.
; 4/11/89 JNG Took CMGetRefCon, CMSetRefCon, CMGetUserData, CMSetUserData,
; CMGetVersion and converted to CTB.
; 4/8/89 JNG Added CTBCore routines
; 8/1/88 BBH 1.0D1
;------------------------------------------------------------------------------------
;
; A0.L -> pointer to the routine selector record
;
; D0.L -> function result
;
INCLUDE 'Traps.a'
INCLUDE 'CommToolboxPriv.a'
INCLUDE 'CTBUtilities.a'
ENTRY CTBGetToolName, _CTBValidate, CTBIdle
CTBEntry MAIN EXPORT
IMPORT DITLEntry, __NuPLookup, __InitCTBUtilities, __InitManager, \
__CTBGetVersion, __CTBDefault, __CTBValidate, \
__CTBSetupPreflight, __CTBSetupSetup, __CTBSetupItem, __CTBSetupItem, \
__CTBSetupFilter, __CTBSetupPostflight, __CTBSetupCleanup, \
__CTBSetupXCleanup, \
__CTBGetConfig, __CTBSetConfig, \
__CTBEnglishToIntl, __CTBIntlToEnglish, __CTBChoose, __CTBGetProcID, \
__CTBResume, __CTBMenu, __CTBEvent, __CTBActivate, __CTBReset, \
__CTBAbort, __CTBPChoose, \
__CTBGetErrorString
BRA.S RealEntry
version DC.W curCTBUversion ; major version 1
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 CTBUStart, A1 ; point to offset table
ADD.W 0(A1,D1.W), A1 ; add the offset
JMP (A1) ; go there
CTBUStart
DC.W @InitCTBUtilities - CTBUStart ; minor selector 1
DC.W @AppendDITL - CTBUStart ; 2
DC.W @CountDITL - CTBUStart ; 3
DC.W @ShortenDITL - CTBUStart ; 4
DC.W @CTBGetCTBVersion - CTBUStart ; 5
DC.W @NuLookup - CTBUStart ; 6
DC.W @NuPLookup - CTBUStart ; 7
DC.W @None - CTBUStart ; 8 -- NOT USED
DC.W @InitManager - CTBUStart ; 9
DC.W @CTBSetRefCon - CTBUStart ; A
DC.W @CTBGetRefCon - CTBUStart ; B
DC.W @CTBSetUserData - CTBUStart ; C
DC.W @CTBGetUserData - CTBUStart ; D
DC.W @CTBGetVersion - CTBUStart ; E
DC.W CTBGetToolName - CTBUStart ; F
DC.W @CTBValidate - CTBUStart ; 10
DC.W @CTBDefault - CTBUStart ; 11
DC.W @CTBSetupPreflight - CTBUStart ; 12
DC.W @CTBSetupSetup - CTBUStart ; 13
DC.W @CTBSetupItem - CTBUStart ; 14
DC.W @CTBSetupFilter - CTBUStart ; 15
DC.W @CTBSetupCleanup - CTBUStart ; 16
DC.W @CTBSetupPostflight - CTBUStart ; 17
DC.W @CTBGetConfig - CTBUStart ; 18
DC.W @CTBSetConfig - CTBUStart ; 19
DC.W @CTBIntlToEnglish - CTBUStart ; 1A
DC.W @CTBEnglishToIntl - CTBUStart ; 1B
DC.W @CTBChoose - CTBUStart ; 1C
DC.W @CTBGetProcID - CTBUStart ; 1D
DC.W @CTBResume - CTBUStart ; 1E
DC.W @CTBMenu - CTBUStart ; 1F
DC.W @CTBEvent - CTBUStart ; 20
DC.W @CTBActivate - CTBUStart ; 21
DC.W CTBIdle - CTBUStart ; 22
DC.W @CTBAbort - CTBUStart ; 23
DC.W @CTBReset - CTBUStart ; 24
DC.W @None - CTBUStart ; 25 -- was CTBKeystrokeFilter
DC.W @CTBPChoose - CTBUStart ; 26
DC.W @CTBSetupXCleanup - CTBUStart ; 27
DC.W @CTBGetErrorString - CTBUStart ; 28
@None
RTS
@InitCTBUtilities ; 0x01
CLR.W -(SP)
JSR __InitCTBUtilities
MOVE.W (SP)+,D0
RTS
@AppendDITL ; 0x04
CLR.L -(SP) ; place holder - All DITL routines go through the common
; entry DITLEntry, therefore, we need to fake some params
MOVE.L 8(A0), -(SP) ; theDialog
MOVE.L 4(A0), -(SP) ; theDITL
MOVE.W 2(A0), -(SP) ; method
CLR.W -(SP) ; place holder for numberItems
MOVE.W #AppendMsg, -(SP) ; 01 = append msg
JSR DITLEntry
ADDA.L #4,SP ; remove place holder
RTS
@CountDITL ; 0x05
CLR.L -(SP) ; make room
MOVE.L 2(A0), -(SP) ; theDialog
CLR.L -(SP) ; place holder for DITL
CLR.W -(SP) ; place holder for method
CLR.W -(SP) ; place holder for numberItems
MOVE.W #CountMsg, -(SP) ; 02 = count msg
JSR DITLEntry
MOVE.L (SP)+, D0 ; return value
RTS
@ShortenDITL ; 0x06
CLR.L -(SP) ; make room
MOVE.L 4(A0), -(SP) ; theDialog
CLR.L -(SP) ; place holder for DITL
CLR.W -(SP) ; place holder for method
MOVE.W 2(A0), -(SP) ; numberItems
MOVE.W #ShortenMsg, -(SP) ; 03 = shorten msg
JSR DITLEntry
ADDA.L #4,SP ; remove place holder
RTS
@CTBGetCTBVersion LEA Version, A0 ; 0x07
MOVE.W (A0), D0 ; put version number
RTS
@NuLookup ; 0x08
CLR.W -(SP)
MOVE.L 28(A0),-(SP) ; where
MOVE.L 24(A0),-(SP) ; prompt
MOVE.W 22(A0),-(SP) ; numTypes
MOVE.L 18(A0),-(SP) ; typeList
MOVE.L 14(A0),-(SP) ; objFilter
MOVE.L 10(A0),-(SP) ; zoneFilter
MOVE.L 6(A0),-(SP) ; hookProc
CLR.L -(SP) ; userData
MOVE.W #CTB_NulookupDLOGID,-(SP) ; dialogID (default one)
CLR.L -(SP) ; filterProc
MOVE.L 2(A0),-(SP) ; theReply
JSR __NuPLookup
MOVE.W (SP)+,D0
RTS
@NuPLookup ; 0x08
CLR.W -(SP)
MOVE.L 38(A0),-(SP) ; where
MOVE.L 34(A0),-(SP) ; prompt
MOVE.W 32(A0),-(SP) ; numTypes
MOVE.L 28(A0),-(SP) ; typeList
MOVE.L 24(A0),-(SP) ; objFilter
MOVE.L 20(A0),-(SP) ; zoneFilter
MOVE.L 16(A0),-(SP) ; hookProc
MOVE.L 12(A0),-(SP) ; userData
MOVE.W 10(A0),-(SP) ; dialogID
MOVE.L 6(A0),-(SP) ; filterProc
MOVE.L 2(A0),-(SP) ; theReply
JSR __NuPLookup
MOVE.W (SP)+,D0
RTS
@InitManager ; 0x09
CLR.W -(SP)
MOVE.W D0, -(SP) ; Manager Selector
JSR __InitManager
MOVE.W (SP)+,D0
RTS
@CTBSetRefCon MOVE.L A1,-(SP) ; 0x0A
MOVE.L 6(A0),A1
MOVE.L (A1),A1
MOVE.L 2(A0),CTBRefCon(A1)
MOVE.L (SP)+,A1
RTS
@CTBGetRefCon MOVE.L A1,-(SP) ; 0x0B
MOVE.L 2(A0),A1
MOVE.L (A1),A1
MOVE.L CTBRefCon(A1),D0
MOVE.L (SP)+,A1
RTS
@CTBSetUserData MOVE.L A1,-(SP) ; 0x0C
MOVE.L 6(A0),A1
MOVE.L (A1),A1
MOVE.L 2(A0),CTBUserData(A1)
MOVE.L (SP)+,A1
RTS
@CTBGetUserData MOVE.L A1,-(SP) ; 0x0D
MOVE.L 2(A0),A1
MOVE.L (A1),A1
MOVE.L CTBUserData(A1),D0
MOVE.L (SP)+,A1
RTS
@CTBGetVersion CLR.L -(SP) ; 0x0E
MOVE.L 2(A0), -(SP) ; hCore
MOVE.W D0, -(SP) ; mgrsel
JSR __CTBGetVersion
MOVE.L (SP)+, D0
RTS
@CTBSetupPreflight CLR.L -(SP) ; make room
MOVE.W 6(A0), -(SP) ; procID
MOVE.L 2(A0), -(SP) ; magicCookie (var)
MOVE.W D0, -(SP) ; manager selector
JSR __CTBSetupPreflight
MOVE.L (SP)+, D0 ; function result
RTS
@CTBSetupSetup
MOVE.W 16(A0), -(SP) ; procID
MOVE.L 12(A0), -(SP) ; theConfig
MOVE.W 10(A0), -(SP) ; count
MOVE.L 6(A0), -(SP) ; theDialog
MOVE.L 2(A0), -(SP) ; magicCookie (var)
MOVE.W D0, -(SP) ; manager selector
JSR __CTBSetupSetup
RTS
@CTBSetupFilter CLR.B -(SP) ; make room
MOVE.W 24(A0), -(SP) ; procID
MOVE.L 20(A0), -(SP) ; theConfig
MOVE.W 18(A0), -(SP) ; count
MOVE.L 14(A0), -(SP) ; theDialog
MOVE.L 10(A0), -(SP) ; theEvent(var)
MOVE.L 6(A0), -(SP) ; theItem(var)
MOVE.L 2(A0), -(SP) ; magicCookie(var)
MOVE.W D0, -(SP) ; manager selector
JSR __CTBSetupFilter
MOVE.B (SP)+, D0 ; function result
RTS
@CTBSetupItem
MOVE.W 20(A0), -(SP) ; procID
MOVE.L 16(A0), -(SP) ; theConfig
MOVE.W 14(A0), -(SP) ; count
MOVE.L 10(A0), -(SP) ; theDialog
MOVE.L 6(A0), -(SP) ; theItem(var)
MOVE.L 2(A0), -(SP) ; magicCookie(var)
MOVE.W D0, -(SP) ; manager selector
JSR __CTBSetupItem
RTS
@CTBSetupXCleanup
MOVE.W 18(A0), -(SP) ; procID
MOVE.L 14(A0), -(SP) ; theConfig
MOVE.W 12(A0), -(SP) ; count
MOVE.L 8(A0), -(SP) ; theDialog
MOVE.W 6(A0), -(SP) ; OKed
MOVE.L 2(A0), -(SP) ; magicCookie
MOVE.W D0, -(SP) ; manager selector
JSR __CTBSetupXCleanup
RTS
@CTBSetupCleanup
MOVE.W 16(A0), -(SP) ; procID
MOVE.L 12(A0), -(SP) ; theConfig
MOVE.W 10(A0), -(SP) ; count
MOVE.L 6(A0), -(SP) ; theDialog
MOVE.L 2(A0), -(SP) ; magicCookie
MOVE.W D0, -(SP) ; manager selector
JSR __CTBSetupCleanup
RTS
@CTBSetupPostflight
MOVE.W 2(A0),-(SP) ; procID
MOVE.W D0, -(SP) ; manager selector
JSR __CTBSetupPostflight
RTS
@CTBGetConfig CLR.L -(SP) ; make room
MOVE.L 2(A0), -(SP) ; hCore
MOVE.W D0, -(SP) ; manager selector
JSR __CTBGetConfig
MOVE.L (SP)+, D0
RTS
@CTBSetConfig CLR.W -(SP) ; make room
MOVE.L 6(A0), -(SP) ; hCore
MOVE.L 2(A0), -(SP) ; thePtr
MOVE.W D0, -(SP) ; manager selector
JSR __CTBSetConfig
MOVE.W (SP)+, D0 ; return value
RTS
@CTBIntlToEnglish CLR.W -(SP) ; make room
MOVE.L 12(A0), -(SP) ; hCore
MOVE.L 8(A0), -(SP) ; input ptr
MOVE.L 4(A0), -(SP) ; output ptr
MOVE.W 2(A0), -(SP) ; language
MOVE.W D0, -(SP) ; manager selector
JSR __CTBIntlToEnglish
MOVE.W (SP)+, D0
RTS
@CTBEnglishToIntl CLR.W -(SP) ; make room
MOVE.L 12(A0), -(SP) ; hCore
MOVE.L 8(A0), -(SP) ; input ptr
MOVE.L 4(A0), -(SP) ; output ptr
MOVE.W 2(A0), -(SP) ; language
MOVE.W D0, -(SP) ; manager selector
JSR __CTBEnglishToIntl
MOVE.W (SP)+, D0
RTS
@CTBChoose ; 292
CLR.W -(SP) ; make room
MOVE.L 10(A0), -(SP) ; hCore
MOVE.L 6(A0), -(SP) ; where
MOVE.L 2(A0), -(SP) ; idleProc
MOVE.W D0, -(SP) ; manager selector
JSR __CTBChoose
MOVE.W (SP)+, D0 ; return point
RTS
@CTBDefault
MOVE.L 6(A0), -(SP) ; theConfig
MOVE.W 4(A0), -(SP) ; procID
MOVE.W 2(A0), -(SP) ; allocate
MOVE.W D0,-(SP) ; MgrSel
JSR __CTBDefault
RTS
@CTBValidate CLR.B -(SP) ; make room
MOVE.L 2(A0), -(SP) ; hCore
MOVE.W D0,-(SP) ; MgrSel
JSR __CTBValidate
MOVE.B (SP)+, D0
RTS
@CTBGetProcID CLR.W -(SP) ; make room
MOVE.L 2(A0), -(SP) ; name
MOVE.W D0, -(SP) ; mgrsel
JSR __CTBGetProcID
MOVE.W (SP)+, D0
RTS
@CTBResume
MOVE.L 4(A0),-(SP) ; hCore
MOVE.W 2(A0),-(SP) ; res
JSR __CTBResume
RTS
@CTBMenu CLR.B -(SP) ; make room
MOVE.L 6(A0), -(SP) ; hCore
MOVE.W 4(A0), -(SP) ; menuID
MOVE.W 2(A0), -(SP) ; item
JSR __CTBMenu
MOVE.B (SP)+, D0
RTS
@CTBEvent
MOVE.L 6(A0), -(SP) ; hCore
MOVE.L 2(A0), -(SP) ; event record pointer
JSR __CTBEvent
RTS
@CTBActivate ; 21
MOVE.L 4(A0), -(SP) ; hCore
MOVE.W 2(A0), -(SP) ; act
JSR __CTBActivate
RTS
@CTBAbort ; 23
CLR.W -(SP) ; make room
MOVE.L 2(A0), -(SP) ; hCore
JSR __CTBAbort
MOVE.W (SP)+, D0
RTS
@CTBReset ; 24
MOVE.L 2(A0), -(SP) ; hCore
JSR __CTBReset
RTS
@CTBPChoose ; 26
CLR.W -(SP) ; make room
MOVE.L 10(A0), -(SP) ; hCore
MOVE.L 6(A0), -(SP) ; where
MOVE.L 2(A0), -(SP) ; chooseRec
MOVE.W D0, -(SP) ; manager selector
JSR __CTBPChoose
MOVE.W (SP)+, D0 ; return point
RTS
@CTBGetErrorString ; 28
MOVE.L 8(A0), -(SP) ; hCore
MOVE.W 6(A0), -(SP) ; id
MOVE.L 2(A0), -(SP) ; msg
MOVE.W D0, -(SP) ; manager selector
JSR __CTBGetErrorString
RTS
CTBGetToolName PROC
IMPORT CRMParseRefNum;
local EQU -2
ignored EQU -2
name EQU 2
procID EQU 6
LINK A6,#local
MOVE.L A1,-(SP)
MOVE.L name(A0),A1
MOVE.B #$0,(A1)
SUB.L #$2,SP
MOVE.W procID(A0),-(SP)
MOVE.L A1,-(SP)
PEA ignored(A6)
JSR CRMParseRefNum
TST.W (SP)+
MOVE.L (SP)+,A1
UNLK A6
RTS
ENDP
_CTBValidate FUNC
;
; Registers:
; A0 - Toolbox Record
; A1 - place to dereference hCore
; A2 - hCore
; A3 - procPtr for valproc
; D0 - (entry)Manager Selector used to index into table
; temp location for setting CCs after getting resource
; D3 - procID until we call the tool, result at end
IMPORT CRMGetAResource, CRMToolPreflight, CRMToolPostflight, CRMReleaseResource
local EQU -$C
context EQU -$C
hCore EQU 2
LINK A6,#local
MOVEM.L D1-D7/A1-A4,-(SP)
SUB.L #4,SP ; Make room for the return value
ASL.W #2, D0 ; multiply by 4
MOVE.L ValTable(D0),-(SP) ; pull it from the table
MOVE.L hCore(A0),A2
MOVE.L (A2),A1
MOVE.W CTBprocID(A1),D3
MOVE.W D3,-(SP)
JSR CRMGetAResource ; Get the Val proc
MOVE.L (A7)+,A0
MOVE.L A0,D0 ; Set the condition codes (MOVEA doesn't set them)
BEQ.S @error
_MoveHHi ; doesn't matter if this errors
_HLock ; Lock it up
MOVE.L A0,A3 ; Save off the proc handle
MOVE.W D3,-(SP) ; Preflight the tool
PEA context(A6)
JSR CRMToolPreflight
CLR.L -(SP)
MOVE.L A2,-(SP) ; hCore
MOVE.W #CTBValidateMsg,-(SP) ; msg
CLR.L -(SP) ; p1
CLR.L -(SP) ; p2
CLR.L -(SP) ; p3
MOVE.L (A3),A0 ; Dereference procptr
JSR (A0)
MOVE.L (SP)+,D3
PEA context(A6)
JSR CRMToolPostflight
MOVE.L A3,-(SP)
JSR CRMReleaseResource ; Get rid of it
BRA.S @done
@error
MOVE.W 0,D3
@done
CLR.L D0
TST.W D3
SEQ D0
NEG.B D0
MOVEM.L D1-D7/A1-A4,-(SP)
UNLK A6
RTS
DbgInfo.new _CTBValidate ; Let me see a name
ValTable DC.L ('cval'), ('tval'), ('fval')
ENDFUNC
CTBIdle PROC
IMPORT CRMToolPreflight, CRMToolPostflight
local EQU -$C
context EQU -$C
hCore EQU 2
LINK A6,#Local
MOVEM.L A1-A3,-(SP)
MOVE.L hCore(A0),A2 ; Get the core handle
MOVE.L (A2),A1 ; Dereference it
MOVE.L CTBdefProc(A1),A3 ; Save off the DefProc
MOVE.W CTBprocID(A1),-(A7) ; Get the procID
PEA context(A6)
JSR CRMToolPreflight ; Preflight the tool
CLR.L -(SP) ; Call the defproc
MOVE.L A2,-(SP) ; hCore
MOVE.W #CTBIdleMsg,-(SP) ; msg
CLR.L -(SP) ; p1
CLR.L -(SP) ; p2
CLR.L -(SP) ; p3
JSR (A3)
TST.L (A7)+ ; Get rid of return value
PEA context(A6) ; Postflight the tool
JSR CRMToolPostflight
MOVEM.L (SP)+,A1-A3 ; Restore the world
UNLK A6
RTS
DbgInfo.new CTBIdle ; Let me see a name
ENDP
END