7 =============================================================================
\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
17 =============================================================================
\r
21 =============================================================================
\r
25 =============================================================================
\r
28 #define BACKCOLOR 0x11
\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
38 #define TEXTROWS ((200-TOPMARGIN-BOTTOMMARGIN)/FONTHEIGHT)
\r
39 #define SPACEWIDTH 7
\r
40 #define SCREENPIXWIDTH 320
\r
41 #define SCREENMID (SCREENPIXWIDTH/2)
\r
44 =============================================================================
\r
48 =============================================================================
\r
51 int pagenum,numpages;
\r
53 unsigned leftmargin[TEXTROWS],rightmargin[TEXTROWS];
\r
57 int picx,picy,picnum,picdelay;
\r
60 //===========================================================================
\r
64 =====================
\r
68 =====================
\r
71 void RipToEOL (void)
\r
73 while (*text++ != '\n') // scan to end of line
\r
79 =====================
\r
83 =====================
\r
86 int ParseNumber (void)
\r
89 char num[80],*numptr;
\r
92 // scan until a number is found
\r
95 while (ch < '0' || ch >'9')
\r
99 // copy the number out
\r
106 } while (ch >= '0' && ch <= '9');
\r
115 =====================
\r
119 = Call with text pointing just after a ^P
\r
120 = Upon exit text points to the start of next line
\r
122 =====================
\r
125 void ParsePicCommand (void)
\r
127 picy=ParseNumber();
\r
128 picx=ParseNumber();
\r
129 picnum=ParseNumber();
\r
134 void ParseTimedCommand (void)
\r
136 picy=ParseNumber();
\r
137 picx=ParseNumber();
\r
138 picnum=ParseNumber();
\r
139 picdelay=ParseNumber();
\r
145 =====================
\r
149 = Call with text pointing just after a ^P
\r
150 = Upon exit text points to the start of next line
\r
152 =====================
\r
155 void TimedPicCommand (void)
\r
157 ParseTimedCommand ();
\r
160 // update the screen, and wait for time delay
\r
162 VW_UpdateScreen ();
\r
168 while (TimeCount < picdelay)
\r
174 VWB_DrawPic (picx&~7,picy,picnum);
\r
179 =====================
\r
183 =====================
\r
186 void HandleCommand (void)
\r
188 int i,margin,top,bottom;
\r
189 int picwidth,picheight,picmid;
\r
191 switch (toupper(*++text))
\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
201 case ';': // comment
\r
204 case 'P': // ^P is start of next page, ^E is end of file
\r
207 text--; // back up to the '^'
\r
210 case 'C': // ^c<hex digit> changes text color
\r
211 i = toupper(*++text);
\r
212 if (i>='0' && i<='9')
\r
214 else if (i>='A' && i<='F')
\r
215 fontcolor = i-'A'+10;
\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
233 rowon = (py-TOPMARGIN)/FONTHEIGHT;
\r
234 py = TOPMARGIN+rowon*FONTHEIGHT;
\r
236 while (*text++ != '\n') // scan to end of line
\r
240 case 'T': // ^Tyyy,xxx,ppp,ttt waits ttt tics, then draws pic
\r
241 TimedPicCommand ();
\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
252 picmid = picx + picwidth/2;
\r
253 if (picmid > SCREENMID)
\r
254 margin = picx-PICMARGIN; // new right margin
\r
256 margin = picx+picwidth+PICMARGIN; // new left margin
\r
258 top = (picy-TOPMARGIN)/FONTHEIGHT;
\r
261 bottom = (picy+picheight-TOPMARGIN)/FONTHEIGHT;
\r
262 if (bottom>=TEXTROWS)
\r
263 bottom = TEXTROWS-1;
\r
265 for (i=top;i<=bottom;i++)
\r
266 if (picmid > SCREENMID)
\r
267 rightmargin[i] = margin;
\r
269 leftmargin[i] = margin;
\r
272 // adjust this line if needed
\r
274 if (px < leftmargin[rowon])
\r
275 px = leftmargin[rowon];
\r
282 =====================
\r
286 =====================
\r
289 void NewLine (void)
\r
293 if (++rowon == TEXTROWS)
\r
296 // overflowed the page, so skip until next page break
\r
303 ch = toupper(*(text+1));
\r
304 if (ch == 'E' || ch == 'P')
\r
315 px = leftmargin[rowon];
\r
322 =====================
\r
326 =====================
\r
329 void HandleCtrls (void)
\r
333 ch = *text++; // get the character and advance
\r
345 =====================
\r
349 =====================
\r
352 void HandleWord (void)
\r
354 char word[WORDLIMIT];
\r
356 unsigned wwidth,wheight,newpos;
\r
360 // copy the next word into [word]
\r
366 word[wordindex] = *text++;
\r
367 if (++wordindex == WORDLIMIT)
\r
368 Quit ("PageLayout: Word limit exceeded");
\r
370 word[wordindex] = 0; // stick a null at end for C
\r
373 // see if it fits on this line
\r
375 VW_MeasurePropString (word,&wwidth,&wheight);
\r
377 while (px+wwidth > rightmargin[rowon])
\r
381 return; // overflowed page
\r
387 newpos = px+wwidth;
\r
388 VWB_DrawPropString (word);
\r
392 // suck up any extra spaces
\r
394 while (*text == ' ')
\r
402 =====================
\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
409 =====================
\r
412 void PageLayout (boolean shownumber)
\r
414 int i,oldfontcolor;
\r
417 oldfontcolor = fontcolor;
\r
422 // clear the screen
\r
424 VWB_Bar (0,0,320,200,BACKCOLOR);
\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
432 for (i=0;i<TEXTROWS;i++)
\r
434 leftmargin[i] = LEFTMARGIN;
\r
435 rightmargin[i] = SCREENPIXWIDTH-RIGHTMARGIN;
\r
441 layoutdone = false;
\r
444 // make sure we are starting layout text (^P first command)
\r
446 while (*text <= 32)
\r
449 if (*text != '^' || toupper(*++text) != 'P')
\r
450 Quit ("PageLayout: Text not headed with ^P");
\r
452 while (*text++ != '\n')
\r
457 // process text stream
\r
476 } while (!layoutdone);
\r
483 strcpy (str,"Hoja ");
\r
484 itoa (pagenum,str2,10);
\r
486 strcat (str," de ");
\r
490 strcpy (str,"pg ");
\r
491 itoa (pagenum,str2,10);
\r
493 strcat (str," of ");
\r
497 itoa (numpages,str2,10);
\r
499 fontcolor = 0x4f; //12^BACKCOLOR;
\r
501 VWB_DrawPropString (str);
\r
504 fontcolor = oldfontcolor;
\r
507 //===========================================================================
\r
510 =====================
\r
514 = Scans for a previous ^P
\r
516 =====================
\r
519 void BackPage (void)
\r
525 if (*text == '^' && toupper(*(text+1)) == 'P')
\r
531 //===========================================================================
\r
535 =====================
\r
537 = CacheLayoutGraphics
\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
542 =====================
\r
544 void CacheLayoutGraphics (void)
\r
546 char far *bombpoint, far *textstart;
\r
550 bombpoint = text+30000;
\r
551 numpages = pagenum = 0;
\r
557 ch = toupper(*++text);
\r
558 if (ch == 'P') // start of a page
\r
560 if (ch == 'E') // end of file, so load graphics and return
\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
572 if (ch == 'G') // draw graphic command, so mark graphics
\r
574 ParsePicCommand ();
\r
575 CA_MarkGrChunk (picnum);
\r
577 if (ch == 'T') // timed draw graphic command, so mark graphics
\r
579 ParseTimedCommand ();
\r
580 CA_MarkGrChunk (picnum);
\r
586 } while (text<bombpoint);
\r
588 Quit ("CacheLayoutGraphics: No ^E to terminate file!");
\r
594 =====================
\r
598 =====================
\r
602 void ShowArticle (int which)
\r
604 void ShowArticle (char far *article)
\r
608 int snames[10] = { H_HELP1PIC,
\r
636 unsigned oldfontnumber;
\r
638 boolean newpage,firstpage;
\r
650 oldfontnumber = fontnumber;
\r
652 CA_MarkGrChunk(STARTFONT);
\r
653 VWB_Bar (0,0,320,200,BACKCOLOR);
\r
654 CacheLayoutGraphics ();
\r
667 CA_CacheScreen(snames[pagenum - 1]);
\r
669 CA_CacheScreen(enames[which*2 + pagenum - 1]);
\r
673 VW_UpdateScreen ();
\r
676 VL_FadeIn(0,255,&gamepal,10);
\r
706 case sc_RightArrow: // the text allready points at next page
\r
707 if (pagenum<numpages)
\r
718 if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))
\r
722 } while (LastScan != sc_Escape);
\r
724 IN_ClearKeysDown ();
\r
725 fontnumber = oldfontnumber;
\r
729 //===========================================================================
\r
733 int endextern = T_ENDART1;
\r
735 int helpextern = T_HELPART;
\r
738 char helpfilename[13] = "HELPART.",
\r
739 endfilename[13] = "ENDART1.";
\r
750 void HelpScreens (void)
\r
771 artnum = helpextern;
\r
772 CA_CacheGrChunk (artnum);
\r
773 text = (char _seg *)grsegs[artnum];
\r
774 MM_SetLock (&grsegs[artnum], true);
\r
776 CA_LoadFile (helpfilename,&layout);
\r
777 text = (char _seg *)layout;
\r
778 MM_SetLock (&layout, true);
\r
781 ShowArticle (text);
\r
784 MM_FreePtr (&grsegs[artnum]);
\r
786 MM_FreePtr (&layout);
\r
803 void EndText (void)
\r
815 ShowArticle(gamestate.episode + 1);
\r
819 SETFONTCOLOR(0,15);
\r
820 IN_ClearKeysDown();
\r
822 Mouse(MDelta); // Clear accumulated mouse movement
\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
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
843 ShowArticle (text);
\r
846 MM_FreePtr (&grsegs[artnum]);
\r
848 MM_FreePtr (&layout);
\r
853 SETFONTCOLOR(0,15);
\r
854 IN_ClearKeysDown();
\r
856 Mouse(MDelta); // Clear accumulated mouse movement
\r