sys7.1-doc-wip/Toolbox/MenuMgr/InvalMenuBarPatch.a
2020-04-26 16:46:44 +08:00

142 lines
6.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;
; Hacks to match MacOS (most recent first):
;
; <Sys7.1> 8/3/92 Restored the routines that were split off in <SM2>.
; 9/2/94 SuperMario ROM source dump (header preserved below)
;
;
; File: InvalMenuBarPatch.a
;
; Contains: implementation of the InvalMenuBar trap as a patch
;
; Written by: Darin Adler
;
; Copyright: © 1990, 1992 by Apple Computer, Inc., all rights reserved.
;
; This file is used in these builds: BigBang
;
; Change History (most recent first):
;
; <SM2> 5/20/92 TN Moved new InvalMenuBar routines to MenuMgrExtensions.a
; <7> 4/16/91 KSM dba,#86852: Add reentrancy bit to fix case where Think Pascal
; patches DrawMenuBar to call HiliteMenu and we die in a recursive
; patch conflict.
; <6> 3/29/91 JSM dba, #85831: Add support for MenuBarGlobalInvalidBit in
; ValidateMenuBarWhenDrawing and ValidateMenuBar.
; <5> 7/25/90 dba fix bug that shows up in THINK Pascal (which patches DrawMenuBar
; to call HiliteMenu) by clearing the invalid bit before calling
; DrawMenuBar; also get rid of the patch to CheckUpdate that calls
; validate, since the Layer Managers CheckUpdate has a call
; inside of it now
; <4> 7/13/90 KSM Add ValidateMenuBar call for WindowMgr's CheckUpdate comefrom
; patch and to save a tiny bit of code.
; <3> 7/9/90 KSM Changed InvalMenuBar proc to use opword.
; <2> 6/7/90 EMT Fix module names so they wont be likely to conflict with other
; patches.
; <1> 4/9/90 dba new to the system today
;
; To Do:
; roll into Menu Manager and Window Manager source
;
load 'StandardEqu.d'
include 'LinkedPatchMacros.a'
include 'MenuMgrPriv.a'
; <Sys7.1> Restored verbatim from MenuMgrExtensions.a
;————————————————————————————————————————————————————————————————————————————————————————————————————
; InvalMenuBar
; Set the low memory bit
InvalMenuBar PatchProc _InvalMenuBar,(Plus,SE,II,Portable,IIci)
bset #MenuBarInvalidBit,MenuBarInvalidByte ; set the invalid bit
rts
EndProc
;————————————————————————————————————————————————————————————————————————————————————————————————————
; DrawMenuBar clear MenuBarInvalidBit and MenuBarGlobalInvalidBit
;
; Note: We depend on the fact that this patch gets invoked after the Process Mgr patch that
; determines whether or not to actually draw the menu bar. Otherwise, we could clear the global
; dirty even if the DrawMenuBar never happens, which we dont want to do.
; Clear the low memory bits whenever we draw the menu bar.
ValidateMenuBarWhenDrawing PatchProc _DrawMenuBar,(Plus,SE,II,Portable,IIci)
bclr #MenuBarInvalidBit,MenuBarInvalidByte ; clear the local invalid bit
bclr #MenuBarGlobalInvalidBit,MenuBarGlobalInvalidByte ; clear the global invalid bit <6>
jmpOld
EndProc
;————————————————————————————————————————————————————————————————————————————————————————————————————
; MenuSelect draw menu bar if invalid
DrawMenuBarIfInvalidOnMenuSelect PatchProc _MenuSelect,(Plus,SE,II,Portable,IIci)
IMPORT ValidateMenuBar
jsr ValidateMenuBar
jmpOld
EndProc
;————————————————————————————————————————————————————————————————————————————————————————————————————
; HiliteMenu draw menu bar if invalid
DrawMenuBarIfInvalidOnHiliteMenu PatchProc _HiliteMenu,(Plus,SE,II,Portable,IIci)
IMPORT ValidateMenuBar
jsr ValidateMenuBar
jmpOld
EndProc
; <Sys7.1> Restored verbatim from MenuMgrExtensions.a
;————————————————————————————————————————————————————————————————————————————————————————————————————
; ValidateMenuBar is the routine that draws the menu bar only if necessary (local or global dirty bit set)
;
; Note that the Process Mgr will not let the _DrawMenuBar through if were not the frontmost process.
;
; For the local dirty bit, we dont care, since well get redrawn anyway when we come to the front. This
; means we can clear it here to eliminate multiple calls to _DrawMenuBar that wont do anything.
;
; However, we want to only test (not clear) the global dirty bit here, which is set by DrawMBARString, since
; we want to make sure the menu bar gets redrawn eventually no matter which app is at the front.
;
; To avoid problems where apps patch any of DrawMenuBar, HiliteMenu, MenuSelect (i.e., the routines
; herein that utilize ValidateMenuBar) and recurse forever trying to validate the menu bar, we
; use a semaphore. (THINK Pascal 3.0 was our orignal culprit.) Note the InstallProc below to
; initialize the semaphore to zero (meaning we are not in ValidateMenuBar).
InitValidateMenuBarSemaphore InstallProc (Plus,SE,II,Portable,IIci) ; <7>
bclr #ValidateMenuBarSemaphoreBit,ValidateMenuBarSemaphoreByte ; clear semaphore at startup
rts
EndProc
ValidateMenuBar Proc EXPORT
bset #ValidateMenuBarSemaphoreBit,ValidateMenuBarSemaphoreByte ; Check and set semaphore <7>
bnz.s @dontRecurse ; If set, then do nothing. <7>
bclr #MenuBarInvalidBit,MenuBarInvalidByte ; clear the local invalid bit
bnz.s @dirty ; draw menu bar if set <6>
btst #MenuBarGlobalInvalidBit,MenuBarGlobalInvalidByte ; check the global invalid bit <6>
bz.s @notDirty ; exit if not set <6>
@dirty
_DrawMenuBar
@notDirty
bclr #ValidateMenuBarSemaphoreBit,ValidateMenuBarSemaphoreByte ; Clear semaphore at exit <7>
@dontRecurse
rts
EndProc
end