From 9883574afb66a347679f42f437a941b764fdf6da Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 24 Feb 2007 18:18:42 +0200 Subject: [PATCH] imported winuaesrc1400b8.zip --- cdtv.c | 32 +++++++++++++++++--- expansion.c | 2 +- filesys.c | 55 +++++++++++++++++------------------ include/cdtv.h | 3 +- main.c | 4 +++ memory.c | 2 +- newcpu.c | 35 +++++++++++++++------- od-win32/blkdev_win32_ioctl.c | 2 +- od-win32/picasso96_win.c | 2 +- od-win32/posixemu.c | 10 ++++--- od-win32/win32.h | 4 +-- od-win32/winuaechangelog.txt | 9 ++++++ 12 files changed, 107 insertions(+), 53 deletions(-) diff --git a/cdtv.c b/cdtv.c index 4f63013a..d1e1a976 100755 --- a/cdtv.c +++ b/cdtv.c @@ -298,12 +298,17 @@ static int cdrom_info(uae_u8 *out) { uae_u8 *p; uae_u32 size; + int i; if (!ismedia()) return -1; cd_motor = 1; out[0] = cdrom_toc[2]; - out[1] = cdrom_toc[3]; + i = (cdrom_toc[0] << 8) | (cdrom_toc[1] << 0); + i -= 2 + 11; + i /= 11; + p = cdrom_toc + 4 + i * 11; + out[1] = p[3]; p = cdrom_toc + 4 + 2 * 11; size = ((p[8] << 16) | (p[9] << 8) | p[10]); out[2] = size >> 16; @@ -535,6 +540,7 @@ static void dma_do_thread(void) static void *dev_thread (void *p) { write_log("CDTV: CD thread started\n"); + thread_alive = 1; for (;;) { uae_u32 b = read_comm_pipe_u32_blocking (&requests); @@ -1053,10 +1059,12 @@ static void open_unit(void) int first = -1; int cdtvunit = -1, audiounit = -1; - if (unitnum >= 0) + if (unitnum >= 0) { + cdaudiostop(); sys_command_close (DF_IOCTL, unitnum); - cdtv_reset(); + } unitnum = -1; + cdtv_reset(); if (!device_func_init(DEVICE_TYPE_ANY)) { write_log ("no CDROM support\n"); return; @@ -1219,13 +1227,29 @@ uae_u8 cdtv_battram_read (int addr) return v; } +void cdtv_free (void) +{ + if (thread_alive > 0) { + write_comm_pipe_u32 (&requests, 0xffff, 1); + while (thread_alive > 0) + sleep_millis(10); + } + thread_alive = 0; + cdaudiostop (); + if (unitnum >= 0) + sys_command_close(DF_IOCTL, unitnum); + unitnum = -1; + configured = 0; +} -void dmac_init (void) +void cdtv_init (void) { if (!thread_alive) { uae_thread_id tid; init_comm_pipe (&requests, 100, 1); uae_start_thread ("cdtv", dev_thread, NULL, &tid); + while (!thread_alive) + sleep_millis(10); } configured = 0; diff --git a/expansion.c b/expansion.c index a1b59dca..d98e78ce 100755 --- a/expansion.c +++ b/expansion.c @@ -1066,7 +1066,7 @@ void expamem_reset (void) allocate_expamem (); if (currprefs.cs_cdtvcd) - dmac_init (); + cdtv_init (); /* check if Kickstart version is below 1.3 */ if (! ersatzkickfile && kickstart_version diff --git a/filesys.c b/filesys.c index 51d405bf..880e6d6f 100755 --- a/filesys.c +++ b/filesys.c @@ -441,7 +441,7 @@ void free_mountinfo (void) struct hardfiledata *get_hardfile_data (int nr) { UnitInfo *uip = mountinfo.ui; - if (nr < 0 || uip[nr].open == 0 || uip[nr].volname != 0) + if (nr < 0 || nr >= MAX_FILESYSTEM_UNITS || uip[nr].open == 0 || uip[nr].volname != 0) return 0; return &uip[nr].hf; } @@ -1805,18 +1805,12 @@ static void action_free_lock (Unit *unit, dpacket packet) } static uaecptr -action_dup_lock_2 (Unit *unit, dpacket packet, uaecptr lock) +action_dup_lock_2 (Unit *unit, dpacket packet, uae_u32 uniq) { uaecptr out; a_inode *a; - TRACE(("ACTION_DUP_LOCK(0x%lx)\n", lock)); - DUMPLOCK(unit, lock); - if (!lock) { - PUT_PCK_RES1 (packet, 0); - return 0; - } - a = lookup_aino (unit, get_long (lock + 4)); + a = lookup_aino (unit, uniq); if (a == 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND); @@ -1841,12 +1835,31 @@ static void action_dup_lock (Unit *unit, dpacket packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; - action_dup_lock_2 (unit, packet, lock); + TRACE(("ACTION_DUP_LOCK(0x%lx)\n", lock)); + if (!lock) { + PUT_PCK_RES1 (packet, 0); + return; + } + action_dup_lock_2 (unit, packet, get_long(lock + 4)); +} + + +static void +action_lock_from_fh (Unit *unit, dpacket packet) +{ + uaecptr out; + Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); + TRACE(("ACTION_COPY_DIR_FH(0x%lx)\n", GET_PCK_ARG1 (packet))); + if (k == 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + return; + } + out = action_dup_lock_2 (unit, packet, k->aino->uniq); } /* convert time_t to/from AmigaDOS time */ -const int secs_per_day = 24 * 60 * 60; -const int diff = (8 * 365 + 2) * (24 * 60 * 60); +static const int secs_per_day = 24 * 60 * 60; +static const int diff = (8 * 365 + 2) * (24 * 60 * 60); static void get_time (time_t t, long* days, long* mins, long* ticks) @@ -2288,7 +2301,7 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb if (create) fsdb_set_file_attrs (aino); - put_long (fh+36, k->uniq); + put_long (fh + 36, k->uniq); if (create == 2) aino->elock = 1; else @@ -2297,20 +2310,6 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb PUT_PCK_RES1 (packet, DOS_TRUE); } -static void -action_lock_from_fh (Unit *unit, dpacket packet) -{ - uaecptr out; - Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); - //write_log("lock_from_fh %x\n", k); - if (k == 0) { - PUT_PCK_RES1 (packet, DOS_FALSE); - return; - } - out = action_dup_lock_2 (unit, packet, make_lock (unit, k->aino->uniq, -2)); - //write_log("=%x\n", out); -} - static void action_fh_from_lock (Unit *unit, dpacket packet) { @@ -2322,7 +2321,7 @@ action_fh_from_lock (Unit *unit, dpacket packet) mode_t openmode; int mode; - TRACE(("ACTION_FH_FROM_LOCK(0x%lx,0x%lx)\n",fh,lock)); + TRACE(("ACTION_FH_FROM_LOCK(0x%lx,0x%lx)\n", fh, lock)); DUMPLOCK(unit,lock); if (!lock) { diff --git a/include/cdtv.h b/include/cdtv.h index 863e6eb0..e44df5c0 100755 --- a/include/cdtv.h +++ b/include/cdtv.h @@ -3,7 +3,8 @@ extern addrbank dmac_bank; -extern void dmac_init (void); +extern void cdtv_init (void); +extern void cdtv_free (void); extern void CDTV_hsync_handler(void); extern void cdtv_entergui (void); diff --git a/main.c b/main.c index cbd511ae..810ecf77 100755 --- a/main.c +++ b/main.c @@ -38,6 +38,7 @@ #include "scsidev.h" #include "uaeserial.h" #include "akiko.h" +#include "cdtv.h" #include "savestate.h" #include "filesys.h" #include "parallel.h" @@ -544,6 +545,9 @@ void do_leave_program (void) #ifdef SERIAL_PORT serial_exit (); #endif +#ifdef CDTV + cdtv_free (); +#endif #ifdef CD32 akiko_free (); #endif diff --git a/memory.c b/memory.c index ce537efe..8acf47ea 100755 --- a/memory.c +++ b/memory.c @@ -1545,7 +1545,7 @@ uae_u8 *REGPARAM2 default_xlate (uaecptr a) } } } - return kickmem_xlate (0); /* So we don't crash. */ + return kickmem_xlate (2); /* So we don't crash. */ } /* Address banks */ diff --git a/newcpu.c b/newcpu.c index 16a27cd2..159974a5 100755 --- a/newcpu.c +++ b/newcpu.c @@ -962,9 +962,6 @@ static void Exception_normal (int nr, struct regstruct *regs, uaecptr oldpc) exception_debug (nr); MakeSR(regs); - if (nr == 3) - activate_debugger(); - if (!regs->s) { regs->usp = m68k_areg(regs, 7); if (currprefs.cpu_level >= 2) @@ -2630,24 +2627,42 @@ void exception2 (uaecptr addr, uaecptr fault) void cpureset (void) { - customreset (); -#if 0 + uaecptr pc; + uaecptr ksboot = 0xf80002 - 2; /* -2 = RESET hasn't increased PC yet */ uae_u16 ins; - if (currprefs.cpu_level == 0 && (currprefs.cpu_compatible || currprefs.cpu_cycle_exact)) { + + if (currprefs.cpu_compatible || currprefs.cpu_cycle_exact) { + customreset (); + return; + } + pc = m68k_getpc(®s); + if (pc >= currprefs.chipmem_size) { + addrbank *b = &get_mem_bank(pc); + if (b->check(pc, 2 + 2)) { + /* We have memory, hope for the best.. */ + customreset (); + return; + } + write_log("M68K RESET PC=%x, rebooting..\n", pc); customreset (); + m68k_setpc (®s, ksboot); return; } - ins = get_word (m68k_getpc(®s) + 2); + /* panic, RAM is going to disappear under PC */ + ins = get_word (pc + 2); if ((ins & ~7) == 0x4ed0) { int reg = ins & 7; uae_u32 addr = m68k_areg (®s, reg); - write_log ("reset/jmp (ax) combination emulated\n"); + write_log ("reset/jmp (ax) combination emulated -> %x\n", addr); customreset (); if (addr < 0x80000) addr += 0xf80000; - m68k_setpc (®s, addr); + m68k_setpc (®s, addr - 2); + return; } -#endif + write_log("M68K RESET PC=%x, rebooting..\n", pc); + customreset (); + m68k_setpc (®s, ksboot); } diff --git a/od-win32/blkdev_win32_ioctl.c b/od-win32/blkdev_win32_ioctl.c index e400aafc..05bbe843 100755 --- a/od-win32/blkdev_win32_ioctl.c +++ b/od-win32/blkdev_win32_ioctl.c @@ -113,7 +113,7 @@ static int close_mci(int unitnum) MCI_GENERIC_PARMS gp = { 0 }; ciw->playend = -1; - if (ciw->mciid) { + if (ciw->mciid > 0) { if (log_scsi) write_log("IOCTL: MCI close\n"); mcierr("MCI_STOP", mciSendCommand(ciw->mciid, MCI_STOP, MCI_WAIT, (DWORD_PTR)&gp)); diff --git a/od-win32/picasso96_win.c b/od-win32/picasso96_win.c index 80c8bb77..d74e276c 100755 --- a/od-win32/picasso96_win.c +++ b/od-win32/picasso96_win.c @@ -65,7 +65,7 @@ int p96hsync_counter, palette_changed; #endif #define LOCK_UNLOCK_MADNESS //need for 7 times faster linedraw #define PIXEL_LOCK //and scrollable screens -#define MAXFLUSHPIXEL 3200 //pixel draw in a lock +#define MAXFLUSHPIXEL 2000 //pixel draw in a lock static void flushpixels(void); #ifdef P96TRACING_ENABLED #define P96TRACE(x) do { write_log x; } while(0) diff --git a/od-win32/posixemu.c b/od-win32/posixemu.c index ffa6f1ff..d5e68654 100755 --- a/od-win32/posixemu.c +++ b/od-win32/posixemu.c @@ -247,17 +247,19 @@ int uae_start_thread (char *name, void *(*f)(void *), void *arg, uae_thread_id * unsigned foo; struct thparms *thp; - if (name) - write_log("Thread '%s' started\n", name); thp = malloc (sizeof (struct thparms)); thp->f = f; thp->arg = arg; hThread = (HANDLE)_beginthreadex(NULL, 0, thread_init, thp, 0, &foo); *tid = hThread; - if (hThread) + if (hThread) { SetThreadPriority (hThread, THREAD_PRIORITY_ABOVE_NORMAL); - else + if (name) + write_log("Thread '%s' started (%d)\n", name, foo); + } else { result = 0; + write_log("Thread '%s' failed to start!?\n", name ? name : ""); + } return result; } diff --git a/od-win32/win32.h b/od-win32/win32.h index 1b0b06fc..55ec845a 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 7 +#define WINUAEBETA 8 #define WINUAEPUBLICBETA 1 -#define WINUAEDATE MAKEBD(2007, 2, 17) +#define WINUAEDATE MAKEBD(2007, 2, 24) #define IHF_WINDOWHIDDEN 6 #define NORMAL_WINDOW_STYLE (WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU) diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index c26c0b28..419e9a21 100755 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -1,4 +1,13 @@ +Beta 8: (RC 1) + +- uaehf.device unit >=30 crash fixed +- CDTV CD audio will be stopped when exiting/reseting +- correct CDTV CD number of tracks returned in ASPI-mode +- re-added and fixed special case handling for 68k reset-instruction + when more compatible CPU setting is not enabled +- filesystem ACTION_COPY_DIR_FH packet memory (lock) leak fixed + Beta 7: (possible bug fixes and small tweaks left) - Picasso96 graphics problems really fixed -- 2.47.3