diff --git a/gr-sim/hgr/Makefile b/gr-sim/hgr/Makefile index 6b20fd13..c4acda29 100644 --- a/gr-sim/hgr/Makefile +++ b/gr-sim/hgr/Makefile @@ -6,7 +6,7 @@ SDL_LIBS= `sdl-config --libs` SDL_INCLUDE= `sdl-config --cflags` GR_SIM = ../gr-sim.a -all: fireworks lines image_load hgr_view +all: fireworks fw_purple lines image_load hgr_view ### @@ -40,8 +40,16 @@ fireworks: fireworks.o $(GR_SIM) fireworks.o: fireworks.c $(CC) $(CFLAGS) -c fireworks.c +### + +fw_purple: fw_purple.o $(GR_SIM) + $(CC) $(LFLAGS) $(SDL_LIBS) -o fw_purple fw_purple.o $(GR_SIM) + +fw_purple.o: fw_purple.c + $(CC) $(CFLAGS) -c fw_purple.c + #### clean: - rm -f *~ *.o fireworks lines image_load hgr_view + rm -f *~ *.o fireworks lines image_load hgr_view fw_purple diff --git a/gr-sim/hgr/fireworks.c b/gr-sim/hgr/fireworks.c index 5d7578b2..3aa70159 100644 --- a/gr-sim/hgr/fireworks.c +++ b/gr-sim/hgr/fireworks.c @@ -5,33 +5,31 @@ #include "gr-sim.h" -// Based on BASIC program posted by FozzTexx -// 100 REM Fireworks by FozzTexx, originally written in 1987 -// Constants: BT/RT is screen size, MG is margin -//120 REM Variables: -//130 REM XV/YV are velocity, PK is highest point of rocket +// Based on BASIC program posted by FozzTexx, originally written in 1987 + //140 REM MS is max steps, CS is current step, X/Y/X1/Y1/X2/Y2 is rocket position //150 REM CL is Apple II hi-res color group -const int ysize=191,xsize=280,mg=24; -int cl; -int ms; -double x1,x2=0,ypos1,y2=0,cs,pk; +const int ysize=160,xsize=280,margin=24; +int color_group; +int max_steps; +double x_even_older,x_old=0,y_even_older,y_old=0,cs,peak; double xpos,ypos,x_velocity,y_velocity; double i,n; void routine_370(void) { - hplot(xpos+x2+n,ypos+y2+n); - hplot(xpos+x2-n,ypos+y2-n); - hplot(xpos+x2+n,ypos+y2-n); - hplot(xpos+x2-n,ypos+y2+n); + hplot(xpos+x_old+n,ypos+y_old+n); // NE + hplot(xpos+x_old-n,ypos+y_old-n); // SW - hplot(xpos+x2,ypos+y2+(n*1.5)); - hplot(xpos+x2+(n*1.5),ypos+y2); + hplot(xpos+x_old+n,ypos+y_old-n); // SE + hplot(xpos+x_old-n,ypos+y_old+n); // NW - hplot(xpos+x2,ypos+y2-(n*1.5)); - hplot(xpos+x2-(n*1.5),ypos+y2); + hplot(xpos+x_old,ypos+y_old+(n*1.5)); // N + hplot(xpos+x_old+(n*1.5),ypos+y_old); // E + + hplot(xpos+x_old,ypos+y_old-(n*1.5)); // S + hplot(xpos+x_old-(n*1.5),ypos+y_old); // W } @@ -43,76 +41,78 @@ int main(int argc, char **argv) { home(); - // 160 HGR:POKE 49234,0:REM Poke hides 4 line text area hgr(); - - // + soft_switch(MIXCLR); // Full screen label_180: - cl=random()%2; - x_velocity=(random()%3)+1; - y_velocity=-((random()%5)+3); + color_group=random()%2; // HGR color group (PG or BO) + x_velocity=(random()%3)+1; // x velocity = 1..3 + y_velocity=-((random()%5)+3); // y velocity = -3..-7 - ms=(random()%25)+40; - xpos=(random()%(xsize-mg*2))+mg; - ypos=ysize; - pk=ypos; + max_steps=(random()%25)+40; // 40..64 + + xpos=(random()%(xsize-margin*2))+margin; + // margin .. xsize-margin + ypos=ysize; // start at ground + peak=ypos; // peak starts at ground? /* Aim towards center of screen */ if (xpos>xsize/2) x_velocity=-x_velocity; - //210 REM Draw rocket + /* Draw rocket */ + for(cs=1;cs<=max_steps;cs++) { + y_even_older=y_old; + y_old=ypos; + x_even_older=x_old; + x_old=xpos; - for(cs=1;cs<=ms;cs++) { - ypos1=y2; - y2=ypos; - x1=x2; - x2=xpos; + /* Move rocket */ xpos=xpos+x_velocity; ypos=ypos+y_velocity; - y_velocity=y_velocity+0.12; - if (ypos=(xsize-mg)) { - cs=ms; -// printf("X too big!\n"); + if (xpos>=(xsize-margin)) { + cs=max_steps; // too far right } - if (ypos<=mg) { - cs=ms; -// printf("Y too small!\n"); + if (ypos<=margin) { + cs=max_steps; // too far up } + + // if falling downward if (y_velocity>0) { - if (ypos>=ysize-mg) { - cs=ms; -// printf("Y too big %d > %d\n",y,ysize-mg); + // if too close to ground, explode + if (ypos>=ysize-margin) { + cs=max_steps; + } + // if fallen a bit past peak, explode + if (ypos>ysize-(ysize-peak)/2) { + cs=max_steps; } - if (ypos>ysize-(ysize-pk)/2) cs=ms; } -// printf("cs=%d,ms=%d\n",cs,ms); - if (cs +#include +#include +#include + +#include "gr-sim.h" + +// Based on BASIC program posted by FozzTexx, originally written in 1987 + +//140 REM MS is max steps, CS is current step, X/Y/X1/Y1/X2/Y2 is rocket position +//150 REM CL is Apple II hi-res color group + +const int ysize=160,xsize=280,margin=24; +int color_group; +int max_steps; +double x_even_older,x_old=0,y_even_older,y_old=0,cs,peak; +double xpos,ypos,x_velocity,y_velocity; +double i,n; + +void routine_370(void) { + + hplot(xpos+x_old+n,ypos+y_old+n); // NE + hplot(xpos+x_old-n,ypos+y_old-n); // SW + + hplot(xpos+x_old+n,ypos+y_old-n); // SE + hplot(xpos+x_old-n,ypos+y_old+n); // NW + + hplot(xpos+x_old,ypos+y_old+(n*1.5)); // N + hplot(xpos+x_old+(n*1.5),ypos+y_old); // E + + hplot(xpos+x_old,ypos+y_old-(n*1.5)); // S + hplot(xpos+x_old-(n*1.5),ypos+y_old); // W + +} + +int main(int argc, char **argv) { + + int ch; + + grsim_init(); + + home(); + + hgr(); + soft_switch(MIXCLR); // Full screen + +label_180: + color_group=random()%2; // HGR color group (PG or BO) + x_velocity=(random()%3)+1; // x velocity = 1..3 + y_velocity=-((random()%5)+3); // y velocity = -3..-7 + + max_steps=(random()%25)+40; // 40..64 + + xpos=(random()%(xsize-margin*2))+margin; + // margin .. xsize-margin + ypos=ysize; // start at ground + peak=ypos; // peak starts at ground? + + /* Aim towards center of screen */ + if (xpos>xsize/2) x_velocity=-x_velocity; + + /* Draw rocket */ + for(cs=1;cs<=max_steps;cs++) { + y_even_older=y_old; + y_old=ypos; + x_even_older=x_old; + x_old=xpos; + + /* Move rocket */ + xpos=xpos+x_velocity; + ypos=ypos+y_velocity; + + /* adjust Y velocity, slow it down */ + y_velocity=y_velocity+0.125; + + /* if we went higher, adjust peak */ + if (ypos=(xsize-margin)) { + cs=max_steps; // too far right + } + + if (ypos<=margin) { + cs=max_steps; // too far up + } + + + // if falling downward + if (y_velocity>0) { + // if too close to ground, explode + if (ypos>=ysize-margin) { + cs=max_steps; + } + // if fallen a bit past peak, explode + if (ypos>ysize-(ysize-peak)/2) { + cs=max_steps; + } + } + + // if not done, draw rocket + if (cs