Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
zxbasic for dos?
#1
Would it be easier to create a script to translate zxbasic to C, or to write a compiler target for x86 asm?
Reply
#2
I'm currently working on all of this.
"Theoretically" ZX BASIC is ready for that. But in practice it needs a lot of refactoring.
Please, be patient.
It's not about "translate to C", but to any target, and make it really extensible.

There are other concerns when porting to other architectures. Eg. I/O, graphics, etc.
You probably will drop most of screen comands. ATTR will be nonsense. POINT could be changed, etc. etc.
Reply
#3
When the refactored version is ready the gamesprogrammer can do IFDEF for different platforms?
So graphic commands can be changed per platform.
Reply
#4
slenkar Wrote:When the refactored version is ready the gamesprogrammer can do IFDEF for different platforms?
So graphic commands can be changed per platform.
Yes.
At the moment the compiler is *broken* :oops: I'm just trying to refact, while recover the previous state. :roll: (that is, ZXBASIC 2.x, apparently doing exactly what it already does by now).
Reply
#5
This may come as an odd thing to suggest, but there already is an excellent Basic compiler for DOS, namely FreeBasic. It has a disadvantage, however, namely that it requires HDPMI, which is tricky to come by nowadays, and so do the executables it generates. If ZXBasic for DOS was completely stand-alone, that would make it more appealing to e.g. people who use DOSbox, even though it would limit the amount of available memory. Or precisely because of that?
Reply
#6
ZX Basic tries to follow FreeBASIC syntax, but at the same time tries to keep some backward compatibility with Sinclair BASIC.
You are right with DOSBox, hdpmi and the like. One solution could be to make ZXBASIC a translator (not exactly a compiler), and use DJGPP © as a backend, so it translates from BASIC to C which will be later compiled with djgpp Smile
But until vacation, I'm afraid I could not make much improvements...
Reply
#7
I wonder about a setup where it introduces a screen simulation, so you can stay in spectrum mode, but send a windows exe.

Or change up to a more native resolution on command. Hmm.
Reply
#8
That makes a lot of sense, britlion. A 320x200 VGA screen is just enough to fit a Spectrum's 256x192 pixels plus a bit of a border. That could allow Spectrum games to be rebuilt for DOS without any changes -- potentially a killer feature for ZXBasic, as people have worked hard to make such ports (I seem to remember that the Warajevo emulator could package a copy of itself along with a game snapshot in a single .exe). And then you could provide extensions for e.g. changing the color palette, accessing the filesystem...
Reply
#9
Ha! Nice ideas!
I wish you were here having beers with me at the TLP event! :mrgreen:
It's been very inspirational.
Back to the topic: I've already though about these. In fact, C is much portable because all IO functions are done through user defined functions (e.g. no PRINT, but printf()) and the like.
So the programmer can always define a library to implement input / output (screen, keyboard, etc).
The idea on screen modes is also very interesting! Smile
Reply
#10
boriel Wrote:ZX Basic tries to follow FreeBASIC syntax, but at the same time tries to keep some backward compatibility with Sinclair BASIC.
You are right with DOSBox, hdpmi and the like. One solution could be to make ZXBASIC a translator (not exactly a compiler), and use DJGPP © as a backend, so it translates from BASIC to C which will be later compiled with djgpp Smile
But until vacation, I'm afraid I could not make much improvements...
FreeBasic is very good (i loved coding <!-- m --><a class="postlink" href="http://www.dosgames.com/forum/about18131.html">http://www.dosgames.com/forum/about18131.html</a><!-- m --> there, for example), but it's not that excellent yet: i think that is quite painful to compile some stuff there that would run decently on CGA display boards on IBM-PCXT machines (CGA modes seems to be simulated from VGA modes... :S ), unless some wise 8088/8086-assembly trick is used (that i didn't find yet...) - maybe Boriel's ZX-Basic Compiler can set goals where FreeBasic fails! Wink
Reply
#11
As posted in the announcement, It's time to add the compiler features we all were expecting.
ZX Basic 1.4 is out, and now it can be converted to a more generic compiler.
I't also opened the Issue Tracker to add proposals (wish list) and bugs. At the moment is open to the public (an experiment).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)