View Single Post
Old 03 January 2014, 20:23   #44
FrodeSolheim
FS-UAE Developer

FrodeSolheim's Avatar
 
Join Date: Dec 2011
Location: Førde, Norway
Age: 36
Posts: 3,368
uaenative.library implementation is more or less complete now, with async mode too - I have also created a simple uni-create-wrapper.py script which takes a native library and generates wrapper functions for ease of use. Here's how usage looks now:

Example native library:

Code:
#include "uni_library.h"
#include <stdio.h>

UNI_DEFINE_LIBRARY (1, NULL);

UNIAPI void UNICALL hello_world (struct uni *uni)
{
    uni_char *data = UNI_PCHAR_PARAM (d1);
    uni_long data_len = UNI_LONG_PARAM (d2);
    snprintf (data, data_len, "Hello World!\n\nBest regards, %s",
              uni->get_uae_string());
}
Example Amiga program using the auto-generated wrapper functions (wrapper name "hwlib" chosen when generating the wrappers - tested using GCC 2.95.3 cross-compiler for m68k-amigaos):

Code:
#include "hwlib.h"

static char data[128];

int main (int argc, char *argv[])
{
    if (!hwlib_open ()) {
        printf ("error opening hwlib: %lx\n", hwlib_get_last_error ());
        return 1;
    }
    hwlib_hello_world (data, 128);
    printf ("%s\n", data);
    hwlib_close ();
    return 0;
}
The advantage of using the wrapper functions, besides ease of use, is that you also get parameter checking due to having proper C function prototypes, and the arguments are sent through the correct registers automatically

(You can of course just use uaenative.library directly, more or less like the old native interface - except you perform library jumps instead of an absolute jump).

Last edited by FrodeSolheim; 05 January 2014 at 11:09.
FrodeSolheim is offline  
 
Page generated in 0.05248 seconds with 9 queries