home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FreeWare Collection 2
/
FreeSoftwareCollection2pd199x-jp.img
/
tv
/
src
/
tv.c
< prev
Wrap
Text File
|
1990-06-14
|
3KB
|
143 lines
/*
TV Moniter Sample Program
*/
#include <time.h>
#include <egb.h>
#include <mos.h>
#include <snd.h>
#define DSP_X 60
#define DSP_Y 200
#define VOL_ON 0x03E0
#define VOL_OFF 0x7C00
char work[4096];
char mwork[4096];
char para[20];
int old_vol=0;
void Dezi(sw)
int sw;
{
static int dz_flg=0;
static clock_t dz_time;
if ( sw == 1 ) {
EGB_writePage(work,0);
EGB_dezitize(work,1);
EGB_dezitize(work,0);
dz_time = clock() + CLK_TCK * 5; /* 約5秒間表示 */
dz_flg = 1;
} else if ( dz_flg != 0 && (sw == 2 || (sw == 0 && dz_time <= clock())) ){
EGB_writePage(work,0);
EGB_color(work,1,0x8000);
EGB_clearScreen(work);
dz_flg = 0;
}
}
void vol_dsp(vol)
int vol;
{
int i;
int fg=0;
static int dsp_flg=0;
static clock_t dsp_time;
if ( old_vol != vol ) {
EGB_writePage(work,0);
EGB_paintMode(work,0x22);
EGB_color(work,0,VOL_ON);
EGB_color(work,2,VOL_ON);
for ( i = 0 ; i < 20 ; i++ ) {
if ( fg == 0 && vol <= (i * (127 / 20)) ) {
EGB_color(work,0,VOL_OFF);
EGB_color(work,2,VOL_OFF);
fg = 1;
}
WORD(para+0) = DSP_X + i * 10;
WORD(para+2) = DSP_Y;
WORD(para+4) = DSP_X + i * 10 + 8;
WORD(para+6) = DSP_Y + 8;
EGB_rectangle(work,para);
}
old_vol = vol;
dsp_time = clock() + CLK_TCK * 5; /* 約5秒間表示 */
dsp_flg = 1;
}
if ( dsp_flg != 0 && dsp_time < clock() ) {
dsp_flg = 0;
/*************************************
EGB_writePage(work,0);
EGB_paintMode(work,0x22);
EGB_color(work,0,0x8000);
EGB_color(work,2,0x8000);
WORD(para+0) = DSP_X;
WORD(para+2) = DSP_Y;
WORD(para+4) = DSP_X + 208;
WORD(para+6) = DSP_Y + 8;
EGB_rectangle(work,para);
************************************/
EGB_writePage(work,0);
EGB_color(work,1,0x8000);
EGB_clearScreen(work);
}
}
void main()
{
int x,y,sw,pat;
int vol=64;
MOS_start(mwork,4096);
SND_elevol_init();
SND_elevol_all_mute(-1);
SND_elevol_mute(0x0C);
SND_elevol_set(0,vol,vol);
EGB_init(work,4096);
EGB_resolution(work,0,11);
EGB_resolution(work,1,11);
EGB_displayPage(work,0,3);
EGB_writePage(work,0);
EGB_color(work,1,0x8000);
EGB_clearScreen(work);
EGB_writePage(work,1);
EGB_dezitize(work,1);
EGB_writePage(work,0);
do {
SND_joy_in_2(0,&pat); pat ^= 0xFF;
if ( (pat & 0x10) != 0 )
Dezi(1);
if ( (pat & 0x20) != 0 )
Dezi(2);
MOS_rdpos(&sw,&x,&y);
if ( sw == 1 || (pat & 0x06) != 0 ) {
if ( vol > 0 )
vol--;
SND_elevol_set(0,vol,vol);
old_vol = (-1);
}
if ( sw == 2 || (pat & 0x09) != 0 ) {
if ( vol < 127 )
vol++;
SND_elevol_set(0,vol,vol);
old_vol = (-1);
}
Dezi(0);
vol_dsp(vol);
} while ( sw != 3 && (pat & 0xC0) == 0 );
MOS_end();
SND_elevol_init();
EGB_displayPage(work,0,0);
EGB_resolution(work,0,3);
}