1 /* Copyright 2000 Kjetil S. Matheussen
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License
5 as published by the Free Software Foundation; either version 2
6 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 #include <proto/dos.h> // Temporary solution. This is not portable.
29 #include "nsmtracker.h"
30 #include "playerclass.h"
31 #include "placement_proc.h"
32 #include "OS_Player_proc.h"
33 #include "PEQrealline_proc.h"
34 #include "PEQblock_proc.h"
35 #include "PEQnotes_proc.h"
36 #include "instruments_proc.h"
37 #include "blocklist_proc.h"
38 #include "OS_Ptask2Mtask_proc.h"
39 #include "time_proc.h"
40 #include "PEQ_clock_proc.h"
41 #include "gfx_upperleft_proc.h"
42 #include "OS_Bs_edit_proc.h"
43 #include "list_proc.h"
45 #include "player_proc.h"
51 /******************** NOTES ******************************
53 Even more "methods" for the playerclass struct.
55 *********************************************************/
57 extern PlayerClass
*pc
;
58 extern struct Root
*root
;
60 extern void (*Ptask2MtaskCallBack
)(void);
62 void PlayStopReally(bool doit
){
64 pc
->initplaying
=false;
67 while(pc
->peq
!=NULL
) Delay(1); //Amiga-spesific, etc.
72 if(doit
) (*Ptask2MtaskCallBack
)();
76 GFX_UpdateQuantitize(root
->song
->tracker_windows
,root
->song
->tracker_windows
->wblock
);
97 pc
->playtype
=PLAYBLOCK
;
101 root
->curr_block
=pc
->block
->l
.num
;
102 debug("root->curr_block: %d\n",root
->curr_block
);
105 (*Ptask2MtaskCallBack
)();
109 InitPEQrealline(block
,place
);
110 InitPEQblock(block
,place
);
111 InitAllPEQnotes(block
,place
);
113 StartPlayer(); // An OS spesific function.
117 pc
->initplaying
=false;
120 void PlayBlockFromStart(struct Tracker_Windows
*window
){
123 struct WBlocks
*wblock
=window
->wblock
;
125 PlayStopReally(false);
126 PlaceSetFirstPos(&place
);
128 root
->setfirstpos
=true;
130 PlayBlock(wblock
->block
,&place
);
133 void PlayBlockCurrPos(struct Tracker_Windows
*window
){
134 struct WBlocks
*wblock
;
136 PlayStopReally(false);
138 root
->setfirstpos
=false;
140 wblock
=window
->wblock
;
142 if(wblock
->curr_realline
==0) root
->setfirstpos
=true;
144 place
=&wblock
->reallines
[wblock
->curr_realline
]->l
.p
;
145 pc
->seqtime
=-Place2STime(wblock
->block
,place
);
147 debug("contblock, time: %d\n",pc
->seqtime
);
149 PlayBlock(wblock
->block
,place
);
156 struct Blocks
*block
;
158 debug("haaasfdfsafsa, root->song->length: %d\n\n\n",root
->song
->length
);
159 pc
->initplaying
=true;
161 block
=BL_GetBlockFromPos(playpos
);
163 debug("blocknum:%d\n",block
->l
.num
);
167 root
->curr_playlist
=playpos
;
169 pc
->playtype
=PLAYSONG
;
173 root
->curr_block
=block
->l
.num
;
175 (*Ptask2MtaskCallBack
)();
179 InitPEQrealline(block
,place
);
180 InitPEQblock(block
,place
);
181 InitAllPEQnotes(block
,place
);
183 StartPlayer(); // An OS spesific function.
187 pc
->initplaying
=false;
191 void PlaySongFromStart(struct Tracker_Windows
*window
){
195 PlaceSetFirstPos(&place
);
197 PlayStopReally(false);
199 BS_SelectPlaylistPos(0);
200 debug("root->curr_block: %d\n",root
->curr_block
);
201 root
->setfirstpos
=true;
204 InitAllInstrumentsForPlaySongFromStart();
209 void PlaySongCurrPos(struct Tracker_Windows
*window
){
210 struct Blocks
*block
;
211 struct WBlocks
*wblock
;
214 bool changeblock
=false;
216 wblock
=window
->wblock
;
218 PlayStopReally(false);
220 root
->setfirstpos
=false;
222 playpos
=root
->curr_playlist
;
224 block
=BL_GetBlockFromPos(playpos
);
225 if(block
==NULL
) return;
227 if(wblock
->l
.num
!=block
->l
.num
){
228 wblock
=ListFindElement1(&window
->wblocks
->l
,block
->l
.num
);
230 root
->setfirstpos
=true;
235 playpos
==root
->song
->length
-1 &&
236 wblock
->curr_realline
==wblock
->num_reallines
241 if(wblock
->curr_realline
==0) root
->setfirstpos
=true;
244 debug("contsong, playpos: %d , root->curr_block: %d\n",playpos
,root
->curr_block
);
247 place
=PlaceGetFirstPos();
250 place
=&wblock
->reallines
[wblock
->curr_realline
]->l
.p
;
251 pc
->seqtime
=-Place2STime(wblock
->block
,place
);
253 debug("contsong, time: %d, playpos: %d , root->curr_block: %d\n",pc
->seqtime
,playpos
,root
->curr_block
);
256 debug("nextline: %d\n",Place2STime(wblock
->block
,place
));
259 PlaySong(place
,playpos
);