home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / MM1 / SOUNDUTILS / mm1_tracker.lzh / TRACKER4.6 / display.c < prev    next >
Text File  |  1994-11-24  |  10KB  |  474 lines

  1. /* display.c 
  2.     vi:ts=3 sw=3:
  3.  */
  4.  
  5. /* $Id: display.c,v 4.3 1994/11/15 16:11:01 espie Exp espie $
  6.  * $Log: display.c,v $
  7.  * Revision 4.3  1994/11/15  16:11:01  espie
  8.  * *** empty log message ***
  9.  *
  10.  *
  11.  * Revision 4.0  1994/01/11  17:45:22  espie
  12.  * Major change: does not use sprintf heavily.
  13.  *
  14.  * Generalized open.c.
  15.  * Use name_of_note(), no need for run_in_fg().
  16.  * Small bug: strcpy -> stringcopy.
  17.  * Cond code to make show/not show robust.
  18.  * Added instrument name as shown per display.c.
  19.  * Major change: use scroller interface.
  20.  * Lots of LOCAL added + minor changes.
  21.  * Try to get rid of %d format in printf.
  22.  */
  23.      
  24. #include <stdio.h>
  25. #include <string.h>
  26.      
  27. #include "defs.h"
  28. #include "song.h"
  29. #include "channel.h"
  30. #include "extern.h"
  31. #include "tags.h"
  32. #include "prefs.h"
  33.  
  34. ID("$Id: display.c,v 4.3 1994/11/15 16:11:01 espie Exp espie $")
  35. LOCAL void init_display P((void));
  36. LOCAL void (*INIT)P((void)) = init_display;
  37.      
  38. #define ENTRY_SIZE 14
  39. LOCAL char buffer[80];
  40. LOCAL char *base;
  41.  
  42. LOCAL char *num[] = {
  43. " 0", " 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9",
  44. "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
  45. "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
  46. "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
  47. "40", "41", "42", "43", "44", "45", "46", "47", "48", "49",
  48. "50", "51", "52", "53", "54", "55", "56", "57", "58", "59",
  49. "60", "61", "62", "63", "64", "65", "66", "67", "68", "69",
  50. "70", "71", "72", "73", "74", "75", "76", "77", "78", "79",
  51. "80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
  52. "90", "91", "92", "93", "94", "95", "96", "97", "98", "99",
  53. "00", "01", "02", "03", "04", "05", "06", "07", "08", "09"};
  54.  
  55. char instname[] = { ' ', '1', '2', '3', '4', '5', '6', '7', '9',
  56. 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
  57. 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
  58.  
  59. LOCAL void reset_buffer()
  60.    {
  61.    base = new_scroll();
  62.    }
  63.  
  64. LOCAL void next_entry()
  65.    {
  66.    base += ENTRY_SIZE;
  67.    }
  68.  
  69. LOCAL void copy1(to, from)
  70. char *to, *from;
  71.    {
  72.    *to = *from;
  73.    }
  74.    
  75. LOCAL void copy2(to, from)
  76. char *to, *from;
  77.    {
  78.    *to++ = *from++;
  79.    *to = *from;
  80.    }
  81.  
  82. LOCAL void copy3(to, from)
  83. char *to, *from;
  84.    {
  85.    *to++ = *from++;
  86.    *to++ = *from++;
  87.    *to = *from;
  88.    }
  89.  
  90. LOCAL void stringcopy(to, from)
  91. char *to, *from;
  92.    {
  93.    while (*from)
  94.       *to++ = *from++;
  95.    }
  96.  
  97. LOCAL void num2(to, n)
  98. char *to;
  99. int n;
  100.    {
  101.    char *v = num[n];
  102.    *to++ = *v++;
  103.    *to = *v;
  104.    }
  105.  
  106. LOCAL void num3(to, n)
  107. char *to;
  108. int n;
  109.    {
  110.    char *v;
  111.  
  112.    if (n >= 100)
  113.       *to = "0123456789"[n/100];
  114.    while (n > 109)
  115.       n -= 100;
  116.    v = num[n];
  117.    to++;
  118.    *to++ = *v++;
  119.    *to = *v;
  120.    }
  121.  
  122. LOCAL void (*table[NUMBER_EFFECTS]) P((int samp, int para, int note, struct channel *ch));
  123.  
  124. LOCAL void disp_default(samp, para, note, ch)
  125. int samp, para, note;
  126. struct channel *ch;
  127.    {
  128.    copy3(base+2, name_of_note(note));
  129.    }
  130.  
  131. LOCAL void disp_speed(samp, para, note, ch)
  132. int samp, para, note;
  133. struct channel *ch;
  134.    {
  135.    copy3(base+2, name_of_note(note));
  136.    if (para < 32)
  137.       {
  138.       stringcopy(base+6, "SPD");
  139.       num2(base+10, para);
  140.       }
  141.    else
  142.       {
  143.       stringcopy(base+6, "spd%");
  144.       num3(base+10, para * 100/NORMAL_FINESPEED);
  145.       }
  146.    }
  147.  
  148. LOCAL void disp_nothing(samp, para, note, ch)
  149. int samp, para, note;
  150. struct channel *ch;
  151.    {
  152.    }
  153.  
  154. LOCAL void disp_portamento(samp, para, note, ch)
  155. int samp, para, note;
  156. struct channel *ch;
  157.    {
  158.    stringcopy(base+2, "-->");
  159.    copy3(base+5, name_of_note(note));
  160.    if (para)
  161.       {
  162.       base[8] = '(';
  163.       num3(base+9, para);
  164.       base[12] = ')';
  165.       }
  166.    }
  167.  
  168. LOCAL void disp_portaslide(samp, para, note, ch)
  169. int samp, para, note;
  170. struct channel *ch;
  171.    {
  172.    stringcopy(base+2, "-->");
  173.    copy3(base+5, name_of_note(note));
  174.    if (LOW(para))
  175.       {
  176.       base[9] = '-';
  177.       num2(base+10, LOW(para));
  178.       }
  179.    else
  180.       {
  181.       base[9] = '+';
  182.       num2(base+10, HI(para));
  183.       }
  184.    }
  185.  
  186. LOCAL void disp_upslide(samp, para, note, ch)
  187. int samp, para, note;
  188. struct channel *ch;
  189.    {
  190.    copy3(base+2, name_of_note(note));
  191.    base[8] = '-';
  192.    if (para)
  193.       num3(base+9, para);
  194.    }
  195.  
  196. LOCAL void disp_downslide(samp, para, note, ch)
  197. int samp, para, note;
  198. struct channel *ch;
  199.    {
  200.    copy3(base+2, name_of_note(note));
  201.    base[8] = '+';
  202.    if (para)
  203.       num3(base+9, para);
  204.    }
  205.  
  206. LOCAL void disp_vibrato(samp, para, note, ch)
  207. int samp, para, note;
  208. struct channel *ch;
  209.    {
  210.    copy3(base+2, name_of_note(note));
  211.    copy2(base+6, "vb");
  212.    if (para)
  213.       {
  214.       num2(base+8, LOW(para));
  215.       base[10] = '/';
  216.       num2(base+11, HI(para));
  217.       }
  218.    }
  219.  
  220. LOCAL void disp_vibratoslide(samp, para, note, ch)
  221. int samp, para, note;
  222. struct channel *ch;
  223.    {
  224.    copy3(base+2, name_of_note(note));
  225.    stringcopy(base+6, "vibs");
  226.    if (LOW(para))
  227.       {
  228.       base[10] = '-';
  229.       num2(base+11, LOW(para));
  230.       }
  231.    else
  232.       {
  233.       base[10] = '+';
  234.       num2(base+11, HI(para));
  235.       }
  236.    }
  237.  
  238. LOCAL void disp_slidevol(samp, para, note, ch)
  239. int samp, para, note;
  240. struct channel *ch;
  241.    {
  242.    copy3(base+2, name_of_note(note));
  243.    stringcopy(base+6, "vol");
  244.    if (LOW(para))
  245.       {
  246.       base[10] = '-';
  247.       num2(base+11, LOW(para));
  248.       }
  249.    else
  250.       if (HI(para))
  251.          {
  252.          base[10] = '+';
  253.          num2(base+11, HI(para));
  254.          }
  255.    }
  256.  
  257. LOCAL void disp_volume(samp, para, note, ch)
  258. int samp, para, note;
  259. struct channel *ch;
  260.    {
  261.    copy3(base+2, name_of_note(note));
  262.    if (para)
  263.       {
  264.       stringcopy(base+6, "vol");
  265.       num3(base+10, para);
  266.       }
  267.    else
  268.       stringcopy(base+6, "silent");
  269.    }
  270.  
  271. LOCAL void disp_arpeggio(samp, para, note, ch)
  272. int samp, para, note;
  273. struct channel *ch;
  274.    {
  275.    if (note != NO_NOTE)
  276.       {
  277.       copy3(base+2, name_of_note(note));
  278.       copy3(base+6, name_of_note(note + LOW(para)));
  279.       copy3(base+10, name_of_note(note + HI(para)));
  280.       }
  281.    else
  282.       if (ch->note == NO_NOTE)
  283.          stringcopy(base, "Arp error");
  284.       else
  285.          {
  286.          copy3(base+6, name_of_note(ch->note + LOW(para)));
  287.          copy3(base+10, name_of_note(ch->note + HI(para)));
  288.          }  
  289.    }
  290.  
  291. LOCAL void disp_retrig(samp, para, note, ch)
  292. int samp, para, note;
  293. struct channel *ch;
  294.    {
  295.    copy3(base+2, name_of_note(note));
  296.    stringcopy(base + 6, "rtg");
  297.    num3(base+9, para);
  298.    }
  299.  
  300. LOCAL void disp_note_cut(samp, para, note, ch)
  301. int samp, para, note;
  302. struct channel *ch;
  303.    {
  304.    copy3(base+2, name_of_note(note));
  305.    stringcopy(base+6, "cut");
  306.    num3(base+9, para);
  307.    }
  308.  
  309. LOCAL void disp_late_start(samp, para, note, ch)
  310. int samp, para, note;
  311. struct channel *ch;
  312.    {
  313.    copy3(base+2, name_of_note(note));
  314.    stringcopy(base+6, "lte");
  315.    num3(base+9, para);
  316.    }
  317.  
  318. LOCAL void disp_offset(samp, para, note, ch)
  319. int samp, para, note;
  320. struct channel *ch;
  321.    {
  322.    copy3(base+2, name_of_note(note));
  323.    stringcopy(base+6, "off   %");
  324.    num3(base+9, para * 25600/ch->samp->length);
  325.    }
  326.  
  327. LOCAL void disp_smooth_up(samp, para, note, ch)
  328. int samp, para, note;
  329. struct channel *ch;
  330.    {
  331.    copy3(base+2, name_of_note(note));
  332.    stringcopy(base+6, "sth-");
  333.    num3(base+10, para);
  334.    }
  335.  
  336. LOCAL void disp_smooth_down(samp, para, note, ch)
  337. int samp, para, note;
  338. struct channel *ch;
  339.    {
  340.    copy3(base+2, name_of_note(note));
  341.    stringcopy(base+6, "sth+");
  342.    num3(base+10, para);
  343.    }
  344.  
  345. LOCAL void disp_smooth_upvolume(samp, para, note, ch)
  346. int samp, para, note;
  347. struct channel *ch;
  348.    {
  349.    copy3(base+2, name_of_note(note));
  350.    stringcopy(base+8, "++");
  351.    num3(base+10, para);
  352.    }
  353.  
  354. LOCAL void disp_smooth_downvolume(samp, para, note, ch)
  355. int samp, para, note;
  356. struct channel *ch;
  357.    {
  358.    copy3(base+2, name_of_note(note));
  359.    stringcopy(base+8, "--");
  360.    num3(base+10, para);
  361.    }
  362.  
  363. LOCAL void disp_change_finetune(samp, para, note, ch)
  364. int samp, para, note;
  365. struct channel *ch;
  366.    {
  367.    copy3(base+2, name_of_note(note));
  368.    stringcopy(base+6, "fine");
  369.    num2(base+11, para);
  370.    }
  371.  
  372. LOCAL void disp_skip(samp, para, note, ch)
  373. int samp, para, note;
  374. struct channel *ch;
  375.    {
  376.    copy3(base+2, name_of_note(note));
  377.    if (para)
  378.       {
  379.       stringcopy(base+6, "skp");
  380.       num3(base+10, para);
  381.       }
  382.    else
  383.       stringcopy(base+6, "next");
  384.    }
  385.  
  386. LOCAL void disp_fastskip(samp, para, note, ch)
  387. int samp, para, note;
  388. struct channel *ch;
  389.    {
  390.    copy3(base+2, name_of_note(note));
  391.    stringcopy(base+6, "ff");
  392.    num3(base+10, para);
  393.    }
  394.  
  395. LOCAL void disp_loop(samp, para, note, ch)
  396. int samp, para, note;
  397. struct channel *ch;
  398.    {
  399.    copy3(base+2, name_of_note(note));
  400.    if (para == 0)
  401.       stringcopy(base+6, "SETLOOP");
  402.    else
  403.       {
  404.       stringcopy(base+6, "LOOP");
  405.       num3(base+10, para);
  406.       }
  407.    }
  408.  
  409. LOCAL void disp_delay_pattern(samp, para, note, ch)
  410. int samp, para, note;
  411. struct channel *ch;
  412.    {
  413.    copy3(base+2, name_of_note(note));
  414.    stringcopy(base+6, "DLAY");
  415.    num3(base+10, para);
  416.    }
  417.  
  418. #define disp_nothing disp_default
  419.  
  420. LOCAL void init_display()
  421.    {
  422.    int i;
  423.  
  424.    for (i = 0; i < NUMBER_EFFECTS; i++)
  425.       table[i] = disp_nothing;
  426.    table[EFF_ARPEGGIO] = disp_arpeggio;
  427.    table[EFF_SPEED] = disp_speed;
  428.    table[EFF_SKIP] = disp_skip;
  429.    table[EFF_FF] = disp_fastskip;
  430.    table[EFF_VOLUME] = disp_volume;
  431.    table[EFF_VOLSLIDE] = disp_slidevol;
  432.    table[EFF_OFFSET] = disp_offset;
  433.    table[EFF_PORTA] = disp_portamento;
  434.    table[EFF_PORTASLIDE] = disp_portaslide;
  435.    table[EFF_UP] = disp_upslide;
  436.    table[EFF_DOWN] = disp_downslide;
  437.    table[EFF_VIBRATO] = disp_vibrato;
  438.    table[EFF_VIBSLIDE] = disp_vibratoslide;
  439.    table[EFF_SMOOTH_UP] = disp_smooth_up;
  440.    table[EFF_SMOOTH_DOWN] = disp_smooth_down;
  441.    table[EFF_CHG_FTUNE] = disp_change_finetune;
  442.    table[EFF_LOOP] = disp_loop;
  443.    table[EFF_RETRIG] = disp_retrig;
  444.    table[EFF_S_UPVOL] = disp_smooth_upvolume;
  445.    table[EFF_S_DOWNVOL] = disp_smooth_downvolume;
  446.    table[EFF_NOTECUT] = disp_note_cut;
  447.    table[EFF_LATESTART] = disp_late_start;
  448.    table[EFF_DELAY] = disp_delay_pattern;
  449.    reset_buffer();
  450.    }
  451.  
  452. void dump_event(ch, e)
  453. struct channel *ch;
  454. struct event *e;
  455.    {
  456.    INIT_ONCE;
  457.    
  458.    if (get_pref_scalar(PREF_SHOW))
  459.       {
  460.       if (ch && base)
  461.          {
  462.          *base = instname[e->sample_number];
  463.          (*table[e->effect])(e->sample_number, e->parameters, e->note, ch);
  464.          next_entry();
  465.          }
  466.       else
  467.          {
  468.          scroll();
  469.          reset_buffer();
  470.          }
  471.       }
  472.    }
  473.  
  474.