phaeron Posted October 11, 2019 Share Posted October 11, 2019 The reason for the recursive crashing on warm reset is that the cartridge sets APPMHI to $9C1F, which is one byte higher than is necessary to open a GR.0 screen. The display handler reacts to a memory allocation failure on screen open by falling back to a GR.0 screen, which in this case causes an infinite loop. Arguably, there is an off by one here in the Display Handler's memory checking, but it's pointless to set APPMHI for a GR.0 screen for this reason. As for DISKIV, there are two variables used by the Disk Handler. One is the format timeout, and the other is the sector size if on an XL/XE OS. DSKINV pushes the sector size into the transfer length in the DCB (DBYTLO/DBYTHI) and sets the timeout (DTIMLO) to either the format timeout or the normal disk access timeout, depending on the command. You should not normally need to call DISKIV to set these values as it is invoked by cold start processing, skipped only for a diagnostic cartridge. If you bypass DSKINV and go directly to SIOV, you are responsible for setting the variables that DSKINV normally would for you: DDEVIC, DSTATS, DTIMLO, DBYTLO, DBYTHI. The default timeout for a regular disk access is $07, while the format timeout defaults to $A0 but is usually raised to the value received from D1: by the status command at the start of the disk boot. DSKINV also normally does this update automatically after a successful status command to any drive. (This is the reason for format commands failing on real disk drives when certain PC-based disk drive emulators are in the SIO chain that report unusably low format timeouts.) Or, you could just use $FE as the highest known value (XF551). By the way... probably want to clear the keyboard character buffer before displaying the "are you sure?" format prompt. Not so good if you happen to have pressed Y first before pressing Option. 2 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 11, 2019 Author Share Posted October 11, 2019 Good point on clearing the kbd buffer. I'll do that. So really, for any disk access, should I use DSKINV or SIOV? Will I be able to handle double density (and/or high speed) if I stick to using the DSKINV? -Thom Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 11, 2019 Author Share Posted October 11, 2019 Meanwhile, since I have some ROM space left over... Am plotting a unicorn for the title screen to be shown as mode D data (will use dlist jumps to bounce in and out of my custom display list patch), on the title screen: 3 Quote Link to comment Share on other sites More sharing options...
phaeron Posted October 12, 2019 Share Posted October 12, 2019 13 hours ago, tschak909 said: So really, for any disk access, should I use DSKINV or SIOV? Will I be able to handle double density (and/or high speed) if I stick to using the DSKINV High-speed patches normally apply to SIO and DSKINV calls into SIO, so they'll work for either entry point. This applies both to high-speed OS patches and PBI device intercepts. If you wanted to support the 400/800 and double density, then you'd need SIOV. Seems you're targeting XEGS here, though, so DSKINV would work as long as you updated DSCLTN. Note that DSKINV will not adjust the sector length for boot sectors, that's your job. Using one over the other is mostly a wash -- you'd potentially save a little code with DSKINV, but using SIOV is also easy. Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted October 12, 2019 Share Posted October 12, 2019 I vote SIOV... Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 12, 2019 Author Share Posted October 12, 2019 @phaeron so for double density I need to use SIOV? Sorry if I am possibly re-treading here, am trying to catch subtle nuances. The support I add will depend on what drive I wind up getting. I have a 1050 coming to me, so I will adjust the code to use ED at the very least...if I do wind up getting an XF551, i'll extend the program for both high-speed and DS/DD. I'm actually somewhat surprised that I've managed to comfortably fit this program (written in C!) in 8K. -Thom 1 Quote Link to comment Share on other sites More sharing options...
Alfred Posted October 12, 2019 Share Posted October 12, 2019 (edited) DSKINV sets some of the SIO parameters for you. That's what the call to $E450 does, it initializes the sector length and the default timeout that DSKINV uses. So if you don't use DSKINV, you don't need the call to $E450. I had a quick look at your bootsect.c and you aren't setting $0300 correctly, but DSKINV is fixing it for you, which is why it works, and SIO fails. It's $30+DriveID, in your case it would be $31. I didn't look in main.c to see if it was the same problem, but I expect it is. The rest looks ok. You can use DSKINV for DD if you like, you just have to set $0246/$0247 (DSCTLN) to 256 rather than 128 before you invoke it. Edited October 12, 2019 by Alfred DD questio. Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 12, 2019 Author Share Posted October 12, 2019 is that for sure $0246/$0247? I can't find that on any equates.. I see $0246 as where DSKTIM is stored, and 0247 was part of a temporary buffer. -Thom Quote Link to comment Share on other sites More sharing options...
Alfred Posted October 12, 2019 Share Posted October 12, 2019 Sorry, $02D5/6. Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 12, 2019 Author Share Posted October 12, 2019 Ahhh, I see... so, basically DSKINV and its minions were added as part of the 1200XL OS and was carried over... Was this purely a convenience mechanism? Trying to look forward into PBI devices? -Thom Quote Link to comment Share on other sites More sharing options...
tjlazer Posted October 12, 2019 Share Posted October 12, 2019 Sorry for the dumb question, what software did you use to program this? Was it on the Atari or on a PC with Emulator or other tools? Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 12, 2019 Author Share Posted October 12, 2019 Nah, not a dumb question The program is written in C, and the code is here: http://github.com/tschak909/ninas-diary To write it, I am currently a Windows PC. with Altirra as an emulator. I use the emacs text editor (I've been using emacs in one guise or another for three decades) I have cygwin (and Windows Services for Linux) installed to provide my other dev tools, like make. For a C compiler, I use CC65 (http://cc65.github.io) I write the code, run make, and out pops a binary. For normal disk based software, this is a DOS binary file. For cartridge based software, it is a raw cartridge image either 8192 or 16384 bytes in length that can be burned onto a PROM. Depending on the target cartridge hardware, I may also decide to duplicate it multiple times in the cartridge image to satisfy banking requirements. To get it onto real hardware, I have a few of options: (1) SIO2PC (2) use my disk writing rig (a Qumetrak 142 attached to a SuperCard Pro), to write an actual disk. (3) pop it onto my sdrive-max But with this setup, I can spend most of my time literally running in emulation. Compilation literally takes 6 seconds, and I can turn right back around, attach the cartridge, and go. If I spent a bit more time on my tooling, I could call altirra directly, and shave some manual process of attaching the cart etc. *shrug* Since I am working with raw disk access, I literally turn on disk emulation in Altirra to test as close to actual behavior as I can, and debug as quickly as possible. Hope this makes it more clear! -Thom Quote Link to comment Share on other sites More sharing options...
Alfred Posted October 12, 2019 Share Posted October 12, 2019 56 minutes ago, tschak909 said: Ahhh, I see... so, basically DSKINV and its minions were added as part of the 1200XL OS and was carried over... Was this purely a convenience mechanism? Trying to look forward into PBI devices? -Thom Well who knows. I doubt it has to do with the PBI, I think it was more likely a way to simplify calling SIO. DSKINV only works with D1: which is probably what the majority of programs would use. So to invoke SIO all you need is to set the command, the unit, the buffer address and the sector number, and DSKINV does the rest for you. No need to worry about status bits or timeout values. You're already doing all the setting, so like Phaeron suggested you might want to just stick with SIOV as DSKINV is not present on the 400/800 machines. I think I only ever ran across one XL program that actually used it. Quote Link to comment Share on other sites More sharing options...
phaeron Posted October 12, 2019 Share Posted October 12, 2019 DSKINV wasn't added in the 1200XL OS, it's been part of the OS from the beginning. It just gained the ability to customize the disk sector size with DSCTLN starting with the 1200XL, instead of being hardcoded to 128 bytes. DSKINV also isn't limited to D1: only, and $0300 isn't $30+DriveID for SIOV. $0300 is DDEVIC, $0301 is DUNIT, and the SIO device ID used is DDEVIC + DUNIT - 1. DSKINV sets DDEVIC to $31 so you select the disk drive with DUNIT values of $01 for D1:, $02 for D2:, etc. If you are using SIOV the you need to set both DDEVIC and DUNIT. If you try just setting DDEVIC to $30+index then the code will break if DUNIT has been left as anything other than $01 from a prior request. 1 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 12, 2019 Author Share Posted October 12, 2019 Ok, I will try again tonight to change the code entirely to SIOV. @phaeron thank you so much for explaining the land-mines. Right now, am trying to get the unicorn working, and then I'll see if I can extend this to double density. Given the way this program works, I'm not sure adding high speed support would be very beneficial. -Thom Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 12, 2019 Author Share Posted October 12, 2019 Ok, the unicorn is in... Will post a new build once I refactor the disk routines a bit. -Thom 4 Quote Link to comment Share on other sites More sharing options...
Alfred Posted October 12, 2019 Share Posted October 12, 2019 (edited) 2 hours ago, phaeron said: DSKINV wasn't added in the 1200XL OS, it's been part of the OS from the beginning. It just gained the ability to customize the disk sector size with DSCTLN starting with the 1200XL, instead of being hardcoded to 128 bytes. DSKINV also isn't limited to D1: only, and $0300 isn't $30+DriveID for SIOV. $0300 is DDEVIC, $0301 is DUNIT, and the SIO device ID used is DDEVIC + DUNIT - 1. DSKINV sets DDEVIC to $31 so you select the disk drive with DUNIT values of $01 for D1:, $02 for D2:, etc. If you are using SIOV the you need to set both DDEVIC and DUNIT. If you try just setting DDEVIC to $30+index then the code will break if DUNIT has been left as anything other than $01 from a prior request. You sure about that ? I find it hard to believe that I can set DDEVIC to $31 and DUNIT to 4 and drive 4 will respond rather than drive 1. I've always understood that DUNIT must match the low 4 bits of DDEVIC, so $31,1 or $32,2 etc. Edited October 12, 2019 by Alfred Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 12, 2019 Author Share Posted October 12, 2019 It's rather bizarre actually, if I set DDEVIC=0x30 then I get a timeout, nothing responds. but it works if I set it to 0x31. *scratch-head* -Thom Quote Link to comment Share on other sites More sharing options...
Alfred Posted October 12, 2019 Share Posted October 12, 2019 28 minutes ago, tschak909 said: It's rather bizarre actually, if I set DDEVIC=0x30 then I get a timeout, nothing responds. but it works if I set it to 0x31. *scratch-head* -Thom Yes, because DDEVIC must be $30+drive #. So for drive #1 you set DDEVIC to $31 which is what DSKINV does for you. DUNIT must be set to the drive # as well, without the $30, so if you set $0300=$31 then you set $0301=$01. Now Phaeron seems to be implying you can set DDEVIC to $31 and use any drive number in DUNIT, and I don't think that's correct, but maybe I've misunderstood his reply. Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted October 12, 2019 Share Posted October 12, 2019 (edited) SpartaDOS X writes $31 to DDEVIC and sets DUNIT to $03 (before calling SIOV) when I call a directory of D3:, so it appears perfectly legitimate practice. Edited October 12, 2019 by flashjazzcat Quote Link to comment Share on other sites More sharing options...
Alfred Posted October 12, 2019 Share Posted October 12, 2019 No, Phaeron is right. $0300 is always $31 for disk and you just set DUNIT to the drive number you want to select. Just checked some of my old code and that's what it does. Dunno why I thought you had to update DDEVIC. Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 13, 2019 Author Share Posted October 13, 2019 Nina's Diary 1.1 Lots of little changes since the first release: Added a unicorn to the splash screen Multiple disk formats now supported, choose the appropriate cartridge version for your disk type: ** 90k for SS/SD drives like the Atari 810 (90 pages a disk) ** 130k for SS/ED drives like the Atari 1050 (130 pages a disk) ** 180k for SS/DD drives like the Indus GT (180 pages a disk) ** 360k for DS/DD drives like the Atari XF-551 (360 pages a disk) ** 720k for e.g. 3.5" 720K drives like Zaxon's XF-551 clone (720 pages a disk) If you have another disk drive format you want supported (8 inch drives at 2002/4004 sectors?), let me know. Pressing reset causes a cold start. Disks are now completely wiped clean (zeroed out) Released as an 8K cartridge that you can flash onto a flash cartridge, or burn onto EPROM. (and since it's an 8K cartridge, it can also be flashed onto the Ultimate 1MB or burned onto an EPROM to put into an XE Game System!) diary-v1_1.zip 1 Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted October 13, 2019 Share Posted October 13, 2019 (edited) This is quite nice, as a general purpose diary the name should be alterable, so any kid can put their name there. -= Perhaps a nice shout out to your daughter as the inspiration or some other convention. =- Nina Soft by tschak909 or even a cool easter egg, pressing a console key, and a screen says written lovingly for our beatiful daughter Nina etc. This is shaping up nicely. maybe the animal could be select-able as well, not a ton of choices, but a couple, to suit moods and age as the child grows. This is the sort of thing EVERY parent should do, or should have done... :) Edited October 13, 2019 by _The Doctor__ 1 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 13, 2019 Author Share Posted October 13, 2019 I recorded a demo video: As for the various suggestions etc, this is literally why I make my source code public, because I want people to take what I've made, and make it better. -Thom 2 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted October 13, 2019 Author Share Posted October 13, 2019 I know I said I wasn't going to try hi-speed SIO (USDoubler), but.. I'm getting conflicting information on hi-speed, it seems that setting the audfX channels isn't sufficient, I have to bit-bang the bits myself? (meaning I can't use SIOV?) -Thom Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.