132
if (tcsetattr (0, TCSAFLUSH, &term) < 0) {
133
fprintf (stderr, "can't reset terminal!\n");
138
if (tcsetattr(0, TCSAFLUSH, &term) < 0) {
139
fprintf(stderr, "can't reset terminal!\n");
208
217
#endif /* HAVE_SIGNAL_H */
221
* from daniel åkerud <daniel.akerud@gmail.com>
222
* date Tue, Jul 28, 2009 at 9:59 AM
224
* Under Cygwin, the read() in process_echoback blocks because VTIME = 0
225
* is not handled correctly. To fix this you can either:
227
* 1. Enable "tty emulation" in Cygwin using an environment variable.
228
* http://www.mail-archive.com/cygwin@cygwin.com/msg99417.html
229
* For me this is _very_ slow and I can see the characters as they are
230
* typed out when running xmp. I have not investigated why this is
231
* happening, but there is of course a reason why this mode is not
232
* enabled by default.
234
* 2. Do a select() before read()ing if the platform is Cygwin.
235
* This makes Cygwin builds work out of the box with no fiddling around,
236
* but does impose a neglectible cpu overhead (for Cygwin builds only).
238
static int stdin_ready_for_reading()
248
FD_SET(STDIN_FILENO, &fds);
250
ret = select(STDIN_FILENO + 1, &fds, NULL, NULL, &tv);
252
if (ret > 0 && FD_ISSET(STDIN_FILENO, &fds))
211
259
static void process_echoback(unsigned long i)
213
261
unsigned long msg = i >> 4;
215
262
static int _pos = -1;
216
263
static int tpo, bpm, nch, _tpo = -1, _bpm = -1;
217
264
static int pos, pat;
218
static int pause = 0;
222
267
if (sigusr == SIGUSR1) {
224
269
xmp_mod_stop(ctx);
226
pause = xmp_mod_pause(ctx);
228
272
} else if (sigusr == SIGUSR2) {
230
274
xmp_mod_stop(ctx);
232
pause = xmp_mod_pause(ctx);
287
int rem = mi.time / 100 - msg;
288
fprintf(stderr, "\r%02d:%02d:%02d.%d ",
289
(int)(msg / (60 * 600)), (int)((msg / 600) % 60),
290
(int)((msg / 10) % 60), (int)(msg % 10));
291
fprintf(stderr, "-%02d:%02d:%02d.%d",
292
(int)(rem / (60 * 600)), (int)((rem / 600) % 60),
293
(int)((rem / 10) % 60), (int)(rem % 10));
241
299
switch (i & 0xf) {
242
300
case XMP_ECHO_BPM:
301
372
case 'q': /* quit */
303
374
xmp_mod_stop(ctx);
305
pause = xmp_mod_pause(ctx);
307
377
case 'f': /* jump to next order */
308
378
xmp_ord_next(ctx);
310
pause = xmp_mod_pause(ctx);
312
381
case 'b': /* jump to previous order */
313
382
xmp_ord_prev(ctx);
315
pause = xmp_mod_pause(ctx);
317
385
case 'n': /* skip to next module */
319
387
xmp_mod_stop(ctx);
321
pause = xmp_mod_pause(ctx);
323
390
case 'p': /* skip to previous module */
325
392
xmp_mod_stop(ctx);
327
pause = xmp_mod_pause(ctx);
329
case ' ': /* pause module */
330
fprintf (stderr, "%s", (pause = xmp_mod_pause(ctx))
331
? "] - PAUSED\b\b\b\b\b\b\b\b\b\b"
332
: "] \b\b\b\b\b\b\b\b\b\b");
395
case ' ': /* paused module */
398
fprintf (stderr, "%s", paused ?
399
"] - PAUSED\b\b\b\b\b\b\b\b\b\b" :
400
"] \b\b\b\b\b\b\b\b\b\b");
370
int main (int argc, char **argv)
439
int main(int argc, char **argv)
372
441
int i, t, lf_flag, first, num_mod, verb = 0;
442
time_t t0, t1, t2, t3;
375
444
struct timeval tv;
376
445
struct timezone tz;
447
xmp_register_event_callback(process_echoback);
518
xmp_register_event_callback(ctx, process_echoback);
449
520
if (opt->verbosity) {
450
fprintf (stderr, "Extended Module Player %s %s\n"
451
"Copyright (C) 1996-2009 Claudio Matsuoka and Hipolito Carraro Jr\n",
452
xmp_version, xmp_date);
454
fprintf(stderr, "OS/2 Port by Kevin Langman (langman@earthling.net)\n" );
521
fprintf(stderr, "Extended Module Player " VERSION "\n"
522
"Copyright (C) 1996-2009 Claudio Matsuoka and Hipolito Carraro Jr\n");
458
525
if (probeonly || (opt->verbosity)) {
572
t = xmp_play_module(ctx);
640
/* Play the module */
642
xmp_player_start(ctx);
649
if (xmp_player_frame(ctx) != 0)
651
xmp_play_buffer(ctx);
656
t = difftime(t3, t2);
574
658
xmp_release_module(ctx);
661
fprintf(stderr, "\r \r");
576
663
if (opt->verbosity && !background) {
578
665
"\rElapsed time : %dmin%02ds %s \n",