Newbie ZX Spectrum question
Newbie ZX Spectrum question
Hi,
I'm new to FreeBasic and this forum, so first I'd like to greet everyone here and thank you all for your work.
Second I want to say that I am NOT a developper, I only like to learn. I just found FreeBasic and, maybe stupidly, started asking this.
Because of so much pandemic 'free' time, I reopened an old book, containing a ZXSpectrum BASIC listing, something I actually coded and used on a ZX 128K disk 'PC' about 30+ years ago.
So, my question here would be, can that code be somehow converted to FreeBasic? Can I write it and get it converted?
Just to start with the right foot, I found https://www.fbide.freebasic.net/, is this the more appropriate tool to edit/code? Are there others?
Much obliged by any answer, and apologies for the ignorance.
I'm new to FreeBasic and this forum, so first I'd like to greet everyone here and thank you all for your work.
Second I want to say that I am NOT a developper, I only like to learn. I just found FreeBasic and, maybe stupidly, started asking this.
Because of so much pandemic 'free' time, I reopened an old book, containing a ZXSpectrum BASIC listing, something I actually coded and used on a ZX 128K disk 'PC' about 30+ years ago.
So, my question here would be, can that code be somehow converted to FreeBasic? Can I write it and get it converted?
Just to start with the right foot, I found https://www.fbide.freebasic.net/, is this the more appropriate tool to edit/code? Are there others?
Much obliged by any answer, and apologies for the ignorance.
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Newbie ZX Spectrum question
There are probably ZX Spectrum emulators out there.
https://dotneteer.github.io/spectnetide/
Translating old code is a pain. Ideally you simply rewrite the program. All programs can be described at a higher level. Just translate up that old code to that higher level and then translate back down to the language you want to use.
https://dotneteer.github.io/spectnetide/
Translating old code is a pain. Ideally you simply rewrite the program. All programs can be described at a higher level. Just translate up that old code to that higher level and then translate back down to the language you want to use.
Re: Newbie ZX Spectrum question
See: FreeBASIC IDEs/Editors listed.pmra wrote:... is this the more appropriate tool to edit/code? Are there others?
Re: Newbie ZX Spectrum question
Hi pmra,
My second BASIC computer was a ZX Spectrum, too, but I don't have listings any more. As BasicCoder2 wrote above, rewriting is probably easier - but in order to judge what to do, we should have a look at your listings. Can you post something, please? I admit I am curious ;-)
My second BASIC computer was a ZX Spectrum, too, but I don't have listings any more. As BasicCoder2 wrote above, rewriting is probably easier - but in order to judge what to do, we should have a look at your listings. Can you post something, please? I admit I am curious ;-)
Re: Newbie ZX Spectrum question
Thanks for answering! I kind of was expecting this. I'll look for a good Freebasic course/tutorial.BasicCoder2 wrote:There are probably ZX Spectrum emulators out there.
https://dotneteer.github.io/spectnetide/
Translating old code is a pain. Ideally you simply rewrite the program. All programs can be described at a higher level. Just translate up that old code to that higher level and then translate back down to the language you want to use.
Re: Newbie ZX Spectrum question
Thanks for answering! Will do.MrSwiss wrote:See: FreeBASIC IDEs/Editors listed.pmra wrote:... is this the more appropriate tool to edit/code? Are there others?
Re: Newbie ZX Spectrum question
Thanks for your interest! Here goes, its about 25 A5 pages of this:jj2007 wrote:Hi pmra,
My second BASIC computer was a ZX Spectrum, too, but I don't have listings any more. As BasicCoder2 wrote above, rewriting is probably easier - but in order to judge what to do, we should have a look at your listings. Can you post something, please? I admit I am curious ;-)
https://imgur.com/a/NwQjx5m
Since I don't have it on digital form, rewriting is definitely the way.
Re: Newbie ZX Spectrum question
Agreed! It will be a bit of typing, but it's worth the effort. Note that FreeBasic does not have line numbers - you will use proper names instead. For example:
That looks different at first sight, but it's much easier to use, and less confusing than "GOTO 123" ;-)
Code: Select all
If qs="1" then
Action1
elseif qs="2"
Action2
elseif qs="3"
Action3
endif
....
Sub Action1
... more code, whatever must be done if q$="1" ...
End Sub
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Newbie ZX Spectrum question
@pmra
Ouch! How unreadable old code was! I would scan the code and perhaps use an OCR to translate it into text. If I was really keen on translating the old code I think I would work on a program to help with the task.Here goes, its about 25 A5 pages of this:
https://imgur.com/a/NwQjx5m
Since I don't have it on digital form, rewriting is definitely the way.
Re: Newbie ZX Spectrum question
Freebasic can use line numbers if option #lang "qb" or lang "fblite" is used.
Example:
merge or list or eval or plot (and many others I reckon) are not freebasic keywords.
You only need the salient line numbers for the goto's, gosubs, but writing in the others does no harm.
Example:
Code: Select all
'rem prime factors
#lang "qb"
1 lowers%=30000
2 uppers%=30500
10 For counts% = lowers% To uppers%
20 number% = counts%
30
40 Print number%;"= ";
50 divisor% = 2
60 While divisor% <= number%
70 Gosub 490
80 divisor% = divisor% + 1
90 Wend
100 Print
101 Next counts%
102 Print
rem subroutine
490
500 If number%/divisor%-Int(number%/divisor%) = 0 Then
510 c$="x"
520 number% = number% / divisor%
530 If number% = 1 Then c$=""
540 Print divisor%;c$;
550 Goto 490
560 End If
570 If counts%<=uppers% Then Return
580 Sleep
You only need the salient line numbers for the goto's, gosubs, but writing in the others does no harm.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Newbie ZX Spectrum question
Go to the following link. Not many people mention this, but it is well-structured and well written.pmra wrote:I'll look for a good Freebasic course/tutorial.
FreeBASIC Tutorials
The right-hand pane may be blank, click on FreeBasic at the top of the left-hand pane.
There are quite a few example programs - try them.
BTW, the correct spelling is FreeBASIC.
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Newbie ZX Spectrum question
I printed a page of FreeBASIC source code and then scanned it into an image.
I then used an online ocr to convert it back to text. It seemed to work fine.
A nice clean scanned image would be required as when I tried
https://imgur.com/a/NwQjx5m
it didn't convert much of it only a few characters.
I then used an online ocr to convert it back to text. It seemed to work fine.
A nice clean scanned image would be required as when I tried
https://imgur.com/a/NwQjx5m
it didn't convert much of it only a few characters.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Newbie ZX Spectrum question
It has been hinted at but the way to go is
will drive you mad.
needs more than a passing acquaintance of 'New code'. Understand the fundamentals of 'New code' and then consider 'Pseudo code -> New code'.
Code: Select all
Old code -> Pseudo code -> New code
Code: Select all
Old code -> New code
Code: Select all
Pseudo code -> New code
Re: Newbie ZX Spectrum question
Hi pmra,
deltarho[1859] is right: start with pseudocode describing the conditions (if qs="1" Then ...) and actions required. Then look into the help file to see which commands you need for the "actions". Members here will help you with that. You will soon see that FreeBasic is much clearer and easier than Spectrum BASIC ;-)
deltarho[1859] is right: start with pseudocode describing the conditions (if qs="1" Then ...) and actions required. Then look into the help file to see which commands you need for the "actions". Members here will help you with that. You will soon see that FreeBasic is much clearer and easier than Spectrum BASIC ;-)
Code: Select all
If qs="1" then
Action1 ' ex GOTO 3460
elseif qs="2"
Action2 ' ex GOTO q11
elseif qs="3"
Action3 ' ex GOTO 2020
endif
....
Sub Action1
... more code, whatever must be done if q$="1" ...
End Sub
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Newbie ZX Spectrum question
Come to think of it prma may not know what pseudocode is. Back in the ZX Spectrum days we talked about top-down programming and flow charts.
Pseudocode
Pseudocode