bugbiter Posted February 23, 2016 Share Posted February 23, 2016 I have a menu program which has to call other modules. The menu program shall be loaded manually in a dos environment from disk or a folder mounted in APE. The other programs are in that same location. So I am looking for a way for the menu program to note which device and drive number is used to load it originally and to use that device to load the other modules later. Is that possible? Maybe during an init routine while the loading process of the menu is still active and the iocb still open? Quote Link to comment Share on other sites More sharing options...
Kyle22 Posted February 24, 2016 Share Posted February 24, 2016 In SpartaDOS-X, D: refers to the default drive\path. For example, if your program was in c:\myprog\myprog.exe, along with myprog.dll, and myprog.ovl, referencing D:MYPROG.DLL or D:MYPROG.OVL would work fine. In most other DOSes, D: refers to D1:. In BASIC, you can peek 769 (DUNIT $301) to find out the last drive used. Hope this helps. Quote Link to comment Share on other sites More sharing options...
Rybags Posted February 24, 2016 Share Posted February 24, 2016 We went through this at least once before, it's a tricky thing and not a definitive answer to be had. The device in the DCB you can usually check during an INIT segment, practically guaranteed it'll refer to the device your program is currently loading from. But the problem is an absolute device number/unit number won't always map to the Dn: drive that you think it will. That can cause a problem if you're using Dos. If you're dealing with absolute device/unit number, doing the IO yourself rather than having a filing system then your disadvantage is just that - without a Dos you're left to dealing with raw sector data. In an application your best bet is probably to do the deduction yourself but allow the user to change the drive details if necessary. 1 Quote Link to comment Share on other sites More sharing options...
Kyle22 Posted February 24, 2016 Share Posted February 24, 2016 You could try automatic detection first, and if there is an error, ask the user. Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted February 24, 2016 Share Posted February 24, 2016 (edited) Easy in SDX since the command line buffer holds a copy of the command that launched the executable and if you re-parse that argument, DOS will resolve the device identifier or add the default if none was provided. Unfortunately other DOSes don't provide such convenience, and even under SDX, drive swap tables and further indirection via partition tables, etc, if hard disks are used present more obstacles. Edited February 24, 2016 by flashjazzcat Quote Link to comment Share on other sites More sharing options...
bugbiter Posted February 25, 2016 Author Share Posted February 25, 2016 Thank you guys, I'll try that. One last question: How can I make Dos load and execute another program via my machine code? Quote Link to comment Share on other sites More sharing options...
Rybags Posted February 26, 2016 Share Posted February 26, 2016 (edited) You're probably best off just OPENing the file and performing the binary load operation yourself. The problem with binary/executable files is it's like they were a bit of an afterthought. No native support at all in the OS. Though some Doses are nice enough to have a special (XIO) command type that performs a binary load, Dos 2.x from Atari doesn't have any such thing. In fact I don't think there's support to do a binary load without having DUP present although AUTORUN.SYS is a binary file and is loaded by Dos without involvement from DUP. Luckily the algorithm to perform a binary load including doing the Init/Run processing is pretty simple and could probably be done in under 150 bytes disregarding the Open file processing part... sort of goes like this (assumes file has already been opened): set $2E0 = <point to RTS> Main_loop set $2E2 = <point to RTS> Get_start get 2 bytes from file to form Segment_start If Segment_start = $FFFF then goto Get_start get 2 bytes from file to form Segment_finish set Current_byte = Segment_start Read_segment get 1 byte from file, store to Current_byte address if Current_byte = Segment_finish then goto Do_init increment Current_byte, jump to Read_segment Do_init JSR indirect via $2E2 Jump to Main_loop End_of_File JSR indirect via $2E2 JMP indirect via $2E0 End_of_File gets executed once the file is exhausted. Note that the Init address should be reinitialized to point to RTS before each segment read starts to ensure it's never called more than once. Files can contain unlimited Init addresses and each one will be executed. Only the last Run address will be valid. Edited February 26, 2016 by Rybags 1 Quote Link to comment Share on other sites More sharing options...
xxl Posted February 26, 2016 Share Posted February 26, 2016 Thank you guys, I'll try that. One last question: How can I make Dos load and execute another program via my machine code? use xB: fname .byte c'MYFILE COM' ldy <fname ldx >fname jsr xBIOS_LOAD_FILE or if you have opened file you can: jsr xBIOS_LOAD_BINARY_FILE from any point in file INI/RUN vectors works as expected 1 Quote Link to comment Share on other sites More sharing options...
bugbiter Posted February 26, 2016 Author Share Posted February 26, 2016 use xB: fname .byte c'MYFILE COM' ldy <fname ldx >fname jsr xBIOS_LOAD_FILE or if you have opened file you can: jsr xBIOS_LOAD_BINARY_FILE from any point in file INI/RUN vectors works as expected Sorry, I don't know what xbios is. Is this part of spartadosx? Quote Link to comment Share on other sites More sharing options...
Kyle22 Posted February 26, 2016 Share Posted February 26, 2016 Sorry, I don't know what xbios is. Is this part of spartadosx? xBIOS is here: https://translate.google.com/translate?ie=UTF-8&tl=en&u=http%3A%2F%2Fxxl.atari.pl%2F BTW, Thanks xxl for not using illegal opcodes in this one. It works on my 816. Quote Link to comment Share on other sites More sharing options...
snicklin Posted February 26, 2016 Share Posted February 26, 2016 Here's an English based document for xBIOS: https://atariwiki.org/wiki/Wiki.jsp?page=XBIOS 1 Quote Link to comment Share on other sites More sharing options...
danwinslow Posted February 26, 2016 Share Posted February 26, 2016 Yes, the 'where was I loaded from" thing is pretty tricky. I never did find a universal solution. 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.