|
Totaal programma
PC3270.H
1 /***************************************************************************/
2 /* PC3270.H - Header file for PC 3270 protocol support */ 3 /***************************************************************************/
4 #define VOID void 5 #define FALSE (1!=1) 6 #define TRUE (1==1) 7 8 /***************************************************************************/
9 /* Highligting */ 10 /***************************************************************************/
11 #define NORMAL 0 12 #define BRIGHT 1 13 #define UNDERSCORE 4 14 #define
BLINK 5 15 #define REVERSE 7 16 #define HIDDEN 8 17 18 /***************************************************************************/
19 /* Type */ 20 /***************************************************************************/
21 #define MIXED 10 22 #define UPCASE 11 23 #define PROTECTED 12 24 25 /***************************************************************************/
26 /* Colors */ 27 /***************************************************************************/
28 #define DEFAULT 30 29 #define RED 31 30 #define GREEN 32 31 #define YELLOW
33 32 #define BLUE 34 33 #define PINK 35 34 #define TURQUOISE 36 35 #define
WHITE 37 36 37 /***************************************************************************/
38 /* Action codes */ 39 /***************************************************************************/
40 #define NOACTION 40 41 #define TABFORWARD 41 42 #define TABBACKWARD 42
43 #define LOOKPROTECTED 43 44 #define GOBACK 49 45 46 /***************************************************************************/
47 /* Key codes */ 48 /***************************************************************************/
49 #define ENTER 0x0D 50 #define TAB 0x09 51 #define ESCAPE 0x1B 52 53 #define
PFKEY 0x00 54 #define BACKTAB 0x0F 55 #define PF1 0x3B 56 #define PF2 0x3C
57 #define PF3 0x3D 58 #define PF4 0x3E 59 #define PF5 0x3F 60 #define PF6
0x40 61 #define PF7 0x41 62 #define PF8 0x42 63 #define PF9 0x43 64 #define
PF10 0x44 65 #define PF11 0x85 66 #define PF12 0x86 67 68 #define ARROWKEY
0xE0 69 #define ARROWUP 0x48 70 #define ARROWLEFT 0x4B 71 #define ARROWRIGHT
0x4D 72 #define ARROWDOWN 0x50 73 74 75 /***************************************************************************/
76 /* Type definitions */ 77 /***************************************************************************/
78 79 typedef int BOOL; 80 81 typedef int SHORT; 82 83 typedef char CHAR;
84 typedef char *PSZ; 85 86 typedef int COLOR; 87 88 typedef int INTENSITY;
89 90 typedef int KEY; 91 typedef KEY *PKEY; 92 93 typedef struct _field
{ 94 struct _field *pFieldPrev; /* pointer to privious field */ 95 struct
_field *pFieldNext; /* pointer to next field */ 96 SHORT sRow; /* field
row */ 97 SHORT sColumn; /* field column */ 98 INTENSITY Intensity; /* intensity
attribute */ 99 COLOR Color; /* color attribute */ 100 PSZ pszString; /*
pointer to string data */ 101 SHORT sLength; /* field length */ 102 } FIELD;
103 typedef FIELD *PFIELD; /* pointer to field struct */ 104 105 typedef
struct _screen { 106 PFIELD pFieldFirst; /* pointer to first field */ 107
PFIELD pFieldLast; /* pointer to last field */ 108 SHORT sNrOfFields; /*
number of fields in list */ 109 SHORT sRows; /* number of rows on screen
*/ 110 SHORT sColumns; /* number of columns on screen */ 111 } SCREEN; 112
typedef SCREEN *PSCREEN; /* pointer to screen struct */ 113 114 115 /***************************************************************************/
116 /* Function prototypes */ 117 /***************************************************************************/
118 119 VOID InitScreen (PSCREEN); 120 121 VOID ConField (PSCREEN, SHORT,
SHORT, INTENSITY, COLOR, PSZ); 122 123 VOID VarField (PSCREEN, SHORT, SHORT,
INTENSITY, COLOR, PSZ, SHORT); 124 125 VOID Display (PSCREEN, SHORT, SHORT,
PKEY); 126 127 VOID DropField (PSCREEN, SHORT, SHORT); 128 129 VOID DropScreen
(PSCREEN); 130 131 /***** (C) Frans Fokkenrood - Januari 1993 *********************************/
YAHTZEE.H
1 /***************************************************************************/
2 /* YAHTZEE.H - Tripple YAHTZEE in C op basis van PC3270 support */ 3 /***************************************************************************/
4 5 /***************************************************************************/
6 /* Macro defines */ 7 /***************************************************************************/
8 #define ENEN 1 9 #define TWEEEN 2 10 #define DRIEEN 3 11 #define VIEREN
4 12 #define VIJVEN 5 13 #define ZESSEN 6 14 #define THREE_OF_A_KIND 7 15
#define CARRE 8 16 #define FULL_HOUSE 9 17 #define KLEINE_STRAAT 10 18 #define
GROTE_STRAAT 11 19 #define Y_A_H_T_Z_E_E 12 20 #define CHANCE 13 21 22 #define
GOED 21 23 #define FOUT 22 24 #define JA 23 25 #define NEE 24 26 #define
SPEL 25 27 #define WORP 26 28 29 #define YAHTZEE 31 30 #define HELP 32 31
#define QUIT 33 32 33 /***************************************************************************/
34 /* Function prototypes */ 35 /***************************************************************************/
36 SHORT ControleerYahtzee (); 37 SHORT Dobbel (); 38 SHORT LeesScherm ();
39 SHORT ProgrammaInit (SHORT); 40 SHORT VerwerkHelp (); 41 SHORT VerwerkQuit
(); 42 SHORT VerwerkSpel (); 43 SHORT VerwerkWorp (); 44 SHORT VerwerkYahtzee
(); 45 SHORT ZendScherm (); 46 47 /***** (C) Frans Fokkenrood - Januari
1993 *********************************/
YZHELP.H
1 /***************************************************************************/
2 /* YZHELP.H - Help voor Tripple YAHTZEE in C (PC3270 support) */ 3 /***************************************************************************/
4 5 /***************************************************************************/
6 /* Macro defines */ 7 /***************************************************************************/
8 #define MAXLINES 18 9 10 #define GOED 21 11 #define FOUT 22 12 13 #define
YZHELP 31 14 #define QUIT 32 15 #define BACKWARD 33 16 #define FORWARD 34
17 18 #define UNDEFINED 99 19 20 /***************************************************************************/
21 /* Type definitions */ 22 /***************************************************************************/
23 typedef struct _hlist { 24 SHORT sLineNr; /* number of text lines */
25 PSZ pszLine; /* text line */ 26 struct _hlist *pPrior; /* pointer to
previous text line */ 27 struct _hlist *pNext; /* pointer to next text line
*/ 28 } HLIST; 29 typedef HLIST *PHLIST; /* pointer to hlist struct */ 30
31 32 /***************************************************************************/
33 /* Function prototypes */ 34 /***************************************************************************/
35 SHORT ControleerBackward (); 36 SHORT ControleerForward (); 37 SHORT
LeesScherm (); 38 SHORT ProgrammaInit (); 39 SHORT VerwerkBackward (); 40
SHORT VerwerkForward (); 41 SHORT VerwerkQuit (); 42 SHORT ZendScherm ();
43 44 /***** (C) Frans Fokkenrood - Januari 1993 *********************************/
DOBBEL.C
1 /***************************************************************************/
2 /* DOBBEL.C - Dobbelsteen simulatie */ 3 /***************************************************************************/
4 5 #include 6 7 int Dobbel () 8 { 9 static unsigned uSeed = 0;
10 int iDS; 11 12 if (uSeed == 0) 13 uSeed = (unsigned) time (NULL); 14
15 srand (uSeed); 16 iDS = (rand () % 6) + 1; 17 18 uSeed += iDS; 19 20
return (iDS); 21 22 } /* End Dobbel */ 23 24 /***** (C) Frans Fokkenrood
- Januari 1993 *********************************/
PC3270.C
1 /***************************************************************************/
2 /* PC3270.C - Functions for PC 3270 protocol support */ 3 /***************************************************************************/
4 5 #include 6 #include 7 #include "pc3270.h" 8 9 10
/***************************************************************************/
11 /* Subroutine to Initialize the screen */ 12 /***************************************************************************/
13 14 VOID InitScreen (pScreen) 15 PSCREEN pScreen; 16 { 17 18 printf ("\033[2J");
/* CLS */ 19 20 pScreen->pFieldFirst = NULL; 21 pScreen->pFieldLast = NULL;
22 pScreen->sNrOfFields = 0; 23 24 pScreen->sRows = 25; 25 pScreen->sColumns
= 80; 26 27 return; 28 29 } /* End InitScreen */ 30 31 32 /***************************************************************************/
33 /* Subroutine to place Constant field on the screen */ 34 /***************************************************************************/
35 36 VOID ConField (pScreen, sRow, sColumn, Intensity, Color, pszString)
37 PSCREEN pScreen; 38 SHORT sRow; 39 SHORT sColumn; 40 INTENSITY Intensity;
41 COLOR Color; 42 PSZ pszString; 43 { 44 45 printf ("\033[%d;%dm", Intensity,
Color); 46 printf ("\033[%d;%dH%s", sRow+1, sColumn+1, pszString); 47 48
return; 49 50 } /* End ConField */ 51 52 53 /***************************************************************************/
54 /* Subroutine to place Variable field on the screen */ 55 /***************************************************************************/
56 57 VOID VarField (pScreen, sRow, sColumn, Intensity, Color, pszString,
sLength) 58 PSCREEN pScreen; 59 SHORT sRow; 60 SHORT sColumn; 61 INTENSITY
Intensity; 62 COLOR Color; 63 PSZ pszString; 64 SHORT sLength; 65 { 66 PFIELD
pField; 67 68 /*************************************************************************/
69 /* Find the location of the field structure within the list */ 70 /*************************************************************************/
71 for (pField = pScreen->pFieldFirst; pField; pField = pField->pFieldNext)
{ 72 if ((sRow == pField->sRow) && (sColumn == pField->sColumn)) { 73 break;
74 } /* endif */ 75 } /* endfor */ 76 77 78 /*************************************************************************/
79 /* If NOT found then add a new field at the end of the linked list */
80 /*************************************************************************/
81 if (pScreen->sNrOfFields == 0) { /* empty list */ 82 pField = (PFIELD)
malloc (sizeof (FIELD)); 83 pField->pFieldPrev = NULL; 84 pField->pFieldNext
= NULL; 85 pScreen->pFieldFirst = pField; 86 pScreen->pFieldLast = pField;
87 } 88 else if (pField == NULL) { /* end of list */ 89 pField = (PFIELD)
malloc (sizeof (FIELD)); 90 pField->pFieldPrev = pScreen->pFieldLast; 91
pField->pFieldNext = NULL; 92 pScreen->pFieldLast->pFieldNext = pField;
93 pScreen->pFieldLast = pField; 94 } /* endif */ 95 96 97 /*************************************************************************/
98 /* Register the parameters of the variable field definition */ 99 /*************************************************************************/
100 pField->sRow = sRow; 101 pField->sColumn = sColumn; 102 pField->Intensity
= Intensity; 103 pField->Color = Color; 104 pField->pszString = pszString;
105 pField->sLength = sLength; 106 107 *(pField->pszString + sLength) =
'\0'; 108 109 110 /*************************************************************************/
111 /* Update the Field counter in the screen structure */ 112 /*************************************************************************/
113 (pScreen->sNrOfFields)++; 114 115 return; 116 117 } /* End VarField
*/ 118 119 120 /***************************************************************************/
121 /* Subroutine to Display the screen */ 122 /***************************************************************************/
123 124 VOID Display (pScreen, sRow, sColumn, pKeyPressed) 125 PSCREEN pScreen;
126 SHORT sRow; 127 SHORT sColumn; 128 PKEY pKeyPressed; 129 { 130 BOOL
fProtected; 131 BOOL fReady; 132 PFIELD pField; 133 SHORT sAction; 134 SHORT
sKey; 135 CHAR *pch; 136 137 /*************************************************************************/
138 /* Print the content of the variable fields on the screen */ 139 /*************************************************************************/
140 for (pField = pScreen->pFieldFirst; pField; pField = pField->pFieldNext)
{ 141 printf ("\033[%d;%dm", pField->Intensity, pField->Color); 142 printf
("\033[%d;%dH%s", 143 (pField->sRow)+1, (pField->sColumn)+1, pField->pszString);
144 } /* endfor */ 145 146 /*************************************************************************/
147 /* Locate the cursor on its initial position */ 148 /* Look if cursor
is located in an unprotected area of the screen */ 149 /*************************************************************************/
150 printf ("\033[%d;%dH", (sRow)+1, (sColumn)+1); 151 152 for (pField =
pScreen->pFieldFirst, pch = NULL, fProtected = TRUE; 153 pField; 154 pField
= pField->pFieldNext) { 155 if ((sRow == pField->sRow) && 156 (sColumn >=
pField->sColumn) && 157 (sColumn < pField->sColumn + pField->sLength)) {
158 pch = pField->pszString + sColumn - pField->sColumn; 159 fProtected
= FALSE; 160 break; 161 } /* endif */ 162 } /* endfor */ 163 164 /*************************************************************************/
165 /* Accept keystrokes from the keyboard until an Attention Key is pressed
*/ 166 /* First determine which key is pressed, then select its action.
*/ 167 /*************************************************************************/
168 for (fReady = FALSE; !fReady; ) { 169 sKey = getch (); 170 171 /***********************************************************************/
172 /* Determine the key type and its value */ 173 /***********************************************************************/
174 switch (sKey) { 175 case ENTER: 176 sAction = GOBACK; 177 break; 178
179 case TAB: 180 sAction = TABFORWARD; 181 break; 182 183 case PFKEY: 184
sKey = getch (); 185 if (sKey == BACKTAB) { 186 sAction = TABBACKWARD; 187
} else { 188 sAction = GOBACK; 189 } /* endif */ 190 break; 191 192 case
ESCAPE: 193 sKey = PF3; 194 sAction = GOBACK; 195 break; 196 197 case ARROWKEY:
198 sKey = getch (); 199 switch (sKey) { 200 case ARROWUP: 201 sRow--; 202
if (sRow < 0) { 203 sRow = pScreen->sRows - 1; 204 sColumn--; 205 } /* endif
*/ 206 sAction = LOOKPROTECTED; 207 break; 208 case ARROWDOWN: 209 sRow++;
210 if (sRow >= pScreen->sRows) { 211 sRow = 0; 212 sColumn++; 213 } /*
endif */ 214 sAction = LOOKPROTECTED; 215 break; 216 case ARROWRIGHT: 217
sColumn++; 218 if (sColumn >= pScreen->sColumns) { 219 sRow++; 220 sColumn
= 0; 221 } /* endif */ 222 pch++; 223 sAction = LOOKPROTECTED; 224 break;
225 case ARROWLEFT: 226 sColumn--; 227 if (sColumn < 0) { 228 sRow++; 229
sColumn = pScreen->sColumns - 1; 230 } /* endif */ 231 pch--; 232 sAction
= LOOKPROTECTED; 233 break; 234 } /* endswitch */ 235 break; 236 237 default:
238 if (fProtected) { 239 printf ("\a"); 240 sAction = NOACTION; 241 } else
{ 242 printf ("%c", sKey); 243 sColumn++; 244 *pch++ = sKey; 245 if (sColumn
< pField->sColumn + pField->sLength) { 246 sAction = NOACTION; 247 } else
{ 248 sAction = TABFORWARD; 249 } /* endif */ 250 } /* endif */ 251 break;
252 253 } /* endswitch */ 254 255 /***********************************************************************/
256 /* Select the appropriate action */ 257 /***********************************************************************/
258 switch (sAction) { 259 case NOACTION: 260 break; 261 262 case TABFORWARD:
263 pField = (pField->pFieldNext ? pField->pFieldNext 264 : pScreen->pFieldFirst);
265 if (pField) { 266 sRow = pField->sRow; 267 sColumn = pField->sColumn;
268 pch = pField->pszString; 269 fProtected = FALSE; 270 printf ("\033[%d;%dH",
(sRow)+1, (sColumn)+1); 271 } else { 272 pch = NULL; 273 printf ("\a");
274 } /* endif */ 275 break; 276 277 case TABBACKWARD: 278 pField = (pField->pFieldPrev
? pField->pFieldPrev 279 : pScreen->pFieldLast); 280 if (pField) { 281 sRow
= pField->sRow; 282 sColumn = pField->sColumn; 283 pch = pField->pszString;
284 fProtected = FALSE; 285 printf ("\033[%d;%dH", (sRow)+1, (sColumn)+1);
286 } else { 287 pch = NULL; 288 printf ("\a"); 289 } /* endif */ 290 break;
291 292 case LOOKPROTECTED: 293 printf ("\033[%d;%dH", (sRow)+1, (sColumn)+1);
294 for (pField = pScreen->pFieldFirst, pch = NULL, fProtected = TRUE; 295
pField; 296 pField = pField->pFieldNext) { 297 if ((sRow == pField->sRow)
&& 298 (sColumn >= pField->sColumn) && 299 (sColumn < pField->sColumn +
pField->sLength)) { 300 pch = pField->pszString + sColumn - pField->sColumn;
301 fProtected = FALSE; 302 break; 303 } /* endif */ 304 } /* endfor */
305 break; 306 307 case GOBACK: 308 *pKeyPressed = sKey; 309 fReady = TRUE;
310 break; 311 312 } /* endswitch */ 313 314 } /* endfor */ 315 316 } /*
End Display */ 317 318 319 /***************************************************************************/
320 /* Subroutine to Drop a field from the list of fields */ 321 /***************************************************************************/
322 323 VOID DropField (pScreen, sRow, sColumn) 324 PSCREEN pScreen; 325
SHORT sRow; 326 SHORT sColumn; 327 { 328 PFIELD pField; 329 330 /*************************************************************************/
331 /* If the list of fields is already empty then return */ 332 /*************************************************************************/
333 if (pScreen->sNrOfFields == 0) { 334 return; 335 } /* endif */ 336 337
338 /*************************************************************************/
339 /* Find the location of the field structure within the list */ 340 /*************************************************************************/
341 for (pField = pScreen->pFieldFirst; pField; pField = pField->pFieldNext)
{ 342 if ((sRow == pField->sRow) && (sColumn == pField->sColumn)) { 343
break; 344 } /* endif */ 345 } /* endfor */ 346 347 348 /*************************************************************************/
349 /* If no field could be found then return */ 350 /*************************************************************************/
351 if (!pField) { 352 return; 353 } /* endif */ 354 355 356 /*************************************************************************/
357 /* Else remove the field from the list depending on its position */
358 /*************************************************************************/
359 if (pField == pScreen->pFieldFirst) { /* first one */ 360 pScreen->pFieldFirst
= pField->pFieldNext; 361 pField->pFieldNext->pFieldPrev = NULL; 362 } 363
else if (pField == pScreen->pFieldLast) { /* last one */ 364 pScreen->pFieldLast
= pField->pFieldPrev; 365 pField->pFieldPrev->pFieldNext = NULL; 366 } 367
else { /* intermediate */ 368 pField->pFieldPrev->pFieldNext = pField->pFieldNext;
369 pField->pFieldNext->pFieldPrev = pField->pFieldPrev; 370 } /* endif
*/ 371 372 373 /*************************************************************************/
374 /* Cleanup storage and update the Field counter in the screen structure
*/ 375 /*************************************************************************/
376 free (pField); 377 (pScreen->sNrOfFields)--; 378 379 return; 380 381
} /* End DropField */ 382 383 384 /***************************************************************************/
385 /* Subroutine to Drop the whole screen */ 386 /***************************************************************************/
387 388 VOID DropScreen (pScreen) 389 PSCREEN pScreen; 390 { 391 PFIELD
pField; 392 393 /*************************************************************************/
394 /* Remove all fields from the list and cleanup storage */ 395 /*************************************************************************/
396 for (pField = pScreen->pFieldFirst; 397 pField; 398 pField = pScreen->pFieldFirst)
{ 399 400 pScreen->pFieldFirst = pScreen->pFieldFirst->pFieldNext; 401 402
free (pField); 403 404 } /* endfor */ 405 406 407 /*************************************************************************/
408 /* ReInitialize the screen structure and clear the screen */ 409 /*************************************************************************/
410 printf ("\033[2J"); /* CLS */ 411 412 pScreen->pFieldLast = NULL; 413
pScreen->sNrOfFields = 0; 414 415 return; 416 417 } /* End DropScreen */
418 419 420 /***** (C) Frans Fokkenrood - Januari 1993 *********************************/
YAHTZEE.C
1 /***************************************************************************/
2 /* YAHTZEE.C - Tripple YAHTZEE in C op basis van PC3270 support */ 3 /***************************************************************************/
4 5 #include 6 #include 7 #include 8 #include
"pc3270.h" 9 #include "yahtzee.h" 10 11 SHORT sInvoer; 12 SHORT sRow, sColumn;
13 SHORT sSpelTel, sWorpTel, sScore, sPersRec; 14 SHORT sDS1, sDS2, sDS3,
sDS4, sDS5; 15 SHORT sVakje[4][14]; 16 SHORT sTotaal[4], sYZ[4], sBonus[4];
17 18 CHAR szSpel[3]; 19 CHAR szKolom[2]; 20 CHAR szWorp[6][2]; 21 CHAR
szFileID[] = "YAHTZEE.DAT"; 22 23 SCREEN Screen; 24 KEY keyPressed; 25 26
27 /***************************************************************************/
28 /* Main procedure */ 29 /***************************************************************************/
30 31 SHORT main (argc, argv) 32 SHORT argc; 33 CHAR **argv; 34 { 35 SHORT
sGoedFout; 36 SHORT sOpdracht; 37 SHORT sSpelParameter; 38 39 sSpelParameter
= (argc > 1 ? *argv[1] : 'C'); 40 41 ProgrammaInit (sSpelParameter); 42
43 do { /* begindo while (sOpdracht != QUIT) */ 44 45 do { /* begindo while
(sGoedFout != GOED) */ 46 ZendScherm (); 47 sOpdracht = LeesScherm (); 48
49 switch (sOpdracht) { 50 case YAHTZEE: 51 sGoedFout = ControleerYahtzee
(); 52 break; 53 case HELP: 54 sGoedFout = GOED; 55 break; 56 case QUIT:
57 sGoedFout = GOED; 58 break; 59 } /* endswitch */ 60 61 } while (sGoedFout
!= GOED); 62 63 switch (sOpdracht) { 64 case YAHTZEE: 65 VerwerkYahtzee
(); 66 break; 67 case HELP: 68 VerwerkHelp (); 69 break; 70 case QUIT: 71
VerwerkQuit (); 72 break; 73 } /* endswitch */ 74 75 } while (sOpdracht
!= QUIT); 76 77 return (0); 78 79 } /* End main */ 80 81 82 /***************************************************************************/
83 /* Controleer het gekozen spel */ 84 /***************************************************************************/
85 86 SHORT ControleerYahtzee () 87 { 88 SHORT sSpel; 89 SHORT sKolom; 90
91 if (sInvoer == WORP) 92 return (GOED); 93 94 if (strcmp (szSpel, "")
== 0) { 95 sRow = 21; 96 sColumn = 66; 97 ConField (&Screen, 23, 24, BRIGHT,
RED, 98 " ** N U M M E R N I E T I N G E V U L D **"); 99 return (FOUT);
100 } /* endif */ 101 102 if (strcmp (szKolom, "") == 0) { 103 sRow = 21;
104 sColumn = 77; 105 ConField (&Screen, 23, 24, BRIGHT, RED, 106 " ** K
O L O M N I E T I N G E V U L D **"); 107 return (FOUT); 108 } /* endif
*/ 109 110 if ((sSpel = atoi (szSpel)) == 0) { 111 sRow = 21; 112 sColumn
= 66; 113 ConField (&Screen, 23, 24, BRIGHT, RED, 114 " ** N U M M E R N
I E T N U M E R I E K **"); 115 return (FOUT); 116 } /* endif */ 117 118
if ((sKolom = atoi (szKolom)) == 0) { 119 sRow = 21; 120 sColumn = 77; 121
ConField (&Screen, 23, 24, BRIGHT, RED, 122 " ** K O L O M N I E T N U M
E R I E K **"); 123 return (FOUT); 124 } /* endif */ 125 126 if ((sSpel
< 1) || (sSpel > 13)) { 127 sRow = 21; 128 sColumn = 66; 129 ConField (&Screen,
23, 24, BRIGHT, RED, 130 " ** N U M M E R I S O N G E L D I G **"); 131
return (FOUT); 132 } /* endif */ 133 134 if ((sKolom < 1) || (sKolom > 3))
{ 135 sRow = 21; 136 sColumn = 77; 137 ConField (&Screen, 23, 24, BRIGHT,
RED, 138 " ** K O L O M I S O N G E L D I G **"); 139 return (FOUT); 140
} /* endif */ 141 142 if ((sSpel != 12) && (sVakje[sKolom][sSpel] != -1))
{ 143 sRow = 21; 144 sColumn = 66; 145 ConField (&Screen, 23, 24, BRIGHT,
RED, 146 "** V A K J E I S R E E D S I N G E V U L D **"); 147 return (FOUT);
148 } /* endif */ 149 150 return (GOED); 151 152 } /* End ControleerYahtzee
*/ 153 154 155 /***************************************************************************/
156 /* Lees het scherm */ 157 /***************************************************************************/
158 159 SHORT LeesScherm () { 160 SHORT sOpdracht; 161 162 switch (keyPressed)
{ 163 case ENTER: 164 sOpdracht = YAHTZEE; 165 break; 166 167 case PF3:
168 sOpdracht = QUIT; 169 break; 170 171 default: 172 sOpdracht = HELP;
173 174 } /* endswitch */ 175 176 return (sOpdracht); 177 178 } /* End LeesScherm
*/ 179 180 181 /***************************************************************************/
182 /* Programma initialisatie */ 183 /***************************************************************************/
184 185 SHORT ProgrammaInit (sSpelParameter) 186 SHORT sSpelParameter; 187
{ 188 SHORT sK, sS; 189 CHAR szVeld[80]; 190 FILE *pFile; 191 192 /*************************************************************************/
193 /* Initialiseer de Scherm linked list header */ 194 /*************************************************************************/
195 InitScreen (&Screen); 196 197 198 /*************************************************************************/
199 /* Kijk of het de eerste keer is en zet persoonlijk record ... */ 200
/*************************************************************************/
201 if ((pFile = fopen (szFileID, "r")) == NULL) { 202 sPersRec = 0; 203
sSpelParameter = 'N'; 204 } else { 205 fscanf (pFile, "%d %*d %*d %d ",
&sSpelTel, &sPersRec); 206 if (sSpelTel == 0) 207 sSpelParameter = 'N';
208 fclose (pFile); 209 } /* endif */ 210 211 /*************************************************************************/
212 /* Initialiseer tellers voor een niew spel ... */ 213 /*************************************************************************/
214 if ((sSpelParameter == 'N') || (sSpelParameter == 'n')) { 215 pFile
= fopen (szFileID, "w"); 216 sDS1 = Dobbel (); 217 sDS2 = Dobbel (); 218
sDS3 = Dobbel (); 219 sDS4 = Dobbel (); 220 sDS5 = Dobbel (); 221 fprintf
(pFile, "39 2 0 %d ", sPersRec); 222 fprintf (pFile, "%d %d %d %d %d\n",
sDS1, sDS2, sDS3, sDS4, sDS5); 223 fprintf (pFile, "-1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 0 0 0\n"); 224 fprintf (pFile, "-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 0 0 0\n"); 225 fprintf (pFile, "-1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 0 0 0\n"); 226 fclose (pFile); 227 } /* endif */ 228 229 /*************************************************************************/
230 /* Teken de vaste velden op het scherm ... */ 231 /*************************************************************************/
232 ConField (&Screen, 0, 2, BRIGHT, BLUE, 233 "YZ-pc3270"); 234 ConField
(&Screen, 0, 21, BRIGHT, BLUE, 235 "*** P E R S O O N L I J K R E C O R
D *"); 236 237 sprintf (szVeld, "%04d", sPersRec); 238 ConField (&Screen,
0, 69, BRIGHT, TURQUOISE, szVeld); 239 240 ConField (&Screen, 0, 76, BRIGHT,
BLUE, 241 "***"); 242 243 ConField (&Screen, 1, 0, BRIGHT, BLUE, 244 "========================================");
245 ConField (&Screen, 1, 40, BRIGHT, BLUE, 246 "=======================================");
247 248 ConField (&Screen, 3, 2, BRIGHT, BLUE, 249 "NR KEUZE"); 250 ConField
(&Screen, 3, 28, BRIGHT, BLUE, 251 "KOL 1 KOL 2 KOL 3 TOTAAL SCORE"); 252
253 ConField (&Screen, 5, 2, BRIGHT, BLUE, 254 " 1 E N E N :"); 255 256
ConField (&Screen, 6, 2, BRIGHT, BLUE, 257 " 2 T W E E E N :"); 258 259
ConField (&Screen, 7, 2, BRIGHT, BLUE, 260 " 3 D R I E E N :"); 261 262
ConField (&Screen, 8, 2, BRIGHT, BLUE, 263 " 4 V I E R E N :"); 264 265
ConField (&Screen, 9, 2, BRIGHT, BLUE, 266 " 5 V I J V E N :"); 267 268
ConField (&Screen, 10, 2, BRIGHT, BLUE, 269 " 6 Z E S S E N :"); 270 271
ConField (&Screen, 11, 56, BRIGHT, BLUE, 272 "--- BONUS INDICATIE ---");
273 274 ConField (&Screen, 13, 2, BRIGHT, BLUE, 275 " 7 THREE OF A KIND
:"); 276 277 ConField (&Screen, 14, 2, BRIGHT, BLUE, 278 " 8 CARRE :");
279 280 ConField (&Screen, 15, 2, BRIGHT, BLUE, 281 " 9 FULL HOUSE :");
282 283 ConField (&Screen, 16, 2, BRIGHT, BLUE, 284 "10 KLEINE STRAAT :");
285 286 ConField (&Screen, 17, 2, BRIGHT, BLUE, 287 "11 GROTE STRAAT :");
288 289 ConField (&Screen, 18, 2, BRIGHT, BLUE, 290 "12 Y A H T Z E E :");
291 292 ConField (&Screen, 19, 2, BRIGHT, BLUE, 293 "13 CHANCE :"); 294
295 ConField (&Screen, 20, 58, BRIGHT, BLUE, 296 "GEGOOID :"); 297 298 ConField
(&Screen, 22, 0, BRIGHT, BLUE, 299 "========================================");
300 ConField (&Screen, 22, 40, BRIGHT, BLUE, 301 "=======================================");
302 303 ConField (&Screen, 23, 0, BRIGHT, BLUE, 304 "(C) Frans Fokkenrood");
305 306 /*************************************************************************/
307 /* Lees de spelwaarden in ... */ 308 /*************************************************************************/
309 pFile = fopen (szFileID, "r"); 310 311 fscanf (pFile, "%d %d %d %d %d
%d %d %d %d", 312 &sSpelTel, &sWorpTel, 313 &sScore, &sPersRec, 314 &sDS1,
&sDS2, &sDS3, &sDS4, &sDS5); 315 316 for (sK=1; sK<4; sK++) { 317 for (sS=1;
sS<14; sS++) { 318 fscanf (pFile, "%d", &sVakje[sK][sS]); 319 320 if (sVakje[sK][sS]
== -1) 321 continue; 322 323 sprintf (szVeld, "%4d", sVakje[sK][sS]); 324
325 ConField (&Screen, (sS < 7 ? sS+4 : sS+6), (sK * 10 + 18), 326 BRIGHT,
TURQUOISE, szVeld); 327 328 } /* endfor */ 329 330 fscanf (pFile, "%d %d
%d", &sTotaal[sK], &sYZ[sK], &sBonus[sK]); 331 332 } /* endfor */ 333 334
fclose (pFile); 335 336 /*************************************************************************/
337 /* Initialiseer programma variabelen ... */ 338 /*************************************************************************/
339 strcpy (szKolom, "."); 340 strcpy (szSpel, ".."); 341 342 sInvoer =
WORP; 343 sRow = 21; 344 sColumn = 69; 345 346 sprintf (szVeld, 347 " %s
%d SPELEN * %d KEER DOBBELEN **", 348 (sSpelTel > 9 ? "**" : " **"), sSpelTel,
sWorpTel); 349 350 ConField (&Screen, 23, 24, BRIGHT, TURQUOISE, szVeld);
351 352 return (0); 353 354 } /* End ProgrammmaInit */ 355 356 357 /***************************************************************************/
358 /* Verwerking HELP voor Yahtzee spel */ 359 /***************************************************************************/
360 361 SHORT VerwerkHelp () 362 { 363 364 VerwerkQuit (); /* Stel de gegevens
van het spel veilig */ 365 366 system ("YZHELP.EXE"); /* Roep de HELP module
voor Yahtzee aan */ 367 368 ProgrammaInit ('C'); /* Haal het spel weer terug;
ga verder */ 369 370 return (0); 371 372 } /* End VerwerkHelp */ 373 374
375 /***************************************************************************/
376 /* Verwerking bij afsluiting van het programma */ 377 /***************************************************************************/
378 379 SHORT VerwerkQuit () 380 { 381 SHORT sK; 382 SHORT sS; 383 FILE
*pFile; 384 385 if (sScore > sPersRec) 386 sPersRec = sScore; 387 388 pFile
= fopen (szFileID, "w"); 389 390 fprintf (pFile, "%d %d %d %d %d %d %d %d
%d\n", 391 sSpelTel, sWorpTel, 392 sScore, sPersRec, 393 sDS1, sDS2, sDS3,
sDS4, sDS5); 394 395 for (sK=1; sK<4; sK++) { 396 for (sS=1; sS<14; sS++)
{ 397 fprintf (pFile, "%d ", sVakje[sK][sS]); 398 399 } /* endfor */ 400
401 fprintf (pFile, " %d %d %d\n", sTotaal[sK], sYZ[sK], sBonus[sK]); 402
403 } /* endfor */ 404 405 fclose (pFile); 406 407 DropScreen (&Screen);
408 409 return (0); 410 411 } /* End VerwerkQuit */ 412 413 414 /***************************************************************************/
415 /* Verwerking Spel */ 416 /***************************************************************************/
417 418 SHORT VerwerkSpel () 419 { 420 SHORT sS, sK; 421 SHORT sYahtzee;
422 SHORT sPunten; 423 CHAR achOgen[7]; 424 CHAR szVeld[80]; 425 426 strcpy
(achOgen, "-000000"); 427 428 achOgen[sDS1]++; 429 achOgen[sDS2]++; 430
achOgen[sDS3]++; 431 achOgen[sDS4]++; 432 achOgen[sDS5]++; 433 434 if (strchr
(achOgen, '5') != 0) 435 sYahtzee = JA; 436 else 437 sYahtzee = NEE; 438
439 sK = atoi (szKolom); 440 sS = atoi (szSpel); 441 sPunten = 0; 442 443
/*************************************************************************/
444 /* Reken de mogelijke punten uit, afhankelijk van het gekozen spel */
445 /*************************************************************************/
446 switch (sS) { 447 case ENEN: 448 case TWEEEN: 449 case DRIEEN: 450 case
VIEREN: 451 case VIJVEN: 452 case ZESSEN: 453 if (sYahtzee == JA) 454 sPunten
= sS * 5 * sK; 455 else 456 sPunten = sS * (achOgen[sS] - '0') * sK; 457
458 sBonus[sK] += (sPunten - (3 * sS * sK)); 459 460 break; 461 462 case
THREE_OF_A_KIND: 463 if ((strchr (achOgen, '3') != 0) || 464 (strchr (achOgen,
'4') != 0) || 465 (sYahtzee == JA)) 466 sPunten = (sDS1 + sDS2 + sDS3 +
sDS4 + sDS5) * sK; 467 468 break; 469 470 case CARRE: 471 if ((strchr (achOgen,
'4') != 0) || 472 (sYahtzee == JA)) 473 sPunten = (sDS1 + sDS2 + sDS3 +
sDS4 + sDS5) * sK; 474 475 break; 476 477 case FULL_HOUSE: 478 if ((strchr
(achOgen, '2') != 0) && 479 (strchr (achOgen, '3') != 0) || 480 (sYahtzee
== JA)) 481 sPunten = 25 * sK; 482 483 break; 484 485 case KLEINE_STRAAT:
486 if (sYahtzee == JA) 487 sPunten = 30 * sK; 488 else if (strstr (achOgen,
"1111") != 0) 489 sPunten = 30 * sK; 490 else if (strstr (achOgen, "2111")
!= 0) 491 sPunten = 30 * sK; 492 else if (strstr (achOgen, "1211") != 0)
493 sPunten = 30 * sK; 494 else if (strstr (achOgen, "1121") != 0) 495 sPunten
= 30 * sK; 496 else if (strstr (achOgen, "1112") != 0) 497 sPunten = 30
* sK; 498 499 break; 500 501 case GROTE_STRAAT: 502 if ((strstr (achOgen,
"11111") != 0) || 503 (sYahtzee == JA)) 504 sPunten = 40 * sK; 505 506 break;
507 508 case Y_A_H_T_Z_E_E: 509 if (sYahtzee == JA) { 510 sYZ[sK]++; 511
if (sYZ[sK] > 1) 512 sPunten = 100 * sK; 513 else 514 sPunten = 50 * sK;
515 } /* endif */ 516 517 break; 518 519 case CHANCE: 520 sPunten = (sDS1
+ sDS2 + sDS3 + sDS4 + sDS5) * sK; 521 522 break; 523 524 } /* endswitch
*/ 525 526 /*************************************************************************/
527 /* Verwerk de punten in de score en initialiseer een nieuw spel */ 528
/*************************************************************************/
529 if (sVakje[sK][sS] == -1) { 530 sVakje[sK][sS] = sPunten; 531 532 sprintf
(szVeld, "%4d", sVakje[sK][sS]); 533 ConField (&Screen, (sS < 7 ? sS+4 :
sS+6), (sK * 10 + 18), 534 BRIGHT, TURQUOISE, szVeld); 535 } /* endif */
536 537 sTotaal[sK] += sPunten; 538 sScore += sPunten; 539 540 sDS1 = Dobbel
(); 541 sDS2 = Dobbel (); 542 sDS3 = Dobbel (); 543 sDS4 = Dobbel (); 544
sDS5 = Dobbel (); 545 546 strcpy (szKolom, "."); 547 strcpy (szSpel, "..");
548 549 sInvoer = WORP; 550 551 if (sSpelTel > 0) { 552 sRow = 21; 553 sColumn
= 69; 554 sprintf (szVeld, 555 " %s %d SPELEN * %d KEER DOBBELEN **", 556
(sSpelTel > 9 ? "**" : " **"), 557 sSpelTel, sWorpTel); 558 ConField (&Screen,
23, 24, BRIGHT, TURQUOISE, szVeld); 559 } else { 560 sRow = 23; 561 sColumn
= 79; 562 ConField (&Screen, 23, 24, BRIGHT, RED, 563 " ** G A M E O V E
R **"); 564 } /* endif */ 565 566 return (0); 567 568 } /* End VerwerkSpel
*/ 569 570 571 /***************************************************************************/
572 /* Verwerking Worp */ 573 /***************************************************************************/
574 575 SHORT VerwerkWorp () 576 { 577 SHORT sOpnieuw; 578 CHAR szVeld[80];
579 580 if (sSpelTel < 1) { 581 sRow = 23; 582 sColumn = 79; 583 ConField
(&Screen, 23, 24, BRIGHT, RED, 584 " ** G A M E O V E R **"); 585 return
(0); 586 } /* endif */ 587 588 sOpnieuw = 0; 589 590 if ((*szWorp[1] ==
'/') || (*szWorp[1] == 'x')) { 591 sDS1 = Dobbel (); 592 sOpnieuw++; 593
} /* endif */ 594 595 if ((*szWorp[2] == '/') || (*szWorp[2] == 'x')) {
596 sDS2 = Dobbel (); 597 sOpnieuw++; 598 } /* endif */ 599 600 if ((*szWorp[3]
== '/') || (*szWorp[3] == 'x')) { 601 sDS3 = Dobbel (); 602 sOpnieuw++;
603 } /* endif */ 604 605 if ((*szWorp[4] == '/') || (*szWorp[4] == 'x'))
{ 606 sDS4 = Dobbel (); 607 sOpnieuw++; 608 } /* endif */ 609 610 if ((*szWorp[5]
== '/') || (*szWorp[5] == 'x')) { 611 sDS5 = Dobbel (); 612 sOpnieuw++;
613 } /* endif */ 614 615 sWorpTel--; 616 617 if ((sOpnieuw == 0) || (sWorpTel
== 0)) { 618 sSpelTel--; 619 sWorpTel = 2; 620 sInvoer = SPEL; 621 sRow
= 21; 622 sColumn = 66; 623 ConField (&Screen, 23, 24, BRIGHT, TURQUOISE,
624 " ** K I E Z E N **"); 625 } else { 626 sRow = 21; 627 sColumn = 69;
628 sprintf (szVeld, 629 " %s %d SPELEN * %d KEER DOBBELEN **", 630 (sSpelTel
> 9 ? "**" : " **"), 631 sSpelTel, sWorpTel); 632 ConField (&Screen, 23,
24, BRIGHT, TURQUOISE, szVeld); 633 } /* endif */ 634 635 return (0); 636
637 } /* End VerwerkWorp */ 638 639 640 /***************************************************************************/
641 /* Verwerking Yahtzee spel */ 642 /***************************************************************************/
643 644 SHORT VerwerkYahtzee () 645 { 646 647 if (sInvoer == WORP) 648 VerwerkWorp
(); 649 else 650 VerwerkSpel (); 651 652 return (0); 653 654 } /* End VerwerkYahtzee
*/ 655 656 657 /***************************************************************************/
658 /* Stuur het spelscherm naar het beeldscherm van de PC */ 659 /***************************************************************************/
660 661 SHORT ZendScherm () 662 { 663 SHORT sW; 664 CHAR szVeld[80]; 665
666 /*************************************************************************/
667 /* Teken de variable velden op het scherm ... */ 668 /*************************************************************************/
669 if (sScore <= sPersRec ) { 670 sprintf (szVeld, "%04d", sScore); 671
ConField (&Screen, 5, 64, BRIGHT, TURQUOISE, szVeld); 672 } else { 673 sprintf
(szVeld, "** %04d **", sScore); 674 ConField (&Screen, 5, 60, BRIGHT, RED,
szVeld); 675 } /* endif */ 676 677 sprintf (szVeld, "%4d", sBonus[1]); 678
ConField (&Screen, 12, 58, BRIGHT, TURQUOISE, szVeld); 679 sprintf (szVeld,
"%4d", sBonus[2]); 680 ConField (&Screen, 12, 64, BRIGHT, TURQUOISE, szVeld);
681 sprintf (szVeld, "%4d", sBonus[3]); 682 ConField (&Screen, 12, 70, BRIGHT,
TURQUOISE, szVeld); 683 684 sprintf (szVeld, "%d %d %d %d %d", sDS1, sDS2,
sDS3, sDS4, sDS5); 685 ConField (&Screen, 20, 69, BRIGHT, TURQUOISE, szVeld);
686 687 if (sInvoer == WORP) { 688 ConField (&Screen, 21, 15, BRIGHT, BLUE,
"TOTAAL : "); 689 sprintf (szVeld, "%4d ", sTotaal[1]); 690 ConField (&Screen,
21, 28, BRIGHT, TURQUOISE, szVeld); 691 sprintf (szVeld, "%4d ", sTotaal[2]);
692 ConField (&Screen, 21, 38, BRIGHT, TURQUOISE, szVeld); 693 sprintf (szVeld,
"%4d ", sTotaal[3]); 694 ConField (&Screen, 21, 48, BRIGHT, TURQUOISE, szVeld);
695 ConField (&Screen, 21, 58, BRIGHT, BLUE, "OPNIEUW : "); 696 ConField
(&Screen, 21, 68, BRIGHT, BLUE, " "); 697 } else { 698 ConField (&Screen,
21, 15, BRIGHT, BLUE, " "); 699 ConField (&Screen, 21, 28, BRIGHT, BLUE,
" "); 700 ConField (&Screen, 21, 38, BRIGHT, BLUE, "VUL KEUZE "); 701 ConField
(&Screen, 21, 48, BRIGHT, BLUE, "IN ===> "); 702 ConField (&Screen, 21,
58, BRIGHT, BLUE, "NUMMER: "); 703 ConField (&Screen, 21, 68, BRIGHT, BLUE,
" KOLOM: "); 704 } /* endif */ 705 706 /*************************************************************************/
707 /* Teken de intikbare velden op het scherm ... */ 708 /*************************************************************************/
709 if (sInvoer == WORP) { 710 for (sW=1; sW<6; sW++) { 711 strcpy (szWorp[sW],
"."); 712 } /* endfor */ 713 DropField (&Screen, 21, 66); 714 VarField (&Screen,
21, 69, BRIGHT, GREEN, szWorp[1], 1); 715 VarField (&Screen, 21, 71, BRIGHT,
GREEN, szWorp[2], 1); 716 VarField (&Screen, 21, 73, BRIGHT, GREEN, szWorp[3],
1); 717 VarField (&Screen, 21, 75, BRIGHT, GREEN, szWorp[4], 1); 718 VarField
(&Screen, 21, 77, BRIGHT, GREEN, szWorp[5], 1); 719 } else { 720 DropField
(&Screen, 21, 69); 721 DropField (&Screen, 21, 71); 722 DropField (&Screen,
21, 73); 723 DropField (&Screen, 21, 75); 724 VarField (&Screen, 21, 66,
BRIGHT, GREEN, szSpel, 2); 725 VarField (&Screen, 21, 77, BRIGHT, GREEN,
szKolom, 1); 726 } /* endif */ 727 728 Display (&Screen, sRow, sColumn,
&keyPressed); 729 730 return (0); 731 732 } /* End ZendScherm */ 733 /*****
(C) Frans Fokkenrood - Januari 1993 *********************************/
YZHELP.C
1 /***************************************************************************/
2 /* YZHELP.C - Help voor Tripple YAHTZEE in C (PC3270 support) */
3 /***************************************************************************/
4
5 #include
6 #include
7 #include
8 #include
9 #include "pc3270.h"
10 #include "yzhelp.h"
11
12 SHORT sRow, sColumn;
13 SHORT sLines;
14
15 CHAR szFileID[] = "YAHTZEE.HLP";
16
17 SCREEN Screen;
18 KEY keyPressed;
19
20 PHLIST pHlistEerste, pHlistHuidige, pHlistLaatste;
21
22
23 /***************************************************************************/
24 /* Main procedure */
25 /***************************************************************************/
26
27 SHORT main ()
28 {
29 SHORT sGoedFout;
30 SHORT sOpdracht;
31
32 ProgrammaInit ();
33
34 do { /* begindo while (sOpdracht != QUIT) */
35
36 do { /* begindo while (sGoedFout != GOED) */
37 ZendScherm ();
38 sOpdracht = LeesScherm ();
39
40 switch (sOpdracht) {
41 case YZHELP:
42 case FORWARD:
43 sGoedFout = ControleerForward ();
44 break;
45 case BACKWARD:
46 sGoedFout = ControleerBackward ();
47 break;
48 case QUIT:
49 sGoedFout = GOED;
50 break;
51 case UNDEFINED:
52 sGoedFout = FOUT;
53 ConField (&Screen, 22, 0, BRIGHT, RED,
54 "Je hebt een verkeerde toets ingedrukt");
55 break;
56 } /* endswitch */
57
58 } while (sGoedFout != GOED);
59
60 switch (sOpdracht) {
61 case YZHELP:
62 case FORWARD:
63 VerwerkForward ();
64 break;
65 case BACKWARD:
66 VerwerkBackward ();
67 break;
68 case QUIT:
69 VerwerkQuit ();
70 break;
71 } /* endswitch */
72
73 ConField (&Screen, 22, 0, BRIGHT, RED, "\033[K"); /* Erase to EOL */
74
75 } while (sOpdracht != QUIT);
76
77 return (0);
78
79 } /* End main */
80
81
82 /***************************************************************************/
83 /* Controleer achteruit bladeren */
84 /***************************************************************************/
85
86 SHORT ControleerBackward ()
87 {
88
89 if (pHlistHuidige->sLineNr == 1) {
90 ConField (&Screen, 22, 0, BRIGHT, RED,
91 "Achteruit bladeren is niet mogelijk ");
92 return (FOUT);
93 } /* endif */
94
95 return (GOED);
96
97 } /* End ControleerBackward */
98
99
100 /***************************************************************************/
101 /* Controleer vooruit bladeren */
102 /***************************************************************************/
103
104 SHORT ControleerForward ()
105 {
106
107 if ((sLines - pHlistHuidige->sLineNr) < MAXLINES-1) {
108 ConField (&Screen, 22, 0, BRIGHT, RED,
109 "Vooruit bladeren is niet mogelijk ");
110 return (FOUT);
111 } /* endif */
112
113 return (GOED);
114
115 } /* End ControleerForward */
116
117
118 /***************************************************************************/
119 /* Lees het scherm */
120 /***************************************************************************/
121
122 SHORT LeesScherm () {
123 SHORT sOpdracht;
124
125 switch (keyPressed) {
126 case ENTER:
127 sOpdracht = YZHELP;
128 break;
129
130 case PF3:
131 sOpdracht = QUIT;
132 break;
133
134 case PF7:
135 sOpdracht = BACKWARD;
136 break;
137
138 case PF8:
139 sOpdracht = FORWARD;
140 break;
141
142 default:
143 sOpdracht = UNDEFINED;
144
145 } /* endswitch */
146
147 return (sOpdracht);
148
149 } /* End LeesScherm */
150
151
152 /***************************************************************************/
153 /* Programma initialisatie */
154 /***************************************************************************/
155
156 SHORT ProgrammaInit ()
157 {
158 SHORT sChar;
159 CHAR *pchRec;
160 CHAR szRec[81];
161 FILE *pFile;
162 PHLIST pHlist;
163
164 /*************************************************************************/
165 /* Initialiseer de Scherm linked list header */
166 /*************************************************************************/
167 InitScreen (&Screen);
168
169
170 /*************************************************************************/
171 /* Lees de HELP-tekst in een dynamic structure ... */
172 /*************************************************************************/
173 pFile = fopen (szFileID, "r");
174
175 pchRec = szRec;
176 sLines = 0;
177
178 do { /* begindo while (sChar != EOF) */
179 sChar = fgetc (pFile);
180
181 if (sChar != '\n') {
182 *pchRec++ = sChar;
183 continue;
184 } /* endif */
185
186 if (sLines == 0) {
187 pHlistEerste = (PHLIST) malloc (sizeof (HLIST));
188 pHlistEerste->pPrior = NULL;
189 pHlist = pHlistEerste;
190 } else {
191 pHlist->pNext = (PHLIST) malloc (sizeof (HLIST));
192 pHlist->pNext->pPrior = pHlist;
193 pHlist = pHlist->pNext;
194 } /* endif */
195
196 pHlist->pszLine = (PSZ) malloc ((SHORT) (pchRec - szRec) + 1);
197 pHlist->pNext = NULL;
198
199 pHlist->sLineNr = ++sLines;
200 *pchRec = '\0';
201 strcpy (pHlist->pszLine, szRec);
202
203 pchRec = szRec;
204
205 } while (sChar != EOF);
206
207 pHlistLaatste = pHlist;
208
209 fclose (pFile);
210
211 /*************************************************************************/
212 /* Teken de vaste velden op het scherm ... */
213 /*************************************************************************/
214 ConField (&Screen, 0, 2, BRIGHT, BLUE,
215 "YZ-pc3270 Help Informatie");
216
217 ConField (&Screen, 1, 0, BRIGHT, BLUE,
218 "----------------------------------------");
219 ConField (&Screen, 1, 0, BRIGHT, BLUE,
220 "---------------------------------------");
221
222 ConField (&Screen, 23, 0, BRIGHT, BLUE,
223 "Enter Pf3=Stoppen 7=Vorige 8=Volgende");
224
225 /*************************************************************************/
226 /* Initialiseer programma variabelen ... */
227 /*************************************************************************/
228 sRow = 23;
229 sColumn = 0;
230
231 pHlistHuidige = pHlistEerste;
232
233 return (0);
234
235 } /* End ProgrammmaInit */
236
237
238 /***************************************************************************/
239 /* Verwerking achteruit bladeren */
240 /***************************************************************************/
241
242 SHORT VerwerkBackward ()
243 {
244 SHORT sCount;
245
246 for (sCount=0; sCountpPrior;
248 } /* endfor */
249
250 return (0);
251
252 } /* End VerwerkBackward */
253
254
255 /***************************************************************************/
256 /* Verwerking vooruit bladeren */
257 /***************************************************************************/
258
259 SHORT VerwerkForward ()
260 {
261 SHORT sCount;
262
263 for (sCount=0; sCountpNext;
265 } /* endfor */
266
267 return (0);
268
269 } /* End VerwerkForward */
270
271
272 /***************************************************************************/
273 /* Verwerking stoppen */
274 /***************************************************************************/
275
276 SHORT VerwerkQuit ()
277 {
278
279 DropScreen (&Screen);
280
281 return (0);
282
283 } /* End VerwerkQuit */
284
285
286 /***************************************************************************/
287 /* Stuur de HELP-tekst naar het beeldscherm van de PC */
288 /***************************************************************************/
289
290 SHORT ZendScherm ()
291 {
292 BOOL fEOF;
293 SHORT sCount;
294 CHAR szVeld[81];
295 PHLIST pHlist;
296
297 /*************************************************************************/
298 /* Teken de variable velden op het scherm ... */
299 /*************************************************************************/
300 sprintf (szVeld, "Regel %3d van %3d", pHlistHuidige->sLineNr, sLines);
301 ConField (&Screen, 0, 62, BRIGHT, BLUE, szVeld);
302
303 pHlist = pHlistHuidige;
304 fEOF = TRUE;
305
306 for (sCount=0; sCountpszLine);
322
323 pHlist = pHlist->pNext;
324
325 } /* endfor */
326
327 Display (&Screen, sRow, sColumn, &keyPressed);
328
329 return (0);
330
331 } /* End ZendScherm */
332
333 /***** (C) Frans Fokkenrood - Januari 1993 *********************************/
|