English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. General (http://eab.abime.net/forumdisplay.php?f=37)
-   -   Problem with fread while booting game from adf (http://eab.abime.net/showthread.php?t=102154)

MacSpain 09 May 2020 15:39

Problem with fread while booting game from adf
 
Hi guys!

I ran into a problem while trying to build my game into an adf file and booting it from WinUAE. I do some memory arena allocation on startup, so I have a space to read my files into. My goal is running the game on either 512 Chip + 512 Fast, or 1 MB Chip. I managed to trim all used memory to around ~900 MB, however there are some problems. On 512+512 the game simply refuses to read any files after allocating memory for the arenas, and on 1 MB it loads small 10 kB files i use as logos for splash screen, but chokes on bigger, 30 KB files I use for intro graphics. It works on bigger memory setups just fine, even on 1 MB+64 KB. Is there some finicky memory stuff I have to keep in mind when planning to read files, or could it be a problem with adf?

I use WinUAE for testing, and when I boot the game from exe in Workbench it works just fine, when ~900 KB of memory is left while starting it up. For building into adf I use exe2adf. http://www.exe2adf.com/

Toni Wilen 09 May 2020 16:52

Does it work if you manually copy files to formatted adf?

MacSpain 09 May 2020 19:24

Quote:

Originally Posted by Toni Wilen (Post 1398671)
Does it work if you manually copy files to formatted adf?

Not sure I understand what you mean by that. You mean after building the game into an adf?

phx 09 May 2020 21:28

Quote:

Originally Posted by MacSpain (Post 1398655)
On 512+512 the game simply refuses to read any files after allocating memory for the arenas, and on 1 MB it loads small 10 kB files i use as logos for splash screen, but chokes on bigger, 30 KB files I use for intro graphics.

What does "refuses to read" or "chokes" mean in detail? You can open the file and get a valid file handle, but then fread() or Read() is returning zero-bytes read and/or an error code (which)?

There is "fread" in the subject, so I guess you're using fread() from a C-compiler's clib? Which?

Why using fread() in an Amiga game anyway? It certainly doesn't need to be portable. So dos.library Read() would be the better choice, without pulling all of the compiler's clib code into the executable and wasting a lot of memory.

Quote:

Is there some finicky memory stuff I have to keep in mind when planning to read files, or could it be a problem with adf?
I doubt that the ADF has anything to do with it. Did you try on real hardware?

Quote:

when I boot the game from exe in Workbench it works just fine,
Then I would debug and compare these two variants. Either by inserting an AvailMem() call just before the failing reads, or by setting a breakpoint and inspect the MemHeaders and memory lists manually.

Quote:

For building into adf I use exe2adf. http://www.exe2adf.com/
Toni suggested that you create the ADF without exe2adf, from within the emulation (format, copy). Might be worth a test, although I doubt it makes a difference.

KaiN 15 May 2020 21:39

Since MacSpain uses ACE, Let me discuss my design decisions. ;)

Quote:

Why using fread() in an Amiga game anyway? It certainly doesn't need to be portable
I plan to make subset of it portable - it already should be able to run headless (no gfx/sfx) on any PC, and there are plans to make a subset of it run via SDL (no sprites, no copper fns, etc.). That's the main reason why I've rewritten your ptplayer to C. ;) Because of that my code is already ifdef'd for Amiga in many many places, so I thought I could have a bit less ifdefs in my code by using stdio for file access. Also, according to my quick googling, there's no fprintf/fscanf in OS.

Back to topic. It's funny that fread etc. doesn't work. IIRC Bebbo's libnix file functions doesn't allocate anything. It could be that there is too little room for stack and it's starting to trash fns / vars.

phx 16 May 2020 11:34

Quote:

Originally Posted by KaiN (Post 1400111)
I plan to make subset of it portable - it already should be able to run headless (no gfx/sfx) on any PC, and there are plans to make a subset of it run via SDL (no sprites, no copper fns, etc.).

Ok. Fair enough. :)

Quote:

Also, according to my quick googling, there's no fprintf/fscanf in OS.
At least not before V36. For Kickstart 1.x you could use some simple format string processing with RawDoFmt().

Quote:

It could be that there is too little room for stack and it's starting to trash fns / vars.
Yes. My best guess would also be that some memory was trashed before by a bug.


All times are GMT +2. The time now is 21:50.

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

Page generated in 0.04694 seconds with 11 queries