18 May 2017, 16:46 | #1 |
Registered User
Join Date: Oct 2015
Location: France
Posts: 82
|
Using DOS routines after a system take over
Hi!
When the system has been taken over (multi-task stopped, IRQs/DMAS/ADKCON registers modified, blitter owned, user copperlist running...etc.). What is the minimum requirement to be able to use the DOS open/read/write routines ? Thanks. |
18 May 2017, 18:51 | #2 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,381
|
as long as you're not tampering with memory you don't own, it should work fine. Not sure about multitask, but calling Forbid & Permit at the proper locations should fix that.
A lot of games use DOS to load files, and don't use the rest of the libraries, but use their own VBL interrupt and hardware banging (using OwnBlitter/DisownBlitter also helps). Also backup system copperlist before overwriting in case you want a chance to return to the OS on exit. |
18 May 2017, 19:08 | #3 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,358
|
DOS absolutely needs multitask to work and will actually violate Forbid state.
IRQ/DMA probably need to be restored. User coplist and blitter owned are no problem as long as no system request can be displayed as result of these Dos calls. |
18 May 2017, 19:24 | #4 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
timer.device is the most important (CIA timers = level 2/6 interrupts and vblank). Floppy access of course needs disk DMA, ADKCON floppy bits etc.. (and blitter if KS 1.x). You may get away without timers with some HD controllers..
I recommend to always temporarily restore INTENA properly and free blitter when calling system routines. Only important DMA channel is floppy DMA. |
18 May 2017, 19:26 | #5 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,351
|
Set your pr_WindowPtr to -1 to suppress DOS requesters (e.g. read/write error, insert volume ... etc.).
|
18 May 2017, 20:36 | #6 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 725
|
Have a look at this,
http://eab.abime.net/showthread.php?t=70691 last post has source code that loads a file from floppy while starfield is running. Hope it helps. |
01 June 2017, 12:39 | #7 |
Registered User
Join Date: Oct 2015
Location: France
Posts: 82
|
Thanks all for your information
I have successfully managed to load files using standard dos routines after a system take over by restoring the DMACON, INTENA, ADKCON registers, the IRQs vectors and doing a DisownBlitter(). Last edited by majikeyric; 01 June 2017 at 12:51. |
01 June 2017, 17:02 | #8 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
Just a quick note here, in my experience the above works fine. But saving files is a different story. There seems to be no way to check if Amiga OS is done writing to a file, so you'd have to guess (as in - wait <x> seconds after the close call returns and hope that was long enough).
Maybe there is a way to do this in a nicer way, but I haven't found one. |
01 June 2017, 20:32 | #9 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,551
|
|
01 June 2017, 20:53 | #10 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
So in your opinion whdload should only support floppies?
|
01 June 2017, 23:26 | #11 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
Well, a trackloader/saver would be a nice option, but I've not found a good tutorial/example on those yet. That is, I did find several example trackloaders with source but no tracksavers at all.
|
03 June 2017, 00:26 | #12 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,551
|
Certainly not. The question was for a nicer way to do it. It doesn't feel nice to me to reanimate the OS after you have taken over everything. Whdload has not much choice, though.
Quote:
When nowadays writing to disks (like high scores, etc.) I would recommend to format a whole track with the data and don't care about read/write errors. Most disks have become so bad that errors are common, and you don't want that they render your game useless. |
|
03 June 2017, 00:48 | #13 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,018
|
|
03 June 2017, 02:21 | #14 |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
I had been thinking for a way to save high scores on my HD installable versions and this was the only solution I could come up with also. Short of making the game system friendly....
|
03 June 2017, 18:56 | #15 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
Quote:
|
|
03 June 2017, 19:33 | #16 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 829
|
I don't get it. What does mean there seems to be no way to check if OS done writing to a file ? I don't see where is the problem. Could you explain a bit more. Thank you.
|
03 June 2017, 19:52 | #17 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
Quote:
Which can mean guessing a too short delay and losing the file or corrupting the disk On other operating systems, you can usually force the OS to finish writing to disk before telling you it's done with the file, not on the Amiga - its OS assumes you'll be running under multitasking all the time and therefore don't need to know that the OS is still busy writing. As phx rightly said, trying to work around that is messy and not something that one should really do (and I'll admit being guilty immediately, never to old to learn and all that!) |
|
03 June 2017, 20:57 | #18 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 829
|
Thanks roondar for explanation. But with your approach (OS is still writting after I am done) you will never known (mean your program which call Write for example ) if there was an error during writting. If I use Write from dos.library then this function will return how many bytes were written. Of course I must wait till floppy motor will be off after read/write, but there is no guessing - 2 seconds should be enough. If I am wrong then please correct me.
|
03 June 2017, 21:07 | #19 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
Quote:
And you can't use the floppy motor as indicator either, because the OS sometimes turns it off and then on again during writing (I've noticed this many times). Which is why waiting a longer time is often used. And usually, that works - but you can't guarantee it. I've had test programs cause corrupted disks this way more than once. |
|
03 June 2017, 21:21 | #20 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
Write will return quickly (may even return practically instantly) if used filesystem and/or device driver has write buffers that are flushed later.
Sending ACTION_FLUSH directly to filesystem should force write buffer flush but I don't know if all filesystems support it. And even if it worked, there is still device driver layer that may ignore any flush attempts (CMD_UPDATE should do it).. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cd32 audio read routines using hardware | jotd | Coders. Asm / Hardware | 40 | 23 January 2024 18:07 |
decompression routines | Toni Wilen | Coders. General | 12 | 17 May 2017 00:30 |
Using System DOS commands within SAS-C | Zetr0 | Coders. System | 5 | 23 April 2017 18:14 |
OSTER's assembler routines & tricks | Shoonay | Coders. Tutorials | 8 | 17 November 2016 15:41 |
Checksum routines in games | Joejoe | Coders. Tutorials | 11 | 26 December 2009 20:24 |
|
|