ftristxt.inc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. PROCEDURE ShowLines;
  2. BEGIN
  3. IF NOT nonupdatemode THEN
  4. BEGIN
  5. IF UseColor THEN
  6. TextColor(Yellow);
  7. GotoXY(40,16); Write('Lines: ',Lines:4,' Level: ',Level);
  8. END;
  9. END;
  10. PROCEDURE ShowGameMode;
  11. BEGIN
  12. IF NOT nonupdatemode THEN
  13. BEGIN
  14. GotoXY(61,13);
  15. IF NrFigures<>7 THEN
  16. write('Extended')
  17. ELSE
  18. write('Standard');
  19. END;
  20. END;
  21. PROCEDURE CreateFrame;
  22. {Used once to print the "background" of the screen (not the background grid,
  23. but the text, and the cadre around the playfield}
  24. VAR I : LONGINT;
  25. BEGIN
  26. SetDefaultColor;
  27. GotoXY(40,4);
  28. Write('FPCTris v0.08, (C) by Marco van de Voort');
  29. GotoXY(40,6);
  30. Write('A demo of the FPC Crt unit, and');
  31. GotoXY(40,7);
  32. Write(' its portability');
  33. FOR I:=9 TO 24 DO
  34. BEGIN
  35. GotoXY(40,I);
  36. Write(' ':38);
  37. END;
  38. ShowGameMode;
  39. IF nonupdatemode THEN
  40. BEGIN
  41. IF HelpMode THEN
  42. BEGIN
  43. GotoXY(40,9);
  44. Write('Arrow left/right to move, down to drop');
  45. GotoXY(40,10);
  46. Write('arrow-up to rotate the piece');
  47. GotoXY(40,11);
  48. Write('"P" to pause');
  49. GotoXY(40,12);
  50. Write('"E" Mode (standard or extended)');
  51. GotoXY(40,13);
  52. Write('"C" switches between color/mono mode');
  53. GotoXY(40,14);
  54. Write('Escape to quit');
  55. GotoXY(40,15);
  56. Write('"S" to show the highscores');
  57. {$IFDEF Linux}
  58. GotoXY(40,16);
  59. Write('"i" try to switch to IBM character set');
  60. {$ENDIF}
  61. END
  62. ELSE
  63. ShowHighScore;
  64. END
  65. ELSE
  66. BEGIN
  67. GotoXY(40,9);
  68. Write('"h" to display the helpscreen');
  69. END;
  70. FOR I :=0 TO TheHeight-1 DO
  71. BEGIN
  72. GotoXY(PosXField-1 ,PosYField+I); Write(Style[2]);
  73. GotoXY(PosXField+2*TheWidth ,PosYField+I); Write(Style[2]);
  74. END;
  75. GotoXY(PosXField-1,PosYField+TheHeight);
  76. Write(Style[3]);
  77. FOR I:=0 TO (2*TheWidth)-1 DO
  78. Write(Style[1]);
  79. Write(Style[4]);
  80. END;
  81. PROCEDURE DisplMainFieldMono;
  82. {Displays the grid with a simple buffering algoritm, depending on
  83. conditional DoubleBuffer}
  84. VAR Row,Column,Difference,StartRow,EndRow : LONGINT;
  85. S : String;
  86. BEGIN
  87. FOR Row:=0 TO TheHeight-1 DO
  88. BEGIN
  89. {$IFDEF DoubleCache}
  90. IF BackField[Row]<>MainField[Row] THEN
  91. BEGIN
  92. {$ENDIF}
  93. FillChar(S[1],2*TheWidth,#32);
  94. StartRow:=0;
  95. EndRow:=TheWidth-1;
  96. {$IFDEF DoubleCache}
  97. Difference:=MainField[Row] XOR BackField[Row]; {Calc differences in line}
  98. {Search for first and last bit changed}
  99. WHILE ((Difference AND AndTable[StartRow])=0) AND (StartRow<(TheWidth-1)) DO
  100. INC(StartRow);
  101. WHILE ((Difference AND AndTable[EndRow])=0) AND (EndRow>0) DO
  102. DEC(EndRow);
  103. {$ENDIF}
  104. {Prepare a string}
  105. GotoXY(PosXField+2*StartRow,PosYField+Row);
  106. S[0]:=CHR(2*(EndRow-StartRow+1));
  107. FOR Column:=0 TO EndRow-StartRow DO
  108. BEGIN
  109. IF (MainField[Row] AND AndTable[StartRow+Column])<>0 THEN
  110. BEGIN
  111. S[Column*2+1]:=Style[5];
  112. S[Column*2+2]:=Style[5];
  113. END;
  114. END;
  115. {Write the string}
  116. Write(S);
  117. {$IFDEF DoubleCache}
  118. END;
  119. {$ENDIF}
  120. END;
  121. {$IFDEF DoubleCache}
  122. BackField:=MainField; {Keep a copy of the screen for faster updates
  123. of terminals, for next DisplMainField.}
  124. {$ENDIF}
  125. END;
  126. PROCEDURE DisplMainFieldColor;
  127. {Same as above, but also use ColorField to output colors,
  128. the buffering is the same, but the colors make it less efficient.}
  129. VAR Row,Column,Difference,StartRow,EndRow,
  130. L : LONGINT;
  131. S : String;
  132. LastCol : LONGINT;
  133. BEGIN
  134. LastCol:=255;
  135. FOR Row:=0 TO TheHeight-1 DO
  136. BEGIN
  137. {$IFDEF DoubleCache}
  138. IF BackField[Row]<>MainField[Row] THEN
  139. BEGIN
  140. {$ENDIF}
  141. FillChar(S[1],2*TheWidth,#32);
  142. StartRow:=0;
  143. EndRow:=TheWidth-1;
  144. {$IFDEF DoubleCache}
  145. Difference:=MainField[Row] XOR BackField[Row]; {Calc differences in line}
  146. WHILE ((Difference AND AndTable[StartRow])=0) AND (StartRow<(TheWidth-1)) DO
  147. INC(StartRow);
  148. WHILE ((Difference AND AndTable[EndRow])=0) AND (EndRow>0) DO
  149. DEC(EndRow);
  150. {$ENDIF}
  151. GotoXY(PosXField+2*StartRow,PosYField+Row);
  152. FOR Column:=0 TO EndRow-StartRow DO
  153. BEGIN
  154. IF (MainField[Row] AND AndTable[StartRow+Column])<>0 THEN
  155. BEGIN
  156. L:=ColorField[Row,StartRow+Column];
  157. IF L=0 THEN
  158. L:=CurrentCol;
  159. IF L<>LastCol THEN
  160. BEGIN
  161. TextColor(L);
  162. Write(Style[5],Style[5]);
  163. END;
  164. END
  165. ELSE
  166. Write(' ');
  167. END;
  168. {$IFDEF DoubleCache}
  169. END;
  170. {$ENDIF}
  171. END;
  172. {$IFDEF DoubleCache}
  173. BackField:=MainField; {Keep a copy of the screen for faster updates
  174. of terminals, for next DisplMainField.}
  175. {$ENDIF}
  176. END;
  177. PROCEDURE DisplMainField;
  178. {Main redraw routine; Check in what mode we are and call appropriate routine}
  179. BEGIN
  180. IF UseColor THEN
  181. DisplMainFieldColor
  182. ELSE
  183. DisplMainFieldMono;
  184. END;
  185. PROCEDURE ShowNextFigure(ThisFig:LONGINT);
  186. VAR I,J,K : LONGINT;
  187. S : String[8];
  188. BEGIN
  189. IF UseColor THEN
  190. TextColor(White);
  191. IF NOT nonupdatemode THEN
  192. BEGIN
  193. FOR I:=0 TO 4 DO
  194. BEGIN
  195. FillChar(S,9,' ');
  196. S[0]:=#8;
  197. K:=Figures[ThisFig][FigureNr];
  198. IF (I+TopY)<=TheHeight THEN
  199. FOR J:=0 TO 4 DO
  200. BEGIN
  201. IF (K AND AndTable[J+5*I])<>0 THEN
  202. BEGIN
  203. S[J*2+1]:=Style[5];
  204. S[J*2+2]:=Style[5];
  205. END
  206. END;
  207. GotoXY(50,11+I); Write(S);
  208. END;
  209. END;
  210. END;
  211. PROCEDURE FixScores;
  212. BEGIN
  213. IF UseColor THEN
  214. SetDefaultColor;
  215. GotoXY(40,18);
  216. Write('Score :',Score);
  217. END;
  218. $Log$
  219. Revision 1.2 2000-07-13 11:33:08 michael
  220. + removed logs
  221. }