home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / LOBE.src.sit / LOBE.src / bdinstall.a next >
Text File  |  1994-12-17  |  3KB  |  113 lines

  1.  
  2.                 include 'ToolEqu.a'
  3.                 include 'SysEqu.a'
  4.                 include 'QuickEqu.a'
  5.                 include 'Traps.a'
  6.  
  7. IconID            EQU        -4064
  8. BadIconID        EQU        128
  9.  
  10. INITInstall        PROC    EXPORT
  11.                 IMPORT    SHOWICON7
  12.                 IMPORT    a_BusDriver:CODE
  13.                 IMPORT    a_BusDriverEnd:CODE
  14.                 IMPORT    BusVars:DATA
  15.                 IMPORT    BusTask:DATA
  16.                 IMPORT    InitToPrefs:CODE
  17.                 
  18. FirstResByte    EQU        a_BusDriver                ; first resident byte
  19. LastResByte        EQU        a_BusDriverEnd            ; last resident byte
  20. VarsAt            EQU        BusVars
  21. TaskAt            EQU        BusTask
  22. ShiftKeyCode    EQU        56                        ; key code for Shift key
  23.  
  24.                 clr.l    DeskHook
  25.                 tst.b    MBState                    ; don't install if mouse button is down
  26.                 bpl        NoInstall                ;
  27.  
  28.                 btst    #(ShiftKeyCode//8),KeyMap+(ShiftKeyCode/8)    ; or if shift key is down
  29.                 bne        NoInstall                ;
  30.  
  31.                 lea        FirstResByte,A0            ; first byte of resident code
  32.                 lea        LastResByte,A1            ; first byte beyond resident code
  33.                 sub.l    A0,A1                    ; size of resident code
  34.                 move.l    A1,D1                    ; save size later for BlockMove
  35.                 move.l    D1,D0
  36.  
  37.                 _NewPtr ,sys                    ; make the resident block in System heap
  38.                 tst.w    d0                        ; check for getting an error
  39.                 bne.w    NoInstall                ; got one, blow out
  40.                 move.l    A0,A2                    ; save new location for _BlockMove
  41.                 
  42.                 subq.l    #4,a7
  43.                 move.l    #'PREF',-(sp)
  44.                 move.w    #128,-(sp)
  45.                 _GetResource
  46.                 move.l    (sp),d0
  47.                 beq.s    NoPrefs
  48.                 move.l    d0,a0
  49.                 _HLock
  50.                 move.l    (a0),a0
  51.                 lea        VarsAt,a1
  52.                 move.l    #6,d0                    ; length of prefs, hardcoded
  53.                 _BlockMove
  54.                 move.l    (sp),a0
  55.                 _HUnlock    
  56.                 _HPurge    
  57.         
  58. NoPrefs            
  59.                 addq.l    #4,a7
  60.                 move.l    a2,a1                    ; restore a1
  61.                 lea        FirstResByte,A0            ; set A0 to source
  62.                 move.l    D1,D0                    ; set D0 to size
  63.                 _BlockMove
  64.                 
  65.                 ; a-reg usage from here out:
  66.                 ; a0 - points to init segment resident image
  67.                 ; a1 - offset calculations, points to stuff to manipulate
  68.                 ; a2 - points to resident image in system heap
  69.                 
  70.                 move.l    a1,a2                    ; save system block
  71.                 lea        VarsAt,a1                ; calcuate vars offset
  72.                 sub.l    a0,a1
  73.                 add.l    a2,a1                    ; get vars address
  74.  
  75.                 move.l    a1,-(sp)                ; call C routine to init
  76.                 move.l    a1,-(sp)                ; 0 and 4 as needed.
  77.                 bsr        InitToPrefs
  78.                 addq.l    #8,a7
  79.                 
  80.                 lea        TaskAt,a1
  81.                 sub.l    a0,a1
  82.                 add.l    a2,a1
  83.  
  84.                 move.w    #vType,qType(a1)        ; preserve a1 in case we need to uninstall
  85.                 move.w    #1,vblCount(a1)
  86.                 clr.w    vblPhase(a1)
  87.                 move.l    a2,vblAddr(a1)
  88.                 
  89.                 move.l    a1,a0
  90.                 _VInstall
  91.                 tst.w    d0
  92.                 bne.s    RemoveNoInstall
  93.  
  94. ExitInit
  95.                 move.l    #$50FF8001,$0            ; Finder demands this, don't know why.
  96.                 move.w    #IconID,-(sp)            ; ICN# ID of happy icon
  97.                 move.w    #$ffff, -(sp)                ; tell it to advance
  98.                 bsr        SHOWICON7                ;
  99.                 rts
  100.  
  101. RemoveNoInstall
  102.                 move.l    A2,A0                    ; dispose of our memory in case of error
  103.                 _DisposPtr
  104. NoInstall
  105.                 move.w    #BadIconID,-(sp)        ; ICN# ID of unhappy icon
  106.                 move.w    #$ffff, -(sp)                ; tell it to advance
  107.                 bsr        SHOWICON7                ;
  108.                 rts
  109.  
  110.                 ENDP
  111.                 END
  112.  
  113.