/***************************************************************************
 *
 * IChing.C:    Find destiny or direction on a particular subject.
 *              CLI version 1.02
 *
 * Author:      Christopher Paul Scott.
 *              7934 SW Barbur Blvd., #6
 *              Portland, Oregon 97219
 *              (503) 246-5718
 *              Copyright 1988, 1989
 *              FREEWARE. All rights reserved.
 *
 * Usage:       IChing
 *
 * Compiling:   lmk IChing  (LATTICE 5.04)
 * lmkfile:     IChing: ICH.o
 *              $(LINK) FROM $(LIB)c.o ICH.o TO work:OBJ/IChing \
 *              LIB $(LIB)lc.lib+$(LIB)amiga.lib MAP\
 *              work:IChing.Map,f,h,l,o,s,x ND
 *
 *              ICH.o:             ICH.c
 *              LC:LC -O -b0 $(CIFLAGS) ICH
 *
 **************************************************************************/

#include "clib/macros.h"
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include "exec/types.h"

#define AUTHOR          "CHRISTOPHER PAUL SCOTT."
#define VERSION         "1.1[31;40m"
#define PROGRAM         "[32;40mIChing[31;40m"
#define SHIFTS          25
#define TRUE            1
#define FALSE           0

char *subDes01[128]={ "01  Chien\n___ Heaven king, father, etc. The symbol of firmness.\n ___ \n ___ \n ___ \n ___ \n ___ \n", NULL };
char *subDes02[128]={ "02  Khwan\n_ _ Earth, people, mother, etc., the symbol of submission. \n _ _ \n _ _ \n _ _ \n _ _ \n _ _ \n", NULL };
char *subDes03[128]={ "03  Kun\n_ _ Initial difficulties, the symbol of bursting.\n___ Represents what is great and originating, pene-  \n_ _ trating, advantageous, correct and having the firmness \n_ _ of a mare.\n_ _ \n___ \n", NULL };
char *subDes04[128]={ "04  Mang\n___ Youthful inexperience, the symbol of obscurity.\n_ _ \n_ _ \n_ _ \n___ \n_ _ \n", NULL };
char *subDes05[128]={ "05  Hsu\n_ _ Delaying the symbol of waiting.\n___ \n_ _ \n___ \n___ \n___ \n", NULL };
char *subDes06[128]={ "06  Sung\n___ Conflict, the symbol of contention.\n___ \n___ \n_ _ \n___ \n_ _ \n", NULL };
char *subDes07[128]={ "07  Sze\n_ _ Group action, the symbolof multitude.\n_ _ \n_ _ \n_ _ \n___ \n_ _ \n", NULL };
char *subDes08[128]={ "08  Pi\n_ _ Union, concord, the symbol of collaboration.\n___ \n_ _ \n_ _ \n_ _ \n_ _ \n", NULL };
char *subDes09[128]={ "09  Hsiao Kao\n___ Minor restraint, the symbol of taming force.\n___ \n_ _ \n___ \n___ \n___ \n", NULL };
char *subDes10[128]={ "10  Li\n___ Treading carefully, the symbol of deliberate action.\n___ \n___ \n_ _ \n___ \n___ \n", NULL };
char *subDes11[128]={ "11  Thai\n_ _ Peace, progress, the symbol of success.\n_ _ \n_ _ \n___ \n___ \n___ \n", NULL };
char *subDes12[128]={ "12  Phi\n___ Retrogression, stagnation, the symbol of failure.\n___ \n___ \n_ _ \n_ _ \n_ _ \n", NULL };
char *subDes13[128]={ "13  Thung Zan\n___ Companionship, the symbol of community.\n___ \n___ \n___ \n_ _ \n___ \n", NULL };
char *subDes14[128]={ "14  Ta Yu\n___ Great possesion, the symbol of abundance.\n_ _ \n___ \n___ \n___ \n___ \n", NULL };
char *subDes15[128]={ "15  Khien\n_ _ Modesty, the symbol of humility.\n_ _ \n_ _ \n___ \n_ _ \n_ _ \n", NULL };
char *subDes16[128]={ "16  Yu\n_ _ Harmonious joy, the symbol of enthusiasm.\n_ _ \n___ \n_ _ \n_ _ \n_ _ \n", NULL };
char *subDes17[128]={ "17  Sui\n_ _ Following, the symbol of succession.\n___ \n___ \n_ _ \n_ _ \n___ \n", NULL };
char *subDes18[128]={ "18  Ku\n___ Decaying, destroying, the symbol of major power.\n_ _ \n_ _ \n___ \n___ \n___ \n", NULL };
char *subDes19[128]={ "19  Lin\n_ _ Approach, the symbol of advance.\n_ _ \n_ _ \n_ _ \n___ \n___ \n", NULL };
char *subDes20[128]={ "20  Kwan\n___ Observation, the symbol of contemplation.\n___ \n_ _ \n_ _ \n_ _ \n_ _ \n", NULL };
char *subDes21[128]={ "21  Shih Ho\n___ Biting through, the symbol of criminal proceedings.\n_ _ \n___ \n_ _ \n_ _ \n___ \n", NULL };
char *subDes22[128]={ "22  Pi\n___ Ornamental, the symbol of model.\n_ _ \n_ _ \n___ \n_ _ \n___ \n", NULL };
char *subDes23[128]={ "23  Po\n___ Collapse, splitting apart, the symbol of dispersion.\n_ _ \n_ _ \n_ _ \n_ _ \n_ _ \n", NULL };
char *subDes24[128]={ "24  Fu\n_ _ Returning, the symbol of reversal.\n_ _ \n_ _ \n_ _ \n_ _ \n___ \n", NULL };
char *subDes25[128]={ "25  Wu Wang\n___ Freedom from error, the symbol of innocence.\n___ \n___ \n_ _ \n_ _ \n___ \n", NULL };
char *subDes26[128]={ "26  Ta Khu\n___ Major restraint, the symbol of great taming force.\n_ _ \n_ _ \n___ \n___ \n___ \n", NULL };
char *subDes27[128]={ "27  I\n___ Nourishment, the symbol of sustenance.\n_ _ \n_ _ \n_ _ \n_ _ \n___ \n", NULL };
char *subDes28[128]={ "28  Ta Kwo\n_ _ Large excess, the symbol of major preponderance.\n___ \n___ \n___ \n___ \n_ _ \n", NULL };
char *subDes29[128]={ "29  Khan\n_ _ Abysmal, the symbol of sinking.\n___ \n_ _ \n_ _ \n___ \n_ _ \n", NULL };
char *subDes30[128]={ "30  Li\n___ Clinging, brightness,, the symbol of adherence, or of fire and light.\n_ _ \n___ \n___ \n_ _ \n___ \n", NULL };
char *subDes31[128]={ "31  Hsien\n_ _ Influence, wooing, the symbol of mutual influence.\n___ \n___ \n___ \n_ _ \n_ _ \n", NULL };
char *subDes32[128]={ "32  Hang\n_ _ Constancy, duration, the symbol of perserverance.\n_ _ \n___ \n___ \n___ \n___ \n", NULL };
char *subDes33[128]={ "33  Thun\n___ Retreat, the symbol of regression.\n___ \n___ \n___ \n_ _ \n_ _ \n", NULL };
char *subDes34[128]={ "34  Ta Kwang\n_ _ Great strength, the symbol of major power.\n_ _ \n___ \n___ \n___ \n___ \n", NULL };
char *subDes35[128]={ "35  Bin\n___ Advance, the symbol of progress.\n_ _ \n___ \n_ _ \n_ _ \n_ _ \n", NULL };
char *subDes36[128]={ "36  Ming I\n_ _ Darkening of the light, the symbol of lack of appreciation.\n_ _ \n_ _ \n___ \n_ _ \n___ \n", NULL };
char *subDes37[128]={ "37  Kia Zan\n___ Members of a family, the symbol of family.\n___ \n_ _ \n___ \n_ _ \n___ \n", NULL };
char *subDes38[128]={ "38  Khwei\n___ Division and disunion, the symbol of opposition.\n_ _ \n___ \n_ _ \n___ \n___ \n", NULL };
char *subDes39[128]={ "39  Kien\n_ _ Inhibition, obstruction, the symbol of difficulty.\n___ \n_ _ \n___ \n_ _ \n_ _ \n", NULL };
char *subDes40[128]={ "40  Kieh\n_ _ Loosening, the symbol of deliverance.\n_ _ \n___ \n_ _ \n___ \n_ _ \n", NULL };
char *subDes41[128]={ "41  Sun\n___ Decrease, lessoning, the symbol of diminution.\n_ _ \n_ _ \n_ _ \n___ \n___ \n", NULL };
char *subDes42[128]={ "42  Yi\n___ Increase, the symbol of addition.\n___ \n_ _ \n_ _ \n_ _ \n___ \n", NULL };
char *subDes43[128]={ "43  Kwai\n_ _ Break-through, the symbol of resoluteness.\n___ \n___ \n___ \n___ \n___ \n", NULL };
char *subDes44[128]={ "44  Kau\n___ Meeting, intercourse, the symbol of coming to meet.\n___ \n___ \n___ \n___ \n_ _ \n", NULL };
char *subDes45[128]={ "45  Shui\n_ _ Gathering together, the symbol of collection.\n___ \n___ \n_ _ \n_ _ \n_ _ \n", NULL };
char *subDes46[128]={ "46  Shang\n_ _ Rising and advancing, the symbol of pushing upward.\n_ _ \n_ _ \n___ \n___ \n_ _ \n", NULL };
char *subDes47[128]={ "47  Khwan\n_ _ Oppression, the symbol of repression.\n___ \n___ \n_ _ \n___ \n_ _ \n", NULL };
char *subDes48[128]={ "48  Bing\n_ _ Well, the symbol of source.\n___ \n_ _ \n___ \n___ \n_ _ \n", NULL };
char *subDes49[128]={ "49  Ko\n_ _ Revolution, the symbol of change.\n___ \n___ \n___ \n_ _ \n___ \n", NULL };
char *subDes50[128]={ "50  Ting\n___ Cauldron, the symbol of nourishment.\n_ _ \n___ \n___ \n___ \n_ _ \n", NULL };
char *subDes51[128]={ "51  Kaan\n_ _ Shock, the symbol of exciting power.\n_ _ \n___ \n_ _ \n_ _ \n___ \n", NULL };
char *subDes52[128]={ "52  Kan\n___ Checking, keeping still, the symbol of stability.\n_ _ \n_ _ \n___ \n_ _ \n_ _ \n", NULL };
char *subDes53[128]={ "53  Kien\n___ Progressive advance, the symbol of gradual progress.\n___ \n_ _ \n___ \n_ _ \n_ _ \n", NULL };
char *subDes54[128]={ "54  Kwei Mei\n_ _ Marrying maiden, the symbol of marriage.\n_ _ \n___ \n_ _ \n___ \n___ \n", NULL };
char *subDes55[128]={ "55  Fang\n_ _ Abundance, the symbol of prosperity.\n_ _ \n___ \n___ \n_ _ \n___ \n", NULL };
char *subDes56[128]={ "56  Lu\n___ Wanderer, the symbol of wandering.\n_ _ \n___ \n___ \n_ _ \n_ _ \n", NULL };
char *subDes57[128]={ "57  Suhn\n___ Mildness, the symbol of penetration.\n___ \n_ _ \n___ \n___ \n_ _ \n", NULL };
char *subDes58[128]={ "58  Tui\n_ _ Joy, lake, the symbol of pleasure.\n___ \n___ \n_ _ \n___ \n___ \n", NULL };
char *subDes59[128]={ "59  Hwan\n___ Dissolution, the symbol of dispersion.\n___ \n_ _ \n_ _ \n___ \n_ _ \n", NULL };
char *subDes60[128]={ "60  Keeh\n_ _ Regulation, limitation, the symbol of regulated restriction.\n___ \n_ _ \n_ _ \n___ \n___ \n", NULL };
char *subDes61[128]={ "61  Kung Fu\n___ Central sincerity, the symbol of truth.\n___ \n_ _ \n_ _ \n___ \n___ \n", NULL };
char *subDes62[128]={ "62  Hsiao Kwo\n_ _ Small excess, the symbol of minor preponderance.\n_ _ \n___ \n___ \n_ _ \n_ _ \n", NULL };
char *subDes63[128]={ "63  Ki Bi\n_ _ Completion, consummation, the symbol of accomplishment.\n___ \n_ _ \n___ \n_ _ \n___ \n", NULL };
char *subDes64[128]={ "64  Wei Bi\n___ Not quite up to accomplishment, the symbol of what is not yet \n_ _ accomplished.\n___ \n_ _ \n___ \n_ _ \n", NULL };

