English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 21 April 2013, 12:54   #1
tolkien
AmigaMan
 
tolkien's Avatar
 
Join Date: Oct 2012
Location: Castro Urdiales/Spain
Posts: 761
AmiDEVcpp: Allocating gfxdata in chip mem

I´m trying AmiDEVccp to code a few things for Amiga68k but I have a problem.
When I define a gfx in other compilers I can use the chip keyword to allocate it in CHIPMEM but here I cant.
How can I do it? Must I do AllocMEM in chipmem and copy my gfx there?
What am I doing wrong?

Thanks!
tolkien is offline  
Old 21 April 2013, 13:13   #2
Zetr0
Ya' like it Retr0?
 
Zetr0's Avatar
 
Join Date: Jul 2005
Location: United Kingdom
Age: 49
Posts: 9,768
as I remember it you need to token the variable you want to store in chip.

in DICE I would use "__CHIP" before the variable - thats two underscore's btw

i.e.
Code:
__CHIP UBYTE tile[2048]
I would suggest looking at CHIP as a place to copy to as opposed to store stuff in - and I would also suggest using Blitter copy routines if you can - although if you are targeting an 030@28Mhz or faster then forget the Blitter as the CPU is faster

To ensure that variables are stored in FAST memory, again the token of "__FAST" is used under DICE, there should be a pre-compiler list for these for the compiler that you are using.

to dynamically allocate memory, as with all pointers its about your cast

Code:
void main( void )
{
    __CHIP unsigned char *tile;
    tile = (char *) malloc ( sizeof (char) *2046 );

    if (tile == 0)
    {
        printf("ERROR: Out of memory\n");
        exit(0);
    }

    // REST OF CODE HERE***
    
    // Remeber to free the pointer afterwards!
}
I hope that helps
Zetr0 is offline  
Old 21 April 2013, 20:45   #3
tolkien
AmigaMan
 
tolkien's Avatar
 
Join Date: Oct 2012
Location: Castro Urdiales/Spain
Posts: 761
I'm out of home but I'll try tomorrow. Thanks mate!
tolkien is offline  
Old 21 April 2013, 20:53   #4
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
__chip (lower case letters) should be defined in GCC (AmiDevCPP), if it's not then try __attribute((chip)) or __attribute((__chip__)). It may also require static duration, so you must declare it either static or global.

If you have to resort to allocating dynamically then you must use AllocMem(), calling malloc() and then casting to a pointer with __chip can never work because the qualifier only applies to storage of the pointer value itself.
Leffmann is offline  
Old 21 April 2013, 21:35   #5
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
using a qualifier like __chip__ causes the data to be stored in a chip data hunk in the resulting executable, i.e. amigados loads it directly into chipmem.. If you don't find a way to make the compiler/linker do this, but use the allocmem method, you will have duplicate copies in memory, which is not a good idea :-)
hooverphonique is offline  
Old 21 April 2013, 21:49   #6
tolkien
AmigaMan
 
tolkien's Avatar
 
Join Date: Oct 2012
Location: Castro Urdiales/Spain
Posts: 761
I think I tried those qualifiers yesterday but remember to have an error "chip attribute is no supported in this target" or something similar. Hope to be in home soon and try. Thanks for the answers!
tolkien is offline  
Old 21 April 2013, 22:00   #7
davideo
Amiga Tomcat
 
davideo's Avatar
 
Join Date: Sep 2007
Location: Boston Lincs
Posts: 1,500
StormC uses Pragmas to set the type of memory that the data should be stored in.

i.e.

#pragma Chip
Everything from here until the #pragma Fast is encountered is stored in Chip RAM.

Dave G
davideo is offline  
Old 21 April 2013, 22:56   #8
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Quote:
Originally Posted by tolkien View Post
I think I tried those qualifiers yesterday but remember to have an error "chip attribute is no supported in this target" or something similar. Hope to be in home soon and try. Thanks for the answers!
Compilers are tricky like this, because each one needs to have its own way of implementing target specifics.

If everything else fails then just put the array in its own file and type a couple of lines assembly to declare it as chip data, and assemble and link it in. That always works.
Leffmann is offline  
Old 22 April 2013, 03:32   #9
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,400
I just use the API?

AllocMem

Code:
MEMF_CHIP:	If the requested memory will be used by
				the Amiga custom chips, this flag *must*
				be set.

				Only certain parts of memory are reachable
				by the special chip sets' DMA circuitry.
				Chip DMA includes screen memory, images that
				are blitted, audio data, copper lists, sprites
				and Pre-V36 trackdisk.device buffers.
NovaCoder is offline  
Old 22 April 2013, 20:21   #10
tolkien
AmigaMan
 
tolkien's Avatar
 
Join Date: Oct 2012
Location: Castro Urdiales/Spain
Posts: 761
Yes NovaCoder. Thats the other option I use but wanted to know why it didn´t work.
I have tried all other options but not working. I´ll use the AllocMem/copy option.

Thanks friends!

Last edited by tolkien; 22 April 2013 at 22:37.
tolkien 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
A600 2 Mb Chip Mem Upgrade (clockport) mikele MarketPlace 7 12 March 2013 07:36
Amiga 500 chip mem Nikolaj_sofus support.Hardware 3 03 September 2010 21:34
Clock port on my A600 chip mem expansion? Frimann support.Hardware 10 18 August 2009 22:07
Allocating Fast RAM as Chip? Fingerlickin_B support.Hardware 22 20 November 2008 22:15
Need virtual memory for chip mem. Thorham request.Apps 7 28 March 2008 15:06

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 20:30.

Top

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