From: Toni Wilen Date: Sat, 6 May 2006 17:43:09 +0000 (+0300) Subject: imported winuaesrc1300b2.zip X-Git-Tag: 2100~287 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=6ffa2e8c331f2c90bd10ad94fcdc88ce118f9961;p=francis%2Fwinuae.git imported winuaesrc1300b2.zip --- diff --git a/arcadia.c b/arcadia.c index aa5f98e8..06e3b8b5 100755 --- a/arcadia.c +++ b/arcadia.c @@ -43,29 +43,35 @@ struct arcadiarom *arcadia_rom; static char arcadia_path[MAX_DPATH]; static struct arcadiarom roms[] = { - { "ar_airh.zip", "scpa211", "airh_", 1, 5, 0, 2, 4, 7, 6, 1, 3, 0x98f564 }, - { "ar_bowl.zip", "scpa211", "bowl_", 1, 7, 6, 0, 1, 2, 3, 4, 5, 0x98f564 }, - { "ar_dart.zip", "scpa211", "dart_", 1, 4, 0, 7, 6, 3, 1, 2, 5, 0x98f564 }, - { "ar_fast.zip", "scpav3_0.1", "fastv28.", 0, 7, 6, 5, 4, 3, 2, 1, 0, 0x9902bc }, - { "ar_ldrb.zip", "scpa211", "lbg240", 0, 7, 6, 5, 4, 3, 2, 1, 0, 0x98f564 }, - { "ar_ldrba.zip", "scpa211", "ldrb_", 1, 2, 3, 4, 1, 0, 7, 5, 6, 0x98f564 }, - { "ar_ninj.zip", "scpa211", "ninj_", 1, 1, 6, 5, 7, 4, 2, 0, 3, 0x98f564 }, - { "ar_rdwr.zip", "scpa211", "rdwr_", 1, 3, 1, 6, 4, 0, 5, 2, 7, 0x98f564 }, - - { "ar_socc.zip", "scpav3_0.1", "socc30.", 2, 0, 7, 1, 6, 5, 4, 3, 2, 0x9902bc }, - - { "ar_sdwr.zip", "scpa211", "sdwr_", 1, 6, 3, 4, 5, 2, 1, 0, 7, 0x98f564 }, - { "ar_spot.zip", "scpav3_0.1", "spotv2.", 0, 7, 6, 5, 4, 3, 2, 1, 0, 0x9902bc }, - { "ar_sprg.zip", "scpa211", "sprg_", 1, 4, 7, 3, 0, 6, 5, 2, 1, 0x98f564 }, - { "ar_xeon.zip", "scpa211", "xeon_", 1, 3, 1, 2, 4, 0, 5, 6, 7, 0x98f564 }, + { "ar_airh.zip", "scpa211", "airh_", 1, 5, 0, 2, 4, 7, 6, 1, 3 }, + { "ar_bowl.zip", "scpa211", "bowl_", 1, 7, 6, 0, 1, 2, 3, 4, 5 }, + { "ar_dart.zip", "scpa211", "dart_", 1, 4, 0, 7, 6, 3, 1, 2, 5 }, + { "ar_fast.zip", "scpav3_0.1", "fastv28.", 0, 7, 6, 5, 4, 3, 2, 1, 0 }, + { "ar_ldrb.zip", "scpa211", "lbg240", 0, 7, 6, 5, 4, 3, 2, 1, 0 }, + { "ar_ldrba.zip", "scpa211", "ldrb_", 1, 2, 3, 4, 1, 0, 7, 5, 6 }, + { "ar_ninj.zip", "scpa211", "ninj_", 1, 1, 6, 5, 7, 4, 2, 0, 3 }, + { "ar_rdwr.zip", "scpa211", "rdwr_", 1, 3, 1, 6, 4, 0, 5, 2, 7 }, + + { "ar_socc.zip", "scpav3_0.1", "socc30.", 2, 0, 7, 1, 6, 5, 4, 3, 2 }, + + { "ar_sdwr.zip", "scpa211", "sdwr_", 1, 6, 3, 4, 5, 2, 1, 0, 7 }, + { "ar_spot.zip", "scpav3_0.1", "spotv2.", 0, 7, 6, 5, 4, 3, 2, 1, 0 }, + { "ar_sprg.zip", "scpa211", "sprg_", 1, 4, 7, 3, 0, 6, 5, 2, 1 }, + { "ar_xeon.zip", "scpa211", "xeon_", 1, 3, 1, 2, 4, 0, 5, 6, 7 }, { NULL, NULL, NULL } }; -static uae_u8 *arbmemory; +static uae_u8 *arbmemory, *arbbmemory; +static int boot_read; + #define arb_start 0x800000 #define arb_mask 0x1fffff #define allocated_arbmemory 0x200000 +#define arbb_start 0xf00000 +#define arbb_mask 0x7ffff +#define allocated_arbbmemory 0x80000 + #define nvram_offset 0x1fc000 #define bios_offset 0x180000 #define NVRAM_SIZE 0x4000 @@ -211,54 +217,46 @@ static void decrypt_roms (struct arcadiarom *rom) arbmemory[1] = 0xfc; } -uae_u32 REGPARAM2 aab_bget (uaecptr addr) +static uae_u32 REGPARAM2 arbb_lget (uaecptr addr) { - return 0; -} + uae_u32 *m; -static uae_u32 REGPARAM2 aab_wget (uaecptr addr) -{ - uae_u32 v; -#ifdef JIT - special_mem |= S_READ; -#endif - v = (aab_bget (addr) << 8) | aab_bget (addr + 1); - return v; + addr -= arbb_start & arbb_mask; + addr &= arbb_mask; + m = (uae_u32 *)(arbbmemory + addr); + return do_get_mem_long (m); } +static uae_u32 REGPARAM2 arbb_wget (uaecptr addr) +{ + uae_u16 *m; -static uae_u32 REGPARAM2 aab_lget (uaecptr addr) + addr -= arbb_start & arbb_mask; + addr &= arbb_mask; + m = (uae_u16 *)(arbbmemory + addr); + return do_get_mem_word (m); +} +static uae_u32 REGPARAM2 arbb_bget (uaecptr addr) { - uae_u32 v; -#ifdef JIT - special_mem |= S_READ; -#endif - v = (aab_bget (addr) << 24) | (aab_bget (addr + 1) << 16) | - (aab_bget (addr + 2) << 8) | (aab_bget (addr + 3)); - return v; + addr -= arbb_start & arbb_mask; + addr &= arbb_mask; + return arbbmemory[addr]; } -static void REGPARAM2 aab_lput (uaecptr addr, uae_u32 l) +static void REGPARAM2 arbb_lput (uaecptr addr, uae_u32 l) { -#ifdef JIT - special_mem |= S_WRITE; -#endif } -static void REGPARAM2 aab_wput (uaecptr addr, uae_u32 w) + +static void REGPARAM2 arbb_wput (uaecptr addr, uae_u32 w) { -#ifdef JIT - special_mem |= S_WRITE; -#endif } -static void REGPARAM2 aab_bput (uaecptr addr, uae_u32 b) + +static void REGPARAM2 arbb_bput (uaecptr addr, uae_u32 b) { -#ifdef JIT - special_mem |= S_WRITE; -#endif } -addrbank arcadia_autoconfig_bank = { - aab_lget, aab_wget, aab_bget, - aab_lput, aab_wput, aab_bput, +static addrbank arcadia_boot_bank = { + arbb_lget, arbb_wget, arbb_bget, + arbb_lput, arbb_wput, arbb_bput, default_xlate, default_check, NULL }; @@ -271,7 +269,7 @@ static uae_u32 REGPARAM2 arb_lget (uaecptr addr) m = (uae_u32 *)(arbmemory + addr); return do_get_mem_long (m); } -uae_u32 REGPARAM2 arb_wget (uaecptr addr) +static uae_u32 REGPARAM2 arb_wget (uaecptr addr) { uae_u16 *m; @@ -280,14 +278,14 @@ uae_u32 REGPARAM2 arb_wget (uaecptr addr) m = (uae_u16 *)(arbmemory + addr); return do_get_mem_word (m); } -uae_u32 REGPARAM2 arb_bget (uaecptr addr) +static uae_u32 REGPARAM2 arb_bget (uaecptr addr) { addr -= arb_start & arb_mask; addr &= arb_mask; return arbmemory[addr]; } -void REGPARAM2 arb_lput (uaecptr addr, uae_u32 l) +static void REGPARAM2 arb_lput (uaecptr addr, uae_u32 l) { uae_u32 *m; @@ -300,7 +298,7 @@ void REGPARAM2 arb_lput (uaecptr addr, uae_u32 l) } } -void REGPARAM2 arb_wput (uaecptr addr, uae_u32 w) +static void REGPARAM2 arb_wput (uaecptr addr, uae_u32 w) { uae_u16 *m; @@ -313,7 +311,7 @@ void REGPARAM2 arb_wput (uaecptr addr, uae_u32 w) } } -void REGPARAM2 arb_bput (uaecptr addr, uae_u32 b) +static void REGPARAM2 arb_bput (uaecptr addr, uae_u32 b) { addr -= arb_start & arb_mask; addr &= arb_mask; @@ -323,21 +321,7 @@ void REGPARAM2 arb_bput (uaecptr addr, uae_u32 b) } } -int REGPARAM2 arb_check (uaecptr addr, uae_u32 size) -{ - addr -= arb_start & arb_mask; - addr &= arb_mask; - return (addr + size) <= allocated_arbmemory; -} - -uae_u8 REGPARAM2 *arb_xlate (uaecptr addr) -{ - addr -= arb_start & arb_mask; - addr &= arb_mask; - return arbmemory + addr; -} - -addrbank arcadia_rom_bank = { +static addrbank arcadia_rom_bank = { arb_lget, arb_wget, arb_bget, arb_lput, arb_wput, arb_bput, default_xlate, default_check, NULL @@ -386,6 +370,7 @@ int arcadia_map_banks (void) if (!arcadia_rom) return 0; arbmemory = xmalloc (allocated_arbmemory); + arbbmemory = arbmemory + bios_offset; memset (arbmemory, 0, allocated_arbmemory); if (!load_roms (arcadia_path, arcadia_rom)) { arcadia_unmap (); @@ -395,6 +380,8 @@ int arcadia_map_banks (void) nvram_read (); map_banks (&arcadia_rom_bank, arb_start >> 16, allocated_arbmemory >> 16, 0); + map_banks (&arcadia_boot_bank, 0xf0, + 8, 0); return 1; } diff --git a/audio.c b/audio.c index 0ea9ceae..5ecdf5a5 100755 --- a/audio.c +++ b/audio.c @@ -1,11 +1,15 @@ /* * UAE - The Un*x Amiga Emulator * - * OS specific functions + * Paula audio emulation * * Copyright 1995, 1996, 1997 Bernd Schmidt * Copyright 1996 Marcus Sundberg * Copyright 1996 Manfred Thole + * Copyright 2006 Toni Wilen + * + * new filter algorithm and "anti" interpolator by Antti S. Lankila + * */ #include "sysconfig.h" @@ -42,6 +46,15 @@ static int debugchannel (int ch) return 0; } +extern const int winsinc_integral[4096]; + +#define SINC_QUEUE_MAX_AGE 4096 +#define SINC_QUEUE_LENGTH 96 + +typedef struct { + int age, output; +} sinc_queue_t; + struct audio_channel_data { unsigned long adk_mask; unsigned long evtime; @@ -56,6 +69,9 @@ struct audio_channel_data { uae_u16 dat, dat2; int request_word, request_word_skip; int vpos; + int sample_accum, sample_accum_time; + sinc_queue_t sinc_queue[SINC_QUEUE_LENGTH]; + int sinc_queue_length; }; int sampleripper_enabled; @@ -240,6 +256,7 @@ static struct audio_channel_data audio_channel[4]; int sound_available = 0; static int sound_table[64][256]; void (*sample_handler) (void); +static void (*sample_prehandler) (unsigned long best_evtime); unsigned long sample_evtime, scaled_sample_evtime; @@ -285,9 +302,19 @@ 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; +static int led_filter_forced, sound_use_filter; +static int sinc_on; + +static struct filter_state { + float rc1, rc2, rc3, rc4, rc5; +} sound_filter_state[2]; + +enum { + FILTER_MODEL_A500 = 1, + FILTER_MODEL_A1200, + FILTER_MODEL_A500E, + FILTER_MODEL_A1200E +}; /* Amiga has two separate filtering circuits per channel, a static RC filter * on A500 and the LED filter. This code emulates both. @@ -305,41 +332,55 @@ static double f_36, f_33, f_135; * and to 1 dB with the filter off. */ -static int filter(int data, double *output) +static int filter(int input, struct filter_state *fs) { - double s, o; + int o; + float normal_output, led_output; - data = (uae_s16)data; + input = (uae_s16)input; 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; + return input; + if (sound_use_filter == 0) + return input; + + switch (sound_use_filter) { + + case FILTER_MODEL_A500E: + fs->rc1 = 0.52 * input + 0.48 * fs->rc1; + fs->rc2 = 0.92 * fs->rc1 + 0.08 * fs->rc2; + normal_output = fs->rc2; + + fs->rc3 = 0.48 * normal_output + 0.52 * fs->rc3; + fs->rc4 = 0.48 * fs->rc3 + 0.52 * fs->rc4; + fs->rc5 = 0.48 * fs->rc4 + 0.52 * fs->rc5; + + led_output = fs->rc5; + break; + + case FILTER_MODEL_A1200E: + normal_output = input; + + fs->rc2 = 0.48 * normal_output + 0.52 * fs->rc2; + fs->rc3 = 0.48 * fs->rc2 + 0.52 * fs->rc3; + fs->rc4 = 0.48 * fs->rc3 + 0.52 * fs->rc4; + + led_output = fs->rc4; + break; + } - /* 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]; + + if (led_filter_forced > 0 || (gui_data.powerled && led_filter_forced >= 0)) + o = led_output; else - o = output[1] * 0.98; /* to avoid overruns */ + o = normal_output; + if (o > 32767) o = 32767; else if (o < -32768) o = -32768; - return (int)o; + + return o; } STATIC_INLINE void put_sound_word_right (uae_u32 w) @@ -375,6 +416,48 @@ STATIC_INLINE void put_sound_word_left (uae_u32 w) #define DO_CHANNEL(v, c) do { (v) &= audio_channel[c].adk_mask; data += v; } while (0); +static void anti_prehandler(unsigned long best_evtime) +{ + int i, j; + + /* Handle accumulator antialiasiation */ + for (i = 0; i < 4; i++) { + struct audio_channel_data *acd = &audio_channel[i]; + int output = (acd->current_sample * acd->vol) & acd->adk_mask; + + if (sinc_on) { + /* if the output state changes, put the new state into the pipeline. + * the first term is to prevent queue overflow when player routines use + * low period values like 16 that produce ultrasonic sounds. */ + if (acd->sinc_queue[0].age > SINC_QUEUE_MAX_AGE/SINC_QUEUE_LENGTH+1 + && acd->sinc_queue[0].output != output) { + acd->sinc_queue_length += 1; + if (acd->sinc_queue_length > SINC_QUEUE_LENGTH) { + write_log("warning: sinc queue truncated. Last age: %d.\n", acd->sinc_queue[SINC_QUEUE_LENGTH-1].age); + acd->sinc_queue_length = SINC_QUEUE_LENGTH; + } + /* make room for new and add the new value */ + memmove(&acd->sinc_queue[1], &acd->sinc_queue[0], + sizeof(acd->sinc_queue[0]) * (acd->sinc_queue_length - 1)); + acd->sinc_queue[0].age = 0; + acd->sinc_queue[0].output = output; + } + /* age the sinc queue and truncate it when necessary */ + for (j = 0; j < SINC_QUEUE_LENGTH; j += 1) { + acd->sinc_queue[j].age += best_evtime; + if (acd->sinc_queue[j].age > SINC_QUEUE_MAX_AGE-1) { + acd->sinc_queue[j].age = SINC_QUEUE_MAX_AGE-1; + acd->sinc_queue_length = j+1; + break; + } + } + } else { + acd->sample_accum += output * best_evtime; + acd->sample_accum_time += best_evtime; + } + } +} + void sample16_handler (void) { uae_u32 data0 = audio_channel[0].current_sample; @@ -400,7 +483,47 @@ void sample16_handler (void) check_sound_buffers (); } -void sample16i_rh_handler (void) +/* This interpolator examines sample points when Paula switches the output + * voltage and computes the average of Paula's output */ +static void sample16i_anti_handler (void) +{ + int i; + int datas[4], data1; + + for (i = 0; i < 4; i++) { + datas[i] = audio_channel[i].sample_accum_time ? (audio_channel[i].sample_accum / audio_channel[i].sample_accum_time) : 0; + audio_channel[i].sample_accum = 0; + audio_channel[i].sample_accum_time = 0; + } + data1 = datas[0] + datas[3] + datas[1] + datas[2]; + FINISH_DATA (data1, 16, 2); + PUT_SOUND_WORD_MONO (data1); + check_sound_buffers (); +} + +static void sample16i_sinc_handler (void) +{ + int i; + int datas[4], data1; + + for (i = 0; i < 4; i += 1) { + int j, val = winsinc_integral[0], sum = 0; + struct audio_channel_data *acd = &audio_channel[i]; + /* this computes the sinc convolution for the stored samples in buffer */ + for (j = 0; j < acd->sinc_queue_length; j += 1) { + int newval = winsinc_integral[acd->sinc_queue[j].age]; + sum += (newval - val) * acd->sinc_queue[j].output; + val = newval; + } + datas[i] = sum >> 17; + } + data1 = datas[0] + datas[3] + datas[1] + datas[2]; + FINISH_DATA (data1, 16, 2); + PUT_SOUND_WORD_MONO (data1); + check_sound_buffers (); +} + +static void sample16i_rh_handler (void) { unsigned long delta, ratio; @@ -451,7 +574,7 @@ void sample16i_rh_handler (void) check_sound_buffers (); } -void sample16i_crux_handler (void) +static void sample16i_crux_handler (void) { uae_u32 data0 = audio_channel[0].current_sample; uae_u32 data1 = audio_channel[1].current_sample; @@ -547,6 +670,53 @@ void sample16ss_handler (void) check_sound_buffers (); } +/* This interpolator examines sample points when Paula switches the output + * voltage and computes the average of Paula's output */ +static void sample16si_anti_handler (void) +{ + int i; + int datas[4], data1, data2; + + for (i = 0; i < 4; i++) { + datas[i] = audio_channel[i].sample_accum_time ? (audio_channel[i].sample_accum / audio_channel[i].sample_accum_time) : 0; + audio_channel[i].sample_accum = 0; + audio_channel[i].sample_accum_time = 0; + } + data1 = datas[0] + datas[3]; + data2 = datas[1] + datas[2]; + FINISH_DATA (data1, 16, 1); + put_sound_word_left (data1); + FINISH_DATA (data2, 16, 1); + put_sound_word_right (data2); + check_sound_buffers (); +} + + +static void sample16si_sinc_handler (void) +{ + int i; + int datas[4], data1, data2; + + for (i = 0; i < 4; i += 1) { + int j, val = winsinc_integral[0], sum = 0; + struct audio_channel_data *acd = &audio_channel[i]; + /* this computes the sinc convolution for the stored samples in buffer */ + for (j = 0; j < acd->sinc_queue_length; j += 1) { + int newval = winsinc_integral[acd->sinc_queue[j].age]; + sum += (newval - val) * acd->sinc_queue[j].output; + val = newval; + } + datas[i] = sum >> 17; + } + data1 = datas[0] + datas[3]; + data2 = datas[1] + datas[2]; + FINISH_DATA (data1, 16, 1); + put_sound_word_left (data1); + FINISH_DATA (data2, 16, 1); + put_sound_word_right (data2); + check_sound_buffers (); +} + void sample16s_handler (void) { uae_u32 data0 = audio_channel[0].current_sample; @@ -580,7 +750,7 @@ void sample16s_handler (void) check_sound_buffers (); } -void sample16si_crux_handler (void) +static void sample16si_crux_handler (void) { uae_u32 data0 = audio_channel[0].current_sample; uae_u32 data1 = audio_channel[1].current_sample; @@ -657,7 +827,7 @@ void sample16si_crux_handler (void) check_sound_buffers (); } -void sample16si_rh_handler (void) +static void sample16si_rh_handler (void) { unsigned long delta, ratio; @@ -949,8 +1119,7 @@ void audio_reset (void) ahi_close_sound (); #endif reset_sound (); - memset(l_output, 0, sizeof l_output); - memset(r_output, 0, sizeof r_output); + memset(sound_filter_state, 0, sizeof sound_filter_state); if (savestate_state != STATE_RESTORE) { for (i = 0; i < 4; i++) { cdp = &audio_channel[i]; @@ -992,7 +1161,8 @@ STATIC_INLINE int sound_prefs_changed (void) || changed_prefs.sound_volume != currprefs.sound_volume || changed_prefs.sound_stereo_swap_paula != currprefs.sound_stereo_swap_paula || changed_prefs.sound_stereo_swap_ahi != currprefs.sound_stereo_swap_ahi - || changed_prefs.sound_filter != currprefs.sound_filter); + || changed_prefs.sound_filter != currprefs.sound_filter + || changed_prefs.sound_filter_type != currprefs.sound_filter_type); } void check_prefs_changed_audio (void) @@ -1016,6 +1186,7 @@ void check_prefs_changed_audio (void) currprefs.sound_freq = changed_prefs.sound_freq; currprefs.sound_maxbsiz = changed_prefs.sound_maxbsiz; currprefs.sound_filter = changed_prefs.sound_filter; + currprefs.sound_filter_type = changed_prefs.sound_filter_type; currprefs.sound_volume = changed_prefs.sound_volume; currprefs.sound_stereo_swap_paula = changed_prefs.sound_stereo_swap_paula; currprefs.sound_stereo_swap_ahi = changed_prefs.sound_stereo_swap_ahi; @@ -1040,19 +1211,47 @@ void check_prefs_changed_audio (void) mixed_stereo_size = currprefs.sound_mixed_stereo > 0 ? (1 << (currprefs.sound_mixed_stereo - 1)) - 1 : 0; mixed_on = (currprefs.sound_stereo_separation > 0 || currprefs.sound_mixed_stereo > 0) ? 1 : 0; + led_filter_forced = -1; // always off + sound_use_filter = 0; + if (currprefs.sound_filter) { + if (currprefs.sound_filter == FILTER_SOUND_ON) + led_filter_forced = 1; + if (currprefs.sound_filter == FILTER_SOUND_EMUL) + led_filter_forced = 0; + if (currprefs.sound_filter_type == FILTER_SOUND_TYPE_A500) + sound_use_filter = FILTER_MODEL_A500E; + else if (currprefs.sound_filter_type == FILTER_SOUND_TYPE_A1200) + sound_use_filter = FILTER_MODEL_A1200E; + } + /* Select the right interpolation method. */ + sample_prehandler = NULL; if (sample_handler == sample16_handler || sample_handler == sample16i_crux_handler - || sample_handler == sample16i_rh_handler) + || sample_handler == sample16i_rh_handler + || sample_handler == sample16i_anti_handler) + { sample_handler = (currprefs.sound_interpol == 0 ? sample16_handler - : currprefs.sound_interpol == 1 ? sample16i_rh_handler - : sample16i_crux_handler); - else if (sample_handler == sample16s_handler + : currprefs.sound_interpol == 3 ? sample16i_rh_handler + : currprefs.sound_interpol == 4 ? sample16i_crux_handler + : currprefs.sound_interpol == 2 ? sample16i_sinc_handler + : sample16i_anti_handler); + } else if (sample_handler == sample16s_handler || sample_handler == sample16si_crux_handler - || sample_handler == sample16si_rh_handler) + || sample_handler == sample16si_rh_handler + || sample_handler == sample16si_anti_handler) + { sample_handler = (currprefs.sound_interpol == 0 ? sample16s_handler - : currprefs.sound_interpol == 1 ? sample16si_rh_handler - : sample16si_crux_handler); + : currprefs.sound_interpol == 3 ? sample16si_rh_handler + : currprefs.sound_interpol == 4 ? sample16si_crux_handler + : currprefs.sound_interpol == 2 ? sample16si_sinc_handler + : sample16si_anti_handler); + } + sinc_on = 0; + if (sample_handler == sample16si_sinc_handler || sample_handler == sample16i_sinc_handler) + sinc_on = 1; + if (sample_handler == sample16si_anti_handler || sample_handler == sample16i_anti_handler || sinc_on) + sample_prehandler = anti_prehandler; if (currprefs.produce_sound == 0) { eventtab[ev_audio].active = 0; @@ -1098,11 +1297,14 @@ void update_audio (void) n_cycles -= best_evtime; if (currprefs.produce_sound > 1) { next_sample_evtime -= best_evtime; + if (sample_prehandler) + sample_prehandler(best_evtime); if (next_sample_evtime == 0) { next_sample_evtime = scaled_sample_evtime; (*sample_handler) (); } } + if (audio_channel[0].evtime == 0) audio_handler (0, 1); if (audio_channel[1].evtime == 0) diff --git a/blitter.c b/blitter.c index b6363505..b6d8c6a8 100755 --- a/blitter.c +++ b/blitter.c @@ -1155,27 +1155,38 @@ uae_u8 *restore_blitter (uae_u8 *src) uae_u32 flags = restore_u32(); bltstate = (flags & 1) ? BLT_init : BLT_done; + if (flags & 2) { + write_log ("blitter was force-finished when this statefile was saved\n"); + write_log ("contact the author if restored program freezes\n"); + } + return src; +} + +void restore_blitter_finish(void) +{ if (bltstate == BLT_init) { write_log ("blitter was started but DMA was inactive during save\n"); do_blitter (0); } - return src; } uae_u8 *save_blitter (int *len, uae_u8 *dstptr) { uae_u8 *dstbak,*dst; + int forced; + forced = 0; if (bltstate != BLT_done && bltstate != BLT_init) { - write_log ("blitter was running, forcing immediate finish\n"); + write_log ("blitter is active, forcing immediate finish\n"); /* blitter is active just now but we don't have blitter state support yet */ blitter_force_finish (); + forced = 2; } if (dstptr) dstbak = dst = dstptr; else dstbak = dst = malloc (16); - save_u32((bltstate != BLT_done) ? 0 : 1); + save_u32(((bltstate != BLT_done) ? 0 : 1) | forced); *len = dst - dstbak; return dstbak; diff --git a/blkdev.c b/blkdev.c index dcef6dc9..6bb6948a 100755 --- a/blkdev.c +++ b/blkdev.c @@ -38,6 +38,7 @@ static void install_driver (int flags) } if (currprefs.win32_uaescsimode == UAESCSI_ADAPTECASPI || currprefs.win32_uaescsimode == UAESCSI_NEROASPI || + currprefs.win32_uaescsimode == UAESCSI_FROGASPI || !installed) { device_func[DF_SCSI] = &devicefunc_win32_aspi; device_func[DF_IOCTL] = 0; diff --git a/cfgfile.c b/cfgfile.c index 8d3861e5..058eb605 100755 --- a/cfgfile.c +++ b/cfgfile.c @@ -29,8 +29,6 @@ #include "filesys.h" #include "fsdb.h" -#define CONFIG_BLEN 2560 - static int config_newfilesystem; static struct strlist *temp_lines; @@ -133,12 +131,13 @@ static const char *soundmode2[] = { "none", "interrupts", "good", "best", 0 }; static const char *centermode1[] = { "none", "simple", "smart", 0 }; static const char *centermode2[] = { "false", "true", "smart", 0 }; static const char *stereomode[] = { "mono", "stereo", "4ch", "mixed", 0 }; -static const char *interpolmode[] = { "none", "rh", "crux", 0 }; +static const char *interpolmode[] = { "none", "anti", "sinc", "rh", "crux", 0 }; 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", "on_aga", 0 }; +static const char *soundfiltermode1[] = { "off", "emulated", "on", 0 }; +static const char *soundfiltermode2[] = { "standard", "enhanced", 0 }; static const char *loresmode[] = { "normal", "filtered", 0 }; #ifdef GFXFILTER static const char *filtermode1[] = { "no_16", "bilinear_16", "no_32", "bilinear_32", 0 }; @@ -208,7 +207,7 @@ void cfgfile_target_write (struct zfile *f, char *format,...) va_end (parms); } -static void save_options (struct zfile *f, struct uae_prefs *p, int type) +void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) { struct strlist *sl; char *str; @@ -292,7 +291,8 @@ static void save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write (f, "sound_frequency=%d\n", p->sound_freq); cfgfile_write (f, "sound_interpol=%s\n", interpolmode[p->sound_interpol]); cfgfile_write (f, "sound_adjust=%d\n", p->sound_adjust); - cfgfile_write (f, "sound_filter=%s\n", soundfiltermode[p->sound_filter]); + cfgfile_write (f, "sound_filter=%s\n", soundfiltermode1[p->sound_filter]); + cfgfile_write (f, "sound_filter_type=%s\n", soundfiltermode2[p->sound_filter_type]); cfgfile_write (f, "sound_volume=%d\n", p->sound_volume); cfgfile_write (f, "comp_trustbyte=%s\n", compmode[p->comptrustbyte]); @@ -345,13 +345,14 @@ static void save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write (f, "gfx_display=%d\n", p->gfx_display); cfgfile_write (f, "gfx_framerate=%d\n", p->gfx_framerate); - cfgfile_write (f, "gfx_width=%d\n", p->gfx_width_win); /* compatibility with old versions */ - cfgfile_write (f, "gfx_height=%d\n", p->gfx_height_win); /* compatibility with old versions */ - cfgfile_write (f, "gfx_width_windowed=%d\n", p->gfx_width_win); - cfgfile_write (f, "gfx_height_windowed=%d\n", p->gfx_height_win); - cfgfile_write (f, "gfx_width_fullscreen=%d\n", p->gfx_width_fs); - cfgfile_write (f, "gfx_height_fullscreen=%d\n", p->gfx_height_fs); + cfgfile_write (f, "gfx_width=%d\n", p->gfx_size_win.width); /* compatibility with old versions */ + cfgfile_write (f, "gfx_height=%d\n", p->gfx_size_win.height); /* compatibility with old versions */ + cfgfile_write (f, "gfx_width_windowed=%d\n", p->gfx_size_win.width); + cfgfile_write (f, "gfx_height_windowed=%d\n", p->gfx_size_win.height); + cfgfile_write (f, "gfx_width_fullscreen=%d\n", p->gfx_size_fs.width); + cfgfile_write (f, "gfx_height_fullscreen=%d\n", p->gfx_size_fs.height); cfgfile_write (f, "gfx_refreshrate=%d\n", p->gfx_refreshrate); + cfgfile_write (f, "gfx_autoresolution=%d\n", p->gfx_autoresolution); cfgfile_write (f, "gfx_vsync=%s\n", p->gfx_vsync ? "true" : "false"); cfgfile_write (f, "gfx_lores=%s\n", p->gfx_lores ? "true" : "false"); cfgfile_write (f, "gfx_lores_mode=%s\n", loresmode[p->gfx_lores_mode]); @@ -642,11 +643,12 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value) || cfgfile_intval (option, value, "gfx_display", &p->gfx_display, 1) || cfgfile_intval (option, value, "gfx_framerate", &p->gfx_framerate, 1) - || cfgfile_intval (option, value, "gfx_width_windowed", &p->gfx_width_win, 1) - || cfgfile_intval (option, value, "gfx_height_windowed", &p->gfx_height_win, 1) - || cfgfile_intval (option, value, "gfx_width_fullscreen", &p->gfx_width_fs, 1) - || cfgfile_intval (option, value, "gfx_height_fullscreen", &p->gfx_height_fs, 1) + || cfgfile_intval (option, value, "gfx_width_windowed", &p->gfx_size_win.width, 1) + || cfgfile_intval (option, value, "gfx_height_windowed", &p->gfx_size_win.height, 1) + || cfgfile_intval (option, value, "gfx_width_fullscreen", &p->gfx_size_fs.width, 1) + || cfgfile_intval (option, value, "gfx_height_fullscreen", &p->gfx_size_fs.height, 1) || cfgfile_intval (option, value, "gfx_refreshrate", &p->gfx_refreshrate, 1) + || cfgfile_intval (option, value, "gfx_autoresolution", &p->gfx_autoresolution, 1) #ifdef GFXFILTER || cfgfile_intval (option, value, "gfx_filter_vert_zoom", &p->gfx_filter_vert_zoom, 1) @@ -695,7 +697,8 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value) if (cfgfile_strval (option, value, "sound_output", &p->produce_sound, soundmode1, 1) || cfgfile_strval (option, value, "sound_output", &p->produce_sound, soundmode2, 0) || cfgfile_strval (option, value, "sound_interpol", &p->sound_interpol, interpolmode, 0) - || cfgfile_strval (option, value, "sound_filter", &p->sound_filter, soundfiltermode, 0) + || cfgfile_strval (option, value, "sound_filter", &p->sound_filter, soundfiltermode1, 0) + || cfgfile_strval (option, value, "sound_filter_type", &p->sound_filter, soundfiltermode2, 0) || cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode1, 1) || cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode2, 1) || cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode3, 0) @@ -759,10 +762,29 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value) #endif if (strcmp (option, "gfx_width") == 0 || strcmp (option, "gfx_height") == 0) { - cfgfile_intval (option, value, "gfx_width", &p->gfx_width_win, 1); - cfgfile_intval (option, value, "gfx_height", &p->gfx_height_win, 1); - p->gfx_width_fs = p->gfx_width_win; - p->gfx_height_fs = p->gfx_height_win; + cfgfile_intval (option, value, "gfx_width", &p->gfx_size_win.width, 1); + cfgfile_intval (option, value, "gfx_height", &p->gfx_size_win.height, 1); + p->gfx_size_fs.width = p->gfx_size_win.width; + p->gfx_size_fs.height = p->gfx_size_win.height; + return 1; + } + + if (strcmp (option, "gfx_fullscreen_multi") == 0 || strcmp (option, "gfx_windowed_multi") == 0) { + char tmp[256], *tmpp, *tmpp2; + struct wh *wh = p->gfx_size_win_xtra; + if (strcmp (option, "gfx_fullscreen_multi") == 0) + wh = p->gfx_size_fs_xtra; + sprintf (tmp, ",%s,", value); + tmpp2 = tmp; + for (i = 0; i < 4; i++) { + tmpp = strchr (tmpp2, ','); + tmpp++; + wh[i].width = atol (tmpp); + while (*tmpp != ',' && *tmpp != 'x') + tmpp++; + wh[i].height = atol (tmpp + 1); + tmpp2 = tmpp; + } return 1; } @@ -1241,7 +1263,7 @@ int cfgfile_parse_option (struct uae_prefs *p, char *option, char *value, int ty return 0; } -static int separate_line (char *line, char *line1b, char *line2b) +static int cfgfile_separate_line (char *line, char *line1b, char *line2b) { char *line1, *line2; int i; @@ -1324,7 +1346,7 @@ void cfgfile_parse_line (struct uae_prefs *p, char *line, int type) { char line1b[CONFIG_BLEN], line2b[CONFIG_BLEN]; - if (!separate_line (line, line1b, line2b)) + if (!cfgfile_separate_line (line, line1b, line2b)) return; cfgfile_parse_separated_line (p, line1b, line2b, type); return; @@ -1404,9 +1426,9 @@ static int cfgfile_load_2 (struct uae_prefs *p, const char *filename, int real, while (len > 0 && strcspn (line + len - 1, "\t \r\n") == 0) line[--len] = '\0'; if (strlen (line) > 0) { - if (line[0] == '#') + if (line[0] == '#' || line[0] == ';') continue; - if (!separate_line (line, line1b, line2b)) + if (!cfgfile_separate_line (line, line1b, line2b)) continue; type1 = type2 = 0; if (cfgfile_yesno (line1b, line2b, "config_hardware", &type1) || @@ -1507,7 +1529,7 @@ int cfgfile_save (struct uae_prefs *p, const char *filename, int type) if (!type) type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST; - save_options (fh, p, type); + cfgfile_save_options (fh, p, type); zfile_fclose (fh); return 1; } @@ -1532,6 +1554,14 @@ int cfgfile_get_description (const char *filename, char *description, char *host return result; } +int cfgfile_configuration_change(int v) +{ + static int mode; + if (v >= 0) + mode = v; + return mode; +} + void cfgfile_show_usage (void) { int i; @@ -1558,8 +1588,8 @@ static void parse_gfx_specs (struct uae_prefs *p, char *spec) goto argh; *x1++ = 0; *x2++ = 0; - p->gfx_width_win = p->gfx_width_fs = atoi (x0); - p->gfx_height_win = p->gfx_height_fs = atoi (x1); + p->gfx_size_win.width = p->gfx_size_fs.width = atoi (x0); + p->gfx_size_win.height = p->gfx_size_fs.height = atoi (x1); p->gfx_lores = strchr (x2, 'l') != 0; p->gfx_xcenter = strchr (x2, 'x') != 0 ? 1 : strchr (x2, 'X') != 0 ? 2 : 0; p->gfx_ycenter = strchr (x2, 'y') != 0 ? 1 : strchr (x2, 'Y') != 0 ? 2 : 0; @@ -1907,7 +1937,7 @@ void cfgfile_addcfgparam (char *line) temp_lines = 0; return; } - if (!separate_line (line, line1b, line2b)) + if (!cfgfile_separate_line (line, line1b, line2b)) return; u = xcalloc (sizeof (struct strlist), 1); u->option = my_strdup(line1b); @@ -1927,13 +1957,13 @@ static int getconfigstoreline (struct zfile *z, char *option, char *value) return 0; tmp[idx++] = b; tmp[idx] = 0; - if (b == '\n') + if (b == '\n' || b == 0) break; } - return separate_line (tmp, option, value); + return cfgfile_separate_line (tmp, option, value); } -int cfgfile_handle_custom_event (char *custom, int mode) +static int cfgfile_handle_custom_event (char *custom, int mode) { char option[CONFIG_BLEN], value[CONFIG_BLEN]; char option2[CONFIG_BLEN], value2[CONFIG_BLEN]; @@ -1944,7 +1974,7 @@ int cfgfile_handle_custom_event (char *custom, int mode) if (!mode) { uae_u8 zero = 0; configstore = zfile_fopen_empty ("configstore", 50000); - save_options (configstore, &currprefs, 0); + cfgfile_save_options (configstore, &currprefs, 0); zfile_fwrite (&zero, 1, 1, configstore); } @@ -1965,7 +1995,7 @@ int cfgfile_handle_custom_event (char *custom, int mode) nextp++; } } - if (separate_line (p, option, value)) { + if (cfgfile_separate_line (p, option, value)) { cnt++; if (mode) { cfgfile_parse_option (&changed_prefs, option, value, 0); @@ -2043,7 +2073,8 @@ int cmdlineparser (char *s, char *outp[], int max) } #define UAELIB_MAX_PARSE 100 -uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u32 out, uae_u32 outsize) + +uae_u32 cfgfile_modify (uae_u32 index, char *parms, uae_u32 size, char *out, uae_u32 outsize) { char *p; char *argc[UAELIB_MAX_PARSE]; @@ -2106,8 +2137,8 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u if (p) { for (i = 0; i < outsize - 1; i++) { uae_u8 b = *++p; - put_byte (out + i, b); - put_byte (out + i + 1, 0); + out[i] = b; + out[i + 1] = 0; if (!b) break; } @@ -2133,8 +2164,8 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u err = 0; if (b == '\n') b = 0; - put_byte (out + i, b); - put_byte (out + i + 1, 0); + out[i] = b; + out[i + 1] = 0; if (!b) break; } @@ -2143,16 +2174,7 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u if (size > 10000) return 10; - p = xmalloc (size + 1); - if (!p) - return 10; - for (i = 0; i < size; i++) { - p[i] = get_byte (parms + i); - if (p[i] == 10 || p[i] == 13 || p[i] == 0) - break; - } - p[i] = 0; - argv = cmdlineparser (p, argc, UAELIB_MAX_PARSE); + argv = cmdlineparser (parms, argc, UAELIB_MAX_PARSE); if (argv <= 1 && index == 0xffffffff) { zfile_fclose (configstore); @@ -2166,7 +2188,7 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u goto end; } zfile_fseek (configstore, 0, SEEK_SET); - save_options (configstore, &currprefs, 0); + cfgfile_save_options (configstore, &currprefs, 0); zfile_fwrite (&zero, 1, 1, configstore); zfile_fseek (configstore, 0, SEEK_SET); err = 0xffffffff; @@ -2193,6 +2215,45 @@ end: return err; } +uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u32 out, uae_u32 outsize) +{ + char *p, *parms_p = NULL, *out_p = NULL; + int i, ret; + + put_byte (out, 0); + parms_p = xmalloc (size + 1); + if (!parms_p) { + ret = 10; + goto end; + } + out_p = xmalloc (outsize + 1); + if (!out_p) { + ret = 10; + goto end; + } + p = parms_p; + for (i = 0; i < size; i++) { + p[i] = get_byte (parms + i); + if (p[i] == 10 || p[i] == 13 || p[i] == 0) + break; + } + p[i] = 0; + out_p[0] = 0; + ret = cfgfile_modify (index, parms_p, size, out_p, outsize); + p = out_p; + for (i = 0; i < outsize - 1; i++) { + uae_u8 b = *p++; + put_byte (out + i, b); + put_byte (out + i + 1, 0); + if (!b) + break; + } +end: + xfree (out_p); + xfree (parms_p); + return ret; +} + uae_u32 cfgfile_uaelib (int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen) { char tmp[CONFIG_BLEN]; @@ -2291,6 +2352,7 @@ static void default_prefs_mini (struct uae_prefs *p, int type) void default_prefs (struct uae_prefs *p, int type) { + int i; int roms[] = { 6, 7, 8, 9, 10, 14, 5, 4, 3, 2, 1, -1 }; memset (p, 0, sizeof (*p)); @@ -2327,8 +2389,9 @@ void default_prefs (struct uae_prefs *p, int type) p->sound_bits = DEFAULT_SOUND_BITS; p->sound_freq = DEFAULT_SOUND_FREQ; p->sound_maxbsiz = DEFAULT_SOUND_MAXB; - p->sound_interpol = 0; - p->sound_filter = FILTER_SOUND_OFF; + p->sound_interpol = 1; + p->sound_filter = FILTER_SOUND_EMUL; + p->sound_filter_type = 0; p->comptrustbyte = 0; p->comptrustword = 0; @@ -2348,24 +2411,28 @@ void default_prefs (struct uae_prefs *p, int type) p->comp_midopt = 0; p->comp_lowopt = 0; p->override_dga_address = 0; - { - int i; - for (i = 0;i < 10; i++) - p->optcount[i] = -1; - p->optcount[0] = 4; /* How often a block has to be executed before it - * is translated */ - p->optcount[1] = 0; /* How often to use the naive translation */ - p->optcount[2] = 0; - p->optcount[3] = 0; - p->optcount[4] = 0; - p->optcount[5] = 0; - } + + for (i = 0;i < 10; i++) + p->optcount[i] = -1; + p->optcount[0] = 4; /* How often a block has to be executed before it is translated */ + p->optcount[1] = 0; /* How often to use the naive translation */ + p->optcount[2] = 0; + p->optcount[3] = 0; + p->optcount[4] = 0; + p->optcount[5] = 0; + p->gfx_framerate = 1; p->gfx_autoframerate = 50; - p->gfx_width_fs = 800; - p->gfx_height_fs = 600; - p->gfx_width_win = 720; - p->gfx_height_win = 568; + p->gfx_size_fs.width = 800; + p->gfx_size_fs.height = 600; + p->gfx_size_win.width = 720; + p->gfx_size_win.height = 568; + for (i = 0; i < 4; i++) { + p->gfx_size_fs_xtra[i].width = 0; + p->gfx_size_fs_xtra[i].height = 0; + p->gfx_size_win_xtra[i].width = 0; + p->gfx_size_win_xtra[i].height = 0; + } p->gfx_lores = 0; p->gfx_linedbl = 1; p->gfx_afullscreen = 0; @@ -2574,7 +2641,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 = FILTER_SOUND_ON_A500; + p->sound_filter = FILTER_SOUND_ON; if (config == 1) p->chipmem_size = 0x40000; set_68000_compa (p, compa); @@ -2781,9 +2848,8 @@ int build_in_prefs (struct uae_prefs *p, int model, int config, int compa, int r v = bip_cdtv (p, config, compa, romcheck); break; case 7: - v = bip_a500 (p, 3, compa, romcheck); + v = bip_a500 (p, 4, compa, romcheck); p->nr_floppies = 0; - p->chipset_mask = CSMASK_ECS_AGNUS; p->dfxtype[0] = -1; p->dfxtype[1] = -1; break; diff --git a/crc32.c b/crc32.c index 30025556..61c8878e 100755 --- a/crc32.c +++ b/crc32.c @@ -2,26 +2,41 @@ #include "sysconfig.h" #include "sysdeps.h" -static unsigned long crc_table[256]; +static unsigned long crc_table32[256]; +static unsigned short crc_table16[256]; static void make_crc_table() { unsigned long c; + unsigned short w; int n, k; - for (n = 0; n < 256; n++) - { + for (n = 0; n < 256; n++) { c = (unsigned long)n; - for (k = 0; k < 8; k++) c = (c >> 1) ^ (c & 1 ? 0xedb88320 : 0); - crc_table[n] = c; + w = n << 8; + for (k = 0; k < 8; k++) { + c = (c >> 1) ^ (c & 1 ? 0xedb88320 : 0); + w = (w << 1) ^ ((w & 0x8000) ? 0x1021 : 0); + } + crc_table32[n] = c; + crc_table16[n] = w; } } uae_u32 get_crc32 (uae_u8 *buf, int len) { uae_u32 crc; - if (!crc_table[1]) + if (!crc_table32[1]) make_crc_table(); crc = 0xffffffff; - while (len-- > 0) { - crc = crc_table[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8); - } + while (len-- > 0) + crc = crc_table32[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8); return crc ^ 0xffffffff; } +uae_u16 get_crc16( uae_u8 *buf, int len) +{ + uae_u16 crc; + if (!crc_table32[1]) + make_crc_table(); + crc = 0xffff; + while (len-- > 0) + crc = (crc << 8) ^ crc_table16[((crc >> 8) ^ (*buf++)) & 0xff]; + return crc; +} \ No newline at end of file diff --git a/custom.c b/custom.c index 4efe168e..9b3d92f9 100755 --- a/custom.c +++ b/custom.c @@ -155,6 +155,7 @@ static int fmode; unsigned int beamcon0, new_beamcon0; uae_u16 vtotal = MAXVPOS_PAL, htotal = MAXHPOS_PAL; static uae_u16 hsstop, hbstrt, hbstop, vsstop, vbstrt, vbstop, hsstrt, vsstrt, hcenter; +static int interlace_started; #define HSYNCTIME (maxhpos * CYCLE_UNIT); @@ -2056,7 +2057,7 @@ static void finish_decisions (void) dip = curr_drawinfo + next_lineno; dip_old = prev_drawinfo + next_lineno; dp = line_decisions + next_lineno; - changed = thisline_changed; + changed = thisline_changed + interlace_started; if (thisline_decision.plfleft != -1) record_diw_line (thisline_decision.plfleft, diwfirstword, diwlastword); @@ -2770,6 +2771,9 @@ static void BPLCON0 (int hpos, uae_u16 v) hpos_previous = hpos; } + if ((v & 4) && !interlace_seen) + interlace_started = 2; + ddf_change = vpos; decide_line (hpos); decide_fetch (hpos); @@ -3978,6 +3982,8 @@ static void init_hardware_frame (void) diwstate = DIW_waiting_start; hdiwstate = DIW_waiting_start; ddfstate = DIW_waiting_start; + if (interlace_started > 0) + interlace_started--; } void init_hardware_for_drawing_frame (void) @@ -4275,7 +4281,7 @@ static void hsync_handler (void) if (currprefs.cpu_cycle_exact || currprefs.blitter_cycle_exact) { decide_blitter (hpos); memset (cycle_line, 0, sizeof cycle_line); - cycle_line[1] = CYCLE_REFRESH; + cycle_line[9] = CYCLE_REFRESH; cycle_line[3] = CYCLE_REFRESH; cycle_line[5] = CYCLE_REFRESH; cycle_line[7] = CYCLE_REFRESH; @@ -4331,7 +4337,7 @@ static void hsync_handler (void) } #endif - if ((bplcon0 & 4) && currprefs.gfx_linedbl) + if (bplcon0 & 4) notice_interlace_seen (); if (!nodraw ()) { diff --git a/debug.c b/debug.c index b2da1987..10d7297a 100755 --- a/debug.c +++ b/debug.c @@ -1683,7 +1683,7 @@ void debug (void) if ((pc < 0xe00000 || pc >= 0x1000000) && opcode != 0x4ef9) bp = 1; } else if (skipaddr_start == 0xffffffff && skipaddr_doskip > 0) { - bp = 1; + bp = 1; } else if (skipaddr_end != 0xffffffff) { if (pc >= skipaddr_start && pc < skipaddr_end) bp = 1; diff --git a/disk.c b/disk.c index 7363a5ed..cc2ebef8 100755 --- a/disk.c +++ b/disk.c @@ -98,7 +98,7 @@ static uae_u16 word, dsksync; static int disk_hpos; static int disk_jitter; -typedef enum { TRACK_AMIGADOS, TRACK_RAW, TRACK_RAW1 } image_tracktype; +typedef enum { TRACK_AMIGADOS, TRACK_RAW, TRACK_RAW1, TRACK_PCDOS } image_tracktype; typedef struct { uae_u16 len; uae_u32 offs; @@ -124,7 +124,7 @@ typedef struct { #define DRIVE_ID_35HD 0xAAAAAAAA #define DRIVE_ID_525SD 0x55555555 /* 40 track 5.25 drive , kickstart does not recognize this */ -typedef enum { ADF_NORMAL, ADF_EXT1, ADF_EXT2, ADF_FDI, ADF_IPF, ADF_CATWEASEL } drive_filetype; +typedef enum { ADF_NORMAL, ADF_EXT1, ADF_EXT2, ADF_FDI, ADF_IPF, ADF_CATWEASEL, ADF_PCDOS } drive_filetype; typedef struct { struct zfile *diskfile; struct zfile *writediskfile; @@ -808,7 +808,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char { unsigned char buffer[2 + 2 + 4 + 4]; trackid *tid; - int num_tracks; + int num_tracks, size; drive_image_free (drv); drv->diskfile = DISK_validate_filename (fname, 1, &drv->wrprot, &drv->crc32); @@ -828,6 +828,14 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char track_reset (drv); return 0; } + + if (input_recording > 0) { + inprec_rstart (INPREC_DISKINSERT); + inprec_ru8 (dnum); + inprec_rstr (fname); + inprec_rend (); + } + strncpy (currprefs.df[dnum], fname, 255); currprefs.df[dnum][255] = 0; strncpy (changed_prefs.df[dnum], fname, 255); @@ -836,8 +844,14 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char gui_filename (dnum, fname); memset (buffer, 0, sizeof (buffer)); - if (drv->diskfile) + size = 0; + if (drv->diskfile) { zfile_fread (buffer, sizeof (char), 8, drv->diskfile); + zfile_fseek (drv->diskfile, 0, SEEK_END); + size = zfile_ftell (drv->diskfile); + zfile_fseek (drv->diskfile, 0, SEEK_SET); + } + if (drv->catweasel) { @@ -918,21 +932,32 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char } drv->useturbo = 1; - } else { + } else if (size == 720 * 1024 || size == 1440 * 1024) { + /* PC formatted image */ int i; - drv->filetype = ADF_NORMAL; + drv->filetype = ADF_PCDOS; + drv->num_tracks = 160; + drv->ddhd = size == 1440 * 1024 ? 2 : 1; + drv->num_secs = drv->ddhd == 2 ? 18 : 9; + for (i = 0; i < drv->num_tracks; i++) { + tid = &drv->trackdata[i]; + tid->type = TRACK_PCDOS; + tid->len = 512 * drv->num_secs; + tid->bitlen = 0; + tid->offs = i * 512 * drv->num_secs; + } - zfile_fseek (drv->diskfile, 0, SEEK_END); - i = zfile_ftell (drv->diskfile); - zfile_fseek (drv->diskfile, 0, SEEK_SET); + } else { + int i; + drv->filetype = ADF_NORMAL; /* High-density disk? */ - if (i >= 160 * 22 * 512) { - drv->num_tracks = i / (512 * (drv->num_secs = 22)); + if (size >= 160 * 22 * 512) { + drv->num_tracks = size / (512 * (drv->num_secs = 22)); drv->ddhd = 2; } else - drv->num_tracks = i / (512 * (drv->num_secs = 11)); + drv->num_tracks = size / (512 * (drv->num_secs = 11)); if (drv->num_tracks > MAX_TRACKS) write_log ("Your diskfile is too big!\n"); @@ -1107,18 +1132,201 @@ static void read_floppy_data (struct zfile *diskfile, trackid *tid, int offset, static void mfmcode (uae_u16 * mfm, int words) { uae_u32 lastword = 0; - while (words--) { uae_u32 v = *mfm; uae_u32 lv = (lastword << 16) | v; uae_u32 nlv = 0x55555555 & ~lv; uae_u32 mfmbits = (nlv << 1) & (nlv >> 1); - *mfm++ = v | mfmbits; lastword = v; } } +static uae_u8 mfmencodetable[16] = { + 0x2a, 0x29, 0x24, 0x25, 0x12, 0x11, 0x14, 0x15, + 0x4a, 0x49, 0x44, 0x45, 0x52, 0x51, 0x54, 0x55 +}; + +static uae_u16 *mfmcoder(uae_u8 *s, uae_u16 *mfm, int len) +{ + static int prev; + + if (!s) { + prev = len; + return NULL; + } + while (len-- > 0) { + uae_u16 db; + uae_u8 b1, b2; + uae_u8 b = *s++; + b1 = b; + b2 = b >> 4; + b1 &= 15; + db = (mfmencodetable[b2] << 8) | mfmencodetable[b1]; + db = db | ((db & (256 | 64)) ? 0 : 128); + if (!prev && !(db & 0x4000)) + db |= 0x8000; + prev = db & 1; + *mfm++ = db; + } + return mfm; +} + + +static void decode_pcdos (drive *drv) +{ + int i; + int tr = drv->cyl * 2 + side; + uae_u16 *dstmfmbuf, *mfm2; + uae_u8 secbuf[700]; + uae_u16 crc16; + trackid *ti = drv->trackdata + tr; + + mfmcoder (NULL, NULL, 0); + mfm2 = drv->bigmfmbuf; + memset (secbuf, 0x4e, 80); // 94 + memset (secbuf + 80, 0x00, 12); // 12 + secbuf[92] = 0xc2; + secbuf[93] = 0xc2; + secbuf[94] = 0xc2; + secbuf[95] = 0xfc; + memset (secbuf + 96, 0x4e, 50); // 50 + dstmfmbuf = mfmcoder(secbuf, mfm2, 146); + mfm2[92] = 0x5224; + mfm2[93] = 0x5224; + mfm2[94] = 0x5224; + for (i = 0; i < drv->num_secs; i++) { + mfm2 = dstmfmbuf; + memset (secbuf, 0x00, 12); + secbuf[12] = 0xa1; + secbuf[13] = 0xa1; + secbuf[14] = 0xa1; + secbuf[15] = 0xfe; + secbuf[16] = drv->cyl; + secbuf[17] = side; + secbuf[18] = 1 + i; + secbuf[19] = 2; // 128 << 2 = 512 + crc16 = get_crc16(secbuf + 12, 3 + 1 + 4); + secbuf[20] = crc16 >> 8; + secbuf[21] = crc16 & 0xff; + memset(secbuf + 22, 0x4e, 22); + memset(secbuf + 44, 0x00, 12); + secbuf[56] = 0xa1; + secbuf[57] = 0xa1; + secbuf[58] = 0xa1; + secbuf[59] = 0xfb; + read_floppy_data (drv->diskfile, ti, i * 512, &secbuf[60], 512); + crc16 = get_crc16(secbuf + 56, 3 + 1 + 512); + secbuf[60 + 512] = crc16 >> 8; + secbuf[61 + 512] = crc16 & 0xff; + memset(secbuf + 512 + 62, 0x4e, 80 / drv->ddhd); + dstmfmbuf = mfmcoder(secbuf, mfm2, 60 + 512 + 2 + 80 / drv->ddhd); + mfm2[12] = 0x4489; + mfm2[13] = 0x4489; + mfm2[14] = 0x4489; + mfm2[56] = 0x4489; + mfm2[57] = 0x4489; + mfm2[58] = 0x4489; + } + drv->skipoffset = 0; + drv->tracklen = (dstmfmbuf - drv->bigmfmbuf) * 16; + if (disk_debug_logging > 0) + write_log ("pcdos read track %d\n", tr); +} + +static void decode_amigados (drive *drv) +{ + /* Normal AmigaDOS format track */ + int tr = drv->cyl * 2 + side; + int sec; + int dstmfmoffset = 0; + uae_u16 *dstmfmbuf = drv->bigmfmbuf; + int len = drv->num_secs * 544 + FLOPPY_GAP_LEN; + + trackid *ti = drv->trackdata + tr; + memset (dstmfmbuf, 0xaa, len * 2); + dstmfmoffset += FLOPPY_GAP_LEN; + drv->skipoffset = (FLOPPY_GAP_LEN * 8) / 3 * 2; + drv->tracklen = len * 2 * 8; + + for (sec = 0; sec < drv->num_secs; sec++) { + uae_u8 secbuf[544]; + uae_u16 mfmbuf[544]; + int i; + uae_u32 deven, dodd; + uae_u32 hck = 0, dck = 0; + + secbuf[0] = secbuf[1] = 0x00; + secbuf[2] = secbuf[3] = 0xa1; + secbuf[4] = 0xff; + secbuf[5] = tr; + secbuf[6] = sec; + secbuf[7] = drv->num_secs - sec; + + for (i = 8; i < 24; i++) + secbuf[i] = 0; + + read_floppy_data (drv->diskfile, ti, sec * 512, &secbuf[32], 512); + + mfmbuf[0] = mfmbuf[1] = 0xaaaa; + mfmbuf[2] = mfmbuf[3] = 0x4489; + + deven = ((secbuf[4] << 24) | (secbuf[5] << 16) + | (secbuf[6] << 8) | (secbuf[7])); + dodd = deven >> 1; + deven &= 0x55555555; + dodd &= 0x55555555; + + mfmbuf[4] = dodd >> 16; + mfmbuf[5] = dodd; + mfmbuf[6] = deven >> 16; + mfmbuf[7] = deven; + + for (i = 8; i < 48; i++) + mfmbuf[i] = 0xaaaa; + for (i = 0; i < 512; i += 4) { + deven = ((secbuf[i + 32] << 24) | (secbuf[i + 33] << 16) + | (secbuf[i + 34] << 8) | (secbuf[i + 35])); + dodd = deven >> 1; + deven &= 0x55555555; + dodd &= 0x55555555; + mfmbuf[(i >> 1) + 32] = dodd >> 16; + mfmbuf[(i >> 1) + 33] = dodd; + mfmbuf[(i >> 1) + 256 + 32] = deven >> 16; + mfmbuf[(i >> 1) + 256 + 33] = deven; + } + + for (i = 4; i < 24; i += 2) + hck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1]; + + deven = dodd = hck; + dodd >>= 1; + mfmbuf[24] = dodd >> 16; + mfmbuf[25] = dodd; + mfmbuf[26] = deven >> 16; + mfmbuf[27] = deven; + + for (i = 32; i < 544; i += 2) + dck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1]; + + deven = dodd = dck; + dodd >>= 1; + mfmbuf[28] = dodd >> 16; + mfmbuf[29] = dodd; + mfmbuf[30] = deven >> 16; + mfmbuf[31] = deven; + mfmcode (mfmbuf + 4, 544 - 4); + + for (i = 0; i < 544; i++) { + dstmfmbuf[dstmfmoffset % len] = mfmbuf[i]; + dstmfmoffset++; + } + } + + if (disk_debug_logging > 0) + write_log ("amigados read track %d\n", tr); +} + static void drive_fill_bigbuf (drive * drv, int force) { int tr = drv->cyl * 2 + side; @@ -1177,96 +1385,15 @@ static void drive_fill_bigbuf (drive * drv, int force) fdi2raw_loadtrack (drv->fdi, drv->bigmfmbuf, drv->tracktiming, tr, &drv->tracklen, &drv->indexoffset, &drv->multi_revolution, 1); #endif - } else if (ti->type == TRACK_AMIGADOS) { - - /* Normal AmigaDOS format track */ - int sec; - int dstmfmoffset = 0; - uae_u16 *dstmfmbuf = drv->bigmfmbuf; - int len = drv->num_secs * 544 + FLOPPY_GAP_LEN; - - memset (dstmfmbuf, 0xaa, len * 2); - dstmfmoffset += FLOPPY_GAP_LEN; - drv->skipoffset = (FLOPPY_GAP_LEN * 8) / 3 * 2; - drv->tracklen = len * 2 * 8; - - for (sec = 0; sec < drv->num_secs; sec++) { - uae_u8 secbuf[544]; - uae_u16 mfmbuf[544]; - int i; - uae_u32 deven, dodd; - uae_u32 hck = 0, dck = 0; - - secbuf[0] = secbuf[1] = 0x00; - secbuf[2] = secbuf[3] = 0xa1; - secbuf[4] = 0xff; - secbuf[5] = tr; - secbuf[6] = sec; - secbuf[7] = drv->num_secs - sec; + } else if (ti->type == TRACK_PCDOS) { - for (i = 8; i < 24; i++) - secbuf[i] = 0; + decode_pcdos(drv); - read_floppy_data (drv->diskfile, ti, sec * 512, &secbuf[32], 512); - mfmbuf[0] = mfmbuf[1] = 0xaaaa; - mfmbuf[2] = mfmbuf[3] = 0x4489; - - deven = ((secbuf[4] << 24) | (secbuf[5] << 16) - | (secbuf[6] << 8) | (secbuf[7])); - dodd = deven >> 1; - deven &= 0x55555555; - dodd &= 0x55555555; - - mfmbuf[4] = dodd >> 16; - mfmbuf[5] = dodd; - mfmbuf[6] = deven >> 16; - mfmbuf[7] = deven; - - for (i = 8; i < 48; i++) - mfmbuf[i] = 0xaaaa; - for (i = 0; i < 512; i += 4) { - deven = ((secbuf[i + 32] << 24) | (secbuf[i + 33] << 16) - | (secbuf[i + 34] << 8) | (secbuf[i + 35])); - dodd = deven >> 1; - deven &= 0x55555555; - dodd &= 0x55555555; - mfmbuf[(i >> 1) + 32] = dodd >> 16; - mfmbuf[(i >> 1) + 33] = dodd; - mfmbuf[(i >> 1) + 256 + 32] = deven >> 16; - mfmbuf[(i >> 1) + 256 + 33] = deven; - } - - for (i = 4; i < 24; i += 2) - hck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1]; - - deven = dodd = hck; - dodd >>= 1; - mfmbuf[24] = dodd >> 16; - mfmbuf[25] = dodd; - mfmbuf[26] = deven >> 16; - mfmbuf[27] = deven; - - for (i = 32; i < 544; i += 2) - dck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1]; - - deven = dodd = dck; - dodd >>= 1; - mfmbuf[28] = dodd >> 16; - mfmbuf[29] = dodd; - mfmbuf[30] = deven >> 16; - mfmbuf[31] = deven; - mfmcode (mfmbuf + 4, 544 - 4); - - for (i = 0; i < 544; i++) { - dstmfmbuf[dstmfmoffset % len] = mfmbuf[i]; - dstmfmoffset++; - } + } else if (ti->type == TRACK_AMIGADOS) { - } + decode_amigados(drv); - if (disk_debug_logging > 0) - write_log ("amigados read track %d\n", tr); } else { int i; int base_offset = ti->type == TRACK_RAW ? 0 : 1; @@ -1432,7 +1559,106 @@ static int decode_buffer (uae_u16 *mbuf, int cyl, int drvsec, int ddhd, int file return 0; } -static int drive_write_adf_amigados (drive * drv) +static uae_u8 mfmdecode(uae_u16 **mfmp, int shift) +{ + uae_u16 mfm = getmfmword (*mfmp, shift); + uae_u8 out = 0; + int i; + + (*mfmp)++; + mfm &= 0x5555; + for (i = 0; i < 8; i++) { + out >>= 1; + if (mfm & 1) + out |= 0x80; + mfm >>= 2; + } + return out; +} + +static int drive_write_pcdos (drive *drv) +{ + int i; + int drvsec = drv->num_secs; + int fwlen = FLOPPY_WRITE_LEN * drv->ddhd; + int length = 2 * fwlen; + uae_u16 *mbuf = drv->bigmfmbuf; + uae_u16 *mend = mbuf + length; + int secwritten = 0, shift = 0, sector = -1; + char sectable[18]; + uae_u8 secbuf[3 + 1 + 512]; + uae_u8 mark; + uae_u16 crc; + + memset (sectable, 0, sizeof (sectable)); + memcpy (mbuf + fwlen, mbuf, fwlen * sizeof (uae_u16)); + mend -= 518; + secbuf[0] = secbuf[1] = secbuf[2] = 0xa1; + secbuf[3] = 0xfb; + + while (secwritten < drvsec) { + while (getmfmword (mbuf, shift) != 0x4489) { + if (mbuf >= mend) + return 1; + shift++; + if (shift == 16) { + shift = 0; + mbuf++; + } + } + while (getmfmword (mbuf, shift) == 0x4489) { + if (mbuf >= mend) + return 1; + mbuf++; + } + mark = mfmdecode(&mbuf, shift); + if (mark == 0xfe) { + uae_u8 tmp[8]; + uae_u8 cyl, head, size; + + cyl = mfmdecode(&mbuf, shift); + head = mfmdecode(&mbuf, shift); + sector = mfmdecode(&mbuf, shift); + size = mfmdecode(&mbuf, shift); + crc = (mfmdecode(&mbuf, shift) << 8) | mfmdecode(&mbuf, shift); + + tmp[0] = 0xa1; tmp[1] = 0xa1; tmp[2] = 0xa1; tmp[3] = mark; + tmp[4] = cyl; tmp[5] = head; tmp[6] = sector; tmp[7] = size; + if (get_crc16(tmp, 8) != crc || cyl != drv->cyl || head != side || size != 2 || sector < 1 || sector > drv->num_secs) { + write_log ("PCDOS: track %d, corrupted sector header\n", drv->cyl * 2 + side); + return 1; + } + sector--; + continue; + } + if (mark != 0xfb) { + write_log ("PCDOS: track %d: unknown address mark %02.2X\n", drv->cyl * 2 + side, mark); + continue; + } + if (sector < 0) + continue; + for (i = 0; i < 512; i++) + secbuf[i + 4] = mfmdecode(&mbuf, shift); + crc = (mfmdecode(&mbuf, shift) << 8) | mfmdecode(&mbuf, shift); + if (get_crc16(secbuf, 3 + 1 + 512) != crc) { + write_log ("PCDOS: track %d, sector %d data checksum error\n", + drv->cyl * 2 + side, sector + 1); + continue; + } + sectable[sector] = 1; + secwritten++; + zfile_fseek (drv->diskfile, drv->trackdata[drv->cyl * 2 + side].offs + sector * 512, SEEK_SET); + zfile_fwrite (secbuf + 4, sizeof (uae_u8), 512, drv->diskfile); + write_log ("PCDOS: track %d sector %d written\n", drv->cyl * 2 + side, sector + 1); + sector = -1; + } + if (secwritten != drv->num_secs) + write_log ("PCDOS: track %d, %d corrupted sectors ignored\n", + drv->cyl * 2 + side, drv->num_secs - secwritten); + return 0; +} + +static int drive_write_adf_amigados (drive *drv) { int drvsec, i; @@ -1499,12 +1725,17 @@ static void drive_write_data (drive * drv) case ADF_EXT2: ret = drive_write_adf_amigados (drv); if (ret) { - write_log("not an amigados track (error %d), writing as raw track\n",ret); + write_log("not an amigados track %d (error %d), writing as raw track\n", drv->cyl * 2 + side, ret); drive_write_ext2 (drv->bigmfmbuf, drv->diskfile, &drv->trackdata[drv->cyl * 2 + side], drv->tracklen); } return; case ADF_IPF: break; + case ADF_PCDOS: + ret = drive_write_pcdos (drv); + if (ret) + write_log("not a PC formatted track %d (error %d)\n", drv->cyl * 2 + side, ret); + break; } drv->tracktiming[0] = 0; } @@ -1526,7 +1757,7 @@ static void drive_eject (drive * drv) if (disk_debug_logging > 0) write_log ("eject drive %d\n", drv - &floppy[0]); if (input_recording > 0) { - inprec_rstart (INPREC_DISKREMOVE, 1); + inprec_rstart (INPREC_DISKREMOVE); inprec_ru8 (drv - floppy); inprec_rend (); } @@ -1708,24 +1939,24 @@ void disk_eject (int num) update_drive_gui (num); } -void DISK_history_add (const char *name, int idx) +int DISK_history_add (const char *name, int idx) { int i; if (name[0] == 0) - return; + return 0; if (!zfile_exists (name)) - return; + return 0; if (idx >= 0) { if (idx >= MAX_PREVIOUS_FLOPPIES) - return; + return 0; dfxhistory[idx][0] = 0; for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++) { if (!strcmp (dfxhistory[i], name)) - return; + return 0; } strcpy (dfxhistory[idx], name); - return; + return 1; } for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++) { if (!strcmp (dfxhistory[i], name)) { @@ -1740,6 +1971,7 @@ void DISK_history_add (const char *name, int idx) for (i = MAX_PREVIOUS_FLOPPIES - 2; i >= 0; i--) strcpy (dfxhistory[i + 1], dfxhistory[i]); strcpy (dfxhistory[0], name); + return 1; } char *DISK_history_get (int idx) @@ -2127,7 +2359,11 @@ static void disk_doupdate_write (drive * drv, int floppybits) dsklength--; if (dsklength == 0) { disk_dmafinished (); - drive_write_data (drv); + for (dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) { + drive *drv2 = &floppy[dr]; + if (drives[dr]) + drive_write_data (drv2); + } } } } diff --git a/drawing.c b/drawing.c index dd7a6554..fcb08583 100755 --- a/drawing.c +++ b/drawing.c @@ -57,9 +57,9 @@ int lores_factor, lores_shift; coordinates have a lower resolution (i.e. we're shrinking the image). */ static int res_shift; -static int interlace_seen = 0; +int interlace_seen = 0; #define AUTO_LORES_FRAMES 10 -static int can_use_lores = 0; +static int can_use_lores = 0, frame_res, frame_res_lace; /* Lookup tables for dual playfields. The dblpf_*1 versions are for the case that playfield 1 has the priority, dbplpf_*2 are used if playfield 2 has @@ -155,7 +155,7 @@ typedef void (*line_draw_func)(int, int); #define LINE_DONE_AS_PREVIOUS 8 #define LINE_REMEMBERED_AS_PREVIOUS 9 -static char linestate[(MAXVPOS + 1)*2 + 1]; +static char linestate[(MAXVPOS + 1) * 2 + 1]; uae_u8 line_data[(MAXVPOS + 1) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2]; @@ -1395,6 +1395,8 @@ static void pfield_expand_dp_bplcon (void) bplplanecnt = dp_for_drawing->nr_planes; bplham = dp_for_drawing->ham_seen; + if (bplres > 0) + frame_res = 1; if (bplres > 0) can_use_lores = 0; if (currprefs.chipset_mask & CSMASK_AGA) { @@ -1556,6 +1558,15 @@ STATIC_INLINE void pfield_draw_line (int lineno, int gfx_ypos, int follow_ypos) return; case LINE_AS_PREVIOUS: + if (linestate[lineno - 1] == LINE_DONE) + /* this was missing. we must not update this line if previous + * line was LINE_DONE. Previously this line would have been + * drawn as a border (plfleft was -1..) which resulted in + * "scanline"-looking display in parts of interlaced screens. + * This was really old bug.. + * (example: Pinball Illusions' score panel in hires) + */ + return; dp_for_drawing--; dip_for_drawing--; if (dp_for_drawing->plfleft == -1) @@ -1782,9 +1793,41 @@ static void lores_reset (void) lores_shift = currprefs.gfx_lores ? 0 : 1; } +#define FRAMES_UNTIL_RES_SWITCH 5 +static int frame_res_cnt; static void init_drawing_frame (void) { int i, maxline; + static int frame_res_old; + + if (FRAMES_UNTIL_RES_SWITCH > 0 && frame_res_old == frame_res * 2 + frame_res_lace) { + frame_res_cnt--; + if (frame_res_cnt == 0) { + int m = frame_res * 2 + frame_res_lace; + struct wh *dst = currprefs.gfx_afullscreen ? &changed_prefs.gfx_size_fs : &changed_prefs.gfx_size_win; + while (m < 4) { + struct wh *src = currprefs.gfx_afullscreen ? &currprefs.gfx_size_fs_xtra[m] : &currprefs.gfx_size_win_xtra[m]; + if ((src->width > 0 && src->height > 0) || (currprefs.gfx_autoresolution && currprefs.gfx_filter > 0)) { + changed_prefs.gfx_lores = (m & 2) == 0 ? 1 : 0; + changed_prefs.gfx_linedbl = (m & 1) == 0 ? 0 : 1; + if (currprefs.gfx_autoresolution) { + changed_prefs.gfx_filter_horiz_zoom_mult = 1000 / (changed_prefs.gfx_lores + 1); + changed_prefs.gfx_filter_vert_zoom_mult = (changed_prefs.gfx_linedbl + 1) * 500; + } else { + *dst = *src; + } + break; + } + m++; + } + frame_res_cnt = FRAMES_UNTIL_RES_SWITCH; + } + } else { + frame_res_old = frame_res * 2 + frame_res_lace; + frame_res_cnt = FRAMES_UNTIL_RES_SWITCH; + } + frame_res = 0; + frame_res_lace = 0; if (can_use_lores > AUTO_LORES_FRAMES && 0) { lores_factor = 1; @@ -2181,6 +2224,7 @@ void vsync_handle_redraw (int long_frame, int lof_changed) void hsync_record_line_state (int lineno, enum nln_how how, int changed) { char *state; + if (framecnt != 0) return; @@ -2219,6 +2263,7 @@ void hsync_record_line_state (int lineno, enum nln_how how, int changed) void notice_interlace_seen (void) { interlace_seen = 1; + frame_res_lace = 1; } void reset_drawing (void) @@ -2245,6 +2290,7 @@ void reset_drawing (void) flush_clear_screen (); notice_screen_contents_lost (); + frame_res_cnt = FRAMES_UNTIL_RES_SWITCH; } void drawing_init (void) diff --git a/driveclick.c b/driveclick.c index 1111e1a9..a6f89adc 100755 --- a/driveclick.c +++ b/driveclick.c @@ -350,8 +350,6 @@ void driveclick_motor (int drive, int running) { if (!click_initialized) return; - if (!wave_initialized) - return; if (!currprefs.dfxclick[drive]) return; if (!wave_initialized) { @@ -392,6 +390,7 @@ void driveclick_check_prefs (void) { int i; + driveclick_fdrawcmd_vsync(); if (currprefs.dfxclickvolume != changed_prefs.dfxclickvolume || currprefs.dfxclick[0] != changed_prefs.dfxclick[0] || currprefs.dfxclick[1] != changed_prefs.dfxclick[1] || diff --git a/expansion.c b/expansion.c index a541f589..569270e6 100755 --- a/expansion.c +++ b/expansion.c @@ -24,7 +24,6 @@ #include "zfile.h" #include "catweasel.h" #include "cdtv.h" -#include "arcadia.h" #define MAX_EXPANSION_BOARDS 8 @@ -763,118 +762,6 @@ static void expamem_init_fastcard (void) /* ********************************************************** */ -#ifdef ARCADIA - -static uae_u8 *arcadiaboot; -static uae_u32 arcadia_start; - -static uae_u32 REGPARAM2 arcadia_lget (uaecptr addr) -{ - uae_u8 *m; -#ifdef JIT - special_mem |= S_READ; -#endif - addr -= arcadia_start & 65535; - addr &= 65535; - m = arcadiaboot + addr; - return do_get_mem_long ((uae_u32 *)m); -} - -static uae_u32 REGPARAM2 arcadia_wget (uaecptr addr) -{ - uae_u8 *m; -#ifdef JIT - special_mem |= S_READ; -#endif - addr -= arcadia_start & 65535; - addr &= 65535; - m = arcadiaboot + addr; - return do_get_mem_word ((uae_u16 *)m); -} - -static uae_u32 REGPARAM2 arcadia_bget (uaecptr addr) -{ -#ifdef JIT - special_mem |= S_READ; -#endif - addr -= arcadia_start & 65535; - addr &= 65535; - return arcadiaboot[addr]; -} - -static void REGPARAM2 arcadia_lput (uaecptr addr, uae_u32 l) -{ -#ifdef JIT - special_mem |= S_WRITE; -#endif - write_log ("arcadia_lput called PC=%p\n", m68k_getpc()); -} - -static void REGPARAM2 arcadia_wput (uaecptr addr, uae_u32 w) -{ -#ifdef JIT - special_mem |= S_WRITE; -#endif - write_log ("arcadia_wput called PC=%p\n", m68k_getpc()); -} - -static void REGPARAM2 arcadia_bput (uaecptr addr, uae_u32 b) -{ -#ifdef JIT - special_mem |= S_WRITE; -#endif -} - -static addrbank arcadia_bank = { - arcadia_lget, arcadia_wget, arcadia_bget, - arcadia_lput, arcadia_wput, arcadia_bput, - default_xlate, default_check, NULL -}; - -static void expamem_map_arcadia (void) -{ - arcadia_start = ((expamem_hi | (expamem_lo >> 4)) << 16); - write_log ("Arcadia initialized @%08.8X\n", arcadia_start); - map_banks (&arcadia_bank, arcadia_start >> 16, 1, 0); -} - -static void expamem_init_arcadia (void) -{ - expamem_init_clear(); - expamem_write (0x00, zorroII | Z2_MEM_2MB | rom_card); - - expamem_write (0x04, 1); - expamem_write (0x08, no_shutup); - - expamem_write (0x10, 0x07); - expamem_write (0x14, 0x70); - - expamem_write (0x18, 0x00); /* ser.no. Byte 0 */ - expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */ - expamem_write (0x20, 0x00); /* ser.no. Byte 2 */ - expamem_write (0x24, 0x01); /* ser.no. Byte 3 */ - - expamem_write (0x28, 0x10); /* Rom-Offset hi */ - expamem_write (0x2c, 0x00); /* ROM-Offset lo */ - - expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/ - - expamem[0x1000] = 0x90; - expamem[0x1001] = 0x00; - expamem[0x1002] = 0x01; - expamem[0x1003] = 0x06; - expamem[0x1004] = 0x01; - expamem[0x1005] = 0x00; - - /* Call DiagEntry */ - do_put_mem_word ((uae_u16 *)(expamem + 0x1100), 0x4EF9); /* JMP */ - do_put_mem_long ((uae_u32 *)(expamem + 0x1102), arcadia_rom->boot); - - memcpy (arcadiaboot, expamem, 0x2000); -} - -#endif - /* * Filesystem device */ @@ -1160,14 +1047,6 @@ void expamem_reset (void) if (nr_units (currprefs.mountinfo) == 0) do_mount = 0; -#ifdef ARCADIA - if (arcadia_rom) { - arcadiaboot = mapped_malloc (0x10000, "arcadia"); - arcadia_bank.baseaddr = arcadiaboot; - card_init[cardno] = expamem_init_arcadia; - card_map[cardno++] = expamem_map_arcadia; - } -#endif if (fastmemory != NULL) { card_init[cardno] = expamem_init_fastcard; card_map[cardno++] = expamem_map_fastcard; @@ -1198,6 +1077,7 @@ void expamem_reset (void) } (*card_init[0]) (); + } void expansion_init (void) diff --git a/filesys.c b/filesys.c index e0e57f83..8fe2be0c 100755 --- a/filesys.c +++ b/filesys.c @@ -207,6 +207,14 @@ char *get_filesys_unit (struct uaedev_mount_info *mountinfo, int nr, return 0; } +static void stripsemicolon(char *s) +{ + if (!s) + return; + while(strlen(s) > 0 && s[strlen(s) - 1] == ':') + s[strlen(s) - 1] = 0; +} + static char *set_filesys_unit_1 (struct uaedev_mount_info *mountinfo, int nr, char *devname, char *volname, char *rootdir, int readonly, int secspertrack, int surfaces, int reserved, @@ -241,6 +249,7 @@ static char *set_filesys_unit_1 (struct uaedev_mount_info *mountinfo, int nr, if (volname != 0) { int flags; ui->volname = my_strdup (volname); + stripsemicolon(ui->volname); flags = my_getvolumeinfo (rootdir); if (flags < 0) { sprintf (errmsg, "directory '%s' not found", rootdir); @@ -279,6 +288,7 @@ static char *set_filesys_unit_1 (struct uaedev_mount_info *mountinfo, int nr, ui->reset_state = FS_STARTUP; ui->rootdir = my_strdup (rootdir); ui->devname = my_strdup (devname); + stripsemicolon(ui->devname); if (filesysdir) ui->filesysdir = my_strdup (filesysdir); ui->readonly = readonly; @@ -685,6 +695,15 @@ find_unit (uaecptr port) return u; } +static int fsdb_cando (Unit *unit) +{ + if (currprefs.filesys_custom_uaefsdb && (unit->volflags & MYVOLUMEINFO_STREAMS)) + return 1; + if (!currprefs.filesys_no_uaefsdb) + return 1; + return 0; +} + static void prepare_for_open (char *name) { #if 0 @@ -1977,6 +1996,7 @@ get_fileinfo (Unit *unit, dpacket packet, uaecptr info, a_inode *aino) struct stat statbuf; long days, mins, ticks; int i, n, entrytype; + int fsdb_can = fsdb_cando (unit); char *x; /* No error checks - this had better work. */ @@ -2006,7 +2026,7 @@ get_fileinfo (Unit *unit, dpacket packet, uaecptr info, a_inode *aino) while (i < 108) put_byte (info + i, 0), i++; - put_long (info + 116, aino->amigaos_mode); + put_long (info + 116, fsdb_can ? aino->amigaos_mode : fsdb_mode_supported(aino)); put_long (info + 124, statbuf.st_size); #ifdef HAVE_ST_BLOCKS put_long (info + 128, statbuf.st_blocks); @@ -2017,7 +2037,7 @@ get_fileinfo (Unit *unit, dpacket packet, uaecptr info, a_inode *aino) put_long (info + 132, days); put_long (info + 136, mins); put_long (info + 140, ticks); - if (aino->comment == 0) + if (aino->comment == 0 || !fsdb_can) put_long (info + 144, 0); else { TRACE(("comment=\"%s\"\n", aino->comment)); @@ -2621,6 +2641,8 @@ action_set_protect (Unit *unit, dpacket packet) } a->amigaos_mode = mask; + if (fsdb_cando (unit)) + a->amigaos_mode = fsdb_mode_supported (a); err = fsdb_set_file_attrs (a); if (err != 0) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -2637,7 +2659,7 @@ static void action_set_comment (Unit * unit, dpacket packet) uaecptr lock = GET_PCK_ARG2 (packet) << 2; uaecptr name = GET_PCK_ARG3 (packet) << 2; uaecptr comment = GET_PCK_ARG4 (packet) << 2; - char *commented; + char *commented = NULL; a_inode *a; uae_u32 err; @@ -2647,8 +2669,10 @@ static void action_set_comment (Unit * unit, dpacket packet) return; } - commented = bstr (unit, comment); - commented = strlen (commented) > 0 ? my_strdup (commented) : 0; + if (fsdb_cando (unit)) { + commented = bstr (unit, comment); + commented = strlen (commented) > 0 ? my_strdup (commented) : NULL; + } TRACE (("ACTION_SET_COMMENT(0x%lx,\"%s\")\n", lock, commented)); a = find_aino (unit, lock, bstr (unit, name), &err); diff --git a/fsdb.c b/fsdb.c index f001aecb..69310f21 100755 --- a/fsdb.c +++ b/fsdb.c @@ -313,7 +313,7 @@ void fsdb_dir_writeback (a_inode *dir) f = get_fsdb (dir, "r+b"); if (f == 0) { - if ((currprefs.filesys_custom_uaefsdb && (dir->volflags & MYVOLUMEINFO_STREAMS)) ||currprefs.filesys_no_uaefsdb) { + if ((currprefs.filesys_custom_uaefsdb && (dir->volflags & MYVOLUMEINFO_STREAMS)) || currprefs.filesys_no_uaefsdb) { for (aino = dir->child; aino; aino = aino->sibling) { aino->dirty = 0; aino->has_dbentry = 0; diff --git a/gencpu.c b/gencpu.c index 37f80b48..646c3a94 100755 --- a/gencpu.c +++ b/gencpu.c @@ -1619,6 +1619,8 @@ static void gen_opcode (unsigned long int opcode) case i_RESET: fill_prefetch_next (); printf ("\tcpureset();\n"); + if (using_prefetch) + printf ("\tregs.irc = get_iword(4);\n"); break; case i_NOP: fill_prefetch_next (); diff --git a/include/arcadia.h b/include/arcadia.h index 432f1152..ed455927 100755 --- a/include/arcadia.h +++ b/include/arcadia.h @@ -1,23 +1,18 @@ #ifdef ARCADIA -extern addrbank arcadia_autoconfig_bank; -extern addrbank arcadia_fast_bank; -extern addrbank arcadia_bios_bank; -extern addrbank arcadia_rom_bank; - extern void arcadia_init (void); extern int is_arcadia_rom (char *path); extern int arcadia_map_banks (void); extern void arcadia_unmap (void); extern void arcadia_vsync (void); +extern void arcadia_reset (void); extern uae_u8 arcadia_parport (int port, uae_u8 pra, uae_u8 dra); struct arcadiarom { char *name, *bios, *rom; int extra; int b7, b6, b5, b4, b3, b2, b1, b0; - uae_u32 boot; }; extern struct arcadiarom *arcadia_rom; diff --git a/include/crc32.h b/include/crc32.h index 0c3146a1..9c69d7c9 100755 --- a/include/crc32.h +++ b/include/crc32.h @@ -1 +1,2 @@ extern uae_u32 get_crc32 (uae_u8 *p, int size); +extern uae_u16 get_crc16 (uae_u8 *p, int size); diff --git a/include/disk.h b/include/disk.h index 2b94dc35..1be447c6 100755 --- a/include/disk.h +++ b/include/disk.h @@ -26,7 +26,7 @@ extern int disk_getwriteprotect (const char *name); extern int disk_setwriteprotect (int num, const char *name, int protect); extern void disk_creatediskfile (char *name, int type, drive_type adftype, char *disk_name); extern void dumpdisk (void); -extern void DISK_history_add (const char *name, int idx); +extern int DISK_history_add (const char *name, int idx); extern char *DISK_history_get (int idx); int DISK_examine_image (struct uae_prefs *p, int num, uae_u32 *crc32); extern char *DISK_get_saveimagepath (const char *name); diff --git a/include/drawing.h b/include/drawing.h index acacd8ad..9e097c8f 100755 --- a/include/drawing.h +++ b/include/drawing.h @@ -30,7 +30,7 @@ #define max_diwlastword (PIXEL_XPOS(0x1d4 >> 1)) -extern int lores_factor, lores_shift, sprite_width; +extern int lores_factor, lores_shift, sprite_width, interlace_seen; STATIC_INLINE int coord_hw_to_window_x (int x) { diff --git a/include/driveclick.h b/include/driveclick.h index 4125ab33..bfa4a2ca 100755 --- a/include/driveclick.h +++ b/include/driveclick.h @@ -47,4 +47,5 @@ extern void driveclick_fdrawcmd_close(int); extern void driveclick_fdrawcmd_detect(void); extern void driveclick_fdrawcmd_seek(int, int); extern void driveclick_fdrawcmd_motor(int, int); +extern void driveclick_fdrawcmd_vsync(void); extern int driveclick_pcdrivemask, driveclick_pcdrivenum; \ No newline at end of file diff --git a/include/fsdb.h b/include/fsdb.h index f147d966..6326b00c 100755 --- a/include/fsdb.h +++ b/include/fsdb.h @@ -115,6 +115,7 @@ extern int fsdb_name_invalid (const char *n); extern int fsdb_fill_file_attrs (a_inode *, a_inode *); extern int fsdb_set_file_attrs (a_inode *); extern int fsdb_mode_representable_p (const a_inode *); +extern int fsdb_mode_supported (const a_inode *); extern char *fsdb_create_unique_nname (a_inode *base, const char *); extern void *my_opendir (const char*); diff --git a/include/gensound.h b/include/gensound.h index 82a05652..1723ca67 100755 --- a/include/gensound.h +++ b/include/gensound.h @@ -28,6 +28,7 @@ extern void sample16i_rh_handler (void); extern void sample16i_crux_handler (void); extern void sample8_handler (void); extern void sample16s_handler (void); +extern void sample16si_anti_handler (void); extern void sample16ss_handler (void); extern void sample16si_rh_handler (void); extern void sample16si_crux_handler (void); diff --git a/include/inputdevice.h b/include/inputdevice.h index d34a6850..fb2b842c 100755 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -166,11 +166,11 @@ extern int input_recording; extern void inprec_close(void); extern int inprec_open(char*, int); extern void inprec_rend(void); -extern void inprec_rstart(uae_u8, uae_u8); +extern void inprec_rstart(uae_u8); extern void inprec_ru8(uae_u8); extern void inprec_ru16(uae_u16); extern void inprec_ru32(uae_u32); -extern void inprec_rstr(char*); +extern void inprec_rstr(const char*); extern int inprec_pstart(uae_u8); extern void inprec_pend(void); extern uae_u8 inprec_pu8(void); diff --git a/include/options.h b/include/options.h index 4cbb6437..c0959f56 100755 --- a/include/options.h +++ b/include/options.h @@ -45,6 +45,12 @@ struct uae_input_device { #define CONFIG_TYPE_HARDWARE 1 #define CONFIG_TYPE_HOST 2 +#define CONFIG_BLEN 2560 + +struct wh { + int width; + int height; +}; struct uae_prefs { @@ -86,6 +92,7 @@ struct uae_prefs { int sound_interpol; int sound_adjust; int sound_filter; + int sound_filter_type; int sound_volume; int sound_stereo_swap_paula; int sound_stereo_swap_ahi; @@ -115,9 +122,12 @@ struct uae_prefs { int gfx_display; int gfx_framerate, gfx_autoframerate; - int gfx_width_win, gfx_height_win; - int gfx_width_fs, gfx_height_fs; - int gfx_width, gfx_height; + struct wh gfx_size_win; + struct wh gfx_size_fs; + struct wh gfx_size; + struct wh gfx_size_win_xtra[4]; + struct wh gfx_size_fs_xtra[4]; + int gfx_autoresolution; int gfx_refreshrate; int gfx_vsync; int gfx_lores; @@ -278,6 +288,7 @@ extern int target_parse_option (struct uae_prefs *, char *option, char *value); extern void target_save_options (struct zfile*, struct uae_prefs *); extern void target_default_options (struct uae_prefs *, int type); extern int target_cfgfile_load (struct uae_prefs *, char *filename, int type, int isdefault); +extern void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type); extern int cfgfile_load (struct uae_prefs *p, const char *filename, int *type, int ignorelink); extern int cfgfile_save (struct uae_prefs *, const char *filename, int); @@ -287,11 +298,11 @@ extern int cfgfile_get_description (const char *filename, char *description, cha extern void cfgfile_show_usage (void); extern uae_u32 cfgfile_uaelib (int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen); extern uae_u32 cfgfile_uaelib_modify (uae_u32 mode, uae_u32 parms, uae_u32 size, uae_u32 out, uae_u32 outsize); +extern uae_u32 cfgfile_modify (uae_u32 index, char *parms, uae_u32 size, char *out, uae_u32 outsize); extern void cfgfile_addcfgparam (char *); extern int build_in_prefs (struct uae_prefs *p, int model, int config, int compa, int romcheck); extern int cmdlineparser (char *s, char *outp[], int max); -extern int cfgfile_handle_custom_event (char *custom, int mode); - +extern int cfgfile_configuration_change(int); extern void fixup_prefs_dimensions (struct uae_prefs *prefs); extern void fixup_prefs (struct uae_prefs *prefs); diff --git a/include/savestate.h b/include/savestate.h index 057b5ffa..94713f49 100755 --- a/include/savestate.h +++ b/include/savestate.h @@ -62,6 +62,7 @@ extern uae_u8 *save_custom_agacolors (int *len, uae_u8 *); extern uae_u8 *restore_blitter (uae_u8 *src); extern uae_u8 *save_blitter (int *len, uae_u8 *); +extern void restore_blitter_finish (void); extern uae_u8 *restore_audio (int, uae_u8 *); extern uae_u8 *save_audio (int, int *, uae_u8 *); diff --git a/include/scsidev.h b/include/scsidev.h index 7af11fd3..dafaa14c 100755 --- a/include/scsidev.h +++ b/include/scsidev.h @@ -21,4 +21,5 @@ extern int log_scsi; #define UAESCSI_SPTISCAN 1 #define UAESCSI_ADAPTECASPI 2 #define UAESCSI_NEROASPI 3 +#define UAESCSI_FROGASPI 4 #endif \ No newline at end of file diff --git a/include/uaeipc.h b/include/uaeipc.h new file mode 100755 index 00000000..af0762d3 --- /dev/null +++ b/include/uaeipc.h @@ -0,0 +1,4 @@ +extern int createIPC(void); +extern void closeIPC(void); +extern int checkIPC(struct uae_prefs*); +extern void *geteventhandleIPC(void); diff --git a/inputdevice.c b/inputdevice.c index cf670e76..e3ca3715 100755 --- a/inputdevice.c +++ b/inputdevice.c @@ -3,7 +3,7 @@ * * joystick/mouse emulation * - * Copyright 2001, 2002 Toni Wilen + * Copyright 2001-2006 Toni Wilen * * new fetures: * - very configurable (and very complex to configure :) @@ -126,6 +126,7 @@ static uae_u16 oldjoy[2]; int inprec_open(char *fname, int record) { uae_u32 t = (uae_u32)time(0); + int i; inprec_close(); inprec_zf = zfile_fopen(fname, record > 0 ? "wb" : "rb"); @@ -147,7 +148,9 @@ int inprec_open(char *fname, int record) } inprec_pu32(); srand(inprec_pu32()); - inprec_pu32(); + i = inprec_pu32(); + while (i-- > 0) + inprec_pu8(); inprec_p = inprec_plastptr; oldbuttons[0] = oldbuttons[1] = oldbuttons[2] = oldbuttons[3] = 0; oldjoy[0] = oldjoy[1] = 0; @@ -159,7 +162,7 @@ int inprec_open(char *fname, int record) inprec_ru8(UAEMINOR); inprec_ru8(UAESUBREV); inprec_ru32(t); - inprec_ru32(0); + inprec_ru32(0); // extra header size } else { return 0; } @@ -175,7 +178,8 @@ void inprec_close(void) return; if (inprec_buffer && input_recording > 0) { hsync_counter++; - inprec_rstart(INPREC_END, 0); + inprec_rstart(INPREC_END); + inprec_rend(); hsync_counter--; zfile_fwrite (inprec_buffer, inprec_p - inprec_buffer, 1, inprec_zf); inprec_p = inprec_buffer; @@ -190,10 +194,6 @@ void inprec_close(void) void inprec_ru8(uae_u8 v) { - if (inprec_p >= inprec_buffer + inprec_size) { - zfile_fwrite (inprec_buffer, inprec_size, 1, inprec_zf); - inprec_p = inprec_buffer; - } *inprec_p++= v; } void inprec_ru16(uae_u16 v) @@ -206,7 +206,7 @@ void inprec_ru32(uae_u32 v) inprec_ru16((uae_u16)(v >> 16)); inprec_ru16((uae_u16)v); } -void inprec_rstr(char *s) +void inprec_rstr(const char *s) { while(*s) { inprec_ru8(*s); @@ -214,16 +214,22 @@ void inprec_rstr(char *s) } inprec_ru8(0); } -void inprec_rstart(uae_u8 type, uae_u8 size) +void inprec_rstart(uae_u8 type) { - write_log("INPREC: %08.8X: %d (%d)\n", hsync_counter, type, size); + write_log("INPREC: %08.8X: %d\n", hsync_counter, type); inprec_ru32(hsync_counter); inprec_ru8(0); - inprec_ru8(size); + inprec_plast = inprec_p; + inprec_ru8(0xff); inprec_ru8(type); } void inprec_rend(void) { + *inprec_plast = inprec_p - (inprec_plast + 2); + if (inprec_p >= inprec_buffer + inprec_size - 256) { + zfile_fwrite (inprec_buffer, inprec_p - inprec_buffer, 1, inprec_zf); + inprec_p = inprec_buffer; + } } int inprec_pstart(uae_u8 type) @@ -780,7 +786,7 @@ int getbuttonstate (int joy, int button) v = (joybutton[joy] & (1 << button)) ? 1 : 0; if (input_recording > 0 && ((joybutton[joy] ^ oldbuttons[joy]) & (1 << button))) { oldbuttons[joy] = joybutton[joy]; - inprec_rstart(INPREC_JOYBUTTON, 3); + inprec_rstart(INPREC_JOYBUTTON); inprec_ru8(joy); inprec_ru8(button); inprec_ru8(v); @@ -893,7 +899,7 @@ int getjoystate (int joy) #endif if (input_recording > 0 && oldjoy[joy] != v) { oldjoy[joy] = v; - inprec_rstart(INPREC_JOYPORT, 2); + inprec_rstart(INPREC_JOYPORT); inprec_ru16(v); inprec_rend(); } else if (input_recording < 0) { diff --git a/keybuf.c b/keybuf.c index 90476efa..feaa5f93 100755 --- a/keybuf.c +++ b/keybuf.c @@ -173,7 +173,7 @@ void record_key_direct (int kc) } if (input_recording > 0) { - inprec_rstart(INPREC_KEY, 1); + inprec_rstart(INPREC_KEY); inprec_ru8(kc); inprec_rend(); } diff --git a/main.c b/main.c index 705b87af..6de33879 100755 --- a/main.c +++ b/main.c @@ -96,24 +96,22 @@ void discard_prefs (struct uae_prefs *p, int type) #endif } +static void fixup_prefs_dim2 (struct wh *wh) +{ + if (wh->width < 320) + wh->width = 320; + if (wh->height < 200) + wh->height = 200; + if (wh->width > 1280) + wh->width = 1280; + wh->width += 7; + wh->width &= ~7; +} + void fixup_prefs_dimensions (struct uae_prefs *prefs) { - if (prefs->gfx_width_fs < 320) - prefs->gfx_width_fs = 320; - if (prefs->gfx_height_fs < 200) - prefs->gfx_height_fs = 200; - if (prefs->gfx_height_fs > 1280) - prefs->gfx_height_fs = 1280; - prefs->gfx_width_fs += 7; /* X86.S wants multiples of 4 bytes, might be 8 in the future. */ - prefs->gfx_width_fs &= ~7; - if (prefs->gfx_width_win < 320) - prefs->gfx_width_win = 320; - if (prefs->gfx_height_win < 200) - prefs->gfx_height_win = 200; - if (prefs->gfx_height_win > 1280) - prefs->gfx_height_win = 1280; - prefs->gfx_width_win += 7; /* X86.S wants multiples of 4 bytes, might be 8 in the future. */ - prefs->gfx_width_win &= ~7; + fixup_prefs_dim2(&prefs->gfx_size_fs); + fixup_prefs_dim2(&prefs->gfx_size_win); } void fixup_prefs (struct uae_prefs *p) diff --git a/memory.c b/memory.c index 5abf21ce..274eeac5 100755 --- a/memory.c +++ b/memory.c @@ -2300,6 +2300,8 @@ uae_u8 *restore_rom (uae_u8 *src) } } src += strlen (src) + 1; + if (zfile_exists(src)) + strncpy (changed_prefs.romfile, src, 255); src += strlen (src) + 1; return src; } diff --git a/od-win32/avioutput.c b/od-win32/avioutput.c index 98181b62..5b35865a 100755 --- a/od-win32/avioutput.c +++ b/od-win32/avioutput.c @@ -4,6 +4,7 @@ avioutput.c Copyright(c) 2001 - 2002; §ane + 2005-2006; Toni Wilen */ @@ -49,7 +50,7 @@ static double StreamSizeAudioExpected; int avioutput_audio, avioutput_video, avioutput_enabled, avioutput_requested; -int avioutput_width = 320, avioutput_height = 256, avioutput_bits = 24; +int avioutput_width, avioutput_height, avioutput_bits; int avioutput_fps = VBLANK_HZ_PAL; int avioutput_framelimiter = 0; @@ -135,14 +136,6 @@ void AVIOutput_ReleaseAudio(void) void AVIOutput_ReleaseVideo(void) { - if(pcompvars) - { - ICClose(pcompvars->hic); // did we inadvertently open it? - ICCompressorFree(pcompvars); - free(pcompvars); - pcompvars = NULL; - } - if(lpbi) { free(lpbi); @@ -156,17 +149,17 @@ void AVIOutput_ReleaseVideo(void) } } -LPSTR AVIOutput_ChooseAudioCodec(HWND hwnd) +static int AVIOutput_AllocateAudio(void) { - DWORD wfxMaxFmtSize; MMRESULT err; + DWORD wfxMaxFmtSize; AVIOutput_ReleaseAudio(); if((err = acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FORMAT, &wfxMaxFmtSize))) { gui_message("acmMetrics() FAILED (%X)\n", err); - return NULL; + return 0; } // set the source format @@ -179,7 +172,7 @@ LPSTR AVIOutput_ChooseAudioCodec(HWND hwnd) wfxSrc.cbSize = 0; if(!(pwfxDst = (LPWAVEFORMATEX) malloc(wfxMaxFmtSize))) - return NULL; + return 0; // set the initial destination format to match source memset(pwfxDst, 0, wfxMaxFmtSize); @@ -190,7 +183,6 @@ LPSTR AVIOutput_ChooseAudioCodec(HWND hwnd) acmopt.cbStruct = sizeof(ACMFORMATCHOOSE); acmopt.fdwStyle = ACMFORMATCHOOSE_STYLEF_ENABLEHOOK | ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT; - acmopt.hwndOwner = hwnd; acmopt.pwfx = pwfxDst; acmopt.cbwfx = wfxMaxFmtSize; @@ -209,7 +201,16 @@ LPSTR AVIOutput_ChooseAudioCodec(HWND hwnd) //ACM_FORMATENUMF_SUGGEST // with this flag set, only MP3 320kbps is displayed, which is closest to the source format acmopt.pwfxEnum = &wfxSrc; + return 1; +} + +LPSTR AVIOutput_ChooseAudioCodec(HWND hwnd) +{ + if (!AVIOutput_AllocateAudio()) + return NULL; + + acmopt.hwndOwner = hwnd; acmopt.pfnHook = acmFilterChooseHookProc; switch(acmFormatChoose(&acmopt)) @@ -249,18 +250,22 @@ LPSTR AVIOutput_ChooseAudioCodec(HWND hwnd) return NULL; } -LPSTR AVIOutput_ChooseVideoCodec(HWND hwnd) +static int AVIOutput_AllocateVideo(void) { - ICINFO icinfo = { 0 }; - AVIOutput_ReleaseVideo(); - avioutput_width = workprefs.gfx_width; - avioutput_height = workprefs.gfx_height; - avioutput_bits = workprefs.color_mode == 2 ? 16 : workprefs.color_mode > 2 ? 32 : 8; + avioutput_width = WIN32GFX_GetWidth(); + avioutput_height = WIN32GFX_GetHeight(); + avioutput_bits = WIN32GFX_GetDepth(0); + + if (!avioutput_width || !avioutput_height || !avioutput_bits) { + avioutput_width = 320; + avioutput_height = 256; + avioutput_bits = 24; + } if(!(lpbi = (LPBITMAPINFOHEADER) malloc(sizeof(BITMAPINFOHEADER) + (((avioutput_bits <= 8) ? 1 << avioutput_bits : 0) * sizeof(RGBQUAD))))) - return NULL; + return 0; lpbi->biSize = sizeof(BITMAPINFOHEADER); lpbi->biWidth = avioutput_width; @@ -274,11 +279,15 @@ LPSTR AVIOutput_ChooseVideoCodec(HWND hwnd) lpbi->biClrUsed = (lpbi->biBitCount <= 8) ? 1 << lpbi->biBitCount : 0; lpbi->biClrImportant = 0; - if(!(pcompvars = (PCOMPVARS) malloc(sizeof(COMPVARS)))) - return NULL; + return 1; +} - memset(pcompvars, 0, sizeof(COMPVARS)); - pcompvars->cbSize = sizeof(COMPVARS); +LPSTR AVIOutput_ChooseVideoCodec(HWND hwnd) +{ + ICINFO icinfo = { 0 }; + + if (!AVIOutput_AllocateVideo()) + return NULL; // we really should check first to see if the user has a particular compressor installed before we set one // we could set one but we will leave it up to the operating system and the set priority levels for the compressors @@ -302,7 +311,7 @@ LPSTR AVIOutput_ChooseVideoCodec(HWND hwnd) { static char string[128]; - if(WideCharToMultiByte(CP_ACP, 0, icinfo.szDescription, -1, string, 128, NULL, NULL) != 0) + if(WideCharToMultiByte(CP_ACP, 0, icinfo.szDescription, -1, string, sizeof string, NULL, NULL) != 0) return string; } } @@ -483,27 +492,24 @@ void AVIOutput_RGBinfo(int rb, int gb, int bb, int rs, int gs, int bs) } #if defined (GFXFILTER) -extern int bufmem_width, bufmem_height; extern uae_u8 *bufmem_ptr; static int getFromBuffer(LPBITMAPINFO lpbi) { - int w, h, x, y; + int x, y; uae_u8 *src; uae_u8 *dst = lpVideo; src = bufmem_ptr; if (!src) return 0; - w = bufmem_width; - h = bufmem_height; - dst += avioutput_width * gfxvidinfo.pixbytes * avioutput_height; + dst += avioutput_width * avioutput_bits / 8 * avioutput_height; for (y = 0; y < (gfxvidinfo.height > avioutput_height ? avioutput_height : gfxvidinfo.height); y++) { - dst -= avioutput_width * gfxvidinfo.pixbytes; + dst -= avioutput_width * avioutput_bits / 8; for (x = 0; x < (gfxvidinfo.width > avioutput_width ? avioutput_width : gfxvidinfo.width); x++) { - if (gfxvidinfo.pixbytes == 1) { + if (avioutput_bits == 8) { dst[x] = src[x]; - } else if (gfxvidinfo.pixbytes == 2) { + } else if (avioutput_bits == 16) { uae_u16 v = ((uae_u16*)src)[x]; uae_u16 v2 = v; if (rgb_type) { @@ -512,7 +518,7 @@ static int getFromBuffer(LPBITMAPINFO lpbi) v2 |= (v >> 1) & (31 << 10); } ((uae_u16*)dst)[x] = v2; - } else if (gfxvidinfo.pixbytes == 4) { + } else if (avioutput_bits == 32) { uae_u32 v = ((uae_u32*)src)[x]; ((uae_u32*)dst)[x] = v; } @@ -748,6 +754,8 @@ void AVIOutput_Begin(void) if(avioutput_audio) { + if (!AVIOutput_AllocateAudio()) + goto error; memset(&avistreaminfo, 0, sizeof(AVISTREAMINFO)); avistreaminfo.fccType = streamtypeAUDIO; avistreaminfo.fccHandler = 0; // This member is not used for audio streams. @@ -790,7 +798,9 @@ void AVIOutput_Begin(void) if(avioutput_video) { - if(!(lpVideo = malloc(lpbi->biSizeImage))) + if (!AVIOutput_AllocateVideo()) + goto error; + if(!(lpVideo = calloc(lpbi->biSizeImage, 1))) { goto error; } @@ -874,6 +884,14 @@ void AVIOutput_Release(void) avioutput_init = 0; } + if(pcompvars) + { + ICClose(pcompvars->hic); // did we inadvertently open it? + ICCompressorFree(pcompvars); + free(pcompvars); + pcompvars = NULL; + } + DeleteCriticalSection(&AVIOutput_CriticalSection); } @@ -881,6 +899,12 @@ void AVIOutput_Initialize(void) { InitializeCriticalSection(&AVIOutput_CriticalSection); + pcompvars = (PCOMPVARS) malloc(sizeof(COMPVARS)); + if (!pcompvars) + return; + memset(pcompvars, 0, sizeof(COMPVARS)); + pcompvars->cbSize = sizeof(COMPVARS); + if(!avioutput_init) { AVIFileInit(); diff --git a/od-win32/blkdev_win32_aspi.c b/od-win32/blkdev_win32_aspi.c index a00f4082..bf1994de 100755 --- a/od-win32/blkdev_win32_aspi.c +++ b/od-win32/blkdev_win32_aspi.c @@ -46,7 +46,7 @@ struct scsi_info { static struct scsi_info si[MAX_TOTAL_DEVICES]; static int unitcnt; -static int getversion(char *name, VS_FIXEDFILEINFO *ver) +static int getversion(const char *name, VS_FIXEDFILEINFO *ver) { int ok = FALSE; DWORD dwVersionHandle, dwFileVersionInfoSize; @@ -76,16 +76,27 @@ static int getversion(char *name, VS_FIXEDFILEINFO *ver) return ok; } -char *get_aspi_path(int neroaspi) +const char *get_aspi_path(int aspitype) { - static int nero, adaptec; + static int nero, adaptec, frog; static char path_nero[MAX_DPATH]; static char path_adaptec[MAX_DPATH]; + static const char *path_frog = "FrogAspi.dll"; VS_FIXEDFILEINFO ver; - switch (neroaspi) + switch (aspitype) { - case 1: + case 2: // Frog + if (frog > 0) + return path_frog; + if (frog < 0) + return NULL; + frog = -1; + if (getversion(path_frog, &ver)) + frog = 1; + return path_frog; + + case 1: // Nero { HKEY key; DWORD type = REG_SZ; @@ -97,7 +108,9 @@ char *get_aspi_path(int neroaspi) nero = -1; if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\Ahead\\shared", 0, KEY_ALL_ACCESS, &key) == ERROR_SUCCESS) { if (RegQueryValueEx (key, "NeroAPI", 0, &type, (LPBYTE)path_nero, &size) == ERROR_SUCCESS) { - strcat (path_nero, "\\wnaspi32.dll"); + if (path_nero[strlen(path_nero) - 1] != '\\') + strcat (path_nero, "\\"); + strcat (path_nero, "wnaspi32.dll"); RegCloseKey (key); if (getversion(path_nero, &ver)) { if (ver.dwFileVersionMS >= 0x20000) { @@ -112,7 +125,7 @@ char *get_aspi_path(int neroaspi) } return NULL; - case 0: + case 0: // Adaptec { if (adaptec > 0) return path_adaptec; @@ -157,7 +170,7 @@ static int open_driver (SCSI *scgp) BYTE HACount; BYTE ASPIStatus; int i; - int nero; + int nero, frog; /* * Check if ASPI library is already loaded yet @@ -165,22 +178,28 @@ static int open_driver (SCSI *scgp) if (AspiLoaded == TRUE) return TRUE; - nero = 0; + nero = frog = 0; strcpy (path, "WNASPI32"); if (currprefs.win32_uaescsimode == UAESCSI_NEROASPI) { - char *p = get_aspi_path(1); + const char *p = get_aspi_path(1); if (p) { strcpy (path, p); nero = 1; } + } else if (currprefs.win32_uaescsimode == UAESCSI_FROGASPI) { + const char *p = get_aspi_path(2); + if (p) { + strcpy (path, p); + frog = 1; + } } /* * Load the ASPI library */ write_log ("ASPI: driver location '%s'\n", path); hAspiLib = LoadLibrary(path); - if (hAspiLib == NULL && nero) { - write_log ("ASPI: NERO ASPI failed to load, falling back to default\n"); + if (hAspiLib == NULL && (nero || frog)) { + write_log ("ASPI: NERO/FROG ASPI failed to load, falling back to default\n"); hAspiLib = LoadLibrary("WNASPI32"); } diff --git a/od-win32/diskutil.c b/od-win32/diskutil.c index 379a22e0..d4cd2bb2 100755 --- a/od-win32/diskutil.c +++ b/od-win32/diskutil.c @@ -1,3 +1,4 @@ +// adfread by Toni Wilen #include #include @@ -131,7 +132,7 @@ static int drive_write_adf_amigados (UWORD *mbuf, UWORD *mend, UBYTE *writebuffe do { while (*mbuf++ != 0x4489) { if (mbuf >= mend) { - printf("* unexpected end of data, sectors left %d\n", 11 - secwritten); + printf("* unexpected end of data\n"); return 1; } } @@ -144,7 +145,7 @@ static int drive_write_adf_amigados (UWORD *mbuf, UWORD *mend, UBYTE *writebuffe trackoffs = (id & 0xff00) >> 8; if (trackoffs > 10) { - printf("* corrupt sector number %d, sectors complete %d\n", trackoffs, secwritten); + printf("* corrupt sector number %d\n", trackoffs); goto next; } chksum = odd ^ even; @@ -155,7 +156,7 @@ static int drive_write_adf_amigados (UWORD *mbuf, UWORD *mend, UBYTE *writebuffe dlong = (odd << 1) | even; if (dlong) { - printf("* sector %d header crc error, sectors complete %d\n", trackoffs, secwritten); + printf("* sector %d header crc error\n", trackoffs); goto next; } chksum ^= odd ^ even; @@ -164,7 +165,7 @@ static int drive_write_adf_amigados (UWORD *mbuf, UWORD *mend, UBYTE *writebuffe odd = getmfmlong (mbuf); even = getmfmlong (mbuf + 2); mbuf += 4; - if (((odd << 1) | even) != chksum || ((id & 0x00ff0000) >> 16) != track) return 3; + if (((odd << 1) | even) != chksum || ((id & 0x00ff0000) >> 16) != (ULONG)track) return 3; odd = getmfmlong (mbuf); even = getmfmlong (mbuf + 2); mbuf += 4; @@ -183,7 +184,7 @@ static int drive_write_adf_amigados (UWORD *mbuf, UWORD *mend, UBYTE *writebuffe } mbuf += 256; if (chksum) { - printf("* sector %d data crc error, sectors complete %d\n", trackoffs, secwritten); + printf("* sector %d data crc error\n", trackoffs); goto next; } sectable[trackoffs] = 1; diff --git a/od-win32/driveclick_win32.c b/od-win32/driveclick_win32.c index 8822eea7..a9b8f36e 100755 --- a/od-win32/driveclick_win32.c +++ b/od-win32/driveclick_win32.c @@ -25,6 +25,16 @@ int driveclick_pcdrivenum, driveclick_pcdrivemask; #define DC_PIPE_SIZE 100 static smp_comm_pipe dc_pipe[DC_PIPE_SIZE]; static HANDLE h[2] = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE }; +static int motors[2]; + +static int CmdMotor (HANDLE h_, BYTE motor_) +{ + DWORD dwRet; + if (h == INVALID_HANDLE_VALUE) + return 0; + return !!DeviceIoControl(h_, motor_ ? IOCTL_FD_MOTOR_ON : IOCTL_FD_MOTOR_OFF, + NULL, 0, NULL, 0, &dwRet, NULL); +} static int CmdSeek (HANDLE h_, BYTE cyl_) { @@ -52,10 +62,34 @@ static int SetDataRate (HANDLE h_, BYTE bDataRate_) return !!DeviceIoControl(h_, IOCTL_FD_SET_DATA_RATE, &bDataRate_, sizeof(bDataRate_), NULL, 0, &dwRet, NULL); } +static int SetMotorDelay (HANDLE h_, BYTE delay_) +{ + DWORD dwRet; + if (h == INVALID_HANDLE_VALUE) + return 0; + return !!DeviceIoControl(h_, IOCTL_FD_SET_MOTOR_TIMEOUT, &delay_, sizeof(delay_), NULL, 0, &dwRet, NULL); +} + void driveclick_fdrawcmd_seek(int drive, int cyl) { write_comm_pipe_int (dc_pipe, (drive << 8) | cyl, 1); } +void driveclick_fdrawcmd_motor (int drive, int running) +{ + write_comm_pipe_int (dc_pipe, 0x8000 | (drive << 8) | (running ? 1 : 0), 1); +} + +void driveclick_fdrawcmd_vsync(void) +{ + int i; + for (i = 0; i < 2; i++) { + if (motors[i] > 0) { + motors[i]--; + if (motors[i] == 0) + CmdMotor(h[i], 0); + } + } +} static void *driveclick_thread (void *v) { @@ -64,9 +98,17 @@ static void *driveclick_thread (void *v) int v = read_comm_pipe_int_blocking (dc_pipe); if (v < 0) break; - drive = v >> 8; - cyl = v & 255; - CmdSeek(h[drive], cyl); + drive = (v >> 8) & 3; + if (v & 0x8000) { + int motor = v & 1; + motors[drive] = motor ? -1 : 0; + CmdMotor(h[drive], motor); + } else { + cyl = v & 255; + if (motors[drive] == 0) + motors[drive] = 100; + CmdSeek(h[drive], cyl); + } } return NULL; } @@ -78,8 +120,11 @@ static int driveclick_fdrawcmd_init(int drive) if (h[drive] == INVALID_HANDLE_VALUE) return 0; + motors[drive] = 0; SetDataRate(h[drive], 3); CmdSpecify(h[drive], 0xd, 0xf, 0x1, 0); + SetMotorDelay(h[drive], 0); + CmdMotor(h[drive], 0); if (thread_ok) return 1; thread_ok = 1; @@ -88,15 +133,12 @@ static int driveclick_fdrawcmd_init(int drive) return 1; } -void driveclick_fdrawcmd_motor (int drive, int running) -{ -} - void driveclick_fdrawcmd_close(int drive) { if (h[drive] != INVALID_HANDLE_VALUE) CloseHandle(h[drive]); h[drive] = INVALID_HANDLE_VALUE; + motors[drive] = 0; } int driveclick_fdrawcmd_open(int drive) @@ -105,7 +147,7 @@ int driveclick_fdrawcmd_open(int drive) driveclick_fdrawcmd_close(drive); sprintf (s, "\\\\.\\fdraw%d", drive); - h[drive] = CreateFile(s, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + h[drive] = CreateFile(s, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (h[drive] == INVALID_HANDLE_VALUE) return 0; driveclick_fdrawcmd_init(drive); diff --git a/od-win32/fdrawcmd.c b/od-win32/fdrawcmd.c index f83a3513..4eb61811 100755 --- a/od-win32/fdrawcmd.c +++ b/od-win32/fdrawcmd.c @@ -1,3 +1,6 @@ +// adfread by Toni Wilen +// +// uses fdrawcmd.sys by Simon Owen #include #include @@ -10,8 +13,7 @@ #include "diskutil.h" #define TRACK_SIZE 16384 -static int longread = 1; -#define MAX_RETRIES 10 +#define MAX_RETRIES 50 static UBYTE writebuffer[11 * 512]; static UBYTE writebuffer_ok[11]; @@ -67,10 +69,8 @@ static int opendevice(void) return 1; } -#if 1 -static int readraw(int cyl, int head) +static int seek(int cyl, int head) { - FD_RAW_READ_PARAMS rrp; FD_SEEK_PARAMS sp; DWORD ret; @@ -80,13 +80,23 @@ static int readraw(int cyl, int head) printf("IOCTL_FDCMD_SEEK failed cyl=%d, err=%d\n", sp.cyl, GetLastError()); return 0; } + return 1; +} + +#if 1 +static int readraw(int cyl, int head) +{ + FD_RAW_READ_PARAMS rrp; + DWORD ret; + + if (!seek(cyl, head)) + return 0; - rrp.flags = FD_OPTION_MFM; - rrp.size = longread == 1 ? 7 : 8; + rrp.flags = FD_OPTION_MFM; rrp.head = head; - memset (trackbuffer, 0, TRACK_SIZE * longread); - if (!DeviceIoControl(h, IOCTL_FD_RAW_READ_TRACK * longread, &rrp, sizeof rrp, - trackbuffer, TRACK_SIZE * longread, &ret, NULL)) { + rrp.size = 7; + memset (trackbuffer, 0, TRACK_SIZE); + if (!DeviceIoControl(h, IOCTL_FD_RAW_READ_TRACK, &rrp, sizeof rrp, trackbuffer, TRACK_SIZE, &ret, NULL)) { printf("IOCTL_FD_RAW_READ_TRACK failed, err=%d\n", GetLastError()); return 0; } @@ -98,7 +108,7 @@ static int readraw(int cyl, int head) { FILE *f; - if (fopen_s(&f, "f:\\amiga\\amiga.dat", "rb")) + if (!(f = fopen("f:\\amiga\\amiga.dat", "rb"))) return 0; fseek(f, (cyl * 2 + head) * 16384, SEEK_SET); fread(trackbuffer, TRACK_SIZE, 1, f); @@ -113,7 +123,7 @@ static void readloop(char *fname) int errsec, oktrk, retr; time_t t = time(0); - if (fopen_s(&fout, fname, "wb")) { + if (!(fout = fopen(fname, "wb"))) { printf("Failed to open '%s'\n", fname); return; } @@ -122,14 +132,15 @@ static void readloop(char *fname) printf ("Track %d: processing started..\n", trk); memset (writebuffer_ok, 0, sizeof writebuffer_ok); memset (writebuffer, 0, sizeof writebuffer); + sec = 0; for (j = 0; j < MAX_RETRIES; j++) { if (j > 0) - printf("Retrying.. (%d/%d)\n", j, MAX_RETRIES - 1); + printf("Retrying.. (%d of max %d), %d/%d sectors ok\n", j, MAX_RETRIES - 1, sec, 11); if (!readraw(trk / 2, trk % 2)) { printf("Raw read error, possible reasons:\nMissing second drive or your hardware only supports single drive.\nOperation aborted.\n"); return; } - isamigatrack(trackbuffer, TRACK_SIZE * longread, writebuffer, writebuffer_ok, trk); + isamigatrack(trackbuffer, TRACK_SIZE, writebuffer, writebuffer_ok, trk); sec = 0; for (i = 0; i < 11; i++) { if (writebuffer_ok[i]) @@ -138,10 +149,12 @@ static void readloop(char *fname) if (sec == 11) break; retr++; + if ((retr % 10) == 0) + seek(trk == 0 ? 2 : 0, 0); } errsec += 11 - sec; if (j == MAX_RETRIES) { - printf("Track %d: read error or non-AmigaDOS formatted track (%d/11 sectors ok)\n", trk, sec); + printf("Track %d: read error or non-AmigaDOS formatted track (%d/%d sectors ok)\n", trk, sec, 11); } else { oktrk++; printf("Track %d: all sectors ok (%d retries)\n", trk, j); @@ -157,28 +170,19 @@ static void readloop(char *fname) int main(int argc, char *argv[]) { DWORD ver; - char *fname = NULL; - int i; - for (i = 1; i < argc; i++) { - if (!_stricmp(argv[i], "-l")) { - longread = 2; - continue; - } - break; - } - if (argc < 2 || i >= argc) { - printf("adiskutil.exe [-l] \n"); + if (argc < 2) { + printf("adfread.exe \n"); return 0; } - fname = argv[i]; + ver = checkversion(); if (!ver) return 0; - printf ("fdrawcmd.sys %x detected. Read size %d\n", ver, TRACK_SIZE * longread); - trackbuffer = VirtualAlloc(NULL, TRACK_SIZE * 4, MEM_COMMIT, PAGE_READWRITE); + printf ("fdrawcmd.sys %x detected\n", ver); + trackbuffer = VirtualAlloc(NULL, TRACK_SIZE * 2, MEM_COMMIT, PAGE_READWRITE); if (opendevice()) { - readloop(fname); + readloop(argv[1]); } closedevice(); VirtualFree(trackbuffer, 0, MEM_RELEASE); diff --git a/od-win32/fsdb_win32.c b/od-win32/fsdb_win32.c index 7c7fb0fd..611ab4cb 100755 --- a/od-win32/fsdb_win32.c +++ b/od-win32/fsdb_win32.c @@ -321,6 +321,16 @@ int fsdb_set_file_attrs (a_inode *aino) return 0; } +/* return supported combination */ +int fsdb_mode_supported (const a_inode *aino) +{ + int mask = aino->amigaos_mode; + if (fsdb_mode_representable_p (aino)) + return mask; + mask &= ~(A_FIBF_SCRIPT | A_FIBF_DELETE | A_FIBF_WRITE); + return mask; +} + /* Return nonzero if we can represent the amigaos_mode of AINO within the * native FS. Return zero if that is not possible. */ int fsdb_mode_representable_p (const a_inode *aino) @@ -565,7 +575,6 @@ void my_close (void *d) { struct my_opens *mos = d; CloseHandle (mos->h); - //write_log ("closehandle %x\n", mos->h); xfree (mos); } @@ -592,19 +601,29 @@ unsigned int my_write (void *d, void *b, unsigned int size) return written; } +static DWORD GetFileAttributesSafe(const char *name) +{ + DWORD attr, last; + + last = SetErrorMode (SEM_FAILCRITICALERRORS); + attr = GetFileAttributes (name); + SetErrorMode (last); + return attr; +} + int my_existsfile (const char *name) { - HANDLE h = CreateFile (name, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (h == INVALID_HANDLE_VALUE) + DWORD attr = GetFileAttributesSafe (name); + if (attr == INVALID_FILE_ATTRIBUTES) return 0; - CloseHandle (h); - return 1; + if (!(attr & FILE_ATTRIBUTE_DIRECTORY)) + return 1; + return 0; } int my_existsdir (const char *name) { - DWORD attr = GetFileAttributes (name); + DWORD attr = GetFileAttributesSafe (name); if (attr == INVALID_FILE_ATTRIBUTES) return 0; if (attr & FILE_ATTRIBUTE_DIRECTORY) @@ -625,7 +644,7 @@ void *my_open (const char *name, int flags) mos = xmalloc (sizeof (struct my_opens)); if (!mos) return NULL; - attr = GetFileAttributes (name); + attr = GetFileAttributesSafe (name); if (flags & O_TRUNC) CreationDisposition = CREATE_ALWAYS; else if (flags & O_CREAT) @@ -732,15 +751,13 @@ typedef BOOL (CALLBACK* GETVOLUMEPATHNAME) int my_getvolumeinfo (char *root) { - DWORD last, v, err; + DWORD v, err; int ret = 0; GETVOLUMEPATHNAME pGetVolumePathName; char volume[MAX_DPATH]; - last = SetErrorMode (SEM_FAILCRITICALERRORS); - v = GetFileAttributes (root); + v = GetFileAttributesSafe (root); err = GetLastError (); - SetErrorMode (last); if (v == INVALID_FILE_ATTRIBUTES) return -1; if (!(v & FILE_ATTRIBUTE_DIRECTORY)) diff --git a/od-win32/ipctester.c b/od-win32/ipctester.c new file mode 100755 index 00000000..dcc45e53 --- /dev/null +++ b/od-win32/ipctester.c @@ -0,0 +1,95 @@ + +#include +#include +#include + +static char *pipename = "\\\\.\\pipe\\WinUAE"; + +static HANDLE p; +static volatile int threadmode_in; +static volatile int threadmode_out; + +static DWORD WINAPI readroutine(void *parm) +{ + char buf[4000]; + DWORD ret, avail; + + for (;;) { + Sleep(50); + if (!threadmode_in) + continue; + threadmode_out = 1; + if (!PeekNamedPipe(p, NULL, 0, NULL, &avail, NULL)) { + printf ("PeekNamedPipe() failed, err=%d\n", GetLastError()); + return 0; + } + if (avail > 0) { + if (!ReadFile(p, buf, sizeof buf, &ret, NULL)) { + printf ("ReadFile() failed, err=%d\n", GetLastError()); + return 0; + } + printf("%s\n", buf); + } + threadmode_out = 0; + } +} + +int main(int argc, char *argv[]) +{ + + DWORD mode; + DWORD tid; + + p = CreateFile( + pipename, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + OPEN_EXISTING, + 0, + NULL); + if (p == INVALID_HANDLE_VALUE) { + DWORD err = GetLastError(); + if (err == ERROR_PIPE_BUSY) { + printf ("Pipe '%s' busy\n", pipename); + return 0; + } + printf("Couldn't open pipe '%s' err=%d\n", pipename, err); + return 0; + } + printf("Connected to '%s'\n", pipename); + + mode = PIPE_READMODE_MESSAGE; + if (!SetNamedPipeHandleState(p, &mode, NULL, NULL)) { + printf("SetNamedPipeHandleState failed err=%d\n", GetLastError()); + return 0; + } + printf("ready\n"); + + if (CreateThread(NULL, 0, &readroutine, NULL, 0, &tid) == NULL) { + printf("Failed to create input thread\n"); + return 0; + } + threadmode_in = 1; + + for (;;) { + DWORD ret; + char inbuf[4000]; + inbuf[0] = 0; + fgets(inbuf, sizeof(inbuf), stdin); + if (strlen(inbuf) == 0 || inbuf[0] == 10) + break; + threadmode_in = 0; + while (threadmode_out) + Sleep(10); + if (!WriteFile(p, inbuf, strlen (inbuf) + 1, &ret, NULL)) { + printf("WriteFile() failed, err=%d\n", GetLastError()); + return 0; + } + threadmode_in = 1; + } + + return 0; +} + + diff --git a/od-win32/picasso96_win.c b/od-win32/picasso96_win.c index 8d042391..f53ba74a 100755 --- a/od-win32/picasso96_win.c +++ b/od-win32/picasso96_win.c @@ -1908,6 +1908,7 @@ uae_u32 picasso_SetGC (void) P96TRACE(("SetGC(%d,%d,%d,%d)\n", picasso96_state.Width, picasso96_state.Height, picasso96_state.GC_Depth, border )); set_gc_called = 1; + picasso96_state.HostAddress = NULL; init_picasso_screen (); init_hz_p96 (); return 1; diff --git a/od-win32/resources/resource.h b/od-win32/resources/resource.h index 1ba85593..27685d63 100755 --- a/od-win32/resources/resource.h +++ b/od-win32/resources/resource.h @@ -185,7 +185,7 @@ #define IDS_SOUND_INTERPOL_CRUX 205 #define IDS_SOUND_FILTER_OFF 206 #define IDS_SOUND_FILTER_EMULATED 207 -#define IDS_SOUND_FILTER_ON_A500 208 +#define IDS_SOUND_FILTER_EMULATED_E 208 #define IDS_INPUT_COMPATIBILITY 209 #define IDS_INPUT_CUSTOM 210 #define IDS_INPUT_COPY_DEFAULT 211 @@ -236,6 +236,7 @@ #define IDB_LCD160X43 252 #define IDS_SOUND_FILTER_ON_AGA 252 #define IDS_SOUND_FILTER_ON 253 +#define IDS_SOUND_FILTER_ON_A500 253 #define IDS_DRIVESOUND_PC_FLOPPY 254 #define IDS_NUMSG_NEEDEXT2 300 #define IDS_NUMSG_NOROMKEY 301 @@ -848,6 +849,7 @@ #define IDC_SCSIMODE2 1706 #define IDC_LANGUAGE 1706 #define IDC_CREATE_NAME 1707 +#define IDC_FILTERAUTORES 1708 #define ID__FLOPPYDRIVES 40004 #define ID_FLOPPYDRIVES_DF0 40005 #define ID_ST_CONFIGURATION 40010 @@ -868,7 +870,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 253 #define _APS_NEXT_COMMAND_VALUE 40021 -#define _APS_NEXT_CONTROL_VALUE 1708 +#define _APS_NEXT_CONTROL_VALUE 1709 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index 9a709255..306adb58 100755 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -194,7 +194,7 @@ BEGIN PUSHBUTTON "...",IDC_DF3,287,109,10,15 GROUPBOX "New Floppy Disk Image",IDC_SETTINGSTEXT,5,183,289,49 COMBOBOX IDC_FLOPPYTYPE,16,196,51,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Create Standard Disk [] Creates a standard 880 KB ADF disk image.",IDC_CREATE,76,196,97,15 + PUSHBUTTON "Create Standard Disk [] Creates a standard 880 or 1760 KB ADF disk image.",IDC_CREATE,76,196,97,15 PUSHBUTTON "Create Custom Disk [] Creates a low level (MFM) ADF disk image (about 2MB). Useful for programs that use non-standard disk formats (for example some save disks or DOS-formatted floppies)",IDC_CREATE_RAW,183,196,101,15 GROUPBOX "Floppy Drive Emulation Speed",IDC_SETTINGSTEXT2,5,144,289,35 CONTROL "",IDC_FLOPPYSPD,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,32,152,116,20 @@ -204,7 +204,7 @@ BEGIN PUSHBUTTON "Delete save image",IDC_SAVEIMAGE2,43,75,70,15,NOT WS_VISIBLE PUSHBUTTON "Delete save image",IDC_SAVEIMAGE3,43,110,70,15,NOT WS_VISIBLE EDITTEXT IDC_CREATE_NAME,75,215,98,13,ES_AUTOHSCROLL - RTEXT "Disk name:",IDC_STATIC,14,216,52,10,SS_CENTERIMAGE + RTEXT "Disk label:",IDC_STATIC,14,216,52,10,SS_CENTERIMAGE END IDD_HARDDISK DIALOGEX 0, 0, 300, 231 @@ -367,7 +367,7 @@ BEGIN CONTROL "bsdsocket.library emulation",IDC_SOCKETS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,15,120,10 CONTROL "Use CTRL-F11 to quit",IDC_CTRLF11,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,29,120,10 CONTROL "Don't use RGB overlays",IDC_NOOVERLAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,43,120,10 - CONTROL "Syncronize clock",IDC_CLOCKSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,70,115,10 + CONTROL "Synchronize clock",IDC_CLOCKSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,70,115,10 GROUPBOX "Keyboard LEDs",IDC_STATIC,7,125,85,94 COMBOBOX IDC_KBLED1,22,139,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_KBLED2,22,158,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -513,14 +513,14 @@ BEGIN CONTROL "Disable frame rate limit while recording",IDC_AVIOUTPUT_FRAMELIMITER, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,68,136,10 CONTROL "AVI output enabled",IDC_AVIOUTPUT_ACTIVATED,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,15,83,108,14 - CONTROL "PAL",IDC_AVIOUTPUT_PAL,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,133,83,66,12 - CONTROL "NTSC",IDC_AVIOUTPUT_NTSC,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,204,83,66,12 + CONTROL "PAL",IDC_AVIOUTPUT_PAL,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,133,83,66,14 + CONTROL "NTSC",IDC_AVIOUTPUT_NTSC,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,204,83,66,14 CONTROL "Slider1",IDC_AVIOUTPUT_FPS,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_ENABLESELRANGE | WS_TABSTOP,156,68,97,11 LTEXT "fps",IDC_AVIOUTPUT_FPS_STATIC,255,68,19,8 PUSHBUTTON "Save screenshot",IDC_SCREENSHOT,16,124,76,14 GROUPBOX "Ripper",IDC_STATIC,5,110,275,38 - PUSHBUTTON "Pro Wizard",IDC_PROWIZARD,100,123,76,14,WS_DISABLED - CONTROL "Sample ripper",IDC_SAMPLERIPPER_ACTIVATED,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,192,123,77,14 + PUSHBUTTON "Pro Wizard",IDC_PROWIZARD,100,124,76,14,WS_DISABLED + CONTROL "Sample ripper",IDC_SAMPLERIPPER_ACTIVATED,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,192,124,77,14 GROUPBOX "Input Recorder",IDC_STATIC,5,152,275,33 CONTROL "Record",IDC_INPREC_RECORD,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,191,164,77,14 CONTROL "Playback",IDC_INPREC_PLAY,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,16,165,77,14 @@ -552,11 +552,11 @@ BEGIN PUSHBUTTON "Swap 1<>2",IDC_INPUTSWAP,249,226,45,14 END -IDD_FILTER DIALOGEX 0, 0, 296, 216 +IDD_FILTER DIALOGEX 0, 0, 296, 224 STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - GROUPBOX "Filter Settings",-1,0,0,294,174 + GROUPBOX "Filter Settings",-1,0,0,294,186 CONTROL "Enable",IDC_FILTERENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,17,38,10 COMBOBOX IDC_FILTERMODE,67,15,56,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_FILTERFILTER,128,15,65,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP @@ -579,13 +579,14 @@ BEGIN COMBOBOX IDC_FILTERSLR,56,146,27,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP CONTROL "Slider1",IDC_FILTERSL2,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,94,146,157,19 EDITTEXT IDC_FILTERSL2V,253,151,34,12,ES_CENTER | ES_READONLY - GROUPBOX "Presets",-1,0,176,296,36 - COMBOBOX IDC_FILTERPRESETS,8,190,119,150,CBS_DROPDOWN | CBS_SORT | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Load",IDC_FILTERPRESETLOAD,132,189,47,14 - PUSHBUTTON "Save",IDC_FILTERPRESETSAVE,184,189,47,14 - PUSHBUTTON "Delete",IDC_FILTERPRESETDELETE,236,189,47,14 + GROUPBOX "Presets",-1,0,187,296,36 + COMBOBOX IDC_FILTERPRESETS,8,201,119,150,CBS_DROPDOWN | CBS_SORT | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Load",IDC_FILTERPRESETLOAD,132,200,47,14 + PUSHBUTTON "Save",IDC_FILTERPRESETSAVE,184,200,47,14 + PUSHBUTTON "Delete",IDC_FILTERPRESETDELETE,236,200,47,14 COMBOBOX IDC_FILTERHZMULT,77,43,27,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_FILTERVZMULT,77,63,27,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP + CONTROL "Autoscale",IDC_FILTERAUTORES,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,26,168,63,10 END IDD_HARDDRIVE DIALOGEX 0, 0, 300, 66 @@ -1071,12 +1072,12 @@ BEGIN IDS_SOUND_INTERPOL_RH "RH" IDS_SOUND_INTERPOL_CRUX "Crux" IDS_SOUND_FILTER_OFF "Always off" - IDS_SOUND_FILTER_EMULATED "Emulated" + IDS_SOUND_FILTER_EMULATED "Emulated (A500)" END STRINGTABLE BEGIN - IDS_SOUND_FILTER_ON_A500 "Always on (pre-AGA)" + IDS_SOUND_FILTER_EMULATED_E "Emulated (A1200)" IDS_INPUT_COMPATIBILITY "Compatibility mode" IDS_INPUT_CUSTOM "Configuration #%d" IDS_INPUT_COPY_DEFAULT "Default" @@ -1133,8 +1134,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" + IDS_SOUND_FILTER_ON_AGA "Always on (A500)" + IDS_SOUND_FILTER_ON_A500 "Always on (A1200)" IDS_DRIVESOUND_PC_FLOPPY "PC floppy drive %c" END diff --git a/od-win32/sounddep/sound.c b/od-win32/sounddep/sound.c index 8d04acd6..09e1ae80 100755 --- a/od-win32/sounddep/sound.c +++ b/od-win32/sounddep/sound.c @@ -179,7 +179,7 @@ static int calibrate (void) { int len = 1000; int pos, lastpos, tpos, expected, diff; - int mult = currprefs.sound_stereo ? 4 : 2; + int mult = (currprefs.sound_stereo == 2) ? 8 : (currprefs.sound_stereo ? 4 : 2); double qv, pct; if (!QueryPerformanceFrequency(&qpf)) { @@ -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 == FILTER_SOUND_ON_A500 || currprefs.sound_filter == FILTER_SOUND_ON_A1200) { + if (gui_data.powerled || currprefs.sound_filter == FILTER_SOUND_ON) { if (ch == 1) { old0 = cold[0]; for (i = 0; i < len; i++) { diff --git a/od-win32/sounddep/sound.h b/od-win32/sounddep/sound.h index 9ab75076..d94a3a06 100755 --- a/od-win32/sounddep/sound.h +++ b/od-win32/sounddep/sound.h @@ -34,9 +34,9 @@ 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) do { if (currprefs.sound_filter) b = filter (b, l_output); PUT_SOUND_WORD(b); } while (0) +#define PUT_SOUND_WORD_LEFT(b) do { if (currprefs.sound_filter) b = filter (b, &sound_filter_state[0]); PUT_SOUND_WORD(b); } while (0) #define PUT_SOUND_BYTE_RIGHT(b) PUT_SOUND_BYTE(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_RIGHT(b) do { if (currprefs.sound_filter) b = filter (b, &sound_filter_state[1]); 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 @@ -49,8 +49,10 @@ static __inline__ void check_sound_buffers (void) #define FILTER_SOUND_OFF 0 #define FILTER_SOUND_EMUL 1 -#define FILTER_SOUND_ON_A500 2 -#define FILTER_SOUND_ON_A1200 3 +#define FILTER_SOUND_ON 2 + +#define FILTER_SOUND_TYPE_A500 0 +#define FILTER_SOUND_TYPE_A1200 1 #ifdef AHI #include "ahidsound.h" diff --git a/od-win32/win32.c b/od-win32/win32.c index 6314388b..ebbd1943 100755 --- a/od-win32/win32.c +++ b/od-win32/win32.c @@ -64,6 +64,7 @@ #include "disk.h" #include "catweasel.h" #include "lcd.h" +#include "uaeipc.h" extern FILE *debugfile; extern int console_logging; @@ -1143,11 +1144,13 @@ void handle_events (void) inputdevicefunc_joystick.read(); inputdevice_handle_inputcode (); check_prefs_changed_gfx (); + while (checkIPC(&currprefs)); } while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage (&msg); DispatchMessage (&msg); } + while (checkIPC(&currprefs)); if (was_paused) { init_sound (); #ifdef AHI @@ -1254,7 +1257,11 @@ int WIN32_CleanupLibraries( void ) /* HtmlHelp Initialization - optional component */ int WIN32_InitHtmlHelp( void ) { + char *chm = "WinUAE.chm"; int result = 0; + sprintf(help_file, "%s%s", start_path_data, chm); + if (!zfile_exists (help_file)) + sprintf(help_file, "%s%s", start_path_exe, chm); if (zfile_exists (help_file)) { if (hHtmlHelp = LoadLibrary("HHCTRL.OCX")) { pHtmlHelp = (HWND(WINAPI *)(HWND, LPCSTR, UINT, LPDWORD))GetProcAddress(hHtmlHelp, "HtmlHelpA"); @@ -1799,7 +1806,10 @@ void set_path (char *name, char *path) char tmp[MAX_DPATH]; if (!path) { - strcpy (tmp, start_path_data); + if (!strcmp (start_path_data, start_path_exe)) + strcpy (tmp, ".\\"); + else + strcpy (tmp, start_path_data); if (!strcmp (name, "KickstartPath")) strcat (tmp, "Roms"); if (!strcmp (name, "ConfigurationPath")) @@ -1818,8 +1828,12 @@ void set_path (char *name, char *path) strip_slashes (tmp); if (!strcmp (name, "KickstartPath")) { DWORD v = GetFileAttributes (tmp); - if (v == INVALID_FILE_ATTRIBUTES || !(v & FILE_ATTRIBUTE_DIRECTORY)) - strcpy (tmp, start_path_data); + if (v == INVALID_FILE_ATTRIBUTES || !(v & FILE_ATTRIBUTE_DIRECTORY)) { + if (!strcmp (start_path_data, start_path_exe)) + strcpy (tmp, ".\\"); + else + strcpy (tmp, start_path_data); + } if (af_path_2005) { strcpy (tmp, start_path_af); strcat (tmp, "System\\rom"); @@ -2303,7 +2317,6 @@ static void getstartpaths(int start_data) fixtrailing(start_path_data); } - extern void test (void); extern int screenshotmode; @@ -2371,7 +2384,6 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR argv[0] = 0; #endif getstartpaths(start_data); - sprintf(help_file, "%sWinUAE.chm", start_path_data); sprintf(VersionStr, "WinUAE %d.%d.%d%s (%d-bit)", UAEMAJOR, UAEMINOR, UAESUBREV, WINUAEBETA ? WINUAEBETASTR : "", #if defined(WIN64) @@ -2417,9 +2429,12 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR #ifdef PARALLEL_PORT paraport_mask = paraport_init (); #endif + createIPC(); real_main (argc, argv); } - + + closeIPC(); + write_disk_history (); if (mm_timerres && timermode == 0) timeend (); #ifdef AVIOUTPUT @@ -2434,9 +2449,9 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR #endif WIN32_CleanupLibraries(); _fcloseall(); - if( hWinUAEKey ) - RegCloseKey( hWinUAEKey ); - CloseHandle( hMutex ); + if(hWinUAEKey) + RegCloseKey(hWinUAEKey); + CloseHandle(hMutex); #ifdef _DEBUG // show memory leaks //_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); diff --git a/od-win32/win32.h b/od-win32/win32.h index 561ee344..36d51b09 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 1" +#define WINUAEBETASTR " Beta 2" extern char start_path_exe[MAX_DPATH]; extern char start_path_data[MAX_DPATH]; diff --git a/od-win32/win32gfx.c b/od-win32/win32gfx.c index edc2f6fa..41193b2f 100755 --- a/od-win32/win32gfx.c +++ b/od-win32/win32gfx.c @@ -89,6 +89,7 @@ GUID *displayGUID; static struct winuae_currentmode currentmodestruct; static int screen_is_initialized; int display_change_requested, normal_display_change_starting; +int window_led_drives, window_led_drives_end; extern int console_logging; #define SM_WINDOW 0 @@ -991,8 +992,8 @@ static int open_windows (void) currentmode->frequency = abs (currprefs.gfx_refreshrate > default_freq ? currprefs.gfx_refreshrate : default_freq); } else { #endif - currentmode->current_width = currprefs.gfx_width; - currentmode->current_height = currprefs.gfx_height; + currentmode->current_width = currprefs.gfx_size.width; + currentmode->current_height = currprefs.gfx_size.height; currentmode->current_depth = (currprefs.color_mode == 0 ? 8 : currprefs.color_mode == 1 ? 15 : currprefs.color_mode == 2 ? 16 @@ -1021,62 +1022,75 @@ int check_prefs_changed_gfx (void) { int c = 0; - if (normal_display_change_starting > 0 && normal_display_change_starting < 4) - normal_display_change_starting--; - - c |= currprefs.gfx_width_fs != changed_prefs.gfx_width_fs ? 1 : 0; - c |= currprefs.gfx_height_fs != changed_prefs.gfx_height_fs ? 1 : 0; - c |= currprefs.gfx_width_win != changed_prefs.gfx_width_win ? 2 : 0; - c |= currprefs.gfx_height_win != changed_prefs.gfx_height_win ? 2 : 0; - c |= currprefs.color_mode != changed_prefs.color_mode ? 1 : 0; - c |= currprefs.gfx_afullscreen != changed_prefs.gfx_afullscreen ? 2 : 0; - c |= currprefs.gfx_pfullscreen != changed_prefs.gfx_pfullscreen ? 2 : 0; - c |= currprefs.gfx_vsync != changed_prefs.gfx_vsync ? 2 : 0; - c |= currprefs.gfx_refreshrate != changed_prefs.gfx_refreshrate ? 1 : 0; - c |= currprefs.gfx_filter != changed_prefs.gfx_filter ? 1 : 0; - c |= currprefs.gfx_filter_filtermode != changed_prefs.gfx_filter_filtermode ? 1 : 0; + c |= currprefs.gfx_size_fs.width != changed_prefs.gfx_size_fs.width ? (1|8) : 0; + c |= currprefs.gfx_size_fs.height != changed_prefs.gfx_size_fs.height ? (1|8) : 0; + c |= currprefs.gfx_size_win.width != changed_prefs.gfx_size_win.width ? (2|8) : 0; + c |= currprefs.gfx_size_win.height != changed_prefs.gfx_size_win.height ? (2|8) : 0; + c |= currprefs.color_mode != changed_prefs.color_mode ? (1|8) : 0; + c |= currprefs.gfx_afullscreen != changed_prefs.gfx_afullscreen ? (2|8) : 0; + c |= currprefs.gfx_pfullscreen != changed_prefs.gfx_pfullscreen ? (2|8) : 0; + c |= currprefs.gfx_vsync != changed_prefs.gfx_vsync ? (2|4|8) : 0; + c |= currprefs.gfx_refreshrate != changed_prefs.gfx_refreshrate ? (1|4|8) : 0; + c |= currprefs.gfx_autoresolution != changed_prefs.gfx_autoresolution ? (1|8) : 0; + + c |= currprefs.gfx_filter != changed_prefs.gfx_filter ? (1|8) : 0; + c |= currprefs.gfx_filter_filtermode != changed_prefs.gfx_filter_filtermode ? (1|8) : 0; + c |= currprefs.gfx_filter_horiz_zoom_mult != changed_prefs.gfx_filter_horiz_zoom_mult ? (1|8) : 0; + c |= currprefs.gfx_filter_vert_zoom_mult != changed_prefs.gfx_filter_vert_zoom_mult ? (1|8) : 0; + c |= currprefs.gfx_lores != changed_prefs.gfx_lores ? 1 : 0; - c |= currprefs.gfx_lores_mode != changed_prefs.gfx_lores_mode ? 1 : 0; c |= currprefs.gfx_linedbl != changed_prefs.gfx_linedbl ? 1 : 0; + c |= currprefs.gfx_lores_mode != changed_prefs.gfx_lores_mode ? 1 : 0; c |= currprefs.gfx_display != changed_prefs.gfx_display ? 1 : 0; c |= currprefs.win32_alwaysontop != changed_prefs.win32_alwaysontop ? 1 : 0; c |= currprefs.win32_borderless != changed_prefs.win32_borderless ? 1 : 0; c |= currprefs.win32_no_overlay != changed_prefs.win32_no_overlay ? 1 : 0; + if (display_change_requested || c) { + cfgfile_configuration_change(1); if (!display_change_requested) normal_display_change_starting = 4; display_change_requested = 0; fixup_prefs_dimensions (&changed_prefs); - currprefs.gfx_width_win = changed_prefs.gfx_width_win; - currprefs.gfx_height_win = changed_prefs.gfx_height_win; - currprefs.gfx_width_fs = changed_prefs.gfx_width_fs; - currprefs.gfx_height_fs = changed_prefs.gfx_height_fs; + currprefs.gfx_size_fs.width = changed_prefs.gfx_size_fs.width; + currprefs.gfx_size_fs.height = changed_prefs.gfx_size_fs.height; + currprefs.gfx_size_win.width = changed_prefs.gfx_size_win.width; + currprefs.gfx_size_win.height = changed_prefs.gfx_size_win.height; currprefs.color_mode = changed_prefs.color_mode; currprefs.gfx_afullscreen = changed_prefs.gfx_afullscreen; currprefs.gfx_pfullscreen = changed_prefs.gfx_pfullscreen; updatewinfsmode (&currprefs); currprefs.gfx_vsync = changed_prefs.gfx_vsync; currprefs.gfx_refreshrate = changed_prefs.gfx_refreshrate; + currprefs.gfx_autoresolution = changed_prefs.gfx_autoresolution; + currprefs.gfx_filter = changed_prefs.gfx_filter; currprefs.gfx_filter_filtermode = changed_prefs.gfx_filter_filtermode; - currprefs.gfx_lores = changed_prefs.gfx_lores; + currprefs.gfx_filter_horiz_zoom_mult = changed_prefs.gfx_filter_horiz_zoom_mult; + currprefs.gfx_filter_vert_zoom_mult = changed_prefs.gfx_filter_vert_zoom_mult; + currprefs.gfx_lores_mode = changed_prefs.gfx_lores_mode; + currprefs.gfx_lores = changed_prefs.gfx_lores; currprefs.gfx_linedbl = changed_prefs.gfx_linedbl; currprefs.gfx_display = changed_prefs.gfx_display; currprefs.win32_alwaysontop = changed_prefs.win32_alwaysontop; currprefs.win32_borderless = changed_prefs.win32_borderless; currprefs.win32_no_overlay = changed_prefs.win32_no_overlay; - inputdevice_unacquire (); - close_windows (); - graphics_init (); -#ifdef PICASSO96 - DX_SetPalette (0, 256); -#endif - init_custom (); - pause_sound (); - resume_sound (); - inputdevice_acquire (); + + if (c & 8) { + inputdevice_unacquire (); + close_windows (); + graphics_init (); + } + init_custom (); + if (c & 4) { + pause_sound (); + resume_sound (); + } + if (c & 8) { + inputdevice_acquire (); + } return 1; } @@ -1727,6 +1741,8 @@ static void createstatuswindow (void) lpParts[7] = lpParts[6] + drive_width; lpParts[8] = lpParts[7] + drive_width; lpParts[9] = lpParts[8] + drive_width; + window_led_drives = lpParts[5]; + window_led_drives_end = lpParts[9]; /* Create the parts */ SendMessage (hStatusWnd, SB_SETPARTS, (WPARAM) num_parts, (LPARAM) lpParts); @@ -1750,6 +1766,8 @@ static int create_windows (void) int gap = 3; int x, y; + window_led_drives = 0; + window_led_drives_end = 0; hMainWnd = NULL; x = 2; y = 2; if (borderless) @@ -2275,11 +2293,9 @@ void updatewinfsmode (struct uae_prefs *p) fixup_prefs_dimensions (p); if (p->gfx_afullscreen) { - p->gfx_width = p->gfx_width_fs; - p->gfx_height = p->gfx_height_fs; + p->gfx_size = p->gfx_size_fs; } else { - p->gfx_width = p->gfx_width_win; - p->gfx_height = p->gfx_height_win; + p->gfx_size = p->gfx_size_win; } displayGUID = NULL; i = 0; diff --git a/od-win32/win32gfx.h b/od-win32/win32gfx.h index d605dea5..a3c9d721 100755 --- a/od-win32/win32gfx.h +++ b/od-win32/win32gfx.h @@ -31,6 +31,7 @@ extern HWND hStatusWnd; extern HINSTANCE hDDraw; extern uae_u32 default_freq; extern int normal_display_change_starting; +extern int window_led_drives, window_led_drives_end; extern HDC gethdc (void); extern void releasehdc (HDC hdc); diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index 8f481bbb..3ea62ac0 100755 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -70,10 +70,11 @@ #endif #include "catweasel.h" #include "lcd.h" +#include "uaeipc.h" -#define DISK_FORMAT_STRING "(*.adf;*.adz;*.gz;*.dms;*.fdi;*.ipf;*.zip;*.rar;*.7z;*.exe)\0*.adf;*.adz;*.gz;*.dms;*.fdi;*.ipf;*.zip;*.rar;*.7z;*.exe\0" -#define ROM_FORMAT_STRING "(*.rom;*.zip;*.rar;*.7z;*.roz)\0*.rom;*.zip;*.rar;*.7z;*.roz\0" -#define USS_FORMAT_STRING_RESTORE "(*.uss;*.gz;*.zip)\0*.uss;*.gz;*.zip\0" +#define DISK_FORMAT_STRING "(*.adf;*.adz;*.gz;*.dms;*.fdi;*.ipf;*.exe)\0*.adf;*.adz;*.gz;*.dms;*.fdi;*.ipf;*.zip;*.rar;*.7z;*.exe;*.ima\0" +#define ROM_FORMAT_STRING "(*.rom;*.roz)\0*.rom;*.zip;*.rar;*.7z;*.roz\0" +#define USS_FORMAT_STRING_RESTORE "(*.uss)\0*.uss;*.gz;*.zip;*.rar;*.7z\0" #define USS_FORMAT_STRING_SAVE "(*.uss)\0*.uss\0" #define HDF_FORMAT_STRING "(*.hdf;*.rdf;*.hdz;*.rdz)\0*.hdf;*.rdf;*.hdz;*.rdz\0" #define INP_FORMAT_STRING "(*.inp)\0*.inp\0" @@ -678,10 +679,10 @@ static int gui_width = 640, gui_height = 480; static int mm = 0; static void m(void) { - write_log ("%d:0: %dx%d %dx%d %dx%d\n", mm, currprefs.gfx_width, currprefs.gfx_height, - workprefs.gfx_width, workprefs.gfx_height, changed_prefs.gfx_width, changed_prefs.gfx_height); - write_log ("%d:1: %dx%d %dx%d %dx%d\n", mm, currprefs.gfx_width_fs, currprefs.gfx_height_fs, - workprefs.gfx_width_fs, workprefs.gfx_height_fs, changed_prefs.gfx_width_fs, changed_prefs.gfx_height_fs); + write_log ("%d:0: %dx%d %dx%d %dx%d\n", mm, currprefs.gfx_size.width, currprefs.gfx_size.height, + workprefs.gfx_size.width, workprefs.gfx_size.height, changed_prefs.gfx_size.width, changed_prefs.gfx_size.height); + write_log ("%d:1: %dx%d %dx%d %dx%d\n", mm, currprefs.gfx_size_fs.width, currprefs.gfx_size_fs.height, + workprefs.gfx_size_fs.width, workprefs.gfx_size_fs.height, changed_prefs.gfx_size_fs.width, changed_prefs.gfx_size_fs.height); mm++; } @@ -710,7 +711,7 @@ void gui_display(int shortcut) pause_sound (); setmouseactive (0); - if ((!WIN32GFX_IsPicassoScreen() && currprefs.gfx_afullscreen && (currprefs.gfx_width < gui_width || currprefs.gfx_height < gui_height)) + if ((!WIN32GFX_IsPicassoScreen() && currprefs.gfx_afullscreen && (currprefs.gfx_size.width < gui_width || currprefs.gfx_size.height < gui_height)) #ifdef PICASSO96 || (WIN32GFX_IsPicassoScreen() && currprefs.gfx_pfullscreen && (picasso96_state.Width < gui_width || picasso96_state.Height < gui_height)) #endif @@ -3281,7 +3282,7 @@ static void enable_for_displaydlg (HWND hDlg) rtg = FALSE; #endif EnableWindow (GetDlgItem (hDlg, IDC_PFULLSCREEN), rtg); - if (! full_property_sheet) { + if (!full_property_sheet) { /* Disable certain controls which are only to be set once at start-up... */ EnableWindow (GetDlgItem (hDlg, IDC_TEST16BIT), FALSE); } else { @@ -3292,6 +3293,10 @@ static void enable_for_displaydlg (HWND hDlg) } EnableWindow (GetDlgItem (hDlg, IDC_FRAMERATE2), !workprefs.gfx_vsync); EnableWindow (GetDlgItem (hDlg, IDC_FRAMERATE), !workprefs.cpu_cycle_exact); + EnableWindow (GetDlgItem (hDlg, IDC_LORES), !workprefs.gfx_autoresolution); + EnableWindow (GetDlgItem (hDlg, IDC_LM_NORMAL), !workprefs.gfx_autoresolution); + EnableWindow (GetDlgItem (hDlg, IDC_LM_DOUBLED), !workprefs.gfx_autoresolution); + EnableWindow (GetDlgItem (hDlg, IDC_LM_SCANLINES), !workprefs.gfx_autoresolution); } static void enable_for_chipsetdlg (HWND hDlg) @@ -3536,7 +3541,7 @@ static void init_display_mode (HWND hDlg) if (workprefs.gfx_afullscreen) { d2 = d; - if ((index = WIN32GFX_AdjustScreenmode(&workprefs.gfx_width_fs, &workprefs.gfx_height_fs, &d2)) >= 0) + if ((index = WIN32GFX_AdjustScreenmode(&workprefs.gfx_size_fs.width, &workprefs.gfx_size_fs.height, &d2)) >= 0) { switch (d2) { @@ -3564,7 +3569,7 @@ static void init_display_mode (HWND hDlg) d = d / 8; } - if ((index = display_mode_index (workprefs.gfx_width_fs, workprefs.gfx_height_fs, d)) >= 0) { + if ((index = display_mode_index (workprefs.gfx_size_fs.width, workprefs.gfx_size_fs.height, d)) >= 0) { int i, cnt; SendDlgItemMessage (hDlg, IDC_RESOLUTION, CB_SETCURSEL, DisplayModes[index].residx, 0); SendDlgItemMessage(hDlg, IDC_RESOLUTIONDEPTH, CB_RESETCONTENT, 0, 0); @@ -3595,8 +3600,8 @@ static void values_to_displaydlg (HWND hDlg) init_display_mode (hDlg); - SetDlgItemInt (hDlg, IDC_XSIZE, workprefs.gfx_width_win, FALSE); - SetDlgItemInt (hDlg, IDC_YSIZE, workprefs.gfx_height_win, FALSE); + SetDlgItemInt (hDlg, IDC_XSIZE, workprefs.gfx_size_win.width, FALSE); + SetDlgItemInt (hDlg, IDC_YSIZE, workprefs.gfx_size_win.height, FALSE); v = workprefs.chipset_refreshrate; if (v == 0) @@ -3670,8 +3675,8 @@ static void values_from_displaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l { BOOL success = FALSE; int i, j; - int gfx_width = workprefs.gfx_width_win; - int gfx_height = workprefs.gfx_height_win; + int gfx_width = workprefs.gfx_size_win.width; + int gfx_height = workprefs.gfx_size_win.height; workprefs.gfx_pfullscreen = IsDlgButtonChecked (hDlg, IDC_PFULLSCREEN); workprefs.gfx_afullscreen = IsDlgButtonChecked (hDlg, IDC_AFULLSCREEN); @@ -3708,12 +3713,12 @@ static void values_from_displaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l } sprintf (buffer, "%d", workprefs.chipset_refreshrate); SetDlgItemText (hDlg, IDC_RATE2TEXT, buffer); - workprefs.gfx_width_win = GetDlgItemInt( hDlg, IDC_XSIZE, &success, FALSE ); - if( !success ) - workprefs.gfx_width_win = 800; - workprefs.gfx_height_win = GetDlgItemInt( hDlg, IDC_YSIZE, &success, FALSE ); - if( !success ) - workprefs.gfx_height_win = 600; + workprefs.gfx_size_win.width = GetDlgItemInt( hDlg, IDC_XSIZE, &success, FALSE ); + if(!success) + workprefs.gfx_size_win.width = 800; + workprefs.gfx_size_win.height = GetDlgItemInt( hDlg, IDC_YSIZE, &success, FALSE ); + if(!success) + workprefs.gfx_size_win.height = 600; } if (workprefs.chipset_refreshrate == (currprefs.ntscmode ? 60 : 50)) workprefs.chipset_refreshrate = 0; @@ -3755,8 +3760,8 @@ static void values_from_displaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l } if (DisplayModes[i].residx != posn1) i = j; - workprefs.gfx_width_fs = DisplayModes[i].res.width; - workprefs.gfx_height_fs = DisplayModes[i].res.height; + workprefs.gfx_size_fs.width = DisplayModes[i].res.width; + workprefs.gfx_size_fs.height = DisplayModes[i].res.height; switch(DisplayModes[i].depth) { case 2: @@ -3771,8 +3776,8 @@ static void values_from_displaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l break; } /* Set the Int boxes */ - SetDlgItemInt (hDlg, IDC_XSIZE, workprefs.gfx_width_win, FALSE); - SetDlgItemInt (hDlg, IDC_YSIZE, workprefs.gfx_height_win, FALSE); + SetDlgItemInt (hDlg, IDC_XSIZE, workprefs.gfx_size_win.width, FALSE); + SetDlgItemInt (hDlg, IDC_YSIZE, workprefs.gfx_size_win.height, FALSE); init_frequency_combo (hDlg, i); } else if (LOWORD (wParam) == IDC_REFRESHRATE) { LRESULT posn1, posn2; @@ -4431,6 +4436,7 @@ static void misc_scsi(HWND hDlg) SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((os_winnt && os_winnt_admin) ? "SPTI + SCSI SCAN" : "(SPTI + SCSI SCAN)")); SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path(0)) ? "AdaptecASPI" : "(AdaptecASPI)")); SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path(1)) ? "NeroASPI" : "(NeroASPI)")); + SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path(2)) ? "FrogASPI" : "(FrogASPI)")); SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_SETCURSEL, workprefs.win32_uaescsimode, 0); } @@ -5116,13 +5122,26 @@ 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 (workprefs.sound_freq == 44100 ? IDS_SOUND_FILTER_ON_A500 : IDS_SOUND_FILTER_ON, txt, sizeof (txt)); + WIN32GUI_LoadUIString (IDS_SOUND_FILTER_EMULATED_E, 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); + WIN32GUI_LoadUIString (IDS_SOUND_FILTER_ON_AGA, txt, sizeof (txt)); + SendDlgItemMessage(hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt); + WIN32GUI_LoadUIString (IDS_SOUND_FILTER_ON_A500, txt, sizeof (txt)); + SendDlgItemMessage(hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt); + i = 0; + switch (workprefs.sound_filter) + { + case 0: + i = 0; + break; + case 1: + i = workprefs.sound_filter_type ? 2 : 1; + break; + case 2: + i = workprefs.sound_filter_type ? 4 : 3; + break; } - SendDlgItemMessage(hDlg, IDC_SOUNDFILTER, CB_SETCURSEL, workprefs.sound_filter, 0 ); + SendDlgItemMessage(hDlg, IDC_SOUNDFILTER, CB_SETCURSEL, i, 0 ); SendDlgItemMessage(hDlg, IDC_SOUNDSTEREO, CB_RESETCONTENT, 0, 0); WIN32GUI_LoadUIString (IDS_SOUND_MONO, txt, sizeof (txt)); @@ -5161,6 +5180,8 @@ static void values_to_sounddlg (HWND hDlg) SendDlgItemMessage(hDlg, IDC_SOUNDINTERPOLATION, CB_RESETCONTENT, 0, 0); WIN32GUI_LoadUIString (IDS_SOUND_INTERPOL_DISABLED, txt, sizeof (txt)); SendDlgItemMessage(hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)txt); + SendDlgItemMessage(hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)"Anti"); + SendDlgItemMessage(hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)"Sinc"); WIN32GUI_LoadUIString (IDS_SOUND_INTERPOL_RH, txt, sizeof (txt)); SendDlgItemMessage(hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)txt); WIN32GUI_LoadUIString (IDS_SOUND_INTERPOL_CRUX, txt, sizeof (txt)); @@ -5247,7 +5268,7 @@ static void values_to_sounddlg (HWND hDlg) static void values_from_sounddlg (HWND hDlg) { - char txt[6]; + char txt[10]; LRESULT idx; idx = SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, CB_GETCURSEL, 0, 0); @@ -5284,7 +5305,28 @@ static void values_from_sounddlg (HWND hDlg) workprefs.sound_interpol = SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_GETCURSEL, 0, 0); workprefs.win32_soundcard = SendDlgItemMessage (hDlg, IDC_SOUNDCARDLIST, CB_GETCURSEL, 0, 0L); - workprefs.sound_filter = SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_GETCURSEL, 0, 0); + switch (SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_GETCURSEL, 0, 0)) + { + case 0: + workprefs.sound_filter = FILTER_SOUND_OFF; + break; + case 1: + workprefs.sound_filter = FILTER_SOUND_EMUL; + workprefs.sound_filter_type = 0; + break; + case 2: + workprefs.sound_filter = FILTER_SOUND_EMUL; + workprefs.sound_filter_type = 1; + break; + case 3: + workprefs.sound_filter = FILTER_SOUND_ON; + workprefs.sound_filter_type = 0; + break; + case 4: + workprefs.sound_filter = FILTER_SOUND_ON; + workprefs.sound_filter_type = 1; + break; + } workprefs.sound_stereo_swap_paula = (SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_GETCURSEL, 0, 0) & 1) ? 1 : 0; workprefs.sound_stereo_swap_ahi = (SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_GETCURSEL, 0, 0) & 2) ? 1 : 0; @@ -6034,6 +6076,36 @@ static INT_PTR CALLBACK HarddiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA #endif +void write_disk_history (void) +{ + int i, j; + char tmp[16]; + HKEY fkey; + + if (!hWinUAEKey) + return; + RegCreateKeyEx(hWinUAEKey , "DiskImageMRUList", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_READ | KEY_WRITE, NULL, &fkey, NULL); + if (fkey == NULL) + return; + j = 1; + for (i = 0; i < 100; i++) { + char *s = DISK_history_get(i); + if (s == 0 || strlen(s) == 0) + continue; + sprintf (tmp, "Image%02d", j); + RegSetValueEx (fkey, tmp, 0, REG_SZ, (CONST BYTE *)s, strlen(s) + 1); + j++; + } + while (j < 100) { + char *s = ""; + sprintf (tmp, "Image%02d", j); + RegSetValueEx (fkey, tmp, 0, REG_SZ, (CONST BYTE *)s, strlen(s) + 1); + j++; + } + RegCloseKey(fkey); +} + HKEY read_disk_history (void) { static int regread; @@ -6126,7 +6198,6 @@ static void addfloppyhistory (HWND hDlg, HKEY fkey, int n, int f_text) { int i, j; char *s; - char tmp[MAX_DPATH]; int nn = workprefs.dfxtype[n] + 1; if (f_text < 0) @@ -6136,9 +6207,9 @@ static void addfloppyhistory (HWND hDlg, HKEY fkey, int n, int f_text) i = 0; while (s = DISK_history_get (i)) { char tmpname[MAX_DPATH], tmppath[MAX_DPATH], *p, *p2; + if (strlen(s) == 0) + break; i++; - if (strlen (s) == 0) - continue; strcpy (tmppath, s); p = tmppath + strlen(tmppath) - 1; for (j = 0; archive_extensions[j]; j++) { @@ -6162,10 +6233,6 @@ static void addfloppyhistory (HWND hDlg, HKEY fkey, int n, int f_text) } if (f_text >= 0) SendDlgItemMessage (hDlg, f_text, CB_ADDSTRING, 0, (LPARAM)tmpname); - if (fkey) { - sprintf (tmp, "Image%02d", i); - RegSetValueEx (fkey, tmp, 0, REG_SZ, (CONST BYTE *)s, strlen(s) + 1); - } if (!strcmp (workprefs.df[n], s)) { if (f_text >= 0) SendDlgItemMessage (hDlg, f_text, CB_SETCURSEL, i - 1, 0); @@ -7636,6 +7703,7 @@ static void enable_for_hw3ddlg (HWND hDlg) EnableWindow (GetDlgItem (hDlg, IDC_FILTERSL2), vv2); EnableWindow (GetDlgItem (hDlg, IDC_FILTERDEFAULT), v); EnableWindow (GetDlgItem (hDlg, IDC_FILTERFILTER), vv); + EnableWindow (GetDlgItem (hDlg, IDC_FILTERAUTORES), vv && !vv2); EnableWindow (GetDlgItem (hDlg, IDC_FILTERPRESETLOAD), filterpreset > 0); EnableWindow (GetDlgItem (hDlg, IDC_FILTERPRESETDELETE), filterpreset > 0); @@ -7982,6 +8050,9 @@ static INT_PTR CALLBACK hw3dDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l case IDC_FILTERENABLE: filter_handle (hDlg); break; + case IDC_FILTERAUTORES: + workprefs.gfx_autoresolution = IsDlgButtonChecked (hDlg, IDC_FILTERAUTORES); + break; default: if (HIWORD (wParam) == CBN_SELCHANGE || HIWORD (wParam) == CBN_KILLFOCUS) { switch (LOWORD (wParam)) @@ -8045,7 +8116,7 @@ static void values_to_avioutputdlg(HWND hDlg) sprintf(tmpstr, "%d fps", avioutput_fps); SendMessage(GetDlgItem(hDlg, IDC_AVIOUTPUT_FPS_STATIC), WM_SETTEXT, (WPARAM) 0, (LPARAM) tmpstr); - sprintf(tmpstr, "Actual: %d x %d", workprefs.gfx_width, workprefs.gfx_height); + sprintf(tmpstr, "Actual: %d x %d", workprefs.gfx_size.width, workprefs.gfx_size.height); SendMessage(GetDlgItem(hDlg, IDC_AVIOUTPUT_DIMENSIONS_STATIC), WM_SETTEXT, (WPARAM) 0, (LPARAM) tmpstr); switch(avioutput_fps) @@ -8202,7 +8273,7 @@ static INT_PTR CALLBACK AVIOutputDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPA break; #endif case IDC_SAMPLERIPPER_ACTIVATED: - sampleripper_enabled = sampleripper_enabled ? 0 : 1; + sampleripper_enabled = !sampleripper_enabled; audio_sampleripper(-1); break; @@ -8724,7 +8795,7 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage) char file[MAX_DPATH]; int dfxtext[] = { IDC_DF0TEXT, IDC_DF0TEXTQ, IDC_DF1TEXT, IDC_DF1TEXTQ, IDC_DF2TEXT, -1, IDC_DF3TEXT, -1 }; POINT pt; - RECT r; + RECT r, r2; int ret = 0; DWORD flags; @@ -8734,7 +8805,18 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage) if (!cnt) return 0; drv = 0; - if (currentpage == FLOPPY_ID || currentpage == QUICKSTART_ID) { + if (currentpage < 0) { + GetClientRect(hMainWnd, &r2); + GetClientRect(hStatusWnd, &r); + if (pt.y >= r2.bottom && pt.y < r2.bottom + r.bottom) { + if (pt.x >= window_led_drives && pt.x < window_led_drives_end && window_led_drives > 0) { + drv = pt.x - window_led_drives; + drv /= (window_led_drives_end - window_led_drives) / 4; + if (drv < 0 || drv > 3) + drv = 0; + } + } + } else if (currentpage == FLOPPY_ID || currentpage == QUICKSTART_ID) { for (i = 0; i < 4; i++) { int id = dfxtext[i * 2 + (currentpage == QUICKSTART_ID ? 1 : 0)]; if (workprefs.dfxtype[i] >= 0 && id >= 0) { @@ -8779,7 +8861,7 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage) } } else { strcpy (workprefs.df[drv], file); - disk_insert (drv, file); + strcpy (changed_prefs.df[drv], workprefs.df[drv]); drv++; if (drv >= (currentpage == QUICKSTART_ID ? 2 : 4)) drv = 0; @@ -9027,21 +9109,31 @@ static int GetSettings (int all_options, HWND hwnd) MSG msg; DWORD v; ShowWindow (dhwnd, SW_SHOW); - while ((v = GetMessage (&msg, NULL, 0, 0))) { - if (dialogreturn >= 0) - break; - if (v == -1) - continue; - if (!IsWindow (dhwnd)) - continue; - if (hAccelTable && panelDlg) { - if (TranslateAccelerator (panelDlg, hAccelTable, &msg)) + for (;;) { + HANDLE IPChandle; + IPChandle = geteventhandleIPC(); + if (IPChandle != INVALID_HANDLE_VALUE) { + MsgWaitForMultipleObjects (1, &IPChandle, FALSE, INFINITE, QS_ALLINPUT); + while (checkIPC(&workprefs)); + } + while ((v = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))) { + if (dialogreturn >= 0) + break; + if (v == -1) + continue; + if (!IsWindow (dhwnd)) + continue; + if (hAccelTable && panelDlg) { + if (TranslateAccelerator (panelDlg, hAccelTable, &msg)) + continue; + } + if (IsDialogMessage (dhwnd, &msg)) continue; + TranslateMessage (&msg); + DispatchMessage (&msg); } - if (IsDialogMessage (dhwnd, &msg)) - continue; - TranslateMessage (&msg); - DispatchMessage (&msg); + if (dialogreturn >= 0) + break; } psresult = dialogreturn; } diff --git a/od-win32/win32gui.h b/od-win32/win32gui.h index 6281cb16..0d25899e 100755 --- a/od-win32/win32gui.h +++ b/od-win32/win32gui.h @@ -17,5 +17,6 @@ extern void pre_gui_message (const char*,...); extern void gui_message_id (int id); int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage); HKEY read_disk_history (void); +void write_disk_history (void); #endif diff --git a/od-win32/winuae_msvc/winuae_msvc.vcproj b/od-win32/winuae_msvc/winuae_msvc.vcproj index e5a5de25..7c14bcff 100755 --- a/od-win32/winuae_msvc/winuae_msvc.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.vcproj @@ -280,7 +280,7 @@ ProgramDataBaseFileName=".\Release/" WarningLevel="3" SuppressStartupBanner="true" - CompileAs="1" + CompileAs="0" DisableSpecificWarnings="4996" ForcedIncludeFiles="" /> @@ -1021,163 +1021,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/savestate.c b/savestate.c index 54146431..bfc54bcf 100755 --- a/savestate.c +++ b/savestate.c @@ -460,6 +460,7 @@ void restore_state (char *filename) name, len, end - chunk); xfree (chunk); } + restore_blitter_finish(); return; error: @@ -590,14 +591,14 @@ void save_state (char *filename, char *description) save_chunk (f, dst, len, "DISK", 0); xfree (dst); - dst = save_custom (&len, 0, 0); - save_chunk (f, dst, len, "CHIP", 0); - xfree (dst); - dst = save_blitter (&len, 0); save_chunk (f, dst, len, "BLIT", 0); xfree (dst); + dst = save_custom (&len, 0, 0); + save_chunk (f, dst, len, "CHIP", 0); + xfree (dst); + dst = save_custom_agacolors (&len, 0); save_chunk (f, dst, len, "AGAC", 0); xfree (dst); diff --git a/sinctable.c b/sinctable.c new file mode 100755 index 00000000..7b198b7f --- /dev/null +++ b/sinctable.c @@ -0,0 +1,443 @@ + /* + * Table of the integral of the sinc function modulated by the blackman window + * (c) Antti S. Lankila 2006 + * + * Theory of operation + * + * Paula synthesizes audio as a pulse waveform at a 3.54 MHz rate. This + * fact may be exploited for performing samplerate conversion to 44.1 kHz + * fast way using convolution with the sinc function, by recognizing that + * convolution with a constant is the integral of the convolution function + * multiplied by the constant. Therefore it follows that the convolution + * can be evaluated as a piecewise sum of such integrals. + * + * The sinc function is evaluated for points -2048 to +2047, oscillating at + * a rate to cause filter cutoff point around 20 kHz in the 3.54 MHz sampling + * frequency. The function is then windowed and numerically integrated, and + * scaled in such a fashion to start the integral from -65536 and end at 65536. + * (The actual values are somewhat arbitrary, as only the difference between + * values matter.) However, this arrangement is symmetrical and gives 2^17 bits + * of resolution for the table, or about -80 dB signal-to-noise ratio across + * the 1.77 MHz audio spectrum. Additionally, the filter response falls very + * close to the minimum at 22.05 kHz, thus avoiding aliasing artifacts. + * + * This table is computed by the program contrib/sinc-integral.py, using + * the following parameters: + * + * convolution_size = 4096 + * sampling_freq = 3541200 + * stopfreq = 20000 + */ + +const int winsinc_integral[4096] = { +-65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, +-65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, +-65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, +-65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, +-65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, +-65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, +-65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, +-65536, -65536, -65536, -65535, -65535, -65535, -65535, -65535, -65535, -65535, +-65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, +-65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, +-65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, +-65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, -65535, +-65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, -65536, +-65536, -65536, -65536, -65536, -65536, -65536, -65537, -65537, -65537, -65537, +-65537, -65537, -65537, -65537, -65537, -65537, -65537, -65538, -65538, -65538, +-65538, -65538, -65538, -65538, -65538, -65538, -65539, -65539, -65539, -65539, +-65539, -65539, -65539, -65539, -65539, -65539, -65540, -65540, -65540, -65540, +-65540, -65540, -65540, -65540, -65540, -65540, -65540, -65540, -65540, -65541, +-65541, -65541, -65541, -65541, -65541, -65541, -65541, -65541, -65541, -65541, +-65541, -65541, -65541, -65541, -65541, -65541, -65541, -65541, -65540, -65540, +-65540, -65540, -65540, -65540, -65540, -65540, -65540, -65540, -65539, -65539, +-65539, -65539, -65539, -65539, -65539, -65538, -65538, -65538, -65538, -65538, +-65537, -65537, -65537, -65537, -65536, -65536, -65536, -65536, -65535, -65535, +-65535, -65535, -65534, -65534, -65534, -65533, -65533, -65533, -65533, -65532, +-65532, -65532, -65531, -65531, -65531, -65531, -65530, -65530, -65530, -65530, +-65529, -65529, -65529, -65528, -65528, -65528, -65528, -65528, -65527, -65527, +-65527, -65527, -65527, -65526, -65526, -65526, -65526, -65526, -65526, -65525, +-65525, -65525, -65525, -65525, -65525, -65525, -65525, -65525, -65525, -65525, +-65525, -65525, -65525, -65525, -65525, -65526, -65526, -65526, -65526, -65526, +-65526, -65527, -65527, -65527, -65527, -65528, -65528, -65528, -65529, -65529, +-65529, -65530, -65530, -65530, -65531, -65531, -65532, -65532, -65532, -65533, +-65533, -65534, -65534, -65535, -65535, -65536, -65537, -65537, -65538, -65538, +-65539, -65539, -65540, -65541, -65541, -65542, -65542, -65543, -65543, -65544, +-65545, -65545, -65546, -65546, -65547, -65547, -65548, -65549, -65549, -65550, +-65550, -65551, -65551, -65552, -65552, -65553, -65553, -65553, -65554, -65554, +-65555, -65555, -65555, -65556, -65556, -65556, -65556, -65557, -65557, -65557, +-65557, -65557, -65557, -65558, -65558, -65558, -65558, -65558, -65558, -65557, +-65557, -65557, -65557, -65557, -65557, -65556, -65556, -65556, -65555, -65555, +-65555, -65554, -65554, -65553, -65553, -65552, -65552, -65551, -65550, -65550, +-65549, -65548, -65547, -65547, -65546, -65545, -65544, -65543, -65543, -65542, +-65541, -65540, -65539, -65538, -65537, -65536, -65535, -65534, -65533, -65532, +-65531, -65530, -65529, -65528, -65527, -65526, -65525, -65524, -65523, -65522, +-65521, -65520, -65519, -65518, -65517, -65516, -65515, -65514, -65513, -65512, +-65511, -65510, -65509, -65509, -65508, -65507, -65506, -65506, -65505, -65504, +-65504, -65503, -65503, -65502, -65502, -65501, -65501, -65501, -65500, -65500, +-65500, -65500, -65500, -65499, -65499, -65499, -65500, -65500, -65500, -65500, +-65500, -65501, -65501, -65501, -65502, -65502, -65503, -65504, -65504, -65505, +-65506, -65506, -65507, -65508, -65509, -65510, -65511, -65512, -65513, -65515, +-65516, -65517, -65518, -65520, -65521, -65522, -65524, -65525, -65527, -65528, +-65530, -65531, -65533, -65534, -65536, -65538, -65539, -65541, -65543, -65544, +-65546, -65548, -65550, -65551, -65553, -65555, -65556, -65558, -65560, -65561, +-65563, -65565, -65566, -65568, -65569, -65571, -65572, -65574, -65575, -65577, +-65578, -65579, -65581, -65582, -65583, -65584, -65585, -65586, -65587, -65588, +-65589, -65590, -65591, -65592, -65592, -65593, -65593, -65594, -65594, -65594, +-65595, -65595, -65595, -65595, -65595, -65595, -65594, -65594, -65594, -65593, +-65593, -65592, -65591, -65591, -65590, -65589, -65588, -65587, -65586, -65584, +-65583, -65582, -65580, -65579, -65577, -65575, -65574, -65572, -65570, -65568, +-65566, -65564, -65562, -65560, -65558, -65556, -65553, -65551, -65549, -65546, +-65544, -65541, -65539, -65536, -65534, -65531, -65529, -65526, -65523, -65521, +-65518, -65515, -65513, -65510, -65508, -65505, -65502, -65500, -65497, -65495, +-65492, -65490, -65487, -65485, -65483, -65480, -65478, -65476, -65474, -65472, +-65470, -65468, -65466, -65464, -65463, -65461, -65459, -65458, -65457, -65455, +-65454, -65453, -65452, -65451, -65450, -65449, -65449, -65448, -65448, -65448, +-65448, -65447, -65448, -65448, -65448, -65448, -65449, -65450, -65450, -65451, +-65452, -65453, -65454, -65456, -65457, -65459, -65460, -65462, -65464, -65466, +-65468, -65470, -65473, -65475, -65478, -65480, -65483, -65486, -65489, -65492, +-65495, -65498, -65501, -65504, -65508, -65511, -65515, -65518, -65522, -65525, +-65529, -65533, -65537, -65540, -65544, -65548, -65552, -65556, -65560, -65563, +-65567, -65571, -65575, -65579, -65583, -65587, -65590, -65594, -65598, -65601, +-65605, -65609, -65612, -65615, -65619, -65622, -65625, -65628, -65631, -65634, +-65637, -65640, -65642, -65645, -65647, -65649, -65651, -65653, -65655, -65657, +-65658, -65660, -65661, -65662, -65663, -65664, -65664, -65665, -65665, -65665, +-65665, -65665, -65665, -65665, -65664, -65663, -65662, -65661, -65660, -65658, +-65656, -65655, -65653, -65650, -65648, -65646, -65643, -65640, -65637, -65634, +-65631, -65627, -65624, -65620, -65616, -65612, -65608, -65604, -65600, -65595, +-65591, -65586, -65581, -65576, -65571, -65566, -65561, -65556, -65551, -65545, +-65540, -65535, -65529, -65524, -65518, -65513, -65507, -65501, -65496, -65490, +-65485, -65479, -65474, -65468, -65463, -65458, -65452, -65447, -65442, -65437, +-65432, -65427, -65422, -65417, -65413, -65408, -65404, -65400, -65396, -65392, +-65388, -65385, -65381, -65378, -65375, -65372, -65369, -65367, -65365, -65362, +-65361, -65359, -65357, -65356, -65355, -65354, -65354, -65353, -65353, -65353, +-65354, -65354, -65355, -65356, -65357, -65359, -65361, -65363, -65365, -65367, +-65370, -65373, -65376, -65379, -65383, -65387, -65391, -65395, -65400, -65404, +-65409, -65414, -65420, -65425, -65431, -65437, -65443, -65449, -65455, -65461, +-65468, -65475, -65482, -65489, -65496, -65503, -65510, -65518, -65525, -65533, +-65540, -65548, -65556, -65563, -65571, -65579, -65587, -65594, -65602, -65610, +-65617, -65625, -65633, -65640, -65648, -65655, -65662, -65669, -65676, -65683, +-65690, -65696, -65703, -65709, -65715, -65721, -65727, -65732, -65738, -65743, +-65748, -65752, -65757, -65761, -65765, -65768, -65771, -65775, -65777, -65780, +-65782, -65784, -65786, -65787, -65788, -65788, -65789, -65789, -65789, -65788, +-65787, -65786, -65784, -65782, -65780, -65777, -65775, -65771, -65768, -65764, +-65760, -65755, -65750, -65745, -65740, -65734, -65728, -65722, -65715, -65709, +-65701, -65694, -65686, -65679, -65671, -65662, -65654, -65645, -65636, -65627, +-65618, -65608, -65598, -65589, -65579, -65569, -65558, -65548, -65538, -65527, +-65517, -65507, -65496, -65485, -65475, -65464, -65454, -65443, -65433, -65422, +-65412, -65402, -65392, -65381, -65372, -65362, -65352, -65343, -65333, -65324, +-65316, -65307, -65299, -65290, -65282, -65275, -65268, -65260, -65254, -65247, +-65241, -65235, -65230, -65225, -65220, -65216, -65212, -65208, -65205, -65202, +-65200, -65198, -65196, -65195, -65195, -65194, -65194, -65195, -65196, -65197, +-65199, -65202, -65205, -65208, -65211, -65216, -65220, -65225, -65230, -65236, +-65243, -65249, -65256, -65264, -65272, -65280, -65289, -65298, -65307, -65317, +-65327, -65337, -65348, -65359, -65370, -65382, -65394, -65406, -65418, -65431, +-65444, -65457, -65470, -65483, -65497, -65511, -65524, -65538, -65552, -65566, +-65581, -65595, -65609, -65623, -65637, -65651, -65665, -65679, -65693, -65707, +-65721, -65734, -65748, -65761, -65774, -65786, -65799, -65811, -65823, -65835, +-65846, -65857, -65868, -65878, -65888, -65898, -65907, -65916, -65924, -65932, +-65940, -65947, -65953, -65960, -65965, -65970, -65975, -65979, -65982, -65985, +-65987, -65989, -65990, -65991, -65991, -65991, -65990, -65988, -65986, -65983, +-65980, -65976, -65971, -65966, -65960, -65954, -65947, -65940, -65932, -65923, +-65914, -65904, -65894, -65883, -65872, -65861, -65848, -65836, -65823, -65809, +-65795, -65781, -65766, -65751, -65735, -65719, -65703, -65687, -65670, -65653, +-65635, -65618, -65600, -65582, -65564, -65545, -65527, -65508, -65490, -65471, +-65452, -65434, -65415, -65396, -65378, -65359, -65341, -65322, -65304, -65286, +-65269, -65251, -65234, -65217, -65200, -65184, -65168, -65152, -65137, -65122, +-65108, -65094, -65081, -65068, -65055, -65044, -65032, -65021, -65011, -65002, +-64993, -64984, -64977, -64970, -64963, -64958, -64953, -64949, -64945, -64942, +-64940, -64939, -64939, -64939, -64940, -64942, -64944, -64947, -64951, -64956, +-64962, -64968, -64975, -64983, -64992, -65001, -65011, -65022, -65034, -65046, +-65059, -65072, -65087, -65102, -65117, -65134, -65150, -65168, -65186, -65204, +-65223, -65243, -65263, -65284, -65305, -65326, -65348, -65370, -65393, -65415, +-65438, -65462, -65485, -65509, -65533, -65557, -65582, -65606, -65630, -65655, +-65679, -65704, -65728, -65752, -65776, -65800, -65824, -65847, -65871, -65894, +-65916, -65939, -65961, -65982, -66003, -66024, -66044, -66063, -66082, -66101, +-66119, -66136, -66152, -66168, -66183, -66198, -66211, -66224, -66236, -66248, +-66258, -66268, -66276, -66284, -66291, -66297, -66302, -66306, -66309, -66311, +-66313, -66313, -66312, -66310, -66307, -66304, -66299, -66293, -66287, -66279, +-66270, -66260, -66250, -66238, -66226, -66212, -66197, -66182, -66166, -66149, +-66130, -66112, -66092, -66071, -66050, -66028, -66005, -65981, -65957, -65931, +-65906, -65879, -65853, -65825, -65797, -65769, -65740, -65710, -65681, -65650, +-65620, -65589, -65558, -65527, -65496, -65464, -65433, -65401, -65370, -65338, +-65306, -65275, -65244, -65213, -65182, -65151, -65121, -65091, -65062, -65033, +-65004, -64976, -64948, -64921, -64895, -64869, -64844, -64820, -64797, -64774, +-64752, -64731, -64711, -64692, -64674, -64657, -64641, -64626, -64612, -64599, +-64587, -64576, -64567, -64558, -64551, -64545, -64541, -64537, -64535, -64534, +-64534, -64536, -64539, -64543, -64548, -64555, -64563, -64572, -64583, -64595, +-64608, -64622, -64638, -64654, -64673, -64692, -64712, -64734, -64757, -64780, +-64805, -64831, -64858, -64887, -64916, -64946, -64977, -65008, -65041, -65075, +-65109, -65144, -65180, -65216, -65253, -65291, -65329, -65367, -65406, -65446, +-65485, -65525, -65566, -65606, -65647, -65688, -65728, -65769, -65810, -65850, +-65891, -65931, -65971, -66010, -66049, -66088, -66126, -66164, -66201, -66238, +-66274, -66309, -66343, -66377, -66409, -66441, -66472, -66502, -66530, -66558, +-66584, -66610, -66634, -66656, -66678, -66698, -66717, -66734, -66750, -66765, +-66778, -66789, -66799, -66808, -66815, -66820, -66824, -66826, -66826, -66825, +-66822, -66818, -66812, -66804, -66795, -66784, -66771, -66756, -66740, -66723, +-66704, -66683, -66660, -66636, -66611, -66584, -66555, -66525, -66494, -66461, +-66427, -66391, -66355, -66317, -66277, -66237, -66195, -66153, -66109, -66065, +-66019, -65973, -65925, -65877, -65829, -65779, -65729, -65679, -65628, -65576, +-65524, -65472, -65420, -65368, -65315, -65263, -65210, -65158, -65106, -65054, +-65002, -64951, -64900, -64850, -64800, -64751, -64703, -64655, -64608, -64563, +-64518, -64474, -64431, -64390, -64349, -64310, -64272, -64236, -64201, -64168, +-64136, -64106, -64077, -64050, -64025, -64001, -63980, -63960, -63942, -63926, +-63912, -63900, -63890, -63882, -63876, -63873, -63871, -63871, -63874, -63878, +-63885, -63894, -63905, -63918, -63934, -63951, -63971, -63992, -64016, -64042, +-64070, -64100, -64132, -64166, -64202, -64239, -64279, -64321, -64364, -64409, +-64456, -64504, -64554, -64606, -64659, -64713, -64769, -64826, -64885, -64944, +-65005, -65067, -65129, -65193, -65257, -65323, -65388, -65455, -65522, -65589, +-65657, -65725, -65793, -65861, -65929, -65997, -66065, -66133, -66200, -66267, +-66333, -66399, -66464, -66528, -66592, -66654, -66716, -66776, -66835, -66893, +-66949, -67004, -67057, -67109, -67159, -67207, -67254, -67298, -67341, -67382, +-67420, -67456, -67490, -67522, -67552, -67579, -67603, -67626, -67645, -67662, +-67677, -67688, -67698, -67704, -67708, -67709, -67707, -67702, -67695, -67685, +-67672, -67656, -67637, -67616, -67592, -67565, -67535, -67503, -67468, -67430, +-67389, -67346, -67300, -67252, -67201, -67148, -67093, -67035, -66974, -66912, +-66847, -66781, -66712, -66641, -66569, -66495, -66419, -66341, -66262, -66181, +-66099, -66016, -65932, -65846, -65760, -65673, -65585, -65496, -65407, -65318, +-65228, -65138, -65048, -64957, -64868, -64778, -64689, -64600, -64512, -64424, +-64337, -64252, -64167, -64084, -64002, -63921, -63842, -63764, -63688, -63614, +-63542, -63472, -63405, -63339, -63276, -63215, -63157, -63102, -63049, -62999, +-62952, -62908, -62867, -62829, -62795, -62763, -62735, -62711, -62690, -62672, +-62658, -62647, -62640, -62637, -62638, -62642, -62650, -62661, -62677, -62696, +-62719, -62746, -62776, -62810, -62848, -62890, -62935, -62985, -63037, -63093, +-63153, -63217, -63283, -63353, -63427, -63503, -63583, -63666, -63752, -63841, +-63933, -64027, -64124, -64223, -64325, -64430, -64536, -64645, -64755, -64867, +-64981, -65097, -65214, -65332, -65452, -65572, -65693, -65816, -65938, -66061, +-66184, -66308, -66431, -66554, -66677, -66799, -66921, -67042, -67161, -67280, +-67397, -67513, -67627, -67739, -67850, -67958, -68064, -68168, -68269, -68367, +-68463, -68555, -68644, -68730, -68813, -68892, -68967, -69039, -69106, -69170, +-69229, -69284, -69335, -69381, -69423, -69460, -69492, -69519, -69542, -69559, +-69572, -69579, -69581, -69578, -69570, -69556, -69537, -69513, -69483, -69448, +-69408, -69362, -69311, -69255, -69193, -69126, -69054, -68976, -68894, -68806, +-68714, -68616, -68514, -68406, -68294, -68178, -68057, -67932, -67802, -67668, +-67531, -67389, -67244, -67095, -66942, -66787, -66628, -66467, -66303, -66136, +-65967, -65795, -65622, -65447, -65270, -65092, -64913, -64733, -64552, -64371, +-64190, -64008, -63827, -63646, -63466, -63286, -63108, -62931, -62756, -62583, +-62411, -62242, -62076, -61913, -61752, -61595, -61441, -61291, -61145, -61004, +-60866, -60734, -60606, -60484, -60366, -60255, -60148, -60048, -59954, -59867, +-59786, -59711, -59643, -59583, -59529, -59483, -59444, -59413, -59390, -59374, +-59367, -59367, -59376, -59393, -59418, -59452, -59494, -59544, -59603, -59671, +-59748, -59833, -59926, -60028, -60139, -60259, -60386, -60523, -60668, -60821, +-60982, -61152, -61329, -61515, -61708, -61909, -62117, -62333, -62556, -62786, +-63023, -63266, -63516, -63772, -64034, -64301, -64574, -64852, -65135, -65423, +-65714, -66010, -66310, -66612, -66918, -67226, -67537, -67850, -68164, -68479, +-68795, -69112, -69429, -69745, -70060, -70375, -70687, -70998, -71306, -71611, +-71913, -72211, -72505, -72794, -73078, -73357, -73629, -73895, -74153, -74405, +-74648, -74883, -75109, -75326, -75533, -75730, -75917, -76092, -76255, -76407, +-76546, -76672, -76785, -76884, -76969, -77039, -77095, -77134, -77158, -77166, +-77157, -77132, -77088, -77027, -76948, -76851, -76735, -76600, -76445, -76271, +-76077, -75863, -75628, -75372, -75096, -74798, -74479, -74138, -73776, -73391, +-72984, -72555, -72104, -71630, -71134, -70615, -70073, -69508, -68920, -68309, +-67676, -67020, -66340, -65638, -64913, -64165, -63395, -62602, -61787, -60950, +-60090, -59208, -58305, -57380, -56433, -55466, -54477, -53468, -52439, -51389, +-50320, -49231, -48123, -46996, -45851, -44687, -43506, -42308, -41093, -39861, +-38613, -37350, -36071, -34778, -33471, -32150, -30816, -29470, -28111, -26740, +-25359, -23967, -22565, -21154, -19734, -18305, -16869, -15426, -13977, -12521, +-11061, -9595, -8126, -6653, -5178, -3700, -2221, -740, 740, 2220, + 3700, 5177, 6653, 8126, 9595, 11060, 12521, 13976, 15426, 16869, + 18305, 19733, 21153, 22565, 23967, 25358, 26740, 28110, 29469, 30816, + 32150, 33471, 34778, 36071, 37349, 38613, 39860, 41092, 42307, 43506, + 44687, 45850, 46996, 48122, 49230, 50319, 51389, 52438, 53468, 54477, + 55466, 56433, 57380, 58305, 59208, 60090, 60949, 61787, 62602, 63395, + 64165, 64913, 65638, 66340, 67019, 67676, 68309, 68920, 69507, 70072, + 70614, 71133, 71630, 72104, 72555, 72984, 73391, 73775, 74138, 74479, + 74798, 75095, 75372, 75628, 75862, 76077, 76271, 76445, 76600, 76735, + 76851, 76948, 77027, 77088, 77131, 77157, 77166, 77158, 77134, 77094, + 77039, 76969, 76884, 76785, 76672, 76546, 76407, 76255, 76092, 75916, + 75730, 75533, 75326, 75109, 74883, 74648, 74404, 74153, 73894, 73629, + 73356, 73078, 72794, 72505, 72211, 71913, 71611, 71306, 70998, 70687, + 70374, 70060, 69745, 69428, 69112, 68795, 68479, 68163, 67849, 67537, + 67226, 66918, 66612, 66309, 66010, 65714, 65422, 65135, 64852, 64574, + 64301, 64033, 63772, 63516, 63266, 63023, 62786, 62556, 62333, 62117, + 61908, 61707, 61514, 61329, 61151, 60982, 60820, 60667, 60522, 60386, + 60258, 60139, 60028, 59926, 59832, 59747, 59671, 59603, 59544, 59493, + 59451, 59418, 59392, 59375, 59367, 59366, 59374, 59389, 59413, 59444, + 59483, 59529, 59582, 59643, 59711, 59785, 59866, 59954, 60048, 60148, + 60254, 60366, 60483, 60606, 60734, 60866, 61003, 61145, 61291, 61441, + 61595, 61752, 61912, 62076, 62242, 62411, 62582, 62756, 62931, 63108, + 63286, 63465, 63645, 63826, 64008, 64189, 64371, 64552, 64733, 64913, + 65092, 65270, 65447, 65622, 65795, 65966, 66135, 66302, 66466, 66628, + 66787, 66942, 67094, 67243, 67389, 67530, 67668, 67802, 67931, 68057, + 68178, 68294, 68406, 68513, 68616, 68713, 68806, 68894, 68976, 69053, + 69126, 69193, 69254, 69311, 69362, 69408, 69448, 69483, 69512, 69537, + 69556, 69569, 69578, 69581, 69579, 69571, 69559, 69541, 69519, 69492, + 69459, 69422, 69381, 69335, 69284, 69229, 69169, 69106, 69038, 68967, + 68891, 68812, 68730, 68644, 68555, 68462, 68367, 68268, 68167, 68064, + 67958, 67849, 67739, 67627, 67513, 67397, 67280, 67161, 67041, 66921, + 66799, 66677, 66554, 66431, 66307, 66184, 66061, 65938, 65815, 65693, + 65572, 65451, 65332, 65214, 65097, 64981, 64867, 64755, 64644, 64536, + 64429, 64325, 64223, 64124, 64027, 63932, 63841, 63752, 63666, 63583, + 63503, 63426, 63353, 63283, 63216, 63153, 63093, 63037, 62984, 62935, + 62890, 62848, 62810, 62776, 62745, 62719, 62696, 62676, 62661, 62649, + 62641, 62637, 62637, 62640, 62647, 62657, 62672, 62689, 62710, 62735, + 62763, 62794, 62829, 62867, 62908, 62952, 62999, 63049, 63101, 63157, + 63215, 63276, 63339, 63404, 63472, 63542, 63614, 63688, 63764, 63841, + 63920, 64001, 64083, 64167, 64251, 64337, 64424, 64511, 64599, 64688, + 64778, 64867, 64957, 65047, 65137, 65227, 65317, 65407, 65496, 65584, + 65672, 65760, 65846, 65931, 66016, 66099, 66181, 66261, 66341, 66418, + 66494, 66568, 66641, 66712, 66780, 66847, 66912, 66974, 67034, 67092, + 67148, 67201, 67252, 67300, 67346, 67389, 67429, 67467, 67502, 67535, + 67565, 67592, 67616, 67637, 67656, 67671, 67684, 67695, 67702, 67707, + 67708, 67707, 67704, 67697, 67688, 67676, 67662, 67645, 67625, 67603, + 67578, 67551, 67522, 67490, 67456, 67420, 67381, 67341, 67298, 67253, + 67207, 67159, 67109, 67057, 67004, 66949, 66892, 66835, 66775, 66715, + 66654, 66591, 66528, 66464, 66399, 66333, 66267, 66200, 66133, 66065, + 65997, 65929, 65861, 65792, 65724, 65656, 65589, 65521, 65454, 65388, + 65322, 65257, 65193, 65129, 65066, 65005, 64944, 64884, 64826, 64769, + 64713, 64658, 64605, 64554, 64504, 64455, 64409, 64364, 64320, 64279, + 64239, 64201, 64165, 64131, 64100, 64070, 64042, 64016, 63992, 63970, + 63951, 63933, 63918, 63905, 63894, 63885, 63878, 63873, 63871, 63870, + 63872, 63876, 63882, 63890, 63900, 63912, 63926, 63942, 63960, 63979, + 64001, 64024, 64050, 64077, 64105, 64136, 64167, 64201, 64236, 64272, + 64310, 64349, 64389, 64431, 64474, 64517, 64562, 64608, 64655, 64702, + 64751, 64800, 64849, 64900, 64951, 65002, 65053, 65105, 65158, 65210, + 65262, 65315, 65367, 65420, 65472, 65524, 65576, 65627, 65678, 65729, + 65779, 65828, 65877, 65925, 65972, 66019, 66064, 66109, 66152, 66195, + 66237, 66277, 66316, 66354, 66391, 66427, 66461, 66494, 66525, 66555, + 66583, 66610, 66636, 66660, 66682, 66703, 66722, 66740, 66756, 66770, + 66783, 66794, 66804, 66811, 66818, 66822, 66825, 66826, 66826, 66823, + 66820, 66814, 66808, 66799, 66789, 66777, 66764, 66750, 66734, 66717, + 66698, 66678, 66656, 66633, 66609, 66584, 66558, 66530, 66501, 66472, + 66441, 66409, 66376, 66343, 66309, 66273, 66238, 66201, 66164, 66126, + 66088, 66049, 66010, 65970, 65930, 65890, 65850, 65809, 65769, 65728, + 65687, 65646, 65606, 65565, 65525, 65485, 65445, 65406, 65367, 65328, + 65290, 65253, 65216, 65179, 65144, 65109, 65074, 65041, 65008, 64976, + 64945, 64915, 64886, 64858, 64831, 64805, 64780, 64756, 64733, 64712, + 64691, 64672, 64654, 64637, 64622, 64607, 64594, 64582, 64572, 64563, + 64555, 64548, 64542, 64538, 64535, 64534, 64534, 64534, 64537, 64540, + 64545, 64551, 64558, 64566, 64576, 64587, 64598, 64611, 64625, 64640, + 64657, 64674, 64692, 64711, 64731, 64752, 64774, 64796, 64820, 64844, + 64869, 64895, 64921, 64948, 64976, 65004, 65032, 65061, 65091, 65121, + 65151, 65182, 65212, 65243, 65275, 65306, 65338, 65369, 65401, 65432, + 65464, 65495, 65527, 65558, 65589, 65620, 65650, 65680, 65710, 65739, + 65768, 65797, 65825, 65852, 65879, 65905, 65931, 65956, 65981, 66004, + 66027, 66049, 66071, 66091, 66111, 66130, 66148, 66165, 66182, 66197, + 66212, 66225, 66238, 66249, 66260, 66270, 66278, 66286, 66293, 66299, + 66303, 66307, 66310, 66312, 66312, 66312, 66311, 66309, 66306, 66302, + 66296, 66291, 66284, 66276, 66267, 66258, 66247, 66236, 66224, 66211, + 66197, 66183, 66168, 66152, 66135, 66118, 66100, 66082, 66063, 66043, + 66023, 66003, 65982, 65960, 65938, 65916, 65893, 65870, 65847, 65824, + 65800, 65776, 65752, 65728, 65703, 65679, 65655, 65630, 65606, 65581, + 65557, 65533, 65509, 65485, 65462, 65438, 65415, 65392, 65370, 65347, + 65326, 65304, 65283, 65263, 65243, 65223, 65204, 65185, 65167, 65150, + 65133, 65117, 65101, 65086, 65072, 65058, 65045, 65033, 65022, 65011, + 65001, 64991, 64983, 64975, 64968, 64961, 64956, 64951, 64947, 64944, + 64941, 64939, 64938, 64938, 64939, 64940, 64942, 64945, 64948, 64953, + 64957, 64963, 64969, 64976, 64984, 64992, 65001, 65011, 65021, 65032, + 65043, 65055, 65067, 65080, 65094, 65108, 65122, 65137, 65152, 65168, + 65184, 65200, 65217, 65234, 65251, 65268, 65286, 65304, 65322, 65340, + 65359, 65377, 65396, 65415, 65433, 65452, 65471, 65489, 65508, 65527, + 65545, 65563, 65581, 65599, 65617, 65635, 65652, 65669, 65686, 65703, + 65719, 65735, 65750, 65766, 65780, 65795, 65809, 65822, 65835, 65848, + 65860, 65872, 65883, 65894, 65904, 65914, 65923, 65931, 65939, 65947, + 65954, 65960, 65966, 65971, 65975, 65979, 65983, 65985, 65988, 65989, + 65990, 65991, 65991, 65990, 65989, 65987, 65985, 65982, 65978, 65974, + 65970, 65965, 65959, 65953, 65947, 65940, 65932, 65924, 65916, 65907, + 65898, 65888, 65878, 65868, 65857, 65846, 65835, 65823, 65811, 65799, + 65786, 65773, 65760, 65747, 65734, 65720, 65707, 65693, 65679, 65665, + 65651, 65637, 65623, 65609, 65594, 65580, 65566, 65552, 65538, 65524, + 65510, 65497, 65483, 65470, 65456, 65443, 65431, 65418, 65406, 65393, + 65381, 65370, 65359, 65347, 65337, 65326, 65316, 65307, 65297, 65288, + 65280, 65271, 65263, 65256, 65249, 65242, 65236, 65230, 65225, 65220, + 65215, 65211, 65207, 65204, 65201, 65199, 65197, 65196, 65195, 65194, + 65194, 65194, 65195, 65196, 65198, 65200, 65202, 65205, 65208, 65211, + 65215, 65220, 65225, 65230, 65235, 65241, 65247, 65253, 65260, 65267, + 65274, 65282, 65290, 65298, 65307, 65315, 65324, 65333, 65342, 65352, + 65361, 65371, 65381, 65391, 65401, 65412, 65422, 65432, 65443, 65453, + 65464, 65474, 65485, 65496, 65506, 65517, 65527, 65538, 65548, 65558, + 65568, 65578, 65588, 65598, 65608, 65617, 65626, 65636, 65645, 65653, + 65662, 65670, 65678, 65686, 65694, 65701, 65708, 65715, 65722, 65728, + 65734, 65740, 65745, 65750, 65755, 65759, 65764, 65767, 65771, 65774, + 65777, 65780, 65782, 65784, 65785, 65787, 65788, 65788, 65788, 65788, + 65788, 65787, 65786, 65785, 65784, 65782, 65779, 65777, 65774, 65771, + 65768, 65764, 65760, 65756, 65752, 65747, 65742, 65737, 65732, 65726, + 65721, 65715, 65709, 65702, 65696, 65689, 65683, 65676, 65669, 65662, + 65655, 65647, 65640, 65632, 65625, 65617, 65609, 65602, 65594, 65586, + 65579, 65571, 65563, 65555, 65548, 65540, 65532, 65525, 65517, 65510, + 65503, 65495, 65488, 65481, 65474, 65468, 65461, 65455, 65448, 65442, + 65436, 65430, 65425, 65419, 65414, 65409, 65404, 65399, 65395, 65391, + 65387, 65383, 65379, 65376, 65373, 65370, 65367, 65364, 65362, 65360, + 65358, 65357, 65356, 65355, 65354, 65353, 65353, 65353, 65353, 65353, + 65354, 65355, 65356, 65357, 65359, 65360, 65362, 65364, 65367, 65369, + 65372, 65375, 65378, 65381, 65384, 65388, 65392, 65396, 65400, 65404, + 65408, 65413, 65417, 65422, 65427, 65431, 65436, 65442, 65447, 65452, + 65457, 65463, 65468, 65473, 65479, 65484, 65490, 65496, 65501, 65507, + 65512, 65518, 65523, 65529, 65534, 65540, 65545, 65550, 65556, 65561, + 65566, 65571, 65576, 65581, 65586, 65590, 65595, 65599, 65604, 65608, + 65612, 65616, 65620, 65623, 65627, 65630, 65634, 65637, 65640, 65643, + 65645, 65648, 65650, 65652, 65654, 65656, 65658, 65659, 65661, 65662, + 65663, 65664, 65664, 65665, 65665, 65665, 65665, 65665, 65665, 65664, + 65663, 65663, 65662, 65661, 65659, 65658, 65656, 65655, 65653, 65651, + 65649, 65647, 65644, 65642, 65639, 65637, 65634, 65631, 65628, 65625, + 65622, 65618, 65615, 65612, 65608, 65605, 65601, 65597, 65594, 65590, + 65586, 65582, 65579, 65575, 65571, 65567, 65563, 65559, 65555, 65551, + 65548, 65544, 65540, 65536, 65532, 65529, 65525, 65521, 65518, 65514, + 65511, 65507, 65504, 65501, 65497, 65494, 65491, 65488, 65485, 65483, + 65480, 65477, 65475, 65472, 65470, 65468, 65466, 65464, 65462, 65460, + 65458, 65457, 65455, 65454, 65453, 65452, 65451, 65450, 65449, 65449, + 65448, 65448, 65447, 65447, 65447, 65447, 65447, 65448, 65448, 65449, + 65449, 65450, 65451, 65452, 65453, 65454, 65455, 65456, 65458, 65459, + 65461, 65462, 65464, 65466, 65468, 65470, 65472, 65474, 65476, 65478, + 65480, 65482, 65485, 65487, 65490, 65492, 65494, 65497, 65500, 65502, + 65505, 65507, 65510, 65513, 65515, 65518, 65520, 65523, 65526, 65528, + 65531, 65533, 65536, 65538, 65541, 65543, 65546, 65548, 65551, 65553, + 65555, 65557, 65560, 65562, 65564, 65566, 65568, 65570, 65572, 65573, + 65575, 65577, 65578, 65580, 65581, 65583, 65584, 65585, 65586, 65587, + 65588, 65589, 65590, 65591, 65592, 65592, 65593, 65593, 65594, 65594, + 65594, 65594, 65594, 65594, 65594, 65594, 65594, 65594, 65593, 65593, + 65592, 65592, 65591, 65590, 65590, 65589, 65588, 65587, 65586, 65585, + 65584, 65583, 65582, 65580, 65579, 65578, 65576, 65575, 65574, 65572, + 65571, 65569, 65567, 65566, 65564, 65563, 65561, 65559, 65558, 65556, + 65554, 65553, 65551, 65549, 65547, 65546, 65544, 65542, 65541, 65539, + 65537, 65536, 65534, 65533, 65531, 65529, 65528, 65526, 65525, 65523, + 65522, 65521, 65519, 65518, 65517, 65515, 65514, 65513, 65512, 65511, + 65510, 65509, 65508, 65507, 65506, 65505, 65505, 65504, 65503, 65503, + 65502, 65502, 65501, 65501, 65500, 65500, 65500, 65499, 65499, 65499, + 65499, 65499, 65499, 65499, 65499, 65499, 65500, 65500, 65500, 65501, + 65501, 65501, 65502, 65502, 65503, 65503, 65504, 65505, 65505, 65506, + 65507, 65507, 65508, 65509, 65510, 65511, 65512, 65512, 65513, 65514, + 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, + 65525, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535, + 65536, 65537, 65538, 65539, 65540, 65540, 65541, 65542, 65543, 65544, + 65545, 65546, 65546, 65547, 65548, 65549, 65549, 65550, 65551, 65551, + 65552, 65552, 65553, 65553, 65554, 65554, 65555, 65555, 65555, 65556, + 65556, 65556, 65556, 65557, 65557, 65557, 65557, 65557, 65557, 65557, + 65557, 65557, 65557, 65557, 65557, 65557, 65557, 65557, 65556, 65556, + 65556, 65556, 65555, 65555, 65555, 65554, 65554, 65553, 65553, 65553, + 65552, 65552, 65551, 65551, 65550, 65550, 65549, 65549, 65548, 65548, + 65547, 65547, 65546, 65545, 65545, 65544, 65544, 65543, 65542, 65542, + 65541, 65541, 65540, 65540, 65539, 65538, 65538, 65537, 65537, 65536, + 65536, 65535, 65535, 65534, 65534, 65533, 65533, 65532, 65532, 65531, + 65531, 65530, 65530, 65530, 65529, 65529, 65528, 65528, 65528, 65528, + 65527, 65527, 65527, 65526, 65526, 65526, 65526, 65526, 65525, 65525, + 65525, 65525, 65525, 65525, 65525, 65525, 65525, 65525, 65525, 65525, + 65525, 65525, 65525, 65525, 65525, 65525, 65525, 65525, 65525, 65526, + 65526, 65526, 65526, 65526, 65526, 65527, 65527, 65527, 65527, 65527, + 65528, 65528, 65528, 65528, 65529, 65529, 65529, 65529, 65530, 65530, + 65530, 65531, 65531, 65531, 65531, 65532, 65532, 65532, 65533, 65533, + 65533, 65533, 65534, 65534, 65534, 65534, 65535, 65535, 65535, 65536, + 65536, 65536, 65536, 65536, 65537, 65537, 65537, 65537, 65538, 65538, + 65538, 65538, 65538, 65539, 65539, 65539, 65539, 65539, 65539, 65539, + 65540, 65540, 65540, 65540, 65540, 65540, 65540, 65540, 65540, 65540, + 65540, 65540, 65540, 65540, 65540, 65540, 65540, 65540, 65540, 65540, + 65540, 65540, 65540, 65540, 65540, 65540, 65540, 65540, 65540, 65540, + 65540, 65540, 65540, 65540, 65540, 65540, 65539, 65539, 65539, 65539, + 65539, 65539, 65539, 65539, 65539, 65539, 65539, 65538, 65538, 65538, + 65538, 65538, 65538, 65538, 65538, 65538, 65537, 65537, 65537, 65537, + 65537, 65537, 65537, 65537, 65537, 65537, 65536, 65536, 65536, 65536, + 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, 65535, 65536, 65536, 65536, 65536, 65536, + 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, + 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, + 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, + 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, + 65536, 65536, 65536, 65536, 65536, 65536 +}; diff --git a/uaeipc.c b/uaeipc.c new file mode 100755 index 00000000..4baa6a54 --- /dev/null +++ b/uaeipc.c @@ -0,0 +1,217 @@ + +#include "config.h" +#include "sysconfig.h" + +#include +#include + +#include "sysdeps.h" +#include "uaeipc.h" +#include "options.h" +#include "zfile.h" +#include "inputdevice.h" + +#include + +static HANDLE *hipc = INVALID_HANDLE_VALUE, *olevent = INVALID_HANDLE_VALUE; +static OVERLAPPED ol; +#define IPC_BUFFER_SIZE 4096 +static uae_u8 buffer[IPC_BUFFER_SIZE], outbuf[IPC_BUFFER_SIZE]; +static int connected, readpending, writepending; + +static void parsemessage(char *in, struct uae_prefs *p, char *out, int outsize) +{ + out[0] = 0; + if (!memcmp(in, "CFG ", 4) || !memcmp(in, "EVT ", 4)) { + char tmpout[256]; + int index = -1; + int cnt = 0; + in += 4; + for (;;) { + int ret; + tmpout[0] = 0; + ret = cfgfile_modify (index, in, strlen (in), tmpout, sizeof (tmpout)); + index++; + if (strlen(tmpout) > 0) { + if (strlen(out) == 0) + strcat (out, "200 "); + strncat (out, "\n", outsize); + strncat (out, tmpout, outsize); + } + cnt++; + if (ret >= 0) + break; + } + if (strlen (out) == 0) + strcat (out, "404"); + } else { + strcpy (out, "501"); + } +} + +static int listenIPC(void) +{ + DWORD err; + + memset(&ol, 0, sizeof ol); + ol.hEvent = olevent; + if (ConnectNamedPipe(hipc, &ol)) { + write_log ("IPC: ConnectNamedPipe init failed, err=%d\n", GetLastError()); + closeIPC(); + return 0; + } + err = GetLastError(); + if (err == ERROR_PIPE_CONNECTED) { + if (SetEvent(olevent)) { + write_log ("IPC: ConnectNamedPipe SetEvent failed, err=%d\n", GetLastError()); + closeIPC(); + return 0; + } + } else if (err != ERROR_IO_PENDING) { + write_log ("IPC: ConnectNamedPipe failed, err=%d\n", GetLastError()); + closeIPC(); + return 0; + } + write_log("IPC: waiting for connections\n"); + return 1; +} + +static void disconnectIPC(void) +{ + readpending = writepending = FALSE; + if (connected) { + if (!DisconnectNamedPipe(hipc)) + write_log ("IPC: DisconnectNamedPipe failed, err=%d\n", GetLastError()); + connected = FALSE; + } + listenIPC(); +} + +void closeIPC(void) +{ + disconnectIPC(); + if (hipc == INVALID_HANDLE_VALUE) + return; + CloseHandle(hipc); + hipc = INVALID_HANDLE_VALUE; + if (olevent != INVALID_HANDLE_VALUE) + CloseHandle (olevent); + olevent = INVALID_HANDLE_VALUE; + +} + +int createIPC(void) +{ + connected = FALSE; + readpending = FALSE; + writepending = FALSE; + olevent = INVALID_HANDLE_VALUE; + hipc = CreateNamedPipe("\\\\.\\pipe\\WinUAE", + PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE, + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, + 1, IPC_BUFFER_SIZE, IPC_BUFFER_SIZE, + NMPWAIT_USE_DEFAULT_WAIT, NULL); + if (hipc == INVALID_HANDLE_VALUE) + return 0; + olevent = CreateEvent(NULL, TRUE, TRUE, NULL); + return listenIPC(); +} + +void *geteventhandleIPC(void) +{ + return olevent; +} + +static int isout; +static char outmsg[IPC_BUFFER_SIZE]; + +int sendIPC(char *msg) +{ + if (hipc == INVALID_HANDLE_VALUE) + return 0; + if (isout) + return 0; + strcpy (outmsg, msg); + if (!readpending && !writepending) + SetEvent (olevent); + return 1; +} + +int checkIPC(struct uae_prefs *p) +{ + BOOL ok; + DWORD ret, err; + + if (hipc == INVALID_HANDLE_VALUE) + return 0; + if (WaitForSingleObject(olevent, 0) != WAIT_OBJECT_0) + return 0; + if (!readpending && !writepending && isout) { + isout = 0; + memset (&ol, 0, sizeof ol); + ol.hEvent = olevent; + ok = WriteFile(hipc, outmsg, strlen (outmsg) + 1, &ret, &ol); + err = GetLastError(); + if (!ok && err != ERROR_IO_PENDING) { + write_log ("IPC: WriteFile() err=%d\n", err); + disconnectIPC(); + return 0; + } + writepending = TRUE; + return 1; + } + if (readpending || writepending) { + ok = GetOverlappedResult(hipc, &ol, &ret, FALSE); + if (!ok) { + err = GetLastError(); + if (err == ERROR_IO_INCOMPLETE) + return 0; + write_log ("IPC: GetOverlappedResult error %d\n", err); + disconnectIPC(); + return 0; + } + if (!connected) { + write_log ("IPC: Pipe connected\n"); + connected = TRUE; + return 0; + } + if (writepending) { + writepending = FALSE; + SetEvent (ol.hEvent); + memset (&ol, 0, sizeof ol); + ol.hEvent = olevent; + return 0; + } + } + if (!readpending) { + ok = ReadFile(hipc, buffer, IPC_BUFFER_SIZE, &ret, &ol); + err = GetLastError(); + if (!ok) { + if (err == ERROR_IO_PENDING) { + readpending = TRUE; + return 0; + } else if (err == ERROR_BROKEN_PIPE) { + write_log ("IPC: IPC client disconnected\n"); + } else { + write_log ("IPC: ReadFile() err=%d\n", err); + } + disconnectIPC(); + return 0; + } + } + readpending = FALSE; + write_log("IPC: got message '%s'\n", buffer); + parsemessage(buffer, p, outbuf, sizeof outbuf); + memset (&ol, 0, sizeof ol); + ol.hEvent = olevent; + ok = WriteFile(hipc, outbuf, strlen (outbuf) + 1, &ret, &ol); + err = GetLastError(); + if (!ok && err != ERROR_IO_PENDING) { + write_log ("IPC: WriteFile() err=%d\n", err); + disconnectIPC(); + return 0; + } + writepending = TRUE; + return 1; +} + diff --git a/zfile.c b/zfile.c index 9de41172..fb0d1301 100755 --- a/zfile.c +++ b/zfile.c @@ -20,6 +20,8 @@ #include "dms/pfile.h" #include "gui.h" #include "crc32.h" +#include "fsdb.h" + #include struct zfile { @@ -1019,6 +1021,8 @@ int zfile_exists (const char *name) f = openzip (fname, 0); if (!f) { manglefilename(fname, name); + if (!my_existsfile(fname)) + return 0; f = fopen(fname,"rb"); } if (!f)