06 August 2011, 04:35 | #1 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
[SAS/C] Making malloc() allocate in fast RAM instead of chip RAM?
How do I do this? I am using SAS/C 6.58 and I'm programming an application that I want to use fast RAM!
My S3M loader seems to just crash in the sample loader... It managed to allocate all the sample data memory, but somehow after reading X amounts of bytes (quite many too) fread() returns 0 as in no byte read/written to buffer, then the Amiga crash. What the..? I use the SAS/C "cpr" debugger, and traced through the code and found out that it indeed crashes in the sample load loop, but only in the middle of the reading -- not on first sample etc. This is weird, it allocates all the sample data (200kB+) but fails in the read/write loop, maybe I need to set some special compiler switches to access over 65535 bytes or to make it fast RAM "compatible"? |
06 August 2011, 15:16 | #2 | |
Registered User
Join Date: Sep 2007
Location: Las Cruces, USA
Age: 71
Posts: 351
|
Quote:
Malloc() should allocate from fast ram first and then chip ram. If you are getting chip ram then there's probably no chunks of contigous fast ram big enough for the allocation. I've never had a problem with my SAS/C not going over the 16 bit limit and I don't remember ever having to tell it to. |
|
06 August 2011, 16:15 | #3 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Probably an error in your code, but if slowmem and chipmem will not do (though they should) and you must have fastmem, then use AllocMem:
Code:
#include <exec/memory.h> #include <clib/exec_protos.h> APTR ptr = AllocMem(1000, MEMF_FAST); if(ptr != NULL) FreeMem(ptr, 1000); Last edited by Leffmann; 06 August 2011 at 22:52. |
07 August 2011, 07:06 | #4 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
I'm such an idiot. You know, endianness on 68k. I read shorts and ints from a file that was made on DOS, without swapping the nybbles. It all works now. Also, the 65535 code boundary got fixed by setting CODE=FAR in the compilation option. Life saver (so slow it's only good to use it in loaders): Code:
void swap16(unsigned short *data) { *data = (*data >> 8) | (*data << 8); } void swap32(unsigned int *data) { *data = (*data >> 24) | ((*data << 8) & 0x00FF0000) | ((*data >> 8) & 0x0000FF00) | (*data << 24); } Last edited by 8bitbubsy; 07 August 2011 at 09:50. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A600 w/ 1MB Chip + 4MB Fast Ram = WHDLoad success rate? | Kenan | support.Hardware | 7 | 08 May 2013 18:14 |
Allocating Fast RAM as Chip? | Fingerlickin_B | support.Hardware | 22 | 20 November 2008 22:15 |
Could not allocate 'shadow ram'? | NovaCoder | project.WHDLoad | 4 | 28 August 2008 01:09 |
32-bit FAST RAM vs. ZII FAST RAM | polbit | support.Hardware | 16 | 28 January 2007 20:16 |
Set Chip and Fast RAM in WinUAE | nineoc | New to Emulation or Amiga scene | 17 | 20 September 2006 09:25 |
|
|