From 3c4e87c68e724118bf5337945f2b8fb99a9838e8 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Wed, 20 Dec 2006 19:26:38 +0200 Subject: [PATCH] imported winuaesrc1430b4b.zip --- bsdsocket.c | 18 +- custom.c | 42 +-- disk.c | 4 +- filesys.c | 31 +- include/custom.h | 1 + od-win32/bsdsock.c | 341 +++++++++-------- od-win32/mman.c | 8 +- od-win32/parser.c | 127 ++++--- od-win32/picasso96_win.c | 76 +++- od-win32/resources/resource.h | 35 -- od-win32/sounddep/sound.c | 3 +- od-win32/win32.c | 169 ++++++--- od-win32/win32.h | 2 +- od-win32/win32gui.c | 4 +- od-win32/winuae_msvc/winuae_msvc.vcproj | 476 ++++++++++++------------ od-win32/winuaechangelog.txt | 17 + 16 files changed, 743 insertions(+), 611 deletions(-) diff --git a/bsdsocket.c b/bsdsocket.c index cd79a5ae..440ca79b 100644 --- a/bsdsocket.c +++ b/bsdsocket.c @@ -245,6 +245,8 @@ void releasesock (SB, int sd) /* @@@ TODO: ensure proper interlocking */ struct socketbase *sbsigqueue; +volatile int bsd_int_requested; + void addtosigqueue (SB, int events) { locksigqueue (); @@ -260,17 +262,20 @@ void addtosigqueue (SB, int events) } sb->dosignal = 1; + bsd_int_requested = 1; + unlocksigqueue (); - INTREQ (0x8000 | 0x2000); + //INTREQ (0x8000 | 0x2000); } static uae_u32 REGPARAM2 bsdsock_int_handler (TrapContext *context) { SB; + locksigqueue (); + if (sbsigqueue != NULL) { - locksigqueue (); for (sb = sbsigqueue; sb; sb = sb->nextsig) { if (sb->dosignal == 1) { @@ -278,17 +283,18 @@ static uae_u32 REGPARAM2 bsdsock_int_handler (TrapContext *context) m68k_areg (&context->regs, 1) = sb->ownertask; m68k_dreg (&context->regs, 0) = sb->sigstosend; CallLib (context, get_long (4), -0x144); /* Signal() */ - - regs = sbved_regs; - + context->regs = sbved_regs; sb->sigstosend = 0; } sb->dosignal = 0; } sbsigqueue = NULL; - unlocksigqueue (); } + + bsd_int_requested = 0; + unlocksigqueue (); + return 0; } diff --git a/custom.c b/custom.c index 6b36c4b1..bcd4ed72 100644 --- a/custom.c +++ b/custom.c @@ -2479,10 +2479,11 @@ static void immediate_copper (int num) perform_copper_write (0); } else { // wait or skip if (cop_state.i1 >= 0xffdf && cop_state.i2 == 0xfffe) - return; + break; } } - + cop_state.state = COP_stop; + unset_special (®s, SPCFLAG_COPPER); } STATIC_INLINE void COP1LCH (uae_u16 v) { cop1lc = (cop1lc & 0xffff) | ((uae_u32)v << 16); } @@ -2490,15 +2491,12 @@ STATIC_INLINE void COP1LCL (uae_u16 v) { cop1lc = (cop1lc & ~0xffff) | (v & 0xff STATIC_INLINE void COP2LCH (uae_u16 v) { cop2lc = (cop2lc & 0xffff) | ((uae_u32)v << 16); } STATIC_INLINE void COP2LCL (uae_u16 v) { cop2lc = (cop2lc & ~0xffff) | (v & 0xfffe); } +static void compute_spcflag_copper (void); + static void COPJMP (int num) { int oldstrobe = cop_state.strobe; - if (nocustom()) { - immediate_copper (num); - return; - } - unset_special (®s, SPCFLAG_COPPER); cop_state.ignore_next = 0; if (!oldstrobe) @@ -2509,9 +2507,13 @@ static void COPJMP (int num) copper_enabled_thisline = 0; cop_state.strobe = num; + if (nocustom()) { + immediate_copper (num); + return; + } + if (dmaen (DMA_COPPER)) { - copper_enabled_thisline = 1; - set_special (®s, SPCFLAG_COPPER); + compute_spcflag_copper (); } else if (oldstrobe > 0 && oldstrobe != num && cop_state.state_prev == COP_wait) { /* dma disabled, copper idle and accessing both COPxJMPs -> copper stops! */ cop_state.state = COP_stop; @@ -2523,7 +2525,6 @@ STATIC_INLINE void COPCON (uae_u16 a) copcon = a; } -static void compute_spcflag_copper (void); static void DMACON (int hpos, uae_u16 v) { int oldcop, newcop; @@ -3398,8 +3399,6 @@ static int isagnus[]= { static void dump_copper (char *error, int until_hpos) { - static int warned = 10; - write_log("%s: vpos=%d until_hpos=%d\n", error, vpos, until_hpos); write_log("cvcmp=%d chcmp=%d chpos=%d cvpos=%d ci1=%04.4X ci2=%04.4X\n", @@ -3671,14 +3670,6 @@ static void compute_spcflag_copper (void) set_special (®s, SPCFLAG_COPPER); } -static void copper_handler (void) -{ - /* This will take effect immediately, within the same cycle. */ - set_special (®s, SPCFLAG_COPPER); - if (! copper_enabled_thisline) - uae_abort ("copper_handler"); -} - void blitter_done_notify (void) { if (cop_state.state != COP_bltwait) @@ -4389,12 +4380,21 @@ static void hsync_handler (void) next_lineno = lineno; reset_decisions (); } - +#if 1 #ifdef FILESYS if (uae_int_requested) { set_uae_int_flag (); INTREQ (0x8000 | 0x0008); } +#endif +#if 1 + { + extern volatile int bsd_int_requested; + if (bsd_int_requested) { + INTREQ (0x8000 | 0x2000); + } + } +#endif #endif /* See if there's a chance of a copper wait ending this line. */ diff --git a/disk.c b/disk.c index f758825e..2eb0c53e 100644 --- a/disk.c +++ b/disk.c @@ -2278,7 +2278,7 @@ void dumpdisk (void) static void disk_dmafinished (void) { - INTREQ (0x8002); + INTREQ (0x8000 | 0x0002); longwritemode = 0; dskdmaen = 0; if (disk_debug_logging > 0) { @@ -2841,7 +2841,7 @@ void DSKLEN (uae_u16 v, int hpos) pos += 16; pos %= drv->tracklen; } - INTREQ (0x9000); + INTREQ (0x8000 | 0x1000); done = 1; } else if (dskdmaen == 3) { /* TURBO write */ diff --git a/filesys.c b/filesys.c index 5b320ea3..23dd959a 100644 --- a/filesys.c +++ b/filesys.c @@ -607,8 +607,6 @@ typedef struct _unit { /* Keys */ struct key *keys; - uae_u32 key_uniq; - uae_u32 a_uniq; a_inode rootnode; unsigned long aino_cache_size; @@ -622,6 +620,8 @@ typedef struct _unit { } Unit; +static uae_u32 a_uniq, key_uniq; + typedef uae_u8 *dpacket; #define PUT_PCK_RES1(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp_Res1), (v)); } while (0) #define PUT_PCK_RES2(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp_Res2), (v)); } while (0) @@ -1062,8 +1062,8 @@ static char *get_aname (Unit *unit, a_inode *base, char *rel) static void init_child_aino (Unit *unit, a_inode *base, a_inode *aino) { - aino->uniq = ++unit->a_uniq; - if (unit->a_uniq == 0xFFFFFFFF) { + aino->uniq = ++a_uniq; + if (a_uniq == 0xFFFFFFFF) { write_log ("Running out of a_inodes (prepare for big trouble)!\n"); } aino->shlock = 0; @@ -1326,7 +1326,6 @@ static Unit *startup_create_unit (UnitInfo *uinfo) unit->total_locked_ainos = 0; unit->next_exkey = 1; unit->keys = 0; - unit->a_uniq = unit->key_uniq = 0; unit->rootnode.aname = uinfo->volname; unit->rootnode.nname = uinfo->rootdir; @@ -1515,7 +1514,7 @@ static Key *lookup_key (Unit *unit, uae_u32 uniq) static Key *new_key (Unit *unit) { Key *k = (Key *) xmalloc(sizeof(Key)); - k->uniq = ++unit->key_uniq; + k->uniq = ++key_uniq; k->fd = NULL; k->file_pos = 0; k->next = unit->keys; @@ -2065,7 +2064,6 @@ int get_native_path(uae_u32 lock, char *out) int i = 0; for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { if (current_mountinfo.ui[i].self) { - uae_u32 err; a_inode *a = lookup_aino (current_mountinfo.ui[i].self, get_long ((lock << 2) + 4)); if (a) { strcpy (out, a->nname); @@ -3289,12 +3287,6 @@ action_flush (Unit *unit, dpacket packet) PUT_PCK_RES1 (packet, DOS_TRUE); } -int last_n, last_n2; -void blehint(void) -{ - do_uae_int_requested(); -} - /* We don't want multiple interrupts to be active at the same time. I don't * know whether AmigaOS takes care of that, but this does. */ static uae_sem_t singlethread_int_sem; @@ -3306,9 +3298,6 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context) int n = m68k_dreg (&context->regs, 0); static int unit_no; - last_n = n; - last_n2 = -1; - switch (n) { case 0: /* Determine whether a given EXTER interrupt is for us. */ @@ -3661,6 +3650,8 @@ void filesys_reset (void) } unit_num = 0; units = 0; + key_uniq = 0; + a_uniq = 0; } static void free_all_ainos (Unit *u, a_inode *parent) @@ -4350,8 +4341,8 @@ static uae_u8 *restore_filesys_virtual (UnitInfo *ui, uae_u8 *src) Unit *u = startup_create_unit (ui); int cnt; - u->a_uniq = restore_u64 (); - u->key_uniq = restore_u64 (); + a_uniq = restore_u64 (); + key_uniq = restore_u64 (); u->dosbase = restore_u32 (); u->volume = restore_u32 (); u->port = restore_u32 (); @@ -4377,8 +4368,8 @@ static uae_u8 *save_filesys_virtual (UnitInfo *ui, uae_u8 *dst) Key *k; int cnt; - save_u64 (u->a_uniq); - save_u64 (u->key_uniq); + save_u64 (a_uniq); + save_u64 (key_uniq); save_u32 (u->dosbase); save_u32 (u->volume); save_u32 (u->port); diff --git a/include/custom.h b/include/custom.h index 6e719a1e..e7e31f1b 100644 --- a/include/custom.h +++ b/include/custom.h @@ -54,6 +54,7 @@ STATIC_INLINE int dmaen (unsigned int dmamask) return (dmamask & dmacon) && (dmacon & 0x200); } +#define SPCFLAG_UAE_INT 1 #define SPCFLAG_STOP 2 #define SPCFLAG_COPPER 4 #define SPCFLAG_INT 8 diff --git a/od-win32/bsdsock.c b/od-win32/bsdsock.c index c0ffcfbc..b722e262 100644 --- a/od-win32/bsdsock.c +++ b/od-win32/bsdsock.c @@ -40,26 +40,6 @@ static int hWndSelector = 0; /* Set this to zero to get hSockWnd */ #define MAX_SELECT_THREADS 64 #define MAX_GET_THREADS 64 -struct selt { - HANDLE hThreads[MAX_SELECT_THREADS]; - struct threadargsw *threadargsw[MAX_SELECT_THREADS]; - HANDLE hEvents[MAX_SELECT_THREADS]; -}; - -struct gett { - HANDLE hGetThreads[MAX_GET_THREADS]; - struct threadargs *threadGetargs[MAX_GET_THREADS]; - int threadGetargs_inuse[MAX_GET_THREADS]; - HANDLE hGetEvents[MAX_GET_THREADS]; -}; - -struct pendingasync { - struct socketbase *asyncsb[MAXPENDINGASYNC]; - SOCKET asyncsock[MAXPENDINGASYNC]; - uae_u32 asyncsd[MAXPENDINGASYNC]; - int asyncindex; -}; - struct bsdsockdata { HWND hSockWnd; HANDLE hSockThread; @@ -70,9 +50,19 @@ struct bsdsockdata { DWORD threadid; WSADATA wsbData; - struct selt *st; - struct gett *gt; - struct pendingasync *as; + HANDLE hGetThreads[MAX_GET_THREADS]; + struct threadargs *threadGetargs[MAX_GET_THREADS]; + int threadGetargs_inuse[MAX_GET_THREADS]; + HANDLE hGetEvents[MAX_GET_THREADS]; + + HANDLE hThreads[MAX_SELECT_THREADS]; + struct threadargsw *threadargsw[MAX_SELECT_THREADS]; + HANDLE hEvents[MAX_SELECT_THREADS]; + + struct socketbase *asyncsb[MAXPENDINGASYNC]; + SOCKET asyncsock[MAXPENDINGASYNC]; + uae_u32 asyncsd[MAXPENDINGASYNC]; + int asyncindex; }; static struct bsdsockdata *bsd; @@ -153,9 +143,6 @@ static int mySockStartup(void) if (!bsd) { bsd = calloc (sizeof (struct bsdsockdata), 1); - bsd->st = calloc (sizeof (struct selt), 1); - bsd->gt = calloc (sizeof (struct gett), 1); - bsd->as = calloc (sizeof (struct pendingasync), 1); } if (WSAStartup(MAKEWORD(SOCKVER_MAJOR, SOCKVER_MINOR), &bsd->wsbData)) { lasterror = WSAGetLastError(); @@ -251,9 +238,9 @@ void deinit_socket_layer(void) CloseHandle(bsd->hSockThread); } for (i = 0; i < MAX_SELECT_THREADS; i++) { - if (bsd->st->hThreads[i]) { - CloseHandle(bsd->st->hThreads[i]); - bsd->st->hThreads[i] = NULL; + if (bsd->hThreads[i]) { + CloseHandle(bsd->hThreads[i]); + bsd->hThreads[i] = NULL; } } } @@ -317,8 +304,8 @@ void host_sbcleanup(SB) int i; for (i = 0; i < MAXPENDINGASYNC; i++) { - if (bsd->as->asyncsb[i] == sb) - bsd->as->asyncsb[i] = NULL; + if (bsd->asyncsb[i] == sb) + bsd->asyncsb[i] = NULL; } if (sb->hEvent != NULL) @@ -329,7 +316,7 @@ void host_sbcleanup(SB) host_closesocketquick(sb->dtable[i]); if (sb->mtable[i]) - bsd->as->asyncsb[(sb->mtable[i] - 0xb000) / 2] = NULL; + bsd->asyncsb[(sb->mtable[i] - 0xb000) / 2] = NULL; } shutdown(sb->sockAbort,1); @@ -342,35 +329,35 @@ void host_sbreset(void) { int i; for (i = 0; i < MAXPENDINGASYNC; i++) { - bsd->as->asyncsb[i] = 0; - bsd->as->asyncsock[i] = 0; - bsd->as->asyncsd[i] = 0; + bsd->asyncsb[i] = 0; + bsd->asyncsock[i] = 0; + bsd->asyncsd[i] = 0; } for (i = 0; i < MAX_GET_THREADS; i++) { - bsd->st->threadargsw[i] = 0; + bsd->threadargsw[i] = 0; } } -void sockmsg(unsigned int msg, WPARAM wParam, LPARAM lParam) +static void sockmsg(unsigned int msg, WPARAM wParam, LPARAM lParam) { SB; unsigned int index; int sdi; - index = (msg-0xb000)/2; - sb = bsd->as->asyncsb[index]; + index = (msg - 0xb000) / 2; + sb = bsd->asyncsb[index]; if (!(msg & 1)) { // is this one really for us? - if ((SOCKET)wParam != bsd->as->asyncsock[index]) + if ((SOCKET)wParam != bsd->asyncsock[index]) { // cancel socket event WSAAsyncSelect((SOCKET)wParam, hWndSelector ? hAmigaWnd : bsd->hSockWnd, 0, 0); return; } - sdi = bsd->as->asyncsd[index] - 1; + sdi = bsd->asyncsd[index] - 1; // asynchronous socket event? if (sb && !(sb->ftable[sdi] & SF_BLOCKINGINPROGRESS) && sb->mtable[sdi]) @@ -390,30 +377,30 @@ void sockmsg(unsigned int msg, WPARAM wParam, LPARAM lParam) if (WSAGETSELECTERROR(lParam)) fmask |= REP_ERROR; // notify - if (sb->ftable[sdi] & fmask) sb->ftable[sdi] |= fmask<<8; + if (sb->ftable[sdi] & fmask) sb->ftable[sdi] |= fmask << 8; - addtosigqueue(sb,1); + addtosigqueue(sb, 1); return; } } locksigqueue(); - if (sb != NULL) - { - + if (sb != NULL) { - bsd->as->asyncsb[index] = NULL; + bsd->asyncsb[index] = NULL; - if (WSAGETASYNCERROR(lParam)) - { - bsdsocklib_seterrno(sb,WSAGETASYNCERROR(lParam)-WSABASEERR); - if (sb->sb_errno >= 1001 && sb->sb_errno <= 1005) bsdsocklib_setherrno(sb,sb->sb_errno-1000); - else if (sb->sb_errno == 55) // ENOBUFS - write_log("BSDSOCK: ERROR - Buffer overflow - %d bytes requested\n",WSAGETASYNCBUFLEN(lParam)); + if (WSAGETASYNCERROR(lParam)) { + bsdsocklib_seterrno(sb, WSAGETASYNCERROR(lParam) - WSABASEERR); + if (sb->sb_errno >= 1001 && sb->sb_errno <= 1005) { + bsdsocklib_setherrno(sb, sb->sb_errno - 1000); + } else if (sb->sb_errno == 55) { // ENOBUFS + write_log("BSDSOCK: ERROR - Buffer overflow - %d bytes requested\n", + WSAGETASYNCBUFLEN(lParam)); + } + } else { + bsdsocklib_seterrno(sb,0); } - else bsdsocklib_seterrno(sb,0); - SETSIGNAL; } @@ -426,19 +413,19 @@ static unsigned int allocasyncmsg(SB,uae_u32 sd,SOCKET s) int i; locksigqueue(); - for (i = bsd->as->asyncindex+1; i != bsd->as->asyncindex; i++) { - if (i == MAXPENDINGASYNC) + for (i = bsd->asyncindex + 1; i != bsd->asyncindex; i++) { + if (i >= MAXPENDINGASYNC) i = 0; - if (!bsd->as->asyncsb[i]) { - bsd->as->asyncsb[i] = sb; - if (++bsd->as->asyncindex == MAXPENDINGASYNC) - bsd->as->asyncindex = 0; + if (!bsd->asyncsb[i]) { + bsd->asyncsb[i] = sb; + if (++bsd->asyncindex >= MAXPENDINGASYNC) + bsd->asyncindex = 0; unlocksigqueue(); if (s == INVALID_SOCKET) { return i * 2 + 0xb001; } else { - bsd->as->asyncsd[i] = sd; - bsd->as->asyncsock[i] = s; + bsd->asyncsd[i] = sd; + bsd->asyncsock[i] = s; return i * 2 + 0xb000; } } @@ -457,10 +444,10 @@ static void cancelasyncmsg(TrapContext *context, unsigned int wMsg) wMsg = (wMsg-0xb000)/2; - sb = bsd->as->asyncsb[wMsg]; + sb = bsd->asyncsb[wMsg]; if (sb != NULL) { - bsd->as->asyncsb[wMsg] = NULL; + bsd->asyncsb[wMsg] = NULL; CANCELSIGNAL; } } @@ -497,9 +484,9 @@ void setWSAAsyncSelect(SB, uae_u32 sd, SOCKET s, long lEvent ) wsbevents |= FD_CLOSE; wsbevents |= lEvent; i = (sb->mtable[sd-1]-0xb000)/2; - bsd->as->asyncsb[i] = sb; - bsd->as->asyncsd[i] = sd; - bsd->as->asyncsock[i] = s; + bsd->asyncsb[i] = sb; + bsd->asyncsd[i] = sd; + bsd->asyncsock[i] = s; WSAAsyncSelect(s, hWndSelector ? hAmigaWnd : bsd->hSockWnd, sb->mtable[sd-1], wsbevents); unlocksigqueue(); @@ -643,9 +630,9 @@ uae_u32 host_listen(SB, uae_u32 sd, uae_u32 backlog) void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) { - struct sockaddr *rp_name,*rp_nameuae; + struct sockaddr *rp_name, *rp_nameuae; struct sockaddr sockaddr; - int hlen,hlenuae=0; + int hlen, hlenuae = 0; SOCKET s, s2; int success = 0; unsigned int wMsg; @@ -675,7 +662,7 @@ void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 nam if (s2 == INVALID_SOCKET) { SETERRNO; - if (sb->ftable[sd-1] & SF_BLOCKING && sb->sb_errno == WSAEWOULDBLOCK - WSABASEERR) { + if ((sb->ftable[sd-1] & SF_BLOCKING) && sb->sb_errno == WSAEWOULDBLOCK - WSABASEERR) { if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0) { if (sb->mtable[sd-1] == 0) { WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : bsd->hSockWnd, wMsg, FD_ACCEPT); @@ -788,12 +775,12 @@ struct threadsock_packet static BOOL HandleStuff( void ) { - BOOL quit = FALSE; - SB = NULL; - BOOL handled = TRUE; - if (bsd->hSockReq) { + BOOL quit = FALSE; + SB = NULL; + BOOL handled = TRUE; + if (bsd->hSockReq) { // 100ms sleepiness might need some tuning... - //if(WaitForSingleObject( hSockReq, 100 ) == WAIT_OBJECT_0 ) + //if(WaitForSingleObject( hSockReq, 100 ) == WAIT_OBJECT_0 ) { switch( sockreq.packet_type ) { @@ -848,7 +835,7 @@ static BOOL HandleStuff( void ) static LRESULT CALLBACK SocketWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - if(message >= 0xB000 && message < 0xB000+MAXPENDINGASYNC * 2) { + if(message >= 0xB000 && message < 0xB000 + MAXPENDINGASYNC * 2) { #if DEBUG_SOCKETS write_log( "sockmsg(0x%x, 0x%x, 0x%x)\n", message, wParam, lParam ); #endif @@ -862,9 +849,9 @@ static LRESULT CALLBACK SocketWindowProc(HWND hwnd, UINT message, WPARAM wParam, static unsigned int __stdcall sock_thread(void *blah) { - unsigned int result = 0; - HANDLE WaitHandle; - MSG msg; + unsigned int result = 0; + HANDLE WaitHandle; + MSG msg; if(bsd->hSockWnd) { // Make sure we're outrunning the wolves @@ -887,7 +874,7 @@ static unsigned int __stdcall sock_thread(void *blah) if(HandleStuff()) // See if its time to quit... break; } - if (wait == WAIT_OBJECT_0 +1) { + if (wait == WAIT_OBJECT_0 + 1) { Sleep(10); while(PeekMessage(&msg, NULL, WM_USER, 0xB000 + MAXPENDINGASYNC * 2, PM_REMOVE) > 0) { TranslateMessage(&msg); @@ -897,9 +884,9 @@ static unsigned int __stdcall sock_thread(void *blah) } } } - write_log( "BSDSOCK: We have exited our sock_thread()\n" ); - THREADEND(result); - return result; + write_log( "BSDSOCK: We have exited our sock_thread()\n" ); + THREADEND(result); + return result; } @@ -1485,7 +1472,7 @@ int host_CloseSocket(TrapContext *context, SB, int sd) if (s != INVALID_SOCKET) { if (sb->mtable[sd-1]) { - bsd->as->asyncsb[(sb->mtable[sd-1]-0xb000)/2] = NULL; + bsd->asyncsb[(sb->mtable[sd-1]-0xb000)/2] = NULL; sb->mtable[sd-1] = 0; } @@ -1604,7 +1591,7 @@ static void makesockbitfield(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win } } } - put_long(fd_set_amiga,val); + put_long(fd_set_amiga, val); fd_set_amiga += 4; } } @@ -1631,9 +1618,9 @@ static unsigned int __stdcall thread_WaitSelect(void *indexp) SB; for (;;) { - WaitForSingleObject(bsd->st->hEvents[index],INFINITE); + WaitForSingleObject(bsd->hEvents[index], INFINITE); - if ((args = bsd->st->threadargsw[index]) != NULL) { + if ((args = bsd->threadargsw[index]) != NULL) { sb = args->sb; nfds = args->nfds; readfds = args->readfds; @@ -1656,7 +1643,8 @@ static unsigned int __stdcall thread_WaitSelect(void *indexp) TRACE(("-> ")); - sb->resultval = select(nfds+1,&readsocks,writefds ? &writesocks : NULL,exceptfds ? &exceptsocks : NULL,timeout ? &tv : 0); + sb->resultval = select(nfds+1,&readsocks,writefds ? &writesocks : NULL, + exceptfds ? &exceptsocks : NULL,timeout ? &tv : 0); if (sb->resultval == SOCKET_ERROR) { // select was stopped by sb->sockAbort if (readsocks.fd_count > 1) { @@ -1700,7 +1688,7 @@ static unsigned int __stdcall thread_WaitSelect(void *indexp) SETSIGNAL; - bsd->st->threadargsw[index] = NULL; + bsd->threadargsw[index] = NULL; SetEvent(sb->hEvent); } } @@ -1716,7 +1704,8 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua wssigs = sigmp ? get_long(sigmp) : 0; - TRACE(("WaitSelect(%d,0x%lx,0x%lx,0x%lx,0x%lx,0x%lx) ",nfds,readfds,writefds,exceptfds,timeout,wssigs)); + TRACE(("WaitSelect(%d,0x%lx,0x%lx,0x%lx,0x%lx,0x%lx) ", + nfds, readfds, writefds, exceptfds, timeout, wssigs)); if (!readfds && !writefds && !exceptfds && !timeout && !wssigs) { sb->resultval = 0; @@ -1748,9 +1737,8 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua if (wssigs != 0) { m68k_dreg(&context->regs, 0) = wssigs; sigs = CallLib(context, get_long(4),-0x13e); // Wait() - put_long(sigmp, sigs & wssigs); - } + } if (readfds) fd_zero(readfds,nfds); @@ -1767,17 +1755,17 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua sb->needAbort = 1; for (i = 0; i < MAX_SELECT_THREADS; i++) { - if (bsd->st->hThreads[i] && !bsd->st->threadargsw[i]) + if (bsd->hThreads[i] && !bsd->threadargsw[i]) break; } if (i >= MAX_SELECT_THREADS) { for (i = 0; i < MAX_SELECT_THREADS; i++) { - if (!bsd->st->hThreads[i]) { - bsd->st->hEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL); - bsd->st->hThreads[i] = THREAD(thread_WaitSelect,&i); - if (bsd->st->hEvents[i] == NULL || bsd->st->hThreads[i] == NULL) { - bsd->st->hThreads[i] = 0; + if (!bsd->hThreads[i]) { + bsd->hEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL); + bsd->hThreads[i] = THREAD(thread_WaitSelect, &i); + if (bsd->hEvents[i] == NULL || bsd->hThreads[i] == NULL) { + bsd->hThreads[i] = 0; write_log("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n", GetLastError()); bsdsocklib_seterrno(sb,12); // ENOMEM @@ -1785,7 +1773,7 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua return; } // this should improve responsiveness - SetThreadPriority(bsd->st->hThreads[i], THREAD_PRIORITY_TIME_CRITICAL); + SetThreadPriority(bsd->hThreads[i], THREAD_PRIORITY_TIME_CRITICAL); break; } } @@ -1803,12 +1791,12 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua taw.exceptfds = exceptfds; taw.timeout = timeout; - bsd->st->threadargsw[i] = &taw; + bsd->threadargsw[i] = &taw; - SetEvent(bsd->st->hEvents[i]); + SetEvent(bsd->hEvents[i]); - m68k_dreg(&context->regs,0) = (((uae_u32)1)<signal)|sb->eintrsigs|wssigs; - sigs = CallLib(context, get_long(4),-0x13e); // Wait() + m68k_dreg(&context->regs, 0) = (((uae_u32)1) << sb->signal) | sb->eintrsigs | wssigs; + sigs = CallLib(context, get_long(4), -0x13e); // Wait() /* if ((1<signal) & sigs) { // 2.3.2002/SR Fix for AmiFTP -> Thread is ready, no need to Abort @@ -1820,12 +1808,12 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua write_log("BSDSOCK: ERROR - Cannot create socket: %d\n", WSAGetLastError()); shutdown(sb->sockAbort,1); if (newsock != sb->sockAbort) { - shutdown(sb->sockAbort,1); + shutdown(sb->sockAbort, 1); closesocket(sb->sockAbort); } } - WaitForSingleObject(sb->hEvent,INFINITE); + WaitForSingleObject(sb->hEvent, INFINITE); CANCELSIGNAL; @@ -1899,6 +1887,7 @@ BOOL CheckOnline(SB) { DWORD dwFlags; BOOL bReturn = TRUE; + if (InternetGetConnectedState(&dwFlags,0) == FALSE) { // Internet is offline if (InternetAttemptConnect(0) != ERROR_SUCCESS) { // Show Dialer window sb->sb_errno = 10001; @@ -1911,7 +1900,7 @@ BOOL CheckOnline(SB) SetActiveWindow(hAmigaWnd); } } - return(bReturn); + return bReturn; } static unsigned int __stdcall thread_get(void *indexp) @@ -1927,12 +1916,12 @@ static unsigned int __stdcall thread_get(void *indexp) SB; for (;;) { - WaitForSingleObject(bsd->gt->hGetEvents[index], INFINITE); - if (bsd->gt->threadGetargs_inuse[index] == -1) { - bsd->gt->threadGetargs_inuse[index] = 0; - bsd->gt->threadGetargs[index] = NULL; + WaitForSingleObject(bsd->hGetEvents[index], INFINITE); + if (bsd->threadGetargs_inuse[index] == -1) { + bsd->threadGetargs_inuse[index] = 0; + bsd->threadGetargs[index] = NULL; } - if ((args = bsd->gt->threadGetargs[index]) != NULL) { + if ((args = bsd->threadGetargs[index]) != NULL) { sb = args->sb; if (args->args1 == 0) { // gethostbyname or gethostbyaddr @@ -1948,17 +1937,17 @@ static unsigned int __stdcall thread_get(void *indexp) if (addrtype == -1) { host = gethostbyname(name_rp); } else { - host = gethostbyaddr(name_rp,namelen,addrtype); + host = gethostbyaddr(name_rp, namelen, addrtype); } - if (bsd->gt->threadGetargs_inuse[index] != -1) { + if (bsd->threadGetargs_inuse[index] != -1) { // No CTRL-C Signal if (host == 0) { // Error occured SETERRNO; - TRACE(("failed (%d) - ",sb->sb_errno)); + TRACE(("failed (%d) - ", sb->sb_errno)); } else { - bsdsocklib_seterrno(sb,0); - memcpy(buf,host,sizeof(HOSTENT)); + bsdsocklib_seterrno(sb, 0); + memcpy(buf, host, sizeof(HOSTENT)); } } } @@ -1971,14 +1960,14 @@ static unsigned int __stdcall thread_get(void *indexp) buf = args->args5; name_rp = get_real_address(name); proto = getprotobyname (name_rp); - if (bsd->gt->threadGetargs_inuse[index] != -1) { // No CTRL-C Signal + if (bsd->threadGetargs_inuse[index] != -1) { // No CTRL-C Signal if (proto == 0) { // Error occured SETERRNO; - TRACE(("failed (%d) - ",sb->sb_errno)); + TRACE(("failed (%d) - ", sb->sb_errno)); } else { - bsdsocklib_seterrno(sb,0); - memcpy(buf,proto,sizeof(struct protoent)); + bsdsocklib_seterrno(sb, 0); + memcpy(buf, proto, sizeof(struct protoent)); } } } @@ -1999,31 +1988,31 @@ static unsigned int __stdcall thread_get(void *indexp) proto_rp = get_real_address(proto); if (type) { - serv = getservbyport(nameport,proto_rp); + serv = getservbyport(nameport, proto_rp); } else { name_rp = get_real_address(nameport); - serv = getservbyname(name_rp,proto_rp); + serv = getservbyname(name_rp, proto_rp); } - if (bsd->gt->threadGetargs_inuse[index] != -1) { + if (bsd->threadGetargs_inuse[index] != -1) { // No CTRL-C Signal if (serv == 0) { // Error occured SETERRNO; - TRACE(("failed (%d) - ",sb->sb_errno)); + TRACE(("failed (%d) - ", sb->sb_errno)); } else { - bsdsocklib_seterrno(sb,0); - memcpy(buf,serv,sizeof(struct servent)); + bsdsocklib_seterrno(sb, 0); + memcpy(buf, serv, sizeof(struct servent)); } } } TRACE(("-> ")); - if (bsd->gt->threadGetargs_inuse[index] != -1) + if (bsd->threadGetargs_inuse[index] != -1) SETSIGNAL; - bsd->gt->threadGetargs_inuse[index] = 0; - bsd->gt->threadGetargs[index] = NULL; + bsd->threadGetargs_inuse[index] = 0; + bsd->threadGetargs[index] = NULL; } } @@ -2079,20 +2068,21 @@ void host_gethostbynameaddr(TrapContext *context, SB, uae_u32 name, uae_u32 name args.args5 = buf; for (i = 0; i < MAX_GET_THREADS; i++) { - if (bsd->gt->threadGetargs_inuse[i] == -1) { - bsd->gt->threadGetargs_inuse[i] = 0; - bsd->gt->threadGetargs[i] = NULL; + if (bsd->threadGetargs_inuse[i] == -1) { + bsd->threadGetargs_inuse[i] = 0; + bsd->threadGetargs[i] = NULL; } - if (bsd->gt->hGetThreads[i] && !bsd->gt->threadGetargs_inuse[i]) break; + if (bsd->hGetThreads[i] && !bsd->threadGetargs_inuse[i]) + break; } if (i >= MAX_GET_THREADS) { for (i = 0; i < MAX_GET_THREADS; i++) { - if (bsd->gt->hGetThreads[i] == NULL) { - bsd->gt->hGetEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL); - bsd->gt->hGetThreads[i] = THREAD(thread_get, &i); - if (bsd->gt->hGetEvents[i] == NULL || bsd->gt->hGetThreads[i] == NULL) { - bsd->gt->hGetThreads[i] = NULL; + if (bsd->hGetThreads[i] == NULL) { + bsd->hGetEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL); + bsd->hGetThreads[i] = THREAD(thread_get, &i); + if (bsd->hGetEvents[i] == NULL || bsd->hGetThreads[i] == NULL) { + bsd->hGetThreads[i] = NULL; write_log("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n", GetLastError()); bsdsocklib_seterrno(sb, 12); // ENOMEM @@ -2107,17 +2097,18 @@ void host_gethostbynameaddr(TrapContext *context, SB, uae_u32 name, uae_u32 name if (i >= MAX_GET_THREADS) write_log("BSDSOCK: ERROR - Too many gethostbyname()s\n"); else { - bsdsetpriority (bsd->gt->hGetThreads[i]); - bsd->gt->threadGetargs[i] = &args; - bsd->gt->threadGetargs_inuse[i] = 1; + bsdsetpriority (bsd->hGetThreads[i]); + bsd->threadGetargs[i] = &args; + bsd->threadGetargs_inuse[i] = 1; - SetEvent(bsd->gt->hGetEvents[i]); + SetEvent(bsd->hGetEvents[i]); } + sb->eintr = 0; - while (bsd->gt->threadGetargs_inuse[i] != 0 && sb->eintr == 0) { + while (bsd->threadGetargs_inuse[i] != 0 && sb->eintr == 0) { WAITSIGNAL; if (sb->eintr == 1) - bsd->gt->threadGetargs_inuse[i] = -1; + bsd->threadGetargs_inuse[i] = -1; } CANCELSIGNAL; @@ -2202,19 +2193,19 @@ void host_getprotobyname(TrapContext *context, SB, uae_u32 name) args.args5 = buf; for (i = 0; i < MAX_GET_THREADS; i++) { - if (bsd->gt->threadGetargs_inuse[i] == -1) { - bsd->gt->threadGetargs_inuse[i] = 0; - bsd->gt->threadGetargs[i] = NULL; + if (bsd->threadGetargs_inuse[i] == -1) { + bsd->threadGetargs_inuse[i] = 0; + bsd->threadGetargs[i] = NULL; } - if (bsd->gt->hGetThreads[i] && !bsd->gt->threadGetargs_inuse[i]) break; + if (bsd->hGetThreads[i] && !bsd->threadGetargs_inuse[i]) break; } if (i >= MAX_GET_THREADS) { for (i = 0; i < MAX_GET_THREADS; i++) { - if (!bsd->gt->hGetThreads[i]) { - bsd->st->hEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL); - bsd->gt->hGetThreads[i] = THREAD(thread_get, &i); - if (bsd->gt->hGetEvents[i] == NULL || bsd->gt->hGetThreads[i] == NULL) { - bsd->gt->hGetThreads[i] = 0; + if (!bsd->hGetThreads[i]) { + bsd->hEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL); + bsd->hGetThreads[i] = THREAD(thread_get, &i); + if (bsd->hGetEvents[i] == NULL || bsd->hGetThreads[i] == NULL) { + bsd->hGetThreads[i] = 0; write_log("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n", GetLastError()); bsdsocklib_seterrno(sb, 12); // ENOMEM sb->resultval = -1; @@ -2228,19 +2219,19 @@ void host_getprotobyname(TrapContext *context, SB, uae_u32 name) if (i >= MAX_GET_THREADS) write_log("BSDSOCK: ERROR - Too many getprotobyname()s\n"); else { - bsdsetpriority (bsd->gt->hGetThreads[i]); + bsdsetpriority (bsd->hGetThreads[i]); - bsd->gt->threadGetargs[i] = &args; - bsd->gt->threadGetargs_inuse[i] = 1; + bsd->threadGetargs[i] = &args; + bsd->threadGetargs_inuse[i] = 1; - SetEvent(bsd->gt->hGetEvents[i]); + SetEvent(bsd->hGetEvents[i]); } sb->eintr = 0; - while (bsd->gt->threadGetargs_inuse[i] != 0 && sb->eintr == 0) { + while (bsd->threadGetargs_inuse[i] != 0 && sb->eintr == 0) { WAITSIGNAL; if (sb->eintr == 1) - bsd->gt->threadGetargs_inuse[i] = -1; + bsd->threadGetargs_inuse[i] = -1; } CANCELSIGNAL; @@ -2327,19 +2318,19 @@ void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32 args.args5 = buf; for (i = 0; i < MAX_GET_THREADS; i++) { - if (bsd->gt->threadGetargs_inuse[i] == -1) { - bsd->gt->threadGetargs_inuse[i] = 0; - bsd->gt->threadGetargs[i] = NULL; + if (bsd->threadGetargs_inuse[i] == -1) { + bsd->threadGetargs_inuse[i] = 0; + bsd->threadGetargs[i] = NULL; } - if (bsd->gt->hGetThreads[i] && !bsd->gt->threadGetargs_inuse[i]) break; + if (bsd->hGetThreads[i] && !bsd->threadGetargs_inuse[i]) break; } if (i >= MAX_GET_THREADS) { for (i = 0; i < MAX_GET_THREADS; i++) { - if (!bsd->gt->hGetThreads[i]) { - bsd->gt->hGetEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL); - bsd->gt->hGetThreads[i] = THREAD(thread_get, &i); - if (bsd->gt->hGetEvents[i] == NULL || bsd->gt->hGetThreads[i] == NULL) { - bsd->gt->hGetThreads[i] = 0; + if (!bsd->hGetThreads[i]) { + bsd->hGetEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL); + bsd->hGetThreads[i] = THREAD(thread_get, &i); + if (bsd->hGetEvents[i] == NULL || bsd->hGetThreads[i] == NULL) { + bsd->hGetThreads[i] = 0; write_log("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n", GetLastError()); bsdsocklib_seterrno(sb, 12); // ENOMEM sb->resultval = -1; @@ -2354,19 +2345,19 @@ void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32 if (i >= MAX_GET_THREADS) write_log("BSDSOCK: ERROR - Too many getprotobyname()s\n"); else { - bsdsetpriority (bsd->gt->hGetThreads[i]); + bsdsetpriority (bsd->hGetThreads[i]); - bsd->gt->threadGetargs[i] = &args; - bsd->gt->threadGetargs_inuse[i] = 1; + bsd->threadGetargs[i] = &args; + bsd->threadGetargs_inuse[i] = 1; - SetEvent(bsd->gt->hGetEvents[i]); + SetEvent(bsd->hGetEvents[i]); } sb->eintr = 0; - while (bsd->gt->threadGetargs_inuse[i] != 0 && sb->eintr == 0) { + while (bsd->threadGetargs_inuse[i] != 0 && sb->eintr == 0) { WAITSIGNAL; if (sb->eintr == 1) - bsd->gt->threadGetargs_inuse[i] = -1; + bsd->threadGetargs_inuse[i] = -1; } CANCELSIGNAL; diff --git a/od-win32/mman.c b/od-win32/mman.c index 1f31bfff..613620ea 100644 --- a/od-win32/mman.c +++ b/od-win32/mman.c @@ -19,9 +19,9 @@ static uae_u32 gfxoffs; uae_u8 *natmem_offset = NULL; #ifdef CPU_64_BIT -static uae_u32 max_allowed_mman = 2048; +int max_allowed_mman = 2048; #else -static uae_u32 max_allowed_mman = 512; +int max_allowed_mman = 512; #endif void cache_free(void *cache) @@ -78,8 +78,8 @@ void init_shm(void) size64 <<= 1; if (size64 > max_allowed_mman * 1024 * 1024) size64 = max_allowed_mman * 1024 * 1024; - if (size64 > 0x40000000) - size64 = 0x40000000; + if (size64 > 0x80000000) + size64 = 0x80000000; if (size64 < 8 * 1024 * 1024) size64 = 8 * 1024 * 1024; size = max_z3fastmem = (uae_u32)size64; diff --git a/od-win32/parser.c b/od-win32/parser.c index e2273ec4..deca87a8 100644 --- a/od-win32/parser.c +++ b/od-win32/parser.c @@ -583,6 +583,7 @@ int uaeser_setparams (struct uaeserialdatawin32 *sd, int baud, int rbuffer, int static void startwce(struct uaeserialdatawin32 *sd, DWORD *evtmask) { + SetEvent(sd->evtwce); WaitCommEvent(sd->hCom, evtmask, &sd->olwce); } @@ -737,7 +738,7 @@ void uaeser_close (struct uaeserialdatawin32 *sd) static HANDLE hCom = INVALID_HANDLE_VALUE; static DCB dcb; -static HANDLE writeevent; +static HANDLE writeevent, readevent; #define SERIAL_WRITE_BUFFER 100 #define SERIAL_READ_BUFFER 100 static uae_u8 outputbuffer[SERIAL_WRITE_BUFFER]; @@ -745,7 +746,7 @@ static uae_u8 outputbufferout[SERIAL_WRITE_BUFFER]; static uae_u8 inputbuffer[SERIAL_READ_BUFFER]; static int datainoutput; static int dataininput, dataininputcnt; -static OVERLAPPED writeol; +static OVERLAPPED writeol, readol; static writepending; int openser (char *sername) @@ -755,68 +756,81 @@ int openser (char *sername) sprintf (buf, "\\.\\\\%s", sername); + if (!(readevent = CreateEvent (NULL, TRUE, FALSE, NULL))) { + write_log ("SERIAL: Failed to create r event!\n"); + return 0; + } + readol.hEvent = readevent; + if (!(writeevent = CreateEvent (NULL, TRUE, FALSE, NULL))) { - write_log ("SERIAL: Failed to create event!\n"); + write_log ("SERIAL: Failed to create w event!\n"); return 0; } SetEvent (writeevent); writeol.hEvent = writeevent; + uartbreak = 0; - if ((hCom = CreateFile (buf, GENERIC_READ | GENERIC_WRITE, + + hCom = CreateFile (buf, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, - NULL)) != INVALID_HANDLE_VALUE) { - SetCommMask (hCom, EV_RXFLAG); - SetupComm (hCom, 65536,128); - PurgeComm (hCom, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR); - CommTimeOuts.ReadIntervalTimeout = 0xFFFFFFFF; - CommTimeOuts.ReadTotalTimeoutMultiplier = 0; - CommTimeOuts.ReadTotalTimeoutConstant = 0; - CommTimeOuts.WriteTotalTimeoutMultiplier = 0; - CommTimeOuts.WriteTotalTimeoutConstant = 0; - SetCommTimeouts (hCom, &CommTimeOuts); - - dcb.DCBlength = sizeof (DCB); - GetCommState (hCom, &dcb); - - dcb.BaudRate = 9600; - dcb.ByteSize = 8; - dcb.Parity = NOPARITY; - dcb.StopBits = ONESTOPBIT; - - dcb.fDsrSensitivity = FALSE; - dcb.fOutxDsrFlow = FALSE; - dcb.fDtrControl = DTR_CONTROL_DISABLE; + NULL); + if (hCom == INVALID_HANDLE_VALUE) { + write_log ("SERIAL: failed to open '%s' err=%d\n", buf, GetLastError()); + closeser(); + return 0; + } + + SetCommMask (hCom, EV_RXFLAG); + SetupComm (hCom, 65536,128); + PurgeComm (hCom, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR); + CommTimeOuts.ReadIntervalTimeout = 0xFFFFFFFF; + CommTimeOuts.ReadTotalTimeoutMultiplier = 0; + CommTimeOuts.ReadTotalTimeoutConstant = 0; + CommTimeOuts.WriteTotalTimeoutMultiplier = 0; + CommTimeOuts.WriteTotalTimeoutConstant = 0; + SetCommTimeouts (hCom, &CommTimeOuts); + + dcb.DCBlength = sizeof (DCB); + GetCommState (hCom, &dcb); + + dcb.BaudRate = 9600; + dcb.ByteSize = 8; + dcb.Parity = NOPARITY; + dcb.StopBits = ONESTOPBIT; + + dcb.fDsrSensitivity = FALSE; + dcb.fOutxDsrFlow = FALSE; + dcb.fDtrControl = DTR_CONTROL_DISABLE; - if (currprefs.serial_hwctsrts) { - dcb.fOutxCtsFlow = TRUE; - dcb.fRtsControl = RTS_CONTROL_HANDSHAKE; - } else { - dcb.fRtsControl = RTS_CONTROL_DISABLE; - dcb.fOutxCtsFlow = FALSE; - } + if (currprefs.serial_hwctsrts) { + dcb.fOutxCtsFlow = TRUE; + dcb.fRtsControl = RTS_CONTROL_HANDSHAKE; + } else { + dcb.fRtsControl = RTS_CONTROL_DISABLE; + dcb.fOutxCtsFlow = FALSE; + } - dcb.fTXContinueOnXoff = FALSE; - dcb.fOutX = FALSE; - dcb.fInX = FALSE; + dcb.fTXContinueOnXoff = FALSE; + dcb.fOutX = FALSE; + dcb.fInX = FALSE; - dcb.fErrorChar = FALSE; - dcb.fNull = FALSE; - dcb.fAbortOnError = FALSE; + dcb.fErrorChar = FALSE; + dcb.fNull = FALSE; + dcb.fAbortOnError = FALSE; - dcb.XoffLim = 512; - dcb.XonLim = 2048; + dcb.XoffLim = 512; + dcb.XonLim = 2048; - if (SetCommState (hCom, &dcb)) { - write_log ("SERIAL: Using %s CTS/RTS=%d\n", sername, currprefs.serial_hwctsrts); - return 1; - } - write_log ("SERIAL: serial driver didn't accept new parameters\n"); - CloseHandle (hCom); - hCom = INVALID_HANDLE_VALUE; + if (SetCommState (hCom, &dcb)) { + write_log ("SERIAL: Using %s CTS/RTS=%d\n", sername, currprefs.serial_hwctsrts); + return 1; } + + write_log ("SERIAL: serial driver didn't accept new parameters\n"); + closeser(); return 0; } @@ -836,6 +850,9 @@ void closeser (void) if(writeevent) CloseHandle(writeevent); writeevent = 0; + if(readevent) + CloseHandle(readevent); + readevent = 0; uartbreak = 0; } @@ -930,13 +947,17 @@ int readser (int *buffer) int len = ComStat.cbInQue; if (len > sizeof (inputbuffer)) len = sizeof (inputbuffer); - if (ReadFile (hCom, inputbuffer, len, &actual, NULL)) { - dataininput = actual; - dataininputcnt = 0; - if (actual == 0) + if (!ReadFile (hCom, inputbuffer, len, &actual, &readol)) { + if (GetLastError() == ERROR_IO_PENDING) + WaitForSingleObject(&readol, INFINITE); + else return 0; - return readser (buffer); } + dataininput = actual; + dataininputcnt = 0; + if (actual == 0) + return 0; + return readser (buffer); } } } diff --git a/od-win32/picasso96_win.c b/od-win32/picasso96_win.c index 302e7f3d..3dbc3f3b 100644 --- a/od-win32/picasso96_win.c +++ b/od-win32/picasso96_win.c @@ -1656,8 +1656,73 @@ static void FillBoardInfo (uaecptr amigamemptr, struct LibResolution *res, struc put_long (amigamemptr + PSSO_ModeInfo_PixelClock, dm->res.width * dm->res.height * (currprefs.gfx_refreshrate ? abs (currprefs.gfx_refreshrate) : default_freq)); } -static int AssignModeID(int i, int count) +struct modeids { + int width, height; + int id; +}; +static struct modeids mi[] = +{ +/* "original" modes */ + + 320, 200, 0, + 320, 240, 1, + 640, 400, 2, + 640, 480, 3, + 800, 600, 4, + 1024, 768, 5, + 1152, 864, 6, + 1280,1024, 7, + 1600,1280, 8, + +/* new modes */ + + 704, 480, 129, + 704, 576, 130, + 720, 480, 131, + 720, 576, 132, + 768, 483, 133, + 768, 576, 134, + 800, 480, 135, + 848, 480, 136, + 854, 480, 137, + 948, 576, 138, + 1024, 576, 139, + 1152, 768, 140, + 1152, 864, 141, + 1280, 720, 142, + 1280, 768, 143, + 1280, 800, 144, + 1280, 854, 145, + 1280, 960, 146, + 1366, 768, 147, + 1440, 900, 148, + 1440, 960, 149, + 1600,1200, 150, + 1680,1050, 151, + 1920,1080, 152, + 1920,1200, 153, + 2048,1152, 154, + 2048,1536, 155, + 2560,1600, 156, + 2560,2048, 157, + + -1,-1,0 +}; + +static int AssignModeID(int dm, int count, int *unkcnt) { + int i, w, h; + + w = DisplayModes[dm].res.width; + h = DisplayModes[dm].res.height; + for (i = 0; mi[i].width > 0; i++) { + if (w == mi[i].width && h == mi[i].height) + return 0x50001000 | (mi[i].id << 16); + } + (*unkcnt)++; + write_log("P96: Non-unique mode %dx%d\n", w, h); + return 0x5F000000 + (*unkcnt) * 0x10000; +#if 0 int result; if(DisplayModes[i].res.width == 320 && DisplayModes[i].res.height == 200) result = 0x50001000; @@ -1678,8 +1743,9 @@ static int AssignModeID(int i, int count) else if(DisplayModes[i].res.width == 1600 && DisplayModes[i].res.height == 1280) result = 0x50081000; else - result = 0x50091000 + count * 0x10000; + result = 0x50090000 + count * 0x10000; return result; +#endif } /**************************************** @@ -1701,8 +1767,9 @@ static int AssignModeID(int i, int count) uae_u32 REGPARAM2 picasso_InitCard (struct regstruct *regs) { struct LibResolution res; - int i; int ModeInfoStructureCount = 1, LibResolutionStructureCount = 0; + int i, unkcnt; + uaecptr amigamemptr = 0; uaecptr AmigaBoardInfo = m68k_areg (regs, 2); put_word (AmigaBoardInfo + PSSO_BoardInfo_BitsPerCannon, DX_BitsPerCannon()); @@ -1725,10 +1792,11 @@ uae_u32 REGPARAM2 picasso_InitCard (struct regstruct *regs) put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 8, alphacolour.height); i = 0; + unkcnt = 0; while (DisplayModes[i].depth >= 0) { int j = i; /* Add a LibResolution structure to the ResolutionsList MinList in our BoardInfo */ - res.DisplayID = AssignModeID(i, LibResolutionStructureCount); + res.DisplayID = AssignModeID(i, LibResolutionStructureCount, &unkcnt); res.BoardInfo = AmigaBoardInfo; res.Width = DisplayModes[i].res.width; res.Height = DisplayModes[i].res.height; diff --git a/od-win32/resources/resource.h b/od-win32/resources/resource.h index c3515a7f..0b99e2e0 100644 --- a/od-win32/resources/resource.h +++ b/od-win32/resources/resource.h @@ -553,49 +553,14 @@ #define IDC_HIGHPRIORITY 1530 #define IDC_MINIMIZED_NOSOUND 1530 #define IDC_MINIMIZED_PAUSE 1531 -#define IDC_D0 1532 #define IDC_STATE_CAPTURE 1532 -#define IDC_D1 1533 #define IDC_KBLED_USB 1533 -#define IDC_D2 1534 -#define IDC_D3 1535 -#define IDC_D4 1536 -#define IDC_D5 1537 -#define IDC_D6 1538 -#define IDC_D7 1539 -#define IDC_A0 1540 -#define IDC_A1 1541 -#define IDC_A2 1542 -#define IDC_A3 1543 -#define IDC_A4 1544 -#define IDC_A5 1545 -#define IDC_A6 1546 -#define IDC_A7 1547 -#define IDC_USP 1548 -#define IDC_SSP 1549 -#define IDC_PC 1550 -#define IDC_T1 1551 -#define IDC_T2 1552 -#define IDC_T3 1553 #define IDC_SER_SHARED 1553 -#define IDC_T4 1554 #define IDC_SER_CTSRTS 1554 -#define IDC_T5 1555 #define IDC_SER_DIRECT 1555 -#define IDC_T6 1556 #define IDC_PSPRINTER 1556 -#define IDC_T7 1557 #define IDC_PSPRINTERDETECT 1557 -#define IDC_T8 1558 #define IDC_UAESERIAL 1558 -#define IDC_T9 1559 -#define IDC_T10 1560 -#define IDC_T11 1561 -#define IDC_T12 1562 -#define IDC_T13 1563 -#define IDC_T14 1564 -#define IDC_T15 1565 -#define IDC_T16 1566 #define IDC_VIEWINFO 1568 #define IDC_SETINFO 1569 #define IDC_FLOPPYSLIDER 1570 diff --git a/od-win32/sounddep/sound.c b/od-win32/sounddep/sound.c index db1acba0..07caf807 100644 --- a/od-win32/sounddep/sound.c +++ b/od-win32/sounddep/sound.c @@ -322,7 +322,7 @@ static int open_audio_ds (int size) sound_buffer.dwBufferBytes = dsoundbuf; sound_buffer.lpwfxFormat = &wavfmt; sound_buffer.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS; - sound_buffer.dwFlags |= DSBCAPS_CTRLVOLUME | DSBCAPS_STATIC; + sound_buffer.dwFlags |= DSBCAPS_CTRLVOLUME | DSBCAPS_LOCSOFTWARE; sound_buffer.guid3DAlgorithm = GUID_NULL; hr = IDirectSound_CreateSoundBuffer(lpDS, &sound_buffer, &pdsb, NULL); @@ -559,6 +559,7 @@ static void finish_sound_buffer_ds (void) hr = IDirectSoundBuffer_GetStatus (lpDSBsecondary, &status); if (FAILED(hr)) { write_log ("SOUND: GetStatus() failed: %s\n", DXError(hr)); + restore (DSERR_BUFFERLOST); return; } if (status & DSBSTATUS_BUFFERLOST) { diff --git a/od-win32/win32.c b/od-win32/win32.c index 1019a540..ee5c6209 100644 --- a/od-win32/win32.c +++ b/od-win32/win32.c @@ -2199,9 +2199,11 @@ static void WIN32_HandleRegistryStuff(void) load_keyring(NULL, NULL); } +#ifdef WINUAEPUBLICBETA static char *BETAMESSAGE = { "This is unstable beta software. Click cancel if you are not comfortable using software that is incomplete and can have serious programming errors." }; +#endif static int betamessage (void) { @@ -2527,7 +2529,7 @@ static void getstartpaths(int start_data) extern void test (void); extern int screenshotmode, b0rken_ati_overlay, postscript_print_debugging, sound_debug, log_uaeserial; -extern int force_direct_catweasel, cpu_affinity; +extern int force_direct_catweasel, cpu_affinity, max_allowed_mman; static int original_affinity; @@ -2555,80 +2557,148 @@ static void makeverstr(char *s) UAEMAJOR, UAEMINOR, UAESUBREV, BetaStr); } -static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, - int nCmdShow) +static int multi_display = 1; +static int start_data = 0; + +static int process_arg(char **xargv) { - HANDLE hMutex; + int i, argc, xargc; char **argv; - int argc; - int i; - int multi_display = 1; - int start_data = 0; - -#ifdef _DEBUG - { - int tmp = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); - //tmp &= 0xffff; - tmp |= _CRTDBG_CHECK_ALWAYS_DF; - tmp |= _CRTDBG_CHECK_CRT_DF; - //tmp |=_CRTDBG_CHECK_EVERY_16_DF; - //tmp |= _CRTDBG_DELAY_FREE_MEM_DF; - _CrtSetDbgFlag(tmp); - } -#endif - - if (!osdetect()) - return 0; - if (!dxdetect()) - return 0; - - hInst = hInstance; - hMutex = CreateMutex( NULL, FALSE, "WinUAE Instantiated" ); // To tell the installer we're running -#ifdef AVIOUTPUT - AVIOutput_Initialize(); -#endif + xargc = 0; argc = __argc; argv = __argv; + xargv[xargc++] = my_strdup(argv[0]); for (i = 1; i < argc; i++) { char *arg = argv[i]; - if (!strcmp (arg, "-log")) console_logging = 1; + if (!strcmp (arg, "-log")) { + console_logging = 1; + continue; + } #ifdef FILESYS - if (!strcmp (arg, "-rdbdump")) do_rdbdump = 1; - if (!strcmp (arg, "-disableharddrivesafetycheck")) harddrive_dangerous = 0x1234dead; - if (!strcmp (arg, "-noaspifiltering")) aspi_allow_all = 1; + if (!strcmp (arg, "-rdbdump")) { + do_rdbdump = 1; + continue; + } + if (!strcmp (arg, "-disableharddrivesafetycheck")) { + harddrive_dangerous = 0x1234dead; + continue; + } + if (!strcmp (arg, "-noaspifiltering")) { + aspi_allow_all = 1; + continue; + } #endif - if (!strcmp (arg, "-disableowr")) b0rken_ati_overlay = -1; - if (!strcmp (arg, "-enableowr")) b0rken_ati_overlay = 1; - if (!strcmp (arg, "-nordtsc")) no_rdtsc = 1; - if (!strcmp (arg, "-forcerdtsc")) no_rdtsc = -1; - if (!strcmp (arg, "-norawinput")) no_rawinput = 1; - if (!strcmp (arg, "-scsilog")) log_scsi = 1; - if (!strcmp (arg, "-seriallog")) log_uaeserial = 1; - if (!strcmp (arg, "-nomultidisplay")) multi_display = 0; - if (!strcmp (arg, "-legacypaths")) start_data = -1; - if (!strcmp (arg, "-screenshotbmp")) screenshotmode = 0; - if (!strcmp (arg, "-psprintdebug")) postscript_print_debugging = 1; - if (!strcmp (arg, "-sounddebug")) sound_debug = 1; + if (!strcmp (arg, "-disableowr")) { + b0rken_ati_overlay = -1; + continue; + } + if (!strcmp (arg, "-enableowr")) { + b0rken_ati_overlay = 1; + continue; + } + if (!strcmp (arg, "-nordtsc")) { + no_rdtsc = 1; + continue; + } + if (!strcmp (arg, "-forcerdtsc")) { + no_rdtsc = -1; + continue; + } + if (!strcmp (arg, "-norawinput")) { + no_rawinput = 1; + continue; + } + if (!strcmp (arg, "-scsilog")) { + log_scsi = 1; + continue; + } + if (!strcmp (arg, "-seriallog")) { + log_uaeserial = 1; + continue; + } + if (!strcmp (arg, "-nomultidisplay")) { + multi_display = 0; + continue; + } + if (!strcmp (arg, "-legacypaths")) { + start_data = -1; + continue; + } + if (!strcmp (arg, "-screenshotbmp")) { + screenshotmode = 0; + continue; + } + if (!strcmp (arg, "-psprintdebug")) { + postscript_print_debugging = 1; + continue; + } + if (!strcmp (arg, "-sounddebug")) { + sound_debug = 1; + continue; + } if (!strcmp (arg, "-directcatweasel")) { force_direct_catweasel = 1; if (i + 1 < argc) force_direct_catweasel = getval (argv[++i]); + continue; } if (!strcmp (arg, "-affinity") && i + 1 < argc) { cpu_affinity = getval (argv[++i]); if (cpu_affinity == 0) cpu_affinity = original_affinity; SetThreadAffinityMask(GetCurrentThread(), cpu_affinity); + continue; } if (!strcmp (arg, "-datapath") && i + 1 < argc) { strcpy(start_path_data, argv[++i]); start_data = 1; + continue; } + if (!strcmp (arg, "-maxmem") && i + 1 < argc) { + max_allowed_mman = getval (argv[++i]); + continue; + } + xargv[xargc++] = my_strdup(arg); } #if 0 argv = 0; argv[0] = 0; #endif + return xargc; +} + +static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + HANDLE hMutex; + char **argv; + int argc, i; + +#ifdef _DEBUG + { + int tmp = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); + //tmp &= 0xffff; + tmp |= _CRTDBG_CHECK_ALWAYS_DF; + tmp |= _CRTDBG_CHECK_CRT_DF; + //tmp |=_CRTDBG_CHECK_EVERY_16_DF; + //tmp |= _CRTDBG_DELAY_FREE_MEM_DF; + _CrtSetDbgFlag(tmp); + } +#endif + + if (!osdetect()) + return 0; + if (!dxdetect()) + return 0; + + hInst = hInstance; + hMutex = CreateMutex( NULL, FALSE, "WinUAE Instantiated" ); // To tell the installer we're running +#ifdef AVIOUTPUT + AVIOutput_Initialize(); +#endif + + argv = xcalloc (sizeof (char*), __argc); + argc = process_arg(argv); + getstartpaths(start_data); makeverstr(VersionStr); SetCurrentDirectory (start_path_data); @@ -2695,9 +2765,13 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR // show memory leaks //_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif + for (i = 0; i < argc; i++) + free (argv[i]); + free(argv); return FALSE; } +#if 0 int execute_command (char *cmd) { STARTUPINFO si; @@ -2713,6 +2787,7 @@ int execute_command (char *cmd) } return 0; } +#endif #include "driveclick.h" static int drvsampleres[] = { diff --git a/od-win32/win32.h b/od-win32/win32.h index 5df5dad6..307308bd 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -17,7 +17,7 @@ #define WINUAEBETA 4 #define WINUAEPUBLICBETA 1 -#define WINUAEDATE MAKEBD(2006, 12, 16) +#define WINUAEDATE MAKEBD(2006, 12, 20) #define IHF_WINDOWHIDDEN 6 #define NORMAL_WINDOW_STYLE (WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU) diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index 4ad3aad2..e81b0025 100644 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -7065,7 +7065,7 @@ static void values_from_portsdlg (HWND hDlg) EnableWindow(GetDlgItem(hDlg, IDC_MIDIINLIST), workprefs.win32_midioutdev < -1 ? FALSE : TRUE); item = SendDlgItemMessage (hDlg, IDC_SERIAL, CB_GETCURSEL, 0, 0L); - if (item != CB_ERR) { + if (item != CB_ERR && item > 0) { workprefs.use_serial = 1; strcpy (workprefs.sername, comports[item - 1]); } else { @@ -7187,6 +7187,7 @@ static void init_portsdlg( HWND hDlg ) } joy0previous = joy1previous = -1; + SendDlgItemMessage (hDlg, IDC_SERIAL, CB_RESETCONTENT, 0, 0L); SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM)szNone); portcnt = 0; @@ -7195,7 +7196,6 @@ static void init_portsdlg( HWND hDlg ) if(GetDefaultCommConfig(comports[portcnt], &cc, &size)) { SendDlgItemMessage(hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM)comports[portcnt++]); } - write_log("%d:%d\n",port, GetLastError()); } SendDlgItemMessage (hDlg, IDC_PRINTERLIST, CB_RESETCONTENT, 0, 0L); diff --git a/od-win32/winuae_msvc/winuae_msvc.vcproj b/od-win32/winuae_msvc/winuae_msvc.vcproj index 3ddf8ac2..76e65829 100644 --- a/od-win32/winuae_msvc/winuae_msvc.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.vcproj @@ -123,9 +123,9 @@ /> - - diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index c8815aa2..cacdcc08 100644 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -1,4 +1,21 @@ +Beta 5: + +- added -maxmem command line parameter, "-maxmem 1536" enables + 1G Z3Fast support. (32-bit max) Note: not default because it + can cause weird side-effects and is not compatible with all Windows + versions. +- remove winuae-specific command line parameters before passing + them to configuration parser. +- internal serial and parallel port selection updates + (partially in b4 + fixes in b5) +- defined more Picasso96 modeIDs, now most PC display modes have + unique ID (updating display card/drivers, moving between PCs + does not anymore cause mysterious mode changes) + NOTE: you may need to reset your Picasso96 display mode if your + current mode was not defined in previous WinUAE versions. +- serial port emulation fixed (broke in b4) + Beta 4: - uaeserial.device tweaks -- 2.47.3