Translate

Sunday, May 20, 2018

Some Basics 4 MSX Basic ( part 4 )

Hellow again.
This example is a bit longer than earlier posts. 

I wanted to make a good example of what you can do with characters in SCREEN 1,
but colours would make the example too long.


Problem:How to get bold characters in SCREEN 1

Solution: VPOKE only the charcters you want to speed up your code
 
Example:
100 ' SB4B-04 apr/may 2018 TnC
110 SCREEN 1:WIDTH32:KEY OFF
120 PRINT "SCREEN 1: Bold Characters":PRINT: PRINT
130 '---
140 T$="ABCDEF":PRINT T$:PRINT:GOSUB 220

150 T$="123456":PRINT T$: PRINT: GOSUB 220
160 T$="abcdef":PRINT T$:PRINT:GOSUB 220
170 '---
180 PRINT:PRINT "Press any key when ready"
190 IF INKEY$="" THEN 190
200 SCREEN 0:KEY ON:END
210 '---
220 FOR T=1 TO LEN(T$)
230 A=(ASC(MID$(T$,T,1)))*8
240 FOR V=A TO (A+8)
250 VPOKE V,VPEEK(V) 0R VPEEK(V)/2
260 NEXT:NEXT
270 RETURN 

I wanted to make a good example of what you can do with characters in SCREEN 1,
but colours would make the example too long.


The clever VPOKE in line 250 does the whole trick, but you need to know the ASCII table. Then you know which characters must be bold.

For example: 
ASCII 65 = "A", 90 = "Z"
ASCII 97 = "a", 122 = "z"
ASCII 32 = space
ASCII 48 = "0", 57 = "9"


Please remember: Never use special msx chars to vpoke if you publish it online. 
Better use standard ascii characters like # or $ or ?




And after a CLS or SCREEN command, the bold characters will be normal again.

No comments:

Post a Comment