home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FreeWare Collection 2
/
FreeSoftwareCollection2pd199x-jp.img
/
manboetc
/
rain.c
< prev
next >
Wrap
Text File
|
1990-06-14
|
7KB
|
283 lines
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <egb.h>
#include <mos.h>
/* Size=(8,8) */
char rain_xor[]={
0x08,0x08,0x14,0x14,0x22,0x22,0x26,0x1C};
/* Size=(32,32) */
char rain1_xor[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,
0x00,0x00,0x80,0x00,0x00,0x01,0xC0,0x00,
0x00,0x01,0x40,0x00,0x00,0x0A,0x28,0x00,
0x00,0x12,0x24,0x00,0x00,0x11,0xC4,0x00,
0x00,0x08,0x08,0x00,0x00,0x07,0xF0,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xF8,0x00,0x00,0x30,0x06,0x00,
0x00,0x40,0x81,0x00,0x00,0x8A,0xA8,0x80,
0x01,0x12,0x24,0x40,0x01,0x11,0xC4,0x40,
0x01,0x08,0x08,0x40,0x00,0x87,0xF0,0x80,
0x00,0x40,0x01,0x00,0x00,0x38,0x0E,0x00,
0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x1F,0x14,0x00,
0x00,0x40,0x01,0x00,0x00,0x00,0x00,0x60,
0x02,0x0F,0xF8,0x10,0x04,0x30,0x06,0x00,
0x08,0x40,0x01,0x08,0x00,0x89,0x48,0x80,
0x11,0x12,0x24,0x44,0x11,0x11,0x44,0x44,
0x11,0x08,0x08,0x44,0x00,0x87,0xF0,0x84,
0x08,0x40,0x01,0x00,0x02,0x38,0x0E,0x10,
0x03,0x07,0xF0,0x00,0x00,0x80,0x00,0xE0,
0x00,0x60,0x03,0x00,0x00,0x07,0x88,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x14,0x48,0x00,0x00,0x40,0x02,0x80,
0x05,0x00,0x00,0x20,0x08,0x14,0xD4,0x08,
0x00,0x40,0x01,0x00,0x21,0x00,0x00,0x42,
0x02,0x0A,0x88,0x10,0x44,0x30,0x06,0x00,
0x08,0x40,0x01,0x09,0x00,0x88,0x08,0x80,
0x90,0x10,0x04,0x04,0x90,0x00,0x00,0x04,
0x90,0x08,0x08,0x01,0x00,0x85,0x50,0x84,
0x08,0x40,0x01,0x01,0x02,0x38,0x0E,0x10,
0x42,0x04,0xB0,0x00,0x40,0x80,0x00,0x22,
0x08,0x20,0x03,0x00,0x00,0x06,0xA8,0x18,
0x01,0x00,0x00,0x40,0x00,0x27,0x8E,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
#define NUM 96
#define COLOR 2
#define DROPOUT 432
#define RND 512
#define WAIT 15
struct RAIN {
short x ;
short y ;
char pat ;
} ;
int downSp = 16 ;
#define work mwork+2560
char mwork[4096] ;
struct RAIN rain[NUM] ;
void main()
{
extern void setRain(struct RAIN *) ;
extern void moveRain() ;
extern void dispRain() ;
int i ;
/*
EGB_init(work,1536) ;
EGB_resolution(work,0,0x3) ;
EGB_resolution(work,1,0x3) ;
EGB_writePage(work,0x0) ;
EGB_displayPage(work,0,3) ;
*/
EGB_resolution(work,0,0x43) ;
EGB_resolution(work,1,0x43) ;
EGB_writePage(work,0x40) ;
for (i = 0 ; i < NUM ; i++)
setRain(&rain[i]) ;
EGB_writeMode(work,4) ;
moveRain() ;
dispRain() ;
}
void moveRain()
{
extern void setRain(struct RAIN *) ;
extern void setPalette() ;
int i = 0 ;
int max = 1 ;
int busy = 0 ;
int ch,x,y ;
char para[64] ;
MOS_start(mwork,4096) ;
EGB_color(work,0,COLOR) ;
do
{
if (busy == 0)
{
if (rain[i].pat == 0)
{
DWORD(para + 0) = (unsigned int)rain_xor ;
WORD(para + 4) = 0x14 ;
WORD(para + 6) = rain[i].x ;
WORD(para + 8) = rain[i].y + downSp ;
WORD(para + 10) = rain[i].x+7 ;
WORD(para + 12) = rain[i].y+7 + downSp ;
EGB_putBlockColor(work,0,para) ;
WORD(para + 8) = rain[i].y ;
WORD(para + 12) = rain[i].y+7 ;
EGB_putBlockColor(work,0,para) ;
rain[i].y += downSp ;
}
if (rain[i].y > DROPOUT)
{
WORD(para + 4) = 0x14 ;
WORD(para + 6) = rain[i].x - 12 ;
WORD(para + 8) = rain[i].y -12 ;
WORD(para + 10) = rain[i].x -12 +31 ;
WORD(para + 12) = rain[i].y -12 +31 ;
if (rain[i].pat < 4)
{
DWORD(para) = (unsigned int)(rain1_xor+128*rain[i].pat) ;
EGB_putBlockColor(work,0,para) ;
}
if (rain[i].pat != 0)
{
DWORD(para)=(unsigned int)(rain1_xor+128*(rain[i].pat-1)) ;
}
else
{
DWORD(para + 0) = (unsigned int)rain_xor ;
WORD(para + 6) = rain[i].x ;
WORD(para + 8) = rain[i].y ;
WORD(para + 10) = rain[i].x+7 ;
WORD(para + 12) = rain[i].y+7 ;
}
EGB_putBlockColor(work,0,para) ;
rain[i].pat++ ;
}
if (rain[i].pat == 5)
setRain(&rain[i]) ;
i++ ;
if (i == max)
{
busy = i ;
i = 0 ;
}
}
else
{
DWORD(para + 0) = (unsigned int)rain_xor ;
WORD(para + 4) = 0x14 ;
WORD(para + 6) = 640 ;
WORD(para + 8) = 0 ;
WORD(para + 10) = 640+WAIT ;
WORD(para + 12) = WAIT ;
EGB_putBlockColor(work,0,para) ;
busy++ ;
if (busy > NUM) busy = 0 ;
}
if (max < NUM)
if ((rand() % RND) == 0)
{
max++ ;
if ((max & 0xf) == 0)
setPalette() ;
}
MOS_rdpos(&ch,&x,&y) ;
} while (!ch) ;
MOS_end() ;
}
void dispRain()
{
int i ;
char para[64] ;
EGB_color(work,0,COLOR) ;
for (i = 0 ; i < NUM ; i++)
{
if (rain[i].pat == 0)
{
DWORD(para + 0) = (unsigned int)rain_xor ;
WORD(para + 6) = rain[i].x ;
WORD(para + 8) = rain[i].y ;
WORD(para + 10) = rain[i].x+7 ;
WORD(para + 12) = rain[i].y+7 ;
}
else
{
DWORD(para + 0) = (unsigned int)(rain1_xor+128*(rain[i].pat-1)) ;
WORD(para + 6) = rain[i].x - 12 ;
WORD(para + 8) = rain[i].y -12 ;
WORD(para + 10) = rain[i].x -12 +31 ;
WORD(para + 12) = rain[i].y -12 +31 ;
}
WORD(para + 4) = 0x14 ;
EGB_putBlockColor(work,0,para) ;
}
}
void setRain(data)
struct RAIN *data ;
{
data->x = (((unsigned) rand()) % 640) ;
data->y = -16 - (rand() & 0xf);
data->pat = 0 ;
}
void setPalette()
{
int i ;
int j ;
int data ;
char ch ;
for (i = 0 ; i < 16 ; i++)
{
j = 0xfd90 ;
outp(j,i) ;
for (j += 2 ; j < 0xfd98 ; j +=2)
{
ch = inp(j) ;
data = ch ;
data -= 16 ;
if (data < 0) data = 0 ;
ch = data ;
outp(j,ch) ;
}
}
}