home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CDPD Public Domain Collection for CDTV 3
/
CDPDIII.bin
/
pd
/
commodities
/
superdark
/
blankers
/
star.dark.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-10
|
4KB
|
180 lines
/* Fichier star.dark.c */
/* Module appele par le programme principal */
/* pour effectuer un effet defini..appele par */
/* loadseg */
#include <exec/types.h>
#include <dos/dos.h>
#include <intuition/intuition.h>
#include <intuition/gadgetclass.h>
#include <graphics/gfx.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <graphics/rastport.h>
#include <graphics/displayinfo.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include "/includes/struct.h"
#include "/includes/tom_gadget.h"
struct RastPort *rp;
struct Screen *s;
extern struct appel_proc *p_data_proc;
extern struct GfxBase *GfxBase;
#define WIDTH 640
#define HEIGHT 256
SHORT width=WIDTH;
SHORT height=HEIGHT;
SHORT depth=2;
ULONG did;
char *p_text_info=
"Effect 'Stars'\n"
"\n"
"\n"
"By T.Landspurg";
#define MAX_SPEED 20
#define reg register
extern void __asm MultiPlot(reg __a0 struct Screen *,reg __d0 WORD, reg __d1 WORD,reg __d2 WORD);
struct NewScreen Screen = {
0, 0, WIDTH, HEIGHT, 2, 0,0, HIRES, CUSTOMSCREEN, NULL, NULL ,NULL, NULL};
#define MAX_STAR 151
struct tom_gadget my_gadg[]={
{"Stars _number",SLIDER, 125,14,139,9,50, 10,MAX_STAR-1,0,0},
{"_Speed",SLIDER, 125,27,139,9,10, 2,20,0,0},
{0, END_LISTE, 0, 0, 0, 0, 0,0,0,0,0}
};
typedef struct pt_3d
{
SHORT x,y,z,speed;
};
typedef struct pt_2d{
SHORT x,y;
};
struct pt_3d tab_pt_3d[MAX_STAR];
struct pt_2d tab_old[MAX_STAR];
#define DE 200
#define de 1000
/*************************************************** Nouvelle etoile ****/
void new_star(p)
struct pt_3d *p;
{
p->x=1500-rand()%3000;
p->y=1000-rand()%2000;
p->z=1000+rand()%2000;
p->speed=rand()%10+my_gadg[1].value;
}
/********************************************************** dark1 ***/
void __saveds dark()
{
SHORT d,i,x,y;
struct pt_3d *p;
struct pt_2d *p2;
depth=2;
width=0;
find_res((SHORT)TRUE,&depth,&width,&height,&did);
Screen.Width=width;
Screen.Height=height;
Screen.ViewModes=did;
if(depth<2)return;
if ( NOT( s = OpenScreen(&Screen)))
return;
FreeSprite (0);
GfxBase->SpriteReserved|=1;
rp = &(s->RastPort);
d=1<<(s->BitMap.Depth);
for(i=0;i<d;i++){
SetRGB4(&s->ViewPort,i,(16*i)/d,(16*i)/d,(16*i)/d);
}
SetRast(rp,0);
for(i=0;i<my_gadg[0].value;i++){
new_star(&tab_pt_3d[i]);
tab_old[i].x=0;
tab_old[i].y=0;
}
while(tst_end()==FALSE){
p2=tab_old;
p=tab_pt_3d;
for(i=0;i<my_gadg[0].value;i++){
x=p2->x;
y=p2->y;
if(p->z>1000){
MultiPlot(s,(WORD)x,(WORD)y,0);
}else if(p->z>200){
MultiPlot(s,(WORD)x,(WORD)y,0);
MultiPlot(s,(WORD)x+1,(WORD)y,0);
}else{
MultiPlot(s,(WORD)x,(WORD)y,0);
MultiPlot(s,(WORD)x+1,(WORD)y,0);
MultiPlot(s,(WORD)x,(WORD)y+1,0);
MultiPlot(s,(WORD)x+1,(WORD)y+1,0);
}
p->z-=p->speed;
if(p->z<=-de){
new_star(p);
}
x=width/2+(DE*p->x)/(p->z+de);
y=height/2+(DE*p->y)/(p->z+de);
if((x<0)||(x>=width)||(y<0)||(y>=height)){
new_star(p);
p2->x=0;
p2->y=0;
}else{
p2->x=x;
p2->y=y;
if(p->z>2000){
MultiPlot(s,(WORD)x,(WORD)y,1);
}else if(p->z>1500){
MultiPlot(s,(WORD)x,(WORD)y,2);
}else if(p->z>1000){
MultiPlot(s,(WORD)x,(WORD)y,3);
}else if(p->z>200){
MultiPlot(s,(WORD)x,(WORD)y,3);
MultiPlot(s,(WORD)x+1,(WORD)y,3);
}else {
MultiPlot(s,(WORD)x,(WORD)y,3);
MultiPlot(s,(WORD)x+1,(WORD)y,3);
MultiPlot(s,(WORD)x,(WORD)y+1,3);
MultiPlot(s,(WORD)x+1,(WORD)y+1,3);
}
}
p2++;
p++;
}
}
CloseScreen(s);
}
void proc_init()
{
p_data_proc->type_screen=SCR_OWN;
}
void proc_save()
{
}
void proc_end()
{
}