home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 95 / af095sub.adf / MBlank.LZX / MBlank / module.i < prev    next >
Text File  |  2003-09-02  |  7KB  |  214 lines

  1. ;Custom blanker-modules:
  2. ;input:        a5    =    APTR Globals (saved/restored before/after
  3. ;                calling you blanker code.)
  4. ;output:    status register's zeroflag SET on failure, UNSET
  5. ;        on succes:    moveq #TRUE,d0
  6. ;                rts        ;succesfull exit
  7.  
  8. ;                moveq #FALSE,d0
  9. ;                rts        ;unsuccesfull exit
  10. ;        in the latter case, MBlank will use its internal
  11. ;        'Black-Screen' as a backup.
  12.  
  13. ;Your code MUST be 100% position-ind. Because of this the CALLEXEC
  14. ;macro is a little strange. If you don't use the 'Ensure PC-relative Code'
  15. ;option of your assembler, you can use the CALLEX macro.
  16.  
  17. ;Instructions on using the AllGlobals(a5) structure:
  18.  
  19. ;- PRIVATE    Blanker modules may not use these in any way!
  20. ;- LIB        A library pointer which is valid. (blanker modules run
  21. ;        on the same context as the Process which opened the Libs.)
  22. ;        Don't close these Libs. under any circumstances.
  23. ;- READ        May be read, contents are valid.
  24. ;- USE        Space may be used, contents may not be valid!
  25. ;- CHANGE    May be set, according to rules.
  26.  
  27. ; A module can Wait() on the gb_ResetSignal(a5) if it doesn't have to keep
  28. ; working. You can ofcourse also poll this signal.
  29. ; If the module does polling to determine wether or not a significant
  30. ; input-event ocurred, use btst #GB_BLANK,gb_Flags(a5).(beq ABORT_blanking).
  31.  
  32. ; The gb_Random(a5) pointer is a pointer to a pseudo-random generator, which
  33. ; I copied from one of Toby Simpson's example Lottery programs.(Shopper)
  34. ; input:    d0.w    =    maximum value (1 to 65535).
  35. ; All registers get saved/restored, therefore the gb_Random entry can
  36. ; easily be used from within loops.
  37. ; output:    d0.w    =    Random number (0 to maximum value-1).
  38.  
  39. ;This is the structure to which you receive a handle in a5.
  40.  STRUCTURE AllGlobals,0
  41.     STRUCT    gb_NewBrokerStruct,nb_SIZEOF        ;PRIVATE
  42.     BYTE    gb_ExtFlags                ;PRIVATE
  43.     BYTE    gb_ActionFlags                ;PRIVATE
  44.     STRUCT    gb_HotKeyIX,ix_SIZEOF            ;PRIVATE
  45.     APTR    gb_WBstartupMsg                ;PRIVATE
  46.     APTR    gb_Broker                ;PRIVATE
  47.     APTR    gb_WBLock                ;PRIVATE
  48.     APTR    gb_Screen    ;USE, not valid on entry.
  49.     APTR    gb_VisInfo                ;PRIVATE
  50.     APTR    gb_Menu                    ;PRIVATE
  51.     APTR    gb_Window                ;PRIVATE
  52.     APTR    gb_BitMap    ;USE, not valid on entry.
  53.     APTR    gb_DiskObject    ;READ, your .info file, if it exists.
  54.     APTR    gb_Process    ;READ, our process, it exists.
  55.     APTR    gb_AppItem                ;PRIVATE
  56.     APTR    gb_ModLock                ;PRIVATE
  57.     APTR    gb_FIB                    ;PRIVATE
  58.     APTR    gb_ModHandle                ;PRIVATE
  59.     APTR    gb_Module    ;READ, APTR to your module. (blm_structure)
  60.     APTR    gb_Random    ;READ, APTR random number generator. (Simpson)
  61.     LONG    gb_ModType    ;READ/USE, 'BLMS' for now.
  62.     LONG    gb_ModSize    ;READ/USE, size of module in bytes.
  63.     APTR    _IconBase    ;LIB, you can use all of the following
  64.     APTR    _IntBase    ;LIB, pointers as if you had opened the
  65.     APTR    _CxBase        ;LIB, libraries yourself. NEVER close
  66.     APTR    _DOSBase    ;LIB, these libraries!!! You don't have
  67.     APTR    _WBBase        ;LIB, to check these pointers first, if
  68.     APTR    _GTBase        ;LIB, MBlank has come this far, ALL libs
  69.     APTR    _GfxBase    ;LIB, will have opened. (versions 37+).
  70.     LONG    gb_OldDir                ;PRIVATE
  71.     LONG    gb_Ticks                ;PRIVATE
  72.     LONG    gb_Counter                ;PRIVATE
  73.     LONG    gb_Delay                ;PRIVATE
  74.     LONG    gb_Store    ;USE, tooltype macros use this for storage!
  75.     LONG    gb_SigNums                ;PRIVATE
  76.     LONG    gb_CountSignal                ;PRIVATE
  77.     LONG    gb_PopSignal                ;PRIVATE
  78.     LONG    gb_ResetSignal    ;READ, WAIT() on it.
  79.     BYTE    gb_CountSigNum                ;PRIVATE
  80.     BYTE    gb_PopSigNum                ;PRIVATE
  81.     BYTE    gb_ResetSigNum                ;PRIVATE
  82.     BYTE    gb_Flags    ;READ, btst #GB_BLANK,gb_Flags(a5)
  83.     BYTE    gb_TRFlags                ;PRIVATE
  84.     STRUCT    gb_ModPath,128                ;PRIVATE
  85.     STRUCT    gb_ModName,30                ;PRIVATE
  86.     STRUCT    gb_User,158    ;USE, contains path/name of your module.
  87.  
  88. ;   LABEL    gb_SIZEOF    ;may be extended in future, so don't rely
  89.                 ;on this for anything!
  90.  
  91. ;gb_Flags:        Bit:    Flagging:
  92. GB_BLANK    EQU    4    ;if CLEAR, blanking should abort right now,
  93.                 ;but first CLEAN UP EVERYTHING.!
  94.  
  95. ;Blanker module structure, equates, flags etc.
  96. ;Only blm_ID/Length/Code fields used for now
  97.  STRUCTURE BlmSimple,0
  98.  
  99.     LONG    blm_ID        ;allways 'BLMS' for simples, other types
  100.                 ;may be added in future.
  101.     LONG    blm_Length    ;length of module-file in bytes.
  102.     BPTR    blm_Code    ;code-entry of your module, MUST be relative
  103.                 ;to module start. (blm_structure)
  104. ;blm_TagList not yet implemented, set to NULL for backwards compatibility.
  105.     APTR    blm_TagList    ;other types may need something like this.
  106.                 ;MUST be relative to blm_ID(BlmSimple).
  107.                 ;if NULL, no taglist supplied.
  108.     BYTE    blm_Flags    ;general flags field.
  109.     LABEL    blm_SIZEOF
  110.  
  111. ;blm_Flags        bit:    meaning:
  112. BLM_SETTINGS    EQU    0    ;blm_structure is followed by a settings-
  113.                 ;structure to be defined in future releases.
  114.  
  115. ;Macros for convenience and clarity
  116. ;FINDTT        -    Checks existence of a tooltype
  117. ;Example usage:    FINDTT    ALERT
  118. ;        beq.s    NotFound
  119. ;        ...    ...
  120. ;ALERT        dc.b    'ALERT',NULL
  121.  
  122. ;Always tst.l gb_DiskObject(a5) first, maybe MBlank didn't get it!
  123.  
  124. FINDTT        MACRO
  125.         move.l    gb_DiskObject(a5),a0
  126.         move.l    do_ToolTypes(a0),a0
  127.         lea    \1(pc),a1
  128.         CALLIC    FindToolType
  129.         tst.l    d0
  130.         ENDM
  131.  
  132. ;Template:    TTVAL    variable,size,minimum,maximum
  133. ;            (defaults should be set in advance!)
  134. ;function:    can be used directly after FINDTT, translates a string
  135. ;        to an integer and stores it in <variable>(a5).
  136. ;variable:    must be a field in the (a5) AllGlobals structure.
  137. ;size:        b, w, l. (byte, word, long)
  138. ;minimum:    if<minimum, uses default. (not changed)
  139. ;maximum:    if>maximum, uses default. (not changed)
  140.  
  141. ;par example:    Handle SPHERES tooltype
  142. ;        FINDTT    TT_SPHERES
  143. ;        TTVAL    bog_Spheres,w,1,30,10
  144. ;        ...    ...
  145. ;        rts
  146. ;TT_SPHERES    dc.b    'SPHERES',NULL
  147.  
  148. ;The above two lines will:    -check the existence of 'SPHERES' tooltype
  149. ;                    -read the tooltype value
  150. ;                    -check its range and validity, if ok
  151. ;                    -move.size #result,<variable>(a5)
  152. ;                -end
  153.  
  154. _ttvalused    set    0
  155. TTVAL        MACRO
  156.         beq.s    TTMnext\<_ttvalused>    ;not found by FINDTT
  157.         move.l    d0,d1            ;found it, extract value
  158.         lea    gb_Store(a5),a0
  159.         move.l    a0,d2
  160.         CALLDOS    StrToLong    ;gb_Store=longalligned, don't worry.
  161.         tst.l    d0
  162.         ble.s    TTMnext\<_ttvalused>    ;no digits found, default
  163.         move.l    gb_Store(a5),d0        ;StrToLong results
  164.         cmp.\2    #\3,d0            ;no smaller than \3 argument
  165.         bcs.s    TTMnext\<_ttvalused>    ;otherwise default used
  166.         cmp.\2    #\4,d0            ;no larger than \4 argument
  167.         bhi.s    TTMnext\<_ttvalused>    ;otherwise default used
  168.         move.\2    d0,\1(a5)
  169. TTMnext\<_ttvalused>    
  170. _ttvalused    set    _ttvalused+1
  171.         ENDM
  172.  
  173. ;handy macros
  174. CALLDOS        MACRO                ;call dos.library
  175.         move.l    _DOSBase(a5),a6
  176.         jsr    _LVO\1(a6)
  177.         ENDM
  178.  
  179. CALLINT        MACRO                ;call intuition.library
  180.         move.l    _IntBase(a5),a6
  181.         jsr    _LVO\1(a6)
  182.         ENDM
  183.  
  184. CALLGFX        MACRO                ;call graphics.library
  185.         move.l    _GfxBase(a5),a6
  186.         jsr    _LVO\1(a6)
  187.         ENDM
  188.  
  189. CALLEXEC    MACRO                ;call the almighty
  190.         move.l    #4,a6
  191.         move.l    (a6),a6            ;avoid asm-complaints
  192.         jsr    _LVO\1(a6)
  193.         ENDM
  194.  
  195. CALLEX        MACRO
  196.         move.l    4,a6
  197.         jsr    _LVO\1(a6)
  198.         ENDM
  199.  
  200. CALLIC        MACRO                ;call icon.library
  201.         move.l    _IconBase(a5),a6
  202.         jsr    _LVO\1(a6)
  203.         ENDM
  204.  
  205. CALLWB        MACRO                ;call workbench.library
  206.         move.l    _WBBase(a5),a6
  207.         jsr    _LVO\1(a6)
  208.         ENDM
  209.  
  210. ;logical
  211. TRUE            EQU    1
  212. FALSE            EQU    0
  213. NULL            EQU    0
  214.