home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC02BusyBox / BusyBox.asm / UEvent.asm < prev    next >
Encoding:
Assembly Source File  |  1990-05-25  |  3.9 KB  |  151 lines  |  [04] ASCII Text (0x0000)

  1. ***********************************************************************
  2. *
  3. * busybox uevent.asm -- Version 3.0 
  4. *
  5. * Copyright (c)
  6. * Apple Computer, Inc.  1986-1990
  7. * All Rights Reserved.
  8. *
  9. * Developer Technical Support Apple II Sample Code
  10. *
  11. * This file contains the code which implements the main event loop
  12. * used by the busybox program.
  13. *
  14. ***********************************************************************
  15.  
  16.                case on
  17.  
  18.                copy 2/ainclude/e16.event
  19.                copy 2/ainclude/e16.window
  20.                copy busybox.equ
  21.  
  22.                mcopy macros/uevent.macros
  23.  
  24.                longi on
  25.                longa on
  26.  
  27. ***********************************************************************
  28. * This procedure is called when an inControl message is returned
  29. * by TaskMaster.
  30. *
  31. * When this routine gets control, the ID of the control that was
  32. * hit is in TaskDATA4.  The control handle is in TaskData2 and
  33. * the part code is in taskData 3.
  34. *
  35. doControls     start
  36.  
  37.                lda event+owmTaskData4   ;The ID
  38.                cmp #ButButtonsID        ;If theID is in range...
  39.                bcc no
  40.                cmp #Prog6ID+1
  41.                bcs no
  42.                pha
  43.                jsr openThisWindow       ;...open the window.
  44.  
  45. no             rts
  46.  
  47.                end
  48.  
  49. *********************************************************************
  50. *
  51. * checkFrontW
  52. *
  53. * This routine checks the front window to see if any changes need
  54. * to be made to the menu items.
  55. *
  56. * We do this so that the edit items are only active when a desk
  57. * accessory is active.
  58. *
  59. checkFrontW    start
  60.  
  61.                pha                      ;What is the front window?
  62.                pha
  63.                _FrontWindow
  64.                PullLong theWindow
  65.  
  66.                lda theWindow            ;If front window is lastWindow, then
  67.                cmp lastWindow           ;everything is already ok.
  68.                bne doit
  69.                ldx theWindow+2
  70.                cpx lastWindow+2
  71.                beq okAlready
  72.  
  73. doit           ora theWindow+2          ;If there are no windows, then
  74.                bne atLeastOneWindow     ;everything should be disabled.
  75.                pea $80
  76.                pea EditMenuID
  77.                _SetMenuFlag
  78.                _DrawMenuBar
  79.                jmp nowOk
  80.  
  81. atLeastOneWindow pha
  82.                pushlong theWindow
  83.                _GetSysWFlag
  84.                ldx #$FF7F               ;Assume system window (desk-accessory).
  85.                pla
  86.                bne aa                   ;It is a system window.
  87.                ldx #$80                 ;It is one of ours.
  88. aa             phx
  89.                pea EditMenuID
  90.                _SetMenuFlag
  91.                _DrawMenuBar
  92.  
  93. nowOk          lda theWindow
  94.                sta lastWindow
  95.                lda theWindow+2
  96.                sta lastWindow+2
  97.  
  98. okAlready      rts
  99.  
  100. theWindow      dc i4'0'
  101.  
  102. lastWindow     entry
  103.                dc i4'0'
  104.  
  105.                end
  106.  
  107. *************************************************************************
  108. *
  109. * mainEvent
  110. *
  111. * This is the main part of the program.  The program cycles in this
  112. * loop until the user choose select.
  113. *
  114. mainEvent      start
  115.  
  116.                stz quitFlag             ;quitFlag flag will be set by QuitItem.
  117.                stz lastWindow           ;Init this for checkFrontW
  118.                stz lastWindow+2
  119.  
  120. loop           jsr checkFrontW
  121.  
  122.                pha                      ;Call TaskMaster
  123.                pea $FFFF
  124.                pushlong #event
  125.                _TaskMaster
  126.                pla
  127.  
  128.                cmp #wInGoAway
  129.                bne aa
  130.                jsr doCloseTop
  131.                jmp zz
  132.  
  133. aa             cmp #wInSpecial
  134.                beq a0
  135.                cmp #wInMenuBar
  136.                bne b
  137.  
  138. a0             jsr doMenu
  139.                jmp zz
  140.  
  141. b              cmp #wInControl
  142.                bne zz
  143.                jsr doControls
  144.  
  145. zz             lda quitFlag
  146.                beq loop
  147.  
  148.                rts
  149.  
  150.                end
  151.