home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FreeWare Collection 2
/
FreeSoftwareCollection2pd199x-jp.img
/
manboetc
/
icon.c
< prev
next >
Wrap
Text File
|
1990-06-14
|
2KB
|
117 lines
#include <stdio.h>
#include <stdlib.h>
#include <egb.h>
#include <mos.h>
#define NUM 96
struct FISH {
short x ;
short y ;
char icon ;
signed char dir ;
char color ;
} ;
#define work mwork+2560
char mwork[4096] ;
struct FISH fish[NUM] ;
void main()
{
extern void setFish(struct FISH *) ;
extern void moveFish() ;
extern void dispFish() ;
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++)
setFish(&fish[i]) ;
EGB_writeMode(work,4) ;
moveFish() ;
dispFish() ;
}
void moveFish()
{
extern void setFish(struct FISH *) ;
int i = 0 ;
int ch,x,y ;
char para[64] ;
MOS_start(mwork,4096) ;
do
{
EGB_color(work,0,fish[i].color) ;
DWORD(para + 0) = 0x28000+fish[i].icon*256 ;
WORD(para + 4) = 0x108 ;
WORD(para + 6) = fish[i].x+fish[i].dir ;
WORD(para + 8) = fish[i].y ;
WORD(para + 10) = fish[i].x+31+fish[i].dir ;
WORD(para + 12) = fish[i].y+31 ;
EGB_putBlockColor(work,0,para) ;
WORD(para + 6) = fish[i].x ;
WORD(para + 10) = fish[i].x+31 ;
EGB_putBlockColor(work,0,para) ;
fish[i].x += fish[i].dir ;
if (((fish[i].dir > 0)&&(fish[i].x > 640))||
((fish[i].dir < 0)&&(fish[i].x < -32)))
setFish(&fish[i]) ;
i++ ;
if (i == NUM) i = 0 ;
MOS_rdpos(&ch,&x,&y) ;
} while (!ch) ;
MOS_end() ;
}
void dispFish()
{
int i ;
char para[64] ;
for (i = 0 ; i < NUM ; i++)
{
EGB_color(work,0,fish[i].color) ;
DWORD(para + 0) = 0x28000+fish[i].icon*256 ;
WORD(para + 4) = 0x108 ;
WORD(para + 6) = fish[i].x ;
WORD(para + 8) = fish[i].y ;
WORD(para + 10) = fish[i].x+31 ;
WORD(para + 12) = fish[i].y+31 ;
EGB_putBlockColor(work,0,para) ;
}
}
void setFish(data)
struct FISH *data ;
{
int dir ;
int spd ;
dir = rand() & 1 ;
spd = (rand() & 0xf)+1 ;
data->x = dir ? -32 : 640 ;
data->y = rand() & 0x1ff ;
data->icon = rand() & 0x7f ;
data->dir = dir ? spd : -spd ;
data->color = rand() & 0xf ;
}