home *** CD-ROM | disk | FTP | other *** search
-
- /******* Konflikt-Morphologie in Quick-C, V.1.01 *******/
- /* (c) 1989 Ulrich Schmitz & toolbox */
- /* Zum Compilieren und Linken Befehlszeilen-Compiler ver- */
- /* wenden! Folgende Kommandos als Batchjob abspeichern */
- /* (C.BAT) und dann mit dem Programmnamen als Parameter */
- /* aufrufen (ohne Extension). Beispiel: c listing */
- /* (Jetzt kommt der Text für den Batch:) */
- /* qcl /c /AL /Ot %1.c */
- /* link %1 ,,, /STACK:0x4800 */
- /**********************************************************/
-
- #include <dos.h>
- #include <stdio.h>
- #include <graph.h>
- #include <conio.h>
-
- #define MOUSE 0x33
- #define MAX_FELDER 150
- #define MONO_SEG 0xB0000000
- #define COLOR_SEG 0xB8000000
- #define DELETE (char)8
- #define SPACE (char)32
-
- union REGS reg;
-
- /****** GLOBALE VARIABLEN *********************************/
-
- int xp[8]={ 0,2,14,26,38,50,62,74 },
- Wahl[MAX_FELDER], alte_Farbe;
- char ff[11]=" ";
- void vm_init (void);
- int vm_modus (void);
-
- static int
- far *intptr_v_ram;
-
- /* - - - - - - - - Strukturen - - - - - - - - - - - - - */
-
- struct Morphos
- {
- char c[12];
- };
-
- struct Morphos Feld[MAX_FELDER];
-
- /* - - - - - - - Unterprogramme - - - - - - - - - - - - */
-
- /* ------------------------------------------------------ */
-
- void init_feld(feld)
-
- char feld[];
- {
- int i;
- for( i=0 ;i <= 12 ;i++ )
- feld[i] = NULL;
-
- for(i=7; i<=MAX_FELDER - 7; i+=7)
- Wahl[i] = 0;
-
- }
-
- /* ------------------------------------------------------ */
- /* Funktion ließt 'n'-Zeichen von der Tastatur und sperrt */
- /* bei Mehreingaben. DEL und BACKSPACE werden interpre- */
- /* tiert */
- /* Eingabe: char *feld -> speichert die eingegeb. Zeichen */
- /* int n -> enthält die Anzahl der Zeichen */
- /* Ausgabe: KEINE, String wird mit '\0' abgeschlossen !!! */
- /* ------------------------------------------------------ */
-
- void form_input(feld,n)
-
- char feld[];
- int n;
-
- {
- char cc;
- int i, c;
- start:
- feld[0]=NULL;
- for(i = 0; i <= n-1; i++){
-
- cc=getch();
- c = (int)cc;
-
- if( (c == 0) || (c == 8) || (c == 13) )
- /* DEL oder BACKSPACE oder CR */
- {
- switch(c){
- case 0:
- cc = getch();
- if((i >= 1) && (cc == 'S')){
- putchar(DELETE);
- putchar(SPACE);
- putchar(DELETE);
- feld[i-1]=' ';}
- i-=2;
- break;
-
- case 8:
- if(i >= 1){
- putchar(DELETE);
- putchar(SPACE);
- putchar(DELETE);
- feld[i-1]=' ';}
- i-=2;
- break;
-
- case 13:
- feld[i]=NULL;
- i = n;
- break;
- }
- }
-
- else
- if (i >= 0){ /* normaler Buchstabe */
- putchar(cc);
- feld[i]=cc;
- }
-
- if (i < 0) /* ABBRUCH, am Anfang DEL ect. */
- i = n;
-
- }
- feld[i]=NULL;
- }
- /* ------------------------------------------------------ */
-
- void Mouse_ON()
- {
- reg.x.ax = 0x01;
- /* Funktionsnummer 1: Maus ein */
- int86(MOUSE, ®, ®);
- }
- /* ------------------------------------------------------ */
-
- int vm_modus (void)
- {
- union REGS regs;
- regs.h.ah = 0x0F;
- int86(0x10, ®s, ®s);
- return(regs.h.al);
- }
- /* ------------------------------------------------------ */
-
- void vm_init (void)
- {
- if (vm_modus() == 7)
- {
- intptr_v_ram = (int far*) MONO_SEG;
- }
-
- else
- {
- intptr_v_ram = (int far*) COLOR_SEG;
- }
- }
- /* ------------------------------------------------------ */
-
- void screen_buffer( int far *ziel)
- {
- register s;
- int far *start;
- int zeile;
-
- for (zeile=0; zeile <= 24; zeile++){
- start = intptr_v_ram + zeile * 80;
- for ( s=0; s<= 79; s++)
- *ziel++ = *start++;
- }
- }
- /* ------------------------------------------------------ */
-
- void buffer_screen( int far *quelle)
- {
- register s;
- int far *start;
- int zeile;
-
- for (zeile=0; zeile <= 24; zeile++){
- start = intptr_v_ram + zeile * 80;
- for ( s=0; s<= 79; s++)
- *start++ = *quelle++;
- }
- }
- /* ------------------------------------------------------ */
-
- void Mouse_OFF()
- {
- reg.x.ax = 0x02;
- /* Funktionsnummer 2: Maus aus */
- int86(MOUSE, ®, ®);
- }
- /* ------------------------------------------------------ */
-
- int Mouse_install()
- { /* ax = -1 :installiert
- ax = 0 :Maustreiber fehlt */
- reg.x.ax = 0x00;
- int86(MOUSE, ®, ®);
- return(reg.x.ax);
- }
- /* ------------------------------------------------------ */
-
- int X_position()
- {
- reg.x.ax = 0x05;
- /* Funktionsnummer 5: Mausinfo */
- reg.x.bx = 0x00;
- /* linke Taste */
- int86(MOUSE, ®, ®);
- return(reg.x.cx);
- }
- /* ------------------------------------------------------ */
- int Mouse_Button()
- {
- reg.x.ax = 0x03;
- /* Funktionsnummer 3: Maustaste */
- int86(MOUSE, ®, ®);
- return(reg.x.bx);
- /* 1=linke, 2=rechte Maustaste */
- }
- /* ------------------------------------------------------ */
-
- int Y_position()
- {
- reg.x.ax = 0x05;
- /* Funktionsnummer 5: Mausinfo */
- reg.x.bx = 0x00;
- /* linke Taste */
- int86(MOUSE, ®, ®);
- return(reg.x.dx);
- }
- /* ------------------------------------------------------ */
-
- void Cursor_Text()
- {
- reg.x.ax = 0x0A;
- /* Funktionsnummer 10: Textcursor */
- reg.x.bx = 0x01;
- /* Hardware-Cursor */
- reg.x.cx = 0x00;
- /* Bildschirm Maskenwert */
- reg.x.dx = 0x0D;
- /* Cursor Maskenwert */
- int86(MOUSE, ®, ®);
- }
- /* ------------------------------------------------------ */
-
- void Cursor()
- {
- reg.x.ax = 0x0A;
- /* Funktionsnummer 10: Textcursor */
- reg.x.bx = 0x01;
- /* Hardware-Cursor */
- reg.x.cx = 0x0C;
- /* Bildschirm Maskenwert */
- reg.x.dx = 0x0D;
- /* Cursor Maskenwert */
- int86(MOUSE, ®, ®);
- }
- /* ------------------------------------------------------ */
-
- void Cursor_OFF()
- {
- reg.x.ax = 0x0A;
- /* Funktionsnummer 10: Textcursor */
- reg.x.bx = 0x01;
- /* Hardware-Cursor */
- reg.x.cx = 0xFF;
- /* Bildschirm Maskenwert */
- reg.x.dx = 0xFF;
- /* Cursor-Maskenwert */
- int86(MOUSE, ®, ®);
- }
- /* ------------------------------------------------------ */
-
- void Mouse_Text()
- {
- static int ix;
- ix++;
-
- if (ix <= 250){
- reg.x.cx = 0x0C;
- reg.x.dx = 0x0D;
- }
-
- else {
- reg.x.cx = 0x01;
- reg.x.dx = 0x0D;
- if (ix == 500)
- ix = 0;
- }
-
- reg.x.ax = 0x0A;
- /* Funktionsnummer 10: Textcursor */
- reg.x.bx = 0x01;
- /* Hardware-Cursor */
- int86(MOUSE, ®, ®);
- }
- /* ------------------------------------------------------ */
-
- void Eingabe_Maske()
- {
- int i;
-
- Cursor_Text();
- Mouse_OFF();
-
- _settextwindow(1,1,25,80);
-
- _wrapon(_GWRAPOFF);
- _clearscreen( _GCLEARSCREEN);
-
- _settextposition(1,1);
- _outtext("<<< Konflikt-Morphologie, ein toolbox-Utility"\
- " von Ulrich Schmitz (C) 1989 >>>");
-
- _settextposition(2,1);
- _outtext("░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ "\
- " ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
- _settextcolor(15);
- _settextposition(2,33);
- _outtext("EINGABE-MASKE");
-
- _settextcolor(alte_Farbe);
- _settextposition(3,1);
- _outtext("░░░░░░░░░░░░░ Forderungen nach Wichtigkeit: 1"\
- " sehr wichtig, 5 unwichtig ░ 1..9 ░");
-
- _settextposition(4,1);
- _outtext("░ PARAMETER ░ <1> ░ <2> ░ <3> "\
- " ░ <4> ░ <5> ░ Wert ░");
-
- for (i=1; i<=20; i++){
-
- _settextposition(4+i,1);
- _outtext("░ ░ ░ ░"\
- " ░ ░ ░ ░");
- }
- _settextposition(25,1);
- _outtext("░░░░░ Um die Eingabe zu beenden, letzten oder"\
- " leeren Parameter eingeben! ░░░░░");
-
- }
- /* ------------------------------------------------------ */
-
- int Umrechnung(int f)
- {
- int x;
- x = (int)*Feld[f].c;
- x-=48;
-
- if ((x < 0) || (x > 9))
- x = 1;
- return(x);
- }
- /* ------------------------------------------------------ */
-
- void Eingabe()
- {
- int i=0, z, f;
-
- for (z=1; z <= MAX_FELDER; z++)
- init_feld(Feld[z].c);
-
- for (z=1; z<=20; z++){
- do {
- i++;
- f = ((z-1) * 7) + i;
- _settextposition(z+4,xp[i]);
-
- if(i==7){
- printf("->");
- form_input(Feld[f].c,1);
- Wahl[f] = Umrechnung(f);
- }
-
- else
- form_input(Feld[f].c,11);
-
- } while( ((*Feld[f].c != NULL)||(i != 1)) && (i <= 6) );
-
- if ((*Feld[f].c == NULL) && (i == 1))
- z=21;
- i=0;
- }
-
- z=0;
- for(i=7; i<=MAX_FELDER - 7; i+=7){
- z++;
- _settextposition(z+4,74);
- if (Wahl[i] != 0)
- printf("░ %d ░░",Wahl[i]);
- else {
-
- _settextposition(z+4,2);
- printf("░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"\
- "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
-
- }
- }
- Cursor_OFF();
- }
- /* ------------------------------------------------------ */
-
- void Loesung()
- {
- int X_Pos,Y_Pos, f, fy, fn, x=0, i, n;
-
- _settextcolor(15);
- _settextposition(2,33);
- _outtext("AUSWAHL-MASKE");
-
- _settextposition(25,1);
- _outtext("░ Lösungen anwählen <-LINKE MAUSTASTE"\
- " RECHTE MAUSTASTE->Berechnung starten ░");
-
- _settextcolor(alte_Farbe);
- Mouse_ON();
-
- while(Mouse_Button() != 2){
- X_Pos = X_position();
- Y_Pos = Y_position();
- Mouse_Text();
- Mouse_ON();
- x = 1;
-
- if (Mouse_Button() == 1){
- for (i=104; i<=488; i=i+96){
- x++;
- if ( (X_Pos >= i) && (X_Pos <= (i + 80)) ) {
- fy = (Y_Pos / 8) - 4;
- f = fy * 7 + x;
- _settextcolor(alte_Farbe);
- for (n=2; n<=6; n++){
- /* Initialisieren */
- _settextposition(fy+5,n*12-10);
- fn = fy * 7 + n;
- if (Feld[fn].c)
- _outtext(Feld[fn].c);
-
- Wahl[fn] = 0;
- }
- _settextcolor(15);
- /* Feld auswaehlen */
- _settextposition(fy+5,x*12-10);
- _outtext(Feld[f].c);
- Wahl[f] = 1;
- }
- }
- }
- }
- }
- /* ------------------------------------------------------ */
-
- int Ergebnis()
- {
- int z, i, ii, Nutzwert_A, Nutzwert_B, x, c;
-
- _settextwindow(7,19,20,59); /* Ausgabefenster definieren */
- _settextcolor(15);
- _settextposition(1,1);
- _outtext(" ╔═════════════════╗ ");
- _settextposition(2,1);
- _outtext("╔══════════╣ E R G E B N I S ╠══════════╗");
- _settextposition(3,1);
- _outtext("║ ╚═════════════════╝ ║");
-
- for(z=4; z<=12; z++){
- _settextposition(z,1);
- _outtext("║ ║");
- }
- _settextposition(13,1);
- _outtext("╚═══════════════════════════════════════╝");
-
- _settextcolor(alte_Farbe);
-
- /*- Berechnung der Nutzwerte : = Summe der Produkte von -*/
- /*- Parametergewicht * Skalenwert -*/
-
- Nutzwert_A = 0;
- Nutzwert_B = 0;
-
- for(i=1; i<=MAX_FELDER - 7; i+=7){
- for(ii = 1; ii<=5; ii++){
- if (Wahl[i+ii] == 1)
- x=ii;
- }
- Nutzwert_A = Nutzwert_A + (x * Wahl[i+6]);
- Nutzwert_B = Nutzwert_B + ((6-x) * Wahl[i+6]);
- x=0;
- }
- _settextposition(5,3);
- printf("Die gewählte Lösung erzielte für Sie ");
- _settextposition(6,3);
- printf("einen Nutzwert von %d zu %d"\
- " Punkten.",Nutzwert_B, Nutzwert_A);
-
- _settextcolor(15);
- _settextposition(9,5);
- _outtext("(1) -> Andere Lösung berechnen.");
- _settextposition(10,5);
- _outtext("(2) -> Neuen Konflikt eingeben.");
- _settextposition(11,5);
- _outtext("(3) -> Programm beenden. ");
-
- _settextwindow(1,1,25,80);
- while((c != '1')&&(c != '2')&&(c != '3'))
- c = getch();
-
- return(c - 48);
- }
-
- /* ------------------------------------------------------ */
-
- /******* H A U P T P R O G R A M M ********************/
-
- main()
- {
- int i, screen[2000];
-
- _setvideomode( _MRES16COLOR);
- vm_init();
- alte_Farbe = _gettextcolor();
-
- if(Mouse_install() == 0)
-
- { printf("Programm-Ende,"\
- " da kein Maustreiber installiert! ");
- goto ENDE; }
-
-
- START:
-
- Eingabe_Maske();
- Eingabe();
-
-
- AUSWAHL:
-
- Loesung();
-
- Mouse_OFF();
- Cursor_OFF();
- screen_buffer(screen);
- /* Bildschirm sichern */
- i = Ergebnis();
- buffer_screen(screen);
- if (i == 1)
- goto AUSWAHL;
- else
- if (i == 2)
- goto START;
-
- _settextcolor(alte_Farbe);
- _clearscreen( _GCLEARSCREEN);
- Cursor();
- ENDE: return(0);
- }
-
- /******* E N D E ***************************************/