home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Programming / Amos / AMOSList-1097 / AMOSLIST / RetroFiles.lha / retrofiles / TextDisplayer.amos / TextDisplayer.amosSourceCode
Encoding:
AMOS Source Code  |  1980-02-25  |  3.6 KB  |  134 lines

  1. ' See the section marked with ******** in _LOADTEXT[] - it shows how to
  2. ' change the line length. See ******** in _DISPLAYPAGE[] to see how to 
  3. ' set text position and font size. 
  4. ' This variable sets the maximum number of pages in a document 
  5. MXPAGES=120
  6.  
  7. ' These variables set the page width and height  
  8. PAGEWIDTH=78
  9. PAGEHEIGHT=24
  10.  
  11. ' PAGE_START=Start in memory of the page 
  12. ' PAGE_LEN  =How many lines are in the page (always 15 unless at end of doc) 
  13. Dim PAGE_START(MXPAGES),PAGE_LEN(MXPAGES)
  14. Global PAGEWIDTH,PAGEHEIGHT,PAGES,PAGE_START(),PAGE_LEN()
  15.  
  16. F$=Fsel$("","","Select text file","")
  17. _LOADTEXT[F$,10]
  18.  
  19. ' Picture is stored on screen 1
  20. F$=Fsel$("","","Select background piccy","")
  21. Load Iff F$,1
  22. Wait Vbl 
  23.  
  24. Screen Open 0,Screen Width,Screen Height,Screen Colour,Screen Mode
  25. Flash Off : Curs Off : Cls 0
  26. Get Palette 1
  27.  
  28. Gr Writing 0
  29. Ink 15
  30. PAGE=1 : MK=0 : ESC=False
  31. Repeat 
  32.    If MK=1 and PAGE>1 Then Dec PAGE
  33.    If MK=2 and PAGE<PAGES Then Inc PAGE
  34.    _DISPLAYPAGE[PAGE]
  35.    Repeat : Until Mouse Key=0
  36.    Repeat 
  37.       MK=Mouse Key : ESC=Key State(69)
  38.    Until ESC or MK
  39. Until ESC
  40.  
  41. Erase All 
  42.  
  43. Edit 
  44.  
  45. Procedure _LOADTEXT[FILE$,BANK]
  46.    ' Load text FILE$ into BANK
  47.  
  48.    Open In 1,FILE$ : SIZE=Lof(1) : Close 1
  49.    Reserve As Work BANK,SIZE+4 : Bload FILE$,Start(BANK)
  50.    SP=Start(BANK) : BNKEND=Start(BANK)+Length(BANK)
  51.    L=0 : LASTSP=Start(BANK) : CHANGE=False
  52.    Repeat 
  53.       C=Peek(SP)
  54.       If C=13 Then Poke SP,10 : C=10
  55.       If C<>10 Then Inc L Else L=0
  56.       If C=32 Then LASTSP=SP : CHANGE=True
  57.       If L>PAGEWIDTH
  58.          If Not(CHANGE) : LASTSP=SP : End If 
  59.          Poke LASTSP,10 : L=0 : SP=LASTSP : CHANGE=False
  60.       End If 
  61.       Inc SP
  62.    Until SP>BNKEND
  63.    SP=Start(BANK) : L=0 : PAGES=1 : OLDSP=SP-1
  64.    Repeat 
  65.       C=Peek(SP)
  66.       If C=10 or SP>=BNKEND
  67.          Inc L
  68.          If L=PAGEHEIGHT or SP>=BNKEND
  69.             PAGE_START(PAGES)=OLDSP+1 : PAGE_LEN(PAGES)=L
  70.             If L>0 : Inc PAGES : End If 
  71.             OLDSP=SP : L=0
  72.          End If 
  73.       End If 
  74.       Inc SP
  75.    Until SP>BNKEND
  76.    Dec PAGES
  77.    Dec PAGE_LEN(PAGES)
  78.  
  79. End Proc
  80. Procedure _DISPLAYPAGE[PAGE]
  81.    ' Display PAGE of text 
  82.    
  83.    ' ***** Change these to where you want the text to start ************
  84.    X=10 : Y=20
  85.    
  86.    ' ***** This variable is the height of the font in pixels ***********
  87.    ' ***** topaz/8 was 8, so your new font, xxxx/9 would be size 9 *****
  88.    SIZE=8
  89.    
  90.    Screen Copy 1 To 0
  91.    
  92.    SP=PAGE_START(PAGE)
  93.    For L=1 To PAGE_LEN(PAGE)
  94.       OLDSP=SP
  95.       SP=Hunt(SP To SP+32*18,Chr$(10))+1
  96.       If SP>0 Then Text X+0,Y+L*SIZE,Peek$(OLDSP,SP-OLDSP-1) Else Exit 
  97.    Next L
  98.    
  99. End Proc
  100.  
  101. Procedure _ADDEXTENSION[F$,X$]
  102.    ' Adds file extension X$ to F$, eg F$="Data", X$="s", Param$="Data.s"
  103.    ' Detects if it's already been added, and puts it in the case of X$... 
  104.    '    eg F$="Screen.iff" changes to "Screen.IFF" if X$="IFF"
  105.  
  106.    _FILENAME[F$] : FILENAM$=Param$
  107.    X$=X$-"." : XPOS=Instr(FILENAM$,"."+X$)
  108.    If XPOS<>Len(FILENAM$)-1-Len(X$)
  109.       If XPOS=0 : XPOS=Instr(FILENAM$,".")
  110.          If XPOS=0 : F$=F$+"."+X$
  111.          Else F$=Left$(F$,XPOS+(Len(F$)-Len(FILENAM$)))+X$
  112.          End If 
  113.       Else F$=Left$(F$,XPOS+1)+X$
  114.       End If 
  115.    Else F$=Left$(F$,Len(F$)-Len(X$))+X$
  116.    End If 
  117.  
  118. End Proc[F$]
  119. Procedure _BWINSTR[A$,C$]
  120.    ' Backwards Instr command/procedure
  121.    ' A$=Input string, C$=Search string
  122.  
  123.    X=Len(A$)
  124.    While Mid$(A$,X,1)<>C$ and X>0 : Dec X : Wend 
  125.  
  126. End Proc[X]
  127. Procedure _FILENAME[F$]
  128.    ' Get filename from pathname and filename F$ 
  129.    ' eg. "DH0:Data/Pic.iff" would return "Pic.iff"
  130.  
  131.    _BWINSTR[F$,"/"] : SLASH=Param : _BWINSTR[F$,":"] : CLON=Param
  132.    F$=Right$(F$,Len(F$)-Max(SLASH,CLON))
  133.  
  134. End Proc[F$]