Welcome, Guest. Please login or register.

Author Topic: Executing c command in c  (Read 10430 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Thomas

Re: Executing c command in c
« on: June 09, 2017, 02:38:06 PM »
Quote from: foleyjo;826825
2 -With AllocMem() and malloc() my concern is that I read that you need to store certain things (images, sound) in chip memory and to do this you would use AllocMem and specify chipmem as one of the parameters. What I was reading implied that malloc would just use any available memory.


You should avoid to use AllocMem with MEMF_CHIP. Rather use more specific functions like AllocBitMap or AllocRaster to get your portion of graphics mem. On an RTG system or when using FBlit, graphics mem does not necessarily be in Chip RAM and if you use MEMF_CHIP you waste valuable Chip RAM.

Quote
Though I'm not sure what HookEntry is


This is the high-level-language interface. h_Entry is called by the system with arguments in registers. HookEntry simply pushes the registers to the stack and calls h_SubEntry. h_SubEntry then finds the arguments on the stack like a C subroutine does.


Quote
or what data would be expected.


The h_Data field is for your personal needs. You can put anything there. It can for example be used by the hook routine to pass some data to the main program. Or vice versa.

Quote
and this is where I really get confused. I call this hook in the MUI List with MUIA_List_DisplayHook, &disphook .
How does it know what array and items are as I don't appear to pass anything to them??


It's not you who calls the hook function. You just tell MUI where the hook is and MUI calls the function. The MUI documentation tells you which arguments your routine has to expect. In case of a DisplayHook it is an array and an item.