hschumann2/TempleOS-Source-Code
0847
1 2/* You "Adam include" this because you want the wallpaper3routine to stay in mem even if this task is killed.4 5 <CTRL-t> to see the hidden text needed for sprite elements.6 7 <CTRL-r> to add a sprite to a document.8*/9 10<1>/* Graphics Not Rendered in HTML */11 12 13<2>/* Graphics Not Rendered in HTML */14 15 16<3>/* Graphics Not Rendered in HTML */17 18 19<4>/* Graphics Not Rendered in HTML */20 21 22 23<5>/* Graphics Not Rendered in HTML */24 25 26 27<6>/* Graphics Not Rendered in HTML */28 29 30 31<7>/* Graphics Not Rendered in HTML */32 33 34<8>/* Graphics Not Rendered in HTML */35 36 37<9>/* Graphics Not Rendered in HTML */38 39 40#define TYPES_OF_CRITTERS 341#define FRAMES_PER_CRITTER 442 43U8 *imgs[TYPES_OF_CRITTERS][FRAMES_PER_CRITTER]={44 {<1>,<2>,<3>,<2>},45 {<4>,<5>,<6>,<5>},46 {<7>,<8>,<9>,<8>}47};48 49#define CRITTERS_NUM 1650class Critter51{52 I64 x,y,dx,dy,type;53 F64 t_offset;54} wall_crits[CRITTERS_NUM];55 56U0 (*old_wall_paper)(CTask *task);57 58U0 WallPaperFish(CTask *task)59{60 I64 i,j,x,y;61 CDC *dc=DCAlias(gr.dc2,task);62 Critter *c=wall_crits;63 64 task->text_attr=CYAN<<4+WHITE;65 dc->color=BROWN;66 for (i=0;i<GR_HEIGHT;i+=20) {67 j=16*Tri(tS*10,20);68 GrLine(dc,0,GR_HEIGHT-i-j,GR_HEIGHT-i-j,GR_HEIGHT);69 }70 for (i=0;i<CRITTERS_NUM;i++,c++) {71 j=(tS*4+c->t_offset)%FRAMES_PER_CRITTER;72 x=c->x>>16%GR_WIDTH;73 if (x<0) x+=GR_WIDTH;74 y=c->y>>16%GR_HEIGHT;75 if (y<0) y+=GR_HEIGHT;76 if (c->dx<0) {77 dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;78 DCSymmetrySet(dc,x,y-1,x,y+1);79 } else80 dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);81 Sprite3(dc,x,y,0,imgs[c->type][j]);82 c->x+=c->dx; c->y+=c->dy;83 }84 DCDel(dc);85 86 //Uncomment the following if you wish.87 //old_wall_paper(task);88}89 90U0 WallInit()91{92 I64 i;93 Critter *c;94 if (Fs!=adam_task) {95 "Must be Adam Included with SHIFT-F5.\n"96 "(Would crash when code mem was freed.)\n";97 return;98 }99 old_wall_paper=gr.fp_wall_paper;100 c=wall_crits;101 for (i=0;i<CRITTERS_NUM;i++,c++) {102 c->x=(RandU16%GR_WIDTH)<<16;103 c->y=(RandU16%GR_HEIGHT)<<16;104 c->type=RandU16%TYPES_OF_CRITTERS;105 c->dx=RandI16;106 if (c->dx<0)107 c->dx-=0x4000;108 else109 c->dx+=0x4000;110 c->dy=RandI16;111 c->t_offset=Rand*FRAMES_PER_CRITTER;112 }113 gr.fp_wall_paper=&WallPaperFish;114}115 116WallInit;117 