Selaa lähdekoodia

broke up files into pieces for easier management

Joshua Bicking 8 vuotta sitten
vanhempi
commit
1418b7b153
9 muutettua tiedostoa jossa 146 lisäystä ja 93 poistoa
  1. 0 6
      src/FalloutTerminal.h
  2. 23 0
      src/Makefile
  3. 71 0
      src/intro.c
  4. 6 0
      src/intro.h
  5. 33 0
      src/main.c
  6. 6 85
      src/pass.c
  7. 6 0
      src/pass.h
  8. 1 1
      src/print.c
  9. 0 1
      src/print.h

+ 0 - 6
src/FalloutTerminal.h

@@ -1,6 +0,0 @@
-#ifndef FALLOUT_TERMINAL_H
-#define FALLOUT_TERMINAL_H
-
-void pass();
-
-#endif

+ 23 - 0
src/Makefile

@@ -0,0 +1,23 @@
+CC = gcc
+CFLAGS = -Wall -Wextra -pedantic -std=c99
+
+ifeq ($(OS),Windows_NT)
+	CFLAGS += -lpdcurses
+else
+	CFLAGS += -lncurses
+endif
+
+FalloutTerminal: main.o print.o intro.o pass.o
+	$(CC) -o $@ $^ $(CFLAGS) 
+
+main.o: main.c intro.c pass.c
+
+intro.o: intro.c print.c
+
+print.o: print.c
+
+pass.o: pass.c print.c
+
+clean:
+	rm *.o FalloutTerminal
+	#TODO conditional for Windows

+ 71 - 0
src/intro.c

@@ -0,0 +1,71 @@
+#define _BSD_SOURCE /* for unistd.h */
+
+#ifdef _WIN32
+#   include <Windows.h>
+#   include <curses.h>
+#   define SLEEP(delay) Sleep(delay/1000)
+// Unix builds require ncurses.h for the Ncurses library.
+// Unix also requires unistd.h for usleep(microseconds).
+// usleep/1000 = Sleep
+#else
+#   include <ncurses.h>
+#   include <unistd.h>
+#   define SLEEP(delay) usleep(delay)
+#endif
+
+#include <string.h>
+
+#include "print.h"
+#include "intro.h"
+
+/// Plays the introduction sequence. 
+///
+void intro(){
+    clear();
+    SLEEP(250000);
+    
+    slowPrint("WELCOME TO ROBCO INDUSTRIES (TM) TERMLINK",strlen("WELCOME TO ROBCO INDUSTRIES (TM) TERMLINK"), 0);
+
+    move(1, 0);
+    refresh();
+    SLEEP(30000);
+    mvprintw(2,0,"%c", '>');
+    move(2,1);
+    refresh();
+    SLEEP(1500000);
+
+    slowType("SET TERMINAL/INQUIRE",strlen("SET TERMINAL/INQUIRE"), 2);
+
+    slowPrint("RIT-V300",strlen("RIT-V300"), 4);
+
+    mvprintw(6,0,"%c", '>');
+    refresh();
+    SLEEP(1500000);
+    slowType("SET FILE/PROTECTION=OWNER:RWED ACCOUNTS.F",strlen("SET FILE/PROTECTION=OWNER:RWED ACCOUNTS.F"),6);
+    
+    mvprintw(7,0,"%c", '>');
+    refresh();
+    SLEEP(1500000);
+    slowType("SET HALT RESTART/MAINT",strlen("SET HALT RESTART/MAINT"),7);
+    
+    slowPrint("Initializing Robco Industries(TM) Boot Agent v2.3.0",strlen("Initializing Robco Industries(TM) Boot Agent v2.3.0"),9);
+
+    slowPrint("RBIOS-4.02.08.00 53EE5.E7.E8",strlen("RBIOS-4.02.08.00 53EE5.E7.E8"),10);
+
+    slowPrint("Copyright 2201-22-3 Robco Ind.",strlen("Copyright 2201-22-3 Robco Ind."),11);
+
+    slowPrint( "Uppermem: 64 KB",strlen("Uppermem: 64 KB"),12);
+
+    slowPrint("Root (5A8)",strlen("Root (5A8)"),13);
+
+    slowPrint("Maintenance Mode",strlen("Maintenance Mode"),14);
+
+    mvprintw(16,0,"%c",'>');
+    refresh();
+    SLEEP(1500000);
+    slowType("RUN DEBUG/ACCOUNTS.F",strlen("RUN DEBUG/ACCOUNTS.F"),16);
+    move(16,0);
+    refresh();
+    SLEEP(50000);
+}
+

+ 6 - 0
src/intro.h

@@ -0,0 +1,6 @@
+#ifndef INTRO_H
+#define INTRO_H
+
+void intro();
+
+#endif

+ 33 - 0
src/main.c

@@ -0,0 +1,33 @@
+#ifdef _WIN32
+#   include <curses.h>
+#else
+#   include <ncurses.h>
+#endif
+
+#include <stdlib.h>
+#include <time.h>
+#include "intro.h"
+#include "pass.h"
+
+int main(){
+
+    // TODO  get input from args here. Pass it to pass
+
+    srand ( (unsigned)time(NULL) );
+    initscr();
+    noecho();
+    refresh();
+    attron(A_BOLD);
+    nodelay(stdscr, 1);
+    if(has_colors() == 1){
+        /* Colors */
+        start_color();
+        init_pair(1,COLOR_GREEN,COLOR_BLACK);
+        attron(COLOR_PAIR(1));
+    }
+
+    intro();
+    pass();
+    
+    return 0;
+}

