home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / Converter / DC-PGS21.DMS / in.adf / Extras / DevDocs.LHA / DeveloperDocs / examples / efx / negative.asm < prev    next >
Encoding:
Assembly Source File  |  1996-06-03  |  8.4 KB  |  315 lines

  1.     opt l+
  2.  
  3. VERSION equ 1
  4. REVISION equ 2
  5.  
  6. LIBNAME    macro
  7.         dc.b    "Negative.efx"
  8.         endm
  9.  
  10. TODAY   macro
  11.         dc.b    "(3/5/96)"
  12.         endm
  13.  
  14. COPYRIGHT macro
  15.         dc.b    "Copyright © Almathera 1994-5. All Rights Reserved"
  16.         endm
  17.  
  18. ASTRING macro
  19.         LIBNAME
  20.         dc.b    " Version \<VERSION>.\<REVISION>.",10,10
  21.         COPYRIGHT
  22.         dc.b    10,10
  23.         dc.b    "A simple effect to invert the whole image. Written by Jolyon Ralph",0
  24.         endm
  25.  
  26.  
  27. *************************************************************************
  28. **                                                                     **
  29. ** End of user-editable stuff...                                       **
  30. **                                                                     **
  31. *************************************************************************
  32.  
  33.  
  34.  
  35. VSTRING macro
  36.         dc.b    "$VER "
  37.         LIBNAME
  38.         dc.b    " \<VERSION>.\<REVISION> "
  39.         TODAY
  40.         dc.b    10
  41.         COPYRIGHT
  42.         dc.b    0
  43.         endm
  44.  
  45.         SECTION    code
  46.  
  47.         machine mc68020
  48.  
  49.         incdir    "include:"
  50.         include "exec/funcdef.i"
  51.         include "exec/types.i"
  52.         INCLUDE "exec/initializers.i"
  53.         INCLUDE "exec/libraries.i"
  54.         INCLUDE "exec/lists.i"
  55.         include "exec/memory.i"
  56.         INCLUDE "exec/alerts.i"
  57.         INCLUDE "exec/resident.i"
  58.         INCLUDE "libraries/dos.i"
  59.  
  60.         include "exec/exec_lib.i"
  61.  
  62.     include "photogenics/pgs_lib.i"
  63.         include "photogenics/efxbase.i"
  64.     include "photogenics/gio.i"
  65.  
  66.         XDEF    InitTable
  67.         XDEF    Open
  68.         XDEF    Close
  69.         XDEF    Expunge
  70.         XDEF    Null
  71.         XDEF    LibName
  72.         XDEF    _main
  73.  
  74.         XREF    _EfxInfo
  75.         XREF    _EfxPreRender
  76.         XREF    _EfxRender
  77.         XREF    _EfxPrefs
  78.  
  79. _main:
  80. Start:
  81.     moveq    #-1,d0
  82.     rts
  83.  
  84. MYPRI   EQU   0
  85.  
  86. RomTag:
  87.              ;STRUCTURE RT,0
  88.      DC.W    RTC_MATCHWORD      ; UWORD RT_MATCHWORD
  89.      DC.L    RomTag             ; APTR  RT_MATCHTAG
  90.      DC.L    EndCode            ; APTR  RT_ENDSKIP
  91.      DC.B    RTF_AUTOINIT       ; UBYTE RT_FLAGS
  92.      DC.B    VERSION            ; UBYTE RT_VERSION
  93.      DC.B    NT_LIBRARY         ; UBYTE RT_TYPE
  94.      DC.B    MYPRI              ; BYTE  RT_PRI
  95.      DC.L    LibName            ; APTR  RT_NAME
  96.      DC.L    IDString           ; APTR  RT_IDSTRING
  97.      DC.L    InitTable          ; APTR  RT_INIT  table for InitResident()
  98.  
  99.    ; this is the name that the library will have
  100. LibName:   LIBNAME
  101.             dc.b 0
  102. IDString:  VSTRING
  103.  
  104.  
  105.    ; force alignment
  106.  
  107.     cnop    0,4
  108.  
  109.  
  110.    ; The romtag specified that we were "RTF_AUTOINIT".  This means that the RT_INIT
  111.    ; structure member points to one of these tables below.  If the AUTOINIT bit was not
  112.    ; set then RT_INIT would point to a routine to run.
  113.  
  114. InitTable:
  115.    DC.L   EfxBase_SIZEOF    ; size of library base data space
  116.    DC.L   funcTable         ; pointer to function initializers
  117.    DC.L   dataTable         ; pointer to data initializers
  118.    DC.L   initRoutine       ; routine to run
  119.  
  120.  
  121. funcTable:
  122.  
  123.    ;------ standard system routines
  124.    dc.l   Open
  125.    dc.l   Close
  126.    dc.l   Expunge
  127.    dc.l   Null
  128.  
  129.    ;------ my libraries definitions
  130.    dc.l   _EfxInfo
  131.    dc.l   _EfxPreRender
  132.    dc.l   _EfxRender
  133.    dc.l   _EfxPrefs
  134.    dc.l   _EfxAbout
  135.  
  136.    ;------ function table end marker
  137.    dc.l   -1
  138.  
  139.  
  140.    ; The data table initializes static data structures.  The format is specified in
  141.    ; exec/InitStruct routine's manual pages.  The INITBYTE/INITWORD/INITLONG routines are
  142.    ; in the file "exec/initializers.i".  The first argument is the offset from the library
  143.    ; base for this byte/word/long.  The second argument is the value to put in that cell.
  144.    ; The table is null terminated.
  145.    ; NOTE - LN_TYPE below is a correction - old example had LH_TYPE.
  146.  
  147. dataTable:
  148.         INITBYTE        LN_TYPE,NT_LIBRARY
  149.         INITLONG        LN_NAME,LibName
  150.         INITBYTE        LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
  151.         INITWORD        LIB_VERSION,VERSION
  152.         INITWORD        LIB_REVISION,REVISION
  153.         INITLONG        LIB_IDSTRING,IDString
  154.         DC.L   0
  155.  
  156.    ; This routine gets called after the library has been allocated.  The library pointer is
  157.    ; in D0.  The segment list is in A0.  If it returns non-zero then the library will be
  158.    ; linked into the library list.
  159.  
  160. initRoutine:
  161.  
  162.    ;------ get the library pointer into a convenient A register
  163.    move.l   a5,-(sp)
  164.    move.l   d0,a5
  165.  
  166.    ;------ save a pointer to exec
  167.    move.l   a6,efxb_SysLib(a5)
  168.  
  169.    ;------ save a pointer to our loaded code
  170.    move.l   a0,efxb_SegList(a5)
  171.  
  172.    ;------ now build the static data that we need
  173.    ;
  174.    ; put your initialization here...
  175.    ;
  176.  
  177.    move.l   a5,d0
  178.    move.l   (sp)+,a5
  179.    rts
  180.  
  181. ;------------------------------------------------------------------------------------------
  182. ; here begins the system interface commands.  When the user calls OpenLibrary/CloseLibrary/
  183. ; RemoveLibrary, this eventually gets translated into a call to the following routines
  184. ; (Open/Close/Expunge).  Exec has already put our library pointer in A6 for us.  Exec has
  185. ; turned off task switching while in these routines (via Forbid/Permit), so we should not
  186. ; take too long in them.
  187. ;------------------------------------------------------------------------------------------
  188.  
  189.    ; Open returns the library pointer in d0 if the open was successful.  If the open failed
  190.    ; then null is returned.  It might fail if we allocated memory on each open, or if only
  191.    ; open application could have the library open at a time...
  192.  
  193. Open:      ; ( libptr:a6, version:d0 )
  194.  
  195.    ;------ mark us as having another opener
  196.    addq.w   #1,LIB_OPENCNT(a6)
  197.  
  198.    ;------ prevent delayed expunges
  199.    bclr   #LIBB_DELEXP,efxb_Flags(a6)
  200.  
  201.    move.l   a6,d0
  202.    rts
  203.  
  204.    ; There are two different things that might be returned from the Close routine.  If the
  205.    ; library is no longer open and there is a delayed expunge then Close should return the
  206.    ; segment list (as given to Init).  Otherwise close should return NULL.
  207.  
  208. Close:      ; ( libptr:a6 )
  209.  
  210.    ;------ set the return value
  211.    moveq    #0,d0
  212.  
  213.    ;------ mark us as having one fewer openers
  214.    subq.w   #1,LIB_OPENCNT(a6)
  215.  
  216.    ;------ see if there is anyone left with us open
  217.    bne.s   1$
  218.  
  219.    ;------ see if we have a delayed expunge pending
  220.    btst   #LIBB_DELEXP,efxb_Flags(a6)
  221.    beq.s   1$
  222.  
  223.    ;------ do the expunge
  224.    bsr   Expunge
  225. 1$:
  226.    rts
  227.  
  228.    ; There are two different things that might be returned from the Expunge routine.  If
  229.    ; the library is no longer open then Expunge should return the segment list (as given
  230.    ; to Init).  Otherwise Expunge should set the delayed expunge flag and return NULL.
  231.    ;
  232.    ; One other important note: because Expunge is called from the memory allocator, it may
  233.    ; NEVER Wait() or otherwise take long time to complete.
  234.  
  235. Expunge:   ; ( libptr: a6 )
  236.  
  237.    movem.l   d2/a5/a6,-(sp)
  238.    move.l   a6,a5
  239.    move.l   efxb_SysLib(a5),a6
  240.  
  241.    ;------ see if anyone has us open
  242.    tst.w   LIB_OPENCNT(a5)
  243.    beq   1$
  244.  
  245.    ;------ it is still open.  set the delayed expunge flag
  246.    bset   #LIBB_DELEXP,efxb_Flags(a5)
  247.    moveq    #0,d0
  248.    bra.s   Expunge_End
  249.  
  250. 1$:
  251.    ;------ go ahead and get rid of us.  Store our seglist in d2
  252.    move.l   efxb_SegList(a5),d2
  253.  
  254.    ;------ unlink from library list
  255.    move.l   a5,a1
  256.    jsr        _LVORemove(a6)
  257.  
  258.    ;------ free our memory
  259.    moveq    #0,d0
  260.    move.l   a5,a1
  261.    move.w   LIB_NEGSIZE(a5),d0
  262.  
  263.    sub.l   d0,a1
  264.    add.w   LIB_POSSIZE(a5),d0
  265.  
  266.     jsr        _LVOFreeMem(a6)
  267.  
  268.    ;------ set up our return value
  269.    move.l   d2,d0
  270.  
  271. Expunge_End:
  272.    movem.l   (sp)+,d2/a5/a6
  273.    rts
  274.  
  275. Null:
  276.    moveq    #0,d0
  277.    rts
  278. EndCode:
  279.  
  280.  
  281. wintitle:
  282.         dc.b "About "
  283.         LIBNAME
  284.         dc.b    0
  285.  
  286. textmsg:
  287.         ASTRING
  288.         dc.b    0
  289. button:
  290.         dc.b     "OK",0
  291.  
  292.         cnop     0,4
  293.  
  294. *******************************************************************
  295. *******************************************************************
  296. *******************************************************************
  297. ***                                                             ***
  298. *** Main code functions for library follow here...              ***
  299. ***                                                             ***
  300. *******************************************************************
  301. *******************************************************************
  302. *******************************************************************
  303.  
  304.  
  305. _EfxAbout
  306.         movem.l  a6/a2,-(sp)
  307.         move.l  gio_PgsBase(a0),a6
  308.         lea     wintitle(pc),a0
  309.         lea     textmsg(pc),a1
  310.         lea     button(pc),a2
  311.         jsr     _LVOOneButtonReq(a6)
  312.         movem.l  (sp)+,a6/a2
  313.         rts
  314.  
  315.