Author Topic: Silly Programming Ideas - Turning Text into Graphics  (Read 26909 times)

0 Members and 1 Guest are viewing this topic.

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1155
  • Likes Given: 1923
Multicoloured Text Scroller in BASIC
« Reply #125 on: 11:25, 11 December 19 »
A while ago I wondered if it were possible to use one of those BASIC Message Scrollers to have each letter in a different colour as it Scrolls Right to Left. I wasn't successful earlier, though my 2nd attempt I had of it was good enough to create this version. I don't know if it could be improved, though the code is compatible in Locomotive BASIC and CPC BASIC 3.


Code: [Select]

100 MODE 1:BORDER 0:INK 0,11:INK 1,26:p=1
110 READ a$,col$
120 a$=a$+MID$(a$,1,1):a$=RIGHT$(a$,LEN(a$)-1)
130 col$=col$+MID$(col$,1,1):col$=RIGHT$(col$,LEN(col$)-1)
140 LOCATE 10,10
150 FOR p2=1 TO 20
160   PEN VAL(MID$(col$,p,1))
170   PRINT MID$(a$,p2,1);
180   p=p+1
190   IF p=len(a$) THEN p=1
200 NEXT p2
210 IF p>20 THEN p=p-20
220 GOTO 120
230 DATA " Multicoloured Text Scrolling in BASIC...."
240 DATA "132231123123212321231212321231322123212321"
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline mv

  • Supporter
  • CPC464
  • *
  • Posts: 42
  • Country: de
  • CPCBasic, CPCemu, CPC 6128
  • Liked: 94
  • Likes Given: 71
Re: Multicoloured Text Scroller in BASIC
« Reply #126 on: 23:23, 13 January 20 »
A while ago I wondered if it were possible to use one of those BASIC Message Scrollers to have each letter in a different colour as it Scrolls Right to Left. I wasn't successful earlier, though my 2nd attempt I had of it was good enough to create this version. I don't know if it could be improved, though the code is compatible in Locomotive BASIC and CPC BASIC 3.

Hmm, improve? Staying with Locomotive BASIC, I just checked that using chr$(15) to set the PEN and printing it as a single string will speeds up the scroller by a factor of 3:
Code: [Select]

100 MODE 1:BORDER 0:INK 0,11:INK 1,26:p=1
110 READ a$,col$
120 a$=a$+MID$(a$,1,1):a$=RIGHT$(a$,LEN(a$)-1)
130 col$=col$+MID$(col$,1,1):col$=RIGHT$(col$,LEN(col$)-1)
140 'LOCATE 10,10
150 FOR p2=1 TO len(a$)
160   'PEN VAL(MID$(col$,p,1))
170   'PRINT MID$(a$,p2,1);
175   s$=s$+chr$(15)+chr$(VAL(MID$(col$,p,1))) +  MID$(a$,p2,1)
180   p=p+1
190   IF p=len(a$) THEN p=1
200 NEXT p2
205 p=1
210 'IF p>20 THEN p=p-20
213 t$=mid$(s$,p,20*3)
214 if len(t$)<20*3 then t$=t$+left$(s$,20*3-len(t$))
215 locate 10,10:?t$;
216 p=p+3:if p>len(s$) then p=1
220 GOTO 213
230 DATA " Multicoloured Text Scrolling in BASIC...."
240 DATA "132231123123212321231212321231322123212321"

Offline Fessor

  • CPC6128
  • ****
  • Posts: 235
  • Country: de
  • Liked: 204
  • Likes Given: 46
Re: Silly Programming Ideas - Turning Text into Graphics
« Reply #127 on: 01:09, 14 January 20 »
Dunno how much it saves, AFAIK converting of the values wasn't needed.

Code: [Select]
175   s$=s$+chr$(15)+MID$(col$,p,1) +  MID$(a$,p2,1)