]> 4ch.mooo.com Git - 16.git/blob - 16/sod8086/wl_text.c
reference to the bbocg
[16.git] / 16 / sod8086 / wl_text.c
1 // WL_TEXT.C\r
2 \r
3 #include "WL_DEF.H"\r
4 #pragma hdrstop\r
5 \r
6 /*\r
7 =============================================================================\r
8 \r
9 TEXT FORMATTING COMMANDS\r
10 ------------------------\r
11 ^C<hex digit>                   Change text color\r
12 ^E[enter]                               End of layout (all pages)\r
13 ^G<y>,<x>,<pic>[enter]  Draw a graphic and push margins\r
14 ^P[enter]                               start new page, must be the first chars in a layout\r
15 ^L<x>,<y>[ENTER]                Locate to a specific spot, x in pixels, y in lines\r
16 \r
17 =============================================================================\r
18 */\r
19 \r
20 /*\r
21 =============================================================================\r
22 \r
23                                                  LOCAL CONSTANTS\r
24 \r
25 =============================================================================\r
26 */\r
27 \r
28 #define BACKCOLOR               0x11\r
29 \r
30 \r
31 #define WORDLIMIT               80\r
32 #define FONTHEIGHT              10\r
33 #define TOPMARGIN               16\r
34 #define BOTTOMMARGIN    32\r
35 #define LEFTMARGIN              16\r
36 #define RIGHTMARGIN             16\r
37 #define PICMARGIN               8\r
38 #define TEXTROWS                ((200-TOPMARGIN-BOTTOMMARGIN)/FONTHEIGHT)\r
39 #define SPACEWIDTH              7\r
40 #define SCREENPIXWIDTH  320\r
41 #define SCREENMID               (SCREENPIXWIDTH/2)\r
42 \r
43 /*\r
44 =============================================================================\r
45 \r
46                                                  LOCAL VARIABLES\r
47 \r
48 =============================================================================\r
49 */\r
50 \r
51 int                     pagenum,numpages;\r
52 \r
53 unsigned        leftmargin[TEXTROWS],rightmargin[TEXTROWS];\r
54 char            far *text;\r
55 unsigned        rowon;\r
56 \r
57 int                     picx,picy,picnum,picdelay;\r
58 boolean         layoutdone;\r
59 \r
60 //===========================================================================\r
61 \r
62 #ifndef JAPAN\r
63 /*\r
64 =====================\r
65 =\r
66 = RipToEOL\r
67 =\r
68 =====================\r
69 */\r
70 \r
71 void RipToEOL (void)\r
72 {\r
73         while (*text++ != '\n')         // scan to end of line\r
74         ;\r
75 }\r
76 \r
77 \r
78 /*\r
79 =====================\r
80 =\r
81 = ParseNumber\r
82 =\r
83 =====================\r
84 */\r
85 \r
86 int     ParseNumber (void)\r
87 {\r
88         char    ch;\r
89         char    num[80],*numptr;\r
90 \r
91 //\r
92 // scan until a number is found\r
93 //\r
94         ch = *text;\r
95         while (ch < '0' || ch >'9')\r
96                 ch = *++text;\r
97 \r
98 //\r
99 // copy the number out\r
100 //\r
101         numptr = num;\r
102         do\r
103         {\r
104                 *numptr++ = ch;\r
105                 ch = *++text;\r
106         } while (ch >= '0' && ch <= '9');\r
107         *numptr = 0;\r
108 \r
109         return atoi (num);\r
110 }\r
111 \r
112 \r
113 \r
114 /*\r
115 =====================\r
116 =\r
117 = ParsePicCommand\r
118 =\r
119 = Call with text pointing just after a ^P\r
120 = Upon exit text points to the start of next line\r
121 =\r
122 =====================\r
123 */\r
124 \r
125 void    ParsePicCommand (void)\r
126 {\r
127         picy=ParseNumber();\r
128         picx=ParseNumber();\r
129         picnum=ParseNumber();\r
130         RipToEOL ();\r
131 }\r
132 \r
133 \r
134 void    ParseTimedCommand (void)\r
135 {\r
136         picy=ParseNumber();\r
137         picx=ParseNumber();\r
138         picnum=ParseNumber();\r
139         picdelay=ParseNumber();\r
140         RipToEOL ();\r
141 }\r
142 \r
143 \r
144 /*\r
145 =====================\r
146 =\r
147 = TimedPicCommand\r
148 =\r
149 = Call with text pointing just after a ^P\r
150 = Upon exit text points to the start of next line\r
151 =\r
152 =====================\r
153 */\r
154 \r
155 void    TimedPicCommand (void)\r
156 {\r
157         ParseTimedCommand ();\r
158 \r
159 //\r
160 // update the screen, and wait for time delay\r
161 //\r
162         VW_UpdateScreen ();\r
163 \r
164 //\r
165 // wait for time\r
166 //\r
167         TimeCount = 0;\r
168         while (TimeCount < picdelay)\r
169         ;\r
170 \r
171 //\r
172 // draw pic\r
173 //\r
174         VWB_DrawPic (picx&~7,picy,picnum);\r
175 }\r
176 \r
177 \r
178 /*\r
179 =====================\r
180 =\r
181 = HandleCommand\r
182 =\r
183 =====================\r
184 */\r
185 \r
186 void HandleCommand (void)\r
187 {\r
188         int     i,margin,top,bottom;\r
189         int     picwidth,picheight,picmid;\r
190 \r
191         switch (toupper(*++text))\r
192         {\r
193         case 'B':\r
194                 picy=ParseNumber();\r
195                 picx=ParseNumber();\r
196                 picwidth=ParseNumber();\r
197                 picheight=ParseNumber();\r
198                 VWB_Bar(picx,picy,picwidth,picheight,BACKCOLOR);\r
199                 RipToEOL();\r
200                 break;\r
201         case ';':               // comment\r
202                 RipToEOL();\r
203                 break;\r
204         case 'P':               // ^P is start of next page, ^E is end of file\r
205         case 'E':\r
206                 layoutdone = true;\r
207                 text--;         // back up to the '^'\r
208                 break;\r
209 \r
210         case 'C':               // ^c<hex digit> changes text color\r
211                 i = toupper(*++text);\r
212                 if (i>='0' && i<='9')\r
213                         fontcolor = i-'0';\r
214                 else if (i>='A' && i<='F')\r
215                         fontcolor = i-'A'+10;\r
216 \r
217                 fontcolor *= 16;\r
218                 i = toupper(*++text);\r
219                 if (i>='0' && i<='9')\r
220                         fontcolor += i-'0';\r
221                 else if (i>='A' && i<='F')\r
222                         fontcolor += i-'A'+10;\r
223                 text++;\r
224                 break;\r
225 \r
226         case '>':\r
227                 px = 160;\r
228                 text++;\r
229                 break;\r
230 \r
231         case 'L':\r
232                 py=ParseNumber();\r
233                 rowon = (py-TOPMARGIN)/FONTHEIGHT;\r
234                 py = TOPMARGIN+rowon*FONTHEIGHT;\r
235                 px=ParseNumber();\r
236                 while (*text++ != '\n')         // scan to end of line\r
237                 ;\r
238                 break;\r
239 \r
240         case 'T':               // ^Tyyy,xxx,ppp,ttt waits ttt tics, then draws pic\r
241                 TimedPicCommand ();\r
242                 break;\r
243 \r
244         case 'G':               // ^Gyyy,xxx,ppp draws graphic\r
245                 ParsePicCommand ();\r
246                 VWB_DrawPic (picx&~7,picy,picnum);\r
247                 picwidth = pictable[picnum-STARTPICS].width;\r
248                 picheight = pictable[picnum-STARTPICS].height;\r
249                 //\r
250                 // adjust margins\r
251                 //\r
252                 picmid = picx + picwidth/2;\r
253                 if (picmid > SCREENMID)\r
254                         margin = picx-PICMARGIN;                        // new right margin\r
255                 else\r
256                         margin = picx+picwidth+PICMARGIN;       // new left margin\r
257 \r
258                 top = (picy-TOPMARGIN)/FONTHEIGHT;\r
259                 if (top<0)\r
260                         top = 0;\r
261                 bottom = (picy+picheight-TOPMARGIN)/FONTHEIGHT;\r
262                 if (bottom>=TEXTROWS)\r
263                         bottom = TEXTROWS-1;\r
264 \r
265                 for (i=top;i<=bottom;i++)\r
266                         if (picmid > SCREENMID)\r
267                                 rightmargin[i] = margin;\r
268                         else\r
269                                 leftmargin[i] = margin;\r
270 \r
271                 //\r
272                 // adjust this line if needed\r
273                 //\r
274                 if (px < leftmargin[rowon])\r
275                         px = leftmargin[rowon];\r
276                 break;\r
277         }\r
278 }\r
279 \r
280 \r
281 /*\r
282 =====================\r
283 =\r
284 = NewLine\r
285 =\r
286 =====================\r
287 */\r
288 \r
289 void NewLine (void)\r
290 {\r
291         char    ch;\r
292 \r
293         if (++rowon == TEXTROWS)\r
294         {\r
295         //\r
296         // overflowed the page, so skip until next page break\r
297         //\r
298                 layoutdone = true;\r
299                 do\r
300                 {\r
301                         if (*text == '^')\r
302                         {\r
303                                 ch = toupper(*(text+1));\r
304                                 if (ch == 'E' || ch == 'P')\r
305                                 {\r
306                                         layoutdone = true;\r
307                                         return;\r
308                                 }\r
309                         }\r
310                         text++;\r
311 \r
312                 } while (1);\r
313 \r
314         }\r
315         px = leftmargin[rowon];\r
316         py+= FONTHEIGHT;\r
317 }\r
318 \r
319 \r
320 \r
321 /*\r
322 =====================\r
323 =\r
324 = HandleCtrls\r
325 =\r
326 =====================\r
327 */\r
328 \r
329 void HandleCtrls (void)\r
330 {\r
331         char    ch;\r
332 \r
333         ch = *text++;                   // get the character and advance\r
334 \r
335         if (ch == '\n')\r
336         {\r
337                 NewLine ();\r
338                 return;\r
339         }\r
340 \r
341 }\r
342 \r
343 \r
344 /*\r
345 =====================\r
346 =\r
347 = HandleWord\r
348 =\r
349 =====================\r
350 */\r
351 \r
352 void HandleWord (void)\r
353 {\r
354         char            word[WORDLIMIT];\r
355         int                     i,wordindex;\r
356         unsigned        wwidth,wheight,newpos;\r
357 \r
358 \r
359         //\r
360         // copy the next word into [word]\r
361         //\r
362         word[0] = *text++;\r
363         wordindex = 1;\r
364         while (*text>32)\r
365         {\r
366                 word[wordindex] = *text++;\r
367                 if (++wordindex == WORDLIMIT)\r
368                         Quit ("PageLayout: Word limit exceeded");\r
369         }\r
370         word[wordindex] = 0;            // stick a null at end for C\r
371 \r
372         //\r
373         // see if it fits on this line\r
374         //\r
375         VW_MeasurePropString (word,&wwidth,&wheight);\r
376 \r
377         while (px+wwidth > rightmargin[rowon])\r
378         {\r
379                 NewLine ();\r
380                 if (layoutdone)\r
381                         return;         // overflowed page\r
382         }\r
383 \r
384         //\r
385         // print it\r
386         //\r
387         newpos = px+wwidth;\r
388         VWB_DrawPropString (word);\r
389         px = newpos;\r
390 \r
391         //\r
392         // suck up any extra spaces\r
393         //\r
394         while (*text == ' ')\r
395         {\r
396                 px += SPACEWIDTH;\r
397                 text++;\r
398         }\r
399 }\r
400 \r
401 /*\r
402 =====================\r
403 =\r
404 = PageLayout\r
405 =\r
406 = Clears the screen, draws the pics on the page, and word wraps the text.\r
407 = Returns a pointer to the terminating command\r
408 =\r
409 =====================\r
410 */\r
411 \r
412 void PageLayout (boolean shownumber)\r
413 {\r
414         int             i,oldfontcolor;\r
415         char    ch;\r
416 \r
417         oldfontcolor = fontcolor;\r
418 \r
419         fontcolor = 0;\r
420 \r
421 //\r
422 // clear the screen\r
423 //\r
424         VWB_Bar (0,0,320,200,BACKCOLOR);\r
425 #ifndef SPEAR\r
426         VWB_DrawPic (0,0,H_TOPWINDOWPIC);\r
427         VWB_DrawPic (0,8,H_LEFTWINDOWPIC);\r
428         VWB_DrawPic (312,8,H_RIGHTWINDOWPIC);\r
429         VWB_DrawPic (8,176,H_BOTTOMINFOPIC);\r
430 #endif\r
431 \r
432         for (i=0;i<TEXTROWS;i++)\r
433         {\r
434                 leftmargin[i] = LEFTMARGIN;\r
435                 rightmargin[i] = SCREENPIXWIDTH-RIGHTMARGIN;\r
436         }\r
437 \r
438         px = LEFTMARGIN;\r
439         py = TOPMARGIN;\r
440         rowon = 0;\r
441         layoutdone = false;\r
442 \r
443 //\r
444 // make sure we are starting layout text (^P first command)\r
445 //\r
446         while (*text <= 32)\r
447                 text++;\r
448 \r
449         if (*text != '^' || toupper(*++text) != 'P')\r
450                 Quit ("PageLayout: Text not headed with ^P");\r
451 \r
452         while (*text++ != '\n')\r
453         ;\r
454 \r
455 \r
456 //\r
457 // process text stream\r
458 //\r
459         do\r
460         {\r
461                 ch = *text;\r
462 \r
463                 if (ch == '^')\r
464                         HandleCommand ();\r
465                 else\r
466                 if (ch == 9)\r
467                 {\r
468                  px = (px+8)&0xf8;\r
469                  text++;\r
470                 }\r
471                 else if (ch <= 32)\r
472                         HandleCtrls ();\r
473                 else\r
474                         HandleWord ();\r
475 \r
476         } while (!layoutdone);\r
477 \r
478         pagenum++;\r
479 \r
480         if (shownumber)\r
481         {\r
482                 #ifdef SPANISH\r
483                 strcpy (str,"Hoja ");\r
484                 itoa (pagenum,str2,10);\r
485                 strcat (str,str2);\r
486                 strcat (str," de ");\r
487                 py = 183;\r
488                 px = 208;\r
489                 #else\r
490                 strcpy (str,"pg ");\r
491                 itoa (pagenum,str2,10);\r
492                 strcat (str,str2);\r
493                 strcat (str," of ");\r
494                 py = 183;\r
495                 px = 213;\r
496                 #endif\r
497                 itoa (numpages,str2,10);\r
498                 strcat (str,str2);\r
499                 fontcolor = 0x4f;                          //12^BACKCOLOR;\r
500 \r
501                 VWB_DrawPropString (str);\r
502         }\r
503 \r
504         fontcolor = oldfontcolor;\r
505 }\r
506 \r
507 //===========================================================================\r
508 \r
509 /*\r
510 =====================\r
511 =\r
512 = BackPage\r
513 =\r
514 = Scans for a previous ^P\r
515 =\r
516 =====================\r
517 */\r
518 \r
519 void BackPage (void)\r
520 {\r
521         pagenum--;\r
522         do\r
523         {\r
524                 text--;\r
525                 if (*text == '^' && toupper(*(text+1)) == 'P')\r
526                         return;\r
527         } while (1);\r
528 }\r
529 \r
530 \r
531 //===========================================================================\r
532 \r
533 \r
534 /*\r
535 =====================\r
536 =\r
537 = CacheLayoutGraphics\r
538 =\r
539 = Scans an entire layout file (until a ^E) marking all graphics used, and\r
540 = counting pages, then caches the graphics in\r
541 =\r
542 =====================\r
543 */\r
544 void CacheLayoutGraphics (void)\r
545 {\r
546         char    far *bombpoint, far *textstart;\r
547         char    ch;\r
548 \r
549         textstart = text;\r
550         bombpoint = text+30000;\r
551         numpages = pagenum = 0;\r
552 \r
553         do\r
554         {\r
555                 if (*text == '^')\r
556                 {\r
557                         ch = toupper(*++text);\r
558                         if (ch == 'P')          // start of a page\r
559                                 numpages++;\r
560                         if (ch == 'E')          // end of file, so load graphics and return\r
561                         {\r
562 #ifndef SPEAR\r
563                                 CA_MarkGrChunk(H_TOPWINDOWPIC);\r
564                                 CA_MarkGrChunk(H_LEFTWINDOWPIC);\r
565                                 CA_MarkGrChunk(H_RIGHTWINDOWPIC);\r
566                                 CA_MarkGrChunk(H_BOTTOMINFOPIC);\r
567 #endif\r
568                                 CA_CacheMarks ();\r
569                                 text = textstart;\r
570                                 return;\r
571                         }\r
572                         if (ch == 'G')          // draw graphic command, so mark graphics\r
573                         {\r
574                                 ParsePicCommand ();\r
575                                 CA_MarkGrChunk (picnum);\r
576                         }\r
577                         if (ch == 'T')          // timed draw graphic command, so mark graphics\r
578                         {\r
579                                 ParseTimedCommand ();\r
580                                 CA_MarkGrChunk (picnum);\r
581                         }\r
582                 }\r
583                 else\r
584                         text++;\r
585 \r
586         } while (text<bombpoint);\r
587 \r
588         Quit ("CacheLayoutGraphics: No ^E to terminate file!");\r
589 }\r
590 #endif\r
591 \r
592 \r
593 /*\r
594 =====================\r
595 =\r
596 = ShowArticle\r
597 =\r
598 =====================\r
599 */\r
600 \r
601 #ifdef JAPAN\r
602 void ShowArticle (int which)\r
603 #else\r
604 void ShowArticle (char far *article)\r
605 #endif\r
606 {\r
607         #ifdef JAPAN\r
608         int             snames[10] = {  H_HELP1PIC,\r
609                                                         H_HELP2PIC,\r
610                                                         H_HELP3PIC,\r
611                                                         H_HELP4PIC,\r
612                                                         H_HELP5PIC,\r
613                                                         H_HELP6PIC,\r
614                                                         H_HELP7PIC,\r
615                                                         H_HELP8PIC,\r
616                                                         H_HELP9PIC,\r
617                                                         H_HELP10PIC};\r
618         int             enames[14] = {\r
619                                                         0,0,\r
620                                                         #ifndef JAPDEMO\r
621                                                         C_ENDGAME1APIC,\r
622                                                         C_ENDGAME1BPIC,\r
623                                                         C_ENDGAME2APIC,\r
624                                                         C_ENDGAME2BPIC,\r
625                                                         C_ENDGAME3APIC,\r
626                                                         C_ENDGAME3BPIC,\r
627                                                         C_ENDGAME4APIC,\r
628                                                         C_ENDGAME4BPIC,\r
629                                                         C_ENDGAME5APIC,\r
630                                                         C_ENDGAME5BPIC,\r
631                                                         C_ENDGAME6APIC,\r
632                                                         C_ENDGAME6BPIC\r
633                                                         #endif\r
634                                                         };\r
635         #endif\r
636         unsigned        oldfontnumber;\r
637         unsigned        temp;\r
638         boolean         newpage,firstpage;\r
639 \r
640         #ifdef JAPAN\r
641         pagenum = 1;\r
642         if (!which)\r
643                 numpages = 10;\r
644         else\r
645                 numpages = 2;\r
646 \r
647         #else\r
648 \r
649         text = article;\r
650         oldfontnumber = fontnumber;\r
651         fontnumber = 0;\r
652         CA_MarkGrChunk(STARTFONT);\r
653         VWB_Bar (0,0,320,200,BACKCOLOR);\r
654         CacheLayoutGraphics ();\r
655         #endif\r
656 \r
657         newpage = true;\r
658         firstpage = true;\r
659 \r
660         do\r
661         {\r
662                 if (newpage)\r
663                 {\r
664                         newpage = false;\r
665                         #ifdef JAPAN\r
666                         if (!which)\r
667                                 CA_CacheScreen(snames[pagenum - 1]);\r
668                         else\r
669                                 CA_CacheScreen(enames[which*2 + pagenum - 1]);\r
670                         #else\r
671                         PageLayout (true);\r
672                         #endif\r
673                         VW_UpdateScreen ();\r
674                         if (firstpage)\r
675                         {\r
676                                 VL_FadeIn(0,255,&gamepal,10);\r
677                                 // VW_FadeIn ()\r
678                                 firstpage = false;\r
679                         }\r
680                 }\r
681 \r
682                 LastScan = 0;\r
683                 while (!LastScan)\r
684                 ;\r
685 \r
686                 switch (LastScan)\r
687                 {\r
688                 case sc_UpArrow:\r
689                 case sc_PgUp:\r
690                 case sc_LeftArrow:\r
691                         if (pagenum>1)\r
692                         {\r
693                                 #ifndef JAPAN\r
694                                 BackPage ();\r
695                                 BackPage ();\r
696                                 #else\r
697                                 pagenum--;\r
698                                 #endif\r
699                                 newpage = true;\r
700                         }\r
701                         break;\r
702 \r
703                 case sc_Enter:\r
704                 case sc_DownArrow:\r
705                 case sc_PgDn:\r
706                 case sc_RightArrow:             // the text allready points at next page\r
707                         if (pagenum<numpages)\r
708                         {\r
709                                 newpage = true;\r
710                                 #ifdef JAPAN\r
711                                 pagenum++;\r
712                                 #endif\r
713                         }\r
714                         break;\r
715                 }\r
716 \r
717                 #ifndef SPEAR\r
718                 if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))\r
719                         PicturePause();\r
720                 #endif\r
721 \r
722         } while (LastScan != sc_Escape);\r
723 \r
724         IN_ClearKeysDown ();\r
725         fontnumber = oldfontnumber;\r
726 }\r
727 \r
728 \r
729 //===========================================================================\r
730 \r
731 #ifndef JAPAN\r
732 #ifdef ARTSEXTERN\r
733 int     endextern = T_ENDART1;\r
734 #ifndef SPEAR\r
735 int             helpextern = T_HELPART;\r
736 #endif\r
737 #endif\r
738 char helpfilename[13] = "HELPART.",\r
739          endfilename[13] = "ENDART1.";\r
740 #endif\r
741 \r
742 /*\r
743 =================\r
744 =\r
745 = HelpScreens\r
746 =\r
747 =================\r
748 */\r
749 #ifndef SPEAR\r
750 void HelpScreens (void)\r
751 {\r
752         int                     artnum;\r
753         char far        *text;\r
754         memptr          layout;\r
755 \r
756 \r
757         CA_UpLevel ();\r
758         MM_SortMem ();\r
759 #ifdef JAPAN\r
760         ShowArticle (0);\r
761         VW_FadeOut();\r
762         FreeMusic ();\r
763         CA_DownLevel ();\r
764         MM_SortMem ();\r
765 #else\r
766 \r
767 \r
768 \r
769 \r
770 #ifdef ARTSEXTERN\r
771         artnum = helpextern;\r
772         CA_CacheGrChunk (artnum);\r
773         text = (char _seg *)grsegs[artnum];\r
774         MM_SetLock (&grsegs[artnum], true);\r
775 #else\r
776         CA_LoadFile (helpfilename,&layout);\r
777         text = (char _seg *)layout;\r
778         MM_SetLock (&layout, true);\r
779 #endif\r
780 \r
781         ShowArticle (text);\r
782 \r
783 #ifdef ARTSEXTERN\r
784         MM_FreePtr (&grsegs[artnum]);\r
785 #else\r
786         MM_FreePtr (&layout);\r
787 #endif\r
788 \r
789 \r
790 \r
791         VW_FadeOut();\r
792 \r
793         FreeMusic ();\r
794         CA_DownLevel ();\r
795         MM_SortMem ();\r
796 #endif\r
797 }\r
798 #endif\r
799 \r
800 //\r
801 // END ARTICLES\r
802 //\r
803 void EndText (void)\r
804 {\r
805         int                     artnum;\r
806         char far        *text;\r
807         memptr          layout;\r
808 \r
809 \r
810         ClearMemory ();\r
811 \r
812         CA_UpLevel ();\r
813         MM_SortMem ();\r
814 #ifdef JAPAN\r
815         ShowArticle(gamestate.episode + 1);\r
816 \r
817         VW_FadeOut();\r
818 \r
819         SETFONTCOLOR(0,15);\r
820         IN_ClearKeysDown();\r
821         if (MousePresent)\r
822                 Mouse(MDelta);  // Clear accumulated mouse movement\r
823 \r
824         FreeMusic ();\r
825         CA_DownLevel ();\r
826         MM_SortMem ();\r
827 #else\r
828 \r
829 \r
830 \r
831 #ifdef ARTSEXTERN\r
832         artnum = endextern+gamestate.episode;\r
833         CA_CacheGrChunk (artnum);\r
834         text = (char _seg *)grsegs[artnum];\r
835         MM_SetLock (&grsegs[artnum], true);\r
836 #else\r
837         endfilename[6] = '1'+gamestate.episode;\r
838         CA_LoadFile (endfilename,&layout);\r
839         text = (char _seg *)layout;\r
840         MM_SetLock (&layout, true);\r
841 #endif\r
842 \r
843         ShowArticle (text);\r
844 \r
845 #ifdef ARTSEXTERN\r
846         MM_FreePtr (&grsegs[artnum]);\r
847 #else\r
848         MM_FreePtr (&layout);\r
849 #endif\r
850 \r
851 \r
852         VW_FadeOut();\r
853         SETFONTCOLOR(0,15);\r
854         IN_ClearKeysDown();\r
855         if (MousePresent)\r
856                 Mouse(MDelta);  // Clear accumulated mouse movement\r
857 \r
858         FreeMusic ();\r
859         CA_DownLevel ();\r
860         MM_SortMem ();\r
861 #endif\r
862 }\r