START     move.l    $4.w,a6
          moveq     #37,d0
          lea       dosname(pc),a1
          jsr       _LVOOpenLibrary(a6)
          move.l    d0,_DosBase
          beq.s     .exit
          move.l    d0,a6
          lea       template(pc),a0
          move.l    a0,d1
          lea       _Param(pc),a0
          move.l    a0,d2
          moveq     #0,d3
          jsr       _LVOReadArgs(a6)
          move.l    d0,d1
          bne.s     .ArgsOK
          jsr       _LVOIoErr(a6)
          move.l    d0,d1
          move.l    d3,d2
          jsr       _LVOPrintFault(a6)
.quit     move.l    $4.w,a6
          move.l    _DosBase(pc),a1
          jsr       _LVOCloseLibrary(a6)
.exit     moveq     #0,d0
          rts

          cnop      0,4

.error    lea       errortxt(pc),a0
          move.l    a0,d1
          move.l    _DosBase(pc),a6
          jsr       _LVOPutStr(a6)
          bra       .quit

          cnop      0,4

.ArgsOK   move.l    _Param(pc),d0
          beq.s     .skip0
          move.l    d0,a0
          move.l    (a0),_Mask
.skip0    jsr       _LVOFreeArgs(a6)
          move.l    $4.w,a6
          lea       DeviceList(a6),a0
          lea       mcname(pc),a1
          jsr       _LVOFindName(a6)
          move.l    d0,_Device
          beq       .error
          move.l    d0,a0
          cmpi.w    #2,LIB_VERSION(a0)
          bne       .error
          cmpi.w    #202,LIB_REVISION(a0)
          bne.s     .error
          lea       mcname(pc),a1
          jsr       _LVOFindTask(a6)
          move.l    d0,_Task
          beq.s     .error
          jsr       _LVODisable(a6)
          moveq     #0,d7
          move.l    _Device(pc),a0
          move.l    -4(a0),a0
          lea       $34(a0),a0
          cmpi.l    #$302e0186,(a0)
          bne.s     .skip1
          cmpi.l    #$03006708,4(a0)
          bne.s     .skip1
          moveq     #1,d7
          lea       Patch1,a1
          move.w    #$4eb9,(a0)+
          move.l    a1,(a0)
.skip1    move.l    _Task(pc),a0
          move.l    pr_SegList(a0),d0
          beq.s     .skip2
          lsl.l     #2,d0
          move.l    d0,a0
          move.l    $c(a0),d0
          beq.s     .skip2
          lsl.l     #2,d0
          move.l    d0,a0
          lea       $2e0(a0),a0
          cmpi.l    #$226a001c,(a0)
          bne.s     .skip2
          moveq     #1,d7
          lea       Patch2,a1
          move.w    #$4eb9,(a0)+
          move.l    a1,(a0)+
          move.w    #$6f3c,(a0)
.skip2    tst.l     d7
          beq.s     .skip3
          lea       START-4(pc),a0
          clr.l     (a0)
.skip3    jsr       _LVOCacheClearU(a6)
          jsr       _LVOEnable(a6)
          bra       .quit


dosname   dc.b      "dos.library",0
mcname    dc.b      "MASOBOSHI.device",0
          dc.b      "$VER: SetPatchMC702 1.2 (12.10.95)"
          dc.b      "for MASOBOSHI.device v2.202",0
errortxt  dc.b      "You need MASOBOSHI.device v2.202 to install this patch!",10,0
template  dc.b      "UNITMASK/N",0
          even
_Device   dc.l      0
_Task     dc.l      0
_DosBase  dc.l      0
_Param    dc.l      0

          section   Ooops,CODE

_Mask     dc.l      0

Patch1    move.w    $186(a6),d0
          or.w      _Mask+2(pc),d0
          btst      d1,d0
          rts

          cnop      0,4

Patch2    move.l    $1c(a2),d1
          move.l    d1,a1
          add.l     a1,a1
          add.l     a1,a1
          subq.l    #2,d1
          rts
