Path: utzoo!utgpu!water!watmath!clyde!rutgers!gatech!mcnc!decvax!decwrl!pyramid!prls!philabs!lamont!adam From: adam@lamont.Columbia.edu (adam levin) Newsgroups: comp.sys.amiga Subject: Copying to chip RAM Message-ID: <442@lamont.Columbia.edu> Date: 26 Mar 88 00:17:34 GMT Organization: Lamont-Doherty Geological Observatory N.Y. Lines: 65 I have a 'C' array which needs to be in chip RAM. The examples I have found declare the array, AllocMem some chip RAM, and copy the array into it. This is wasteful if all one has is chip RAM, or if the program was linked with Manx's +C option. I wrote the following routine, and I'd like to know if this is a reasonable way to avoid the unnecessary copy. Must I #include the value of FAST_STARTS, or is it available in some system structure? /* MemType - Given a starting address and a length, returns either MEMF_CHIP, MEMF_FAST, or both. 25-Mar-1988 aklevin */ #include #include #define FAST_STARTS 0x80000L ULONG MemType(start, length) ULONG start, length; { if (start >= FAST_STARTS) return(MEMF_FAST); if (start + length < FAST_STARTS) return (MEMF_CHIP); else return (MEMF_FAST | MEMF_CHIP); } /* end MemType() */ /* Here is a code fragment to show how I use MemType(): */ int i; USHORT *varipointer, pointer[] = { 0x0000, 0x0c80,... 0x0202 }; if (MemType((ULONG)pointer, (ULONG)sizeof(pointer)) == MEMF_CHIP) /* If it is already in chip RAM, use the existing pointer. */ varipointer = pointer; else { /* Otherwise, attempt to allocate chip RAM for it. */ varipointer = (USHORT *)AllocMem((long)sizeof(pointer), MEMF_CHIP|MEMF_CLEAR); /* If chip RAM was successfully allocated, copy the array into it. */ if (varipointer) { for(i=0; i