English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. System (https://eab.abime.net/forumdisplay.php?f=113)
-   -   Listing files, loading files and allocating all available chip ram. (https://eab.abime.net/showthread.php?t=65890)

h0ffman 17 September 2012 11:35

Listing files, loading files and allocating all available chip ram.
 
Hi Guys. I need to do the following..

1. Allocate the largest available chunk of chip ram (largest continuous block)
2. List all files (preferablly starting with mod.) in the EXE folder
3. Load a file
4. Deallocate that block of chip ram (just to be nice)


All calls using dos library etc.

PMC gave me a Doc which shows example assembly calls to these functions but I've since lost it.

Also, the system will be shut down, however I seem to remember Stinger saying that as long as the ports and timers are still on, loading from the hard drive should still be possible?

Any help would be greatly appreciated.

Cheers

hooverphonique 17 September 2012 13:56

what do you mean by "the system will be shut down" ? using forbid/permit? if so, that will be void, because using dos library open/read/etc will re-enable multitasking..

If I were you, I would take over the display, but leave multitasking on and raise the priority of your task to avoid anybody else stealing cpu.. that way there will be no problems with listing/loading files.

also, don't allocate more chipram than you actually need.. the crude way to find the largest chunk is to traverse the chipram free list (I don't remember if there is an exec function that will perform this sort of thing).

StingRay 17 September 2012 15:37

Quote:

Originally Posted by h0ffman (Post 839968)
Hi Guys. I need to do the following..

1. Allocate the largest available chunk of chip ram (largest continuous block)
2. List all files (preferablly starting with mod.) in the EXE folder
3. Load a file
4. Deallocate that block of chip ram (just to be nice)


All calls using dos library etc.

PMC gave me a Doc which shows example assembly calls to these functions but I've since lost it.

Also, the system will be shut down, however I seem to remember Stinger saying that as long as the ports and timers are still on, loading from the hard drive should still be possible?

Any help would be greatly appreciated.

Cheers

1. Use Exec's AvailMem() with MEMF_LARGEST parameter and then use the result of that for AllocMem().
2. Lock the directory and use Examine() (dos.library), then use the info in the FIB (file info block). Then use ExNext() in a loop to examine the next entry, if you get NO_MORE_FILES as return code you have checked all files in the directory. If you need more help let me know, I do have code which does exactly what I just described (needed it for an IFF to chunky converter some years ago).
3. Re-enable ports/timer interrupts and you can happily load a file, I did that in countless demos. And yes, it was me who told you that. :)
4. Should be obvious. :)

Quote:

Originally Posted by hooverphonique (Post 839986)
If I were you, I would take over the display, but leave multitasking on and raise the priority of your task to avoid anybody else stealing cpu.. that way there will be no problems with listing/loading files.

I actually never liked the "set task priority very high" approach, IMHO demos should kill the system and re-enable it when they need parts of it. Guess it's a matter of taste. :)

hooverphonique 17 September 2012 17:34

Quote:

Originally Posted by StingRay (Post 839999)
I actually never liked the "set task priority very high" approach, IMHO demos should kill the system and re-enable it when they need parts of it. Guess it's a matter of taste. :)

Hehe.. Well, if you know exactly what you are doing, that will be fine.. OP suggested that a simple approach might be best ;)

btw, does loading from harddrive not require interrupts (or is that covered by what you call "ports") ? I seem to remember that at least A4000 internal IDE uses INT6..

h0ffman 18 September 2012 00:46

Cheers Stinger, between you and PMC, the ProTracker DJ Player will become a reality sooner rather than later, even if its a dirty bangs on the chips while reaching around the OS old school style app! ;)

h0ffman 18 September 2012 20:43

Ok, after basically copying some code, I've managed to build a file lister, mem allocator and loader.

However, for some reason, now when I run the file lister, the file info block seems to be missing the first two bytes?! Its really odd, first time I ran it, the file name was at offset 8, now its at 6??

Anyone know why this might be???

StingRay 18 September 2012 20:47

FIB needs to be longword aligned IIRC. So add a CNOP 0,4 in front of your FIB buffer and it should work.

Quote:

Originally Posted by hooverphonique (Post 840019)
btw, does loading from harddrive not require interrupts (or is that covered by what you call "ports") ? I seem to remember that at least A4000 internal IDE uses INT6..

Level 2 interrupt (ports/timers) is enough, at least I never needed a level 6 interrupt to load from HD.

hooverphonique 18 September 2012 23:16

Quote:

Originally Posted by StingRay (Post 840231)
Level 2 interrupt (ports/timers) is enough, at least I never needed a level 6 interrupt to load from HD.

Just checked the schematics - you are correct, IDE indeed uses INT2, not 6.

I wonder if any controllers attached directly to accelerator boards interrupts its cpu directly, thereby circumventing paula!?

h0ffman 19 September 2012 00:57

Cheers stinger, wondered if that might be the case, never use cnop before! Manage to get all the mod. files in the exe folder, allocate the chip ram for the files size and load it! I know not the most complex of tasks but it's one step closer for the PT-1210 MK1 turntable ;)

Photon 16 October 2012 20:29

Quote:

Originally Posted by StingRay (Post 840231)
FIB needs to be longword aligned IIRC. So add a CNOP 0,4 in front of your FIB buffer and it should work.

FileInfo and DiskInfo must be 8-byte aligned (CNOP 0,8) for reasons unexplained in Libs & Devs and unrelated to CPU model.

Toni Wilen 16 October 2012 21:27

Quote:

Originally Posted by Photon (Post 845402)
FileInfo and DiskInfo must be 8-byte aligned (CNOP 0,8) for reasons unexplained in Libs & Devs and unrelated to CPU model.

What? Where?

StingRay 16 October 2012 21:54

Quote:

Originally Posted by Photon (Post 845402)
FileInfo and DiskInfo must be 8-byte aligned (CNOP 0,8) for reasons unexplained in Libs & Devs and unrelated to CPU model.

Eh?????

Wepl 16 October 2012 23:03

Since BCPL uses 64 bit per address, SCNR

Asman 07 February 2013 12:08

Quote:

Originally Posted by StingRay (Post 839999)
3. Re-enable ports/timer interrupts and you can happily load a file, I did that in countless demos. And yes, it was me who told you that. :)

Hi StingRay

Is this method works fine for kick1.3 ?

Edit: Especially I mean about loading files from DF0:

Regards

Mrs Beanbag 08 March 2013 01:08

I re-enable interrupts for loading on Mr Beanbag, works fine from floppy.

Also I recently added directory listing to the special levels menu, I allocate the file info block buffer with exec.AllocMem; seems to work.

Photon 23 March 2013 01:33

Thread moved to Asm.System!

Asman 04 April 2013 21:24

Quote:

Originally Posted by Mrs Beanbag (Post 873392)
I re-enable interrupts for loading on Mr Beanbag, works fine from floppy.

Also I recently added directory listing to the special levels menu, I allocate the file info block buffer with exec.AllocMem; seems to work.

Just for information: I forget to add DMAF_DISK into dmacon and loading from floppy under WinUAE worked only if turbo mode was set (Floppy Drive Emulation Speed).
Now loading from floppy, works fine (re-enable PORTS with DMAF_DISK set into dmacon ), but under WinUAE debugger I obtained exception messages (not too many) when I opened file. I'm not sure if this is ok - but files were loaded correctly.

Edit: One more thing on Kick 1.3. If blitter was taken with OwBlitter (graphics.library) then to load file do DissownBlitter (graphics.library).


All times are GMT +2. The time now is 09:57.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.25254 seconds with 11 queries