home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / e / evsound / !Ev / Source / EvSnd next >
Encoding:
Text File  |  1994-02-26  |  3.7 KB  |  180 lines

  1. /* Front end for EventSound application
  2.  * Front end version 1.00
  3.  * Written in ARM C version 3.0
  4.  * By and (c) Neil A Carson 1993 A.D.
  5.  * FreeWare!
  6.  */
  7.  
  8. #include "baricon.h"
  9. #include "dbox.h"
  10. #include "event.h"
  11. #include "kernel.h"
  12. #include "menu.h"
  13. #include "res.h"
  14. #include "resspr.h"
  15. #include "template.h"
  16. #include "visdelay.h"
  17. #include "werr.h"
  18. #include "wimp.h"
  19. #include "wimpt.h"
  20. #include "win.h"
  21.  
  22. #include <stdlib.h>
  23. #include <string.h>
  24.  
  25. #define event_count 14
  26. #define EvSound_VoiceInfo 0xDFFC1
  27. #define EvSound_WriteVoiceName 0xDFFC2
  28. #define EvSound_WriteTuning 0xDFFC3
  29. #define ins_path_prefix 13
  30.  
  31. int events[event_count] = 
  32. {
  33.     0x4,
  34.     0x6,
  35.     0x9,
  36.     0x27,
  37.     0x2A,
  38.     0x45,
  39.     0x46,
  40.     0x49,
  41.     0x4A,
  42.     0x4D,
  43.     0x4E,
  44.     0x52,
  45.     0x53,
  46.     0x57
  47. };
  48. char voice_string[64] = "Sample";
  49. menu main_menu;
  50. dbox main_win;
  51. char path_prefix[32] = "<Sounds$Dir>.";
  52. int sound_tuning = 0;
  53.  
  54. void show_main(wimp_i);
  55. void main_menu_handler(void *, char *);
  56. void get_filenames(void);
  57. void set_filenames(void);
  58.  
  59. int main(void)
  60. {
  61.     _kernel_swi_regs r;
  62.  
  63.     visdelay_begin();
  64.     trace_on();
  65.     wimpt_init("Event Sounder");
  66.     res_init("EvSound");
  67.     resspr_init();
  68.     template_init();
  69.     baricon("!Ev Sound", (int) resspr_area(), show_main);
  70.     main_menu = menu_new("EvSound", ">Info,Quit");
  71.     event_attachmenu(win_ICONBAR, main_menu, main_menu_handler, 0);
  72.  
  73.     r.r[0] = (int) voice_string;
  74.     _kernel_swi(EvSound_WriteVoiceName, &r, &r);
  75.  
  76.     visdelay_end();
  77.  
  78.     for (;;)
  79.         event_process();
  80. }
  81.  
  82. void main_menu_handler(void *handle, char *hit)
  83. {
  84.     handle = handle; /* Stops compiler warning */
  85.  
  86.     switch (hit[0])
  87.     {
  88.         case 1:
  89.         {
  90.             dbox d = dbox_new("Info");
  91.             dbox_show(d);
  92.             dbox_fillin(d);
  93.             dbox_dispose(&d);
  94.         }
  95.         break;
  96.  
  97.         case 2:
  98.             exit(0);
  99.         break;
  100.     }
  101. }
  102.  
  103. void show_main(wimp_i icon)
  104. {
  105.     BOOL filling = TRUE;
  106.  
  107.     icon = icon;
  108.  
  109.     main_win = dbox_new("Main");
  110.     set_filenames();
  111.     dbox_showstatic(main_win);
  112.  
  113.     while (filling)
  114.     {
  115.         switch (dbox_fillin(main_win))
  116.         {
  117.             case 30:
  118.                 get_filenames();
  119.                 filling = FALSE;
  120.                 dbox_dispose(&main_win);
  121.                 break;
  122.  
  123.             case dbox_CLOSE:
  124.                 filling = FALSE;
  125.                 dbox_dispose(&main_win);
  126.                 break;
  127.         }
  128.     }
  129. }
  130.  
  131. void set_filenames(void)
  132. {
  133.     _kernel_swi_regs r;
  134.     int cnt;
  135.     char *base;
  136.  
  137.     for (cnt=0; cnt<event_count; cnt++)
  138.     {
  139.         r.r[0] = events[cnt];
  140.         _kernel_swi(EvSound_VoiceInfo, &r, &r);
  141.  
  142.         if (r.r[0] == 0) werr(1,"Fatal error: Event not found! Report!");
  143.         base = (char *) (r.r[0] + ins_path_prefix);
  144.         dbox_setfield(main_win, cnt + 16, base);
  145.     }
  146.     dbox_setfield(main_win, 31, voice_string);
  147.     dbox_setnumeric(main_win, 34, sound_tuning);
  148. }
  149.  
  150. void get_filenames(void)
  151. {
  152.     _kernel_swi_regs r;
  153.     int cnt;
  154.     char temp[32];
  155.     int *base;
  156.  
  157.     for (cnt=0; cnt<event_count; cnt++)
  158.     {
  159.         r.r[0] = events[cnt];
  160.         _kernel_swi(EvSound_VoiceInfo, &r, &r);
  161.  
  162.         if (r.r[0] == 0) werr(1,"Fatal error: Event not found! Report!");
  163.         strcpy(&temp[0], path_prefix);
  164.         dbox_getfield(main_win, cnt + 16, &temp[ins_path_prefix],
  165.                       32-ins_path_prefix);
  166.         strncpy((char *) r.r[0], temp, 31);
  167.         if ((temp[ins_path_prefix+1] == 0) || (temp[ins_path_prefix] == 0))
  168.         {
  169.             base = (int *) r.r[0];
  170.             *base= 0;
  171.         }
  172.     }
  173.     dbox_getfield(main_win, 31, voice_string, 63);
  174.     r.r[0] = (int) voice_string;
  175.     _kernel_swi(EvSound_WriteVoiceName, &r, &r);
  176.     sound_tuning = dbox_getnumeric(main_win, 34);
  177.     r.r[0] = sound_tuning;
  178.     _kernel_swi(EvSound_WriteTuning, &r, &r);
  179. }
  180.