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 / resident.a < prev    next >
Text File  |  1994-12-13  |  3KB  |  149 lines

  1. ; Variables:
  2. ;
  3. ; Locked:
  4. ; 0 => not locked, we can execute the VBL
  5. ; !0 => we are locked, the cdev is messing with the variables, do nothing.
  6. ;
  7. ; Behavior:
  8. ; 0 => Do nothing
  9. ; 1 => Beep
  10. ; 2 => DebugStr
  11. ;
  12. ; Do4
  13. ; 0 => ignore 4
  14. ; !0 => manage 4 just like 0
  15. ;
  16. ; Snd
  17. ; Handle to locked sound resource.
  18. ;
  19.  
  20.                 include 'ToolEqu.a'
  21.                 include 'SysEqu.a'
  22.                 include 'QuickEqu.a'
  23.                 include 'Traps.a'
  24.                 
  25. DangerStr        equ        $50FF8001
  26.  
  27. a_BusDriver        PROC    EXPORT
  28.                 EXPORT    BusTask
  29.                 EXPORT    BusVars
  30.                 EXPORT    MyTag
  31.                 
  32.                 ; This is the real entry point. It jumps over the variables.
  33.                 ; It also has the 'CR91' tag so the cdev can find the vars by 
  34.                 ; scanning all VBLS. Skanky, but it works.
  35.                 
  36.                 bra.s    VarSkip
  37.                 
  38.                 STRING    ASIS
  39. MyTag            dc.b    'CR91'            ; tag so cdev can find me
  40. BusVars    
  41. bv_Locked        dc.w    0                ; default: not locked (running) 
  42. bv_Behavior        dc.w    $FFFF            ;          what to do when a write to 0/4 is detected
  43. bv_Do4            dc.w    $FFFF            ;          also do 4
  44. bv_Snd            dc.l    $0                ; inited by InitToPrefs, not read from PREF resource
  45.  
  46. BusTask    
  47.                 ds.b    14                ; size of vbl task, block is inited by installer.
  48.                 
  49.                 ; a VBL task may trash a0-a3 and d0-d3
  50. VarSkip            
  51.                 lea        bv_Locked,a0    ; first, grasshopper, you must find thyself
  52.                 tst.w    (a0)
  53.                 bne.s    bvExit            ; we're locked, do nothing
  54.                 
  55. Chk0
  56.                 move.l    $0, d0            ; Get 0 value
  57.                 lsl.l    #1,d0            ; clear high bit to avoid ROM bug (faster than ANDI #$7FFFFFFF)
  58.                 cmp.l    #(DangerStr<<1),d0
  59.                 beq.s    Replace0        ; we're clear, go check 4 (replace 0 in case ROM bug set hi bit)
  60.                 
  61.                 ; At this point, we know 0 is screwed up. But what to do? 
  62.                 ; Check the behavior variable, of course.
  63.                 
  64.                 lea        bv_Behavior, a0
  65.                 move.w    (a0), d0        ; Should set Z flag
  66.                 beq.s    Replace0        ; If zero, just restore bus error value
  67.                 subq.w    #1, d0            ; Should also set Z flag
  68.                 beq.s    bv_DebugStrGo0    ; behavior 1 == go
  69.  
  70. bv_DebugStrStop0
  71.                 clr.l    d0                ; point to 0
  72.                 bsr.s    WriteFailure
  73.                 bra.s    Replace0
  74.  
  75. bv_DebugStrGo0
  76.                 bsr.s    WriteFailureGo
  77.                 
  78. Replace0
  79.                 move.l    #DangerStr, d0    ; restore danger value
  80.                 move.l    d0, $0
  81.                 
  82.                 ;
  83.                 ; Now check 4
  84.                 ;
  85.                 
  86. Chk4
  87.                 lea        bv_Do4, a0        ; Check to see if we should bother
  88.                 tst.w    (a0)
  89.                 beq.s    bvExit            ; Nope, just exit
  90.                 
  91.                 move.l    $4, d0            ; Get 4 value
  92.                 lsl.l    #1,d0            ; clear high bit to avoid ROM bug (faster than ANDI #$7FFFFFFF)
  93.                 cmp.l    #(DangerStr<<1),d0
  94.                 beq.s    Replace4        ; we're clear, get out
  95.                 
  96.                 ; At this point, we know 4 is screwed up. But what to do? 
  97.                 ; Check the behavior variable, of course.
  98.                 
  99.                 lea        bv_Behavior, a0
  100.                 move.w    (a0), d0        ; Should set Z flag
  101.                 beq.s    Replace4        ; If zero, just restore bus error value
  102.                 subq.w    #1, d0            ; Should also set Z flag
  103.                 beq.s    bv_DebugStrGo4
  104.  
  105. bv_DebugStrStop4
  106.                 moveq.l    #4, d0            ; point to 0
  107.                 bsr.s    WriteFailure
  108.                 bra.s    Replace4
  109.  
  110. bv_DebugStrGo4
  111.                 bsr.s    WriteFailureGo
  112.                 
  113. Replace4
  114.                 move.l    #DangerStr, d0    ; restore danger value
  115.                 move.l    d0, $4
  116.                 
  117. bvExit            
  118.                 lea        BusTask,a0        ; make sure we get called again later.
  119.                 add.w    #1,vblCount(a0)
  120.                 rts
  121.                 
  122. WriteFailure
  123.                 pea        FailString
  124.                 _DebugStr
  125.                 rts
  126.                 
  127. WriteFailureGo
  128.                 pea        FailStringGo
  129.                 _DebugStr
  130.                 rts
  131.  
  132. FailString        
  133.                 align    2
  134.                 STRING    PASCAL
  135.                 dc.b    'Write to 0 or 4 (d0 shows which)'
  136.                 align    2
  137.  
  138. FailStringGo
  139.                 align    2
  140.                 STRING    PASCAL
  141.                 dc.b    'Write to 0 or 4; dm 0; g'
  142.                 align    2
  143.                 ENDP
  144.                 
  145. a_BusDriverEnd    PROC    EXPORT        ; dummy marker for install code
  146.                 ENDP
  147.                 END
  148.                 
  149.