home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / tracker-4.13.lha / tracker / Amiga / scroll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-14  |  2.2 KB  |  101 lines

  1. /* amiga/scroll.c
  2.     vi:ts=3 sw=3:
  3.  */
  4.  
  5. /* $Id: scroll.c,v 1.3 1995/02/14 16:51:22 espie Exp espie $
  6.  * $Log: scroll.c,v $
  7.  * Revision 1.3  1995/02/14  16:51:22  espie
  8.  * *** empty log message ***
  9.  *
  10.  * Revision 1.2  1995/02/13  22:05:42  espie
  11.  * Added one space to buffer.
  12.  *
  13.  * Revision 1.1  1995/01/13  13:31:35  espie
  14.  * Initial revision
  15.  *
  16.  */
  17.  
  18. #include <proto/exec.h>
  19.  
  20. #include "defs.h"
  21. #include "extern.h"
  22. #include "amiga/amiga.h"
  23. #include "prefs.h"
  24. ID("$Id")
  25.  
  26. XT unsigned int inhibit_output;
  27.  
  28. LOCAL void init_scroll(void);
  29. LOCAL void (*INIT)(void) = init_scroll;
  30.  
  31. /* the special structure to display lines 
  32.  *    
  33.  */
  34. LOCAL struct MinList scrolls;
  35.  
  36. struct scroll_line
  37.    {
  38.    struct MinNode node;
  39.    char buffer[80];
  40.    };
  41.  
  42. LOCAL void init_scroll()
  43.    {
  44.    NewList(&scrolls);
  45.    }
  46.  
  47. /***
  48.  ***
  49.  ***    Scrolling line handling: 
  50.  ***        note this is totally asynchronous and uses the TYPE_DO_SYNC
  51.  ***        message for synchronizing with songs that are really played
  52.  ***/
  53.  
  54. LOCAL struct scroll_line *scroll_buffer = 0;
  55.  
  56. char *new_scroll(void)
  57.    {
  58.    char *s;
  59.        /* need some temporary storage in case everything is full */
  60.     LOCAL char buffer[80];
  61.  
  62.    INIT_ONCE;
  63.                            /* check for a scroll line available */
  64.    scroll_buffer = RemHead(&scrolls);
  65.    if (!scroll_buffer)     /* none available ? allocate one on the fly */
  66.       scroll_buffer = malloc(sizeof(struct scroll_line));
  67.    if (scroll_buffer)
  68.       s = scroll_buffer->buffer;
  69.    else                    /* still none ? use static buffer */
  70.       s = buffer;
  71.    strcpy(s, "                                                        ");
  72.    return s;
  73.    }
  74.  
  75. /* The actual hook that does all the printing */
  76. LOCAL void do_scroll(VALUE p)  
  77.    {
  78.    struct scroll_line *s = p.pointer;
  79.     
  80.     if (inhibit_output == 0 && get_pref_scalar(PREF_SHOW))
  81.         {
  82.         add_scroller(s->buffer);
  83.       }
  84.     AddTail(&scrolls, s);
  85.    }
  86.  
  87. void scroll()
  88.    {
  89.    struct ext_message *msg;
  90.    
  91.    if (scroll_buffer)        /* did we obtain a scroll line ? */
  92.       {                    /* then set up to scroll it */
  93.       msg = obtain_message();
  94.       msg->data.hook.func = do_scroll;
  95.       msg->data.hook.p.pointer = scroll_buffer;
  96.       send(msg, TYPE_SYNC_DO);
  97.       }
  98.    scroll_buffer = 0;
  99.    }
  100.  
  101.