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 / Amiga / scroll.c < prev    next >
Text File  |  1994-11-24  |  2KB  |  95 lines

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