home *** CD-ROM | disk | FTP | other *** search
- ; $VER: Fred.library 2.0
- ;
-
- INCDIR "Includes3.0:Include3.0/"
- INCLUDE "Exec/Types.i"
- INCLUDE "Own/SystemBases.i"
- INCLUDE "Own/SystemStructures.i"
- INCLUDE "Own/SystemOffsets.i"
- INCLUDE "Own/AccessiblePlayer.i"
-
-
- VERSION = 2
- REVISION = 0
-
- TRUE = -1
- FALSE = 0
-
- ; Library Data
-
- LN_Name = 10
- LN_Type = 8
- NT_Library = 9
-
- LIBB_Summing = 0
- LIBB_Changed = 1
- LIBB_SumUsed = 2
- LIBB_DelExp = 3
-
- LIBF_Summing = 1<<LIBB_Summing
- LIBF_Changed = 1<<LIBB_Changed
- LIBF_SumUsed = 1<<LIBB_SumUsed
- LIBF_DelExp = 1<<LIBB_DelExp
-
- ; Macros
-
- INBYTE MACRO
- dc.b %11100000,0
- dc.w \1
- dc.b \2,0
- ENDM
-
- INWORD MACRO
- dc.b %11010000,0
- dc.w \1,\2
- ENDM
-
- INLONG MACRO
- dc.b %11000000,0
- dc.w \1
- dc.l \2
- ENDM
-
- ; Library Base Structure
-
- STRUCTURE LibraryStruct,0
- STRUCT LIB_Node,14
- UBYTE LIB_Flags
- UBYTE LIB_Pad
- UWORD LIB_NegSize
- UWORD LIB_PosSize
- UWORD LIB_Version
- UWORD LIB_Revision
- APTR LIB_IDString
- ULONG LIB_Sum
- UWORD LIB_OpenCnt
-
- LONG LIB_SegList
- LABEL LibraryStruct_SIZEOF
-
-
- SECTION Fred.library,CODE
-
- START moveq #0,d0
- rts
- ;------------------------------------------------------------------------------
- LIBNAME dc.b "apFred.library",0
-
- LIBID dc.b "Fred.library 2.0 (13-June-1994)",0
- even
- ;------------------------------------------------------------------------------
- ; ROMTAG Structure
- ;
-
- ROMTAG dc.w $4afc ;ROMTAG Indentifier
- dc.l romtag
- dc.l slut
- dc.b $80 ;Flags
- dc.b version
- dc.b $09 ;Type Of Module
- dc.b $00 ;Initialization Priority
- dc.l libname
- dc.l libid
- dc.l autinit ;Pointer To AUTOINIT Table
- ;------------------------------------------------------------------------------
- ; AUTOINIT Table
- ;
-
- AUTINIT dc.l LibraryStruct_SIZEOF ;Size Of Structure AFTER Base Address
- dc.l vector ;Pointer To Vector Table
- dc.l inittab ;Pointer To Init Structure
- dc.l init ;Pointer To Init Routine
- ;------------------------------------------------------------------------------
- ; Init Table
- ;
-
- INITTAB INBYTE LN_Type,NT_Library
- INBYTE LIB_Flags,LIBF_SumUsed!LIBF_Changed
- INWORD LIB_Version,version
- INWORD LIB_Revision,revision
- INLONG LN_Name,libname
- INLONG LIB_IDString,libid
- dc.l 0
- ;------------------------------------------------------------------------------
- ; Vector Table
- ;
-
- VECTOR dc.w -1
- dc.w opnlib-vector,clslib-vector,expunge-vector,extfunc-vector
- dc.w FP_GetTags-vector
- dc.w -1
- ;------------------------------------------------------------------------------
- ; Init Routine
- ;
-
- INIT movem.l d1-d7/a0-a6,-(sp)
- move.l d0,a4 ;Base Address
- move.l a0,LIB_SegList(a4)
-
- move.l a4,d0
- movem.l (sp)+,d1-d7/a0-a6
- rts
- ;------------------------------------------------------------------------------
- ; Offset -6: Open Library
- ;
-
- OPNLIB addq.w #1,LIB_OpenCnt(a6)
- bclr #LIBB_DelExp,LIB_Flags(a6)
- move.l a6,d0
- rts
- ;------------------------------------------------------------------------------
- ; Offset -12: Close Library
- ;
-
- CLSLIB moveq #0,d0
- subq.w #1,LIB_OpenCnt(a6)
- bne.b clslibo
- btst #LIBB_DelExp,LIB_Flags(a6)
- bne.b expunge
- CLSLIBO rts
- ;------------------------------------------------------------------------------
- ; Offset -18: Expunge
- ;
-
- EXPUNGE movem.l d1-d7/a0-a6,-(sp)
- move.l a6,a4
- tst.w LIB_OpenCnt(a4)
- beq.b exp1
- bset #LIBB_DelExp,LIB_Flags(a4)
- moveq #0,d0
- bra.b expungo
-
- EXP1 move.l 4.w,a6
- move.l LIB_SegList(a4),d2
- move.l a4,a1
- jsr Remove(a6)
-
- move.l a4,a1
- moveq #0,d0
- move.w LIB_NegSize(a4),d0
- sub.l d0,a1
- add.w LIB_PosSize(a4),d0
- jsr FreeMem(a6)
- move.l d2,d0
-
- EXPUNGO movem.l (sp)+,d1-d7/a0-a6
- rts
- ;------------------------------------------------------------------------------
- ; Offset -24: ExtFunc
- ;
-
- EXTFUNC moveq #0,d0
- rts
- ;------------------------------------------------------------------------------
- ;******************************************************************************
- ;* Fred Player
- ;******************************************************************************
- ;------------------------------------------------------------------------------
- ; Offset -30: GetTags
- ;
- ; IN : Nothing
- ;
- ; OUT: A0 = Pointer To A TagList
- ;
-
- FP_GetTags
- lea FP_Tags(pc),a0
- rts
-
- FP_Tags dc.l APT_PlayerName,fpname
- dc.l APT_Description,fpdes
-
- dc.l APT_Check,FP_TestModule
- dc.l APT_InitSound,FP_InitSound
- dc.l APT_EndSound,FP_EndSound
- dc.l APT_Interrupt,FP_PlayModule
-
- dc.l APT_Author,FP_Author
- dc.l APT_SubSong,FP_SubSong
-
- dc.l APT_Pause,TRUE
- dc.l TAG_END
-
- FPNAME dc.b "Fred Player",0
- FPDES dc.b "Original player by JC & Fred.",10
- dc.b "Adapted by Tax.",0
- even
- ;------------------------------------------------------------------------------
- ; TestModule
- ;
- ; IN : A1 = Address
- ;
- ; OUT: D0 = Success (0=Unknown, 1=Ok, 2=Error)
- ;
-
- FP_TestModule
- movem.l d1-d2/a1/a3,-(sp)
-
- cmp.w #$4efa,(a1)
- bne.b .tsmod3
- cmp.w #$4efa,4(a1)
- bne.b .tsmod3
- cmp.w #$4efa,8(a1)
- bne.b .tsmod3
- cmp.w #$4efa,12(a1)
- bne.b .tsmod3
-
- moveq #0,d1
- move.w 2(a1),d1
- add.l d1,a1
- moveq #4-1,d2
- .TSMOD1 cmp.w #$123a,2(a1)
- bne.b .tsmod2
- cmp.w #$b001,6(a1)
- beq.b .tsmod4
- .TSMOD2 addq.l #2,a1
- dbra d2,.tsmod1
-
- .TSMOD3 moveq #0,d0 ;Unknown
- bra.b .tsmodo
-
- .TSMOD4 move.w 4(a1),d1
- add.l d1,a1
-
- moveq #0,d1
- move.b 4(a1),d1
- addq.w #1,d1
- move.w d1,maxtune
-
- moveq #1,d0 ;Ok
- .TSMODO movem.l (sp)+,d1-d2/a1/a3
- rts
- ;------------------------------------------------------------------------------
- ; InitSound
- ;
- ; IN : A1 = Address
- ;
- ; OUT: Nothing
- ;
-
- FP_InitSound
- movem.l d0-d7/a0-a6,-(sp)
-
- move.w APG_Tune(a5),d0
- ext.l d0
- jsr (a1) ;Init Module
-
- movem.l (sp)+,d0-d7/a0-a6
- rts
- ;------------------------------------------------------------------------------
- ; EndSound
- ;
- ; IN : A1 = Address
- ;
- ; OUT: Nothing
- ;
-
- FP_EndSound
- movem.l d0-d7/a0-a6,-(sp)
-
- moveq #0,d1
- jsr 8(a1) ;Stop Module Playing
-
- moveq #0,d0
- move.w d0,$dff0a8
- move.w d0,$dff0b8
- move.w d0,$dff0c8
- move.w d0,$dff0d8
-
- movem.l (sp)+,d0-d7/a0-a6
- rts
- ;------------------------------------------------------------------------------
- ; PlayModule
- ;
- ; IN : A1 = Address
- ; D1 = VBlank/Cia (0=CIA)
- ;
- ; OUT: Nothing
- ;
-
- FP_PlayModule
- movem.l d0-d7/a0-a6,-(sp)
- jsr 4(a1) ;Play Module
- movem.l (sp)+,d0-d7/a0-a6
- rts
- ;------------------------------------------------------------------------------
- ; Author
- ;
- ; IN : A1 = Address
- ;
- ; OUT: D0 = Pointer To Author Or NULL For Not Found
- ;
-
- FP_Author
- move.l #author,d0
- rts
-
- AUTHOR dc.b "Fred",0
- even
- ;------------------------------------------------------------------------------
- ; SubSong
- ;
- ; IN : A1 = Address
- ;
- ; OUT: A0 = Pointer To Two SubSongs Words
- ;
-
- FP_SubSong
- lea maxtune(pc),a0
- rts
-
- MAXTUNE dc.w 0,0
- ;------------------------------------------------------------------------------
- SLUT
-