home *** CD-ROM | disk | FTP | other *** search
-
- /********************************************
- * CD Audio Player using 14bit sound driver *
- * for Toshiba 4101 CDRom and compatible *
- * (c) 1995 by Christian Buchner *
- ********************************************
- *
- * DeliInterface.c
- */
-
- /* Note: TAB SIZE = 4 */
-
- /* Includes */
-
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <libraries/dos.h>
- #include <dos/rdargs.h>
- #include <utility/tagitem.h>
- #include <string.h>
- #include "DeliPlayer.h"
-
- /* Prototypes */
-
- #include "CDPlayer_Protos.h"
- void __asm __saveds DeliProcess(void);
- ULONG __asm __saveds Check(void);
- ULONG __asm __saveds InitPlayer(void);
- ULONG __asm __saveds EndPlayer(void);
- ULONG __asm __saveds InitSound(void);
- ULONG __asm __saveds EndSound(void);
- ULONG __asm __saveds StartInt(void);
- ULONG __asm __saveds StopInt(void);
- ULONG __asm __saveds UserConfig(void);
- ULONG __asm __saveds Config(void);
- ULONG __asm __saveds NextPatt(void);
- ULONG __asm __saveds PrevPatt(void);
- ULONG __asm __saveds NextSong(void);
- ULONG __asm __saveds PrevSong(void);
- ULONG __asm __saveds SubSongTest(void);
- ULONG __asm __saveds Faster(void);
- ULONG __asm __saveds Slower(void);
- ULONG __asm __saveds Volume(void);
- ULONG __asm __saveds Balance(void);
- extern BOOL ReadDefaults(void); /* From CLIInterface.c */
- extern void FreeDefaults(void);
-
-
- /* Externals */
-
- extern struct DosLibrary *DOSBase; /* From CDPlayer.c */
- extern struct IntuitionBase *IntuitionBase;
-
- extern UBYTE ErrorBuffer[100]; /* From CLIInterface.c */
- extern UBYTE *Template;
- extern struct ArgArray AA;
- extern struct RDArgs *RDArgs;
- extern struct RDArgs *RDArgsSuccess;
-
-
- /* Default parameters */
-
- extern UBYTE DefaultDriverName[]; /* From CLIInterface.c */
- extern UBYTE DefaultSCSIName[];
- extern ULONG DefaultSCSIUnit;
- extern ULONG DefaultFrequency;
- extern ULONG DefaultQuality;
- extern ULONG DefaultBuffers;
-
-
- /* DeliTracker's stuff */
-
- struct DeliTrackerGlobals *DeliBase;
- struct MsgPort *DeliPort;
-
-
- /* Variables */
-
- ULONG Frequency;
-
-
- /* Copyright and info */
-
- UBYTE AboutString[]="CD Player using a 14bit sound driver\n"
- "for Toshiba 4101 CDRom and compatible\n"
- "(c) 1995 by Christian Buchner";
-
-
- /* Tag list for DeliTracker */
-
- struct TagItem PlayerTagArray[]=
- {
- DTP_RequestDTVersion, 16,
- DTP_PlayerVersion, (PLAYER_VERSION<<16)+PLAYER_REVISION,
- DTP_PlayerName, (ULONG)"CDPlayer",
- DTP_Creator, (ULONG)AboutString,
- DTP_Description, (ULONG)"SCSI CD Digital Audio Player",
- DTP_Flags, PLYF_SONGEND|PLYF_ANYMEM,
- DTP_DeliBase, (ULONG)&DeliBase,
- DTP_Check2, (ULONG)&Check,
- /* DTP_Config, (ULONG)&Config, */
- /* DTP_UserConfig, (ULONG)&UserConfig, */
- DTP_SubSongTest, (ULONG)&SubSongTest,
- DTP_Process, (ULONG)&DeliProcess,
- DTP_Priority, 0,
- DTP_StackSize, 4096,
- DTP_MsgPort, (ULONG)&DeliPort,
- DTP_InitPlayer, (ULONG)&InitPlayer,
- DTP_EndPlayer, (ULONG)&EndPlayer,
- DTP_InitSound, (ULONG)&InitSound,
- DTP_EndSound, (ULONG)&EndSound,
- DTP_StartInt, (ULONG)&StartInt,
- DTP_StopInt, (ULONG)&StopInt,
- /* DTP_Volume, (ULONG)&Volume, */
- /* DTP_Balance, (ULONG)&Balance, */
- DTP_Faster, (ULONG)&Faster,
- DTP_Slower, (ULONG)&Slower,
- DTP_NextPatt, (ULONG)&NextPatt,
- DTP_PrevPatt, (ULONG)&PrevPatt,
- DTP_NextSong, (ULONG)&NextSong,
- DTP_PrevSong, (ULONG)&PrevSong,
- TAG_DONE
- };
-
-
-
- /* Variables and data for parsing the options (same as in CLIInterface.c) */
-
- UBYTE IDString[]="CD-DA";
-
- struct ArgArray
- {
- ULONG **aa_Tracks;
- UBYTE *aa_SCSIName;
- ULONG *aa_SCSIUnit;
- UBYTE *aa_SoundDriver;
- ULONG aa_Repeat;
- ULONG *aa_Frequency;
- ULONG *aa_Quality;
- ULONG *aa_Buffers;
- ULONG aa_HighPri;
- UBYTE *aa_PubScreen;
- ULONG aa_GUI;
- };
-
-
- /****************************************************************************/
-
- /* Our player's Process */
-
- void __asm __saveds DeliProcess(void)
- {
- BOOL ProcActive=TRUE;
- ULONG Signals;
- struct DeliMessage *DeliMessage;
-
- DOSBase=(struct DosLibrary*)DeliBase->DOSBase;
- IntuitionBase=(struct IntuitionBase*)DeliBase->IntuitionBase;
-
- while(ProcActive)
- {
- Signals=Wait(SIGBREAKF_CTRL_C | (1L<<DeliPort->mp_SigBit));
-
- if (Signals & SIGBREAKF_CTRL_C)
- {
- ProcActive=FALSE;
- }
- else
- {
- if (DeliMessage=(struct DeliMessage*)GetMsg(DeliPort))
- {
- DeliMessage->Result=(DeliMessage->Function)();
- ReplyMsg((struct Message*)DeliMessage);
- }
- }
- }
- }
-
-
-
- /****************************************************************************/
-
- /* Callback routine for finished program */
-
- void __saveds SongendCallback(void)
- {
- /* Repeat desired? */
- if (AA.aa_Repeat)
- {
- /* Restart playing */
- CD_Start();
- }
- else
- {
- /* Signal Songend */
- dt_SongEnd();
- }
- }
-
-
- /****************************************************************************/
-
- /* Module check routine */
-
- ULONG __asm __saveds Check(void)
- {
- if (!strncmp(IDString,DeliBase->ChkData,5)) return(FALSE);
- else return(TRUE);
- }
-
-
- /****************************************************************************/
-
- /* Init player (alloc channels, etc...) */
-
- ULONG __asm __saveds InitPlayer(void)
- {
- BOOL Error=TRUE;
-
- /* Read global defaults */
- if (ReadDefaults())
- {
- if (RDArgs=(struct RDArgs*)AllocDosObject(DOS_RDARGS,TAG_DONE))
- {
- RDArgs->RDA_Source.CS_Buffer=(UBYTE*)(dt_GetListDataPos(0))+strlen(IDString);
- RDArgs->RDA_Source.CS_Length=dt_GetListDataSize(0)-strlen(IDString);
- RDArgs->RDA_Source.CS_CurChr=0;
- RDArgs->RDA_DAList=NULL;
- RDArgs->RDA_Buffer=NULL;
- RDArgs->RDA_BufSiz=NULL;
- RDArgs->RDA_ExtHelp=NULL;
- RDArgs->RDA_Flags=RDAF_NOPROMPT;
-
- if (!(RDArgsSuccess=ReadArgs(Template, (LONG *)&AA, RDArgs)))
- {
- Fault(IoErr(),NULL, ErrorBuffer, sizeof(ErrorBuffer));
- Message("Error parsing options in fake module:\n%s\n%s",RDArgs->RDA_Source.CS_Buffer+1,ErrorBuffer);
- }
- else
- {
- /* Set defaults for the arguments */
- if (!AA.aa_SCSIName) AA.aa_SCSIName= DefaultSCSIName;
- if (!AA.aa_SCSIUnit) AA.aa_SCSIUnit= &DefaultSCSIUnit;
- if (!AA.aa_SoundDriver) AA.aa_SoundDriver= DefaultDriverName;
- if (!AA.aa_Frequency) AA.aa_Frequency= &DefaultFrequency;
- if (!AA.aa_Quality) AA.aa_Quality= &DefaultQuality;
- if (!AA.aa_Buffers) AA.aa_Buffers= &DefaultBuffers;
-
- if (InitDriver(AA.aa_SoundDriver,*AA.aa_Buffers))
- {
- if (OpenSCSI(AA.aa_SCSIName,*AA.aa_SCSIUnit,(BOOL)AA.aa_HighPri))
- {
- /* Create a program for replay */
- if (!(CD_SetProgram(AA.aa_Tracks, &SongendCallback)))
- {
- Message("CD or specified track list contain no audio tracks.");
- }
- else
- {
- CD_Frequency(Frequency= *AA.aa_Frequency);
- CD_Quality (*AA.aa_Quality);
-
- /* Start with first index in program */
- DeliBase->SndNum=1;
-
- Error=FALSE;
- }
- }
- }
- }
- }
- }
-
- if (Error) EndPlayer();
-
- return(Error);
- }
-
-
- /****************************************************************************/
-
- /* Clean up the Player (deallocate, etc..) */
-
- ULONG __asm __saveds EndPlayer(void)
- {
- CloseSCSI();
- DeInitDriver();
-
- if (RDArgsSuccess)
- {
- FreeArgs(RDArgs);
- RDArgsSuccess=NULL;
- }
-
- if (RDArgs)
- {
- FreeDosObject(DOS_RDARGS,RDArgs);
- RDArgs=NULL;
- }
-
- FreeDefaults();
-
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* Initialize the "Module" */
-
- ULONG __asm __saveds InitSound(void)
- {
- /* Prepare replay buffers */
- CD_Init();
-
- /* Restart track list */
- CD_ToIndex(DeliBase->SndNum);
-
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* End sound */
-
- ULONG __asm __saveds EndSound(void)
- {
- /* Abort playing */
- CD_Abort();
-
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* Start sound */
-
- ULONG __asm __saveds StartInt(void)
- {
- /* Start or resume reading/playing */
- CD_Start();
- CD_Resume();
-
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* Stop sound */
-
- ULONG __asm __saveds StopInt(void)
- {
- /* Pause playing */
- CD_Pause();
-
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* UserConfig */
-
- ULONG __asm __saveds UserConfig(void)
- {
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* Config */
-
- ULONG __asm __saveds Config(void)
- {
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* Next Pattern */
-
- ULONG __asm __saveds NextPatt(void)
- {
- CD_Skip(10);
-
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* Prev Pattern */
-
- ULONG __asm __saveds PrevPatt(void)
- {
- CD_Skip(-10);
-
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* Next Song */
-
- ULONG __asm __saveds NextSong(void)
- {
- BOOL Error=TRUE;
- UWORD Cur;
-
- if (Cur=CD_NextIndex())
- {
- DeliBase->SndNum=Cur;
- Error=FALSE;
- }
- else
- {
- DisplayBeep(NULL);
- }
-
- return(Error);
- }
-
-
- /****************************************************************************/
-
- /* Prev Song */
-
- ULONG __asm __saveds PrevSong(void)
- {
- BOOL Error=TRUE;
- UWORD Cur;
-
- if (Cur=CD_PrevIndex())
- {
- DeliBase->SndNum=Cur;
- Error=FALSE;
- }
- else
- {
- DisplayBeep(NULL);
- }
-
- return(Error);
- }
-
-
- /****************************************************************************/
-
- /* Sub Song Test */
-
- ULONG __asm __saveds SubSongTest(void)
- {
- /* All Indexes are playable (as long as they stay in range) */
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* Play Faster */
-
- ULONG __asm __saveds Faster(void)
- {
- Frequency+=100;
- CD_Frequency(Frequency);
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* Slower */
-
- ULONG __asm __saveds Slower(void)
- {
- Frequency-=100;
- CD_Frequency(Frequency);
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* Volume */
-
- ULONG __asm __saveds Volume(void)
- {
- return(0);
- }
-
-
- /****************************************************************************/
-
- /* Balance */
-
- ULONG __asm __saveds Balance(void)
- {
- return(0);
- }
-