+ 6 - 85
src/FalloutTerminal.c → src/pass.c

@@ -1,7 +1,5 @@
 #define _BSD_SOURCE /* for unistd.h */
 
-// Win32 builds require Windows.h for Sleep(milliseconds).
-// They also require curses.h for the PDCurses library.
 #ifdef _WIN32
 #   include <Windows.h>
 #   include <curses.h>
@@ -15,67 +13,17 @@
 #   define SLEEP(delay) usleep(delay)
 #endif
 
-#include <stdlib.h>
-#include <time.h>
 #include <string.h>
+#include <stdlib.h>
+
+#include "pass.h"
 #include "print.h"
 
 #define OFFSET_LEFT 0
 #define OFFSET_RIGHT 20
+#define BIGSTRING_SIZE 408
 
-/// Plays the introduction sequence. 
-///
-void intro(){
-    clear();
-    SLEEP(250000);
-    
-    slowPrint("WELCOME TO ROBCO INDUSTRIES (TM) TERMLINK",strlen("WELCOME TO ROBCO INDUSTRIES (TM) TERMLINK"), 0);
-
-    move(1, 0);
-    refresh();
-    SLEEP(30000);
-    mvprintw(2,0,"%c", '>');
-    move(2,1);
-    refresh();
-    SLEEP(1500000);
-
-    slowType("SET TERMINAL/INQUIRE",strlen("SET TERMINAL/INQUIRE"), 2);
-
-    slowPrint("RIT-V300",strlen("RIT-V300"), 4);
-
-    mvprintw(6,0,"%c", '>');
-    refresh();
-    SLEEP(1500000);
-    slowType("SET FILE/PROTECTION=OWNER:RWED ACCOUNTS.F",strlen("SET FILE/PROTECTION=OWNER:RWED ACCOUNTS.F"),6);
-    
-    mvprintw(7,0,"%c", '>');
-    refresh();
-    SLEEP(1500000);
-    slowType("SET HALT RESTART/MAINT",strlen("SET HALT RESTART/MAINT"),7);
-    
-    slowPrint("Initializing Robco Industries(TM) Boot Agent v2.3.0",strlen("Initializing Robco Industries(TM) Boot Agent v2.3.0"),9);
-
-    slowPrint("RBIOS-4.02.08.00 53EE5.E7.E8",strlen("RBIOS-4.02.08.00 53EE5.E7.E8"),10);
-
-    slowPrint("Copyright 2201-22-3 Robco Ind.",strlen("Copyright 2201-22-3 Robco Ind."),11);
-
-    slowPrint( "Uppermem: 64 KB",strlen("Uppermem: 64 KB"),12);
-
-    slowPrint("Root (5A8)",strlen("Root (5A8)"),13);
-
-    slowPrint("Maintenance Mode",strlen("Maintenance Mode"),14);
-
-    mvprintw(16,0,"%c",'>');
-    refresh();
-    SLEEP(1500000);
-    slowType("RUN DEBUG/ACCOUNTS.F",strlen("RUN DEBUG/ACCOUNTS.F"),16);
-    move(16,0);
-    refresh();
-    SLEEP(50000);
-}
-
-
-int currentCharContains(char arr[],char c){
+static int currentCharContains(char arr[],char c){
     int i;
     for(i=0; i<12; i++)
         if(arr[i]==c)
@@ -83,7 +31,7 @@ int currentCharContains(char arr[],char c){
     return 0;
 }
 
-int getCharLoc(int y, int x){
+static int getCharLoc(int y, int x){
     /* Left side */
     if(x<19)
         return 12*(y-5)+(x-7);
@@ -93,8 +41,6 @@ int getCharLoc(int y, int x){
 }
 
 void pass(){
-    static const int BIGSTRING_SIZE = 408;
-
 
     /* Start a new screen where nodelay is false */
     erase();
@@ -1575,28 +1521,3 @@ void pass(){
     endwin();
     exit(0);
 }
-
-
-int main(){
-
-    // TODO  get input from args here. Pass it to pass
-
-    srand ( (unsigned)time(NULL) );
-    initscr();
-    noecho();
-    refresh();
-    attron(A_BOLD);
-    nodelay(stdscr, 1);
-    if(has_colors() == 1){
-        /* Colors */
-        start_color();
-        init_pair(1,COLOR_GREEN,COLOR_BLACK);
-        attron(COLOR_PAIR(1));
-    }
-
-    intro();
-    pass();
-
-    
-    return 0;
-}

+ 6 - 0
src/pass.h

@@ -0,0 +1,6 @@
+#ifndef PASS_H
+#define PASS_H
+
+void pass();
+
+#endif

+ 1 - 1
src/print.c

@@ -22,7 +22,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include "print.h"
-#include "FalloutTerminal.h"
+#include "pass.h"
 
 void slowPrint(char arr[], int size, int line){
     for(int i=0; i<size; i++){  

+ 0 - 1
src/print.h

@@ -1,4 +1,3 @@
-
 #ifndef PRINT_H
 #define PRINT_H