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

  1. ;*---------------------------------------------------------------------------
  2. ;  :Modul.    blitfix_dn_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_dn_58a5.s 1.5 2000/04/16 16:46:17 jah Exp $
  9. ;  :History.    14.09.98 created from blitfix_dn_58a6.s
  10. ;        14.09.98 now all registers are preserved
  11. ;        19.03.99 checked area fixed, a2 now returns pointer
  12. ;        05.04.00 bug in patchcount fixed
  13. ;        09.04.00 interrupt blit check added
  14. ;  :Requires.    -
  15. ;  :Copyright.    Public Domain
  16. ;  :Language.    68000 Assembler
  17. ;  :Translator.    Barfly V1.131
  18. ;  :To Do.
  19. ;---------------------------------------------------------------------------*
  20. ;
  21. ; this will patch the following instructions:
  22. ;        move.w    d0,($58,a5)
  23. ;        move.w    d1,($58,a5)
  24. ;        move.w    d2,($58,a5)
  25. ;        move.w    d3,($58,a5)
  26. ;        move.w    d4,($58,a5)
  27. ;        move.w    d5,($58,a5)
  28. ;        move.w    d6,($58,a5)
  29. ;        move.w    d7,($58,a5)
  30. ;
  31. ; IN:    A0 = APTR start of memory to patch
  32. ;    A1 = APTR end of memory to patch
  33. ;    A2 = APTR space for patch routine MUST be < $8000 !!!
  34. ; OUT:    D0-D1/A0-A1 unchanged
  35. ;    A2 = APTR points to the end of patch routine
  36.  
  37. _blitfix_dn_58a5
  38.         movem.l    d0/a0-a1,-(a7)
  39.  
  40.     IFD PATCHCOUNT
  41.         clr.l    (a2)+
  42.         clr.l    (a2)+
  43.     ENDC
  44.  
  45.         subq.l    #2,a1
  46. .loop        move.w    (a0)+,d0
  47.         and.w    #$fff8,d0
  48.         cmp.w    #$3b40,d0        ;move.w dx,($58,a5)
  49.         bne    .next
  50.         cmp.w    #$0058,(a0)
  51.         bne    .next
  52.         move.w    -(a0),d0        ;old opcode
  53.         move.w    #$4eb8,(a0)+        ;JSR $XXXX.w
  54.         move.w    a2,(a0)
  55.         and.w    #7,d0            ;register number
  56.  
  57.     IFD PATCHCOUNT
  58.         addq.b    #1,(-8,a2,d0.w)
  59.     ENDC
  60.  
  61.         mulu    #6,d0
  62.         add.w    d0,(a0)+        ;jmp address
  63. .next        cmp.l    a0,a1
  64.         bhs    .loop
  65.  
  66.         lea    (.wait_d0),a0
  67.         lea    (.wait_end),a1
  68. .cpy        move.w    (a0)+,(a2)+
  69.         cmp.l    a0,a1
  70.         bne    .cpy
  71.  
  72.         movem.l    (a7)+,d0/a0-a1
  73.         rts
  74.  
  75. .wait_d0    move.w    d0,($58,a5)
  76.         bra.b    .wait
  77. .wait_d1    move.w    d1,($58,a5)
  78.         bra.b    .wait
  79. .wait_d2    move.w    d2,($58,a5)
  80.         bra.b    .wait
  81. .wait_d3    move.w    d3,($58,a5)
  82.         bra.b    .wait
  83. .wait_d4    move.w    d4,($58,a5)
  84.         bra.b    .wait
  85. .wait_d5    move.w    d5,($58,a5)
  86.         bra.b    .wait
  87. .wait_d6    move.w    d6,($58,a5)
  88.         bra.b    .wait
  89. .wait_d7    move.w    d7,($58,a5)
  90. .wait        BLITWAIT a5
  91.     IFD INTBLITCHECK
  92.         move.l    d0,-(a7)
  93.         move    sr,d0
  94.         and.w    #$0700,d0
  95.         beq    .intok
  96.         illegal
  97. .intok        move.l    (a7)+,d0
  98.     ENDC
  99.         rts
  100. .wait_end
  101.