Some Basics 4 MSX Basic ( part 5 )
Problem:
Sometimes you cant start the next program automaticly, for example the Wordstore+ Basic replayer. Why ? Cause the replayer removes the entire Basic program that started the replayer.
Example:
10 PRINT Play the WS+ sample"
20 BLOAD "sample.ws",R
30 A=USR(0)
40 END
It wil not work. After the BLOAD the whole Basic program is gone.
Solution:
An easy methode is, let the user press a key to start the next part of the program.
Example:
10 ' Some Basics 4 MSX Basic 5
20 SCREEN 0
30 PRINT "Press ENTER to run this program again"
40 PRINT:PRINT "run"
50 LOCATE 0,CSRLIN-2
60 END
The trick is in line 50. The CSRLIN has the value of the current Y coordinate on the text-screen. We extract 2 from the current Y coordinate, so the cursor will be on the first character of the word "run" and we end the program.
If the user press ENTER, it will start then same program again.
Of course instead of "run" you can use "BLOAD"sample.ws",R".
It's not very fancy, but I used this trick a couple of times,
cause I didn't had a better solution.
Translate
Showing posts with label Some Basics 4 MSX Basic. Show all posts
Showing posts with label Some Basics 4 MSX Basic. Show all posts
Saturday, May 26, 2018
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.
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:
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
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
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.
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.
Friday, April 27, 2018
Some Basics 4 MSX Basic ( part 3 )
My MSX Basic tips and tricks part 3. Yes, I know more than just a few tricks.
Problem: How to generate GFX on an MSX-1, without showing how it's generated?
Solution: Using DEFUSR=&H41 and DEFUSR=&H44 commands
Example:
100 SCREEN 0
110 PRINT "This screen will be switched OFF"
120 PRINT "and switched ON after printing texts"
130 FOR T=1 TO 1600:NEXT T
140 DEFUSR=&H41: A=USR(0)
150 FOR T=1 TO 160
160 PRINT "ON on ";
110 PRINT "This screen will be switched OFF"
120 PRINT "and switched ON after printing texts"
130 FOR T=1 TO 1600:NEXT T
140 DEFUSR=&H41: A=USR(0)
150 FOR T=1 TO 160
160 PRINT "ON on ";
170 NEXT T
180 DEFUSR=&H44:A=USR(0)
190 IF INKEY$="" THEN 190
200 CLS:END
180 DEFUSR=&H44:A=USR(0)
190 IF INKEY$="" THEN 190
200 CLS:END
The lines 150 t/m 170 are just to generate some text to show what had been hidden.
Line 180 switched the screen ON and you see the generated texts for the first time.
Then another trick in line 190, this is the easiest way to wait until the user pressed a key.
However, SHIFT, CTRL, GRAPH, CODE and other special keys will not work.
The DEFUSR trick works in any SCREEN, but in the SCREEN 4 and higher (on MSX-2
and higher) you can use the SET PAGE command to display a nice waiting screen while generating other GFX on other pages. On SCREEN 0,1,2,3 you don't have pages and this DEFUSR trick works very well.
Thursday, April 5, 2018
Some Basics 4 MSX Basic ( part 1)
And here is part 1 of my programming tips and trick, in the serie Some Basics 4 MSX Basic.
Problem: Checking firebuttons
Solution: Using IF THEN and GOTO, instead of ON STRIG GOSUB and STRIG ON
Example:
10 PRINT "Press FIRE"
20 IF STRIG(0) OR STRIG (1) THEN 40
30 GOTO 20
40 PRINT "FIRE !!!!"
50 END
20 IF STRIG(0) OR STRIG (1) THEN 40
30 GOTO 20
40 PRINT "FIRE !!!!"
50 END
This solution is easier than using ON STRIG, but if you use this routine more than once,
you must insert a short sleep routine, like:
50 FOR T=1 TO 200: NEXT
Just to make sure it also wait the 2nd time for the fire button, otherwise it will skip the 2nd test and go on.
I use this trick often in the last posted 112 MSX Basic games, cause I wanted to play those games without pressing any key on the keyboard.
The routine checks only the spacebar (0) and firebutton 1 of joystick 1 (1), which is mostly
enough for all single player games.
The routine checks only the spacebar (0) and firebutton 1 of joystick 1 (1), which is mostly
enough for all single player games.
Saturday, March 31, 2018
Some MSX-links: RuMSX emulator of Lex Lechz
I mentioned the RuMSX emulator of Lex Lechz. It's very outdated and it works as an emulator, still, lots of features are still missing and there are no signs it will be updated ever.
Why bother then?
RuMSX has just one feature that all other MSX emulators are missing, a complete interactive reference of all MSX Basic commands with examples and lots of information for experienced MSX-ers, like VDP registers etc.
When you click on Help and MSX help you see the page above with almost everything
you want to know about MSX (if you interested in programming of course)
Many times its information got me on the right track to solve my MSX-Basic problems.
Get it if you want to start programming in MSX-Basic, now !!!
Subscribe to:
Posts (Atom)


