home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.eri.u-tokyo.ac.jp
/
2014.03.ftp.eri.u-tokyo.ac.jp.zip
/
ftp.eri.u-tokyo.ac.jp
/
pub
/
seisv
/
src
/
3.02a
/
retrv.c
< prev
next >
Wrap
Text File
|
2000-04-23
|
3KB
|
104 lines
/* SeisView alone/client Copyright (C) 1992,1998 K.Koketsu
<history>
98-10-18 retrv() is again separated from `select.c'.
96-06-22 retrv() is included in `select.c'.
94-01-07 retrv() is separated form `select.c' and `seivd.c'. */
/* This is the common retrieving kernel for `select.c' and `seisvd.c'. */
unsigned retrv(I, total, js1, js2)
unsigned I, js1, js2;
int total;
{
long lon;
short lat, mag, i;
unsigned pag, J, si, di;
unsigned yy, md, hm, sc, dep;
unsigned char *b1, *b2;
pag = total / 4095;
J = total % 4095;
b1 = (unsigned char *)iseg[js1];
b2 = (unsigned char *)iseg[js2+pag];
if(total%4095==0 && total>0) {
poke(0xfe, 0xfff4, iseg[js2+pag-1]);
poke(0xff, 0xfff5, iseg[js2+pag-1]);
}
di = J*16 + 4;
Rvp:
si = I*16 + 4;
yy = b1[si] + (b1[si+1] << 8);
if(yy >= 0xff00) {
b2[di ] = b1[si ];
b2[di+1] = b1[si+1];
return( yy );
}
if(b1[si] == 0xff) {
yy = b1[si+13] + (b1[si+14] << 8);
}
else {
if(b1[si] >= 155) yy = b1[si] + 1800 - 155;
else yy = b1[si] + 1900;
}
if(yy > iyy2) goto Rv9;
if(yy == iyy2) {
md = (b1[si+1] << 8) + b1[si+2];
if(md > imd2) goto Rv9;
if(md == imd2) {
hm = (b1[si+3] << 8) + b1[si+4];
if(hm > ihm2) goto Rv9;
sc = b1[si+5] + (b1[si+6] << 8);
if(hm==ihm2 && sc>isc2) goto Rv9;
}
}
if(yy < iyy1) goto Rv9;
if(yy == iyy1) {
md = (b1[si+1] << 8) + b1[si+2];
if(md < imd1) goto Rv9;
if(md == imd1) {
hm = (b1[si+3] << 8) + b1[si+4];
if(hm < ihm1) goto Rv9;
sc = b1[si+5] + (b1[si+6] << 8);
if(hm==ihm1 && sc<isc1) goto Rv9;
}
}
lon = ((long)b1[si+7] << 8) + ((long)b1[si+8] & 0x7f);
if(b1[si+ 8] & 0x80) lon = - lon;
if(lo2>b180 && lon<lo1) lon = lon + b360;
if(lon<lo1 || lon>lo2) goto Rv9;
if(lon==lo2 && b1[si+ 9]>0) goto Rv9;
if(lon==lo1 && b1[si+ 9]>0 && lo1<0) goto Rv9;
lat = (b1[si+10] << 8) + (b1[si+11] & 0x7f);
if(b1[si+11] & 0x80) lat = - lat;
if(lat<la1 || lat>la2) goto Rv9;
if(lat==la2 && b1[si+12]>0) goto Rv9;
if(lat==la1 && b1[si+12]>0 && la1<0) goto Rv9;
if(b1[si] == 0xff) {
if(*ynh$ == 'N') goto Rv9;
}
else {
dep = b1[si+13] + (b1[si+14] << 8);
if(dep == 0xffff) { if(*ynh$ == 'N') goto Rv9; }
else if(dep<ih1 || dep>ih2) goto Rv9;
}
if(b1[si+15] == 0) {
if(*ynm$ == 'N') goto Rv9;
}
else {
mag = b1[si+15] & 0x7f;
if(b1[si+15] & 0x80) mag = - mag;
if(mag<m1 || mag>m2) goto Rv9;
}
for(i=0; i<16; i++) b2[di+i] = b1[si+i];
return( I );
Rv9:
I++;
goto Rvp;
}