  xref _GfxBase
  xref _SysBase
  xref _oldBltBitMap
  cnop 0,4
_copyonepixel:
   movem.l  d2-d6,-(sp)
   move.l   (24,sp),a0
   move.l   (28,sp),d3
   move.l   (32,sp),a1
   move.l   (36,sp),d2
   move.l   (40,sp),d5
   clr.l d4
   tst.l a0
   beq   L3
   move.b   #1,d4
   moveq #-1,d0
   cmp.l a0,d0
   beq   L3
   move.l   d3,d0
   not.l d0
   moveq #7,d1
   and.l d1,d0
   move.b   #1,d1
   lsl.l d0,d1
   lsr.l #3,d3
   move.b   (a0,d3.l),d0
   and.b d1,d0
   sne   d0
   move.b   d0,d4
   extb.l   d4
   neg.l d4
L3:
   move.l   d2,d3
   lsr.l #3,d3
   not.l d2
   moveq #7,d0
   and.l d0,d2
   move.b   #1,d0
   lsl.l d2,d0
   move.b   d0,d1
   move.b   (a1,d3.l),d2
   move.b   d2,d0
   and.b d1,d0
   sne   d0
   extb.l   d0
   neg.l d0
   clr.w d6
   btst  #4,d5
   beq   L6
   tst.l d4
   bne   L6
   tst.l d0
   beq   L19

L6:
   btst  #5,d5
   beq   L8
   tst.l d4
   bne   L8
   tst.l d0
   bne   L20

L8:
   btst  #6,d5
   beq   L10
   tst.l d4
   beq   L10
   tst.l d0
   beq   L21

L10:
   tst.b d5
   bge   L12
   tst.l d4
   beq   L12
   tst.l d0
   beq   L12

L16:
   or.b  d1,d2
   bra   L17

L12:
   tst.w d6
   bne   L16
   not.b d1
   and.b d1,d2
   bra   L17

L21:
   moveq #1,d6
   bra   L10

L20:
   moveq #1,d6
   bra   L8

L19:
   move.b   #1,d6
   bra   L6

L17:
   move.b   d2,(a1,d3.l)
   movem.l  (sp)+,d2-d6
   rts

  cnop 0,4

_NewBltBitMap:
   add.w #-68,sp
   movem.l  d2-d7/a2-a6,-(sp)
   move.l   a0,(108,sp)
   move.l   d0,a4
   move.l   d1,(104,sp)
   move.l   a1,(100,sp)
   move.l   d2,a5
   move.l   d3,(96,sp)
   move.l   d4,a3
   move.l   d5,(92,sp)
   move.l   d6,(88,sp)
   move.l   d7,(84,sp)
   move.l   a2,(80,sp)
   tst.w (6,a0)
   bne   L24
   tst.w (6,a1)
   beq   L23
L24:
   jsr   _oldBltBitMap
L25:
   move.l   (76,sp),d0
   bra   L22

L23:
   move.l   _GfxBase,a6
   moveq #8,d1
    jsr -$3c0(a6)
   move.l   d0,d4
   move.l   _GfxBase,a6
   move.l   (100,sp),a0
   moveq #8,d1
    jsr -$3c0(a6)
   move.l   d0,d3
   clr.l (64,sp)
   move.l   _GfxBase,a6
   move.l   (108,sp),a0
   moveq #4,d1
    jsr -$3c0(a6)
   move.l   d0,(68,sp)
   move.l   _GfxBase,a6
   move.l   (100,sp),a0
   moveq #4,d1
    jsr -$3c0(a6)
   cmp.l (68,sp),d0
   bcc   L26
   move.l   d0,(68,sp)
L26:
   tst.l a4
   blt   L73
   tst.l (104,sp)
   blt   L74
L28:
   move.l   (104,sp),d1
   add.l (92,sp),d1
   move.l   (108,sp),a0
   move.w   (2,a0),d2
   clr.l d0
   move.w   d2,d0
   cmp.l d0,d1
   ble   L29
   clr.w (92,sp)
   move.w   d2,(94,sp)
   move.l   (104,sp),d0
   sub.l d0,(92,sp)
L29:
   move.l   (96,sp),d1
   add.l (92,sp),d1
   move.l   (100,sp),a0
   move.w   (2,a0),d2
   clr.l d0
   move.w   d2,d0
   cmp.l d0,d1
   ble   L30
   clr.w (92,sp)
   move.w   d2,(94,sp)
   move.l   (96,sp),d0
   sub.l d0,(92,sp)
L30:
   lea   (0,a4,a3.l),a0
   cmp.l a0,d4
   bhi   L31
   move.l   d4,a3
   sub.l a4,a3
L31:
   lea   (0,a5,a3.l),a0
   cmp.l a0,d3
   bhi   L32
   move.l   d3,a3
   sub.l a5,a3
