MSX Basic Tokenizer. Should I?

Страница 2/4
1 | | 3 | 4

By Manuel

Ascended (15763)

Аватар пользователя Manuel

02-08-2019, 20:51

Stuff from msxcomputermagazine.nl for instance. Or check msxarchive.nl

By Louthrax

Prophet (2084)

Аватар пользователя Louthrax

02-08-2019, 21:40

Hi Farique,

Thank you and congratulations for that tool, I was really waiting for it. I'll now be able to have the BASIC sources of my projects in text files and generate the final tokenized version in my build process. Plus, it's written in Python, a tool I already have in my make chain Smile

By Grauw

Ascended (8457)

Аватар пользователя Grauw

02-08-2019, 21:42

Ohh, I hadn’t even considered that Louthrax, indeed that sounds like a useful cross-development application if I ever need some Basic code in a project!

By Louthrax

Prophet (2084)

Аватар пользователя Louthrax

02-08-2019, 21:56

Yes, that's a thing I'm very sensitive to (only having sources stored in SVN/Git, nice makefiles detecting all changes in the sources and reflecting them in the target ROM or DSK image). I had it for everything in my projects, except for BASIC files, that I still had to convert manually (implying having both source .ASC and target .BAS files at the same time on SVN - bad bad practice Smile). Until now !

By Manuel

Ascended (15763)

Аватар пользователя Manuel

02-08-2019, 22:16

Well, it should not be too hard to convert ASCII to tokenized basic using an openMSX script... Let the MSX do it itself...

By Louthrax

Prophet (2084)

Аватар пользователя Louthrax

02-08-2019, 22:25

Yeah, I remember that was already suggested. I was a bit lazy to investigate how to pass parameters (source and destination files) in the command line to openMSX/TCL, plus stuff to read / write files on HD and not disk image...

By the way, can openMSX be launched in a "headless" way (no windows) for purposes like that ?

By farique

Rookie (23)

Аватар пользователя farique

03-08-2019, 00:15

Thank you, @Manuel, never quite found a clean source of basic programs. The magazines, of course.

@Louthrax, @Manuel, I'm not in the mood of learning TCL right now Tongue but then there is this in Python.
Just put together based on the code for the Dignified build system. Worked here!
The bottleneck for me is the loading of the ASCII that can take quite a while. Would it be faster on an internal script?

EDIT: Just found a bug. It keeps the openMSX process open and non responding. How can I close it after it is finished loading and saving the file?

import subprocess
import os.path

openmsx_filepath = '/Users/Farique/desktop/pessoal/retro/openmsx/openmsx.app'
savestate_filepath = '/Users/Farique/.openmsx/savestates/Teste.oms'

import_file = 'getfiles.asc'
export_path = '/Users/Farique/desktop/badig test/'
export_file = os.path.splitext(import_file)[0][0:8] + '.bas'

export_path = export_path.replace(' ', r'\ ')
export_file = export_file.replace(' ', r'\ ')

cmd = (openmsx_filepath + '/contents/macos/openmsx -control stdio -savestate ' + savestate_filepath)
proc = subprocess.Popen([cmd], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)

# proc.stdin.write('set renderer SDL')
proc.stdin.write('diska eject')
proc.stdin.write('diska insert ' + export_path + '')
proc.stdin.write('set throttle off')
proc.stdin.write('type_via_keybuf load"' + import_file + '\\r')
proc.stdin.write('type_via_keybuf save"' + export_file + '",a\\r')

By Grauw

Ascended (8457)

Аватар пользователя Grauw

03-08-2019, 00:26

farique wrote:

EDIT: Just found a bug. It keeps the openMSX process open and non responding. How can I close it after it is finished loading and saving the file?

Write “quit”.

By farique

Rookie (23)

Аватар пользователя farique

03-08-2019, 00:39

Hahahahahahahahaha that was embarrassing. Done!
Had to put a timer to give openMSX some time to finish the task. Any way to detect that?
OBS: The code here is not displaying the LESS_THANcommandGREATER_THAN on the write function.

import time
.
.
.
time.sleep(10)
proc.stdin.write('quit')

By Manuel

Ascended (15763)

Аватар пользователя Manuel

03-08-2019, 08:55

Yeah, headless is possible, renderer "none".

You can tell openMSX to quit after it is done. Use a smart breakpoint or watchpoint to trigger that at the right time and use dir as disk on an empty temp folder to handle the I/O. So also for loading the ASCII file.

Страница 2/4
1 | | 3 | 4