From 963cce9f00082e6c08b39a5b4ba1296ed2a2ebea Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 9 Jan 2006 14:43:10 +0200 Subject: [PATCH] imported winuaesrc1200b5.zip --- audio.c | 65 +- cfgfile.c | 8 +- cia.c | 4 +- compemu_fpp.c | 1217 ++++++++++++----------- compemu_raw_x86.c | 187 ++-- custom.c | 19 +- debug.c | 1 + disk.c | 12 +- drawing.c | 2 +- filesys.c | 85 +- inputdevice.c | 10 +- od-win32/dinput.c | 11 +- od-win32/direct3d.c | 5 + od-win32/fsdb_win32.c | 31 +- od-win32/opengl.c | 5 +- od-win32/resources/resource.h | 5 +- od-win32/resources/winuae.rc | 34 +- od-win32/sounddep/sound.c | 4 +- od-win32/sounddep/sound.h | 10 +- od-win32/win32.c | 4 +- od-win32/win32.h | 2 +- od-win32/win32gui.c | 6 +- od-win32/winuae_msvc/winuae_msvc.vcproj | 2 +- 23 files changed, 985 insertions(+), 744 deletions(-) diff --git a/audio.c b/audio.c index 0e3a7e74..0ea9ceae 100755 --- a/audio.c +++ b/audio.c @@ -25,6 +25,7 @@ #include "driveclick.h" #include "zfile.h" #include "uae.h" +#include "gui.h" #ifdef AVIOUTPUT #include "avioutput.h" #endif @@ -285,6 +286,62 @@ static int saved_ptr; #define MIXED_STEREO_MAX 32 static int mixed_on, mixed_stereo_size, mixed_mul1, mixed_mul2; +static double l_output[3], r_output[3]; +static double f_36, f_33, f_135; + +/* Amiga has two separate filtering circuits per channel, a static RC filter + * on A500 and the LED filter. This code emulates both. + * + * The Amiga filtering circuitry depends on Amiga model. Older Amigas seem + * to have a 6 dB/oct RC filter with cutoff frequency such that the -6 dB + * point for filter is reached at 6 kHz, while newer Amigas have no filtering. + * + * The LED filter is complicated, and we are modelling it with a pair of + * RC filters, the other providing a highboost. The LED starts to cut + * into signal somewhere around 5-6 kHz, and there's some kind of highboost + * in effect above 12 kHz. Better measurements are required. + * + * The current filtering should be accurate to 2 dB with the filter on, + * and to 1 dB with the filter off. +*/ + +static int filter(int data, double *output) +{ + double s, o; + + data = (uae_s16)data; + + if (currprefs.sound_freq != 44100) + return data; + + if (currprefs.sound_filter == FILTER_SOUND_ON_A500 || + (currprefs.sound_filter == FILTER_SOUND_EMUL && !(currprefs.chipset_mask & CSMASK_AGA)) + ) { + s = 0.36 * data; + s += 0.64 * output[2]; + output[2] = s; + } else { + output[2] = data; + } + /* output[0] is output[2] through lowpass */ + s = 0.33 * output[2]; + s += 0.67 * output[0]; + output[0] = s; + /* output[1] is output[2] with slight highboost */ + s = 1.35 * output[0]; + s -= 0.35 * output[1]; + output[1] = s; + if (gui_data.powerled) + o = output[2]; + else + o = output[1] * 0.98; /* to avoid overruns */ + if (o > 32767) + o = 32767; + else if (o < -32768) + o = -32768; + return (int)o; +} + STATIC_INLINE void put_sound_word_right (uae_u32 w) { if (mixed_on) { @@ -338,7 +395,7 @@ void sample16_handler (void) { uae_u32 data = SBASEVAL16(2) + data0; FINISH_DATA (data, 16, 2); - PUT_SOUND_WORD (data); + PUT_SOUND_WORD_MONO (data); } check_sound_buffers (); } @@ -389,7 +446,7 @@ void sample16i_rh_handler (void) { uae_u32 data = SBASEVAL16(2) + data0; FINISH_DATA (data, 16, 2); - PUT_SOUND_WORD (data); + PUT_SOUND_WORD_MONO (data); } check_sound_buffers (); } @@ -460,7 +517,7 @@ void sample16i_crux_handler (void) { uae_u32 data = SBASEVAL16(2) + data0; FINISH_DATA (data, 16, 2); - PUT_SOUND_WORD (data); + PUT_SOUND_WORD_MONO (data); } check_sound_buffers (); } @@ -892,6 +949,8 @@ void audio_reset (void) ahi_close_sound (); #endif reset_sound (); + memset(l_output, 0, sizeof l_output); + memset(r_output, 0, sizeof r_output); if (savestate_state != STATE_RESTORE) { for (i = 0; i < 4; i++) { cdp = &audio_channel[i]; diff --git a/cfgfile.c b/cfgfile.c index 6ab85147..a6a4c798 100755 --- a/cfgfile.c +++ b/cfgfile.c @@ -138,7 +138,7 @@ static const char *collmode[] = { "none", "sprites", "playfields", "full", 0 }; static const char *compmode[] = { "direct", "indirect", "indirectKS", "afterPic", 0 }; static const char *flushmode[] = { "soft", "hard", 0 }; static const char *kbleds[] = { "none", "POWER", "DF0", "DF1", "DF2", "DF3", "HD", "CD", 0 }; -static const char *soundfiltermode[] = { "off", "emulated", "on", 0 }; +static const char *soundfiltermode[] = { "off", "emulated", "on", "on_aga", 0 }; static const char *loresmode[] = { "normal", "filtered", 0 }; #ifdef GFXFILTER static const char *filtermode1[] = { "no_16", "bilinear_16", "no_32", "bilinear_32", 0 }; @@ -2326,7 +2326,7 @@ void default_prefs (struct uae_prefs *p, int type) p->sound_freq = DEFAULT_SOUND_FREQ; p->sound_maxbsiz = DEFAULT_SOUND_MAXB; p->sound_interpol = 0; - p->sound_filter = 1; + p->sound_filter = FILTER_SOUND_OFF; p->comptrustbyte = 0; p->comptrustword = 0; @@ -2467,7 +2467,7 @@ static void buildin_default_prefs_68020 (struct uae_prefs *p) static void buildin_default_host_prefs (struct uae_prefs *p) { - p->sound_filter = 1; + p->sound_filter = FILTER_SOUND_OFF; p->sound_stereo = 1; p->sound_stereo_separation = 7; p->sound_mixed_stereo = 0; @@ -2570,7 +2570,7 @@ static int bip_a1000 (struct uae_prefs *p, int config, int compa, int romcheck) roms[2] = -1; p->chipset_mask = 0; p->bogomem_size = 0; - p->sound_filter = 2; + p->sound_filter = FILTER_SOUND_ON_A500; if (config == 1) p->chipmem_size = 0x40000; set_68000_compa (p, compa); diff --git a/cia.c b/cia.c index 8d2cb867..3d1b5871 100755 --- a/cia.c +++ b/cia.c @@ -759,7 +759,7 @@ static void WriteCIAA (uae_u16 addr,uae_u8 val) ciaaalarm = (ciaaalarm & ~0xff00) | (val << 8); } else { ciaatod = (ciaatod & ~0xff00) | (val << 8); - ciaatodon = 0; + //ciaatodon = 0; } break; case 10: @@ -901,7 +901,7 @@ static void WriteCIAB (uae_u16 addr,uae_u8 val) ciabalarm = (ciabalarm & ~0xff00) | (val << 8); } else { ciabtod = (ciabtod & ~0xff00) | (val << 8); - ciabtodon = 0; + //ciabtodon = 0; } break; case 10: diff --git a/compemu_fpp.c b/compemu_fpp.c index 91b78797..ece77149 100755 --- a/compemu_fpp.c +++ b/compemu_fpp.c @@ -23,71 +23,63 @@ #include "compemu.h" #if defined(JIT) - -#define MAKE_FPSR(r) do { fmov_rr(FP_RESULT,r); } while (0) - -uae_s32 temp_fp[] = {0,0,0}; /* To convert between FP and */ +uae_u32 temp_fp[] = {0,0,0}, save_fp[3]; /* To convert between FP and */ /* 128 words, indexed through the low byte of the 68k fpu control word */ static uae_u16 x86_fpucw[]={ - 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, /* p0r0 */ - 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, /* p0r1 */ - 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, /* p0r2 */ - 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, /* p0r3 */ + 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, /* E-RN */ + 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, /* E-RZ */ + 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, /* E-RD */ + 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, /* E-RU */ - 0x107f, 0x107f, 0x107f, 0x107f, 0x107f, 0x107f, 0x107f, 0x107f, /* p1r0 */ - 0x1c7f, 0x1c7f, 0x1c7f, 0x1c7f, 0x1c7f, 0x1c7f, 0x1c7f, 0x1c7f, /* p1r1 */ - 0x147f, 0x147f, 0x147f, 0x147f, 0x147f, 0x147f, 0x147f, 0x147f, /* p1r2 */ - 0x187f, 0x187f, 0x187f, 0x187f, 0x187f, 0x187f, 0x187f, 0x187f, /* p1r3 */ + 0x107f, 0x107f, 0x107f, 0x107f, 0x107f, 0x107f, 0x107f, 0x107f, /* S-RN */ + 0x1c7f, 0x1c7f, 0x1c7f, 0x1c7f, 0x1c7f, 0x1c7f, 0x1c7f, 0x1c7f, /* S-RZ */ + 0x147f, 0x147f, 0x147f, 0x147f, 0x147f, 0x147f, 0x147f, 0x147f, /* S-RD */ + 0x187f, 0x187f, 0x187f, 0x187f, 0x187f, 0x187f, 0x187f, 0x187f, /* S-RU */ - 0x127f, 0x127f, 0x127f, 0x127f, 0x127f, 0x127f, 0x127f, 0x127f, /* p2r0 */ - 0x1e7f, 0x1e7f, 0x1e7f, 0x1e7f, 0x1e7f, 0x1e7f, 0x1e7f, 0x1e7f, /* p2r1 */ - 0x167f, 0x167f, 0x167f, 0x167f, 0x167f, 0x167f, 0x167f, 0x167f, /* p2r2 */ - 0x1a7f, 0x1a7f, 0x1a7f, 0x1a7f, 0x1a7f, 0x1a7f, 0x1a7f, 0x1a7f, /* p2r3 */ + 0x127f, 0x127f, 0x127f, 0x127f, 0x127f, 0x127f, 0x127f, 0x127f, /* D-RN */ + 0x1e7f, 0x1e7f, 0x1e7f, 0x1e7f, 0x1e7f, 0x1e7f, 0x1e7f, 0x1e7f, /* D-RZ */ + 0x167f, 0x167f, 0x167f, 0x167f, 0x167f, 0x167f, 0x167f, 0x167f, /* D-RD */ + 0x1a7f, 0x1a7f, 0x1a7f, 0x1a7f, 0x1a7f, 0x1a7f, 0x1a7f, 0x1a7f, /* D-RU */ - 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, /* p3r0 */ - 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, /* p3r1 */ - 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, /* p3r2 */ - 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f /* p3r3 */ + 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, /* ?-RN */ + 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, /* ?-RZ */ + 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, /* ?-RD */ + 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f /* ?-RU */ }; +static int sz1[8] = { 4, 4, 12, 12, 2, 8, 1, 0 }; +static int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 }; -/* return register number, or -1 for failure */ -STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra) +/* return the required floating point precision or -1 for failure, 0=E, 1=S, 2=D */ +STATIC_INLINE int comp_fp_get (uae_u32 opcode, uae_u16 extra, int treg) { - static int sz1[8] = { 4, 4, 12, 12, 2, 8, 1, 0 }; - static int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 }; int reg = opcode & 7; int mode = (opcode >> 3) & 7; int size = (extra >> 10) & 7; - if (!(extra & 0x4000)) /* R/M=0, from FPx to FPy */ - return size; /* size is the source register FPx */ - if (size == 3) /* packed decimal is not supported on 68040 */ - return -1; - if (size == 7) /* this size is not defined */ + if (size == 3 || size == 7) /* 3 = packed decimal, 7 is not defined */ return -1; - switch (mode) { case 0: /* Dn */ switch (size) { case 0: /* Long */ mov_l_mr((uae_u32)temp_fp,reg); - fmovi_rm(FS1,(uae_u32)temp_fp); - return FS1; + fmovi_rm(treg,(uae_u32)temp_fp); + return 2; case 1: /* Single */ mov_l_mr((uae_u32)temp_fp,reg); - fmovs_rm(FS1,(uae_u32)temp_fp); - return FS1; + fmovs_rm(treg,(uae_u32)temp_fp); + return 1; case 4: /* Word */ sign_extend_16_rr(S1,reg); mov_l_mr((uae_u32)temp_fp,S1); - fmovi_rm(FS1,(uae_u32)temp_fp); - return FS1; + fmovi_rm(treg,(uae_u32)temp_fp); + return 1; case 6: /* Byte */ sign_extend_8_rr(S1,reg); mov_l_mr((uae_u32)temp_fp,S1); - fmovi_rm(FS1,(uae_u32)temp_fp); - return FS1; + fmovi_rm(treg,(uae_u32)temp_fp); + return 1; default: return -1; } @@ -151,30 +143,30 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra) if (li == (int) si) { //write_log ("converted immediate LONG constant to SINGLE\n"); - fmovs_ri(FS1,*(uae_u32 *)&si); - return FS1; + fmovs_ri(treg,*(uae_u32 *)&si); + return 1; } //write_log ("immediate LONG constant\n"); - fmovl_ri(FS1,li); - return FS1; + fmovl_ri(treg,li); + return 2; } case 1: //write_log ("immediate SINGLE constant\n"); - fmovs_ri(FS1,comp_get_ilong(m68k_pc_offset-4)); - return FS1; + fmovs_ri(treg,comp_get_ilong(m68k_pc_offset-4)); + return 1; case 2: //write_log ("immediate LONG DOUBLE constant\n"); - fmov_ext_ri(FS1,comp_get_ilong(m68k_pc_offset-4), + fmov_ext_ri(treg,comp_get_ilong(m68k_pc_offset-4), comp_get_ilong(m68k_pc_offset-8), (comp_get_ilong(m68k_pc_offset-12)>>16)&0xffff); - return FS1; + return 0; case 4: { float si = (float)(uae_s16)comp_get_iword(m68k_pc_offset-2); //write_log ("converted immediate WORD constant to SINGLE\n"); - fmovs_ri(FS1,*(uae_u32 *)&si); - return FS1; + fmovs_ri(treg,*(uae_u32 *)&si); + return 1; } case 5: { @@ -184,20 +176,20 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra) if (*(double *)longarray == (double)si) { //write_log ("SPEED GAIN: converted a DOUBLE constant to SINGLE\n"); - fmovs_ri(FS1,*(uae_u32 *)&si); - return FS1; + fmovs_ri(treg,*(uae_u32 *)&si); + return 1; } //write_log ("immediate DOUBLE constant\n"); - fmov_ri(FS1,longarray[0],longarray[1]); - return FS1; + fmov_ri(treg,longarray[0],longarray[1]); + return 2; } case 6: { float si = (float)(uae_s8)comp_get_ibyte(m68k_pc_offset-2); //write_log ("immediate BYTE constant converted to SINGLE\n"); - fmovs_ri(FS1,*(uae_u32 *)&si); - return FS1; + fmovs_ri(treg,*(uae_u32 *)&si); + return 1; } default: /* never reached */ return -1; @@ -211,13 +203,13 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra) case 0: /* Long */ readlong(S1,S2,S3); mov_l_mr((uae_u32)temp_fp,S2); - fmovi_rm(FS1,(uae_u32)temp_fp); - return FS1; + fmovi_rm(treg,(uae_u32)temp_fp); + return 2; case 1: /* Single */ readlong(S1,S2,S3); mov_l_mr((uae_u32)temp_fp,S2); - fmovs_rm(FS1,(uae_u32)temp_fp); - return FS1; + fmovs_rm(treg,(uae_u32)temp_fp); + return 1; case 2: /* Long Double */ readword(S1,S2,S3); mov_w_mr(((uae_u32)temp_fp)+8,S2); @@ -227,28 +219,28 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra) add_l_ri(S1,4); readlong(S1,S2,S3); mov_l_mr((uae_u32)(temp_fp),S2); - fmov_ext_rm(FS1,(uae_u32)(temp_fp)); - return FS1; + fmov_ext_rm(treg,(uae_u32)(temp_fp)); + return 0; case 4: /* Word */ readword(S1,S2,S3); sign_extend_16_rr(S2,S2); mov_l_mr((uae_u32)temp_fp,S2); - fmovi_rm(FS1,(uae_u32)temp_fp); - return FS1; + fmovi_rm(treg,(uae_u32)temp_fp); + return 1; case 5: /* Double */ readlong(S1,S2,S3); mov_l_mr(((uae_u32)temp_fp)+4,S2); add_l_ri(S1,4); readlong(S1,S2,S3); mov_l_mr((uae_u32)(temp_fp),S2); - fmov_rm(FS1,(uae_u32)(temp_fp)); - return FS1; + fmov_rm(treg,(uae_u32)(temp_fp)); + return 2; case 6: /* Byte */ readbyte(S1,S2,S3); sign_extend_8_rr(S2,S2); mov_l_mr((uae_u32)temp_fp,S2); - fmovi_rm(FS1,(uae_u32)temp_fp); - return FS1; + fmovi_rm(treg,(uae_u32)temp_fp); + return 1; default: return -1; } @@ -256,23 +248,15 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra) } /* return of -1 means failure, >=0 means OK */ -STATIC_INLINE int put_fp_value (int val, uae_u32 opcode, uae_u16 extra) +STATIC_INLINE int comp_fp_put (uae_u32 opcode, uae_u16 extra) { - static int sz1[8] = { 4, 4, 12, 12, 2, 8, 1, 0 }; - static int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 }; int reg = opcode & 7; + int sreg = (extra >> 7) &7; int mode = (opcode >> 3) & 7; int size = (extra >> 10) & 7; - if (!(extra & 0x4000)) { /* R/M=0, from FPx to FPy */ - fmov_rr(size,val); - return 0; - } - if (size == 3) /* packed decimal is not supported on 68040 */ + if (size == 3 || size == 7) /* 3 = packed decimal, 7 is not defined */ return -1; - if (size == 7) /* this size is not defined */ - return -1; - switch (mode) { case 0: /* Dn */ switch (size) { @@ -281,7 +265,7 @@ STATIC_INLINE int put_fp_value (int val, uae_u32 opcode, uae_u16 extra) if (!(regs.fpcr & 0xf0)) { /* if extended round to nearest */ mov_l_ri(S1,0x10); /* use extended round to zero mode */ fldcw_m_indexed(S1,(uae_u32)x86_fpucw); - fmovi_mr((uae_u32)temp_fp,val); + fmovi_mr((uae_u32)temp_fp,sreg); mov_l_rm(reg,(uae_u32)temp_fp); mov_l_rm(S1,(uae_u32)®s.fpcr); and_l_ri(S1,0xf0); /* restore control word */ @@ -289,11 +273,11 @@ STATIC_INLINE int put_fp_value (int val, uae_u32 opcode, uae_u16 extra) return 0; } #endif - fmovi_mr((uae_u32)temp_fp,val); + fmovi_mr((uae_u32)temp_fp,sreg); mov_l_rm(reg,(uae_u32)temp_fp); return 0; case 1: /* FMOVE.S FPx, Dn */ - fmovs_mr((uae_u32)temp_fp,val); + fmovs_mr((uae_u32)temp_fp,sreg); mov_l_rm(reg,(uae_u32)temp_fp); return 0; case 4: /* FMOVE.W FPx, Dn */ @@ -301,7 +285,7 @@ STATIC_INLINE int put_fp_value (int val, uae_u32 opcode, uae_u16 extra) if (!(regs.fpcr & 0xf0)) { /* if extended round to nearest */ mov_l_ri(S1,0x10); /* use extended round to zero mode */ fldcw_m_indexed(S1,(uae_u32)x86_fpucw); - fmovi_mr((uae_u32)temp_fp,val); + fmovi_mr((uae_u32)temp_fp,sreg); mov_w_rm(reg,(uae_u32)temp_fp); mov_l_rm(S1,(uae_u32)®s.fpcr); and_l_ri(S1,0xf0); /* restore control word */ @@ -309,7 +293,7 @@ STATIC_INLINE int put_fp_value (int val, uae_u32 opcode, uae_u16 extra) return 0; } #endif - fmovi_mr((uae_u32)temp_fp,val); + fmovi_mr((uae_u32)temp_fp,sreg); mov_w_rm(reg,(uae_u32)temp_fp); return 0; case 6: /* FMOVE.B FPx, Dn */ @@ -317,7 +301,7 @@ STATIC_INLINE int put_fp_value (int val, uae_u32 opcode, uae_u16 extra) if (!(regs.fpcr & 0xf0)) { /* if extended round to nearest */ mov_l_ri(S1,0x10); /* use extended round to zero mode */ fldcw_m_indexed(S1,(uae_u32)x86_fpucw); - fmovi_mr((uae_u32)temp_fp,val); + fmovi_mr((uae_u32)temp_fp,sreg); mov_b_rm(reg,(uae_u32)temp_fp); mov_l_rm(S1,(uae_u32)®s.fpcr); and_l_ri(S1,0xf0); /* restore control word */ @@ -325,7 +309,7 @@ STATIC_INLINE int put_fp_value (int val, uae_u32 opcode, uae_u16 extra) return 0; } #endif - fmovi_mr((uae_u32)temp_fp,val); + fmovi_mr((uae_u32)temp_fp,sreg); mov_b_rm(reg,(uae_u32)temp_fp); return 0; default: @@ -371,24 +355,24 @@ STATIC_INLINE int put_fp_value (int val, uae_u32 opcode, uae_u16 extra) mov_l_ri(S1,off); break; } - default: /* All other modes are not allowed for FPx to */ + default: /* All other modes are not allowed for FPx to */ write_log ("JIT FMOVE FPx, Mode is not allowed %04x %04x\n",opcode,extra); return -1; } } switch (size) { case 0: /* Long */ - fmovi_mr((uae_u32)temp_fp,val); + fmovi_mr((uae_u32)temp_fp,sreg); mov_l_rm(S2,(uae_u32)temp_fp); writelong_clobber(S1,S2,S3); return 0; case 1: /* Single */ - fmovs_mr((uae_u32)temp_fp,val); + fmovs_mr((uae_u32)temp_fp,sreg); mov_l_rm(S2,(uae_u32)temp_fp); writelong_clobber(S1,S2,S3); return 0; case 2:/* Long Double */ - fmov_ext_mr((uae_u32)temp_fp,val); + fmov_ext_mr((uae_u32)temp_fp,sreg); mov_w_rm(S2,(uae_u32)temp_fp+8); writeword_clobber(S1,S2,S3); add_l_ri(S1,4); @@ -399,12 +383,12 @@ STATIC_INLINE int put_fp_value (int val, uae_u32 opcode, uae_u16 extra) writelong_clobber(S1,S2,S3); return 0; case 4: /* Word */ - fmovi_mr((uae_u32)temp_fp,val); + fmovi_mr((uae_u32)temp_fp,sreg); mov_l_rm(S2,(uae_u32)temp_fp); writeword_clobber(S1,S2,S3); return 0; case 5: /* Double */ - fmov_mr((uae_u32)temp_fp,val); + fmov_mr((uae_u32)temp_fp,sreg); mov_l_rm(S2,(uae_u32)temp_fp+4); writelong_clobber(S1,S2,S3); add_l_ri(S1,4); @@ -412,7 +396,7 @@ STATIC_INLINE int put_fp_value (int val, uae_u32 opcode, uae_u16 extra) writelong_clobber(S1,S2,S3); return 0; case 6: /* Byte */ - fmovi_mr((uae_u32)temp_fp,val); + fmovi_mr((uae_u32)temp_fp,sreg); mov_l_rm(S2,(uae_u32)temp_fp); writebyte(S1,S2,S3); return 0; @@ -423,16 +407,13 @@ STATIC_INLINE int put_fp_value (int val, uae_u32 opcode, uae_u16 extra) } /* return -1 for failure, or register number for success */ -STATIC_INLINE int get_fp_ad (uae_u32 opcode) +STATIC_INLINE int comp_fp_adr (uae_u32 opcode) { uae_s32 off; int mode = (opcode >> 3) & 7; int reg = opcode & 7; switch (mode) { - case 0: - case 1: - return -1; case 2: case 3: case 4: @@ -443,8 +424,6 @@ STATIC_INLINE int get_fp_ad (uae_u32 opcode) mov_l_rr(S1,8+reg); add_l_ri(S1,off); return S1; - case 6: - return -1; case 7: switch (reg) { case 0: @@ -455,11 +434,10 @@ STATIC_INLINE int get_fp_ad (uae_u32 opcode) off=comp_get_ilong((m68k_pc_offset+=4)-4); mov_l_ri(S1,off); return S1; - default: - return -1; } + default: + return -1; } - abort(); } void comp_fdbcc_opp (uae_u32 opcode, uae_u16 extra) @@ -528,7 +506,7 @@ void comp_fscc_opp (uae_u32 opcode, uae_u16 extra) mov_b_rr(reg,S4); else { abort(); - if (!get_fp_ad (opcode)) { + if (!comp_fp_adr (opcode)) { m68k_setpc (m68k_getpc () - 4); op_illg (opcode); } @@ -707,7 +685,7 @@ void comp_fsave_opp (uae_u32 opcode) printf ("fsave_opp at %08lx\n", m68k_getpc ()); fflush (stdout); #endif - if (!get_fp_ad (opcode)) { + if (!comp_fp_adr (opcode)) { m68k_setpc (m68k_getpc () - 2); op_illg (opcode); return; @@ -767,7 +745,7 @@ void comp_frestore_opp (uae_u32 opcode) printf ("frestore_opp at %08lx\n", m68k_getpc ()); fflush (stdout); #endif - if (!get_fp_ad (opcode)) { + if (!comp_fp_adr (opcode)) { m68k_setpc (m68k_getpc () - 2); op_illg (opcode); return; @@ -838,176 +816,23 @@ extern float fp_1e1, fp_1e2, fp_1e4; void comp_fpp_opp (uae_u32 opcode, uae_u16 extra) { - int dreg; - int sreg; + int sreg, prec = 0; + int dreg = (extra >> 7) & 7; + int source = (extra >> 13) & 7; + int opmode = extra & 0x7f; if (!currprefs.compfpu) { FAIL(1); return; } - switch ((extra >> 13) & 7) { - case 3: /* 2nd most common */ - if (put_fp_value ((extra >> 7) & 7, opcode, extra) < 0) { + switch (source) { + case 3: /* FMOVE FPx, */ + if (comp_fp_put(opcode,extra) < 0) FAIL(1); - return; - } - return; - case 6: - case 7: - { - uae_u32 list = 0; - int incr = 0; - if (extra & 0x2000) { - int ad; - - /* FMOVEM FPP->memory */ - switch ((extra >> 11) & 3) { /* Get out early if failure */ - case 0: - case 2: - break; - case 1: - case 3: - default: - FAIL(1); return; - } - ad=get_fp_ad (opcode); - if (ad<0) { - FAIL(1); -#if 0 - m68k_setpc (m68k_getpc () - 4); - op_illg (opcode); -#endif - return; - } - switch ((extra >> 11) & 3) { - case 0: /* static pred */ - list = extra & 0xff; - incr = -1; - break; - case 2: /* static postinc */ - list = extra & 0xff; - incr = 1; - break; - case 1: /* dynamic pred */ - case 3: /* dynamic postinc */ - abort(); - } - while (list) { - if (incr < 0) { /* Predecrement */ - fmov_ext_mr((uae_u32)temp_fp,fpp_movem_index2[list]); - sub_l_ri(ad,4); - mov_l_rm(S2,(uae_u32)temp_fp); - writelong_clobber(ad,S2,S3); - sub_l_ri(ad,4); - mov_l_rm(S2,(uae_u32)temp_fp+4); - writelong_clobber(ad,S2,S3); - sub_l_ri(ad,4); - mov_w_rm(S2,(uae_u32)temp_fp+8); - writeword_clobber(ad,S2,S3); - } else { /* postinc */ - fmov_ext_mr((uae_u32)temp_fp,fpp_movem_index2[list]); - mov_w_rm(S2,(uae_u32)temp_fp+8); - writeword_clobber(ad,S2,S3); - add_l_ri(ad,4); - mov_l_rm(S2,(uae_u32)temp_fp+4); - writelong_clobber(ad,S2,S3); - add_l_ri(ad,4); - mov_l_rm(S2,(uae_u32)temp_fp); - writelong_clobber(ad,S2,S3); - add_l_ri(ad,4); - } - list = fpp_movem_next[list]; - } - if ((opcode & 0x38) == 0x18) - mov_l_rr((opcode & 7)+8,ad); - if ((opcode & 0x38) == 0x20) - mov_l_rr((opcode & 7)+8,ad); - } else { - /* FMOVEM memory->FPP */ - - int ad; - switch ((extra >> 11) & 3) { /* Get out early if failure */ - case 0: - case 2: - break; - case 1: - case 3: - default: - FAIL(1); return; - } - ad=get_fp_ad (opcode); - if (ad<0) { - FAIL(1); -#if 0 - m68k_setpc (m68k_getpc () - 4); - op_illg (opcode); -#endif - return; - } - switch ((extra >> 11) & 3) { - case 0: /* static pred */ - list = extra & 0xff; - incr = -1; - break; - case 2: /* static postinc */ - list = extra & 0xff; - incr = 1; - break; - case 1: /* dynamic pred */ - case 3: /* dynamic postinc */ - abort(); - } - - while (list) { - if (incr < 0) { - sub_l_ri(ad,4); - readlong(ad,S2,S3); - mov_l_mr((uae_u32)(temp_fp),S2); - sub_l_ri(ad,4); - readlong(ad,S2,S3); - mov_l_mr((uae_u32)(temp_fp)+4,S2); - sub_l_ri(ad,4); - readword(ad,S2,S3); - mov_w_mr(((uae_u32)temp_fp)+8,S2); - fmov_ext_rm(fpp_movem_index2[list],(uae_u32)(temp_fp)); - } else { - readword(ad,S2,S3); - mov_w_mr(((uae_u32)temp_fp)+8,S2); - add_l_ri(ad,4); - readlong(ad,S2,S3); - mov_l_mr((uae_u32)(temp_fp)+4,S2); - add_l_ri(ad,4); - readlong(ad,S2,S3); - mov_l_mr((uae_u32)(temp_fp),S2); - add_l_ri(ad,4); - fmov_ext_rm(fpp_movem_index1[list],(uae_u32)(temp_fp)); - } - list = fpp_movem_next[list]; - } - if ((opcode & 0x38) == 0x18) - mov_l_rr((opcode & 7)+8,ad); - if ((opcode & 0x38) == 0x20) - mov_l_rr((opcode & 7)+8,ad); - } - } return; - - case 4: - case 5: /* rare */ - if ((opcode & 0x30) == 0) { - if (extra & 0x2000) { - if (extra & 0x1000) { - mov_l_rm(opcode & 15,(uae_u32)®s.fpcr); return; - } - if (extra & 0x0800) { - FAIL(1); - return; - } - if (extra & 0x0400) { - mov_l_rm(opcode & 15,(uae_u32)®s.fpiar); return; - } - } else { - if (extra & 0x1000) { + case 4: /* FMOVE.L , ControlReg */ + if (!(opcode & 0x30)) { /* Dn or An */ + if (extra & 0x1000) { /* FPCR */ mov_l_mr((uae_u32)®s.fpcr,opcode & 15); #if USE_X86_FPUCW mov_l_rr(S1,opcode & 15); @@ -1016,18 +841,17 @@ void comp_fpp_opp (uae_u32 opcode, uae_u16 extra) #endif return; } - if (extra & 0x0800) { + if (extra & 0x0800) { /* FPSR */ FAIL(1); return; // set_fpsr(m68k_dreg (regs, opcode & 15)); } - if (extra & 0x0400) { + if (extra & 0x0400) { /* FPIAR */ mov_l_mr((uae_u32)®s.fpiar,opcode & 15); return; } - } - } else if ((opcode & 0x3f) == 0x3c) { - if ((extra & 0x2000) == 0) { - if (extra & 0x1000) { + } + else if ((opcode & 0x3f) == 0x3c) { + if (extra & 0x1000) { /* FPCR */ uae_u32 val=comp_get_ilong((m68k_pc_offset+=4)-4); mov_l_mi((uae_u32)®s.fpcr,val); #if USE_X86_FPUCW @@ -1036,358 +860,589 @@ void comp_fpp_opp (uae_u32 opcode, uae_u16 extra) #endif return; } - if (extra & 0x0800) { + if (extra & 0x0800) { /* FPSR */ FAIL(1); return; } - if (extra & 0x0400) { + if (extra & 0x0400) { /* FPIAR */ uae_u32 val=comp_get_ilong((m68k_pc_offset+=4)-4); mov_l_mi((uae_u32)®s.fpiar,val); return; } + } + FAIL(1); + return; + case 5: /* FMOVE.L ControlReg, */ + if (!(opcode & 0x30)) { /* Dn or An */ + if (extra & 0x1000) { /* FPCR */ + mov_l_rm(opcode & 15,(uae_u32)®s.fpcr); return; + } + if (extra & 0x0800) { /* FPSR */ + FAIL(1); + return; + } + if (extra & 0x0400) { /* FPIAR */ + mov_l_rm(opcode & 15,(uae_u32)®s.fpiar); return; + } + } + FAIL(1); + return; + case 6: /* FMOVEM , FPx-FPz */ + if (!(extra & 0x0800)) { + uae_u32 list = extra & 0xff; + int ad; + if ((ad = comp_fp_adr(opcode)) < 0) {FAIL(1);return;} + while (list) { + if (extra & 0x1000) { /* postincrement */ + readword(ad,S2,S3); + mov_w_mr(((uae_u32)temp_fp)+8,S2); + add_l_ri(ad,4); + readlong(ad,S2,S3); + mov_l_mr((uae_u32)(temp_fp)+4,S2); + add_l_ri(ad,4); + readlong(ad,S2,S3); + mov_l_mr((uae_u32)(temp_fp),S2); + add_l_ri(ad,4); + fmov_ext_rm(fpp_movem_index1[list],(uae_u32)(temp_fp)); + } else { /* predecrement */ + sub_l_ri(ad,4); + readlong(ad,S2,S3); + mov_l_mr((uae_u32)(temp_fp),S2); + sub_l_ri(ad,4); + readlong(ad,S2,S3); + mov_l_mr((uae_u32)(temp_fp)+4,S2); + sub_l_ri(ad,4); + readword(ad,S2,S3); + mov_w_mr(((uae_u32)temp_fp)+8,S2); + fmov_ext_rm(fpp_movem_index2[list],(uae_u32)(temp_fp)); + } + list = fpp_movem_next[list]; } - FAIL(1); + if ((opcode & 0x38) == 0x18) + mov_l_rr((opcode & 7)+8,ad); return; - } else if (extra & 0x2000) { - FAIL(1); + } /* no break for dynamic register list */ + case 7: /* FMOVEM FPx-FPz, */ + if (!(extra & 0x0800)) { + uae_u32 list = extra & 0xff; + int ad; + if ((ad = comp_fp_adr(opcode)) < 0) {FAIL(1);return;} + while (list) { + if (extra & 0x1000) { /* postincrement */ + fmov_ext_mr((uae_u32)temp_fp,fpp_movem_index2[list]); + mov_w_rm(S2,(uae_u32)temp_fp+8); + writeword_clobber(ad,S2,S3); + add_l_ri(ad,4); + mov_l_rm(S2,(uae_u32)temp_fp+4); + writelong_clobber(ad,S2,S3); + add_l_ri(ad,4); + mov_l_rm(S2,(uae_u32)temp_fp); + writelong_clobber(ad,S2,S3); + add_l_ri(ad,4); + } else { /* predecrement */ + fmov_ext_mr((uae_u32)temp_fp,fpp_movem_index2[list]); + sub_l_ri(ad,4); + mov_l_rm(S2,(uae_u32)temp_fp); + writelong_clobber(ad,S2,S3); + sub_l_ri(ad,4); + mov_l_rm(S2,(uae_u32)temp_fp+4); + writelong_clobber(ad,S2,S3); + sub_l_ri(ad,4); + mov_w_rm(S2,(uae_u32)temp_fp+8); + writeword_clobber(ad,S2,S3); + } + list = fpp_movem_next[list]; + } + if ((opcode & 0x38) == 0x20) + mov_l_rr((opcode & 7)+8,ad); return; - } else { + } /* no break */ + write_log ("fallback from JIT FMOVEM dynamic register list\n"); + FAIL(1); + return; + case 2: /* from to FPx */ + dont_care_fflags(); + if ((extra & 0xfc00) == 0x5c00) { /* FMOVECR */ + //write_log ("JIT FMOVECR %x\n", opmode); + switch (opmode) { + case 0x00: + fmov_pi(dreg); + break; + case 0x0b: + fmov_ext_rm(dreg,(uae_u32)&xhex_l10_2); + break; + case 0x0c: + fmov_ext_rm(dreg,(uae_u32)&xhex_exp_1); + break; + case 0x0d: + fmov_log2_e(dreg); + break; + case 0x0e: + fmov_ext_rm(dreg,(uae_u32)&xhex_l10_e); + break; + case 0x0f: + fmov_0(dreg); + break; + case 0x30: + fmov_loge_2(dreg); + break; + case 0x31: + fmov_ext_rm(dreg,(uae_u32)&xhex_ln_10); + break; + case 0x32: + fmov_1(dreg); + break; + case 0x33: + fmovs_rm(dreg,(uae_u32)&fp_1e1); + break; + case 0x34: + fmovs_rm(dreg,(uae_u32)&fp_1e2); + break; + case 0x35: + fmovs_rm(dreg,(uae_u32)&fp_1e4); + break; + case 0x36: + fmov_rm(dreg,(uae_u32)&fp_1e8); + break; + case 0x37: + fmov_ext_rm(dreg,(uae_u32)&xhex_1e16); + break; + case 0x38: + fmov_ext_rm(dreg,(uae_u32)&xhex_1e32); + break; + case 0x39: + fmov_ext_rm(dreg,(uae_u32)&xhex_1e64); + break; + case 0x3a: + fmov_ext_rm(dreg,(uae_u32)&xhex_1e128); + break; + case 0x3b: + fmov_ext_rm(dreg,(uae_u32)&xhex_1e256); + break; + case 0x3c: + fmov_ext_rm(dreg,(uae_u32)&xhex_1e512); + break; + case 0x3d: + fmov_ext_rm(dreg,(uae_u32)&xhex_1e1024); + break; + case 0x3e: + fmov_ext_rm(dreg,(uae_u32)&xhex_1e2048); + break; + case 0x3f: + fmov_ext_rm(dreg,(uae_u32)&xhex_1e4096); + break; + default: + FAIL(1); + return; + } + fmov_rr(FP_RESULT,dreg); + return; + } + if (opmode & 0x20) /* two operands, so we need a scratch reg */ + sreg = FS1; + else /* one operand only, thus we can load the argument into dreg */ + sreg = dreg; + if ((prec = comp_fp_get(opcode,extra,sreg)) < 0) { FAIL(1); return; } - FAIL(1); - return; - - case 0: - case 2: /* Extremely common */ - dreg = (extra >> 7) & 7; - if ((extra & 0xfc00) == 0x5c00) { - //write_log ("JIT FMOVECR %x\n", extra & 0x7f); - dont_care_fflags(); - switch (extra & 0x7f) { - case 0x00: - fmov_pi(dreg); + if (!opmode) { /* FMOVE ,FPx */ + fmov_rr(FP_RESULT,dreg); + return; + } + /* no break here for to dreg */ + case 0: /* directly from sreg to dreg */ + if (!source) { /* no */ + dont_care_fflags(); + sreg = (extra >> 10) & 7; + } + switch (opmode) { + case 0x00: /* FMOVE */ + fmov_rr(dreg,sreg); + break; + case 0x01: /* FINT */ + frndint_rr(dreg,sreg); + break; + case 0x02: /* FSINH */ + fsinh_rr(dreg,sreg); + break; + case 0x03: /* FINTRZ */ +#if USE_X86_FPUCW /* if we have control over the CW, we can do this */ + if ((regs.fpcr & 0xf0) == 0x10) /* maybe unsafe, because this test is done */ + frndint_rr(dreg,sreg); /* during the JIT compilation and not at runtime */ + else { + mov_l_ri(S1,0x10); /* extended round to zero */ + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + frndint_rr(dreg,sreg); + mov_l_rm(S1,(uae_u32)®s.fpcr); + and_l_ri(S1,0xf0); /* restore control word */ + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + } break; - case 0x0b: - fmov_log10_2(dreg); +#endif + FAIL(1); + return; + case 0x04: /* FSQRT */ + fsqrt_rr(dreg,sreg); break; - case 0x0c: - fmov_ext_rm(dreg,(uae_u32)&xhex_exp_1); + case 0x06: /* FLOGNP1 */ + flogNP1_rr(dreg,sreg); break; - case 0x0d: - fmov_log2_e(dreg); + case 0x08: /* FETOXM1 */ + fetoxM1_rr(dreg,sreg); break; - case 0x0e: - fmov_ext_rm(dreg,(uae_u32)&xhex_l10_e); + case 0x09: /* FTANH */ + ftanh_rr(dreg,sreg); break; - case 0x0f: - fmov_0(dreg); + case 0x0a: /* FATAN */ + fatan_rr(dreg,sreg); break; - case 0x30: - fmov_loge_2(dreg); + case 0x0c: /* FASIN */ + fasin_rr(dreg,sreg); break; - case 0x31: - fmov_ext_rm(dreg,(uae_u32)&xhex_ln_10); + case 0x0d: /* FATANH */ + fatanh_rr(dreg,sreg); break; - case 0x32: - fmov_1(dreg); + case 0x0e: /* FSIN */ + fsin_rr(dreg,sreg); break; - case 0x33: - fmovs_rm(dreg,(uae_u32)&fp_1e1); + case 0x0f: /* FTAN */ + ftan_rr(dreg,sreg); break; - case 0x34: - fmovs_rm(dreg,(uae_u32)&fp_1e2); + case 0x10: /* FETOX */ + fetox_rr(dreg,sreg); break; - case 0x35: - fmovs_rm(dreg,(uae_u32)&fp_1e4); + case 0x11: /* FTWOTOX */ + ftwotox_rr(dreg,sreg); break; - case 0x36: - fmov_rm(dreg,(uae_u32)&fp_1e8); + case 0x12: /* FTENTOX */ + ftentox_rr(dreg,sreg); break; - case 0x37: - fmov_ext_rm(dreg,(uae_u32)&xhex_1e16); + case 0x14: /* FLOGN */ + flogN_rr(dreg,sreg); break; - case 0x38: - fmov_ext_rm(dreg,(uae_u32)&xhex_1e32); + case 0x15: /* FLOG10 */ + flog10_rr(dreg,sreg); break; - case 0x39: - fmov_ext_rm(dreg,(uae_u32)&xhex_1e64); + case 0x16: /* FLOG2 */ + flog2_rr(dreg,sreg); break; - case 0x3a: - fmov_ext_rm(dreg,(uae_u32)&xhex_1e128); + case 0x18: /* FABS */ + fabs_rr(dreg,sreg); break; - case 0x3b: - fmov_ext_rm(dreg,(uae_u32)&xhex_1e256); + case 0x19: /* FCOSH */ + fcosh_rr(dreg,sreg); break; - case 0x3c: - fmov_ext_rm(dreg,(uae_u32)&xhex_1e512); + case 0x1a: /* FNEG */ + fneg_rr(dreg,sreg); break; - case 0x3d: - fmov_ext_rm(dreg,(uae_u32)&xhex_1e1024); + case 0x1c: /* FACOS */ +#if USE_X86_FPUCW + if ((regs.fpcr & 0x30) != 0x10) { /* use round to zero */ + mov_l_ri(S1,(regs.fpcr & 0xC0) | 0x10); + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + facos_rr(dreg,sreg); + mov_l_rm(S1,(uae_u32)®s.fpcr); + and_l_ri(S1,0xf0); /* restore control word */ + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + break; + } +#endif + facos_rr(dreg,sreg); break; - case 0x3e: - fmov_ext_rm(dreg,(uae_u32)&xhex_1e2048); + case 0x1d: /* FCOS */ + fcos_rr(dreg,sreg); break; - case 0x3f: - fmov_ext_rm(dreg,(uae_u32)&xhex_1e4096); + case 0x1e: /* FGETEXP */ + fgetexp_rr(dreg,sreg); break; - default: - FAIL(1); + case 0x1f: /* FGETMAN */ + fgetman_rr(dreg,sreg); + break; + case 0x20: /* FDIV */ + fdiv_rr(dreg,sreg); + break; + case 0x21: /* FMOD */ + frem_rr(dreg,sreg); + break; + case 0x22: /* FADD */ + fadd_rr(dreg,sreg); + break; + case 0x23: /* FMUL */ + fmul_rr(dreg,sreg); + break; + case 0x24: /* FSGLDIV */ +#if USE_X86_FPUCW + if ((regs.fpcr & 0xC0) == 0x40) { /* if SINGLE precision */ + fdiv_rr(dreg,sreg); + break; + } +#endif + if (!source) /* don't scratch, save sreg first */ + fmov_ext_mr((uae_u32)save_fp,sreg); + if (prec != 1) { + fmovs_mr((uae_u32)temp_fp,sreg); + fmovs_rm(sreg,(uae_u32)temp_fp); + } + fmovs_mr((uae_u32)temp_fp,dreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + fdiv_rr(dreg,sreg); /* Both have to be SINGLE */ + fmovs_mr((uae_u32)temp_fp,dreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + if (!source) /* restore sreg */ + fmov_ext_rm(sreg,(uae_u32)save_fp); + break; + case 0x25: /* FREM */ + frem1_rr(dreg,sreg); + break; + case 0x26: /* FSCALE */ + fscale_rr(dreg,sreg); + break; + case 0x27: /* FSGLMUL */ +#if USE_X86_FPUCW + if ((regs.fpcr & 0xC0) == 0x40) { /* if SINGLE precision */ + fmul_rr(dreg,sreg); + break; + } +#endif + if (!source) /* dont scratch, save sreg first */ + fmov_ext_mr((uae_u32)save_fp,sreg); + if (prec != 1) { + fmovs_mr((uae_u32)temp_fp,sreg); + fmovs_rm(sreg,(uae_u32)temp_fp); + } + fmovs_mr((uae_u32)temp_fp,dreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + fmul_rr(dreg,sreg); /* Both have to be SINGLE */ + fmovs_mr((uae_u32)temp_fp,dreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + if (!source) /* restore sreg */ + fmov_ext_rm(sreg,(uae_u32)save_fp); + break; + case 0x28: /* FSUB */ + fsub_rr(dreg,sreg); + break; + case 0x30: /* FSINCOS */ + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + if (dreg == (extra & 7)) + fsin_rr(dreg, sreg); + else + fsincos_rr(dreg, extra & 7, sreg); + break; + case 0x38: /* FCMP */ + fmov_rr(FP_RESULT,dreg); + fsub_rr(FP_RESULT,sreg); return; - } - MAKE_FPSR (dreg); - return; - } - - switch (extra & 0x7f) { - case 0x00: /* FMOVE */ - case 0x40: - case 0x44: - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fmov_rr(dreg,sreg); - break; - case 0x01: /* FINT */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - frndint_rr(dreg,sreg); - break; - case 0x02: /* FSINH */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fsinh_rr(dreg,sreg); - break; - case 0x03: /* FINTRZ */ + case 0x3a: /* FTST */ + fmov_rr(FP_RESULT,sreg); + return; + case 0x40: /* FSMOVE */ + if (prec == 1) { + if (sreg != dreg) /* no */ + fmov_rr(dreg,sreg); + } else { + fmovs_mr((uae_u32)temp_fp,sreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + } + break; + case 0x41: /* FSSQRT */ + fsqrt_rr(dreg,sreg); #if USE_X86_FPUCW - /* If we have control over the CW, we can do this */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - if ((regs.fpcr & 0xf0) == 0x10) /* maybe unsafe, because this test is done */ - frndint_rr(dreg,sreg); /* during the JIT compilation and not at runtime */ - else { - mov_l_ri(S1,0x10); /* extended round to zero */ - fldcw_m_indexed(S1,(uae_u32)x86_fpucw); - frndint_rr(dreg,sreg); - mov_l_rm(S1,(uae_u32)®s.fpcr); - and_l_ri(S1,0xf0); /* restore control word */ - fldcw_m_indexed(S1,(uae_u32)x86_fpucw); - } - break; + if ((regs.fpcr & 0xC0) == 0x40) /* if SINGLE precision */ + break; #endif - FAIL(1); - return; - case 0x04: /* FSQRT */ - case 0x41: - case 0x45: - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fsqrt_rr(dreg,sreg); - break; - case 0x06: /* FLOGNP1 */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - flogNP1_rr(dreg,sreg); - break; - case 0x08: /* FETOXM1 */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fetoxM1_rr(dreg,sreg); - break; - case 0x09: /* FTANH */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - ftanh_rr(dreg,sreg); - break; - case 0x0a: /* FATAN */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fatan_rr(dreg,sreg); - break; - case 0x0c: /* FASIN */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fasin_rr(dreg,sreg); - break; - case 0x0d: /* FATANH */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fatanh_rr(dreg,sreg); - break; - case 0x0e: /* FSIN */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fsin_rr(dreg,sreg); - break; - case 0x0f: /* FTAN */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - ftan_rr(dreg,sreg); - break; - case 0x10: /* FETOX */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fetox_rr(dreg,sreg); - break; - case 0x11: /* FTWOTOX */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - ftwotox_rr(dreg,sreg); - break; - case 0x12: /* FTENTOX */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - ftentox_rr(dreg,sreg); - break; - case 0x14: /* FLOGN */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - flogN_rr(dreg,sreg); - break; - case 0x15: /* FLOG10 */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - flog10_rr(dreg,sreg); - break; - case 0x16: /* FLOG2 */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - flog2_rr(dreg,sreg); - break; - case 0x18: /* FABS */ - case 0x58: - case 0x5c: - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fabs_rr(dreg,sreg); - break; - case 0x19: /* FCOSH */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fcosh_rr(dreg,sreg); - break; - case 0x1a: /* FNEG */ - case 0x5a: - case 0x5e: - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fneg_rr(dreg,sreg); - break; - case 0x1c: /* FACOS */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} + fmovs_mr((uae_u32)temp_fp,dreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + break; + case 0x44: /* FDMOVE */ + if (prec) { + if (sreg != dreg) /* no */ + fmov_rr(dreg,sreg); + } else { + fmov_mr((uae_u32)temp_fp,sreg); + fmov_rm(dreg,(uae_u32)temp_fp); + } + break; + case 0x45: /* FDSQRT */ #if USE_X86_FPUCW - if ((regs.fpcr & 0x30) != 0x10) { - mov_l_ri(S1,(regs.fpcr & 0xC0) | 0x10); /* use round to zero */ - fldcw_m_indexed(S1,(uae_u32)x86_fpucw); - facos_rr(dreg,sreg); - mov_l_rm(S1,(uae_u32)®s.fpcr); - and_l_ri(S1,0xf0); /* restore control word */ - fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + if (regs.fpcr & 0xC0) { /* if we don't have EXTENDED precision */ + if ((regs.fpcr & 0xC0) == 0x80) /* if we have DOUBLE */ + fsqrt_rr(dreg,sreg); + else { /* if we have SINGLE presision, force DOUBLE */ + mov_l_ri(S1,(regs.fpcr & 0x30) | 0x80); + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + fsqrt_rr(dreg,sreg); + mov_l_rm(S1,(uae_u32)®s.fpcr); + and_l_ri(S1,0xf0); /* restore control word */ + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + } + break; + } +#endif /* in case of EXTENDED precision, just reduce the result to DOUBLE */ + fsqrt_rr(dreg,sreg); + fmov_mr((uae_u32)temp_fp,dreg); + fmov_rm(dreg,(uae_u32)temp_fp); break; - } + case 0x58: /* FSABS */ + fabs_rr(dreg,sreg); + if (prec != 1) { + fmovs_mr((uae_u32)temp_fp,dreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + } + break; + case 0x5a: /* FSNEG */ + fneg_rr(dreg,sreg); + if (prec != 1) { + fmovs_mr((uae_u32)temp_fp,dreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + } + break; + case 0x5c: /* FDABS */ + fabs_rr(dreg,sreg); + if (!prec) { + fmov_mr((uae_u32)temp_fp,dreg); + fmov_rm(dreg,(uae_u32)temp_fp); + } + break; + case 0x5e: /* FDNEG */ + fneg_rr(dreg,sreg); + if (!prec) { + fmov_mr((uae_u32)temp_fp,dreg); + fmov_rm(dreg,(uae_u32)temp_fp); + } + break; + case 0x60: /* FSDIV */ + fdiv_rr(dreg,sreg); +#if USE_X86_FPUCW + if ((regs.fpcr & 0xC0) == 0x40) /* if SINGLE precision */ + break; #endif - facos_rr(dreg,sreg); - break; - case 0x1d: /* FCOS */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fcos_rr(dreg,sreg); - break; - case 0x1e: /* FGETEXP */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fgetexp_rr(dreg,sreg); - break; - case 0x1f: /* FGETMAN */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fgetman_rr(dreg,sreg); - break; - case 0x20: /* FDIV */ - case 0x60: - case 0x64: - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fdiv_rr(dreg,sreg); - break; - case 0x21: /* FMOD */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - frem_rr(dreg,sreg); - break; - case 0x22: /* FADD */ - case 0x62: - case 0x66: - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fadd_rr(dreg,sreg); - break; - case 0x23: /* FMUL */ - case 0x63: - case 0x67: - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fmul_rr(dreg,sreg); - break; - case 0x24: /* FSGLDIV */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fdiv_rr(dreg,sreg); - break; - case 0x25: /* FREM */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - frem1_rr(dreg,sreg); - break; - case 0x26: /* FSCALE */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fscale_rr(dreg,sreg); - break; - case 0x27: /* FSGLMUL */ - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fmul_rr(dreg,sreg); - break; - case 0x28: /* FSUB */ - case 0x68: - case 0x6c: - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fsub_rr(dreg,sreg); - break; - case 0x30: /* FSINCOS */ - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - dont_care_fflags(); - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - if (dreg == (extra & 7)) - fsin_rr(dreg, sreg); - else - fsincos_rr(dreg, extra & 7, sreg); - break; - case 0x38: /* FCMP */ - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fmov_rr(FP_RESULT,dreg); - fsub_rr(FP_RESULT,sreg); /* Right way? */ - return; - case 0x3a: /* FTST */ - if ((sreg=get_fp_value(opcode,extra)) < 0) {FAIL(1);return;} - fmov_rr(FP_RESULT,sreg); - return; - default: - FAIL(1); - return; + fmovs_mr((uae_u32)temp_fp,dreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + break; + case 0x62: /* FSADD */ + fadd_rr(dreg,sreg); +#if USE_X86_FPUCW + if ((regs.fpcr & 0xC0) == 0x40) /* if SINGLE precision */ + break; +#endif + fmovs_mr((uae_u32)temp_fp,dreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + break; + case 0x63: /* FSMUL */ + fmul_rr(dreg,sreg); +#if USE_X86_FPUCW + if ((regs.fpcr & 0xC0) == 0x40) /* if SINGLE precision */ + break; +#endif + fmovs_mr((uae_u32)temp_fp,dreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + break; + case 0x64: /* FDDIV */ +#if USE_X86_FPUCW + if (regs.fpcr & 0xC0) { /* if we don't have EXTENDED precision */ + if ((regs.fpcr & 0xC0) == 0x80) /* if we have DOUBLE */ + fdiv_rr(dreg,sreg); + else { /* if we have SINGLE presision, force DOUBLE */ + mov_l_ri(S1,(regs.fpcr & 0x30) | 0x80); + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + fdiv_rr(dreg,sreg); + mov_l_rm(S1,(uae_u32)®s.fpcr); + and_l_ri(S1,0xf0); /* restore control word */ + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + } + break; + } +#endif /* in case of EXTENDED precision, just reduce the result to DOUBLE */ + fdiv_rr(dreg,sreg); + fmov_mr((uae_u32)temp_fp,dreg); + fmov_rm(dreg,(uae_u32)temp_fp); + break; + case 0x66: /* FDADD */ +#if USE_X86_FPUCW + if (regs.fpcr & 0xC0) { /* if we don't have EXTENDED precision */ + if ((regs.fpcr & 0xC0) == 0x80) /* if we have DOUBLE */ + fadd_rr(dreg,sreg); + else { /* if we have SINGLE presision, force DOUBLE */ + mov_l_ri(S1,(regs.fpcr & 0x30) | 0x80); + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + fadd_rr(dreg,sreg); + mov_l_rm(S1,(uae_u32)®s.fpcr); + and_l_ri(S1,0xf0); /* restore control word */ + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + } + break; + } +#endif /* in case of EXTENDED precision, just reduce the result to DOUBLE */ + fadd_rr(dreg,sreg); + fmov_mr((uae_u32)temp_fp,dreg); + fmov_rm(dreg,(uae_u32)temp_fp); + break; + case 0x67: /* FDMUL */ +#if USE_X86_FPUCW + if (regs.fpcr & 0xC0) { /* if we don't have EXTENDED precision */ + if ((regs.fpcr & 0xC0) == 0x80) /* if we have DOUBLE */ + fmul_rr(dreg,sreg); + else { /* if we have SINGLE presision, force DOUBLE */ + mov_l_ri(S1,(regs.fpcr & 0x30) | 0x80); + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + fmul_rr(dreg,sreg); + mov_l_rm(S1,(uae_u32)®s.fpcr); + and_l_ri(S1,0xf0); /* restore control word */ + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + } + break; + } +#endif /* in case of EXTENDED precision, just reduce the result to DOUBLE */ + fmul_rr(dreg,sreg); + fmov_mr((uae_u32)temp_fp,dreg); + fmov_rm(dreg,(uae_u32)temp_fp); + break; + case 0x68: /* FSSUB */ + fsub_rr(dreg,sreg); +#if USE_X86_FPUCW + if ((regs.fpcr & 0xC0) == 0x40) /* if SINGLE precision */ + break; +#endif + fmovs_mr((uae_u32)temp_fp,dreg); + fmovs_rm(dreg,(uae_u32)temp_fp); + break; + case 0x6c: /* FDSUB */ +#if USE_X86_FPUCW + if (regs.fpcr & 0xC0) { /* if we don't have EXTENDED precision */ + if ((regs.fpcr & 0xC0) == 0x80) /* if we have DOUBLE */ + fsub_rr(dreg,sreg); + else { /* if we have SINGLE presision, force DOUBLE */ + mov_l_ri(S1,(regs.fpcr & 0x30) | 0x80); + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + fsub_rr(dreg,sreg); + mov_l_rm(S1,(uae_u32)®s.fpcr); + and_l_ri(S1,0xf0); /* restore control word */ + fldcw_m_indexed(S1,(uae_u32)x86_fpucw); + } + break; + } +#endif /* in case of EXTENDED precision, just reduce the result to DOUBLE */ + fsub_rr(dreg,sreg); + fmov_mr((uae_u32)temp_fp,dreg); + fmov_rm(dreg,(uae_u32)temp_fp); + break; + default: + FAIL(1); + return; } - MAKE_FPSR (dreg); + fmov_rr(FP_RESULT,dreg); + return; + default: + write_log ("Unsupported JIT-FPU instruction: 0x%04x %04x\n",opcode,extra); + FAIL(1); return; } - m68k_setpc (m68k_getpc () - 4); - op_illg (opcode); } #endif diff --git a/compemu_raw_x86.c b/compemu_raw_x86.c index 80eaa4cf..45adcf95 100755 --- a/compemu_raw_x86.c +++ b/compemu_raw_x86.c @@ -3078,28 +3078,38 @@ LOWFUNC(NONE,NONE,3,raw_fsincos_rr,(FW d, FW c, FR s)) { int ds; + if (s==d) { + //write_log ("FSINCOS src = dest\n"); + make_tos(s); + emit_byte(0xd9); + emit_byte(0xfb); /* fsincos sin(x) push cos(x) */ + tos_make(c); /* store cos(x) to c */ + return; + } + ds=stackpos(s); emit_byte(0xd9); emit_byte(0xc0+ds); /* fld x */ emit_byte(0xd9); emit_byte(0xfb); /* fsincos sin(x) push cos(x) */ - if ((live.spos[c]<0)&&(live.spos[d]<0)) { - live.tos++; - live.spos[d]=live.tos; - live.onstack[live.tos]=d; /* sin(x) comes first */ - live.tos++; - live.spos[c]=live.tos; - live.onstack[live.tos]=c; - return; /* occupy both regs directly */ - } if (live.spos[c]<0) { - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap cos(x) with sin(x) */ - emit_byte(0xdd); /* store sin(x) to d & pop */ - emit_byte(0xd8+(live.tos+2)-live.spos[d]); - live.tos++; /* occupy a reg for cos(x) here */ - live.spos[c]=live.tos; - live.onstack[live.tos]=c; + if (live.spos[d]<0) { /* occupy both regs directly */ + live.tos++; + live.spos[d]=live.tos; + live.onstack[live.tos]=d; /* sin(x) comes first */ + live.tos++; + live.spos[c]=live.tos; + live.onstack[live.tos]=c; + } + else { + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap cos(x) with sin(x) */ + emit_byte(0xdd); /* store sin(x) to d & pop */ + emit_byte(0xd8+(live.tos+2)-live.spos[d]); + live.tos++; /* occupy a reg for cos(x) here */ + live.spos[c]=live.tos; + live.onstack[live.tos]=c; + } } else { emit_byte(0xdd); /* store cos(x) to c & pop */ @@ -3149,7 +3159,7 @@ LOWFUNC(NONE,NONE,2,raw_ftwotox_rr,(FW d, FR s)) emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ emit_byte(0xd8); emit_byte(0x05); - emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ + emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ emit_byte(0xd9); emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x) */ emit_byte(0xdd); @@ -3162,9 +3172,13 @@ LOWFUNC(NONE,NONE,2,raw_fetox_rr,(FW d, FR s)) { int ds; - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); emit_byte(0xea); /* fldl2e log2(e) */ emit_byte(0xd8); @@ -3186,7 +3200,8 @@ LOWFUNC(NONE,NONE,2,raw_fetox_rr,(FW d, FR s)) emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ emit_byte(0xdd); emit_byte(0xd9); /* fstp copy & pop */ - tos_make(d); /* store y=e^x */ + if (s!=d) + tos_make(d); /* store y=e^x */ } LENDFUNC(NONE,NONE,2,raw_fetox_rr,(FW d, FR s)) @@ -3194,9 +3209,13 @@ LOWFUNC(NONE,NONE,2,raw_fetoxM1_rr,(FW d, FR s)) { int ds; - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); emit_byte(0xea); /* fldl2e log2(e) */ emit_byte(0xd8); @@ -3215,7 +3234,8 @@ LOWFUNC(NONE,NONE,2,raw_fetoxM1_rr,(FW d, FR s)) emit_byte(0xfd); /* fscale ((2^frac(x))-1)*2^int(x*log2(e)) */ emit_byte(0xdd); emit_byte(0xd9); /* fstp copy & pop */ - tos_make(d); /* store y=(e^x)-1 */ + if (s!=d) + tos_make(d); /* store y=(e^x)-1 */ } LENDFUNC(NONE,NONE,2,raw_fetoxM1_rr,(FW d, FR s)) @@ -3223,9 +3243,13 @@ LOWFUNC(NONE,NONE,2,raw_ftentox_rr,(FW d, FR s)) { int ds; - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); emit_byte(0xe9); /* fldl2t log2(10) */ emit_byte(0xd8); @@ -3247,7 +3271,8 @@ LOWFUNC(NONE,NONE,2,raw_ftentox_rr,(FW d, FR s)) emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(10)) */ emit_byte(0xdd); emit_byte(0xd9); /* fstp copy & pop */ - tos_make(d); /* store y=10^x */ + if (s!=d) + tos_make(d); /* store y=10^x */ } LENDFUNC(NONE,NONE,2,raw_ftentox_rr,(FW d, FR s)) @@ -3255,16 +3280,21 @@ LOWFUNC(NONE,NONE,2,raw_flog2_rr,(FW d, FR s)) { int ds; - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); emit_byte(0xe8); /* fld1 1 */ emit_byte(0xd9); emit_byte(0xc9); /* fxch swap 1 with x */ emit_byte(0xd9); emit_byte(0xf1); /* fyl2x 1*log2(x) */ - tos_make(d); /* store y=log2(x) */ + if (s!=d) + tos_make(d); /* store y=log2(x) */ } LENDFUNC(NONE,NONE,2,raw_flog2_rr,(FW d, FR s)) @@ -3272,16 +3302,21 @@ LOWFUNC(NONE,NONE,2,raw_flogN_rr,(FW d, FR s)) { int ds; - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); emit_byte(0xed); /* fldln2 logN(2) */ emit_byte(0xd9); emit_byte(0xc9); /* fxch swap logN(2) with x */ emit_byte(0xd9); emit_byte(0xf1); /* fyl2x logN(2)*log2(x) */ - tos_make(d); /* store y=logN(x) */ + if (s!=d) + tos_make(d); /* store y=logN(x) */ } LENDFUNC(NONE,NONE,2,raw_flogN_rr,(FW d, FR s)) @@ -3289,16 +3324,21 @@ LOWFUNC(NONE,NONE,2,raw_flogNP1_rr,(FW d, FR s)) { int ds; - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); emit_byte(0xed); /* fldln2 logN(2) */ emit_byte(0xd9); emit_byte(0xc9); /* fxch swap logN(2) with x */ emit_byte(0xd9); emit_byte(0xf9); /* fyl2xp1 logN(2)*log2(x+1) */ - tos_make(d); /* store y=logN(x+1) */ + if (s!=d) + tos_make(d); /* store y=logN(x+1) */ } LENDFUNC(NONE,NONE,2,raw_flogNP1_rr,(FW d, FR s)) @@ -3306,16 +3346,21 @@ LOWFUNC(NONE,NONE,2,raw_flog10_rr,(FW d, FR s)) { int ds; - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); emit_byte(0xec); /* fldlg2 log10(2) */ emit_byte(0xd9); emit_byte(0xc9); /* fxch swap log10(2) with x */ emit_byte(0xd9); emit_byte(0xf1); /* fyl2x log10(2)*log2(x) */ - tos_make(d); /* store y=log10(x) */ + if (s!=d) + tos_make(d); /* store y=log10(x) */ } LENDFUNC(NONE,NONE,2,raw_flog10_rr,(FW d, FR s)) @@ -3379,14 +3424,19 @@ LOWFUNC(NONE,NONE,2,raw_fatan_rr,(FW d, FR s)) { int ds; - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); emit_byte(0xe8); /* fld 1.0 */ emit_byte(0xd9); emit_byte(0xf3); /* fpatan atan(x)/1 & pop*/ - tos_make(d); /* store y=atan(x) */ + if (s!=d) + tos_make(d); /* store y=atan(x) */ } LENDFUNC(NONE,NONE,2,raw_fatan_rr,(FW d, FR s)) @@ -3430,9 +3480,13 @@ LOWFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s)) int ds,tr; tr=live.onstack[live.tos+3]; - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); emit_byte(0xea); /* fldl2e log2(e) */ emit_byte(0xd8); @@ -3511,7 +3565,8 @@ LOWFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s)) emit_byte(0xfd); /* fscale ((e^x)-(e^-x))/2 */ emit_byte(0xdd); emit_byte(0xd9); /* fstp copy & pop */ - tos_make(d); /* store y=sinh(x) */ + if (s!=d) + tos_make(d); /* store y=sinh(x) */ } LENDFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s)) @@ -3520,9 +3575,13 @@ LOWFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) int ds,tr; tr=live.onstack[live.tos+3]; - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); emit_byte(0xea); /* fldl2e log2(e) */ emit_byte(0xd8); @@ -3597,7 +3656,8 @@ LOWFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) emit_byte(0xfd); /* fscale ((e^x)+(e^-x))/2 */ emit_byte(0xdd); emit_byte(0xd9); /* fstp copy & pop */ - tos_make(d); /* store y=cosh(x) */ + if (s!=d) + tos_make(d); /* store y=cosh(x) */ } LENDFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) @@ -3606,9 +3666,13 @@ LOWFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s)) int ds,tr; tr=live.onstack[live.tos+3]; - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); emit_byte(0xea); /* fldl2e log2(e) */ emit_byte(0xd8); @@ -3683,7 +3747,8 @@ LOWFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s)) emit_byte(0xde); emit_byte(0xf1); /* fdivrp ((e^x)-(e^-x))/((e^x)+(e^-x)) */ } - tos_make(d); /* store y=tanh(x) */ + if (s!=d) + tos_make(d); /* store y=tanh(x) */ } LENDFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s)) diff --git a/custom.c b/custom.c index 45329ce9..2772edfe 100755 --- a/custom.c +++ b/custom.c @@ -15,7 +15,7 @@ #define SPR0_HPOS 0x15 #define MAX_SPRITES 8 #define SPRITE_COLLISIONS -//#define SPEEDUP +#define SPEEDUP #include "sysconfig.h" #include "sysdeps.h" @@ -125,6 +125,7 @@ static int lof_changed = 0; * worth the trouble.. */ static int vpos_previous, hpos_previous; +static int vpos_lpen, hpos_lpen; static uae_u32 sprtaba[256],sprtabb[256]; static uae_u32 sprite_ab_merge[256]; @@ -1585,6 +1586,8 @@ static void record_color_change (int hpos, int regno, unsigned long value) return; } #endif + if (regno < 0) + write_log("%d\n", regno); curr_color_changes[next_color_change].linepos = hpos; curr_color_changes[next_color_change].regno = regno; curr_color_changes[next_color_change++].value = value; @@ -2399,11 +2402,11 @@ STATIC_INLINE uae_u16 ADKCONR (void) STATIC_INLINE GETVPOS(void) { - return ((bplcon0 & 2) && !currprefs.genlock) ? vpos_previous : vpos; + return vpos_lpen > 0 ? vpos_lpen : (((bplcon0 & 2) && !currprefs.genlock) ? vpos_previous : vpos); } STATIC_INLINE GETHPOS(void) { - return ((bplcon0 & 2) && !currprefs.genlock) ? hpos_previous : current_hpos (); + return vpos_lpen > 0 ? hpos_lpen : (((bplcon0 & 2) && !currprefs.genlock) ? hpos_previous : current_hpos ()); } STATIC_INLINE uae_u16 VPOSR (void) @@ -4264,6 +4267,10 @@ static void hsync_handler (void) ciahsync = 0; } + /* reset light pen latch */ + if (vpos == sprite_vblank_endline) + vpos_lpen = -1; + #ifdef CPUEMU_6 if (currprefs.cpu_cycle_exact || currprefs.blitter_cycle_exact) { decide_blitter (hpos); @@ -4293,8 +4300,11 @@ static void hsync_handler (void) goes haywire with the VPOSW register, it can cause us to miss this, with vpos going into the thousands (and all the nasty consequences this has). */ - if (++vpos >= (maxvpos + (lof == 0 ? 0 : 1))) { + if (bplcon0 & 8) { + vpos_lpen = vpos - 1; + hpos_lpen = maxhpos; + } vpos = 0; vsync_handler (); } @@ -4462,6 +4472,7 @@ void customreset (void) new_beamcon0 = currprefs.ntscmode ? 0x00 : 0x20; hack_vpos = 0; init_hz (); + vpos_lpen = -1; audio_reset (); if (savestate_state != STATE_RESTORE) { diff --git a/debug.c b/debug.c index 6265c773..e99d7219 100755 --- a/debug.c +++ b/debug.c @@ -106,6 +106,7 @@ static char help[] = { " h,? Show this help page\n" " b Step to previous state capture position\n" " am Enable or disable audio channels\n" + " sm Enable or disable sprites\n" " di [] Break on disk access. R=DMA read,W=write,RW=both,P=PIO\n" " Also enables extended disk logging\n" " q Quit the emulator. You don't want to use this command.\n\n" diff --git a/disk.c b/disk.c index 767b9f69..c63f18ae 100755 --- a/disk.c +++ b/disk.c @@ -769,7 +769,8 @@ static int diskfile_iswriteprotect (const char *fname, int *needwritefile, drive *needwritefile = 0; *drvtype = DRV_35_DD; zf1 = DISK_validate_filename (fname, 1, &wrprot1, NULL); - if (!zf1) return 1; + if (!zf1) + return 1; if (zfile_iscompressed (zf1)) { wrprot1 = 1; *needwritefile = 1; @@ -1664,8 +1665,11 @@ int disk_setwriteprotect (int num, const char *name, int protect) oldprotect = diskfile_iswriteprotect (name, &needwritefile, &drvtype); zf1 = DISK_validate_filename (name, 1, &wrprot1, NULL); - if (!zf1) return 0; - if (zfile_iscompressed (zf1)) wrprot1 = 1; + if (!zf1) + return 0; + if (zfile_iscompressed (zf1)) + wrprot1 = 1; + zfile_fclose (zf1); zf2 = getwritefile (name, &wrprot2); name2 = DISK_get_saveimagepath (name); @@ -2444,7 +2448,7 @@ void DSKLEN (uae_u16 v, int hpos) } if (!(v & 0x8000)) { if (dskdmaen) { - /* Megalomania and Knightmare does this */ + /* Megalomania and Knightmare does this */ if (disk_debug_logging > 0 && dskdmaen == 2) write_log ("warning: Disk read DMA aborted, %d words left PC=%x\n", dsklength, m68k_getpc()); if (dskdmaen == 3) diff --git a/drawing.c b/drawing.c index 08910f97..8a944ac4 100755 --- a/drawing.c +++ b/drawing.c @@ -933,7 +933,7 @@ STATIC_INLINE void draw_sprites_1 (struct sprite_entry *e, int ham, int dualpf, v >>= offs * 2; v &= 15; #if SPRITE_DEBUG > 0 - v |= 1 | 4; + v ^= 8; #endif if (has_attach && (stbuf[pos] & (3 << offs))) { diff --git a/filesys.c b/filesys.c index ccce4188..28c1c3dd 100755 --- a/filesys.c +++ b/filesys.c @@ -2941,6 +2941,55 @@ action_set_file_size (Unit *unit, dpacket packet) PUT_PCK_RES2 (packet, 0); } +static int relock_do(Unit *unit, a_inode *a1) +{ + Key *k1, *knext; + int wehavekeys = 0; + + for (k1 = unit->keys; k1; k1 = knext) { + knext = k1->next; + if (k1->aino == a1 && k1->fd) { + wehavekeys++; + my_close (k1->fd); + write_log ("handle %p freed\n", k1->fd); + } + } + return wehavekeys; +} + +static void relock_re(Unit *unit, a_inode *a1, a_inode *a2, int failed) +{ + Key *k1, *knext; + + for (k1 = unit->keys; k1; k1 = knext) { + knext = k1->next; + if (k1->aino == a1 && k1->fd) { + int mode = (k1->dosmode & A_FIBF_READ) == 0 ? O_WRONLY : (k1->dosmode & A_FIBF_WRITE) == 0 ? O_RDONLY : O_RDWR; + mode |= O_BINARY; + if (failed) { + /* rename still failed, restore fd */ + k1->fd = my_open (a1->nname, mode); + write_log ("restoring old handle '%s' %d\n", a1->nname, k1->dosmode); + } else { + /* transfer fd to new name */ + if (a2) { + k1->aino = a2; + k1->fd = my_open (a2->nname, mode); + write_log ("restoring new handle '%s' %d\n", a2->nname, k1->dosmode); + } else { + write_log ("no new handle, deleting old lock(s).\n"); + } + } + if (k1->fd == NULL) { + write_log ("relocking failed '%s' -> '%s'\n", a1->nname, a2->nname); + free_key (unit, k1); + } else { + my_lseek (k1->fd, k1->file_pos, SEEK_SET); + } + } + } +} + static void action_delete_object (Unit *unit, dpacket packet) { @@ -3064,7 +3113,7 @@ action_rename_object (Unit *unit, dpacket packet) /* rename always fails if file is open for writing */ for (k1 = unit->keys; k1; k1 = knext) { knext = k1->next; - if (k1->aino == a1 && k1->fd >= 0 && k1->createmode == 2) { + if (k1->aino == a1 && k1->fd && k1->createmode == 2) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_OBJECT_IN_USE); return; @@ -3101,39 +3150,11 @@ action_rename_object (Unit *unit, dpacket packet) int ret = -1; /* maybe we have open file handles that caused failure? */ write_log ("rename '%s' -> '%s' failed, trying relocking..\n", a1->nname, a2->nname); - for (k1 = unit->keys; k1; k1 = knext) { - knext = k1->next; - if (k1->aino == a1 && k1->fd >= 0) { - wehavekeys++; - my_close (k1->fd); - write_log ("handle %d freed\n", k1->fd); - } - } + wehavekeys = relock_do(unit, a1); /* try again... */ ret = my_rename (a1->nname, a2->nname); - for (k1 = unit->keys; k1; k1 = knext) { - knext = k1->next; - if (k1->aino == a1 && k1->fd >= 0) { - int mode = (k1->dosmode & A_FIBF_READ) == 0 ? O_WRONLY : (k1->dosmode & A_FIBF_WRITE) == 0 ? O_RDONLY : O_RDWR; - mode |= O_BINARY; - if (ret == -1) { - /* rename still failed, restore fd */ - k1->fd = my_open (a1->nname, mode); - write_log ("restoring old handle '%s' %d\n", a1->nname, k1->dosmode); - } else { - /* transfer fd to new name */ - k1->aino = a2; - k1->fd = my_open (a2->nname, mode); - write_log ("restoring new handle '%s' %d\n", a2->nname, k1->dosmode); - } - if (k1->fd == NULL) { - write_log ("relocking failed '%s' -> '%s'\n", a1->nname, a2->nname); - free_key (unit, k1); - } else { - my_lseek (k1->fd, k1->file_pos, SEEK_SET); - } - } - } + /* restore locks */ + relock_re(unit, a1, a2, ret == -1 ? 1 : 0); if (ret == -1) { delete_aino (unit, a2); PUT_PCK_RES1 (packet, DOS_FALSE); diff --git a/inputdevice.c b/inputdevice.c index e28130e8..3635f462 100755 --- a/inputdevice.c +++ b/inputdevice.c @@ -699,8 +699,6 @@ static uae_u8 parconvert (uae_u8 v, int jd, int shift) return v; } - - /* io-pins floating: dir=1 -> return data, dir=0 -> always return 1 */ uae_u8 handle_parport_joystick (int port, uae_u8 pra, uae_u8 dra) { @@ -717,8 +715,8 @@ uae_u8 handle_parport_joystick (int port, uae_u8 pra, uae_u8 dra) case 1: v = ((pra & dra) | (dra ^ 0xff)) & 0x7; if (parport_joystick_enabled) { - if (getbuttonstate (2, 0)) v &= ~1; - if (getbuttonstate (3, 0)) v &= ~4; + if (getbuttonstate (2, 0)) v &= ~4; + if (getbuttonstate (3, 0)) v &= ~1; } return v; default: @@ -784,7 +782,8 @@ static uae_u16 handle_joystick_potgor (uae_u16 potgor) uae_u16 p5dat = 0x0100 << (i * 4); /* data P5 */ if (mouse_port[i]) { - /* mouse has pull-up resistors in button lines */ + /* official Commodore mouse has pull-up resistors in button lines + * NOTE: 3rd party mice may not have pullups! */ if (!(potgo_value & p5dir)) potgor |= p5dat; if (!(potgo_value & p9dir)) @@ -814,7 +813,6 @@ static uae_u16 handle_joystick_potgor (uae_u16 potgor) potgor &= ~p9dat; /* shift at zero == return zero */ if (cd32_shifter[i] >= 2 && (joybutton[i] & ((1 << JOYBUTTON_CD32_PLAY) << (cd32_shifter[i] - 2)))) potgor &= ~p9dat; - //write_log ("%d:%04.4X %08.8X\n", cd32_shifter[i], potgor, m68k_getpc()); } else { if (getbuttonstate (i, JOYBUTTON_3)) potgor &= ~p5dat; diff --git a/od-win32/dinput.c b/od-win32/dinput.c index d4149a86..fe619814 100755 --- a/od-win32/dinput.c +++ b/od-win32/dinput.c @@ -231,7 +231,8 @@ static int initialize_catweasel(void) } -#define RDP_MOUSE "\\??\\Root#RDP_MOU#" +#define RDP_MOUSE1 "\\??\\Root#RDP_MOU#" +#define RDP_MOUSE2 "\\\\?\\Root#RDP_MOU#" static int initialize_rawinput (void) { @@ -279,7 +280,9 @@ static int initialize_rawinput (void) vtmp = bufsize; pGetRawInputDeviceInfo (h, RIDI_DEVICENAME, buf, &vtmp); - if (!memcmp (RDP_MOUSE, buf, strlen (RDP_MOUSE))) + if (!memcmp (RDP_MOUSE1, buf, strlen (RDP_MOUSE1))) + continue; + if (!memcmp (RDP_MOUSE2, buf, strlen (RDP_MOUSE2))) continue; if (type == RIM_TYPEMOUSE) rnum_mouse++; @@ -300,7 +303,9 @@ static int initialize_rawinput (void) pGetRawInputDeviceInfo (h, RIDI_DEVICENAME, buf, &vtmp); if (did == di_mouse) { - if (!memcmp (RDP_MOUSE, buf, strlen (RDP_MOUSE))) + if (!memcmp (RDP_MOUSE1, buf, strlen (RDP_MOUSE1))) + continue; + if (!memcmp (RDP_MOUSE2, buf, strlen (RDP_MOUSE2))) continue; if (rnum_mouse < 2) continue; diff --git a/od-win32/direct3d.c b/od-win32/direct3d.c index 8aa50cfe..4e00e196 100755 --- a/od-win32/direct3d.c +++ b/od-win32/direct3d.c @@ -433,6 +433,11 @@ static void calc (float *xp, float *yp, float *sxp, float *syp) tx = fx / ((currprefs.gfx_filter_horiz_zoom_mult + currprefs.gfx_filter_horiz_zoom / 4) / 1000.0); ty = fy / ((currprefs.gfx_filter_vert_zoom_mult + currprefs.gfx_filter_vert_zoom / 4) / 1000.0); + if (currprefs.gfx_lores) + tx /= 2; + if (!currprefs.gfx_linedbl) + ty /= 2; + mx = (currprefs.gfx_filter_horiz_offset / 1000.0) * fx; my = (currprefs.gfx_filter_vert_offset / 1000.0) * fy; diff --git a/od-win32/fsdb_win32.c b/od-win32/fsdb_win32.c index e013ba86..f6021eca 100755 --- a/od-win32/fsdb_win32.c +++ b/od-win32/fsdb_win32.c @@ -450,20 +450,23 @@ int my_mkdir (const char *name) static int recycle (const char *name) { - SHFILEOPSTRUCT fos; - /* name must be terminated by \0\0 */ - char *p = xcalloc (strlen (name) + 2, 1); - int v; + if (currprefs.win32_norecyclebin) { + return DeleteFile(name) ? 0 : -1; + } else { + SHFILEOPSTRUCT fos; + /* name must be terminated by \0\0 */ + char *p = xcalloc (strlen (name) + 2, 1); + int v; - strcpy (p, name); - memset (&fos, 0, sizeof (fos)); - fos.wFunc = FO_DELETE; - fos.pFrom = p; - fos.fFlags = (currprefs.win32_norecyclebin ? 0 : FOF_ALLOWUNDO) | - FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NORECURSION | FOF_SILENT; - v = SHFileOperation (&fos); - xfree (p); - return v ? -1 : 0; + strcpy (p, name); + memset (&fos, 0, sizeof (fos)); + fos.wFunc = FO_DELETE; + fos.pFrom = p; + fos.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NORECURSION | FOF_SILENT; + v = SHFileOperation (&fos); + xfree (p); + return v ? -1 : 0; + } } int my_rmdir (const char *name) @@ -704,6 +707,8 @@ int dos_errno (void) case ERROR_SHARING_VIOLATION: case ERROR_BUSY: + /* SHFileOperation() returns this if file can't be deleted!?! */ + case ERROR_INVALID_HANDLE: return ERROR_OBJECT_IN_USE; case ERROR_CURRENT_DIRECTORY: diff --git a/od-win32/opengl.c b/od-win32/opengl.c index 390b9db9..21f528e3 100755 --- a/od-win32/opengl.c +++ b/od-win32/opengl.c @@ -461,10 +461,10 @@ static void OGL_dorender (int newtex) { uae_u8 *data = gfxvidinfo.bufmem; float x1, y1, x2, y2, tx, ty; - double mx, my, fx, fy, xm, ym; + double mx, my, fx, fy, fx2, fy2, xm, ym; xm = currprefs.gfx_lores ? 2 : 1; - ym = currprefs.gfx_linedbl ? 1 : 2; + ym = currprefs.gfx_linedbl ? 2 : 1; fx = (required_texture_size * w_width / t_width) / 2.0; fy = (required_texture_size * w_height / t_height) / 2.0; @@ -484,7 +484,6 @@ static void OGL_dorender (int newtex) x2 += tx + mx; y2 += ty + my; - #ifdef FSAA glEnable (GL_MULTISAMPLE_ARB); #endif diff --git a/od-win32/resources/resource.h b/od-win32/resources/resource.h index 30a02436..0c2a2542 100755 --- a/od-win32/resources/resource.h +++ b/od-win32/resources/resource.h @@ -182,7 +182,7 @@ #define IDS_SOUND_INTERPOL_CRUX 205 #define IDS_SOUND_FILTER_OFF 206 #define IDS_SOUND_FILTER_EMULATED 207 -#define IDS_SOUND_FILTER_ON 208 +#define IDS_SOUND_FILTER_ON_A500 208 #define IDS_INPUT_COMPATIBILITY 209 #define IDS_INPUT_CUSTOM 210 #define IDS_INPUT_COPY_DEFAULT 211 @@ -231,6 +231,8 @@ #define IDS_SOUND_SWAP_BOTH 251 #define IDB_BITMAP1 252 #define IDB_LCD160X43 252 +#define IDS_SOUND_FILTER_ON_AGA 252 +#define IDS_SOUND_FILTER_ON 253 #define IDS_NUMSG_NEEDEXT2 300 #define IDS_NUMSG_NOROMKEY 301 #define IDS_NUMSG_KSROMCRCERROR 302 @@ -312,7 +314,6 @@ #define IDC_CAPS 1077 #define IDC_ABIME 1078 #define IDC_AMIGASYS 1079 -#define IDC_AMIGASYS2 1080 #define IDC_AMIKIT 1080 #define IDC_RICHEDIT1 1091 #define IDC_RICHEDIT2 1092 diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index e4167072..86202092 100755 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -238,18 +238,18 @@ BEGIN CONTROL "Slider1",IDC_SOUNDBUFFERRAM,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,138,75,106,19 EDITTEXT IDC_SOUNDBUFFERMEM,248,78,40,12,ES_CENTER | ES_READONLY GROUPBOX "Settings",IDC_SOUNDINTERPOLATION2,6,101,290,60 - LTEXT "Frequency:",IDC_SOUNDFREQTXT,13,111,37,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDFREQ,15,120,59,75,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - LTEXT "Audio filter:",IDC_SOUNDFILTERTXT,227,135,34,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDFILTER,227,144,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Stereo mode:",IDC_SOUNDSTEREOTXT,86,111,41,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDSTEREO,85,120,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Interpolation:",IDC_SOUNDINTERPOLATIONTXT,227,111,41,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDINTERPOLATION,227,119,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Stereo separation:",IDC_SOUNDSTEREOSEPTXT,155,111,56,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDSTEREOSEP,156,120,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Stereo mixing delay:",IDC_SOUNDSTEREOMIXTXT,155,135,63,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDSTEREOMIX,156,144,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Frequency:",IDC_SOUNDFREQTXT,11,111,37,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDFREQ,13,120,51,75,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LTEXT "Audio filter:",IDC_SOUNDFILTERTXT,209,135,34,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDFILTER,209,144,80,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Stereo mode:",IDC_SOUNDSTEREOTXT,74,111,41,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDSTEREO,73,120,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Interpolation:",IDC_SOUNDINTERPOLATIONTXT,209,111,41,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDINTERPOLATION,209,119,80,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Stereo separation:",IDC_SOUNDSTEREOSEPTXT,141,111,56,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDSTEREOSEP,142,120,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Stereo mixing delay:",IDC_SOUNDSTEREOMIXTXT,141,135,63,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDSTEREOMIX,142,144,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP GROUPBOX "Floppy Drive Sound Emulation",IDC_STATIC,6,164,290,46 CONTROL "",IDC_SOUNDDRIVEVOLUME,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,14,172,107,19 EDITTEXT IDC_SOUNDDRIVEVOLUME2,124,178,40,12,ES_CENTER | ES_READONLY @@ -259,8 +259,8 @@ BEGIN CONTROL "Slider1",IDC_SOUNDADJUST,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,14,221,107,19 EDITTEXT IDC_SOUNDADJUSTNUM,124,224,40,12,ES_CENTER | ES_READONLY PUSHBUTTON "Calibrate",IDC_SOUNDCALIBRATE,183,223,40,14 - COMBOBOX IDC_SOUNDSWAP,85,144,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Swap channels:",IDC_SOUNDSWAPTXT,86,135,50,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDSWAP,73,144,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Swap channels:",IDC_SOUNDSWAPTXT,82,135,50,8,SS_CENTERIMAGE END IDD_LOADSAVE DIALOGEX 0, 0, 302, 241 @@ -838,7 +838,7 @@ BEGIN VALUE "FileDescription", "WinUAE" VALUE "FileVersion", "1.2" VALUE "InternalName", "WinUAE" - VALUE "LegalCopyright", "© 1996-2005 under the GNU Public License (GPL)" + VALUE "LegalCopyright", "© 1996-2006 under the GNU Public License (GPL)" VALUE "OriginalFilename", "WinUAE.exe" VALUE "ProductName", "WinUAE" VALUE "ProductVersion", "1.2" @@ -1059,7 +1059,7 @@ END STRINGTABLE BEGIN - IDS_SOUND_FILTER_ON "Always on" + IDS_SOUND_FILTER_ON_A500 "Always on (pre-AGA)" IDS_INPUT_COMPATIBILITY "Compatibility mode" IDS_INPUT_CUSTOM "Configuration #%d" IDS_INPUT_COPY_DEFAULT "Default" @@ -1116,6 +1116,8 @@ BEGIN IDS_SOUND_SWAP_PAULA "Paula only" IDS_SOUND_SWAP_AHI "AHI only" IDS_SOUND_SWAP_BOTH "Both" + IDS_SOUND_FILTER_ON_AGA "Always on (AGA)" + IDS_SOUND_FILTER_ON "Always on" END STRINGTABLE diff --git a/od-win32/sounddep/sound.c b/od-win32/sounddep/sound.c index fa819e7d..8d04acd6 100755 --- a/od-win32/sounddep/sound.c +++ b/od-win32/sounddep/sound.c @@ -598,7 +598,7 @@ static void filtercheck (uae_s16 *sndbuffer, int len) static double cold[4]; double old0, old1, v; - if (gui_data.powerled || currprefs.sound_filter == 2) { + if (gui_data.powerled || currprefs.sound_filter == FILTER_SOUND_ON_A500 || currprefs.sound_filter == FILTER_SOUND_ON_A1200) { if (ch == 1) { old0 = cold[0]; for (i = 0; i < len; i++) { @@ -631,7 +631,7 @@ void finish_sound_buffer (void) { if (turbo_emulation) return; - if (currprefs.sound_filter) + if (currprefs.sound_filter && currprefs.sound_freq != 44100) filtercheck((uae_s16*)sndbuffer, sndbufsize / 2); if (currprefs.sound_stereo == 1 && currprefs.sound_stereo_swap_paula) channelswap((uae_s16*)sndbuffer, sndbufsize / 2); diff --git a/od-win32/sounddep/sound.h b/od-win32/sounddep/sound.h index 2bb8ea7c..9ab75076 100755 --- a/od-win32/sounddep/sound.h +++ b/od-win32/sounddep/sound.h @@ -34,9 +34,10 @@ static __inline__ void check_sound_buffers (void) #define PUT_SOUND_BYTE(b) do { *(uae_u8 *)sndbufpt = b; sndbufpt = (uae_u16 *)(((uae_u8 *)sndbufpt) + 1); } while (0) #define PUT_SOUND_WORD(b) do { *(uae_u16 *)sndbufpt = b; sndbufpt = (uae_u16 *)(((uae_u8 *)sndbufpt) + 2); } while (0) #define PUT_SOUND_BYTE_LEFT(b) PUT_SOUND_BYTE(b) -#define PUT_SOUND_WORD_LEFT(b) PUT_SOUND_WORD(b) +#define PUT_SOUND_WORD_LEFT(b) do { if (currprefs.sound_filter) b = filter (b, l_output); PUT_SOUND_WORD(b); } while (0) #define PUT_SOUND_BYTE_RIGHT(b) PUT_SOUND_BYTE(b) -#define PUT_SOUND_WORD_RIGHT(b) PUT_SOUND_WORD(b) +#define PUT_SOUND_WORD_RIGHT(b) do { if (currprefs.sound_filter) b = filter (b, r_output); PUT_SOUND_WORD(b); } while (0) +#define PUT_SOUND_WORD_MONO(b) PUT_SOUND_WORD_LEFT(b) #define SOUND16_BASE_VAL 0 #define SOUND8_BASE_VAL 128 @@ -46,6 +47,11 @@ static __inline__ void check_sound_buffers (void) #define DEFAULT_SOUND_FREQ 44100 #define HAVE_STEREO_SUPPORT +#define FILTER_SOUND_OFF 0 +#define FILTER_SOUND_EMUL 1 +#define FILTER_SOUND_ON_A500 2 +#define FILTER_SOUND_ON_A1200 3 + #ifdef AHI #include "ahidsound.h" #endif diff --git a/od-win32/win32.c b/od-win32/win32.c index 5d7deb2e..9eb16f39 100755 --- a/od-win32/win32.c +++ b/od-win32/win32.c @@ -919,7 +919,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, num -= 6; if (nm->code == NM_RCLICK) { disk_eject (num); - } else { + } else if (changed_prefs.dfxtype[num] >= 0) { DiskSelection (hWnd, IDC_DF0 + num, 0, &changed_prefs, 0); disk_insert (num, changed_prefs.df[num]); } @@ -1640,7 +1640,7 @@ void logging_init( void ) SystemInfo.wProcessorLevel, SystemInfo.wProcessorRevision, SystemInfo.dwNumberOfProcessors); write_log ("\n(c) 1995-2001 Bernd Schmidt - Core UAE concept and implementation." - "\n(c) 1998-2005 Toni Wilen - Win32 port, core code updates." + "\n(c) 1998-2006 Toni Wilen - Win32 port, core code updates." "\n(c) 1996-2001 Brian King - Win32 port, Picasso96 RTG, and GUI." "\n(c) 1996-1999 Mathias Ortmann - Win32 port and bsdsocket support." "\n(c) 2000-2001 Bernd Meyer - JIT engine." diff --git a/od-win32/win32.h b/od-win32/win32.h index a0836991..27555318 100755 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -22,7 +22,7 @@ extern int manual_palette_refresh_needed; extern int mouseactive, focus; extern int ignore_messages_all; #define WINUAEBETA 1 -#define WINUAEBETASTR " Beta 4" +#define WINUAEBETASTR " Beta 5" extern char start_path_exe[MAX_DPATH]; extern char start_path_data[MAX_DPATH]; diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index 40fff4e1..66ee3c05 100755 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -5022,8 +5022,12 @@ static void values_to_sounddlg (HWND hDlg) SendDlgItemMessage(hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt); WIN32GUI_LoadUIString (IDS_SOUND_FILTER_EMULATED, txt, sizeof (txt)); SendDlgItemMessage(hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt); - WIN32GUI_LoadUIString (IDS_SOUND_FILTER_ON, txt, sizeof (txt)); + WIN32GUI_LoadUIString (workprefs.sound_freq == 44100 ? IDS_SOUND_FILTER_ON_A500 : IDS_SOUND_FILTER_ON, txt, sizeof (txt)); SendDlgItemMessage(hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt); + if (workprefs.sound_freq == 44100) { + WIN32GUI_LoadUIString (IDS_SOUND_FILTER_ON_AGA, txt, sizeof (txt)); + SendDlgItemMessage(hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt); + } SendDlgItemMessage(hDlg, IDC_SOUNDFILTER, CB_SETCURSEL, workprefs.sound_filter, 0 ); SendDlgItemMessage(hDlg, IDC_SOUNDSTEREO, CB_RESETCONTENT, 0, 0); diff --git a/od-win32/winuae_msvc/winuae_msvc.vcproj b/od-win32/winuae_msvc/winuae_msvc.vcproj index 35f5acac..699eb2af 100755 --- a/od-win32/winuae_msvc/winuae_msvc.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.vcproj @@ -259,7 +259,7 @@