main(argc,argv)
int argc;
char *argv[];
{
        if(BadArgs(argc, argv))
            randomtoss(argc, argv);
        else {
            Usage("IChing");
        }
}

BadArgs(argc, argv)
int argc; char *argv[];
{
        if ( argc > 1 )
                return(FALSE);
        else
                return(TRUE);
}

Usage(progName)
char *progName;
{
    printf("%s [33;40mV%s by %s  FREEWARE. ALL RIGHTS RESERVED.\n",
        PROGRAM, VERSION, AUTHOR);
    printf("Usage: IChing<RETURN>...and receive your destiny\n");
    exit(5);
}

randomtoss(argc, argv)
int argc; char *argv[];
{
    ULONG t, i;
    unsigned x;
    i = 63;

    /* Here's my random number generator it uses the time routine to give me
       a different seed every second. I then AND it with 63 to get a range
       from 0-63 but I want 1-64 so I add 1 to the result. */

    x = (((srand(time(&t))) & i) + 1);

    switch ( x ) {
        case 1:
        printf("%s\n", (*subDes01));
        break;
        case 2:
        printf("%s\n", (*subDes02));
        break;
        case 3:
        printf("%s\n", (*subDes03));
        break;
        case 4:
        printf("%s\n", (*subDes04));
        break;
        case 5:
        printf("%s\n", (*subDes05));
        break;
        case 6:
        printf("%s\n", (*subDes06));
        break;
        case 7:
        printf("%s\n", (*subDes07));
        break;
        case 8:
        printf("%s\n", (*subDes08));
        break;
        case 9:
        printf("%s\n", (*subDes09));
        break;
        case 10:
        printf("%s\n", (*subDes10));
        break;
        case 11:
        printf("%s\n", (*subDes11));
        break;
        case 12:
        printf("%s\n", (*subDes12));
        break;
        case 13:
        printf("%s\n", (*subDes13));
        break;
        case 14:
        printf("%s\n", (*subDes14));
        break;
        case 15:
        printf("%s\n", (*subDes15));
        break;
        case 16:
        printf("%s\n", (*subDes16));
        break;
        case 17:
        printf("%s\n", (*subDes17));
        break;
        case 18:
        printf("%s\n", (*subDes18));
        break;
        case 19:
        printf("%s\n", (*subDes19));
        break;
        case 20:
        printf("%s\n", (*subDes20));
        break;
        case 21:
        printf("%s\n", (*subDes21));
        break;
        case 22:
        printf("%s\n", (*subDes22));
        break;
        case 23:
        printf("%s\n", (*subDes23));
        break;
        case 24:
        printf("%s\n", (*subDes24));
        break;
        case 25:
        printf("%s\n", (*subDes25));
        break;
        case 26:
        printf("%s\n", (*subDes26));
        break;
        case 27:
        printf("%s\n", (*subDes27));
        break;
        case 28:
        printf("%s\n", (*subDes28));
        break;
        case 29:
        printf("%s\n", (*subDes29));
        break;
        case 30:
        printf("%s\n", (*subDes30));
        break;
        case 31:
        printf("%s\n", (*subDes31));
        break;
        case 32:
        printf("%s\n", (*subDes32));
        break;
        case 33:
        printf("%s\n", (*subDes33));
        break;
        case 34:
        printf("%s\n", (*subDes34));
        break;
        case 35:
        printf("%s\n", (*subDes35));
        break;
        case 36:
        printf("%s\n", (*subDes36));
        break;
        case 37:
        printf("%s\n", (*subDes37));
        break;
        case 38:
        printf("%s\n", (*subDes38));
        break;
        case 39:
        printf("%s\n", (*subDes39));
        break;
        case 40:
        printf("%s\n", (*subDes40));
        break;
        case 41:
        printf("%s\n", (*subDes41));
        break;
        case 42:
        printf("%s\n", (*subDes42));
        break;
        case 43:
        printf("%s\n", (*subDes43));
        break;
        case 44:
        printf("%s\n", (*subDes44));
        break;
        case 45:
        printf("%s\n", (*subDes45));
        break;
        case 46:
        printf("%s\n", (*subDes46));
        break;
        case 47:
        printf("%s\n", (*subDes47));
        break;
        case 48:
        printf("%s\n", (*subDes48));
        break;
        case 49:
        printf("%s\n", (*subDes49));
        break;
        case 50:
        printf("%s\n", (*subDes50));
        break;
        case 51:
        printf("%s\n", (*subDes51));
        break;
        case 52:
        printf("%s\n", (*subDes52));
        break;
        case 53:
        printf("%s\n", (*subDes53));
        break;
        case 54:
        printf("%s\n", (*subDes54));
        break;
        case 55:
        printf("%s\n", (*subDes55));
        break;
        case 56:
        printf("%s\n", (*subDes56));
        break;
        case 57:
        printf("%s\n", (*subDes57));
        break;
        case 58:
        printf("%s\n", (*subDes58));
        break;
        case 59:
        printf("%s\n", (*subDes59));
        break;
        case 60:
        printf("%s\n", (*subDes60));
        break;
        case 61:
        printf("%s\n", (*subDes61));
        break;
        case 62:
        printf("%s\n", (*subDes62));
        break;
        case 63:
        printf("%s\n", (*subDes63));
        break;
        case 64:
        printf("%s\n", (*subDes64));
        break;
        default:
        printf("No Fortune! Good Luck!\n");
        break;
    }
}
