home *** CD-ROM | disk | FTP | other *** search
/ FreeWare Collection 2 / FreeSoftwareCollection2pd199x-jp.img / tv / src / tv.c < prev   
Text File  |  1990-06-14  |  3KB  |  143 lines

  1. /*
  2.     TV Moniter Sample Program
  3. */
  4.  
  5. #include    <time.h>
  6. #include    <egb.h>
  7. #include    <mos.h>
  8. #include    <snd.h>
  9.  
  10. #define    DSP_X    60
  11. #define    DSP_Y    200
  12. #define    VOL_ON    0x03E0
  13. #define    VOL_OFF    0x7C00
  14.  
  15. char    work[4096];
  16. char    mwork[4096];
  17. char    para[20];
  18. int        old_vol=0;
  19.  
  20. void    Dezi(sw)
  21. int    sw;
  22. {
  23.     static int     dz_flg=0;
  24.     static clock_t dz_time;
  25.  
  26.     if ( sw == 1 ) {
  27.     EGB_writePage(work,0);
  28.     EGB_dezitize(work,1);
  29.     EGB_dezitize(work,0);
  30.     dz_time = clock() + CLK_TCK * 5;    /* 約5秒間表示 */
  31.     dz_flg = 1;
  32.     } else if ( dz_flg != 0 && (sw == 2 || (sw == 0 && dz_time <= clock())) ){
  33.     EGB_writePage(work,0);
  34.         EGB_color(work,1,0x8000);
  35.         EGB_clearScreen(work);
  36.     dz_flg = 0;
  37.     }
  38. }
  39.  
  40. void    vol_dsp(vol)
  41. int    vol;
  42. {
  43.     int     i;
  44.     int     fg=0;
  45.     static int     dsp_flg=0;
  46.     static clock_t dsp_time;
  47.  
  48.     if ( old_vol != vol ) {
  49.     EGB_writePage(work,0);
  50.     EGB_paintMode(work,0x22);
  51.     EGB_color(work,0,VOL_ON);
  52.     EGB_color(work,2,VOL_ON);
  53.     for ( i = 0 ; i < 20 ; i++ ) {
  54.         if ( fg == 0 && vol <= (i * (127 / 20)) ) {
  55.         EGB_color(work,0,VOL_OFF);
  56.         EGB_color(work,2,VOL_OFF);
  57.         fg = 1;
  58.         }
  59.         WORD(para+0) = DSP_X + i * 10; 
  60.         WORD(para+2) = DSP_Y;
  61.         WORD(para+4) = DSP_X + i * 10 + 8; 
  62.         WORD(para+6) = DSP_Y + 8;
  63.         EGB_rectangle(work,para);
  64.     }
  65.     old_vol = vol;
  66.     dsp_time = clock() + CLK_TCK * 5;    /* 約5秒間表示 */
  67.     dsp_flg = 1;
  68.     }
  69.     if ( dsp_flg != 0 && dsp_time < clock() ) {
  70.     dsp_flg = 0;
  71. /*************************************
  72.     EGB_writePage(work,0);
  73.     EGB_paintMode(work,0x22);
  74.     EGB_color(work,0,0x8000);
  75.     EGB_color(work,2,0x8000);
  76.     WORD(para+0) = DSP_X; 
  77.     WORD(para+2) = DSP_Y;
  78.     WORD(para+4) = DSP_X + 208; 
  79.     WORD(para+6) = DSP_Y + 8;
  80.     EGB_rectangle(work,para);
  81. ************************************/
  82.     EGB_writePage(work,0);
  83.         EGB_color(work,1,0x8000);
  84.         EGB_clearScreen(work);
  85.     }
  86. }
  87.  
  88. void    main()
  89. {
  90.     int     x,y,sw,pat;
  91.     int     vol=64;
  92.  
  93.     MOS_start(mwork,4096);
  94.     SND_elevol_init();
  95.     SND_elevol_all_mute(-1);
  96.     SND_elevol_mute(0x0C);
  97.     SND_elevol_set(0,vol,vol);
  98.  
  99.     EGB_init(work,4096);
  100.     EGB_resolution(work,0,11);
  101.     EGB_resolution(work,1,11);
  102.     EGB_displayPage(work,0,3);
  103.  
  104.     EGB_writePage(work,0);
  105.     EGB_color(work,1,0x8000);
  106.     EGB_clearScreen(work);
  107.  
  108.     EGB_writePage(work,1);
  109.     EGB_dezitize(work,1);
  110.     EGB_writePage(work,0);
  111.  
  112.     do {
  113.     SND_joy_in_2(0,&pat); pat ^= 0xFF;
  114.     if ( (pat & 0x10) != 0 )
  115.         Dezi(1);
  116.     if ( (pat & 0x20) != 0 )
  117.         Dezi(2);
  118.  
  119.     MOS_rdpos(&sw,&x,&y);
  120.     if ( sw == 1 || (pat & 0x06) != 0 ) {
  121.         if ( vol > 0 )
  122.         vol--;
  123.         SND_elevol_set(0,vol,vol);
  124.         old_vol = (-1);
  125.     }
  126.     if ( sw == 2 || (pat & 0x09) != 0 ) {
  127.         if ( vol < 127 )
  128.         vol++;
  129.         SND_elevol_set(0,vol,vol);
  130.         old_vol = (-1);
  131.     }
  132.  
  133.     Dezi(0);
  134.     vol_dsp(vol);
  135.  
  136.     } while ( sw != 3 && (pat & 0xC0) == 0 );
  137.  
  138.     MOS_end();
  139.     SND_elevol_init();
  140.     EGB_displayPage(work,0,0);
  141.     EGB_resolution(work,0,3);
  142. }
  143.