]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
2020b14
authorToni Wilen <twilen@winuae.net>
Mon, 1 Mar 2010 17:40:24 +0000 (19:40 +0200)
committerToni Wilen <twilen@winuae.net>
Mon, 1 Mar 2010 17:40:24 +0000 (19:40 +0200)
24 files changed:
custom.cpp
debug.cpp
disk.cpp
expansion.cpp
fpp.cpp
gfxutil.cpp
include/custom.h
include/events_jit.h
include/memory.h
include/newcpu.h
include/sysdeps.h
jit/compemu_support.cpp
memory.cpp
newcpu.cpp
od-win32/ahidsound_new.cpp
od-win32/direct3d.cpp
od-win32/picasso96_win.cpp
od-win32/srcrelease.cmd
od-win32/unicode.cpp
od-win32/win32.h
od-win32/win32_scaler.cpp
od-win32/win32gfx.cpp
od-win32/win32gui.cpp
od-win32/winuae_msvc10/winuae_msvc.vcxproj

index a9384a65d4a001ddd80d27085a1a7e7efdbd9ead..84e75b92ac31a3821162296311c1c769dae4a8ee 100644 (file)
@@ -3396,15 +3396,15 @@ static void INTENA (uae_u16 v)
        uae_u16 old = intena;
        setclr (&intena, v);
 
-       if (old == intena) {
-               doint ();
+       if (!(v & 0x8000) && old == intena)
                return;
-       }
-
-       if (use_eventmode (v))
+       if (use_eventmode (v)) {
                event2_newevent_xx (-1, INT_PROCESSING_DELAY, intena, send_intena_do);
-       else
-               send_intena_do (intena);
+       } else {
+               intena_internal = intena;
+               if (v & 0x8000)
+                       doint ();
+       }
 #if 0
        if (v & 0x40)
                write_log (L"INTENA %04X (%04X) %p\n", intena, v, M68K_GETPC);
@@ -3426,17 +3426,19 @@ void INTREQ_0 (uae_u16 v)
        uae_u16 old = intreq;
        setclr (&intreq, v);
 
+       if (!(v & 0x8000) && old == intreq)
+               return;
+
        if (v & (0x0080 | 0x0100 | 0x0200 | 0x0400))
                audio_update_irq (v);
 
-       if (old == intreq) {
-               doint ();
-               return;
-       }
-       if (use_eventmode (v))
+       if (use_eventmode (v)) {
                event2_newevent_xx (-1, INT_PROCESSING_DELAY, intreq, send_intreq_do);
-       else
-               send_intreq_do (intreq);
+       } else {
+               intreq_internal = intreq;
+               if (v & 0x8000)
+                       doint ();
+       }
 }
 
 void INTREQ (uae_u16 data)
index 0650c64868678817a6948dbf0dbdda8032d8316a..adcf720c13e066d77edf71ddd11c57b4ebe68476 100644 (file)
--- a/debug.cpp
+++ b/debug.cpp
@@ -3545,8 +3545,9 @@ void mmu_do_hit (void)
        put_long (m68k_areg (regs, 7), get_long (p - 4));
        m68k_areg (regs, 7) -= 2;
        put_word (m68k_areg (regs, 7), mmur.sr);
-
+#ifdef JIT
        set_special(SPCFLAG_END_COMPILE);
+#endif
 }
 
 static void mmu_do_hit_pre (struct mmudata *md, uaecptr addr, int size, int rwi, uae_u32 v)
index 5eccc7e77884144106ba9eb4557676afd8b93bea..4d27ed54e1ce3ffae73e74e6578166bd0ec3f288 100644 (file)
--- a/disk.cpp
+++ b/disk.cpp
@@ -3578,3 +3578,63 @@ uae_u8 *save_floppy(int *len, uae_u8 *dstptr)
 }
 
 #endif /* SAVESTATE */
+
+static int getnextdisk (TCHAR *img)
+{
+       TCHAR *ext, *p, *dst;
+       int num = -1;
+
+       dst = NULL;
+       for (;;) {
+               // disk x of y
+               p = _tcsstr (img, L"disk ");
+               if (p && _istdigit (p[5])) {
+                       num = _tstoi (p + 5);
+                       dst = p + 5;
+               } else {
+                       ext = _tcsrchr (img, '.');
+                       if (!ext || ext - img < 4)
+                               break;
+                       // name_<non numeric character>x.ext
+                       if (ext[-3] == '_' && !_istdigit (ext[-2]) && _istdigit (ext[-1])) {
+                               num = _tstoi (ext - 1);
+                               dst = ext - 1;
+                       // name_x.ext
+                       } else if (ext[-2] == '_' && _istdigit (ext[-1])) {
+                               num = _tstoi (ext - 1);
+                               dst = ext - 1;
+                       // name_a.ext
+                       } else if (ext[-2] == '_' && ext[-1] >= 'a' && ext[-1] <= 'z') {
+                               num = ext[-1] - 'a';
+                               dst = ext - 1;
+                       }
+               }
+               break;
+       }
+       if (num <= 0 || num >= 19)
+               return 0;
+       if (num > 9)
+               return 0;
+       if (num == 9)
+               num = 0;
+       if (!_istdigit (dst[0]))
+               dst[0] = num + 'a';
+       else
+               dst[0] = num + '0';
+       return 0;
+}
+
+int disk_next (int drive)
+{
+       TCHAR img[MAX_DPATH];
+
+        _tcscpy (img, currprefs.df[drive]);
+        to_lower (img, sizeof img / sizeof (TCHAR));
+
+       if (img[0])
+               return 0;
+       getnextdisk (img);
+       return 1;
+}
+
+
index 407542829c189eae7264edd77b50af0693a32ff0..46702b2c498e82f5253396a2a5099497e27c3353 100644 (file)
@@ -1029,7 +1029,7 @@ uaecptr p96ram_start;
 static void expamem_map_gfxcard (void)
 {
        gfxmem_start = (expamem_hi | (expamem_lo >> 4)) << 16;
-       map_banks (&gfxmem_bankx, gfxmem_start >> 16, allocated_gfxmem >> 16, allocated_gfxmem);
+       map_banks (&gfxmem_bank, gfxmem_start >> 16, allocated_gfxmem >> 16, allocated_gfxmem);
        write_log (L"UAEGFX-card: mapped @$%lx, %d MB RTG RAM\n", gfxmem_start, allocated_gfxmem / 0x100000);
 }
 
@@ -1163,7 +1163,7 @@ static void allocate_expamem (void)
        z3fastmem_bank.baseaddr = z3fastmem;
        z3fastmem2_bank.baseaddr = z3fastmem2;
        fastmem_bank.baseaddr = fastmemory;
-       gfxmem_bankx.baseaddr = gfxmemory;
+       gfxmem_bank.baseaddr = gfxmemory;
 
 #ifdef SAVESTATE
        if (savestate_state == STATE_RESTORE) {
@@ -1185,7 +1185,7 @@ static void allocate_expamem (void)
 #ifdef PICASSO96
                if (allocated_gfxmem > 0 && gfxmem_start > 0) {
                        restore_ram (p96_filepos, gfxmemory);
-                       map_banks (&gfxmem_bankx, gfxmem_start >> 16, currprefs.gfxmem_size >> 16,
+                       map_banks (&gfxmem_bank, gfxmem_start >> 16, currprefs.gfxmem_size >> 16,
                                allocated_gfxmem);
                }
 #endif
diff --git a/fpp.cpp b/fpp.cpp
index d819c92ea9a8c83ccfb3346f7c35495676d4453e..94c4f4976a01d15d2e563ec75a176ebdd2dea2cd 100644 (file)
--- a/fpp.cpp
+++ b/fpp.cpp
@@ -242,7 +242,9 @@ static void fpu_op_illg (uae_u32 opcode, int pcoffset)
                        write_log (L"68040/060 FPU disabled exception PC=%x\n", newpc);
                        newpc = get_long_fpu (regs.vbr + 11 * 4);
                        m68k_setpc (newpc);
+#ifdef JIT
                        set_special (SPCFLAG_END_COMPILE);
+#endif
                        return;
        }
        op_illg (opcode);
index 7c9ce6c6f19394ba071a76c1572782dc791044ea..22355738e3408620ce16230ee626e411cac47d31 100644 (file)
@@ -69,6 +69,8 @@ unsigned int doMask256 (int p, int bits, int shift)
        * shift to align msb with mask, and apply mask */
 
        unsigned long val = p * 0x01010101UL;
+       if (bits == 0)
+               return 0;
        val >>= (32 - bits);
        val <<= shift;
 
index f351c28495ecd0b4f76cd3d24ef6a43090b5a6f7..27b807cd347d41b7ada15713b56cae75509b9d96 100644 (file)
@@ -67,7 +67,9 @@ STATIC_INLINE int dmaen (unsigned int dmamask)
 #define SPCFLAG_ACTION_REPLAY 2048
 #define SPCFLAG_TRAP 4096 /* enforcer-hack */
 #define SPCFLAG_MODE_CHANGE 8192
+#ifdef JIT
 #define SPCFLAG_END_COMPILE 16384
+#endif
 
 extern uae_u16 adkcon;
 
index e01530dc3c276ed424eb94fca1095eb310b4569c..2e4da10bef1ace0e64f298e22fe8adc61ea7f3e8 100644 (file)
@@ -23,12 +23,23 @@ STATIC_INLINE void events_schedule (void)
        nextevent = currcycle + mintime;
 }
 
+#ifdef JIT
+extern uae_u8* compiled_code;
+#endif
 extern signed long pissoff;
 
 STATIC_INLINE void cycles_do_special (void)
 {
-       if (pissoff >= 0)
-               pissoff = -1;
+#ifdef JIT
+       if (compiled_code) {
+               if (pissoff >= 0)
+                       pissoff = -1;
+       } else {
+               pissoff = 0;
+       }
+#else
+       pissoff = 0;
+#endif
 }
 
 STATIC_INLINE void do_extra_cycles (unsigned long cycles_to_add)
index 0a4f02ae200d885bd57dd7b832fcd57070648ed2..fdad6ea0f39f3fd4192da68ad9df4e4b26f8533b 100644 (file)
@@ -116,7 +116,7 @@ extern addrbank cia_bank;
 extern addrbank rtarea_bank;
 extern addrbank expamem_bank;
 extern addrbank fastmem_bank;
-extern addrbank gfxmem_bank, gfxmem_bankx;
+extern addrbank gfxmem_bank;
 extern addrbank gayle_bank;
 extern addrbank gayle2_bank;
 extern addrbank mbres_bank;
index 6be54dfb0805c653039044fb7d51c9a8b002394e..a5eb228e75e55f14209b02189fd2e3b953cbd386 100644 (file)
@@ -175,14 +175,10 @@ STATIC_INLINE uae_u32 munge24 (uae_u32 x)
 extern int mmu_enabled, mmu_triggered;
 extern int cpu_cycles;
 extern int cpucycleunit;
-#ifdef JIT
-extern uae_u8* compiled_code;
-#endif
 STATIC_INLINE void set_special (uae_u32 x)
 {
        regs.spcflags |= x;
-       if (compiled_code)
-               cycles_do_special ();
+       cycles_do_special ();
 }
 
 STATIC_INLINE void unset_special (uae_u32 x)
index 4382cb72e63dea46653203ac83c6a41ba4188ca6..e500a366cae79b5afc6ba585f1db02b34744e46a 100644 (file)
@@ -243,7 +243,8 @@ extern TCHAR *au_fs_copy (TCHAR *dst, int maxlen, const char *src);
 extern char *uutf8 (const TCHAR *s);
 extern TCHAR *utf8u (const char *s);
 extern void unicode_init (void);
-
+extern void to_lower (TCHAR *s, int len);
+extern void to_upper (TCHAR *s, int len);
 /* We can only rely on GNU C getting enums right. Mickeysoft VSC++ is known
  * to have problems, and it's likely that other compilers choke too. */
 #ifdef __GNUC__
index ffaf507938957b4b8a744d07f68507a39480dcad..5dd4dafff4376e6b4ad9cf48371d5bbc7155b84c 100644 (file)
@@ -72,9 +72,9 @@ extern unsigned long foink3;
 extern unsigned long foink;
 
 /* The 68k only ever executes from even addresses. So right now, we
-   waste half the entries in this array
-   UPDATE: We now use those entries to store the start of the linked
-   lists that we maintain for each hash result. */
+waste half the entries in this array
+UPDATE: We now use those entries to store the start of the linked
+lists that we maintain for each hash result. */
 static cacheline cache_tags[TAGSIZE];
 static int letit=0;
 static blockinfo* hold_bi[MAX_HOLD_BI];
@@ -127,425 +127,425 @@ static uae_u8 *popallspace;
 uae_u32 m68k_pc_offset;
 
 /* Some arithmetic operations can be optimized away if the operands
-   are known to be constant. But that's only a good idea when the
-   side effects they would have on the flags are not important. This
-   variable indicates whether we need the side effects or not
+are known to be constant. But that's only a good idea when the
+side effects they would have on the flags are not important. This
+variable indicates whether we need the side effects or not
 */
 uae_u32 needflags=0;
 
 /* Flag handling is complicated.
 
-   x86 instructions create flags, which quite often are exactly what we
-   want. So at times, the "68k" flags are actually in the x86 flags.
+x86 instructions create flags, which quite often are exactly what we
+want. So at times, the "68k" flags are actually in the x86 flags.
 
-   Then again, sometimes we do x86 instructions that clobber the x86
-   flags, but don't represent a corresponding m68k instruction. In that
-   case, we have to save them.
+Then again, sometimes we do x86 instructions that clobber the x86
+flags, but don't represent a corresponding m68k instruction. In that
+case, we have to save them.
 
-   We used to save them to the stack, but now store them back directly
-   into the regflags.cznv of the traditional emulation. Thus some odd
-   names.
+We used to save them to the stack, but now store them back directly
+into the regflags.cznv of the traditional emulation. Thus some odd
+names.
 
-   So flags can be in either of two places (used to be three; boy were
-   things complicated back then!); And either place can contain either
-   valid flags or invalid trash (and on the stack, there was also the
-   option of "nothing at all", now gone). A couple of variables keep
-   track of the respective states.
+So flags can be in either of two places (used to be three; boy were
+things complicated back then!); And either place can contain either
+valid flags or invalid trash (and on the stack, there was also the
+option of "nothing at all", now gone). A couple of variables keep
+track of the respective states.
 
-   To make things worse, we might or might not be interested in the flags.
-   by default, we are, but a call to dont_care_flags can change that
-   until the next call to live_flags. If we are not, pretty much whatever
-   is in the register and/or the native flags is seen as valid.
+To make things worse, we might or might not be interested in the flags.
+by default, we are, but a call to dont_care_flags can change that
+until the next call to live_flags. If we are not, pretty much whatever
+is in the register and/or the native flags is seen as valid.
 */
 
 
 STATIC_INLINE blockinfo* get_blockinfo(uae_u32 cl)
 {
-    return cache_tags[cl+1].bi;
+       return cache_tags[cl+1].bi;
 }
 
 STATIC_INLINE blockinfo* get_blockinfo_addr(void* addr)
 {
-    blockinfo*  bi=get_blockinfo(cacheline(addr));
+       blockinfo*  bi=get_blockinfo(cacheline(addr));
 
-    while (bi) {
-       if (bi->pc_p==addr)
-           return bi;
-       bi=bi->next_same_cl;
-    }
-    return NULL;
+       while (bi) {
+               if (bi->pc_p==addr)
+                       return bi;
+               bi=bi->next_same_cl;
+       }
+       return NULL;
 }
 
 
 /*******************************************************************
- * All sorts of list related functions for all of the lists        *
- *******************************************************************/
+* All sorts of list related functions for all of the lists        *
+*******************************************************************/
 
 STATIC_INLINE void remove_from_cl_list(blockinfo* bi)
 {
-    uae_u32 cl=cacheline(bi->pc_p);
+       uae_u32 cl=cacheline(bi->pc_p);
 
-    if (bi->prev_same_cl_p)
-       *(bi->prev_same_cl_p)=bi->next_same_cl;
-    if (bi->next_same_cl)
-       bi->next_same_cl->prev_same_cl_p=bi->prev_same_cl_p;
-    if (cache_tags[cl+1].bi)
-       cache_tags[cl].handler=cache_tags[cl+1].bi->handler_to_use;
-    else
-       cache_tags[cl].handler=(cpuop_func*)popall_execute_normal;
+       if (bi->prev_same_cl_p)
+               *(bi->prev_same_cl_p)=bi->next_same_cl;
+       if (bi->next_same_cl)
+               bi->next_same_cl->prev_same_cl_p=bi->prev_same_cl_p;
+       if (cache_tags[cl+1].bi)
+               cache_tags[cl].handler=cache_tags[cl+1].bi->handler_to_use;
+       else
+               cache_tags[cl].handler=(cpuop_func*)popall_execute_normal;
 }
 
 STATIC_INLINE void remove_from_list(blockinfo* bi)
 {
-    if (bi->prev_p)
-       *(bi->prev_p)=bi->next;
-    if (bi->next)
-       bi->next->prev_p=bi->prev_p;
+       if (bi->prev_p)
+               *(bi->prev_p)=bi->next;
+       if (bi->next)
+               bi->next->prev_p=bi->prev_p;
 }
 
 STATIC_INLINE void remove_from_lists(blockinfo* bi)
 {
-    remove_from_list(bi);
-    remove_from_cl_list(bi);
+       remove_from_list(bi);
+       remove_from_cl_list(bi);
 }
 
 STATIC_INLINE void add_to_cl_list(blockinfo* bi)
 {
-    uae_u32 cl=cacheline(bi->pc_p);
+       uae_u32 cl=cacheline(bi->pc_p);
 
-    if (cache_tags[cl+1].bi)
-       cache_tags[cl+1].bi->prev_same_cl_p=&(bi->next_same_cl);
-    bi->next_same_cl=cache_tags[cl+1].bi;
+       if (cache_tags[cl+1].bi)
+               cache_tags[cl+1].bi->prev_same_cl_p=&(bi->next_same_cl);
+       bi->next_same_cl=cache_tags[cl+1].bi;
 
-    cache_tags[cl+1].bi=bi;
-    bi->prev_same_cl_p=&(cache_tags[cl+1].bi);
+       cache_tags[cl+1].bi=bi;
+       bi->prev_same_cl_p=&(cache_tags[cl+1].bi);
 
-    cache_tags[cl].handler=bi->handler_to_use;
+       cache_tags[cl].handler=bi->handler_to_use;
 }
 
 STATIC_INLINE void raise_in_cl_list(blockinfo* bi)
 {
-    remove_from_cl_list(bi);
-    add_to_cl_list(bi);
+       remove_from_cl_list(bi);
+       add_to_cl_list(bi);
 }
 
 STATIC_INLINE void add_to_active(blockinfo* bi)
 {
-    if (active)
-       active->prev_p=&(bi->next);
-    bi->next=active;
+       if (active)
+               active->prev_p=&(bi->next);
+       bi->next=active;
 
-    active=bi;
-    bi->prev_p=&active;
+       active=bi;
+       bi->prev_p=&active;
 }
 
 STATIC_INLINE void add_to_dormant(blockinfo* bi)
 {
-    if (dormant)
-       dormant->prev_p=&(bi->next);
-    bi->next=dormant;
+       if (dormant)
+               dormant->prev_p=&(bi->next);
+       bi->next=dormant;
 
-    dormant=bi;
-    bi->prev_p=&dormant;
+       dormant=bi;
+       bi->prev_p=&dormant;
 }
 
 STATIC_INLINE void remove_dep(dependency* d)
 {
-    if (d->prev_p)
-       *(d->prev_p)=d->next;
-    if (d->next)
-       d->next->prev_p=d->prev_p;
-    d->prev_p=NULL;
-    d->next=NULL;
+       if (d->prev_p)
+               *(d->prev_p)=d->next;
+       if (d->next)
+               d->next->prev_p=d->prev_p;
+       d->prev_p=NULL;
+       d->next=NULL;
 }
 
 /* This block's code is about to be thrown away, so it no longer
-   depends on anything else */
+depends on anything else */
 STATIC_INLINE void remove_deps(blockinfo* bi)
 {
-    remove_dep(&(bi->dep[0]));
-    remove_dep(&(bi->dep[1]));
+       remove_dep(&(bi->dep[0]));
+       remove_dep(&(bi->dep[1]));
 }
 
 STATIC_INLINE void adjust_jmpdep(dependency* d, void* a)
 {
-    *(d->jmp_off)=(uae_u32)a-((uae_u32)d->jmp_off+4);
+       *(d->jmp_off)=(uae_u32)a-((uae_u32)d->jmp_off+4);
 }
 
 /********************************************************************
- * Soft flush handling support functions                            *
- ********************************************************************/
+* Soft flush handling support functions                            *
+********************************************************************/
 
 STATIC_INLINE void set_dhtu(blockinfo* bi, void* dh)
 {
-    //write_log (L"JIT: bi is %p\n",bi);
-    if (dh!=bi->direct_handler_to_use) {
-       dependency* x=bi->deplist;
-       //write_log (L"JIT: bi->deplist=%p\n",bi->deplist);
-       while (x) {
-           //write_log (L"JIT: x is %p\n",x);
-           //write_log (L"JIT: x->next is %p\n",x->next);
-           //write_log (L"JIT: x->prev_p is %p\n",x->prev_p);
-
-           if (x->jmp_off) {
-               adjust_jmpdep(x,dh);
-           }
-           x=x->next;
+       //write_log (L"JIT: bi is %p\n",bi);
+       if (dh!=bi->direct_handler_to_use) {
+               dependency* x=bi->deplist;
+               //write_log (L"JIT: bi->deplist=%p\n",bi->deplist);
+               while (x) {
+                       //write_log (L"JIT: x is %p\n",x);
+                       //write_log (L"JIT: x->next is %p\n",x->next);
+                       //write_log (L"JIT: x->prev_p is %p\n",x->prev_p);
+
+                       if (x->jmp_off) {
+                               adjust_jmpdep(x,dh);
+                       }
+                       x=x->next;
+               }
+               bi->direct_handler_to_use=(cpuop_func*)dh;
        }
-       bi->direct_handler_to_use=(cpuop_func*)dh;
-    }
 }
 
 STATIC_INLINE void invalidate_block(blockinfo* bi)
 {
-    int i;
+       int i;
 
-    bi->optlevel=0;
-    bi->count=currprefs.optcount[0]-1;
-    bi->handler=NULL;
-    bi->handler_to_use=(cpuop_func*)popall_execute_normal;
-    bi->direct_handler=NULL;
-    set_dhtu(bi,bi->direct_pen);
-    bi->needed_flags=0xff;
+       bi->optlevel=0;
+       bi->count=currprefs.optcount[0]-1;
+       bi->handler=NULL;
+       bi->handler_to_use=(cpuop_func*)popall_execute_normal;
+       bi->direct_handler=NULL;
+       set_dhtu(bi,bi->direct_pen);
+       bi->needed_flags=0xff;
 
-    for (i=0;i<2;i++) {
-       bi->dep[i].jmp_off=NULL;
-       bi->dep[i].target=NULL;
-    }
-    remove_deps(bi);
+       for (i=0;i<2;i++) {
+               bi->dep[i].jmp_off=NULL;
+               bi->dep[i].target=NULL;
+       }
+       remove_deps(bi);
 }
 
 STATIC_INLINE void create_jmpdep(blockinfo* bi, int i, uae_u32* jmpaddr, uae_u32 target)
 {
-    blockinfo*  tbi=get_blockinfo_addr((void*)target);
+       blockinfo*  tbi=get_blockinfo_addr((void*)target);
 
-    Dif(!tbi) {
-       jit_abort (L"JIT: Could not create jmpdep!\n");
-    }
-    bi->dep[i].jmp_off=jmpaddr;
-    bi->dep[i].target=tbi;
-    bi->dep[i].next=tbi->deplist;
-    if (bi->dep[i].next)
-       bi->dep[i].next->prev_p=&(bi->dep[i].next);
-    bi->dep[i].prev_p=&(tbi->deplist);
-    tbi->deplist=&(bi->dep[i]);
+       Dif(!tbi) {
+               jit_abort (L"JIT: Could not create jmpdep!\n");
+       }
+       bi->dep[i].jmp_off=jmpaddr;
+       bi->dep[i].target=tbi;
+       bi->dep[i].next=tbi->deplist;
+       if (bi->dep[i].next)
+               bi->dep[i].next->prev_p=&(bi->dep[i].next);
+       bi->dep[i].prev_p=&(tbi->deplist);
+       tbi->deplist=&(bi->dep[i]);
 }
 
 STATIC_INLINE void big_to_small_state(bigstate* b, smallstate* s)
 {
-    int i;
-    int count=0;
-
-    for (i=0;i<N_REGS;i++) {
-       s->nat[i].validsize=0;
-       s->nat[i].dirtysize=0;
-       if (b->nat[i].nholds) {
-           int index=b->nat[i].nholds-1;
-           int r=b->nat[i].holds[index];
-           s->nat[i].holds=r;
-           s->nat[i].validsize=b->state[r].validsize;
-           s->nat[i].dirtysize=b->state[r].dirtysize;
-           count++;
+       int i;
+       int count=0;
+
+       for (i=0;i<N_REGS;i++) {
+               s->nat[i].validsize=0;
+               s->nat[i].dirtysize=0;
+               if (b->nat[i].nholds) {
+                       int index=b->nat[i].nholds-1;
+                       int r=b->nat[i].holds[index];
+                       s->nat[i].holds=r;
+                       s->nat[i].validsize=b->state[r].validsize;
+                       s->nat[i].dirtysize=b->state[r].dirtysize;
+                       count++;
+               }
+       }
+       write_log (L"JIT: count=%d\n",count);
+       for (i=0;i<N_REGS;i++) {  // FIXME --- don't do dirty yet
+               s->nat[i].dirtysize=0;
        }
-    }
-    write_log (L"JIT: count=%d\n",count);
-    for (i=0;i<N_REGS;i++) {  // FIXME --- don't do dirty yet
-       s->nat[i].dirtysize=0;
-    }
 }
 
 STATIC_INLINE void attached_state(blockinfo* bi)
 {
-    bi->havestate=1;
-    if (bi->direct_handler_to_use==bi->direct_handler)
-       set_dhtu(bi,bi->direct_pen);
-    bi->direct_handler=bi->direct_pen;
-    bi->status=BI_TARGETTED;
+       bi->havestate=1;
+       if (bi->direct_handler_to_use==bi->direct_handler)
+               set_dhtu(bi,bi->direct_pen);
+       bi->direct_handler=bi->direct_pen;
+       bi->status=BI_TARGETTED;
 }
 
 STATIC_INLINE blockinfo* get_blockinfo_addr_new(void* addr, int setstate)
 {
-    blockinfo*  bi=get_blockinfo_addr(addr);
-    int i;
+       blockinfo*  bi=get_blockinfo_addr(addr);
+       int i;
 
 #if USE_OPTIMIZER
-    if (reg_alloc_run)
-       return NULL;
+       if (reg_alloc_run)
+               return NULL;
 #endif
-    if (!bi) {
-       for (i=0;i<MAX_HOLD_BI && !bi;i++) {
-           if (hold_bi[i]) {
-               uae_u32 cl=cacheline(addr);
-
-               bi=hold_bi[i];
-               hold_bi[i]=NULL;
-               bi->pc_p=(uae_u8*)addr;
-               invalidate_block(bi);
-               add_to_active(bi);
-               add_to_cl_list(bi);
-
-           }
+       if (!bi) {
+               for (i=0;i<MAX_HOLD_BI && !bi;i++) {
+                       if (hold_bi[i]) {
+                               uae_u32 cl=cacheline(addr);
+
+                               bi=hold_bi[i];
+                               hold_bi[i]=NULL;
+                               bi->pc_p=(uae_u8*)addr;
+                               invalidate_block(bi);
+                               add_to_active(bi);
+                               add_to_cl_list(bi);
+
+                       }
+               }
+       }
+       if (!bi) {
+               jit_abort (L"JIT: Looking for blockinfo, can't find free one\n");
        }
-    }
-    if (!bi) {
-       jit_abort (L"JIT: Looking for blockinfo, can't find free one\n");
-    }
 
 #if USE_MATCHSTATE
-    if (setstate &&
-       !bi->havestate) {
-       big_to_small_state(&live,&(bi->env));
-       attached_state(bi);
-    }
+       if (setstate &&
+               !bi->havestate) {
+                       big_to_small_state(&live,&(bi->env));
+                       attached_state(bi);
+       }
 #endif
-    return bi;
+       return bi;
 }
 
 static void prepare_block(blockinfo* bi);
 
 STATIC_INLINE void alloc_blockinfos(void)
 {
-    int i;
-    blockinfo* bi;
+       int i;
+       blockinfo* bi;
 
-    for (i=0;i<MAX_HOLD_BI;i++) {
-       if (hold_bi[i])
-           return;
-       bi=hold_bi[i]=(blockinfo*)current_compile_p;
-       current_compile_p+=sizeof(blockinfo);
+       for (i=0;i<MAX_HOLD_BI;i++) {
+               if (hold_bi[i])
+                       return;
+               bi=hold_bi[i]=(blockinfo*)current_compile_p;
+               current_compile_p+=sizeof(blockinfo);
 
-       prepare_block(bi);
-    }
+               prepare_block(bi);
+       }
 }
 
 /********************************************************************
- * Preferences handling. This is just a convenient place to put it  *
- ********************************************************************/
+* Preferences handling. This is just a convenient place to put it  *
+********************************************************************/
 extern int have_done_picasso;
 
 int check_prefs_changed_comp (void)
 {
-    int changed = 0;
-    static int cachesize_prev, comptrust_prev, canbang_prev;
-
-    if (currprefs.comptrustbyte != changed_prefs.comptrustbyte ||
-       currprefs.comptrustword != changed_prefs.comptrustword ||
-       currprefs.comptrustlong != changed_prefs.comptrustlong ||
-       currprefs.comptrustnaddr!= changed_prefs.comptrustnaddr ||
-       currprefs.compnf != changed_prefs.compnf ||
-       currprefs.comp_hardflush != changed_prefs.comp_hardflush ||
-       currprefs.comp_constjump != changed_prefs.comp_constjump ||
-       currprefs.comp_oldsegv != changed_prefs.comp_oldsegv ||
-       currprefs.compfpu != changed_prefs.compfpu ||
-       currprefs.fpu_strict != changed_prefs.fpu_strict)
-       changed = 1;
-
-    currprefs.comptrustbyte = changed_prefs.comptrustbyte;
-    currprefs.comptrustword = changed_prefs.comptrustword;
-    currprefs.comptrustlong = changed_prefs.comptrustlong;
-    currprefs.comptrustnaddr= changed_prefs.comptrustnaddr;
-    currprefs.compnf = changed_prefs.compnf;
-    currprefs.comp_hardflush = changed_prefs.comp_hardflush;
-    currprefs.comp_constjump = changed_prefs.comp_constjump;
-    currprefs.comp_oldsegv = changed_prefs.comp_oldsegv;
-    currprefs.compfpu = changed_prefs.compfpu;
-    currprefs.fpu_strict = changed_prefs.fpu_strict;
-
-    if (currprefs.cachesize != changed_prefs.cachesize) {
-       if (currprefs.cachesize && !changed_prefs.cachesize) {
-           cachesize_prev = currprefs.cachesize;
-           comptrust_prev = currprefs.comptrustbyte;
-           canbang_prev = canbang;
-       } else if (!currprefs.cachesize && changed_prefs.cachesize == cachesize_prev) {
-           changed_prefs.comptrustbyte = currprefs.comptrustbyte = comptrust_prev;
-           changed_prefs.comptrustword = currprefs.comptrustword = comptrust_prev;
-           changed_prefs.comptrustlong = currprefs.comptrustlong = comptrust_prev;
-           changed_prefs.comptrustnaddr = currprefs.comptrustnaddr = comptrust_prev;
-       }
-       currprefs.cachesize = changed_prefs.cachesize;
-       alloc_cache();
-       changed = 1;
-    }
-    if (!candirect)
-       canbang = 0;
-
-    // Turn off illegal-mem logging when using JIT...
-    if(currprefs.cachesize)
-       currprefs.illegal_mem = changed_prefs.illegal_mem;// = 0;
-
-    currprefs.comp_midopt = changed_prefs.comp_midopt;
-    currprefs.comp_lowopt = changed_prefs.comp_lowopt;
-
-    if ((!canbang || !currprefs.cachesize) && currprefs.comptrustbyte != 1) {
-       // Set all of these to indirect when canbang == 0
-       // Basically, set the compforcesettings option...
-       currprefs.comptrustbyte = 1;
-       currprefs.comptrustword = 1;
-       currprefs.comptrustlong = 1;
-       currprefs.comptrustnaddr= 1;
-
-       changed_prefs.comptrustbyte = 1;
-       changed_prefs.comptrustword = 1;
-       changed_prefs.comptrustlong = 1;
-       changed_prefs.comptrustnaddr= 1;
-
-       changed = 1;
-
-       if (currprefs.cachesize)
-           write_log (L"JIT: Reverting to \"indirect\" access, because canbang is zero!\n");
-    }
-
-    if (changed)
-       write_log (L"JIT: cache=%d. b=%d w=%d l=%d fpu=%d nf=%d const=%d hard=%d\n",
-           currprefs.cachesize,
-           currprefs.comptrustbyte, currprefs.comptrustword, currprefs.comptrustlong, 
-           currprefs.compfpu, currprefs.compnf, currprefs.comp_constjump, currprefs.comp_hardflush);
+       int changed = 0;
+       static int cachesize_prev, comptrust_prev, canbang_prev;
+
+       if (currprefs.comptrustbyte != changed_prefs.comptrustbyte ||
+               currprefs.comptrustword != changed_prefs.comptrustword ||
+               currprefs.comptrustlong != changed_prefs.comptrustlong ||
+               currprefs.comptrustnaddr!= changed_prefs.comptrustnaddr ||
+               currprefs.compnf != changed_prefs.compnf ||
+               currprefs.comp_hardflush != changed_prefs.comp_hardflush ||
+               currprefs.comp_constjump != changed_prefs.comp_constjump ||
+               currprefs.comp_oldsegv != changed_prefs.comp_oldsegv ||
+               currprefs.compfpu != changed_prefs.compfpu ||
+               currprefs.fpu_strict != changed_prefs.fpu_strict)
+               changed = 1;
+
+       currprefs.comptrustbyte = changed_prefs.comptrustbyte;
+       currprefs.comptrustword = changed_prefs.comptrustword;
+       currprefs.comptrustlong = changed_prefs.comptrustlong;
+       currprefs.comptrustnaddr= changed_prefs.comptrustnaddr;
+       currprefs.compnf = changed_prefs.compnf;
+       currprefs.comp_hardflush = changed_prefs.comp_hardflush;
+       currprefs.comp_constjump = changed_prefs.comp_constjump;
+       currprefs.comp_oldsegv = changed_prefs.comp_oldsegv;
+       currprefs.compfpu = changed_prefs.compfpu;
+       currprefs.fpu_strict = changed_prefs.fpu_strict;
+
+       if (currprefs.cachesize != changed_prefs.cachesize) {
+               if (currprefs.cachesize && !changed_prefs.cachesize) {
+                       cachesize_prev = currprefs.cachesize;
+                       comptrust_prev = currprefs.comptrustbyte;
+                       canbang_prev = canbang;
+               } else if (!currprefs.cachesize && changed_prefs.cachesize == cachesize_prev) {
+                       changed_prefs.comptrustbyte = currprefs.comptrustbyte = comptrust_prev;
+                       changed_prefs.comptrustword = currprefs.comptrustword = comptrust_prev;
+                       changed_prefs.comptrustlong = currprefs.comptrustlong = comptrust_prev;
+                       changed_prefs.comptrustnaddr = currprefs.comptrustnaddr = comptrust_prev;
+               }
+               currprefs.cachesize = changed_prefs.cachesize;
+               alloc_cache();
+               changed = 1;
+       }
+       if (!candirect)
+               canbang = 0;
+
+       // Turn off illegal-mem logging when using JIT...
+       if(currprefs.cachesize)
+               currprefs.illegal_mem = changed_prefs.illegal_mem;// = 0;
+
+       currprefs.comp_midopt = changed_prefs.comp_midopt;
+       currprefs.comp_lowopt = changed_prefs.comp_lowopt;
+
+       if ((!canbang || !currprefs.cachesize) && currprefs.comptrustbyte != 1) {
+               // Set all of these to indirect when canbang == 0
+               // Basically, set the compforcesettings option...
+               currprefs.comptrustbyte = 1;
+               currprefs.comptrustword = 1;
+               currprefs.comptrustlong = 1;
+               currprefs.comptrustnaddr= 1;
+
+               changed_prefs.comptrustbyte = 1;
+               changed_prefs.comptrustword = 1;
+               changed_prefs.comptrustlong = 1;
+               changed_prefs.comptrustnaddr= 1;
+
+               changed = 1;
+
+               if (currprefs.cachesize)
+                       write_log (L"JIT: Reverting to \"indirect\" access, because canbang is zero!\n");
+       }
+
+       if (changed)
+               write_log (L"JIT: cache=%d. b=%d w=%d l=%d fpu=%d nf=%d const=%d hard=%d\n",
+               currprefs.cachesize,
+               currprefs.comptrustbyte, currprefs.comptrustword, currprefs.comptrustlong, 
+               currprefs.compfpu, currprefs.compnf, currprefs.comp_constjump, currprefs.comp_hardflush);
 
 #if 0
-    if (!currprefs.compforcesettings) {
-       int stop=0;
-       if (currprefs.comptrustbyte!=0 && currprefs.comptrustbyte!=3)
-           stop = 1, write_log (L"JIT: comptrustbyte is not 'direct' or 'afterpic'\n");
-       if (currprefs.comptrustword!=0 && currprefs.comptrustword!=3)
-           stop = 1, write_log (L"JIT: comptrustword is not 'direct' or 'afterpic'\n");
-       if (currprefs.comptrustlong!=0 && currprefs.comptrustlong!=3)
-           stop = 1, write_log (L"JIT: comptrustlong is not 'direct' or 'afterpic'\n");
-       if (currprefs.comptrustnaddr!=0 && currprefs.comptrustnaddr!=3)
-           stop = 1, write_log (L"JIT: comptrustnaddr is not 'direct' or 'afterpic'\n");
-       if (currprefs.compnf!=1)
-           stop = 1, write_log (L"JIT: compnf is not 'yes'\n");
-       if (currprefs.cachesize<1024)
-           stop = 1, write_log (L"JIT: cachesize is less than 1024\n");
-       if (currprefs.comp_hardflush)
-           stop = 1, write_log (L"JIT: comp_flushmode is 'hard'\n");
-       if (!canbang)
-           stop = 1, write_log (L"JIT: Cannot use most direct memory access,\n"
-                               "     and unable to recover from failed guess!\n");
-       if (stop) {
-           gui_message("JIT: Configuration problems were detected!\n"
-                     "JIT: These will adversely affect performance, and should\n"
-                     "JIT: not be used. For more info, please see README.JIT-tuning\n"
-                     "JIT: in the UAE documentation directory. You can force\n"
-                     "JIT: your settings to be used by setting\n"
-                     "JIT:      'compforcesettings=yes'\n"
-                     "JIT: in your config file\n");
-           exit(1);
-       }
-    }
+       if (!currprefs.compforcesettings) {
+               int stop=0;
+               if (currprefs.comptrustbyte!=0 && currprefs.comptrustbyte!=3)
+                       stop = 1, write_log (L"JIT: comptrustbyte is not 'direct' or 'afterpic'\n");
+               if (currprefs.comptrustword!=0 && currprefs.comptrustword!=3)
+                       stop = 1, write_log (L"JIT: comptrustword is not 'direct' or 'afterpic'\n");
+               if (currprefs.comptrustlong!=0 && currprefs.comptrustlong!=3)
+                       stop = 1, write_log (L"JIT: comptrustlong is not 'direct' or 'afterpic'\n");
+               if (currprefs.comptrustnaddr!=0 && currprefs.comptrustnaddr!=3)
+                       stop = 1, write_log (L"JIT: comptrustnaddr is not 'direct' or 'afterpic'\n");
+               if (currprefs.compnf!=1)
+                       stop = 1, write_log (L"JIT: compnf is not 'yes'\n");
+               if (currprefs.cachesize<1024)
+                       stop = 1, write_log (L"JIT: cachesize is less than 1024\n");
+               if (currprefs.comp_hardflush)
+                       stop = 1, write_log (L"JIT: comp_flushmode is 'hard'\n");
+               if (!canbang)
+                       stop = 1, write_log (L"JIT: Cannot use most direct memory access,\n"
+                       "     and unable to recover from failed guess!\n");
+               if (stop) {
+                       gui_message("JIT: Configuration problems were detected!\n"
+                               "JIT: These will adversely affect performance, and should\n"
+                               "JIT: not be used. For more info, please see README.JIT-tuning\n"
+                               "JIT: in the UAE documentation directory. You can force\n"
+                               "JIT: your settings to be used by setting\n"
+                               "JIT:      'compforcesettings=yes'\n"
+                               "JIT: in your config file\n");
+                       exit(1);
+               }
+       }
 #endif
-    return changed;
+       return changed;
 }
 
 /********************************************************************
- * Get the optimizer stuff                                          *
- ********************************************************************/
+* Get the optimizer stuff                                          *
+********************************************************************/
 
 //#include "compemu_optimizer.c"
 #include "compemu_optimizer_x86.cpp"
 
 /********************************************************************
- * Functions to emit data into memory, and other general support    *
- ********************************************************************/
+* Functions to emit data into memory, and other general support    *
+********************************************************************/
 
 static uae_u8* target;
 
@@ -555,117 +555,117 @@ static  void emit_init(void)
 
 STATIC_INLINE void emit_byte(uae_u8 x)
 {
-    *target++=x;
+       *target++=x;
 }
 
 STATIC_INLINE void emit_word(uae_u16 x)
 {
-    *((uae_u16*)target)=x;
-    target+=2;
+       *((uae_u16*)target)=x;
+       target+=2;
 }
 
 STATIC_INLINE void emit_long(uae_u32 x)
 {
-    *((uae_u32*)target)=x;
-    target+=4;
+       *((uae_u32*)target)=x;
+       target+=4;
 }
 
 STATIC_INLINE uae_u32 reverse32(uae_u32 oldv)
 {
-    return ((oldv>>24)&0xff) | ((oldv>>8)&0xff00) |
-       ((oldv<<8)&0xff0000) | ((oldv<<24)&0xff000000);
+       return ((oldv>>24)&0xff) | ((oldv>>8)&0xff00) |
+               ((oldv<<8)&0xff0000) | ((oldv<<24)&0xff000000);
 }
 
 
 void set_target(uae_u8* t)
 {
-    lopt_emit_all();
-    target=t;
+       lopt_emit_all();
+       target=t;
 }
 
 STATIC_INLINE uae_u8* get_target_noopt(void)
 {
-    return target;
+       return target;
 }
 
 STATIC_INLINE uae_u8* get_target(void)
 {
-    lopt_emit_all();
-    return get_target_noopt();
+       lopt_emit_all();
+       return get_target_noopt();
 }
 
 
 /********************************************************************
- * Getting the information about the target CPU                     *
- ********************************************************************/
+* Getting the information about the target CPU                     *
+********************************************************************/
 
 #include "compemu_raw_x86.cpp"
 
 
 /********************************************************************
- * Flags status handling. EMIT TIME!                                *
- ********************************************************************/
+* Flags status handling. EMIT TIME!                                *
+********************************************************************/
 
 static void bt_l_ri_noclobber(R4 r, IMM i);
 
 static void make_flags_live_internal(void)
 {
-    if (live.flags_in_flags==VALID)
-       return;
-    Dif (live.flags_on_stack==TRASH) {
-       jit_abort (L"JIT: Want flags, got something on stack, but it is TRASH\n");
-    }
-    if (live.flags_on_stack==VALID) {
-       int tmp;
-       tmp=readreg_specific(FLAGTMP,4,FLAG_NREG2);
-       raw_reg_to_flags(tmp);
-       unlock(tmp);
+       if (live.flags_in_flags==VALID)
+               return;
+       Dif (live.flags_on_stack==TRASH) {
+               jit_abort (L"JIT: Want flags, got something on stack, but it is TRASH\n");
+       }
+       if (live.flags_on_stack==VALID) {
+               int tmp;
+               tmp=readreg_specific(FLAGTMP,4,FLAG_NREG2);
+               raw_reg_to_flags(tmp);
+               unlock(tmp);
 
-       live.flags_in_flags=VALID;
-       return;
-    }
-    jit_abort (L"JIT: Huh? live.flags_in_flags=%d, live.flags_on_stack=%d, but need to make live\n",
-          live.flags_in_flags,live.flags_on_stack);
+               live.flags_in_flags=VALID;
+               return;
+       }
+       jit_abort (L"JIT: Huh? live.flags_in_flags=%d, live.flags_on_stack=%d, but need to make live\n",
+               live.flags_in_flags,live.flags_on_stack);
 }
 
 static void flags_to_stack(void)
 {
-    if (live.flags_on_stack==VALID)
-       return;
-    if (!live.flags_are_important) {
+       if (live.flags_on_stack==VALID)
+               return;
+       if (!live.flags_are_important) {
+               live.flags_on_stack=VALID;
+               return;
+       }
+       Dif (live.flags_in_flags!=VALID)
+               jit_abort (L"flags_to_stack != VALID");
+       else  {
+               int tmp;
+               tmp=writereg_specific(FLAGTMP,4,FLAG_NREG1);
+               raw_flags_to_reg(tmp);
+               unlock(tmp);
+       }
        live.flags_on_stack=VALID;
-       return;
-    }
-    Dif (live.flags_in_flags!=VALID)
-       jit_abort (L"flags_to_stack != VALID");
-    else  {
-       int tmp;
-       tmp=writereg_specific(FLAGTMP,4,FLAG_NREG1);
-       raw_flags_to_reg(tmp);
-       unlock(tmp);
-    }
-    live.flags_on_stack=VALID;
 }
 
 STATIC_INLINE void clobber_flags(void)
 {
-    if (live.flags_in_flags==VALID && live.flags_on_stack!=VALID)
-       flags_to_stack();
-    live.flags_in_flags=TRASH;
+       if (live.flags_in_flags==VALID && live.flags_on_stack!=VALID)
+               flags_to_stack();
+       live.flags_in_flags=TRASH;
 }
 
 /* Prepare for leaving the compiled stuff */
 STATIC_INLINE void flush_flags(void)
 {
-    flags_to_stack();
-    return;
+       flags_to_stack();
+       return;
 }
 
 int touchcnt;
 
 /********************************************************************
- * register allocation per block logging                            *
- ********************************************************************/
+* register allocation per block logging                            *
+********************************************************************/
 
 static uae_s8 vstate[VREGS];
 static uae_s8 nstate[N_REGS];
@@ -677,1771 +677,1771 @@ static uae_s8 nstate[N_REGS];
 
 STATIC_INLINE void log_startblock(void)
 {
-    int i;
-    for (i=0;i<VREGS;i++)
-       vstate[i]=L_UNKNOWN;
-    for (i=0;i<N_REGS;i++)
-       nstate[i]=L_UNKNOWN;
+       int i;
+       for (i=0;i<VREGS;i++)
+               vstate[i]=L_UNKNOWN;
+       for (i=0;i<N_REGS;i++)
+               nstate[i]=L_UNKNOWN;
 }
 
 STATIC_INLINE void log_isused(int n)
 {
-    if (nstate[n]==L_UNKNOWN)
-       nstate[n]=L_UNAVAIL;
+       if (nstate[n]==L_UNKNOWN)
+               nstate[n]=L_UNAVAIL;
 }
 
 STATIC_INLINE void log_isreg(int n, int r)
 {
-    if (nstate[n]==L_UNKNOWN)
-       nstate[n]=r;
-    if (vstate[r]==L_UNKNOWN)
-       vstate[r]=L_NEEDED;
+       if (nstate[n]==L_UNKNOWN)
+               nstate[n]=r;
+       if (vstate[r]==L_UNKNOWN)
+               vstate[r]=L_NEEDED;
 }
 
 STATIC_INLINE void log_clobberreg(int r)
 {
-    if (vstate[r]==L_UNKNOWN)
-       vstate[r]=L_UNNEEDED;
+       if (vstate[r]==L_UNKNOWN)
+               vstate[r]=L_UNNEEDED;
 }
 
 /* This ends all possibility of clever register allocation */
 
 STATIC_INLINE void log_flush(void)
 {
-    int i;
-    for (i=0;i<VREGS;i++)
-       if (vstate[i]==L_UNKNOWN)
-           vstate[i]=L_NEEDED;
-    for (i=0;i<N_REGS;i++)
-       if (nstate[i]==L_UNKNOWN)
-           nstate[i]=L_UNAVAIL;
+       int i;
+       for (i=0;i<VREGS;i++)
+               if (vstate[i]==L_UNKNOWN)
+                       vstate[i]=L_NEEDED;
+       for (i=0;i<N_REGS;i++)
+               if (nstate[i]==L_UNKNOWN)
+                       nstate[i]=L_UNAVAIL;
 }
 
 STATIC_INLINE void log_dump(void)
 {
-    int i;
+       int i;
 
-    return;
+       return;
 
-    write_log (L"----------------------\n");
-    for (i=0;i<N_REGS;i++) {
-       switch(nstate[i]) {
-        case L_UNKNOWN: write_log (L"Nat %d : UNKNOWN\n",i); break;
-        case L_UNAVAIL: write_log (L"Nat %d : UNAVAIL\n",i); break;
-        default:        write_log (L"Nat %d : %d\n",i,nstate[i]); break;
+       write_log (L"----------------------\n");
+       for (i=0;i<N_REGS;i++) {
+               switch(nstate[i]) {
+               case L_UNKNOWN: write_log (L"Nat %d : UNKNOWN\n",i); break;
+               case L_UNAVAIL: write_log (L"Nat %d : UNAVAIL\n",i); break;
+               default:        write_log (L"Nat %d : %d\n",i,nstate[i]); break;
+               }
+       }
+       for (i=0;i<VREGS;i++) {
+               if (vstate[i]==L_UNNEEDED)
+                       write_log (L"Virt %d: UNNEEDED\n",i);
        }
-    }
-    for (i=0;i<VREGS;i++) {
-       if (vstate[i]==L_UNNEEDED)
-           write_log (L"Virt %d: UNNEEDED\n",i);
-    }
 }
 
 /********************************************************************
- * register status handling. EMIT TIME!                             *
- ********************************************************************/
+* register status handling. EMIT TIME!                             *
+********************************************************************/
 
 STATIC_INLINE void set_status(int r, int status)
 {
-    if (status==ISCONST)
-       log_clobberreg(r);
-    live.state[r].status=status;
+       if (status==ISCONST)
+               log_clobberreg(r);
+       live.state[r].status=status;
 }
 
 
 STATIC_INLINE int isinreg(int r)
 {
-    return live.state[r].status==CLEAN || live.state[r].status==DIRTY;
+       return live.state[r].status==CLEAN || live.state[r].status==DIRTY;
 }
 
 STATIC_INLINE void adjust_nreg(int r, uae_u32 val)
 {
-    if (!val)
-       return;
-    raw_lea_l_brr(r,r,val);
+       if (!val)
+               return;
+       raw_lea_l_brr(r,r,val);
 }
 
 static  void tomem(int r)
 {
-    int rr=live.state[r].realreg;
+       int rr=live.state[r].realreg;
 
-    if (isinreg(r)) {
-       if (live.state[r].val &&
-           live.nat[rr].nholds==1 &&
-           !live.nat[rr].locked) {
-           // write_log (L"JIT: RemovingA offset %x from reg %d (%d) at %p\n",
-           //   live.state[r].val,r,rr,target);
-           adjust_nreg(rr,live.state[r].val);
-           live.state[r].val=0;
-           live.state[r].dirtysize=4;
-           set_status(r,DIRTY);
+       if (isinreg(r)) {
+               if (live.state[r].val &&
+                       live.nat[rr].nholds==1 &&
+                       !live.nat[rr].locked) {
+                               // write_log (L"JIT: RemovingA offset %x from reg %d (%d) at %p\n",
+                               //   live.state[r].val,r,rr,target);
+                               adjust_nreg(rr,live.state[r].val);
+                               live.state[r].val=0;
+                               live.state[r].dirtysize=4;
+                               set_status(r,DIRTY);
+               }
        }
-    }
 
-    if (live.state[r].status==DIRTY) {
-       switch (live.state[r].dirtysize) {
-        case 1: raw_mov_b_mr((uae_u32)live.state[r].mem,rr); break;
-        case 2: raw_mov_w_mr((uae_u32)live.state[r].mem,rr); break;
-        case 4: raw_mov_l_mr((uae_u32)live.state[r].mem,rr); break;
-        default: abort();
+       if (live.state[r].status==DIRTY) {
+               switch (live.state[r].dirtysize) {
+               case 1: raw_mov_b_mr((uae_u32)live.state[r].mem,rr); break;
+               case 2: raw_mov_w_mr((uae_u32)live.state[r].mem,rr); break;
+               case 4: raw_mov_l_mr((uae_u32)live.state[r].mem,rr); break;
+               default: abort();
+               }
+               set_status(r,CLEAN);
+               live.state[r].dirtysize=0;
        }
-       set_status(r,CLEAN);
-       live.state[r].dirtysize=0;
-    }
 }
 
 STATIC_INLINE int isconst(int r)
 {
-    return live.state[r].status==ISCONST;
+       return live.state[r].status==ISCONST;
 }
 
 int is_const(int r)
 {
-    return isconst(r);
+       return isconst(r);
 }
 
 STATIC_INLINE void writeback_const(int r)
 {
-    if (!isconst(r))
-       return;
-    Dif (live.state[r].needflush==NF_HANDLER) {
-       jit_abort (L"JIT: Trying to write back constant NF_HANDLER!\n");
-    }
+       if (!isconst(r))
+               return;
+       Dif (live.state[r].needflush==NF_HANDLER) {
+               jit_abort (L"JIT: Trying to write back constant NF_HANDLER!\n");
+       }
 
-    raw_mov_l_mi((uae_u32)live.state[r].mem,live.state[r].val);
-    live.state[r].val=0;
-    set_status(r,INMEM);
+       raw_mov_l_mi((uae_u32)live.state[r].mem,live.state[r].val);
+       live.state[r].val=0;
+       set_status(r,INMEM);
 }
 
 STATIC_INLINE void tomem_c(int r)
 {
-    if (isconst(r)) {
-       writeback_const(r);
-    }
-    else
-       tomem(r);
+       if (isconst(r)) {
+               writeback_const(r);
+       }
+       else
+               tomem(r);
 }
 
 static  void evict(int r)
 {
-    int rr;
+       int rr;
 
-    if (!isinreg(r))
-       return;
-    tomem(r);
-    rr=live.state[r].realreg;
+       if (!isinreg(r))
+               return;
+       tomem(r);
+       rr=live.state[r].realreg;
 
-    Dif (live.nat[rr].locked &&
-       live.nat[rr].nholds==1) {
-       jit_abort (L"JIT: register %d in nreg %d is locked!\n",r,live.state[r].realreg);
-    }
+       Dif (live.nat[rr].locked &&
+               live.nat[rr].nholds==1) {
+                       jit_abort (L"JIT: register %d in nreg %d is locked!\n",r,live.state[r].realreg);
+       }
 
-    live.nat[rr].nholds--;
-    if (live.nat[rr].nholds!=live.state[r].realind) { /* Was not last */
-       int topreg=live.nat[rr].holds[live.nat[rr].nholds];
-       int thisind=live.state[r].realind;
-       live.nat[rr].holds[thisind]=topreg;
-       live.state[topreg].realind=thisind;
-    }
-    live.state[r].realreg=-1;
-    set_status(r,INMEM);
+       live.nat[rr].nholds--;
+       if (live.nat[rr].nholds!=live.state[r].realind) { /* Was not last */
+               int topreg=live.nat[rr].holds[live.nat[rr].nholds];
+               int thisind=live.state[r].realind;
+               live.nat[rr].holds[thisind]=topreg;
+               live.state[topreg].realind=thisind;
+       }
+       live.state[r].realreg=-1;
+       set_status(r,INMEM);
 }
 
 STATIC_INLINE void free_nreg(int r)
 {
-    int i=live.nat[r].nholds;
+       int i=live.nat[r].nholds;
 
-    while (i) {
-       int vr;
+       while (i) {
+               int vr;
 
-       --i;
-       vr=live.nat[r].holds[i];
-       evict(vr);
-    }
-    Dif (live.nat[r].nholds!=0) {
-       jit_abort (L"JIT: Failed to free nreg %d, nholds is %d\n",r,live.nat[r].nholds);
-    }
+               --i;
+               vr=live.nat[r].holds[i];
+               evict(vr);
+       }
+       Dif (live.nat[r].nholds!=0) {
+               jit_abort (L"JIT: Failed to free nreg %d, nholds is %d\n",r,live.nat[r].nholds);
+       }
 }
 
 /* Use with care! */
 STATIC_INLINE void isclean(int r)
 {
-    if (!isinreg(r))
-       return;
-    live.state[r].validsize=4;
-    live.state[r].dirtysize=0;
-    live.state[r].val=0;
-    set_status(r,CLEAN);
+       if (!isinreg(r))
+               return;
+       live.state[r].validsize=4;
+       live.state[r].dirtysize=0;
+       live.state[r].val=0;
+       set_status(r,CLEAN);
 }
 
 STATIC_INLINE void disassociate(int r)
 {
-    isclean(r);
-    evict(r);
+       isclean(r);
+       evict(r);
 }
 
 STATIC_INLINE void set_const(int r, uae_u32 val)
 {
-    disassociate(r);
-    live.state[r].val=val;
-    set_status(r,ISCONST);
+       disassociate(r);
+       live.state[r].val=val;
+       set_status(r,ISCONST);
 }
 
 STATIC_INLINE uae_u32 get_offset(int r)
 {
-    return live.state[r].val;
+       return live.state[r].val;
 }
 
 static  int alloc_reg_hinted(int r, int size, int willclobber, int hint)
 {
-    int bestreg;
-    uae_s32 when;
-    int i;
-    uae_s32 badness=0; /* to shut up gcc */
-    bestreg=-1;
-    when=2000000000;
-
-    for (i=N_REGS;i--;) {
-       badness=live.nat[i].touched;
-       if (live.nat[i].nholds==0)
-           badness=0;
-       if (i==hint)
-           badness-=200000000;
-       if (!live.nat[i].locked && badness<when) {
-           if ((size==1 && live.nat[i].canbyte) ||
-               (size==2 && live.nat[i].canword) ||
-               (size==4)) {
-               bestreg=i;
-               when=badness;
-               if (live.nat[i].nholds==0 && hint<0)
-                   break;
+       int bestreg;
+       uae_s32 when;
+       int i;
+       uae_s32 badness=0; /* to shut up gcc */
+       bestreg=-1;
+       when=2000000000;
+
+       for (i=N_REGS;i--;) {
+               badness=live.nat[i].touched;
+               if (live.nat[i].nholds==0)
+                       badness=0;
                if (i==hint)
-                   break;
-           }
+                       badness-=200000000;
+               if (!live.nat[i].locked && badness<when) {
+                       if ((size==1 && live.nat[i].canbyte) ||
+                               (size==2 && live.nat[i].canword) ||
+                               (size==4)) {
+                                       bestreg=i;
+                                       when=badness;
+                                       if (live.nat[i].nholds==0 && hint<0)
+                                               break;
+                                       if (i==hint)
+                                               break;
+                       }
+               }
        }
-    }
-    Dif (bestreg==-1)
-       jit_abort (L"alloc_reg_hinted bestreg=-1");
+       Dif (bestreg==-1)
+               jit_abort (L"alloc_reg_hinted bestreg=-1");
 
-    if (live.nat[bestreg].nholds>0) {
-       free_nreg(bestreg);
-    }
-    if (isinreg(r)) {
-       int rr=live.state[r].realreg;
-       /* This will happen if we read a partially dirty register at a
-          bigger size */
-       Dif (willclobber || live.state[r].validsize>=size)
-           jit_abort (L"willclobber || live.state[r].validsize>=size");
-       Dif (live.nat[rr].nholds!=1)
-           jit_abort (L"live.nat[rr].nholds!=1");
-       if (size==4 && live.state[r].validsize==2) {
-           log_isused(bestreg);
-           raw_mov_l_rm(bestreg,(uae_u32)live.state[r].mem);
-           raw_bswap_32(bestreg);
-           raw_zero_extend_16_rr(rr,rr);
-           raw_zero_extend_16_rr(bestreg,bestreg);
-           raw_bswap_32(bestreg);
-           raw_lea_l_rr_indexed(rr,rr,bestreg);
-           live.state[r].validsize=4;
-           live.nat[rr].touched=touchcnt++;
-           return rr;
-       }
-       if (live.state[r].validsize==1) {
-           /* Nothing yet */
+       if (live.nat[bestreg].nholds>0) {
+               free_nreg(bestreg);
+       }
+       if (isinreg(r)) {
+               int rr=live.state[r].realreg;
+               /* This will happen if we read a partially dirty register at a
+               bigger size */
+               Dif (willclobber || live.state[r].validsize>=size)
+                       jit_abort (L"willclobber || live.state[r].validsize>=size");
+               Dif (live.nat[rr].nholds!=1)
+                       jit_abort (L"live.nat[rr].nholds!=1");
+               if (size==4 && live.state[r].validsize==2) {
+                       log_isused(bestreg);
+                       raw_mov_l_rm(bestreg,(uae_u32)live.state[r].mem);
+                       raw_bswap_32(bestreg);
+                       raw_zero_extend_16_rr(rr,rr);
+                       raw_zero_extend_16_rr(bestreg,bestreg);
+                       raw_bswap_32(bestreg);
+                       raw_lea_l_rr_indexed(rr,rr,bestreg);
+                       live.state[r].validsize=4;
+                       live.nat[rr].touched=touchcnt++;
+                       return rr;
+               }
+               if (live.state[r].validsize==1) {
+                       /* Nothing yet */
+               }
+               evict(r);
        }
-       evict(r);
-    }
 
-    if (!willclobber) {
-       if (live.state[r].status!=UNDEF) {
-           if (isconst(r)) {
-               raw_mov_l_ri(bestreg,live.state[r].val);
-               live.state[r].val=0;
-               live.state[r].dirtysize=4;
-               set_status(r,DIRTY);
-               log_isused(bestreg);
-           }
-           else {
-               if (r==FLAGTMP)
-                   raw_load_flagreg(bestreg,r);
-               else if (r==FLAGX)
-                   raw_load_flagx(bestreg,r);
+       if (!willclobber) {
+               if (live.state[r].status!=UNDEF) {
+                       if (isconst(r)) {
+                               raw_mov_l_ri(bestreg,live.state[r].val);
+                               live.state[r].val=0;
+                               live.state[r].dirtysize=4;
+                               set_status(r,DIRTY);
+                               log_isused(bestreg);
+                       }
+                       else {
+                               if (r==FLAGTMP)
+                                       raw_load_flagreg(bestreg,r);
+                               else if (r==FLAGX)
+                                       raw_load_flagx(bestreg,r);
+                               else {
+                                       raw_mov_l_rm(bestreg,(uae_u32)live.state[r].mem);
+                               }
+                               live.state[r].dirtysize=0;
+                               set_status(r,CLEAN);
+                               log_isreg(bestreg,r);
+                       }
+               }
                else {
-                   raw_mov_l_rm(bestreg,(uae_u32)live.state[r].mem);
+                       live.state[r].val=0;
+                       live.state[r].dirtysize=0;
+                       set_status(r,CLEAN);
+                       log_isused(bestreg);
                }
-               live.state[r].dirtysize=0;
-               set_status(r,CLEAN);
-               log_isreg(bestreg,r);
-           }
-       }
-       else {
-           live.state[r].val=0;
-           live.state[r].dirtysize=0;
-           set_status(r,CLEAN);
-           log_isused(bestreg);
-       }
-       live.state[r].validsize=4;
-    }
-    else { /* this is the easiest way, but not optimal. FIXME! */
-       /* Now it's trickier, but hopefully still OK */
-       if (!isconst(r) || size==4) {
-           live.state[r].validsize=size;
-           live.state[r].dirtysize=size;
-           live.state[r].val=0;
-           set_status(r,DIRTY);
-           if (size==4)
-               log_isused(bestreg);
-           else
-               log_isreg(bestreg,r);
+               live.state[r].validsize=4;
        }
-       else {
-           if (live.state[r].status!=UNDEF)
-               raw_mov_l_ri(bestreg,live.state[r].val);
-           live.state[r].val=0;
-           live.state[r].validsize=4;
-           live.state[r].dirtysize=4;
-           set_status(r,DIRTY);
-           log_isused(bestreg);
+       else { /* this is the easiest way, but not optimal. FIXME! */
+               /* Now it's trickier, but hopefully still OK */
+               if (!isconst(r) || size==4) {
+                       live.state[r].validsize=size;
+                       live.state[r].dirtysize=size;
+                       live.state[r].val=0;
+                       set_status(r,DIRTY);
+                       if (size==4)
+                               log_isused(bestreg);
+                       else
+                               log_isreg(bestreg,r);
+               }
+               else {
+                       if (live.state[r].status!=UNDEF)
+                               raw_mov_l_ri(bestreg,live.state[r].val);
+                       live.state[r].val=0;
+                       live.state[r].validsize=4;
+                       live.state[r].dirtysize=4;
+                       set_status(r,DIRTY);
+                       log_isused(bestreg);
+               }
        }
-    }
-    live.state[r].realreg=bestreg;
-    live.state[r].realind=live.nat[bestreg].nholds;
-    live.nat[bestreg].touched=touchcnt++;
-    live.nat[bestreg].holds[live.nat[bestreg].nholds]=r;
-    live.nat[bestreg].nholds++;
+       live.state[r].realreg=bestreg;
+       live.state[r].realind=live.nat[bestreg].nholds;
+       live.nat[bestreg].touched=touchcnt++;
+       live.nat[bestreg].holds[live.nat[bestreg].nholds]=r;
+       live.nat[bestreg].nholds++;
 
-    return bestreg;
+       return bestreg;
 }
 
 static  int alloc_reg(int r, int size, int willclobber)
 {
-    return alloc_reg_hinted(r,size,willclobber,-1);
+       return alloc_reg_hinted(r,size,willclobber,-1);
 }
 
 static  void unlock(int r)
 {
-    Dif (!live.nat[r].locked)
-       jit_abort (L"unlock %d not locked", r);
-    live.nat[r].locked--;
+       Dif (!live.nat[r].locked)
+               jit_abort (L"unlock %d not locked", r);
+       live.nat[r].locked--;
 }
 
 static  void setlock(int r)
 {
-    live.nat[r].locked++;
+       live.nat[r].locked++;
 }
 
 
 static void mov_nregs(int d, int s)
 {
-    int ns=live.nat[s].nholds;
-    int nd=live.nat[d].nholds;
-    int i;
+       int ns=live.nat[s].nholds;
+       int nd=live.nat[d].nholds;
+       int i;
 
-    if (s==d)
-       return;
+       if (s==d)
+               return;
 
-    if (nd>0)
-       free_nreg(d);
+       if (nd>0)
+               free_nreg(d);
 
-    raw_mov_l_rr(d,s);
-    log_isused(d);
+       raw_mov_l_rr(d,s);
+       log_isused(d);
 
-    for (i=0;i<live.nat[s].nholds;i++) {
-       int vs=live.nat[s].holds[i];
+       for (i=0;i<live.nat[s].nholds;i++) {
+               int vs=live.nat[s].holds[i];
 
-       live.state[vs].realreg=d;
-       live.state[vs].realind=i;
-       live.nat[d].holds[i]=vs;
-    }
-    live.nat[d].nholds=live.nat[s].nholds;
+               live.state[vs].realreg=d;
+               live.state[vs].realind=i;
+               live.nat[d].holds[i]=vs;
+       }
+       live.nat[d].nholds=live.nat[s].nholds;
 
-    live.nat[s].nholds=0;
+       live.nat[s].nholds=0;
 }
 
 
 STATIC_INLINE void make_exclusive(int r, int size, int spec)
 {
-    reg_status oldstate;
-    int rr=live.state[r].realreg;
-    int nr;
-    int nind;
-    int ndirt=0;
-    int i;
+       reg_status oldstate;
+       int rr=live.state[r].realreg;
+       int nr;
+       int nind;
+       int ndirt=0;
+       int i;
 
-    if (!isinreg(r))
-       return;
-    if (live.nat[rr].nholds==1)
-       return;
-    for (i=0;i<live.nat[rr].nholds;i++) {
-       int vr=live.nat[rr].holds[i];
-       if (vr!=r &&
-           (live.state[vr].status==DIRTY || live.state[vr].val))
-           ndirt++;
-    }
-    if (!ndirt && size<live.state[r].validsize && !live.nat[rr].locked) {
-       /* Everything else is clean, so let's keep this register */
+       if (!isinreg(r))
+               return;
+       if (live.nat[rr].nholds==1)
+               return;
        for (i=0;i<live.nat[rr].nholds;i++) {
-           int vr=live.nat[rr].holds[i];
-           if (vr!=r) {
-               evict(vr);
-               i--; /* Try that index again! */
-           }
+               int vr=live.nat[rr].holds[i];
+               if (vr!=r &&
+                       (live.state[vr].status==DIRTY || live.state[vr].val))
+                       ndirt++;
        }
-       Dif (live.nat[rr].nholds!=1) {
-           jit_abort (L"JIT: natreg %d holds %d vregs, %d not exclusive\n",
-                  rr,live.nat[rr].nholds,r);
+       if (!ndirt && size<live.state[r].validsize && !live.nat[rr].locked) {
+               /* Everything else is clean, so let's keep this register */
+               for (i=0;i<live.nat[rr].nholds;i++) {
+                       int vr=live.nat[rr].holds[i];
+                       if (vr!=r) {
+                               evict(vr);
+                               i--; /* Try that index again! */
+                       }
+               }
+               Dif (live.nat[rr].nholds!=1) {
+                       jit_abort (L"JIT: natreg %d holds %d vregs, %d not exclusive\n",
+                               rr,live.nat[rr].nholds,r);
+               }
+               return;
        }
-       return;
-    }
-
-    /* We have to split the register */
-    oldstate=live.state[r];
-
-    setlock(rr); /* Make sure this doesn't go away */
-    /* Forget about r being in the register rr */
-    disassociate(r);
-    /* Get a new register, that we will clobber completely */
-    if (oldstate.status==DIRTY) {
-       /* If dirtysize is <4, we need a register that can handle the
-          eventual smaller memory store! Thanks to Quake68k for exposing
-          this detail ;-) */
-       nr=alloc_reg_hinted(r,oldstate.dirtysize,1,spec);
-    }
-    else {
-       nr=alloc_reg_hinted(r,4,1,spec);
-    }
-    nind=live.state[r].realind;
-    live.state[r]=oldstate;   /* Keep all the old state info */
-    live.state[r].realreg=nr;
-    live.state[r].realind=nind;
-
-    if (size<live.state[r].validsize) {
-       if (live.state[r].val) {
-           /* Might as well compensate for the offset now */
-           raw_lea_l_brr(nr,rr,oldstate.val);
-           live.state[r].val=0;
-           live.state[r].dirtysize=4;
-           set_status(r,DIRTY);
+
+       /* We have to split the register */
+       oldstate=live.state[r];
+
+       setlock(rr); /* Make sure this doesn't go away */
+       /* Forget about r being in the register rr */
+       disassociate(r);
+       /* Get a new register, that we will clobber completely */
+       if (oldstate.status==DIRTY) {
+               /* If dirtysize is <4, we need a register that can handle the
+               eventual smaller memory store! Thanks to Quake68k for exposing
+               this detail ;-) */
+               nr=alloc_reg_hinted(r,oldstate.dirtysize,1,spec);
        }
-       else
-           raw_mov_l_rr(nr,rr);  /* Make another copy */
-    }
-    unlock(rr);
+       else {
+               nr=alloc_reg_hinted(r,4,1,spec);
+       }
+       nind=live.state[r].realind;
+       live.state[r]=oldstate;   /* Keep all the old state info */
+       live.state[r].realreg=nr;
+       live.state[r].realind=nind;
+
+       if (size<live.state[r].validsize) {
+               if (live.state[r].val) {
+                       /* Might as well compensate for the offset now */
+                       raw_lea_l_brr(nr,rr,oldstate.val);
+                       live.state[r].val=0;
+                       live.state[r].dirtysize=4;
+                       set_status(r,DIRTY);
+               }
+               else
+                       raw_mov_l_rr(nr,rr);  /* Make another copy */
+       }
+       unlock(rr);
 }
 
 STATIC_INLINE void add_offset(int r, uae_u32 off)
 {
-    live.state[r].val+=off;
+       live.state[r].val+=off;
 }
 
 STATIC_INLINE void remove_offset(int r, int spec)
 {
-    int rr;
+       int rr;
 
-    if (isconst(r))
-       return;
-    if (live.state[r].val==0)
-       return;
-    if (isinreg(r) && live.state[r].validsize<4)
-       evict(r);
+       if (isconst(r))
+               return;
+       if (live.state[r].val==0)
+               return;
+       if (isinreg(r) && live.state[r].validsize<4)
+               evict(r);
 
-    if (!isinreg(r))
-       alloc_reg_hinted(r,4,0,spec);
+       if (!isinreg(r))
+               alloc_reg_hinted(r,4,0,spec);
 
-    Dif (live.state[r].validsize!=4) {
-       jit_abort (L"JIT: Validsize=%d in remove_offset\n",live.state[r].validsize);
-    }
-    make_exclusive(r,0,-1);
-    /* make_exclusive might have done the job already */
-    if (live.state[r].val==0)
-       return;
+       Dif (live.state[r].validsize!=4) {
+               jit_abort (L"JIT: Validsize=%d in remove_offset\n",live.state[r].validsize);
+       }
+       make_exclusive(r,0,-1);
+       /* make_exclusive might have done the job already */
+       if (live.state[r].val==0)
+               return;
 
-    rr=live.state[r].realreg;
+       rr=live.state[r].realreg;
 
-    if (live.nat[rr].nholds==1) {
-       //write_log (L"JIT: RemovingB offset %x from reg %d (%d) at %p\n",
-       //       live.state[r].val,r,rr,target);
-       adjust_nreg(rr,live.state[r].val);
-       live.state[r].dirtysize=4;
-       live.state[r].val=0;
-       set_status(r,DIRTY);
-       return;
-    }
-    jit_abort (L"JIT: Failed in remove_offset\n");
+       if (live.nat[rr].nholds==1) {
+               //write_log (L"JIT: RemovingB offset %x from reg %d (%d) at %p\n",
+               //       live.state[r].val,r,rr,target);
+               adjust_nreg(rr,live.state[r].val);
+               live.state[r].dirtysize=4;
+               live.state[r].val=0;
+               set_status(r,DIRTY);
+               return;
+       }
+       jit_abort (L"JIT: Failed in remove_offset\n");
 }
 
 STATIC_INLINE void remove_all_offsets(void)
 {
-    int i;
+       int i;
 
-    for (i=0;i<VREGS;i++)
-       remove_offset(i,-1);
+       for (i=0;i<VREGS;i++)
+               remove_offset(i,-1);
 }
 
 STATIC_INLINE int readreg_general(int r, int size, int spec, int can_offset)
 {
-    int n;
-    int answer=-1;
+       int n;
+       int answer=-1;
 
-    if (live.state[r].status==UNDEF) {
-       write_log (L"JIT: WARNING: Unexpected read of undefined register %d\n",r);
-    }
-    if (!can_offset)
-       remove_offset(r,spec);
-
-    if (isinreg(r) && live.state[r].validsize>=size) {
-       n=live.state[r].realreg;
-       switch(size) {
-        case 1:
-           if (live.nat[n].canbyte || spec>=0) {
-               answer=n;
-           }
-           break;
-        case 2:
-           if (live.nat[n].canword || spec>=0) {
-               answer=n;
-           }
-           break;
-        case 4:
-           answer=n;
-           break;
-        default: abort();
+       if (live.state[r].status==UNDEF) {
+               write_log (L"JIT: WARNING: Unexpected read of undefined register %d\n",r);
+       }
+       if (!can_offset)
+               remove_offset(r,spec);
+
+       if (isinreg(r) && live.state[r].validsize>=size) {
+               n=live.state[r].realreg;
+               switch(size) {
+               case 1:
+                       if (live.nat[n].canbyte || spec>=0) {
+                               answer=n;
+                       }
+                       break;
+               case 2:
+                       if (live.nat[n].canword || spec>=0) {
+                               answer=n;
+                       }
+                       break;
+               case 4:
+                       answer=n;
+                       break;
+               default: abort();
+               }
+               if (answer<0)
+                       evict(r);
+       }
+       /* either the value was in memory to start with, or it was evicted and
+       is in memory now */
+       if (answer<0) {
+               answer=alloc_reg_hinted(r,spec>=0?4:size,0,spec);
        }
-       if (answer<0)
-           evict(r);
-    }
-    /* either the value was in memory to start with, or it was evicted and
-       is in memory now */
-    if (answer<0) {
-       answer=alloc_reg_hinted(r,spec>=0?4:size,0,spec);
-    }
 
-    if (spec>=0 && spec!=answer) {
-       /* Too bad */
-       mov_nregs(spec,answer);
-       answer=spec;
-    }
-    live.nat[answer].locked++;
-    live.nat[answer].touched=touchcnt++;
-    return answer;
+       if (spec>=0 && spec!=answer) {
+               /* Too bad */
+               mov_nregs(spec,answer);
+               answer=spec;
+       }
+       live.nat[answer].locked++;
+       live.nat[answer].touched=touchcnt++;
+       return answer;
 }
 
 
 
 static int readreg(int r, int size)
 {
-    return readreg_general(r,size,-1,0);
+       return readreg_general(r,size,-1,0);
 }
 
 static int readreg_specific(int r, int size, int spec)
 {
-    return readreg_general(r,size,spec,0);
+       return readreg_general(r,size,spec,0);
 }
 
 static int readreg_offset(int r, int size)
 {
-    return readreg_general(r,size,-1,1);
+       return readreg_general(r,size,-1,1);
 }
 
 
 STATIC_INLINE int writereg_general(int r, int size, int spec)
 {
-    int n;
-    int answer=-1;
-
-    if (size<4) {
-       remove_offset(r,spec);
-    }
+       int n;
+       int answer=-1;
 
-    make_exclusive(r,size,spec);
-    if (isinreg(r)) {
-       int nvsize=size>live.state[r].validsize?size:live.state[r].validsize;
-       int ndsize=size>live.state[r].dirtysize?size:live.state[r].dirtysize;
-       n=live.state[r].realreg;
-
-       Dif (live.nat[n].nholds!=1)
-           jit_abort (L"live.nat[%d].nholds!=1", n);
-       switch(size) {
-        case 1:
-           if (live.nat[n].canbyte || spec>=0) {
-               live.state[r].dirtysize=ndsize;
-               live.state[r].validsize=nvsize;
-               answer=n;
-           }
-           break;
-        case 2:
-           if (live.nat[n].canword || spec>=0) {
-               live.state[r].dirtysize=ndsize;
-               live.state[r].validsize=nvsize;
-               answer=n;
-           }
-           break;
-        case 4:
-           live.state[r].dirtysize=ndsize;
-           live.state[r].validsize=nvsize;
-           answer=n;
-           break;
-        default: abort();
+       if (size<4) {
+               remove_offset(r,spec);
        }
-       if (answer<0)
-           evict(r);
-    }
-    /* either the value was in memory to start with, or it was evicted and
-       is in memory now */
-    if (answer<0) {
-       answer=alloc_reg_hinted(r,size,1,spec);
-    }
-    if (spec>=0 && spec!=answer) {
-       mov_nregs(spec,answer);
-       answer=spec;
-    }
-    if (live.state[r].status==UNDEF)
-       live.state[r].validsize=4;
-    live.state[r].dirtysize=size>live.state[r].dirtysize?size:live.state[r].dirtysize;
-    live.state[r].validsize=size>live.state[r].validsize?size:live.state[r].validsize;
 
-    live.nat[answer].locked++;
-    live.nat[answer].touched=touchcnt++;
-    if (size==4) {
-       live.state[r].val=0;
-    }
-    else {
-       Dif (live.state[r].val) {
-           jit_abort (L"JIT: Problem with val\n");
+       make_exclusive(r,size,spec);
+       if (isinreg(r)) {
+               int nvsize=size>live.state[r].validsize?size:live.state[r].validsize;
+               int ndsize=size>live.state[r].dirtysize?size:live.state[r].dirtysize;
+               n=live.state[r].realreg;
+
+               Dif (live.nat[n].nholds!=1)
+                       jit_abort (L"live.nat[%d].nholds!=1", n);
+               switch(size) {
+               case 1:
+                       if (live.nat[n].canbyte || spec>=0) {
+                               live.state[r].dirtysize=ndsize;
+                               live.state[r].validsize=nvsize;
+                               answer=n;
+                       }
+                       break;
+               case 2:
+                       if (live.nat[n].canword || spec>=0) {
+                               live.state[r].dirtysize=ndsize;
+                               live.state[r].validsize=nvsize;
+                               answer=n;
+                       }
+                       break;
+               case 4:
+                       live.state[r].dirtysize=ndsize;
+                       live.state[r].validsize=nvsize;
+                       answer=n;
+                       break;
+               default: abort();
+               }
+               if (answer<0)
+                       evict(r);
+       }
+       /* either the value was in memory to start with, or it was evicted and
+       is in memory now */
+       if (answer<0) {
+               answer=alloc_reg_hinted(r,size,1,spec);
+       }
+       if (spec>=0 && spec!=answer) {
+               mov_nregs(spec,answer);
+               answer=spec;
+       }
+       if (live.state[r].status==UNDEF)
+               live.state[r].validsize=4;
+       live.state[r].dirtysize=size>live.state[r].dirtysize?size:live.state[r].dirtysize;
+       live.state[r].validsize=size>live.state[r].validsize?size:live.state[r].validsize;
+
+       live.nat[answer].locked++;
+       live.nat[answer].touched=touchcnt++;
+       if (size==4) {
+               live.state[r].val=0;
+       }
+       else {
+               Dif (live.state[r].val) {
+                       jit_abort (L"JIT: Problem with val\n");
+               }
        }
-    }
-    set_status(r,DIRTY);
-    return answer;
+       set_status(r,DIRTY);
+       return answer;
 }
 
 static int writereg(int r, int size)
 {
-    return writereg_general(r,size,-1);
+       return writereg_general(r,size,-1);
 }
 
 static int writereg_specific(int r, int size, int spec)
 {
-    return writereg_general(r,size,spec);
+       return writereg_general(r,size,spec);
 }
 
 STATIC_INLINE int rmw_general(int r, int wsize, int rsize, int spec)
 {
-    int n;
-    int answer=-1;
-
-    if (live.state[r].status==UNDEF) {
-       write_log (L"JIT: WARNING: Unexpected read of undefined register %d\n",r);
-    }
-    remove_offset(r,spec);
-    make_exclusive(r,0,spec);
-
-    Dif (wsize<rsize) {
-       jit_abort (L"JIT: Cannot handle wsize<rsize in rmw_general()\n");
-    }
-    if (isinreg(r) && live.state[r].validsize>=rsize) {
-       n=live.state[r].realreg;
-       Dif (live.nat[n].nholds!=1)
-           jit_abort (L"live.nat[n].nholds!=1", n);
-
-       switch(rsize) {
-        case 1:
-           if (live.nat[n].canbyte || spec>=0) {
-               answer=n;
-           }
-           break;
-        case 2:
-           if (live.nat[n].canword || spec>=0) {
-               answer=n;
-           }
-           break;
-        case 4:
-           answer=n;
-           break;
-        default: abort();
+       int n;
+       int answer=-1;
+
+       if (live.state[r].status==UNDEF) {
+               write_log (L"JIT: WARNING: Unexpected read of undefined register %d\n",r);
        }
-       if (answer<0)
-           evict(r);
-    }
-    /* either the value was in memory to start with, or it was evicted and
-       is in memory now */
-    if (answer<0) {
-       answer=alloc_reg_hinted(r,spec>=0?4:rsize,0,spec);
-    }
-
-    if (spec>=0 && spec!=answer) {
-       /* Too bad */
-       mov_nregs(spec,answer);
-       answer=spec;
-    }
-    if (wsize>live.state[r].dirtysize)
-       live.state[r].dirtysize=wsize;
-    if (wsize>live.state[r].validsize)
-       live.state[r].validsize=wsize;
-    set_status(r,DIRTY);
-
-    live.nat[answer].locked++;
-    live.nat[answer].touched=touchcnt++;
-
-    Dif (live.state[r].val) {
-       jit_abort (L"JIT: Problem with val(rmw)\n");
-    }
-    return answer;
+       remove_offset(r,spec);
+       make_exclusive(r,0,spec);
+
+       Dif (wsize<rsize) {
+               jit_abort (L"JIT: Cannot handle wsize<rsize in rmw_general()\n");
+       }
+       if (isinreg(r) && live.state[r].validsize>=rsize) {
+               n=live.state[r].realreg;
+               Dif (live.nat[n].nholds!=1)
+                       jit_abort (L"live.nat[n].nholds!=1", n);
+
+               switch(rsize) {
+               case 1:
+                       if (live.nat[n].canbyte || spec>=0) {
+                               answer=n;
+                       }
+                       break;
+               case 2:
+                       if (live.nat[n].canword || spec>=0) {
+                               answer=n;
+                       }
+                       break;
+               case 4:
+                       answer=n;
+                       break;
+               default: abort();
+               }
+               if (answer<0)
+                       evict(r);
+       }
+       /* either the value was in memory to start with, or it was evicted and
+       is in memory now */
+       if (answer<0) {
+               answer=alloc_reg_hinted(r,spec>=0?4:rsize,0,spec);
+       }
+
+       if (spec>=0 && spec!=answer) {
+               /* Too bad */
+               mov_nregs(spec,answer);
+               answer=spec;
+       }
+       if (wsize>live.state[r].dirtysize)
+               live.state[r].dirtysize=wsize;
+       if (wsize>live.state[r].validsize)
+               live.state[r].validsize=wsize;
+       set_status(r,DIRTY);
+
+       live.nat[answer].locked++;
+       live.nat[answer].touched=touchcnt++;
+
+       Dif (live.state[r].val) {
+               jit_abort (L"JIT: Problem with val(rmw)\n");
+       }
+       return answer;
 }
 
 static int rmw(int r, int wsize, int rsize)
 {
-    return rmw_general(r,wsize,rsize,-1);
+       return rmw_general(r,wsize,rsize,-1);
 }
 
 static int rmw_specific(int r, int wsize, int rsize, int spec)
 {
-    return rmw_general(r,wsize,rsize,spec);
+       return rmw_general(r,wsize,rsize,spec);
 }
 
 
 /* needed for restoring the carry flag on non-P6 cores */
 static void bt_l_ri_noclobber(R4 r, IMM i)
 {
-    int size=4;
-    if (i<16)
-       size=2;
-    r=readreg(r,size);
-    raw_bt_l_ri(r,i);
-    unlock(r);
+       int size=4;
+       if (i<16)
+               size=2;
+       r=readreg(r,size);
+       raw_bt_l_ri(r,i);
+       unlock(r);
 }
 
 /********************************************************************
- * FPU register status handling. EMIT TIME!                         *
- ********************************************************************/
+* FPU register status handling. EMIT TIME!                         *
+********************************************************************/
 
 static  void f_tomem(int r)
 {
-    if (live.fate[r].status==DIRTY) {
+       if (live.fate[r].status==DIRTY) {
 #if USE_LONG_DOUBLE
-       raw_fmov_ext_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg);
+               raw_fmov_ext_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg);
 #else
-       raw_fmov_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg);
+               raw_fmov_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg);
 #endif
-       live.fate[r].status=CLEAN;
-    }
+               live.fate[r].status=CLEAN;
+       }
 }
 
 static  void f_tomem_drop(int r)
 {
-    if (live.fate[r].status==DIRTY) {
+       if (live.fate[r].status==DIRTY) {
 #if USE_LONG_DOUBLE
-       raw_fmov_ext_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg);
+               raw_fmov_ext_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg);
 #else
-       raw_fmov_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg);
+               raw_fmov_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg);
 #endif
-       live.fate[r].status=INMEM;
-    }
+               live.fate[r].status=INMEM;
+       }
 }
 
 
 STATIC_INLINE int f_isinreg(int r)
 {
-    return live.fate[r].status==CLEAN || live.fate[r].status==DIRTY;
+       return live.fate[r].status==CLEAN || live.fate[r].status==DIRTY;
 }
 
 static void f_evict(int r)
 {
-    int rr;
+       int rr;
 
-    if (!f_isinreg(r))
-       return;
-    rr=live.fate[r].realreg;
-    if (live.fat[rr].nholds==1)
-       f_tomem_drop(r);
-    else
-       f_tomem(r);
-
-    Dif (live.fat[rr].locked &&
-       live.fat[rr].nholds==1) {
-       jit_abort (L"JIT: FPU register %d in nreg %d is locked!\n",r,live.fate[r].realreg);
-    }
-
-    live.fat[rr].nholds--;
-    if (live.fat[rr].nholds!=live.fate[r].realind) { /* Was not last */
-       int topreg=live.fat[rr].holds[live.fat[rr].nholds];
-       int thisind=live.fate[r].realind;
-       live.fat[rr].holds[thisind]=topreg;
-       live.fate[topreg].realind=thisind;
-    }
-    live.fate[r].status=INMEM;
-    live.fate[r].realreg=-1;
+       if (!f_isinreg(r))
+               return;
+       rr=live.fate[r].realreg;
+       if (live.fat[rr].nholds==1)
+               f_tomem_drop(r);
+       else
+               f_tomem(r);
+
+       Dif (live.fat[rr].locked &&
+               live.fat[rr].nholds==1) {
+                       jit_abort (L"JIT: FPU register %d in nreg %d is locked!\n",r,live.fate[r].realreg);
+       }
+
+       live.fat[rr].nholds--;
+       if (live.fat[rr].nholds!=live.fate[r].realind) { /* Was not last */
+               int topreg=live.fat[rr].holds[live.fat[rr].nholds];
+               int thisind=live.fate[r].realind;
+               live.fat[rr].holds[thisind]=topreg;
+               live.fate[topreg].realind=thisind;
+       }
+       live.fate[r].status=INMEM;
+       live.fate[r].realreg=-1;
 }
 
 STATIC_INLINE void f_free_nreg(int r)
 {
-    int i=live.fat[r].nholds;
+       int i=live.fat[r].nholds;
 
-    while (i) {
-       int vr;
+       while (i) {
+               int vr;
 
-       --i;
-       vr=live.fat[r].holds[i];
-       f_evict(vr);
-    }
-    Dif (live.fat[r].nholds!=0) {
-       jit_abort (L"JIT: Failed to free nreg %d, nholds is %d\n",r,live.fat[r].nholds);
-    }
+               --i;
+               vr=live.fat[r].holds[i];
+               f_evict(vr);
+       }
+       Dif (live.fat[r].nholds!=0) {
+               jit_abort (L"JIT: Failed to free nreg %d, nholds is %d\n",r,live.fat[r].nholds);
+       }
 }
 
 
 /* Use with care! */
 STATIC_INLINE void f_isclean(int r)
 {
-    if (!f_isinreg(r))
-       return;
-    live.fate[r].status=CLEAN;
+       if (!f_isinreg(r))
+               return;
+       live.fate[r].status=CLEAN;
 }
 
 STATIC_INLINE void f_disassociate(int r)
 {
-    f_isclean(r);
-    f_evict(r);
+       f_isclean(r);
+       f_evict(r);
 }
 
 
 
 static  int f_alloc_reg(int r, int willclobber)
 {
-    int bestreg;
-    uae_s32 when;
-    int i;
-    uae_s32 badness;
-    bestreg=-1;
-    when=2000000000;
-    for (i=N_FREGS;i--;) {
-       badness=live.fat[i].touched;
-       if (live.fat[i].nholds==0)
-           badness=0;
-
-       if (!live.fat[i].locked && badness<when) {
-           bestreg=i;
-           when=badness;
-           if (live.fat[i].nholds==0)
-               break;
-       }
-    }
-    Dif (bestreg==-1)
-       abort();
-
-    if (live.fat[bestreg].nholds>0) {
-       f_free_nreg(bestreg);
-    }
-    if (f_isinreg(r)) {
-       f_evict(r);
-    }
+       int bestreg;
+       uae_s32 when;
+       int i;
+       uae_s32 badness;
+       bestreg=-1;
+       when=2000000000;
+       for (i=N_FREGS;i--;) {
+               badness=live.fat[i].touched;
+               if (live.fat[i].nholds==0)
+                       badness=0;
+
+               if (!live.fat[i].locked && badness<when) {
+                       bestreg=i;
+                       when=badness;
+                       if (live.fat[i].nholds==0)
+                               break;
+               }
+       }
+       Dif (bestreg==-1)
+               abort();
+
+       if (live.fat[bestreg].nholds>0) {
+               f_free_nreg(bestreg);
+       }
+       if (f_isinreg(r)) {
+               f_evict(r);
+       }
 
-    if (!willclobber) {
-       if (live.fate[r].status!=UNDEF) {
+       if (!willclobber) {
+               if (live.fate[r].status!=UNDEF) {
 #if USE_LONG_DOUBLE
-           raw_fmov_ext_rm(bestreg,(uae_u32)live.fate[r].mem);
+                       raw_fmov_ext_rm(bestreg,(uae_u32)live.fate[r].mem);
 #else
-           raw_fmov_rm(bestreg,(uae_u32)live.fate[r].mem);
+                       raw_fmov_rm(bestreg,(uae_u32)live.fate[r].mem);
 #endif
+               }
+               live.fate[r].status=CLEAN;
        }
-       live.fate[r].status=CLEAN;
-    }
-    else {
-       live.fate[r].status=DIRTY;
-    }
-    live.fate[r].realreg=bestreg;
-    live.fate[r].realind=live.fat[bestreg].nholds;
-    live.fat[bestreg].touched=touchcnt++;
-    live.fat[bestreg].holds[live.fat[bestreg].nholds]=r;
-    live.fat[bestreg].nholds++;
+       else {
+               live.fate[r].status=DIRTY;
+       }
+       live.fate[r].realreg=bestreg;
+       live.fate[r].realind=live.fat[bestreg].nholds;
+       live.fat[bestreg].touched=touchcnt++;
+       live.fat[bestreg].holds[live.fat[bestreg].nholds]=r;
+       live.fat[bestreg].nholds++;
 
-    return bestreg;
+       return bestreg;
 }
 
 static  void f_unlock(int r)
 {
-    Dif (!live.fat[r].locked)
-       jit_abort (L"unlock %d", r);
-    live.fat[r].locked--;
+       Dif (!live.fat[r].locked)
+               jit_abort (L"unlock %d", r);
+       live.fat[r].locked--;
 }
 
 static  void f_setlock(int r)
 {
-    live.fat[r].locked++;
+       live.fat[r].locked++;
 }
 
 STATIC_INLINE int f_readreg(int r)
 {
-    int n;
-    int answer=-1;
+       int n;
+       int answer=-1;
 
-    if (f_isinreg(r)) {
-       n=live.fate[r].realreg;
-       answer=n;
-    }
-    /* either the value was in memory to start with, or it was evicted and
-       is in memory now */
-    if (answer<0)
-       answer=f_alloc_reg(r,0);
+       if (f_isinreg(r)) {
+               n=live.fate[r].realreg;
+               answer=n;
+       }
+       /* either the value was in memory to start with, or it was evicted and
+       is in memory now */
+       if (answer<0)
+               answer=f_alloc_reg(r,0);
 
-    live.fat[answer].locked++;
-    live.fat[answer].touched=touchcnt++;
-    return answer;
+       live.fat[answer].locked++;
+       live.fat[answer].touched=touchcnt++;
+       return answer;
 }
 
 STATIC_INLINE void f_make_exclusive(int r, int clobber)
 {
-    freg_status oldstate;
-    int rr=live.fate[r].realreg;
-    int nr;
-    int nind;
-    int ndirt=0;
-    int i;
+       freg_status oldstate;
+       int rr=live.fate[r].realreg;
+       int nr;
+       int nind;
+       int ndirt=0;
+       int i;
 
-    if (!f_isinreg(r))
-       return;
-    if (live.fat[rr].nholds==1)
-       return;
-    for (i=0;i<live.fat[rr].nholds;i++) {
-       int vr=live.fat[rr].holds[i];
-       if (vr!=r && live.fate[vr].status==DIRTY)
-           ndirt++;
-    }
-    if (!ndirt && !live.fat[rr].locked) {
-       /* Everything else is clean, so let's keep this register */
+       if (!f_isinreg(r))
+               return;
+       if (live.fat[rr].nholds==1)
+               return;
        for (i=0;i<live.fat[rr].nholds;i++) {
-           int vr=live.fat[rr].holds[i];
-           if (vr!=r) {
-               f_evict(vr);
-               i--; /* Try that index again! */
-           }
-       }
-       Dif (live.fat[rr].nholds!=1) {
-           write_log (L"JIT: realreg %d holds %d (",rr,live.fat[rr].nholds);
-           for (i=0;i<live.fat[rr].nholds;i++) {
-               write_log (L"JIT: %d(%d,%d)",live.fat[rr].holds[i],
-                      live.fate[live.fat[rr].holds[i]].realreg,
-                      live.fate[live.fat[rr].holds[i]].realind);
-           }
-           write_log (L"\n");
-           jit_abort (L"x");
+               int vr=live.fat[rr].holds[i];
+               if (vr!=r && live.fate[vr].status==DIRTY)
+                       ndirt++;
+       }
+       if (!ndirt && !live.fat[rr].locked) {
+               /* Everything else is clean, so let's keep this register */
+               for (i=0;i<live.fat[rr].nholds;i++) {
+                       int vr=live.fat[rr].holds[i];
+                       if (vr!=r) {
+                               f_evict(vr);
+                               i--; /* Try that index again! */
+                       }
+               }
+               Dif (live.fat[rr].nholds!=1) {
+                       write_log (L"JIT: realreg %d holds %d (",rr,live.fat[rr].nholds);
+                       for (i=0;i<live.fat[rr].nholds;i++) {
+                               write_log (L"JIT: %d(%d,%d)",live.fat[rr].holds[i],
+                                       live.fate[live.fat[rr].holds[i]].realreg,
+                                       live.fate[live.fat[rr].holds[i]].realind);
+                       }
+                       write_log (L"\n");
+                       jit_abort (L"x");
+               }
+               return;
        }
-       return;
-    }
 
-    /* We have to split the register */
-    oldstate=live.fate[r];
+       /* We have to split the register */
+       oldstate=live.fate[r];
 
-    f_setlock(rr); /* Make sure this doesn't go away */
-    /* Forget about r being in the register rr */
-    f_disassociate(r);
-    /* Get a new register, that we will clobber completely */
-    nr=f_alloc_reg(r,1);
-    nind=live.fate[r].realind;
-    if (!clobber)
-       raw_fmov_rr(nr,rr);  /* Make another copy */
-    live.fate[r]=oldstate;   /* Keep all the old state info */
-    live.fate[r].realreg=nr;
-    live.fate[r].realind=nind;
-    f_unlock(rr);
+       f_setlock(rr); /* Make sure this doesn't go away */
+       /* Forget about r being in the register rr */
+       f_disassociate(r);
+       /* Get a new register, that we will clobber completely */
+       nr=f_alloc_reg(r,1);
+       nind=live.fate[r].realind;
+       if (!clobber)
+               raw_fmov_rr(nr,rr);  /* Make another copy */
+       live.fate[r]=oldstate;   /* Keep all the old state info */
+       live.fate[r].realreg=nr;
+       live.fate[r].realind=nind;
+       f_unlock(rr);
 }
 
 
 STATIC_INLINE int f_writereg(int r)
 {
-    int n;
-    int answer=-1;
-
-    f_make_exclusive(r,1);
-    if (f_isinreg(r)) {
-       n=live.fate[r].realreg;
-       answer=n;
-    }
-    if (answer<0) {
-       answer=f_alloc_reg(r,1);
-    }
-    live.fate[r].status=DIRTY;
-    live.fat[answer].locked++;
-    live.fat[answer].touched=touchcnt++;
-    return answer;
-}
+       int n;
+       int answer=-1;
 
-static int f_rmw(int r)
+       f_make_exclusive(r,1);
+       if (f_isinreg(r)) {
+               n=live.fate[r].realreg;
+               answer=n;
+       }
+       if (answer<0) {
+               answer=f_alloc_reg(r,1);
+       }
+       live.fate[r].status=DIRTY;
+       live.fat[answer].locked++;
+       live.fat[answer].touched=touchcnt++;
+       return answer;
+}
+
+static int f_rmw(int r)
 {
-    int n;
+       int n;
 
-    f_make_exclusive(r,0);
-    if (f_isinreg(r)) {
-       n=live.fate[r].realreg;
-    }
-    else
-       n=f_alloc_reg(r,0);
-    live.fate[r].status=DIRTY;
-    live.fat[n].locked++;
-    live.fat[n].touched=touchcnt++;
-    return n;
+       f_make_exclusive(r,0);
+       if (f_isinreg(r)) {
+               n=live.fate[r].realreg;
+       }
+       else
+               n=f_alloc_reg(r,0);
+       live.fate[r].status=DIRTY;
+       live.fat[n].locked++;
+       live.fat[n].touched=touchcnt++;
+       return n;
 }
 
 static void fflags_into_flags_internal(uae_u32 tmp)
 {
-    int r;
+       int r;
 
-    clobber_flags();
-    r=f_readreg(FP_RESULT);
-    raw_fflags_into_flags(r);
-    f_unlock(r);
+       clobber_flags();
+       r=f_readreg(FP_RESULT);
+       raw_fflags_into_flags(r);
+       f_unlock(r);
 }
 
 
 
 
 /********************************************************************
- * CPU functions exposed to gencomp. Both CREATE and EMIT time      *
- ********************************************************************/
+* CPU functions exposed to gencomp. Both CREATE and EMIT time      *
+********************************************************************/
 
 /*
- *  RULES FOR HANDLING REGISTERS:
- *
- *  * In the function headers, order the parameters
- *     - 1st registers written to
- *     - 2nd read/modify/write registers
- *     - 3rd registers read from
- *  * Before calling raw_*, you must call readreg, writereg or rmw for
- *    each register
- *  * The order for this is
- *     - 1st call remove_offset for all registers written to with size<4
- *     - 2nd call readreg for all registers read without offset
- *     - 3rd call rmw for all rmw registers
- *     - 4th call readreg_offset for all registers that can handle offsets
- *     - 5th call get_offset for all the registers from the previous step
- *     - 6th call writereg for all written-to registers
- *     - 7th call raw_*
- *     - 8th unlock all registers that were locked
- */
+*  RULES FOR HANDLING REGISTERS:
+*
+*  * In the function headers, order the parameters
+*     - 1st registers written to
+*     - 2nd read/modify/write registers
+*     - 3rd registers read from
+*  * Before calling raw_*, you must call readreg, writereg or rmw for
+*    each register
+*  * The order for this is
+*     - 1st call remove_offset for all registers written to with size<4
+*     - 2nd call readreg for all registers read without offset
+*     - 3rd call rmw for all rmw registers
+*     - 4th call readreg_offset for all registers that can handle offsets
+*     - 5th call get_offset for all the registers from the previous step
+*     - 6th call writereg for all written-to registers
+*     - 7th call raw_*
+*     - 8th unlock all registers that were locked
+*/
 
 MIDFUNC(0,live_flags,(void))
 {
-    live.flags_on_stack=TRASH;
-    live.flags_in_flags=VALID;
-    live.flags_are_important=1;
+       live.flags_on_stack=TRASH;
+       live.flags_in_flags=VALID;
+       live.flags_are_important=1;
 }
 MENDFUNC(0,live_flags,(void))
 
-MIDFUNC(0,dont_care_flags,(void))
+       MIDFUNC(0,dont_care_flags,(void))
 {
-    live.flags_are_important=0;
+       live.flags_are_important=0;
 }
 MENDFUNC(0,dont_care_flags,(void))
 
 
-/*
- * Copy m68k C flag into m68k X flag
- *
- * FIXME: This needs to be moved into the machdep
- * part of the source because it depends on what bit
- * is used to hold X.
- */
-MIDFUNC(0,duplicate_carry,(void))
-{
-    evict(FLAGX);
-    make_flags_live_internal();
-    COMPCALL(setcc_m)((uae_u32)live.state[FLAGX].mem + 1,2);
+       /*
      * Copy m68k C flag into m68k X flag
      *
      * FIXME: This needs to be moved into the machdep
      * part of the source because it depends on what bit
      * is used to hold X.
      */
+       MIDFUNC(0,duplicate_carry,(void))
+{
+       evict(FLAGX);
+       make_flags_live_internal();
+       COMPCALL(setcc_m)((uae_u32)live.state[FLAGX].mem + 1,2);
 }
 MENDFUNC(0,duplicate_carry,(void))
 
-/*
- * Set host C flag from m68k X flag.
- *
- * FIXME: This needs to be moved into the machdep
- * part of the source because it depends on what bit
- * is used to hold X.
- */
-MIDFUNC(0,restore_carry,(void))
-{
-    if (!have_rat_stall) { /* Not a P6 core, i.e. no partial stalls */
-       bt_l_ri_noclobber(FLAGX, 8);
-    }
-    else {  /* Avoid the stall the above creates.
-              This is slow on non-P6, though.
-           */
-       COMPCALL(rol_w_ri(FLAGX, 8));
-       isclean(FLAGX);
-       /* Why is the above faster than the below? */
-       //raw_rol_b_mi((uae_u32)live.state[FLAGX].mem,8);
-    }
+       /*
      * Set host C flag from m68k X flag.
      *
      * FIXME: This needs to be moved into the machdep
      * part of the source because it depends on what bit
      * is used to hold X.
      */
+       MIDFUNC(0,restore_carry,(void))
+{
+       if (!have_rat_stall) { /* Not a P6 core, i.e. no partial stalls */
+               bt_l_ri_noclobber(FLAGX, 8);
+       }
+       else {  /* Avoid the stall the above creates.
+                       This is slow on non-P6, though.
+                       */
+               COMPCALL(rol_w_ri(FLAGX, 8));
+               isclean(FLAGX);
+               /* Why is the above faster than the below? */
+               //raw_rol_b_mi((uae_u32)live.state[FLAGX].mem,8);
+       }
 }
 MENDFUNC(0,restore_carry,(void))
 
-MIDFUNC(0,start_needflags,(void))
+       MIDFUNC(0,start_needflags,(void))
 {
-    needflags=1;
+       needflags=1;
 }
 MENDFUNC(0,start_needflags,(void))
 
-MIDFUNC(0,end_needflags,(void))
+       MIDFUNC(0,end_needflags,(void))
 {
-    needflags=0;
+       needflags=0;
 }
 MENDFUNC(0,end_needflags,(void))
 
-MIDFUNC(0,make_flags_live,(void))
+       MIDFUNC(0,make_flags_live,(void))
 {
-    make_flags_live_internal();
+       make_flags_live_internal();
 }
 MENDFUNC(0,make_flags_live,(void))
 
-MIDFUNC(1,fflags_into_flags,(W2 tmp))
+       MIDFUNC(1,fflags_into_flags,(W2 tmp))
 {
-    clobber_flags();
-    fflags_into_flags_internal(tmp);
+       clobber_flags();
+       fflags_into_flags_internal(tmp);
 }
 MENDFUNC(1,fflags_into_flags,(W2 tmp))
 
 
-MIDFUNC(2,bt_l_ri,(R4 r, IMM i)) /* This is defined as only affecting C */
+       MIDFUNC(2,bt_l_ri,(R4 r, IMM i)) /* This is defined as only affecting C */
 {
-    int size=4;
-    if (i<16)
-       size=2;
-    CLOBBER_BT;
-    r=readreg(r,size);
-    raw_bt_l_ri(r,i);
-    unlock(r);
+       int size=4;
+       if (i<16)
+               size=2;
+       CLOBBER_BT;
+       r=readreg(r,size);
+       raw_bt_l_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,bt_l_ri,(R4 r, IMM i)) /* This is defined as only affecting C */
 
-MIDFUNC(2,bt_l_rr,(R4 r, R4 b)) /* This is defined as only affecting C */
+       MIDFUNC(2,bt_l_rr,(R4 r, R4 b)) /* This is defined as only affecting C */
 {
-    CLOBBER_BT;
-    r=readreg(r,4);
-    b=readreg(b,4);
-    raw_bt_l_rr(r,b);
-    unlock(r);
-    unlock(b);
+       CLOBBER_BT;
+       r=readreg(r,4);
+       b=readreg(b,4);
+       raw_bt_l_rr(r,b);
+       unlock(r);
+       unlock(b);
 }
 MENDFUNC(2,bt_l_rr,(R4 r, R4 b)) /* This is defined as only affecting C */
 
-MIDFUNC(2,btc_l_ri,(RW4 r, IMM i))
+       MIDFUNC(2,btc_l_ri,(RW4 r, IMM i))
 {
-    int size=4;
-    if (i<16)
-       size=2;
-    CLOBBER_BT;
-    r=rmw(r,size,size);
-    raw_btc_l_ri(r,i);
-    unlock(r);
+       int size=4;
+       if (i<16)
+               size=2;
+       CLOBBER_BT;
+       r=rmw(r,size,size);
+       raw_btc_l_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,btc_l_ri,(RW4 r, IMM i))
 
-MIDFUNC(2,btc_l_rr,(RW4 r, R4 b))
+       MIDFUNC(2,btc_l_rr,(RW4 r, R4 b))
 {
-    CLOBBER_BT;
-    b=readreg(b,4);
-    r=rmw(r,4,4);
-    raw_btc_l_rr(r,b);
-    unlock(r);
-    unlock(b);
+       CLOBBER_BT;
+       b=readreg(b,4);
+       r=rmw(r,4,4);
+       raw_btc_l_rr(r,b);
+       unlock(r);
+       unlock(b);
 }
 MENDFUNC(2,btc_l_rr,(RW4 r, R4 b))
 
 
-MIDFUNC(2,btr_l_ri,(RW4 r, IMM i))
+       MIDFUNC(2,btr_l_ri,(RW4 r, IMM i))
 {
-    int size=4;
-    if (i<16)
-       size=2;
-    CLOBBER_BT;
-    r=rmw(r,size,size);
-    raw_btr_l_ri(r,i);
-    unlock(r);
+       int size=4;
+       if (i<16)
+               size=2;
+       CLOBBER_BT;
+       r=rmw(r,size,size);
+       raw_btr_l_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,btr_l_ri,(RW4 r, IMM i))
 
-MIDFUNC(2,btr_l_rr,(RW4 r, R4 b))
+       MIDFUNC(2,btr_l_rr,(RW4 r, R4 b))
 {
-    CLOBBER_BT;
-    b=readreg(b,4);
-    r=rmw(r,4,4);
-    raw_btr_l_rr(r,b);
-    unlock(r);
-    unlock(b);
+       CLOBBER_BT;
+       b=readreg(b,4);
+       r=rmw(r,4,4);
+       raw_btr_l_rr(r,b);
+       unlock(r);
+       unlock(b);
 }
 MENDFUNC(2,btr_l_rr,(RW4 r, R4 b))
 
 
-MIDFUNC(2,bts_l_ri,(RW4 r, IMM i))
+       MIDFUNC(2,bts_l_ri,(RW4 r, IMM i))
 {
-    int size=4;
-    if (i<16)
-       size=2;
-    CLOBBER_BT;
-    r=rmw(r,size,size);
-    raw_bts_l_ri(r,i);
-    unlock(r);
+       int size=4;
+       if (i<16)
+               size=2;
+       CLOBBER_BT;
+       r=rmw(r,size,size);
+       raw_bts_l_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,bts_l_ri,(RW4 r, IMM i))
 
-MIDFUNC(2,bts_l_rr,(RW4 r, R4 b))
+       MIDFUNC(2,bts_l_rr,(RW4 r, R4 b))
 {
-    CLOBBER_BT;
-    b=readreg(b,4);
-    r=rmw(r,4,4);
-    raw_bts_l_rr(r,b);
-    unlock(r);
-    unlock(b);
+       CLOBBER_BT;
+       b=readreg(b,4);
+       r=rmw(r,4,4);
+       raw_bts_l_rr(r,b);
+       unlock(r);
+       unlock(b);
 }
 MENDFUNC(2,bts_l_rr,(RW4 r, R4 b))
 
-MIDFUNC(2,mov_l_rm,(W4 d, IMM s))
+       MIDFUNC(2,mov_l_rm,(W4 d, IMM s))
 {
-    CLOBBER_MOV;
-    d=writereg(d,4);
-    raw_mov_l_rm(d,s);
-    unlock(d);
+       CLOBBER_MOV;
+       d=writereg(d,4);
+       raw_mov_l_rm(d,s);
+       unlock(d);
 }
 MENDFUNC(2,mov_l_rm,(W4 d, IMM s))
 
 
-MIDFUNC(1,call_r,(R4 r)) /* Clobbering is implicit */
+       MIDFUNC(1,call_r,(R4 r)) /* Clobbering is implicit */
 {
-    r=readreg(r,4);
-    raw_call_r(r);
-    unlock(r);
+       r=readreg(r,4);
+       raw_call_r(r);
+       unlock(r);
 }
 MENDFUNC(1,call_r,(R4 r)) /* Clobbering is implicit */
 
-MIDFUNC(2,sub_l_mi,(IMM d, IMM s))
+       MIDFUNC(2,sub_l_mi,(IMM d, IMM s))
 {
-    CLOBBER_SUB;
-    raw_sub_l_mi(d,s) ;
+       CLOBBER_SUB;
+       raw_sub_l_mi(d,s) ;
 }
 MENDFUNC(2,sub_l_mi,(IMM d, IMM s))
 
-MIDFUNC(2,mov_l_mi,(IMM d, IMM s))
+       MIDFUNC(2,mov_l_mi,(IMM d, IMM s))
 {
-    CLOBBER_MOV;
-    raw_mov_l_mi(d,s) ;
+       CLOBBER_MOV;
+       raw_mov_l_mi(d,s) ;
 }
 MENDFUNC(2,mov_l_mi,(IMM d, IMM s))
 
-MIDFUNC(2,mov_w_mi,(IMM d, IMM s))
+       MIDFUNC(2,mov_w_mi,(IMM d, IMM s))
 {
-    CLOBBER_MOV;
-    raw_mov_w_mi(d,s) ;
+       CLOBBER_MOV;
+       raw_mov_w_mi(d,s) ;
 }
 MENDFUNC(2,mov_w_mi,(IMM d, IMM s))
 
-MIDFUNC(2,mov_b_mi,(IMM d, IMM s))
+       MIDFUNC(2,mov_b_mi,(IMM d, IMM s))
 {
-    CLOBBER_MOV;
-    raw_mov_b_mi(d,s) ;
+       CLOBBER_MOV;
+       raw_mov_b_mi(d,s) ;
 }
 MENDFUNC(2,mov_b_mi,(IMM d, IMM s))
 
-MIDFUNC(2,rol_b_ri,(RW1 r, IMM i))
+       MIDFUNC(2,rol_b_ri,(RW1 r, IMM i))
 {
-               if (!i && !needflags)
+       if (!i && !needflags)
                return;
-    CLOBBER_ROL;
-    r=rmw(r,1,1);
-    raw_rol_b_ri(r,i);
-    unlock(r);
+       CLOBBER_ROL;
+       r=rmw(r,1,1);
+       raw_rol_b_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,rol_b_ri,(RW1 r, IMM i))
 
-MIDFUNC(2,rol_w_ri,(RW2 r, IMM i))
+       MIDFUNC(2,rol_w_ri,(RW2 r, IMM i))
 {
-               if (!i && !needflags)
+       if (!i && !needflags)
                return;
-    CLOBBER_ROL;
-    r=rmw(r,2,2);
-    raw_rol_w_ri(r,i);
-    unlock(r);
+       CLOBBER_ROL;
+       r=rmw(r,2,2);
+       raw_rol_w_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,rol_w_ri,(RW2 r, IMM i))
 
-MIDFUNC(2,rol_l_ri,(RW4 r, IMM i))
+       MIDFUNC(2,rol_l_ri,(RW4 r, IMM i))
 {
-               if (!i && !needflags)
+       if (!i && !needflags)
                return;
-    CLOBBER_ROL;
-    r=rmw(r,4,4);
-    raw_rol_l_ri(r,i);
-    unlock(r);
+       CLOBBER_ROL;
+       r=rmw(r,4,4);
+       raw_rol_l_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,rol_l_ri,(RW4 r, IMM i))
 
-MIDFUNC(2,rol_l_rr,(RW4 d, R1 r))
+       MIDFUNC(2,rol_l_rr,(RW4 d, R1 r))
 {
-    if (isconst(r)) {
-       COMPCALL(rol_l_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-    CLOBBER_ROL;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,4,4);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
-    }
-    raw_rol_l_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(rol_l_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+       CLOBBER_ROL;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,4,4);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+       }
+       raw_rol_l_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,rol_l_rr,(RW4 d, R1 r))
 
-MIDFUNC(2,rol_w_rr,(RW2 d, R1 r))
+       MIDFUNC(2,rol_w_rr,(RW2 d, R1 r))
 { /* Can only do this with r==1, i.e. cl */
 
-    if (isconst(r)) {
-       COMPCALL(rol_w_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-    CLOBBER_ROL;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,2,2);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
-    }
-    raw_rol_w_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(rol_w_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+       CLOBBER_ROL;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,2,2);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+       }
+       raw_rol_w_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,rol_w_rr,(RW2 d, R1 r))
 
-MIDFUNC(2,rol_b_rr,(RW1 d, R1 r))
+       MIDFUNC(2,rol_b_rr,(RW1 d, R1 r))
 { /* Can only do this with r==1, i.e. cl */
 
-    if (isconst(r)) {
-       COMPCALL(rol_b_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-
-    CLOBBER_ROL;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,1,1);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
-    }
-    raw_rol_b_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(rol_b_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+
+       CLOBBER_ROL;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,1,1);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+       }
+       raw_rol_b_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,rol_b_rr,(RW1 d, R1 r))
 
 
-MIDFUNC(2,shll_l_rr,(RW4 d, R1 r))
+       MIDFUNC(2,shll_l_rr,(RW4 d, R1 r))
 {
-    if (isconst(r)) {
-       COMPCALL(shll_l_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-    CLOBBER_SHLL;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,4,4);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
-    }
-    raw_shll_l_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(shll_l_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+       CLOBBER_SHLL;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,4,4);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+       }
+       raw_shll_l_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,shll_l_rr,(RW4 d, R1 r))
 
-MIDFUNC(2,shll_w_rr,(RW2 d, R1 r))
+       MIDFUNC(2,shll_w_rr,(RW2 d, R1 r))
 { /* Can only do this with r==1, i.e. cl */
 
-    if (isconst(r)) {
-       COMPCALL(shll_w_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-    CLOBBER_SHLL;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,2,2);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_shll_b\n",r);
-    }
-    raw_shll_w_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(shll_w_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+       CLOBBER_SHLL;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,2,2);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_shll_b\n",r);
+       }
+       raw_shll_w_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,shll_w_rr,(RW2 d, R1 r))
 
-MIDFUNC(2,shll_b_rr,(RW1 d, R1 r))
+       MIDFUNC(2,shll_b_rr,(RW1 d, R1 r))
 { /* Can only do this with r==1, i.e. cl */
 
-    if (isconst(r)) {
-       COMPCALL(shll_b_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-
-    CLOBBER_SHLL;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,1,1);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_shll_b\n",r);
-    }
-    raw_shll_b_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(shll_b_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+
+       CLOBBER_SHLL;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,1,1);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_shll_b\n",r);
+       }
+       raw_shll_b_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,shll_b_rr,(RW1 d, R1 r))
 
 
-MIDFUNC(2,ror_b_ri,(R1 r, IMM i))
+       MIDFUNC(2,ror_b_ri,(R1 r, IMM i))
 {
-               if (!i && !needflags)
+       if (!i && !needflags)
                return;
-    CLOBBER_ROR;
-    r=rmw(r,1,1);
-    raw_ror_b_ri(r,i);
-    unlock(r);
+       CLOBBER_ROR;
+       r=rmw(r,1,1);
+       raw_ror_b_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,ror_b_ri,(R1 r, IMM i))
 
-MIDFUNC(2,ror_w_ri,(R2 r, IMM i))
+       MIDFUNC(2,ror_w_ri,(R2 r, IMM i))
 {
-               if (!i && !needflags)
+       if (!i && !needflags)
                return;
-    CLOBBER_ROR;
-    r=rmw(r,2,2);
-    raw_ror_w_ri(r,i);
-    unlock(r);
+       CLOBBER_ROR;
+       r=rmw(r,2,2);
+       raw_ror_w_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,ror_w_ri,(R2 r, IMM i))
 
-MIDFUNC(2,ror_l_ri,(R4 r, IMM i))
+       MIDFUNC(2,ror_l_ri,(R4 r, IMM i))
 {
-               if (!i && !needflags)
+       if (!i && !needflags)
                return;
-    CLOBBER_ROR;
-    r=rmw(r,4,4);
-    raw_ror_l_ri(r,i);
-    unlock(r);
+       CLOBBER_ROR;
+       r=rmw(r,4,4);
+       raw_ror_l_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,ror_l_ri,(R4 r, IMM i))
 
-MIDFUNC(2,ror_l_rr,(R4 d, R1 r))
+       MIDFUNC(2,ror_l_rr,(R4 d, R1 r))
 {
-    if (isconst(r)) {
-       COMPCALL(ror_l_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-    CLOBBER_ROR;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,4,4);
-    raw_ror_l_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(ror_l_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+       CLOBBER_ROR;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,4,4);
+       raw_ror_l_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,ror_l_rr,(R4 d, R1 r))
 
-MIDFUNC(2,ror_w_rr,(R2 d, R1 r))
+       MIDFUNC(2,ror_w_rr,(R2 d, R1 r))
 {
-    if (isconst(r)) {
-       COMPCALL(ror_w_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-    CLOBBER_ROR;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,2,2);
-    raw_ror_w_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(ror_w_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+       CLOBBER_ROR;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,2,2);
+       raw_ror_w_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,ror_w_rr,(R2 d, R1 r))
 
-MIDFUNC(2,ror_b_rr,(R1 d, R1 r))
+       MIDFUNC(2,ror_b_rr,(R1 d, R1 r))
 {
-    if (isconst(r)) {
-       COMPCALL(ror_b_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
+       if (isconst(r)) {
+               COMPCALL(ror_b_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
 
-    CLOBBER_ROR;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,1,1);
-    raw_ror_b_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       CLOBBER_ROR;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,1,1);
+       raw_ror_b_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,ror_b_rr,(R1 d, R1 r))
 
-MIDFUNC(2,shrl_l_rr,(RW4 d, R1 r))
+       MIDFUNC(2,shrl_l_rr,(RW4 d, R1 r))
 {
-    if (isconst(r)) {
-       COMPCALL(shrl_l_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-    CLOBBER_SHRL;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,4,4);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
-    }
-    raw_shrl_l_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(shrl_l_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+       CLOBBER_SHRL;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,4,4);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+       }
+       raw_shrl_l_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,shrl_l_rr,(RW4 d, R1 r))
 
-MIDFUNC(2,shrl_w_rr,(RW2 d, R1 r))
+       MIDFUNC(2,shrl_w_rr,(RW2 d, R1 r))
 { /* Can only do this with r==1, i.e. cl */
 
-    if (isconst(r)) {
-       COMPCALL(shrl_w_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-    CLOBBER_SHRL;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,2,2);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_shrl_b\n",r);
-    }
-    raw_shrl_w_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(shrl_w_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+       CLOBBER_SHRL;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,2,2);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_shrl_b\n",r);
+       }
+       raw_shrl_w_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,shrl_w_rr,(RW2 d, R1 r))
 
-MIDFUNC(2,shrl_b_rr,(RW1 d, R1 r))
+       MIDFUNC(2,shrl_b_rr,(RW1 d, R1 r))
 { /* Can only do this with r==1, i.e. cl */
 
-    if (isconst(r)) {
-       COMPCALL(shrl_b_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-
-    CLOBBER_SHRL;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,1,1);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_shrl_b\n",r);
-    }
-    raw_shrl_b_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(shrl_b_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+
+       CLOBBER_SHRL;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,1,1);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_shrl_b\n",r);
+       }
+       raw_shrl_b_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,shrl_b_rr,(RW1 d, R1 r))
 
-MIDFUNC(2,shll_l_ri,(RW4 r, IMM i))
+       MIDFUNC(2,shll_l_ri,(RW4 r, IMM i))
 {
-    if (!i && !needflags)
-       return;
-    if (isconst(r) && !needflags) {
-       live.state[r].val<<=i;
-       return;
-    }
-    CLOBBER_SHLL;
-    r=rmw(r,4,4);
-    raw_shll_l_ri(r,i);
-    unlock(r);
+       if (!i && !needflags)
+               return;
+       if (isconst(r) && !needflags) {
+               live.state[r].val<<=i;
+               return;
+       }
+       CLOBBER_SHLL;
+       r=rmw(r,4,4);
+       raw_shll_l_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,shll_l_ri,(RW4 r, IMM i))
 
-MIDFUNC(2,shll_w_ri,(RW2 r, IMM i))
+       MIDFUNC(2,shll_w_ri,(RW2 r, IMM i))
 {
-    if (!i && !needflags)
-       return;
-    CLOBBER_SHLL;
-    r=rmw(r,2,2);
-    raw_shll_w_ri(r,i);
-    unlock(r);
+       if (!i && !needflags)
+               return;
+       CLOBBER_SHLL;
+       r=rmw(r,2,2);
+       raw_shll_w_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,shll_w_ri,(RW2 r, IMM i))
 
-MIDFUNC(2,shll_b_ri,(RW1 r, IMM i))
+       MIDFUNC(2,shll_b_ri,(RW1 r, IMM i))
 {
-    if (!i && !needflags)
-       return;
-    CLOBBER_SHLL;
-    r=rmw(r,1,1);
-    raw_shll_b_ri(r,i);
-    unlock(r);
+       if (!i && !needflags)
+               return;
+       CLOBBER_SHLL;
+       r=rmw(r,1,1);
+       raw_shll_b_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,shll_b_ri,(RW1 r, IMM i))
 
-MIDFUNC(2,shrl_l_ri,(RW4 r, IMM i))
+       MIDFUNC(2,shrl_l_ri,(RW4 r, IMM i))
 {
-    if (!i && !needflags)
-       return;
-    if (isconst(r) && !needflags) {
-       live.state[r].val>>=i;
-       return;
-    }
-    CLOBBER_SHRL;
-    r=rmw(r,4,4);
-    raw_shrl_l_ri(r,i);
-    unlock(r);
+       if (!i && !needflags)
+               return;
+       if (isconst(r) && !needflags) {
+               live.state[r].val>>=i;
+               return;
+       }
+       CLOBBER_SHRL;
+       r=rmw(r,4,4);
+       raw_shrl_l_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,shrl_l_ri,(RW4 r, IMM i))
 
-MIDFUNC(2,shrl_w_ri,(RW2 r, IMM i))
+       MIDFUNC(2,shrl_w_ri,(RW2 r, IMM i))
 {
-    if (!i && !needflags)
-       return;
-    CLOBBER_SHRL;
-    r=rmw(r,2,2);
-    raw_shrl_w_ri(r,i);
-    unlock(r);
+       if (!i && !needflags)
+               return;
+       CLOBBER_SHRL;
+       r=rmw(r,2,2);
+       raw_shrl_w_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,shrl_w_ri,(RW2 r, IMM i))
 
-MIDFUNC(2,shrl_b_ri,(RW1 r, IMM i))
+       MIDFUNC(2,shrl_b_ri,(RW1 r, IMM i))
 {
-    if (!i && !needflags)
-       return;
-    CLOBBER_SHRL;
-    r=rmw(r,1,1);
-    raw_shrl_b_ri(r,i);
-    unlock(r);
+       if (!i && !needflags)
+               return;
+       CLOBBER_SHRL;
+       r=rmw(r,1,1);
+       raw_shrl_b_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,shrl_b_ri,(RW1 r, IMM i))
 
-MIDFUNC(2,shra_l_ri,(RW4 r, IMM i))
+       MIDFUNC(2,shra_l_ri,(RW4 r, IMM i))
 {
-    if (!i && !needflags)
-       return;
-    CLOBBER_SHRA;
-    r=rmw(r,4,4);
-    raw_shra_l_ri(r,i);
-    unlock(r);
+       if (!i && !needflags)
+               return;
+       CLOBBER_SHRA;
+       r=rmw(r,4,4);
+       raw_shra_l_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,shra_l_ri,(RW4 r, IMM i))
 
-MIDFUNC(2,shra_w_ri,(RW2 r, IMM i))
+       MIDFUNC(2,shra_w_ri,(RW2 r, IMM i))
 {
-    if (!i && !needflags)
-       return;
-    CLOBBER_SHRA;
-    r=rmw(r,2,2);
-    raw_shra_w_ri(r,i);
-    unlock(r);
+       if (!i && !needflags)
+               return;
+       CLOBBER_SHRA;
+       r=rmw(r,2,2);
+       raw_shra_w_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,shra_w_ri,(RW2 r, IMM i))
 
-MIDFUNC(2,shra_b_ri,(RW1 r, IMM i))
+       MIDFUNC(2,shra_b_ri,(RW1 r, IMM i))
 {
-    if (!i && !needflags)
-       return;
-    CLOBBER_SHRA;
-    r=rmw(r,1,1);
-    raw_shra_b_ri(r,i);
-    unlock(r);
+       if (!i && !needflags)
+               return;
+       CLOBBER_SHRA;
+       r=rmw(r,1,1);
+       raw_shra_b_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,shra_b_ri,(RW1 r, IMM i))
 
-MIDFUNC(2,shra_l_rr,(RW4 d, R1 r))
+       MIDFUNC(2,shra_l_rr,(RW4 d, R1 r))
 {
-    if (isconst(r)) {
-       COMPCALL(shra_l_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-    CLOBBER_SHRA;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,4,4);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
-    }
-    raw_shra_l_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(shra_l_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+       CLOBBER_SHRA;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,4,4);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+       }
+       raw_shra_l_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,shra_l_rr,(RW4 d, R1 r))
 
-MIDFUNC(2,shra_w_rr,(RW2 d, R1 r))
+       MIDFUNC(2,shra_w_rr,(RW2 d, R1 r))
 { /* Can only do this with r==1, i.e. cl */
 
-    if (isconst(r)) {
-       COMPCALL(shra_w_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-    CLOBBER_SHRA;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,2,2);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_shra_b\n",r);
-    }
-    raw_shra_w_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(shra_w_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+       CLOBBER_SHRA;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,2,2);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_shra_b\n",r);
+       }
+       raw_shra_w_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,shra_w_rr,(RW2 d, R1 r))
 
-MIDFUNC(2,shra_b_rr,(RW1 d, R1 r))
+       MIDFUNC(2,shra_b_rr,(RW1 d, R1 r))
 { /* Can only do this with r==1, i.e. cl */
 
-    if (isconst(r)) {
-       COMPCALL(shra_b_ri)(d,(uae_u8)live.state[r].val);
-       return;
-    }
-
-    CLOBBER_SHRA;
-    r=readreg_specific(r,1,SHIFTCOUNT_NREG);
-    d=rmw(d,1,1);
-    Dif (r!=1) {
-       jit_abort (L"JIT: Illegal register %d in raw_shra_b\n",r);
-    }
-    raw_shra_b_rr(d,r) ;
-    unlock(r);
-    unlock(d);
+       if (isconst(r)) {
+               COMPCALL(shra_b_ri)(d,(uae_u8)live.state[r].val);
+               return;
+       }
+
+       CLOBBER_SHRA;
+       r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+       d=rmw(d,1,1);
+       Dif (r!=1) {
+               jit_abort (L"JIT: Illegal register %d in raw_shra_b\n",r);
+       }
+       raw_shra_b_rr(d,r) ;
+       unlock(r);
+       unlock(d);
 }
 MENDFUNC(2,shra_b_rr,(RW1 d, R1 r))
 
-MIDFUNC(2,setcc,(W1 d, IMM cc))
+       MIDFUNC(2,setcc,(W1 d, IMM cc))
 {
-    CLOBBER_SETCC;
-    d=writereg(d,1);
-    raw_setcc(d,cc);
-    unlock(d);
+       CLOBBER_SETCC;
+       d=writereg(d,1);
+       raw_setcc(d,cc);
+       unlock(d);
 }
 MENDFUNC(2,setcc,(W1 d, IMM cc))
 
-MIDFUNC(2,setcc_m,(IMM d, IMM cc))
+       MIDFUNC(2,setcc_m,(IMM d, IMM cc))
 {
-    CLOBBER_SETCC;
-    raw_setcc_m(d,cc);
+       CLOBBER_SETCC;
+       raw_setcc_m(d,cc);
 }
 MENDFUNC(2,setcc_m,(IMM d, IMM cc))
 
-MIDFUNC(3,cmov_b_rr,(RW1 d, R1 s, IMM cc))
+       MIDFUNC(3,cmov_b_rr,(RW1 d, R1 s, IMM cc))
 {
-    if (d==s)
-       return;
-    CLOBBER_CMOV;
-    s=readreg(s,1);
-    d=rmw(d,1,1);
-    raw_cmov_b_rr(d,s,cc);
-    unlock(s);
-    unlock(d);
+       if (d==s)
+               return;
+       CLOBBER_CMOV;
+       s=readreg(s,1);
+       d=rmw(d,1,1);
+       raw_cmov_b_rr(d,s,cc);
+       unlock(s);
+       unlock(d);
 }
 MENDFUNC(3,cmov_b_rr,(RW1 d, R1 s, IMM cc))
 
-MIDFUNC(3,cmov_w_rr,(RW2 d, R2 s, IMM cc))
+       MIDFUNC(3,cmov_w_rr,(RW2 d, R2 s, IMM cc))
 {
-    if (d==s)
-       return;
-    CLOBBER_CMOV;
-    s=readreg(s,2);
-    d=rmw(d,2,2);
-    raw_cmov_w_rr(d,s,cc);
-    unlock(s);
-    unlock(d);
+       if (d==s)
+               return;
+       CLOBBER_CMOV;
+       s=readreg(s,2);
+       d=rmw(d,2,2);
+       raw_cmov_w_rr(d,s,cc);
+       unlock(s);
+       unlock(d);
 }
 MENDFUNC(3,cmov_w_rr,(RW2 d, R2 s, IMM cc))
 
-MIDFUNC(3,cmov_l_rr,(RW4 d, R4 s, IMM cc))
+       MIDFUNC(3,cmov_l_rr,(RW4 d, R4 s, IMM cc))
 {
-    if (d==s)
-       return;
-    CLOBBER_CMOV;
-    s=readreg(s,4);
-    d=rmw(d,4,4);
-    raw_cmov_l_rr(d,s,cc);
-    unlock(s);
-    unlock(d);
+       if (d==s)
+               return;
+       CLOBBER_CMOV;
+       s=readreg(s,4);
+       d=rmw(d,4,4);
+       raw_cmov_l_rr(d,s,cc);
+       unlock(s);
+       unlock(d);
 }
 MENDFUNC(3,cmov_l_rr,(RW4 d, R4 s, IMM cc))
 
-MIDFUNC(1,setzflg_l,(RW4 r))
+       MIDFUNC(1,setzflg_l,(RW4 r))
 {
        if (setzflg_uses_bsf) {
                CLOBBER_BSF;
@@ -2452,2772 +2452,2772 @@ MIDFUNC(1,setzflg_l,(RW4 r))
        else {
                Dif (live.flags_in_flags!=VALID) {
                        jit_abort (L"JIT: setzflg() wanted flags in native flags, they are %d\n",
-                           live.flags_in_flags);
+                               live.flags_in_flags);
                }
                r=readreg(r,4);
                {
-               int f=writereg(S11,4);
-               int t=writereg(S12,4);
-               raw_flags_set_zero(f,r,t);
-               unlock(f);
-               unlock(r);
-               unlock(t);
+                       int f=writereg(S11,4);
+                       int t=writereg(S12,4);
+                       raw_flags_set_zero(f,r,t);
+                       unlock(f);
+                       unlock(r);
+                       unlock(t);
                }
        }
 }
 MENDFUNC(1,setzflg_l,(RW4 r))
 
-MIDFUNC(3,cmov_l_rm,(RW4 d, IMM s, IMM cc))
+       MIDFUNC(3,cmov_l_rm,(RW4 d, IMM s, IMM cc))
 {
-    CLOBBER_CMOV;
-    d=rmw(d,4,4);
-    raw_cmov_l_rm(d,s,cc);
-    unlock(d);
+       CLOBBER_CMOV;
+       d=rmw(d,4,4);
+       raw_cmov_l_rm(d,s,cc);
+       unlock(d);
 }
 MENDFUNC(3,cmov_l_rm,(RW4 d, IMM s, IMM cc))
 
-MIDFUNC(2,bsf_l_rr,(W4 d, R4 s))
+       MIDFUNC(2,bsf_l_rr,(W4 d, R4 s))
 {
-    CLOBBER_BSF;
-    s=readreg(s,4);
-    d=writereg(d,4);
-    raw_bsf_l_rr(d,s);
-    unlock(s);
-    unlock(d);
+       CLOBBER_BSF;
+       s=readreg(s,4);
+       d=writereg(d,4);
+       raw_bsf_l_rr(d,s);
+       unlock(s);
+       unlock(d);
 }
 MENDFUNC(2,bsf_l_rr,(W4 d, R4 s))
 
-MIDFUNC(2,imul_32_32,(RW4 d, R4 s))
+       MIDFUNC(2,imul_32_32,(RW4 d, R4 s))
 {
-    CLOBBER_MUL;
-    s=readreg(s,4);
-    d=rmw(d,4,4);
-    raw_imul_32_32(d,s);
-    unlock(s);
-    unlock(d);
+       CLOBBER_MUL;
+       s=readreg(s,4);
+       d=rmw(d,4,4);
+       raw_imul_32_32(d,s);
+       unlock(s);
+       unlock(d);
 }
 MENDFUNC(2,imul_32_32,(RW4 d, R4 s))
 
-MIDFUNC(2,imul_64_32,(RW4 d, RW4 s))
+       MIDFUNC(2,imul_64_32,(RW4 d, RW4 s))
 {
-    CLOBBER_MUL;
-    s=rmw_specific(s,4,4,MUL_NREG2);
-    d=rmw_specific(d,4,4,MUL_NREG1);
-    raw_imul_64_32(d,s);
-    unlock(s);
-    unlock(d);
+       CLOBBER_MUL;
+       s=rmw_specific(s,4,4,MUL_NREG2);
+       d=rmw_specific(d,4,4,MUL_NREG1);
+       raw_imul_64_32(d,s);
+       unlock(s);
+       unlock(d);
 }
 MENDFUNC(2,imul_64_32,(RW4 d, RW4 s))
 
-MIDFUNC(2,mul_64_32,(RW4 d, RW4 s))
+       MIDFUNC(2,mul_64_32,(RW4 d, RW4 s))
 {
-    CLOBBER_MUL;
-    s=rmw_specific(s,4,4,MUL_NREG2);
-    d=rmw_specific(d,4,4,MUL_NREG1);
-    raw_mul_64_32(d,s);
-    unlock(s);
-    unlock(d);
+       CLOBBER_MUL;
+       s=rmw_specific(s,4,4,MUL_NREG2);
+       d=rmw_specific(d,4,4,MUL_NREG1);
+       raw_mul_64_32(d,s);
+       unlock(s);
+       unlock(d);
 }
 MENDFUNC(2,mul_64_32,(RW4 d, RW4 s))
 
-MIDFUNC(2,sign_extend_16_rr,(W4 d, R2 s))
+       MIDFUNC(2,sign_extend_16_rr,(W4 d, R2 s))
 {
-    int isrmw;
+       int isrmw;
 
-    if (isconst(s)) {
-       set_const(d,(uae_s32)(uae_s16)live.state[s].val);
-       return;
-    }
+       if (isconst(s)) {
+               set_const(d,(uae_s32)(uae_s16)live.state[s].val);
+               return;
+       }
 
-    CLOBBER_SE16;
-    isrmw=(s==d);
-    if (!isrmw) {
-       s=readreg(s,2);
-       d=writereg(d,4);
-    }
-    else {  /* If we try to lock this twice, with different sizes, we
-              are int trouble! */
-       s=d=rmw(s,4,2);
-    }
-    raw_sign_extend_16_rr(d,s);
-    if (!isrmw) {
-       unlock(d);
-       unlock(s);
-    }
-    else {
-       unlock(s);
-    }
+       CLOBBER_SE16;
+       isrmw=(s==d);
+       if (!isrmw) {
+               s=readreg(s,2);
+               d=writereg(d,4);
+       }
+       else {  /* If we try to lock this twice, with different sizes, we
+                       are int trouble! */
+               s=d=rmw(s,4,2);
+       }
+       raw_sign_extend_16_rr(d,s);
+       if (!isrmw) {
+               unlock(d);
+               unlock(s);
+       }
+       else {
+               unlock(s);
+       }
 }
 MENDFUNC(2,sign_extend_16_rr,(W4 d, R2 s))
 
-MIDFUNC(2,sign_extend_8_rr,(W4 d, R1 s))
+       MIDFUNC(2,sign_extend_8_rr,(W4 d, R1 s))
 {
-    int isrmw;
+       int isrmw;
 
-    if (isconst(s)) {
-       set_const(d,(uae_s32)(uae_s8)live.state[s].val);
-       return;
-    }
+       if (isconst(s)) {
+               set_const(d,(uae_s32)(uae_s8)live.state[s].val);
+               return;
+       }
 
-    isrmw=(s==d);
-    CLOBBER_SE8;
-    if (!isrmw) {
-       s=readreg(s,1);
-       d=writereg(d,4);
-    }
-    else {  /* If we try to lock this twice, with different sizes, we
-              are int trouble! */
-       s=d=rmw(s,4,1);
-    }
+       isrmw=(s==d);
+       CLOBBER_SE8;
+       if (!isrmw) {
+               s=readreg(s,1);
+               d=writereg(d,4);
+       }
+       else {  /* If we try to lock this twice, with different sizes, we
+                       are int trouble! */
+               s=d=rmw(s,4,1);
+       }
 
-    raw_sign_extend_8_rr(d,s);
+       raw_sign_extend_8_rr(d,s);
 
-    if (!isrmw) {
-       unlock(d);
-       unlock(s);
-    }
-    else {
-       unlock(s);
-    }
+       if (!isrmw) {
+               unlock(d);
+               unlock(s);
+       }
+       else {
+               unlock(s);
+       }
 }
 MENDFUNC(2,sign_extend_8_rr,(W4 d, R1 s))
 
-MIDFUNC(2,zero_extend_16_rr,(W4 d, R2 s))
+       MIDFUNC(2,zero_extend_16_rr,(W4 d, R2 s))
 {
-    int isrmw;
+       int isrmw;
 
-    if (isconst(s)) {
-       set_const(d,(uae_u32)(uae_u16)live.state[s].val);
-       return;
-    }
+       if (isconst(s)) {
+               set_const(d,(uae_u32)(uae_u16)live.state[s].val);
+               return;
+       }
 
-    isrmw=(s==d);
-    CLOBBER_ZE16;
-    if (!isrmw) {
-       s=readreg(s,2);
-       d=writereg(d,4);
-    }
-    else {  /* If we try to lock this twice, with different sizes, we
-              are int trouble! */
-       s=d=rmw(s,4,2);
-    }
-    raw_zero_extend_16_rr(d,s);
-    if (!isrmw) {
-       unlock(d);
-       unlock(s);
-    }
-    else {
-       unlock(s);
-    }
+       isrmw=(s==d);
+       CLOBBER_ZE16;
+       if (!isrmw) {
+               s=readreg(s,2);
+               d=writereg(d,4);
+       }
+       else {  /* If we try to lock this twice, with different sizes, we
+                       are int trouble! */
+               s=d=rmw(s,4,2);
+       }
+       raw_zero_extend_16_rr(d,s);
+       if (!isrmw) {
+               unlock(d);
+               unlock(s);
+       }
+       else {
+               unlock(s);
+       }
 }
 MENDFUNC(2,zero_extend_16_rr,(W4 d, R2 s))
 
-MIDFUNC(2,zero_extend_8_rr,(W4 d, R1 s))
+       MIDFUNC(2,zero_extend_8_rr,(W4 d, R1 s))
 {
-    int isrmw;
-    if (isconst(s)) {
-       set_const(d,(uae_u32)(uae_u8)live.state[s].val);
-       return;
-    }
+       int isrmw;
+       if (isconst(s)) {
+               set_const(d,(uae_u32)(uae_u8)live.state[s].val);
+               return;
+       }
 
-    isrmw=(s==d);
-    CLOBBER_ZE8;
-    if (!isrmw) {
-       s=readreg(s,1);
-       d=writereg(d,4);
-    }
-    else {  /* If we try to lock this twice, with different sizes, we
-              are int trouble! */
-       s=d=rmw(s,4,1);
-    }
+       isrmw=(s==d);
+       CLOBBER_ZE8;
+       if (!isrmw) {
+               s=readreg(s,1);
+               d=writereg(d,4);
+       }
+       else {  /* If we try to lock this twice, with different sizes, we
+                       are int trouble! */
+               s=d=rmw(s,4,1);
+       }
 
-    raw_zero_extend_8_rr(d,s);
+       raw_zero_extend_8_rr(d,s);
 
-    if (!isrmw) {
-       unlock(d);
-       unlock(s);
-    }
-    else {
-       unlock(s);
-    }
+       if (!isrmw) {
+               unlock(d);
+               unlock(s);
+       }
+       else {
+               unlock(s);
+       }
 }
 MENDFUNC(2,zero_extend_8_rr,(W4 d, R1 s))
 
-MIDFUNC(2,mov_b_rr,(W1 d, R1 s))
+       MIDFUNC(2,mov_b_rr,(W1 d, R1 s))
 {
-    if (d==s)
-       return;
-    if (isconst(s)) {
-       COMPCALL(mov_b_ri)(d,(uae_u8)live.state[s].val);
-       return;
-    }
+       if (d==s)
+               return;
+       if (isconst(s)) {
+               COMPCALL(mov_b_ri)(d,(uae_u8)live.state[s].val);
+               return;
+       }
 
-    CLOBBER_MOV;
-    s=readreg(s,1);
-    d=writereg(d,1);
-    raw_mov_b_rr(d,s);
-    unlock(d);
-    unlock(s);
+       CLOBBER_MOV;
+       s=readreg(s,1);
+       d=writereg(d,1);
+       raw_mov_b_rr(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,mov_b_rr,(W1 d, R1 s))
 
-MIDFUNC(2,mov_w_rr,(W2 d, R2 s))
+       MIDFUNC(2,mov_w_rr,(W2 d, R2 s))
 {
-    if (d==s)
-       return;
-    if (isconst(s)) {
-       COMPCALL(mov_w_ri)(d,(uae_u16)live.state[s].val);
-       return;
-    }
+       if (d==s)
+               return;
+       if (isconst(s)) {
+               COMPCALL(mov_w_ri)(d,(uae_u16)live.state[s].val);
+               return;
+       }
 
-    CLOBBER_MOV;
-    s=readreg(s,2);
-    d=writereg(d,2);
-    raw_mov_w_rr(d,s);
-    unlock(d);
-    unlock(s);
+       CLOBBER_MOV;
+       s=readreg(s,2);
+       d=writereg(d,2);
+       raw_mov_w_rr(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,mov_w_rr,(W2 d, R2 s))
 
-MIDFUNC(3,mov_l_rrm_indexed,(W4 d,R4 baser, R4 index))
+       MIDFUNC(3,mov_l_rrm_indexed,(W4 d,R4 baser, R4 index))
 {
-    CLOBBER_MOV;
-    baser=readreg(baser,4);
-    index=readreg(index,4);
-    d=writereg(d,4);
+       CLOBBER_MOV;
+       baser=readreg(baser,4);
+       index=readreg(index,4);
+       d=writereg(d,4);
 
-    raw_mov_l_rrm_indexed(d,baser,index);
-    unlock(d);
-    unlock(baser);
-    unlock(index);
+       raw_mov_l_rrm_indexed(d,baser,index);
+       unlock(d);
+       unlock(baser);
+       unlock(index);
 }
 MENDFUNC(3,mov_l_rrm_indexed,(W4 d,R4 baser, R4 index))
 
-MIDFUNC(3,mov_w_rrm_indexed,(W2 d, R4 baser, R4 index))
+       MIDFUNC(3,mov_w_rrm_indexed,(W2 d, R4 baser, R4 index))
 {
-    CLOBBER_MOV;
-    baser=readreg(baser,4);
-    index=readreg(index,4);
-    d=writereg(d,2);
+       CLOBBER_MOV;
+       baser=readreg(baser,4);
+       index=readreg(index,4);
+       d=writereg(d,2);
 
-    raw_mov_w_rrm_indexed(d,baser,index);
-    unlock(d);
-    unlock(baser);
-    unlock(index);
+       raw_mov_w_rrm_indexed(d,baser,index);
+       unlock(d);
+       unlock(baser);
+       unlock(index);
 }
 MENDFUNC(3,mov_w_rrm_indexed,(W2 d, R4 baser, R4 index))
 
-MIDFUNC(3,mov_b_rrm_indexed,(W1 d, R4 baser, R4 index))
+       MIDFUNC(3,mov_b_rrm_indexed,(W1 d, R4 baser, R4 index))
 {
-    CLOBBER_MOV;
-    baser=readreg(baser,4);
-    index=readreg(index,4);
-    d=writereg(d,1);
+       CLOBBER_MOV;
+       baser=readreg(baser,4);
+       index=readreg(index,4);
+       d=writereg(d,1);
 
-    raw_mov_b_rrm_indexed(d,baser,index);
+       raw_mov_b_rrm_indexed(d,baser,index);
 
-    unlock(d);
-    unlock(baser);
-    unlock(index);
+       unlock(d);
+       unlock(baser);
+       unlock(index);
 }
 MENDFUNC(3,mov_b_rrm_indexed,(W1 d, R4 baser, R4 index))
 
-MIDFUNC(3,mov_l_mrr_indexed,(R4 baser, R4 index, R4 s))
+       MIDFUNC(3,mov_l_mrr_indexed,(R4 baser, R4 index, R4 s))
 {
-    CLOBBER_MOV;
-    baser=readreg(baser,4);
-    index=readreg(index,4);
-    s=readreg(s,4);
+       CLOBBER_MOV;
+       baser=readreg(baser,4);
+       index=readreg(index,4);
+       s=readreg(s,4);
 
-    Dif (baser==s || index==s)
-       jit_abort (L"mov_l_mrr_indexed");
+       Dif (baser==s || index==s)
+               jit_abort (L"mov_l_mrr_indexed");
 
-    raw_mov_l_mrr_indexed(baser,index,s);
-    unlock(s);
-    unlock(baser);
-    unlock(index);
+       raw_mov_l_mrr_indexed(baser,index,s);
+       unlock(s);
+       unlock(baser);
+       unlock(index);
 }
 MENDFUNC(3,mov_l_mrr_indexed,(R4 baser, R4 index, R4 s))
 
-MIDFUNC(3,mov_w_mrr_indexed,(R4 baser, R4 index, R2 s))
+       MIDFUNC(3,mov_w_mrr_indexed,(R4 baser, R4 index, R2 s))
 {
-    CLOBBER_MOV;
-    baser=readreg(baser,4);
-    index=readreg(index,4);
-    s=readreg(s,2);
+       CLOBBER_MOV;
+       baser=readreg(baser,4);
+       index=readreg(index,4);
+       s=readreg(s,2);
 
-    raw_mov_w_mrr_indexed(baser,index,s);
-    unlock(s);
-    unlock(baser);
-    unlock(index);
+       raw_mov_w_mrr_indexed(baser,index,s);
+       unlock(s);
+       unlock(baser);
+       unlock(index);
 }
 MENDFUNC(3,mov_w_mrr_indexed,(R4 baser, R4 index, R2 s))
 
-MIDFUNC(3,mov_b_mrr_indexed,(R4 baser, R4 index, R1 s))
+       MIDFUNC(3,mov_b_mrr_indexed,(R4 baser, R4 index, R1 s))
 {
-    CLOBBER_MOV;
-    s=readreg(s,1);
-    baser=readreg(baser,4);
-    index=readreg(index,4);
+       CLOBBER_MOV;
+       s=readreg(s,1);
+       baser=readreg(baser,4);
+       index=readreg(index,4);
 
-    raw_mov_b_mrr_indexed(baser,index,s);
-    unlock(s);
-    unlock(baser);
-    unlock(index);
+       raw_mov_b_mrr_indexed(baser,index,s);
+       unlock(s);
+       unlock(baser);
+       unlock(index);
 }
 MENDFUNC(3,mov_b_mrr_indexed,(R4 baser, R4 index, R1 s))
 
-/* Read a long from base+4*index */
-MIDFUNC(3,mov_l_rm_indexed,(W4 d, IMM base, R4 index))
+       /* Read a long from base+4*index */
+       MIDFUNC(3,mov_l_rm_indexed,(W4 d, IMM base, R4 index))
 {
-    int indexreg=index;
+       int indexreg=index;
 
-    if (isconst(index)) {
-       COMPCALL(mov_l_rm)(d,base+4*live.state[index].val);
-       return;
-    }
+       if (isconst(index)) {
+               COMPCALL(mov_l_rm)(d,base+4*live.state[index].val);
+               return;
+       }
 
-    CLOBBER_MOV;
-    index=readreg_offset(index,4);
-    base+=get_offset(indexreg)*4;
-    d=writereg(d,4);
+       CLOBBER_MOV;
+       index=readreg_offset(index,4);
+       base+=get_offset(indexreg)*4;
+       d=writereg(d,4);
 
-    raw_mov_l_rm_indexed(d,base,index);
-    unlock(index);
-    unlock(d);
+       raw_mov_l_rm_indexed(d,base,index);
+       unlock(index);
+       unlock(d);
 }
 MENDFUNC(3,mov_l_rm_indexed,(W4 d, IMM base, R4 index))
 
-/* read the long at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_l_rR,(W4 d, R4 s, IMM offset))
+       /* read the long at the address contained in s+offset and store in d */
+       MIDFUNC(3,mov_l_rR,(W4 d, R4 s, IMM offset))
 {
-    if (isconst(s)) {
-       COMPCALL(mov_l_rm)(d,live.state[s].val+offset);
-       return;
-    }
-    CLOBBER_MOV;
-    s=readreg(s,4);
-    d=writereg(d,4);
+       if (isconst(s)) {
+               COMPCALL(mov_l_rm)(d,live.state[s].val+offset);
+               return;
+       }
+       CLOBBER_MOV;
+       s=readreg(s,4);
+       d=writereg(d,4);
 
-    raw_mov_l_rR(d,s,offset);
-    unlock(d);
-    unlock(s);
+       raw_mov_l_rR(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_l_rR,(W4 d, R4 s, IMM offset))
 
-/* read the word at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_w_rR,(W2 d, R4 s, IMM offset))
+       /* read the word at the address contained in s+offset and store in d */
+       MIDFUNC(3,mov_w_rR,(W2 d, R4 s, IMM offset))
 {
-    if (isconst(s)) {
-       COMPCALL(mov_w_rm)(d,live.state[s].val+offset);
-       return;
-    }
-    CLOBBER_MOV;
-    s=readreg(s,4);
-    d=writereg(d,2);
+       if (isconst(s)) {
+               COMPCALL(mov_w_rm)(d,live.state[s].val+offset);
+               return;
+       }
+       CLOBBER_MOV;
+       s=readreg(s,4);
+       d=writereg(d,2);
 
-    raw_mov_w_rR(d,s,offset);
-    unlock(d);
-    unlock(s);
+       raw_mov_w_rR(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_w_rR,(W2 d, R4 s, IMM offset))
 
-/* read the word at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_b_rR,(W1 d, R4 s, IMM offset))
+       /* read the word at the address contained in s+offset and store in d */
+       MIDFUNC(3,mov_b_rR,(W1 d, R4 s, IMM offset))
 {
-    if (isconst(s)) {
-       COMPCALL(mov_b_rm)(d,live.state[s].val+offset);
-       return;
-    }
-    CLOBBER_MOV;
-    s=readreg(s,4);
-    d=writereg(d,1);
+       if (isconst(s)) {
+               COMPCALL(mov_b_rm)(d,live.state[s].val+offset);
+               return;
+       }
+       CLOBBER_MOV;
+       s=readreg(s,4);
+       d=writereg(d,1);
 
-    raw_mov_b_rR(d,s,offset);
-    unlock(d);
-    unlock(s);
+       raw_mov_b_rR(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_b_rR,(W1 d, R4 s, IMM offset))
 
-/* read the long at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_l_brR,(W4 d, R4 s, IMM offset))
+       /* read the long at the address contained in s+offset and store in d */
+       MIDFUNC(3,mov_l_brR,(W4 d, R4 s, IMM offset))
 {
-    int sreg=s;
-    if (isconst(s)) {
-       COMPCALL(mov_l_rm)(d,live.state[s].val+offset);
-       return;
-    }
-    CLOBBER_MOV;
-    s=readreg_offset(s,4);
-    offset+=get_offset(sreg);
-    d=writereg(d,4);
+       int sreg=s;
+       if (isconst(s)) {
+               COMPCALL(mov_l_rm)(d,live.state[s].val+offset);
+               return;
+       }
+       CLOBBER_MOV;
+       s=readreg_offset(s,4);
+       offset+=get_offset(sreg);
+       d=writereg(d,4);
 
-    raw_mov_l_brR(d,s,offset);
-    unlock(d);
-    unlock(s);
+       raw_mov_l_brR(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_l_brR,(W4 d, R4 s, IMM offset))
 
-/* read the word at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_w_brR,(W2 d, R4 s, IMM offset))
+       /* read the word at the address contained in s+offset and store in d */
+       MIDFUNC(3,mov_w_brR,(W2 d, R4 s, IMM offset))
 {
-    int sreg=s;
-    if (isconst(s)) {
-       COMPCALL(mov_w_rm)(d,live.state[s].val+offset);
-       return;
-    }
-    CLOBBER_MOV;
-    remove_offset(d,-1);
-    s=readreg_offset(s,4);
-    offset+=get_offset(sreg);
-    d=writereg(d,2);
+       int sreg=s;
+       if (isconst(s)) {
+               COMPCALL(mov_w_rm)(d,live.state[s].val+offset);
+               return;
+       }
+       CLOBBER_MOV;
+       remove_offset(d,-1);
+       s=readreg_offset(s,4);
+       offset+=get_offset(sreg);
+       d=writereg(d,2);
 
-    raw_mov_w_brR(d,s,offset);
-    unlock(d);
-    unlock(s);
+       raw_mov_w_brR(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_w_brR,(W2 d, R4 s, IMM offset))
 
-/* read the word at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_b_brR,(W1 d, R4 s, IMM offset))
+       /* read the word at the address contained in s+offset and store in d */
+       MIDFUNC(3,mov_b_brR,(W1 d, R4 s, IMM offset))
 {
-    int sreg=s;
-    if (isconst(s)) {
-       COMPCALL(mov_b_rm)(d,live.state[s].val+offset);
-       return;
-    }
-    CLOBBER_MOV;
-    remove_offset(d,-1);
-    s=readreg_offset(s,4);
-    offset+=get_offset(sreg);
-    d=writereg(d,1);
+       int sreg=s;
+       if (isconst(s)) {
+               COMPCALL(mov_b_rm)(d,live.state[s].val+offset);
+               return;
+       }
+       CLOBBER_MOV;
+       remove_offset(d,-1);
+       s=readreg_offset(s,4);
+       offset+=get_offset(sreg);
+       d=writereg(d,1);
 
-    raw_mov_b_brR(d,s,offset);
-    unlock(d);
-    unlock(s);
+       raw_mov_b_brR(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_b_brR,(W1 d, R4 s, IMM offset))
 
-MIDFUNC(3,mov_l_Ri,(R4 d, IMM i, IMM offset))
+       MIDFUNC(3,mov_l_Ri,(R4 d, IMM i, IMM offset))
 {
-    int dreg=d;
-    if (isconst(d)) {
-       COMPCALL(mov_l_mi)(live.state[d].val+offset,i);
-       return;
-    }
+       int dreg=d;
+       if (isconst(d)) {
+               COMPCALL(mov_l_mi)(live.state[d].val+offset,i);
+               return;
+       }
 
-    CLOBBER_MOV;
-    d=readreg_offset(d,4);
-    offset+=get_offset(dreg);
-    raw_mov_l_Ri(d,i,offset);
-    unlock(d);
+       CLOBBER_MOV;
+       d=readreg_offset(d,4);
+       offset+=get_offset(dreg);
+       raw_mov_l_Ri(d,i,offset);
+       unlock(d);
 }
 MENDFUNC(3,mov_l_Ri,(R4 d, IMM i, IMM offset))
 
-MIDFUNC(3,mov_w_Ri,(R4 d, IMM i, IMM offset))
+       MIDFUNC(3,mov_w_Ri,(R4 d, IMM i, IMM offset))
 {
-    int dreg=d;
-    if (isconst(d)) {
-       COMPCALL(mov_w_mi)(live.state[d].val+offset,i);
-       return;
-    }
+       int dreg=d;
+       if (isconst(d)) {
+               COMPCALL(mov_w_mi)(live.state[d].val+offset,i);
+               return;
+       }
 
-    CLOBBER_MOV;
-    d=readreg_offset(d,4);
-    offset+=get_offset(dreg);
-    raw_mov_w_Ri(d,i,offset);
-    unlock(d);
+       CLOBBER_MOV;
+       d=readreg_offset(d,4);
+       offset+=get_offset(dreg);
+       raw_mov_w_Ri(d,i,offset);
+       unlock(d);
 }
 MENDFUNC(3,mov_w_Ri,(R4 d, IMM i, IMM offset))
 
-MIDFUNC(3,mov_b_Ri,(R4 d, IMM i, IMM offset))
+       MIDFUNC(3,mov_b_Ri,(R4 d, IMM i, IMM offset))
 {
-    int dreg=d;
-    if (isconst(d)) {
-       COMPCALL(mov_b_mi)(live.state[d].val+offset,i);
-       return;
-    }
+       int dreg=d;
+       if (isconst(d)) {
+               COMPCALL(mov_b_mi)(live.state[d].val+offset,i);
+               return;
+       }
 
-    CLOBBER_MOV;
-    d=readreg_offset(d,4);
-    offset+=get_offset(dreg);
-    raw_mov_b_Ri(d,i,offset);
-    unlock(d);
+       CLOBBER_MOV;
+       d=readreg_offset(d,4);
+       offset+=get_offset(dreg);
+       raw_mov_b_Ri(d,i,offset);
+       unlock(d);
 }
 MENDFUNC(3,mov_b_Ri,(R4 d, IMM i, IMM offset))
 
-     /* Warning! OFFSET is byte sized only! */
-MIDFUNC(3,mov_l_Rr,(R4 d, R4 s, IMM offset))
+       /* Warning! OFFSET is byte sized only! */
+       MIDFUNC(3,mov_l_Rr,(R4 d, R4 s, IMM offset))
 {
-    if (isconst(d)) {
-       COMPCALL(mov_l_mr)(live.state[d].val+offset,s);
-       return;
-    }
-    if (isconst(s)) {
-       COMPCALL(mov_l_Ri)(d,live.state[s].val,offset);
-       return;
-    }
+       if (isconst(d)) {
+               COMPCALL(mov_l_mr)(live.state[d].val+offset,s);
+               return;
+       }
+       if (isconst(s)) {
+               COMPCALL(mov_l_Ri)(d,live.state[s].val,offset);
+               return;
+       }
 
-    CLOBBER_MOV;
-    s=readreg(s,4);
-    d=readreg(d,4);
+       CLOBBER_MOV;
+       s=readreg(s,4);
+       d=readreg(d,4);
 
-    raw_mov_l_Rr(d,s,offset);
-    unlock(d);
-    unlock(s);
+       raw_mov_l_Rr(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_l_Rr,(R4 d, R4 s, IMM offset))
 
-MIDFUNC(3,mov_w_Rr,(R4 d, R2 s, IMM offset))
+       MIDFUNC(3,mov_w_Rr,(R4 d, R2 s, IMM offset))
 {
-    if (isconst(d)) {
-       COMPCALL(mov_w_mr)(live.state[d].val+offset,s);
-       return;
-    }
-    if (isconst(s)) {
-       COMPCALL(mov_w_Ri)(d,(uae_u16)live.state[s].val,offset);
-       return;
-    }
+       if (isconst(d)) {
+               COMPCALL(mov_w_mr)(live.state[d].val+offset,s);
+               return;
+       }
+       if (isconst(s)) {
+               COMPCALL(mov_w_Ri)(d,(uae_u16)live.state[s].val,offset);
+               return;
+       }
 
-    CLOBBER_MOV;
-    s=readreg(s,2);
-    d=readreg(d,4);
-    raw_mov_w_Rr(d,s,offset);
-    unlock(d);
-    unlock(s);
+       CLOBBER_MOV;
+       s=readreg(s,2);
+       d=readreg(d,4);
+       raw_mov_w_Rr(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_w_Rr,(R4 d, R2 s, IMM offset))
 
-MIDFUNC(3,mov_b_Rr,(R4 d, R1 s, IMM offset))
+       MIDFUNC(3,mov_b_Rr,(R4 d, R1 s, IMM offset))
 {
-    if (isconst(d)) {
-       COMPCALL(mov_b_mr)(live.state[d].val+offset,s);
-       return;
-    }
-    if (isconst(s)) {
-       COMPCALL(mov_b_Ri)(d,(uae_u8)live.state[s].val,offset);
-       return;
-    }
+       if (isconst(d)) {
+               COMPCALL(mov_b_mr)(live.state[d].val+offset,s);
+               return;
+       }
+       if (isconst(s)) {
+               COMPCALL(mov_b_Ri)(d,(uae_u8)live.state[s].val,offset);
+               return;
+       }
 
-    CLOBBER_MOV;
-    s=readreg(s,1);
-    d=readreg(d,4);
-    raw_mov_b_Rr(d,s,offset);
-    unlock(d);
-    unlock(s);
+       CLOBBER_MOV;
+       s=readreg(s,1);
+       d=readreg(d,4);
+       raw_mov_b_Rr(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_b_Rr,(R4 d, R1 s, IMM offset))
 
-MIDFUNC(3,lea_l_brr,(W4 d, R4 s, IMM offset))
+       MIDFUNC(3,lea_l_brr,(W4 d, R4 s, IMM offset))
 {
-    if (isconst(s)) {
-       COMPCALL(mov_l_ri)(d,live.state[s].val+offset);
-       return;
-    }
+       if (isconst(s)) {
+               COMPCALL(mov_l_ri)(d,live.state[s].val+offset);
+               return;
+       }
 #if USE_OFFSET
-    if (d==s) {
-       add_offset(d,offset);
-       return;
-    }
+       if (d==s) {
+               add_offset(d,offset);
+               return;
+       }
 #endif
-    CLOBBER_LEA;
-    s=readreg(s,4);
-    d=writereg(d,4);
-    raw_lea_l_brr(d,s,offset);
-    unlock(d);
-    unlock(s);
+       CLOBBER_LEA;
+       s=readreg(s,4);
+       d=writereg(d,4);
+       raw_lea_l_brr(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,lea_l_brr,(W4 d, R4 s, IMM offset))
 
-MIDFUNC(5,lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset))
+       MIDFUNC(5,lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset))
 {
-    CLOBBER_LEA;
-    s=readreg(s,4);
-    index=readreg(index,4);
-    d=writereg(d,4);
+       CLOBBER_LEA;
+       s=readreg(s,4);
+       index=readreg(index,4);
+       d=writereg(d,4);
 
-    raw_lea_l_brr_indexed(d,s,index,factor,offset);
-    unlock(d);
-    unlock(index);
-    unlock(s);
+       raw_lea_l_brr_indexed(d,s,index,factor,offset);
+       unlock(d);
+       unlock(index);
+       unlock(s);
 }
 MENDFUNC(5,lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset))
 
-/* write d to the long at the address contained in s+offset */
-MIDFUNC(3,mov_l_bRr,(R4 d, R4 s, IMM offset))
+       /* write d to the long at the address contained in s+offset */
+       MIDFUNC(3,mov_l_bRr,(R4 d, R4 s, IMM offset))
 {
-    int dreg=d;
-    if (isconst(d)) {
-       COMPCALL(mov_l_mr)(live.state[d].val+offset,s);
-       return;
-    }
+       int dreg=d;
+       if (isconst(d)) {
+               COMPCALL(mov_l_mr)(live.state[d].val+offset,s);
+               return;
+       }
 
-    CLOBBER_MOV;
-    s=readreg(s,4);
-    d=readreg_offset(d,4);
-    offset+=get_offset(dreg);
+       CLOBBER_MOV;
+       s=readreg(s,4);
+       d=readreg_offset(d,4);
+       offset+=get_offset(dreg);
 
-    raw_mov_l_bRr(d,s,offset);
-    unlock(d);
-    unlock(s);
+       raw_mov_l_bRr(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_l_bRr,(R4 d, R4 s, IMM offset))
 
-/* write the word at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_w_bRr,(R4 d, R2 s, IMM offset))
+       /* write the word at the address contained in s+offset and store in d */
+       MIDFUNC(3,mov_w_bRr,(R4 d, R2 s, IMM offset))
 {
-    int dreg=d;
+       int dreg=d;
 
-    if (isconst(d)) {
-       COMPCALL(mov_w_mr)(live.state[d].val+offset,s);
-       return;
-    }
+       if (isconst(d)) {
+               COMPCALL(mov_w_mr)(live.state[d].val+offset,s);
+               return;
+       }
 
-    CLOBBER_MOV;
-    s=readreg(s,2);
-    d=readreg_offset(d,4);
-    offset+=get_offset(dreg);
-    raw_mov_w_bRr(d,s,offset);
-    unlock(d);
-    unlock(s);
+       CLOBBER_MOV;
+       s=readreg(s,2);
+       d=readreg_offset(d,4);
+       offset+=get_offset(dreg);
+       raw_mov_w_bRr(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_w_bRr,(R4 d, R2 s, IMM offset))
 
-MIDFUNC(3,mov_b_bRr,(R4 d, R1 s, IMM offset))
+       MIDFUNC(3,mov_b_bRr,(R4 d, R1 s, IMM offset))
 {
-    int dreg=d;
-    if (isconst(d)) {
-       COMPCALL(mov_b_mr)(live.state[d].val+offset,s);
-       return;
-    }
+       int dreg=d;
+       if (isconst(d)) {
+               COMPCALL(mov_b_mr)(live.state[d].val+offset,s);
+               return;
+       }
 
-    CLOBBER_MOV;
-    s=readreg(s,1);
-    d=readreg_offset(d,4);
-    offset+=get_offset(dreg);
-    raw_mov_b_bRr(d,s,offset);
-    unlock(d);
-    unlock(s);
+       CLOBBER_MOV;
+       s=readreg(s,1);
+       d=readreg_offset(d,4);
+       offset+=get_offset(dreg);
+       raw_mov_b_bRr(d,s,offset);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(3,mov_b_bRr,(R4 d, R1 s, IMM offset))
 
-MIDFUNC(1,gen_bswap_32,(RW4 r))
+       MIDFUNC(1,gen_bswap_32,(RW4 r))
 {
-    int reg=r;
+       int reg=r;
 
-    if (isconst(r)) {
-       uae_u32 oldv=live.state[r].val;
-       live.state[r].val=reverse32(oldv);
-       return;
-    }
+       if (isconst(r)) {
+               uae_u32 oldv=live.state[r].val;
+               live.state[r].val=reverse32(oldv);
+               return;
+       }
 
-    CLOBBER_SW32;
-    r=rmw(r,4,4);
-    raw_bswap_32(r);
-    unlock(r);
+       CLOBBER_SW32;
+       r=rmw(r,4,4);
+       raw_bswap_32(r);
+       unlock(r);
 }
 MENDFUNC(1,gen_bswap_32,(RW4 r))
 
-MIDFUNC(1,gen_bswap_16,(RW2 r))
+       MIDFUNC(1,gen_bswap_16,(RW2 r))
 {
-    if (isconst(r)) {
-       uae_u32 oldv=live.state[r].val;
-       live.state[r].val=((oldv>>8)&0xff) | ((oldv<<8)&0xff00) |
-           (oldv&0xffff0000);
-       return;
-    }
+       if (isconst(r)) {
+               uae_u32 oldv=live.state[r].val;
+               live.state[r].val=((oldv>>8)&0xff) | ((oldv<<8)&0xff00) |
+                       (oldv&0xffff0000);
+               return;
+       }
 
-    CLOBBER_SW16;
-    r=rmw(r,2,2);
+       CLOBBER_SW16;
+       r=rmw(r,2,2);
 
-    raw_bswap_16(r);
-    unlock(r);
+       raw_bswap_16(r);
+       unlock(r);
 }
 MENDFUNC(1,gen_bswap_16,(RW2 r))
 
 
 
-MIDFUNC(2,mov_l_rr,(W4 d, R4 s))
+       MIDFUNC(2,mov_l_rr,(W4 d, R4 s))
 {
-    int olds;
+       int olds;
 
-    if (d==s) { /* How pointless! */
-       return;
-    }
-    if (isconst(s)) {
-       COMPCALL(mov_l_ri)(d,live.state[s].val);
-       return;
-    }
+       if (d==s) { /* How pointless! */
+               return;
+       }
+       if (isconst(s)) {
+               COMPCALL(mov_l_ri)(d,live.state[s].val);
+               return;
+       }
 #if USE_ALIAS
-    olds=s;
-    disassociate(d);
-    s=readreg_offset(s,4);
-    live.state[d].realreg=s;
-    live.state[d].realind=live.nat[s].nholds;
-    live.state[d].val=live.state[olds].val;
-    live.state[d].validsize=4;
-    live.state[d].dirtysize=4;
-    set_status(d,DIRTY);
-
-    live.nat[s].holds[live.nat[s].nholds]=d;
-    live.nat[s].nholds++;
-    log_clobberreg(d);
-
-    /* write_log (L"JIT: Added %d to nreg %d(%d), now holds %d regs\n",
-       d,s,live.state[d].realind,live.nat[s].nholds); */
-    unlock(s);
+       olds=s;
+       disassociate(d);
+       s=readreg_offset(s,4);
+       live.state[d].realreg=s;
+       live.state[d].realind=live.nat[s].nholds;
+       live.state[d].val=live.state[olds].val;
+       live.state[d].validsize=4;
+       live.state[d].dirtysize=4;
+       set_status(d,DIRTY);
+
+       live.nat[s].holds[live.nat[s].nholds]=d;
+       live.nat[s].nholds++;
+       log_clobberreg(d);
+
+       /* write_log (L"JIT: Added %d to nreg %d(%d), now holds %d regs\n",
+       d,s,live.state[d].realind,live.nat[s].nholds); */
+       unlock(s);
 #else
-    CLOBBER_MOV;
-    s=readreg(s,4);
-    d=writereg(d,4);
+       CLOBBER_MOV;
+       s=readreg(s,4);
+       d=writereg(d,4);
 
-    raw_mov_l_rr(d,s);
-    unlock(d);
-    unlock(s);
+       raw_mov_l_rr(d,s);
+       unlock(d);
+       unlock(s);
 #endif
 }
 MENDFUNC(2,mov_l_rr,(W4 d, R4 s))
 
-MIDFUNC(2,mov_l_mr,(IMM d, R4 s))
+       MIDFUNC(2,mov_l_mr,(IMM d, R4 s))
 {
-    if (isconst(s)) {
-       COMPCALL(mov_l_mi)(d,live.state[s].val);
-       return;
-    }
-    CLOBBER_MOV;
-    s=readreg(s,4);
+       if (isconst(s)) {
+               COMPCALL(mov_l_mi)(d,live.state[s].val);
+               return;
+       }
+       CLOBBER_MOV;
+       s=readreg(s,4);
 
-    raw_mov_l_mr(d,s);
-    unlock(s);
+       raw_mov_l_mr(d,s);
+       unlock(s);
 }
 MENDFUNC(2,mov_l_mr,(IMM d, R4 s))
 
 
-MIDFUNC(2,mov_w_mr,(IMM d, R2 s))
+       MIDFUNC(2,mov_w_mr,(IMM d, R2 s))
 {
-    if (isconst(s)) {
-       COMPCALL(mov_w_mi)(d,(uae_u16)live.state[s].val);
-       return;
-    }
-    CLOBBER_MOV;
-    s=readreg(s,2);
+       if (isconst(s)) {
+               COMPCALL(mov_w_mi)(d,(uae_u16)live.state[s].val);
+               return;
+       }
+       CLOBBER_MOV;
+       s=readreg(s,2);
 
-    raw_mov_w_mr(d,s);
-    unlock(s);
+       raw_mov_w_mr(d,s);
+       unlock(s);
 }
 MENDFUNC(2,mov_w_mr,(IMM d, R2 s))
 
-MIDFUNC(2,mov_w_rm,(W2 d, IMM s))
+       MIDFUNC(2,mov_w_rm,(W2 d, IMM s))
 {
-    CLOBBER_MOV;
-    d=writereg(d,2);
+       CLOBBER_MOV;
+       d=writereg(d,2);
 
-    raw_mov_w_rm(d,s);
-    unlock(d);
+       raw_mov_w_rm(d,s);
+       unlock(d);
 }
 MENDFUNC(2,mov_w_rm,(W2 d, IMM s))
 
-MIDFUNC(2,mov_b_mr,(IMM d, R1 s))
+       MIDFUNC(2,mov_b_mr,(IMM d, R1 s))
 {
-    if (isconst(s)) {
-       COMPCALL(mov_b_mi)(d,(uae_u8)live.state[s].val);
-       return;
-    }
+       if (isconst(s)) {
+               COMPCALL(mov_b_mi)(d,(uae_u8)live.state[s].val);
+               return;
+       }
 
-    CLOBBER_MOV;
-    s=readreg(s,1);
+       CLOBBER_MOV;
+       s=readreg(s,1);
 
-    raw_mov_b_mr(d,s);
-    unlock(s);
+       raw_mov_b_mr(d,s);
+       unlock(s);
 }
 MENDFUNC(2,mov_b_mr,(IMM d, R1 s))
 
-MIDFUNC(2,mov_b_rm,(W1 d, IMM s))
+       MIDFUNC(2,mov_b_rm,(W1 d, IMM s))
 {
-    CLOBBER_MOV;
-    d=writereg(d,1);
+       CLOBBER_MOV;
+       d=writereg(d,1);
 
-    raw_mov_b_rm(d,s);
-    unlock(d);
+       raw_mov_b_rm(d,s);
+       unlock(d);
 }
 MENDFUNC(2,mov_b_rm,(W1 d, IMM s))
 
-MIDFUNC(2,mov_l_ri,(W4 d, IMM s))
+       MIDFUNC(2,mov_l_ri,(W4 d, IMM s))
 {
-    set_const(d,s);
-    return;
+       set_const(d,s);
+       return;
 }
 MENDFUNC(2,mov_l_ri,(W4 d, IMM s))
 
-MIDFUNC(2,mov_w_ri,(W2 d, IMM s))
+       MIDFUNC(2,mov_w_ri,(W2 d, IMM s))
 {
-    CLOBBER_MOV;
-    d=writereg(d,2);
+       CLOBBER_MOV;
+       d=writereg(d,2);
 
-    raw_mov_w_ri(d,s);
-    unlock(d);
+       raw_mov_w_ri(d,s);
+       unlock(d);
 }
 MENDFUNC(2,mov_w_ri,(W2 d, IMM s))
 
-MIDFUNC(2,mov_b_ri,(W1 d, IMM s))
+       MIDFUNC(2,mov_b_ri,(W1 d, IMM s))
 {
-    CLOBBER_MOV;
-    d=writereg(d,1);
+       CLOBBER_MOV;
+       d=writereg(d,1);
 
-    raw_mov_b_ri(d,s);
-    unlock(d);
+       raw_mov_b_ri(d,s);
+       unlock(d);
 }
 MENDFUNC(2,mov_b_ri,(W1 d, IMM s))
 
 
-MIDFUNC(2,add_l_mi,(IMM d, IMM s))
+       MIDFUNC(2,add_l_mi,(IMM d, IMM s))
 {
-    CLOBBER_ADD;
-    raw_add_l_mi(d,s) ;
+       CLOBBER_ADD;
+       raw_add_l_mi(d,s) ;
 }
 MENDFUNC(2,add_l_mi,(IMM d, IMM s))
 
-MIDFUNC(2,add_w_mi,(IMM d, IMM s))
+       MIDFUNC(2,add_w_mi,(IMM d, IMM s))
 {
-    CLOBBER_ADD;
-    raw_add_w_mi(d,s) ;
+       CLOBBER_ADD;
+       raw_add_w_mi(d,s) ;
 }
 MENDFUNC(2,add_w_mi,(IMM d, IMM s))
 
-MIDFUNC(2,add_b_mi,(IMM d, IMM s))
+       MIDFUNC(2,add_b_mi,(IMM d, IMM s))
 {
-    CLOBBER_ADD;
-    raw_add_b_mi(d,s) ;
+       CLOBBER_ADD;
+       raw_add_b_mi(d,s) ;
 }
 MENDFUNC(2,add_b_mi,(IMM d, IMM s))
 
 
-MIDFUNC(2,test_l_ri,(R4 d, IMM i))
+       MIDFUNC(2,test_l_ri,(R4 d, IMM i))
 {
-    CLOBBER_TEST;
-    d=readreg(d,4);
+       CLOBBER_TEST;
+       d=readreg(d,4);
 
-    raw_test_l_ri(d,i);
-    unlock(d);
+       raw_test_l_ri(d,i);
+       unlock(d);
 }
 MENDFUNC(2,test_l_ri,(R4 d, IMM i))
 
-MIDFUNC(2,test_l_rr,(R4 d, R4 s))
+       MIDFUNC(2,test_l_rr,(R4 d, R4 s))
 {
-    CLOBBER_TEST;
-    d=readreg(d,4);
-    s=readreg(s,4);
+       CLOBBER_TEST;
+       d=readreg(d,4);
+       s=readreg(s,4);
 
-    raw_test_l_rr(d,s);;
-    unlock(d);
-    unlock(s);
+       raw_test_l_rr(d,s);;
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,test_l_rr,(R4 d, R4 s))
 
-MIDFUNC(2,test_w_rr,(R2 d, R2 s))
+       MIDFUNC(2,test_w_rr,(R2 d, R2 s))
 {
-    CLOBBER_TEST;
-    d=readreg(d,2);
-    s=readreg(s,2);
+       CLOBBER_TEST;
+       d=readreg(d,2);
+       s=readreg(s,2);
 
-    raw_test_w_rr(d,s);
-    unlock(d);
-    unlock(s);
+       raw_test_w_rr(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,test_w_rr,(R2 d, R2 s))
 
-MIDFUNC(2,test_b_rr,(R1 d, R1 s))
+       MIDFUNC(2,test_b_rr,(R1 d, R1 s))
 {
-    CLOBBER_TEST;
-    d=readreg(d,1);
-    s=readreg(s,1);
+       CLOBBER_TEST;
+       d=readreg(d,1);
+       s=readreg(s,1);
 
-    raw_test_b_rr(d,s);
-    unlock(d);
-    unlock(s);
+       raw_test_b_rr(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,test_b_rr,(R1 d, R1 s))
 
-MIDFUNC(2,and_l_ri,(RW4 d, IMM i))
+       MIDFUNC(2,and_l_ri,(RW4 d, IMM i))
 {
-    if (isconst (d) && ! needflags) {
-       live.state[d].val &= i;
-       return;
-    }
+       if (isconst (d) && ! needflags) {
+               live.state[d].val &= i;
+               return;
+       }
 
-    CLOBBER_AND;
-    d=rmw(d,4,4);
+       CLOBBER_AND;
+       d=rmw(d,4,4);
 
-    raw_and_l_ri(d,i);
-    unlock(d);
+       raw_and_l_ri(d,i);
+       unlock(d);
 }
 MENDFUNC(2,and_l_ri,(RW4 d, IMM i))
 
-MIDFUNC(2,and_l,(RW4 d, R4 s))
+       MIDFUNC(2,and_l,(RW4 d, R4 s))
 {
-    CLOBBER_AND;
-    s=readreg(s,4);
-    d=rmw(d,4,4);
+       CLOBBER_AND;
+       s=readreg(s,4);
+       d=rmw(d,4,4);
 
-    raw_and_l(d,s);
-    unlock(d);
-    unlock(s);
+       raw_and_l(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,and_l,(RW4 d, R4 s))
 
-MIDFUNC(2,and_w,(RW2 d, R2 s))
+       MIDFUNC(2,and_w,(RW2 d, R2 s))
 {
-    CLOBBER_AND;
-    s=readreg(s,2);
-    d=rmw(d,2,2);
+       CLOBBER_AND;
+       s=readreg(s,2);
+       d=rmw(d,2,2);
 
-    raw_and_w(d,s);
-    unlock(d);
-    unlock(s);
+       raw_and_w(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,and_w,(RW2 d, R2 s))
 
-MIDFUNC(2,and_b,(RW1 d, R1 s))
+       MIDFUNC(2,and_b,(RW1 d, R1 s))
 {
-    CLOBBER_AND;
-    s=readreg(s,1);
-    d=rmw(d,1,1);
+       CLOBBER_AND;
+       s=readreg(s,1);
+       d=rmw(d,1,1);
 
-    raw_and_b(d,s);
-    unlock(d);
-    unlock(s);
+       raw_and_b(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,and_b,(RW1 d, R1 s))
 
-MIDFUNC(2,or_l_ri,(RW4 d, IMM i))
+       MIDFUNC(2,or_l_ri,(RW4 d, IMM i))
 {
-    if (isconst(d) && !needflags) {
-       live.state[d].val|=i;
-       return;
-    }
-    CLOBBER_OR;
-    d=rmw(d,4,4);
+       if (isconst(d) && !needflags) {
+               live.state[d].val|=i;
+               return;
+       }
+       CLOBBER_OR;
+       d=rmw(d,4,4);
 
-    raw_or_l_ri(d,i);
-    unlock(d);
+       raw_or_l_ri(d,i);
+       unlock(d);
 }
 MENDFUNC(2,or_l_ri,(RW4 d, IMM i))
 
-MIDFUNC(2,or_l,(RW4 d, R4 s))
+       MIDFUNC(2,or_l,(RW4 d, R4 s))
 {
-    if (isconst(d) && isconst(s) && !needflags) {
-       live.state[d].val|=live.state[s].val;
-       return;
-    }
-    CLOBBER_OR;
-    s=readreg(s,4);
-    d=rmw(d,4,4);
+       if (isconst(d) && isconst(s) && !needflags) {
+               live.state[d].val|=live.state[s].val;
+               return;
+       }
+       CLOBBER_OR;
+       s=readreg(s,4);
+       d=rmw(d,4,4);
 
-    raw_or_l(d,s);
-    unlock(d);
-    unlock(s);
+       raw_or_l(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,or_l,(RW4 d, R4 s))
 
-MIDFUNC(2,or_w,(RW2 d, R2 s))
+       MIDFUNC(2,or_w,(RW2 d, R2 s))
 {
-    CLOBBER_OR;
-    s=readreg(s,2);
-    d=rmw(d,2,2);
+       CLOBBER_OR;
+       s=readreg(s,2);
+       d=rmw(d,2,2);
 
-    raw_or_w(d,s);
-    unlock(d);
-    unlock(s);
+       raw_or_w(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,or_w,(RW2 d, R2 s))
 
-MIDFUNC(2,or_b,(RW1 d, R1 s))
+       MIDFUNC(2,or_b,(RW1 d, R1 s))
 {
-    CLOBBER_OR;
-    s=readreg(s,1);
-    d=rmw(d,1,1);
+       CLOBBER_OR;
+       s=readreg(s,1);
+       d=rmw(d,1,1);
 
-    raw_or_b(d,s);
-    unlock(d);
-    unlock(s);
+       raw_or_b(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,or_b,(RW1 d, R1 s))
 
-MIDFUNC(2,adc_l,(RW4 d, R4 s))
+       MIDFUNC(2,adc_l,(RW4 d, R4 s))
 {
-    CLOBBER_ADC;
-    s=readreg(s,4);
-    d=rmw(d,4,4);
+       CLOBBER_ADC;
+       s=readreg(s,4);
+       d=rmw(d,4,4);
 
-    raw_adc_l(d,s);
+       raw_adc_l(d,s);
 
-    unlock(d);
-    unlock(s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,adc_l,(RW4 d, R4 s))
 
-MIDFUNC(2,adc_w,(RW2 d, R2 s))
+       MIDFUNC(2,adc_w,(RW2 d, R2 s))
 {
-    CLOBBER_ADC;
-    s=readreg(s,2);
-    d=rmw(d,2,2);
+       CLOBBER_ADC;
+       s=readreg(s,2);
+       d=rmw(d,2,2);
 
-    raw_adc_w(d,s);
-    unlock(d);
-    unlock(s);
+       raw_adc_w(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,adc_w,(RW2 d, R2 s))
 
-MIDFUNC(2,adc_b,(RW1 d, R1 s))
+       MIDFUNC(2,adc_b,(RW1 d, R1 s))
 {
-    CLOBBER_ADC;
-    s=readreg(s,1);
-    d=rmw(d,1,1);
+       CLOBBER_ADC;
+       s=readreg(s,1);
+       d=rmw(d,1,1);
 
-    raw_adc_b(d,s);
-    unlock(d);
-    unlock(s);
+       raw_adc_b(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,adc_b,(RW1 d, R1 s))
 
-MIDFUNC(2,add_l,(RW4 d, R4 s))
+       MIDFUNC(2,add_l,(RW4 d, R4 s))
 {
-    if (isconst(s)) {
-       COMPCALL(add_l_ri)(d,live.state[s].val);
-       return;
-    }
+       if (isconst(s)) {
+               COMPCALL(add_l_ri)(d,live.state[s].val);
+               return;
+       }
 
-    CLOBBER_ADD;
-    s=readreg(s,4);
-    d=rmw(d,4,4);
+       CLOBBER_ADD;
+       s=readreg(s,4);
+       d=rmw(d,4,4);
 
-    raw_add_l(d,s);
+       raw_add_l(d,s);
 
-    unlock(d);
-    unlock(s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,add_l,(RW4 d, R4 s))
 
-MIDFUNC(2,add_w,(RW2 d, R2 s))
+       MIDFUNC(2,add_w,(RW2 d, R2 s))
 {
-    if (isconst(s)) {
-       COMPCALL(add_w_ri)(d,(uae_u16)live.state[s].val);
-       return;
-    }
+       if (isconst(s)) {
+               COMPCALL(add_w_ri)(d,(uae_u16)live.state[s].val);
+               return;
+       }
 
-    CLOBBER_ADD;
-    s=readreg(s,2);
-    d=rmw(d,2,2);
+       CLOBBER_ADD;
+       s=readreg(s,2);
+       d=rmw(d,2,2);
 
-    raw_add_w(d,s);
-    unlock(d);
-    unlock(s);
+       raw_add_w(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,add_w,(RW2 d, R2 s))
 
-MIDFUNC(2,add_b,(RW1 d, R1 s))
+       MIDFUNC(2,add_b,(RW1 d, R1 s))
 {
-    if (isconst(s)) {
-       COMPCALL(add_b_ri)(d,(uae_u8)live.state[s].val);
-       return;
-    }
+       if (isconst(s)) {
+               COMPCALL(add_b_ri)(d,(uae_u8)live.state[s].val);
+               return;
+       }
 
-    CLOBBER_ADD;
-    s=readreg(s,1);
-    d=rmw(d,1,1);
+       CLOBBER_ADD;
+       s=readreg(s,1);
+       d=rmw(d,1,1);
 
-    raw_add_b(d,s);
-    unlock(d);
-    unlock(s);
+       raw_add_b(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,add_b,(RW1 d, R1 s))
 
-MIDFUNC(2,sub_l_ri,(RW4 d, IMM i))
+       MIDFUNC(2,sub_l_ri,(RW4 d, IMM i))
 {
-    if (!i && !needflags)
-       return;
-    if (isconst(d) && !needflags) {
-       live.state[d].val-=i;
-       return;
-    }
+       if (!i && !needflags)
+               return;
+       if (isconst(d) && !needflags) {
+               live.state[d].val-=i;
+               return;
+       }
 #if USE_OFFSET
-    if (!needflags) {
-       add_offset(d,-(signed)i);
-       return;
-    }
+       if (!needflags) {
+               add_offset(d,-(signed)i);
+               return;
+       }
 #endif
 
-    CLOBBER_SUB;
-    d=rmw(d,4,4);
+       CLOBBER_SUB;
+       d=rmw(d,4,4);
 
-    raw_sub_l_ri(d,i);
-    unlock(d);
+       raw_sub_l_ri(d,i);
+       unlock(d);
 }
 MENDFUNC(2,sub_l_ri,(RW4 d, IMM i))
 
-MIDFUNC(2,sub_w_ri,(RW2 d, IMM i))
+       MIDFUNC(2,sub_w_ri,(RW2 d, IMM i))
 {
-    if (!i && !needflags)
-       return;
+       if (!i && !needflags)
+               return;
 
-    CLOBBER_SUB;
-    d=rmw(d,2,2);
+       CLOBBER_SUB;
+       d=rmw(d,2,2);
 
-    raw_sub_w_ri(d,i);
-    unlock(d);
+       raw_sub_w_ri(d,i);
+       unlock(d);
 }
 MENDFUNC(2,sub_w_ri,(RW2 d, IMM i))
 
-MIDFUNC(2,sub_b_ri,(RW1 d, IMM i))
+       MIDFUNC(2,sub_b_ri,(RW1 d, IMM i))
 {
-    if (!i && !needflags)
-       return;
+       if (!i && !needflags)
+               return;
 
-    CLOBBER_SUB;
-    d=rmw(d,1,1);
+       CLOBBER_SUB;
+       d=rmw(d,1,1);
 
-    raw_sub_b_ri(d,i);
+       raw_sub_b_ri(d,i);
 
-    unlock(d);
+       unlock(d);
 }
 MENDFUNC(2,sub_b_ri,(RW1 d, IMM i))
 
-MIDFUNC(2,add_l_ri,(RW4 d, IMM i))
+       MIDFUNC(2,add_l_ri,(RW4 d, IMM i))
 {
-    if (!i && !needflags)
-       return;
-    if (isconst(d) && !needflags) {
-       live.state[d].val+=i;
-       return;
-    }
+       if (!i && !needflags)
+               return;
+       if (isconst(d) && !needflags) {
+               live.state[d].val+=i;
+               return;
+       }
 #if USE_OFFSET
-    if (!needflags) {
-       add_offset(d,i);
-       return;
-    }
+       if (!needflags) {
+               add_offset(d,i);
+               return;
+       }
 #endif
-    CLOBBER_ADD;
-    d=rmw(d,4,4);
-    raw_add_l_ri(d,i);
-    unlock(d);
+       CLOBBER_ADD;
+       d=rmw(d,4,4);
+       raw_add_l_ri(d,i);
+       unlock(d);
 }
 MENDFUNC(2,add_l_ri,(RW4 d, IMM i))
 
-MIDFUNC(2,add_w_ri,(RW2 d, IMM i))
+       MIDFUNC(2,add_w_ri,(RW2 d, IMM i))
 {
-    if (!i && !needflags)
-       return;
+       if (!i && !needflags)
+               return;
 
-    CLOBBER_ADD;
-    d=rmw(d,2,2);
+       CLOBBER_ADD;
+       d=rmw(d,2,2);
 
-    raw_add_w_ri(d,i);
-    unlock(d);
+       raw_add_w_ri(d,i);
+       unlock(d);
 }
 MENDFUNC(2,add_w_ri,(RW2 d, IMM i))
 
-MIDFUNC(2,add_b_ri,(RW1 d, IMM i))
+       MIDFUNC(2,add_b_ri,(RW1 d, IMM i))
 {
-    if (!i && !needflags)
-       return;
+       if (!i && !needflags)
+               return;
 
-    CLOBBER_ADD;
-    d=rmw(d,1,1);
+       CLOBBER_ADD;
+       d=rmw(d,1,1);
 
-    raw_add_b_ri(d,i);
+       raw_add_b_ri(d,i);
 
-    unlock(d);
+       unlock(d);
 }
 MENDFUNC(2,add_b_ri,(RW1 d, IMM i))
 
-MIDFUNC(2,sbb_l,(RW4 d, R4 s))
+       MIDFUNC(2,sbb_l,(RW4 d, R4 s))
 {
-    CLOBBER_SBB;
-    s=readreg(s,4);
-    d=rmw(d,4,4);
+       CLOBBER_SBB;
+       s=readreg(s,4);
+       d=rmw(d,4,4);
 
-    raw_sbb_l(d,s);
-    unlock(d);
-    unlock(s);
+       raw_sbb_l(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,sbb_l,(RW4 d, R4 s))
 
-MIDFUNC(2,sbb_w,(RW2 d, R2 s))
+       MIDFUNC(2,sbb_w,(RW2 d, R2 s))
 {
-    CLOBBER_SBB;
-    s=readreg(s,2);
-    d=rmw(d,2,2);
+       CLOBBER_SBB;
+       s=readreg(s,2);
+       d=rmw(d,2,2);
 
-    raw_sbb_w(d,s);
-    unlock(d);
-    unlock(s);
+       raw_sbb_w(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,sbb_w,(RW2 d, R2 s))
 
-MIDFUNC(2,sbb_b,(RW1 d, R1 s))
+       MIDFUNC(2,sbb_b,(RW1 d, R1 s))
 {
-    CLOBBER_SBB;
-    s=readreg(s,1);
-    d=rmw(d,1,1);
+       CLOBBER_SBB;
+       s=readreg(s,1);
+       d=rmw(d,1,1);
 
-    raw_sbb_b(d,s);
-    unlock(d);
-    unlock(s);
+       raw_sbb_b(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,sbb_b,(RW1 d, R1 s))
 
-MIDFUNC(2,sub_l,(RW4 d, R4 s))
+       MIDFUNC(2,sub_l,(RW4 d, R4 s))
 {
-    if (isconst(s)) {
-       COMPCALL(sub_l_ri)(d,live.state[s].val);
-       return;
-    }
+       if (isconst(s)) {
+               COMPCALL(sub_l_ri)(d,live.state[s].val);
+               return;
+       }
 
-    CLOBBER_SUB;
-    s=readreg(s,4);
-    d=rmw(d,4,4);
+       CLOBBER_SUB;
+       s=readreg(s,4);
+       d=rmw(d,4,4);
 
-    raw_sub_l(d,s);
-    unlock(d);
-    unlock(s);
+       raw_sub_l(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,sub_l,(RW4 d, R4 s))
 
-MIDFUNC(2,sub_w,(RW2 d, R2 s))
+       MIDFUNC(2,sub_w,(RW2 d, R2 s))
 {
-    if (isconst(s)) {
-       COMPCALL(sub_w_ri)(d,(uae_u16)live.state[s].val);
-       return;
-    }
+       if (isconst(s)) {
+               COMPCALL(sub_w_ri)(d,(uae_u16)live.state[s].val);
+               return;
+       }
 
-    CLOBBER_SUB;
-    s=readreg(s,2);
-    d=rmw(d,2,2);
+       CLOBBER_SUB;
+       s=readreg(s,2);
+       d=rmw(d,2,2);
 
-    raw_sub_w(d,s);
-    unlock(d);
-    unlock(s);
+       raw_sub_w(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,sub_w,(RW2 d, R2 s))
 
-MIDFUNC(2,sub_b,(RW1 d, R1 s))
+       MIDFUNC(2,sub_b,(RW1 d, R1 s))
 {
-    if (isconst(s)) {
-       COMPCALL(sub_b_ri)(d,(uae_u8)live.state[s].val);
-       return;
-    }
+       if (isconst(s)) {
+               COMPCALL(sub_b_ri)(d,(uae_u8)live.state[s].val);
+               return;
+       }
 
-    CLOBBER_SUB;
-    s=readreg(s,1);
-    d=rmw(d,1,1);
+       CLOBBER_SUB;
+       s=readreg(s,1);
+       d=rmw(d,1,1);
 
-    raw_sub_b(d,s);
-    unlock(d);
-    unlock(s);
+       raw_sub_b(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,sub_b,(RW1 d, R1 s))
 
-MIDFUNC(2,cmp_l,(R4 d, R4 s))
+       MIDFUNC(2,cmp_l,(R4 d, R4 s))
 {
-    CLOBBER_CMP;
-    s=readreg(s,4);
-    d=readreg(d,4);
+       CLOBBER_CMP;
+       s=readreg(s,4);
+       d=readreg(d,4);
 
-    raw_cmp_l(d,s);
-    unlock(d);
-    unlock(s);
+       raw_cmp_l(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,cmp_l,(R4 d, R4 s))
 
-MIDFUNC(2,cmp_l_ri,(R4 r, IMM i))
+       MIDFUNC(2,cmp_l_ri,(R4 r, IMM i))
 {
-    CLOBBER_CMP;
-    r=readreg(r,4);
+       CLOBBER_CMP;
+       r=readreg(r,4);
 
-    raw_cmp_l_ri(r,i);
-    unlock(r);
+       raw_cmp_l_ri(r,i);
+       unlock(r);
 }
 MENDFUNC(2,cmp_l_ri,(R4 r, IMM i))
 
-MIDFUNC(2,cmp_w,(R2 d, R2 s))
+       MIDFUNC(2,cmp_w,(R2 d, R2 s))
 {
-    CLOBBER_CMP;
-    s=readreg(s,2);
-    d=readreg(d,2);
+       CLOBBER_CMP;
+       s=readreg(s,2);
+       d=readreg(d,2);
 
-    raw_cmp_w(d,s);
-    unlock(d);
-    unlock(s);
+       raw_cmp_w(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,cmp_w,(R2 d, R2 s))
 
-MIDFUNC(2,cmp_b,(R1 d, R1 s))
+       MIDFUNC(2,cmp_b,(R1 d, R1 s))
 {
-    CLOBBER_CMP;
-    s=readreg(s,1);
-    d=readreg(d,1);
+       CLOBBER_CMP;
+       s=readreg(s,1);
+       d=readreg(d,1);
 
-    raw_cmp_b(d,s);
-    unlock(d);
-    unlock(s);
+       raw_cmp_b(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,cmp_b,(R1 d, R1 s))
 
 
-MIDFUNC(2,xor_l,(RW4 d, R4 s))
+       MIDFUNC(2,xor_l,(RW4 d, R4 s))
 {
-    CLOBBER_XOR;
-    s=readreg(s,4);
-    d=rmw(d,4,4);
+       CLOBBER_XOR;
+       s=readreg(s,4);
+       d=rmw(d,4,4);
 
-    raw_xor_l(d,s);
-    unlock(d);
-    unlock(s);
+       raw_xor_l(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,xor_l,(RW4 d, R4 s))
 
-MIDFUNC(2,xor_w,(RW2 d, R2 s))
+       MIDFUNC(2,xor_w,(RW2 d, R2 s))
 {
-    CLOBBER_XOR;
-    s=readreg(s,2);
-    d=rmw(d,2,2);
+       CLOBBER_XOR;
+       s=readreg(s,2);
+       d=rmw(d,2,2);
 
-    raw_xor_w(d,s);
-    unlock(d);
-    unlock(s);
+       raw_xor_w(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,xor_w,(RW2 d, R2 s))
 
-MIDFUNC(2,xor_b,(RW1 d, R1 s))
+       MIDFUNC(2,xor_b,(RW1 d, R1 s))
 {
-    CLOBBER_XOR;
-    s=readreg(s,1);
-    d=rmw(d,1,1);
+       CLOBBER_XOR;
+       s=readreg(s,1);
+       d=rmw(d,1,1);
 
-    raw_xor_b(d,s);
-    unlock(d);
-    unlock(s);
+       raw_xor_b(d,s);
+       unlock(d);
+       unlock(s);
 }
 MENDFUNC(2,xor_b,(RW1 d, R1 s))
 
-MIDFUNC(5,call_r_11,(W4 out1, R4 r, R4 in1, IMM osize, IMM isize))
+       MIDFUNC(5,call_r_11,(W4 out1, R4 r, R4 in1, IMM osize, IMM isize))
 {
-    clobber_flags();
-    remove_all_offsets();
-    if (osize==4) {
-       if (out1!=in1 && out1!=r) {
-           COMPCALL(forget_about)(out1);
+       clobber_flags();
+       remove_all_offsets();
+       if (osize==4) {
+               if (out1!=in1 && out1!=r) {
+                       COMPCALL(forget_about)(out1);
+               }
+       }
+       else {
+               tomem_c(out1);
        }
-    }
-    else {
-       tomem_c(out1);
-    }
 
-    in1=readreg_specific(in1,isize,REG_PAR1);
-    r=readreg(r,4);
-    prepare_for_call_1();  /* This should ensure that there won't be
-                             any need for swapping nregs in prepare_for_call_2
-                          */
+       in1=readreg_specific(in1,isize,REG_PAR1);
+       r=readreg(r,4);
+       prepare_for_call_1();  /* This should ensure that there won't be
+                                                  any need for swapping nregs in prepare_for_call_2
+                                                  */
 #if USE_NORMAL_CALLING_CONVENTION
-    raw_push_l_r(in1);
+       raw_push_l_r(in1);
 #endif
-    unlock(in1);
-    unlock(r);
+       unlock(in1);
+       unlock(r);
 
-    prepare_for_call_2();
-    raw_call_r(r);
+       prepare_for_call_2();
+       raw_call_r(r);
 
 #if USE_NORMAL_CALLING_CONVENTION
-    raw_inc_sp(4);
+       raw_inc_sp(4);
 #endif
 
 
-    live.nat[REG_RESULT].holds[0]=out1;
-    live.nat[REG_RESULT].nholds=1;
-    live.nat[REG_RESULT].touched=touchcnt++;
+       live.nat[REG_RESULT].holds[0]=out1;
+       live.nat[REG_RESULT].nholds=1;
+       live.nat[REG_RESULT].touched=touchcnt++;
 
-    live.state[out1].realreg=REG_RESULT;
-    live.state[out1].realind=0;
-    live.state[out1].val=0;
-    live.state[out1].validsize=osize;
-    live.state[out1].dirtysize=osize;
-    set_status(out1,DIRTY);
+       live.state[out1].realreg=REG_RESULT;
+       live.state[out1].realind=0;
+       live.state[out1].val=0;
+       live.state[out1].validsize=osize;
+       live.state[out1].dirtysize=osize;
+       set_status(out1,DIRTY);
 }
 MENDFUNC(5,call_r_11,(W4 out1, R4 r, R4 in1, IMM osize, IMM isize))
 
-MIDFUNC(5,call_r_02,(R4 r, R4 in1, R4 in2, IMM isize1, IMM isize2))
+       MIDFUNC(5,call_r_02,(R4 r, R4 in1, R4 in2, IMM isize1, IMM isize2))
 {
-    clobber_flags();
-    remove_all_offsets();
-    in1=readreg_specific(in1,isize1,REG_PAR1);
-    in2=readreg_specific(in2,isize2,REG_PAR2);
-    r=readreg(r,4);
-    prepare_for_call_1();  /* This should ensure that there won't be
-                             any need for swapping nregs in prepare_for_call_2
-                          */
+       clobber_flags();
+       remove_all_offsets();
+       in1=readreg_specific(in1,isize1,REG_PAR1);
+       in2=readreg_specific(in2,isize2,REG_PAR2);
+       r=readreg(r,4);
+       prepare_for_call_1();  /* This should ensure that there won't be
+                                                  any need for swapping nregs in prepare_for_call_2
+                                                  */
 #if USE_NORMAL_CALLING_CONVENTION
-    raw_push_l_r(in2);
-    raw_push_l_r(in1);
+       raw_push_l_r(in2);
+       raw_push_l_r(in1);
 #endif
-    unlock(r);
-    unlock(in1);
-    unlock(in2);
-    prepare_for_call_2();
-    raw_call_r(r);
+       unlock(r);
+       unlock(in1);
+       unlock(in2);
+       prepare_for_call_2();
+       raw_call_r(r);
 #if USE_NORMAL_CALLING_CONVENTION
-    raw_inc_sp(8);
+       raw_inc_sp(8);
 #endif
 }
 MENDFUNC(5,call_r_02,(R4 r, R4 in1, R4 in2, IMM isize1, IMM isize2))
 
-MIDFUNC(1,forget_about,(W4 r))
+       MIDFUNC(1,forget_about,(W4 r))
 {
-    if (isinreg(r))
-       disassociate(r);
-    live.state[r].val=0;
-    set_status(r,UNDEF);
+       if (isinreg(r))
+               disassociate(r);
+       live.state[r].val=0;
+       set_status(r,UNDEF);
 }
 MENDFUNC(1,forget_about,(W4 r))
 
-MIDFUNC(0,nop,(void))
+       MIDFUNC(0,nop,(void))
 {
-    raw_nop();
+       raw_nop();
 }
 MENDFUNC(0,nop,(void))
 
-MIDFUNC(1,f_forget_about,(FW r))
+       MIDFUNC(1,f_forget_about,(FW r))
 {
-    if (f_isinreg(r))
-       f_disassociate(r);
-    live.fate[r].status=UNDEF;
+       if (f_isinreg(r))
+               f_disassociate(r);
+       live.fate[r].status=UNDEF;
 }
 MENDFUNC(1,f_forget_about,(FW r))
 
-MIDFUNC(1,fmov_pi,(FW r))
+       MIDFUNC(1,fmov_pi,(FW r))
 {
-    r=f_writereg(r);
-    raw_fmov_pi(r);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmov_pi(r);
+       f_unlock(r);
 }
 MENDFUNC(1,fmov_pi,(FW r))
 
-MIDFUNC(1,fmov_log10_2,(FW r))
+       MIDFUNC(1,fmov_log10_2,(FW r))
 {
-    r=f_writereg(r);
-    raw_fmov_log10_2(r);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmov_log10_2(r);
+       f_unlock(r);
 }
 MENDFUNC(1,fmov_log10_2,(FW r))
 
-MIDFUNC(1,fmov_log2_e,(FW r))
+       MIDFUNC(1,fmov_log2_e,(FW r))
 {
-    r=f_writereg(r);
-    raw_fmov_log2_e(r);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmov_log2_e(r);
+       f_unlock(r);
 }
 MENDFUNC(1,fmov_log2_e,(FW r))
 
-MIDFUNC(1,fmov_loge_2,(FW r))
+       MIDFUNC(1,fmov_loge_2,(FW r))
 {
-    r=f_writereg(r);
-    raw_fmov_loge_2(r);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmov_loge_2(r);
+       f_unlock(r);
 }
 MENDFUNC(1,fmov_loge_2,(FW r))
 
-MIDFUNC(1,fmov_1,(FW r))
+       MIDFUNC(1,fmov_1,(FW r))
 {
-    r=f_writereg(r);
-    raw_fmov_1(r);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmov_1(r);
+       f_unlock(r);
 }
 MENDFUNC(1,fmov_1,(FW r))
 
-MIDFUNC(1,fmov_0,(FW r))
+       MIDFUNC(1,fmov_0,(FW r))
 {
-    r=f_writereg(r);
-    raw_fmov_0(r);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmov_0(r);
+       f_unlock(r);
 }
 MENDFUNC(1,fmov_0,(FW r))
 
-MIDFUNC(2,fmov_rm,(FW r, MEMR m))
+       MIDFUNC(2,fmov_rm,(FW r, MEMR m))
 {
-    r=f_writereg(r);
-    raw_fmov_rm(r,m);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmov_rm(r,m);
+       f_unlock(r);
 }
 MENDFUNC(2,fmov_rm,(FW r, MEMR m))
 
-MIDFUNC(2,fmovi_rm,(FW r, MEMR m))
+       MIDFUNC(2,fmovi_rm,(FW r, MEMR m))
 {
-    r=f_writereg(r);
-    raw_fmovi_rm(r,m);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmovi_rm(r,m);
+       f_unlock(r);
 }
 MENDFUNC(2,fmovi_rm,(FW r, MEMR m))
 
-MIDFUNC(3,fmovi_mrb,(MEMW m, FR r, double *bounds))
+       MIDFUNC(3,fmovi_mrb,(MEMW m, FR r, double *bounds))
 {
-    r=f_readreg(r);
-    raw_fmovi_mrb(m,r,bounds);
-    f_unlock(r);
+       r=f_readreg(r);
+       raw_fmovi_mrb(m,r,bounds);
+       f_unlock(r);
 }
 MENDFUNC(3,fmovi_mrb,(MEMW m, FR r, double *bounds))
 
-MIDFUNC(2,fmovs_rm,(FW r, MEMR m))
+       MIDFUNC(2,fmovs_rm,(FW r, MEMR m))
 {
-    r=f_writereg(r);
-    raw_fmovs_rm(r,m);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmovs_rm(r,m);
+       f_unlock(r);
 }
 MENDFUNC(2,fmovs_rm,(FW r, MEMR m))
 
-MIDFUNC(2,fmovs_mr,(MEMW m, FR r))
+       MIDFUNC(2,fmovs_mr,(MEMW m, FR r))
 {
-    r=f_readreg(r);
-    raw_fmovs_mr(m,r);
-    f_unlock(r);
+       r=f_readreg(r);
+       raw_fmovs_mr(m,r);
+       f_unlock(r);
 }
 MENDFUNC(2,fmovs_mr,(MEMW m, FR r))
 
-MIDFUNC(1,fcuts_r,(FRW r))
+       MIDFUNC(1,fcuts_r,(FRW r))
 {
-    r=f_rmw(r);
-    raw_fcuts_r(r);
-    f_unlock(r);
+       r=f_rmw(r);
+       raw_fcuts_r(r);
+       f_unlock(r);
 }
 MENDFUNC(1,fcuts_r,(FRW r))
 
-MIDFUNC(1,fcut_r,(FRW r))
+       MIDFUNC(1,fcut_r,(FRW r))
 {
-    r=f_rmw(r);
-    raw_fcut_r(r);
-    f_unlock(r);
+       r=f_rmw(r);
+       raw_fcut_r(r);
+       f_unlock(r);
 }
 MENDFUNC(1,fcut_r,(FRW r))
 
-MIDFUNC(2,fmovl_ri,(FW r, IMMS i))
+       MIDFUNC(2,fmovl_ri,(FW r, IMMS i))
 {
-    r=f_writereg(r);
-    raw_fmovl_ri(r,i);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmovl_ri(r,i);
+       f_unlock(r);
 }
 MENDFUNC(2,fmovl_ri,(FW r, IMMS i))
 
-MIDFUNC(2,fmovs_ri,(FW r, IMM i))
+       MIDFUNC(2,fmovs_ri,(FW r, IMM i))
 {
-    r=f_writereg(r);
-    raw_fmovs_ri(r,i);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmovs_ri(r,i);
+       f_unlock(r);
 }
 MENDFUNC(2,fmovs_ri,(FW r, IMM i))
 
-MIDFUNC(3,fmov_ri,(FW r, IMM i1, IMM i2))
+       MIDFUNC(3,fmov_ri,(FW r, IMM i1, IMM i2))
 {
-    r=f_writereg(r);
-    raw_fmov_ri(r,i1,i2);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmov_ri(r,i1,i2);
+       f_unlock(r);
 }
 MENDFUNC(3,fmov_ri,(FW r, IMM i1, IMM i2))
 
-MIDFUNC(4,fmov_ext_ri,(FW r, IMM i1, IMM i2, IMM i3))
+       MIDFUNC(4,fmov_ext_ri,(FW r, IMM i1, IMM i2, IMM i3))
 {
-    r=f_writereg(r);
-    raw_fmov_ext_ri(r,i1,i2,i3);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmov_ext_ri(r,i1,i2,i3);
+       f_unlock(r);
 }
 MENDFUNC(4,fmov_ext_ri,(FW r, IMM i1, IMM i2, IMM i3))
 
-MIDFUNC(2,fmov_ext_mr,(MEMW m, FR r))
+       MIDFUNC(2,fmov_ext_mr,(MEMW m, FR r))
 {
-    r=f_readreg(r);
-    raw_fmov_ext_mr(m,r);
-    f_unlock(r);
+       r=f_readreg(r);
+       raw_fmov_ext_mr(m,r);
+       f_unlock(r);
 }
 MENDFUNC(2,fmov_ext_mr,(MEMW m, FR r))
 
-MIDFUNC(2,fmov_mr,(MEMW m, FR r))
+       MIDFUNC(2,fmov_mr,(MEMW m, FR r))
 {
-    r=f_readreg(r);
-    raw_fmov_mr(m,r);
-    f_unlock(r);
+       r=f_readreg(r);
+       raw_fmov_mr(m,r);
+       f_unlock(r);
 }
 MENDFUNC(2,fmov_mr,(MEMW m, FR r))
 
-MIDFUNC(2,fmov_ext_rm,(FW r, MEMR m))
+       MIDFUNC(2,fmov_ext_rm,(FW r, MEMR m))
 {
-    r=f_writereg(r);
-    raw_fmov_ext_rm(r,m);
-    f_unlock(r);
+       r=f_writereg(r);
+       raw_fmov_ext_rm(r,m);
+       f_unlock(r);
 }
 MENDFUNC(2,fmov_ext_rm,(FW r, MEMR m))
 
-MIDFUNC(2,fmov_rr,(FW d, FR s))
+       MIDFUNC(2,fmov_rr,(FW d, FR s))
 {
-    if (d==s) { /* How pointless! */
-       return;
-    }
+       if (d==s) { /* How pointless! */
+               return;
+       }
 #if USE_F_ALIAS
-    f_disassociate(d);
-    s=f_readreg(s);
-    live.fate[d].realreg=s;
-    live.fate[d].realind=live.fat[s].nholds;
-    live.fate[d].status=DIRTY;
-    live.fat[s].holds[live.fat[s].nholds]=d;
-    live.fat[s].nholds++;
-    f_unlock(s);
+       f_disassociate(d);
+       s=f_readreg(s);
+       live.fate[d].realreg=s;
+       live.fate[d].realind=live.fat[s].nholds;
+       live.fate[d].status=DIRTY;
+       live.fat[s].holds[live.fat[s].nholds]=d;
+       live.fat[s].nholds++;
+       f_unlock(s);
 #else
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fmov_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fmov_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 #endif
 }
 MENDFUNC(2,fmov_rr,(FW d, FR s))
 
-MIDFUNC(2,fldcw_m_indexed,(R4 index, IMM base))
+       MIDFUNC(2,fldcw_m_indexed,(R4 index, IMM base))
 {
-    index=readreg(index,4);
+       index=readreg(index,4);
 
-    raw_fldcw_m_indexed(index,base);
-    unlock(index);
+       raw_fldcw_m_indexed(index,base);
+       unlock(index);
 }
 MENDFUNC(2,fldcw_m_indexed,(R4 index, IMM base))
 
-MIDFUNC(1,ftst_r,(FR r))
+       MIDFUNC(1,ftst_r,(FR r))
 {
-    r=f_readreg(r);
-    raw_ftst_r(r);
-    f_unlock(r);
+       r=f_readreg(r);
+       raw_ftst_r(r);
+       f_unlock(r);
 }
 MENDFUNC(1,ftst_r,(FR r))
 
-MIDFUNC(0,dont_care_fflags,(void))
+       MIDFUNC(0,dont_care_fflags,(void))
 {
-    f_disassociate(FP_RESULT);
+       f_disassociate(FP_RESULT);
 }
 MENDFUNC(0,dont_care_fflags,(void))
 
-MIDFUNC(2,fsqrt_rr,(FW d, FR s))
+       MIDFUNC(2,fsqrt_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fsqrt_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fsqrt_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fsqrt_rr,(FW d, FR s))
 
-MIDFUNC(2,fabs_rr,(FW d, FR s))
+       MIDFUNC(2,fabs_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fabs_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fabs_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fabs_rr,(FW d, FR s))
 
-MIDFUNC(2,frndint_rr,(FW d, FR s))
+       MIDFUNC(2,frndint_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_frndint_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_frndint_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,frndint_rr,(FW d, FR s))
 
-MIDFUNC(2,fgetexp_rr,(FW d, FR s))
+       MIDFUNC(2,fgetexp_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fgetexp_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fgetexp_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fgetexp_rr,(FW d, FR s))
 
-MIDFUNC(2,fgetman_rr,(FW d, FR s))
+       MIDFUNC(2,fgetman_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fgetman_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fgetman_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fgetman_rr,(FW d, FR s))
 
-MIDFUNC(2,fsin_rr,(FW d, FR s))
+       MIDFUNC(2,fsin_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fsin_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fsin_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fsin_rr,(FW d, FR s))
 
-MIDFUNC(2,fcos_rr,(FW d, FR s))
+       MIDFUNC(2,fcos_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fcos_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fcos_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fcos_rr,(FW d, FR s))
 
-MIDFUNC(2,ftan_rr,(FW d, FR s))
+       MIDFUNC(2,ftan_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_ftan_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_ftan_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,ftan_rr,(FW d, FR s))
 
-MIDFUNC(3,fsincos_rr,(FW d, FW c, FR s))
+       MIDFUNC(3,fsincos_rr,(FW d, FW c, FR s))
 {
-    s=f_readreg(s);  /* s for source */
-    d=f_writereg(d); /* d for sine   */
-    c=f_writereg(c); /* c for cosine */
-    raw_fsincos_rr(d,c,s);
-    f_unlock(s);
-    f_unlock(d);
-    f_unlock(c);
+       s=f_readreg(s);  /* s for source */
+       d=f_writereg(d); /* d for sine   */
+       c=f_writereg(c); /* c for cosine */
+       raw_fsincos_rr(d,c,s);
+       f_unlock(s);
+       f_unlock(d);
+       f_unlock(c);
 }
 MENDFUNC(3,fsincos_rr,(FW d, FW c, FR s))
 
-MIDFUNC(2,fscale_rr,(FRW d, FR s))
+       MIDFUNC(2,fscale_rr,(FRW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_rmw(d);
-    raw_fscale_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_rmw(d);
+       raw_fscale_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fscale_rr,(FRW d, FR s))
 
-MIDFUNC(2,ftwotox_rr,(FW d, FR s))
+       MIDFUNC(2,ftwotox_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_ftwotox_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_ftwotox_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,ftwotox_rr,(FW d, FR s))
 
-MIDFUNC(2,fetox_rr,(FW d, FR s))
+       MIDFUNC(2,fetox_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fetox_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fetox_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fetox_rr,(FW d, FR s))
 
-MIDFUNC(2,fetoxM1_rr,(FW d, FR s))
+       MIDFUNC(2,fetoxM1_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fetoxM1_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fetoxM1_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fetoxM1_rr,(FW d, FR s))
 
-MIDFUNC(2,ftentox_rr,(FW d, FR s))
+       MIDFUNC(2,ftentox_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_ftentox_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_ftentox_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,ftentox_rr,(FW d, FR s))
 
-MIDFUNC(2,flog2_rr,(FW d, FR s))
+       MIDFUNC(2,flog2_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_flog2_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_flog2_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,flog2_rr,(FW d, FR s))
 
-MIDFUNC(2,flogN_rr,(FW d, FR s))
+       MIDFUNC(2,flogN_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_flogN_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_flogN_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,flogN_rr,(FW d, FR s))
 
-MIDFUNC(2,flogNP1_rr,(FW d, FR s))
+       MIDFUNC(2,flogNP1_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_flogNP1_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_flogNP1_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,flogNP1_rr,(FW d, FR s))
 
-MIDFUNC(2,flog10_rr,(FW d, FR s))
+       MIDFUNC(2,flog10_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_flog10_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_flog10_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,flog10_rr,(FW d, FR s))
 
-MIDFUNC(2,fasin_rr,(FW d, FR s))
+       MIDFUNC(2,fasin_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fasin_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fasin_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fasin_rr,(FW d, FR s))
 
-MIDFUNC(2,facos_rr,(FW d, FR s))
+       MIDFUNC(2,facos_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_facos_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_facos_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,facos_rr,(FW d, FR s))
 
-MIDFUNC(2,fatan_rr,(FW d, FR s))
+       MIDFUNC(2,fatan_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fatan_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fatan_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fatan_rr,(FW d, FR s))
 
-MIDFUNC(2,fatanh_rr,(FW d, FR s))
+       MIDFUNC(2,fatanh_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fatanh_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fatanh_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fatanh_rr,(FW d, FR s))
 
-MIDFUNC(2,fsinh_rr,(FW d, FR s))
+       MIDFUNC(2,fsinh_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fsinh_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fsinh_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fsinh_rr,(FW d, FR s))
 
-MIDFUNC(2,fcosh_rr,(FW d, FR s))
+       MIDFUNC(2,fcosh_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fcosh_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fcosh_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fcosh_rr,(FW d, FR s))
 
-MIDFUNC(2,ftanh_rr,(FW d, FR s))
+       MIDFUNC(2,ftanh_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_ftanh_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_ftanh_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,ftanh_rr,(FW d, FR s))
 
-MIDFUNC(2,fneg_rr,(FW d, FR s))
+       MIDFUNC(2,fneg_rr,(FW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_writereg(d);
-    raw_fneg_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_writereg(d);
+       raw_fneg_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fneg_rr,(FW d, FR s))
 
-MIDFUNC(2,fadd_rr,(FRW d, FR s))
+       MIDFUNC(2,fadd_rr,(FRW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_rmw(d);
-    raw_fadd_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_rmw(d);
+       raw_fadd_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fadd_rr,(FRW d, FR s))
 
-MIDFUNC(2,fsub_rr,(FRW d, FR s))
+       MIDFUNC(2,fsub_rr,(FRW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_rmw(d);
-    raw_fsub_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_rmw(d);
+       raw_fsub_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fsub_rr,(FRW d, FR s))
 
-MIDFUNC(2,fcmp_rr,(FR d, FR s))
+       MIDFUNC(2,fcmp_rr,(FR d, FR s))
 {
-    d=f_readreg(d);
-    s=f_readreg(s);
-    raw_fcmp_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       d=f_readreg(d);
+       s=f_readreg(s);
+       raw_fcmp_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fcmp_rr,(FR d, FR s))
 
-MIDFUNC(2,fdiv_rr,(FRW d, FR s))
+       MIDFUNC(2,fdiv_rr,(FRW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_rmw(d);
-    raw_fdiv_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_rmw(d);
+       raw_fdiv_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fdiv_rr,(FRW d, FR s))
 
-MIDFUNC(2,frem_rr,(FRW d, FR s))
+       MIDFUNC(2,frem_rr,(FRW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_rmw(d);
-    raw_frem_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_rmw(d);
+       raw_frem_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,frem_rr,(FRW d, FR s))
 
-MIDFUNC(2,frem1_rr,(FRW d, FR s))
+       MIDFUNC(2,frem1_rr,(FRW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_rmw(d);
-    raw_frem1_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_rmw(d);
+       raw_frem1_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,frem1_rr,(FRW d, FR s))
 
-MIDFUNC(2,fmul_rr,(FRW d, FR s))
+       MIDFUNC(2,fmul_rr,(FRW d, FR s))
 {
-    s=f_readreg(s);
-    d=f_rmw(d);
-    raw_fmul_rr(d,s);
-    f_unlock(s);
-    f_unlock(d);
+       s=f_readreg(s);
+       d=f_rmw(d);
+       raw_fmul_rr(d,s);
+       f_unlock(s);
+       f_unlock(d);
 }
 MENDFUNC(2,fmul_rr,(FRW d, FR s))
 
-/********************************************************************
- * Support functions exposed to gencomp. CREATE time                *
- ********************************************************************/
+       /********************************************************************
      * Support functions exposed to gencomp. CREATE time                *
      ********************************************************************/
 
-int kill_rodent(int r)
+       int kill_rodent(int r)
 {
-    return KILLTHERAT &&
-       have_rat_stall &&
-       (live.state[r].status==INMEM ||
-        live.state[r].status==CLEAN ||
-        live.state[r].status==ISCONST ||
-        live.state[r].dirtysize==4);
+       return KILLTHERAT &&
+               have_rat_stall &&
+               (live.state[r].status==INMEM ||
+               live.state[r].status==CLEAN ||
+               live.state[r].status==ISCONST ||
+               live.state[r].dirtysize==4);
 }
 
 uae_u32 get_const(int r)
 {
 #if USE_OPTIMIZER
-    if (!reg_alloc_run)
+       if (!reg_alloc_run)
 #endif
-       Dif (!isconst(r)) {
-           jit_abort (L"JIT: Register %d should be constant, but isn't\n",r);
+               Dif (!isconst(r)) {
+                       jit_abort (L"JIT: Register %d should be constant, but isn't\n",r);
        }
-    return live.state[r].val;
+       return live.state[r].val;
 }
 
 void sync_m68k_pc(void)
 {
-    if (m68k_pc_offset) {
-       add_l_ri(PC_P,m68k_pc_offset);
-       comp_pc_p+=m68k_pc_offset;
-       m68k_pc_offset=0;
-    }
+       if (m68k_pc_offset) {
+               add_l_ri(PC_P,m68k_pc_offset);
+               comp_pc_p+=m68k_pc_offset;
+               m68k_pc_offset=0;
+       }
 }
 
 /********************************************************************
- * Support functions exposed to newcpu                              *
- ********************************************************************/
+* Support functions exposed to newcpu                              *
+********************************************************************/
 
 uae_u32 scratch[VREGS];
 fptype fscratch[VFREGS];
 
 void init_comp(void)
 {
-    int i;
-    uae_u8* cb=can_byte;
-    uae_u8* cw=can_word;
-    uae_u8* au=always_used;
-
-    for (i=0;i<VREGS;i++) {
-       live.state[i].realreg=-1;
-       live.state[i].needflush=NF_SCRATCH;
-       live.state[i].val=0;
-       set_status(i,UNDEF);
-    }
-
-    for (i=0;i<VFREGS;i++) {
-       live.fate[i].status=UNDEF;
-       live.fate[i].realreg=-1;
-       live.fate[i].needflush=NF_SCRATCH;
-    }
-
-    for (i=0;i<VREGS;i++) {
-       if (i<16) { /* First 16 registers map to 68k registers */
-           live.state[i].mem=((uae_u32*)&regs)+i;
-           live.state[i].needflush=NF_TOMEM;
-           set_status(i,INMEM);
-       }
-       else
-           live.state[i].mem=scratch+i;
-    }
-    live.state[PC_P].mem=(uae_u32*)&(regs.pc_p);
-    live.state[PC_P].needflush=NF_TOMEM;
-    set_const(PC_P,(uae_u32)comp_pc_p);
-
-    live.state[FLAGX].mem=&(regflags.x);
-    live.state[FLAGX].needflush=NF_TOMEM;
-    set_status(FLAGX,INMEM);
-
-    live.state[FLAGTMP].mem=&(regflags.cznv);
-    live.state[FLAGTMP].needflush=NF_TOMEM;
-    set_status(FLAGTMP,INMEM);
-
-    live.state[NEXT_HANDLER].needflush=NF_HANDLER;
-    set_status(NEXT_HANDLER,UNDEF);
-
-    for (i=0;i<VFREGS;i++) {
-       if (i<8) { /* First 8 registers map to 68k FPU registers */
-           live.fate[i].mem=(uae_u32*)(((fptype*)regs.fp)+i);
-           live.fate[i].needflush=NF_TOMEM;
-           live.fate[i].status=INMEM;
-       }
-       else if (i==FP_RESULT) {
-           live.fate[i].mem=(uae_u32*)(&regs.fp_result);
-           live.fate[i].needflush=NF_TOMEM;
-           live.fate[i].status=INMEM;
-       }
-       else
-           live.fate[i].mem=(uae_u32*)(fscratch+i);
-    }
-
-    for (i=0;i<N_REGS;i++) {
-       live.nat[i].touched=0;
-       live.nat[i].nholds=0;
-       live.nat[i].locked=0;
-       if (*cb==i) {
-           live.nat[i].canbyte=1; cb++;
-       } else live.nat[i].canbyte=0;
-       if (*cw==i) {
-           live.nat[i].canword=1; cw++;
-       } else live.nat[i].canword=0;
-       if (*au==i) {
-           live.nat[i].locked=1; au++;
-       }
-    }
-
-    for (i=0;i<N_FREGS;i++) {
-       live.fat[i].touched=0;
-       live.fat[i].nholds=0;
-       live.fat[i].locked=0;
-    }
-
-    touchcnt=1;
-    m68k_pc_offset=0;
-    live.flags_in_flags=TRASH;
-    live.flags_on_stack=VALID;
-    live.flags_are_important=1;
-
-    raw_fp_init();
-}
+       int i;
+       uae_u8* cb=can_byte;
+       uae_u8* cw=can_word;
+       uae_u8* au=always_used;
+
+       for (i=0;i<VREGS;i++) {
+               live.state[i].realreg=-1;
+               live.state[i].needflush=NF_SCRATCH;
+               live.state[i].val=0;
+               set_status(i,UNDEF);
+       }
+
+       for (i=0;i<VFREGS;i++) {
+               live.fate[i].status=UNDEF;
+               live.fate[i].realreg=-1;
+               live.fate[i].needflush=NF_SCRATCH;
+       }
+
+       for (i=0;i<VREGS;i++) {
+               if (i<16) { /* First 16 registers map to 68k registers */
+                       live.state[i].mem=((uae_u32*)&regs)+i;
+                       live.state[i].needflush=NF_TOMEM;
+                       set_status(i,INMEM);
+               }
+               else
+                       live.state[i].mem=scratch+i;
+       }
+       live.state[PC_P].mem=(uae_u32*)&(regs.pc_p);
+       live.state[PC_P].needflush=NF_TOMEM;
+       set_const(PC_P,(uae_u32)comp_pc_p);
+
+       live.state[FLAGX].mem=&(regflags.x);
+       live.state[FLAGX].needflush=NF_TOMEM;
+       set_status(FLAGX,INMEM);
+
+       live.state[FLAGTMP].mem=&(regflags.cznv);
+       live.state[FLAGTMP].needflush=NF_TOMEM;
+       set_status(FLAGTMP,INMEM);
+
+       live.state[NEXT_HANDLER].needflush=NF_HANDLER;
+       set_status(NEXT_HANDLER,UNDEF);
+
+       for (i=0;i<VFREGS;i++) {
+               if (i<8) { /* First 8 registers map to 68k FPU registers */
+                       live.fate[i].mem=(uae_u32*)(((fptype*)regs.fp)+i);
+                       live.fate[i].needflush=NF_TOMEM;
+                       live.fate[i].status=INMEM;
+               }
+               else if (i==FP_RESULT) {
+                       live.fate[i].mem=(uae_u32*)(&regs.fp_result);
+                       live.fate[i].needflush=NF_TOMEM;
+                       live.fate[i].status=INMEM;
+               }
+               else
+                       live.fate[i].mem=(uae_u32*)(fscratch+i);
+       }
+
+       for (i=0;i<N_REGS;i++) {
+               live.nat[i].touched=0;
+               live.nat[i].nholds=0;
+               live.nat[i].locked=0;
+               if (*cb==i) {
+                       live.nat[i].canbyte=1; cb++;
+               } else live.nat[i].canbyte=0;
+               if (*cw==i) {
+                       live.nat[i].canword=1; cw++;
+               } else live.nat[i].canword=0;
+               if (*au==i) {
+                       live.nat[i].locked=1; au++;
+               }
+       }
+
+       for (i=0;i<N_FREGS;i++) {
+               live.fat[i].touched=0;
+               live.fat[i].nholds=0;
+               live.fat[i].locked=0;
+       }
+
+       touchcnt=1;
+       m68k_pc_offset=0;
+       live.flags_in_flags=TRASH;
+       live.flags_on_stack=VALID;
+       live.flags_are_important=1;
+
+       raw_fp_init();
+}
 
 static void vinton(int i, uae_s8* vton, int depth)
 {
-    int n;
-    int rr;
-
-    Dif (vton[i]==-1) {
-       jit_abort (L"JIT: Asked to load register %d, but nowhere to go\n",i);
-    }
-    n=vton[i];
-    Dif (live.nat[n].nholds>1)
-       jit_abort (L"vinton");
-    if (live.nat[n].nholds && depth<N_REGS) {
-       vinton(live.nat[n].holds[0],vton,depth+1);
-    }
-    if (!isinreg(i))
-       return;  /* Oops --- got rid of that one in the recursive calls */
-    rr=live.state[i].realreg;
-    if (rr!=n)
-       mov_nregs(n,rr);
+       int n;
+       int rr;
+
+       Dif (vton[i]==-1) {
+               jit_abort (L"JIT: Asked to load register %d, but nowhere to go\n",i);
+       }
+       n=vton[i];
+       Dif (live.nat[n].nholds>1)
+               jit_abort (L"vinton");
+       if (live.nat[n].nholds && depth<N_REGS) {
+               vinton(live.nat[n].holds[0],vton,depth+1);
+       }
+       if (!isinreg(i))
+               return;  /* Oops --- got rid of that one in the recursive calls */
+       rr=live.state[i].realreg;
+       if (rr!=n)
+               mov_nregs(n,rr);
 }
 
 #if USE_MATCHSTATE
 /* This is going to be, amongst other things, a more elaborate version of
-   flush() */
+flush() */
 STATIC_INLINE void match_states(smallstate* s)
 {
-    uae_s8 vton[VREGS];
-    uae_s8 ndone[N_REGS];
-    int i;
-    int again=0;
-
-    for (i=0;i<VREGS;i++)
-       vton[i]=-1;
-
-    for (i=0;i<N_REGS;i++)
-       if (s->nat[i].validsize)
-           vton[s->nat[i].holds]=i;
-
-    flush_flags(); /* low level */
-    sync_m68k_pc(); /* mid level */
-
-    /* We don't do FREGS yet, so this is raw flush() code */
-    for (i=0;i<VFREGS;i++) {
-       if (live.fate[i].needflush==NF_SCRATCH ||
-           live.fate[i].status==CLEAN) {
-           f_disassociate(i);
-       }
-    }
-    for (i=0;i<VFREGS;i++) {
-       if (live.fate[i].needflush==NF_TOMEM &&
-           live.fate[i].status==DIRTY) {
-           f_evict(i);
-       }
-    }
-    raw_fp_cleanup_drop();
-
-    /* Now comes the fun part. First, we need to remove all offsets */
-    for (i=0;i<VREGS;i++)
-       if (!isconst(i) && live.state[i].val)
-           remove_offset(i,-1);
-
-    /* Next, we evict everything that does not end up in registers,
-       write back overly dirty registers, and write back constants */
-    for (i=0;i<VREGS;i++) {
-       switch (live.state[i].status) {
-        case ISCONST:
-           if (i!=PC_P)
-               writeback_const(i);
-           break;
-        case DIRTY:
-           if (vton[i]==-1) {
-               evict(i);
-               break;
-           }
-           if (live.state[i].dirtysize>s->nat[vton[i]].dirtysize)
-               tomem(i);
-           /* Fall-through! */
-        case CLEAN:
-           if (vton[i]==-1 ||
-               live.state[i].validsize<s->nat[vton[i]].validsize)
-               evict(i);
-           else
-               make_exclusive(i,0,-1);
-           break;
-        case INMEM:
-           break;
-        case UNDEF:
-           break;
-        default:
-           write_log (L"JIT: Weird status: %d\n",live.state[i].status);
-           abort();
-       }
-    }
-
-    /* Quick consistency check */
-    for (i=0;i<VREGS;i++) {
-       if (isinreg(i)) {
-           int n=live.state[i].realreg;
-
-           if (live.nat[n].nholds!=1) {
-               write_log (L"JIT: Register %d isn't alone in nreg %d\n",
-                      i,n);
-               abort();
-           }
-           if (vton[i]==-1) {
-               write_log (L"JIT: Register %d is still in register, shouldn't be\n",
-                      i);
-               abort();
-           }
-       }
-    }
-
-    /* Now we need to shuffle things around so the VREGs are in the
-       right N_REGs. */
-    for (i=0;i<VREGS;i++) {
-       if (isinreg(i) && vton[i]!=live.state[i].realreg)
-           vinton(i,vton,0);
-    }
-
-    /* And now we may need to load some registers from memory */
-    for (i=0;i<VREGS;i++) {
-       int n=vton[i];
-       if (n==-1) {
-           Dif (isinreg(i)) {
-               write_log (L"JIT: Register %d unexpectedly in nreg %d\n",
-                      i,live.state[i].realreg);
-               abort();
-           }
+       uae_s8 vton[VREGS];
+       uae_s8 ndone[N_REGS];
+       int i;
+       int again=0;
+
+       for (i=0;i<VREGS;i++)
+               vton[i]=-1;
+
+       for (i=0;i<N_REGS;i++)
+               if (s->nat[i].validsize)
+                       vton[s->nat[i].holds]=i;
+
+       flush_flags(); /* low level */
+       sync_m68k_pc(); /* mid level */
+
+       /* We don't do FREGS yet, so this is raw flush() code */
+       for (i=0;i<VFREGS;i++) {
+               if (live.fate[i].needflush==NF_SCRATCH ||
+                       live.fate[i].status==CLEAN) {
+                               f_disassociate(i);
+               }
        }
-       else {
-           switch(live.state[i].status) {
-            case CLEAN:
-            case DIRTY:
-               Dif (n!=live.state[i].realreg)
-                   abort();
-               break;
-            case INMEM:
-               Dif (live.nat[n].nholds) {
-                   write_log (L"JIT: natreg %d holds %d vregs, should be empty\n",
-                          n,live.nat[n].nholds);
+       for (i=0;i<VFREGS;i++) {
+               if (live.fate[i].needflush==NF_TOMEM &&
+                       live.fate[i].status==DIRTY) {
+                               f_evict(i);
                }
-               raw_mov_l_rm(n,(uae_u32)live.state[i].mem);
-               live.state[i].validsize=4;
-               live.state[i].dirtysize=0;
-               live.state[i].realreg=n;
-               live.state[i].realind=0;
-               live.state[i].val=0;
-               live.state[i].is_swapped=0;
-               live.nat[n].nholds=1;
-               live.nat[n].holds[0]=i;
-
-               set_status(i,CLEAN);
-               break;
-            case ISCONST:
-               if (i!=PC_P) {
-                   write_log (L"JIT: Got constant in matchstate for reg %d. Bad!\n",i);
-                   abort();
+       }
+       raw_fp_cleanup_drop();
+
+       /* Now comes the fun part. First, we need to remove all offsets */
+       for (i=0;i<VREGS;i++)
+               if (!isconst(i) && live.state[i].val)
+                       remove_offset(i,-1);
+
+       /* Next, we evict everything that does not end up in registers,
+       write back overly dirty registers, and write back constants */
+       for (i=0;i<VREGS;i++) {
+               switch (live.state[i].status) {
+               case ISCONST:
+                       if (i!=PC_P)
+                               writeback_const(i);
+                       break;
+               case DIRTY:
+                       if (vton[i]==-1) {
+                               evict(i);
+                               break;
+                       }
+                       if (live.state[i].dirtysize>s->nat[vton[i]].dirtysize)
+                               tomem(i);
+                       /* Fall-through! */
+               case CLEAN:
+                       if (vton[i]==-1 ||
+                               live.state[i].validsize<s->nat[vton[i]].validsize)
+                               evict(i);
+                       else
+                               make_exclusive(i,0,-1);
+                       break;
+               case INMEM:
+                       break;
+               case UNDEF:
+                       break;
+               default:
+                       write_log (L"JIT: Weird status: %d\n",live.state[i].status);
+                       abort();
                }
-               break;
-            case UNDEF:
-               break;
-           }
-       }
-    }
-
-    /* One last consistency check, and adjusting the states in live
-       to those in s */
-    for (i=0;i<VREGS;i++) {
-       int n=vton[i];
-       switch(live.state[i].status) {
-        case INMEM:
-           if (n!=-1)
-               abort();
-           break;
-        case ISCONST:
-           if (i!=PC_P)
-               abort();
-           break;
-        case CLEAN:
-        case DIRTY:
-           if (n==-1)
-               abort();
-           if (live.state[i].dirtysize>s->nat[n].dirtysize)
-               abort;
-           if (live.state[i].validsize<s->nat[n].validsize)
-               abort;
-           live.state[i].dirtysize=s->nat[n].dirtysize;
-           live.state[i].validsize=s->nat[n].validsize;
-           if (live.state[i].dirtysize)
-               set_status(i,DIRTY);
-           break;
-        case UNDEF:
-           break;
-       }
-       if (n!=-1)
-           live.nat[n].touched=touchcnt++;
-    }
+       }
+
+       /* Quick consistency check */
+       for (i=0;i<VREGS;i++) {
+               if (isinreg(i)) {
+                       int n=live.state[i].realreg;
+
+                       if (live.nat[n].nholds!=1) {
+                               write_log (L"JIT: Register %d isn't alone in nreg %d\n",
+                                       i,n);
+                               abort();
+                       }
+                       if (vton[i]==-1) {
+                               write_log (L"JIT: Register %d is still in register, shouldn't be\n",
+                                       i);
+                               abort();
+                       }
+               }
+       }
+
+       /* Now we need to shuffle things around so the VREGs are in the
+       right N_REGs. */
+       for (i=0;i<VREGS;i++) {
+               if (isinreg(i) && vton[i]!=live.state[i].realreg)
+                       vinton(i,vton,0);
+       }
+
+       /* And now we may need to load some registers from memory */
+       for (i=0;i<VREGS;i++) {
+               int n=vton[i];
+               if (n==-1) {
+                       Dif (isinreg(i)) {
+                               write_log (L"JIT: Register %d unexpectedly in nreg %d\n",
+                                       i,live.state[i].realreg);
+                               abort();
+                       }
+               }
+               else {
+                       switch(live.state[i].status) {
+                       case CLEAN:
+                       case DIRTY:
+                               Dif (n!=live.state[i].realreg)
+                                       abort();
+                               break;
+                       case INMEM:
+                               Dif (live.nat[n].nholds) {
+                                       write_log (L"JIT: natreg %d holds %d vregs, should be empty\n",
+                                               n,live.nat[n].nholds);
+                               }
+                               raw_mov_l_rm(n,(uae_u32)live.state[i].mem);
+                               live.state[i].validsize=4;
+                               live.state[i].dirtysize=0;
+                               live.state[i].realreg=n;
+                               live.state[i].realind=0;
+                               live.state[i].val=0;
+                               live.state[i].is_swapped=0;
+                               live.nat[n].nholds=1;
+                               live.nat[n].holds[0]=i;
+
+                               set_status(i,CLEAN);
+                               break;
+                       case ISCONST:
+                               if (i!=PC_P) {
+                                       write_log (L"JIT: Got constant in matchstate for reg %d. Bad!\n",i);
+                                       abort();
+                               }
+                               break;
+                       case UNDEF:
+                               break;
+                       }
+               }
+       }
+
+       /* One last consistency check, and adjusting the states in live
+       to those in s */
+       for (i=0;i<VREGS;i++) {
+               int n=vton[i];
+               switch(live.state[i].status) {
+               case INMEM:
+                       if (n!=-1)
+                               abort();
+                       break;
+               case ISCONST:
+                       if (i!=PC_P)
+                               abort();
+                       break;
+               case CLEAN:
+               case DIRTY:
+                       if (n==-1)
+                               abort();
+                       if (live.state[i].dirtysize>s->nat[n].dirtysize)
+                               abort;
+                       if (live.state[i].validsize<s->nat[n].validsize)
+                               abort;
+                       live.state[i].dirtysize=s->nat[n].dirtysize;
+                       live.state[i].validsize=s->nat[n].validsize;
+                       if (live.state[i].dirtysize)
+                               set_status(i,DIRTY);
+                       break;
+               case UNDEF:
+                       break;
+               }
+               if (n!=-1)
+                       live.nat[n].touched=touchcnt++;
+       }
 }
 #else
 STATIC_INLINE void match_states(smallstate* s)
 {
-    flush(1);
+       flush(1);
 }
 #endif
 
 /* Only do this if you really mean it! The next call should be to init!*/
 void flush(int save_regs)
 {
-    int i;
+       int i;
 
-    log_flush();
-    flush_flags(); /* low level */
-    sync_m68k_pc(); /* mid level */
+       log_flush();
+       flush_flags(); /* low level */
+       sync_m68k_pc(); /* mid level */
 
-    if (save_regs) {
-       for (i=0;i<VFREGS;i++) {
-           if (live.fate[i].needflush==NF_SCRATCH ||
-               live.fate[i].status==CLEAN) {
-               f_disassociate(i);
-           }
-       }
-       for (i=0;i<VREGS;i++) {
-           if (live.state[i].needflush==NF_TOMEM) {
-               switch(live.state[i].status) {
-                case INMEM:
-                   if (live.state[i].val) {
-                       raw_add_l_mi((uae_u32)live.state[i].mem,live.state[i].val);
-                       live.state[i].val=0;
-                   }
-                   break;
-                case CLEAN:
-                case DIRTY:
-                   remove_offset(i,-1); tomem(i); break;
-                case ISCONST:
-                   if (i!=PC_P)
-                       writeback_const(i);
-                   break;
-                default: break;
+       if (save_regs) {
+               for (i=0;i<VFREGS;i++) {
+                       if (live.fate[i].needflush==NF_SCRATCH ||
+                               live.fate[i].status==CLEAN) {
+                                       f_disassociate(i);
+                       }
+               }
+               for (i=0;i<VREGS;i++) {
+                       if (live.state[i].needflush==NF_TOMEM) {
+                               switch(live.state[i].status) {
+                               case INMEM:
+                                       if (live.state[i].val) {
+                                               raw_add_l_mi((uae_u32)live.state[i].mem,live.state[i].val);
+                                               live.state[i].val=0;
+                                       }
+                                       break;
+                               case CLEAN:
+                               case DIRTY:
+                                       remove_offset(i,-1); tomem(i); break;
+                               case ISCONST:
+                                       if (i!=PC_P)
+                                               writeback_const(i);
+                                       break;
+                               default: break;
+                               }
+                               Dif (live.state[i].val && i!=PC_P) {
+                                       write_log (L"JIT: Register %d still has val %x\n",
+                                               i,live.state[i].val);
+                               }
+                       }
                }
-               Dif (live.state[i].val && i!=PC_P) {
-                   write_log (L"JIT: Register %d still has val %x\n",
-                          i,live.state[i].val);
+               for (i=0;i<VFREGS;i++) {
+                       if (live.fate[i].needflush==NF_TOMEM &&
+                               live.fate[i].status==DIRTY) {
+                                       f_evict(i);
+                       }
                }
-           }
+               raw_fp_cleanup_drop();
        }
-       for (i=0;i<VFREGS;i++) {
-           if (live.fate[i].needflush==NF_TOMEM &&
-               live.fate[i].status==DIRTY) {
-               f_evict(i);
-           }
+       if (needflags) {
+               write_log (L"JIT: Warning! flush with needflags=1!\n");
        }
-       raw_fp_cleanup_drop();
-    }
-    if (needflags) {
-       write_log (L"JIT: Warning! flush with needflags=1!\n");
-    }
 
-    lopt_emit_all();
+       lopt_emit_all();
 }
 
 static void flush_keepflags(void)
 {
-    int i;
-
-    for (i=0;i<VFREGS;i++) {
-       if (live.fate[i].needflush==NF_SCRATCH ||
-           live.fate[i].status==CLEAN) {
-           f_disassociate(i);
-       }
-    }
-    for (i=0;i<VREGS;i++) {
-       if (live.state[i].needflush==NF_TOMEM) {
-           switch(live.state[i].status) {
-            case INMEM:
-               /* Can't adjust the offset here --- that needs "add" */
-               break;
-            case CLEAN:
-            case DIRTY:
-               remove_offset(i,-1); tomem(i); break;
-            case ISCONST:
-               if (i!=PC_P)
-                   writeback_const(i);
-               break;
-            default: break;
-           }
-       }
-    }
-    for (i=0;i<VFREGS;i++) {
-       if (live.fate[i].needflush==NF_TOMEM &&
-           live.fate[i].status==DIRTY) {
-           f_evict(i);
-       }
-    }
-    raw_fp_cleanup_drop();
-    lopt_emit_all();
+       int i;
+
+       for (i=0;i<VFREGS;i++) {
+               if (live.fate[i].needflush==NF_SCRATCH ||
+                       live.fate[i].status==CLEAN) {
+                               f_disassociate(i);
+               }
+       }
+       for (i=0;i<VREGS;i++) {
+               if (live.state[i].needflush==NF_TOMEM) {
+                       switch(live.state[i].status) {
+                       case INMEM:
+                               /* Can't adjust the offset here --- that needs "add" */
+                               break;
+                       case CLEAN:
+                       case DIRTY:
+                               remove_offset(i,-1); tomem(i); break;
+                       case ISCONST:
+                               if (i!=PC_P)
+                                       writeback_const(i);
+                               break;
+                       default: break;
+                       }
+               }
+       }
+       for (i=0;i<VFREGS;i++) {
+               if (live.fate[i].needflush==NF_TOMEM &&
+                       live.fate[i].status==DIRTY) {
+                               f_evict(i);
+               }
+       }
+       raw_fp_cleanup_drop();
+       lopt_emit_all();
 }
 
 void freescratch(void)
 {
-    int i;
-    for (i=0;i<N_REGS;i++)
-       if (live.nat[i].locked && i!=4)
-           write_log (L"JIT: Warning! %d is locked\n",i);
+       int i;
+       for (i=0;i<N_REGS;i++)
+               if (live.nat[i].locked && i!=4)
+                       write_log (L"JIT: Warning! %d is locked\n",i);
 
-    for (i=0;i<VREGS;i++)
-       if (live.state[i].needflush==NF_SCRATCH) {
-           forget_about(i);
-       }
+       for (i=0;i<VREGS;i++)
+               if (live.state[i].needflush==NF_SCRATCH) {
+                       forget_about(i);
+               }
 
-    for (i=0;i<VFREGS;i++)
-       if (live.fate[i].needflush==NF_SCRATCH) {
-           f_forget_about(i);
-       }
+               for (i=0;i<VFREGS;i++)
+                       if (live.fate[i].needflush==NF_SCRATCH) {
+                               f_forget_about(i);
+                       }
 }
 
 /********************************************************************
- * Support functions, internal                                      *
- ********************************************************************/
+* Support functions, internal                                      *
+********************************************************************/
 
 
 static void align_target(uae_u32 a)
 {
-    lopt_emit_all();
-    /* Fill with NOPs --- makes debugging with gdb easier */
-    while ((uae_u32)target&(a-1))
-       *target++=0x90;
+       lopt_emit_all();
+       /* Fill with NOPs --- makes debugging with gdb easier */
+       while ((uae_u32)target&(a-1))
+               *target++=0x90;
 }
 
 extern uae_u8* kickmemory;
 STATIC_INLINE int isinrom(uae_u32 addr)
 {
-    return (addr>=(uae_u32)kickmemory &&
-           addr<(uae_u32)kickmemory+8*65536);
+       return (addr>=(uae_u32)kickmemory &&
+               addr<(uae_u32)kickmemory+8*65536);
 }
 
 static void flush_all(void)
 {
-    int i;
+       int i;
 
-    log_flush();
-    for (i=0;i<VREGS;i++)
-       if (live.state[i].status==DIRTY) {
-           if (!call_saved[live.state[i].realreg]) {
-               tomem(i);
-           }
-       }
-    for (i=0;i<VFREGS;i++)
-       if (f_isinreg(i))
-           f_evict(i);
-    raw_fp_cleanup_drop();
+       log_flush();
+       for (i=0;i<VREGS;i++)
+               if (live.state[i].status==DIRTY) {
+                       if (!call_saved[live.state[i].realreg]) {
+                               tomem(i);
+                       }
+               }
+               for (i=0;i<VFREGS;i++)
+                       if (f_isinreg(i))
+                               f_evict(i);
+               raw_fp_cleanup_drop();
 }
 
 /* Make sure all registers that will get clobbered by a call are
-   save and sound in memory */
+save and sound in memory */
 static void prepare_for_call_1(void)
 {
-    flush_all();  /* If there are registers that don't get clobbered,
-                  * we should be a bit more selective here */
+       flush_all();  /* If there are registers that don't get clobbered,
+                                 * we should be a bit more selective here */
 }
 
 /* We will call a C routine in a moment. That will clobber all registers,
-   so we need to disassociate everything */
+so we need to disassociate everything */
 static void prepare_for_call_2(void)
 {
-    int i;
-    for (i=0;i<N_REGS;i++)
-       if (!call_saved[i] && live.nat[i].nholds>0)
-           free_nreg(i);
+       int i;
+       for (i=0;i<N_REGS;i++)
+               if (!call_saved[i] && live.nat[i].nholds>0)
+                       free_nreg(i);
 
-    for (i=0;i<N_FREGS;i++)
-       if (live.fat[i].nholds>0)
-           f_free_nreg(i);
+       for (i=0;i<N_FREGS;i++)
+               if (live.fat[i].nholds>0)
+                       f_free_nreg(i);
 
-    live.flags_in_flags=TRASH;  /* Note: We assume we already rescued the
-                                  flags at the very start of the call_r
-                                  functions! */
+       live.flags_in_flags=TRASH;  /* Note: We assume we already rescued the
+                                                               flags at the very start of the call_r
+                                                               functions! */
 }
 
 
 /********************************************************************
- * Memory access and related functions, CREATE time                 *
- ********************************************************************/
+* Memory access and related functions, CREATE time                 *
+********************************************************************/
 
 void register_branch(uae_u32 not_taken, uae_u32 taken, uae_u8 cond)
 {
-    next_pc_p=not_taken;
-    taken_pc_p=taken;
-    branch_cc=cond;
+       next_pc_p=not_taken;
+       taken_pc_p=taken;
+       branch_cc=cond;
 }
 
 static uae_u32 get_handler_address(uae_u32 addr)
 {
-    uae_u32 cl=cacheline(addr);
-    blockinfo* bi=get_blockinfo_addr_new((void*)addr,0);
+       uae_u32 cl=cacheline(addr);
+       blockinfo* bi=get_blockinfo_addr_new((void*)addr,0);
 
 #if USE_OPTIMIZER
-    if (!bi && reg_alloc_run)
-       return 0;
+       if (!bi && reg_alloc_run)
+               return 0;
 #endif
-    return (uae_u32)&(bi->direct_handler_to_use);
+       return (uae_u32)&(bi->direct_handler_to_use);
 }
 
 static uae_u32 get_handler(uae_u32 addr)
 {
-    uae_u32 cl=cacheline(addr);
-    blockinfo* bi=get_blockinfo_addr_new((void*)addr,0);
+       uae_u32 cl=cacheline(addr);
+       blockinfo* bi=get_blockinfo_addr_new((void*)addr,0);
 
 #if USE_OPTIMIZER
-    if (!bi && reg_alloc_run)
-       return 0;
+       if (!bi && reg_alloc_run)
+               return 0;
 #endif
-    return (uae_u32)bi->direct_handler_to_use;
+       return (uae_u32)bi->direct_handler_to_use;
 }
 
 static void load_handler(int reg, uae_u32 addr)
 {
-    mov_l_rm(reg,get_handler_address(addr));
+       mov_l_rm(reg,get_handler_address(addr));
 }
 
 /* This version assumes that it is writing *real* memory, and *will* fail
- *  if that assumption is wrong! No branches, no second chances, just
- *  straight go-for-it attitude */
+*  if that assumption is wrong! No branches, no second chances, just
+*  straight go-for-it attitude */
 
 static void writemem_real(int address, int source, int offset, int size, int tmp, int clobber)
 {
-    int f=tmp;
+       int f=tmp;
 
 #ifdef NATMEM_OFFSET
-    if (canbang) {  /* Woohoo! go directly at the memory! */
-       if (clobber)
-           f=source;
-       switch(size) {
-        case 1: mov_b_bRr(address,source,NATMEM_OFFSETX); break;
-        case 2: mov_w_rr(f,source); gen_bswap_16(f); mov_w_bRr(address,f,NATMEM_OFFSETX); break;
-        case 4: mov_l_rr(f,source); gen_bswap_32(f); mov_l_bRr(address,f,NATMEM_OFFSETX); break;
+       if (canbang) {  /* Woohoo! go directly at the memory! */
+               if (clobber)
+                       f=source;
+               switch(size) {
+               case 1: mov_b_bRr(address,source,NATMEM_OFFSETX); break;
+               case 2: mov_w_rr(f,source); gen_bswap_16(f); mov_w_bRr(address,f,NATMEM_OFFSETX); break;
+               case 4: mov_l_rr(f,source); gen_bswap_32(f); mov_l_bRr(address,f,NATMEM_OFFSETX); break;
+               }
+               forget_about(tmp);
+               forget_about(f);
+               return;
        }
-       forget_about(tmp);
-       forget_about(f);
-       return;
-    }
 #endif
 
-    mov_l_rr(f,address);
-    shrl_l_ri(f,16);  /* The index into the baseaddr table */
-    mov_l_rm_indexed(f,(uae_u32)(baseaddr),f);
-
-    if (address==source) { /* IBrowse does this! */
-       if (size > 1) {
-           add_l(f,address); /* f now holds the final address */
-           switch (size) {
-               case 2: gen_bswap_16(source); mov_w_Rr(f,source,0);
-                       gen_bswap_16(source); return;
-               case 4: gen_bswap_32(source); mov_l_Rr(f,source,0);
-                       gen_bswap_32(source); return;
-           }
-       }
-    }
-    switch (size) { /* f now holds the offset */
+       mov_l_rr(f,address);
+       shrl_l_ri(f,16);  /* The index into the baseaddr table */
+       mov_l_rm_indexed(f,(uae_u32)(baseaddr),f);
+
+       if (address==source) { /* IBrowse does this! */
+               if (size > 1) {
+                       add_l(f,address); /* f now holds the final address */
+                       switch (size) {
+                       case 2: gen_bswap_16(source); mov_w_Rr(f,source,0);
+                               gen_bswap_16(source); return;
+                       case 4: gen_bswap_32(source); mov_l_Rr(f,source,0);
+                               gen_bswap_32(source); return;
+                       }
+               }
+       }
+       switch (size) { /* f now holds the offset */
        case 1: mov_b_mrr_indexed(address,f,source); break;
        case 2: gen_bswap_16(source); mov_w_mrr_indexed(address,f,source);
                gen_bswap_16(source); break;       /* base, index, source */
        case 4: gen_bswap_32(source); mov_l_mrr_indexed(address,f,source);
                gen_bswap_32(source); break;
-    }
+       }
 }
 
 STATIC_INLINE void writemem(int address, int source, int offset, int size, int tmp)
 {
-    int f=tmp;
+       int f=tmp;
 
-    mov_l_rr(f,address);
-    shrl_l_ri(f,16);   /* The index into the mem bank table */
-    mov_l_rm_indexed(f,(uae_u32)mem_banks,f);
-    /* Now f holds a pointer to the actual membank */
-    mov_l_rR(f,f,offset);
-    /* Now f holds the address of the b/w/lput function */
-    call_r_02(f,address,source,4,size);
-    forget_about(tmp);
+       mov_l_rr(f,address);
+       shrl_l_ri(f,16);   /* The index into the mem bank table */
+       mov_l_rm_indexed(f,(uae_u32)mem_banks,f);
+       /* Now f holds a pointer to the actual membank */
+       mov_l_rR(f,f,offset);
+       /* Now f holds the address of the b/w/lput function */
+       call_r_02(f,address,source,4,size);
+       forget_about(tmp);
 }
 
 void writebyte(int address, int source, int tmp)
 {
-    int  distrust;
-    switch (currprefs.comptrustbyte) {
-     case 0: distrust=0; break;
-     case 1: distrust=1; break;
-     case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
-     case 3: distrust=!have_done_picasso; break;
-     default: abort();
-    }
+       int  distrust;
+       switch (currprefs.comptrustbyte) {
+       case 0: distrust=0; break;
+       case 1: distrust=1; break;
+       case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+       case 3: distrust=!have_done_picasso; break;
+       default: abort();
+       }
 
-    if ((special_mem&S_WRITE) || distrust)
-       writemem_special(address,source,20,1,tmp);
-    else
-       writemem_real(address,source,20,1,tmp,0);
+       if ((special_mem&S_WRITE) || distrust)
+               writemem_special(address,source,20,1,tmp);
+       else
+               writemem_real(address,source,20,1,tmp,0);
 }
 
 STATIC_INLINE void writeword_general(int address, int source, int tmp,
-                                        int clobber)
-{
-    int  distrust;
-    switch (currprefs.comptrustword) {
-     case 0: distrust=0; break;
-     case 1: distrust=1; break;
-     case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
-     case 3: distrust=!have_done_picasso; break;
-     default: abort();
-    }
+       int clobber)
+{
+       int  distrust;
+       switch (currprefs.comptrustword) {
+       case 0: distrust=0; break;
+       case 1: distrust=1; break;
+       case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+       case 3: distrust=!have_done_picasso; break;
+       default: abort();
+       }
 
-    if ((special_mem&S_WRITE) || distrust)
-       writemem_special(address,source,16,2,tmp);
-    else
-       writemem_real(address,source,16,2,tmp,clobber);
+       if ((special_mem&S_WRITE) || distrust)
+               writemem_special(address,source,16,2,tmp);
+       else
+               writemem_real(address,source,16,2,tmp,clobber);
 }
 
 void writeword_clobber(int address, int source, int tmp)
 {
-    writeword_general(address,source,tmp,1);
+       writeword_general(address,source,tmp,1);
 }
 
 void writeword(int address, int source, int tmp)
 {
-    writeword_general(address,source,tmp,0);
+       writeword_general(address,source,tmp,0);
 }
 
 STATIC_INLINE void writelong_general(int address, int source, int tmp,
-                                        int clobber)
-{
-    int  distrust;
-    switch (currprefs.comptrustlong) {
-     case 0: distrust=0; break;
-     case 1: distrust=1; break;
-     case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
-     case 3: distrust=!have_done_picasso; break;
-     default: abort();
-    }
+       int clobber)
+{
+       int  distrust;
+       switch (currprefs.comptrustlong) {
+       case 0: distrust=0; break;
+       case 1: distrust=1; break;
+       case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+       case 3: distrust=!have_done_picasso; break;
+       default: abort();
+       }
 
-    if ((special_mem&S_WRITE) || distrust)
-       writemem_special(address,source,12,4,tmp);
-    else
-       writemem_real(address,source,12,4,tmp,clobber);
+       if ((special_mem&S_WRITE) || distrust)
+               writemem_special(address,source,12,4,tmp);
+       else
+               writemem_real(address,source,12,4,tmp,clobber);
 }
 
 void writelong_clobber(int address, int source, int tmp)
 {
-    writelong_general(address,source,tmp,1);
+       writelong_general(address,source,tmp,1);
 }
 
 void writelong(int address, int source, int tmp)
 {
-    writelong_general(address,source,tmp,0);
+       writelong_general(address,source,tmp,0);
 }
 
 
 
 /* This version assumes that it is reading *real* memory, and *will* fail
- *  if that assumption is wrong! No branches, no second chances, just
- *  straight go-for-it attitude */
+*  if that assumption is wrong! No branches, no second chances, just
+*  straight go-for-it attitude */
 
 static void readmem_real(int address, int dest, int offset, int size, int tmp)
 {
-    int f=tmp;
+       int f=tmp;
 
-    if (size==4 && address!=dest)
-       f=dest;
+       if (size==4 && address!=dest)
+               f=dest;
 
 #ifdef NATMEM_OFFSET
-    if (canbang) {  /* Woohoo! go directly at the memory! */
-       switch(size) {
-        case 1: mov_b_brR(dest,address,NATMEM_OFFSETX); break;
-        case 2: mov_w_brR(dest,address,NATMEM_OFFSETX); gen_bswap_16(dest); break;
-        case 4: mov_l_brR(dest,address,NATMEM_OFFSETX); gen_bswap_32(dest); break;
+       if (canbang) {  /* Woohoo! go directly at the memory! */
+               switch(size) {
+               case 1: mov_b_brR(dest,address,NATMEM_OFFSETX); break;
+               case 2: mov_w_brR(dest,address,NATMEM_OFFSETX); gen_bswap_16(dest); break;
+               case 4: mov_l_brR(dest,address,NATMEM_OFFSETX); gen_bswap_32(dest); break;
+               }
+               forget_about(tmp);
+               return;
        }
-       forget_about(tmp);
-       return;
-    }
 #endif
 
-    mov_l_rr(f,address);
-    shrl_l_ri(f,16);   /* The index into the baseaddr table */
-    mov_l_rm_indexed(f,(uae_u32)baseaddr,f);
-    /* f now holds the offset */
+       mov_l_rr(f,address);
+       shrl_l_ri(f,16);   /* The index into the baseaddr table */
+       mov_l_rm_indexed(f,(uae_u32)baseaddr,f);
+       /* f now holds the offset */
 
-    switch(size) {
-     case 1: mov_b_rrm_indexed(dest,address,f); break;
-     case 2: mov_w_rrm_indexed(dest,address,f); gen_bswap_16(dest); break;
-     case 4: mov_l_rrm_indexed(dest,address,f); gen_bswap_32(dest); break;
-    }
-    forget_about(tmp);
+       switch(size) {
+       case 1: mov_b_rrm_indexed(dest,address,f); break;
+       case 2: mov_w_rrm_indexed(dest,address,f); gen_bswap_16(dest); break;
+       case 4: mov_l_rrm_indexed(dest,address,f); gen_bswap_32(dest); break;
+       }
+       forget_about(tmp);
 }
 
 
 
 STATIC_INLINE void readmem(int address, int dest, int offset, int size, int tmp)
 {
-    int f=tmp;
+       int f=tmp;
 
-    mov_l_rr(f,address);
-    shrl_l_ri(f,16);   /* The index into the mem bank table */
-    mov_l_rm_indexed(f,(uae_u32)mem_banks,f);
-    /* Now f holds a pointer to the actual membank */
-    mov_l_rR(f,f,offset);
-    /* Now f holds the address of the b/w/lget function */
-    call_r_11(dest,f,address,size,4);
-    forget_about(tmp);
+       mov_l_rr(f,address);
+       shrl_l_ri(f,16);   /* The index into the mem bank table */
+       mov_l_rm_indexed(f,(uae_u32)mem_banks,f);
+       /* Now f holds a pointer to the actual membank */
+       mov_l_rR(f,f,offset);
+       /* Now f holds the address of the b/w/lget function */
+       call_r_11(dest,f,address,size,4);
+       forget_about(tmp);
 }
 
 void readbyte(int address, int dest, int tmp)
 {
-    int  distrust;
-    switch (currprefs.comptrustbyte) {
-     case 0: distrust=0; break;
-     case 1: distrust=1; break;
-     case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
-     case 3: distrust=!have_done_picasso; break;
-     default: abort();
-    }
+       int  distrust;
+       switch (currprefs.comptrustbyte) {
+       case 0: distrust=0; break;
+       case 1: distrust=1; break;
+       case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+       case 3: distrust=!have_done_picasso; break;
+       default: abort();
+       }
 
-    if ((special_mem&S_READ) || distrust)
-       readmem_special(address,dest,8,1,tmp);
-    else
-       readmem_real(address,dest,8,1,tmp);
+       if ((special_mem&S_READ) || distrust)
+               readmem_special(address,dest,8,1,tmp);
+       else
+               readmem_real(address,dest,8,1,tmp);
 }
 
 void readword(int address, int dest, int tmp)
 {
-    int  distrust;
-    switch (currprefs.comptrustword) {
-     case 0: distrust=0; break;
-     case 1: distrust=1; break;
-     case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
-     case 3: distrust=!have_done_picasso; break;
-     default: abort();
-    }
+       int  distrust;
+       switch (currprefs.comptrustword) {
+       case 0: distrust=0; break;
+       case 1: distrust=1; break;
+       case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+       case 3: distrust=!have_done_picasso; break;
+       default: abort();
+       }
 
-    if ((special_mem&S_READ) || distrust)
-       readmem_special(address,dest,4,2,tmp);
-    else
-       readmem_real(address,dest,4,2,tmp);
+       if ((special_mem&S_READ) || distrust)
+               readmem_special(address,dest,4,2,tmp);
+       else
+               readmem_real(address,dest,4,2,tmp);
 }
 
 void readlong(int address, int dest, int tmp)
 {
-    int  distrust;
-    switch (currprefs.comptrustlong) {
-     case 0: distrust=0; break;
-     case 1: distrust=1; break;
-     case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
-     case 3: distrust=!have_done_picasso; break;
-     default: abort();
-    }
+       int  distrust;
+       switch (currprefs.comptrustlong) {
+       case 0: distrust=0; break;
+       case 1: distrust=1; break;
+       case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+       case 3: distrust=!have_done_picasso; break;
+       default: abort();
+       }
 
-    if ((special_mem&S_READ) || distrust)
-       readmem_special(address,dest,0,4,tmp);
-    else
-       readmem_real(address,dest,0,4,tmp);
+       if ((special_mem&S_READ) || distrust)
+               readmem_special(address,dest,0,4,tmp);
+       else
+               readmem_real(address,dest,0,4,tmp);
 }
 
 
@@ -5225,682 +5225,682 @@ void readlong(int address, int dest, int tmp)
 /* This one might appear a bit odd... */
 STATIC_INLINE void get_n_addr_old(int address, int dest, int tmp)
 {
-    readmem(address,dest,24,4,tmp);
+       readmem(address,dest,24,4,tmp);
 }
 
 STATIC_INLINE void get_n_addr_real(int address, int dest, int tmp)
 {
-    int f=tmp;
-    if (address!=dest)
-       f=dest;
+       int f=tmp;
+       if (address!=dest)
+               f=dest;
 
 #ifdef NATMEM_OFFSET
-    if (canbang) {
-       lea_l_brr(dest,address,NATMEM_OFFSETX);
-       forget_about(tmp);
-       return;
-    }
+       if (canbang) {
+               lea_l_brr(dest,address,NATMEM_OFFSETX);
+               forget_about(tmp);
+               return;
+       }
 #endif
-    mov_l_rr(f,address);
-    mov_l_rr(dest,address); // gb-- nop if dest==address
-    shrl_l_ri(f,16);
-    mov_l_rm_indexed(f,(uae_u32)baseaddr,f);
-    add_l(dest,f);
-    forget_about(tmp);
+       mov_l_rr(f,address);
+       mov_l_rr(dest,address); // gb-- nop if dest==address
+       shrl_l_ri(f,16);
+       mov_l_rm_indexed(f,(uae_u32)baseaddr,f);
+       add_l(dest,f);
+       forget_about(tmp);
 }
 
 void get_n_addr(int address, int dest, int tmp)
 {
-    int  distrust;
-    switch (currprefs.comptrustnaddr) {
-     case 0: distrust=0; break;
-     case 1: distrust=1; break;
-     case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
-     case 3: distrust=!have_done_picasso; break;
-     default: abort();
-    }
+       int  distrust;
+       switch (currprefs.comptrustnaddr) {
+       case 0: distrust=0; break;
+       case 1: distrust=1; break;
+       case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+       case 3: distrust=!have_done_picasso; break;
+       default: abort();
+       }
 
-    if (special_mem || distrust)
-       get_n_addr_old(address,dest,tmp);
-    else
-       get_n_addr_real(address,dest,tmp);
+       if (special_mem || distrust)
+               get_n_addr_old(address,dest,tmp);
+       else
+               get_n_addr_real(address,dest,tmp);
 }
 
 void get_n_addr_jmp(int address, int dest, int tmp)
 {
 #if 0 /* For this, we need to get the same address as the rest of UAE
-        would --- otherwise we end up translating everything twice */
-    get_n_addr(address,dest,tmp);
+would --- otherwise we end up translating everything twice */
+       get_n_addr(address,dest,tmp);
 #else
-    int f=tmp;
-    if (address!=dest)
-       f=dest;
-    mov_l_rr(f,address);
-    shrl_l_ri(f,16);   /* The index into the baseaddr bank table */
-    mov_l_rm_indexed(dest,(uae_u32)baseaddr,f);
-    add_l(dest,address);
-    and_l_ri (dest, ~1);
-    forget_about(tmp);
+       int f=tmp;
+       if (address!=dest)
+               f=dest;
+       mov_l_rr(f,address);
+       shrl_l_ri(f,16);   /* The index into the baseaddr bank table */
+       mov_l_rm_indexed(dest,(uae_u32)baseaddr,f);
+       add_l(dest,address);
+       and_l_ri (dest, ~1);
+       forget_about(tmp);
 #endif
 }
 
 /* base, target and tmp are registers, but dp is the actual opcode extension word */
 void calc_disp_ea_020(int base, uae_u32 dp, int target, int tmp)
 {
-    int reg = (dp >> 12) & 15;
-    int regd_shift=(dp >> 9) & 3;
-
-    if (dp & 0x100) {
-       int ignorebase=(dp&0x80);
-       int ignorereg=(dp&0x40);
-       int addbase=0;
-       int outer=0;
-
-       if ((dp & 0x30) == 0x20) addbase = (uae_s32)(uae_s16)comp_get_iword((m68k_pc_offset+=2)-2);
-       if ((dp & 0x30) == 0x30) addbase = comp_get_ilong((m68k_pc_offset+=4)-4);
-
-       if ((dp & 0x3) == 0x2) outer = (uae_s32)(uae_s16)comp_get_iword((m68k_pc_offset+=2)-2);
-       if ((dp & 0x3) == 0x3) outer = comp_get_ilong((m68k_pc_offset+=4)-4);
-
-       if ((dp & 0x4) == 0) {  /* add regd *before* the get_long */
-           if (!ignorereg) {
-               if ((dp & 0x800) == 0)
-                   sign_extend_16_rr(target,reg);
-               else
-                   mov_l_rr(target,reg);
-               shll_l_ri(target,regd_shift);
-           }
-           else
-               mov_l_ri(target,0);
-
-           /* target is now regd */
-           if (!ignorebase)
-               add_l(target,base);
-           add_l_ri(target,addbase);
-           if (dp&0x03) readlong(target,target,tmp);
-       } else { /* do the getlong first, then add regd */
-           if (!ignorebase) {
-               mov_l_rr(target,base);
-               add_l_ri(target,addbase);
-           }
-           else
-               mov_l_ri(target,addbase);
-           if (dp&0x03) readlong(target,target,tmp);
-
-           if (!ignorereg) {
-               if ((dp & 0x800) == 0)
-                   sign_extend_16_rr(tmp,reg);
-               else
-                   mov_l_rr(tmp,reg);
-               shll_l_ri(tmp,regd_shift);
-               /* tmp is now regd */
-               add_l(target,tmp);
-           }
-       }
-       add_l_ri(target,outer);
-    }
-    else { /* 68000 version */
-       if ((dp & 0x800) == 0) { /* Sign extend */
-           sign_extend_16_rr(target,reg);
-           lea_l_brr_indexed(target,base,target,regd_shift,(uae_s32)(uae_s8)dp);
+       int reg = (dp >> 12) & 15;
+       int regd_shift=(dp >> 9) & 3;
+
+       if (dp & 0x100) {
+               int ignorebase=(dp&0x80);
+               int ignorereg=(dp&0x40);
+               int addbase=0;
+               int outer=0;
+
+               if ((dp & 0x30) == 0x20) addbase = (uae_s32)(uae_s16)comp_get_iword((m68k_pc_offset+=2)-2);
+               if ((dp & 0x30) == 0x30) addbase = comp_get_ilong((m68k_pc_offset+=4)-4);
+
+               if ((dp & 0x3) == 0x2) outer = (uae_s32)(uae_s16)comp_get_iword((m68k_pc_offset+=2)-2);
+               if ((dp & 0x3) == 0x3) outer = comp_get_ilong((m68k_pc_offset+=4)-4);
+
+               if ((dp & 0x4) == 0) {  /* add regd *before* the get_long */
+                       if (!ignorereg) {
+                               if ((dp & 0x800) == 0)
+                                       sign_extend_16_rr(target,reg);
+                               else
+                                       mov_l_rr(target,reg);
+                               shll_l_ri(target,regd_shift);
+                       }
+                       else
+                               mov_l_ri(target,0);
+
+                       /* target is now regd */
+                       if (!ignorebase)
+                               add_l(target,base);
+                       add_l_ri(target,addbase);
+                       if (dp&0x03) readlong(target,target,tmp);
+               } else { /* do the getlong first, then add regd */
+                       if (!ignorebase) {
+                               mov_l_rr(target,base);
+                               add_l_ri(target,addbase);
+                       }
+                       else
+                               mov_l_ri(target,addbase);
+                       if (dp&0x03) readlong(target,target,tmp);
+
+                       if (!ignorereg) {
+                               if ((dp & 0x800) == 0)
+                                       sign_extend_16_rr(tmp,reg);
+                               else
+                                       mov_l_rr(tmp,reg);
+                               shll_l_ri(tmp,regd_shift);
+                               /* tmp is now regd */
+                               add_l(target,tmp);
+                       }
+               }
+               add_l_ri(target,outer);
        }
-       else {
-           lea_l_brr_indexed(target,base,reg,regd_shift,(uae_s32)(uae_s8)dp);
+       else { /* 68000 version */
+               if ((dp & 0x800) == 0) { /* Sign extend */
+                       sign_extend_16_rr(target,reg);
+                       lea_l_brr_indexed(target,base,target,regd_shift,(uae_s32)(uae_s8)dp);
+               }
+               else {
+                       lea_l_brr_indexed(target,base,reg,regd_shift,(uae_s32)(uae_s8)dp);
+               }
        }
-    }
-    forget_about(tmp);
+       forget_about(tmp);
 }
 
 STATIC_INLINE unsigned int cft_map (unsigned int f)
 {
-    return ((f >> 8) & 255) | ((f & 255) << 8);
+       return ((f >> 8) & 255) | ((f & 255) << 8);
 }
 
 void set_cache_state(int enabled)
 {
-    if (enabled!=letit)
-       flush_icache_hard(0, 3);
-    letit=enabled;
+       if (enabled!=letit)
+               flush_icache_hard(0, 3);
+       letit=enabled;
 }
 
 int get_cache_state(void)
 {
-    return letit;
+       return letit;
 }
 
 uae_u32 get_jitted_size(void)
 {
-    if (compiled_code)
-       return current_compile_p-compiled_code;
-    return 0;
+       if (compiled_code)
+               return current_compile_p-compiled_code;
+       return 0;
 }
 
 void alloc_cache(void)
 {
-    if (compiled_code) {
-       flush_icache_hard(0, 3);
-       cache_free(compiled_code);
-    }
-    if (veccode == NULL)
-       veccode = cache_alloc (256);
-    if (popallspace == NULL)
-       popallspace = cache_alloc (1024);
-    compiled_code = NULL;
-    if (currprefs.cachesize == 0)
-       return;
+       if (compiled_code) {
+               flush_icache_hard(0, 3);
+               cache_free(compiled_code);
+       }
+       if (veccode == NULL)
+               veccode = cache_alloc (256);
+       if (popallspace == NULL)
+               popallspace = cache_alloc (1024);
+       compiled_code = NULL;
+       if (currprefs.cachesize == 0)
+               return;
 
-    while (!compiled_code && currprefs.cachesize) {
-       compiled_code=cache_alloc(currprefs.cachesize*1024);
-       if (!compiled_code)
-           currprefs.cachesize/=2;
-    }
-    if (compiled_code) {
-       max_compile_start=compiled_code+currprefs.cachesize*1024-BYTES_PER_INST;
-       current_compile_p=compiled_code;
-    }
+       while (!compiled_code && currprefs.cachesize) {
+               compiled_code=cache_alloc(currprefs.cachesize*1024);
+               if (!compiled_code)
+                       currprefs.cachesize/=2;
+       }
+       if (compiled_code) {
+               max_compile_start=compiled_code+currprefs.cachesize*1024-BYTES_PER_INST;
+               current_compile_p=compiled_code;
+       }
 }
 
 static void calc_checksum(blockinfo* bi, uae_u32* c1, uae_u32* c2)
 {
-    uae_u32 k1=0;
-    uae_u32 k2=0;
-    uae_s32 len=bi->len;
-    uae_u32 tmp=bi->min_pcp;
-    uae_u32* pos;
+       uae_u32 k1=0;
+       uae_u32 k2=0;
+       uae_s32 len=bi->len;
+       uae_u32 tmp=bi->min_pcp;
+       uae_u32* pos;
 
-    len+=(tmp&3);
-    tmp&=(~3);
-    pos=(uae_u32*)tmp;
+       len+=(tmp&3);
+       tmp&=(~3);
+       pos=(uae_u32*)tmp;
 
-    if (len<0 || len>MAX_CHECKSUM_LEN) {
-       *c1=0;
-       *c2=0;
-    }
-    else {
-       while (len>0) {
-           k1+=*pos;
-           k2^=*pos;
-           pos++;
-           len-=4;
+       if (len<0 || len>MAX_CHECKSUM_LEN) {
+               *c1=0;
+               *c2=0;
+       }
+       else {
+               while (len>0) {
+                       k1+=*pos;
+                       k2^=*pos;
+                       pos++;
+                       len-=4;
+               }
+               *c1=k1;
+               *c2=k2;
        }
-       *c1=k1;
-       *c2=k2;
-    }
 }
 
 static void show_checksum(blockinfo* bi)
 {
-    uae_u32 k1=0;
-    uae_u32 k2=0;
-    uae_s32 len=bi->len;
-    uae_u32 tmp=(uae_u32)bi->pc_p;
-    uae_u32* pos;
+       uae_u32 k1=0;
+       uae_u32 k2=0;
+       uae_s32 len=bi->len;
+       uae_u32 tmp=(uae_u32)bi->pc_p;
+       uae_u32* pos;
 
-    len+=(tmp&3);
-    tmp&=(~3);
-    pos=(uae_u32*)tmp;
+       len+=(tmp&3);
+       tmp&=(~3);
+       pos=(uae_u32*)tmp;
 
-    if (len<0 || len>MAX_CHECKSUM_LEN) {
-       return;
-    }
-    else {
-       while (len>0) {
-           write_log (L"%08x ",*pos);
-           pos++;
-           len-=4;
+       if (len<0 || len>MAX_CHECKSUM_LEN) {
+               return;
+       }
+       else {
+               while (len>0) {
+                       write_log (L"%08x ",*pos);
+                       pos++;
+                       len-=4;
+               }
+               write_log (L" bla\n");
        }
-       write_log (L" bla\n");
-    }
 }
 
 
 int check_for_cache_miss(void)
 {
-    blockinfo* bi=get_blockinfo_addr(regs.pc_p);
+       blockinfo* bi=get_blockinfo_addr(regs.pc_p);
 
-    if (bi) {
-       int cl=cacheline(regs.pc_p);
-       if (bi!=cache_tags[cl+1].bi) {
-           raise_in_cl_list(bi);
-           return 1;
+       if (bi) {
+               int cl=cacheline(regs.pc_p);
+               if (bi!=cache_tags[cl+1].bi) {
+                       raise_in_cl_list(bi);
+                       return 1;
+               }
        }
-    }
-    return 0;
+       return 0;
 }
 
 
 static void recompile_block(void)
 {
-    /* An existing block's countdown code has expired. We need to make
-       sure that execute_normal doesn't refuse to recompile due to a
-       perceived cache miss... */
-    blockinfo*  bi=get_blockinfo_addr(regs.pc_p);
+       /* An existing block's countdown code has expired. We need to make
+       sure that execute_normal doesn't refuse to recompile due to a
+       perceived cache miss... */
+       blockinfo*  bi=get_blockinfo_addr(regs.pc_p);
 
-    Dif (!bi)
-       jit_abort (L"recompile_block");
-    raise_in_cl_list(bi);
-    execute_normal();
-    return;
+       Dif (!bi)
+               jit_abort (L"recompile_block");
+       raise_in_cl_list(bi);
+       execute_normal();
+       return;
 }
 
 static void cache_miss(void)
 {
-    blockinfo*  bi=get_blockinfo_addr(regs.pc_p);
-    uae_u32     cl=cacheline(regs.pc_p);
-    blockinfo*  bi2=get_blockinfo(cl);
+       blockinfo*  bi=get_blockinfo_addr(regs.pc_p);
+       uae_u32     cl=cacheline(regs.pc_p);
+       blockinfo*  bi2=get_blockinfo(cl);
 
-    if (!bi) {
-       execute_normal(); /* Compile this block now */
+       if (!bi) {
+               execute_normal(); /* Compile this block now */
+               return;
+       }
+       Dif (!bi2 || bi==bi2) {
+               jit_abort (L"Unexplained cache miss %p %p\n",bi,bi2);
+       }
+       raise_in_cl_list(bi);
        return;
-    }
-    Dif (!bi2 || bi==bi2) {
-       jit_abort (L"Unexplained cache miss %p %p\n",bi,bi2);
-    }
-    raise_in_cl_list(bi);
-    return;
 }
 
 static void check_checksum(void)
 {
-    blockinfo*  bi=get_blockinfo_addr(regs.pc_p);
-    uae_u32     cl=cacheline(regs.pc_p);
-    blockinfo*  bi2=get_blockinfo(cl);
+       blockinfo*  bi=get_blockinfo_addr(regs.pc_p);
+       uae_u32     cl=cacheline(regs.pc_p);
+       blockinfo*  bi2=get_blockinfo(cl);
 
-    uae_u32     c1,c2;
+       uae_u32     c1,c2;
 
-    checksum_count++;
-    /* These are not the droids you are looking for...  */
-    if (!bi) {
-       /* Whoever is the primary target is in a dormant state, but
-          calling it was accidental, and we should just compile this
-          new block */
-       execute_normal();
-       return;
-    }
-    if (bi!=bi2) {
-       /* The block was hit accidentally, but it does exist. Cache miss */
-       cache_miss();
-       return;
-    }
-
-    if (bi->c1 || bi->c2)
-       calc_checksum(bi,&c1,&c2);
-    else {
-       c1=c2=1;  /* Make sure it doesn't match */
-    }
-    if (c1==bi->c1 && c2==bi->c2) {
-       /* This block is still OK. So we reactivate. Of course, that
-          means we have to move it into the needs-to-be-flushed list */
-       bi->handler_to_use=bi->handler;
-       set_dhtu(bi,bi->direct_handler);
-
-       /*      write_log (L"JIT: reactivate %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
+       checksum_count++;
+       /* These are not the droids you are looking for...  */
+       if (!bi) {
+               /* Whoever is the primary target is in a dormant state, but
+               calling it was accidental, and we should just compile this
+               new block */
+               execute_normal();
+               return;
+       }
+       if (bi!=bi2) {
+               /* The block was hit accidentally, but it does exist. Cache miss */
+               cache_miss();
+               return;
+       }
+
+       if (bi->c1 || bi->c2)
+               calc_checksum(bi,&c1,&c2);
+       else {
+               c1=c2=1;  /* Make sure it doesn't match */
+       }
+       if (c1==bi->c1 && c2==bi->c2) {
+               /* This block is still OK. So we reactivate. Of course, that
+               means we have to move it into the needs-to-be-flushed list */
+               bi->handler_to_use=bi->handler;
+               set_dhtu(bi,bi->direct_handler);
+
+               /*      write_log (L"JIT: reactivate %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
                c1,c2,bi->c1,bi->c2);*/
-       remove_from_list(bi);
-       add_to_active(bi);
-       raise_in_cl_list(bi);
-    }
-    else {
-       /* This block actually changed. We need to invalidate it,
-          and set it up to be recompiled */
-       /* write_log (L"JIT: discard %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
-          c1,c2,bi->c1,bi->c2); */
-       invalidate_block(bi);
-       raise_in_cl_list(bi);
-       execute_normal();
-    }
+               remove_from_list(bi);
+               add_to_active(bi);
+               raise_in_cl_list(bi);
+       }
+       else {
+               /* This block actually changed. We need to invalidate it,
+               and set it up to be recompiled */
+               /* write_log (L"JIT: discard %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
+               c1,c2,bi->c1,bi->c2); */
+               invalidate_block(bi);
+               raise_in_cl_list(bi);
+               execute_normal();
+       }
 }
 
 
 STATIC_INLINE void create_popalls(void)
 {
-  int i,r;
+       int i,r;
 
-  current_compile_p=popallspace;
-  set_target(current_compile_p);
+       current_compile_p=popallspace;
+       set_target(current_compile_p);
 #if USE_PUSH_POP
-  /* If we can't use gcc inline assembly, we need to pop some
-     registers before jumping back to the various get-out routines.
-     This generates the code for it.
-  */
-  popall_do_nothing=current_compile_p;
-  for (i=0;i<N_REGS;i++) {
-      if (need_to_preserve[i])
-         raw_pop_l_r(i);
-  }
-  raw_jmp((uae_u32)do_nothing);
-  align_target(32);
-
-  popall_execute_normal=get_target();
-  for (i=0;i<N_REGS;i++) {
-      if (need_to_preserve[i])
-         raw_pop_l_r(i);
-  }
-  raw_jmp((uae_u32)execute_normal);
-  align_target(32);
-
-  popall_cache_miss=get_target();
-  for (i=0;i<N_REGS;i++) {
-      if (need_to_preserve[i])
-         raw_pop_l_r(i);
-  }
-  raw_jmp((uae_u32)cache_miss);
-  align_target(32);
-
-  popall_recompile_block=get_target();
-  for (i=0;i<N_REGS;i++) {
-      if (need_to_preserve[i])
-         raw_pop_l_r(i);
-  }
-  raw_jmp((uae_u32)recompile_block);
-  align_target(32);
-
-  popall_exec_nostats=get_target();
-  for (i=0;i<N_REGS;i++) {
-      if (need_to_preserve[i])
-         raw_pop_l_r(i);
-  }
-  raw_jmp((uae_u32)exec_nostats);
-  align_target(32);
-
-  popall_check_checksum=get_target();
-  for (i=0;i<N_REGS;i++) {
-      if (need_to_preserve[i])
-         raw_pop_l_r(i);
-  }
-  raw_jmp((uae_u32)check_checksum);
-  align_target(32);
-
-  current_compile_p=get_target();
+       /* If we can't use gcc inline assembly, we need to pop some
+       registers before jumping back to the various get-out routines.
+       This generates the code for it.
+       */
+       popall_do_nothing=current_compile_p;
+       for (i=0;i<N_REGS;i++) {
+               if (need_to_preserve[i])
+                       raw_pop_l_r(i);
+       }
+       raw_jmp((uae_u32)do_nothing);
+       align_target(32);
+
+       popall_execute_normal=get_target();
+       for (i=0;i<N_REGS;i++) {
+               if (need_to_preserve[i])
+                       raw_pop_l_r(i);
+       }
+       raw_jmp((uae_u32)execute_normal);
+       align_target(32);
+
+       popall_cache_miss=get_target();
+       for (i=0;i<N_REGS;i++) {
+               if (need_to_preserve[i])
+                       raw_pop_l_r(i);
+       }
+       raw_jmp((uae_u32)cache_miss);
+       align_target(32);
+
+       popall_recompile_block=get_target();
+       for (i=0;i<N_REGS;i++) {
+               if (need_to_preserve[i])
+                       raw_pop_l_r(i);
+       }
+       raw_jmp((uae_u32)recompile_block);
+       align_target(32);
+
+       popall_exec_nostats=get_target();
+       for (i=0;i<N_REGS;i++) {
+               if (need_to_preserve[i])
+                       raw_pop_l_r(i);
+       }
+       raw_jmp((uae_u32)exec_nostats);
+       align_target(32);
+
+       popall_check_checksum=get_target();
+       for (i=0;i<N_REGS;i++) {
+               if (need_to_preserve[i])
+                       raw_pop_l_r(i);
+       }
+       raw_jmp((uae_u32)check_checksum);
+       align_target(32);
+
+       current_compile_p=get_target();
 #else
-  popall_exec_nostats=exec_nostats;
-  popall_execute_normal=execute_normal;
-  popall_cache_miss=cache_miss;
-  popall_recompile_block=recompile_block;
-  popall_do_nothing=do_nothing;
-  popall_check_checksum=check_checksum;
+       popall_exec_nostats=exec_nostats;
+       popall_execute_normal=execute_normal;
+       popall_cache_miss=cache_miss;
+       popall_recompile_block=recompile_block;
+       popall_do_nothing=do_nothing;
+       popall_check_checksum=check_checksum;
 #endif
 
-  /* And now, the code to do the matching pushes and then jump
-     into a handler routine */
-  pushall_call_handler=get_target();
+       /* And now, the code to do the matching pushes and then jump
+       into a handler routine */
+       pushall_call_handler=get_target();
 #if USE_PUSH_POP
-  for (i=N_REGS;i--;) {
-      if (need_to_preserve[i])
-         raw_push_l_r(i);
-  }
+       for (i=N_REGS;i--;) {
+               if (need_to_preserve[i])
+                       raw_push_l_r(i);
+       }
 #endif
-  r=REG_PC_TMP;
-  raw_mov_l_rm(r,(uae_u32)&regs.pc_p);
-  raw_and_l_ri(r,TAGMASK);
-  raw_jmp_m_indexed((uae_u32)cache_tags,r,4);
+       r=REG_PC_TMP;
+       raw_mov_l_rm(r,(uae_u32)&regs.pc_p);
+       raw_and_l_ri(r,TAGMASK);
+       raw_jmp_m_indexed((uae_u32)cache_tags,r,4);
 }
 
 STATIC_INLINE void reset_lists(void)
 {
-    int i;
+       int i;
 
-    for (i=0;i<MAX_HOLD_BI;i++)
-       hold_bi[i]=NULL;
-    active=NULL;
-    dormant=NULL;
+       for (i=0;i<MAX_HOLD_BI;i++)
+               hold_bi[i]=NULL;
+       active=NULL;
+       dormant=NULL;
 }
 
 static void prepare_block(blockinfo* bi)
 {
-    int i;
+       int i;
 
-    set_target(current_compile_p);
-    align_target(32);
-    bi->direct_pen=(cpuop_func*)get_target();
-    raw_mov_l_rm(0,(uae_u32)&(bi->pc_p));
-    raw_mov_l_mr((uae_u32)&regs.pc_p,0);
-    raw_jmp((uae_u32)popall_execute_normal);
+       set_target(current_compile_p);
+       align_target(32);
+       bi->direct_pen=(cpuop_func*)get_target();
+       raw_mov_l_rm(0,(uae_u32)&(bi->pc_p));
+       raw_mov_l_mr((uae_u32)&regs.pc_p,0);
+       raw_jmp((uae_u32)popall_execute_normal);
 
-    align_target(32);
-    bi->direct_pcc=(cpuop_func*)get_target();
-    raw_mov_l_rm(0,(uae_u32)&(bi->pc_p));
-    raw_mov_l_mr((uae_u32)&regs.pc_p,0);
-    raw_jmp((uae_u32)popall_check_checksum);
+       align_target(32);
+       bi->direct_pcc=(cpuop_func*)get_target();
+       raw_mov_l_rm(0,(uae_u32)&(bi->pc_p));
+       raw_mov_l_mr((uae_u32)&regs.pc_p,0);
+       raw_jmp((uae_u32)popall_check_checksum);
 
-    align_target(32);
-    current_compile_p=get_target();
+       align_target(32);
+       current_compile_p=get_target();
 
-    bi->deplist=NULL;
-    for (i=0;i<2;i++) {
-       bi->dep[i].prev_p=NULL;
-       bi->dep[i].next=NULL;
-    }
-    bi->env=default_ss;
-    bi->status=BI_NEW;
-    bi->havestate=0;
-    //bi->env=empty_ss;
+       bi->deplist=NULL;
+       for (i=0;i<2;i++) {
+               bi->dep[i].prev_p=NULL;
+               bi->dep[i].next=NULL;
+       }
+       bi->env=default_ss;
+       bi->status=BI_NEW;
+       bi->havestate=0;
+       //bi->env=empty_ss;
 }
 
 void compemu_reset(void)
 {
-    set_cache_state(0);
+       set_cache_state(0);
 }
 
 void build_comp(void)
 {
-    int i;
-    int jumpcount=0;
-    unsigned long opcode;
-    const struct comptbl* tbl=op_smalltbl_0_comp_ff;
-    const struct comptbl* nftbl=op_smalltbl_0_comp_nf;
-    int count;
+       int i;
+       int jumpcount=0;
+       unsigned long opcode;
+       const struct comptbl* tbl=op_smalltbl_0_comp_ff;
+       const struct comptbl* nftbl=op_smalltbl_0_comp_nf;
+       int count;
 #ifdef NOFLAGS_SUPPORT
-    struct comptbl *nfctbl = (currprefs.cpu_level >= 5 ? op_smalltbl_0_nf
-                            : currprefs.cpu_level == 4 ? op_smalltbl_1_nf
-                            : (currprefs.cpu_level == 2 || currprefs.cpu_level == 3) ? op_smalltbl_2_nf
-                            : currprefs.cpu_level == 1 ? op_smalltbl_3_nf
-                            : ! currprefs.cpu_compatible ? op_smalltbl_4_nf
-                            : op_smalltbl_5_nf);
+       struct comptbl *nfctbl = (currprefs.cpu_level >= 5 ? op_smalltbl_0_nf
+               : currprefs.cpu_level == 4 ? op_smalltbl_1_nf
+               : (currprefs.cpu_level == 2 || currprefs.cpu_level == 3) ? op_smalltbl_2_nf
+               : currprefs.cpu_level == 1 ? op_smalltbl_3_nf
+               : ! currprefs.cpu_compatible ? op_smalltbl_4_nf
+               : op_smalltbl_5_nf);
 #endif
-    raw_init_cpu();
+       raw_init_cpu();
 #ifdef NATMEM_OFFSET
-    write_log (L"JIT: Setting signal handler\n");
+       write_log (L"JIT: Setting signal handler\n");
 #ifndef _WIN32
-    signal(SIGSEGV,vec);
+       signal(SIGSEGV,vec);
 #endif
 #endif
-    write_log (L"JIT: Building Compiler function table\n");
-    for (opcode = 0; opcode < 65536; opcode++) {
+       write_log (L"JIT: Building Compiler function table\n");
+       for (opcode = 0; opcode < 65536; opcode++) {
 #ifdef NOFLAGS_SUPPORT
-       nfcpufunctbl[opcode] = op_illg;
+               nfcpufunctbl[opcode] = op_illg;
 #endif
-       compfunctbl[opcode] = NULL;
-       nfcompfunctbl[opcode] = NULL;
-       prop[opcode].use_flags = 0x1f;
-       prop[opcode].set_flags = 0x1f;
-       prop[opcode].is_jump=1;
-    }
-
-    for (i = 0; tbl[i].opcode < 65536; i++) {
-       int isjmp=(tbl[i].specific&1);
-       int isaddx=(tbl[i].specific&8);
-       int iscjmp=(tbl[i].specific&16);
-
-       prop[tbl[i].opcode].is_jump=isjmp;
-       prop[tbl[i].opcode].is_const_jump=iscjmp;
-       prop[tbl[i].opcode].is_addx=isaddx;
-       compfunctbl[tbl[i].opcode] = tbl[i].handler;
-    }
-    for (i = 0; nftbl[i].opcode < 65536; i++) {
-       nfcompfunctbl[nftbl[i].opcode] = nftbl[i].handler;
+               compfunctbl[opcode] = NULL;
+               nfcompfunctbl[opcode] = NULL;
+               prop[opcode].use_flags = 0x1f;
+               prop[opcode].set_flags = 0x1f;
+               prop[opcode].is_jump=1;
+       }
+
+       for (i = 0; tbl[i].opcode < 65536; i++) {
+               int isjmp=(tbl[i].specific&1);
+               int isaddx=(tbl[i].specific&8);
+               int iscjmp=(tbl[i].specific&16);
+
+               prop[tbl[i].opcode].is_jump=isjmp;
+               prop[tbl[i].opcode].is_const_jump=iscjmp;
+               prop[tbl[i].opcode].is_addx=isaddx;
+               compfunctbl[tbl[i].opcode] = tbl[i].handler;
+       }
+       for (i = 0; nftbl[i].opcode < 65536; i++) {
+               nfcompfunctbl[nftbl[i].opcode] = nftbl[i].handler;
 #ifdef NOFLAGS_SUPPORT
-       nfcpufunctbl[nftbl[i].opcode] = nfctbl[i].handler;
+               nfcpufunctbl[nftbl[i].opcode] = nfctbl[i].handler;
 #endif
-    }
+       }
 
 #ifdef NOFLAGS_SUPPORT
-    for (i = 0; nfctbl[i].handler; i++) {
-       nfcpufunctbl[nfctbl[i].opcode] = nfctbl[i].handler;
-    }
+       for (i = 0; nfctbl[i].handler; i++) {
+               nfcpufunctbl[nfctbl[i].opcode] = nfctbl[i].handler;
+       }
 #endif
 
-    for (opcode = 0; opcode < 65536; opcode++) {
-       compop_func *f;
-       compop_func *nff;
+       for (opcode = 0; opcode < 65536; opcode++) {
+               compop_func *f;
+               compop_func *nff;
 #ifdef NOFLAGS_SUPPORT
-       compop_func *nfcf;
+               compop_func *nfcf;
 #endif
-       int isjmp,isaddx,iscjmp;
-       int lvl;
-
-       lvl = (currprefs.cpu_model - 68000) / 10;
-       if (lvl > 4)
-           lvl--;
-       if (table68k[opcode].mnemo == i_ILLG || table68k[opcode].clev > lvl)
-           continue;
-
-       if (table68k[opcode].handler != -1) {
-           f = compfunctbl[table68k[opcode].handler];
-           nff = nfcompfunctbl[table68k[opcode].handler];
+               int isjmp,isaddx,iscjmp;
+               int lvl;
+
+               lvl = (currprefs.cpu_model - 68000) / 10;
+               if (lvl > 4)
+                       lvl--;
+               if (table68k[opcode].mnemo == i_ILLG || table68k[opcode].clev > lvl)
+                       continue;
+
+               if (table68k[opcode].handler != -1) {
+                       f = compfunctbl[table68k[opcode].handler];
+                       nff = nfcompfunctbl[table68k[opcode].handler];
 #ifdef NOFLAGS_SUPPORT
-           nfcf = nfcpufunctbl[table68k[opcode].handler];
+                       nfcf = nfcpufunctbl[table68k[opcode].handler];
 #endif
-           isjmp=prop[table68k[opcode].handler].is_jump;
-           iscjmp=prop[table68k[opcode].handler].is_const_jump;
-           isaddx=prop[table68k[opcode].handler].is_addx;
-           prop[opcode].is_jump=isjmp;
-           prop[opcode].is_const_jump=iscjmp;
-           prop[opcode].is_addx=isaddx;
-           compfunctbl[opcode] = f;
-           nfcompfunctbl[opcode] = nff;
+                       isjmp=prop[table68k[opcode].handler].is_jump;
+                       iscjmp=prop[table68k[opcode].handler].is_const_jump;
+                       isaddx=prop[table68k[opcode].handler].is_addx;
+                       prop[opcode].is_jump=isjmp;
+                       prop[opcode].is_const_jump=iscjmp;
+                       prop[opcode].is_addx=isaddx;
+                       compfunctbl[opcode] = f;
+                       nfcompfunctbl[opcode] = nff;
 #ifdef NOFLAGS_SUPPORT
-           Dif (nfcf == op_illg)
-               abort();
-           nfcpufunctbl[opcode] = nfcf;
+                       Dif (nfcf == op_illg)
+                               abort();
+                       nfcpufunctbl[opcode] = nfcf;
 #endif
+               }
+               prop[opcode].set_flags =table68k[opcode].flagdead;
+               prop[opcode].use_flags =table68k[opcode].flaglive;
+               /* Unconditional jumps don't evaluate condition codes, so they
+               don't actually use any flags themselves */
+               if (prop[opcode].is_const_jump)
+                       prop[opcode].use_flags=0;
        }
-       prop[opcode].set_flags =table68k[opcode].flagdead;
-       prop[opcode].use_flags =table68k[opcode].flaglive;
-       /* Unconditional jumps don't evaluate condition codes, so they
-          don't actually use any flags themselves */
-       if (prop[opcode].is_const_jump)
-           prop[opcode].use_flags=0;
-    }
 #ifdef NOFLAGS_SUPPORT
-    for (i = 0; nfctbl[i].handler != NULL; i++) {
-       if (nfctbl[i].specific)
-           nfcpufunctbl[tbl[i].opcode] = nfctbl[i].handler;
-    }
+       for (i = 0; nfctbl[i].handler != NULL; i++) {
+               if (nfctbl[i].specific)
+                       nfcpufunctbl[tbl[i].opcode] = nfctbl[i].handler;
+       }
 #endif
 
-    count=0;
-    for (opcode = 0; opcode < 65536; opcode++) {
-       if (compfunctbl[opcode])
-           count++;
-    }
-    write_log (L"JIT: Supposedly %d compileable opcodes!\n",count);
-
-    /* Initialise state */
-    alloc_cache();
-    create_popalls();
-    reset_lists();
-
-    for (i=0;i<TAGSIZE;i+=2) {
-       cache_tags[i].handler=(cpuop_func*)popall_execute_normal;
-       cache_tags[i+1].bi=NULL;
-    }
-    compemu_reset();
-
-    for (i=0;i<N_REGS;i++) {
-       empty_ss.nat[i].holds=-1;
-       empty_ss.nat[i].validsize=0;
-       empty_ss.nat[i].dirtysize=0;
-    }
-    default_ss=empty_ss;
+       count=0;
+       for (opcode = 0; opcode < 65536; opcode++) {
+               if (compfunctbl[opcode])
+                       count++;
+       }
+       write_log (L"JIT: Supposedly %d compileable opcodes!\n",count);
+
+       /* Initialise state */
+       alloc_cache();
+       create_popalls();
+       reset_lists();
+
+       for (i=0;i<TAGSIZE;i+=2) {
+               cache_tags[i].handler=(cpuop_func*)popall_execute_normal;
+               cache_tags[i+1].bi=NULL;
+       }
+       compemu_reset();
+
+       for (i=0;i<N_REGS;i++) {
+               empty_ss.nat[i].holds=-1;
+               empty_ss.nat[i].validsize=0;
+               empty_ss.nat[i].dirtysize=0;
+       }
+       default_ss=empty_ss;
 #if 0
-    default_ss.nat[6].holds=11;
-    default_ss.nat[6].validsize=4;
-    default_ss.nat[5].holds=12;
-    default_ss.nat[5].validsize=4;
+       default_ss.nat[6].holds=11;
+       default_ss.nat[6].validsize=4;
+       default_ss.nat[5].holds=12;
+       default_ss.nat[5].validsize=4;
 #endif
 }
 
 
 static void flush_icache_hard(uae_u32 ptr, int n)
 {
-    blockinfo* bi;
+       blockinfo* bi;
 
-    hard_flush_count++;
+       hard_flush_count++;
 #if 0
-    write_log (L"JIT: Flush Icache_hard(%d/%x/%p), %u instruction bytes\n",
-          n,regs.pc,regs.pc_p,current_compile_p-compiled_code);
+       write_log (L"JIT: Flush Icache_hard(%d/%x/%p), %u instruction bytes\n",
+               n,regs.pc,regs.pc_p,current_compile_p-compiled_code);
 #endif
-    bi=active;
-    while(bi) {
-       cache_tags[cacheline(bi->pc_p)].handler=(cpuop_func*)popall_execute_normal;
-       cache_tags[cacheline(bi->pc_p)+1].bi=NULL;
-       bi=bi->next;
-    }
-    bi=dormant;
-    while(bi) {
-       cache_tags[cacheline(bi->pc_p)].handler=(cpuop_func*)popall_execute_normal;
-       cache_tags[cacheline(bi->pc_p)+1].bi=NULL;
-       bi=bi->next;
-    }
-
-    reset_lists();
-    if (!compiled_code)
-       return;
-    current_compile_p=compiled_code;
-    set_special(0); /* To get out of compiled code */
+       bi=active;
+       while(bi) {
+               cache_tags[cacheline(bi->pc_p)].handler=(cpuop_func*)popall_execute_normal;
+               cache_tags[cacheline(bi->pc_p)+1].bi=NULL;
+               bi=bi->next;
+       }
+       bi=dormant;
+       while(bi) {
+               cache_tags[cacheline(bi->pc_p)].handler=(cpuop_func*)popall_execute_normal;
+               cache_tags[cacheline(bi->pc_p)+1].bi=NULL;
+               bi=bi->next;
+       }
+
+       reset_lists();
+       if (!compiled_code)
+               return;
+       current_compile_p=compiled_code;
+       set_special(0); /* To get out of compiled code */
 }
 
 
 /* "Soft flushing" --- instead of actually throwing everything away,
-   we simply mark everything as "needs to be checked".
+we simply mark everything as "needs to be checked".
 */
 
 void flush_icache(uaecptr ptr, int n)
 {
-    blockinfo* bi;
-    blockinfo* bi2;
+       blockinfo* bi;
+       blockinfo* bi2;
 
-    if (currprefs.comp_hardflush) {
-       flush_icache_hard(ptr, n);
-       return;
-    }
-    soft_flush_count++;
-    if (!active)
-       return;
+       if (currprefs.comp_hardflush) {
+               flush_icache_hard(ptr, n);
+               return;
+       }
+       soft_flush_count++;
+       if (!active)
+               return;
 
-    bi=active;
-    while (bi) {
-       uae_u32 cl=cacheline(bi->pc_p);
-       if (!bi->handler) {
-           /* invalidated block */
-           if (bi==cache_tags[cl+1].bi)
-               cache_tags[cl].handler=(cpuop_func*)popall_execute_normal;
-           bi->handler_to_use=(cpuop_func*)popall_execute_normal;
-           set_dhtu(bi,bi->direct_pen);
-       } else {
-           if (bi==cache_tags[cl+1].bi)
-               cache_tags[cl].handler=(cpuop_func*)popall_check_checksum;
-           bi->handler_to_use=(cpuop_func*)popall_check_checksum;
-           set_dhtu(bi,bi->direct_pcc);
+       bi=active;
+       while (bi) {
+               uae_u32 cl=cacheline(bi->pc_p);
+               if (!bi->handler) {
+                       /* invalidated block */
+                       if (bi==cache_tags[cl+1].bi)
+                               cache_tags[cl].handler=(cpuop_func*)popall_execute_normal;
+                       bi->handler_to_use=(cpuop_func*)popall_execute_normal;
+                       set_dhtu(bi,bi->direct_pen);
+               } else {
+                       if (bi==cache_tags[cl+1].bi)
+                               cache_tags[cl].handler=(cpuop_func*)popall_check_checksum;
+                       bi->handler_to_use=(cpuop_func*)popall_check_checksum;
+                       set_dhtu(bi,bi->direct_pcc);
+               }
+               bi2=bi;
+               bi=bi->next;
        }
-       bi2=bi;
-       bi=bi->next;
-    }
-    /* bi2 is now the last entry in the active list */
-    bi2->next=dormant;
-    if (dormant)
-       dormant->prev_p=&(bi2->next);
+       /* bi2 is now the last entry in the active list */
+       bi2->next=dormant;
+       if (dormant)
+               dormant->prev_p=&(bi2->next);
 
-    dormant=active;
-    active->prev_p=&dormant;
-    active=NULL;
+       dormant=active;
+       active->prev_p=&dormant;
+       active=NULL;
 }
 
 
 static void catastrophe(void)
 {
-    jit_abort (L"catastprophe");
+       jit_abort (L"catastprophe");
 }
 
 int failure;
@@ -5908,378 +5908,378 @@ int failure;
 
 void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
 {
-    if (letit && compiled_code && currprefs.cpu_model>=68020) {
+       if (letit && compiled_code && currprefs.cpu_model>=68020) {
+
+               /* OK, here we need to 'compile' a block */
+               int i;
+               int r;
+               int was_comp=0;
+               uae_u8 liveflags[MAXRUN+1];
+               uae_u32 max_pcp=(uae_u32)pc_hist[0].location;
+               uae_u32 min_pcp=max_pcp;
+               uae_u32 cl=cacheline(pc_hist[0].location);
+               void* specflags=(void*)&regs.spcflags;
+               blockinfo* bi=NULL;
+               blockinfo* bi2;
+               int extra_len=0;
+
+               compile_count++;
+               if (current_compile_p>=max_compile_start)
+                       flush_icache_hard(0, 3);
+
+               alloc_blockinfos();
+
+               bi=get_blockinfo_addr_new(pc_hist[0].location,0);
+               bi2=get_blockinfo(cl);
+
+               optlev=bi->optlevel;
+               if (bi->handler) {
+                       Dif (bi!=bi2) {
+                               /* I don't think it can happen anymore. Shouldn't, in
+                               any case. So let's make sure... */
+                               jit_abort (L"JIT: WOOOWOO count=%d, ol=%d %p %p\n",
+                                       bi->count,bi->optlevel,bi->handler_to_use,
+                                       cache_tags[cl].handler);
+                       }
+
+                       Dif (bi->count!=-1 && bi->status!=BI_TARGETTED) {
+                               /* What the heck? We are not supposed to be here! */
+                               jit_abort (L"BI_TARGETTED");
+                       }
+               }
+               if (bi->count==-1) {
+                       optlev++;
+                       while (!currprefs.optcount[optlev])
+                               optlev++;
+                       bi->count=currprefs.optcount[optlev]-1;
+               }
+               current_block_pc_p=(uae_u32)pc_hist[0].location;
+
+               remove_deps(bi); /* We are about to create new code */
+               bi->optlevel=optlev;
+               bi->pc_p=(uae_u8*)pc_hist[0].location;
+
+               liveflags[blocklen]=0x1f; /* All flags needed afterwards */
+               i=blocklen;
+               while (i--) {
+                       uae_u16* currpcp=pc_hist[i].location;
+                       int op=cft_map(*currpcp);
+
+                       if ((uae_u32)currpcp<min_pcp)
+                               min_pcp=(uae_u32)currpcp;
+                       if ((uae_u32)currpcp>max_pcp)
+                               max_pcp=(uae_u32)currpcp;
+
+                       if (currprefs.compnf) {
+                               liveflags[i]=((liveflags[i+1]&
+                                       (~prop[op].set_flags))|
+                                       prop[op].use_flags);
+                               if (prop[op].is_addx && (liveflags[i+1]&FLAG_Z)==0)
+                                       liveflags[i]&= ~FLAG_Z;
+                       }
+                       else {
+                               liveflags[i]=0x1f;
+                       }
+               }
 
-       /* OK, here we need to 'compile' a block */
-       int i;
-       int r;
-       int was_comp=0;
-       uae_u8 liveflags[MAXRUN+1];
-       uae_u32 max_pcp=(uae_u32)pc_hist[0].location;
-       uae_u32 min_pcp=max_pcp;
-       uae_u32 cl=cacheline(pc_hist[0].location);
-       void* specflags=(void*)&regs.spcflags;
-       blockinfo* bi=NULL;
-       blockinfo* bi2;
-       int extra_len=0;
-
-       compile_count++;
-       if (current_compile_p>=max_compile_start)
-           flush_icache_hard(0, 3);
-
-       alloc_blockinfos();
-
-       bi=get_blockinfo_addr_new(pc_hist[0].location,0);
-       bi2=get_blockinfo(cl);
-
-       optlev=bi->optlevel;
-       if (bi->handler) {
-           Dif (bi!=bi2) {
-               /* I don't think it can happen anymore. Shouldn't, in
-                  any case. So let's make sure... */
-               jit_abort (L"JIT: WOOOWOO count=%d, ol=%d %p %p\n",
-                      bi->count,bi->optlevel,bi->handler_to_use,
-                      cache_tags[cl].handler);
-           }
-
-           Dif (bi->count!=-1 && bi->status!=BI_TARGETTED) {
-               /* What the heck? We are not supposed to be here! */
-               jit_abort (L"BI_TARGETTED");
-           }
-       }
-       if (bi->count==-1) {
-           optlev++;
-           while (!currprefs.optcount[optlev])
-               optlev++;
-           bi->count=currprefs.optcount[optlev]-1;
-       }
-       current_block_pc_p=(uae_u32)pc_hist[0].location;
-
-       remove_deps(bi); /* We are about to create new code */
-       bi->optlevel=optlev;
-       bi->pc_p=(uae_u8*)pc_hist[0].location;
-
-       liveflags[blocklen]=0x1f; /* All flags needed afterwards */
-       i=blocklen;
-       while (i--) {
-           uae_u16* currpcp=pc_hist[i].location;
-           int op=cft_map(*currpcp);
-
-           if ((uae_u32)currpcp<min_pcp)
-               min_pcp=(uae_u32)currpcp;
-           if ((uae_u32)currpcp>max_pcp)
-               max_pcp=(uae_u32)currpcp;
-
-           if (currprefs.compnf) {
-               liveflags[i]=((liveflags[i+1]&
-                              (~prop[op].set_flags))|
-                             prop[op].use_flags);
-               if (prop[op].is_addx && (liveflags[i+1]&FLAG_Z)==0)
-                   liveflags[i]&= ~FLAG_Z;
-           }
-           else {
-               liveflags[i]=0x1f;
-           }
-       }
-
-       bi->needed_flags=liveflags[0];
-
-       /* This is the non-direct handler */
-       align_target(32);
-       set_target(get_target()+1);
-       align_target(16);
-       /* Now aligned at n*32+16 */
+               bi->needed_flags=liveflags[0];
 
-       bi->handler=
-           bi->handler_to_use=(cpuop_func*)get_target();
-       raw_cmp_l_mi((uae_u32)&regs.pc_p,(uae_u32)pc_hist[0].location);
-       raw_jnz((uae_u32)popall_cache_miss);
-       /* This was 16 bytes on the x86, so now aligned on (n+1)*32 */
+               /* This is the non-direct handler */
+               align_target(32);
+               set_target(get_target()+1);
+               align_target(16);
+               /* Now aligned at n*32+16 */
 
-       was_comp=0;
+               bi->handler=
+                       bi->handler_to_use=(cpuop_func*)get_target();
+               raw_cmp_l_mi((uae_u32)&regs.pc_p,(uae_u32)pc_hist[0].location);
+               raw_jnz((uae_u32)popall_cache_miss);
+               /* This was 16 bytes on the x86, so now aligned on (n+1)*32 */
+
+               was_comp=0;
 
 #if USE_MATCHSTATE
-       comp_pc_p=(uae_u8*)pc_hist[0].location;
-       init_comp();
-       match_states(&(bi->env));
-       was_comp=1;
+               comp_pc_p=(uae_u8*)pc_hist[0].location;
+               init_comp();
+               match_states(&(bi->env));
+               was_comp=1;
 #endif
 
-       bi->direct_handler=(cpuop_func*)get_target();
-       set_dhtu(bi,bi->direct_handler);
-       current_block_start_target=(uae_u32)get_target();
+               bi->direct_handler=(cpuop_func*)get_target();
+               set_dhtu(bi,bi->direct_handler);
+               current_block_start_target=(uae_u32)get_target();
 
-       if (bi->count>=0) { /* Need to generate countdown code */
-           raw_mov_l_mi((uae_u32)&regs.pc_p,(uae_u32)pc_hist[0].location);
-           raw_sub_l_mi((uae_u32)&(bi->count),1);
-           raw_jl((uae_u32)popall_recompile_block);
-       }
-       if (optlev==0) { /* No need to actually translate */
-           /* Execute normally without keeping stats */
-           raw_mov_l_mi((uae_u32)&regs.pc_p,(uae_u32)pc_hist[0].location);
-           raw_jmp((uae_u32)popall_exec_nostats);
-       }
-       else {
-           reg_alloc_run=0;
-           next_pc_p=0;
-           taken_pc_p=0;
-           branch_cc=0;
-
-           log_startblock();
-           for (i=0;i<blocklen &&
-                    get_target_noopt()<max_compile_start;i++) {
-               cpuop_func **cputbl;
-               compop_func **comptbl;
-               uae_u16 opcode;
-
-               opcode=cft_map((uae_u16)*pc_hist[i].location);
-               special_mem=pc_hist[i].specmem;
-               needed_flags=(liveflags[i+1] & prop[opcode].set_flags);
-               if (!needed_flags && currprefs.compnf) {
+               if (bi->count>=0) { /* Need to generate countdown code */
+                       raw_mov_l_mi((uae_u32)&regs.pc_p,(uae_u32)pc_hist[0].location);
+                       raw_sub_l_mi((uae_u32)&(bi->count),1);
+                       raw_jl((uae_u32)popall_recompile_block);
+               }
+               if (optlev==0) { /* No need to actually translate */
+                       /* Execute normally without keeping stats */
+                       raw_mov_l_mi((uae_u32)&regs.pc_p,(uae_u32)pc_hist[0].location);
+                       raw_jmp((uae_u32)popall_exec_nostats);
+               }
+               else {
+                       reg_alloc_run=0;
+                       next_pc_p=0;
+                       taken_pc_p=0;
+                       branch_cc=0;
+
+                       log_startblock();
+                       for (i=0;i<blocklen &&
+                               get_target_noopt()<max_compile_start;i++) {
+                                       cpuop_func **cputbl;
+                                       compop_func **comptbl;
+                                       uae_u16 opcode;
+
+                                       opcode=cft_map((uae_u16)*pc_hist[i].location);
+                                       special_mem=pc_hist[i].specmem;
+                                       needed_flags=(liveflags[i+1] & prop[opcode].set_flags);
+                                       if (!needed_flags && currprefs.compnf) {
 #ifdef NOFLAGS_SUPPORT
-                   cputbl=nfcpufunctbl;
+                                               cputbl=nfcpufunctbl;
 #else
-                   cputbl=cpufunctbl;
+                                               cputbl=cpufunctbl;
 #endif
-                   comptbl=nfcompfunctbl;
-               }
-               else {
-                   cputbl=cpufunctbl;
-                   comptbl=compfunctbl;
-               }
-
-               if (comptbl[opcode] && optlev>1) {
-                   failure=0;
-                   if (!was_comp) {
-                       comp_pc_p=(uae_u8*)pc_hist[i].location;
-                       init_comp();
-                   }
-                   was_comp++;
-
-                   comptbl[opcode](opcode);
-                   freescratch();
-                   if (!(liveflags[i+1] & FLAG_CZNV)) {
-                       /* We can forget about flags */
-                       dont_care_flags();
-                   }
+                                               comptbl=nfcompfunctbl;
+                                       }
+                                       else {
+                                               cputbl=cpufunctbl;
+                                               comptbl=compfunctbl;
+                                       }
+
+                                       if (comptbl[opcode] && optlev>1) {
+                                               failure=0;
+                                               if (!was_comp) {
+                                                       comp_pc_p=(uae_u8*)pc_hist[i].location;
+                                                       init_comp();
+                                               }
+                                               was_comp++;
+
+                                               comptbl[opcode](opcode);
+                                               freescratch();
+                                               if (!(liveflags[i+1] & FLAG_CZNV)) {
+                                                       /* We can forget about flags */
+                                                       dont_care_flags();
+                                               }
 #if INDIVIDUAL_INST
-                   flush(1);
-                   nop();
-                   flush(1);
-                   was_comp=0;
+                                               flush(1);
+                                               nop();
+                                               flush(1);
+                                               was_comp=0;
 #endif
-               }
-               else
-                   failure=1;
-               if (failure) {
-                   if (was_comp) {
-                       flush(1);
-                       was_comp=0;
-                   }
-                   raw_mov_l_ri(REG_PAR1,(uae_u32)opcode);
-                   raw_mov_l_ri(REG_PAR2,(uae_u32)&regs);
+                                       }
+                                       else
+                                               failure=1;
+                                       if (failure) {
+                                               if (was_comp) {
+                                                       flush(1);
+                                                       was_comp=0;
+                                               }
+                                               raw_mov_l_ri(REG_PAR1,(uae_u32)opcode);
+                                               raw_mov_l_ri(REG_PAR2,(uae_u32)&regs);
 #if USE_NORMAL_CALLING_CONVENTION
-                   raw_push_l_r(REG_PAR2);
-                   raw_push_l_r(REG_PAR1);
+                                               raw_push_l_r(REG_PAR2);
+                                               raw_push_l_r(REG_PAR1);
 #endif
-                   raw_mov_l_mi((uae_u32)&regs.pc_p,
-                                (uae_u32)pc_hist[i].location);
-                   raw_call((uae_u32)cputbl[opcode]);
-                   //raw_add_l_mi((uae_u32)&oink,1); // FIXME
+                                               raw_mov_l_mi((uae_u32)&regs.pc_p,
+                                                       (uae_u32)pc_hist[i].location);
+                                               raw_call((uae_u32)cputbl[opcode]);
+                                               //raw_add_l_mi((uae_u32)&oink,1); // FIXME
 #if USE_NORMAL_CALLING_CONVENTION
-                   raw_inc_sp(8);
+                                               raw_inc_sp(8);
 #endif
-                   /*if (needed_flags)
-                       raw_mov_l_mi((uae_u32)&foink3,(uae_u32)opcode+65536);
-                   else
-                       raw_mov_l_mi((uae_u32)&foink3,(uae_u32)opcode);
-                    */
-
-                   if (i<blocklen-1) {
-                       uae_s8* branchadd;
-
-                       raw_mov_l_rm(0,(uae_u32)specflags);
-                       raw_test_l_rr(0,0);
-                       raw_jz_b_oponly();
-                       branchadd=(uae_s8*)get_target();
-                       emit_byte(0);
-                       raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
-                       raw_jmp((uae_u32)popall_do_nothing);
-                       *branchadd=(uae_u32)get_target()-(uae_u32)branchadd-1;
-                   }
-               }
-           }
+                                               /*if (needed_flags)
+                                               raw_mov_l_mi((uae_u32)&foink3,(uae_u32)opcode+65536);
+                                               else
+                                               raw_mov_l_mi((uae_u32)&foink3,(uae_u32)opcode);
+                                               */
+
+                                               if (i<blocklen-1) {
+                                                       uae_s8* branchadd;
+
+                                                       raw_mov_l_rm(0,(uae_u32)specflags);
+                                                       raw_test_l_rr(0,0);
+                                                       raw_jz_b_oponly();
+                                                       branchadd=(uae_s8*)get_target();
+                                                       emit_byte(0);
+                                                       raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                                                       raw_jmp((uae_u32)popall_do_nothing);
+                                                       *branchadd=(uae_u32)get_target()-(uae_u32)branchadd-1;
+                                               }
+                                       }
+                       }
 #if 0 /* This isn't completely kosher yet; It really needs to be
-        be integrated into a general inter-block-dependency scheme */
-           if (next_pc_p && taken_pc_p &&
-               was_comp && taken_pc_p==current_block_pc_p) {
-               blockinfo* bi1=get_blockinfo_addr_new((void*)next_pc_p,0);
-               blockinfo* bi2=get_blockinfo_addr_new((void*)taken_pc_p,0);
-               uae_u8 x=bi1->needed_flags;
-
-               if (x==0xff || 1) {  /* To be on the safe side */
-                   uae_u16* next=(uae_u16*)next_pc_p;
-                   uae_u16 op=cft_map(*next);
-
-                   x=0x1f;
-                   x&=(~prop[op].set_flags);
-                   x|=prop[op].use_flags;
-               }
-
-               x|=bi2->needed_flags;
-               if (!(x & FLAG_CZNV)) {
-                   /* We can forget about flags */
-                   dont_care_flags();
-                   extra_len+=2; /* The next instruction now is part of this
-                                    block */
-               }
-
-           }
+                       be integrated into a general inter-block-dependency scheme */
+                       if (next_pc_p && taken_pc_p &&
+                               was_comp && taken_pc_p==current_block_pc_p) {
+                                       blockinfo* bi1=get_blockinfo_addr_new((void*)next_pc_p,0);
+                                       blockinfo* bi2=get_blockinfo_addr_new((void*)taken_pc_p,0);
+                                       uae_u8 x=bi1->needed_flags;
+
+                                       if (x==0xff || 1) {  /* To be on the safe side */
+                                               uae_u16* next=(uae_u16*)next_pc_p;
+                                               uae_u16 op=cft_map(*next);
+
+                                               x=0x1f;
+                                               x&=(~prop[op].set_flags);
+                                               x|=prop[op].use_flags;
+                                       }
+
+                                       x|=bi2->needed_flags;
+                                       if (!(x & FLAG_CZNV)) {
+                                               /* We can forget about flags */
+                                               dont_care_flags();
+                                               extra_len+=2; /* The next instruction now is part of this
+                                                                         block */
+                                       }
+
+                       }
 #endif
 
-           if (next_pc_p) { /* A branch was registered */
-               uae_u32 t1=next_pc_p;
-               uae_u32 t2=taken_pc_p;
-               int     cc=branch_cc;
-
-               uae_u32* branchadd;
-               uae_u32* tba;
-               bigstate tmp;
-               blockinfo* tbi;
-
-               if (taken_pc_p<next_pc_p) {
-                   /* backward branch. Optimize for the "taken" case ---
-                      which means the raw_jcc should fall through when
-                      the 68k branch is taken. */
-                   t1=taken_pc_p;
-                   t2=next_pc_p;
-                   cc=branch_cc^1;
-               }
+                       if (next_pc_p) { /* A branch was registered */
+                               uae_u32 t1=next_pc_p;
+                               uae_u32 t2=taken_pc_p;
+                               int     cc=branch_cc;
+
+                               uae_u32* branchadd;
+                               uae_u32* tba;
+                               bigstate tmp;
+                               blockinfo* tbi;
+
+                               if (taken_pc_p<next_pc_p) {
+                                       /* backward branch. Optimize for the "taken" case ---
+                                       which means the raw_jcc should fall through when
+                                       the 68k branch is taken. */
+                                       t1=taken_pc_p;
+                                       t2=next_pc_p;
+                                       cc=branch_cc^1;
+                               }
 
 #if !USE_MATCHSTATE
-               flush_keepflags();
+                               flush_keepflags();
 #endif
-               tmp=live; /* ouch! This is big... */
-               raw_jcc_l_oponly(cc);
-               branchadd=(uae_u32*)get_target();
-               emit_long(0);
-               /* predicted outcome */
-               tbi=get_blockinfo_addr_new((void*)t1,1);
-               match_states(&(tbi->env));
-               //flush(1); /* Can only get here if was_comp==1 */
-               raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
-               raw_jcc_l_oponly(9);
-               tba=(uae_u32*)get_target();
-               emit_long(get_handler(t1)-((uae_u32)tba+4));
-               raw_mov_l_mi((uae_u32)&regs.pc_p,t1);
-               raw_jmp((uae_u32)popall_do_nothing);
-               create_jmpdep(bi,0,tba,t1);
-
-               align_target(16);
-               /* not-predicted outcome */
-               *branchadd=(uae_u32)get_target()-((uae_u32)branchadd+4);
-               live=tmp; /* Ouch again */
-               tbi=get_blockinfo_addr_new((void*)t2,1);
-               match_states(&(tbi->env));
-
-               //flush(1); /* Can only get here if was_comp==1 */
-               raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
-               raw_jcc_l_oponly(9);
-               tba=(uae_u32*)get_target();
-               emit_long(get_handler(t2)-((uae_u32)tba+4));
-               raw_mov_l_mi((uae_u32)&regs.pc_p,t2);
-               raw_jmp((uae_u32)popall_do_nothing);
-               create_jmpdep(bi,1,tba,t2);
-           }
-           else
-           {
-               if (was_comp) {
-                   flush(1);
+                               tmp=live; /* ouch! This is big... */
+                               raw_jcc_l_oponly(cc);
+                               branchadd=(uae_u32*)get_target();
+                               emit_long(0);
+                               /* predicted outcome */
+                               tbi=get_blockinfo_addr_new((void*)t1,1);
+                               match_states(&(tbi->env));
+                               //flush(1); /* Can only get here if was_comp==1 */
+                               raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                               raw_jcc_l_oponly(9);
+                               tba=(uae_u32*)get_target();
+                               emit_long(get_handler(t1)-((uae_u32)tba+4));
+                               raw_mov_l_mi((uae_u32)&regs.pc_p,t1);
+                               raw_jmp((uae_u32)popall_do_nothing);
+                               create_jmpdep(bi,0,tba,t1);
+
+                               align_target(16);
+                               /* not-predicted outcome */
+                               *branchadd=(uae_u32)get_target()-((uae_u32)branchadd+4);
+                               live=tmp; /* Ouch again */
+                               tbi=get_blockinfo_addr_new((void*)t2,1);
+                               match_states(&(tbi->env));
+
+                               //flush(1); /* Can only get here if was_comp==1 */
+                               raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                               raw_jcc_l_oponly(9);
+                               tba=(uae_u32*)get_target();
+                               emit_long(get_handler(t2)-((uae_u32)tba+4));
+                               raw_mov_l_mi((uae_u32)&regs.pc_p,t2);
+                               raw_jmp((uae_u32)popall_do_nothing);
+                               create_jmpdep(bi,1,tba,t2);
+                       }
+                       else
+                       {
+                               if (was_comp) {
+                                       flush(1);
+                               }
+
+                               /* Let's find out where next_handler is... */
+                               if (was_comp && isinreg(PC_P)) {
+                                       int r2;
+
+                                       r=live.state[PC_P].realreg;
+
+                                       if (r==0)
+                                               r2=1;
+                                       else
+                                               r2=0;
+
+                                       raw_and_l_ri(r,TAGMASK);
+                                       raw_mov_l_ri(r2,(uae_u32)popall_do_nothing);
+                                       raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                                       raw_cmov_l_rm_indexed(r2,(uae_u32)cache_tags,r,9);
+                                       raw_jmp_r(r2);
+                               }
+                               else if (was_comp && isconst(PC_P)) {
+                                       uae_u32 v=live.state[PC_P].val;
+                                       uae_u32* tba;
+                                       blockinfo* tbi;
+
+                                       tbi=get_blockinfo_addr_new((void*)v,1);
+                                       match_states(&(tbi->env));
+
+                                       raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                                       raw_jcc_l_oponly(9);
+                                       tba=(uae_u32*)get_target();
+                                       emit_long(get_handler(v)-((uae_u32)tba+4));
+                                       raw_mov_l_mi((uae_u32)&regs.pc_p,v);
+                                       raw_jmp((uae_u32)popall_do_nothing);
+                                       create_jmpdep(bi,0,tba,v);
+                               }
+                               else {
+                                       int r2;
+
+                                       r=REG_PC_TMP;
+                                       raw_mov_l_rm(r,(uae_u32)&regs.pc_p);
+                                       if (r==0)
+                                               r2=1;
+                                       else
+                                               r2=0;
+
+                                       raw_and_l_ri(r,TAGMASK);
+                                       raw_mov_l_ri(r2,(uae_u32)popall_do_nothing);
+                                       raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                                       raw_cmov_l_rm_indexed(r2,(uae_u32)cache_tags,r,9);
+                                       raw_jmp_r(r2);
+                               }
+                       }
                }
 
-               /* Let's find out where next_handler is... */
-               if (was_comp && isinreg(PC_P)) {
-                   int r2;
-
-                   r=live.state[PC_P].realreg;
-
-                   if (r==0)
-                       r2=1;
-                   else
-                       r2=0;
-
-                   raw_and_l_ri(r,TAGMASK);
-                   raw_mov_l_ri(r2,(uae_u32)popall_do_nothing);
-                   raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
-                   raw_cmov_l_rm_indexed(r2,(uae_u32)cache_tags,r,9);
-                   raw_jmp_r(r2);
-               }
-               else if (was_comp && isconst(PC_P)) {
-                   uae_u32 v=live.state[PC_P].val;
-                   uae_u32* tba;
-                   blockinfo* tbi;
-
-                   tbi=get_blockinfo_addr_new((void*)v,1);
-                   match_states(&(tbi->env));
-
-                   raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
-                   raw_jcc_l_oponly(9);
-                   tba=(uae_u32*)get_target();
-                   emit_long(get_handler(v)-((uae_u32)tba+4));
-                   raw_mov_l_mi((uae_u32)&regs.pc_p,v);
-                   raw_jmp((uae_u32)popall_do_nothing);
-                   create_jmpdep(bi,0,tba,v);
-               }
+               if (next_pc_p+extra_len>=max_pcp &&
+                       next_pc_p+extra_len<max_pcp+LONGEST_68K_INST)
+                       max_pcp=next_pc_p+extra_len;  /* extra_len covers flags magic */
+               else
+                       max_pcp+=LONGEST_68K_INST;
+               bi->len=max_pcp-min_pcp;
+               bi->min_pcp=min_pcp;
+
+               remove_from_list(bi);
+               if (isinrom(min_pcp) && isinrom(max_pcp))
+                       add_to_dormant(bi); /* No need to checksum it on cache flush.
+                                                               Please don't start changing ROMs in
+                                                               flight! */
                else {
-                   int r2;
-
-                   r=REG_PC_TMP;
-                   raw_mov_l_rm(r,(uae_u32)&regs.pc_p);
-                   if (r==0)
-                       r2=1;
-                   else
-                       r2=0;
-
-                   raw_and_l_ri(r,TAGMASK);
-                   raw_mov_l_ri(r2,(uae_u32)popall_do_nothing);
-                   raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
-                   raw_cmov_l_rm_indexed(r2,(uae_u32)cache_tags,r,9);
-                   raw_jmp_r(r2);
+                       calc_checksum(bi,&(bi->c1),&(bi->c2));
+                       add_to_active(bi);
                }
-           }
-       }
 
-       if (next_pc_p+extra_len>=max_pcp &&
-           next_pc_p+extra_len<max_pcp+LONGEST_68K_INST)
-           max_pcp=next_pc_p+extra_len;  /* extra_len covers flags magic */
-       else
-           max_pcp+=LONGEST_68K_INST;
-       bi->len=max_pcp-min_pcp;
-       bi->min_pcp=min_pcp;
+               log_dump();
+               align_target(32);
+               current_compile_p=get_target();
 
-       remove_from_list(bi);
-       if (isinrom(min_pcp) && isinrom(max_pcp))
-           add_to_dormant(bi); /* No need to checksum it on cache flush.
-                                  Please don't start changing ROMs in
-                                  flight! */
-       else {
-           calc_checksum(bi,&(bi->c1),&(bi->c2));
-           add_to_active(bi);
-       }
+               raise_in_cl_list(bi);
+               bi->nexthandler=current_compile_p;
 
-       log_dump();
-       align_target(32);
-       current_compile_p=get_target();
+               /* We will flush soon, anyway, so let's do it now */
+               if (current_compile_p>=max_compile_start)
+                       flush_icache_hard(0, 3);
 
-       raise_in_cl_list(bi);
-       bi->nexthandler=current_compile_p;
-
-       /* We will flush soon, anyway, so let's do it now */
-       if (current_compile_p>=max_compile_start)
-           flush_icache_hard(0, 3);
-
-       do_extra_cycles(totcycles); /* for the compilation time */
-    }
+               do_extra_cycles(totcycles); /* for the compilation time */
+       }
 }
 
 #endif
index 65321c7f4156b3b2ec374c7d702653742302e4ca..9ddf7da62c88620583ea0c7b6e1c40d699419123 100644 (file)
@@ -947,7 +947,7 @@ static void REGPARAM2 kickmem_bput (uaecptr addr, uae_u32 b)
                } else
                        a1000_handle_kickstart (0);
        } else if (currprefs.illegal_mem)
-               write_log (L"Illegal kickmem lput at %08lx\n", addr);
+               write_log (L"Illegal kickmem bput at %08lx\n", addr);
 }
 
 static void REGPARAM2 kickmem2_lput (uaecptr addr, uae_u32 l)
index 9b2c6d62a9d029747541b064ef22fe6b91f7cd3b..1ce4450d05c31546a9fdd65c40ca6b7dbde2557e 100644 (file)
@@ -1442,7 +1442,9 @@ kludge_me_do:
        regs.ir = get_word_ce (m68k_getpc ()); // prefetch 1
        do_cycles_ce000 (2);
        regs.irc = get_word_ce (m68k_getpc () + 2); // prefetch 2
+#ifdef JIT
        set_special (SPCFLAG_END_COMPILE);
+#endif
        exception_trace (nr);
 }
 #endif
@@ -1566,7 +1568,9 @@ kludge_me_do:
                return;
        }
        m68k_setpc (newpc);
+#ifdef JIT
        set_special (SPCFLAG_END_COMPILE);
+#endif
        fill_prefetch_slow ();
        exception_trace (nr);
 }
@@ -1638,7 +1642,9 @@ static void Exception_normal (int nr, uaecptr oldpc)
                                                        return;
                                                }
                                                m68k_setpc (newpc);
+#ifdef JIT
                                                set_special (SPCFLAG_END_COMPILE);
+#endif
                                                exception_trace (nr);
                                                return;
 
@@ -1747,7 +1753,9 @@ kludge_me_do:
                return;
        }
        m68k_setpc (newpc);
+#ifdef JIT
        set_special (SPCFLAG_END_COMPILE);
+#endif
        fill_prefetch_slow ();
        exception_trace (nr);
 }
@@ -2653,7 +2661,6 @@ STATIC_INLINE int do_specialties (int cycles)
        if (regs.spcflags & SPCFLAG_COPPER)
                do_copper ();
 
-       /*n_spcinsns++;*/
 #ifdef JIT
        unset_special (SPCFLAG_END_COMPILE);   /* has done its job */
 #endif
index e47f341360a93a3b62925358ec937dec5296e1c4..0c61c3412858ad54af8072339ff47c18185b57d8 100644 (file)
@@ -129,6 +129,7 @@ struct AHIAudioCtrlDrv
        ULONG        ahiac_AntiClickSamples;    /* AntiClick samples (V6)       */
        struct Hook *ahiac_PreTimerFunc;        /* A Hook wrapper for ahiac_PreTimer (V6) */
        struct Hook *ahiac_PostTimerFunc;       /* A Hook wrapper for ahiac_PostTimer (V6) */
+}
 #endif
 
 #define ahiac_AudioCtrl 0
@@ -156,7 +157,7 @@ struct AHIAudioCtrlDrv
 #define ahiac_PreTimerFunc ahiac_AntiClickSamples + 4 
 #define ahiac_PostTimerFunc ahiac_PreTimerFunc + 4 
 
-       /* AHIsub_AllocAudio return flags */
+/* AHIsub_AllocAudio return flags */
 #define AHISF_ERROR            (1<<0)
 #define AHISF_MIXING           (1<<1)
 #define AHISF_TIMING           (1<<2)
@@ -175,14 +176,14 @@ struct AHIAudioCtrlDrv
 #define AHISB_CANPOSTPROCESS   (6)
 #define AHISB_KNOWMULTICHANNEL (7)
 
-       /* AHIsub_Start() and AHIsub_Stop() flags */
+/* AHIsub_Start() and AHIsub_Stop() flags */
 #define        AHISF_PLAY              (1<<0)
 #define        AHISF_RECORD            (1<<1)
 
 #define        AHISB_PLAY              (0)
 #define        AHISB_RECORD            (1)
 
-       /* ahiac_Flags */
+/* ahiac_Flags */
 #define        AHIACF_VOL              (1<<0)
 #define        AHIACF_PAN              (1<<1)
 #define        AHIACF_STEREO           (1<<2)
@@ -216,7 +217,7 @@ struct AHIAudioCtrlDrv
 #define AHI_TagBase            (0x80000000)
 #define AHI_TagBaseR           (AHI_TagBase|0x8000)
 
-       /* AHI_AllocAudioA tags */
+/* AHI_AllocAudioA tags */
 #define AHIA_AudioID           (AHI_TagBase+1)         /* Desired audio mode */
 #define AHIA_MixFreq           (AHI_TagBase+2)         /* Suggested mixing frequency */
 #define AHIA_Channels          (AHI_TagBase+3)         /* Suggested number of channels */
@@ -230,13 +231,13 @@ struct AHIAudioCtrlDrv
 #define AHIA_UserData          (AHI_TagBase+11)        /* What to put in ahiac_UserData */
 #define AHIA_AntiClickSamples  (AHI_TagBase+13)        /* # of samples to smooth (V6)  */
 
-       /* AHI_ControlAudioA tags */
+/* AHI_ControlAudioA tags */
 #define AHIC_Play              (AHI_TagBase+80)        /* Boolean */
 #define AHIC_Record            (AHI_TagBase+81)        /* Boolean */
 #define AHIC_MonitorVolume     (AHI_TagBase+82)
 #define AHIC_MonitorVolume_Query (AHI_TagBase+83)      /* ti_Data is pointer to Fixed (LONG) */
 #define AHIC_MixFreq_Query     (AHI_TagBase+84)        /* ti_Data is pointer to ULONG */
-       /* --- New for V2, they will be ignored by V1 --- */
+/* --- New for V2, they will be ignored by V1 --- */
 #define AHIC_InputGain         (AHI_TagBase+85)
 #define AHIC_InputGain_Query   (AHI_TagBase+86)        /* ti_Data is pointer to Fixed (LONG) */
 #define AHIC_OutputVolume      (AHI_TagBase+87)
@@ -246,7 +247,7 @@ struct AHIAudioCtrlDrv
 #define AHIC_Output            (AHI_TagBase+91)
 #define AHIC_Output_Query      (AHI_TagBase+92)        /* ti_Data is pointer to ULONG */
 
-       /* AHI_GetAudioAttrsA tags */
+/* AHI_GetAudioAttrsA tags */
 #define AHIDB_AudioID          (AHI_TagBase+100)
 #define AHIDB_Driver           (AHI_TagBaseR+101)      /* Pointer to name of driver */
 #define AHIDB_Flags            (AHI_TagBase+102)       /* Private! */
@@ -276,7 +277,7 @@ struct AHIAudioCtrlDrv
 #define AHIDB_MaxPlaySamples   (AHI_TagBase+126)       /* It's sample *frames* */
 #define AHIDB_MaxRecordSamples (AHI_TagBase+127)       /* It's sample *frames* */
 #define AHIDB_FullDuplex       (AHI_TagBase+129)       /* Boolean */
-       /* --- New for V2, they will be ignored by V1 --- */
+/* --- New for V2, they will be ignored by V1 --- */
 #define AHIDB_MinMonitorVolume (AHI_TagBase+130)
 #define AHIDB_MaxMonitorVolume (AHI_TagBase+131)
 #define AHIDB_MinInputGain     (AHI_TagBase+132)
@@ -289,23 +290,23 @@ struct AHIAudioCtrlDrv
 #define AHIDB_Outputs          (AHI_TagBase+139)
 #define AHIDB_OutputArg                (AHI_TagBase+140)       /* ti_Data is input index */
 #define AHIDB_Output           (AHI_TagBase+141)
-       /* --- New for V4, they will be ignored by V2 and earlier --- */
+/* --- New for V4, they will be ignored by V2 and earlier --- */
 #define AHIDB_Data             (AHI_TagBaseR+142)      /* Private! */
 #define AHIDB_DriverBaseName   (AHI_TagBaseR+143)      /* Private! */
-       /* --- New for V6, they will be ignored by V4 and earlier --- */
+/* --- New for V6, they will be ignored by V4 and earlier --- */
 #define AHIDB_MultiChannel     (AHI_TagBase+144)       /* Boolean */
 
-       /* Sound Types */
+/* Sound Types */
 #define AHIST_NOTYPE           (~0UL)                  /* Private */
 #define AHIST_SAMPLE           (0UL)                   /* 8 or 16 bit sample */
 #define AHIST_DYNAMICSAMPLE    (1UL)                   /* Dynamic sample */
 #define AHIST_INPUT            (1UL<<29)               /* The input from your sampler */
 #define AHIST_BW               (1UL<<30)               /* Private */
 
-       /* Sample types */
-       /* Note that only AHIST_M8S, AHIST_S8S, AHIST_M16S and AHIST_S16S
-       (plus AHIST_M32S, AHIST_S32S and AHIST_L7_1 in V6)
-       are supported by AHI_LoadSound(). */
+/* Sample types */
+/* Note that only AHIST_M8S, AHIST_S8S, AHIST_M16S and AHIST_S16S
+(plus AHIST_M32S, AHIST_S32S and AHIST_L7_1 in V6)
+are supported by AHI_LoadSound(). */
 #define AHIST_M8S              (0UL)                   /* Mono, 8 bit signed (BYTE) */
 #define AHIST_M16S             (1UL)                   /* Mono, 16 bit signed (WORD) */
 #define AHIST_S8S              (2UL)                   /* Stereo, 8 bit signed (2×BYTE) */
@@ -315,7 +316,7 @@ struct AHIAudioCtrlDrv
 #define AHIST_M8U              (4UL)                   /* OBSOLETE! */
 #define AHIST_L7_1             (0x00c3000aUL)          /* 7.1, 32 bit signed (8×LONG) */
 
-       /* Error codes */
+/* Error codes */
 #define AHIE_OK                        (0UL)                   /* No error */
 #define AHIE_NOMEM             (1UL)                   /* Out of memory */
 #define AHIE_BADSOUNDTYPE      (2UL)                   /* Unknown sound type */
@@ -324,90 +325,90 @@ struct AHIAudioCtrlDrv
 #define AHIE_UNKNOWN           (5UL)                   /* Error, but unknown */
 #define AHIE_HALFDUPLEX                (6UL)                   /* CMD_WRITE/CMD_READ failure */
 
-       struct dssample {
-               int num;
-               int ch;
-               int bitspersample;
-               int bytespersample;
-               int dynamic;
-               uae_u32 addr;
-               uae_u32 len;
-               uae_u32 type;
-               uae_u32 sampletype;
-               ALuint al_buffer[2];
-       };
-
-       struct chsample {
-               int frequency;
-               int volume;
-               int panning;
-               int backwards;
-               struct dssample *ds;
-               int srcplayoffset;
-               int srcplaylen;
-       };
-
-       struct dschannel {
-               int num;
-               struct chsample cs;
-               struct chsample csnext;
-               int channelsignal;
-               int dsplaying;
-               ALuint al_source;
-               int samplecounter;
-               int buffertoggle;
-               int maxplaysamples;
-               int totalsamples;
-               int waitforack;
-       };
-
-       struct DSAHI {
-               uae_u32 audioctrl;
-               int chout;
-               int bits24;
-               int bitspersampleout;
-               int bytespersampleout;
-               int channellength;
-               int mixlength;
-               int input;
-               int output;
-               int channels;
-               int sounds;
-               int playerfreq;
-               uae_u32 audioid;
-               int enabledisable;
-               struct dssample *sample;
-               struct dschannel *channel;
-               int playing, recording;
-               evt evttime;
-               uae_u32 signalchannelmask;
-
-               ALCdevice *al_dev, *al_recorddev;
-               ALCcontext *al_ctx;
-               int al_bufferformat;
-               uae_u8 *tmpbuffer;
-               int tmpbuffer_size;
-               int dsrecording;
-               int record_samples;
-               int record_ch;
-               int record_bytespersample;
-               int record_wait;
-               int maxplaysamples;
-       };
-
-       static struct DSAHI dsahi[1];
+struct dssample {
+       int num;
+       int ch;
+       int bitspersample;
+       int bytespersample;
+       int dynamic;
+       uae_u32 addr;
+       uae_u32 len;
+       uae_u32 type;
+       uae_u32 sampletype;
+       ALuint al_buffer[2];
+};
+
+struct chsample {
+       int frequency;
+       int volume;
+       int panning;
+       int backwards;
+       struct dssample *ds;
+       int srcplayoffset;
+       int srcplaylen;
+};
+
+struct dschannel {
+       int num;
+       struct chsample cs;
+       struct chsample csnext;
+       int channelsignal;
+       int dsplaying;
+       ALuint al_source;
+       int samplecounter;
+       int buffertoggle;
+       int maxplaysamples;
+       int totalsamples;
+       int waitforack;
+};
+
+struct DSAHI {
+       uae_u32 audioctrl;
+       int chout;
+       int bits24;
+       int bitspersampleout;
+       int bytespersampleout;
+       int channellength;
+       int mixlength;
+       int input;
+       int output;
+       int channels;
+       int sounds;
+       int playerfreq;
+       uae_u32 audioid;
+       int enabledisable;
+       struct dssample *sample;
+       struct dschannel *channel;
+       int playing, recording;
+       evt evttime;
+       uae_u32 signalchannelmask;
+
+       ALCdevice *al_dev, *al_recorddev;
+       ALCcontext *al_ctx;
+       int al_bufferformat;
+       uae_u8 *tmpbuffer;
+       int tmpbuffer_size;
+       int dsrecording;
+       int record_samples;
+       int record_ch;
+       int record_bytespersample;
+       int record_wait;
+       int maxplaysamples;
+};
+
+static struct DSAHI dsahi[1];
 
 #define GETAHI (&dsahi[get_long(get_long(audioctrl + ahiac_DriverData) + pub_Index)])
 #define GETSAMPLE (dsahip && sound >= 0 && sound < UAE_MAXSOUNDS ? &dsahip->sample[sound] : NULL)
 #define GETCHANNEL (dsahip && channel >= 0 && channel < UAE_MAXCHANNELS ? &dsahip->channel[channel] : NULL)
 
-       static int default_freq = 44100;
-       static int cansurround;
-       static uae_u32 xahi_author, xahi_copyright, xahi_version;
-       static uae_u32 xahi_output[MAX_SOUND_DEVICES], xahi_output_num;
-       static uae_u32 xahi_input[MAX_SOUND_DEVICES], xahi_input_num;
-       static int ahi_paused;
-       static int ahi_active;
+static int default_freq = 44100;
+static int cansurround;
+static uae_u32 xahi_author, xahi_copyright, xahi_version;
+static uae_u32 xahi_output[MAX_SOUND_DEVICES], xahi_output_num;
+static uae_u32 xahi_input[MAX_SOUND_DEVICES], xahi_input_num;
+static int ahi_paused;
+static int ahi_active;
 
 #define TAG_DONE   (0L)                /* terminates array of TagItems. ti_Data unused */
 #define TAG_IGNORE (1L)                /* ignore this item, not end of array */
@@ -415,1524 +416,1524 @@ struct AHIAudioCtrlDrv
 #define TAG_SKIP   (3L)                /* skip this and the next ti_Data items */
 #define TAG_USER   ((uae_u32)(1L << 31))
 
-       static uae_u32 gettag (uae_u32 *tagpp, uae_u32 *datap)
-       {
-               uae_u32 tagp = *tagpp;
-               for (;;) {
-                       uae_u32 tag = get_long (tagp);
-                       uae_u32 data = get_long (tagp + 4);
-                       switch (tag)
-                       {
-                       case TAG_DONE:
-                               return 0;
-                       case TAG_IGNORE:
-                               tagp += 8;
-                               break;
-                       case TAG_MORE:
-                               tagp = data;
-                               break;
-                       case TAG_SKIP:
-                               tagp += data * 8;
-                               break;
-                       default:
-                               tagp += 8;
-                               *tagpp = tagp;
-                               *datap = data;
-                               return tag;
-                       }
+static uae_u32 gettag (uae_u32 *tagpp, uae_u32 *datap)
+{
+       uae_u32 tagp = *tagpp;
+       for (;;) {
+               uae_u32 tag = get_long (tagp);
+               uae_u32 data = get_long (tagp + 4);
+               switch (tag)
+               {
+               case TAG_DONE:
+                       return 0;
+               case TAG_IGNORE:
+                       tagp += 8;
+                       break;
+               case TAG_MORE:
+                       tagp = data;
+                       break;
+               case TAG_SKIP:
+                       tagp += data * 8;
+                       break;
+               default:
+                       tagp += 8;
+                       *tagpp = tagp;
+                       *datap = data;
+                       return tag;
                }
        }
+}
 
 
-       static int sendsignal (struct DSAHI *dsahip)
-       {
-               uae_u32 audioctrl = dsahip->audioctrl;
-               uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
-               uae_u32 channelinfo;
-               uae_u32 task, signalmask;
-               uae_s16 taskmode = get_word (puaebase + pub_TaskMode);
-               uae_s16 funcmode = get_word (puaebase + pub_FuncMode);
-               task = get_long (puaebase + pub_FuncTask);
-               signalmask = get_long (puaebase + pub_WaitMask);
-
-               if ((!dsahip->playing && !dsahip->recording) || ahi_paused)
-                       return 0;
-               if (taskmode <= 0)
-                       return 0;
-               if (dsahip->enabledisable) {
-                       // allocate Amiga-side recordingbuffer
-                       funcmode &= FUNCMODE_RECORDALLOC;
-                       put_word (puaebase + pub_FuncMode, funcmode);
-               }
+static int sendsignal (struct DSAHI *dsahip)
+{
+       uae_u32 audioctrl = dsahip->audioctrl;
+       uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
+       uae_u32 channelinfo;
+       uae_u32 task, signalmask;
+       uae_s16 taskmode = get_word (puaebase + pub_TaskMode);
+       uae_s16 funcmode = get_word (puaebase + pub_FuncMode);
+       task = get_long (puaebase + pub_FuncTask);
+       signalmask = get_long (puaebase + pub_WaitMask);
+
+       if ((!dsahip->playing && !dsahip->recording) || ahi_paused)
+               return 0;
+       if (taskmode <= 0)
+               return 0;
+       if (dsahip->enabledisable) {
+               // allocate Amiga-side recordingbuffer
+               funcmode &= FUNCMODE_RECORDALLOC;
+               put_word (puaebase + pub_FuncMode, funcmode);
+       }
 
-               channelinfo = get_long (puaebase + pub_ChannelInfo);
-               if (channelinfo) {
-                       int i, ch;
-                       ch = get_word (channelinfo + ahieci_Channels);
-                       if (ch > UAE_MAXCHANNELS)
-                               ch = UAE_MAXCHANNELS;
-                       for (i = 0; i < ch; i++) {
-                               struct dschannel *dc = &dsahip->channel[i];
-                               int v;
-                               alGetSourcei (dc->al_source, AL_SAMPLE_OFFSET, &v);
-                               put_long (channelinfo + ahieci_Offset + i * 4, v + dc->samplecounter * dc->maxplaysamples);
-                       }
+       channelinfo = get_long (puaebase + pub_ChannelInfo);
+       if (channelinfo) {
+               int i, ch;
+               ch = get_word (channelinfo + ahieci_Channels);
+               if (ch > UAE_MAXCHANNELS)
+                       ch = UAE_MAXCHANNELS;
+               for (i = 0; i < ch; i++) {
+                       struct dschannel *dc = &dsahip->channel[i];
+                       int v;
+                       alGetSourcei (dc->al_source, AL_SAMPLE_OFFSET, &v);
+                       put_long (channelinfo + ahieci_Offset + i * 4, v + dc->samplecounter * dc->maxplaysamples);
                }
-
-               uae_Signal (task, signalmask);
-               return 1;
        }
 
-       static int setchannelevent (struct DSAHI *dsahip, struct dschannel *dc)
-       {
-               uae_u32 audioctrl = dsahip->audioctrl;
-               uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
-               int ch = dc - &dsahip->channel[0];
-               uae_u32 mask;
+       uae_Signal (task, signalmask);
+       return 1;
+}
 
-               if (!dsahip->playing || ahi_paused || !dc->al_source || !get_long (audioctrl + ahiac_SoundFunc))
-                       return 0;
-               mask = get_long (puaebase + pub_ChannelSignal);
-               if (mask & (1 << ch))
-                       return 0;
-               dc->channelsignal = 1;
-               put_long (puaebase + pub_ChannelSignal, mask | (1 << ch));
-               sendsignal (dsahip);
-               return 1;
-       }
+static int setchannelevent (struct DSAHI *dsahip, struct dschannel *dc)
+{
+       uae_u32 audioctrl = dsahip->audioctrl;
+       uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
+       int ch = dc - &dsahip->channel[0];
+       uae_u32 mask;
 
-       static void evtfunc (uae_u32 v)
-       {
-               if (ahi_active) {
-                       struct DSAHI *dsahip = &dsahi[v];
-                       uae_u32 audioctrl = dsahip->audioctrl;
-                       uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
-
-                       put_word (puaebase + pub_FuncMode, get_word (puaebase + pub_FuncMode) | FUNCMODE_PLAY);
-                       if (sendsignal (dsahip)) {
-                               event2_newevent2 (dsahip->evttime, v, evtfunc);
-                       } else {
-                               dsahip->evttime = 0;
-                       }
-               }
-       }
+       if (!dsahip->playing || ahi_paused || !dc->al_source || !get_long (audioctrl + ahiac_SoundFunc))
+               return 0;
+       mask = get_long (puaebase + pub_ChannelSignal);
+       if (mask & (1 << ch))
+               return 0;
+       dc->channelsignal = 1;
+       put_long (puaebase + pub_ChannelSignal, mask | (1 << ch));
+       sendsignal (dsahip);
+       return 1;
+}
 
-       static void setevent (struct DSAHI *dsahip)
-       {
+static void evtfunc (uae_u32 v)
+{
+       if (ahi_active) {
+               struct DSAHI *dsahip = &dsahi[v];
                uae_u32 audioctrl = dsahip->audioctrl;
-               uae_u32 freq = get_long (audioctrl + ahiac_PlayerFreq);
-               double f;
-               uae_u32 cycles;
-               evt t;
+               uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
 
-               f = ((double)(freq >> 16)) + ((double)(freq & 0xffff)) / 65536.0;
-               if (f < 1)
-                       return;
-               cycles = maxhpos * maxvpos_nom * vblank_hz;
-               t = (evt)(cycles / f);
-               if (dsahip->evttime == t)
-                       return;
-               write_log (L"AHI: playerfunc freq = %.2fHz\n", f);
-               dsahip->evttime = t;
-               if (t < 10)
-                       return;
-               event2_newevent2 (t, dsahip - &dsahi[0], evtfunc);
+               put_word (puaebase + pub_FuncMode, get_word (puaebase + pub_FuncMode) | FUNCMODE_PLAY);
+               if (sendsignal (dsahip)) {
+                       event2_newevent2 (dsahip->evttime, v, evtfunc);
+               } else {
+                       dsahip->evttime = 0;
+               }
        }
+}
 
-       static void alClear (void)
-       {
-               alGetError ();
-       }
-       static int alError (const TCHAR *format,...)
-       {
-               TCHAR buffer[1000];
-               va_list parms;
-               int err;
+static void setevent (struct DSAHI *dsahip)
+{
+       uae_u32 audioctrl = dsahip->audioctrl;
+       uae_u32 freq = get_long (audioctrl + ahiac_PlayerFreq);
+       double f;
+       uae_u32 cycles;
+       evt t;
+
+       f = ((double)(freq >> 16)) + ((double)(freq & 0xffff)) / 65536.0;
+       if (f < 1)
+               return;
+       cycles = maxhpos * maxvpos_nom * vblank_hz;
+       t = (evt)(cycles / f);
+       if (dsahip->evttime == t)
+               return;
+       write_log (L"AHI: playerfunc freq = %.2fHz\n", f);
+       dsahip->evttime = t;
+       if (t < 10)
+               return;
+       event2_newevent2 (t, dsahip - &dsahi[0], evtfunc);
+}
+
+static void alClear (void)
+{
+       alGetError ();
+}
+static int alError (const TCHAR *format,...)
+{
+       TCHAR buffer[1000];
+       va_list parms;
+       int err;
 
-               err = alGetError ();
-               if (err == AL_NO_ERROR)
-                       return 0;
-               va_start (parms, format);
-               _vsntprintf (buffer, sizeof buffer -1, format, parms);
-               _stprintf (buffer + _tcslen (buffer), L": ERR=%x\n", err);
-               write_log (L"%s", buffer);
-               return err;
-       }
+       err = alGetError ();
+       if (err == AL_NO_ERROR)
+               return 0;
+       va_start (parms, format);
+       _vsntprintf (buffer, sizeof buffer -1, format, parms);
+       _stprintf (buffer + _tcslen (buffer), L": ERR=%x\n", err);
+       write_log (L"%s", buffer);
+       return err;
+}
+
+static void ds_freechannel (struct DSAHI *ahidsp, struct dschannel *dc)
+{
+       if (!dc)
+               return;
+       alDeleteSources (1, &dc->al_source);
+       memset (dc, 0, sizeof (struct dschannel));
+       dc->al_source = -1;
+}
+
+static void ds_freesample (struct DSAHI *ahidsp, struct dssample *ds)
+{
+       if (!ds)
+               return;
+       alDeleteBuffers (2, ds->al_buffer);
+       memset (ds, 0, sizeof (struct dssample));
+       ds->al_buffer[0] = -1;
+       ds->al_buffer[1] = -1;
+}
+
+static void ds_free (struct DSAHI *dsahip)
+{
+       int i;
 
-       static void ds_freechannel (struct DSAHI *ahidsp, struct dschannel *dc)
-       {
-               if (!dc)
-                       return;
-               alDeleteSources (1, &dc->al_source);
-               memset (dc, 0, sizeof (struct dschannel));
-               dc->al_source = -1;
+       if (!ahi_active)
+               return;
+       for (i = 0; i < dsahip->channels; i++) {
+               struct dschannel *dc = &dsahip->channel[i];
+               ds_freechannel (dsahip, dc);
        }
-
-       static void ds_freesample (struct DSAHI *ahidsp, struct dssample *ds)
-       {
-               if (!ds)
-                       return;
-               alDeleteBuffers (2, ds->al_buffer);
-               memset (ds, 0, sizeof (struct dssample));
-               ds->al_buffer[0] = -1;
-               ds->al_buffer[1] = -1;
+       for (i = 0; i < dsahip->sounds; i++) {
+               struct dssample *ds = &dsahip->sample[i];
+               ds_freesample (dsahip, ds);
        }
+       alcMakeContextCurrent (NULL);
+       alcDestroyContext (dsahip->al_ctx);
+       dsahip->al_ctx = 0;
+       alcCloseDevice (dsahip->al_dev);
+       dsahip->al_dev = 0;
+       if (ahi_debug && ahi_active)
+               write_log (L"AHI: OpenAL freed\n");
+       ahi_active = 0;
+}
+
+static void ds_free_record (struct DSAHI *dsahip)
+{
+       if (dsahip->al_recorddev)
+               alcCaptureCloseDevice (dsahip->al_recorddev);
+       dsahip->al_recorddev = NULL;
+}
 
-       static void ds_free (struct DSAHI *dsahip)
-       {
-               int i;
+static int ds_init_record (struct DSAHI *dsahip)
+{
+       uae_u32 pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
+       int freq = get_long (dsahip->audioctrl + ahiac_MixFreq);
+       struct sound_device *sd;
+       int device;
+       char *s;
 
-               if (!ahi_active)
-                       return;
-               for (i = 0; i < dsahip->channels; i++) {
-                       struct dschannel *dc = &dsahip->channel[i];
-                       ds_freechannel (dsahip, dc);
-               }
-               for (i = 0; i < dsahip->sounds; i++) {
-                       struct dssample *ds = &dsahip->sample[i];
-                       ds_freesample (dsahip, ds);
+       if (!freq)
+               return 0;
+       device = dsahip->input;
+       sd = record_devices;
+       for (;;) {
+               if (sd->type == SOUND_DEVICE_AL) {
+                       if (device <= 0)
+                               break;
+                       device--;
                }
-               alcMakeContextCurrent (NULL);
-               alcDestroyContext (dsahip->al_ctx);
-               dsahip->al_ctx = 0;
-               alcCloseDevice (dsahip->al_dev);
-               dsahip->al_dev = 0;
-               if (ahi_debug && ahi_active)
-                       write_log (L"AHI: OpenAL freed\n");
-               ahi_active = 0;
-       }
-
-       static void ds_free_record (struct DSAHI *dsahip)
-       {
-               if (dsahip->al_recorddev)
-                       alcCaptureCloseDevice (dsahip->al_recorddev);
-               dsahip->al_recorddev = NULL;
+               sd++;
+               if (sd->name == NULL)
+                       return 0;
        }
+       dsahip->record_samples = UAE_RECORDSAMPLES;
+       dsahip->record_ch = 2;
+       dsahip->record_bytespersample = 2;
+       alClear ();
+       s = ua (sd->alname);
+       dsahip->al_recorddev = alcCaptureOpenDevice (s, freq, AL_FORMAT_STEREO16, dsahip->record_samples);
+       xfree (s);
+       if (dsahip->al_recorddev == NULL)
+               goto error;
+       return 1;
+error:
+       if (ahi_debug)
+               write_log (L"AHI: OPENAL recording initialization failed\n");
+       return 0;
+}
 
-       static int ds_init_record (struct DSAHI *dsahip)
-       {
-               uae_u32 pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
-               int freq = get_long (dsahip->audioctrl + ahiac_MixFreq);
-               struct sound_device *sd;
-               int device;
-               char *s;
-
-               if (!freq)
-                       return 0;
-               device = dsahip->input;
-               sd = record_devices;
-               for (;;) {
-                       if (sd->type == SOUND_DEVICE_AL) {
-                               if (device <= 0)
-                                       break;
-                               device--;
-                       }
-                       sd++;
-                       if (sd->name == NULL)
-                               return 0;
+static int ds_init (struct DSAHI *dsahip)
+{
+       int freq = 44100;
+       int v;
+       struct sound_device *sd;
+       int device;
+       char *s;
+
+       device = dsahip->output;
+       sd = sound_devices;
+       for (;;) {
+               if (sd->type == SOUND_DEVICE_AL) {
+                       if (device <= 0)
+                               break;
+                       device--;
                }
-               dsahip->record_samples = UAE_RECORDSAMPLES;
-               dsahip->record_ch = 2;
-               dsahip->record_bytespersample = 2;
-               alClear ();
-               s = ua (sd->alname);
-               dsahip->al_recorddev = alcCaptureOpenDevice (s, freq, AL_FORMAT_STEREO16, dsahip->record_samples);
-               xfree (s);
-               if (dsahip->al_recorddev == NULL)
-                       goto error;
-               return 1;
-error:
-               if (ahi_debug)
-                       write_log (L"AHI: OPENAL recording initialization failed\n");
-               return 0;
+               sd++;
+               if (sd->name == NULL)
+                       return 0;
        }
-
-       static int ds_init (struct DSAHI *dsahip)
-       {
-               int freq = 44100;
-               int v;
-               struct sound_device *sd;
-               int device;
-               char *s;
-
-               device = dsahip->output;
-               sd = sound_devices;
-               for (;;) {
-                       if (sd->type == SOUND_DEVICE_AL) {
-                               if (device <= 0)
-                                       break;
-                               device--;
-                       }
-                       sd++;
-                       if (sd->name == NULL)
-                               return 0;
+       s = ua (sd->alname);
+       dsahip->al_dev = alcOpenDevice (s);
+       xfree (s);
+       if (!dsahip->al_dev)
+               goto error;
+       dsahip->al_ctx = alcCreateContext (dsahip->al_dev, NULL);
+       if (!dsahip->al_ctx)
+               goto error;
+       alcMakeContextCurrent (dsahip->al_ctx);
+
+       dsahip->chout = 2;
+       dsahip->al_bufferformat = AL_FORMAT_STEREO16;
+       cansurround = 0;
+       if ((dsahip->audioid & 0xff) == 2) {
+               if (v = alGetEnumValue ("AL_FORMAT_QUAD16")) {
+                       dsahip->chout = 4;
+                       cansurround = 1;
+                       dsahip->al_bufferformat = v;
                }
-               s = ua (sd->alname);
-               dsahip->al_dev = alcOpenDevice (s);
-               xfree (s);
-               if (!dsahip->al_dev)
-                       goto error;
-               dsahip->al_ctx = alcCreateContext (dsahip->al_dev, NULL);
-               if (!dsahip->al_ctx)
-                       goto error;
-               alcMakeContextCurrent (dsahip->al_ctx);
-
-               dsahip->chout = 2;
-               dsahip->al_bufferformat = AL_FORMAT_STEREO16;
-               cansurround = 0;
-               if ((dsahip->audioid & 0xff) == 2) {
-                       if (v = alGetEnumValue ("AL_FORMAT_QUAD16")) {
-                               dsahip->chout = 4;
-                               cansurround = 1;
-                               dsahip->al_bufferformat = v;
-                       }
-                       if (v = alGetEnumValue ("AL_FORMAT_51CHN16")) {
-                               dsahip->chout = 6;
-                               cansurround = 1;
-                               dsahip->al_bufferformat = v;
-                       }
+               if (v = alGetEnumValue ("AL_FORMAT_51CHN16")) {
+                       dsahip->chout = 6;
+                       cansurround = 1;
+                       dsahip->al_bufferformat = v;
                }
-               dsahip->bitspersampleout = dsahip->bits24 ? 24 : 16;
-               dsahip->bytespersampleout = dsahip->bitspersampleout / 8;
-               dsahip->channellength = 65536 * dsahip->chout * dsahip->bytespersampleout;
-               if (ahi_debug)
-                       write_log (L"AHI: CH=%d BLEN=%d\n",
-                       dsahip->chout, dsahip->channellength);
-
-               dsahip->tmpbuffer_size = 1000000;
-               dsahip->tmpbuffer = xmalloc (uae_u8, dsahip->tmpbuffer_size);
-               if (ahi_debug)
-                       write_log (L"AHI: OpenAL initialized: %s\n", sound_devices[dsahip->output].name);
-
-               return 1;
-error:
-               if (ahi_debug)
-                       write_log (L"AHI: OpenAL initialization failed\n");
-               ds_free (dsahip);
-               return 0;
        }
+       dsahip->bitspersampleout = dsahip->bits24 ? 24 : 16;
+       dsahip->bytespersampleout = dsahip->bitspersampleout / 8;
+       dsahip->channellength = 65536 * dsahip->chout * dsahip->bytespersampleout;
+       if (ahi_debug)
+               write_log (L"AHI: CH=%d BLEN=%d\n",
+               dsahip->chout, dsahip->channellength);
+
+       dsahip->tmpbuffer_size = 1000000;
+       dsahip->tmpbuffer = xmalloc (uae_u8, dsahip->tmpbuffer_size);
+       if (ahi_debug)
+               write_log (L"AHI: OpenAL initialized: %s\n", sound_devices[dsahip->output].name);
+
+       return 1;
+error:
+       if (ahi_debug)
+               write_log (L"AHI: OpenAL initialization failed\n");
+       ds_free (dsahip);
+       return 0;
+}
 
-       static int ds_reinit (struct DSAHI *dsahip)
-       {
-               ds_free (dsahip);
-               return ds_init (dsahip);
-       }
+static int ds_reinit (struct DSAHI *dsahip)
+{
+       ds_free (dsahip);
+       return ds_init (dsahip);
+}
 
-       static void ds_setvolume (struct DSAHI *dsahip, struct dschannel *dc)
-       {
-               if (dc->al_source != -1) {
-                       if (abs (dc->cs.volume) != abs (dc->csnext.volume)) {
-                               float vol = ((float)(abs (dc->csnext.volume))) / 65536.0;
-                               alClear ();
-                               alSourcef (dc->al_source, AL_GAIN, vol);
-                               alError (L"AHI: SetVolume(%d,%d)", dc->num, vol);
-                       }
-                       if (abs (dc->cs.panning) != abs (dc->csnext.panning)) {
-                               ;//         pan = (abs (dc->csnext.panning) - 0x8000) * DSBPAN_RIGHT / 32768;
-                       }
+static void ds_setvolume (struct DSAHI *dsahip, struct dschannel *dc)
+{
+       if (dc->al_source != -1) {
+               if (abs (dc->cs.volume) != abs (dc->csnext.volume)) {
+                       float vol = ((float)(abs (dc->csnext.volume))) / 65536.0;
+                       alClear ();
+                       alSourcef (dc->al_source, AL_GAIN, vol);
+                       alError (L"AHI: SetVolume(%d,%d)", dc->num, vol);
+               }
+               if (abs (dc->cs.panning) != abs (dc->csnext.panning)) {
+                       ;//         pan = (abs (dc->csnext.panning) - 0x8000) * DSBPAN_RIGHT / 32768;
                }
-               dc->cs.volume = dc->csnext.volume;
-               dc->cs.panning = dc->csnext.panning;
        }
+       dc->cs.volume = dc->csnext.volume;
+       dc->cs.panning = dc->csnext.panning;
+}
 
-       static void ds_setfreq (struct DSAHI *dsahip, struct dschannel *dc)
-       {
-               if (dc->dsplaying && dc->cs.frequency != dc->csnext.frequency && dc->csnext.frequency > 0 && dc->al_source != -1) {
-                       //alClear ();
-                       //alSourcei (dc->al_source, AL_FREQUENCY, dc->csnext.frequency);
-                       //alError (L"AHI: SetFrequency(%d,%d)", dc->num, dc->csnext.frequency);
-               }
-               dc->cs.frequency = dc->csnext.frequency;
+static void ds_setfreq (struct DSAHI *dsahip, struct dschannel *dc)
+{
+       if (dc->dsplaying && dc->cs.frequency != dc->csnext.frequency && dc->csnext.frequency > 0 && dc->al_source != -1) {
+               //alClear ();
+               //alSourcei (dc->al_source, AL_FREQUENCY, dc->csnext.frequency);
+               //alError (L"AHI: SetFrequency(%d,%d)", dc->num, dc->csnext.frequency);
        }
+       dc->cs.frequency = dc->csnext.frequency;
+}
 
-       static int ds_allocchannel (struct DSAHI *dsahip, struct dschannel *dc)
-       {
-               if (dc->al_source != -1)
-                       return 1;
-               alClear ();
-               alGenSources (1, &dc->al_source);
-               if (alError (L"alGenSources()"))
-                       goto error;
-               dc->cs.frequency = -1;
-               dc->cs.volume = -1;
-               dc->cs.panning = -1;
-               ds_setvolume (dsahip, dc);
-               ds_setfreq (dsahip, dc);
-               if (ahi_debug)
-                       write_log (L"AHI: allocated OpenAL source for channel %d. vol=%d pan=%d freq=%d\n",
-                       dc->num, dc->cs.volume, dc->cs.panning, dc->cs.frequency);
+static int ds_allocchannel (struct DSAHI *dsahip, struct dschannel *dc)
+{
+       if (dc->al_source != -1)
                return 1;
+       alClear ();
+       alGenSources (1, &dc->al_source);
+       if (alError (L"alGenSources()"))
+               goto error;
+       dc->cs.frequency = -1;
+       dc->cs.volume = -1;
+       dc->cs.panning = -1;
+       ds_setvolume (dsahip, dc);
+       ds_setfreq (dsahip, dc);
+       if (ahi_debug)
+               write_log (L"AHI: allocated OpenAL source for channel %d. vol=%d pan=%d freq=%d\n",
+               dc->num, dc->cs.volume, dc->cs.panning, dc->cs.frequency);
+       return 1;
 error:
-               ds_freechannel (dsahip, dc);
-               return 0;
-       }
+       ds_freechannel (dsahip, dc);
+       return 0;
+}
 
 #define MAKEXCH makexch (dsahip, dc, dst, i, och2, l, r)
 
-       STATIC_INLINE void makexch (struct DSAHI *dsahip, struct dschannel *dc, uae_u8 *dst, int idx, int och2, uae_s32 l, uae_s32 r)
-       {
-               if (dsahip->bits24) {
-               } else {
-                       uae_s16 *dst2 = (uae_s16*)(&dst[idx * och2]);
-                       l >>= 8;
-                       r >>= 8;
-                       if (dc->cs.volume < 0) {
-                               l = -l;
-                               r = -r;
-                       }
-                       dst2[0] = l;
-                       dst2[1] = r;
-                       if (dsahip->chout <= 2)
-                               return;
-                       dst2[4] = dst2[0];
-                       dst2[5] = dst2[1];
-                       if (dc->cs.panning < 0) {
-                               // surround only
-                               dst2[2] = 0; // center
-                               dst2[3] = (dst2[0] + dst2[1]) / 4; // lfe
-                               dst2[0] = dst2[1] = 0;
-                               return;
-                       }
-                       dst2[2] = dst2[3] = (dst2[0] + dst2[1]) / 4;
-                       if (dsahip->chout <= 6)
-                               return;
-                       dst2[6] = dst2[4];
-                       dst2[7] = dst2[5];
+STATIC_INLINE void makexch (struct DSAHI *dsahip, struct dschannel *dc, uae_u8 *dst, int idx, int och2, uae_s32 l, uae_s32 r)
+{
+       if (dsahip->bits24) {
+       } else {
+               uae_s16 *dst2 = (uae_s16*)(&dst[idx * och2]);
+               l >>= 8;
+               r >>= 8;
+               if (dc->cs.volume < 0) {
+                       l = -l;
+                       r = -r;
                }
+               dst2[0] = l;
+               dst2[1] = r;
+               if (dsahip->chout <= 2)
+                       return;
+               dst2[4] = dst2[0];
+               dst2[5] = dst2[1];
+               if (dc->cs.panning < 0) {
+                       // surround only
+                       dst2[2] = 0; // center
+                       dst2[3] = (dst2[0] + dst2[1]) / 4; // lfe
+                       dst2[0] = dst2[1] = 0;
+                       return;
+               }
+               dst2[2] = dst2[3] = (dst2[0] + dst2[1]) / 4;
+               if (dsahip->chout <= 6)
+                       return;
+               dst2[6] = dst2[4];
+               dst2[7] = dst2[5];
        }
+}
 
-       /* sample conversion routines */
-       static int copysampledata (struct DSAHI *dsahip, struct dschannel *dc, struct dssample *ds, uae_u8 **psrcp, uae_u8 *srce, uae_u8 *srcp, void *dstp, int dstlen)
+/* sample conversion routines */
+static int copysampledata (struct DSAHI *dsahip, struct dschannel *dc, struct dssample *ds, uae_u8 **psrcp, uae_u8 *srce, uae_u8 *srcp, void *dstp, int dstlen)
+{
+       int i;
+       uae_u8 *src = *psrcp;
+       uae_u8 *dst = (uae_u8*)dstp;
+       int och = dsahip->chout;
+       int och2 = och * 2;
+       int ich = ds->ch;
+       int len;
+
+       len = dstlen;
+       switch (ds->sampletype)
        {
-               int i;
-               uae_u8 *src = *psrcp;
-               uae_u8 *dst = (uae_u8*)dstp;
-               int och = dsahip->chout;
-               int och2 = och * 2;
-               int ich = ds->ch;
-               int len;
-
-               len = dstlen;
-               switch (ds->sampletype)
-               {
-               case AHIST_M8S:
-                       for (i = 0; i < len; i++) {
-                               uae_u32 l = (src[0] << 16) | (src[0] << 8) | src[0] ;
-                               uae_u32 r = (src[0] << 16) | (src[0] << 8) | src[0];
-                               src += 1;
-                               if (src >= srce)
-                                       src = srcp;
-                               MAKEXCH;
-                       }
-                       break;
-               case AHIST_S8S:
-                       for (i = 0; i < len; i++) {
-                               uae_u32 l = (src[0] << 16) | (src[0] << 8) | src[0] ;
-                               uae_u32 r = (src[1] << 16) | (src[1] << 8) | src[1];
-                               src += 2;
-                               if (src >= srce)
-                                       src = srcp;
-                               MAKEXCH;
-                       }
-                       break;
-               case AHIST_M16S:
-                       for (i = 0; i < len; i++) {
-                               uae_u32 l = (src[0] << 16) | (src[1] << 8) | src[1];
-                               uae_u32 r = (src[0] << 16) | (src[1] << 8) | src[1];
-                               src += 2;
-                               if (src >= srce)
-                                       src = srcp;
-                               MAKEXCH;
-                       }
-                       break;
-               case AHIST_S16S:
-                       for (i = 0; i < len; i++) {
-                               uae_u32 l = (src[0] << 16) | (src[1] << 8) | src[1];
-                               uae_u32 r = (src[2] << 16) | (src[3] << 8) | src[3];
-                               src += 4;
-                               if (src >= srce)
-                                       src = srcp;
-                               MAKEXCH;
-                       }
-                       break;
-               case AHIST_M32S:
+       case AHIST_M8S:
+               for (i = 0; i < len; i++) {
+                       uae_u32 l = (src[0] << 16) | (src[0] << 8) | src[0] ;
+                       uae_u32 r = (src[0] << 16) | (src[0] << 8) | src[0];
+                       src += 1;
+                       if (src >= srce)
+                               src = srcp;
+                       MAKEXCH;
+               }
+               break;
+       case AHIST_S8S:
+               for (i = 0; i < len; i++) {
+                       uae_u32 l = (src[0] << 16) | (src[0] << 8) | src[0] ;
+                       uae_u32 r = (src[1] << 16) | (src[1] << 8) | src[1];
+                       src += 2;
+                       if (src >= srce)
+                               src = srcp;
+                       MAKEXCH;
+               }
+               break;
+       case AHIST_M16S:
+               for (i = 0; i < len; i++) {
+                       uae_u32 l = (src[0] << 16) | (src[1] << 8) | src[1];
+                       uae_u32 r = (src[0] << 16) | (src[1] << 8) | src[1];
+                       src += 2;
+                       if (src >= srce)
+                               src = srcp;
+                       MAKEXCH;
+               }
+               break;
+       case AHIST_S16S:
+               for (i = 0; i < len; i++) {
+                       uae_u32 l = (src[0] << 16) | (src[1] << 8) | src[1];
+                       uae_u32 r = (src[2] << 16) | (src[3] << 8) | src[3];
+                       src += 4;
+                       if (src >= srce)
+                               src = srcp;
+                       MAKEXCH;
+               }
+               break;
+       case AHIST_M32S:
+               for (i = 0; i < len; i++) {
+                       uae_u32 l = (src[3] << 16) | (src[2] << 8) | src[1];
+                       uae_u32 r = (src[3] << 16) | (src[2] << 8) | src[1];
+                       src += 4;
+                       if (src >= srce)
+                               src = srcp;
+                       MAKEXCH;
+               }
+               break;
+       case AHIST_S32S:
+               for (i = 0; i < len; i++) {
+                       uae_u32 l = (src[3] << 16) | (src[2] << 8) | src[1];
+                       uae_u32 r = (src[7] << 16) | (src[6] << 8) | src[5];
+                       src += 8;
+                       if (src >= srce)
+                               src = srcp;
+                       MAKEXCH;
+               }
+               break;
+       case AHIST_L7_1:
+               if (och == 8) {
                        for (i = 0; i < len; i++) {
-                               uae_u32 l = (src[3] << 16) | (src[2] << 8) | src[1];
-                               uae_u32 r = (src[3] << 16) | (src[2] << 8) | src[1];
-                               src += 4;
+                               if (dsahip->bits24) {
+                                       uae_u32 fl = (src[0 * 4 + 3] << 16) | (src[0 * 4 + 2] << 8) | src[0 * 4 + 1];
+                                       uae_u32 fr = (src[1 * 4 + 3] << 16) | (src[1 * 4 + 2] << 8) | src[1 * 4 + 1];
+                                       uae_u32 cc = (src[6 * 4 + 3] << 16) | (src[6 * 4 + 2] << 8) | src[6 * 4 + 1];
+                                       uae_u32 lf = (src[7 * 4 + 3] << 16) | (src[7 * 4 + 2] << 8) | src[7 * 4 + 1];
+                                       uae_u32 bl = (src[2 * 4 + 3] << 16) | (src[2 * 4 + 2] << 8) | src[2 * 4 + 1];
+                                       uae_u32 br = (src[3 * 4 + 3] << 16) | (src[3 * 4 + 2] << 8) | src[3 * 4 + 1];
+                                       uae_u32 sl = (src[4 * 4 + 3] << 16) | (src[4 * 4 + 2] << 8) | src[4 * 4 + 1];
+                                       uae_u32 sr = (src[5 * 4 + 3] << 16) | (src[5 * 4 + 2] << 8) | src[5 * 4 + 1];
+                                       uae_s32 *dst2 = (uae_s32*)(&dst[i * och2]);
+                                       dst2[0] = fl;
+                                       dst2[1] = fr;
+                                       dst2[2] = cc;
+                                       dst2[3] = lf;
+                                       dst2[4] = bl;
+                                       dst2[5] = br;
+                                       dst2[6] = sl;
+                                       dst2[7] = sr;
+                               } else {
+                                       uae_u16 fl = (src[0 * 4 + 3] << 8) | src[0 * 4 + 2];
+                                       uae_u16 fr = (src[1 * 4 + 3] << 8) | src[1 * 4 + 2];
+                                       uae_u16 cc = (src[6 * 4 + 3] << 8) | src[6 * 4 + 2];
+                                       uae_u16 lf = (src[7 * 4 + 3] << 8) | src[7 * 4 + 2];
+                                       uae_u16 bl = (src[2 * 4 + 3] << 8) | src[2 * 4 + 2];
+                                       uae_u16 br = (src[3 * 4 + 3] << 8) | src[3 * 4 + 2];
+                                       uae_u16 sl = (src[4 * 4 + 3] << 8) | src[4 * 4 + 2];
+                                       uae_u16 sr = (src[5 * 4 + 3] << 8) | src[5 * 4 + 2];
+                                       uae_s16 *dst2 = (uae_s16*)(&dst[i * och2]);
+                                       dst2[0] = fl;
+                                       dst2[1] = fr;
+                                       dst2[2] = cc;
+                                       dst2[3] = lf;
+                                       dst2[4] = bl;
+                                       dst2[5] = br;
+                                       dst2[6] = sl;
+                                       dst2[7] = sr;
+                               }
+                               dst += och2;
+                               src += 8 * 4;
                                if (src >= srce)
                                        src = srcp;
-                               MAKEXCH;
                        }
-                       break;
-               case AHIST_S32S:
+               } else if (och == 6) { /* 7.1 -> 5.1 */
                        for (i = 0; i < len; i++) {
-                               uae_u32 l = (src[3] << 16) | (src[2] << 8) | src[1];
-                               uae_u32 r = (src[7] << 16) | (src[6] << 8) | src[5];
-                               src += 8;
+                               if (dsahip->bits24) {
+                                       uae_s32 *dst2 = (uae_s32*)(&dst[i * och2]);
+                                       uae_u32 fl = (src[0 * 4 + 3] << 16) | (src[0 * 4 + 2] << 8) | src[0 * 4 + 1];
+                                       uae_u32 fr = (src[1 * 4 + 3] << 16) | (src[1 * 4 + 2] << 8) | src[1 * 4 + 1];
+                                       uae_u32 cc = (src[6 * 4 + 3] << 16) | (src[6 * 4 + 2] << 8) | src[6 * 4 + 1];
+                                       uae_u32 lf = (src[7 * 4 + 3] << 16) | (src[7 * 4 + 2] << 8) | src[7 * 4 + 1];
+                                       uae_u32 bl = (src[2 * 4 + 3] << 16) | (src[2 * 4 + 2] << 8) | src[2 * 4 + 1];
+                                       uae_u32 br = (src[3 * 4 + 3] << 16) | (src[3 * 4 + 2] << 8) | src[3 * 4 + 1];
+                                       uae_u32 sl = (src[4 * 4 + 3] << 16) | (src[4 * 4 + 2] << 8) | src[4 * 4 + 1];
+                                       uae_u32 sr = (src[5 * 4 + 3] << 16) | (src[5 * 4 + 2] << 8) | src[5 * 4 + 1];
+                               } else {
+                                       uae_s16 *dst2 = (uae_s16*)(&dst[i * och2]);
+                                       uae_u16 fl = (src[0 * 4 + 3] << 8) | src[0 * 4 + 2];
+                                       uae_u16 fr = (src[1 * 4 + 3] << 8) | src[1 * 4 + 2];
+                                       uae_u16 cc = (src[6 * 4 + 3] << 8) | src[6 * 4 + 2];
+                                       uae_u16 lf = (src[7 * 4 + 3] << 8) | src[7 * 4 + 2];
+                                       uae_u16 bl = (src[2 * 4 + 3] << 8) | src[2 * 4 + 2];
+                                       uae_u16 br = (src[3 * 4 + 3] << 8) | src[3 * 4 + 2];
+                                       uae_u16 sl = (src[4 * 4 + 3] << 8) | src[4 * 4 + 2];
+                                       uae_u16 sr = (src[5 * 4 + 3] << 8) | src[5 * 4 + 2];
+                                       dst2[0] = fl;
+                                       dst2[1] = fr;
+                                       dst2[2] = cc;
+                                       dst2[3] = lf;
+                                       dst2[4] = (bl + sl) / 2;
+                                       dst2[5] = (br + sr) / 2;
+                               }
+                               dst += och2;
+                               src += 8 * 4;
                                if (src >= srce)
                                        src = srcp;
-                               MAKEXCH;
-                       }
-                       break;
-               case AHIST_L7_1:
-                       if (och == 8) {
-                               for (i = 0; i < len; i++) {
-                                       if (dsahip->bits24) {
-                                               uae_u32 fl = (src[0 * 4 + 3] << 16) | (src[0 * 4 + 2] << 8) | src[0 * 4 + 1];
-                                               uae_u32 fr = (src[1 * 4 + 3] << 16) | (src[1 * 4 + 2] << 8) | src[1 * 4 + 1];
-                                               uae_u32 cc = (src[6 * 4 + 3] << 16) | (src[6 * 4 + 2] << 8) | src[6 * 4 + 1];
-                                               uae_u32 lf = (src[7 * 4 + 3] << 16) | (src[7 * 4 + 2] << 8) | src[7 * 4 + 1];
-                                               uae_u32 bl = (src[2 * 4 + 3] << 16) | (src[2 * 4 + 2] << 8) | src[2 * 4 + 1];
-                                               uae_u32 br = (src[3 * 4 + 3] << 16) | (src[3 * 4 + 2] << 8) | src[3 * 4 + 1];
-                                               uae_u32 sl = (src[4 * 4 + 3] << 16) | (src[4 * 4 + 2] << 8) | src[4 * 4 + 1];
-                                               uae_u32 sr = (src[5 * 4 + 3] << 16) | (src[5 * 4 + 2] << 8) | src[5 * 4 + 1];
-                                               uae_s32 *dst2 = (uae_s32*)(&dst[i * och2]);
-                                               dst2[0] = fl;
-                                               dst2[1] = fr;
-                                               dst2[2] = cc;
-                                               dst2[3] = lf;
-                                               dst2[4] = bl;
-                                               dst2[5] = br;
-                                               dst2[6] = sl;
-                                               dst2[7] = sr;
-                                       } else {
-                                               uae_u16 fl = (src[0 * 4 + 3] << 8) | src[0 * 4 + 2];
-                                               uae_u16 fr = (src[1 * 4 + 3] << 8) | src[1 * 4 + 2];
-                                               uae_u16 cc = (src[6 * 4 + 3] << 8) | src[6 * 4 + 2];
-                                               uae_u16 lf = (src[7 * 4 + 3] << 8) | src[7 * 4 + 2];
-                                               uae_u16 bl = (src[2 * 4 + 3] << 8) | src[2 * 4 + 2];
-                                               uae_u16 br = (src[3 * 4 + 3] << 8) | src[3 * 4 + 2];
-                                               uae_u16 sl = (src[4 * 4 + 3] << 8) | src[4 * 4 + 2];
-                                               uae_u16 sr = (src[5 * 4 + 3] << 8) | src[5 * 4 + 2];
-                                               uae_s16 *dst2 = (uae_s16*)(&dst[i * och2]);
-                                               dst2[0] = fl;
-                                               dst2[1] = fr;
-                                               dst2[2] = cc;
-                                               dst2[3] = lf;
-                                               dst2[4] = bl;
-                                               dst2[5] = br;
-                                               dst2[6] = sl;
-                                               dst2[7] = sr;
-                                       }
-                                       dst += och2;
-                                       src += 8 * 4;
-                                       if (src >= srce)
-                                               src = srcp;
-                               }
-                       } else if (och == 6) { /* 7.1 -> 5.1 */
-                               for (i = 0; i < len; i++) {
-                                       if (dsahip->bits24) {
-                                               uae_s32 *dst2 = (uae_s32*)(&dst[i * och2]);
-                                               uae_u32 fl = (src[0 * 4 + 3] << 16) | (src[0 * 4 + 2] << 8) | src[0 * 4 + 1];
-                                               uae_u32 fr = (src[1 * 4 + 3] << 16) | (src[1 * 4 + 2] << 8) | src[1 * 4 + 1];
-                                               uae_u32 cc = (src[6 * 4 + 3] << 16) | (src[6 * 4 + 2] << 8) | src[6 * 4 + 1];
-                                               uae_u32 lf = (src[7 * 4 + 3] << 16) | (src[7 * 4 + 2] << 8) | src[7 * 4 + 1];
-                                               uae_u32 bl = (src[2 * 4 + 3] << 16) | (src[2 * 4 + 2] << 8) | src[2 * 4 + 1];
-                                               uae_u32 br = (src[3 * 4 + 3] << 16) | (src[3 * 4 + 2] << 8) | src[3 * 4 + 1];
-                                               uae_u32 sl = (src[4 * 4 + 3] << 16) | (src[4 * 4 + 2] << 8) | src[4 * 4 + 1];
-                                               uae_u32 sr = (src[5 * 4 + 3] << 16) | (src[5 * 4 + 2] << 8) | src[5 * 4 + 1];
-                                       } else {
-                                               uae_s16 *dst2 = (uae_s16*)(&dst[i * och2]);
-                                               uae_u16 fl = (src[0 * 4 + 3] << 8) | src[0 * 4 + 2];
-                                               uae_u16 fr = (src[1 * 4 + 3] << 8) | src[1 * 4 + 2];
-                                               uae_u16 cc = (src[6 * 4 + 3] << 8) | src[6 * 4 + 2];
-                                               uae_u16 lf = (src[7 * 4 + 3] << 8) | src[7 * 4 + 2];
-                                               uae_u16 bl = (src[2 * 4 + 3] << 8) | src[2 * 4 + 2];
-                                               uae_u16 br = (src[3 * 4 + 3] << 8) | src[3 * 4 + 2];
-                                               uae_u16 sl = (src[4 * 4 + 3] << 8) | src[4 * 4 + 2];
-                                               uae_u16 sr = (src[5 * 4 + 3] << 8) | src[5 * 4 + 2];
-                                               dst2[0] = fl;
-                                               dst2[1] = fr;
-                                               dst2[2] = cc;
-                                               dst2[3] = lf;
-                                               dst2[4] = (bl + sl) / 2;
-                                               dst2[5] = (br + sr) / 2;
-                                       }
-                                       dst += och2;
-                                       src += 8 * 4;
-                                       if (src >= srce)
-                                               src = srcp;
-                               }
                        }
-                       break;
                }
-               *psrcp = src;
-               return dstlen * och2;
+               break;
        }
+       *psrcp = src;
+       return dstlen * och2;
+}
 
-       static void dorecord (struct DSAHI *dsahip)
-       {
-               uae_u32 pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
-               uae_u32 recordbuf;
-               int bytes;
-
-               if (dsahip->al_recorddev == NULL)
-                       return;
-               if (dsahip->record_wait && !get_word (pbase + pub_RecordHookDone))
-                       return;
-               dsahip->record_wait = 0;
-               bytes = dsahip->record_samples * dsahip->record_ch * dsahip->record_bytespersample;
-               recordbuf = get_long (pbase + pub_RecordBuffer);
-               if (recordbuf == 0 || !valid_address (recordbuf, bytes))
-                       return;
-               alClear ();
-               alcCaptureSamples (dsahip->al_recorddev, (void*)recordbuf, dsahip->record_samples);
-               if (alGetError () != AL_NO_ERROR)
-                       return;
-               put_word (pbase + pub_RecordHookDone, 0);
-               dsahip->record_wait = 1;
-               put_word (pbase + pub_FuncMode, get_word (pbase + pub_FuncMode) | FUNCMODE_RECORD);
-               sendsignal (dsahip);
-       }
+static void dorecord (struct DSAHI *dsahip)
+{
+       uae_u32 pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
+       uae_u32 recordbuf;
+       int bytes;
+
+       if (dsahip->al_recorddev == NULL)
+               return;
+       if (dsahip->record_wait && !get_word (pbase + pub_RecordHookDone))
+               return;
+       dsahip->record_wait = 0;
+       bytes = dsahip->record_samples * dsahip->record_ch * dsahip->record_bytespersample;
+       recordbuf = get_long (pbase + pub_RecordBuffer);
+       if (recordbuf == 0 || !valid_address (recordbuf, bytes))
+               return;
+       alClear ();
+       alcCaptureSamples (dsahip->al_recorddev, (void*)recordbuf, dsahip->record_samples);
+       if (alGetError () != AL_NO_ERROR)
+               return;
+       put_word (pbase + pub_RecordHookDone, 0);
+       dsahip->record_wait = 1;
+       put_word (pbase + pub_FuncMode, get_word (pbase + pub_FuncMode) | FUNCMODE_RECORD);
+       sendsignal (dsahip);
+}
+
+
+static void al_setloop (struct dschannel *dc, int state)
+{
+       alClear ();
+       alSourcei (dc->al_source, AL_LOOPING, state ? AL_TRUE : AL_FALSE);
+       alError (L"AHI: ds_play() alSourcei(AL_LOOPING)");
+}
 
+static void al_startplay (struct dschannel *dc)
+{
+       alClear ();
+       alSourcePlay (dc->al_source);
+       alError (L"AHI: ds_play() alSourcePlay");
+}
 
-       static void al_setloop (struct dschannel *dc, int state)
-       {
-               alClear ();
-               alSourcei (dc->al_source, AL_LOOPING, state ? AL_TRUE : AL_FALSE);
-               alError (L"AHI: ds_play() alSourcei(AL_LOOPING)");
-       }
+static void preparesample_single (struct DSAHI *dsahip, struct dschannel *dc)
+{
+       uae_u8 *p, *ps, *pe;
+       struct dssample *ds;
+       int slen, dlen;
+
+       dc->samplecounter = -1;
+       dc->buffertoggle = 0;
+
+       ds = dc->cs.ds;
+       ps = p = get_real_address (ds->addr);
+       pe = ps + ds->len * ds->bytespersample * ds->ch;
+
+       slen = ds->len;
+       p += dc->cs.srcplayoffset * ds->bytespersample * ds->ch;
+       dlen = copysampledata (dsahip, dc, ds, &p, pe, ps, dsahip->tmpbuffer, slen);
+       alClear ();
+       alBufferData (ds->al_buffer[dc->buffertoggle], dsahip->al_bufferformat, dsahip->tmpbuffer, dlen, dc->cs.frequency);
+       alError (L"AHI: preparesample_single:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
+       alClear ();
+       alSourceQueueBuffers (dc->al_source, 1, &ds->al_buffer[dc->buffertoggle]);
+       alError (L"AHI: al_initsample_single:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
+       if (ahi_debug > 2)
+               write_log (L"AHI: sample queued %d: %d/%d\n",
+               dc->num, dc->samplecounter, dc->totalsamples);
+}
+
+
+static void preparesample_multi (struct DSAHI *dsahip, struct dschannel *dc)
+{
+       uae_u8 *p, *ps, *pe;
+       struct dssample *ds;
+       int slen, dlen;
+
+       ds = dc->cs.ds;
+       ps = p = get_real_address (ds->addr);
+       pe = ps + ds->len * ds->bytespersample * ds->ch;
+
+       slen = dc->maxplaysamples;
+       if (dc->samplecounter == dc->totalsamples - 1)
+               slen = ds->len - dc->maxplaysamples * (dc->totalsamples - 1);
+
+       p += (dc->maxplaysamples * dc->samplecounter + dc->cs.srcplayoffset) * ds->bytespersample * ds->ch;
+       dlen = copysampledata (dsahip, dc, ds, &p, pe, ps, dsahip->tmpbuffer, slen);
+       alClear ();
+       alBufferData (ds->al_buffer[dc->buffertoggle], dsahip->al_bufferformat, dsahip->tmpbuffer, dlen, dc->cs.frequency);
+       alError (L"AHI: preparesample:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
+       alClear ();
+       alSourceQueueBuffers (dc->al_source, 1, &ds->al_buffer[dc->buffertoggle]);
+       alError (L"AHI: al_initsample:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
+       if (ahi_debug > 2)
+               write_log (L"AHI: sample queued %d: %d/%d\n",
+               dc->num, dc->samplecounter, dc->totalsamples);
+       dc->samplecounter++;
+       dc->buffertoggle ^= 1;
+}
+
+/* called when sample is started for the first time */
+static void al_initsample (struct DSAHI *dsahip, struct dschannel *dc)
+{
+       uae_u32 audioctrl = dsahip->audioctrl;
+       struct dssample *ds;
+       int single = 0;
+
+       alSourceStop (dc->al_source);
+       alClear ();
+       alSourcei (dc->al_source, AL_BUFFER, AL_NONE);
+       alError (L"AHI: al_initsample:AL_BUFFER=AL_NONE");
+
+       memcpy (&dc->cs, &dc->csnext, sizeof (struct chsample));
+       dc->csnext.ds = NULL;
+       dc->waitforack = 0;
+       ds = dc->cs.ds;
+       if (ds == NULL)
+               return;
+
+       if (get_long (audioctrl + ahiac_SoundFunc)) {
+               dc->samplecounter = 0;
+               if (ds->dynamic) {
+                       dc->maxplaysamples = dsahip->maxplaysamples / 2;
+                       if (dc->maxplaysamples > ds->len / 2)
+                               dc->maxplaysamples = ds->len / 2;
+               } else {
+                       dc->maxplaysamples = ds->len / 2;
+               }
+               if (dc->maxplaysamples > dsahip->tmpbuffer_size)
+                       dc->maxplaysamples = dsahip->tmpbuffer_size;
 
-       static void al_startplay (struct dschannel *dc)
-       {
-               alClear ();
-               alSourcePlay (dc->al_source);
-               alError (L"AHI: ds_play() alSourcePlay");
+               dc->totalsamples = ds->len / dc->maxplaysamples;
+               if (dc->totalsamples <= 1)
+                       dc->totalsamples = 2;
+               /* queue first half */
+               preparesample_multi (dsahip, dc);
+               /* queue second half */
+               preparesample_multi (dsahip, dc);
+       } else {
+               single = 1;
+               preparesample_single (dsahip, dc);
        }
+       al_setloop (dc, single);
 
-       static void preparesample_single (struct DSAHI *dsahip, struct dschannel *dc)
-       {
-               uae_u8 *p, *ps, *pe;
-               struct dssample *ds;
-               int slen, dlen;
-
-               dc->samplecounter = -1;
-               dc->buffertoggle = 0;
-
-               ds = dc->cs.ds;
-               ps = p = get_real_address (ds->addr);
-               pe = ps + ds->len * ds->bytespersample * ds->ch;
-
-               slen = ds->len;
-               p += dc->cs.srcplayoffset * ds->bytespersample * ds->ch;
-               dlen = copysampledata (dsahip, dc, ds, &p, pe, ps, dsahip->tmpbuffer, slen);
-               alClear ();
-               alBufferData (ds->al_buffer[dc->buffertoggle], dsahip->al_bufferformat, dsahip->tmpbuffer, dlen, dc->cs.frequency);
-               alError (L"AHI: preparesample_single:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
-               alClear ();
-               alSourceQueueBuffers (dc->al_source, 1, &ds->al_buffer[dc->buffertoggle]);
-               alError (L"AHI: al_initsample_single:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
-               if (ahi_debug > 2)
-                       write_log (L"AHI: sample queued %d: %d/%d\n",
-                       dc->num, dc->samplecounter, dc->totalsamples);
+       if (dc->dsplaying) {
+               dc->dsplaying = 1;
+               al_startplay (dc);
+               setchannelevent (dsahip, dc);
        }
+}
 
+/* called when previous sample is still playing */
+static void al_queuesample (struct DSAHI *dsahip, struct dschannel *dc)
+{
+       int v, restart;
 
-       static void preparesample_multi (struct DSAHI *dsahip, struct dschannel *dc)
-       {
-               uae_u8 *p, *ps, *pe;
-               struct dssample *ds;
-               int slen, dlen;
-
-               ds = dc->cs.ds;
-               ps = p = get_real_address (ds->addr);
-               pe = ps + ds->len * ds->bytespersample * ds->ch;
-
-               slen = dc->maxplaysamples;
-               if (dc->samplecounter == dc->totalsamples - 1)
-                       slen = ds->len - dc->maxplaysamples * (dc->totalsamples - 1);
-
-               p += (dc->maxplaysamples * dc->samplecounter + dc->cs.srcplayoffset) * ds->bytespersample * ds->ch;
-               dlen = copysampledata (dsahip, dc, ds, &p, pe, ps, dsahip->tmpbuffer, slen);
-               alClear ();
-               alBufferData (ds->al_buffer[dc->buffertoggle], dsahip->al_bufferformat, dsahip->tmpbuffer, dlen, dc->cs.frequency);
-               alError (L"AHI: preparesample:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
-               alClear ();
-               alSourceQueueBuffers (dc->al_source, 1, &ds->al_buffer[dc->buffertoggle]);
-               alError (L"AHI: al_initsample:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
-               if (ahi_debug > 2)
-                       write_log (L"AHI: sample queued %d: %d/%d\n",
-                       dc->num, dc->samplecounter, dc->totalsamples);
-               dc->samplecounter++;
-               dc->buffertoggle ^= 1;
+       if (!dc->cs.ds)
+               return;
+       if (dc->cs.ds->num < 0) {
+               dc->cs.ds = NULL;
+               return;
        }
-
-       /* called when sample is started for the first time */
-       static void al_initsample (struct DSAHI *dsahip, struct dschannel *dc)
-       {
-               uae_u32 audioctrl = dsahip->audioctrl;
-               struct dssample *ds;
-               int single = 0;
-
-               alSourceStop (dc->al_source);
+       restart = 0;
+       if (dc->dsplaying) {
                alClear ();
-               alSourcei (dc->al_source, AL_BUFFER, AL_NONE);
-               alError (L"AHI: al_initsample:AL_BUFFER=AL_NONE");
-
-               memcpy (&dc->cs, &dc->csnext, sizeof (struct chsample));
-               dc->csnext.ds = NULL;
-               dc->waitforack = 0;
-               ds = dc->cs.ds;
-               if (ds == NULL)
-                       return;
-
-               if (get_long (audioctrl + ahiac_SoundFunc)) {
-                       dc->samplecounter = 0;
-                       if (ds->dynamic) {
-                               dc->maxplaysamples = dsahip->maxplaysamples / 2;
-                               if (dc->maxplaysamples > ds->len / 2)
-                                       dc->maxplaysamples = ds->len / 2;
-                       } else {
-                               dc->maxplaysamples = ds->len / 2;
-                       }
-                       if (dc->maxplaysamples > dsahip->tmpbuffer_size)
-                               dc->maxplaysamples = dsahip->tmpbuffer_size;
-
-                       dc->totalsamples = ds->len / dc->maxplaysamples;
-                       if (dc->totalsamples <= 1)
-                               dc->totalsamples = 2;
-                       /* queue first half */
-                       preparesample_multi (dsahip, dc);
-                       /* queue second half */
+               alGetSourcei (dc->al_source, AL_SOURCE_STATE, &v);
+               alError (L"AHI: queuesample AL_SOURCE_STATE");
+               if (v != AL_PLAYING) {
+                       alClear ();
+                       alSourceRewind (dc->al_source);
+                       alError (L"AHI: queuesample:restart");
+                       restart = 1;
+                       if (ahi_debug > 2)
+                               write_log (L"AHI: queuesample, play restart\n");
                        preparesample_multi (dsahip, dc);
-               } else {
-                       single = 1;
-                       preparesample_single (dsahip, dc);
-               }
-               al_setloop (dc, single);
-
-               if (dc->dsplaying) {
-                       dc->dsplaying = 1;
-                       al_startplay (dc);
-                       setchannelevent (dsahip, dc);
                }
        }
+       preparesample_multi (dsahip, dc);
+       if (dc->dsplaying)
+               dc->dsplaying = 1;
+       if (restart)
+               al_startplay (dc);
+       if (ahi_debug > 2)
+               write_log (L"AHI: sample %d queued to channel %d\n", dc->cs.ds->num, dc->num);
+}
 
-       /* called when previous sample is still playing */
-       static void al_queuesample (struct DSAHI *dsahip, struct dschannel *dc)
-       {
-               int v, restart;
-
-               if (!dc->cs.ds)
-                       return;
-               if (dc->cs.ds->num < 0) {
-                       dc->cs.ds = NULL;
-                       return;
-               }
-               restart = 0;
-               if (dc->dsplaying) {
-                       alClear ();
-                       alGetSourcei (dc->al_source, AL_SOURCE_STATE, &v);
-                       alError (L"AHI: queuesample AL_SOURCE_STATE");
-                       if (v != AL_PLAYING) {
-                               alClear ();
-                               alSourceRewind (dc->al_source);
-                               alError (L"AHI: queuesample:restart");
-                               restart = 1;
-                               if (ahi_debug > 2)
-                                       write_log (L"AHI: queuesample, play restart\n");
-                               preparesample_multi (dsahip, dc);
-                       }
-               }
-               preparesample_multi (dsahip, dc);
-               if (dc->dsplaying)
-                       dc->dsplaying = 1;
-               if (restart)
-                       al_startplay (dc);
-               if (ahi_debug > 2)
-                       write_log (L"AHI: sample %d queued to channel %d\n", dc->cs.ds->num, dc->num);
+static int unqueuebuffers (struct dschannel *dc)
+{
+       int v, cnt = 0;
+       for (;;) {
+               ALuint tmp;
+               alClear ();
+               alGetSourcei (dc->al_source, AL_BUFFERS_PROCESSED, &v);
+               if (alError (L"AHI: hsync AL_BUFFERS_PROCESSED %d", dc->num))
+                       return cnt;
+               if (v == 0)
+                       return cnt;
+               alSourceUnqueueBuffers (dc->al_source, 1, &tmp);
+               cnt++;
        }
+}
 
-       static int unqueuebuffers (struct dschannel *dc)
-       {
-               int v, cnt = 0;
-               for (;;) {
-                       ALuint tmp;
-                       alClear ();
-                       alGetSourcei (dc->al_source, AL_BUFFERS_PROCESSED, &v);
-                       if (alError (L"AHI: hsync AL_BUFFERS_PROCESSED %d", dc->num))
-                               return cnt;
-                       if (v == 0)
-                               return cnt;
-                       alSourceUnqueueBuffers (dc->al_source, 1, &tmp);
-                       cnt++;
+void ahi_hsync (void)
+{
+       struct DSAHI *dsahip = &dsahi[0];
+       static int cnt;
+       uae_u32 pbase;
+       int i, flags;
+
+       if (ahi_paused || !ahi_active)
+               return;
+       pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
+       if (cnt >= 0)
+               cnt--;
+       if (cnt < 0) {
+               if (dsahip->dsrecording && dsahip->enabledisable == 0) {
+                       dorecord (dsahip);
+                       cnt = 100;
                }
        }
-
-       void ahi_hsync (void)
-       {
-               struct DSAHI *dsahip = &dsahi[0];
-               static int cnt;
-               uae_u32 pbase;
-               int i, flags;
-
-               if (ahi_paused || !ahi_active)
-                       return;
-               pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
-               if (cnt >= 0)
-                       cnt--;
-               if (cnt < 0) {
-                       if (dsahip->dsrecording && dsahip->enabledisable == 0) {
-                               dorecord (dsahip);
-                               cnt = 100;
+       if (!dsahip->playing)
+               return;
+       flags = get_long (pbase + pub_ChannelSignalAck);
+       for (i = 0; i < UAE_MAXCHANNELS; i++) {
+               int v, removed;
+               struct dschannel *dc = &dsahip->channel[i];
+               uae_u32 mask = 1 << (dc - &dsahip->channel[0]);
+
+               if (dc->dsplaying != 1 || dc->al_source == -1)
+                       continue;
+
+               removed = unqueuebuffers (dc);
+               v = 0;
+               alClear ();
+               alGetSourcei (dc->al_source, AL_SOURCE_STATE, &v);
+               alError (L"AHI: hsync AL_SOURCE_STATE");
+               if (v != AL_PLAYING) {
+                       if (dc->cs.ds) {
+                               setchannelevent (dsahip, dc);
+                               if (ahi_debug)
+                                       write_log (L"AHI: ********* channel %d stopped state=%d!\n", dc->num, v);
+                               removed = 1;
+                               dc->dsplaying = 2;
+                               dc->waitforack = 0;
                        }
                }
-               if (!dsahip->playing)
-                       return;
-               flags = get_long (pbase + pub_ChannelSignalAck);
-               for (i = 0; i < UAE_MAXCHANNELS; i++) {
-                       int v, removed;
-                       struct dschannel *dc = &dsahip->channel[i];
-                       uae_u32 mask = 1 << (dc - &dsahip->channel[0]);
-
-                       if (dc->dsplaying != 1 || dc->al_source == -1)
-                               continue;
-
-                       removed = unqueuebuffers (dc);
-                       v = 0;
-                       alClear ();
-                       alGetSourcei (dc->al_source, AL_SOURCE_STATE, &v);
-                       alError (L"AHI: hsync AL_SOURCE_STATE");
-                       if (v != AL_PLAYING) {
-                               if (dc->cs.ds) {
-                                       setchannelevent (dsahip, dc);
-                                       if (ahi_debug)
-                                               write_log (L"AHI: ********* channel %d stopped state=%d!\n", dc->num, v);
-                                       removed = 1;
-                                       dc->dsplaying = 2;
-                                       dc->waitforack = 0;
-                               }
-                       }
-                       if (!dc->waitforack && dc->samplecounter >= 0 && removed) {
-                               int evt = 0;
+               if (!dc->waitforack && dc->samplecounter >= 0 && removed) {
+                       int evt = 0;
+                       if (ahi_debug > 2)
+                               write_log (L"sample end channel %d: %d/%d\n", dc->num, dc->samplecounter, dc->totalsamples);
+                       if (dc->samplecounter >= dc->totalsamples) {
+                               evt = 1;
                                if (ahi_debug > 2)
-                                       write_log (L"sample end channel %d: %d/%d\n", dc->num, dc->samplecounter, dc->totalsamples);
-                               if (dc->samplecounter >= dc->totalsamples) {
-                                       evt = 1;
-                                       if (ahi_debug > 2)
-                                               write_log (L"sample finished channel %d: %d\n", dc->num, dc->totalsamples);
-                                       dc->samplecounter = 0;
-                                       if (dc->csnext.ds) {
-                                               memcpy (&dc->cs, &dc->csnext, sizeof (struct chsample));
-                                               dc->csnext.ds = NULL;
-                                       }
-                               }
-                               if (evt) {
-                                       flags &= ~mask;
-                                       if (setchannelevent (dsahip, dc))
-                                               dc->waitforack = 1;
+                                       write_log (L"sample finished channel %d: %d\n", dc->num, dc->totalsamples);
+                               dc->samplecounter = 0;
+                               if (dc->csnext.ds) {
+                                       memcpy (&dc->cs, &dc->csnext, sizeof (struct chsample));
+                                       dc->csnext.ds = NULL;
                                }
-                               if (!dc->waitforack)
-                                       al_queuesample (dsahip, dc);
                        }
-                       if (dc->waitforack && (flags & mask)) {
-                               al_queuesample (dsahip, dc);
-                               dc->waitforack = 0;
+                       if (evt) {
                                flags &= ~mask;
+                               if (setchannelevent (dsahip, dc))
+                                       dc->waitforack = 1;
                        }
+                       if (!dc->waitforack)
+                               al_queuesample (dsahip, dc);
                }
-               put_long (pbase + pub_ChannelSignalAck, flags);
-       }
-
-       static void ds_record (struct DSAHI *dsahip, int start)
-       {
-               alClear ();
-               if (start) {
-                       if (!dsahip->dsrecording)
-                               alcCaptureStart (dsahip->al_recorddev);
-                       dsahip->dsrecording = 1;
-               } else {
-                       alcCaptureStop (dsahip->al_recorddev);
-                       dsahip->dsrecording = 0;
+               if (dc->waitforack && (flags & mask)) {
+                       al_queuesample (dsahip, dc);
+                       dc->waitforack = 0;
+                       flags &= ~mask;
                }
-               alError (L"AHI: alcCapture%s failed", start ? "Start" : "Stop");
        }
+       put_long (pbase + pub_ChannelSignalAck, flags);
+}
 
-       static void ds_stop (struct DSAHI *dsahip, struct dschannel *dc)
-       {
-               dc->dsplaying = 0;
-               if (dc->al_source == -1)
-                       return;
-               if (ahi_debug)
-                       write_log (L"AHI: ds_stop(%d)\n", dc->num);
-               alClear ();
-               alSourceStop (dc->al_source);
-               alError (L"AHI: alSourceStop");
-               unqueuebuffers (dc);
+static void ds_record (struct DSAHI *dsahip, int start)
+{
+       alClear ();
+       if (start) {
+               if (!dsahip->dsrecording)
+                       alcCaptureStart (dsahip->al_recorddev);
+               dsahip->dsrecording = 1;
+       } else {
+               alcCaptureStop (dsahip->al_recorddev);
+               dsahip->dsrecording = 0;
        }
+       alError (L"AHI: alcCapture%s failed", start ? "Start" : "Stop");
+}
 
-       static void ds_play (struct DSAHI *dsahip, struct dschannel *dc)
-       {
-               if (dc->dsplaying) {
-                       dc->dsplaying = 1;
-                       return;
-               }
+static void ds_stop (struct DSAHI *dsahip, struct dschannel *dc)
+{
+       dc->dsplaying = 0;
+       if (dc->al_source == -1)
+               return;
+       if (ahi_debug)
+               write_log (L"AHI: ds_stop(%d)\n", dc->num);
+       alClear ();
+       alSourceStop (dc->al_source);
+       alError (L"AHI: alSourceStop");
+       unqueuebuffers (dc);
+}
+
+static void ds_play (struct DSAHI *dsahip, struct dschannel *dc)
+{
+       if (dc->dsplaying) {
                dc->dsplaying = 1;
-               if (dc->cs.frequency == 0)
-                       return;
+               return;
+       }
+       dc->dsplaying = 1;
+       if (dc->cs.frequency == 0)
+               return;
+       if (dc->al_source == -1)
+               return;
+       if (ahi_debug)
+               write_log (L"AHI: ds_play(%d)\n", dc->num);
+       al_startplay (dc);
+}
+
+void ahi2_pause_sound (int paused)
+{
+       int i;
+       struct DSAHI *dsahip = &dsahi[0];
+
+       ahi_paused = paused;
+       if (!dsahip->playing && !dsahip->recording)
+               return;
+       for (i = 0; i < UAE_MAXCHANNELS; i++) {
+               struct dschannel *dc = &dsahip->channel[i];
                if (dc->al_source == -1)
-                       return;
-               if (ahi_debug)
-                       write_log (L"AHI: ds_play(%d)\n", dc->num);
-               al_startplay (dc);
+                       continue;
+               if (paused) {
+                       ds_stop (dsahip, dc);
+               } else {
+                       ds_play (dsahip, dc);
+                       setchannelevent (dsahip, dc);
+               }
        }
+}
 
-       void ahi2_pause_sound (int paused)
-       {
-               int i;
-               struct DSAHI *dsahip = &dsahi[0];
+static uae_u32 init (TrapContext *ctx)
+{
+       int i, j;
+
+       enumerate_sound_devices ();
+       xahi_author = ds (L"Toni Wilen");
+       xahi_copyright = ds (L"GPL");
+       xahi_version = ds (L"uae2 0.2 (xx.xx.2008)\r\n");
+       j = 0;
+       for (i = 0; sound_devices[i].name; i++) {
+               if (sound_devices[i].type == SOUND_DEVICE_AL)
+                       xahi_output[j++] = ds (sound_devices[i].name);
+       }
+       xahi_output_num = j;
+       j = 0;
+       for (i = 0; record_devices[i].name; i++) {
+               if (record_devices[i].type == SOUND_DEVICE_AL)
+                       xahi_input[j++] = ds (record_devices[i].name);
+       }
+       xahi_input_num = j;
+       return 1;
+}
 
-               ahi_paused = paused;
-               if (!dsahip->playing && !dsahip->recording)
-                       return;
-               for (i = 0; i < UAE_MAXCHANNELS; i++) {
-                       struct dschannel *dc = &dsahip->channel[i];
-                       if (dc->al_source == -1)
-                               continue;
-                       if (paused) {
-                               ds_stop (dsahip, dc);
-                       } else {
-                               ds_play (dsahip, dc);
-                               setchannelevent (dsahip, dc);
-                       }
-               }
+static uae_u32 AHIsub_AllocAudio (TrapContext *ctx)
+{
+       int i;
+       uae_u32 tags = m68k_areg (regs, 1);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       uae_u32 pbase = get_long (audioctrl + ahiac_DriverData);
+       uae_u32 tag, data, v, ver, size;
+       uae_u32 ret = AHISF_KNOWSTEREO | AHISF_KNOWHIFI;
+       struct DSAHI *dsahip = &dsahi[0];
+
+       if (ahi_debug)
+               write_log (L"AHI: AllocAudio(%08x,%08x)\n", tags, audioctrl);
+
+       ver = get_long (pbase + pub_Version);
+       size = get_long (pbase + pub_SizeOf);
+       if (ver != AHI_STRUCT_VERSION) {
+               gui_message (L"AHI: Incompatible DEVS:AHI/uae2.audio\nVersion mismatch %d<>%d.", ver, AHI_STRUCT_VERSION);
+               return AHISF_ERROR;
+       }
+       if (size < pub_End) {
+               gui_message (L"AHI: Incompatible DEVS:AHI/uae2.audio.\nInternal structure size %d<>%d.", size, pub_End);
+               return AHISF_ERROR;
        }
 
-       static uae_u32 init (TrapContext *ctx)
-       {
-               int i, j;
-
-               enumerate_sound_devices ();
-               xahi_author = ds (L"Toni Wilen");
-               xahi_copyright = ds (L"GPL");
-               xahi_version = ds (L"uae2 0.2 (xx.xx.2008)\r\n");
-               j = 0;
-               for (i = 0; sound_devices[i].name; i++) {
-                       if (sound_devices[i].type == SOUND_DEVICE_AL)
-                               xahi_output[j++] = ds (sound_devices[i].name);
-               }
-               xahi_output_num = j;
-               j = 0;
-               for (i = 0; record_devices[i].name; i++) {
-                       if (record_devices[i].type == SOUND_DEVICE_AL)
-                               xahi_input[j++] = ds (record_devices[i].name);
-               }
-               xahi_input_num = j;
-               return 1;
+       v = get_long (pbase + pub_Index);
+       if (v != -1) {
+               write_log (L"AHI: corrupted memory\n");
+               return AHISF_ERROR;
        }
+       put_long (pbase + pub_Index, dsahip - dsahi);
+       dsahip->audioctrl = audioctrl;
 
-       static uae_u32 AHIsub_AllocAudio (TrapContext *ctx)
-       {
-               int i;
-               uae_u32 tags = m68k_areg (regs, 1);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               uae_u32 pbase = get_long (audioctrl + ahiac_DriverData);
-               uae_u32 tag, data, v, ver, size;
-               uae_u32 ret = AHISF_KNOWSTEREO | AHISF_KNOWHIFI;
-               struct DSAHI *dsahip = &dsahi[0];
+       dsahip->maxplaysamples = UAE_MAXPLAYSAMPLES;
+       dsahip->sounds = UAE_MAXSOUNDS;
+       dsahip->channels = UAE_MAXCHANNELS;
 
+       dsahip->audioid = 0x003b0001;
+       while ((tag = gettag (&tags, &data))) {
                if (ahi_debug)
-                       write_log (L"AHI: AllocAudio(%08x,%08x)\n", tags, audioctrl);
-
-               ver = get_long (pbase + pub_Version);
-               size = get_long (pbase + pub_SizeOf);
-               if (ver != AHI_STRUCT_VERSION) {
-                       gui_message (L"AHI: Incompatible DEVS:AHI/uae2.audio\nVersion mismatch %d<>%d.", ver, AHI_STRUCT_VERSION);
-                       return AHISF_ERROR;
-               }
-               if (size < pub_End) {
-                       gui_message (L"AHI: Incompatible DEVS:AHI/uae2.audio.\nInternal structure size %d<>%d.", size, pub_End);
-                       return AHISF_ERROR;
-               }
-
-               v = get_long (pbase + pub_Index);
-               if (v != -1) {
-                       write_log (L"AHI: corrupted memory\n");
-                       return AHISF_ERROR;
-               }
-               put_long (pbase + pub_Index, dsahip - dsahi);
-               dsahip->audioctrl = audioctrl;
-
-               dsahip->maxplaysamples = UAE_MAXPLAYSAMPLES;
-               dsahip->sounds = UAE_MAXSOUNDS;
-               dsahip->channels = UAE_MAXCHANNELS;
-
-               dsahip->audioid = 0x003b0001;
-               while ((tag = gettag (&tags, &data))) {
-                       if (ahi_debug)
-                               write_log (L"- TAG %08x=%d: %08x=%u\n", tag, tag & 0x7fff, data, data);
-                       switch (tag)
-                       {
-                       case AHIA_AudioID:
-                               dsahip->audioid = data;
-                               break;
-                       }
+                       write_log (L"- TAG %08x=%d: %08x=%u\n", tag, tag & 0x7fff, data, data);
+               switch (tag)
+               {
+               case AHIA_AudioID:
+                       dsahip->audioid = data;
+                       break;
                }
+       }
 
-               if ((dsahip->audioid >> 16) != 0x3b)
-                       return AHISF_ERROR;
+       if ((dsahip->audioid >> 16) != 0x3b)
+               return AHISF_ERROR;
 
-               if (dsahip->sounds < 0 || dsahip->sounds > 1000)
-                       return AHISF_ERROR;
+       if (dsahip->sounds < 0 || dsahip->sounds > 1000)
+               return AHISF_ERROR;
 
-               if (!ds_init (dsahip))
-                       return AHISF_ERROR;
+       if (!ds_init (dsahip))
+               return AHISF_ERROR;
 
-               if (xahi_input_num)
-                       ret |= AHISF_CANRECORD;
-               if (cansurround)
-                       ret |= AHISF_KNOWMULTICHANNEL;
+       if (xahi_input_num)
+               ret |= AHISF_CANRECORD;
+       if (cansurround)
+               ret |= AHISF_KNOWMULTICHANNEL;
 
-               dsahip->sample = xcalloc (struct dssample, dsahip->sounds);
-               dsahip->channel = xcalloc (struct dschannel, dsahip->channels);
-               for (i = 0; i < dsahip->channels; i++) {
-                       struct dschannel *dc = &dsahip->channel[i];
-                       dc->num = i;
-                       dc->al_source = -1;
-               }
-               for (i = 0; i < dsahip->sounds; i++) {
-                       struct dssample *ds = &dsahip->sample[i];
-                       ds->num = -1;
-                       ds->al_buffer[0] = -1;
-                       ds->al_buffer[1] = -1;
-               }
-               ahi_active = 1;
-               return ret;
+       dsahip->sample = xcalloc (struct dssample, dsahip->sounds);
+       dsahip->channel = xcalloc (struct dschannel, dsahip->channels);
+       for (i = 0; i < dsahip->channels; i++) {
+               struct dschannel *dc = &dsahip->channel[i];
+               dc->num = i;
+               dc->al_source = -1;
        }
-
-       static void AHIsub_Disable (TrapContext *ctx)
-       {
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               struct DSAHI *dsahip = GETAHI;
-               if (ahi_debug > 1)
-                       write_log (L"AHI: Disable(%08x)\n", audioctrl);
-               dsahip->enabledisable++;
+       for (i = 0; i < dsahip->sounds; i++) {
+               struct dssample *ds = &dsahip->sample[i];
+               ds->num = -1;
+               ds->al_buffer[0] = -1;
+               ds->al_buffer[1] = -1;
        }
+       ahi_active = 1;
+       return ret;
+}
 
-       static void AHIsub_Enable (TrapContext *ctx)
-       {
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               struct DSAHI *dsahip = GETAHI;
-               if (ahi_debug > 1)
-                       write_log (L"AHI: Enable(%08x)\n", audioctrl);
-               dsahip->enabledisable--;
-               if (dsahip->enabledisable == 0 && dsahip->playing)
-                       setevent (dsahip);
-       }
+static void AHIsub_Disable (TrapContext *ctx)
+{
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       struct DSAHI *dsahip = GETAHI;
+       if (ahi_debug > 1)
+               write_log (L"AHI: Disable(%08x)\n", audioctrl);
+       dsahip->enabledisable++;
+}
+
+static void AHIsub_Enable (TrapContext *ctx)
+{
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       struct DSAHI *dsahip = GETAHI;
+       if (ahi_debug > 1)
+               write_log (L"AHI: Enable(%08x)\n", audioctrl);
+       dsahip->enabledisable--;
+       if (dsahip->enabledisable == 0 && dsahip->playing)
+               setevent (dsahip);
+}
 
-       static void AHIsub_FreeAudio (TrapContext *ctx)
-       {
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               uae_u32 pbase = get_long (audioctrl + ahiac_DriverData);
-               struct DSAHI *dsahip = GETAHI;
-               if (ahi_debug)
-                       write_log (L"AHI: FreeAudio(%08x)\n", audioctrl);
-               if (ahi_active == 0)
-                       return;
-               ahi_active = 0;
-               put_long (pbase + pub_Index, -1);
-               if (dsahip) {
-                       ds_free (dsahip);
-                       ds_free_record (dsahip);
-                       xfree (dsahip->channel);
-                       xfree (dsahip->sample);
-                       memset (dsahip, 0, sizeof (struct DSAHI));
-               }
+static void AHIsub_FreeAudio (TrapContext *ctx)
+{
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       uae_u32 pbase = get_long (audioctrl + ahiac_DriverData);
+       struct DSAHI *dsahip = GETAHI;
+       if (ahi_debug)
+               write_log (L"AHI: FreeAudio(%08x)\n", audioctrl);
+       if (ahi_active == 0)
+               return;
+       ahi_active = 0;
+       put_long (pbase + pub_Index, -1);
+       if (dsahip) {
+               ds_free (dsahip);
+               ds_free_record (dsahip);
+               xfree (dsahip->channel);
+               xfree (dsahip->sample);
+               memset (dsahip, 0, sizeof (struct DSAHI));
        }
+}
 
-       static uae_u32 frequencies[] = { 48000, 44100 };
+static uae_u32 frequencies[] = { 48000, 44100 };
 #define MAX_FREQUENCIES (sizeof (frequencies) / sizeof (uae_u32))
 
-       static uae_u32 getattr2 (struct DSAHI *dsahip, uae_u32 attribute, uae_u32 argument, uae_u32 def)
-       {
-               int i;
-
-               switch (attribute)
-               {
-               case AHIDB_Bits:
-                       return 32;
-               case AHIDB_Frequencies:
-                       return MAX_FREQUENCIES;
-               case AHIDB_Frequency:
-                       if (argument < 0 || argument >= MAX_FREQUENCIES)
-                               argument = 0;
-                       return frequencies[argument];
-               case AHIDB_Index:
-                       if (argument <= frequencies[0])
-                               return 0;
-                       if (argument >= frequencies[MAX_FREQUENCIES - 1])
-                               return MAX_FREQUENCIES - 1;
-                       for (i = 1; i < MAX_FREQUENCIES; i++) {
-                               if (frequencies[i] > argument) {
-                                       if (argument - frequencies[i - 1] < frequencies[i] - argument)
-                                               return i - 1;
-                                       else
-                                               return i;
-                               }
-                       }
-                       return 0;
-               case AHIDB_Author:
-                       return xahi_author;
-               case AHIDB_Copyright:
-                       return xahi_copyright;
-               case AHIDB_Version:
-                       return xahi_version;
-               case AHIDB_Record:
-                       return -1;
-               case AHIDB_Realtime:
-                       return -1;
-               case AHIDB_MinOutputVolume:
-                       return 0x00000;
-               case AHIDB_MaxOutputVolume:
-                       return 0x10000;
-               case AHIDB_Outputs:
-                       return xahi_output_num;
-               case AHIDB_Output:
-                       if (argument >= 0 && argument < xahi_output_num)
-                               return xahi_output[argument];
-                       return 0;
-               case AHIDB_Inputs:
-                       return xahi_input_num;
-               case AHIDB_Input:
-                       if (argument >= 0 && argument < xahi_input_num)
-                               return xahi_input[argument];
-                       return 0;
-               case AHIDB_Volume:
-                       return -1;
-               case AHIDB_Panning:
-                       return -1;
-               case AHIDB_HiFi:
-                       return -1;
-               case AHIDB_MultiChannel:
-                       return cansurround ? -1 : 0;
-               case AHIDB_MaxChannels:
-                       return UAE_MAXCHANNELS;
-               case AHIDB_FullDuplex:
-                       return -1;
-               case AHIDB_MaxRecordSamples:
-                       return UAE_RECORDSAMPLES;
-               case AHIDB_MaxPlaySamples:
-                       if (def < dsahip->maxplaysamples)
-                               def = dsahip->maxplaysamples;
-                       return def;
-               default:
-                       return def;
-               }
-       }
-
-       static uae_u32 AHIsub_GetAttr (TrapContext *ctx)
-       {
-               uae_u32 attribute = m68k_dreg (regs, 0);
-               uae_u32 argument = m68k_dreg (regs, 1);
-               uae_u32 def = m68k_dreg (regs, 2);
-               uae_u32 taglist = m68k_areg (regs, 1);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               struct DSAHI *dsahip = GETAHI;
-               uae_u32 v;
-
-               v = getattr2 (dsahip, attribute, argument, def);
-               if (ahi_debug)
-                       write_log (L"AHI: GetAttr(%08x=%d,%08x,%08x)=%08x\n", attribute, attribute & 0x7fff, argument, def, v);
-
-               return v;
-       }
+static uae_u32 getattr2 (struct DSAHI *dsahip, uae_u32 attribute, uae_u32 argument, uae_u32 def)
+{
+       int i;
 
-       static uae_u32 AHIsub_HardwareControl (TrapContext *ctx)
+       switch (attribute)
        {
-               uae_u32 attribute = m68k_dreg (regs, 0);
-               uae_u32 argument = m68k_dreg (regs, 1);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               struct DSAHI *dsahip = GETAHI;
-               if (ahi_debug)
-                       write_log (L"AHI: HardwareControl(%08x=%d,%08x,%08x)\n", attribute, attribute & 0x7fff, argument, audioctrl);
-               switch (attribute)
-               {
-               case AHIC_Input:
-                       if (dsahip->input != argument) {
-                               dsahip->input = argument;
-                               if (dsahip->al_dev) {
-                                       ds_free_record (dsahip);
-                                       ds_init_record (dsahip);
-                                       if (dsahip->recording)
-                                               ds_record (dsahip, 1);
-                               }
-                       }
-                       break;
-               case AHIC_Input_Query:
-                       return dsahip->input;
-               case AHIC_Output:
-                       if (dsahip->output != argument) {
-                               dsahip->output = argument;
-                               if (dsahip->al_dev)
-                                       ds_reinit (dsahip);
+       case AHIDB_Bits:
+               return 32;
+       case AHIDB_Frequencies:
+               return MAX_FREQUENCIES;
+       case AHIDB_Frequency:
+               if (argument < 0 || argument >= MAX_FREQUENCIES)
+                       argument = 0;
+               return frequencies[argument];
+       case AHIDB_Index:
+               if (argument <= frequencies[0])
+                       return 0;
+               if (argument >= frequencies[MAX_FREQUENCIES - 1])
+                       return MAX_FREQUENCIES - 1;
+               for (i = 1; i < MAX_FREQUENCIES; i++) {
+                       if (frequencies[i] > argument) {
+                               if (argument - frequencies[i - 1] < frequencies[i] - argument)
+                                       return i - 1;
+                               else
+                                       return i;
                        }
-                       break;
-               case AHIC_Output_Query:
-                       return dsahip->output;
                }
                return 0;
-       }
-
-       static uae_u32 AHIsub_Start (TrapContext *ctx)
-       {
-               uae_u32 flags = m68k_dreg (regs, 0);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               struct DSAHI *dsahip = GETAHI;
-               int i;
-
-               if (ahi_debug)
-                       write_log (L"AHI: Play(%08x,%08x)\n",
-                       flags, audioctrl);
-               if ((flags & AHISF_PLAY) && !dsahip->playing) {
-                       dsahip->playing = 1;
-                       setevent (dsahip);
-                       for (i = 0; i < dsahip->channels; i++) {
-                               struct dschannel *dc = &dsahip->channel[i];
-                               ds_play (dsahip, dc);
-                       }
-               }
-               if ((flags & AHISF_RECORD) && !dsahip->recording) {
-                       dsahip->recording = 1;
-                       ds_init_record (dsahip);
-                       ds_record (dsahip, 1);
-               }
+       case AHIDB_Author:
+               return xahi_author;
+       case AHIDB_Copyright:
+               return xahi_copyright;
+       case AHIDB_Version:
+               return xahi_version;
+       case AHIDB_Record:
+               return -1;
+       case AHIDB_Realtime:
+               return -1;
+       case AHIDB_MinOutputVolume:
+               return 0x00000;
+       case AHIDB_MaxOutputVolume:
+               return 0x10000;
+       case AHIDB_Outputs:
+               return xahi_output_num;
+       case AHIDB_Output:
+               if (argument >= 0 && argument < xahi_output_num)
+                       return xahi_output[argument];
+               return 0;
+       case AHIDB_Inputs:
+               return xahi_input_num;
+       case AHIDB_Input:
+               if (argument >= 0 && argument < xahi_input_num)
+                       return xahi_input[argument];
                return 0;
+       case AHIDB_Volume:
+               return -1;
+       case AHIDB_Panning:
+               return -1;
+       case AHIDB_HiFi:
+               return -1;
+       case AHIDB_MultiChannel:
+               return cansurround ? -1 : 0;
+       case AHIDB_MaxChannels:
+               return UAE_MAXCHANNELS;
+       case AHIDB_FullDuplex:
+               return -1;
+       case AHIDB_MaxRecordSamples:
+               return UAE_RECORDSAMPLES;
+       case AHIDB_MaxPlaySamples:
+               if (def < dsahip->maxplaysamples)
+                       def = dsahip->maxplaysamples;
+               return def;
+       default:
+               return def;
        }
+}
 
-       static uae_u32 AHIsub_Stop (TrapContext *ctx)
+static uae_u32 AHIsub_GetAttr (TrapContext *ctx)
+{
+       uae_u32 attribute = m68k_dreg (regs, 0);
+       uae_u32 argument = m68k_dreg (regs, 1);
+       uae_u32 def = m68k_dreg (regs, 2);
+       uae_u32 taglist = m68k_areg (regs, 1);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       struct DSAHI *dsahip = GETAHI;
+       uae_u32 v;
+
+       v = getattr2 (dsahip, attribute, argument, def);
+       if (ahi_debug)
+               write_log (L"AHI: GetAttr(%08x=%d,%08x,%08x)=%08x\n", attribute, attribute & 0x7fff, argument, def, v);
+
+       return v;
+}
+
+static uae_u32 AHIsub_HardwareControl (TrapContext *ctx)
+{
+       uae_u32 attribute = m68k_dreg (regs, 0);
+       uae_u32 argument = m68k_dreg (regs, 1);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       struct DSAHI *dsahip = GETAHI;
+       if (ahi_debug)
+               write_log (L"AHI: HardwareControl(%08x=%d,%08x,%08x)\n", attribute, attribute & 0x7fff, argument, audioctrl);
+       switch (attribute)
        {
-               uae_u32 flags = m68k_dreg (regs, 0);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               struct DSAHI *dsahip = GETAHI;
-               int i;
-
-               if (ahi_debug)
-                       write_log (L"AHI: Stop(%08x,%08x)\n",
-                       flags, audioctrl);
-               if ((flags & AHISF_PLAY) && dsahip->playing) {
-                       dsahip->playing = 0;
-                       for (i = 0; i < dsahip->channels; i++) {
-                               struct dschannel *dc = &dsahip->channel[i];
-                               ds_stop (dsahip, dc);
+       case AHIC_Input:
+               if (dsahip->input != argument) {
+                       dsahip->input = argument;
+                       if (dsahip->al_dev) {
+                               ds_free_record (dsahip);
+                               ds_init_record (dsahip);
+                               if (dsahip->recording)
+                                       ds_record (dsahip, 1);
                        }
                }
-               if ((flags & AHISF_RECORD) && dsahip->recording) {
-                       dsahip->recording = 0;
-                       ds_record (dsahip, 0);
-                       ds_free_record (dsahip);
+               break;
+       case AHIC_Input_Query:
+               return dsahip->input;
+       case AHIC_Output:
+               if (dsahip->output != argument) {
+                       dsahip->output = argument;
+                       if (dsahip->al_dev)
+                               ds_reinit (dsahip);
                }
-               return 0;
+               break;
+       case AHIC_Output_Query:
+               return dsahip->output;
        }
+       return 0;
+}
 
-       static uae_u32 AHIsub_Update (TrapContext *ctx)
-       {
-               uae_u32 flags = m68k_dreg (regs, 0);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               struct DSAHI *dsahip = GETAHI;
-               if (ahi_debug)
-                       write_log (L"AHI: Update(%08x,%08x)\n", flags, audioctrl);
+static uae_u32 AHIsub_Start (TrapContext *ctx)
+{
+       uae_u32 flags = m68k_dreg (regs, 0);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       struct DSAHI *dsahip = GETAHI;
+       int i;
+
+       if (ahi_debug)
+               write_log (L"AHI: Play(%08x,%08x)\n",
+               flags, audioctrl);
+       if ((flags & AHISF_PLAY) && !dsahip->playing) {
+               dsahip->playing = 1;
                setevent (dsahip);
-               return 0;
+               for (i = 0; i < dsahip->channels; i++) {
+                       struct dschannel *dc = &dsahip->channel[i];
+                       ds_play (dsahip, dc);
+               }
        }
+       if ((flags & AHISF_RECORD) && !dsahip->recording) {
+               dsahip->recording = 1;
+               ds_init_record (dsahip);
+               ds_record (dsahip, 1);
+       }
+       return 0;
+}
 
-       static uae_u32 AHIsub_SetVol (TrapContext *ctx)
-       {
-               uae_u16 channel = m68k_dreg (regs, 0);
-               uae_s32 volume = m68k_dreg (regs, 1);
-               uae_s32 pan = m68k_dreg (regs, 2);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               uae_u32 flags = m68k_dreg (regs, 3);
-               struct DSAHI *dsahip = GETAHI;
-               struct dschannel *dc = GETCHANNEL;
-
-               if (ahi_debug > 1)
-                       write_log (L"AHI: SetVol(%d,%d,%d,%08x,%08x)\n",
-                       channel, volume, pan, audioctrl, flags);
-               if (dc) {
-                       if (volume < -65535)
-                               volume = -65535;
-                       if (volume > 65535)
-                               volume = 65535;
-                       if (pan < -65535)
-                               pan = -65535;
-                       if (pan > 65535)
-                               pan = 65535;
-                       dc->csnext.volume = volume;
-                       dc->csnext.panning = pan;
-                       if (flags & AHISF_IMM) {
-                               ds_setvolume (dsahip, dc);
-                       }
+static uae_u32 AHIsub_Stop (TrapContext *ctx)
+{
+       uae_u32 flags = m68k_dreg (regs, 0);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       struct DSAHI *dsahip = GETAHI;
+       int i;
+
+       if (ahi_debug)
+               write_log (L"AHI: Stop(%08x,%08x)\n",
+               flags, audioctrl);
+       if ((flags & AHISF_PLAY) && dsahip->playing) {
+               dsahip->playing = 0;
+               for (i = 0; i < dsahip->channels; i++) {
+                       struct dschannel *dc = &dsahip->channel[i];
+                       ds_stop (dsahip, dc);
                }
-               return 0;
        }
+       if ((flags & AHISF_RECORD) && dsahip->recording) {
+               dsahip->recording = 0;
+               ds_record (dsahip, 0);
+               ds_free_record (dsahip);
+       }
+       return 0;
+}
 
-       static uae_u32 AHIsub_SetFreq (TrapContext *ctx)
-       {
-               uae_u16 channel = m68k_dreg (regs, 0);
-               uae_u32 frequency = m68k_dreg (regs, 1);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               uae_u32 flags = m68k_dreg (regs, 3);
-               struct DSAHI *dsahip = GETAHI;
-               struct dschannel *dc = GETCHANNEL;
-
-               if (ahi_debug > 1)
-                       write_log (L"AHI: SetFreq(%d,%d,%08x,%08x)\n",
-                       channel, frequency, audioctrl, flags);
-               if (dc) {
-                       dc->csnext.frequency = frequency;
-                       if (flags & AHISF_IMM) {
-                               ds_setfreq (dsahip, dc);
-                               ds_play (dsahip, dc);
-                       }
+static uae_u32 AHIsub_Update (TrapContext *ctx)
+{
+       uae_u32 flags = m68k_dreg (regs, 0);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       struct DSAHI *dsahip = GETAHI;
+       if (ahi_debug)
+               write_log (L"AHI: Update(%08x,%08x)\n", flags, audioctrl);
+       setevent (dsahip);
+       return 0;
+}
+
+static uae_u32 AHIsub_SetVol (TrapContext *ctx)
+{
+       uae_u16 channel = m68k_dreg (regs, 0);
+       uae_s32 volume = m68k_dreg (regs, 1);
+       uae_s32 pan = m68k_dreg (regs, 2);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       uae_u32 flags = m68k_dreg (regs, 3);
+       struct DSAHI *dsahip = GETAHI;
+       struct dschannel *dc = GETCHANNEL;
+
+       if (ahi_debug > 1)
+               write_log (L"AHI: SetVol(%d,%d,%d,%08x,%08x)\n",
+               channel, volume, pan, audioctrl, flags);
+       if (dc) {
+               if (volume < -65535)
+                       volume = -65535;
+               if (volume > 65535)
+                       volume = 65535;
+               if (pan < -65535)
+                       pan = -65535;
+               if (pan > 65535)
+                       pan = 65535;
+               dc->csnext.volume = volume;
+               dc->csnext.panning = pan;
+               if (flags & AHISF_IMM) {
+                       ds_setvolume (dsahip, dc);
                }
-               return 0;
        }
+       return 0;
+}
 
-       static uae_u32 AHIsub_SetSound (TrapContext *ctx)
-       {
-               uae_u16 channel = m68k_dreg (regs, 0);
-               uae_u16 sound = m68k_dreg (regs, 1);
-               uae_u32 offset = m68k_dreg (regs, 2);
-               int length  = m68k_dreg (regs, 3);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               uae_u32 flags = m68k_dreg (regs, 4);
-               struct DSAHI *dsahip = GETAHI;
-               struct dssample *ds = GETSAMPLE;
-               struct dschannel *dc = GETCHANNEL;
-
-               if (ahi_debug > 1)
-                       write_log (L"AHI: SetSound(%d,%d,%08x,%d,%08x,%08x)\n",
-                       channel, sound, offset, length, audioctrl, flags);
-               if (dc == NULL)
-                       return AHIE_UNKNOWN;
-               if (sound == 0xffff) {
-                       if (flags & AHISF_IMM) {
-                               dc->cs.ds = NULL;
-                               dc->csnext.ds = NULL;
-                       }
-                       return 0;
+static uae_u32 AHIsub_SetFreq (TrapContext *ctx)
+{
+       uae_u16 channel = m68k_dreg (regs, 0);
+       uae_u32 frequency = m68k_dreg (regs, 1);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       uae_u32 flags = m68k_dreg (regs, 3);
+       struct DSAHI *dsahip = GETAHI;
+       struct dschannel *dc = GETCHANNEL;
+
+       if (ahi_debug > 1)
+               write_log (L"AHI: SetFreq(%d,%d,%08x,%08x)\n",
+               channel, frequency, audioctrl, flags);
+       if (dc) {
+               dc->csnext.frequency = frequency;
+               if (flags & AHISF_IMM) {
+                       ds_setfreq (dsahip, dc);
+                       ds_play (dsahip, dc);
                }
-               if (ds == NULL || ds->num < 0)
-                       return AHIE_UNKNOWN;
-               ds_allocchannel (dsahip, dc);
-               dc->cs.backwards = length < 0;
-               length = abs (length);
-               if (length == 0)
-                       length = ds->len;
-               if (length > ds->len)
-                       length = ds->len;
-               dc->csnext.ds = ds;
-               dc->csnext.srcplaylen = length;
-               dc->csnext.srcplayoffset = offset;
-               if (flags & AHISF_IMM)
+       }
+       return 0;
+}
+
+static uae_u32 AHIsub_SetSound (TrapContext *ctx)
+{
+       uae_u16 channel = m68k_dreg (regs, 0);
+       uae_u16 sound = m68k_dreg (regs, 1);
+       uae_u32 offset = m68k_dreg (regs, 2);
+       int length  = m68k_dreg (regs, 3);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       uae_u32 flags = m68k_dreg (regs, 4);
+       struct DSAHI *dsahip = GETAHI;
+       struct dssample *ds = GETSAMPLE;
+       struct dschannel *dc = GETCHANNEL;
+
+       if (ahi_debug > 1)
+               write_log (L"AHI: SetSound(%d,%d,%08x,%d,%08x,%08x)\n",
+               channel, sound, offset, length, audioctrl, flags);
+       if (dc == NULL)
+               return AHIE_UNKNOWN;
+       if (sound == 0xffff) {
+               if (flags & AHISF_IMM) {
                        dc->cs.ds = NULL;
-               ds_setfreq (dsahip, dc);
-               ds_setvolume (dsahip, dc);
-               if (dc->cs.ds == NULL)
-                       al_initsample (dsahip, dc);
+                       dc->csnext.ds = NULL;
+               }
                return 0;
        }
-
-       static uae_u32 AHIsub_SetEffect (TrapContext *ctx)
+       if (ds == NULL || ds->num < 0)
+               return AHIE_UNKNOWN;
+       ds_allocchannel (dsahip, dc);
+       dc->cs.backwards = length < 0;
+       length = abs (length);
+       if (length == 0)
+               length = ds->len;
+       if (length > ds->len)
+               length = ds->len;
+       dc->csnext.ds = ds;
+       dc->csnext.srcplaylen = length;
+       dc->csnext.srcplayoffset = offset;
+       if (flags & AHISF_IMM)
+               dc->cs.ds = NULL;
+       ds_setfreq (dsahip, dc);
+       ds_setvolume (dsahip, dc);
+       if (dc->cs.ds == NULL)
+               al_initsample (dsahip, dc);
+       return 0;
+}
+
+static uae_u32 AHIsub_SetEffect (TrapContext *ctx)
+{
+       uae_u32 effect = m68k_areg (regs, 0);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       uae_u32 effectype = get_long (effect);
+       uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
+       struct DSAHI *dsahip = GETAHI;
+
+       if (ahi_debug)
+               write_log (L"AHI: SetEffect(%08x (%08x),%08x)\n", effect, effectype, audioctrl);
+       switch (effectype)
        {
-               uae_u32 effect = m68k_areg (regs, 0);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               uae_u32 effectype = get_long (effect);
-               uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
-               struct DSAHI *dsahip = GETAHI;
-
-               if (ahi_debug)
-                       write_log (L"AHI: SetEffect(%08x (%08x),%08x)\n", effect, effectype, audioctrl);
-               switch (effectype)
-               {
-               case AHIET_CHANNELINFO:
-                       put_long (puaebase + pub_ChannelInfo, effect);
-                       break;
-               case AHIET_CHANNELINFO | AHIET_CANCEL:
-                       put_long (puaebase + pub_ChannelInfo, 0);
-                       break;
-               case AHIET_MASTERVOLUME:
-                       write_log (L"AHI: SetEffect(MasterVolume=%08x)\n", get_long (effect + 4));
-               case AHIET_MASTERVOLUME | AHIET_CANCEL:
-                       break;
-               default:
-                       return AHIE_UNKNOWN;
-               }
-               return AHIE_OK;
+       case AHIET_CHANNELINFO:
+               put_long (puaebase + pub_ChannelInfo, effect);
+               break;
+       case AHIET_CHANNELINFO | AHIET_CANCEL:
+               put_long (puaebase + pub_ChannelInfo, 0);
+               break;
+       case AHIET_MASTERVOLUME:
+               write_log (L"AHI: SetEffect(MasterVolume=%08x)\n", get_long (effect + 4));
+       case AHIET_MASTERVOLUME | AHIET_CANCEL:
+               break;
+       default:
+               return AHIE_UNKNOWN;
        }
+       return AHIE_OK;
+}
 
-       static uae_u32 AHIsub_LoadSound (TrapContext *ctx)
+static uae_u32 AHIsub_LoadSound (TrapContext *ctx)
+{
+       uae_u16 sound = m68k_dreg (regs, 0);
+       uae_u32 type = m68k_dreg (regs, 1);
+       uae_u32 info = m68k_areg (regs, 0);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       struct DSAHI *dsahip = GETAHI;
+       uae_u32 ret = AHIE_BADSOUNDTYPE;
+       int sampletype = get_long (info + ahisi_Type);
+       uae_u32 addr = get_long (info + ahisi_Address);
+       uae_u32 len = get_long (info + ahisi_Length);
+       struct dssample *ds = GETSAMPLE;
+       int ch;
+       int bps;
+
+       if (ahi_debug > 1)
+               write_log (L"AHI: LoadSound(%d,%d,%08x,%08x,SMP=%d,ADDR=%08x,LEN=%d)\n",
+               sound, type, info, audioctrl, sampletype, addr, len);
+
+       if (!ds)
+               return AHIE_BADSOUNDTYPE;
+
+       ds->num = sound;
+       if (!cansurround && sampletype == AHIST_L7_1)
+               return AHIE_BADSOUNDTYPE;
+       ds->addr = addr;
+       ds->sampletype = sampletype;
+       ds->type = type;
+       ds->len = len;
+       ds->dynamic = type == AHIST_DYNAMICSAMPLE;
+
+       switch (sampletype)
        {
-               uae_u16 sound = m68k_dreg (regs, 0);
-               uae_u32 type = m68k_dreg (regs, 1);
-               uae_u32 info = m68k_areg (regs, 0);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               struct DSAHI *dsahip = GETAHI;
-               uae_u32 ret = AHIE_BADSOUNDTYPE;
-               int sampletype = get_long (info + ahisi_Type);
-               uae_u32 addr = get_long (info + ahisi_Address);
-               uae_u32 len = get_long (info + ahisi_Length);
-               struct dssample *ds = GETSAMPLE;
-               int ch;
-               int bps;
-
-               if (ahi_debug > 1)
-                       write_log (L"AHI: LoadSound(%d,%d,%08x,%08x,SMP=%d,ADDR=%08x,LEN=%d)\n",
-                       sound, type, info, audioctrl, sampletype, addr, len);
-
-               if (!ds)
-                       return AHIE_BADSOUNDTYPE;
-
-               ds->num = sound;
-               if (!cansurround && sampletype == AHIST_L7_1)
-                       return AHIE_BADSOUNDTYPE;
-               ds->addr = addr;
-               ds->sampletype = sampletype;
-               ds->type = type;
-               ds->len = len;
-               ds->dynamic = type == AHIST_DYNAMICSAMPLE;
-
-               switch (sampletype)
-               {
-               case AHIST_M8S:
-               case AHIST_M16S:
-               case AHIST_M32S:
-                       ch = 1;
-                       break;
-               case AHIST_S8S:
-               case AHIST_S16S:
-               case AHIST_S32S:
-                       ch = 2;
-                       break;
-               case AHIST_L7_1:
-                       ch = 8;
-                       break;
-               default:
-                       return 0;
-               }
-               switch (sampletype)
-               {
-               case AHIST_M8S:
-               case AHIST_S8S:
-                       bps = 8;
-                       break;
-               case AHIST_M16S:
-               case AHIST_S16S:
-                       bps = 16;
-                       break;
-               case AHIST_M32S:
-               case AHIST_S32S:
-               case AHIST_L7_1:
-                       bps = 24;
-                       break;
-               default:
-                       return 0;
-               }
-               ds->bitspersample = bps;
-               ds->ch = ch;
-               ds->bytespersample = bps / 8;
-               if (ds->al_buffer[0] == -1) {
-                       alClear ();
-                       alGenBuffers (2, ds->al_buffer);
-                       if (alError (L"AHI: alGenBuffers"))
-                               return AHIE_NOMEM;
-                       if (ahi_debug > 1)
-                               write_log (L"AHI:LoadSound:allocated OpenAL buffer\n");
-               }
-               return AHIE_OK;
+       case AHIST_M8S:
+       case AHIST_M16S:
+       case AHIST_M32S:
+               ch = 1;
+               break;
+       case AHIST_S8S:
+       case AHIST_S16S:
+       case AHIST_S32S:
+               ch = 2;
+               break;
+       case AHIST_L7_1:
+               ch = 8;
+               break;
+       default:
+               return 0;
        }
-
-       static uae_u32 AHIsub_UnloadSound (TrapContext *ctx)
+       switch (sampletype)
        {
-               uae_u16 sound = m68k_dreg (regs, 0);
-               uae_u32 audioctrl = m68k_areg (regs, 2);
-               struct DSAHI *dsahip = GETAHI;
-               struct dssample *ds = GETSAMPLE;
-
+       case AHIST_M8S:
+       case AHIST_S8S:
+               bps = 8;
+               break;
+       case AHIST_M16S:
+       case AHIST_S16S:
+               bps = 16;
+               break;
+       case AHIST_M32S:
+       case AHIST_S32S:
+       case AHIST_L7_1:
+               bps = 24;
+               break;
+       default:
+               return 0;
+       }
+       ds->bitspersample = bps;
+       ds->ch = ch;
+       ds->bytespersample = bps / 8;
+       if (ds->al_buffer[0] == -1) {
+               alClear ();
+               alGenBuffers (2, ds->al_buffer);
+               if (alError (L"AHI: alGenBuffers"))
+                       return AHIE_NOMEM;
                if (ahi_debug > 1)
-                       write_log (L"AHI: UnloadSound(%d,%08x)\n",
-                       sound, audioctrl);
-               ds->num = -1;
-               return AHIE_OK;
+                       write_log (L"AHI:LoadSound:allocated OpenAL buffer\n");
        }
+       return AHIE_OK;
+}
 
-       static uae_u32 REGPARAM2 ahi_demux (TrapContext *ctx)
-       {
-               uae_u32 ret = 0;
-               uae_u32 sp = m68k_areg (regs, 7);
-               uae_u32 offset = get_long (sp + 4);
-
-               if (0 && ahi_debug)
-                       write_log (L"AHI: %d\n", offset);
+static uae_u32 AHIsub_UnloadSound (TrapContext *ctx)
+{
+       uae_u16 sound = m68k_dreg (regs, 0);
+       uae_u32 audioctrl = m68k_areg (regs, 2);
+       struct DSAHI *dsahip = GETAHI;
+       struct dssample *ds = GETSAMPLE;
+
+       if (ahi_debug > 1)
+               write_log (L"AHI: UnloadSound(%d,%08x)\n",
+               sound, audioctrl);
+       ds->num = -1;
+       return AHIE_OK;
+}
+
+static uae_u32 REGPARAM2 ahi_demux (TrapContext *ctx)
+{
+       uae_u32 ret = 0;
+       uae_u32 sp = m68k_areg (regs, 7);
+       uae_u32 offset = get_long (sp + 4);
 
-               switch (offset)
-               {
-               case 0xffffffff:
-                       ret = init (ctx);
-                       break;
-               case 0:
-                       ret = AHIsub_AllocAudio (ctx);
-                       break;
-               case 1:
-                       AHIsub_FreeAudio (ctx);
-                       break;
-               case 2:
-                       AHIsub_Disable (ctx);
-                       break;
-               case 3:
-                       AHIsub_Enable (ctx);
-                       break;
-               case 4:
-                       ret = AHIsub_Start (ctx);
-                       break;
-               case 5:
-                       ret = AHIsub_Update (ctx);
-                       break;
-               case 6:
-                       ret = AHIsub_Stop (ctx);
-                       break;
-               case 7:
-                       ret = AHIsub_SetVol (ctx);
-                       break;
-               case 8:
-                       ret = AHIsub_SetFreq (ctx);
-                       break;
-               case 9:
-                       ret = AHIsub_SetSound (ctx);
-                       break;
-               case 10:
-                       ret = AHIsub_SetEffect (ctx);
-                       break;
-               case 11:
-                       ret = AHIsub_LoadSound (ctx);
-                       break;
-               case 12:
-                       ret = AHIsub_UnloadSound (ctx);
-                       break;
-               case 13:
-                       ret = AHIsub_GetAttr (ctx);
-                       break;
-               case 14:
-                       ret = AHIsub_HardwareControl (ctx);
-                       break;
-               }
-               return ret;
-       }
+       if (0 && ahi_debug)
+               write_log (L"AHI: %d\n", offset);
 
-       void init_ahi_v2 (void)
+       switch (offset)
        {
-               uaecptr a = here ();
-               org (rtarea_base + 0xFFC8);
-               calltrap (deftrapres (ahi_demux, 0, L"ahi_v2"));
-               dw (RTS);
-               org (a);
+       case 0xffffffff:
+               ret = init (ctx);
+               break;
+       case 0:
+               ret = AHIsub_AllocAudio (ctx);
+               break;
+       case 1:
+               AHIsub_FreeAudio (ctx);
+               break;
+       case 2:
+               AHIsub_Disable (ctx);
+               break;
+       case 3:
+               AHIsub_Enable (ctx);
+               break;
+       case 4:
+               ret = AHIsub_Start (ctx);
+               break;
+       case 5:
+               ret = AHIsub_Update (ctx);
+               break;
+       case 6:
+               ret = AHIsub_Stop (ctx);
+               break;
+       case 7:
+               ret = AHIsub_SetVol (ctx);
+               break;
+       case 8:
+               ret = AHIsub_SetFreq (ctx);
+               break;
+       case 9:
+               ret = AHIsub_SetSound (ctx);
+               break;
+       case 10:
+               ret = AHIsub_SetEffect (ctx);
+               break;
+       case 11:
+               ret = AHIsub_LoadSound (ctx);
+               break;
+       case 12:
+               ret = AHIsub_UnloadSound (ctx);
+               break;
+       case 13:
+               ret = AHIsub_GetAttr (ctx);
+               break;
+       case 14:
+               ret = AHIsub_HardwareControl (ctx);
+               break;
        }
+       return ret;
+}
 
-       void free_ahi_v2 (void)
-       {
-               ds_free_record (&dsahi[0]);
-               ds_free (&dsahi[0]);
-       }
+void init_ahi_v2 (void)
+{
+       uaecptr a = here ();
+       org (rtarea_base + 0xFFC8);
+       calltrap (deftrapres (ahi_demux, 0, L"ahi_v2"));
+       dw (RTS);
+       org (a);
+}
+
+void free_ahi_v2 (void)
+{
+       ds_free_record (&dsahi[0]);
+       ds_free (&dsahi[0]);
+}
 
 #endif
index 1450a81738e92c98a20ea0cf74a6a8c2a34d7967..6dcc125527f69726d204600868150b711a9cee3d 100644 (file)
@@ -25,7 +25,7 @@ extern int D3DEX, d3ddebug;
 #include "direct3d.h"
 
 static TCHAR *D3DHEAD = L"-";
-static int psEnabled, psActive, psPreProcess;
+static int psEnabled, psActive, psPreProcess, shaderon;
 
 static D3DFORMAT tformat;
 static int d3d_enabled, d3d_ex;
@@ -47,6 +47,7 @@ static HWND d3dhwnd;
 static int devicelost;
 static int locked;
 static int cursor_offset_x, cursor_offset_y;
+static float maskmult_x, maskmult_y;
 
 static D3DXMATRIX m_matProj, m_matProj2;
 static D3DXMATRIX m_matWorld, m_matWorld2;
@@ -55,7 +56,7 @@ static D3DXMATRIX m_matPreProj;
 static D3DXMATRIX m_matPreView;
 static D3DXMATRIX m_matPreWorld;
 static D3DXMATRIX postproj;
-static D3DXVECTOR4 maskmult;
+static D3DXVECTOR4 maskmult, maskshift;
 
 static int ledwidth, ledheight;
 static int twidth, theight, max_texture_w, max_texture_h;
@@ -189,7 +190,7 @@ static D3DXHANDLE postSourceTextureHandle;
 static D3DXHANDLE postMaskTextureHandle;
 static D3DXHANDLE postTechnique, postTechniquePlain, postTechniqueAlpha;
 static D3DXHANDLE postMatrixSource;
-static D3DXHANDLE postMaskMult;
+static D3DXHANDLE postMaskMult, postMaskShift;
 static D3DXHANDLE postFilterMode;
 
 static LPD3DXEFFECT pEffect;
@@ -225,7 +226,12 @@ static int postEffect_ParseParameters (LPD3DXEFFECTCOMPILER EffectCompiler, LPD3
        postTechniqueAlpha = effect->GetTechniqueByName ("PostTechniqueAlpha");
        postMatrixSource = effect->GetParameterByName (NULL, "mtx");
        postMaskMult = effect->GetParameterByName (NULL, "maskmult");
+       postMaskShift = effect->GetParameterByName (NULL, "maskshift");
        postFilterMode = effect->GetParameterByName (NULL, "filtermode");
+       if (!postMaskShift || !postMaskMult || !postFilterMode || !postMatrixSource) {
+               gui_message (L"Mismatched _winuae.fx! Exiting..");
+               abort ();
+       }
        return true;
 }
 
@@ -395,15 +401,13 @@ static int psEffect_ParseParameters (LPD3DXEFFECTCOMPILER EffectCompiler, LPD3DX
 static int psEffect_hasPreProcess (void) { return m_PreprocessTechnique1EffectHandle != 0; }
 static int psEffect_hasPreProcess2 (void) { return m_PreprocessTechnique2EffectHandle != 0; }
 
-static int d3d_yesno = 0;
-
 int D3D_goodenough (void)
 {
        static int d3d_good;
        LPDIRECT3D9 d3dx;
        D3DCAPS9 d3dCaps;
 
-       if (d3d_yesno > 0 || d3d_good > 0)
+       if (d3d_good > 0)
                return 1;
        if (d3d_good < 0)
                return 0;
@@ -415,6 +419,7 @@ int D3D_goodenough (void)
                                if ((d3dCaps.TextureCaps & (D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_NONPOW2CONDITIONAL)) != D3DPTEXTURECAPS_POW2) {
                                        if (!(d3dCaps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) && (d3dCaps.Caps2 & D3DCAPS2_DYNAMICTEXTURES)) {
                                                d3d_good = 1;
+                                               shaderon = 1;
                                        }
                                }
                        }
@@ -426,6 +431,7 @@ int D3D_goodenough (void)
 
 int D3D_canshaders (void)
 {
+       static int d3d_yesno = 0;
        HMODULE h;
        LPDIRECT3D9 d3dx;
        D3DCAPS9 d3dCaps;
@@ -832,6 +838,8 @@ static int createsltexture (void)
        if (!sltexture)
                return 0;
        write_log (L"%s: SL %d*%d texture allocated\n", D3DHEAD, required_sl_texture_w, required_sl_texture_h);
+       maskmult_x = 1.0;
+       maskmult_y = 1.0;
        return 1;
 }
 
@@ -842,7 +850,7 @@ static int createmasktexture (TCHAR *filename)
        struct zfile *zf;
        int size;
        uae_u8 *buf;
-       D3DSURFACE_DESC maskdesc;
+       D3DSURFACE_DESC maskdesc, txdesc;
        LPDIRECT3DTEXTURE9 tx;
        HRESULT hr;
        D3DLOCKED_RECT lock, slock;
@@ -873,53 +881,62 @@ static int createmasktexture (TCHAR *filename)
                write_log (L"%s: temp mask texture load failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
                goto end;
        }
-       masktexture_w = dinfo.Width;
-       masktexture_h = dinfo.Height;
-#if 0
-       masktexture = tx;
-#else
-       masktexture = createtext (ww, hh, D3DFMT_X8R8G8B8);
+       hr = tx->GetLevelDesc (0, &txdesc);
        if (FAILED (hr)) {
-               write_log (L"%s: mask texture creation failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+               write_log (L"%s: mask image texture GetLevelDesc() failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
                goto end;
        }
-       hr = masktexture->GetLevelDesc (0, &maskdesc);
-       if (FAILED (hr)) {
-               write_log (L"%s: mask texture GetLevelDesc() failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
-               goto end;
-       }
-       if (SUCCEEDED (hr = masktexture->LockRect (0, &lock, NULL, 0))) {
-               if (SUCCEEDED (hr = tx->LockRect (0, &slock, NULL, 0))) {
-                       int x, y, sx, sy;
-                       uae_u32 *sptr, *ptr;
-                       sy = 0;
-                       for (y = 0; y < maskdesc.Height; y++) {
-                               sx = 0;
-                               for (x = 0; x < maskdesc.Width; x++) {
-                                       uae_u32 v;
-                                       sptr = (uae_u32*)((uae_u8*)slock.pBits + sy * slock.Pitch + sx * 4);
-                                       ptr = (uae_u32*)((uae_u8*)lock.pBits + y * lock.Pitch + x * 4);
-                                       v = *sptr;
-//                                     v &= 0x00FFFFFF;
-//                                     v |= 0x80000000;
-                                       *ptr = v;
-                                       sx++;
-                                       if (sx >= dinfo.Width)
-                                               sx = 0;
+       masktexture_w = dinfo.Width;
+       masktexture_h = dinfo.Height;
+       if (txdesc.Width == masktexture_w && txdesc.Height == masktexture_h && psEnabled) {
+               // texture size == image size, no need to tile it (Wrap sampler does the rest)
+               masktexture = tx;
+               tx = NULL;
+       } else {
+               masktexture = createtext (ww, hh, D3DFMT_X8R8G8B8);
+               if (FAILED (hr)) {
+                       write_log (L"%s: mask texture creation failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+                       goto end;
+               }
+               hr = masktexture->GetLevelDesc (0, &maskdesc);
+               if (FAILED (hr)) {
+                       write_log (L"%s: mask texture GetLevelDesc() failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+                       goto end;
+               }
+               if (SUCCEEDED (hr = masktexture->LockRect (0, &lock, NULL, 0))) {
+                       if (SUCCEEDED (hr = tx->LockRect (0, &slock, NULL, 0))) {
+                               int x, y, sx, sy;
+                               uae_u32 *sptr, *ptr;
+                               sy = 0;
+                               for (y = 0; y < maskdesc.Height; y++) {
+                                       sx = 0;
+                                       for (x = 0; x < maskdesc.Width; x++) {
+                                               uae_u32 v;
+                                               sptr = (uae_u32*)((uae_u8*)slock.pBits + sy * slock.Pitch + sx * 4);
+                                               ptr = (uae_u32*)((uae_u8*)lock.pBits + y * lock.Pitch + x * 4);
+                                               v = *sptr;
+       //                                      v &= 0x00FFFFFF;
+       //                                      v |= 0x80000000;
+                                               *ptr = v;
+                                               sx++;
+                                               if (sx >= dinfo.Width)
+                                                       sx = 0;
+                                       }
+                                       sy++;
+                                       if (sy >= dinfo.Height)
+                                               sy = 0;
                                }
-                               sy++;
-                               if (sy >= dinfo.Height)
-                                       sy = 0;
+                               tx->UnlockRect (0);
                        }
-                       tx->UnlockRect (0);
+                       masktexture->UnlockRect (0);
                }
-               masktexture->UnlockRect (0);
+               tx->Release ();
+               masktexture_w = maskdesc.Width;
+               masktexture_h = maskdesc.Height;
        }
-       tx->Release ();
-       masktexture_w = maskdesc.Width;
-       masktexture_h = maskdesc.Height;
-#endif
-       write_log (L"%s: mask %d*%d ('%s') texture allocated\n", D3DHEAD, masktexture_w, masktexture_h, filename);
+       write_log (L"%s: mask %d*%d (%d*%d) ('%s') texture allocated\n", D3DHEAD, masktexture_w, masktexture_h, txdesc.Width, txdesc.Height, filename);
+       maskmult_x = (float)ww / masktexture_w;
+       maskmult_y = (float)hh / masktexture_h;
 
        return 1;
 end:
@@ -967,17 +984,19 @@ static void setupscenecoords (void)
                +0.5f + dh * tin_h / window_h / 2 - zr.top - (tin_h - 2 * zr.top - h) + sr.top, // <- ???
                0);
 
-       float sw = dw * tin_w / window_w + 0.5;
-       float sh = dh * tin_h / window_h + 0.5;
+       float sw = dw * tin_w / window_w + 0.5f;
+       float sh = dh * tin_h / window_h + 0.5f;
        MatrixScaling (&m_matWorld,
                sw,
                sh,
                1.0f);
 
        // ratio between Amiga texture and overlay texture
-       maskmult.x = sw / w;
-       maskmult.y = sh / h;
-       maskmult.z = maskmult.w = 0;
+       maskmult.x = sw * maskmult_x / w;
+       maskmult.y = sh * maskmult_y / h;
+
+       maskshift.x = 1.0f / maskmult_x;
+       maskshift.y = 1.0f / maskmult_y;
 
        D3DXMATRIX tmp;
        D3DXMatrixMultiply (&tmp, &m_matWorld, &m_matView);
@@ -1199,19 +1218,27 @@ static int restoredeviceobjects (void)
        HRESULT hr;
 
        invalidatedeviceobjects ();
-       postEffect = psEffect_LoadEffect (psEnabled ? L"winuae.fx" : L"winuae_old.fx", false);
-       if (!postEffect)
-               return 0;
-       if (currprefs.gfx_filtershader[0]) {
-               if (!(pEffect = psEffect_LoadEffect (currprefs.gfx_filtershader, true)))
-                       currprefs.gfx_filtershader[0] = changed_prefs.gfx_filtershader[0] = 0;
+       while (shaderon) {
+               postEffect = psEffect_LoadEffect (psEnabled ? L"_winuae.fx" : L"_winuae_old.fx", false);
+               if (!postEffect) {
+                       shaderon = 0;
+                       break;
+               }
+               if (currprefs.gfx_filtershader[0]) {
+                       if (!(pEffect = psEffect_LoadEffect (currprefs.gfx_filtershader, true))) {
+                               currprefs.gfx_filtershader[0] = changed_prefs.gfx_filtershader[0] = 0;
+                               shaderon = 0;
+                               break;
+                       }
+               }
+               if (currprefs.gfx_filter_scanlines > 0)
+                       createsltexture ();
+               createmasktexture (currprefs.gfx_filtermask);
+               break;
        }
        if (!createtexture (tin_w, tin_h))
                return 0;
-       if (currprefs.gfx_filter_scanlines > 0)
-               createsltexture ();
        createledtexture ();
-       createmasktexture (currprefs.gfx_filtermask);
 
        hr = D3DXCreateSprite (d3ddev, &sprite);
        if (FAILED (hr)) {
@@ -1283,12 +1310,6 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth
        LPDIRECT3DCREATE9EX d3dexp = NULL;
 
        D3D_free2 ();
-       if (D3D_goodenough () <= 0) {
-               _tcscpy (errmsg, L"Direct3D: Pixel and Vertex shader 1.0 or newer support required");
-               return errmsg;
-       }
-
-       D3D_canshaders ();
        d3d_enabled = 0;
        if (!currprefs.gfx_api) {
                _tcscpy (errmsg, L"D3D: not enabled");
@@ -1304,6 +1325,9 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth
        }
        FreeLibrary (d3dx);
 
+       D3D_goodenough ();
+       D3D_canshaders ();
+
        d3d_ex = FALSE;
        d3dDLL = LoadLibrary (L"D3D9.DLL");
        if (d3dDLL == NULL) {
@@ -1455,11 +1479,13 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth
                t_depth
                );
 
-       if ((d3dCaps.PixelShaderVersion < D3DPS_VERSION(3,0) || d3dCaps.VertexShaderVersion < D3DVS_VERSION(3,0) || !psEnabled || max_texture_w < 4096 || max_texture_h < 4096) && d3d_ex) {
+       if ((d3dCaps.PixelShaderVersion < D3DPS_VERSION(3,0) || d3dCaps.VertexShaderVersion < D3DVS_VERSION(3,0) || !psEnabled || max_texture_w < 4096 || max_texture_h < 4096 || !shaderon) && d3d_ex) {
                D3DEX = 0;
                write_log (L"Disabling D3D9Ex\n");
                return D3D_init (ahwnd, w_w, w_h, t_w, t_h, depth);
        }
+       if (!shaderon)
+               write_log (L"Using non-shader version\n");
 
        mult = S2X_getmult ();
        t_w *= mult;
@@ -1487,9 +1513,11 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth
                        tformat = D3DFMT_A8R8G8B8;
                break;
                case 15:
-               case 16:
                        tformat = D3DFMT_A1R5G5B5;
                break;
+               case 16:
+                       tformat = D3DFMT_R5G6B5;
+               break;
        }
        window_w = w_w;
        window_h = w_h;
@@ -1602,121 +1630,145 @@ static void D3D_render22 (void)
                write_log (L"%s: BeginScene: %s\n", D3DHEAD, D3D_ErrorString (hr));
                return;
        }
-       if (psActive) {
-               LPDIRECT3DSURFACE9 lpRenderTarget;
-               LPDIRECT3DSURFACE9 lpNewRenderTarget;
-               LPDIRECT3DTEXTURE9 lpWorkTexture;
-
-               settransform ();
-               if (!psEffect_SetTextures (texture, lpWorkTexture1, lpWorkTexture2, lpHq2xLookupTexture))
-                       return;
-               if (psPreProcess) {
-                       if (!psEffect_SetMatrices (&m_matPreProj, &m_matPreView, &m_matPreWorld))
+       if (shaderon) {
+               if (psActive) {
+                       LPDIRECT3DSURFACE9 lpRenderTarget;
+                       LPDIRECT3DSURFACE9 lpNewRenderTarget;
+                       LPDIRECT3DTEXTURE9 lpWorkTexture;
+
+                       settransform ();
+                       if (!psEffect_SetTextures (texture, lpWorkTexture1, lpWorkTexture2, lpHq2xLookupTexture))
                                return;
+                       if (psPreProcess) {
+                               if (!psEffect_SetMatrices (&m_matPreProj, &m_matPreView, &m_matPreWorld))
+                                       return;
+
+                               if (FAILED (hr = d3ddev->GetRenderTarget (0, &lpRenderTarget)))
+                                       write_log (L"%s: GetRenderTarget: %s\n", D3DHEAD, D3D_ErrorString (hr));
+                               lpWorkTexture = lpWorkTexture1;
+                               lpNewRenderTarget = NULL;
+       pass2:
+                               if (FAILED (hr = lpWorkTexture->GetSurfaceLevel (0, &lpNewRenderTarget)))
+                                       write_log (L"%s: GetSurfaceLevel: %s\n", D3DHEAD, D3D_ErrorString (hr));
+                               if (FAILED (hr = d3ddev->SetRenderTarget (0, lpNewRenderTarget)))
+                                       write_log (L"%s: SetRenderTarget: %s\n", D3DHEAD, D3D_ErrorString (hr));
+
+                               uPasses = 0;
+                               if (psEffect_Begin (pEffect, (lpWorkTexture == lpWorkTexture1) ? psEffect_PreProcess1 : psEffect_PreProcess2, &uPasses)) {
+                                       for (uPass = 0; uPass < uPasses; uPass++) {
+                                               if (psEffect_BeginPass (pEffect, uPass)) {
+                                                       if (FAILED (hr = d3ddev->DrawPrimitive (D3DPT_TRIANGLESTRIP, 4, 2))) {
+                                                               write_log (L"%s: Effect DrawPrimitive failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+                                                       }
+                                                       psEffect_EndPass (pEffect);
+                                               }
+                                       }
+                                       psEffect_End (pEffect);
+                               }
+                               if (psEffect_hasPreProcess2 () && lpWorkTexture == lpWorkTexture1) {
+                                       lpWorkTexture = lpWorkTexture2;
+                                       lpNewRenderTarget->Release ();
+                                       lpNewRenderTarget = NULL;
+                                       goto pass2;
+                               }
+                               if (FAILED (hr = d3ddev->SetRenderTarget (0, lpRenderTarget)))
+                                       write_log (L"%s: Effect RenderTarget reset failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+                               lpRenderTarget->Release ();
+                               lpRenderTarget = NULL;
+                               lpNewRenderTarget->Release ();
+                               lpNewRenderTarget = NULL;
+                       }
+                       psEffect_SetMatrices (&m_matProj2, &m_matView2, &m_matWorld2);
 
                        if (FAILED (hr = d3ddev->GetRenderTarget (0, &lpRenderTarget)))
                                write_log (L"%s: GetRenderTarget: %s\n", D3DHEAD, D3D_ErrorString (hr));
-                       lpWorkTexture = lpWorkTexture1;
-                       lpNewRenderTarget = NULL;
-pass2:
-                       if (FAILED (hr = lpWorkTexture->GetSurfaceLevel (0, &lpNewRenderTarget)))
+                       if (FAILED (hr = lpTempTexture->GetSurfaceLevel (0, &lpNewRenderTarget)))
                                write_log (L"%s: GetSurfaceLevel: %s\n", D3DHEAD, D3D_ErrorString (hr));
                        if (FAILED (hr = d3ddev->SetRenderTarget (0, lpNewRenderTarget)))
                                write_log (L"%s: SetRenderTarget: %s\n", D3DHEAD, D3D_ErrorString (hr));
+                       hr = d3ddev->Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, d3ddebug ? 0x80 : 0), 0, 0);
 
                        uPasses = 0;
-                       if (psEffect_Begin (pEffect, (lpWorkTexture == lpWorkTexture1) ? psEffect_PreProcess1 : psEffect_PreProcess2, &uPasses)) {
+                       if (psEffect_Begin (pEffect, psEffect_Combine, &uPasses)) {
                                for (uPass = 0; uPass < uPasses; uPass++) {
-                                       if (psEffect_BeginPass (pEffect, uPass)) {
-                                               if (FAILED (hr = d3ddev->DrawPrimitive (D3DPT_TRIANGLESTRIP, 4, 2))) {
-                                                       write_log (L"%s: Effect DrawPrimitive failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
-                                               }
-                                               psEffect_EndPass (pEffect);
-                                       }
+                                       if (!psEffect_BeginPass (pEffect, uPass))
+                                               return;
+                                       if (FAILED (hr = d3ddev->DrawPrimitive (D3DPT_TRIANGLESTRIP, 0, 2)))
+                                               write_log (L"%s: Effect2 DrawPrimitive failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+                                       psEffect_EndPass (pEffect);
                                }
                                psEffect_End (pEffect);
                        }
-                       if (psEffect_hasPreProcess2 () && lpWorkTexture == lpWorkTexture1) {
-                               lpWorkTexture = lpWorkTexture2;
-                               lpNewRenderTarget->Release ();
-                               lpNewRenderTarget = NULL;
-                               goto pass2;
-                       }
+
                        if (FAILED (hr = d3ddev->SetRenderTarget (0, lpRenderTarget)))
-                               write_log (L"%s: Effect RenderTarget reset failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
-                       lpRenderTarget->Release ();
-                       lpRenderTarget = NULL;
+                               write_log (L"%s: SetRenderTarget: %s\n", D3DHEAD, D3D_ErrorString (hr));
                        lpNewRenderTarget->Release ();
-                       lpNewRenderTarget = NULL;
+                       lpRenderTarget->Release ();
+                       srctex = lpTempTexture;
+
+               } else {
+
+                       srctex = texture;
+
+               }
+
+               if (masktexture) {
+                       if (FAILED (hr = postEffect->SetTechnique (postTechnique)))
+                               write_log (L"%s: SetTechnique(postTechnique) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+                       if (FAILED (hr = postEffect->SetTexture (postMaskTextureHandle, masktexture)))
+                               write_log (L"%s: SetTexture(masktexture) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+               } else if (sltexture) {
+                       if (FAILED (hr = postEffect->SetTechnique (postTechniqueAlpha)))
+                               write_log (L"%s: SetTechnique(postTechniqueAlpha) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+                       if (FAILED (hr = postEffect->SetTexture (postMaskTextureHandle, sltexture)))
+                               write_log (L"%s: SetTexture(sltexture) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+               } else {
+                       if (FAILED (hr = postEffect->SetTechnique (postTechniquePlain)))
+                               write_log (L"%s: SetTechnique(postTechniquePlain) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
                }
-               psEffect_SetMatrices (&m_matProj2, &m_matView2, &m_matWorld2);
+               hr = postEffect->SetInt (postFilterMode, currprefs.gfx_filter_bilinear ? D3DTEXF_LINEAR : D3DTEXF_POINT);
 
-               if (FAILED (hr = d3ddev->GetRenderTarget (0, &lpRenderTarget)))
-                       write_log (L"%s: GetRenderTarget: %s\n", D3DHEAD, D3D_ErrorString (hr));
-               if (FAILED (hr = lpTempTexture->GetSurfaceLevel (0, &lpNewRenderTarget)))
-                       write_log (L"%s: GetSurfaceLevel: %s\n", D3DHEAD, D3D_ErrorString (hr));
-               if (FAILED (hr = d3ddev->SetRenderTarget (0, lpNewRenderTarget)))
-                       write_log (L"%s: SetRenderTarget: %s\n", D3DHEAD, D3D_ErrorString (hr));
-               hr = d3ddev->Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, d3ddebug ? 0x80 : 0), 0, 0);
+               if (FAILED (hr = postEffect->SetTexture (postSourceTextureHandle, srctex)))
+                       write_log (L"%s: SetTexture(srctex) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+               setupscenecoords ();
+               hr = postEffect->SetMatrix (postMatrixSource, &postproj);
+               hr = postEffect->SetVector (postMaskMult, &maskmult);
+               hr = postEffect->SetVector (postMaskShift, &maskshift);
 
                uPasses = 0;
-               if (psEffect_Begin (pEffect, psEffect_Combine, &uPasses)) {
+               if (psEffect_Begin (postEffect, psEffect_None, &uPasses)) {
                        for (uPass = 0; uPass < uPasses; uPass++) {
-                               if (!psEffect_BeginPass (pEffect, uPass))
-                                       return;
-                               if (FAILED (hr = d3ddev->DrawPrimitive (D3DPT_TRIANGLESTRIP, 0, 2)))
-                                       write_log (L"%s: Effect2 DrawPrimitive failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
-                               psEffect_EndPass (pEffect);
+                               if (psEffect_BeginPass (postEffect, uPass)) {
+                                       if (FAILED (hr = d3ddev->DrawPrimitive (D3DPT_TRIANGLESTRIP, 0, 2)))
+                                               write_log (L"%s: Post DrawPrimitive failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
+                                       psEffect_EndPass (postEffect);
+                               }
                        }
-                       psEffect_End (pEffect);
+                       psEffect_End (postEffect);
                }
 
-               if (FAILED (hr = d3ddev->SetRenderTarget (0, lpRenderTarget)))
-                       write_log (L"%s: SetRenderTarget: %s\n", D3DHEAD, D3D_ErrorString (hr));
-               lpNewRenderTarget->Release ();
-               lpRenderTarget->Release ();
-               srctex = lpTempTexture;
-
-       } else {
-
-               srctex = texture;
-
-       }
-
-       if (masktexture) {
-               if (FAILED (hr = postEffect->SetTechnique (postTechnique)))
-                       write_log (L"%s: SetTechnique(postTechnique) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
-               if (FAILED (hr = postEffect->SetTexture (postMaskTextureHandle, masktexture)))
-                       write_log (L"%s: SetTexture(masktexture) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
-       } else if (sltexture) {
-               if (FAILED (hr = postEffect->SetTechnique (postTechniqueAlpha)))
-                       write_log (L"%s: SetTechnique(postTechniqueAlpha) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
-               if (FAILED (hr = postEffect->SetTexture (postMaskTextureHandle, sltexture)))
-                       write_log (L"%s: SetTexture(sltexture) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
        } else {
-               if (FAILED (hr = postEffect->SetTechnique (postTechniquePlain)))
-                       write_log (L"%s: SetTechnique(postTechniquePlain) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
-       }
-       hr = postEffect->SetInt (postFilterMode, currprefs.gfx_filter_bilinear ? D3DTEXF_LINEAR : D3DTEXF_POINT);
 
-       if (FAILED (hr = postEffect->SetTexture (postSourceTextureHandle, srctex)))
-               write_log (L"%s: SetTexture(srctex) failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
-       setupscenecoords ();
-       hr = postEffect->SetMatrix (postMatrixSource, &postproj);
-       hr = postEffect->SetVector (postMaskMult, &maskmult);
-
-       uPasses = 0;
-       if (psEffect_Begin (postEffect, psEffect_None, &uPasses)) {
-               for (uPass = 0; uPass < uPasses; uPass++) {
-                       if (psEffect_BeginPass (postEffect, uPass)) {
-                               if (FAILED (hr = d3ddev->DrawPrimitive (D3DPT_TRIANGLESTRIP, 0, 2)))
-                                       write_log (L"%s: Post DrawPrimitive failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
-                               psEffect_EndPass (postEffect);
+               // non-shader version
+               hr = d3ddev->SetTransform (D3DTS_PROJECTION, &m_matProj);
+               hr = d3ddev->SetTransform (D3DTS_VIEW, &m_matView);
+               hr = d3ddev->SetTransform (D3DTS_WORLD, &m_matWorld);
+               hr = d3ddev->SetTexture (0, texture);
+               hr = d3ddev->DrawPrimitive (D3DPT_TRIANGLESTRIP, 0, 2);
+               int bl = currprefs.gfx_filter_bilinear ? D3DTEXF_LINEAR : D3DTEXF_POINT;
+               hr = d3ddev->SetSamplerState (0, D3DSAMP_MINFILTER, bl);
+               hr = d3ddev->SetSamplerState (0, D3DSAMP_MAGFILTER, bl);
+
+               if (sprite && sltexture) {
+                       D3DXVECTOR3 v;
+                       sprite->Begin (D3DXSPRITE_ALPHABLEND);
+                       if (sltexture) {
+                               v.x = v.y = v.z = 0;
+                               sprite->Draw (sltexture, NULL, NULL, &v, 0xffffffff);
                        }
+                       sprite->End ();
                }
-               psEffect_End (postEffect);
        }
-
        if (sprite && ((ledtexture) || (cursorsurfaced3d && cursor_v))) {
                D3DXVECTOR3 v;
                sprite->Begin (D3DXSPRITE_ALPHABLEND);
@@ -1741,6 +1793,7 @@ pass2:
                sprite->End ();
        }
 
+
        hr = d3ddev->EndScene ();
        if (FAILED (hr))
                write_log (L"%s: EndScene() %s\n", D3DHEAD, D3D_ErrorString (hr));
@@ -1843,7 +1896,6 @@ void D3D_getpixelformat (int depth, int *rb, int *gb, int *bb, int *rs, int *gs,
                *a = 255;
                break;
        case 15:
-       case 16:
                *rb = 5;
                *gb = 5;
                *bb = 5;
@@ -1852,7 +1904,18 @@ void D3D_getpixelformat (int depth, int *rb, int *gb, int *bb, int *rs, int *gs,
                *gs = 5;
                *bs = 0;
                *as = 15;
-               *a = 1;
+               *a = 0;
+       break;
+       case 16:
+               *rb = 5;
+               *gb = 6;
+               *bb = 5;
+               *ab = 1;
+               *rs = 11;
+               *gs = 5;
+               *bs = 0;
+               *as = 0;
+               *a = 0;
                break;
        }
 }
index ac210cfed4a447b5923e5ffe24f1b59d76095d65..90c05fed4bff3f9327358d6a16fbe64e5b8d7c91 100644 (file)
 */
 
 #define MULTIDISPLAY 0
-#define P96DX 0
 #define WINCURSOR 1
 
 #include "sysconfig.h"
 #include "sysdeps.h"
 
+#if defined(PICASSO96)
+
 #include "options.h"
 #include "threaddep/thread.h"
 #include "memory.h"
@@ -50,9 +51,7 @@
 #include "native2amiga.h"
 #include "drawing.h"
 #include "inputdevice.h"
-
-#if defined(PICASSO96)
-
+#include "debug.h"
 #include "registry.h"
 #include "dxwrap.h"
 #include "rp.h"
@@ -124,21 +123,16 @@ static struct ScreenResolution alphacolour = { 640, 480 };
 uae_u32 p96_rgbx16[65536];
 uae_u32 p96rc[256], p96gc[256], p96bc[256];
 
-#if P96DX > 0
-static LPDIRECTDRAWSURFACE7 p96surface;
-#endif
 static int cursorwidth, cursorheight, cursorok;
+static uae_u8 *cursordata;
 static uae_u32 cursorrgb[4], cursorrgbn[4];
 static int cursorvisible, cursordeactivate;
 static HCURSOR wincursor;
 static int wincursor_shown;
-static uaecptr boardinfo;
+static uaecptr boardinfo, ABI_interrupt;
 static int interrupt_enabled;
 int p96vblank;
 
-static uae_sem_t sem;
-static int thread_alive;
-
 static uaecptr uaegfx_resname,
        uaegfx_resid,
        uaegfx_init,
@@ -162,7 +156,7 @@ typedef enum {
        BLIT_NOTONLYDST,
        BLIT_OR,
        BLIT_TRUE,
-       BLIT_LAST
+       BLIT_SWAP = 30
 } BLIT_OPCODE;
 
 #include "win32gui.h"
@@ -182,7 +176,7 @@ static void checkrtglibrary(void)
        while ((v = get_long (v))) {
                uae_u32 v2 = get_long (v + 10); // name
                uae_u8 *p;
-               addrbank *b = &get_mem_bank(v2);
+               addrbank *b = &get_mem_bank (v2);
                if (!b || !b->check (v2, 12))
                        continue;
                p = b->xlateaddr(v2);
@@ -207,7 +201,7 @@ static int set_gc_called = 0, init_picasso_screen_called = 0;
 static uaecptr oldscr = 0;
 
 
-static void endianswap (uae_u32 *vp, int bpp)
+STATIC_INLINE void endianswap (uae_u32 *vp, int bpp)
 {
        uae_u32 v = *vp;
        switch (bpp)
@@ -581,6 +575,8 @@ static void disablemouse (void)
 {
        cursorok = FALSE;
        cursordeactivate = 0;
+       if (!hwsprite)
+               return;
        if (!currprefs.gfx_api)
                return;
        D3D_setcursor (0, 0, 0);
@@ -594,6 +590,8 @@ static void mouseupdate (void)
        int y = newcursor_y;
        int forced = 0;
 
+       if (!hwsprite)
+               return;
        if (cursordeactivate > 0) {
                cursordeactivate--;
                if (cursordeactivate == 0) {
@@ -618,10 +616,9 @@ static int doskip (void)
 
 static void picasso_trigger_vblank (void)
 {
-       if (!boardinfo || !uaegfx_base || !interrupt_enabled || currprefs.win32_rtgvblankrate < -1) {
+       if (!ABI_interrupt || !uaegfx_base || !interrupt_enabled || currprefs.win32_rtgvblankrate < -1)
                return;
-       }
-       put_long (uaegfx_base + CARD_IRQPTR, boardinfo + PSSO_BoardInfo_SoftInterrupt);
+       put_long (uaegfx_base + CARD_IRQPTR, ABI_interrupt + PSSO_BoardInfo_SoftInterrupt);
        put_byte (uaegfx_base + CARD_IRQFLAG, 1);
        if (currprefs.win32_rtgvblankrate != 0)
                INTREQ (0x8000 | 0x0008);
@@ -714,6 +711,27 @@ typedef enum {
        RGBFB_CLUT_8
 };
 
+static void setupcursor (void)
+{
+       uae_u8 *dptr = NULL;
+       int bpp = 4;
+       DWORD pitch;
+       D3DLOCKED_RECT locked;
+
+       if (cursorsurfaced3d == NULL)
+               return;
+       if (SUCCEEDED (cursorsurfaced3d->LockRect (0, &locked, NULL, 0))) {
+               dptr = (uae_u8*)locked.pBits;
+               pitch = locked.Pitch;
+               for (int y = 0; y < cursorheight; y++) {
+                       uae_u8 *p1 = cursordata + cursorwidth * bpp * y;
+                       uae_u8 *p2 = dptr + pitch * y;
+                       memcpy (p2, p1, cursorwidth * bpp);
+               }
+               cursorsurfaced3d->UnlockRect (0);
+       }
+}
+
 static uae_u32 setspriteimage (uaecptr bi);
 static void recursor (void)
 {
@@ -815,12 +833,16 @@ static void setconvert (void)
                break;
        }
        picasso_convert = v;
-       host_mode = DirectDraw_GetSurfacePixelFormat (NULL);
-       gfx_set_picasso_colors (picasso96_state.RGBFormat);
+       if (currprefs.gfx_api) {
+               host_mode = d == 4 ? RGBFB_B8G8R8A8 : RGBFB_B5G6R5PC;
+       } else {
+               host_mode = DirectDraw_GetSurfacePixelFormat (NULL);
+       }
        if (d == 4)
                alloc_colors_rgb (8, 8, 8, 16, 8, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc);
        else
                alloc_colors_rgb (5, 6, 5, 11, 5, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc);
+       gfx_set_picasso_colors (picasso96_state.RGBFormat);
        if (host_mode != ohost_mode || picasso96_state.RGBFormat != orgbformat) {
                write_log (L"RTG conversion: Depth=%d HostRGBF=%d P96RGBF=%d Mode=%d\n", d, host_mode, picasso96_state.RGBFormat, v);
                ohost_mode = host_mode;
@@ -844,6 +866,7 @@ void picasso_refresh (void)
                return;
        full_refresh = 1;
        setconvert ();
+       setupcursor ();
 
        /* Make sure that the first time we show a Picasso video mode, we don't blit any crap.
        * We can do this by checking if we have an Address yet. 
@@ -920,7 +943,7 @@ void picasso_refresh (void)
 #define BLT_NAME BLIT_TRUE_32
 #define BLT_FUNC(s,d) *d = 0xffffffff
 #include "p96_blit.cpp"
-#define BLT_NAME BLIT_30_32
+#define BLT_NAME BLIT_SWAP_32
 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp;
 #define BLT_TEMP
 #include "p96_blit.cpp"
@@ -971,7 +994,7 @@ void picasso_refresh (void)
 #define BLT_NAME BLIT_TRUE_24
 #define BLT_FUNC(s,d) *d = 0xffffffff
 #include "p96_blit.cpp"
-#define BLT_NAME BLIT_30_24
+#define BLT_NAME BLIT_SWAP_24
 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp;
 #define BLT_TEMP
 #include "p96_blit.cpp"
@@ -1022,7 +1045,7 @@ void picasso_refresh (void)
 #define BLT_NAME BLIT_TRUE_16
 #define BLT_FUNC(s,d) *d = 0xffffffff
 #include "p96_blit.cpp"
-#define BLT_NAME BLIT_30_16
+#define BLT_NAME BLIT_SWAP_16
 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp;
 #define BLT_TEMP
 #include "p96_blit.cpp"
@@ -1073,7 +1096,7 @@ void picasso_refresh (void)
 #define BLT_NAME BLIT_TRUE_8
 #define BLT_FUNC(s,d) *d = 0xffffffff
 #include "p96_blit.cpp"
-#define BLT_NAME BLIT_30_8
+#define BLT_NAME BLIT_SWAP_8
 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp;
 #define BLT_TEMP
 #include "p96_blit.cpp"
@@ -1141,7 +1164,7 @@ static int do_blitrect_frame_buffer (struct RenderInfo *ri, struct
                        case BLIT_NOTONLYDST: BLIT_NOTONLYDST_32 (PARMS); break;
                        case BLIT_OR: BLIT_OR_32 (PARMS); break;
                        case BLIT_TRUE: BLIT_TRUE_32 (PARMS); break;
-                       case 30: BLIT_30_32 (PARMS); break;
+                       case BLIT_SWAP: BLIT_SWAP_32 (PARMS); break;
                        }
                } else if (Bpp == 3) {
 
@@ -1162,7 +1185,7 @@ static int do_blitrect_frame_buffer (struct RenderInfo *ri, struct
                        case BLIT_NOTONLYDST: BLIT_NOTONLYDST_24 (PARMS); break;
                        case BLIT_OR: BLIT_OR_24 (PARMS); break;
                        case BLIT_TRUE: BLIT_TRUE_24 (PARMS); break;
-                       case 30: BLIT_30_24 (PARMS); break;
+                       case BLIT_SWAP: BLIT_SWAP_24 (PARMS); break;
                        }
 
                } else if (Bpp == 2) {
@@ -1184,7 +1207,7 @@ static int do_blitrect_frame_buffer (struct RenderInfo *ri, struct
                        case BLIT_NOTONLYDST: BLIT_NOTONLYDST_16 (PARMS); break;
                        case BLIT_OR: BLIT_OR_16 (PARMS); break;
                        case BLIT_TRUE: BLIT_TRUE_16 (PARMS); break;
-                       case 30: BLIT_30_16 (PARMS); break;
+                       case BLIT_SWAP: BLIT_SWAP_16 (PARMS); break;
                        }
 
                } else if (Bpp == 1) {
@@ -1206,7 +1229,7 @@ static int do_blitrect_frame_buffer (struct RenderInfo *ri, struct
                        case BLIT_NOTONLYDST: BLIT_NOTONLYDST_8 (PARMS); break;
                        case BLIT_OR: BLIT_OR_8 (PARMS); break;
                        case BLIT_TRUE: BLIT_TRUE_8 (PARMS); break;
-                       case 30: BLIT_30_8 (PARMS); break;
+                       case BLIT_SWAP: BLIT_SWAP_8 (PARMS); break;
                        }
 
                }
@@ -1276,10 +1299,6 @@ static void updatesprcolors (int bpp)
                uae_u32 v = cursorrgb[i];
                switch (bpp)
                {
-               case 1:
-                       /* use custom chip sprite palette */
-                       cursorrgbn[i] = i + 16;
-                       break;
                case 2:
                        cursorrgbn[i] = rgb32torgb16pc (v);
                        break;
@@ -1294,20 +1313,13 @@ static void updatesprcolors (int bpp)
        }
 }
 
-static void putmousepixel (uae_u8 *d, int bpp, int idx)
+STATIC_INLINE void putmousepixel (uae_u8 *d, int bpp, int idx)
 {
        uae_u32 val;
 
-       if (idx == 0 && !currprefs.gfx_api)
-               val = dxdata.colorkey;
-       else
-               val = cursorrgbn[idx];
-
+       val = cursorrgbn[idx];
        switch (bpp)
        {
-       case 1:
-               ((uae_u8*)d)[0] = (uae_u8)val;
-               break;
        case 2:
                ((uae_u16*)d)[0] = (uae_u16)val;
                break;
@@ -1520,18 +1532,18 @@ static uae_u32 setspriteimage (uaecptr bi)
 {
        uae_u32 flags;
        int x, y, yy, bits, bpp;
-       uae_u8 *tmpbuf;
        int hiressprite, doubledsprite;
        int ret = 0;
        int w, h;
 
        cursordeactivate = 0;
-       if (!hwsprite || !cursorsurfaced3d)
+       if (!hwsprite)
                return 0;
+       xfree (cursordata);
+       cursordata = NULL;
        bpp = 4;
        w = get_byte (bi + PSSO_BoardInfo_MouseWidth);
        h = get_byte (bi + PSSO_BoardInfo_MouseHeight);
-       tmpbuf = NULL;
        flags = get_long (bi + PSSO_BoardInfo_Flags);
        hiressprite = 1;
        doubledsprite = 0;
@@ -1554,9 +1566,9 @@ static uae_u32 setspriteimage (uaecptr bi)
        createwindowscursor (get_long (bi + PSSO_BoardInfo_MouseImage) + 4 * hiressprite,
                w, h, hiressprite, doubledsprite, 0);
 
-       tmpbuf = xmalloc (uae_u8, w * h * bpp);
+       cursordata = xmalloc (uae_u8, w * h * bpp);
        for (y = 0, yy = 0; y < h; y++, yy++) {
-               uae_u8 *p = tmpbuf + w * bpp * y;
+               uae_u8 *p = cursordata + w * bpp * y;
                uae_u8 *pprev = p;
                uaecptr img = get_long (bi + PSSO_BoardInfo_MouseImage) + 4 * hiressprite + yy * 4 * hiressprite;
                x = 0;
@@ -1589,26 +1601,11 @@ static uae_u32 setspriteimage (uaecptr bi)
        cursorwidth = w;
        cursorheight = h;
 
-       uae_u8 *dptr = NULL;
-       DWORD pitch;
-       D3DLOCKED_RECT locked;
-       if (SUCCEEDED (cursorsurfaced3d->LockRect (0, &locked, NULL, 0))) {
-               dptr = (uae_u8*)locked.pBits;
-               pitch = locked.Pitch;
-       }
-       if (dptr) {
-               for (y = 0; y < h; y++) {
-                       uae_u8 *p1 = tmpbuf + w * bpp * y;
-                       uae_u8 *p2 = dptr + pitch * y;
-                       memcpy (p2, p1, w * bpp);
-               }
-               cursorsurfaced3d->UnlockRect (0);
-       }
+       setupcursor ();
        ret = 1;
        cursorok = TRUE;
        P96TRACE_SPR ((L"hardware sprite created\n"));
 end:
-       xfree (tmpbuf);
        return ret;
 }
 
@@ -2061,7 +2058,7 @@ static void inituaegfx (uaecptr ABI)
        flags &= 0xffff0000;
        flags |= BIF_BLITTER | BIF_NOMEMORYMODEMIX;
        flags &= ~BIF_HARDWARESPRITE;
-       if (currprefs.gfx_api) {
+       if (currprefs.gfx_api && D3D_goodenough ()) {
                hwsprite = 1;
                flags |= BIF_HARDWARESPRITE;
                write_log (L"P96: Hardware sprite support enabled\n");
@@ -2071,14 +2068,12 @@ static void inituaegfx (uaecptr ABI)
        }
        if (flags & BIF_NOBLITTER)
                write_log (L"P96: Blitter disabled in devs:monitors/uaegfx!\n");
-
        if (currprefs.win32_rtgvblankrate >= -1)
                flags |= BIF_VBLANKINTERRUPT;
        if (!(flags & BIF_INDISPLAYCHAIN)) {
                write_log (L"P96: BIF_INDISPLAYCHAIN force-enabled!\n");
                flags |= BIF_INDISPLAYCHAIN;
        }
-
        put_long (ABI + PSSO_BoardInfo_Flags, flags);
 
        put_word (ABI + PSSO_BoardInfo_MaxHorResolution + 0, planar.width);
@@ -2417,17 +2412,6 @@ static uae_u32 REGPARAM2 picasso_SetPanning (TrapContext *ctx)
                changed = 1;
        }
 
-       if (changed) {
-#if P96DX > 0
-               freesurface (p96surface);
-               p96surface = NULL;
-               if (picasso96_state.BytesPerPixel == picasso_vidinfo.pixbytes)
-                       p96surface = createsurface (get_real_address (picasso96_state.Address),
-                       picasso96_state.Width * picasso96_state.BytesPerPixel, picasso96_state.Width, picasso96_state.Height);
-               write_log (L"P96Surface: %08X %p\n", picasso96_state.Address, p96surface);
-#endif
-       }
-
        bme_width = get_word (bmeptr + PSSO_BitMapExtra_Width);
        bme_height = get_word (bmeptr + PSSO_BitMapExtra_Height);
        rgbf = picasso96_state.RGBFormat;
@@ -3357,8 +3341,7 @@ static uae_u32 REGPARAM2 picasso_BlitPlanar2Chunky (TrapContext *ctx)
 static void PlanarToDirect (struct RenderInfo *ri, struct BitMap *bm,
        unsigned long srcx, unsigned long srcy,
        unsigned long dstx, unsigned long dsty,
-       unsigned long width, unsigned long height, uae_u8 mask,
-struct ColorIndexMapping *cim)
+       unsigned long width, unsigned long height, uae_u8 mask, struct ColorIndexMapping *cim)
 {
        int j;
        int bpp = GetBytesPerPixel (ri->RGBFormat);
@@ -3514,7 +3497,7 @@ static void statusline (uae_u8 *dst)
        }
 }
 
-STATIC_INLINE void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width)
+static void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width)
 {
        uae_u8 *src2 = src + y * picasso96_state.BytesPerRow;
        uae_u8 *dst2 = dst + y * picasso_vidinfo.rowbytes;
@@ -3526,18 +3509,29 @@ STATIC_INLINE void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width)
                memcpy (dst2 + x * dstpix, src2 + x * srcpix, width * dstpix);
                return;
        }
+       // native match?
+       if (currprefs.gfx_api) {
+               switch (picasso_convert)
+               {
+                       case RGBFB_B8G8R8A8_32:
+                       case RGBFB_R5G6B5PC_16:
+                               memcpy (dst2 + x * dstpix, src2 + x * srcpix, width * dstpix);
+                       return;
+               }
+       } else {
+               switch (picasso_convert)
+               {
+                       case RGBFB_B8G8R8A8_32:
+                       case RGBFB_R5G6B5PC_16:
+                               memcpy (dst2 + x * dstpix, src2 + x * srcpix, width * dstpix);
+                       return;
+               }
+       }
 
        endx4 = endx & ~3;
 
        switch (picasso_convert)
        {
-               /* Picasso96mode == Nativemode */
-       case RGBFB_B8G8R8A8_32:
-       case RGBFB_R5G6B5PC_16:
-       case RGBFB_CLUT_8:
-               memcpy (dst2 + x * dstpix, src2 + x * srcpix, width * dstpix);
-               break;
-
                /* 24bit->32bit */
        case RGBFB_R8G8B8_32:
                while (x < endx) {
@@ -3607,7 +3601,8 @@ STATIC_INLINE void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width)
        case RGBFB_R5G5B5_16:
        case RGBFB_B5G5R5PC_16:
        case RGBFB_B5G6R5PC_16:
-               {
+       case RGBFB_R5G6B5PC_16:
+       {
                        while ((x & 3) && x < endx) {
                                ((uae_u16*)dst2)[x] = (uae_u16)p96_rgbx16[((uae_u16*)src2)[x]];
                                x++;
@@ -3826,13 +3821,6 @@ static int flushpixels (void)
 
                dofull = gwwcnt >= ((src_end - src_start) / gwwpagesize) * 80 / 100;
 
-#if P96DX > 0
-               if (p96surface && dofull && picasso_vidinfo.pixbytes == picasso96_state.BytesPerPixel) {
-                       flushpixels_surface (gwwbuf, gwwcnt, src_start, src_end);
-                       return;
-               }
-#endif
-
                dst = gfx_lock_picasso ();
                if (dst == NULL)
                        break;
@@ -3990,7 +3978,7 @@ static uae_u8 *REGPARAM2 gfxmem_xlate (uaecptr addr)
        return gfxmemory + addr;
 }
 
-addrbank gfxmem_bankx = {
+addrbank gfxmem_bank = {
        gfxmem_lgetx, gfxmem_wgetx, gfxmem_bgetx,
        gfxmem_lputx, gfxmem_wputx, gfxmem_bputx,
        gfxmem_xlate, gfxmem_check, NULL, L"RTG RAM",
@@ -4032,6 +4020,46 @@ static uae_u32 REGPARAM2 picasso_SetInterrupt (TrapContext *ctx)
        return onoff;
 }
 
+static uaecptr uaegfx_vblankname, uaegfx_portsname;
+static void initvblankABI (uaecptr base, uaecptr ABI)
+{
+       for (int i = 0; i < 22; i++)
+               put_byte (ABI + PSSO_BoardInfo_HardInterrupt + i, get_byte (base + CARD_PORTSIRQ + i));
+       ABI_interrupt = ABI;
+}
+static void initvblankirq (TrapContext *ctx, uaecptr base)
+{
+       uaecptr p1 = base + CARD_VBLANKIRQ;
+       uaecptr p2 = base + CARD_PORTSIRQ;
+       uaecptr c = base + CARD_IRQCODE;
+
+       put_word (p1 + 8, 0x0205);
+       put_long (p1 + 10, uaegfx_vblankname);
+       put_long (p1 + 14, base + CARD_IRQFLAG);
+       put_long (p1 + 18, c);
+
+       put_word (p2 + 8, 0x0205);
+       put_long (p2 + 10, uaegfx_portsname);
+       put_long (p2 + 14, base + CARD_IRQFLAG);
+       put_long (p2 + 18, c);
+
+       put_word (c, 0x4a11); c += 2;           // tst.b (a1)
+       put_word (c, 0x670e); c += 2;           // beq.s label
+       put_word (c, 0x4211); c += 2;           // clr.b (a1)
+       put_long (c, 0x22690004); c += 4;       // move.l 4(a1),a1
+       put_long (c, 0x2c780004); c += 4;       // move.l 4.w,a6
+       put_long (c, 0x4eaeff4c); c += 4;       // jsr Cause(a6)
+       put_word (c, 0x7000); c += 2;           // label: moveq #0,d0
+       put_word (c, RTS);                                      // rts
+
+       m68k_areg (regs, 1) = p1;
+       m68k_dreg (regs, 0) = 5;                        /* VERTB */
+       CallLib (ctx, get_long (4), -168);      /* AddIntServer */
+       m68k_areg (regs, 1) = p2;
+       m68k_dreg (regs, 0) = 3;                        /* PORTS */
+       CallLib (ctx, get_long (4), -168);      /* AddIntServer */
+}
+
 #define PUTABI(func) \
        if (ABI) \
        put_long (ABI + func, here ());
@@ -4218,6 +4246,8 @@ static uaecptr inituaegfxfuncs (uaecptr start, uaecptr ABI)
 
        write_log (L"uaegfx.card magic code: %08X-%08X ABI=%08X\n", start, here (), ABI);
 
+       if (ABI && currprefs.win32_rtgvblankrate >= -1)
+               initvblankABI (uaegfx_base, ABI);
        ptr = here ();
        org (old);
        return ptr;
@@ -4254,59 +4284,6 @@ static uae_u32 REGPARAM2 gfx_expunge (TrapContext *context)
        return 0;
 }
 
-static uaecptr uaegfx_vblankname, uaegfx_portsname;
-static void initvblankirq (TrapContext *ctx, uaecptr base)
-{
-       uaecptr p1 = base + CARD_VBLANKIRQ;
-       uaecptr p2 = base + CARD_PORTSIRQ;
-       uaecptr c = base + CARD_IRQCODE;
-
-       put_word (p1 + 8, 0x0205);
-       put_long (p1 + 10, uaegfx_vblankname);
-       put_long (p1 + 14, base + CARD_IRQFLAG);
-       put_long (p1 + 18, c);
-
-       put_word (p2 + 8, 0x0205);
-       put_long (p2 + 10, uaegfx_portsname);
-       put_long (p2 + 14, base + CARD_IRQFLAG);
-       put_long (p2 + 18, c);
-
-       put_word (c, 0x4a11); c += 2;           // tst.b (a1)
-       put_word (c, 0x670e); c += 2;           // beq.s label
-       put_word (c, 0x4211); c += 2;           // clr.b (a1)
-       put_long (c, 0x22690004); c += 4;       // move.l 4(a1),a1
-       put_long (c, 0x2c780004); c += 4;       // move.l 4.w,a6
-       put_long (c, 0x4eaeff4c); c += 4;       // jsr Cause(a6)
-       put_word (c, 0x7000); c += 2;           // label: moveq #0,d0
-       put_word (c, RTS);                                      // rts
-
-       m68k_areg (regs, 1) = p1;
-       m68k_dreg (regs, 0) = 5;                        /* VERTB */
-       CallLib (ctx, get_long (4), -168);      /* AddIntServer */
-       m68k_areg (regs, 1) = p2;
-       m68k_dreg (regs, 0) = 3;                        /* PORTS */
-       CallLib (ctx, get_long (4), -168);      /* AddIntServer */
-}
-
-static void *picasso_copy (void *data)
-{
-       thread_alive = 1;
-       while (thread_alive) {
-               uae_sem_wait (&sem);
-               if (!thread_alive)
-                       break;
-               if (!picasso_on)
-                       continue;
-               if (dx_islost ())
-                       continue;
-               mouseupdate ();
-               flushpixels ();
-       }
-       thread_alive = -1;
-       return NULL;
-}
-
-
 static uaecptr uaegfx_card_install (TrapContext *ctx, uae_u32 extrasize)
 {
        uae_u32 functable, datatable, a2;
index 48c9e790d2c828a6f0a91fb04ccae7183e30c455..a77c2d4602a694ed576c2e1ec2c48bdd718ab397 100644 (file)
@@ -1,15 +1,25 @@
 cd c:\projects\winuae_bak
 rm -rf bak
 mkdir bak
-copy /s c:\projects\winuae\src\* c:\projects\winuae_bak\bak\
+
+copy c:\projects\winuae\src\* c:\projects\winuae_bak\bak\
+copy /s c:\projects\winuae\src\archivers\* c:\projects\winuae_bak\bak\archivers\
+mkdir bak\include
+copy c:\projects\winuae\src\include\* c:\projects\winuae_bak\bak\include\
+mkdir bak\jit
+copy c:\projects\winuae\src\jit\* c:\projects\winuae_bak\bak\jit\
+mkdir bak\md-generic
+copy c:\projects\winuae\src\md-generic\* c:\projects\winuae_bak\bak\md-generic\
+mkdir bak\md-i386-gcc
+copy c:\projects\winuae\src\md-i386-gcc\* c:\projects\winuae_bak\bak\md-i386-gcc\
+copy /s c:\projects\winuae\src\od-win32\* c:\projects\winuae_bak\bak\od-win32\
+
 copy d:\amiga\text\winuaechangelog.txt c:\projects\winuae_bak\bak\od-win32
 copy d:\amiga\amiga\filesys.asm c:\projects\winuae_bak\bak
 
 cd bak
 del *.obj *.ilk *.exe *.pdb *.pch *.idb *.ncb *.sln *.suo *.ncb *.sdf /s
 
-
-
 del cpudefs.cpp
 del blit.h
 del blitfunc.cpp
@@ -133,6 +143,6 @@ copy winuaesrc.zip d:\amiga\winuaepackets\winuaesrc%1.zip
 move winuaesrc.zip d:\amiga
 cd c:\projects\winuae\src\od-win32
 zip -9 winuaedebug%1 winuae_msvc\release\winuae.pdb winuae_msvc\fullrelease\winuae.pdb winuae_msvc10\release\winuae.pdb  winuae_msvc10\fullrelease\winuae.pdb 
-move winuaedebug%1.zip d:\amiga\winuaepackets\
+move winuaedebug%1.zip d:\amiga\winuaepackets\debug\
 copy winuae_msvc10\fullrelease\winuae.pdb d:\amiga\dump
 copy d:\amiga\winuae.exe d:\amiga\dump
index f61940edfa617490e57b933cacd1e180b1513020..8efe7677b7ae6c8077eae5e8a86f50107bc65efa 100644 (file)
@@ -322,3 +322,12 @@ int same_aname (const TCHAR *an1, const TCHAR *an2)
 {
        return CompareString (LOCALE_INVARIANT, NORM_IGNORECASE, an1, -1, an2, -1) == CSTR_EQUAL;
 }
+
+void to_lower (TCHAR *s, int len)
+{
+       CharLowerBuff (s, len);
+}
+void to_upper (TCHAR *s, int len)
+{
+       CharUpperBuff (s, len);
+}
\ No newline at end of file
index f88533f423bc49e4431d94d7b1f1d9b374a93c48..21b0e90ef55cf9ba5e9c8426dc641f5916d94890 100644 (file)
@@ -18,8 +18,8 @@
 #define WINUAEPUBLICBETA 1
 #define LANG_DLL 1
 
-#define WINUAEBETA L"13"
-#define WINUAEDATE MAKEBD(2010, 2, 26)
+#define WINUAEBETA L"14"
+#define WINUAEDATE MAKEBD(2010, 3, 1)
 #define WINUAEEXTRA L""
 #define WINUAEREV L""
 
index 15686c4af72f222f00b4ac37f6720ecf444aca76..6ed36eff127ec37dd006e3768a23dc6af35a6397 100644 (file)
@@ -72,7 +72,7 @@ static void getinit (void)
 static int vblscale (int v)
 {
        static int o;
-       int n;
+       int n, v2;
 
        n = (beamcon0 & 0x80) + maxvpos_nom;
        if (n != o)
@@ -81,9 +81,12 @@ static int vblscale (int v)
        if (beamcon0 & 0x80)
                return v;
        if (currprefs.ntscmode)
-               v = v * maxvpos_nom / MAXVPOS_NTSC;
+               v2 = MAXVPOS_NTSC;
        else
-               v = v * maxvpos_nom / MAXVPOS_PAL;
+               v2 = MAXVPOS_PAL;
+       if (abs (v2 - maxvpos_nom) <= 3)
+               return v;
+       v = v * maxvpos_nom / v2;
        return v;
 }
 static int vblscale2 (int v)
index f0e00b70a4479a8ee0e3c10d877be3021f1400d0..722c02c74a0e7a119614631d917884bab7dfd684 100644 (file)
@@ -1482,8 +1482,6 @@ static xcolnr xcol8[4096];
 
 static int red_bits, green_bits, blue_bits, alpha_bits;
 static int red_shift, green_shift, blue_shift, alpha_shift;
-static int x_red_bits, x_green_bits, x_blue_bits, x_alpha_bits;
-static int x_red_shift, x_green_shift, x_blue_shift, x_alpha_shift;
 static int alpha;
 
 void init_colors (void)
@@ -1496,34 +1494,22 @@ void init_colors (void)
        case 2:
        case 3:
        case 4:
-               x_red_bits = bits_in_mask (DirectDraw_GetPixelFormatBitMask (red_mask));
-               x_green_bits = bits_in_mask (DirectDraw_GetPixelFormatBitMask (green_mask));
-               x_blue_bits = bits_in_mask (DirectDraw_GetPixelFormatBitMask (blue_mask));
-               x_red_shift = mask_shift (DirectDraw_GetPixelFormatBitMask (red_mask));
-               x_green_shift = mask_shift (DirectDraw_GetPixelFormatBitMask (green_mask));
-               x_blue_shift = mask_shift (DirectDraw_GetPixelFormatBitMask (blue_mask));
-               x_alpha_bits = 0;
-               x_alpha_shift = 0;
+               red_bits = bits_in_mask (DirectDraw_GetPixelFormatBitMask (red_mask));
+               green_bits = bits_in_mask (DirectDraw_GetPixelFormatBitMask (green_mask));
+               blue_bits = bits_in_mask (DirectDraw_GetPixelFormatBitMask (blue_mask));
+               red_shift = mask_shift (DirectDraw_GetPixelFormatBitMask (red_mask));
+               green_shift = mask_shift (DirectDraw_GetPixelFormatBitMask (green_mask));
+               blue_shift = mask_shift (DirectDraw_GetPixelFormatBitMask (blue_mask));
+               alpha_bits = 0;
+               alpha_shift = 0;
                break;
        }
 
-       if (currentmode->flags & DM_OPENGL) {
-#ifdef OPENGL
-               OGL_getpixelformat (currentmode->current_depth,&red_bits,&green_bits,&blue_bits,&red_shift,&green_shift,&blue_shift,&alpha_bits,&alpha_shift,&alpha);
-#endif
-       } else if (currentmode->flags & DM_D3D) {
+       if (currentmode->flags & DM_D3D) {
 #ifdef D3D
-               D3D_getpixelformat (currentmode->current_depth,&red_bits,&green_bits,&blue_bits,&red_shift,&green_shift,&blue_shift,&alpha_bits,&alpha_shift,&alpha);
+               D3D_getpixelformat (currentmode->current_depth,
+                       &red_bits, &green_bits, &blue_bits, &red_shift, &green_shift, &blue_shift, &alpha_bits, &alpha_shift, &alpha);
 #endif
-       } else {
-               red_bits = x_red_bits;
-               green_bits = x_green_bits;
-               blue_bits = x_blue_bits;
-               red_shift = x_red_shift;
-               green_shift = x_green_shift;
-               blue_shift = x_blue_shift;
-               alpha_bits = x_alpha_bits;
-               alpha_shift = x_alpha_shift;
        }
 
        if (!(currentmode->flags & (DM_OPENGL|DM_D3D))) {
@@ -1537,6 +1523,7 @@ void init_colors (void)
                        }
                }
        }
+       write_log (L"%d %d %d %d %d %d\n", red_bits, green_bits, blue_bits, red_shift, green_shift, blue_shift);
        alloc_colors64k (red_bits, green_bits, blue_bits, red_shift,green_shift, blue_shift, alpha_bits, alpha_shift, alpha, 0);
        notice_new_xcolors ();
 #ifdef GFXFILTER
@@ -1824,7 +1811,7 @@ void gfx_set_picasso_modeinfo (uae_u32 w, uae_u32 h, uae_u32 depth, RGBFTYPE rgb
 
 void gfx_set_picasso_colors (RGBFTYPE rgbfmt)
 {
-       alloc_colors_picasso (x_red_bits, x_green_bits, x_blue_bits, x_red_shift, x_green_shift, x_blue_shift, rgbfmt);
+       alloc_colors_picasso (red_bits, green_bits, blue_bits, red_shift, green_shift, blue_shift, rgbfmt);
 }
 
 static void gfxmode_reset (void)
@@ -2471,8 +2458,8 @@ static BOOL doInit (void)
 
                }
                init_row_map ();
-               init_colors ();
        }
+       init_colors ();
 
 
 #if defined (GFXFILTER)
index d12b94488f8462b80daf2fad81674207c8b76fe6..21beef396797ff51bebba047dd4beefa7cbab7c6 100644 (file)
@@ -3821,13 +3821,13 @@ static urlinfo urls[] =
        {IDC_CLOANTOHOME, FALSE, L"Cloanto's Amiga Forever", L"http://www.amigaforever.com/"},
        {IDC_AMIGAHOME, FALSE, L"Amiga Inc.", L"http://www.amiga.com"},
 //     {IDC_PICASSOHOME, FALSE, L"Picasso96 Home Page", L"http://www.picasso96.cogito.de/"},
-       {IDC_UAEHOME, FALSE, L"UAE Home Page", L"http://uae.coresystems.de/"},
+       {IDC_UAEHOME, FALSE, L"UAE Home Page", L"http://www.amigaemulator.org/"},
        {IDC_WINUAEHOME, FALSE, L"WinUAE Home Page", L"http://www.winuae.net/"},
 //     {IDC_AIABHOME, FALSE, L"AIAB", L"http://www.amigainabox.co.uk/"},
        {IDC_THEROOTS, FALSE, L"Back To The Roots", L"http://www.back2roots.org/"},
        {IDC_ABIME, FALSE, L"abime.net", L"http://www.abime.net/"},
        {IDC_CAPS, FALSE, L"SPS", L"http://www.softpres.org/"},
-       {IDC_AMIGASYS, FALSE, L"AmigaSYS", L"http://amigasys.extra.hu/"},
+       {IDC_AMIGASYS, FALSE, L"AmigaSYS", L"http://www.amigasys.com/"},
        {IDC_AMIKIT, FALSE, L"AmiKit", L"http://amikit.amiga.sk/"},
        { -1, FALSE, NULL, NULL }
 };
@@ -10924,7 +10924,7 @@ static void values_to_hw3ddlg (HWND hDlg)
                _stprintf (tmp, L"%s%sfiltershaders\\direct3d\\*.fx", start_path_data, WIN32_PLUGINDIR);
                h = FindFirstFile (tmp, &wfd);
                while (h != INVALID_HANDLE_VALUE) {
-                       if (_tcsicmp (wfd.cFileName, L"winuae.fx") && _tcsicmp (wfd.cFileName, L"winuae_old.fx")) {
+                       if (wfd.cFileName[0] != '_') {
                                TCHAR tmp2[100];
                                _stprintf (tmp2, L"D3D: %s", wfd.cFileName);
                                tmp2[_tcslen (tmp2) - 3] = 0;
index e45ce1082c428cd918677cdd535c27783d9b4b95..62ca8fa2d5e8ffa7f0402a25323b9fd1e271c4f1 100644 (file)
       <AdditionalIncludeDirectories>..\..\include;..\..;..\;..\resources;..\osdep;..\sounddep;..\..\prowizard\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WINVER=0x0500;NDEBUG;_WIN32_IE=0x0700;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
-      <ExceptionHandling>
-      </ExceptionHandling>
+      <ExceptionHandling>false</ExceptionHandling>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>