mirror of
https://github.com/elliotnunn/supermario.git
synced 2024-11-25 09:30:50 +00:00
461 lines
15 KiB
Plaintext
461 lines
15 KiB
Plaintext
;
|
||
; File: CommToolboxPriv.a
|
||
;
|
||
; Contains: Assembly Privates for CTB
|
||
;
|
||
; Written by: Byron Han
|
||
;
|
||
; Copyright: © 1988-1992 by Apple Computer, Inc., all rights reserved.
|
||
;
|
||
; Change History (most recent first):
|
||
;
|
||
; <SM3> 7/7/92 CSS Roll-in from Reality.
|
||
; <20> 2/7/92 BH ResourceMapRecord removed, use ResourceMgrPriv.a instead
|
||
; <SM2> 7/6/92 PN Add CommToolBoxTable into CTBBlock
|
||
; <19> 8/21/91 JSM Clean up header.
|
||
; <18> 1/30/91 gbm sab, #38: Change the ‘already including this file’ variable to
|
||
; all uppercase (for security reasons)
|
||
; <17> 1/14/91 CP Moved gestalt EQU's to GestaltPrivateEqu.a <BBH>
|
||
; <16> 1/9/91 kaz <jng> Changing ModemStringType and PrinterStringType to STR# to
|
||
; include driver names. Changing ChooseIDStrID from -32512 to
|
||
; -32510.
|
||
; <15> 12/10/90 kaz Fixing Gestalt typo <jng>
|
||
; <14> 11/1/90 fjs add equates for color icon types
|
||
; <13> 10/2/90 kaz Adding CRMAppRec to keep track of the processes that init the
|
||
; Term, FT, or Conn Mgrs; renamed reserved to appList to CTBBlock;
|
||
; added bitfields for initialized mgrs. <jng>
|
||
; <12> 9/10/90 JNG Have ResFileRec contain canonical form of file name; Add in new
|
||
; resources for choose
|
||
; <11> 8/6/90 BBH add back gestalt constants that are now private
|
||
; <9> 4/11/90 BBH added CTBBlockSize to determine size of the CTBBlock data
|
||
; structure
|
||
; <8> 3/17/90 BBH changed gestaltVersion to funcVersion to avoid duplicate symbol
|
||
; conflict with gestaltEqu.a
|
||
; <7> 3/17/90 BBH added gestalt function header for better stuffing of the version
|
||
; into the gestalt function resource
|
||
; <6> 3/16/90 BBH removed CTB_SysHeapType and replaced it with CTB_VersionType
|
||
; <5> 3/15/90 BBH fix typo
|
||
; <4> 3/14/90 BBH add constants for DITL entry
|
||
; <3> 3/14/90 BBH fix case for CTB_sysHeapMinID
|
||
; <2> 3/14/90 BBH added resource for minimum system heap size and merge in
|
||
; CommResourcesPriv.a, CTBPrivate.a, and CTBCoreIntf.a
|
||
; <1> 3/14/90 BBH first checked in
|
||
;
|
||
|
||
IF &TYPE('__INCLUDINGCOMMTOOLBOXPRIV__') = 'UNDEFINED' THEN
|
||
__INCLUDINGCOMMTOOLBOXPRIV__ SET 1
|
||
|
||
INCLUDE 'FSEqu.a'
|
||
|
||
;
|
||
;===============================================================================
|
||
;NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
|
||
;
|
||
;Any changes made here MUST be reflected also in
|
||
; CommToolboxPriv.p
|
||
; CommToolboxPriv.a
|
||
; CommToolboxPriv.h
|
||
; CommToolboxPriv.r
|
||
;NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
|
||
;===============================================================================
|
||
;
|
||
; This file contains the resource types and resource ID's to be used by the CommToolbox
|
||
|
||
; the following 7 resources are temporary to be merged into ptch code
|
||
CTB_InstallType EQU 'INIT'
|
||
CTB_InstallID EQU 29
|
||
|
||
CTB_DispatcherType EQU 'proc' ; this used to be ctbd -32512
|
||
CTB_DispatcherID EQU -32509
|
||
|
||
CTB_GestaltProcType EQU 'proc' ; this used to be ctbg -32510
|
||
CTB_GestaltProcID EQU -32508
|
||
|
||
CTB_PatchType EQU 'ctbp' ; this used to be type ctb∂
|
||
CTB_Patch1 EQU -32512 ; allocate low memory
|
||
CTB_Patch2 EQU -32511 ; register builtin ports
|
||
CTB_Patch3 EQU -32510 ; perform gestalt installation
|
||
; end temporary
|
||
|
||
CTB_ConnectionMgrType EQU 'cmtb'
|
||
CTB_FileTransferMgrType EQU 'cmtb'
|
||
CTB_TerminalMgrType EQU 'cmtb'
|
||
CTB_CTBUtilitiesType EQU 'cmtb'
|
||
CTB_CommResourceMgrType EQU 'cmtb'
|
||
|
||
CTB_ConnectionMgrID EQU -32512
|
||
CTB_FileTransferMgrID EQU -32511
|
||
CTB_TerminalMgrID EQU -32510
|
||
CTB_CTBUtilitiesID EQU -32509
|
||
CTB_CommResourceMgrID EQU -32508
|
||
|
||
CTB_VersionType EQU 'ctb ' ; used to be ctbv -32512
|
||
CTB_VersionID EQU -32512
|
||
|
||
CTB_KeyclickType EQU 'snd ' ; this used to be ctb$ -32511
|
||
CTB_KeyclickID EQU -32512
|
||
|
||
CTB_ChooseType EQU 'proc' ; this used to be choo -32512
|
||
CTB_ChooseID EQU -32512
|
||
|
||
CTB_DITLPackType EQU 'proc' ; this used to be ditl -32512
|
||
CTB_DITLPackID EQU -32511
|
||
|
||
CTB_NuLookupType EQU 'proc' ; this used to be nlup -32510
|
||
CTB_NuLookupID EQU -32510
|
||
|
||
CTB_NuLookupParmsType EQU 'flst' ; this used to be parm -32510
|
||
CTB_NuLookupParmsID EQU -32510
|
||
|
||
CTB_ModemIconType EQU 'ICN#' ; this used to be ctbi -32512
|
||
CTB_Modem4ColorIconType EQU 'icl4'
|
||
CTB_Modem8ColorIconType EQU 'icl8'
|
||
CTB_ModemIconID EQU -32512
|
||
|
||
CTB_PrinterIconType EQU 'ICN#' ; this used to be ctbi -32511
|
||
CTB_Printer4ColorIconType EQU 'icl4'
|
||
CTB_Printer8ColorIconType EQU 'icl8'
|
||
CTB_PrinterIconID EQU -32511
|
||
|
||
CTB_ModemStringType EQU 'STR#' ; this used to be ctbs -32512
|
||
CTB_ModemStringID EQU -32512
|
||
|
||
CTB_PrinterStringType EQU 'STR#' ; this used to be ctbs -32511
|
||
CTB_PrinterStringID EQU -32511
|
||
|
||
CTB_CommFolderNameType EQU 'STR ' ; this used to be ctbs -32510
|
||
CTB_CommFolderNameID EQU -32510
|
||
|
||
CTB_MarkerType EQU 'ctb ' ; lets CTB6 installer scripts know CTB7 is installed
|
||
CTB_CTB6MarkerID EQU 0
|
||
CTB_CTB7MarkerID EQU 1
|
||
|
||
CTB_ChooseDLOGID EQU -32512
|
||
CTB_ChoosehdlgID EQU -32512
|
||
CTB_ChoosedctbID EQU -32512
|
||
CTB_ChooseDITLID EQU -32512
|
||
CTB_ChooseSTRsID EQU -32510
|
||
CTB_ChooseLDEFID EQU -32512
|
||
CTB_ChoosehmnuID EQU -32512
|
||
CTB_ChoosefinfID EQU -32512
|
||
CTB_ChooseflstID EQU -32512 ; preferred over finf
|
||
CTB_ChooseCNTLID EQU -32512
|
||
CTB_ChooseMENUID EQU -32512
|
||
|
||
CTB_ChooseConfirmDLOGID EQU -32511
|
||
CTB_ChooseConfirmDITLID EQU -32511
|
||
|
||
CTB_ChooseUnavailableDLOGID EQU -32509
|
||
CTB_ChooseUnavailableDITLID EQU -32509
|
||
|
||
CTB_NulookuphdlgID EQU -32510
|
||
CTB_NulookupDLOGID EQU -32510
|
||
CTB_NulookupdctbID EQU -32510
|
||
CTB_NulookupDITLID EQU -32510
|
||
CTB_NulookupSTRsID EQU -32510
|
||
CTB_NulookupLDEFID EQU -32510
|
||
|
||
CTB_PopupCDEFType EQU 'CDEF'
|
||
CTB_PopupCDEFID EQU 63
|
||
|
||
; added since CTB6
|
||
CTB_PopupTriangleType EQU 'PICT'
|
||
CTB_PopupTriangleID EQU -8224 ; owned by cdef 63
|
||
|
||
CTB_PopupExpandType EQU 'proc' ; this expands menuwidth
|
||
CTB_PopupExpandID EQU -8224 ; owned by cdef 63
|
||
|
||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||
;;;;; Begin CommToolboxUtilites privates
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||
AppendMsg EQU 1
|
||
CountMsg EQU 2
|
||
ShortenMsg EQU 3
|
||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||
;;;;; Begin Installer privates
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||
|
||
; partial resource map description
|
||
dispatchBranch EQU 0
|
||
dispatchTable EQU 2
|
||
dispatchRefnum EQU 78
|
||
dispatchBig EQU 80
|
||
|
||
|
||
; gestalt function description header
|
||
funcBranch EQU 0
|
||
funcType EQU 2
|
||
funcVersion EQU 6
|
||
funcID EQU 8
|
||
funcCTBV EQU 10
|
||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||
;;;;; Begin CommResourceMgr privates
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||
|
||
; removed in <20> - use ResourceMgrPriv.a
|
||
;
|
||
; partial resource map description
|
||
;ResourceMapRecord RECORD 0
|
||
;theHeader DS.L 4
|
||
;next DS.L 1
|
||
;refNum DS.W 1
|
||
; ENDR
|
||
|
||
|
||
; description of CommResourceMgr structures for resource map manipulation
|
||
CRMToolContext RECORD 0 ; NOTE::: If you change anything here, make sure CRMToolPreflight
|
||
; tool postflight get changed as well.
|
||
oldProcID DS.W 1
|
||
oldHidden DS.L 1
|
||
toolProcID DS.W 1
|
||
wasBelow DS.B 1
|
||
ENDR
|
||
|
||
; CommResourceMgr structures for resource file management
|
||
ResFileRec RECORD 0
|
||
theName DS FSSpec ; Canonical File name
|
||
refNum DS.W 1 ; resource file reference number
|
||
resMap DS.L 1 ; handle to master resource map
|
||
pZone DS.L 1 ; zone where resource map resides
|
||
useCount DS.L 1 ; use count in the current heap
|
||
special DS CRMToolContext ; context saved for setup
|
||
reserved DS.L 1
|
||
next DS.L 1 ; next in the chain
|
||
size EQU *
|
||
ENDR
|
||
|
||
; CRMResourceCount to track individual resources
|
||
CRMResourceCount RECORD 0
|
||
next DS.L 1 ; next in the chain
|
||
theHandle DS.L 1 ; the resource to track
|
||
useCount DS.L 1 ; use count for this resource
|
||
refnum DS.W 1 ; god only knows
|
||
ENDR
|
||
|
||
; CRM App bits values for the cmtbFlags below
|
||
cmInUse EQU 1
|
||
tmInUse EQU 2
|
||
ftInUse EQU 4
|
||
|
||
; CRMAppRec to track processes that have called InitTM, InitFT, and InitCM
|
||
CRMAppRec RECORD 0
|
||
aProcess DS.L 2 ; unique id for each process (not in Processes.a)
|
||
cmtbFlags DS.W 1 ; bit field for InitXX calls
|
||
reserved DS.L 1 ;
|
||
next DS.L 1 ; next in chain
|
||
ENDR
|
||
|
||
|
||
; CommToolbox globals
|
||
CTBBlockVersion EQU 1
|
||
|
||
CTBBlock RECORD 0
|
||
version DS.W 1 ; CTBBlockVersion
|
||
CRMQueue DS.L 1 ; QHdrPtr;
|
||
resList DS.L 1 ; LONGINT;
|
||
private DS.W 1 ; INTEGER;
|
||
appList DS.L 1 ; CRMAppRecPtr;
|
||
resFiles DS.L 1 ; ResFileRecHdl;
|
||
toolResChain DS.L 1 ; ResourceMapHandle;
|
||
CommToolBoxTable DS.L 1 ; ptr to table
|
||
secret DS.L 16 ; LONGINT
|
||
CTBBlockSize EQU *
|
||
ENDR
|
||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||
;; Core routines
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||
|
||
; manager selectors
|
||
CMSel EQU 0
|
||
TMSel EQU 1
|
||
FTSel EQU 2
|
||
|
||
|
||
; common error codes
|
||
CTBNoTools EQU 8
|
||
|
||
; Common Tool Messages
|
||
CTBInitMsg EQU 0
|
||
CTBDisposeMsg EQU 1
|
||
CTBSuspendMsg EQU 2
|
||
CTBResumeMsg EQU 3
|
||
CTBMenuMsg EQU 4
|
||
CTBEventMsg EQU 5
|
||
CTBActivateMsg EQU 6
|
||
CTBDeactivateMsg EQU 7
|
||
CTBGetErrorStringMsg EQU 8 ; except for connection manager since I BBH f*cked up
|
||
|
||
CTBIdleMsg EQU 50
|
||
CTBResetMsg EQU 51
|
||
CTBAbortMsg EQU 52
|
||
|
||
CTBValidateMsg EQU 0
|
||
CTBDefaultMsg EQU 1
|
||
|
||
CTBPreflightMsg EQU 0
|
||
CTBSetupMsg EQU 1
|
||
CTBItemMsg EQU 2
|
||
CTBFilterMsg EQU 3
|
||
CTBCleanupMsg EQU 4
|
||
|
||
CTBGetMsg EQU 0
|
||
CTBSetMsg EQU 1
|
||
|
||
CTB2EnglishMsg EQU 0
|
||
CTB2IntlMsg EQU 1
|
||
|
||
; core data structures
|
||
CTBProcID EQU 0 ;INTEGER;
|
||
CTBFlags EQU CTBProcID+2 ;LONGINT;
|
||
CTBerrCode EQU CTBFlags+4 ;OSErr;
|
||
CTBRefCon EQU CTBerrCode+2 ;LONGINT
|
||
CTBUserData EQU CTBRefCon+4 ;LONGINT;
|
||
CTBDefProc EQU CTBUserData+4 ;ProcPtr;
|
||
CTBConfig EQU CTBDefProc+4 ;Ptr;
|
||
CTBOldConfig EQU CTBConfig+4 ;Ptr;
|
||
CTBReserved0 EQU CTBOldConfig+4 ;LONGINT;
|
||
CTBReserved1 EQU CTBReserved0+4 ;LONGINT;
|
||
CTBReserved2 EQU CTBReserved1+4 ;LONGINT;
|
||
|
||
|
||
; macros for invoking managers from assembler
|
||
; macros for including macsbug symbols
|
||
|
||
MACRO
|
||
_CTBTrap &selector
|
||
MOVE.L (SP)+,D0 ; Get the return address
|
||
MOVE.W &selector,-(SP) ; Push the selector
|
||
MOVE.L SP,A0 ; Save off the record flag
|
||
MOVE.L D0,-(SP) ; Put RA back onto stack
|
||
_CommToolboxDispatch ; Trap
|
||
ENDM
|
||
|
||
; macro for invoking core routines
|
||
; note that this differs from ExternalCore macros in that there is an
|
||
; additional manager selector field to be passed
|
||
;
|
||
MACRO
|
||
_RealExternalCore &selector,&mgrsel
|
||
MOVE.W &mgrsel,D0 ; Set the MgrSelector
|
||
MOVE.W (A0),-(SP) ; Save the selector
|
||
MOVE.W &selector,(A0) ; Replace with new selector
|
||
_CommToolboxDispatch ; Trap
|
||
MOVE.W (SP)+,(A0)
|
||
RTS
|
||
ENDM
|
||
|
||
Macro
|
||
EndCTBTrap &parmsize,&returnsize=0
|
||
MOVE.L (SP)+,A0 ; Get RA
|
||
ADDA.W &parmsize,SP ; Clear parameters
|
||
If (&UC(&returnsize) = 'W') Then
|
||
MOVE.w D0,(SP) ; Stuff Return value
|
||
ElseIf (&UC(&returnsize) = 'B') Then
|
||
MOVE.B D0,(SP)
|
||
ElseIf (&UC(&returnsize) = 'L') Then
|
||
Move.L D0,(SP)
|
||
Endif
|
||
JMP (A0) ; Return to caller
|
||
ENDM
|
||
|
||
* ----------- DEBUGGING INFORMATION -------------
|
||
* This is used as a global switch to turn off the generation of debugging information.
|
||
* The MACRO "DbgInfo" will generate this debugging information if set to 1.
|
||
|
||
IF (&TYPE('DebuggerInfo') = 'UNDEFINED') THEN
|
||
IF (&TYPE('RAID') = 'UNDEFINED') THEN
|
||
RAID EQU 0
|
||
ENDIF
|
||
|
||
IF RAID THEN
|
||
DebuggerInfo EQU 1
|
||
ELSE
|
||
DebuggerInfo EQU 0
|
||
ENDIF
|
||
ENDIF
|
||
|
||
* ------------- GENERATE DEBUGGER SYMBOL INFORMATION -------------
|
||
* This Macro will generate information for the debugger to read and display
|
||
* as its module name. This aids in debugging Asm code while looking at it
|
||
* in the debugger. This macro can only work if called at the end of stack
|
||
* frame. The appearance of the Macro statement in the source code must occur
|
||
* immediately after the final "JMP (A0)" or "RTS" instruction following the UNLINK.
|
||
* Spaces may be included in the name, but no quotes are allowed.
|
||
|
||
* {Form #1} DbgInfo ModName
|
||
* {Form #2} DbgInfo.New Really Long Module Name For MacsBug 6.0
|
||
|
||
* There are now two naming conventions used in MacsBug, Form #1 is the older MacsBug,
|
||
* or TMON, and Form #2 is the newer MacsBug 6.0. The older method would only
|
||
* allow for a fixed length of eight characters. If a shorter name is passed to
|
||
* this Macro, it will extend the length to 8 chars with trailing spaces.
|
||
* MacsBug 6.0 will now allow for a variable length C type string. This Macro will
|
||
* create the proper DC statements and takes into account word alignment issues.
|
||
|
||
|
||
MACRO
|
||
DbgInfo.&Opt &ModName# ; the name to be used in the Debugger
|
||
PRINT Push,NoMDir ; Only list generated code
|
||
LCLC &DbgName# ; name to generate for MacsBug
|
||
LCLC &DbgTemp ; temporary name variable
|
||
LCLC &New ; variable used to test old vs. new
|
||
LCLC &S ; variable used to save PRINT state
|
||
|
||
IF DebuggerInfo THEN ; do we want debugging info?
|
||
IF &ModName# ≠ '' THEN ; did we get a module name?
|
||
&New: SETC &UpCase(&Opt) ; make option all upper case
|
||
IF (&New = 'NEW') THEN ; do we want new style?
|
||
|
||
.* Create the new MacsBug naming convention
|
||
* -----------------------------------------------
|
||
&DbgTemp: SETC &ModName# ; generate new type symbols
|
||
IF &Len(&ModName#) < 32 THEN ; if module name < 32 chars
|
||
IF &Len(&ModName#) // 2 = 0 THEN ; add space if even so that...
|
||
&DbgTemp: SETC &Concat(&ModName#,' ') ; string length plus length byte...
|
||
ENDIF ; will align to word boundary
|
||
&DbgName#: SETC &Concat(&Chr($80 + &Len(&ModName#)), &DbgTemp)
|
||
ELSE ; Length > 32 characters
|
||
IF &Len(&ModName#) // 2 = 1 THEN ; add space if length is odd
|
||
&DbgTemp: SETC &Concat(&ModName#,' ')
|
||
ENDIF
|
||
&DbgName#: SETC &Concat(&Chr($80), &Chr(&Len(&ModName#)), &DbgTemp)
|
||
ENDIF
|
||
ELSE ; make it the older style
|
||
|
||
.* Create the older MacsBug naming convention
|
||
* -----------------------------------------------
|
||
IF &Len(&ModName#) < 8 THEN ; if module name < 8 chars
|
||
&DbgName#: SETC &Concat(&ModName#,' ') ; add at least 7 spaces
|
||
&DbgName#: SETC &Concat(&Chr($80 + &ORD(&SubStr(&DbgName#,1,1))), &SubStr(&DbgName#,2,7))
|
||
ELSE ; there are at least 8 chars
|
||
&DbgName#: SETC &Concat(&Chr($80 + &ORD(&SubStr(&ModName#,1,1))), &SubStr(&ModName#,2,7))
|
||
ENDIF
|
||
ENDIF
|
||
|
||
.* Create the DC.B with the debugger name, and include the NULs if new MacsBug option
|
||
* -----------------------------------------------
|
||
&S: SETC &Setting('STRING') ; preserve STRING status
|
||
IF &S ≠ 'ASIS' THEN ; only change it if not already ASIS
|
||
STRING ASIS
|
||
DC.B '&DbgName#'
|
||
IF (&New = 'NEW') THEN
|
||
DC.W 0 ; fake literal size for new MacsBug
|
||
ENDIF
|
||
STRING &S
|
||
ELSE
|
||
DC.B '&DbgName#'
|
||
IF (&New = 'NEW') THEN
|
||
DC.W 0 ; fake literal size for new MacsBug
|
||
ENDIF
|
||
ENDIF
|
||
ENDIF
|
||
ENDIF
|
||
|
||
PRINT Pop ; restore original print status
|
||
ENDM
|
||
|
||
ENDIF ; ...already included |