Pages: 1
|
 |
|
Author
|
Topic: problems using dll calls (Read 2986 times)
|
RogerLevy
Full Member
   
Karma: +1/-0
Offline
Posts: 55
|
i'm trying to bind to the Allegro game library from Retro. first thing is to get the initialization func working - the call i want to make would be the equivilant of, in C:
install_allegro(0,&errno,0); \\ i think! been a long time since i've used C
here's my retroforth code. these lines work just fine:
" alleg40.dll" LoadLibraryAs allegro allegro " install_allegro" MapFunctionAs install_allegro variable errno
but it crashes here:
0 errno 0 3 install_allegro invoke
am i doing something wrong?
|
|
|
|
« Last Edit: November 25, 2004, 02:16:09 AM by RogerLevy »
|
Logged
|
|
|
|
crc @ work
Guest
|
Try this:
" alleg40.dll" LoadLibraryAs allegro allegro " install_allegro" MapFunctionAs install_allegro variable errno
install_allegro 0 errno 0 3 invoke
The function name should preceed arguments (I might change this; it'd make some things cleaner. What do you think?)
|
|
|
|
|
Logged
|
|
|
|
RogerLevy
Full Member
   
Karma: +1/-0
Offline
Posts: 55
|
no luck. but this time instead of simply closing itself, i get the standard windows XP "this program encountered a problem and needs to close." message box.
|
|
|
|
« Last Edit: November 25, 2004, 08:17:09 AM by RogerLevy »
|
Logged
|
|
|
|
crc @ work
Guest
|
I'll try to get this working once I get home from work (3-4 hours from now).
|
|
|
|
|
Logged
|
|
|
|
crc @ work
Guest
|
What does the & in &errno do? I haven't used C in quite a while, so I'm sort of rusty here...
|
|
|
|
|
Logged
|
|
|
|
Charles Childers
Administrator
Sr. Member
    
Karma: +2/-0
Offline
Posts: 745
|
I've tried a lot of approaches, and none seem to work :-( I'll do some reading of the documentation and see if I can find the problem.
|
|
|
|
|
Logged
|
|
|
|
RogerLevy
Full Member
   
Karma: +1/-0
Offline
Posts: 55
|
basically you just have to pass the address of a variable to the function. & is the "address of" operator in C, if i'm not mistaken.
if it will help, i think that the dll doesn't "clean up" after itself, unlike two other DLL's i've used, so it seems to be an oddball. in win32forth i have to DROP all the args plus sometimes the return arg after each call. maybe it's trying to return to one of its args?
|
|
|
|
« Last Edit: November 25, 2004, 03:42:16 PM by RogerLevy »
|
Logged
|
|
|
|
|
|
RogerLevy
Full Member
   
Karma: +1/-0
Offline
Posts: 55
|
thanks, it worked! although it is a slight approach toward "fathood" i appreciate it alot.
you asked what i thought about the arg order - actually it would be nice if they came before, and perhaps if the function words were self-executing, that would be convenient too. not that the current way is a big deal, imo.
|
|
|
|
|
Logged
|
|
|
|
RogerLevy
Full Member
   
Karma: +1/-0
Offline
Posts: 55
|
btw, i noticed that linking to variables is as easy as using MapFunctionAs on em as if they were functions. then just made sure to @ the resulting created word, and you can @ and ! the address it gives as normal. just thought it would be useful to point out.
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: 1
|
|
|
|
|