ZX BASIC: Test for 48/128k system
Re: ZX BASIC: Test for 48/128k system
Oh dear, they changed syntax from 128/+2 to +3/+2x?
I only know the first 128 (Toastrack) and assumed using the silicon disk is the same syntax with all 128K ZX Spectrums...
I only know the first 128 (Toastrack) and assumed using the silicon disk is the same syntax with all 128K ZX Spectrums...
48K/+/+/+/+128K/Vega/Next&80/81&88
Re: ZX BASIC: Test for 48/128k system
No, unfortunately not. I do prefer the +3DOS syntax, as it makes it much easier to allow a user to choose where to save, but the lack of support for the "old" 128K syntax makes it difficult to write a BASIC program which uses the extra memory and runs on all machines.
Re: ZX BASIC: Test for 48/128k system
Oh, yes, seems so! Up to now I can determine whether there is a silicon disk or not with:
Code: Select all
1000 LET sys48=1: REM 48K as default, no silicon disk
1010 IF PEEK 2899=159 AND PEEK 23611=221 THEN LET sys48=0
48K/+/+/+/+128K/Vega/Next&80/81&88
Re: ZX BASIC: Test for 48/128k system
I'm now doing it like this from my BASIC loader:
Code: Select all
...
10 POKE 49152,123: POKE 23388,17: OUT 32765,17: IF PEEK 49152<>123 THEN GOTO 20
{NOT a 128k machine - do somethings and NEW / STOP or sth.}
20 {a 128k machine}
Re: ZX BASIC: Test for 48/128k system
If anyone ever wonders why I had to make two different tape files for Corona Capers (not that anyone did...), refer to this post.AndyC wrote: ↑Tue Jul 30, 2019 7:49 pm No, unfortunately not. I do prefer the +3DOS syntax, as it makes it much easier to allow a user to choose where to save, but the lack of support for the "old" 128K syntax makes it difficult to write a BASIC program which uses the extra memory and runs on all machines.
The only changes are because I needed to save and reload the loading screen from the RAM disc because I knew a CLEAR command was going to wipe it out. So, one version uses SAVE! and LOAD! and the other uses SAVE "m:" and LOAD "m:" (SCREEN$ both times, obviously). Other than that, they're identical...
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
Re: ZX BASIC: Test for 48/128k system
On the +2A/+3/Next you can unmount/resize the RAMdisk with the DOS_SET_1346 call and even return to BASIC, so don't assume the RAMdisk is always available or has sufficient space.
On the Next the PEEK 23611 (sysvar) passes in all modes, but the PEEK 2899 (ROM) gives a different number in NextBASIC. You can't rightly expect an extended BASIC to have exactly the same bytes in every single ROM address, otherwise you wouldn't have any BASIC extensions. However NextBASIC is backwards compatible with 128K BASIC syntax and the hardware in NextBASIC mode is functionally a +3, so that ROM peek test needs expanding a little depending on what you are actually trying to test for.
ROM magic numbers are always best avoided unless you have no other mechanism to test. It's always best to test for the feature you plan to use, rather than an arbitrary attribute of a machine you expect to contain the feature. For features it's far better to test officially documented sysvars and API calls.
On the Next the PEEK 23611 (sysvar) passes in all modes, but the PEEK 2899 (ROM) gives a different number in NextBASIC. You can't rightly expect an extended BASIC to have exactly the same bytes in every single ROM address, otherwise you wouldn't have any BASIC extensions. However NextBASIC is backwards compatible with 128K BASIC syntax and the hardware in NextBASIC mode is functionally a +3, so that ROM peek test needs expanding a little depending on what you are actually trying to test for.
ROM magic numbers are always best avoided unless you have no other mechanism to test. It's always best to test for the feature you plan to use, rather than an arbitrary attribute of a machine you expect to contain the feature. For features it's far better to test officially documented sysvars and API calls.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
Re: ZX BASIC: Test for 48/128k system
As I need to use the memory banks, how do you find my approach?
-
- Manic Miner
- Posts: 401
- Joined: Fri Jan 03, 2020 10:00 am
Re: ZX BASIC: Test for 48/128k system
Mr Gluk Reset Service, ERS (and several TR-DOS boots and commanders AFAIR) run programs in USR0 mode. So, the only correct way to test for 128K is to switch banks, write numbers in them and compare.
Re: ZX BASIC: Test for 48/128k system
I concur.Alone Coder wrote: ↑Mon Jul 13, 2020 5:43 am the only correct way to test for 128K is to switch banks, write numbers in them and compare.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
Re: ZX BASIC: Test for 48/128k system
MODULA-2
Code: Select all
MODULE ZX;
FROM InOut IMPORT WriteString,WriteLn,WriteInt;
VAR [2899] ZX : SHORTCARD;
BEGIN
WriteInt(ZX,3);
WriteLn;
WriteString("ZX Spectrum ");
IF ZX = 165 THEN
WriteString("48k");
WriteLn;
END;
IF ZX = 159 THEN
WriteString("128k");
WriteLn;
END;
IF ZX = 126 THEN
WriteString("+3");
WriteLn;
END;
END ZX.