Hi,
I have this code:
float pcm_multiply(float src, float dest) { return src * dest * inv255; } float pcm_divide(float src, float dest) { return 255.0 * dest / (src + 1.0); } struct PixelCombineModes pcm[] = { { PCM_BLEND, "Normal", NULL }, { PCM_MULTIPLY, "Multiply", pcm_multiply}, { PCM_DIVIDE, "Divide", pcm_divide}, { PCM_NUMMODES, NULL, NULL } }; UWORD FindPCFByName(struct PixelCombineModes *pcm, STRPTR name) { UWORD result = NULL; int _index = 0; IDOS->Printf(" Finding %s\n",name); while((pcm[_index].pcm_Name != NULL)) { if(!(strcmp(name,pcm[_index].pcm_Name))) { result = pcm[_index].pcm_PCF; break; } _index ++; } IDOS->Printf(" Setting function to %08lx\n",result); return result; } BOOL SetLayerPCFByName(struct SketchLayer *sklay, STRPTR name) { if(name) { if((sklay->sl_PCF = FindPCFByName(pcm, name))) { return TRUE; } } return FALSE; }
The function FindPFCByName seems to return 0x00007300 when called for "Multiply", which is clearly not the address of pcm_multiply
Any ideas why this might not work?
The UWORD type is only 16 bits wide, not 32 bits as would be required for a pointer.
Better tune your compiler settings. Something like "UWORD result = NULL" should have raised a warning already, because you are assigning a pointer type to a an integer variable.
Thanks!
I knew it would be something so obvious I couldn't see it.
I cut paste the framework of the code from a function that returned a UWORD and forgot to update that bit.