Author Topic: Silly Programming Ideas - Turning Text into Graphics  (Read 31443 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: 1161
  • Likes Given: 1931
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: 44
  • Country: de
  • CPCBasic, CPCemu, CPC 6128
  • Liked: 96
  • Likes Given: 75
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: 262
  • Country: de
  • Liked: 297
  • Likes Given: 50
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)

Offline Z|G

  • CPC464
  • **
  • Posts: 19
  • Country: af
  • Liked: 22
  • Likes Given: 34
Re: Silly Programming Ideas - Turning Text into Graphics
« Reply #128 on: 12:01, 29 May 21 »
Not as one nice as the above ones.



Code: [Select]
10 CLS
20 MODE 2
30 a$="Hello CPC Wiki... Greetings to all members... Found a scroller and thought it worthy of posting...."
50 startatpos=40
60 amt=LEN(a$):a$=STRING$(startatpos," ")+a$:a$=a$+" "
80 FOR txt=1 TO LEN(a$)-1
90 LOCATE 20,10:PRINT MID$(a$,txt,startatpos);   
100 FOR delay=1 TO 50:NEXT delay     
110 NEXT txt
120 GOTO 80
« Last Edit: 13:06, 29 May 21 by Z|G »
1xCPC6128, 1xTandy Model 4, 1xC64 (IN BOX)