home *** CD-ROM | disk | FTP | other *** search
- ;Custom blanker-modules:
- ;input: a5 = APTR Globals (saved/restored before/after
- ; calling you blanker code.)
- ;output: status register's zeroflag SET on failure, UNSET
- ; on succes: moveq #TRUE,d0
- ; rts ;succesfull exit
-
- ; moveq #FALSE,d0
- ; rts ;unsuccesfull exit
- ; in the latter case, MBlank will use its internal
- ; 'Black-Screen' as a backup.
-
- ;Your code MUST be 100% position-ind. Because of this the CALLEXEC
- ;macro is a little strange. If you don't use the 'Ensure PC-relative Code'
- ;option of your assembler, you can use the CALLEX macro.
-
- ;Instructions on using the AllGlobals(a5) structure:
-
- ;- PRIVATE Blanker modules may not use these in any way!
- ;- LIB A library pointer which is valid. (blanker modules run
- ; on the same context as the Process which opened the Libs.)
- ; Don't close these Libs. under any circumstances.
- ;- READ May be read, contents are valid.
- ;- USE Space may be used, contents may not be valid!
- ;- CHANGE May be set, according to rules.
-
- ; A module can Wait() on the gb_ResetSignal(a5) if it doesn't have to keep
- ; working. You can ofcourse also poll this signal.
- ; If the module does polling to determine wether or not a significant
- ; input-event ocurred, use btst #GB_BLANK,gb_Flags(a5).(beq ABORT_blanking).
-
- ; The gb_Random(a5) pointer is a pointer to a pseudo-random generator, which
- ; I copied from one of Toby Simpson's example Lottery programs.(Shopper)
- ; input: d0.w = maximum value (1 to 65535).
- ; All registers get saved/restored, therefore the gb_Random entry can
- ; easily be used from within loops.
- ; output: d0.w = Random number (0 to maximum value-1).
-
- ;This is the structure to which you receive a handle in a5.
- STRUCTURE AllGlobals,0
- STRUCT gb_NewBrokerStruct,nb_SIZEOF ;PRIVATE
- BYTE gb_ExtFlags ;PRIVATE
- BYTE gb_ActionFlags ;PRIVATE
- STRUCT gb_HotKeyIX,ix_SIZEOF ;PRIVATE
- APTR gb_WBstartupMsg ;PRIVATE
- APTR gb_Broker ;PRIVATE
- APTR gb_WBLock ;PRIVATE
- APTR gb_Screen ;USE, not valid on entry.
- APTR gb_VisInfo ;PRIVATE
- APTR gb_Menu ;PRIVATE
- APTR gb_Window ;PRIVATE
- APTR gb_BitMap ;USE, not valid on entry.
- APTR gb_DiskObject ;READ, your .info file, if it exists.
- APTR gb_Process ;READ, our process, it exists.
- APTR gb_AppItem ;PRIVATE
- APTR gb_ModLock ;PRIVATE
- APTR gb_FIB ;PRIVATE
- APTR gb_ModHandle ;PRIVATE
- APTR gb_Module ;READ, APTR to your module. (blm_structure)
- APTR gb_Random ;READ, APTR random number generator. (Simpson)
- LONG gb_ModType ;READ/USE, 'BLMS' for now.
- LONG gb_ModSize ;READ/USE, size of module in bytes.
- APTR _IconBase ;LIB, you can use all of the following
- APTR _IntBase ;LIB, pointers as if you had opened the
- APTR _CxBase ;LIB, libraries yourself. NEVER close
- APTR _DOSBase ;LIB, these libraries!!! You don't have
- APTR _WBBase ;LIB, to check these pointers first, if
- APTR _GTBase ;LIB, MBlank has come this far, ALL libs
- APTR _GfxBase ;LIB, will have opened. (versions 37+).
- LONG gb_OldDir ;PRIVATE
- LONG gb_Ticks ;PRIVATE
- LONG gb_Counter ;PRIVATE
- LONG gb_Delay ;PRIVATE
- LONG gb_Store ;USE, tooltype macros use this for storage!
- LONG gb_SigNums ;PRIVATE
- LONG gb_CountSignal ;PRIVATE
- LONG gb_PopSignal ;PRIVATE
- LONG gb_ResetSignal ;READ, WAIT() on it.
- BYTE gb_CountSigNum ;PRIVATE
- BYTE gb_PopSigNum ;PRIVATE
- BYTE gb_ResetSigNum ;PRIVATE
- BYTE gb_Flags ;READ, btst #GB_BLANK,gb_Flags(a5)
- BYTE gb_TRFlags ;PRIVATE
- STRUCT gb_ModPath,128 ;PRIVATE
- STRUCT gb_ModName,30 ;PRIVATE
- STRUCT gb_User,158 ;USE, contains path/name of your module.
-
- ; LABEL gb_SIZEOF ;may be extended in future, so don't rely
- ;on this for anything!
-
- ;gb_Flags: Bit: Flagging:
- GB_BLANK EQU 4 ;if CLEAR, blanking should abort right now,
- ;but first CLEAN UP EVERYTHING.!
-
- ;Blanker module structure, equates, flags etc.
- ;Only blm_ID/Length/Code fields used for now
- STRUCTURE BlmSimple,0
-
- LONG blm_ID ;allways 'BLMS' for simples, other types
- ;may be added in future.
- LONG blm_Length ;length of module-file in bytes.
- BPTR blm_Code ;code-entry of your module, MUST be relative
- ;to module start. (blm_structure)
- ;blm_TagList not yet implemented, set to NULL for backwards compatibility.
- APTR blm_TagList ;other types may need something like this.
- ;MUST be relative to blm_ID(BlmSimple).
- ;if NULL, no taglist supplied.
- BYTE blm_Flags ;general flags field.
- LABEL blm_SIZEOF
-
- ;blm_Flags bit: meaning:
- BLM_SETTINGS EQU 0 ;blm_structure is followed by a settings-
- ;structure to be defined in future releases.
-
- ;Macros for convenience and clarity
- ;FINDTT - Checks existence of a tooltype
- ;Example usage: FINDTT ALERT
- ; beq.s NotFound
- ; ... ...
- ;ALERT dc.b 'ALERT',NULL
-
- ;Always tst.l gb_DiskObject(a5) first, maybe MBlank didn't get it!
-
- FINDTT MACRO
- move.l gb_DiskObject(a5),a0
- move.l do_ToolTypes(a0),a0
- lea \1(pc),a1
- CALLIC FindToolType
- tst.l d0
- ENDM
-
- ;Template: TTVAL variable,size,minimum,maximum
- ; (defaults should be set in advance!)
- ;function: can be used directly after FINDTT, translates a string
- ; to an integer and stores it in <variable>(a5).
- ;variable: must be a field in the (a5) AllGlobals structure.
- ;size: b, w, l. (byte, word, long)
- ;minimum: if<minimum, uses default. (not changed)
- ;maximum: if>maximum, uses default. (not changed)
-
- ;par example: Handle SPHERES tooltype
- ; FINDTT TT_SPHERES
- ; TTVAL bog_Spheres,w,1,30,10
- ; ... ...
- ; rts
- ;TT_SPHERES dc.b 'SPHERES',NULL
-
- ;The above two lines will: -check the existence of 'SPHERES' tooltype
- ; -read the tooltype value
- ; -check its range and validity, if ok
- ; -move.size #result,<variable>(a5)
- ; -end
-
- _ttvalused set 0
- TTVAL MACRO
- beq.s TTMnext\<_ttvalused> ;not found by FINDTT
- move.l d0,d1 ;found it, extract value
- lea gb_Store(a5),a0
- move.l a0,d2
- CALLDOS StrToLong ;gb_Store=longalligned, don't worry.
- tst.l d0
- ble.s TTMnext\<_ttvalused> ;no digits found, default
- move.l gb_Store(a5),d0 ;StrToLong results
- cmp.\2 #\3,d0 ;no smaller than \3 argument
- bcs.s TTMnext\<_ttvalused> ;otherwise default used
- cmp.\2 #\4,d0 ;no larger than \4 argument
- bhi.s TTMnext\<_ttvalused> ;otherwise default used
- move.\2 d0,\1(a5)
- TTMnext\<_ttvalused>
- _ttvalused set _ttvalused+1
- ENDM
-
- ;handy macros
- CALLDOS MACRO ;call dos.library
- move.l _DOSBase(a5),a6
- jsr _LVO\1(a6)
- ENDM
-
- CALLINT MACRO ;call intuition.library
- move.l _IntBase(a5),a6
- jsr _LVO\1(a6)
- ENDM
-
- CALLGFX MACRO ;call graphics.library
- move.l _GfxBase(a5),a6
- jsr _LVO\1(a6)
- ENDM
-
- CALLEXEC MACRO ;call the almighty
- move.l #4,a6
- move.l (a6),a6 ;avoid asm-complaints
- jsr _LVO\1(a6)
- ENDM
-
- CALLEX MACRO
- move.l 4,a6
- jsr _LVO\1(a6)
- ENDM
-
- CALLIC MACRO ;call icon.library
- move.l _IconBase(a5),a6
- jsr _LVO\1(a6)
- ENDM
-
- CALLWB MACRO ;call workbench.library
- move.l _WBBase(a5),a6
- jsr _LVO\1(a6)
- ENDM
-
- ;logical
- TRUE EQU 1
- FALSE EQU 0
- NULL EQU 0
-