home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / chip_20022115.iso / amiga / chiputil / uaegfx.lha / uaegfx.asm < prev    next >
Assembly Source File  |  2001-12-10  |  8KB  |  369 lines

  1. ; UAEGFX V1.0 - reassembled an reworked by Holger.Hippenstiel.org - lynxx@uni.de
  2. ; Don't ask me how it works - i don't know !
  3. ; If you think it's slower than V0.9
  4. ; Make your Benchmark again with the old version, and another time
  5. ; with the new version ... You see, the speed differs,
  6. ; regardless which test you use.
  7. ; if everything fails, optimize it yourself - or use the old version.
  8.  
  9.     INCDIR    I:
  10.     INCLUDE "exec/exec.i"
  11.     INCLUDE "exec/exec_lib.i"
  12.     INCLUDE "exec/execbase.i"
  13.     INCLUDE "exec/initializers.i"
  14.     INCLUDE "exec/resident.i"
  15.     INCLUDE "exec/nodes.i"
  16.     INCLUDE "exec/types.i"
  17.     INCLUDE "exec/libraries.i"
  18.     INCLUDE "exec/lists.i"
  19.     INCLUDE "libraries/expansion_lib.i"
  20.  
  21. picasso_FindCard        =16;
  22. picasso_FillRect        =17;
  23. picasso_SetSwitch        =18;
  24. picasso_SetColorArray        =19;
  25. picasso_SetDAC            =20;
  26. picasso_SetGC            =21;
  27. picasso_SetPanning        =22;
  28. picasso_CalculateBytesPerRow    =23;
  29. picasso_BlitPlanar2Chunky    =24;
  30. picasso_BlitRect        =25;
  31. picasso_SetDisplay        =26;
  32. picasso_BlitTemplate        =27;
  33. picasso_BlitRectNoMaskComplete    =28;
  34. picasso_InitCard        =29;
  35. picasso_BlitPattern        =30;
  36. picasso_InvertRect        =31;
  37. picasso_BlitPlanar2Direct    =32;
  38. picasso_WaitVerticalSync    =34;
  39. allocated_gfxmem        =35;    ;UNUSED
  40. picasso_SetSprite        =36;    ;UNUSED
  41. picasso_SetSpritePosition    =37;    ;UNUSED
  42. picasso_SetSpriteImage        =38;    ;UNUSED
  43. picasso_SetSpriteColor        =39;    ;UNUSED
  44. picasso_DrawLine        =40;    ;UNUSED
  45.  
  46. CALL_U:            MACRO
  47.             movem.l    d2-d7/a2-a6,-(sp)
  48.             pea    (\1).w
  49.             ENDM
  50.  
  51. CALL_C:            MACRO
  52.             movem.l    d0-d7/a0-a6,-(sp)
  53.             move.l    UaeBase(pc),a5
  54.             pea    (\1).w
  55.             jsr    (a5)
  56.  
  57.             addq    #4,sp
  58.             subq.l    #1,d0
  59.             movem.l    (sp)+,d0-d7/a0-a6
  60.             ENDM
  61.  
  62. SYS:            MACRO
  63.             jsr    _LVO\1(a6)
  64.  
  65.             ENDM
  66.  
  67.             SECTION    UAEGfx,CODE
  68.  
  69.  
  70. _LVOprv_TaggedOpenLibrary=-810
  71. ;1=Gfx,2=Layer,3=Int,4=Dos,5=Icon,6=Exp,7=Util,8=Keymap,9=Gadt,10=wb
  72.  
  73. ProgStart:        moveq    #-1,d0
  74.             rts
  75.  
  76. ResidentTag:        dc.w    RTC_MATCHWORD
  77.             dc.l    ResidentTag
  78.             dc.l    ResidentEnd
  79.             dc.b    2^RTB_AUTOINIT        ;RT_FLAGS
  80.             dc.b    1            ;Version
  81.             dc.b    NT_LIBRARY        ;Type
  82.             dc.b    0            ;Pri
  83.             dc.l    DriverName
  84.             dc.l    DriverDesc
  85.             dc.l    LibTab
  86. Driver:            dc.b    'uaegfx',0
  87. DriverName:        dc.b    'uaegfx.card',0
  88.             dc.b    "$VER: "
  89. DriverDesc:        dc.b    'uaegfx V1.0 ⌐ Holger.Hippenstiel.org (10.12.2001) - lynxx@uni.de',$D,$A,0
  90.             even
  91.     
  92. LibTab:            dc.l    $34            ;Postive Size of Lib
  93.             dc.l    Functions
  94.             dc.l    InitTab
  95.             dc.l    InitFunc
  96.  
  97. Functions:        dc.l    _OpenLib
  98.             dc.l    _CloseLib
  99.             dc.l    _ExpungeLib
  100.             dc.l    Null
  101.             dc.l    FindCard
  102.             dc.l    AddCard
  103.             dc.l    -1
  104.  
  105. InitTab:        INITBYTE    LN_TYPE,NT_LIBRARY
  106.             INITBYTE    LN_PRI,206
  107.             INITLONG    LN_NAME,DriverName
  108.             INITBYTE    LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
  109.             INITWORD    LIB_VERSION,1
  110.             INITWORD    LIB_REVISION,0
  111.             INITLONG    LIB_IDSTRING,DriverDesc
  112.             INITLONG    $30,Driver            ;???
  113.             dc.l    0
  114.  
  115. InitFunc:        move.l    d0,a1
  116.             move.l    a0,($2C,a1)
  117.             tst.l    d0
  118.             rts
  119.  
  120. _OpenLib:        addq    #1,LIB_OPENCNT(a6)
  121.             bclr    #LIBB_DELEXP,($22,a6)
  122.             move.l    a6,d0
  123. Return:            rts
  124.  
  125. _CloseLib:        moveq    #0,d0
  126.             subq    #1,LIB_OPENCNT(a6)
  127.             bne.b    Return
  128.  
  129.             btst    #LIBB_DELEXP,($22,a6)
  130.             beq.b    Return
  131.  
  132. _ExpungeLib:        movem.l    d2/a5/a6,-(sp)
  133.             move.l    a6,a5
  134.             tst    LIB_OPENCNT(a5)
  135.             beq.b    .ExpungeIt
  136.  
  137.             bset    #LIBB_DELEXP,($22,a5)
  138.             moveq    #0,d0
  139.             bra.b    .ExpungeSoon
  140.  
  141. .ExpungeIt:        move.l    ($2C,a5),d2
  142.             move.l    a5,a1
  143.             move.l    4.w,a6
  144.             SYS    Remove
  145.  
  146.             moveq    #0,d0
  147.             move.l    a5,a1
  148.             move    LIB_NEGSIZE(a5),d0
  149.             sub.l    d0,a1
  150.             add    LIB_POSSIZE(a5),d0
  151.             SYS    FreeMem
  152.  
  153.             move.l    d2,d0
  154. .ExpungeSoon:
  155.             movem.l    (sp)+,d2/a5/a6
  156.             rts
  157.  
  158. Null:            moveq    #0,d0
  159. NoUAE:            rts
  160.  
  161. FindCard:        movem.l    a2/a3/a6,-(sp)
  162.             move.l    a0,a2
  163.             moveq    #6,d0            ;Exp
  164.             move.l    4.w,a6
  165.             SYS    prv_TaggedOpenLibrary
  166.  
  167.             move.l    d0,a6            ;Exp_Base
  168.             sub.l    a0,a0
  169.             move.l    #2011,d0
  170.             moveq    #96,d1
  171.             SYS    FindConfigDev
  172.  
  173.             move.l    a2,a0
  174.             tst.l    d0
  175.             movem.l    (sp)+,a2/a3/a6
  176.             beq.b    NoUAE
  177.  
  178.             CALL_U    picasso_FindCard
  179.             bra.w    DoUAE
  180.  
  181. AddCard:        movem.l    d6/d7/a2/a5/a6,-(sp)
  182.             sub.l    a1,a1
  183.             move.l    a0,a2
  184.             move.l    a1,($B2,a2)
  185.             move.l    a1,($AE,a2)
  186.             addq    #1,a1
  187.             move.l    a1,($AA,a2)
  188.             lea    (Driver,pc),a1
  189.             move.l    a1,($10,a2)
  190.             or.l    #$8002,($BA,a2)
  191.             bsr.w    InitCard
  192.             moveq    #-1,d0
  193.             moveq    #1,d6
  194.             lea    $fe(a2),a6
  195.             lea    $ca(a2),a5
  196.             moveq    #4,d7
  197. .l0            move.l    d6,(a6)+
  198.             move.l    d0,(a5)+
  199.             dbf    d7,.l0
  200.             lea    (Nothing,pc),a5
  201.             lea    $11a(a2),a6
  202.             lea    (SetSwitch,pc),a1
  203.             move.l    a1,(a6)+
  204.             lea    (SetColorArray,pc),a1
  205.             move.l    a1,(a6)+
  206.             lea    (SetDAC,pc),a1
  207.             move.l    a1,(a6)+
  208.             lea    (SetGC,pc),a1
  209.             move.l    a1,(a6)+
  210.             lea    (SetPanning,pc),a1
  211.             move.l    a1,(a6)+
  212.             lea    (CalculateBytesPerRow,pc),a1
  213.             move.l    a1,(a6)+
  214.             lea    (UseSoftware,pc),a1
  215.             move.l    a1,(a6)+
  216.             lea    (NotSupported,pc),a1
  217.             move.l    a1,(a6)+
  218.             lea    (SetDisplay,pc),a1
  219.             move.l    a1,(a6)+
  220.             lea    (HardwareDirect,pc),a1
  221.             move.l    a1,(a6)+
  222.             lea    (Secret,pc),a1
  223.             move.l    a1,(a6)+
  224.  
  225.             moveq    #4,d7
  226. .l1            move.l    a5,(a6)+            ;Not supported
  227.             dbf    d7,.l1
  228.  
  229.             lea    (WaitVerticalSync,pc),a1
  230.             move.l    a1,(a6)
  231.             addq    #8,a6
  232.             move.l    a5,(a6)                ;Not supported
  233.             addq    #8,a6
  234.             move.l    4(a6),(a6)            ;Always use Software
  235.             addq    #8,a6
  236.             move.l    4(a6),(a6)            ;Always use Software
  237.             addq    #8,a6
  238.             lea    (BlitPlanar2Chunky,pc),a1
  239.             move.l    a1,(a6)
  240.             addq    #8,a6
  241.             lea    (FillRect,pc),a1
  242.             move.l    a1,(a6)
  243.             addq    #8,a6
  244.             lea    (InvertRect,pc),a1
  245.             move.l    a1,(a6)
  246.             addq    #8,a6
  247.             lea    (BlitRect,pc),a1
  248.             move.l    a1,(a6)
  249.             addq    #8,a6
  250.             lea    (BlitTemplate,pc),a1
  251.             move.l    a1,(a6)
  252.             addq    #8,a6
  253.             lea    (BlitPattern,pc),a1
  254.             move.l    a1,(a6)
  255.             addq    #8,a6
  256.             move.l    4(a6),(a6)            ;Always use Software
  257.             addq    #8,a6
  258.             lea    (BlitRectNoMaskComplete,pc),a1
  259.             move.l    a1,(a6)
  260.             addq    #8,a6
  261.             lea    (BlitPlanar2Direct,pc),a1
  262.             move.l    a1,(a6)
  263.             movem.l    (sp)+,d6/d7/a2/a5/a6
  264.             rts
  265.  
  266. InitCard:        CALL_U    picasso_InitCard
  267. DoUAE:            move.l    UaeBase(pc),a5
  268.             jsr    (a5)
  269.  
  270.             addq    #4,sp
  271.             movem.l    (sp)+,d2-d7/a2-a6
  272.             rts
  273.  
  274. SetSwitch:        CALL_U    picasso_SetSwitch
  275.             bra.b    DoUAE
  276.  
  277. SetColorArray:        CALL_U    picasso_SetColorArray
  278.             bra.b    DoUAE
  279.  
  280. SetDAC:            CALL_U    picasso_SetDAC
  281.             bra.b    DoUAE
  282.  
  283. SetGC:            move.l    a1,($22E,a0)
  284.             move    d0,($23C,a0)
  285.             CALL_U    picasso_SetGC
  286.             bra.b    DoUAE
  287.  
  288. SetPanning:        move    d1,($236,a0)
  289.             move    d2,($238,a0)
  290.             move.l    a1,d4
  291.             sub.l    (4,a0),d4
  292.             CALL_U    picasso_SetPanning
  293.             bra.b    DoUAE
  294.  
  295. CalculateBytesPerRow:    CALL_U    picasso_CalculateBytesPerRow
  296.             bra.b    DoUAE
  297.  
  298. SetDisplay:        CALL_U    picasso_SetDisplay
  299.             bra.b    DoUAE
  300.  
  301. WaitVerticalSync:    CALL_U    picasso_WaitVerticalSync
  302.             bra.b    DoUAE
  303.  
  304. FillRect:        CALL_C    picasso_FillRect
  305.             beq.b    .NoEmulation
  306.  
  307.             move.l    $182(a0),-(sp)        ;Hardware can't do it - emulate it
  308. .NoEmulation:        rts
  309.  
  310. BlitPlanar2Chunky:    CALL_C    picasso_BlitPlanar2Chunky
  311.             beq.b    .NoEmulation
  312.  
  313.             move.l    $17a(a0),-(sp)        ;Hardware can't do it - emulate it
  314. .NoEmulation:        rts
  315.  
  316. BlitRect:        CALL_C    picasso_BlitRect
  317.             beq.b    .NoEmulation
  318.  
  319.             move.l    $192(a0),-(sp)        ;Hardware can't do it - emulate it
  320. .NoEmulation:        rts
  321.  
  322. BlitTemplate:        CALL_C    picasso_BlitTemplate
  323.             beq.b    .NoEmulation
  324.  
  325.             move.l    $19a(a0),-(sp)        ;Hardware can't do it - emulate it
  326. .NoEmulation:        rts
  327.  
  328. BlitRectNoMaskComplete:    CALL_C    picasso_BlitRectNoMaskComplete
  329.             beq.b    .NoEmulation
  330.  
  331.             move.l    $1b2(a0),-(sp)        ;Hardware can't do it - emulate it
  332. .NoEmulation:        rts
  333.  
  334. BlitPattern:        CALL_C    picasso_BlitPattern
  335.             beq.b    .NoEmulation
  336.  
  337.             move.l    $1a2(a0),-(sp)        ;Hardware can't do it - emulate it
  338. .NoEmulation:        rts
  339.  
  340. InvertRect:        CALL_C    picasso_InvertRect
  341.             beq.b    .NoEmulation
  342.  
  343.             move.l    $18a(a0),-(sp)        ;Hardware can't do it - emulate it
  344. .NoEmulation:        rts
  345.  
  346. BlitPlanar2Direct:    CALL_C    picasso_BlitPlanar2Direct
  347.             beq.b    .NoEmulation
  348.  
  349.             move.l    $1ba(a0),-(sp)        ;Hardware can't do it - emulate it
  350. .NoEmulation:        rts
  351.  
  352. NotSupported:        moveq    #-2,d0
  353.             rts
  354.  
  355. UseSoftware:        move.l    a1,d0
  356.             rts
  357.  
  358. HardwareDirect:        move    #$620E,(42,a1)
  359.             move.l    d0,(44,a1)
  360.             moveq    #0,d0
  361.             rts
  362.  
  363. Secret:            move.l    #$5F958BC,d0
  364. Nothing:        rts
  365.  
  366.  
  367. UaeBase:        dc.l    $F0FF60
  368. ResidentEnd:
  369.