I'm Doug, BTW. I like my username, but it can be goofy in conversation sometimes. Hi Garth.
Well, I wrote it wrong: RWTS = Read Write Track Sector. It's the core bit of code needed to interact with the Apple ][ disk drive. The drive is a software driven device, with only a little bit of hardware assisting the 6502 in the task of using the disk storage. Most, if not all other disks I've encountered employ a controller of some sort to accomplish what the Apple ][ does in software.
An Apple has just enough in ROM to read a very small portion of a given floppy disk, and that portion then fetches the whole of the RWTS and the start up code for the DOS.
My understanding of this is still a work in progress, but as I understand it a given disk format scheme is associated with a specific RWTS code. Standard code, like for say DOS 3.3, does 16 sectors per track. The PoP code uses a custom RWTS that does 18 sectors per track, and in addition includes copy protection hackery that makes it difficult to make a copy of. This also made the B0rderbrund disks more efficient, allowing for better game assets, etc... as a nice positive for the user.
The product of that is an environment where a program can literally be built onto a bootable disk readable only by that program! Interesting stuff.
Miles actually communicated that very well, and his posts are a big help in understanding what happened to build that program. Without those comments, I would very likely be in the dark on it, moving on. But I think I get it.
Now, there isn't an association between execute addresses and disk tracks and sectors. PoP was written to utilize the disk as tracks and sectors though. No filenames, etc... Just the interface provided by the custom RWTS software, a missing piece today. What will need to happen is a build of the program that employs 16 sector RWTS, which will break some things. Actually most things, particularly those written to just read in an entire track very quickly in one go.
Before any real work begins, Miles did correctly assert that a working model needs to be created so that one can "assemble" to disk. He suggested one big file, though I believe that's a suggestion and perhaps not the best one. I don't know. What I do know at this stage is that I need to be able to assemble code "to the disk" and that's where the crux of the discussion is!
Spent the weekend looking at a ton of assemblers! That actually was a lot of fun, and there is an amazing number of 6502 related tools, none of which seem to complete the very lucid picture Miles created. And I'm kind of stuck on this because every other piece of information he provided has proven to be spot on!
From what I can tell, it's needing to work like this:
A disk is a linear sequence of bytes, starting with $0 and ending 140Kbytes later at $22FFF. Side two of that disk begins at $23000 and ends at $45FFF. A PoP disk is bigger than that due to the 18 sectors. Whether or not that takes three disks, or some space can be reclaimed remains to be seen. There are a couple of places in the PoP code that appear to blow a whole track for speed. Perhaps something can be done, or maybe it's gonna be a three disk affair. I don't know. Will be fun to get there though!
So that's the disk.
PoP was originally built in Merlin and each portion of it was assembled somewhere in the Apple //e RAM, and it was assembled there because that's where assembly could happen on the setup JM had. Nothing special there. Code either gets assembled where it's intended to execute, or it's assembled where it needs to be, intended to execute somewhere else. From what I can tell so far, this is a perfectly ordinary thing to do, given that "somewhere else" is actually within the 64K address space.
What I really need is for that "somewhere else" to simply be anywhere, not just within the 64K address space, and then I can carry forward given the methodology shared here. And that's compelling, because it makes a hell of a lot of good sense.
The product of that will be an assembly source code file that will "assemble to disk", directly building the disk image, and as far as I can tell, the only real difference between doing this and just doing it in the 64K address space is allowing for a target address larger than 64K. In every other way, it's ordinary enough that I find myself somewhat stunned that it's simply not out there possible to do.
An alternative that struck me today is to play a lot of games with segments and such so that there are a bunch of little 64K friendly bits of code built, kept track of, then piled together to form the disk image indirectly. This appears to involve defining a lot of little memory regions, then defining how they behave, then writing some scripts or describing how that all would combine to make a floppy disk for the linker part of the process.
For systems employing bank selection of large RAM, or ROM cartridge type storage devices, this makes a lot of sense! I get that, and since this kind of thing isn't done every day, I think I get why my queries here seem strange or maybe just really difficult to talk about.
If it's possible to do this with your products --or possible to make it possible, I'll give the project a go, and I'll write up what happens along the way too.
Again, to be really clear the necessary functionality is as follows:
1. Assemble code with an ORG that equals the intended execute address and an OBJ that can exceed 64K, and do that for 6502 / 65c02.This may require defining some memory structure or other; otherwise, the software would have to just make a "virtual memory" kind of assumption requiring dynamic allocation of RAM, etc... It could be as simple as a linear storage definition with an upper boundary, 24 or 32 bits in size. Any disk then could be represented as bytes. The programmer would simply declare the upper boundary and optional fill value and proceed.
In fact, having that initialized to a value, say 0, would be extremely useful!
2. Be able to assemble a body of code consisting of multiple ORG statements and multiple OBJ statements.
3. Save the product to a file. Optionally, saving part of it to a file for the purpose of generating individual discrete disk images as part of the assembly process. However, just building it, then writing out the file is enough.
That's as clear as I'm capable of right now.