[xmp] Fix information update

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
master
Claudio Matsuoka 14 years ago
parent 4002715991
commit eb63788f35
  1. 3
      src/common.h
  2. 17
      src/info.c
  3. 11
      src/main.c

@ -34,8 +34,9 @@ int reset_tty(void);
/* info */ /* info */
void info_mod(struct xmp_module_info *); void info_mod(struct xmp_module_info *);
void info_frame_init(struct xmp_module_info *);
void info_frame(struct xmp_module_info *, struct control *, int); void info_frame(struct xmp_module_info *, struct control *, int);
void info_instruments_compact(struct xmp_module_info *); void info_instruments(struct xmp_module_info *);
void info_help(void); void info_help(void);
/* commands */ /* commands */

@ -43,26 +43,25 @@ void info_mod(struct xmp_module_info *mi)
((mi->total_time + 500) / 1000) % 60); ((mi->total_time + 500) / 1000) % 60);
} }
void info_frame_init(struct xmp_module_info *mi)
{
max_channels = 0;
}
void info_frame(struct xmp_module_info *mi, struct control *ctl, int reset) void info_frame(struct xmp_module_info *mi, struct control *ctl, int reprint)
{ {
static int ord = -1, tpo = -1, bpm = -1; static int ord = -1, tpo = -1, bpm = -1;
int time; int time;
if (reset) {
ord = -1;
max_channels = -1;
}
if (mi->virt_used > max_channels) if (mi->virt_used > max_channels)
max_channels = mi->virt_used; max_channels = mi->virt_used;
if (!reset && mi->frame != 0) if (!reprint && mi->frame != 0)
return; return;
time = mi->current_time / 100; time = mi->current_time / 100;
if (mi->order != ord || mi->bpm != bpm || mi->tempo != tpo) { if (reprint || mi->order != ord || mi->bpm != bpm || mi->tempo != tpo) {
printf("\rTempo[%02X] BPM[%02X] Pos[%02X/%02X] " printf("\rTempo[%02X] BPM[%02X] Pos[%02X/%02X] "
"Pat[%02X/%02X] Row[ / ] Chn[ / ] 0:00:00.0", "Pat[%02X/%02X] Row[ / ] Chn[ / ] 0:00:00.0",
mi->tempo, mi->bpm, mi->tempo, mi->bpm,
@ -89,7 +88,7 @@ void info_frame(struct xmp_module_info *mi, struct control *ctl, int reset)
fflush(stdout); fflush(stdout);
} }
void info_instruments_compact(struct xmp_module_info *mi) void info_instruments(struct xmp_module_info *mi)
{ {
int i, j; int i, j;
struct xmp_module *mod = mi->mod; struct xmp_module *mod = mi->mod;

@ -42,7 +42,7 @@ static void show_info(int what, struct xmp_module_info *mi)
info_help(); info_help();
break; break;
case 'i': case 'i':
info_instruments_compact(mi); info_instruments(mi);
break; break;
case 'm': case 'm':
info_mod(mi); info_mod(mi);
@ -159,7 +159,7 @@ int main(int argc, char **argv)
skipprev = 0; skipprev = 0;
if (xmp_player_start(handle, options.start, 44100, 0) == 0) { if (xmp_player_start(handle, options.start, 44100, 0) == 0) {
int refresh_line = 1; int refresh_line;
/* Mute channels */ /* Mute channels */
@ -175,11 +175,14 @@ int main(int argc, char **argv)
info_mod(&mi); info_mod(&mi);
} }
if (options.verbose == 2) { if (options.verbose == 2) {
info_instruments_compact(&mi); info_instruments(&mi);
} }
/* Play module */ /* Play module */
refresh_line = 1;
info_frame_init(&mi);
while (!options.info && xmp_player_frame(handle) == 0) { while (!options.info && xmp_player_frame(handle) == 0) {
int old_loop = mi.loop_count; int old_loop = mi.loop_count;
@ -188,6 +191,8 @@ int main(int argc, char **argv)
break; break;
info_frame(&mi, &control, refresh_line); info_frame(&mi, &control, refresh_line);
refresh_line = 0;
sound->play(mi.buffer, mi.buffer_size); sound->play(mi.buffer, mi.buffer_size);
if (options.out_file) { if (options.out_file) {

Loading…
Cancel
Save