/* ------------------------------------------------------------------ Black Nebula File : intro.c Programmer: Colin Adams Date: 15/5/91 Last Modified : 10/6/91 Description: Does all the stuff for the introduction screens at the start. ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ Includes and Defines ------------------------------------------------------------------ */ #define AMIGA_INCLUDES #include "3d.h" #include "intro.h" /* ------------------------------------------------------------------ Data/Variables ------------------------------------------------------------------ */ struct IntuiMessage *message; struct Window *window1; struct Screen *screen; struct RastPort *intro_rast; USHORT Code; ULONG Class; APTR IAddress; static int x; static int y; extern char *EnterName(void); extern int player_score; /* ------------------------------------------------------------------ Routines ------------------------------------------------------------------ */ void cls(void) { x = 15; y = 135; SetAPen(intro_rast, 0); RectFill(intro_rast, x, y-10, 635, 250); SetAPen(intro_rast, 2); Move(intro_rast, x, y); } void printit(char *string, char flag) { Move(intro_rast, x, y); Text(intro_rast, string, strlen(string)); x += TextLength(intro_rast, string, strlen(string)); if(flag) { y+= 10; x = 15; } } void print(char *string) { printit(string, 0); } void println(char *string) { printit(string, 1); } void ViewFame(void) { FILE *fp; int i, score, c, counter, number; char name[50]; char printbuff[20]; if(!(fp=fopen("fame.dat","r"))) { DisplayBeep(NULL); return; } cls(); fscanf(fp, "%d",&number); SetAPen(intro_rast, 3); print("Name:"); x = 480; println("Score:"); for(i=0; i score[i]) { int j; println(""); println("Congratulations!!! You have a new high score."); for(j=number-1; j>i; j--) { strcpy(&name[j][0], &name[j-1][0]); score[j] = score[j-1]; } strcpy(&name[i][0], EnterName()); score[i] = player_score; flag = 1; break; } } if(!flag) { println(""); println("You didn't score high enough to qualify for the hall"); println("of fame."); SetAPen(intro_rast, 3); println(""); println("More practise is recommended!!"); return; } /* write it out again */ if(!(fp=fopen("fame.dat","w"))) { DisplayBeep(NULL); return; } fprintf(fp,"%d\n",number); for(i=0; iUserPort))==NULL) { Wait(1 << window1->UserPort->mp_SigBit); continue; } /* store fields needed */ Class = message->Class; Code = message->Code; IAddress = message->IAddress; ReplyMsg((struct Message *) message); /* reply to intuition */ if(Class == GADGETUP) { if(IAddress==(APTR) &Gadget1) { Do3d(); OutputScore(); } else if(IAddress==(APTR) &Gadget2) ViewFame(); else if(IAddress==(APTR) &Gadget3) Instructions(); else if(IAddress==(APTR) &Gadget4) return; } } } void DoIntro(void) { if(!(screen=(struct Screen *) OpenScreen(&NewScreenStructure))) { printf("Open Screen failed.\n"); CleanUpandExit(); } NewWindowStructure1.Screen = screen; if(!(window1=(struct Window *) OpenWindow(&NewWindowStructure1))) { printf("Open Window failed.\n"); CleanUpandExit(); } intro_rast = window1->RPort; ActivateWindow(window1); /* make window the active one */ EventLoop(); } /* end of module intro.c */