Creating SNA files for CSpect

Do you live and breathe hexadecimal? Do you like speaking to hardware directly?

Moderator: Programming Moderators

User avatar
varmfskii
Posts: 186
Joined: Fri Jun 23, 2017 1:13 pm
Location: Albuquerque, NM USA

Re: Creating SNA files for CSpect

Post by varmfskii » Sat Apr 07, 2018 11:06 pm

It is not just that I am an opinionated so and so (I am, but that isn't the point). Memory snapshots are one of the most primitive and basic of file formats for storing software. In the case where one is storing a binary, like a copy protected game, where one doesn't have any real information about what is important and what isn't it is useful, and it does work, but beyond that there is little to recommend such formats. Other platforms have files which support multiple data extents. If you are going to create a new format, a collection of start, size, data along with a partial or full memory configuration and a starting address would make a whole lot more sense.
Backer #2741 - TS2068, Byte, ZX Evolution

User avatar
SevenFFF
Posts: 221
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: Creating SNA files for CSpect

Post by SevenFFF » Sun Apr 08, 2018 2:06 pm

I recognise your point. It's not just memory configuration, you will want to store the contents of all the registers, sprite BRAM, copper and DMA programs, and countless other things. However you do it, it will end up being a snapshot by another name, and a very complicated one.

Any polished program should probably be setting everything in code rather than relying on an inherited environment. Defensive programming, possibility of different NMI browsers loading snapshots differently, etc.

The way I'm doing it is that there will be a loader .z80 file, then a subdirectory called [GAMENAME].DAT with all the extra resources. Snapshots are also somewhat better than .tap files, as they don't trigger the Standard/128/USR0 loader menu (which is only really applicable for legacy programs). The code references the subdirectory relative to the loader file, so users can put the game anywhere they like, not just in the root. But the extra resources are kept out of the way to make it obvious which is the loader file.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel Spectron 2084blog

User avatar
varmfskii
Posts: 186
Joined: Fri Jun 23, 2017 1:13 pm
Location: Albuquerque, NM USA

Re: Creating SNA files for CSpect

Post by varmfskii » Sun Apr 08, 2018 3:19 pm

If you think I am talking about anything that more than vaguely resembles a snapshot, you are completely misunderstanding what I am talking about. You don't need to store all that other crap. You load enough of a file into memory (memory configuration, that is which 8-8k pages are in memory, is only necessary because you may want to load more than 64k from a single bit on a machine that only directly addresses 64k) then you branch to a portion of code that sets up the rest. Storing the contents of the registers etc. is complete BS.
Backer #2741 - TS2068, Byte, ZX Evolution

Alcoholics Anonymous
Posts: 508
Joined: Mon May 29, 2017 7:00 pm

Re: Creating SNA files for CSpect

Post by Alcoholics Anonymous » Sun Apr 08, 2018 6:43 pm

I agree sna is not really a good format to use, except it's a quick way to dev something.

There are a few problems with it. One is you can't cooperate with NextOS because the sna defines the basic system's environment (it overwrites the system variables and, importantly, misses NextOS state in bank 8). Most tools cannot generate Next snapshots either - instead they generate snapshots for the 48k or 128k machines so there's no way to use the NextOS API or return to basic.

Another problem is it puts the main code into contended banks. On the Next banks 0-7 follow the +3 contention pattern so banks 4-7 are slow memory. Banks 8+ are not contended and are fast.

Thirdly, it doesn't let you place code in the bottom 16k. Instead your program has to load extra code into the relevant pages and bank it into the bottom 16k before running. Similarly you have to load all the banks manually if your program exceeds the sna's range to bank 7. So it's a manual format rather than an automatic one and it should be really easy just to have it all automatically load instead of just the first 7 banks. One of the main reasons the sna is being used is that it allows you to load 128k all at once and for most people the program size is less than 128k. Having a format that can load all banks would be convenient for the same reason as program sizes increase. This may be stunted a little bit as most tools people are using are not suited to large memory spaces so they tend to keep the program in 128k or even in the main 64k and restrict the rest of memory to data to avoid hassles.

For z88dk the sna will be deprecated once we get around to doing something else. It's actually fairly easy to automatically make a tap loader that will load all the banks, set the initial banking configuration and run, but there are more sophisticated things you can do during loading which should be pursued too.

User avatar
chernandezba
Posts: 228
Joined: Mon May 29, 2017 8:14 pm

Re: Creating SNA files for CSpect

Post by chernandezba » Sun Apr 08, 2018 8:03 pm

mdf200 wrote:
Sat Apr 07, 2018 7:23 pm
chernandezba wrote:
Thu Mar 22, 2018 9:25 pm
Slowing down? Nextos in ZEsarUX boots in 10 seconds. Anyway, as you may know, cspect is not a full Next emulator (and ZEsarUX is a full emulator). About sna, you shouldn’t use that format. It’s an old and ugly format, you’d better use tap
Unless you're doing BASIC, you don't need a full emulator - i think we've proven this! :) CSpect does most of the other hardware, and starts up in under a second - not to mention has a good debugger built in. So as an ASM "dev" tool, it's much quicker to dev with.

And I really don't know why some folk don't like SNA files. They are much faster to load, easier to write, and all of your program code - and loading screen, are all loaded in one go. Then it jumps to the start of your program. I mean....seriously, what else do you need?

But hey.... use whatever you want and are comfortable with.
ZEsarUX now has a tbblue fast boot mode that you can enable and it justs boot like cspect. See info on YouTube or fb
About sna, I won’t change my mind. They are horrible. They even use the stack to store the registers. It’s the worst snapshot format I’ve ever seen
And you should really try debugging with ZEsarUX ZRCP

Cheers
----

ZEsarUX
ZX Second-Emulator And Released for UniX
https://github.com/chernandezba/zesarux

User avatar
mdf200
Posts: 112
Joined: Fri Jun 02, 2017 9:52 am
Location: Dundee
Contact:

Re: Creating SNA files for CSpect

Post by mdf200 » Wed Apr 11, 2018 6:12 am

The only thing stored is the return address - which is what stacks do. And since you will need a stack, it's going to be there anyway, and you can fill it with 0's if you really want. Game code will initialise everything anyway, so there is zero harm in it.
Loading from tape doesn't initialise anything, so you end up with exactly the same thing. SNA gets data into memory, as simple as that. It's fast, and it jumps to a location. As a game dev, that's all I need.

I'll agree it's not a great snapshot format - it works, but meh - especially the 128 one. But for a "new" game... its actually not bad at all.

And I did use the debugger in ZEsarUX.... which is why I did my own :P Sorry, but it's nasty. While it is indeed a debugger, and does debug -
it needs some serious work to be actually user friendly and usable for serious dev.

User avatar
chernandezba
Posts: 228
Joined: Mon May 29, 2017 8:14 pm

Re: Creating SNA files for CSpect

Post by chernandezba » Wed Apr 11, 2018 3:06 pm

mdf200 wrote:
Wed Apr 11, 2018 6:12 am


And I did use the debugger in ZEsarUX.... which is why I did my own :P Sorry, but it's nasty. While it is indeed a debugger, and does debug -
it needs some serious work to be actually user friendly and usable for serious dev.
You haven't tried ZRCP, have you?
----

ZEsarUX
ZX Second-Emulator And Released for UniX
https://github.com/chernandezba/zesarux


Post Reply