From 4e7c253b8e86cb100cce3d16263344d6980e5aee Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 13 Oct 2007 19:34:32 +0300 Subject: [PATCH] imported winuaesrc1450b3.zip --- amax.c | 158 +++++++++++++++++ cfgfile.c | 196 +++++++++++----------- cia.c | 4 + custom.c | 3 +- debug.c | 16 +- disk.c | 70 +++++++- enforcer.c | 2 +- expansion.c | 2 +- include/amax.h | 7 + include/options.h | 1 + include/savestate.h | 1 + inputdevice.c | 21 ++- od-win32/dinput.c | 108 ++++++++---- od-win32/sysconfig.h | 1 + od-win32/win32.c | 8 +- od-win32/win32.h | 4 +- od-win32/win32gui.c | 5 +- od-win32/winuae_msvc/winuae_msvc.8.vcproj | 4 + od-win32/winuae_msvc/winuae_msvc.vcproj | 4 + od-win32/winuaechangelog.txt | 22 ++- od-win32/writelog.c | 26 ++- sana2.c | 84 ++++++++-- savestate.c | 1 + zfile.c | 5 +- 24 files changed, 575 insertions(+), 178 deletions(-) create mode 100755 amax.c create mode 100755 include/amax.h diff --git a/amax.c b/amax.c new file mode 100755 index 00000000..b477e854 --- /dev/null +++ b/amax.c @@ -0,0 +1,158 @@ + +#include "sysconfig.h" +#include "sysdeps.h" + +#include "options.h" +#include "zfile.h" +#include "amax.h" +#include "custom.h" +#include "memory.h" +#include "newcpu.h" + +static int data_scramble[8] = { 3, 2, 4, 5, 7, 6, 0, 1 }; +static int addr_scramble[16] = { 14, 12, 2, 10, 15, 13, 1, 0, 7, 6, 5, 4, 8, 9, 11, 3 }; + +static int romptr; +static uae_u8 *rom; +static int rom_size, rom_oddeven; +static uae_u8 data; +static uae_u8 bfd100, bfe001; +static uae_u8 dselect; + +#define AMAX_LOG 0 + +static void load_byte (void) +{ + int addr, i; + uae_u8 val, v; + + v = 0xff; + addr = 0; + for (i = 0; i < 16; i++) { + if (romptr & (1 << i)) + addr |= 1 << addr_scramble[i]; + } + if (rom_oddeven < 0) { + val = v; + } else { + v = rom[addr * 2 + rom_oddeven]; + val = 0; + for (i = 0; i < 8; i++) { + if (v & (1 << data_scramble[i])) + val |= 1 << i; + } + } + data = val; + if (AMAX_LOG > 0) + write_log ("AMAX: load byte, rom=%d addr=%06x (%06x) data=%02x (%02x) PC=%08X\n", rom_oddeven, romptr, addr, v, val, M68K_GETPC); +} + +static void amax_check (void) +{ + /* DIR low = reset address counter */ + if ((bfd100 & 2)) { + if (romptr && AMAX_LOG > 0) + write_log ("AMAX: counter reset PC=%08X\n", M68K_GETPC); + romptr = 0; + } +} + +static int dwlastbit; + +void amax_diskwrite (uae_u16 w) +{ + int i; + + /* this is weird, 1->0 transition in disk write line increases address pointer.. */ + for (i = 0; i < 16; i++) { + if (dwlastbit && !(w & 0x8000)) { + romptr++; + if (AMAX_LOG > 0) + write_log ("AMAX: counter increase %d PC=%08X\n", romptr, M68K_GETPC); + } + dwlastbit = (w & 0x8000) ? 1 : 0; + w <<= 1; + } + romptr &= rom_size - 1; + amax_check (); +} + +static uae_u8 bfe001_ov; + +void amax_bfe001_write (uae_u8 pra, uae_u8 dra) +{ + uae_u8 v = dra & pra; + + bfe001 = v; + /* CHNG low -> high: shift data register */ + if ((v & 4) && !(bfe001_ov & 4)) { + data <<= 1; + data |= 1; + if (AMAX_LOG > 0) + write_log ("AMAX: data shifted\n"); + } + /* TK0 = even, WPRO = odd */ + rom_oddeven = -1; + if ((v & (8 | 16)) != (8 | 16)) { + rom_oddeven = 0; + if (!(v & 16)) + rom_oddeven = 1; + } + bfe001_ov = v; + amax_check (); +} + +void amax_disk_select (uae_u8 v, uae_u8 ov) +{ + bfd100 = v; + + if (!(bfd100 & dselect) && (ov & dselect)) + load_byte (); + amax_check (); +} + +uae_u8 amax_disk_status (void) +{ + uae_u8 st = 0x3c; + + if (!(data & 0x80)) + st &= ~0x20; + return st; +} + +void amax_reset (void) +{ + romptr = 0; + rom_oddeven = 0; + bfe001_ov = 0; + dwlastbit = 0; + data = 0xff; + xfree (rom); + rom = NULL; + dselect = 0; +} + +void amax_init (void) +{ + struct zfile *z; + + if (!currprefs.amaxromfile[0]) + return; + amax_reset (); + z = zfile_fopen (currprefs.amaxromfile, "rb"); + if (!z) { + write_log ("AMAX: failed to load rom '%s'\n", currprefs.amaxromfile); + return; + } + zfile_fseek (z, 0, SEEK_END); + rom_size = zfile_ftell (z); + zfile_fseek (z, 0, SEEK_SET); + rom = xmalloc (rom_size); + zfile_fread (rom, rom_size, 1, z); + zfile_fclose (z); + write_log ("AMAX: '%s' loaded, %d bytes\n", currprefs.amaxromfile, rom_size); + dselect = 0x20; +} + + + diff --git a/cfgfile.c b/cfgfile.c index 6dc021fe..ae1fde39 100755 --- a/cfgfile.c +++ b/cfgfile.c @@ -226,7 +226,7 @@ void cfgfile_dwrite (struct zfile *f, char *format,...) va_start (parms, format); vsprintf (tmp, format, parms); - if (!isdefault (tmp)) + if (1 || !isdefault (tmp)) zfile_fwrite (tmp, 1, strlen (tmp), f); va_end (parms); } @@ -324,7 +324,7 @@ static void write_compatibility_cpu(struct zfile *f, struct uae_prefs *p) sprintf(tmp, "%d", model); if (model == 68020 && (p->fpu_model == 68881 || p->fpu_model == 68882)) strcat(tmp,"/68881"); - cfgfile_dwrite (f, "cpu_type=%s\n", tmp); + cfgfile_write (f, "cpu_type=%s\n", tmp); } void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) @@ -357,33 +357,39 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write (f, "; common\n"); - cfgfile_dwrite (f, "use_gui=%s\n", guimode1[p->start_gui]); - cfgfile_dwrite (f, "use_debugger=%s\n", p->start_debugger ? "true" : "false"); + cfgfile_write (f, "use_gui=%s\n", guimode1[p->start_gui]); + cfgfile_write (f, "use_debugger=%s\n", p->start_debugger ? "true" : "false"); str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->romfile); - cfgfile_dwrite (f, "kickstart_rom_file=%s\n", str); + cfgfile_write (f, "kickstart_rom_file=%s\n", str); free (str); if (p->romident[0]) cfgfile_dwrite (f, "kickstart_rom=%s\n", p->romident); str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->romextfile); - cfgfile_dwrite (f, "kickstart_ext_rom_file=%s\n", str); + cfgfile_write (f, "kickstart_ext_rom_file=%s\n", str); free (str); if (p->romextident[0]) - cfgfile_dwrite (f, "kickstart_ext_rom=%s\n", p->romextident); + cfgfile_write (f, "kickstart_ext_rom=%s\n", p->romextident); str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->flashfile); - cfgfile_dwrite (f, "flash_file=%s\n", str); + cfgfile_write (f, "flash_file=%s\n", str); free (str); str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->cartfile); - cfgfile_dwrite (f, "cart_file=%s\n", str); + cfgfile_write (f, "cart_file=%s\n", str); free (str); if (p->cartident[0]) - cfgfile_dwrite (f, "cart=%s\n", p->cartident); - //cfgfile_dwrite (f, "cart_internal=%s\n", cartsmode[p->cart_internal]); - cfgfile_dwrite (f, "kickshifter=%s\n", p->kickshifter ? "true" : "false"); + cfgfile_write (f, "cart=%s\n", p->cartident); + //cfgfile_write (f, "cart_internal=%s\n", cartsmode[p->cart_internal]); + if (p->amaxromfile[0]) { + str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->amaxromfile); + cfgfile_write (f, "amax_rom_file=%s\n", str); + free (str); + } + + cfgfile_write (f, "kickshifter=%s\n", p->kickshifter ? "true" : "false"); p->nr_floppies = 4; for (i = 0; i < 4; i++) { str = cfgfile_subst_path (p->path_floppy, UNEXPANDED, p->df[i]); - cfgfile_dwrite (f, "floppy%d=%s\n", i, str); + cfgfile_write (f, "floppy%d=%s\n", i, str); free (str); cfgfile_dwrite (f, "floppy%dtype=%d\n", i, p->dfxtype[i]); cfgfile_dwrite (f, "floppy%dsound=%d\n", i, p->dfxclick[i]); @@ -397,53 +403,53 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_dwrite (f, "diskimage%d=%s\n", i, p->dfxlist[i]); } - cfgfile_dwrite (f, "nr_floppies=%d\n", p->nr_floppies); - cfgfile_dwrite (f, "floppy_speed=%d\n", p->floppy_speed); - cfgfile_dwrite (f, "floppy_volume=%d\n", p->dfxclickvolume); - cfgfile_dwrite (f, "parallel_on_demand=%s\n", p->parallel_demand ? "true" : "false"); - cfgfile_dwrite (f, "serial_on_demand=%s\n", p->serial_demand ? "true" : "false"); - cfgfile_dwrite (f, "serial_hardware_ctsrts=%s\n", p->serial_hwctsrts ? "true" : "false"); - cfgfile_dwrite (f, "serial_direct=%s\n", p->serial_direct ? "true" : "false"); - cfgfile_dwrite (f, "scsi=%s\n", scsimode[p->scsi]); - cfgfile_dwrite (f, "uaeserial=%s\n", p->uaeserial ? "true" : "false"); - cfgfile_dwrite (f, "sana2=%s\n", p->sana2[0] ? p->sana2 : "none"); - - cfgfile_dwrite (f, "sound_output=%s\n", soundmode1[p->produce_sound]); - cfgfile_dwrite (f, "sound_bits=%d\n", p->sound_bits); - cfgfile_dwrite (f, "sound_channels=%s\n", stereomode[p->sound_stereo]); - cfgfile_dwrite (f, "sound_stereo_separation=%d\n", p->sound_stereo_separation); - cfgfile_dwrite (f, "sound_stereo_mixing_delay=%d\n", p->sound_mixed_stereo_delay >= 0 ? p->sound_mixed_stereo_delay : 0); - cfgfile_dwrite (f, "sound_max_buff=%d\n", p->sound_maxbsiz); - cfgfile_dwrite (f, "sound_frequency=%d\n", p->sound_freq); - cfgfile_dwrite (f, "sound_latency=%d\n", p->sound_latency); - cfgfile_dwrite (f, "sound_interpol=%s\n", interpolmode[p->sound_interpol]); - cfgfile_dwrite (f, "sound_filter=%s\n", soundfiltermode1[p->sound_filter]); - cfgfile_dwrite (f, "sound_filter_type=%s\n", soundfiltermode2[p->sound_filter_type]); - cfgfile_dwrite (f, "sound_volume=%d\n", p->sound_volume); - cfgfile_dwrite (f, "sound_auto=%s\n", p->sound_auto ? "yes" : "no"); - cfgfile_dwrite (f, "sound_stereo_swap_paula=%s\n", p->sound_stereo_swap_paula ? "yes" : "no"); - cfgfile_dwrite (f, "sound_stereo_swap_ahi=%s\n", p->sound_stereo_swap_ahi ? "yes" : "no"); - - cfgfile_dwrite (f, "comp_trustbyte=%s\n", compmode[p->comptrustbyte]); - cfgfile_dwrite (f, "comp_trustword=%s\n", compmode[p->comptrustword]); - cfgfile_dwrite (f, "comp_trustlong=%s\n", compmode[p->comptrustlong]); - cfgfile_dwrite (f, "comp_trustnaddr=%s\n", compmode[p->comptrustnaddr]); - cfgfile_dwrite (f, "comp_nf=%s\n", p->compnf ? "true" : "false"); - cfgfile_dwrite (f, "comp_constjump=%s\n", p->comp_constjump ? "true" : "false"); - cfgfile_dwrite (f, "comp_oldsegv=%s\n", p->comp_oldsegv ? "true" : "false"); - - cfgfile_dwrite (f, "comp_flushmode=%s\n", flushmode[p->comp_hardflush]); - cfgfile_dwrite (f, "compforcesettings=%s\n", p->compforcesettings ? "true" : "false"); - cfgfile_dwrite (f, "compfpu=%s\n", p->compfpu ? "true" : "false"); - cfgfile_dwrite (f, "fpu_strict=%s\n", p->fpu_strict ? "true" : "false"); - cfgfile_dwrite (f, "comp_midopt=%s\n", p->comp_midopt ? "true" : "false"); - cfgfile_dwrite (f, "comp_lowopt=%s\n", p->comp_lowopt ? "true" : "false"); - cfgfile_dwrite (f, "avoid_cmov=%s\n", p->avoid_cmov ? "true" : "false" ); - cfgfile_dwrite (f, "avoid_dga=%s\n", p->avoid_dga ? "true" : "false" ); - cfgfile_dwrite (f, "avoid_vid=%s\n", p->avoid_vid ? "true" : "false" ); - cfgfile_dwrite (f, "cachesize=%d\n", p->cachesize); + cfgfile_write (f, "nr_floppies=%d\n", p->nr_floppies); + cfgfile_write (f, "floppy_speed=%d\n", p->floppy_speed); + cfgfile_write (f, "floppy_volume=%d\n", p->dfxclickvolume); + cfgfile_write (f, "parallel_on_demand=%s\n", p->parallel_demand ? "true" : "false"); + cfgfile_write (f, "serial_on_demand=%s\n", p->serial_demand ? "true" : "false"); + cfgfile_write (f, "serial_hardware_ctsrts=%s\n", p->serial_hwctsrts ? "true" : "false"); + cfgfile_write (f, "serial_direct=%s\n", p->serial_direct ? "true" : "false"); + cfgfile_write (f, "scsi=%s\n", scsimode[p->scsi]); + cfgfile_write (f, "uaeserial=%s\n", p->uaeserial ? "true" : "false"); + cfgfile_write (f, "sana2=%s\n", p->sana2[0] ? p->sana2 : "none"); + + cfgfile_write (f, "sound_output=%s\n", soundmode1[p->produce_sound]); + cfgfile_write (f, "sound_bits=%d\n", p->sound_bits); + cfgfile_write (f, "sound_channels=%s\n", stereomode[p->sound_stereo]); + cfgfile_write (f, "sound_stereo_separation=%d\n", p->sound_stereo_separation); + cfgfile_write (f, "sound_stereo_mixing_delay=%d\n", p->sound_mixed_stereo_delay >= 0 ? p->sound_mixed_stereo_delay : 0); + cfgfile_write (f, "sound_max_buff=%d\n", p->sound_maxbsiz); + cfgfile_write (f, "sound_frequency=%d\n", p->sound_freq); + cfgfile_write (f, "sound_latency=%d\n", p->sound_latency); + cfgfile_write (f, "sound_interpol=%s\n", interpolmode[p->sound_interpol]); + 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, "sound_auto=%s\n", p->sound_auto ? "yes" : "no"); + cfgfile_write (f, "sound_stereo_swap_paula=%s\n", p->sound_stereo_swap_paula ? "yes" : "no"); + cfgfile_write (f, "sound_stereo_swap_ahi=%s\n", p->sound_stereo_swap_ahi ? "yes" : "no"); + + cfgfile_write (f, "comp_trustbyte=%s\n", compmode[p->comptrustbyte]); + cfgfile_write (f, "comp_trustword=%s\n", compmode[p->comptrustword]); + cfgfile_write (f, "comp_trustlong=%s\n", compmode[p->comptrustlong]); + cfgfile_write (f, "comp_trustnaddr=%s\n", compmode[p->comptrustnaddr]); + cfgfile_write (f, "comp_nf=%s\n", p->compnf ? "true" : "false"); + cfgfile_write (f, "comp_constjump=%s\n", p->comp_constjump ? "true" : "false"); + cfgfile_write (f, "comp_oldsegv=%s\n", p->comp_oldsegv ? "true" : "false"); + + cfgfile_write (f, "comp_flushmode=%s\n", flushmode[p->comp_hardflush]); + cfgfile_write (f, "compforcesettings=%s\n", p->compforcesettings ? "true" : "false"); + cfgfile_write (f, "compfpu=%s\n", p->compfpu ? "true" : "false"); + cfgfile_write (f, "fpu_strict=%s\n", p->fpu_strict ? "true" : "false"); + cfgfile_write (f, "comp_midopt=%s\n", p->comp_midopt ? "true" : "false"); + cfgfile_write (f, "comp_lowopt=%s\n", p->comp_lowopt ? "true" : "false"); + cfgfile_write (f, "avoid_cmov=%s\n", p->avoid_cmov ? "true" : "false" ); + cfgfile_write (f, "avoid_dga=%s\n", p->avoid_dga ? "true" : "false" ); + cfgfile_write (f, "avoid_vid=%s\n", p->avoid_vid ? "true" : "false" ); + cfgfile_write (f, "cachesize=%d\n", p->cachesize); if (p->override_dga_address) - cfgfile_dwrite (f, "override_dga_address=0x%08x\n", p->override_dga_address); + cfgfile_write (f, "override_dga_address=0x%08x\n", p->override_dga_address); for (i = 0; i < 2; i++) { int v = i == 0 ? p->jport0 : p->jport1; @@ -460,17 +466,17 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) sprintf (tmp2, "mouse%d", v - JSEM_MICE); } sprintf (tmp1, "joyport%d=%s\n", i, tmp2); - cfgfile_dwrite (f, tmp1); + cfgfile_write (f, tmp1); } - cfgfile_dwrite (f, "bsdsocket_emu=%s\n", p->socket_emu ? "true" : "false"); + cfgfile_write (f, "bsdsocket_emu=%s\n", p->socket_emu ? "true" : "false"); - cfgfile_dwrite (f, "synchronize_clock=%s\n", p->tod_hack ? "yes" : "no"); - cfgfile_dwrite (f, "maprom=0x%x\n", p->maprom); - cfgfile_dwrite (f, "parallel_postscript_emulation=%s\n", p->parallel_postscript_emulation ? "yes" : "no"); - cfgfile_dwrite (f, "parallel_postscript_detection=%s\n", p->parallel_postscript_detection ? "yes" : "no"); - cfgfile_dwrite (f, "ghostscript_parameters=%s\n", p->ghostscript_parameters); - cfgfile_dwrite (f, "parallel_autoflush=%d\n", p->parallel_autoflush_time); + cfgfile_write (f, "synchronize_clock=%s\n", p->tod_hack ? "yes" : "no"); + cfgfile_write (f, "maprom=0x%x\n", p->maprom); + cfgfile_write (f, "parallel_postscript_emulation=%s\n", p->parallel_postscript_emulation ? "yes" : "no"); + cfgfile_write (f, "parallel_postscript_detection=%s\n", p->parallel_postscript_detection ? "yes" : "no"); + cfgfile_write (f, "ghostscript_parameters=%s\n", p->ghostscript_parameters); + cfgfile_write (f, "parallel_autoflush=%d\n", p->parallel_autoflush_time); cfgfile_dwrite (f, "gfx_display=%d\n", p->gfx_display); cfgfile_dwrite (f, "gfx_framerate=%d\n", p->gfx_framerate); @@ -544,9 +550,9 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_dwrite (f, "gfx_gamma=%d\n", p->gfx_gamma); #endif - cfgfile_dwrite (f, "immediate_blits=%s\n", p->immediate_blits ? "true" : "false"); - cfgfile_dwrite (f, "ntsc=%s\n", p->ntscmode ? "true" : "false"); - cfgfile_dwrite (f, "genlock=%s\n", p->genlock ? "true" : "false"); + cfgfile_write (f, "immediate_blits=%s\n", p->immediate_blits ? "true" : "false"); + cfgfile_write (f, "ntsc=%s\n", p->ntscmode ? "true" : "false"); + cfgfile_write (f, "genlock=%s\n", p->genlock ? "true" : "false"); cfgfile_dwrite (f, "show_leds=%s\n", p->leds_on_screen ? "true" : "false"); cfgfile_dwrite (f, "keyboard_leds=numlock:%s,capslock:%s,scrolllock:%s\n", kbleds[p->keyboard_leds[0]], kbleds[p->keyboard_leds[1]], kbleds[p->keyboard_leds[2]]); @@ -560,10 +566,10 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_dwrite (f, "chipset=ecs_denise\n"); else cfgfile_dwrite (f, "chipset=ocs\n"); - cfgfile_dwrite (f, "chipset_refreshrate=%d\n", p->chipset_refreshrate); - cfgfile_dwrite (f, "collision_level=%s\n", collmode[p->collision_level]); + cfgfile_write (f, "chipset_refreshrate=%d\n", p->chipset_refreshrate); + cfgfile_write (f, "collision_level=%s\n", collmode[p->collision_level]); - cfgfile_dwrite (f, "chipset_compatible=%s\n", cscompa[p->cs_compatible]); + cfgfile_write (f, "chipset_compatible=%s\n", cscompa[p->cs_compatible]); cfgfile_dwrite (f, "ciaatod=%s\n", ciaatodmode[p->cs_ciaatod]); cfgfile_dwrite (f, "rtc=%s\n", rtctype[p->cs_rtc]); //cfgfile_dwrite (f, "chipset_rtc_adjust=%d\n", p->cs_rtc_adjust); @@ -584,39 +590,39 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_dwrite (f, "scsi_a3000=%s\n", p->cs_mbdmac == 1 ? "true" : "false"); cfgfile_dwrite (f, "scsi_a4000t=%s\n", p->cs_mbdmac == 2 ? "true" : "false"); - cfgfile_dwrite (f, "fastmem_size=%d\n", p->fastmem_size / 0x100000); - cfgfile_dwrite (f, "a3000mem_size=%d\n", p->mbresmem_low_size / 0x100000); - cfgfile_dwrite (f, "mbresmem_size=%d\n", p->mbresmem_high_size / 0x100000); - cfgfile_dwrite (f, "z3mem_size=%d\n", p->z3fastmem_size / 0x100000); - cfgfile_dwrite (f, "z3mem_start=0x%x\n", p->z3fastmem_start); - cfgfile_dwrite (f, "bogomem_size=%d\n", p->bogomem_size / 0x40000); - cfgfile_dwrite (f, "gfxcard_size=%d\n", p->gfxmem_size / 0x100000); - cfgfile_dwrite (f, "chipmem_size=%d\n", (p->chipmem_size == 0x40000) ? 0 : p->chipmem_size / 0x80000); + cfgfile_write (f, "fastmem_size=%d\n", p->fastmem_size / 0x100000); + cfgfile_write (f, "a3000mem_size=%d\n", p->mbresmem_low_size / 0x100000); + cfgfile_write (f, "mbresmem_size=%d\n", p->mbresmem_high_size / 0x100000); + cfgfile_write (f, "z3mem_size=%d\n", p->z3fastmem_size / 0x100000); + cfgfile_write (f, "z3mem_start=0x%x\n", p->z3fastmem_start); + cfgfile_write (f, "bogomem_size=%d\n", p->bogomem_size / 0x40000); + cfgfile_write (f, "gfxcard_size=%d\n", p->gfxmem_size / 0x100000); + cfgfile_write (f, "chipmem_size=%d\n", (p->chipmem_size == 0x40000) ? 0 : p->chipmem_size / 0x80000); if (p->m68k_speed > 0) - cfgfile_dwrite (f, "finegrain_cpu_speed=%d\n", p->m68k_speed); + cfgfile_write (f, "finegrain_cpu_speed=%d\n", p->m68k_speed); else - cfgfile_dwrite (f, "cpu_speed=%s\n", p->m68k_speed == -1 ? "max" : "real"); + cfgfile_write (f, "cpu_speed=%s\n", p->m68k_speed == -1 ? "max" : "real"); /* do not reorder start */ write_compatibility_cpu(f, p); - cfgfile_dwrite (f, "cpu_model=%d\n", p->cpu_model); + cfgfile_write (f, "cpu_model=%d\n", p->cpu_model); if (p->fpu_model) - cfgfile_dwrite (f, "fpu_model=%d\n", p->fpu_model); - cfgfile_dwrite (f, "cpu_compatible=%s\n", p->cpu_compatible ? "true" : "false"); - cfgfile_dwrite (f, "cpu_24bit_addressing=%s\n", p->address_space_24 ? "true" : "false"); + cfgfile_write (f, "fpu_model=%d\n", p->fpu_model); + cfgfile_write (f, "cpu_compatible=%s\n", p->cpu_compatible ? "true" : "false"); + cfgfile_write (f, "cpu_24bit_addressing=%s\n", p->address_space_24 ? "true" : "false"); /* do not reorder end */ - cfgfile_dwrite (f, "cpu_cycle_exact=%s\n", p->cpu_cycle_exact ? "true" : "false"); - cfgfile_dwrite (f, "blitter_cycle_exact=%s\n", p->blitter_cycle_exact ? "true" : "false"); - cfgfile_dwrite (f, "rtg_nocustom=%s\n", p->picasso96_nocustom ? "true" : "false"); + cfgfile_write (f, "cpu_cycle_exact=%s\n", p->cpu_cycle_exact ? "true" : "false"); + cfgfile_write (f, "blitter_cycle_exact=%s\n", p->blitter_cycle_exact ? "true" : "false"); + cfgfile_write (f, "rtg_nocustom=%s\n", p->picasso96_nocustom ? "true" : "false"); - cfgfile_dwrite (f, "log_illegal_mem=%s\n", p->illegal_mem ? "true" : "false"); + cfgfile_write (f, "log_illegal_mem=%s\n", p->illegal_mem ? "true" : "false"); if (p->catweasel >= 100) cfgfile_dwrite (f, "catweasel=0x%x\n", p->catweasel); else cfgfile_dwrite (f, "catweasel=%d\n", p->catweasel); - cfgfile_dwrite (f, "kbd_lang=%s\n", (p->keyboard_lang == KBD_LANG_DE ? "de" + cfgfile_write (f, "kbd_lang=%s\n", (p->keyboard_lang == KBD_LANG_DE ? "de" : p->keyboard_lang == KBD_LANG_DK ? "dk" : p->keyboard_lang == KBD_LANG_ES ? "es" : p->keyboard_lang == KBD_LANG_US ? "us" @@ -632,7 +638,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) #ifdef FILESYS write_filesys_config (p, UNEXPANDED, p->path_hardfile, f); if (p->filesys_no_uaefsdb) - cfgfile_dwrite (f, "filesys_no_fsdb=%s\n", p->filesys_no_uaefsdb ? "true" : "false"); + cfgfile_write (f, "filesys_no_fsdb=%s\n", p->filesys_no_uaefsdb ? "true" : "false"); #endif write_inputdevice_config (p, f); @@ -1209,7 +1215,7 @@ struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index, uci->autoboot = 0; if (bootpri < -128) uci->donotmount = 1; - else if (bootpri > -127) + else if (bootpri >= -127) uci->autoboot = 1; uci->controller = hdc; strcpy (uci->filesys, filesysdir ? filesysdir : ""); @@ -1337,6 +1343,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu if (cfgfile_string (option, value, "kickstart_rom_file", p->romfile, sizeof p->romfile) || cfgfile_string (option, value, "kickstart_ext_rom_file", p->romextfile, sizeof p->romextfile) + || cfgfile_string (option, value, "amax_rom_file", p->amaxromfile, sizeof p->amaxromfile) || cfgfile_string (option, value, "sana2", p->sana2, sizeof p->sana2) || cfgfile_string (option, value, "flash_file", p->flashfile, sizeof p->flashfile) || cfgfile_string (option, value, "cart_file", p->cartfile, sizeof p->cartfile) @@ -3023,6 +3030,7 @@ static void buildin_default_prefs (struct uae_prefs *p) strcpy (p->romextfile, ""); strcpy (p->flashfile, ""); strcpy (p->cartfile, ""); + strcpy (p->amaxromfile, ""); p->prtname[0] = 0; p->sername[0] = 0; diff --git a/cia.c b/cia.c index f3d81fcf..6c14ef10 100755 --- a/cia.c +++ b/cia.c @@ -681,6 +681,10 @@ static void WriteCIAA (uae_u16 addr,uae_u8 val) ciaapra = (ciaapra & ~0xc3) | (val & 0xc3); bfe001_change (); handle_cd32_joystick_cia (ciaapra, ciaadra); +#ifdef AMAX + if (currprefs.amaxromfile[0]) + amax_bfe001_write (val, ciaadra); +#endif break; case 1: #ifdef DONGLE_DEBUG diff --git a/custom.c b/custom.c index 33063936..a92f2fc9 100755 --- a/custom.c +++ b/custom.c @@ -2709,7 +2709,8 @@ void INTREQ_f(uae_u32 data) static void INTREQ_d (uae_u16 v, int d) { intreqr = intreq; - setclr (&intreqr, v); /* data in intreq is immediately available */ + /* data in intreq is immediately available (vsync only currently because there is something unknown..) */ + setclr (&intreqr, v & (0x8000 | 0x20)); if (!use_eventmode() || v == 0) INTREQ_f(v); else diff --git a/debug.c b/debug.c index 9215f530..41557b8e 100755 --- a/debug.c +++ b/debug.c @@ -836,7 +836,7 @@ static void deepcheatsearch (char **c) *p1++ = get_byte (i); addr = end - 1; } - console_out("deep trainer first pass complete.\n"); + console_out("Deep trainer first pass complete.\n"); return; } inconly = deconly = 0; @@ -951,16 +951,16 @@ static void cheatsearch (char **c) } val = readint (c); if (first) { - ignore_ws (c); if (val > 255) size = 2; if (val > 65535) size = 3; if (val > 16777215) size = 4; - if (more_params(c)) - size = readint(c); } + ignore_ws (c); + if (more_params(c)) + size = readint(c); if (size > 4) size = 4; if (size < 1) @@ -980,7 +980,8 @@ static void cheatsearch (char **c) while ((addr = nextaddr(addr, &end)) != 0xffffffff) { if (addr + size < end) { for (i = 0; i < size; i++) { - if (get_byte (addr + i) != val >> ((size - i - 1) << 8)) + int shift = (size - i - 1) * 8; + if (get_byte (addr + i) != ((val >> shift) & 0xff)) break; } if (i == size) { @@ -1011,10 +1012,11 @@ static void cheatsearch (char **c) vlist[prevmemcnt >> 3] &= ~(1 << (prevmemcnt & 7)); prevmemcnt++; } - listcheater(0, size); + listcheater (0, size); } console_out ("Found %d possible addresses with 0x%X (%u) (%d bytes)\n", count, val, val, size); - console_out ("Now continue with 'g' and use 'C' with a different value\n"); + if (count > 0) + console_out ("Now continue with 'g' and use 'C' with a different value\n"); first = 0; } diff --git a/disk.c b/disk.c index 62af5603..c41f02e2 100755 --- a/disk.c +++ b/disk.c @@ -39,6 +39,7 @@ #endif #include "crc32.h" #include "inputdevice.h" +#include "amax.h" #undef CATWEASEL @@ -176,6 +177,7 @@ typedef struct { catweasel_drive *catweasel; #else int catweasel; + int amax; #endif } drive; @@ -570,9 +572,31 @@ static void reset_drive_gui(int i) gui_data.drive_disabled[i] = 1; } +static void setamax(void) +{ +#ifdef AMAX + if (currprefs.amaxromfile[0]) { + /* Put A-Max as last drive in drive chain */ + int j; + for (j = 0; j < MAX_FLOPPY_DRIVES; j++) + if (floppy[j].amax) + return; + for (j = 0; j < MAX_FLOPPY_DRIVES; j++) { + if ((1 << j) & disabled) { + floppy[j].amax = 1; + write_log ("AMAX: drive %d\n", j); + return; + } + } + } +#endif +} + static void reset_drive(int i) { drive *drv = &floppy[i]; + + drv->amax = 0; drive_image_free (drv); drv->motoroff = 1; disabled &= ~(1 << i); @@ -2123,6 +2147,11 @@ void DISK_select (uae_u8 data) if (disk_debug_logging > 1) write_log ("%08.8X %02.2X %s drvmask=%x", M68K_GETPC, data, tobin(data), selected ^ 15); +#ifdef AMAX + if (currprefs.amaxromfile[0]) + amax_disk_select (data, prevdata); +#endif + if ((prevdata & 0x80) != (data & 0x80)) { for (dr = 0; dr < 4; dr++) { if (floppy[dr].indexhackmode > 1 && !(selected & (1 << dr))) { @@ -2202,7 +2231,9 @@ uae_u8 DISK_status (void) for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = floppy + dr; - if (!((selected | disabled) & (1 << dr))) { + if (drv->amax) { + st = amax_disk_status (); + } else if (!((selected | disabled) & (1 << dr))) { if (drive_running (drv)) { if (drv->catweasel) { #ifdef CATWEASEL @@ -2238,7 +2269,7 @@ uae_u8 DISK_status (void) } } else if (!(selected & (1 << dr))) { if (drv->idbit) - st &= ~0x20; + st &= ~0x20; } } return st; @@ -2386,8 +2417,13 @@ static void disk_doupdate_write (drive * drv, int floppybits) if (!bitoffset) { for (dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) { drive *drv2 = &floppy[dr]; + uae_u16 w = get_word (dskpt); if (drives[dr]) - drv2->bigmfmbuf[drv2->mfmpos >> 4] = get_word (dskpt); + drv2->bigmfmbuf[drv2->mfmpos >> 4] = w; +#ifdef AMAX + if (currprefs.amaxromfile[0]) + amax_diskwrite (w); +#endif } dskpt += 2; dsklength--; @@ -2826,8 +2862,8 @@ void DSKLEN (uae_u16 v, int hpos) break; } if (dr == 4) { - write_log ("disk %s DMA started, drvmask=%x motormask=%x\n", - dskdmaen == 3 ? "write" : "read", selected ^ 15, motormask); + write_log ("disk %s DMA started, drvmask=%x motormask=%x\n", + dskdmaen == 3 ? "write" : "read", selected ^ 15, motormask); noselected = 1; } else { if (disk_debug_logging > 0) { @@ -2898,7 +2934,12 @@ void DSKLEN (uae_u16 v, int hpos) } else if (dskdmaen == 3) { /* TURBO write */ for (i = 0; i < dsklength; i++) { - drv->bigmfmbuf[pos >> 4] = get_word (dskpt + i * 2); + uae_u16 w = get_word (dskpt + i * 2); + drv->bigmfmbuf[pos >> 4] = w; +#ifdef AMAX + if (currprefs.amaxromfile[0]) + amax_diskwrite (w); +#endif pos += 16; pos %= drv->tracklen; } @@ -2908,7 +2949,15 @@ void DSKLEN (uae_u16 v, int hpos) } if (!done && noselected) { while (dsklength-- > 0) { - put_word (dskpt, 0); + if (dskdmaen == 3) { + uae_u16 w = get_word (dskpt); +#ifdef AMAX + if (currprefs.amaxromfile[0]) + amax_diskwrite (w); +#endif + } else { + put_word (dskpt, 0); + } dskpt += 2; } INTREQ_f (0x8000 | 0x1000); @@ -2985,6 +3034,7 @@ void DISK_init (void) } if (disk_empty (0)) write_log ("No disk in drive 0.\n"); + amax_init (); } void DISK_reset (void) @@ -3000,6 +3050,7 @@ void DISK_reset (void) disabled = 0; for (i = 0; i < MAX_FLOPPY_DRIVES; i++) reset_drive (i); + setamax (); } int DISK_examine_image (struct uae_prefs *p, int num, uae_u32 *crc32) @@ -3088,6 +3139,11 @@ void DISK_restore_custom (uae_u32 pdskpt, uae_u16 pdsklength, uae_u16 pdskbytr) dskbytr_val = pdskbytr; } +void restore_disk_finish (void) +{ + setamax(); +} + uae_u8 *restore_disk(int num,uae_u8 *src) { drive *drv; diff --git a/enforcer.c b/enforcer.c index 86360355..8705ed11 100755 --- a/enforcer.c +++ b/enforcer.c @@ -194,7 +194,7 @@ static void enforcer_display_hit (const char *addressmode, uae_u32 pc, uaecptr a if (enforcer_hit) return; /* our function itself generated a hit ;), avoid endless loop */ - if (regs.vbr < 0x100 && addr >= 0x0c && addr < 0x78) + if (regs.vbr < 0x100 && addr >= 0x0c && addr < 0x80) return; enforcer_hit = 1; diff --git a/expansion.c b/expansion.c index 42d31892..48b67f19 100755 --- a/expansion.c +++ b/expansion.c @@ -1071,7 +1071,7 @@ int need_uae_boot_rom(void) return 1; if (currprefs.scsi == 1) return 1; - if (currprefs.sana2) + if (currprefs.sana2[0]) return 1; if (currprefs.win32_outsidemouse) return 1; diff --git a/include/amax.h b/include/amax.h new file mode 100755 index 00000000..42269646 --- /dev/null +++ b/include/amax.h @@ -0,0 +1,7 @@ + +void amax_diskwrite (uae_u16 w); +void amax_bfe001_write (uae_u8 pra, uae_u8 dra); +uae_u8 amax_disk_status (void); +void amax_disk_select (uae_u8 v, uae_u8 ov); +void amax_reset (void); +void amax_init (void); \ No newline at end of file diff --git a/include/options.h b/include/options.h index 20de59a0..d0241ef6 100755 --- a/include/options.h +++ b/include/options.h @@ -229,6 +229,7 @@ struct uae_prefs { char pci_devices[256]; char prtname[256]; char sername[256]; + char amaxromfile[MAX_DPATH]; char path_floppy[256]; char path_hardfile[256]; diff --git a/include/savestate.h b/include/savestate.h index 13936d23..577ceaec 100755 --- a/include/savestate.h +++ b/include/savestate.h @@ -51,6 +51,7 @@ extern uae_u8 *restore_floppy (uae_u8 *src); extern uae_u8 *save_floppy (int *len, uae_u8 *); extern void DISK_save_custom (uae_u32 *pdskpt, uae_u16 *pdsklen, uae_u16 *pdsksync, uae_u16 *pdskbytr); extern void DISK_restore_custom (uae_u32 pdskpt, uae_u16 pdsklength, uae_u16 pdskbytr); +extern void restore_disk_finish (void); extern uae_u8 *restore_custom (uae_u8 *); extern uae_u8 *save_custom (int *, uae_u8 *, int); diff --git a/inputdevice.c b/inputdevice.c index cd3858b6..a30f0e50 100755 --- a/inputdevice.c +++ b/inputdevice.c @@ -399,8 +399,7 @@ static struct input_queue_struct input_queue[INPUT_QUEUE_SIZE]; static void out_config (struct zfile *f, int id, int num, char *s1, char *s2) { - cfgfile_dwrite (f, "input.%d.%s%d=%s\n", id, s1, num, s2); - //write_log ("-input.%d.%s%d=%s\n", id, s1, num, s2); + cfgfile_write (f, "input.%d.%s%d=%s\n", id, s1, num, s2); } static void write_config2 (struct zfile *f, int idnum, int i, int offset, char *tmp1, struct uae_input_device *id) @@ -444,7 +443,7 @@ static void write_config (struct zfile *f, int idnum, int devnum, char *name, st if (!isdevice (id)) return; - cfgfile_dwrite (f, "input.%d.%s.%d.disabled=%d\n", idnum, name, devnum, id->enabled ? 0 : 1); + cfgfile_write (f, "input.%d.%s.%d.disabled=%d\n", idnum, name, devnum, id->enabled ? 0 : 1); sprintf (tmp1, "%s.%d.axis.", name, devnum); for (i = 0; i < ID_AXIS_TOTAL; i++) write_config2 (f, idnum, i, ID_AXIS_OFFSET, tmp1, id); @@ -519,7 +518,7 @@ static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae sprintf (tmp3, "%d", kbr->extra[i][0]); kbrlabel (tmp3); sprintf (tmp1, "keyboard.%d.button.%s", devnum, tmp3); - cfgfile_dwrite (f, "input.%d.%s=%s\n", idnum, tmp1, tmp2[0] ? tmp2 : "NULL"); + cfgfile_write (f, "input.%d.%s=%s\n", idnum, tmp1, tmp2[0] ? tmp2 : "NULL"); i++; } } @@ -528,13 +527,13 @@ void write_inputdevice_config (struct uae_prefs *p, struct zfile *f) { int i, id; - cfgfile_dwrite (f, "input.config=%d\n", p->input_selected_setting); - cfgfile_dwrite (f, "input.joymouse_speed_analog=%d\n", p->input_joymouse_multiplier); - cfgfile_dwrite (f, "input.joymouse_speed_digital=%d\n", p->input_joymouse_speed); - cfgfile_dwrite (f, "input.joymouse_deadzone=%d\n", p->input_joymouse_deadzone); - cfgfile_dwrite (f, "input.joystick_deadzone=%d\n", p->input_joystick_deadzone); - cfgfile_dwrite (f, "input.mouse_speed=%d\n", p->input_mouse_speed); - cfgfile_dwrite (f, "input.autofire=%d\n", p->input_autofire_framecnt); + cfgfile_write (f, "input.config=%d\n", p->input_selected_setting); + cfgfile_write (f, "input.joymouse_speed_analog=%d\n", p->input_joymouse_multiplier); + cfgfile_write (f, "input.joymouse_speed_digital=%d\n", p->input_joymouse_speed); + cfgfile_write (f, "input.joymouse_deadzone=%d\n", p->input_joymouse_deadzone); + cfgfile_write (f, "input.joystick_deadzone=%d\n", p->input_joystick_deadzone); + cfgfile_write (f, "input.mouse_speed=%d\n", p->input_mouse_speed); + cfgfile_write (f, "input.autofire=%d\n", p->input_autofire_framecnt); for (id = 1; id <= MAX_INPUT_SETTINGS; id++) { for (i = 0; i < MAX_INPUT_DEVICES; i++) write_config (f, id, i, "joystick", &p->joystick_settings[id][i], &joysticks2[i]); diff --git a/od-win32/dinput.c b/od-win32/dinput.c index a4c5c389..84acd5cb 100755 --- a/od-win32/dinput.c +++ b/od-win32/dinput.c @@ -75,6 +75,9 @@ struct didata { int buttonmappings[MAX_MAPPINGS]; char *buttonname[MAX_MAPPINGS]; int buttonsort[MAX_MAPPINGS]; + + int axisparent[MAX_MAPPINGS]; + int axisparentdir[MAX_MAPPINGS]; }; #define DI_BUFFER 30 @@ -106,6 +109,40 @@ int dinput_winmousemode (void) return 0; } +static void fixbuttons (struct didata *did) +{ + if (did->buttons > 0) + return; + write_log ("'%s' has no buttons, adding single default button\n", did->name); + did->buttonmappings[0] = DIJOFS_BUTTON(0); + did->buttonsort[0] = 0; + did->buttonname[0] = my_strdup("Button"); + did->buttons++; +} + +#define AXISBUTTON 0x20000 +#define AXISBUTTON_2 0x10000 + +static void fixthings (struct didata *did) +{ + int i, j; + char tmp[256]; + + for (i = 0; i < did->axles; i++) { + if (did->buttons + 1 >= MAX_MAPPINGS) + break; + for (j = 0; j < 2; j++) { + sprintf (tmp, "%s [%c]", did->axisname[i], j ? '+' : '-'); + did->buttonname[did->buttons] = my_strdup (tmp); + did->buttonmappings[did->buttons] = did->axismappings[i]; + did->buttonsort[did->buttons] = 1000 + (did->axismappings[i] + did->axistype[i]) * 2 + j; + did->axisparent[did->buttons] = i; + did->axisparentdir[did->buttons] = j; + did->buttons++; + } + } +} + typedef BOOL (CALLBACK* REGISTERRAWINPUTDEVICES) (PCRAWINPUTDEVICE, UINT, UINT); static REGISTERRAWINPUTDEVICES pRegisterRawInputDevices; @@ -164,6 +201,7 @@ static void cleardid(struct didata *did) for (i = 0; i < MAX_MAPPINGS; i++) { did->axismappings[i] = -1; did->buttonmappings[i] = -1; + did->axisparent[i] = -1; } } @@ -184,10 +222,8 @@ static int initialize_catweasel(void) did->sortname = my_strdup (tmp); did->buttons = 3; did->axles = 2; - did->axistype[0] = 1; did->axissort[0] = 0; did->axisname[0] = my_strdup ("X-Axis"); - did->axistype[1] = 1; did->axissort[1] = 1; did->axisname[1] = my_strdup ("Y-Axis"); for (j = 0; j < did->buttons; j++) { @@ -211,10 +247,8 @@ static int initialize_catweasel(void) did->sortname = my_strdup (tmp); did->buttons = (catweasel_isjoystick() & 0x80) ? 3 : 1; did->axles = 2; - did->axistype[0] = 1; did->axissort[0] = 0; did->axisname[0] = my_strdup ("X-Axis"); - did->axistype[1] = 1; did->axissort[1] = 1; did->axisname[1] = my_strdup ("Y-Axis"); for (j = 0; j < did->buttons; j++) { @@ -223,6 +257,8 @@ static int initialize_catweasel(void) did->buttonname[j] = my_strdup (tmp); } did->priority = -1; + fixbuttons (did); + fixthings (did); num_joystick++; } } @@ -361,17 +397,13 @@ static int initialize_rawinput (void) rdim->dwId, rdim->dwNumberOfButtons, rdim->fHasHorizontalWheel, rdim->dwSampleRate); did->buttons = rdim->dwNumberOfButtons; did->axles = 3; - did->axistype[0] = 1; did->axissort[0] = 0; did->axisname[0] = my_strdup ("X-Axis"); - did->axistype[1] = 1; did->axissort[1] = 1; did->axisname[1] = my_strdup ("Y-Axis"); - did->axistype[2] = 1; did->axissort[2] = 2; did->axisname[2] = my_strdup ("Wheel"); if (rdim->fHasHorizontalWheel) { - did->axistype[3] = 1; did->axissort[3] = 3; did->axisname[3] = my_strdup ("HWheel"); did->axles++; @@ -428,19 +460,15 @@ static void initialize_windowsmouse (void) if (did->buttons > 3 && !os_winnt) did->buttons = 3; /* Windows 98/ME support max 3 non-DI buttons */ did->axles = os_vista ? 4 : 3; - did->axistype[0] = 1; did->axissort[0] = 0; did->axisname[0] = my_strdup ("X-Axis"); - did->axistype[1] = 1; did->axissort[1] = 1; did->axisname[1] = my_strdup ("Y-Axis"); if (did->axles > 2) { - did->axistype[2] = 1; did->axissort[2] = 2; did->axisname[2] = my_strdup ("Wheel"); } if (did->axles > 3) { - did->axistype[3] = 1; did->axissort[3] = 3; did->axisname[3] = my_strdup ("HWheel"); } @@ -624,17 +652,6 @@ static void sortdd (struct didata *dd, int num, int type) } -static void fixbuttons (struct didata *did) -{ - if (did->buttons > 0) - return; - write_log ("'%s' has no buttons, adding single default button\n", did->name); - did->buttonmappings[0] = DIJOFS_BUTTON(0); - did->buttonsort[0] = 0; - did->buttonname[0] = my_strdup("Button"); - did->buttons++; -} - static void sortobjects (struct didata *did, int *mappings, int *sort, char **names, int *types, int num) { int i, j, tmpi; @@ -732,7 +749,7 @@ static BOOL CALLBACK EnumObjectsCallback (const DIDEVICEOBJECTINSTANCE* pdidoi, sprintf (tmp, "%s (%d)", pdidoi->tszName, i + 1); did->axisname[did->axles + i] = my_strdup (tmp); did->axissort[did->axles + i] = did->axissort[did->axles]; - did->axistype[did->axles + i] = 1; + did->axistype[did->axles + i] = i + 1; } did->axles += 2; } @@ -1746,34 +1763,64 @@ static void read_joystick (void) data -= 32768; for (k = 0; k < did->buttons; k++) { - if (did->buttonmappings[k] == dimofs) { + + if (did->axisparent >= 0 && did->buttonmappings[k] == dimofs) { + int bstate = 0; + int axis = did->axisparent[k]; + int dir = did->axisparentdir[k]; + + if (did->axistype[axis] == 1) { + if (!dir) + bstate = (data2 >= 20250 && data2 <= 33750) ? 1 : 0; + else + bstate = (data2 >= 2250 && data2 <= 15750) ? 1 : 0; + } else if (did->axistype[axis] == 2) { + if (!dir) + bstate = ((data2 >= 29250 && data2 <= 33750) || (data2 >= 0 && data2 <= 6750)) ? 1 : 0; + else + bstate = (data2 >= 11250 && data2 <= 24750) ? 1 : 0; + } else if (did->axistype[axis] == 0) { + if (dir) + bstate = data > 20000 ? 1 : 0; + else + bstate = data < -20000 ? 1 : 0; + } + setjoybuttonstate (i, k, bstate); +#ifdef DI_DEBUG2 + write_log ("AB:NUM=%d OFF=%d AXIS=%d DIR=%d NAME=%s VAL=%d STATE=%d\n", + k, dimofs, axis, dir, did->buttonname[k], data, state); +#endif + + } else if (did->buttonmappings[k] == dimofs) { #ifdef DI_DEBUG2 write_log ("B:NUM=%d OFF=%d NAME=%s VAL=%d STATE=%d\n", k, dimofs, did->buttonname[k], data, state); #endif setjoybuttonstate (i, k, state); - break; } } + for (k = 0; k < did->axles; k++) { if (did->axismappings[k] == dimofs) { - if (did->axistype[k]) { + if (did->axistype[k] == 1) { setjoystickstate (i, k, (data2 >= 20250 && data2 <= 33750) ? -1 : (data2 >= 2250 && data2 <= 15750) ? 1 : 0, 1); - setjoystickstate (i, k + 1, ((data2 >= 29250 && data2 <= 33750) || (data2 >= 0 && data2 <= 6750)) ? -1 : (data2 >= 11250 && data2 <= 24750) ? 1 : 0, 1); + } else if (did->axistype[k] == 2) { + setjoystickstate (i, k, ((data2 >= 29250 && data2 <= 33750) || (data2 >= 0 && data2 <= 6750)) ? -1 : (data2 >= 11250 && data2 <= 24750) ? 1 : 0, 1); #ifdef DI_DEBUG2 write_log ("P:NUM=%d OFF=%d NAME=%s VAL=%d\n", k, dimofs, did->axisname[k], data2); #endif - } else { + } else if (did->axistype[k] == 0) { #ifdef DI_DEBUG2 if (data < -20000 || data > 20000) write_log ("A:NUM=%d OFF=%d NAME=%s VAL=%d\n", k, dimofs, did->axisname[k], data); #endif setjoystickstate (i, k, data, 32768); } - break; } } + } + } else if (hr == DIERR_INPUTLOST) { acquire (lpdi, "joystick"); } else if (did->acquired && hr == DIERR_NOTACQUIRED) { @@ -1804,6 +1851,7 @@ static int init_joystick (void) did->lpdi = lpdi; IDirectInputDevice8_EnumObjects (lpdi, EnumObjectsCallback, (void*)did, DIDFT_ALL); fixbuttons (did); + fixthings (did); sortobjects (did, did->axismappings, did->axissort, did->axisname, did->axistype, did->axles); sortobjects (did, did->buttonmappings, did->buttonsort, did->buttonname, 0, did->buttons); } diff --git a/od-win32/sysconfig.h b/od-win32/sysconfig.h index ac9969b6..4de5b6f6 100755 --- a/od-win32/sysconfig.h +++ b/od-win32/sysconfig.h @@ -55,6 +55,7 @@ #define A2091 /* A590/A2091 SCSI */ #define NCR /* A4000T/A4091 SCSI */ #define SANA2 /* SANA2 network driver */ +#define AMAX /* A-Max ROM adapater emulation */ #else diff --git a/od-win32/win32.c b/od-win32/win32.c index 6c4c37b3..d3d3e81e 100755 --- a/od-win32/win32.c +++ b/od-win32/win32.c @@ -3452,11 +3452,15 @@ typedef BOOL (CALLBACK* CHANGEWINDOWMESSAGEFILTER)(UINT, DWORD); int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { SETPROCESSDPIAWARE pSetProcessDPIAware; + DWORD_PTR sys_aff; + + original_affinity = 1; + GetProcessAffinityMask (GetCurrentProcess(), &original_affinity, &sys_aff); +#if 0 HANDLE thread; thread = GetCurrentThread(); original_affinity = SetThreadAffinityMask(thread, 1); -#if 0 CHANGEWINDOWMESSAGEFILTER pChangeWindowMessageFilter; pChangeWindowMessageFilter = (CHANGEWINDOWMESSAGEFILTER)GetProcAddress( GetModuleHandle("user32.dll"), "ChangeWindowMessageFilter"); @@ -3472,7 +3476,9 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin WinMain2 (hInstance, hPrevInstance, lpCmdLine, nCmdShow); } __except(WIN32_ExceptionFilter(GetExceptionInformation(), GetExceptionCode())) { } +#if 0 SetThreadAffinityMask(thread, original_affinity); +#endif return FALSE; } diff --git a/od-win32/win32.h b/od-win32/win32.h index cce92893..bf2b69c4 100755 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -15,9 +15,9 @@ #define GETBDM(x) (((x) - ((x / 10000) * 10000)) / 100) #define GETBDD(x) ((x) % 100) -#define WINUAEBETA 2 +#define WINUAEBETA 3 #define WINUAEPUBLICBETA 1 -#define WINUAEDATE MAKEBD(2007, 10, 6) +#define WINUAEDATE MAKEBD(2007, 10, 13) #define WINUAEEXTRA "" #define WINUAEREV "" diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index e026dda4..f16d8752 100755 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -6010,11 +6010,12 @@ static INT_PTR CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, SetDlgItemText (hDlg, IDC_VOLUME_NAME, current_fsvdlg.volume); SetDlgItemText (hDlg, IDC_VOLUME_DEVICE, current_fsvdlg.device); SetDlgItemText (hDlg, IDC_PATH_NAME, current_fsvdlg.rootdir); - SetDlgItemInt (hDlg, IDC_VOLUME_BOOTPRI, current_fsvdlg.bootpri, TRUE); + SetDlgItemInt (hDlg, IDC_VOLUME_BOOTPRI, current_fsvdlg.bootpri >= -127 ? current_fsvdlg.bootpri : -127, TRUE); if (archivehd) current_fsvdlg.rw = 0; CheckDlgButton (hDlg, IDC_FS_RW, current_fsvdlg.rw); CheckDlgButton (hDlg, IDC_FS_AUTOBOOT, current_fsvdlg.autoboot); + current_fsvdlg.donotmount = 0; ew (hDlg, IDC_FS_RW, !archivehd); recursive--; } @@ -6098,7 +6099,7 @@ static void sethardfile (HWND hDlg) SetDlgItemInt (hDlg, IDC_HEADS, current_hfdlg.surfaces, FALSE); SetDlgItemInt (hDlg, IDC_RESERVED, current_hfdlg.reserved, FALSE); SetDlgItemInt (hDlg, IDC_BLOCKSIZE, current_hfdlg.blocksize, FALSE); - SetDlgItemInt (hDlg, IDC_HARDFILE_BOOTPRI, current_hfdlg.bootpri, TRUE); + SetDlgItemInt (hDlg, IDC_HARDFILE_BOOTPRI, current_hfdlg.bootpri >= -127 ? current_hfdlg.bootpri : -127, TRUE); CheckDlgButton (hDlg, IDC_HDF_RW, current_hfdlg.rw); CheckDlgButton (hDlg, IDC_HDF_AUTOBOOT, current_hfdlg.autoboot); CheckDlgButton (hDlg, IDC_HDF_DONOTMOUNT, current_hfdlg.donotmount); diff --git a/od-win32/winuae_msvc/winuae_msvc.8.vcproj b/od-win32/winuae_msvc/winuae_msvc.8.vcproj index 13699221..f215ca5b 100755 --- a/od-win32/winuae_msvc/winuae_msvc.8.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.8.vcproj @@ -1583,6 +1583,10 @@ RelativePath="..\..\akiko.c" > + + diff --git a/od-win32/winuae_msvc/winuae_msvc.vcproj b/od-win32/winuae_msvc/winuae_msvc.vcproj index 4ac14ca4..101c777d 100755 --- a/od-win32/winuae_msvc/winuae_msvc.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.vcproj @@ -1577,6 +1577,10 @@ RelativePath="..\..\akiko.c" > + + diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index 795aa82f..df4b0104 100755 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -1,4 +1,25 @@ +Beta 3: + +- autoboot/donotmount checkbox problems fixed +- winuaenforcer enabled and VBR not moved: interrupt levels + 6 and 7 caused enforcer hit flood +- uae boot rom was always mounted (b2) +- b2 interrupt fix update, only "pre-delay" vblank interrupt +- A-Max rom-"dongle" emulation added (manual configuration file + editing currently needed, amaxromfile=) Yes, this is + very pointless feature. (A-Max technical info by Mark Knibbs) +- C debugger command only worked in byte-mode +- disk write without drives selected was emulated as a read without + drives selected, clearing disk dma buffer +- input configuration is fully saved again, need design update.. + (in b2 all default settings disappeared after saving and loading..) +- added "directional buttons" to input panel list, for example + "X-Axis" is available as "X-Axis" (original), "X-Axis [-]" (button + event when joystick/dpad moved left) and "X-Axis [+]" (button + event when joystick/dpad moved right) Currently new "buttons" + are at the end of the list. + Beta 2: - warp (.wrp) disk compression format supported @@ -25,7 +46,6 @@ Beta 2: - high end quickstart cpu changed back to 68040 (68060 does not boot very well without 68060.library..) - Beta 1: - CDTV and CD32 interrupt handling improved, fixes "Snoopy In The diff --git a/od-win32/writelog.c b/od-win32/writelog.c index 42a39c58..6792f7d3 100755 --- a/od-win32/writelog.c +++ b/od-win32/writelog.c @@ -270,28 +270,44 @@ void write_log (const char *format, ...) { int count; char buffer[WRITE_LOG_BUF_SIZE], *ts; + int bufsize = WRITE_LOG_BUF_SIZE; + char *bufp; va_list parms; va_start(parms, format); - count = _vsnprintf(buffer, WRITE_LOG_BUF_SIZE - 1, format, parms); + bufp = buffer; + for (;;) { + count = _vsnprintf(bufp, bufsize - 1, format, parms); + if (count < 0) { + bufsize *= 10; + if (bufp != buffer) + xfree (bufp); + bufp = xmalloc (bufsize); + continue; + } + break; + } + bufp[bufsize - 1] = 0; ts = writets(); - if (buffer[0] == '*') + if (bufp[0] == '*') count++; if (SHOW_CONSOLE || console_logging) { if (lfdetected && ts) writeconsole(ts); - writeconsole(buffer); + writeconsole(bufp); } if (debugfile) { if (lfdetected && ts) fprintf(debugfile, ts); - fprintf(debugfile, buffer); + fprintf(debugfile, bufp); fflush(debugfile); } lfdetected = 0; - if (strlen(buffer) > 0 && buffer[strlen(buffer) - 1] == '\n') + if (strlen(bufp) > 0 && bufp[strlen(bufp) - 1] == '\n') lfdetected = 1; va_end (parms); + if (bufp != buffer) + xfree (bufp); } void f_out (void *f, const char *format, ...) diff --git a/sana2.c b/sana2.c index 4fdd201b..f42246e0 100755 --- a/sana2.c +++ b/sana2.c @@ -3,6 +3,8 @@ * * SanaII emulation * + * partially based on code from 3c589 PCMCIA driver by Neil Cafferke + * * Copyright 2007 Toni Wilen * */ @@ -99,6 +101,9 @@ #define S2EVENT_HARDWARE (1L<<6) /* hardware error catch all */ #define S2EVENT_SOFTWARE (1L<<7) /* software error catch all */ +#define KNOWN_EVENTS (S2EVENT_ERROR|S2EVENT_TX|S2EVENT_RX|S2EVENT_ONLINE|\ + S2EVENT_OFFLINE|S2EVENT_BUFF|S2EVENT_HARDWARE|S2EVENT_SOFTWARE) + #define DRIVE_NEWSTYLE 0x4E535459L /* 'NSTY' */ #define NSCMD_DEVICEQUERY 0x4000 @@ -125,15 +130,18 @@ struct priv_devstruct { int flags; /* OpenDevice() */ int configured; int adapter; + int online; uae_u8 mac[ADDR_SIZE]; struct tapdata *td; - int packetsreceived; - int packetssent; - int baddata; - int overruns; - int unknowntypesreceived; - int reconfigurations; + uae_u32 packetsreceived; + uae_u32 packetssent; + uae_u32 baddata; + uae_u32 overruns; + uae_u32 unknowntypesreceived; + uae_u32 reconfigurations; + uae_u32 online_micro; + uae_u32 online_secs; }; static struct tapdata td; @@ -385,19 +393,38 @@ static int dev_do_io (struct devstruct *dev, uaecptr request) break; case CMD_READ: - goto offline; + if (!pdev->online) + goto offline; break; + case S2_READORPHAN: - goto offline; + if (!pdev->online) + goto offline; break; - case CMD_WRITE: - goto offline; - break; case S2_BROADCAST: - goto offline; + if (!pdev->online) + goto offline; + put_byte (dstaddr + 0, 0xff); + put_byte (dstaddr + 1, 0xff); + put_byte (dstaddr + 2, 0xff); + put_byte (dstaddr + 3, 0xff); + put_byte (dstaddr + 4, 0xff); + put_byte (dstaddr + 5, 0xff); + /* fall through */ + case CMD_WRITE: + if (!pdev->online) + goto offline; break; + case S2_MULTICAST: + if (!pdev->online) + goto offline; + if ((get_byte (dstaddr + 0) & 1) == 0) { + io_error = S2ERR_BAD_ADDRESS; + wire_error = S2WERR_BAD_MULTICAST; + goto end; + } io_error = S2WERR_BAD_MULTICAST; break; @@ -438,6 +465,8 @@ static int dev_do_io (struct devstruct *dev, uaecptr request) put_long (statdata + 12, pdev->overruns); put_long (statdata + 16, pdev->unknowntypesreceived); put_long (statdata + 20, pdev->reconfigurations); + put_long (statdata + 24, pdev->online_secs); + put_long (statdata + 28, pdev->online_micro); break; case S2_GETSPECIALSTATS: @@ -472,21 +501,47 @@ static int dev_do_io (struct devstruct *dev, uaecptr request) wire_error = S2WERR_RCVREL_HDW_ERR; } if (!io_error) { + time_t t; pdev->packetsreceived = 0; pdev->packetssent = 0; pdev->baddata = 0; pdev->overruns = 0; pdev->unknowntypesreceived = 0; pdev->reconfigurations = 0; + pdev->online = 1; + t = time (NULL); + pdev->online_micro = 0; + pdev->online_secs = (uae_u32)t; } break; case S2_OFFLINE: + pdev->online = 0; break; case S2_ONEVENT: - io_error = S2ERR_NOT_SUPPORTED; - wire_error = S2WERR_BAD_EVENT; + { + int complete = FALSE; + uae_u32 events; + uae_u32 wanted_events = get_long (request + 32); + if (wanted_events & ~KNOWN_EVENTS) { + io_error = S2ERR_NOT_SUPPORTED; + events = S2WERR_BAD_EVENT; + } else { + if (!pdev->online) + events = S2EVENT_ONLINE; + else + events = S2EVENT_OFFLINE; + events &= wanted_events; + } + if (events) { + wire_error = events; + complete = TRUE; + } else { + io_error = S2ERR_NOT_SUPPORTED; + wire_error = S2WERR_BAD_EVENT; + } + } break; default: @@ -498,6 +553,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request) wire_error = S2WERR_UNIT_OFFLINE; break; } +end: put_long (request + 32, wire_error); put_byte (request + 31, io_error); return async; diff --git a/savestate.c b/savestate.c index 7d80e851..5e5f1f13 100755 --- a/savestate.c +++ b/savestate.c @@ -546,6 +546,7 @@ void restore_state (char *filename) name, len, end - chunk); xfree (chunk); } + restore_disk_finish(); restore_blitter_finish(); restore_akiko_finish(); return; diff --git a/zfile.c b/zfile.c index 8453b521..e1200634 100755 --- a/zfile.c +++ b/zfile.c @@ -773,7 +773,10 @@ int zfile_ferror (struct zfile *z) char *zfile_getdata (struct zfile *z, int offset, int len) { size_t pos; - uae_u8 *b = xmalloc (len); + uae_u8 *b; + if (len < 0) + len = z->size; + b = xmalloc (len); if (z->data) { memcpy (b, z->data + offset, len); } else { -- 2.47.3