L32:
   tst.l (92,sp)
   ble   L70
   tst.l a3
   ble   L70
   tst.l (84,sp)
   beq   L70
   clr.l (76,sp)
   clr.l (72,sp)
   clr.l d2
   cmp.l (68,sp),d2
   bcc   L25
   clr.l (56,sp)
   move.l   (108,sp),a0
   addq.l   #8,a0
   move.l   a0,(44,sp)
   move.l   (100,sp),d7
   addq.l   #8,d7
   clr.l (48,sp)

L60:
   move.l   d7,a6
   move.l   (a6),d1
   beq   L37
   moveq #-1,d0
   cmp.l d1,d0
   beq   L37
   moveq #1,d0
   move.l   (72,sp),d2
   lsl.l d2,d0
   and.l (84,sp),d0
   beq   L37
   addq.l   #1,(76,sp)
   clr.l d6
   tst.l (92,sp)
   bls   L37
   clr.l (60,sp)
   clr.l (52,sp)

L59:
   move.l   (104,sp),d0
   add.l d6,d0
   move.l   (108,sp),a6
   move.w   (a6),d4
   move.w   d4,(62,sp)
   muls.l   (60,sp),d0
   move.l   (44,sp),a0
   move.l   (a0),d3
   add.l d0,d3
   move.l   (96,sp),d0
   add.l d6,d0
   move.l   (100,sp),a6
   move.w   (a6),d5
   move.w   d5,(58,sp)
   muls.l   (56,sp),d0
   move.l   d1,d2
   add.l d0,d2
   cmp.l d3,d2
   bcs   L45
   move.w   d4,(54,sp)
   move.l   (52,sp),d0
   add.l d3,d0
   cmp.l d0,d2
   bcs   L44
L45:
   cmp.l d2,d3
   bcs   L43
   move.w   d5,(50,sp)
   move.l   (48,sp),d0
   add.l d2,d0
   cmp.l d0,d3
   bcs   L44
L43:
   lea   (0).w,a2
   tst.l a3
   bls   L42
   lea   _copyonepixel,a6

L58:
   move.l   (88,sp),-(sp)
   pea   (a5,a2.l)
   move.l   d2,-(sp)
   pea   (a4,a2.l)
   move.l   d3,-(sp)
   jsr   (a6)
   add.w #20,sp
   addq.l   #1,a2
   cmp.l a3,a2
   bcs   L58
L42:
   addq.l   #1,d6
   cmp.l (92,sp),d6
   bcc   L37
   move.l   d7,a0
   move.l   (a0),d1
   bra   L59

L70:
   clr.l d0
   bra   L22

L44:
   tst.l (64,sp)
   beq   L75
L46:
   move.l   _SysBase,a6
   move.l   d3,a0
   move.l   (64,sp),a1
   clr.l d0
   move.w   d4,d0
     jsr -$270(a6)
   lea   (0).w,a2
   tst.l a3
   bls   L42
   lea   _copyonepixel,a6

L53:
   move.l   (88,sp),-(sp)
   pea   (a5,a2.l)
   move.l   d2,-(sp)
   pea   (a4,a2.l)
   move.l   (80,sp),-(sp)
   jsr   (a6)
   add.w #20,sp
   addq.l   #1,a2
   cmp.l a3,a2
   bcc   L42
   move.l   (88,sp),-(sp)
   pea   (a5,a2.l)
   move.l   d2,-(sp)
   pea   (a4,a2.l)
   move.l   (80,sp),-(sp)
   jsr   (a6)
   add.w #20,sp
   addq.l   #1,a2
   cmp.l a3,a2
   bcs   L53
   bra   L42

L75:
   move.l   (80,sp),(64,sp)
   beq   L76
L48:
   tst.l (64,sp)
   beq   L70
   move.l   (108,sp),a0
   move.w   (a0),d4
   bra   L46

L74:
   move.l   (104,sp),d0
   sub.l d0,(96,sp)
   add.l d0,(92,sp)
   clr.l (104,sp)
   bra   L28

L73:
   sub.l a4,a5
   add.l a4,a3
   lea   (0).w,a4
   tst.l (104,sp)
   bge   L28
   bra   L74

L37:
   addq.l   #1,(72,sp)
   addq.l   #4,d7
   addq.l   #4,(44,sp)
   move.l   (72,sp),d0
   cmp.l (68,sp),d0
   bcs   L60
   tst.l (64,sp)
   beq   L25
   tst.l (80,sp)
   bne   L25
   move.l   _SysBase,a6
   move.l   (64,sp),a1
   move.l   (108,sp),a0
   clr.l d0
   move.w   (a0),d0
    jsr -$d2(a6)
   bra   L25

L76:
   move.l   _SysBase,a6
   clr.l d0
   move.w   d4,d0
   clr.l d1
    jsr -$c6(a6)
   move.l   d0,(64,sp)
   bra   L48

L22:
   movem.l  (sp)+,d2-d7/a2-a6
   add.w #68,sp
   rts
