home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FreeWare Collection 2
/
FreeSoftwareCollection2pd199x-jp.img
/
tvjack
/
tv2.c
< prev
next >
Wrap
Text File
|
1990-06-14
|
13KB
|
430 lines
/* 魔女っ子愛ちゃんのTV・Jack!*/
#include <EGB.h> /* グラフィック */
#include <mos.h> /* マウス */
#include <stdlib.h>
#include <stdio.h>
#include <snd.h>
#include <spr.h>
typedef unsigned int usint;
char *sbuf; /* スプライトのバッファ */
char *sbuft; /* スプライトのバッファ */
char *sbufa; /* スプライトのバッファ */
char *sbufb; /* スプライトのバッファ */
char *Gbuf16; /* TIF データ16色のバッファ*/
char *Gbuf32; /* TIF データ32K色のバッファ*/
char *mp;
char work[15360]; /* グラフィック作業域 */
char mwork[4096]; /* マウス作業域 */
char para[64];
char swork[16384]; /* サウンド作業域 */
int tifx,tify;
int c,off;
int cx,cy,cb;
int swtv;
void freadb()
{
FILE *fp;
Gbuf16 = malloc(154112);
Gbuf32 = malloc(154112);
sbuft = malloc(3074);
sbufa = malloc(1024);
sbufb = malloc(1024);
fp = fopen("ITEM0.SPR","rb" );
fread(sbuft,1,3074,fp);
fclose(fp);
fp = fopen("ITEMA.SPR","rb" );
fread(sbufa,1,1024,fp);
fclose(fp);
fp = fopen("ITEMB.SPR","rb" );
fread(sbufb,1,1024,fp);
fclose(fp);
fp = fopen("HAIKEI.TIF","rb" );
fread(Gbuf16,1,154112,fp);
fclose(fp);
fp = fopen("TV.TIF","rb" );
fread(Gbuf32,1,154112,fp);
fclose(fp);
}
void freads(fnames,snames)
char *fnames;
char *snames;
{
FILE *fps;
fps = fopen(fnames,"rb" );
fread(sbuf,1,6144,fps);
fclose(fps);
fps = fopen(snames,"rb");
fread(mp,1,3000,fps);
fclose(fps);
*(int *)(mp + 20) = 0;
}
void m_init(n)
int n;
{
MOS_start(mwork,4096);
MOS_disp(n);
MOS_resolution(0,3); /* マウス仮想画面の設定 */
}
void mouse(x,y)
int x,y;
{
MOS_setpos(x,y);
}
int mposx()
{
int bot,x,y;
MOS_rdpos(&bot,&x,&y);
return(x);
}
int mposy()
{
int bot,x,y;
MOS_rdpos(&bot,&x,&y);
return(y);
}
int mposb()
{
int bot,x,y;
MOS_rdpos(&bot,&x,&y);
return(bot);
}
/*アイテムの選択の判断 */
int iselect()
{
int mm,mx,my;
MOS_rdpos(&mm,&mx,&my);
if (mm==1 && 45 <=mx && mx<=124 && 317<=my && my<= 384) return(1);
else if (mm==1 && 153 <=mx && mx<=233 && 317<=my && my<= 384) return(2);
else if (mm==1 && 268 <=mx && mx<=345 && 317<=my && my<= 384) return(3);
else if (mm==1 && 390 <=mx && mx<=466 && 317<=my && my<= 384) return(4);
else if (mm==1 && 507 <=mx && mx<=586 && 317<=my && my<= 384) return(5);
else if (mm==1 && 45 <=mx && mx<=124 && 400<=my && my<= 467) return(6);
else if (mm==1 && 153 <=mx && mx<=233 && 400<=my && my<= 467) return(7);
else if (mm==1 && 268 <=mx && mx<=345 && 400<=my && my<= 467) return(8);
else if (mm==1 && 390 <=mx && mx<=466 && 400<=my && my<= 467) return(9);
else if (mm==1 && 507 <=mx && mx<=586 && 400<=my && my<= 467) return(10);
else if (mm==1 && 5 <=mx && mx<=33 && 380<=my && my<= 400) return(11);
else return(0);
}
/* TIFF or TV 選択判断 */
int tselect()
{
int mm,mx,my;
MOS_rdpos(&mm,&mx,&my);
if (mm==1 && 30 <=mx && mx<=50 && 270<=my && my<= 290) return(1);
else if (mm==1 && 305 <=mx && mx<=325 && 270<=my && my<= 290) return(2);
else return(0);
}
/* TIFF データ出力 */
void put( x1, y1, x2, y2, p)
int x1, y1, x2, y2;
usint p;
{
DWORD(para+0) = p;
WORD(para+4) = 0x14;
WORD(para+6) = x1;
WORD(para+8) = y1;
WORD(para+10) = x2;
WORD(para+12) = y2;
EGB_putBlock( work,0,para );
}
/* TIFF 画面出力 */
void tv32(x1,y1,xy)
int x1,y1,xy;
{
EGB_writeMode(work,0);
EGB_color(work,1,0); /* 背景色 : Black */
EGB_color(work,0,15); /* 前景色 : L_White */
EGB_color(work,3,0); /* 透過色 : BLACK */
EGB_clearScreen(work);
EGB_displayStart(work,1,0,0); /* 仮想画面位置 */
EGB_displayStart(work,0,x1,y1); /* 表示開始位置 */
EGB_displayStart(work,2,xy,xy); /* 画面の拡大 */
EGB_displayStart(work,3,319,239);/* 画面の大きさ */
tifx = *(Gbuf32+31);tifx <<= 8;tifx |= *(Gbuf32+30); /* X Size */
tify = *(Gbuf32+43);tify <<= 8;tify |= *(Gbuf32+42); /* Y Size */
off = *(Gbuf32+0x67);off <<= 8; off |= *(Gbuf32+0x66); /* OFF Size */
for (c=0;c<tify;c++)
{
put(0,c,tifx-1,c,(usint)Gbuf32+off);
off += (tifx * 2);
}
}
/* テレビ画面出力 */
void tv33(x1,y1,xy)
int x1,y1,xy;
{
EGB_clearScreen(work);
EGB_writeMode(work,0);
EGB_color(work,1,0x8000); /* 透過色 : BLACK */
EGB_color(work,0,0x800f); /* 透過色 : BLACK */
EGB_color(work,3,0x8000); /* 透過色 : BLACK */
EGB_displayStart(work,1,0,0); /* 仮想画面位置 */
EGB_displayStart(work,0,x1,y1); /* 表示開始位置 */
EGB_displayStart(work,2,xy,xy); /* 画面の拡大 */
EGB_displayStart(work,3,319,239);/* 画面の大きさ */
EGB_superImpose(work,0x81);
EGB_clearScreen(work);
}
/* 初期画面出力 */
void firstg()
{
tifx = *(Gbuf16+31);tifx <<= 8;tifx |= *(Gbuf16+30); /* X Size */
tify = *(Gbuf16+43);tify <<= 8;tify |= *(Gbuf16+42); /* Y Size */
off = *(Gbuf16+0x67);off <<= 8; off |= *(Gbuf16+0x66); /* OFF Size*/
if (tifx%2) tifx++;
for (c=0;c<tify;c++)
{
put(0,c,tifx-1,c,(usint)Gbuf16+off);
off += (tifx / 2);
}
}
/* グラフィックの初期化 */
void g_init(p1,p2)
int p1,p2;
{
EGB_init(work,15360);
EGB_resolution(work,0,p1);
EGB_resolution(work,1,p2);
}
/* 1/4画面出力 */
void tvon()
{
EGB_color(work,0,0x8000);
EGB_color(work,1,0x8000);
EGB_color(work,2,0x8000);
EGB_paintMode(work,0x22);
WORD(para+0)=30;
WORD(para+2)=100;
WORD(para+4)=325;
WORD(para+6)=254;
EGB_rectangle(work,para);
}
/* TV OR TIFF 判断処理メイン */
void itemslct()
{
int it1;
g_init(3,10); /* 初期化 */
EGB_displayPage(work,0,1); /* 表示ページの指定 */
EGB_writePage(work,0); /* Write to Page 0 */
firstg(); /* 初期画面出力 */
if(swtv == 1)
{
tvon();
EGB_writePage(work,1);
tv32(20,17,1);
}
if(swtv == 2)
{
tvon();
EGB_writePage(work,1);
tv33(20,17,1);
}
m_init(1); /* マウスの初期化 */
if(swtv == 0)
{
do {
it1 = tselect();
if(it1 == 1)
{
tvon();
EGB_writePage(work,1); /* Write to Page 1 */
swtv = 1;
tv32(20,17,1); /* テレビ画面出力1/4 */
}
if(it1 == 2)
{
tvon();
EGB_writePage(work,1); /* Write to Page 1 */
swtv = 2;
tv33(20,17,1); /* テレビ画面出力1/4 */
}
}while(it1 == 0);
}
EGB_displayPage(work,0,3);
}
/* 効果音 */
void sdplay()
{
SND_pcm_play(64,64,127,mp); /* 再生 */
while(0 != SND_pcm_status(64)); /* 再生状態のチェック */
}
/* 効果音出力とスプライトON/OFF */
void sdplays()
{
sdplay();
SPR_display(1,320);
SPR_display(2,320);
}
/* テレビ画面で遊ぶ処理 */
void tvplay(target)
int target;
{
MOS_end(); /*マウス動作終了の設定*/
g_init(11,8); /* 初期化 */
EGB_displayPage(work,1,3); /* 表示ページの指定 */
EGB_writePage(work,0); /* Write to Page 0 */
if (swtv == 1) tv32(0,0,2);
if (swtv == 2) tv33(0,0,2);
m_init(0);
EGB_writePage(work,1); /* Write to Page 0 */
EGB_clearScreen(work);
EGB_colorIGRB(work,3,0x00000000); /* 透過色 : BLACK */
WORD(para+0) = 0;
WORD(para+2) = 0;
WORD(para+4) = 255;
WORD(para+6) = 239;
EGB_viewport(work,para);
EGB_displayStart(work,0,32,0);
EGB_displayStart(work,1,0,0);
EGB_displayStart(work,2,2,2);
EGB_displayStart(work,3,255,239);
SPR_init();
SPR_define(1,820,3,2,sbuft);
if (target == 1 || target == 3 || target == 5)
{
SPR_define(1,844,1,1,sbufa+512);
SPR_define(1,848,1,1,sbufa);
SPR_setAttribute(844,1,1,0x034c,0x0d00);
SPR_setAttribute(848,1,1,0x0350,0x0d00);
}
if (target == 2 || target == 4 || target == 9)
{
SPR_define(1,844,1,1,sbufb+512);
SPR_define(1,848,1,1,sbufb);
SPR_setAttribute(844,1,1,0x034c,0x0d00);
SPR_setAttribute(848,1,1,0x0350,0x0d00);
}
SPR_define(1,868,3,2,sbuf);
SPR_define(1,892,3,2,sbuf+3072);
SPR_setAttribute(868,3,2,0x0364,0x0d00);
SPR_setAttribute(820,3,2,0x0334,0x0d00);
SPR_setAttribute(892,3,2,0x037c,0x0d00);
SPR_display(1,320);
do{
cx=mposx();cy=mposy();
SPR_display(2,320);
if(target==0 || target==3 || target==4 || target==5 || target==9)
SPR_setPosition(0x00,868,3,2,cx/2,cy/2);
if(target == 1 || target == 2)
{
SPR_setPosition(0x00,820,3,2,cx/2,cy/2);
SPR_setPosition(0x00,868,3,2,215,cy/2);
}
cb=mposb();
if(cb == 1)
{
if(target != 0)sdplay();
if(target == 0 || target == 3 || target == 4 || target == 5)
SPR_setPosition(0x00,892,3,2,cx/2+30,cy/2-30);
if(target == 3 || target == 4)
SPR_setPosition(0x00,844,1,1,cx/2+24,cy/2-4);
if(target == 9)
{
SPR_setPosition(0x00,892,3,2,cx/2+6,cy/2-30);
SPR_setPosition(0x00,844,1,1,cx/2,cy/2-4);
}
if(target == 5)
{
SPR_setPosition(0x00,844,1,1,cx/2+24,cy/2-4);
sdplays();
SPR_setPosition(0x00,844,1,1,cx/2+44,cy/2-4);
sdplays();
SPR_setPosition(0x00,844,1,1,cx/2+4,cy/2-4);
sdplays();
SPR_setPosition(0x00,844,1,1,cx/2+24,cy/2+16);
sdplays();
SPR_setPosition(0x00,844,1,1,cx/2+24,cy/2-24);
sdplays();
SPR_setPosition(0x00,844,1,1,cx/2+44,cy/2-24);
sdplays();
SPR_setPosition(0x00,844,1,1,cx/2+44,cy/2+16);
sdplays();
SPR_setPosition(0x00,844,1,1,cx/2+4,cy/2+16);
sdplays();
SPR_setPosition(0x00,844,1,1,cx/2+4,cy/2-24);
sdplays();
}
if(target == 1 || target == 2)
{
SPR_setPosition(0x00,848,1,1,214,cy/2+8);
SPR_setPosition(0x00,892,3,2,220,cy/2-20);
for(c=0;c<51-cx/8;c++)
{
SPR_setMotion(848,1,1,-4,0);
SPR_display(1,320);
SPR_display(2,320);
}
SPR_setPosition(0x00,844,1,1,cx/2+16,cy/2+8);
}
}
SPR_display(1,320);
}while(cb != 3);
SPR_display(0,320);
MOS_end(); /*マウス動作終了の設定*/
itemslct();
}
/* メイン処理 */
void main()
{
int swg;
freadb();
SND_init(swork);
SND_pcm_mode_set(8); /* 音声モードチャンネルの設定 */ SND_volume_change(64,127); /* チャンネル音量設定 */
SND_elevol_all_mute(0); /* オールミュート */
SND_elevol_mute(1); /* 電子ボリュームミュート設定 */
SND_elevol_all_mute(1); /* オールミュート */
swtv = 0;
itemslct();
sbuf = malloc(6144);
mp = malloc(3000);
do {
swg = iselect();
if(swg == 1) {freads("item1.spr","KOKA1.SND");tvplay(1);}
else if(swg == 2) {freads("item2.spr","KOKA1.SND");tvplay(2);}
else if(swg == 3) {freads("item3.spr","KOKA1.SND");tvplay(3);}
else if(swg == 4) {freads("item4.spr","KOKA1.SND");tvplay(4);}
else if(swg == 5) {freads("item5.spr","KOKA1.SND");tvplay(5);}
else if(swg == 6) {freads("item6.spr","KOKA1.SND");tvplay(0);}
else if(swg == 7) {freads("item7.spr","KOKA1.SND");tvplay(0);}
else if(swg == 8) {freads("item8.spr","KOKA1.SND");tvplay(4);}
else if(swg == 9) {freads("item9.spr","KOKA1.SND");tvplay(9);}
else if(swg == 10) {freads("item10.spr","KOKA1.SND");tvplay(4);}
}while(swg != 11);
free(mp);
SND_end();
MOS_end(); /*マウス動作終了の設定*/
}