Advertisement
Mysoft

Untitled

Dec 6th, 2016
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "crt.bi"
  2.  
  3. const SCREEN_WIDTH = 20, SCREEN_HEIGHT = 13
  4. width SCREEN_WIDTH+2,SCREEN_HEIGHT
  5.  
  6. dim shared as integer TextRow,iC=10
  7.  
  8. sub Clean()
  9.   color ,0: cls
  10.   for L as integer = 1 to SCREEN_HEIGHT
  11.     locate L, SCREEN_WIDTH+1
  12.     color 7: print "|";  
  13.   next L
  14.   locate 1,1: TextRow = 0
  15. end sub
  16.  
  17. sub TypeText2 (pzText as zstring ptr)  
  18.   var pzBegin = cast(ubyte ptr,pzText)
  19.   var pzCurrent = pzBegin, pzEnd = pzBegin
  20.   var X = 0, iAdvanceLine = 0
  21.   do    
  22.     select case *pzCurrent
  23.     case asc(!"\n"),0 : pzEnd = pzCurrent: iAdvanceLine = 1
  24.     case asc(" ")     : pzEnd = pzCurrent
  25.     case asc(!"\r")   : pzCurrent += 1: continue do
  26.     end select        
  27.     if iAdvanceLine or X >= SCREEN_WIDTH then
  28.       if pzEnd = pzBegin then
  29.         pzEnd = pzCurrent: pzCurrent += (*pzCurrent<>asc(!"\n"))
  30.       else
  31.         pzCurrent = pzEnd
  32.       end if      
  33.       iC xor= 1: color iC,1
  34.       while pzBegin < pzEnd
  35.         if *pzBegin <> asc(!"\r") then
  36.           print chr$(*pzBegin);
  37.           'pCon.Lock()
  38.           'CharPtr(X, TextRow) = Text[CharNum]
  39.           'pCon.Unlock()
  40.         end if
  41.         pzBegin += 1: sleep 25,1
  42.       wend      
  43.       if *pzEnd = 0 then exit do      
  44.       TextRow += 1: X = 0 : iAdvanceLine = 0
  45.       pzCurrent += 1: pzBegin = pzCurrent: pzEnd = pzCurrent      
  46.       locate TextRow+1,1
  47.     else
  48.       X += 1: pzCurrent += 1
  49.     end if
  50.   loop
  51.  
  52. end sub
  53.  
  54. Clean()
  55. TypeText2( _
  56. !"Hello World :] we have a big sentence that was indeed split by spaces.\r\n" _
  57. !"it may end splitting several lines!\r\n" _
  58. !"NoSpacesButSplitting\n\nExactlyAtWrap.\r\n" _
  59. !"ThisHasNoSpacesSoWhatDoiDoNow?\r\n" _
  60. !"Last Line." )
  61.  
  62. sleep
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement