mirror of
https://github.com/elliotnunn/supermario.git
synced 2024-11-28 13:52:37 +00:00
346 lines
10 KiB
Plaintext
346 lines
10 KiB
Plaintext
|
;
|
||
|
; File: dpMisc.a
|
||
|
;
|
||
|
; Contains: random assembly language routines for the Edition Manager
|
||
|
;
|
||
|
; Written by: Nick Kledzik
|
||
|
;
|
||
|
; Copyright: © 1989-1990 by Apple Computer, Inc., all rights reserved.
|
||
|
;
|
||
|
; This file is used in these builds: BigBang
|
||
|
;
|
||
|
; Change History (most recent first):
|
||
|
;
|
||
|
; <9> 11/26/90 ngk <DFH> Added dpSetCurrentAppRefNum and dp_GetCurrentAppRefNum.
|
||
|
; This takes advantage of new switch expandmem field
|
||
|
; emEditionMgrPerApp.
|
||
|
; <8> 7/11/90 gbm add END to file. Sorry about last comment.
|
||
|
; <7> 7/11/90 gbm .
|
||
|
; <6> 5/31/90 ngk change globals from a handle to a pointer.
|
||
|
; <5> 4/7/90 ngk Added, FailOSErr, IsFailure. Fix dp_CallFormatIOProc to return
|
||
|
; error if I/O has been aborted.
|
||
|
; <4> 3/10/90 ngk Removed GetStateAndLock and RestoreState
|
||
|
; <3> 1/22/90 ngk Fix CallProcPtr routines to use symbolic standard names
|
||
|
; <2> 1/6/90 ngk Added dp_CallEditionOpenerProc and dp_CallFormatIOProc
|
||
|
; <1> 1/6/90 ngk first checked into BBS
|
||
|
; <1.7> 11/20/89 ngk Added dummy rts at end to get MacsBug symbols
|
||
|
; <1.6> 11/13/89 ngk Added GetStateAndLock and RestoreState
|
||
|
; <1.5> 10/25/89 ngk Fixed bug in which I forgot to deallocate parameters in
|
||
|
; UnSignedDivide and UnSignedMultiply
|
||
|
; <•1.4> 10/2/89 ngk nothing
|
||
|
; <1.3> 9/18/89 ngk Added unsigned multiple and divide
|
||
|
; <1.2> 8/8/89 ngk No changes
|
||
|
; <1.1> 5/29/89 ngk Got qNames to work with MacsBug Symbols
|
||
|
; <1.0> 5/19/89 ngk Submitted for first time
|
||
|
;
|
||
|
; To Do:
|
||
|
;
|
||
|
|
||
|
|
||
|
|
||
|
SEG 'Main'
|
||
|
CASE OFF
|
||
|
|
||
|
LOAD 'StandardEqu.d'
|
||
|
INCLUDE 'dpCompileOptions.inc.a'
|
||
|
INCLUDE 'EditionsPrivate.a'
|
||
|
|
||
|
|
||
|
;---------------------------------------------------------------------------
|
||
|
; dpGetGlobalsLocation
|
||
|
;
|
||
|
; FUNCTION dpGetGlobalsLocation: EdtnMgrGlobalsPtrPtr; EXTERNAL;
|
||
|
;
|
||
|
;---------------------------------------------------------------------------
|
||
|
dpGetGlobalsLocation PROC EXPORT
|
||
|
move.l ExpandMem,A0 ; get pointer to expanded low mem
|
||
|
lea ExpandMemRec.emDataPub(A0),A0 ; get location of globals handle
|
||
|
move.l A0,4(SP) ; return it
|
||
|
rts
|
||
|
|
||
|
IF qNames THEN
|
||
|
DebugerSymbol dpGetGlobalsLocation ; MacsBug Symbols
|
||
|
ENDIF
|
||
|
|
||
|
ENDPROC ; dpGetGlobalsLocation
|
||
|
|
||
|
|
||
|
;---------------------------------------------------------------------------
|
||
|
; dpSetCurrentAppRefNum
|
||
|
;
|
||
|
; PROCEDURE dpSetCurrentAppRefNum(app: AppRefNum);
|
||
|
;
|
||
|
;---------------------------------------------------------------------------
|
||
|
dpSetCurrentAppRefNum PROC EXPORT
|
||
|
move.l (SP)+,A0 ; get return address
|
||
|
move.l ExpandMem,A1 ; get pointer to expanded low mem
|
||
|
move.l (SP)+,ExpandMemRec.emEditionMgrPerApp(A1); store handle
|
||
|
jmp (A0) ; return
|
||
|
|
||
|
IF qNames THEN
|
||
|
DebugerSymbol dpSetCurrentAppRefNum ; MacsBug Symbols
|
||
|
ENDIF
|
||
|
|
||
|
ENDPROC ; dpSetCurrentAppRefNum
|
||
|
|
||
|
|
||
|
;---------------------------------------------------------------------------
|
||
|
; dp_GetCurrentAppRefNum
|
||
|
;
|
||
|
; FUNCTION dp_GetCurrentAppRefNum(VAR app: AppRefNum): OSErr;
|
||
|
;
|
||
|
;---------------------------------------------------------------------------
|
||
|
dp_GetCurrentAppRefNum PROC EXPORT
|
||
|
move.l ExpandMem,A0 ; get pointer to expanded low mem
|
||
|
move.l ExpandMemRec.emEditionMgrPerApp(A0),D0 ; get app's global's handle
|
||
|
move.l (SP)+,A0 ; get return address
|
||
|
move.l (SP)+,A1 ; get place to put handle
|
||
|
clr.w (SP) ; return noErr by default
|
||
|
move.l D0,(A1) ; return handle
|
||
|
bne.s @done ; is handle NIL?
|
||
|
move.w #editionMgrInitErr,(SP) ; if so, return error
|
||
|
@done jmp (A0) ; return
|
||
|
|
||
|
IF qNames THEN
|
||
|
DebugerSymbol dp_GetCurrentAppRefNum ; MacsBug Symbols
|
||
|
ENDIF
|
||
|
|
||
|
ENDPROC ; dp_GetCurrentAppRefNum
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
;---------------------------------------------------------------------------
|
||
|
;
|
||
|
; PROCEDURE UnSignedDivide(numerator: {unsigned}LONGINT;
|
||
|
; denom: {unsigned}INTEGER;
|
||
|
; VAR quotient,remainder: {unsigned}INTEGER);
|
||
|
;
|
||
|
;---------------------------------------------------------------------------
|
||
|
UnSignedDivide PROC EXPORT
|
||
|
numerator EQU 18
|
||
|
denom EQU 16
|
||
|
quotient EQU 12
|
||
|
remainder EQU 8
|
||
|
link A6,#0
|
||
|
move.l numerator(a6),D0
|
||
|
divu denom(a6),D0
|
||
|
move.l quotient(a6),A0
|
||
|
move.w D0,(A0)
|
||
|
swap D0
|
||
|
move.l remainder(a6),A0
|
||
|
move.w D0,(A0)
|
||
|
unlk A6
|
||
|
move.l (SP)+,A0
|
||
|
add #14,SP
|
||
|
jmp (A0)
|
||
|
|
||
|
IF qNames THEN
|
||
|
DebugerSymbol UnSignedDivide ; MacsBug Symbols
|
||
|
ENDIF
|
||
|
|
||
|
ENDPROC ; UnSignedDivide
|
||
|
|
||
|
|
||
|
;---------------------------------------------------------------------------
|
||
|
;
|
||
|
; PROCEDURE UnSignedMultiply(mult1, mult2: {unsigned}INTEGER;
|
||
|
; VAR result{unsigned}LONGINT);
|
||
|
;
|
||
|
;---------------------------------------------------------------------------
|
||
|
UnSignedMultiply PROC EXPORT
|
||
|
mult1 EQU 14
|
||
|
mult2 EQU 12
|
||
|
result EQU 8
|
||
|
link A6,#0
|
||
|
move.w mult1(A6),D0
|
||
|
mulu mult2(a6),D0
|
||
|
move.l result(a6),A0
|
||
|
move.l D0,(A0)
|
||
|
unlk A6
|
||
|
move.l (SP)+,A0
|
||
|
add #8,SP
|
||
|
jmp (A0)
|
||
|
|
||
|
IF qNames THEN
|
||
|
DebugerSymbol UnSignedMultiply ; MacsBug Symbols
|
||
|
ENDIF
|
||
|
|
||
|
ENDPROC ; UnSignedMultiply
|
||
|
|
||
|
|
||
|
|
||
|
;----------------------------------------------------------------------------------------------
|
||
|
;
|
||
|
; FUNCTION dp_CallEditionOpenerProc(selector: EditionOpenerVerb; VAR PB: EditionOpenerParamBlock;
|
||
|
; routine: EditionOpenerProcPtr): OSErr;
|
||
|
;
|
||
|
;----------------------------------------------------------------------------------------------
|
||
|
dp_CallEditionOpenerProc PROC EXPORT
|
||
|
IMPORT dpStandardOpener
|
||
|
|
||
|
move.l (SP)+,A0 ; get return address
|
||
|
move.l (SP)+,D0 ; get routine address
|
||
|
move.l A0, -(SP) ; restore return address
|
||
|
cmp.l #kStandardOpenerProcPtr,D0 ; do we use standard ?
|
||
|
beq dpStandardOpener ; if yes, jump to standard
|
||
|
move.l D0,A0 ; otherwise,
|
||
|
jmp (A0) ; jump to ProcPtr
|
||
|
|
||
|
IF qNames THEN
|
||
|
DebugerSymbol dp_CallEditionOpenerProc ; MacsBug Symbols
|
||
|
ENDIF
|
||
|
|
||
|
ENDPROC ; dp_CallEditionOpenerProc
|
||
|
|
||
|
|
||
|
;----------------------------------------------------------------------------------------------
|
||
|
;
|
||
|
; FUNCTION dp_CallFormatIOProc(selector: FormatIOVerb; VAR PB: FormatIOParamBlock;
|
||
|
; routine: FormatIOProcPtr): OSErr;
|
||
|
;
|
||
|
;----------------------------------------------------------------------------------------------
|
||
|
dp_CallFormatIOProc PROC EXPORT
|
||
|
IMPORT dpStandardIO
|
||
|
|
||
|
move.l (SP)+,A0 ; get return address
|
||
|
move.l (SP)+,D0 ; get routine address
|
||
|
move.l A0, -(SP) ; restore return address
|
||
|
cmp.l #kStandardFormatIOProcPtr,D0 ; do we use standard ?
|
||
|
beq dpStandardIO ; if yes, jump to standard
|
||
|
cmp.l #kBogusFormatIOProcPtr,D0 ; has I/O been aborted ?
|
||
|
bne.s @callThePtr ; if no, call the pointer
|
||
|
move.l (SP)+,D0 ; get return address
|
||
|
addq.l #6,SP ; remove parameters
|
||
|
move.w #abortErr,(SP) ; return OSErr
|
||
|
@callThePtr move.l D0,A0 ; otherwise,
|
||
|
jmp (A0) ; jump to ProcPtr
|
||
|
|
||
|
IF qNames THEN
|
||
|
DebugerSymbol dp_CallFormatIOProc ; MacsBug Symbols
|
||
|
ENDIF
|
||
|
|
||
|
ENDPROC ; dp_CallFormatIOProc
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
;----------------------------------------------------------------------------------------------
|
||
|
;
|
||
|
; FUNCTION IsFailure(VAR info: FailInfo; VAR errorValue: OSErr): BOOLEAN;
|
||
|
;
|
||
|
;----------------------------------------------------------------------------------------------
|
||
|
IsFailure PROC EXPORT
|
||
|
|
||
|
returnAddr EQU 0
|
||
|
errorPtr EQU 4
|
||
|
infoPtr EQU 8
|
||
|
|
||
|
; save All regs first
|
||
|
MOVE.L infoPtr(SP),A1
|
||
|
MOVEM.L A2-A7/D3-D7,FailInfo.regs(A1)
|
||
|
|
||
|
; save where to return to on failure and where to put error code
|
||
|
MOVE.L returnAddr(SP),FailInfo.returnTo(A1) ; save the return address
|
||
|
MOVE.L errorPtr(SP),A0
|
||
|
MOVE.L A0,FailInfo.errorPtr(A1) ; save the place to put error
|
||
|
CLR.W (A0) ; be nice and initialize it
|
||
|
|
||
|
; link failinfo into list
|
||
|
SUBQ.L #4,SP
|
||
|
BSR dpGetGlobalsLocation
|
||
|
MOVE.L (SP)+,A0
|
||
|
MOVE.L (A0),A0
|
||
|
MOVE.L EdtnMgrGlobals.failureHandler(A0),FailInfo.nextInfo(A1)
|
||
|
MOVE.L infoPtr(SP),EdtnMgrGlobals.failureHandler(A0)
|
||
|
|
||
|
; clean up stack and return
|
||
|
MOVE.L (SP)+,A0
|
||
|
ADDQ.L #8,SP
|
||
|
CLR.W (SP) ; return FALSE
|
||
|
JMP (A0)
|
||
|
|
||
|
IF qNames THEN
|
||
|
DebugerSymbol IsFailure ; MacsBug Symbols
|
||
|
ENDIF
|
||
|
|
||
|
ENDPROC ; IsFailure
|
||
|
|
||
|
|
||
|
;----------------------------------------------------------------------------------------------
|
||
|
;
|
||
|
; PROCEDURE FailOSErr(anErr: OSErr);
|
||
|
;
|
||
|
;----------------------------------------------------------------------------------------------
|
||
|
FailOSErr PROC EXPORT
|
||
|
|
||
|
returnAddr EQU 0
|
||
|
anErr EQU 4
|
||
|
infoPtr EQU 8
|
||
|
|
||
|
|
||
|
IF qCatchFailures THEN
|
||
|
SUBQ.L #4,SP
|
||
|
BSR dpGetGlobalsLocation
|
||
|
MOVE.L (SP)+,A0
|
||
|
MOVE.L (A0),A0
|
||
|
MOVE.L EdtnMgrGlobals.failureHandler(A0),D0
|
||
|
BNE.S @isHandler
|
||
|
PEA NoHandlerWarn
|
||
|
_DebugStr
|
||
|
@isHandler MOVE.W anErr(SP),D0
|
||
|
BEQ.S @noErr
|
||
|
CMP.W #noTypeErr,D0
|
||
|
BEQ.S @DoFail
|
||
|
PEA FailWarning
|
||
|
_DebugStr
|
||
|
MOVE.W anErr(SP),D0
|
||
|
ELSE
|
||
|
MOVE.W anErr(SP),D0
|
||
|
BEQ.S @noErr
|
||
|
ENDIF
|
||
|
|
||
|
; get current failure info and unlink from list
|
||
|
@DoFail SUBQ.L #4,SP
|
||
|
BSR dpGetGlobalsLocation
|
||
|
MOVE.L (SP)+,A0
|
||
|
MOVE.L (A0),A0
|
||
|
MOVE.L EdtnMgrGlobals.failureHandler(A0),A1
|
||
|
|
||
|
IF qCatchFailures THEN
|
||
|
MOVE.L A1,D1
|
||
|
BNE.S @infoOK
|
||
|
PEA NoHandlerWarn
|
||
|
_DebugStr
|
||
|
@infoOK
|
||
|
ENDIF
|
||
|
MOVE.L FailInfo.nextInfo(A1),EdtnMgrGlobals.failureHandler(A0)
|
||
|
|
||
|
; restore state to return to place that called IsFailure
|
||
|
MOVEM.L FailInfo.regs(A1),A2-A7/D3-D7 ; restore regs
|
||
|
ADD.L #14,SP ; remove IsFailure parameters
|
||
|
|
||
|
; save where to return to on failure and where to put error code
|
||
|
MOVE.L FailInfo.errorPtr(A1),A0 ; get place to put error
|
||
|
MOVE.W D0,(A0) ; put error code where caller wants
|
||
|
MOVE.L FailInfo.returnTo(A1),A0 ; get where to goto
|
||
|
ST -(SP) ; Fake IsFailure returning TRUE
|
||
|
BRA.S @jmp
|
||
|
|
||
|
@noErr MOVE.L (SP)+,A0
|
||
|
ADDQ.L #2,SP
|
||
|
@jmp JMP (A0)
|
||
|
|
||
|
IF qNames THEN
|
||
|
DebugerSymbol FailOSErr ; MacsBug Symbols
|
||
|
ENDIF
|
||
|
|
||
|
IF qCatchFailures THEN
|
||
|
STRING PASCAL
|
||
|
NoHandlerWarn DC.B 'FailOSErr: no failure handler, crash!'
|
||
|
FailWarning DC.B 'FailOSErr: failing.'
|
||
|
ENDIF
|
||
|
|
||
|
ENDPROC ; FailOSErr
|
||
|
|
||
|
END
|