--- uae/src/uaelib.c 2018/04/24 16:42:13 1.1.1.4 +++ uae/src/uaelib.c 2018/04/24 17:18:34 1.1.1.13 @@ -14,27 +14,30 @@ #include #include -#include "config.h" #include "options.h" -#include "threaddep/penguin.h" +#include "threaddep/thread.h" #include "uae.h" #include "include/memory.h" #include "custom.h" -#include "readcpu.h" #include "newcpu.h" #include "xwin.h" +#include "traps.h" #include "autoconf.h" #include "disk.h" #include "debug.h" #include "gensound.h" #include "picasso96.h" +/* We don't get a numerical version from autoconf, but this is the only place + that wants it, and it doesn't matter - so cheat. */ +#define UAEVERSION 0x0826 + /* * Returns UAE Version */ static uae_u32 emulib_GetVersion (void) { - return version; + return UAEVERSION; } /* @@ -42,13 +45,13 @@ static uae_u32 emulib_GetVersion (void) */ static uae_u32 emulib_HardReset (void) { - uae_reset(); + uae_reset(1); return 0; } static uae_u32 emulib_Reset (void) { - uae_reset(); + uae_reset(0); return 0; } @@ -69,7 +72,8 @@ static uae_u32 emulib_EnableSound (uae_u */ static uae_u32 emulib_EnableJoystick (uae_u32 val) { - currprefs.fake_joystick = val; + currprefs.jport0 = val & 255; + currprefs.jport1 = (val >> 8) & 255; return 1; } @@ -83,7 +87,7 @@ static uae_u32 emulib_SetFrameRate (uae_ else if (val > 20) return 0; else { - currprefs.framerate = val; + currprefs.gfx_framerate = val; return 1; } } @@ -93,7 +97,7 @@ static uae_u32 emulib_SetFrameRate (uae_ */ static uae_u32 emulib_ChangeLanguage (uae_u32 which) { - if (which > 5) + if (which > 6) return 0; else { switch (which) { @@ -101,18 +105,21 @@ static uae_u32 emulib_ChangeLanguage (ua currprefs.keyboard_lang = KBD_LANG_US; break; case 1: - currprefs.keyboard_lang = KBD_LANG_DE; + currprefs.keyboard_lang = KBD_LANG_DK; break; case 2: - currprefs.keyboard_lang = KBD_LANG_SE; + currprefs.keyboard_lang = KBD_LANG_DE; break; case 3: - currprefs.keyboard_lang = KBD_LANG_FR; + currprefs.keyboard_lang = KBD_LANG_SE; break; case 4: - currprefs.keyboard_lang = KBD_LANG_IT; + currprefs.keyboard_lang = KBD_LANG_FR; break; case 5: + currprefs.keyboard_lang = KBD_LANG_IT; + break; + case 6: currprefs.keyboard_lang = KBD_LANG_ES; break; default: @@ -132,12 +139,12 @@ static uae_u32 emulib_ChgCMemSize (uae_u if (memsize != 0x80000 && memsize != 0x100000 && memsize != 0x200000) { memsize = 0x200000; - fprintf (stderr, "Unsupported chipmem size!\n"); + write_log ("Unsupported chipmem size!\n"); } - m68k_dreg(regs, 0) = 0; + m68k_dreg (regs, 0) = 0; currprefs.chipmem_size = memsize; - uae_reset(); + uae_reset(0); return 1; } @@ -150,12 +157,12 @@ static uae_u32 emulib_ChgSMemSize (uae_u if (memsize != 0x80000 && memsize != 0x100000 && memsize != 0x180000 && memsize != 0x1C0000) { memsize = 0; - fprintf (stderr, "Unsupported bogomem size!\n"); + write_log ("Unsupported bogomem size!\n"); } - m68k_dreg(regs, 0) = 0; + m68k_dreg (regs, 0) = 0; currprefs.bogomem_size = memsize; - uae_reset (); + uae_reset (0); return 1; } @@ -168,11 +175,11 @@ static uae_u32 emulib_ChgFMemSize (uae_u if (memsize != 0x100000 && memsize != 0x200000 && memsize != 0x400000 && memsize != 0x800000) { memsize = 0; - fprintf (stderr, "Unsupported fastmem size!\n"); + write_log ("Unsupported fastmem size!\n"); } - m68k_dreg(regs, 0) = 0; + m68k_dreg (regs, 0) = 0; currprefs.fastmem_size = memsize; - uae_reset (); + uae_reset (0); return 0; } @@ -214,13 +221,13 @@ static uae_u32 emulib_GetUaeConfig (uaec { int i,j; - put_long (place, version); + put_long (place, UAEVERSION); put_long (place + 4, allocated_chipmem); put_long (place + 8, allocated_bogomem); put_long (place + 12, allocated_fastmem); - put_long (place + 16, currprefs.framerate); + put_long (place + 16, currprefs.gfx_framerate); put_long (place + 20, currprefs.produce_sound); - put_long (place + 24, currprefs.fake_joystick); + put_long (place + 24, currprefs.jport0 | (currprefs.jport1 << 8)); put_long (place + 28, currprefs.keyboard_lang); if (disk_empty (0)) put_byte (place + 32, 0); @@ -286,6 +293,13 @@ static uae_u32 emulib_Debug (void) * and add that offset to the base address of the object. Now we've got code to execute. * * @@@ Brian: does anything actually use this yet? + * @@@ Bernd: Not yet. It needs to get much better. Should spawn off a seperate task to handle the + * function, and then somehow "signal" the Amiga caller that completion or error has + * occurred. I don't know how to do that, so right now it is a synchronous call. Yuck! + * Would be nice to implement jpg decompression functionality for the Amiga which used + * the UAE Host to do all the work, for example. + * @@@ Brian: I disabled it to prevent people from starting to use it - if that happens, we're + * stuck with this. */ static uae_u32 FindFunctionInObject (uae_u8 *objectptr) { @@ -299,44 +313,47 @@ static uae_u32 FindFunctionInObject (uae return 0; } -#define CREATE_NATIVE_FUNC_PTR uae_u32 (* native_func)( uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, \ +#define CREATE_NATIVE_FUNC_PTR uae_u32 (* native_func) (uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, \ uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32) #define SET_NATIVE_FUNC(x) native_func = (uae_u32 (*)(uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32))(x) -#define CALL_NATIVE_FUNC( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 ) if(native_func) native_func( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 ) +#define CALL_NATIVE_FUNC(d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6) if(native_func) native_func (d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6) /* A0 - Contains a ptr to the native .obj data. This ptr is Amiga-based. */ /* We simply find the first function in this .obj data, and execute it. */ static uae_u32 emulib_ExecuteNativeCode (void) { - uaecptr object_AAM = m68k_areg( regs, 0 ); - uae_u32 d1 = m68k_dreg( regs, 1 ); - uae_u32 d2 = m68k_dreg( regs, 2 ); - uae_u32 d3 = m68k_dreg( regs, 3 ); - uae_u32 d4 = m68k_dreg( regs, 4 ); - uae_u32 d5 = m68k_dreg( regs, 5 ); - uae_u32 d6 = m68k_dreg( regs, 6 ); - uae_u32 d7 = m68k_dreg( regs, 7 ); - uae_u32 a1 = m68k_areg( regs, 1 ); - uae_u32 a2 = m68k_areg( regs, 2 ); - uae_u32 a3 = m68k_areg( regs, 3 ); - uae_u32 a4 = m68k_areg( regs, 4 ); - uae_u32 a5 = m68k_areg( regs, 5 ); - uae_u32 a6 = m68k_areg( regs, 6 ); +#if 0 + uaecptr object_AAM = m68k_areg (regs, 0); + uae_u32 d1 = m68k_dreg (regs, 1); + uae_u32 d2 = m68k_dreg (regs, 2); + uae_u32 d3 = m68k_dreg (regs, 3); + uae_u32 d4 = m68k_dreg (regs, 4); + uae_u32 d5 = m68k_dreg (regs, 5); + uae_u32 d6 = m68k_dreg (regs, 6); + uae_u32 d7 = m68k_dreg (regs, 7); + uae_u32 a1 = m68k_areg (regs, 1); + uae_u32 a2 = m68k_areg (regs, 2); + uae_u32 a3 = m68k_areg (regs, 3); + uae_u32 a4 = m68k_areg (regs, 4); + uae_u32 a5 = m68k_areg (regs, 5); + uae_u32 a6 = m68k_areg (regs, 6); uae_u8* object_UAM = NULL; CREATE_NATIVE_FUNC_PTR; - if( get_mem_bank( object_AAM ).check( object_AAM, 1 ) ) - object_UAM = get_mem_bank( object_AAM).xlateaddr( object_AAM ); + if (get_mem_bank (object_AAM).check( object_AAM, 1)) + object_UAM = get_mem_bank (object_AAM).xlateaddr (object_AAM); - if( object_UAM ) + if (object_UAM) { - SET_NATIVE_FUNC( FindFunctionInObject( object_UAM ) ); - CALL_NATIVE_FUNC( d1, d2, d3, d4, d5, d6, d7, a1, a2, a3, a4, a5, a6); + SET_NATIVE_FUNC (FindFunctionInObject (object_UAM)); + CALL_NATIVE_FUNC (d1, d2, d3, d4, d5, d6, d7, a1, a2, a3, a4, a5, a6); } return 1; +#endif + return 0; } -static uae_u32 uaelib_demux (void) +static uae_u32 uaelib_demux (TrapContext *dummy) { #define ARG0 (get_long (m68k_areg (regs, 7) + 4)) #define ARG1 (get_long (m68k_areg (regs, 7) + 8)) @@ -395,7 +412,7 @@ static uae_u32 uaelib_demux (void) void emulib_install (void) { uaecptr a = here (); - org (0xF0FF60); + org (RTAREA_BASE + 0xFF60); calltrap (deftrap (uaelib_demux)); dw (RTS); org (a);