home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FreeWare Collection 2
/
FreeSoftwareCollection2pd199x-jp.img
/
tvball
/
tvball2.c
< prev
next >
Wrap
Text File
|
1990-06-14
|
17KB
|
499 lines
/* 魔女っ子愛ちゃんのTV・Jack!野球編*/
#include <EGB.h> /* グラフィック */
#include <stdlib.h>
#include <stdio.h>
#include <mos.h> /* マウス */
#include <string.h>
#include <spr.h>
#define GworkSize 15360 /* グラフィック作業域のサイズ */
char *fnng;
char *fnns;
char *sbuf; /* スプライトのバッファ */
char *Gbuf32; /* TIF データ32K色のバッファ*/
char line[80];
char work[GworkSize]; /* グラフィック作業域 */
char mwork[4096]; /* マウス作業域 */
char para[640];
int y,xxx;
int tifx,tify;
int c,off;
int swtv,swen,swdate;
typedef unsigned int usint;
/* テレビ画面出力 */
void m_init(n)
int n;
{MOS_start(mwork,4096);MOS_disp(n);MOS_resolution(0,11);}
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);}
void g_init(p1,p2)
int p1,p2;
{
EGB_init(work,15360);
EGB_resolution(work,0,p1);
EGB_resolution(work,1,p2);
}
void freads(fnames)
char *fnames;
{
if(fnames != fnns)
{
FILE *fps;
fps = fopen(fnames,"rb" );
fread(sbuf,1,2048,fps);
fclose(fps);
fnns = fnames;
}
}
void freadb(fnamew)
char *fnamew;
{
if(fnamew != fnng)
{
FILE *fp;
fp = fopen(fnamew,"rb" );
fread(Gbuf32,1,154112,fp);
fclose(fp);
fnng = fnamew;
}
}
/* 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 );
}
void
textdisp(x,y,text)
int x,y; /* 表示位置 l:テキスト文字数 */
char *text; /* テキスト格納アドレス */
{
EGB_textDirection(work,0); /* 文字方向の設定(右) */
EGB_textDisplayDirection(work,0); /*表示方向の設定(右) */
EGB_textSpace(work,0); /* 文字間の設定(1ドット) */
EGB_textZoom(work,0,8,16); /* ANK */
EGB_textZoom(work,1,16,16); /* KANJI */
EGB_fontStyle(work,0);
unsigned int sl ;
WORD( para+0 ) = x ; /* X Point */
WORD( para+2 ) = y ; /* Y Point */
sl = strlen( text ) ;
WORD( para+4 ) = sl-1 ;
strcpy( para+6,text ) ;
EGB_sjisString( work,para ) ; /* 文字表示 */
}
int iselect()
{
int mmi,mxi,myi;
MOS_rdpos(&mmi,&mxi,&myi);
if (mmi==1 && 45 <=mxi && mxi<=75 && 120<=myi && myi<= 145) return(1);
else if(mmi==1 && 85 <=mxi && mxi<=115 && 120<=myi && myi<= 145) return(2);
else if(mmi==1 && 125 <=mxi && mxi<=155 && 120<=myi && myi<= 145) return(3);
else if(mmi==1 && 165 <=mxi && mxi<=195 && 120<=myi && myi<= 145) return(4);
else if(mmi==1 && 205 <=mxi && mxi<=235 && 120<=myi && myi<= 145) return(5);
else if(mmi==1 && 245 <=mxi && mxi<=275 && 120<=myi && myi<= 145) return(6);
else if(mmi==1 && 45 <=mxi && mxi<=75 && 150<=myi && myi<= 175) return(7);
else if(mmi==1 && 85 <=mxi && mxi<=115 && 150<=myi && myi<= 175) return(8);
else if(mmi==1 && 125 <=mxi && mxi<=155 && 150<=myi && myi<= 175) return(9);
else if(mmi==1 && 165 <=mxi && mxi<=195 && 150<=myi && myi<= 175)return(10);
else if(mmi==1 && 205 <=mxi && mxi<=235 && 150<=myi && myi<= 175)return(11);
else if(mmi==1 && 245 <=mxi && mxi<=275 && 150<=myi && myi<= 175)return(12);
else if(mmi==1 && 258 <=mxi && mxi<=272 && 97<=myi && myi<= 111)return(13);
else if(mmi==1 && 30 <=mxi && mxi<=45 && 96<=myi && myi<= 111)
{swdate=1;textdisp(197,112,"月日程");return(0);}
else return(0);
}
int nselect()
{
int mm,mx,my;
MOS_rdpos(&mm,&mx,&my);
if (mm==1 && 85 <=mx && mx<=107 && 180<=my && my<= 207)return(0);
else if (mm==1 && 108 <=mx && mx<=123 && 180<=my && my<= 207)return(1);
else if (mm==1 && 124 <=mx && mx<=142 && 180<=my && my<= 207)return(2);
else if (mm==1 && 143 <=mx && mx<=160 && 180<=my && my<= 207)return(3);
else if (mm==1 && 161 <=mx && mx<=177 && 180<=my && my<= 207)return(4);
else if (mm==1 && 178 <=mx && mx<=196 && 180<=my && my<= 207)return(5);
else if (mm==1 && 197 <=mx && mx<=215 && 180<=my && my<= 207)return(6);
else if (mm==1 && 216 <=mx && mx<=233 && 180<=my && my<= 207)return(7);
else if (mm==1 && 234 <=mx && mx<=250 && 180<=my && my<= 207)return(8);
else if (mm==1 && 251 <=mx && mx<=275 && 180<=my && my<= 207)return(9);
else if (mm==2)return(10);
else return(11);
}
/* TIFF 画面出力 */
void tv32(x1,y1,xy)
int x1,y1,xy;
{
EGB_init( work,GworkSize ) ; /* EGB 初期化 */
EGB_resolution( work,0,11 ) ;
EGB_resolution( work,1,11 ) ;
EGB_displayPage(work,0,3); /* 表示ページの指定 ( 0 & 1 p:0 ) */
EGB_writePage( work,0 ) ; /* Write to Page 0 */
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 tv34(x1,y1,xy,wp)
int x1,y1,xy,wp;
{
EGB_writePage( work,wp ) ; /* Write to Page 0 */
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 g_init_32k()
{
EGB_init( work,GworkSize ) ; /* EGB 初期化 */
EGB_resolution( work,0,11 ) ;
EGB_resolution( work,1,11 ) ;
EGB_writePage( work,0 ) ; /* Write to Page 0 */
EGB_writeMode( work,0 ) ;
EGB_color( work,1,0x8000) ; /* 背景色 : Black */
EGB_color( work,0,0x7fff) ; /* 前景色 : L_White */
EGB_color(work,3,0x8000); /* 透過色 : BLACK */
EGB_clearScreen( work ) ;
EGB_displayStart( work,1,0,0 ) ;/* 仮想画面位置 */
EGB_displayStart( work,0,0,0 ) ;/* 表示開始位置 */
EGB_displayStart( work,2,2,2 ) ;/* 画面の拡大 */
EGB_displayStart( work,3,319,239 ) ;/* 画面の大きさ */
}
void txtdisp(fnames)
char *fnames;
{
FILE *fp;
g_init_32k() ; /* 初期化 */
m_init(0);
EGB_displayPage(work,0,3); /* 表示ページの指定 ( 0 & 1 p:0 ) */
EGB_writePage(work,1); /* Write to Page 0 */
tv33(0,0,2);
EGB_writePage(work,0); /* Write to Page 0 */
/* テキスト表示の初期化 */
EGB_writeMode(work,0); /* 書き込みモードの設定(pset) */
EGB_color( work,0,0x70ff); /* 前景色 : L_White */
EGB_textDirection(work,0); /* 文字方向の設定(右) */
EGB_textDisplayDirection(work,0); /*表示方向の設定(右) */
EGB_textSpace(work,0); /* 文字間の設定(1ドット) */
EGB_textZoom(work,0,8,16); /* ANK */
EGB_textZoom(work,1,16,16); /* KANJI */
EGB_fontStyle(work,0);
y = 30;
if((fp = fopen(fnames,"rt"))!=NULL)
{
do
{
while(fgets(line,80,fp)!=NULL)
{
EGB_color( work,0,0x03e0) ; /* 前景色 : L_White */
textdisp(20,y,line);
y=y+16;
}
}while(mposb()!=3);
fclose(fp);
}
else
{
do
{
EGB_color( work,0,0x03e0) ; /* 前景色 : L_White */
if(swdate==0)textdisp(20,30,"該当の選手はデータベースにありません");
else textdisp(20,30,"該当の日程表はありません");
}while(mposb()!=3);
}
MOS_end(); /*マウス動作終了の設定*/
}
/* お面機能 */
void tvplai()
{
int cx,cy,cb;
MOS_end(); /*マウス動作終了の設定*/
g_init(11,8); /* 初期化 */
EGB_displayPage(work,1,3); /* 表示ページの指定 */
EGB_writePage(work,0); /* Write to Page 0 */
tv33(0,0,2);
MOS_start(mwork,4096);
MOS_disp(0);
MOS_resolution(0,8); /* マウス仮想画面の設定 */
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,868,2,2,sbuf);
SPR_setAttribute(868,2,2,0x0364,0x0d00);
SPR_display(1,320);
do{
cx=mposx();cy=mposy();
SPR_display(2,320);
SPR_setPosition(0x00,868,2,2,cx,cy);
cb=mposb();
SPR_display(1,320);
}while(cb != 3);
SPR_display(0,32);
MOS_end(); /*マウス動作終了の設定*/
}
/* ストライクゾーン表示 */
void tvplay()
{
int x1,y1,swpl,xx1,xx2,yy1,yy2;
g_init_32k() ; /* 初期化 */
m_init(1);
EGB_displayPage(work,0,1); /* 表示ページの指定 ( 0 & 1 p:0 ) */
EGB_writePage(work,0); /* Write to Page 0 */
tv33(0,0,2);
do{
MOS_end(); /*マウス動作終了の設定*/
m_init(1);
MOS_color(0,0x7fff);
EGB_writePage( work,1 ) ; /* Write to Page 0 */
EGB_writeMode( work,0 ) ;
EGB_color( work,1,0x8000) ; /* 背景色 : Black */
EGB_color( work,0,0x7fff) ; /* 前景色 : L_White */
EGB_color(work,3,0x8000); /* 透過色 : BLACK */
EGB_clearScreen( work ) ;
EGB_displayPage(work,0,3); /* 表示ページの指定 ( 0 & 1 p:0 ) */
do{MOS_rdpos(&swpl,&x1,&y1);}while(swpl==1);
do{MOS_rdpos(&swpl,&x1,&y1);}while(swpl!=1);
xx1=x1;yy1=y1;
WORD(para+0)=1;
WORD(para+2)=xx1;
WORD(para+4)=yy1;
EGB_pset(work,para);
do{MOS_rdpos(&swpl,&x1,&y1);}while(swpl!=0);
do{MOS_rdpos(&swpl,&x1,&y1);}while(swpl!=1);
xx2=x1;yy2=y1;
WORD(para+0)=1;
WORD(para+2)=xx2;
WORD(para+4)=yy2;
EGB_pset(work,para);
EGB_clearScreen( work ) ;
WORD(para+0)=xx1;
WORD(para+2)=yy1;
WORD(para+4)=xx2;
WORD(para+6)=yy2;
EGB_rectangle(work,para);
MOS_setpos((xx1+xx2)/2,(yy1+yy2)/2);
do{MOS_rdpos(&swpl,&x1,&y1);}while(swpl!=0);
MOS_disp(0); /*マウス動作終了の設定*/
do{
MOS_rdpos(&swpl,&x1,&y1);
EGB_color(work,0,0x8000) ; /* 前景色 : L_White */
EGB_rectangle(work,para);
EGB_color( work,0,0x7fff) ; /* 前景色 : L_White */
WORD(para+0)=x1-(xx2-xx1)/2;
WORD(para+2)=y1-(yy2-yy1)/2;
WORD(para+4)=x1+(xx2-xx1)/2;
WORD(para+6)=y1+(yy2-yy1)/2;
EGB_rectangle(work,para);
EGB_rectangle(work,para);
EGB_rectangle(work,para);
}while(swpl==0);
if(swpl==2)
do{swpl=mposb();}while(swpl==0 || swpl==2);
}while(swpl!=3);
}
/* 花火機能 */
void tvplay1(f1,f2)
char *f1,*f2;
{
int x1,y1,swpl,cc;
m_init(0);
EGB_init( work,GworkSize ) ; /* EGB 初期化 */
EGB_resolution( work,0,11 ) ;
EGB_resolution( work,1,11 ) ;
freadb(f1);
tv34(0,0,2,0);
EGB_displayPage(work,0,1); /* 表示ページの指定 ( 0 & 1 p:0 ) */
freadb(f2);
tv34(0,0,2,1);
EGB_displayPage(work,0,2); /* 表示ページの指定 ( 0 & 1 p:0 ) */
do{
for (cc=0;cc<10;cc++)
{EGB_displayPage(work,0,1);} /* 表示ページの指定 ( 0 & 1 p:0 ) */
for (cc=0;cc<10;cc++)
{EGB_displayPage(work,0,2);} /* 表示ページの指定 ( 0 & 1 p:0 ) */
MOS_rdpos(&swpl,&x1,&y1);
}while(swpl!=3);
}
/* メイン処理 */
void main()
{
Gbuf32 = malloc(154112);
sbuf = malloc(2048);
char flnm[100];
int sw,swtb;
swen = 0;
do
{
g_init_32k() ; /* 初期化 */
m_init(1);
EGB_displayPage(work,0,1); /* 表示ページの指定 ( 0 & 1 p:0 ) */
EGB_writePage(work,0); /* Write to Page 0 */
tv33(0,0,2);
do{sw = mposb();}while(sw==0);
if(sw==2)
{
MOS_end(); /*マウス動作終了の設定*/
freadb("tv1.tif");
tv32(0,0,2);
m_init(1);
do{swtv = iselect();
}while (swtv==0);
EGB_color(work,0,0x0000); /* 前景色 : 黒*/
if(swtv==1){freads("ai.spr");tvplai();} /*愛のお面*/
if(swtv==2){freads("oh.spr");tvplai();} /*王選手のお面*/
if(swtv==3){freads("nagasima.spr");tvplai();} /*長島選手のお面*/
if(swtv==4){freads("kakefu.spr");tvplai();} /*掛布選手のお面*/
if(swtv==5){freads("egawa.spr");tvplai();} /*江川選手のお面*/
if(swtv==6){freads("enatu.spr");tvplai();} /*江夏選手のお面*/
if(swtv==7)tvplay(); /*ストライクゾーン*/
if(swtv==8)tvplay1("hb1.tif","hb2.tif"); /*花火*/
if(swtv==9)tvplay1("hb1.tif","hb3.tif"); /*花吹雪*/
if(swtv==10)tvplay1("hb1.tif","hb4.tif"); /*風船*/
if(swtv==11)tvplay1("hb1.tif","hb5.tif"); /*交替を告げる監督*/
if(swtv==12)tvplay1("hb1.tif","hb2.tif"); /*予備*/
}
if(sw==1)
{
swdate=0;
MOS_end(); /*マウス動作終了の設定*/
freadb("tv.tif");
tv32(0,0,2);
m_init(1);
do{swtv = iselect();
}while (swtv==0);
EGB_color(work,0,0x0000); /* 前景色 : 黒*/
if(swtv==1){textdisp(63,112,"巨人");strcpy(flnm,"g\\");}
if(swtv==2){textdisp(63,112,"中日");strcpy(flnm,"d\\");}
if(swtv==3){textdisp(63,112,"広島");strcpy(flnm,"c\\");}
if(swtv==4){textdisp(63,112,"阪神");strcpy(flnm,"t\\");}
if(swtv==5){textdisp(63,112,"ヤクルト");strcpy(flnm,"s\\");}
if(swtv==6){textdisp(63,112,"横浜大洋");strcpy(flnm,"w\\");}
if(swtv==7){textdisp(63,112,"近鉄");strcpy(flnm,"bu\\");}
if(swtv==8){textdisp(63,112,"西武");strcpy(flnm,"l\\");}
if(swtv==9){textdisp(63,112,"オリックス");strcpy(flnm,"b\\");}
if(swtv==10){textdisp(63,112,"ロッテ");strcpy(flnm,"o\\");}
if(swtv==11){textdisp(63,112,"日本ハム");strcpy(flnm,"f\\");}
if(swtv==12){textdisp(63,112,"ダイエー");strcpy(flnm,"h\\");}
if(swtv==13){textdisp(63,112,"終了");swen=1;}
if(swdate==1)strcat(flnm,"sc");
if(swen!=1)
{
xxx = 0;
MOS_end(); /*マウス動作終了の設定*/
m_init(1);
do{
do{swtb = nselect();
}while (swtb==11);
EGB_color( work,0,0x0000) ; /* 前景色 : 黒*/
if(swtb==0){textdisp(177+xxx,112,"0");strcat(flnm,"0");}
if(swtb==1){textdisp(177+xxx,112,"1");strcat(flnm,"1");}
if(swtb==2){textdisp(177+xxx,112,"2");strcat(flnm,"2");}
if(swtb==3){textdisp(177+xxx,112,"3");strcat(flnm,"3");}
if(swtb==4){textdisp(177+xxx,112,"4");strcat(flnm,"4");}
if(swtb==5){textdisp(177+xxx,112,"5");strcat(flnm,"5");}
if(swtb==6){textdisp(177+xxx,112,"6");strcat(flnm,"6");}
if(swtb==7){textdisp(177+xxx,112,"7");strcat(flnm,"7");}
if(swtb==8){textdisp(177+xxx,112,"8");strcat(flnm,"8");}
if(swtb==9){textdisp(177+xxx,112,"9");strcat(flnm,"9");}
xxx = xxx + 10;
do{sw = mposb();}while(sw!=0);
}while(swtb !=10);
MOS_end(); /*マウス動作終了の設定*/
strcat(flnm,".txt");
txtdisp(flnm);
}
}
MOS_end(); /*マウス動作終了の設定*/
}while(swen==0);
}