home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 13
/
AACD13.ISO
/
AACD
/
Utilities
/
ACDPlay
/
src
/
V1.6
/
PanelCommands.c.BAK
< prev
next >
Wrap
Text File
|
1998-01-28
|
6KB
|
245 lines
/* PanelCommands.c */
#include "Constants.h"
#include <exec/types.h>
#include <exec/memory.h>
#include <exec/libraries.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <libraries/commodities.h>
#include <libraries/asl.h>
#include <graphics/rastport.h>
#include <devices/scsidisk.h>
#include <devices/cd.h>
#include <libraries/screennotify.h>
#include <pragma/screennotify_lib.h>
#include "AsmLib/CD-ROM.h"
#include "Locale.h"
#include "Structures/Application.h"
#include "Structures/DirNode.h"
#include "Structures/MyPubScreenNode.h"
#include <clib/alib_protos.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <clib/asl_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <clib/commodities_protos.h>
#include <clib/icon_protos.h>
#include <clib/locale_protos.h>
#include <clib/wb_protos.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "ACDPlay_protos.h"
ULONG DirectChoice(Application *app, UWORD track)
{
ULONG suc = RETURN_OK;
register struct CDStruct *cdstr = app->cdstr;
track = FitInteger(track, 1, cdstr->num_track);
if (cdstr->active != AUDIO_STAT_NO_DISK)
if (suc = PlayListStart(cdstr, track))
if (cdstr->active == AUDIO_STAT_PAUSED)
suc = CDPauseA(cdstr->cdx, TRUE);
cdstr->useraction = TRUE;
CDUpdateA(cdstr->cdx);
UpdateGadgets(app);
return(suc ? RETURN_SCSIERR : RETURN_OK);
}
ULONG EjectButton(Application *app)
{
ULONG suc;
/* Gibt es eine Möglichkeit, ein und denselben Button zum Öffnen */
/* und Schließen des Laufwerks zu Verwenden? Ich sehe keine. :-( */
/* Mann müsste auslesen können ob die Schublade offen ist. */
/* Ich glaube aus diesem Grund sperrt auch OptyPlayer die */
/* manuelle Bedienung der Schublade. Frag doch mal Patrick ob */
/* er da was machen kann [mak] */
/* Hab' ich schon... :-) */
/* Endlich! Es funktioniert! :) */
StopButton(app);
/* Wenn (CD vorhanden ist) oder (Schublade gerade geschlossen wurde) : öffnen */
if (!CDTestUnitA(app->cdstr->cdx) || (app->cdstr->cdx->cdx_Flags & SPECIALF_JUSTCLOSED))
suc = CDEjectA(app->cdstr->cdx, TRUE);
else
suc = CDEjectA(app->cdstr->cdx, FALSE);
return(suc ? RETURN_SCSIERR : RETURN_OK);
}
ULONG JumpBackwardButton(Application *app)
{
BOOL success = TRUE;
register struct CDStruct *cdstr = app->cdstr;
if (cdstr->active != AUDIO_STAT_NO_DISK)
if (success = PlayListPrev(cdstr))
if (cdstr->active == AUDIO_STAT_PAUSED)
success = CDPauseA(cdstr->cdx, TRUE);
cdstr->useraction = TRUE;
return(success ? RETURN_SCSIERR : RETURN_OK);
}
ULONG JumpForwardButton(Application *app)
{
BOOL success = TRUE;
register struct CDStruct *cdstr = app->cdstr;
if (cdstr->active != AUDIO_STAT_NO_DISK)
if (success = PlayListNext(cdstr))
if (cdstr->active == AUDIO_STAT_PAUSED)
success = CDPauseA(cdstr->cdx, TRUE);
cdstr->useraction = TRUE;
return(success ? RETURN_SCSIERR : RETURN_OK);
}
ULONG SearchBackwardButton(Application *app, WORD val)
{
ULONG suc;
register struct CDxRequest *cdx = app->cdstr->cdx;
/* Was bringt das eigentlich? */
/* Der Compiler wird gezwungen die Variable in einem Register
zu halten, was eine Codeersparnis bringt und das Programm
beschleunigt, außerdem wird damit nicht immer wieder von dem
Applicationzeiger ausgegangen, wie das sonst oft der Fall ist.
Allerdings bringt das nur was, wenn das Register nicht anderweitig
gebraucht wird, und immer zwischengespeichert werden muß. ACDPlay
wurde damit ca. 2k kürzer. */
switch (app->cdstr->active)
{
case AUDIO_STAT_STOPPED:
case AUDIO_STAT_PLAYING:
case AUDIO_STAT_PAUSED:
suc = CDJumpA(cdx, -75 * val, JUMPMODE_PLAY_REL);
if (app->cdstr->active == AUDIO_STAT_PAUSED)
suc |= CDPauseA(cdx, TRUE);
break;
}
return(suc ? RETURN_SCSIERR : RETURN_OK);
}
ULONG SearchForwardButton(Application *app, WORD val)
{
ULONG suc;
register struct CDxRequest *cdx = app->cdstr->cdx;
switch (app->cdstr->active)
{
case AUDIO_STAT_STOPPED:
case AUDIO_STAT_PLAYING:
case AUDIO_STAT_PAUSED:
suc = CDJumpA(cdx, 75 * val, JUMPMODE_PLAY_REL);
if (app->cdstr->active == AUDIO_STAT_PAUSED)
suc |= CDPauseA(cdx, TRUE);
break;
}
return(suc ? RETURN_SCSIERR : RETURN_OK);
}
ULONG StopButton(Application *app)
{
app->cdstr->useraction = TRUE;
return (CDStopA(app->cdstr->cdx) ? RETURN_SCSIERR : RETURN_OK);
}
ULONG PauseButton(Application *app)
{
ULONG suc = RETURN_OK;
register struct CDxRequest *cdx = app->cdstr->cdx;
switch (app->cdstr->active)
{
case AUDIO_STAT_STOPPED:
PlayListStart(app->cdstr);
case AUDIO_STAT_PLAYING:
suc = CDPauseA(cdx, TRUE);
break;
case AUDIO_STAT_PAUSED:
suc = CDPauseA(cdx, FALSE);
break;
}
cdstr->useraction = TRUE;
suc |= CDUpdateA(cdx); /* Damit der neue AudioStatus gleich übernommen wird */
return(suc ? RETURN_SCSIERR : RETURN_OK);
}
ULONG PlayButton(Application *app)
{
ULONG suc;
register struct CDStruct *cdstr = app->cdstr;
switch (cdstr->active)
{
case AUDIO_STAT_PLAYING:
suc = CDPlayA(cdstr->cdx, cdstr->cur_track, 1);
break;
case AUDIO_STAT_STOPPED:
PlayListStart(cdstr);
break;
case AUDIO_STAT_PAUSED:
suc = CDPauseA(cdstr->cdx, FALSE);
break;
}
return(suc ? RETURN_SCSIERR : RETURN_OK);
}
ULONG Trackslider(Application *app, UWORD newpos)
{
ULONG suc;
register struct CDxRequest *cdx = app->cdstr->cdx;
/* Bug: Wenn im Pausemodus bis an den Start zurückgescrollt und dann auf Play gedrückt wird,
ist man an der Stelle, an der man vorher war (nur im Pausemodus).
Dies kann verhindert werden, indem man _immer_ "newpos + 1" nimmt, dann kann man aber nicht
ganz bis an den Start zurückgehen.
Wenn man immer "newpos" nimmt, stimmt die Position nicht mit dem gewünschten Wert überein */
suc = CDUpdateA(cdx);
switch (app->cdstr->active)
{
case AUDIO_STAT_PLAYING:
case AUDIO_STAT_PAUSED:
suc |= CDJumpA(cdx, (cdx->cdx_TrackLength / 100 * (newpos?newpos+1:0)) - cdx->cdx_CurrentRelAddr, JUMPMODE_PLAY_REL);
if (app->cdstr->active == AUDIO_STAT_PAUSED)
suc |= CDPauseA(cdx, TRUE);
suc |= CDUpdateA(cdx);
UpdateTimeGadget(app);
break;
}
return(suc ? RETURN_SCSIERR : RETURN_OK);
}