--- uae/src/newcpu.c 2018/04/24 16:40:00 1.1.1.3 +++ uae/src/newcpu.c 2018/04/24 16:52:58 1.1.1.10 @@ -11,11 +11,8 @@ #include "config.h" #include "options.h" -#include "gensound.h" -#include "sounddep/sound.h" #include "events.h" #include "uae.h" -#include "machdep/m68k.h" #include "memory.h" #include "custom.h" #include "readcpu.h" @@ -52,7 +49,7 @@ cpuop_func *cpufunctbl[65536]; static unsigned long int instrcount[65536]; static uae_u16 opcodenums[65536]; -static int compfn(const void *el1, const void *el2) +static int compfn (const void *el1, const void *el2) { return instrcount[*(const uae_u16 *)el1] < instrcount[*(const uae_u16 *)el2]; } @@ -65,18 +62,18 @@ static char *icountfilename (void) return COUNT_INSTRS == 2 ? "frequent.68k" : "insncount"; } -void dump_counts(void) +void dump_counts (void) { - FILE *f = fopen(icountfilename(), "w"); + FILE *f = fopen (icountfilename (), "w"); unsigned long int total; int i; write_log ("Writing instruction count file...\n"); - for (i=0; i < 65536; i++) { + for (i = 0; i < 65536; i++) { opcodenums[i] = i; total += instrcount[i]; } - qsort(opcodenums, 65536, sizeof(uae_u16), compfn); + qsort (opcodenums, 65536, sizeof(uae_u16), compfn); fprintf (f, "Total: %lu\n", total); for (i=0; i < 65536; i++) { @@ -86,19 +83,28 @@ void dump_counts(void) if (!cnt) break; dp = table68k + opcodenums[i]; - for (lookup = lookuptab;lookup->mnemo != dp->mnemo; lookup++) ; + for (lookup = lookuptab;lookup->mnemo != dp->mnemo; lookup++) + ; fprintf (f, "%04x: %lu %s\n", opcodenums[i], cnt, lookup->name); } - fclose(f); + fclose (f); } #else -void dump_counts(void) +void dump_counts (void) { } #endif int broken_in; +static unsigned long op_illg_1 (uae_u32 opcode) REGPARAM; + +static unsigned long REGPARAM2 op_illg_1 (uae_u32 opcode) +{ + op_illg (opcode); + return 4; +} + static void build_cpufunctbl (void) { int i; @@ -109,12 +115,11 @@ static void build_cpufunctbl (void) : currprefs.cpu_compatible ? op_smalltbl_4 : op_smalltbl_3); - sprintf (warning_buffer, "Building CPU function table (%d %d %d).\n", - currprefs.cpu_level, currprefs.cpu_compatible, currprefs.address_space_24); - write_log (warning_buffer); + write_log ("Building CPU function table (%d %d %d).\n", + currprefs.cpu_level, currprefs.cpu_compatible, currprefs.address_space_24); for (opcode = 0; opcode < 65536; opcode++) - cpufunctbl[opcode] = op_illg; + cpufunctbl[opcode] = op_illg_1; for (i = 0; tbl[i].handler != NULL; i++) { if (! tbl[i].specific) cpufunctbl[tbl[i].opcode] = tbl[i].handler; @@ -127,7 +132,7 @@ static void build_cpufunctbl (void) if (table68k[opcode].handler != -1) { f = cpufunctbl[table68k[opcode].handler]; - if (f == op_illg) + if (f == op_illg_1) abort(); cpufunctbl[opcode] = f; } @@ -138,6 +143,18 @@ static void build_cpufunctbl (void) } } +unsigned long cycles_mask, cycles_val; + +static void update_68k_cycles (void) +{ + cycles_mask = 0; + cycles_val = currprefs.m68k_speed; + if (currprefs.m68k_speed < 1) { + cycles_mask = 0xFFFFFFFF; + cycles_val = 0; + } +} + void check_prefs_changed_cpu (void) { if (currprefs.cpu_level != changed_prefs.cpu_level @@ -146,13 +163,19 @@ void check_prefs_changed_cpu (void) currprefs.cpu_compatible = changed_prefs.cpu_compatible; build_cpufunctbl (); } - currprefs.m68k_speed = changed_prefs.m68k_speed; + if (currprefs.m68k_speed != changed_prefs.m68k_speed) { + currprefs.m68k_speed = changed_prefs.m68k_speed; + reset_frame_rate_hack (); + update_68k_cycles (); + } } void init_m68k (void) { int i; + update_68k_cycles (); + for (i = 0 ; i < 256 ; i++) { int j; for (j = 0 ; j < 8 ; j++) { @@ -167,35 +190,55 @@ void init_m68k (void) for (j = 7 ; j >= 0 ; j--) { if (i & (1 << j)) break; } - fpp_movem_index1[i] = j; - fpp_movem_index2[i] = 7-j; + fpp_movem_index1[i] = 7-j; + fpp_movem_index2[i] = j; fpp_movem_next[i] = i & (~(1 << j)); } #if COUNT_INSTRS { - FILE *f = fopen(icountfilename(), "r"); - memset(instrcount, 0, sizeof instrcount); + FILE *f = fopen (icountfilename (), "r"); + memset (instrcount, 0, sizeof instrcount); if (f) { uae_u32 opcode, count, total; char name[20]; write_log ("Reading instruction count file...\n"); - fscanf(f,"Total: %lu\n",&total); - while(fscanf(f,"%lx: %lu %s\n",&opcode,&count,name)==3) { + fscanf (f, "Total: %lu\n", &total); + while (fscanf (f, "%lx: %lu %s\n", &opcode, &count, name) == 3) { instrcount[opcode] = count; } fclose(f); } } #endif - write_log("Building CPU table... "); + write_log ("Building CPU table for configuration: 68"); + if (currprefs.address_space_24 && currprefs.cpu_level > 1) + write_log ("EC"); + switch (currprefs.cpu_level) { + case 1: + write_log ("010"); + break; + case 2: + write_log ("020"); + break; + case 3: + write_log ("020/881"); + break; + default: + write_log ("000"); + break; + } + if (currprefs.cpu_compatible) + write_log (" (compatible mode)"); + write_log ("\n"); + read_table68k (); do_merges (); - sprintf (warning_buffer, "%d CPU functions\n", nr_cpuop_funcs); - write_log (warning_buffer); + write_log ("%d CPU functions\n", nr_cpuop_funcs); build_cpufunctbl (); } + struct regstruct regs, lastint_regs; static struct regstruct regs_backup[16]; static int backup_pointer = 0; @@ -206,7 +249,7 @@ int lastint_no; #define get_iword_1(o) get_word(regs.pc + (regs.pc_p - regs.pc_oldp) + (o)) #define get_ilong_1(o) get_long(regs.pc + (regs.pc_p - regs.pc_oldp) + (o)) -uae_s32 ShowEA(int reg, amodes mode, wordsizes size, char *buf) +uae_s32 ShowEA (int reg, amodes mode, wordsizes size, char *buf) { uae_u16 dp; uae_s8 disp8; @@ -234,13 +277,13 @@ uae_s32 ShowEA(int reg, amodes mode, wor sprintf (buffer,"-(A%d)", reg); break; case Ad16: - disp16 = get_iword_1(m68kpc_offset); m68kpc_offset += 2; + disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; addr = m68k_areg(regs,reg) + (uae_s16)disp16; sprintf (buffer,"(A%d,$%04x) == $%08lx", reg, disp16 & 0xffff, - (long unsigned int)addr); + (unsigned long)addr); break; case Ad8r: - dp = get_iword_1(m68kpc_offset); m68kpc_offset += 2; + dp = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; disp8 = dp & 0xFF; r = (dp & 0x7000) >> 12; dispreg = dp & 0x8000 ? m68k_areg(regs,r) : m68k_dreg(regs,r); @@ -254,12 +297,12 @@ uae_s32 ShowEA(int reg, amodes mode, wor sprintf (name,"A%d, ",reg); if (dp & 0x80) { base = 0; name[0] = 0; } if (dp & 0x40) dispreg = 0; - if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_iword_1(m68kpc_offset); m68kpc_offset += 2; } - if ((dp & 0x30) == 0x30) { disp = get_ilong_1(m68kpc_offset); m68kpc_offset += 4; } + if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; } + if ((dp & 0x30) == 0x30) { disp = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; } base += disp; - if ((dp & 0x3) == 0x2) { outer = (uae_s32)(uae_s16)get_iword_1(m68kpc_offset); m68kpc_offset += 2; } - if ((dp & 0x3) == 0x3) { outer = get_ilong_1(m68kpc_offset); m68kpc_offset += 4; } + if ((dp & 0x3) == 0x2) { outer = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; } + if ((dp & 0x3) == 0x3) { outer = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; } if (!(dp & 4)) base += dispreg; if (dp & 3) base = get_long (base); @@ -270,24 +313,24 @@ uae_s32 ShowEA(int reg, amodes mode, wor dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W', 1 << ((dp >> 9) & 3), disp,outer, - (long unsigned int)addr); + (unsigned long)addr); } else { addr = m68k_areg(regs,reg) + (uae_s32)((uae_s8)disp8) + dispreg; sprintf (buffer,"(A%d, %c%d.%c*%d, $%02x) == $%08lx", reg, dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W', 1 << ((dp >> 9) & 3), disp8, - (long unsigned int)addr); + (unsigned long)addr); } break; case PC16: - addr = m68k_getpc() + m68kpc_offset; - disp16 = get_iword_1(m68kpc_offset); m68kpc_offset += 2; + addr = m68k_getpc () + m68kpc_offset; + disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; addr += (uae_s16)disp16; - sprintf (buffer,"(PC,$%04x) == $%08lx", disp16 & 0xffff,(long unsigned int)addr); + sprintf (buffer,"(PC,$%04x) == $%08lx", disp16 & 0xffff,(unsigned long)addr); break; case PC8r: - addr = m68k_getpc() + m68kpc_offset; - dp = get_iword_1(m68kpc_offset); m68kpc_offset += 2; + addr = m68k_getpc () + m68kpc_offset; + dp = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; disp8 = dp & 0xFF; r = (dp & 0x7000) >> 12; dispreg = dp & 0x8000 ? m68k_areg(regs,r) : m68k_dreg(regs,r); @@ -301,12 +344,12 @@ uae_s32 ShowEA(int reg, amodes mode, wor sprintf (name,"PC, "); if (dp & 0x80) { base = 0; name[0] = 0; } if (dp & 0x40) dispreg = 0; - if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_iword_1(m68kpc_offset); m68kpc_offset += 2; } - if ((dp & 0x30) == 0x30) { disp = get_ilong_1(m68kpc_offset); m68kpc_offset += 4; } + if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; } + if ((dp & 0x30) == 0x30) { disp = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; } base += disp; - if ((dp & 0x3) == 0x2) { outer = (uae_s32)(uae_s16)get_iword_1(m68kpc_offset); m68kpc_offset += 2; } - if ((dp & 0x3) == 0x3) { outer = get_ilong_1(m68kpc_offset); m68kpc_offset += 4; } + if ((dp & 0x3) == 0x2) { outer = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; } + if ((dp & 0x3) == 0x3) { outer = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; } if (!(dp & 4)) base += dispreg; if (dp & 3) base = get_long (base); @@ -317,34 +360,34 @@ uae_s32 ShowEA(int reg, amodes mode, wor dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W', 1 << ((dp >> 9) & 3), disp,outer, - (long unsigned int)addr); + (unsigned long)addr); } else { addr += (uae_s32)((uae_s8)disp8) + dispreg; sprintf (buffer,"(PC, %c%d.%c*%d, $%02x) == $%08lx", dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W', 1 << ((dp >> 9) & 3), - disp8, (long unsigned int)addr); + disp8, (unsigned long)addr); } break; case absw: - sprintf (buffer,"$%08lx", (long unsigned int)(uae_s32)(uae_s16)get_iword_1(m68kpc_offset)); + sprintf (buffer,"$%08lx", (unsigned long)(uae_s32)(uae_s16)get_iword_1 (m68kpc_offset)); m68kpc_offset += 2; break; case absl: - sprintf (buffer,"$%08lx", (long unsigned int)get_ilong_1(m68kpc_offset)); + sprintf (buffer,"$%08lx", (unsigned long)get_ilong_1 (m68kpc_offset)); m68kpc_offset += 4; break; case imm: switch (size){ case sz_byte: - sprintf (buffer,"#$%02x", (unsigned int)(get_iword_1(m68kpc_offset) & 0xff)); + sprintf (buffer,"#$%02x", (unsigned int)(get_iword_1 (m68kpc_offset) & 0xff)); m68kpc_offset += 2; break; case sz_word: - sprintf (buffer,"#$%04x", (unsigned int)(get_iword_1(m68kpc_offset) & 0xffff)); + sprintf (buffer,"#$%04x", (unsigned int)(get_iword_1 (m68kpc_offset) & 0xffff)); m68kpc_offset += 2; break; case sz_long: - sprintf (buffer,"#$%08lx", (long unsigned int)(get_ilong_1(m68kpc_offset))); + sprintf (buffer,"#$%08lx", (unsigned long)(get_ilong_1 (m68kpc_offset))); m68kpc_offset += 4; break; default: @@ -352,23 +395,23 @@ uae_s32 ShowEA(int reg, amodes mode, wor } break; case imm0: - offset = (uae_s32)(uae_s8)get_iword_1(m68kpc_offset); + offset = (uae_s32)(uae_s8)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; sprintf (buffer,"#$%02x", (unsigned int)(offset & 0xff)); break; case imm1: - offset = (uae_s32)(uae_s16)get_iword_1(m68kpc_offset); + offset = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; sprintf (buffer,"#$%04x", (unsigned int)(offset & 0xffff)); break; case imm2: - offset = (uae_s32)get_ilong_1(m68kpc_offset); + offset = (uae_s32)get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; - sprintf (buffer,"#$%08lx", (long unsigned int)offset); + sprintf (buffer,"#$%08lx", (unsigned long)offset); break; case immi: offset = (uae_s32)(uae_s8)(reg & 0xff); - sprintf (buffer,"#$%08lx", (long unsigned int)offset); + sprintf (buffer,"#$%08lx", (unsigned long)offset); break; default: break; @@ -376,14 +419,14 @@ uae_s32 ShowEA(int reg, amodes mode, wor if (buf == 0) printf ("%s", buffer); else - strcat(buf, buffer); + strcat (buf, buffer); return offset; } /* The plan is that this will take over the job of exception 3 handling - * the CPU emulation functions will just do a longjmp to m68k_go whenever * they hit an odd address. */ -static int verify_ea(int reg, amodes mode, wordsizes size, uae_u32 *val) +static int verify_ea (int reg, amodes mode, wordsizes size, uae_u32 *val) { uae_u16 dp; uae_s8 disp8; @@ -409,13 +452,13 @@ static int verify_ea(int reg, amodes mod addr = m68k_areg (regs, reg); break; case Ad16: - disp16 = get_iword_1(m68kpc_offset); m68kpc_offset += 2; + disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; addr = m68k_areg(regs,reg) + (uae_s16)disp16; break; case Ad8r: addr = m68k_areg (regs, reg); d8r_common: - dp = get_iword_1(m68kpc_offset); m68kpc_offset += 2; + dp = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; disp8 = dp & 0xFF; r = (dp & 0x7000) >> 12; dispreg = dp & 0x8000 ? m68k_areg(regs,r) : m68k_dreg(regs,r); @@ -427,12 +470,12 @@ static int verify_ea(int reg, amodes mod uae_s32 base = addr; if (dp & 0x80) base = 0; if (dp & 0x40) dispreg = 0; - if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_iword_1(m68kpc_offset); m68kpc_offset += 2; } - if ((dp & 0x30) == 0x30) { disp = get_ilong_1(m68kpc_offset); m68kpc_offset += 4; } + if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; } + if ((dp & 0x30) == 0x30) { disp = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; } base += disp; - if ((dp & 0x3) == 0x2) { outer = (uae_s32)(uae_s16)get_iword_1(m68kpc_offset); m68kpc_offset += 2; } - if ((dp & 0x3) == 0x3) { outer = get_ilong_1(m68kpc_offset); m68kpc_offset += 4; } + if ((dp & 0x3) == 0x2) { outer = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; } + if ((dp & 0x3) == 0x3) { outer = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; } if (!(dp & 4)) base += dispreg; if (dp & 3) base = get_long (base); @@ -444,33 +487,33 @@ static int verify_ea(int reg, amodes mod } break; case PC16: - addr = m68k_getpc() + m68kpc_offset; - disp16 = get_iword_1(m68kpc_offset); m68kpc_offset += 2; + addr = m68k_getpc () + m68kpc_offset; + disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; addr += (uae_s16)disp16; break; case PC8r: - addr = m68k_getpc() + m68kpc_offset; + addr = m68k_getpc () + m68kpc_offset; goto d8r_common; case absw: - addr = (uae_s32)(uae_s16)get_iword_1(m68kpc_offset); + addr = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; break; case absl: - addr = get_ilong_1(m68kpc_offset); + addr = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; break; case imm: switch (size){ case sz_byte: - *val = get_iword_1(m68kpc_offset) & 0xff; + *val = get_iword_1 (m68kpc_offset) & 0xff; m68kpc_offset += 2; break; case sz_word: - *val = get_iword_1(m68kpc_offset) & 0xffff; + *val = get_iword_1 (m68kpc_offset) & 0xffff; m68kpc_offset += 2; break; case sz_long: - *val = get_ilong_1(m68kpc_offset); + *val = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; break; default: @@ -499,12 +542,64 @@ static int verify_ea(int reg, amodes mod if ((addr & 1) == 0) return 1; - last_addr_for_exception_3 = m68k_getpc() + m68kpc_offset; + last_addr_for_exception_3 = m68k_getpc () + m68kpc_offset; last_fault_for_exception_3 = addr; return 0; } -void MakeSR(void) +uae_u32 get_disp_ea_020 (uae_u32 base, uae_u32 dp) +{ + int reg = (dp >> 12) & 15; + uae_s32 regd = regs.regs[reg]; + if ((dp & 0x800) == 0) + regd = (uae_s32)(uae_s16)regd; + regd <<= (dp >> 9) & 3; + if (dp & 0x100) { + uae_s32 outer = 0; + if (dp & 0x80) base = 0; + if (dp & 0x40) regd = 0; + + if ((dp & 0x30) == 0x20) base += (uae_s32)(uae_s16)next_iword(); + if ((dp & 0x30) == 0x30) base += next_ilong(); + + if ((dp & 0x3) == 0x2) outer = (uae_s32)(uae_s16)next_iword(); + if ((dp & 0x3) == 0x3) outer = next_ilong(); + + if ((dp & 0x4) == 0) base += regd; + if (dp & 0x3) base = get_long (base); + if (dp & 0x4) base += regd; + + return base + outer; + } else { + return base + (uae_s32)((uae_s8)dp) + regd; + } +} + +uae_u32 get_disp_ea_000 (uae_u32 base, uae_u32 dp) +{ + int reg = (dp >> 12) & 15; + uae_s32 regd = regs.regs[reg]; +#if 1 + if ((dp & 0x800) == 0) + regd = (uae_s32)(uae_s16)regd; + return base + (uae_s8)dp + regd; +#else + /* Branch-free code... benchmark this again now that + * things are no longer inline. */ + uae_s32 regd16; + uae_u32 mask; + mask = ((dp & 0x800) >> 11) - 1; + regd16 = (uae_s32)(uae_s16)regd; + regd16 &= mask; + mask = ~mask; + base += (uae_s8)dp; + regd &= mask; + regd |= regd16; + return base + regd; +#endif +} + +void MakeSR (void) { #if 0 assert((regs.t1 & 1) == regs.t1); @@ -519,11 +614,11 @@ void MakeSR(void) #endif regs.sr = ((regs.t1 << 15) | (regs.t0 << 14) | (regs.s << 13) | (regs.m << 12) | (regs.intmask << 8) - | (XFLG << 4) | (NFLG << 3) | (ZFLG << 2) | (VFLG << 1) - | CFLG); + | (GET_XFLG << 4) | (GET_NFLG << 3) | (GET_ZFLG << 2) | (GET_VFLG << 1) + | GET_CFLG); } -void MakeFromSR(void) +void MakeFromSR (void) { int oldm = regs.m; int olds = regs.s; @@ -533,11 +628,11 @@ void MakeFromSR(void) regs.s = (regs.sr >> 13) & 1; regs.m = (regs.sr >> 12) & 1; regs.intmask = (regs.sr >> 8) & 7; - XFLG = (regs.sr >> 4) & 1; - NFLG = (regs.sr >> 3) & 1; - ZFLG = (regs.sr >> 2) & 1; - VFLG = (regs.sr >> 1) & 1; - CFLG = regs.sr & 1; + SET_XFLG ((regs.sr >> 4) & 1); + SET_NFLG ((regs.sr >> 3) & 1); + SET_ZFLG ((regs.sr >> 2) & 1); + SET_VFLG ((regs.sr >> 1) & 1); + SET_CFLG (regs.sr & 1); if (currprefs.cpu_level >= 2) { if (olds != regs.s) { if (olds) { @@ -658,11 +753,12 @@ static void Interrupt(int nr) static int caar, cacr; -void m68k_move2c (int regno, uae_u32 *regp) +int m68k_move2c (int regno, uae_u32 *regp) { - if (currprefs.cpu_level == 1 && (regno & 0x7FF) > 1) + if (currprefs.cpu_level == 1 && (regno & 0x7FF) > 1) { op_illg (0x4E7B); - else + return 0; + } else switch (regno) { case 0: regs.sfc = *regp & 7; break; case 1: regs.dfc = *regp & 7; break; @@ -674,15 +770,17 @@ void m68k_move2c (int regno, uae_u32 *re case 0x804: regs.isp = *regp; if (regs.m == 0) m68k_areg(regs, 7) = regs.isp; break; default: op_illg (0x4E7B); - break; + return 0; } + return 1; } -void m68k_movec2 (int regno, uae_u32 *regp) +int m68k_movec2 (int regno, uae_u32 *regp) { - if (currprefs.cpu_level == 1 && (regno & 0x7FF) > 1) + if (currprefs.cpu_level == 1 && (regno & 0x7FF) > 1) { op_illg (0x4E7A); - else + return 0; + } else switch (regno) { case 0: *regp = regs.sfc; break; case 1: *regp = regs.dfc; break; @@ -694,18 +792,19 @@ void m68k_movec2 (int regno, uae_u32 *re case 0x804: *regp = regs.m == 0 ? m68k_areg(regs, 7) : regs.isp; break; default: op_illg (0x4E7A); - break; + return 0; } + return 1; } -static __inline__ int +STATIC_INLINE int div_unsigned(uae_u32 src_hi, uae_u32 src_lo, uae_u32 div, uae_u32 *quot, uae_u32 *rem) { uae_u32 q = 0, cbit = 0; int i; if (div <= src_hi) { - return(1); + return 1; } for (i = 0 ; i < 32 ; i++) { cbit = src_hi & 0x80000000ul; @@ -720,14 +819,14 @@ div_unsigned(uae_u32 src_hi, uae_u32 src } *quot = q; *rem = src_hi; - return(0); + return 0; } void m68k_divl (uae_u32 opcode, uae_u32 src, uae_u16 extra, uaecptr oldpc) { #if defined(uae_s64) if (src == 0) { - Exception(5,oldpc); + Exception (5, oldpc); return; } if (extra & 0x800) { @@ -744,14 +843,15 @@ void m68k_divl (uae_u32 opcode, uae_u32 if ((quot & UVAL64(0xffffffff80000000)) != 0 && (quot & UVAL64(0xffffffff80000000)) != UVAL64(0xffffffff80000000)) { - VFLG = NFLG = 1; - CFLG = 0; - } - else { + SET_VFLG (1); + SET_NFLG (1); + SET_CFLG (0); + } else { if (((uae_s32)rem < 0) != ((uae_s64)a < 0)) rem = -rem; - VFLG = CFLG = 0; - ZFLG = ((uae_s32)quot) == 0; - NFLG = ((uae_s32)quot) < 0; + SET_VFLG (0); + SET_CFLG (0); + SET_ZFLG (((uae_s32)quot) == 0); + SET_NFLG (((uae_s32)quot) < 0); m68k_dreg(regs, extra & 7) = rem; m68k_dreg(regs, (extra >> 12) & 7) = quot; } @@ -767,20 +867,21 @@ void m68k_divl (uae_u32 opcode, uae_u32 rem = a % (uae_u64)src; quot = a / (uae_u64)src; if (quot > 0xffffffffu) { - VFLG = NFLG = 1; - CFLG = 0; - } - else { - VFLG = CFLG = 0; - ZFLG = ((uae_s32)quot) == 0; - NFLG = ((uae_s32)quot) < 0; + SET_VFLG (1); + SET_NFLG (1); + SET_CFLG (0); + } else { + SET_VFLG (0); + SET_CFLG (0); + SET_ZFLG (((uae_s32)quot) == 0); + SET_NFLG (((uae_s32)quot) < 0); m68k_dreg(regs, extra & 7) = rem; m68k_dreg(regs, (extra >> 12) & 7) = quot; } } #else if (src == 0) { - Exception(5,oldpc); + Exception (5, oldpc); return; } if (extra & 0x800) { @@ -797,22 +898,23 @@ void m68k_divl (uae_u32 opcode, uae_u32 save_high = hi; sign = (hi ^ src); if (hi < 0) { - hi = ~hi; - lo = -lo; - if (lo == 0) hi++; + hi = ~hi; + lo = -lo; + if (lo == 0) hi++; } if ((uae_s32)src < 0) src = -src; if (div_unsigned(hi, lo, src, ", &rem) || (sign & 0x80000000) ? quot > 0x80000000 : quot > 0x7fffffff) { - VFLG = NFLG = 1; - CFLG = 0; - } - else { + SET_VFLG (1); + SET_NFLG (1); + SET_CFLG (0); + } else { if (sign & 0x80000000) quot = -quot; if (((uae_s32)rem < 0) != (save_high < 0)) rem = -rem; - VFLG = CFLG = 0; - ZFLG = ((uae_s32)quot) == 0; - NFLG = ((uae_s32)quot) < 0; + SET_VFLG (0); + SET_CFLG (0); + SET_ZFLG (((uae_s32)quot) == 0); + SET_NFLG (((uae_s32)quot) < 0); m68k_dreg(regs, extra & 7) = rem; m68k_dreg(regs, (extra >> 12) & 7) = quot; } @@ -826,13 +928,14 @@ void m68k_divl (uae_u32 opcode, uae_u32 hi = (uae_u32)m68k_dreg(regs, extra & 7); } if (div_unsigned(hi, lo, src, ", &rem)) { - VFLG = NFLG = 1; - CFLG = 0; - } - else { - VFLG = CFLG = 0; - ZFLG = ((uae_s32)quot) == 0; - NFLG = ((uae_s32)quot) < 0; + SET_VFLG (1); + SET_NFLG (1); + SET_CFLG (0); + } else { + SET_VFLG (0); + SET_CFLG (0); + SET_ZFLG (((uae_s32)quot) == 0); + SET_NFLG (((uae_s32)quot) < 0); m68k_dreg(regs, extra & 7) = rem; m68k_dreg(regs, (extra >> 12) & 7) = quot; } @@ -840,7 +943,7 @@ void m68k_divl (uae_u32 opcode, uae_u32 #endif } -static __inline__ void +STATIC_INLINE void mul_unsigned(uae_u32 src1, uae_u32 src2, uae_u32 *dst_hi, uae_u32 *dst_lo) { uae_u32 r0 = (src1 & 0xffff) * (src2 & 0xffff); @@ -867,15 +970,16 @@ void m68k_mull (uae_u32 opcode, uae_u32 uae_s64 a = (uae_s64)(uae_s32)m68k_dreg(regs, (extra >> 12) & 7); a *= (uae_s64)(uae_s32)src; - VFLG = CFLG = 0; - ZFLG = a == 0; - NFLG = a < 0; + SET_VFLG (0); + SET_CFLG (0); + SET_ZFLG (a == 0); + SET_NFLG (a < 0); if (extra & 0x400) m68k_dreg(regs, extra & 7) = a >> 32; else if ((a & UVAL64(0xffffffff80000000)) != 0 && (a & UVAL64(0xffffffff80000000)) != UVAL64(0xffffffff80000000)) { - VFLG = 1; + SET_VFLG (1); } m68k_dreg(regs, (extra >> 12) & 7) = (uae_u32)a; } else { @@ -883,13 +987,14 @@ void m68k_mull (uae_u32 opcode, uae_u32 uae_u64 a = (uae_u64)(uae_u32)m68k_dreg(regs, (extra >> 12) & 7); a *= (uae_u64)src; - VFLG = CFLG = 0; - ZFLG = a == 0; - NFLG = ((uae_s64)a) < 0; + SET_VFLG (0); + SET_CFLG (0); + SET_ZFLG (a == 0); + SET_NFLG (((uae_s64)a) < 0); if (extra & 0x400) m68k_dreg(regs, extra & 7) = a >> 32; else if ((a & UVAL64(0xffffffff00000000)) != 0) { - VFLG = 1; + SET_VFLG (1); } m68k_dreg(regs, (extra >> 12) & 7) = (uae_u32)a; } @@ -911,16 +1016,17 @@ void m68k_mull (uae_u32 opcode, uae_u32 dst_lo = -dst_lo; if (dst_lo == 0) dst_hi++; } - VFLG = CFLG = 0; - ZFLG = dst_hi == 0 && dst_lo == 0; - NFLG = ((uae_s32)dst_hi) < 0; + SET_VFLG (0); + SET_CFLG (0); + SET_ZFLG (dst_hi == 0 && dst_lo == 0); + SET_NFLG (((uae_s32)dst_hi) < 0); if (extra & 0x400) m68k_dreg(regs, extra & 7) = dst_hi; else if ((dst_hi != 0 || (dst_lo & 0x80000000) != 0) && ((dst_hi & 0xffffffff) != 0xffffffff || (dst_lo & 0x80000000) != 0x80000000)) { - VFLG = 1; + SET_VFLG (1); } m68k_dreg(regs, (extra >> 12) & 7) = dst_lo; } else { @@ -929,13 +1035,14 @@ void m68k_mull (uae_u32 opcode, uae_u32 mul_unsigned(src,(uae_u32)m68k_dreg(regs, (extra >> 12) & 7),&dst_hi,&dst_lo); - VFLG = CFLG = 0; - ZFLG = dst_hi == 0 && dst_lo == 0; - NFLG = ((uae_s32)dst_hi) < 0; + SET_VFLG (0); + SET_CFLG (0); + SET_ZFLG (dst_hi == 0 && dst_lo == 0); + SET_NFLG (((uae_s32)dst_hi) < 0); if (extra & 0x400) m68k_dreg(regs, extra & 7) = dst_hi; else if (dst_hi != 0) { - VFLG = 1; + SET_VFLG (1); } m68k_dreg(regs, (extra >> 12) & 7) = dst_lo; } @@ -945,7 +1052,7 @@ static char* ccnames[] = { "T ","F ","HI","LS","CC","CS","NE","EQ", "VC","VS","PL","MI","GE","LT","GT","LE" }; -void m68k_reset(void) +void m68k_reset (void) { m68k_areg (regs, 7) = get_long (0x00f80000); m68k_setpc (get_long (0x00f80004)); @@ -956,28 +1063,31 @@ void m68k_reset(void) regs.stopped = 0; regs.t1 = 0; regs.t0 = 0; - ZFLG = CFLG = NFLG = VFLG = 0; + SET_ZFLG (0); + SET_XFLG (0); + SET_CFLG (0); + SET_VFLG (0); + SET_NFLG (0); regs.spcflags = 0; regs.intmask = 7; regs.vbr = regs.sfc = regs.dfc = 0; regs.fpcr = regs.fpsr = regs.fpiar = 0; - customreset (); } -void REGPARAM2 op_illg(uae_u32 opcode) +unsigned long REGPARAM2 op_illg (uae_u32 opcode) { uaecptr pc = m68k_getpc (); - + if (cloanto_rom && (opcode & 0xF100) == 0x7100) { m68k_dreg (regs, (opcode >> 9) & 7) = (uae_s8)(opcode & 0xFF); m68k_incpc (2); fill_prefetch_0 (); - return; + return 4; } compiler_flush_jsr_stack (); if (opcode == 0x4E7B && get_long (0x10) == 0 && (pc & 0xF80000) == 0xF80000) { - write_log("Your Kickstart requires a 68020 CPU. Giving up.\n"); + write_log ("Your Kickstart requires a 68020 CPU. Giving up.\n"); broken_in = 1; regs.spcflags |= SPCFLAG_BRK; quit_program = 1; @@ -989,11 +1099,11 @@ void REGPARAM2 op_illg(uae_u32 opcode) m68k_incpc (4); ersatz_perform (arg); fill_prefetch_0 (); - return; + return 4; } else if ((pc & 0xF80000) == 0xF00000) { /* User-mode STOP replacement */ m68k_setstopped (1); - return; + return 4; } } @@ -1002,12 +1112,12 @@ void REGPARAM2 op_illg(uae_u32 opcode) m68k_incpc(2); call_calltrap (opcode & 0xFFF); fill_prefetch_0 (); - return; + return 4; } if ((opcode & 0xF000) == 0xF000) { Exception(0xB,0); - return; + return 4; } if ((opcode & 0xF000) == 0xA000) { if ((pc & 0xF80000) == 0xF00000) { @@ -1015,11 +1125,13 @@ void REGPARAM2 op_illg(uae_u32 opcode) call_calltrap (opcode & 0xFFF); } Exception(0xA,0); - return; + return 4; } - sprintf (warning_buffer, "Illegal instruction: %04x at %08lx\n", opcode, pc); - write_log (warning_buffer); +#if 0 + write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc); +#endif Exception (4,0); + return 4; } void mmu_op(uae_u32 opcode, uae_u16 extra) @@ -1032,90 +1144,84 @@ void mmu_op(uae_u32 opcode, uae_u16 extr op_illg (opcode); } -static int n_insns=0, n_spcinsns=0; +static int n_insns = 0, n_spcinsns = 0; static uaecptr last_trace_ad = 0; -static __inline__ void do_trace(void) +static void do_trace (void) { - if (regs.spcflags & SPCFLAG_TRACE) { /* 6 */ - if (regs.t0) { - uae_u16 opcode; - /* should also include TRAP, CHK, SR modification FPcc */ - /* probably never used so why bother */ - /* We can afford this to be inefficient... */ - m68k_setpc (m68k_getpc ()); - fill_prefetch_0 (); - opcode = get_word (regs.pc); - if (opcode == 0x4e72 /* RTE */ - || opcode == 0x4e74 /* RTD */ - || opcode == 0x4e75 /* RTS */ - || opcode == 0x4e77 /* RTR */ - || opcode == 0x4e76 /* TRAPV */ - || (opcode & 0xffc0) == 0x4e80 /* JSR */ - || (opcode & 0xffc0) == 0x4ec0 /* JMP */ - || (opcode & 0xff00) == 0x6100 /* BSR */ - || ((opcode & 0xf000) == 0x6000 /* Bcc */ - && cctrue((opcode >> 8) & 0xf)) - || ((opcode & 0xf0f0) == 0x5050 /* DBcc */ - && !cctrue((opcode >> 8) & 0xf) - && (uae_s16)m68k_dreg(regs, opcode & 7) != 0)) - { - last_trace_ad = m68k_getpc(); - regs.spcflags &= ~SPCFLAG_TRACE; - regs.spcflags |= SPCFLAG_DOTRACE; - } - } else if (regs.t1) { - last_trace_ad = m68k_getpc(); + if (regs.t0) { + uae_u16 opcode; + /* should also include TRAP, CHK, SR modification FPcc */ + /* probably never used so why bother */ + /* We can afford this to be inefficient... */ + m68k_setpc (m68k_getpc ()); + fill_prefetch_0 (); + opcode = get_word (regs.pc); + if (opcode == 0x4e72 /* RTE */ + || opcode == 0x4e74 /* RTD */ + || opcode == 0x4e75 /* RTS */ + || opcode == 0x4e77 /* RTR */ + || opcode == 0x4e76 /* TRAPV */ + || (opcode & 0xffc0) == 0x4e80 /* JSR */ + || (opcode & 0xffc0) == 0x4ec0 /* JMP */ + || (opcode & 0xff00) == 0x6100 /* BSR */ + || ((opcode & 0xf000) == 0x6000 /* Bcc */ + && cctrue((opcode >> 8) & 0xf)) + || ((opcode & 0xf0f0) == 0x5050 /* DBcc */ + && !cctrue((opcode >> 8) & 0xf) + && (uae_s16)m68k_dreg(regs, opcode & 7) != 0)) + { + last_trace_ad = m68k_getpc (); regs.spcflags &= ~SPCFLAG_TRACE; regs.spcflags |= SPCFLAG_DOTRACE; } + } else if (regs.t1) { + last_trace_ad = m68k_getpc (); + regs.spcflags &= ~SPCFLAG_TRACE; + regs.spcflags |= SPCFLAG_DOTRACE; } } + static int do_specialties (void) { + if (regs.spcflags & SPCFLAG_COPPER) + do_copper (); + /*n_spcinsns++;*/ while (regs.spcflags & SPCFLAG_BLTNASTY) { - do_cycles(); - if (regs.spcflags & SPCFLAG_DISK) - do_disk(); + do_cycles (4); + if (regs.spcflags & SPCFLAG_COPPER) + do_copper (); } + run_compiled_code(); if (regs.spcflags & SPCFLAG_DOTRACE) { - Exception(9,last_trace_ad); + Exception (9,last_trace_ad); } while (regs.spcflags & SPCFLAG_STOP) { - do_cycles(); - if (regs.spcflags & SPCFLAG_DISK) - do_disk(); + do_cycles (4); + if (regs.spcflags & SPCFLAG_COPPER) + do_copper (); if (regs.spcflags & (SPCFLAG_INT | SPCFLAG_DOINT)){ - int intr = intlev(); + int intr = intlev (); regs.spcflags &= ~(SPCFLAG_INT | SPCFLAG_DOINT); if (intr != -1 && intr > regs.intmask) { - Interrupt(intr); + Interrupt (intr); regs.stopped = 0; regs.spcflags &= ~SPCFLAG_STOP; } } } - do_trace(); -#ifdef WANT_SLOW_MULTIPLY - /* Kludge for Hardwired demo. The guys who wrote it should be - * mutilated. */ - if (regs.spcflags & SPCFLAG_EXTRA_CYCLES) { - do_cycles (); do_cycles (); do_cycles (); do_cycles (); - regs.spcflags &= ~SPCFLAG_EXTRA_CYCLES; - } -#endif - if (regs.spcflags & SPCFLAG_DISK) - do_disk(); + if (regs.spcflags & SPCFLAG_TRACE) + do_trace (); if (regs.spcflags & SPCFLAG_DOINT) { - int intr = intlev(); + int intr = intlev (); regs.spcflags &= ~SPCFLAG_DOINT; if (intr != -1 && intr > regs.intmask) { - Interrupt(intr); + Interrupt (intr); regs.stopped = 0; } } @@ -1123,17 +1229,59 @@ static int do_specialties (void) regs.spcflags &= ~SPCFLAG_INT; regs.spcflags |= SPCFLAG_DOINT; } - if (regs.spcflags & (SPCFLAG_BRK|SPCFLAG_MODE_CHANGE)) { - regs.spcflags &= ~(SPCFLAG_BRK|SPCFLAG_MODE_CHANGE); + if (regs.spcflags & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE)) { + regs.spcflags &= ~(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE); return 1; } return 0; } -static void m68k_run_1(void) +/* It's really sad to have two almost identical functions for this, but we + do it all for performance... :( */ +static void m68k_run_1 (void) +{ + for (;;) { + int cycles; + uae_u32 opcode = get_iword_prefetch (0); +#if 0 + if (get_ilong (0) != do_get_mem_long (®s.prefetch)) { + debugging = 1; + return; + } +#endif + /* assert (!regs.stopped && !(regs.spcflags & SPCFLAG_STOP)); */ +/* regs_backup[backup_pointer = (backup_pointer + 1) % 16] = regs;*/ +#if COUNT_INSTRS == 2 + if (table68k[opcode].handler != -1) + instrcount[table68k[opcode].handler]++; +#elif COUNT_INSTRS == 1 + instrcount[opcode]++; +#endif +#if defined X86_ASSEMBLY + __asm__ __volatile__("\tcall *%%ebx" + : "=&a" (cycles) : "b" (cpufunctbl[opcode]), "0" (opcode) + : "%edx", "%ecx", + "%esi", "%edi", "%ebp", "memory", "cc"); +#else + cycles = (*cpufunctbl[opcode])(opcode); +#endif + /*n_insns++;*/ + cycles &= cycles_mask; + cycles |= cycles_val; + do_cycles (cycles); + if (regs.spcflags) { + if (do_specialties ()) + return; + } + } +} + +/* Same thing, but don't use prefetch to get opcode. */ +static void m68k_run_2 (void) { for (;;) { - uae_u32 opcode = get_iword(0); + int cycles; + uae_u32 opcode = get_iword (0); #if 0 if (get_ilong (0) != do_get_mem_long (®s.prefetch)) { debugging = 1; @@ -1148,60 +1296,66 @@ static void m68k_run_1(void) #elif COUNT_INSTRS == 1 instrcount[opcode]++; #endif -#if defined(X86_ASSEMBLY) +#if defined X86_ASSEMBLY __asm__ __volatile__("\tcall *%%ebx" - : : "b" (cpufunctbl[opcode]), "a" (opcode) + : "=&a" (cycles) : "b" (cpufunctbl[opcode]), "0" (opcode) : "%edx", "%ecx", "%esi", "%edi", "%ebp", "memory", "cc"); #else - (*cpufunctbl[opcode])(opcode); + cycles = (*cpufunctbl[opcode])(opcode); #endif /*n_insns++;*/ - do_cycles(); + cycles &= cycles_mask; + cycles |= cycles_val; + do_cycles (cycles); if (regs.spcflags) { - if (do_specialties()) + if (do_specialties ()) return; } } } #ifdef X86_ASSEMBLY -static __inline__ void m68k_run1(void) +STATIC_INLINE void m68k_run1 (void (*func)(void)) { /* Work around compiler bug: GCC doesn't push %ebp in m68k_run_1. */ - __asm__ __volatile__ ("pushl %%ebp\n\tcall *%0\n\tpopl %%ebp" : : "r" (m68k_run_1) : "%eax", "%edx", "%ecx", "memory", "cc"); + __asm__ __volatile__ ("pushl %%ebp\n\tcall *%0\n\tpopl %%ebp" + : : "r" (func) : "%eax", "%edx", "%ecx", "memory", "cc"); } #else -#define m68k_run1 m68k_run_1 +#define m68k_run1(F) F #endif int in_m68k_go = 0; -void m68k_go(int may_quit) +void m68k_go (int may_quit) { if (in_m68k_go || !may_quit) { - write_log("Bug! m68k_go is not reentrant.\n"); - abort(); + write_log ("Bug! m68k_go is not reentrant.\n"); + abort (); } -#ifdef FRAME_RATE_HACK - vsyncmintime = read_processor_time () + vsynctime; -#endif + + reset_frame_rate_hack (); + update_68k_cycles (); + in_m68k_go++; for (;;) { if (quit_program > 0) { if (quit_program == 1) break; quit_program = 0; - m68k_reset(); + m68k_reset (); + reset_all_systems (); + customreset (); } if (debugging) - debug(); - m68k_run1(); + debug (); + m68k_run1 (currprefs.cpu_compatible ? m68k_run_1 : m68k_run_2); } in_m68k_go--; } -static void m68k_verify(uaecptr addr, uaecptr *nextpc) +static void m68k_verify (uaecptr addr, uaecptr *nextpc) { uae_u32 opcode, val; struct instr *dp; @@ -1210,7 +1364,7 @@ static void m68k_verify(uaecptr addr, ua last_op_for_exception_3 = opcode; m68kpc_offset = 2; - if (cpufunctbl[opcode] == op_illg) { + if (cpufunctbl[opcode] == op_illg_1) { opcode = 0x4AFC; } dp = table68k + opcode; @@ -1229,33 +1383,33 @@ static void m68k_verify(uaecptr addr, ua } } -void m68k_disasm(uaecptr addr, uaecptr *nextpc, int cnt) +void m68k_disasm (uaecptr addr, uaecptr *nextpc, int cnt) { uaecptr newpc = 0; - m68kpc_offset = addr - m68k_getpc(); - for (;cnt--;){ + m68kpc_offset = addr - m68k_getpc (); + while (cnt-- > 0) { char instrname[20],*ccpt; int opwords; uae_u32 opcode; struct mnemolookup *lookup; struct instr *dp; - printf ("%08lx: ", m68k_getpc() + m68kpc_offset); + printf ("%08lx: ", m68k_getpc () + m68kpc_offset); for (opwords = 0; opwords < 5; opwords++){ - printf ("%04x ", get_iword_1(m68kpc_offset + opwords*2)); + printf ("%04x ", get_iword_1 (m68kpc_offset + opwords*2)); } - opcode = get_iword_1(m68kpc_offset); + opcode = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; - if (cpufunctbl[opcode] == op_illg) { + if (cpufunctbl[opcode] == op_illg_1) { opcode = 0x4AFC; } dp = table68k + opcode; for (lookup = lookuptab;lookup->mnemo != dp->mnemo; lookup++) ; - strcpy(instrname,lookup->name); - ccpt = strstr(instrname,"cc"); + strcpy (instrname, lookup->name); + ccpt = strstr (instrname, "cc"); if (ccpt != 0) { - strncpy(ccpt,ccnames[dp->cc],2); + strncpy (ccpt, ccnames[dp->cc], 2); } printf ("%s", instrname); switch (dp->size){ @@ -1266,28 +1420,29 @@ void m68k_disasm(uaecptr addr, uaecptr * } if (dp->suse) { - newpc = m68k_getpc() + m68kpc_offset; - newpc += ShowEA(dp->sreg, dp->smode, dp->size, 0); + newpc = m68k_getpc () + m68kpc_offset; + newpc += ShowEA (dp->sreg, dp->smode, dp->size, 0); } if (dp->suse && dp->duse) printf (","); if (dp->duse) { - newpc = m68k_getpc() + m68kpc_offset; - newpc += ShowEA(dp->dreg, dp->dmode, dp->size, 0); + newpc = m68k_getpc () + m68kpc_offset; + newpc += ShowEA (dp->dreg, dp->dmode, dp->size, 0); } if (ccpt != 0) { if (cctrue(dp->cc)) - printf (" == %08lx (TRUE)",newpc); + printf (" == %08lx (TRUE)", newpc); else - printf (" == %08lx (FALSE)",newpc); + printf (" == %08lx (FALSE)", newpc); } else if ((opcode & 0xff00) == 0x6100) /* BSR */ - printf (" == %08lx",newpc); + printf (" == %08lx", newpc); printf ("\n"); } - if (nextpc) *nextpc = m68k_getpc() + m68kpc_offset; + if (nextpc) + *nextpc = m68k_getpc () + m68kpc_offset; } -void m68k_dumpstate(uaecptr *nextpc) +void m68k_dumpstate (uaecptr *nextpc) { int i; for (i = 0; i < 8; i++){ @@ -1305,7 +1460,7 @@ void m68k_dumpstate(uaecptr *nextpc) regs.usp,regs.isp,regs.msp,regs.vbr); printf ("T=%d%d S=%d M=%d X=%d N=%d Z=%d V=%d C=%d IMASK=%d\n", regs.t1, regs.t0, regs.s, regs.m, - XFLG, NFLG, ZFLG, VFLG, CFLG, regs.intmask); + GET_XFLG, GET_NFLG, GET_ZFLG, GET_VFLG, GET_CFLG, regs.intmask); for (i = 0; i < 8; i++){ printf ("FP%d: %g ", i, regs.fp[i]); if ((i & 3) == 3) printf ("\n"); @@ -1318,6 +1473,7 @@ void m68k_dumpstate(uaecptr *nextpc) if (currprefs.cpu_compatible) printf ("prefetch %08lx\n", (unsigned long)do_get_mem_long(®s.prefetch)); - m68k_disasm(m68k_getpc(), nextpc, 1); - if (nextpc) printf ("next PC: %08lx\n", *nextpc); + m68k_disasm(m68k_getpc (), nextpc, 1); + if (nextpc) + printf ("next PC: %08lx\n", *nextpc); }