home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Games / WHDLoad / Src / sources / whdload / blitfix_d16an_58a5.s next >
Text File  |  2000-08-07  |  3KB  |  127 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Modul.    blitfix_d16an_58a5.s
  3. ;  :Contents.    routine to fix program that does not correctly wait for
  4. ;        blitter finish
  5. ;        the instruction which writes the "bltsize" register will be
  6. ;        patched with a routine which will wait for blitter finish
  7. ;        after writing "bltsize"
  8. ;  :Version.    $Id: blitfix_d16an_58a5.s 1.5 2000/04/16 16:46:17 jah Exp $
  9. ;  :History.    13.09.98 created
  10. ;        19.03.99 checked area fixed, a2 now returns pointer
  11. ;        09.04.00 interrupt blit check added
  12. ;  :Requires.    -
  13. ;  :Copyright.    Public Domain
  14. ;  :Language.    68000 Assembler
  15. ;  :Translator.    Barfly V1.131
  16. ;  :To Do.
  17. ;---------------------------------------------------------------------------*
  18. ;
  19. ; this will patch the following instructions:
  20. ;        move.w    (d16,a0),($58,a5)
  21. ;        move.w    (d16,a1),($58,a5)
  22. ;        move.w    (d16,a2),($58,a5)
  23. ;
  24. ; IN:    A0 = APTR start of memory to patch
  25. ;    A1 = APTR end of memory to patch
  26. ;    A2 = APTR space for patch routine MUST be < $8000 !!!
  27. ;          required are 18 bytes
  28. ; OUT:    D0-D1/A0-A1 unchanged
  29. ;    A2 = APTR points to the end of patch routine
  30.  
  31. _blitfix_d16an_58a5
  32.         movem.l    d0-d2/a0-a1,-(a7)
  33.  
  34.         move.w    a2,d0            ;D0 = address for A0
  35.         move.w    #$4ef9,(a2)+        ;JMP $xxxxxxxx.l
  36.         pea    .waita0
  37.         move.l    (a7)+,(a2)+
  38.         move.w    a2,d1            ;D1 = address for A1
  39.         move.w    #$4ef9,(a2)+        ;JMP $xxxxxxxx.l
  40.         pea    .waita1
  41.         move.l    (a7)+,(a2)+
  42.         move.w    a2,d2            ;D2 = address for A2
  43.         move.w    #$4ef9,(a2)+        ;JMP $xxxxxxxx.l
  44.         pea    .waita2
  45.         move.l    (a7)+,(a2)+
  46.  
  47.         subq.l    #4,a1
  48. .loop        cmp.w    #$0058,(4,a0)
  49.         bne    .next
  50.         cmp.w    #$3b68,(a0)        ;move.w ($xxxx,a0),($xxxx,a5)
  51.         beq    .a0
  52.         cmp.w    #$3b69,(a0)        ;move.w ($xxxx,a1),($xxxx,a5)
  53.         beq    .a1
  54.         cmp.w    #$3b6a,(a0)        ;move.w ($xxxx,a2),($xxxx,a5)
  55.         bne    .next
  56. .a2        move.w    #$4eb8,(a0)+        ;JSR $xxxx.w
  57.         move.w    (a0),(2,a0)        ;save d16
  58.         move.w    d2,(a0)+        ;routine
  59.         bra    .next
  60. .a1        move.w    #$4eb8,(a0)+        ;JSR $xxxx.w
  61.         move.w    (a0),(2,a0)        ;save d16
  62.         move.w    d1,(a0)+        ;routine
  63.         bra    .next
  64. .a0        move.w    #$4eb8,(a0)+        ;JSR $xxxx.w
  65.         move.w    (a0),(2,a0)        ;save d16
  66.         move.w    d0,(a0)+        ;routine
  67. .next        addq.l    #2,a0
  68.         cmp.l    a0,a1
  69.         bhs    .loop
  70.  
  71.         movem.l    (a7)+,d0-d2/a0-a1
  72.         rts
  73.  
  74. .waita0        move.l    a1,-(a7)
  75.         move.l    (4,a7),a1
  76.         add.w    (a1),a0
  77.         move.w    (a0),($58,a5)
  78.         sub.w    (a1)+,a0
  79.         move.l    a1,(4,a7)
  80.         move.l    (a7)+,a1
  81.         BLITWAIT a5
  82.     IFD INTBLITCHECK
  83.         move.l    d0,-(a7)
  84.         move    sr,d0
  85.         and.w    #$0700,d0
  86.         beq    .intok
  87.         illegal
  88. .intok        move.l    (a7)+,d0
  89.     ENDC
  90.         rts
  91.  
  92. .waita1        move.l    a0,-(a7)
  93.         move.l    (4,a7),a0
  94.         add.w    (a0),a1
  95.         move.w    (a1),($58,a5)
  96.         sub.w    (a0)+,a1
  97.         move.l    a0,(4,a7)
  98.         move.l    (a7)+,a0
  99.         BLITWAIT a5
  100.     IFD INTBLITCHECK
  101.         move.l    d0,-(a7)
  102.         move    sr,d0
  103.         and.w    #$0700,d0
  104.         beq    .intok
  105.         illegal
  106. .intok        move.l    (a7)+,d0
  107.     ENDC
  108.         rts
  109.  
  110. .waita2        move.l    a0,-(a7)
  111.         move.l    (4,a7),a0
  112.         add.w    (a0),a2
  113.         move.w    (a2),($58,a5)
  114.         sub.w    (a0)+,a2
  115.         move.l    a0,(4,a7)
  116.         move.l    (a7)+,a0
  117.         BLITWAIT a5
  118.     IFD INTBLITCHECK
  119.         move.l    d0,-(a7)
  120.         move    sr,d0
  121.         and.w    #$0700,d0
  122.         beq    .intok
  123.         illegal
  124. .intok        move.l    (a7)+,d0
  125.     ENDC
  126.         rts
  127.