Memory questions
Question 1:
PRINT PEEK 23732+256*PEEK 23733 returns 65535 for a 48K Spectrum and 32767 for a 16K Spectrum.
PRINT PEEK 16388+256*PEEK 16389 returns 32768 on a 16K ZX81 and 17408 on a 1K ZX81.
But was there ever an equivalent for the ZX80, to test if it was unexpanded, or had a 3K (or more) RAM pack attached?
The offline copy of the ZX80 manual I've got stashed on my hard drive gives a completely different system variable at 16388-16389, and there are far fewer of them than there are on the ZX81 (to my complete non-surprise).
Question 2:
Was there ever anyone so mad as to try to write a program in BASIC so huge that it required the use of the 128K RAM disc and being split into pieces to make it work? (i.e. with a central loader or option menu that will LOAD! "part 1", LOAD! "part 2" etc. or LOAD "m:part 1" etc. on the +2A...)
And no, extra loading screens don't count, and neither does that bouncing ball program in the 128K+/+2 manual.
PRINT PEEK 23732+256*PEEK 23733 returns 65535 for a 48K Spectrum and 32767 for a 16K Spectrum.
PRINT PEEK 16388+256*PEEK 16389 returns 32768 on a 16K ZX81 and 17408 on a 1K ZX81.
But was there ever an equivalent for the ZX80, to test if it was unexpanded, or had a 3K (or more) RAM pack attached?
The offline copy of the ZX80 manual I've got stashed on my hard drive gives a completely different system variable at 16388-16389, and there are far fewer of them than there are on the ZX81 (to my complete non-surprise).
Question 2:
Was there ever anyone so mad as to try to write a program in BASIC so huge that it required the use of the 128K RAM disc and being split into pieces to make it work? (i.e. with a central loader or option menu that will LOAD! "part 1", LOAD! "part 2" etc. or LOAD "m:part 1" etc. on the +2A...)
And no, extra loading screens don't count, and neither does that bouncing ball program in the 128K+/+2 manual.
Comments
Keep on mind that you can "merge" BASIC programs, but you can not "unmerge" them. So having some kind of overlays on BASIC is forbidden. At most, you can make a BASIC program that uses some kind of binary data that can be stored on RAM disc (or try to load arrays with data from RAM disc).
An' you know what they said?
Well, some of it was true!
LOAD "menu" (from tape)
SAVE ! "menu" (to RAM disc)
LOAD "part1"
SAVE ! "part1"
LOAD "part2"
SAVE ! "part2" (etc etc etc etc etc for all the parts).
Each part of the program then calls what's stored in the RAM disc, so "menu" has options to LOAD ! "part1", LOAD ! "part2", LOAD ! "part3" and so on, and each part has a "return to menu" option with LOAD ! "menu". Putting all the parts together would exceed 48K so this would be the long, laborious but working way to do it.
If such a program never existed, but anyone wants to see it as a challenge to do so, I nominate the programmer for whatever WOS's equivalent of a Cacoward is. This will be the 128K Spectrum's answer to NUTS.WAD...
Something like the Trader Trilogy ( http://www.worldofspectrum.org/infoseekid.cgi?id=0005363 ) might be a good place to get some practise... maybe add some 128K sounds as well....
There was no equivalent RAMTOP BASIC system variable on the ZX80. However, since the BASIC ROM sets the stack pointer to the top of available memory at startup, the most common way to determine (approximate) RAM size is to check the value of SP at the start of the program, eg:
Although you can overwrite existing BASIC lines from a merged program. So you could, for example have a common BASIC menu program using lines 10 to 1000; then load in lots of different sub-programs in the 1001 to 9999 lines; each time overwriting the previous sub-program.
Sounds like a perfect candidate for the CSSCGC, looking forward to receiving your entry :)
Everyone has a crap game inside them, let yours out!
So if the loaded program has been SAVEd to auto-run...
Mark
Repair Guides. Spanish Hardware site.
WoS - can't download? Info here...
former Meulie Spectrum Archive but no longer available :-(
Spectranet: the TNFS directory thread
! Standby alert !
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb!
Looking forward to summer in Somerset later in the year :)
Yes just make sure every overlay has the same set of line numbers, even if they are do-nothing REMs to delete all common lines.
TS2068 basic has the DELETE keyword that allows a range of lines to be deleted which would fit this problem well. This means it's possible to write a short routine on the spectrum (perhaps copied from the TS2068 rom) to do the same. In fact, I'm sure at least one of the many basic toolkits would offer such a routine.
Write games in C using Z88DK and SP1
Now a further question:
I know (and have known since I was a nipper when I saw it in said Sinclair Programs listings) that ZX81 machine code is stored in a REM statement at line 1 with start address 16514 - looking at the hex loader program I assume it's the same for the ZX80. If the statement looked something like this:
1 REM H*$7X{**}{A}4?{OR }{R}{CLEAR }GB/ (etc...)...then could I just type in that REM statement with a bit of trickery with the K cursor (i.e. I need to type in CLEAR first then cursor-left for the REM, and so on if there are more keywords), or do I have to go through the hex loader?Anything in non-ZX80-approved brackets above is a token or a block character from SHIFT + Q-T or A-G (i.e. the ones from ZX81 graphics mode).
I have considered entering this year, if I can get some good ideas to match the 128K PLAY music I've had written for a while. Because the game has to be crap for the competition, any gameplay will of course be of secondary importance to said music.
I last entered in 2004 with the late, great Jim Langmead running the show. He was suitably unimpressed by my attempts to showcase some music, 2x2 UDGs and a font I'd ripped from Mario games and package them as Super Mario Fruit Machine. Mission accomplished. Expect more of the same!
Or I might try a text adventure, if I'm really determined to land myself in a massive mess.
That code snippet I posted is only of use in as part of a larger assembly program, without the appropriate labels to jump to - it won't work. If you just want to check the amount of memory from BASIC all you need is: Then check the return value using IF statements.
You can store Machine Code in REM statements on the ZX80, but it isn't as easy as on the ZX81; since there are huge chunks of the character set you can't type from the keyboard. To create the five byte routine above you'd need to enter this:
10 REM -{space}{space}T0 POKE 16431,201and call it with Remembering that BASIC variables are signed 16-bit integers, so addresses more than 32767 will be displayed as negative numbers.Everyone has a crap game inside them, let yours out!
I'll try the routine (with NO$ZX81 set to ZX80 Reactor Control System mode) and see what happens. I'm not sure I can test the 3K version, though - I'll see if Paul Farrow's ZX80-on-Spectrum emulator gives the same figures (it should do!), I know that's got a 3K option. How many RAM packs for the ZX80 were there, anyway?
It's at times like this I should dig out the "Machine Code for the Complete Beginner" book I found while digging through the old relics I bought off a friend a while back. There's Hewson's "Complete Machine Code Tutor" as well - I should go through that. This comment has been brought to you by typing in the INPUT assembler, noticing a dreadful typo (a GOTO statement with no number), tearing out what little hair I have, realising it presents no problems*, gluing all my hair back on, and finding it works. But every machine code line has to be stored as REM statements and it's as clunky to use as INPUT's word processor (that stores every line of the document in a DATA statement).
Anyway, I'm going to have a butcher's in the WOS archive for a proper assembler/disassembler (if there's a good one, feel free to recommend it).
* The program stops with 2 Variable not found (I've filled in the missing number with xxxx), but as it's the end of the assembly, I think it was supposed to jump to a dummy line 9999 and may as well just say STOP. 2 Variable not found, 0 OK, 9 STOP statement, what's the difference?
Everyone has a crap game inside them, let yours out!
I had a look anyway, found a lot of MIA files, and a couple of programs that are designed for people who are already fluent in machine code and spit out error messages that I don't understand. And one from McGraw-Hill (who wrote a few of my university textbooks) that quite helpfully fails to run at all with Q Parameter error...
Essentially what I was looking for was something where I could type in a machine code listing just the way I would do with a BASIC program, have an indication of the number of bytes (so when it's finished I could cram it at the highest address possible and have the last byte at 65535), SAVE "filename" CODE, and load it back in later. Equally with a disassembler all I ask is to LOAD "" CODE, and the program spits out a listing of ld, jr, push and pop statements. Is that so much to ask of the Spectrum software available?
Anyway, I'll have a look at Pasmo - if it's not too complex!
But first, I'll give the ZX80 memory routines a go.
You can run an assembler on the Spectrum if you want to, but you're severely limiting what you can do both in terms of code size and debugging. The assembler, source code, debugger and disassembler all occupy memory, which limits both the features available and the size and location of your assembled code. Even under emulation, having to reload your assembler, then your source code, then reassemble every time the program crashes gets very old, very fast.
There's nothing wrong with the McGraw-Hill ZX Spectrum Assembler; the "Q Parameter error" you're getting, means you've made a syntax error in your source code.
If you're just starting out learning machine code, I'd suggest you start with a Spectrum emulator with a built in Z80 Assembler, such as ZXSpin, which can assemble directly to the emulated Spectrum's memory. It also has an excellent debugger and disassembler built in.
You've probably already realised this - but if you're determined to have all your machine code at the top of memory - you'll overwrite the stack, so you'd need to relocate it elsewhere.
Everyone has a crap game inside them, let yours out!
Small RAM expansions can also do this. But the 2k byte expansion instead adds it's 2k bytes to the internal 1k byte, making a total of 3k bytes.
I don't have the details of the other RAM expansions, so can't help with those.
Mark
Repair Guides. Spanish Hardware site.
WoS - can't download? Info here...
former Meulie Spectrum Archive but no longer available :-(
Spectranet: the TNFS directory thread
! Standby alert !
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb!
Looking forward to summer in Somerset later in the year :)
I was just testing it... download, load, run, "use this RANDOMIZE USR statement", the programs NEWs, I use the statement, Q Parameter error. I had no source code, I thought that's how it would run so I could write some!
Which I am. Can you tell?
When I went looking for an example program to test the INPUT assembler, I found the "machine code in 30 minutes" program on Bytes: Chuntey which looked promising - the article mentioned Spin's assembler, but I thought under the circumstances it was cheating! Still, I'll give this a shot now.
Srangely, I always found Spin took ages to load - no idea why (and it seems to be OK now - maybe it didn't like Windows XP!). It's the emulator I used to use for recording RZXs on in t'old days (any of mine from 2004 such as Rick Dangerous I/II will have been made in Spin) but I'd never known of this feature before (as I had no cause to notice it in the menus).
Which I hadn't...
Not that I was particularly determined, but I thought "if this code is only a kilobyte long at best, why load it at 33000 instead of 64000 or so?"
Would they have been third-party-only RAM packs, like Memotech's 32K/64K RAM for the ZX81?
I just spent half an hour wondering why I had no control over the blue square. And then it hit me, like a blue square slamming into a black square... seeing as the tutorial explains that the same principle is used as where I've seen ten addresses of the IN function floating at 191 when no key is pressed, have I got Spin set to an Issue 2 keyboard?
Sure enough, I have.
Switch it to Issue 3 and it's working. I could probably work out the way to make this program work with an Issue 2 keyboard (it's actually quite obvious from the text), but I'd need a manual for an Issue 2 Spectrum to find out the IN addresses to read, and of the three manuals I have, one is for the +2, one is for the +2A, and one is for the +3. No Issue 2 keyboards there!
The port addresses to read the keyboard don't change with Issue numbers, only the contents of bits 5 to 7 in the return value. Usually a quick AND 31 is all you need to allow for all issues of keyboard.
If you need them, the Spectrum manuals are available here: worldofspectrum.org/faq/resources/documents.htm
Don't be caught out by the misprint in some editions of the +3 Manual regarding keyboard addresses.
Or you could always RTFFAQ :-)
Everyone has a crap game inside them, let yours out!
Mark
Repair Guides. Spanish Hardware site.
WoS - can't download? Info here...
former Meulie Spectrum Archive but no longer available :-(
Spectranet: the TNFS directory thread
! Standby alert !
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb!
Looking forward to summer in Somerset later in the year :)