English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 09 May 2020, 15:39   #1
MacSpain
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 10
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/
MacSpain is offline  
Old 09 May 2020, 16:52   #2
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,506
Does it work if you manually copy files to formatted adf?
Toni Wilen is offline  
Old 09 May 2020, 19:24   #3
MacSpain
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 10
Quote:
Originally Posted by Toni Wilen View Post
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?
MacSpain is offline  
Old 09 May 2020, 21:28   #4
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by MacSpain View Post
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.

Last edited by phx; 09 May 2020 at 21:31. Reason: s/with/without/
phx is offline  
Old 15 May 2020, 21:39   #5
KaiN
Registered User
 
Join Date: Sep 2018
Location: Poland
Posts: 15
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.
KaiN is offline  
Old 16 May 2020, 11:34   #6
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by KaiN View Post
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.
phx is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Booting adf with game crashes WinUAE MacSpain support.WinUAE 3 26 March 2020 18:04
Booting more than one ADF/DMS from within ZIP/LHA archive Foebane support.WinUAE 2 29 June 2018 18:26
Problem booting from HD Hedefar support.WinUAE 14 20 July 2012 00:21
Problem booting with JIT... Leo42 support.WinUAE 3 15 June 2009 21:25
DMS and ADF booting... VermillioN support.WinUAE 7 28 October 2002 15:41

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.39732 seconds with 13 queries