home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 615 / text_spd / text_spd.lst
Encoding:
File List  |  1992-06-24  |  6.6 KB  |  231 lines

  1. ' 6/24/92
  2. ' =================================================================
  3. ' DESCRIPTION:
  4. ' This GFA BASIC 3.x program demos and tests different screen text functions.
  5. ' Both native GFA BASIC commands (TEXT and PRINT) and calls to the VDI
  6. ' and GEMDOS are used.
  7. '
  8. ' The inspiration for this came from the horrible discovery that graphic text
  9. ' in HiSoft BASIC is MUCH faster than GFA BASIC's.  TEXT is not a simple call
  10. ' to the ST's v_gtext funtion (VDISYS 8) but has been optimized to work quickly
  11. ' in the interpreter and across all text attributes.  Unfortunately, TEXT
  12. ' works at the same speed when compiled as interpreted and is much slower
  13. ' than v_gtext (which is what HiSoft uses) with compiled programs using normal
  14. ' text.  Also, it is not helped by screen accelerators like v_gtext
  15. ' (the blitter helps it quite a bit though).
  16. '
  17. ' CREDITS:
  18. ' It was written by Jonathan Corey and is in the Public Domain.  Send any
  19. ' comments (or improvments to JWC-OEO on GEnie).
  20. '
  21. ' The original v_gtext routine is a slightly modified version of the one I
  22. ' found in the AccuSoft ST BASIC Programmer's Kit.  It is faster than TEXT.
  23. '
  24. ' What's referred to here as mod #1 is a change to the above written by me.
  25. ' It is faster than TEXT and PRINT.
  26. '
  27. ' mod #2 is based on changes written by D.LIVINGST11 [Big Earnest] via GEnie.
  28. ' It is the fastest of the v_gtext implimentations here.
  29. '
  30. ' The routine for calling GEMDOS 9 came from D.SEBERG [IceBerg] via GEnie.
  31. ' This is an interesting one.  It's does the fastest screen output with a
  32. ' screen accelerator (ST Turbo etc) installed and the slowest without one.
  33. '
  34. ' ======================================================================
  35. DEFWRD "a-z"
  36. DEFMOUSE 0
  37. DEFTEXT ,0,,,   !0 is normal text, change to 1 for Bold etc..
  38. '
  39. PRINT CHR$(27)+"w";   !turn off line wrap
  40. '
  41. m$=" Speed test of screen output  | methods using GFA BASIC 3.x|"
  42. m$=m$+" |Press a key after each screen"
  43. m$="[0]["+m$+"][Continue|Quit]"
  44. IF FORM_ALERT(1,m$)=2
  45.   EDIT
  46. ENDIF
  47. m$="[2][|Set a clipping rectangle?][Full|Clip]"
  48. IF FORM_ALERT(1,m$)=2
  49.   clip!=TRUE
  50. ENDIF
  51. '
  52. ~GRAF_HANDLE(char_w,char_h,box_w,box_h)
  53. '
  54. t$="All I want for breakfast, is my Two Front Teeth!  For BREAKFAST you say?!?!"+CHR$(0)
  55. '
  56. screen_columns=(WORK_OUT(0)+1)\char_w
  57. IF screen_columns<LEN(t$)   !for low res
  58.   t$=LEFT$(t$,screen_columns-1)
  59. ENDIF
  60. '
  61. @tclip
  62. '
  63. ' ====================== GRAPHIC TEXT SECTION =========================
  64. CLS
  65. t_text$=" TEXT  "
  66. t#=TIMER
  67. FOR line=1 TO 24
  68.   TEXT 8,line*char_h,0,t$
  69. NEXT line
  70. t_text#=TIMER-t#
  71. CLIP OFF
  72. TEXT 8,char_h,SPACE$(screen_columns)
  73. TEXT 8,char_h,t_text$+"took "+STR$(t_text#/200)+" seconds."
  74. @tclip
  75. ~INP(2)
  76. '
  77. CLS
  78. t_vdisys1$=" VDISYS 8, orignl "
  79. len_t=LEN(t$)
  80. t#=TIMER
  81. FOR line=1 TO 24
  82.   v_gtext_orig(8,line*char_h,t$)
  83. NEXT line
  84. t_vdisys1#=TIMER-t#
  85. CLIP OFF
  86. v_gtext_orig(8,char_h,SPACE$(screen_columns))
  87. v_gtext_orig(8,char_h,t_vdisys1$+"took "+STR$(t_vdisys1#/200)+" seconds.")
  88. @tclip
  89. ~INP(2)
  90. '
  91. CLS
  92. t_vdisys2$=" VDISYS 8, mod #1 "
  93. t#=TIMER
  94. FOR line=1 TO 24
  95.   v_gtext_mod1(8,line*char_h,t$)
  96. NEXT line
  97. t_vdisys2#=TIMER-t#
  98. CLIP OFF
  99. v_gtext_mod1(8,char_h,SPACE$(screen_columns))
  100. v_gtext_mod1(8,char_h,t_vdisys2$+"took "+STR$(t_vdisys2#/200)+" seconds.")
  101. @tclip
  102. ~INP(2)
  103. '
  104. CLS
  105. t_vdisys3$=" VDISYS 8, mod #2 "
  106. t#=TIMER
  107. FOR line=1 TO 24
  108.   v_gtext_mod2(8,line*char_h,t$)
  109. NEXT line
  110. t_vdisys3#=TIMER-t#
  111. CLIP OFF
  112. v_gtext_mod2(8,char_h,SPACE$(screen_columns))
  113. v_gtext_mod2(8,char_h,t_vdisys3$+"took "+STR$(t_vdisys3#/200)+" seconds.")
  114. @tclip
  115. ~INP(2)
  116. '
  117. ' ========================= CHARACTER TEXT SECTION ==============
  118. CLS
  119. t_print$=" PRINT "
  120. t#=TIMER
  121. FOR line=1 TO 24
  122.   ' LOCATE 2,line
  123.   ' PRINT t$;
  124.   PRINT AT(2,line);t$
  125. NEXT line
  126. t_print#=TIMER-t#
  127. PRINT AT(1,1);SPACE$(screen_columns)
  128. PRINT AT(2,1);t_print$;"took ";t_print#/200;" seconds."
  129. ~INP(2)
  130. '
  131. CLS
  132. t_gemdos$=" GEMDOS 9   "
  133. t#=TIMER
  134. t$=t$+CHR$(0)   !need to terminate strings with CHR$(0) for GEMDOS 9
  135. FOR line=1 TO 24
  136.   LOCATE 2,line
  137.   ~GEMDOS(9,L:V:t$)
  138. NEXT line
  139. t_gemdos#=TIMER-t#
  140. PRINT AT(1,1);SPACE$(screen_columns)
  141. PRINT AT(2,1);t_gemdos$;"took ";t_gemdos#/200;" seconds."
  142. ~INP(2)
  143. '
  144. ' ============================== SUMMARY ======================
  145. CLS
  146. PRINT " Ratios of elapsed time"
  147. PRINT
  148. PRINT " A TO B =2.0  means A takes twice as long as B (B is 2 times faster than A)"
  149. PRINT " A TO B =0.5  means A takes half as long as B  (A is 2 times faster than B)"
  150. PRINT
  151. PRINT t_vdisys1$;" TO ";t_text$;"= ";ROUND(t_vdisys1#/t_text#,3)
  152. PRINT t_vdisys2$;" TO ";t_text$;"= ";ROUND(t_vdisys2#/t_text#,3)
  153. PRINT t_vdisys3$;" TO ";t_text$;"= ";ROUND(t_vdisys3#/t_text#,3)
  154. PRINT t_print$;SPC(11);" TO ";t_text$;"= ";ROUND(t_print#/t_text#,3)
  155. PRINT
  156. PRINT t_vdisys1$;" TO ";t_print$;"= ";ROUND(t_vdisys1#/t_print#,3)
  157. PRINT t_vdisys2$;" TO ";t_print$;"= ";ROUND(t_vdisys2#/t_print#,3)
  158. PRINT t_vdisys3$;" TO ";t_print$;"= ";ROUND(t_vdisys3#/t_print#,3)
  159. PRINT
  160. PRINT t_text$;SPC(11);" TO ";t_print$;"= ";ROUND(t_text#/t_print#,3)
  161. PRINT t_gemdos$;SPC(6);" TO ";t_print$;"= ";ROUND(t_gemdos#/t_print#,3)
  162. PRINT
  163. PRINT t_vdisys2$;" TO  orig  = ";ROUND(t_vdisys2#/t_vdisys1#,3)
  164. PRINT t_vdisys3$;" TO  orig  = ";ROUND(t_vdisys3#/t_vdisys1#,3)
  165. PRINT t_vdisys3$;" TO  mod1  = ";ROUND(t_vdisys3#/t_vdisys2#,3)
  166. PRINT
  167. PRINT t_vdisys3$;" TO GMDOS9 = ";ROUND(t_vdisys3#/t_gemdos#,3)
  168. PRINT
  169. PRINT " End of test"
  170. ~INP(2)
  171. EDIT
  172. '
  173. > PROCEDURE v_gtext_orig(x_,y_,text_$)
  174.   len_t=LEN(text_$)
  175.   CONTRL(1)=1
  176.   CONTRL(2)=0
  177.   CONTRL(3)=len_t
  178.   CONTRL(4)=0
  179.   PTSIN(0)=x_
  180.   PTSIN(1)=y_
  181.   FOR column=0 TO len_t-1
  182.     '  DPOKE INTIN+(2*column&),ASC(MID$(text_$,column&+1,1))
  183.     WORD{INTIN+(2*column)}=ASC(MID$(text_$,column+1,1))
  184.     '  CARD{INTIN... works too, all give the same results
  185.   NEXT column
  186.   VDISYS 8
  187. RETURN
  188. '
  189. > PROCEDURE v_gtext_mod1(x_,y_,text_$)
  190.   len_t=LEN(text_$)
  191.   CONTRL(1)=1
  192.   CONTRL(2)=0
  193.   CONTRL(3)=len_t
  194.   CONTRL(4)=0
  195.   PTSIN(0)=x_
  196.   PTSIN(1)=y_
  197.   FOR column_%=0 TO len_t-1
  198.     '    DPOKE INTIN+(2*column_%),BYTE{(V:text_$)+column_%}
  199.     WORD{INTIN+(2*column_%)}=BYTE{(V:text_$)+column_%}
  200.     '   CARD{INTIN... works too, all give the same results
  201.   NEXT column_%
  202.   VDISYS 8
  203. RETURN
  204. '
  205. > PROCEDURE v_gtext_mod2(x_,y_,text_$)
  206.   ' LOCAL p_str%,p_intin%,p_pin1%,chars_left
  207.   ' globals are faster, locals are safer
  208.   chars_left=LEN(text_$)
  209.   CONTRL(1)=1
  210.   CONTRL(2)=0
  211.   CONTRL(3)=chars_left
  212.   CONTRL(4)=0
  213.   PTSIN(0)=x_
  214.   PTSIN(1)=y_
  215.   p_str%=V:text_$
  216.   p_intin%=INTIN
  217.   WHILE chars_left>0
  218.     WORD{p_intin%}=BYTE{p_str%}
  219.     INC p_str%
  220.     ADD p_intin%,2
  221.     DEC chars_left
  222.   WEND
  223.   VDISYS 8
  224. RETURN
  225. '
  226. > PROCEDURE tclip
  227.   IF clip!
  228.     CLIP (3*char_w)+3,(4*char_h)-4,WORK_OUT(0)-(9*char_w),WORK_OUT(1)-(7*char_h)
  229.   ENDIF
  230. RETURN
  231.