static void text(void) { int ch; /* next input character */ /* * * Translates the next input file into PostScript. The redirect(-1) call forces * the initial output to go to /dev/null - so the stuff formfeed() does at the * end of each page doesn't go to stdout. * */ redirect(-1); /* get ready for the first page */ formfeed(); /* force PAGE comment etc. */ inittabs(); while ( (ch = getc(fp_in)) != EOF ) switch ( ch ) { case '\010': /* backspace */ backspace(); break; case '\011': /* horizontal tab */ htab(); break; case '\012': /* new line */ linefeed(); break; case '\013': /* vertical tab */ vtab(); break; case '\014': /* form feed */ formfeed(); break; case '\015': /* carriage return */ carriage(); break; case '\016': /* extended character set - SO */ break; case '\017': /* extended character set - SI */ break; case '\031': /* next char from supplementary set */ break; case '\033': /* 2 or 3 byte escape sequence */ escape(); break; default: oput(ch); break; } /* End switch */ formfeed(); /* next file starts on a new page? */ } /* End of text */
int flying(void) { unsigned char ch; int shipy; int turning=0; int draw_splash=0,splash_count=0; int zint; /************************************************/ /* Flying */ /************************************************/ gr(); ram[DRAW_PAGE]=PAGE0; clear_bottom(); ram[DRAW_PAGE]=PAGE1; clear_bottom(); shipy=20; while(1) { if (splash_count>0) splash_count--; ch=grsim_input(); if ((ch=='q') || (ch==27)) break; #if 0 if (ch=='g') { BETA+=0.1; printf("Horizon=%lf\n",BETA); } if (ch=='h') { BETA-=0.1; printf("Horizon=%lf\n",BETA); } if (ch=='s') { scale_x++; scale_y++; printf("Scale=%lf\n",scale_x); } #endif if ((ch=='w') || (ch==APPLE_UP)) { if (shipy>16) { shipy-=2; space_z.i++; } splash_count=0; // printf("Z=%lf\n",space_z); } if ((ch=='s') || (ch==APPLE_DOWN)) { if (shipy<28) { shipy+=2; space_z.i--; } else { splash_count=10; } // printf("Z=%lf\n",space_z); } if ((ch=='a') || (ch==APPLE_LEFT)) { if (turning>0) { turning=0; } else { turning=-20; angle-=1; if (angle<0) angle+=ANGLE_STEPS; } } if ((ch=='d') || (ch==APPLE_RIGHT)) { if (turning<0) { turning=0; } else { turning=20; angle+=1; if (angle>=ANGLE_STEPS) angle-=ANGLE_STEPS; } } /* Used to be able to go backwards */ if (ch=='z') { if (speed<3) speed++; } if (ch=='x') { if (speed>0) speed--; } if (ch==' ') { speed=SPEED_STOPPED; } if (ch=='h') { print_help(); } /* Ending */ if (ch==13) { int landing_color,tx,ty; tx=cx.i; ty=cy.i; landing_color=lookup_map(tx,ty); printf("Trying to land at %d %d\n",tx,ty); printf("Color=%d\n",landing_color); if (landing_color==12) { int loop; zint=space_z.i; /* Land the ship */ for(loop=zint;loop>0;loop--) { draw_background_mode7(); grsim_put_sprite(shadow_forward,SHIPX+3,31+zint); grsim_put_sprite(ship_forward,SHIPX,shipy); page_flip(); usleep(200000); space_z.i--; } return 0; } else { htab(11); vtab(22); move_cursor(); print_both_pages("NEED TO LAND ON GRASS!"); } } if (speed!=SPEED_STOPPED) { int ii; dx.i = fixed_sin_scale[(angle+4)&0xf].i; // cos dx.f = fixed_sin_scale[(angle+4)&0xf].f; // cos dy.i = fixed_sin_scale[angle&0xf].i; dy.f = fixed_sin_scale[angle&0xf].f; for(ii=0;ii<speed;ii++) { fixed_add(&cx,&dx,&cx); fixed_add(&cy,&dy,&cy); } } draw_background_mode7(); zint=space_z.i; draw_splash=0; if (speed>0) { if ((shipy>25) && (turning!=0)) { splash_count=1; } if ((over_water) && (splash_count)) { draw_splash=1; } } // printf("VMW: %d %d\n",draw_splash,splash_count); if (turning==0) { if (draw_splash) { grsim_put_sprite(splash_forward, SHIPX+1,shipy+9); } grsim_put_sprite(shadow_forward,SHIPX+3,31+zint); grsim_put_sprite(ship_forward,SHIPX,shipy); } if (turning<0) { if (draw_splash) { grsim_put_sprite(splash_left, SHIPX+1,36); } grsim_put_sprite(shadow_left,SHIPX+3,31+zint); grsim_put_sprite(ship_left,SHIPX,shipy); turning++; } if (turning>0) { if (draw_splash) { grsim_put_sprite(splash_right, SHIPX+1,36); } grsim_put_sprite(shadow_right,SHIPX+3,31+zint); grsim_put_sprite(ship_right,SHIPX,shipy); turning--; } page_flip(); usleep(20000); } return 0; }