* Copyright 1996 Manfred Thole
* Copyright 2006 Toni Wilen
*
- * new filter algorithm and "anti" interpolator by Antti S. Lankila
+ * new filter algorithm and anti&sinc interpolators by Antti S. Lankila
*
*/
audio_sampleripper(0);
}
-STATIC_INLINE int current_hpos (void)
-{
- return (get_cycles () - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT;
-}
-
static struct audio_channel_data audio_channel[4];
int sound_available = 0;
static int sound_table[64][256];
#define MIXED_STEREO_MAX 32
static int mixed_on, mixed_stereo_size, mixed_mul1, mixed_mul2;
static int led_filter_forced, sound_use_filter;
-static int sinc_on;
+static int sinc_on, led_filter_on;
+
+/* denormals are very small floating point numbers that force FPUs into slow
+ mode. All lowpass filters using floats are suspectible to denormals unless
+ a small offset is added to avoid very small floating point numbers. */
+#define DENORMAL_OFFSET (1E-10)
static struct filter_state {
float rc1, rc2, rc3, rc4, rc5;
} sound_filter_state[2];
+static float a500e_filter1_a0;
+static float a500e_filter2_a0;
+static float filter_a0; /* a500 and a1200 use the same */
+
enum {
FILTER_MODEL_A500 = 1,
- FILTER_MODEL_A1200,
- FILTER_MODEL_A500E,
- FILTER_MODEL_A1200E
+ FILTER_MODEL_A1200
};
/* Amiga has two separate filtering circuits per channel, a static RC filter
input = (uae_s16)input;
- if (currprefs.sound_freq != 44100)
- 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;
+ case FILTER_MODEL_A500:
+ fs->rc1 = a500e_filter1_a0 * input + (1 - a500e_filter1_a0) * fs->rc1 + DENORMAL_OFFSET;
+ fs->rc2 = a500e_filter2_a0 * fs->rc1 + (1-a500e_filter2_a0) * 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;
+ fs->rc3 = filter_a0 * normal_output + (1 - filter_a0) * fs->rc3;
+ fs->rc4 = filter_a0 * fs->rc3 + (1 - filter_a0) * fs->rc4;
+ fs->rc5 = filter_a0 * fs->rc4 + (1 - filter_a0) * fs->rc5;
led_output = fs->rc5;
break;
- case FILTER_MODEL_A1200E:
+ case FILTER_MODEL_A1200:
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;
+ fs->rc2 = filter_a0 * normal_output + (1 - filter_a0) * fs->rc2 + DENORMAL_OFFSET;
+ fs->rc3 = filter_a0 * fs->rc2 + (1 - filter_a0) * fs->rc3;
+ fs->rc4 = filter_a0 * fs->rc3 + (1 - filter_a0) * fs->rc4;
led_output = fs->rc4;
break;
}
- if (led_filter_forced > 0 || (gui_data.powerled && led_filter_forced >= 0))
+ if (led_filter_on)
o = led_output;
else
o = normal_output;
#define DO_CHANNEL(v, c) do { (v) &= audio_channel[c].adk_mask; data += v; } while (0);
-static void anti_prehandler(unsigned long best_evtime)
+static void anti_sinc_prehandler(unsigned long best_evtime)
{
int i, j;
/* 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
+ 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) {
/* 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;
+ 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;
}
}
|| changed_prefs.sound_filter_type != currprefs.sound_filter_type);
}
+/* This computes the 1st order low-pass filter term b0.
+ * The a1 term is 1.0 - b0. The center frequency marks the -3 dB point. */
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+static float rc_calculate_a0(int sample_rate, int cutoff_freq)
+{
+ float omega;
+ /* The BLT correction formula below blows up if the cutoff is above nyquist. */
+ if (cutoff_freq >= sample_rate / 2)
+ return 1.0;
+
+ omega = 2 * M_PI * cutoff_freq / sample_rate;
+ /* Compensate for the bilinear transformation. This allows us to specify the
+ * stop frequency more exactly, but the filter becomes less steep further
+ * from stopband. */
+ omega = tan(omega / 2) * 2;
+ return 1 / (1 + 1 / omega);
+}
+
void check_prefs_changed_audio (void)
{
#ifdef DRIVESOUND
driveclick_check_prefs ();
#endif
- if (sound_available && sound_prefs_changed ()) {
- close_sound ();
+ if (!sound_available || !sound_prefs_changed ())
+ return;
+ close_sound ();
#ifdef AVIOUTPUT
- AVIOutput_Restart ();
+ AVIOutput_Restart ();
#endif
- currprefs.produce_sound = changed_prefs.produce_sound;
- currprefs.win32_soundcard = changed_prefs.win32_soundcard;
- currprefs.sound_stereo = changed_prefs.sound_stereo;
- currprefs.sound_stereo_separation = changed_prefs.sound_stereo_separation;
- currprefs.sound_mixed_stereo = changed_prefs.sound_mixed_stereo;
- currprefs.sound_adjust = changed_prefs.sound_adjust;
- currprefs.sound_interpol = changed_prefs.sound_interpol;
- 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;
- if (currprefs.produce_sound >= 2) {
- if (!init_audio ()) {
- if (! sound_available) {
- write_log ("Sound is not supported.\n");
- } else {
- write_log ("Sorry, can't initialize sound.\n");
- currprefs.produce_sound = 0;
- /* So we don't do this every frame */
- changed_prefs.produce_sound = 0;
- }
+ currprefs.produce_sound = changed_prefs.produce_sound;
+ currprefs.win32_soundcard = changed_prefs.win32_soundcard;
+ currprefs.sound_stereo = changed_prefs.sound_stereo;
+ currprefs.sound_stereo_separation = changed_prefs.sound_stereo_separation;
+ currprefs.sound_mixed_stereo = changed_prefs.sound_mixed_stereo;
+ currprefs.sound_adjust = changed_prefs.sound_adjust;
+ currprefs.sound_interpol = changed_prefs.sound_interpol;
+ 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;
+ if (currprefs.produce_sound >= 2) {
+ if (!init_audio ()) {
+ if (! sound_available) {
+ write_log ("Sound is not supported.\n");
+ } else {
+ write_log ("Sorry, can't initialize sound.\n");
+ currprefs.produce_sound = 0;
+ /* So we don't do this every frame */
+ changed_prefs.produce_sound = 0;
}
}
- last_cycles = get_cycles () - 1;
- next_sample_evtime = scaled_sample_evtime;
- compute_vsynctime ();
}
+ last_cycles = get_cycles () - 1;
+ next_sample_evtime = scaled_sample_evtime;
+ compute_vsynctime ();
+
mixed_mul1 = MIXED_STEREO_MAX / 2 - ((currprefs.sound_stereo_separation * 3) / 2);
mixed_mul2 = MIXED_STEREO_MAX / 2 + ((currprefs.sound_stereo_separation * 3) / 2);
mixed_stereo_size = currprefs.sound_mixed_stereo > 0 ? (1 << (currprefs.sound_mixed_stereo - 1)) - 1 : 0;
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;
+ sound_use_filter = FILTER_MODEL_A500;
else if (currprefs.sound_filter_type == FILTER_SOUND_TYPE_A1200)
- sound_use_filter = FILTER_MODEL_A1200E;
+ sound_use_filter = FILTER_MODEL_A1200;
}
+ a500e_filter1_a0 = rc_calculate_a0(currprefs.sound_freq, 6200);
+ a500e_filter2_a0 = rc_calculate_a0(currprefs.sound_freq, 20000);
+ filter_a0 = rc_calculate_a0(currprefs.sound_freq, 7000);
+ led_filter_audio();
/* Select the right interpolation method. */
sample_prehandler = NULL;
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;
+ sample_prehandler = anti_sinc_prehandler;
if (currprefs.produce_sound == 0) {
eventtab[ev_audio].active = 0;
return init_sound ();
}
+
+void led_filter_audio (void)
+{
+ led_filter_on = 0;
+ if (led_filter_forced > 0 || (gui_data.powerled && led_filter_forced >= 0))
+ led_filter_on = 1;
+ gui_led (0, gui_data.powerled);
+}
+
uae_u8 *restore_audio (int i, uae_u8 *src)
{
struct audio_channel_data *acd;
if (bltstate == BLT_done)
return;
+ if (savestate_state)
+ return;
if (!warned && dmaen (DMA_BLITTER)) {
#ifndef BLITTER_DEBUG
cfgfile_write (f, "gfx_framerate=%d\n", p->gfx_framerate);
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_top_windowed=%d\n", p->gfx_size_win.x);
+ cfgfile_write (f, "gfx_left_windowed=%d\n", p->gfx_size_win.y);
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_intval (option, value, "gfx_framerate", &p->gfx_framerate, 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_top_windowed", &p->gfx_size_win.x, 1)
+ || cfgfile_intval (option, value, "gfx_left_windowed", &p->gfx_size_win.y, 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)
#include "akiko.h"
#include "debug.h"
#include "arcadia.h"
+#include "audio.h"
//#define CIA_DEBUG_R
//#define CIA_DEBUG_W
unsigned int ciabpra;
-unsigned int gui_ledstate;
-
static unsigned long ciaala, ciaalb, ciabla, ciablb;
static int ciaatodon, ciabtodon;
static unsigned int ciaapra, ciaaprb, ciaadra, ciaadrb, ciaasdr, ciaasdr_cnt;
if ((v & 2) != oldled) {
int led = (v & 2) ? 0 : 1;
oldled = v & 2;
- gui_led (0, led);
- gui_ledstate &= ~1;
gui_data.powerled = led;
- gui_ledstate |= led;
+ led_filter_audio();
}
if ((v & 1) != oldovl) {
oldovl = v & 1;
currprefs.comptrustlong = changed_prefs.comptrustlong;
currprefs.comptrustnaddr= changed_prefs.comptrustnaddr;
currprefs.compnf = changed_prefs.compnf;
- currprefs.comp_hardflush= changed_prefs.comp_hardflush;
- currprefs.comp_constjump= changed_prefs.comp_constjump;
- currprefs.comp_oldsegv= changed_prefs.comp_oldsegv;
- currprefs.compfpu= changed_prefs.compfpu;
+ currprefs.comp_hardflush = changed_prefs.comp_hardflush;
+ currprefs.comp_constjump = changed_prefs.comp_constjump;
+ currprefs.comp_oldsegv = changed_prefs.comp_oldsegv;
+ currprefs.compfpu = changed_prefs.compfpu;
+ currprefs.fpu_strict = changed_prefs.fpu_strict;
if (currprefs.cachesize!=changed_prefs.cachesize) {
currprefs.cachesize = changed_prefs.cachesize;
#endif
}
-STATIC_INLINE int current_hpos (void)
-{
- return (get_cycles () - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT;
-}
-
STATIC_INLINE uae_u8 *pfield_xlateptr (uaecptr plpt, int bytecount)
{
if (!chipmem_bank.check (plpt, bytecount)) {
dip = curr_drawinfo + next_lineno;
dip_old = prev_drawinfo + next_lineno;
dp = line_decisions + next_lineno;
+ dp->valid = 0;
changed = thisline_changed + interlace_started;
if (thisline_decision.plfleft != -1)
if (changed) {
thisline_changed = 1;
*dp = thisline_decision;
+ dp->valid = 1;
} else
/* The only one that may differ: */
dp->ctable = thisline_decision.ctable;
}
#ifdef AGA
+
+void dump_aga_custom (void)
+{
+ int c1, c2, c3, c4;
+ uae_u32 rgb1, rgb2, rgb3, rgb4;
+
+ for (c1 = 0; c1 < 64; c1++) {
+ c2 = c1 + 64;
+ c3 = c2 + 64;
+ c4 = c3 + 64;
+ rgb1 = current_colors.acolors[c1];
+ rgb2 = current_colors.acolors[c2];
+ rgb3 = current_colors.acolors[c3];
+ rgb4 = current_colors.acolors[c4];
+ console_out("%3d %06.6X %3d %06.6X %3d %06.6X %3d %06.6X\n",
+ c1, rgb1, c2, rgb2, c3, rgb3, c4, rgb4);
+ }
+}
+
static uae_u16 COLOR_READ (int num)
{
int cr, cg, cb, colreg;
*nxmem = addr;
}
-static void dump_custom_regs (void)
+static void dump_custom_regs (int aga)
{
int len, i, j, end;
uae_u8 *p1, *p2, *p3, *p4;
+ if (aga) {
+ dump_aga_custom();
+ return;
+ }
+
p1 = p2 = save_custom (&len, 0, 1);
p1 += 4; // skip chipset type
for (i = 0; i < 4; i++) {
addr = readhex (&inptr);
dump_vectors (addr);
break;
- case 'e': dump_custom_regs (); break;
+ case 'e': dump_custom_regs (tolower(*inptr) == 'a'); break;
case 'r': if (more_params(&inptr))
m68k_modify (&inptr);
else
static uae_u16 bigmfmbufw[0x4000 * DDHDMULT];
static drive floppy[MAX_FLOPPY_DRIVES];
-#define MAX_PREVIOUS_FLOPPIES 99
static char dfxhistory[MAX_PREVIOUS_FLOPPIES][MAX_DPATH];
static uae_u8 exeheader[]={0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00};
gui_data.drive_track[num] = drv->cyl;
gui_data.drive_side = side;
gui_data.drive_writing[num] = writ;
- gui_ledstate &= ~(2 << num);
- if (drv->state)
- gui_ledstate |= 2 << num;
gui_led (num + 1, gui_data.drive_motor[num]);
}
{
int i;
+ if (idx >= MAX_PREVIOUS_FLOPPIES)
+ return 0;
+ if (name == NULL) {
+ dfxhistory[idx][0] = 0;
+ return 1;
+ }
if (name[0] == 0)
return 0;
if (!zfile_exists (name))
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--;
+ linestate[lineno] = LINE_DONE_AS_PREVIOUS;
+ if (!dp_for_drawing->valid)
+ return;
if (dp_for_drawing->plfleft == -1)
border = 1;
- linestate[lineno] = LINE_DONE_AS_PREVIOUS;
break;
case LINE_DONE_AS_PREVIOUS:
num1 = idle / 100;
num2 = (idle - num1 * 100) / 10;
num3 = idle % 10;
- num4 = 13;
- am = 4;
- if (num1 == 0)
- am = 3;
+ num4 = num1 == 0 ? 13 : -1;
+ am = 3;
}
c = xcolors[on ? on_rgb : off_rgb];
last_redraw_point++;
if (lof_changed || ! interlace_seen || last_redraw_point >= 2 || long_frame) {
last_redraw_point = 0;
- interlace_seen = 0;
if (framecnt == 0)
finish_drawing_frame ();
+ interlace_seen = 0;
+
/* At this point, we have finished both the hardware and the
* drawing frame. Essentially, we are outside of all loops and
* can do some things which would cause confusion if they were
| (create == 2 ? O_TRUNC : 0));
fd = my_open (aino->nname, openmode | O_BINARY);
-
if (fd == NULL) {
if (aino_created)
delete_aino (unit, aino);
PUT_PCK_RES2 (packet, dos_errno ());
return;
}
+
k = new_key (unit);
k->fd = fd;
k->aino = aino;
k->createmode = create;
k->notifyactive = create ? 1 : 0;
+ if (create)
+ fsdb_set_file_attrs (aino);
+
put_long (fh+36, k->uniq);
if (create == 2)
aino->elock = 1;
return;
}
aino->shlock = 1;
+ fsdb_set_file_attrs (aino);
de_recycle_aino (unit, aino);
notify_check (unit, aino);
updatedirtime (aino, 0);
if (a2->parent)
fsdb_dir_writeback (a2->parent);
updatedirtime (a2, 1);
+ fsdb_set_file_attrs (a2);
if (a2->elock > 0 || a2->shlock > 0 || wehavekeys > 0)
de_recycle_aino (unit, a2);
PUT_PCK_RES1 (packet, DOS_TRUE);
extern void audio_update_adkmasks (void);
extern void audio_update_irq (uae_u16);
extern void update_sound (int freq);
+extern void led_filter_audio (void);
extern void audio_sampleripper(int);
extern int sampleripper_enabled;
extern void record_copper (uaecptr addr, int hpos, int vpos);
extern void record_copper_reset(void);
extern int snooper(uaecptr);
+extern void dump_aga_custom (void);
#else
#define DISK_DEBUG_DMA_WRITE 2
#define DISK_DEBUG_PIO 4
+#define MAX_PREVIOUS_FLOPPIES 99
+
unsigned int any_hires_sprites:1;
unsigned int ham_seen:1;
unsigned int ham_at_start:1;
+ unsigned int valid:1;
};
/* Anything related to changes in hw registers during the DDF for one
#include "events_normal.h"
#endif
+STATIC_INLINE int current_hpos (void)
+{
+ return (get_cycles () - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT;
+}
+
#endif
#define CONFIG_BLEN 2560
struct wh {
- int width;
- int height;
+ int x, y;
+ int width, height;
};
struct uae_prefs {
/* save, restore and initialize routines for Amiga's subsystems */
extern uae_u8 *restore_cpu (uae_u8 *);
+extern void restore_cpu_finish (void);
extern uae_u8 *save_cpu (int *, uae_u8 *);
extern uae_u8 *restore_fpu (uae_u8 *);
return 0;
}
+static char *kickstring = "exec.library";
int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksum, int *cloanto_rom)
{
unsigned char buffer[20];
- int i, cr = 0;
+ int i, j, cr = 0;
if (cloanto_rom)
*cloanto_rom = 0;
i = 524288;
dochecksum = 0;
}
- if (dochecksum && i >= 262144)
+ for (j = 0; j < 256 && i >= 262144; j++) {
+ if (!memcmp (kickmemory + j, kickstring, strlen (kickstring) + 1))
+ break;
+ }
+ if (j == 256 || i < 262144)
+ dochecksum = 0;
+
+ if (dochecksum)
kickstart_checksum (mem, size);
return i;
}
write_log ("CPU %d%s%03d, PC=%08.8X\n",
model / 1000, flags & 1 ? "EC" : "", model % 1000, regs.pc);
+ return src;
+}
+
+void restore_cpu_finish(void)
+{
init_m68k_full ();
m68k_setpc (regs.pc);
- return src;
}
static int cpumodel[] = { 68000, 68010, 68020, 68020, 68040, 68060 };
return 0;
}
+static int delete_uaefsdb (const char *dir)
+{
+ char *p;
+ int ret;
+
+ p = make_uaefsdbpath (dir, NULL);
+ ret = DeleteFile(p);
+ write_log("delete FSDB stream '%s' = %d\n", p, ret);
+ xfree (p);
+ return ret;
+}
+
static int write_uaefsdb (const char *dir, uae_u8 *fsdb)
{
char *p;
aino->has_dbentry = 0;
aino->dirty = 0;
aino->db_offset = 0;
+ if((mode = GetFileAttributes(aino->nname)) == INVALID_FILE_ATTRIBUTES) {
+ write_log("xGetFileAttributes('%s') failed! error=%d, aino=%p\n",
+ aino->nname, GetLastError(), aino);
+ return aino;
+ }
+ aino->dir = (mode & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0;
return aino;
}
aino->amigaos_mode = A_FIBF_EXECUTE | A_FIBF_READ;
if (!(FILE_ATTRIBUTE_ARCHIVE & mode))
aino->amigaos_mode |= A_FIBF_ARCHIVE;
- if (! (FILE_ATTRIBUTE_READONLY & mode))
+ if (!(FILE_ATTRIBUTE_READONLY & mode))
aino->amigaos_mode |= A_FIBF_WRITE | A_FIBF_DELETE;
if (FILE_ATTRIBUTE_SYSTEM & mode)
aino->amigaos_mode |= A_FIBF_PURE;
aino->amigaos_mode |= A_FIBF_HIDDEN;
aino->amigaos_mode = filesys_parse_mask(aino->amigaos_mode);
aino->amigaos_mode |= oldamode & A_FIBF_SCRIPT;
- if (reset) {
- if (base->volflags & MYVOLUMEINFO_STREAMS) {
- create_uaefsdb (aino, fsdb, mode);
- write_uaefsdb (aino->nname, fsdb);
- }
+ if (reset && (base->volflags & MYVOLUMEINFO_STREAMS)) {
+ create_uaefsdb (aino, fsdb, mode);
+ write_uaefsdb (aino->nname, fsdb);
}
return 1;
}
+static int needs_fsdb (a_inode *aino)
+{
+ const char *nn_begin;
+
+ if (aino->deleted)
+ return 0;
+
+ if (!fsdb_mode_representable_p (aino) || aino->comment != 0)
+ return 1;
+
+ nn_begin = nname_begin (aino->nname);
+ return strcmp (nn_begin, aino->aname) != 0;
+}
+
int fsdb_set_file_attrs (a_inode *aino)
{
uae_u32 tmpmask;
aino->dirty = 1;
if (aino->volflags & MYVOLUMEINFO_STREAMS) {
- create_uaefsdb (aino, fsdb, mode);
- write_uaefsdb (aino->nname, fsdb);
+ if (needs_fsdb(aino)) {
+ create_uaefsdb (aino, fsdb, mode);
+ write_uaefsdb (aino->nname, fsdb);
+ } else {
+ delete_uaefsdb (aino->nname);
+ }
}
return 0;
}
SetFileAttributes (name, FILE_ATTRIBUTE_NORMAL);
h = CreateFile (name, DesiredAccess, ShareMode, NULL, CreationDisposition, FlagsAndAttributes, NULL);
if (h == INVALID_HANDLE_VALUE) {
- if (GetLastError () == ERROR_ACCESS_DENIED && (DesiredAccess & GENERIC_WRITE)) {
+ DWORD err = GetLastError();
+ if (err == ERROR_ACCESS_DENIED && (DesiredAccess & GENERIC_WRITE)) {
DesiredAccess &= ~GENERIC_WRITE;
h = CreateFile (name, DesiredAccess, ShareMode, NULL, CreationDisposition, FlagsAndAttributes, NULL);
+ if (h == INVALID_HANDLE_VALUE)
+ err = GetLastError();
}
if (h == INVALID_HANDLE_VALUE) {
- write_log ("failed to open '%s' %x %x\n", name, DesiredAccess, CreationDisposition);
+ write_log ("failed to open '%s' %x %x err=%d\n", name, DesiredAccess, CreationDisposition, err);
xfree (mos);
- mos = 0;
+ mos = NULL;
goto err;
}
}
#define IDC_QUICKSTART_COMPATIBILITY 1676
#define IDC_PATHS_AVIOUTPUTS 1676
#define IDC_QUICKSTART_CONFIG 1677
+#define IDC_RESETREGISTRY2 1677
+#define IDC_RESETDISKHISTORY 1677
#define IDC_DF0Q 1678
#define IDC_DF0QQ 1678
#define IDC_DF1Q 1679
EDITTEXT IDC_SOUNDADJUSTNUM,124,224,40,12,ES_CENTER | ES_READONLY
PUSHBUTTON "Calibrate",IDC_SOUNDCALIBRATE,183,223,40,14
COMBOBOX IDC_SOUNDSWAP,73,144,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- LTEXT "Swap channels:",IDC_SOUNDSWAPTXT,82,135,50,8,SS_CENTERIMAGE
+ LTEXT "Swap channels:",IDC_SOUNDSWAPTXT,74,135,50,8,SS_CENTERIMAGE
END
IDD_LOADSAVE DIALOGEX 0, 0, 302, 241
PUSHBUTTON "...",IDC_PATHS_SAVEIMAGES,281,175,11,15
PUSHBUTTON "Reset to defaults",IDC_PATHS_DEFAULT,14,199,92,14
PUSHBUTTON "Rescan ROMs",IDC_ROM_RESCAN,14,218,92,14
- PUSHBUTTON "Clear registry",IDC_RESETREGISTRY,190,217,85,14
+ PUSHBUTTON "Clear registry",IDC_RESETREGISTRY,112,218,77,14
COMBOBOX IDC_PATHS_DEFAULTTYPE,112,199,163,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Clear disk history",IDC_RESETDISKHISTORY,198,218,77,14
END
IDD_QUICKSTART DIALOGEX 0, 0, 300, 242
}
}
+#if 0
static void filtercheck (uae_s16 *sndbuffer, int len)
{
int ch = currprefs.sound_stereo == 2 ? 4 : (currprefs.sound_stereo ? 2 : 1);
}
}
}
+#endif
void finish_sound_buffer (void)
{
if (turbo_emulation)
return;
+#if 0 /* done completely in audio.c now */
if (currprefs.sound_filter && currprefs.sound_freq != 44100)
filtercheck((uae_s16*)sndbuffer, sndbufsize / 2);
+#endif
if (currprefs.sound_stereo == 1 && currprefs.sound_stereo_swap_paula)
channelswap((uae_s16*)sndbuffer, sndbufsize / 2);
#ifdef DRIVESOUND
ClipCursor (&amigawin_rect);
}
mousecapture = 1;
+ setcursor (-1, -1);
}
- setcursor (-1, -1);
}
inputdevice_acquire ();
}
setmousebuttonstate (dinput_winmouse(), num, updown);
}
+#define MSGDEBUG 0
+
static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
static int mm;
static int minimized;
+#if MSGDEBUG
+ write_log ("AWP: %x %d\n", hWnd, message);
+#endif
+
if (ignore_messages_all)
return DefWindowProc (hWnd, message, wParam, lParam);
switch (message)
{
+ case WM_SETCURSOR:
+ return TRUE;
case WM_SIZE:
{
-#if 0
- write_log ("WM_SIZE %d %d\n", wParam, minimized);
+#if MSGDEBUG
+ write_log ("WM_SIZE %x %d %d\n", hWnd, wParam, minimized);
#endif
if (isfullscreen ()) {
v = minimized;
}
case WM_ACTIVATE:
-#if 0
- write_log ("WM_ACTIVE %d %d %d\n", HIWORD (wParam), LOWORD (wParam), minimized);
+#if MSGDEBUG
+ write_log ("WM_ACTIVE %x %d %d %d\n", hWnd, HIWORD (wParam), LOWORD (wParam), minimized);
#endif
if (!isfullscreen ()) {
minimized = HIWORD (wParam);
break;
case WM_ACTIVATEAPP:
-#if 0
- write_log ("WM_ACTIVATEAPP %d %d\n", wParam, minimized);
+#if MSGDEBUG
+ write_log ("WM_ACTIVATEAPP %x %d %d\n", hWnd, wParam, minimized);
#endif
activateapp = wParam;
if (!wParam) {
case WM_WINDOWPOSCHANGED:
GetWindowRect (hWnd, &amigawin_rect);
+ if (!isfullscreen()) {
+ currprefs.gfx_size_win.x = amigawin_rect.left;
+ currprefs.gfx_size_win.y = amigawin_rect.top;
+ }
break;
case WM_MOUSEMOVE:
RECT rc;
HDC hDC;
+#if MSGDEBUG
+ write_log ("MWP: %x %d\n", hWnd, message);
+#endif
+
switch (message)
{
case WM_MOUSEMOVE:
case WM_WINDOWPOSCHANGED:
WIN32GFX_WindowMove();
- if( hAmigaWnd && GetWindowRect(hAmigaWnd, &amigawin_rect)) {
+ if (hAmigaWnd && GetWindowRect(hAmigaWnd, &amigawin_rect)) {
if (in_sizemove > 0)
break;
static int store_xy;
RECT rc2;
if (GetWindowRect(hMainWnd, &rc2)) {
+ DWORD left = rc2.left - win_x_diff;
+ DWORD top = rc2.top - win_y_diff;
if (amigawin_rect.left & 3) {
- MoveWindow (hMainWnd, rc2.left+ 4 - amigawin_rect.left % 4, rc2.top,
+ MoveWindow (hMainWnd, rc2.left + 4 - amigawin_rect.left % 4, rc2.top,
rc2.right - rc2.left, rc2.bottom - rc2.top, TRUE);
}
if (hWinUAEKey && store_xy++) {
- DWORD left = rc2.left - win_x_diff;
- DWORD top = rc2.top - win_y_diff;
RegSetValueEx(hWinUAEKey, "xPos", 0, REG_DWORD, (LPBYTE)&left, sizeof(LONG));
RegSetValueEx(hWinUAEKey, "yPos", 0, REG_DWORD, (LPBYTE)&top, sizeof(LONG));
}
+ currprefs.gfx_size_win.x = left;
+ currprefs.gfx_size_win.y = top;
}
return 0;
}
emulation_paused = 0;
manual_painting_needed--;
}
-
}
/* We're not a console-app anymore! */
extern int mouseactive, focus;
extern int ignore_messages_all;
#define WINUAEBETA 1
-#define WINUAEBETASTR " Beta 2"
+#define WINUAEBETASTR " Beta 3"
extern char start_path_exe[MAX_DPATH];
extern char start_path_data[MAX_DPATH];
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.gfx_size_win.x != changed_prefs.gfx_size_win.x ? 16 : 0;
+ c |= currprefs.gfx_size_win.y != changed_prefs.gfx_size_win.y ? 16 : 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_lores != changed_prefs.gfx_lores ? 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.gfx_display != changed_prefs.gfx_display ? (1|4|8) : 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;
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.gfx_size_win.x = changed_prefs.gfx_size_win.x;
+ currprefs.gfx_size_win.y = changed_prefs.gfx_size_win.y;
currprefs.color_mode = changed_prefs.color_mode;
currprefs.gfx_afullscreen = changed_prefs.gfx_afullscreen;
currprefs.gfx_pfullscreen = changed_prefs.gfx_pfullscreen;
};
static struct ToolTipHWNDS ToolTipHWNDS2[MAX_IMAGETOOLTIPS + 1];
+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 <= MAX_PREVIOUS_FLOPPIES; 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 <= MAX_PREVIOUS_FLOPPIES) {
+ char *s = "";
+ sprintf (tmp, "Image%02d", j);
+ RegSetValueEx (fkey, tmp, 0, REG_SZ, (CONST BYTE *)s, strlen(s) + 1);
+ j++;
+ }
+ RegCloseKey(fkey);
+}
+
+void reset_disk_history (void)
+{
+ int i;
+
+ for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++)
+ DISK_history_add (NULL, i);
+ write_disk_history();
+}
+
+HKEY read_disk_history (void)
+{
+ static int regread;
+ char tmp2[1000];
+ DWORD size2;
+ int idx, idx2;
+ HKEY fkey;
+ char tmp[1000];
+ DWORD size;
+
+ if (!hWinUAEKey)
+ return NULL;
+ RegCreateKeyEx(hWinUAEKey , "DiskImageMRUList", 0, NULL, REG_OPTION_NON_VOLATILE,
+ KEY_READ | KEY_WRITE, NULL, &fkey, NULL);
+ if (fkey == NULL || regread)
+ return fkey;
+
+ idx = 0;
+ for (;;) {
+ int err;
+ size = sizeof (tmp);
+ size2 = sizeof (tmp2);
+ err = RegEnumValue (fkey, idx, tmp, &size, NULL, NULL, tmp2, &size2);
+ if (err != ERROR_SUCCESS)
+ break;
+ if (strlen (tmp) == 7) {
+ idx2 = atol (tmp + 5) - 1;
+ if (idx2 >= 0)
+ DISK_history_add (tmp2, idx2);
+ }
+ idx++;
+ }
+ regread = 1;
+ return fkey;
+}
+
void exit_gui (int ok)
{
if (!gui_active)
DX_SetPalette (0, 256);
#endif
screenshot_free();
+ write_disk_history();
here--;
}
case IDC_RESETREGISTRY:
resetregistry ();
break;
+ case IDC_RESETDISKHISTORY:
+ reset_disk_history ();
+ break;
}
recursive--;
}
CheckDlgButton (hDlg, IDC_SHOWGUI, workprefs.start_gui);
CheckDlgButton (hDlg, IDC_JULIAN, workprefs.win32_middle_mouse);
CheckDlgButton (hDlg, IDC_CREATELOGFILE, workprefs.win32_logfile);
- CheckDlgButton (hDlg, IDC_INACTIVE_PAUSE, workprefs.win32_inactive_pause);
- CheckDlgButton (hDlg, IDC_INACTIVE_NOSOUND, workprefs.win32_inactive_nosound || workprefs.win32_inactive_pause);
- CheckDlgButton (hDlg, IDC_MINIMIZED_PAUSE, workprefs.win32_iconified_pause);
- CheckDlgButton (hDlg, IDC_MINIMIZED_NOSOUND, workprefs.win32_iconified_nosound || workprefs.win32_iconified_pause);
CheckDlgButton (hDlg, IDC_CTRLF11, workprefs.win32_ctrl_F11_is_quit);
CheckDlgButton (hDlg, IDC_NOOVERLAY, workprefs.win32_no_overlay);
CheckDlgButton (hDlg, IDC_SHOWLEDS, workprefs.leds_on_screen);
} else if (currentpage == MISC2_ID) {
+ CheckDlgButton (hDlg, IDC_INACTIVE_PAUSE, workprefs.win32_inactive_pause);
+ CheckDlgButton (hDlg, IDC_INACTIVE_NOSOUND, workprefs.win32_inactive_nosound || workprefs.win32_inactive_pause);
+ CheckDlgButton (hDlg, IDC_MINIMIZED_PAUSE, workprefs.win32_iconified_pause);
+ CheckDlgButton (hDlg, IDC_MINIMIZED_NOSOUND, workprefs.win32_iconified_nosound || workprefs.win32_iconified_pause);
misc_addpri (hDlg, IDC_ACTIVE_PRIORITY, workprefs.win32_active_priority);
misc_addpri (hDlg, IDC_INACTIVE_PRIORITY, workprefs.win32_inactive_priority);
misc_addpri (hDlg, IDC_MINIMIZED_PRIORITY, workprefs.win32_iconified_priority);
#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;
- char tmp2[1000];
- DWORD size2;
- int idx, idx2;
- HKEY fkey;
- char tmp[1000];
- DWORD size;
-
- if (!hWinUAEKey)
- return NULL;
- RegCreateKeyEx(hWinUAEKey , "DiskImageMRUList", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_READ | KEY_WRITE, NULL, &fkey, NULL);
- if (fkey == NULL || regread)
- return fkey;
-
- idx = 0;
- for (;;) {
- int err;
- size = sizeof (tmp);
- size2 = sizeof (tmp2);
- err = RegEnumValue (fkey, idx, tmp, &size, NULL, NULL, tmp2, &size2);
- if (err != ERROR_SUCCESS)
- break;
- if (strlen (tmp) == 7) {
- idx2 = atol (tmp + 5) - 1;
- if (idx2 >= 0)
- DISK_history_add (tmp2, idx2);
- }
- idx++;
- }
- regread = 1;
- return fkey;
-}
-
static void out_floppyspeed (HWND hDlg)
{
char txt[30];
#include "sysdeps.h"
#include <windows.h>
+#include <sys/timeb.h>
+
+#include "custom.h"
+#include "events.h"
#define SHOW_CONSOLE 0
{
if(consoleopen) return;
AllocConsole();
- stdinput=GetStdHandle(STD_INPUT_HANDLE);
- stdoutput=GetStdHandle(STD_OUTPUT_HANDLE);
+ stdinput = GetStdHandle(STD_INPUT_HANDLE);
+ stdoutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleMode(stdinput,ENABLE_PROCESSED_INPUT|ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT|ENABLE_PROCESSED_OUTPUT);
consoleopen = 1;
}
{
}
+static int lfdetected = 1;
+
+static char *writets(void)
+{
+ struct tm *t;
+ struct _timeb tb;
+ static char out[100];
+ char *p;
+ static char lastts[100];
+ char curts[100];
+
+ _ftime(&tb);
+ t = localtime(&tb.time);
+ strftime(curts, sizeof curts, "%Y-%m-%d %H:%M:%S\n", t);
+ p = out;
+ *p = 0;
+ if (memcmp (curts, lastts, strlen (curts))) {
+ strcat (p, curts);
+ p += strlen (p);
+ strcpy (lastts, curts);
+ }
+ strftime(p, sizeof out - (p - out) , "%S-", t);
+ p += strlen(p);
+ sprintf(p, "%03d", tb.millitm);
+ p += strlen(p);
+ if (timeframes || vpos > 0 && current_hpos() > 0)
+ sprintf (p, " [%d %03dx%03d]", timeframes, current_hpos(), vpos);
+ strcat (p, ": ");
+ return out;
+}
+
+
void write_dlog (const char *format, ...)
{
int count;
DWORD numwritten;
char buffer[WRITE_LOG_BUF_SIZE];
+ char *ts;
va_list parms;
va_start (parms, format);
- count = _vsnprintf( buffer, WRITE_LOG_BUF_SIZE-1, format, parms );
+ count = _vsnprintf(buffer, WRITE_LOG_BUF_SIZE-1, format, parms);
+ ts = writets();
if (SHOW_CONSOLE || console_logging) {
openconsole();
- WriteConsole(stdoutput,buffer,strlen(buffer),&numwritten,0);
+ if (lfdetected)
+ WriteConsole(stdoutput, ts, strlen(ts), &numwritten,0);
+ WriteConsole(stdoutput, buffer, strlen(buffer), &numwritten,0);
}
if (debugfile) {
- fprintf( debugfile, buffer );
- fflush (debugfile);
+ if (lfdetected)
+ fprintf(debugfile, ts);
+ fprintf(debugfile, buffer);
+ fflush(debugfile);
}
+ lfdetected = 0;
+ if (strlen(buffer) > 0 && buffer[strlen(buffer) - 1] == '\n')
+ lfdetected = 1;
va_end (parms);
}
void write_log (const char *format, ...)
{
int count, tmp;
DWORD numwritten;
- char buffer[WRITE_LOG_BUF_SIZE];
+ char buffer[WRITE_LOG_BUF_SIZE], *ts;
va_list parms;
- va_start (parms, format);
- count = _vsnprintf( buffer, WRITE_LOG_BUF_SIZE-1, format, parms );
+ va_start(parms, format);
+ count = _vsnprintf(buffer, WRITE_LOG_BUF_SIZE-1, format, parms);
+ ts = writets();
if (SHOW_CONSOLE || console_logging) {
openconsole();
- tmp = WriteConsole(stdoutput,buffer,strlen(buffer),&numwritten,0);
+ if (lfdetected)
+ WriteConsole(stdoutput, ts, strlen(ts), &numwritten,0);
+ tmp = WriteConsole(stdoutput, buffer, strlen(buffer), &numwritten, 0);
if (!tmp)
tmp = GetLastError();
}
if (debugfile) {
- fprintf (debugfile, buffer);
- fflush (debugfile);
+ if (lfdetected)
+ fprintf(debugfile, ts);
+ fprintf(debugfile, buffer);
+ fflush(debugfile);
}
+ lfdetected = 0;
+ if (strlen(buffer) > 0 && buffer[strlen(buffer) - 1] == '\n')
+ lfdetected = 1;
va_end (parms);
}
zfile_fclose (savestate_file);
savestate_file = 0;
savestate_state = 0;
+ restore_cpu_finish();
}
/* 1=compressed,2=not compressed,3=ram dump,4=audio dump */