Code cleanup

This commit is contained in:
Dimitris Panokostas 2017-01-29 11:26:26 +01:00
parent 45ff29e811
commit 41b46094ef
7 changed files with 1087 additions and 1100 deletions

View file

@ -1,208 +1,209 @@
/*
* UAE - The Un*x Amiga Emulator
*
* bsdsocket.library emulation
*
* Copyright 1997,98 Mathias Ortmann
*
*/
#define BSD_TRACING_ENABLED 0
extern int log_bsd;
#define ISBSDTRACE (log_bsd || BSD_TRACING_ENABLED)
#define BSDTRACE(x) do { if (ISBSDTRACE) { write_log x; } } while(0)
extern int init_socket_layer (void);
extern void deinit_socket_layer (void);
/* inital size of per-process descriptor table (currently fixed) */
#define DEFAULT_DTABLE_SIZE 64
#define SCRATCHBUFSIZE 128
#define MAXPENDINGASYNC 512
#define MAXADDRLEN 256
#ifdef _WIN32
#define SOCKET_TYPE SOCKET
#else
#define SOCKET_TYPE int
#endif
/* allocated and maintained on a per-task basis */
struct socketbase
{
struct socketbase *next;
struct socketbase *nextsig; /* queue for tasks to signal */
uaecptr sysbase;
int dosignal; /* signal flag */
uae_u32 ownertask; /* task that opened the library */
int signal; /* signal allocated for that task */
int sb_errno, sb_herrno; /* errno and herrno variables */
uae_u32 errnoptr, herrnoptr; /* pointers */
uae_u32 errnosize, herrnosize; /* pinter sizes */
int dtablesize; /* current descriptor/flag etc. table size */
SOCKET_TYPE *dtable; /* socket descriptor table */
int *ftable; /* socket flags */
int resultval;
uae_u32 hostent; /* pointer to the current hostent structure (Amiga mem) */
uae_u32 hostentsize;
uae_u32 protoent; /* pointer to the current protoent structure (Amiga mem) */
uae_u32 protoentsize;
uae_u32 servent; /* pointer to the current servent structure (Amiga mem) */
uae_u32 serventsize;
uae_u32 sigstosend;
uae_u32 eventsigs; /* EVENT sigmask */
uae_u32 eintrsigs; /* EINTR sigmask */
int eintr; /* interrupted by eintrsigs? */
int eventindex; /* current socket looked at by GetSocketEvents() to prevent starvation */
uae_u32 logstat;
uae_u32 logptr;
uae_u32 logmask;
uae_u32 logfacility;
uaecptr fdcallback;
unsigned int *mtable; /* window messages allocated for asynchronous event notification */
/* host-specific fields below */
#ifdef _WIN32
SOCKET_TYPE sockAbort; /* for aborting WinSock2 select() (damn Microsoft) */
SOCKET_TYPE sockAsync; /* for aborting WSBAsyncSelect() in window message handler */
int needAbort; /* abort flag */
void *hAsyncTask; /* async task handle */
void *hEvent; /* thread event handle */
#else
uae_sem_t sem; /* semaphore to notify the socket thread of work */
uae_thread_id thread; /* socket thread */
int sockabort[2]; /* pipe used to tell the thread to abort a select */
int action;
int s; /* for accept */
uae_u32 name; /* For gethostbyname */
uae_u32 a_addr; /* gethostbyaddr, accept */
uae_u32 a_addrlen; /* for gethostbyaddr, accept */
uae_u32 flags;
void *buf;
uae_u32 len;
uae_u32 to, tolen, from, fromlen;
int nfds;
uae_u32 sets [3];
uae_u32 timeout;
uae_u32 sigmp;
#endif
TrapContext *context;
};
#define LIBRARY_SIZEOF 36
struct UAEBSDBase
{
uae_u8 dummy[LIBRARY_SIZEOF];
struct socketbase *sb;
uae_u8 scratchbuf[SCRATCHBUFSIZE];
};
/* socket flags */
/* socket events to report */
#define REP_ACCEPT 0x01 /* there is a connection to accept() */
#define REP_CONNECT 0x02 /* connect() completed */
#define REP_OOB 0x04 /* socket has out-of-band data */
#define REP_READ 0x08 /* socket is readable */
#define REP_WRITE 0x10 /* socket is writeable */
#define REP_ERROR 0x20 /* asynchronous error on socket */
#define REP_CLOSE 0x40 /* connection closed (graceful or not) */
#define REP_ALL 0x7f
/* socket events that occurred */
#define SET_ACCEPT 0x0100 /* there is a connection to accept() */
#define SET_CONNECT 0x0200 /* connect() completed */
#define SET_OOB 0x0400 /* socket has out-of-band data */
#define SET_READ 0x0800 /* socket is readable */
#define SET_WRITE 0x1000 /* socket is writeable */
#define SET_ERROR 0x2000 /* asynchronous error on socket */
#define SET_CLOSE 0x4000 /* connection closed (graceful or not) */
#define SET_ALL 0x7f00
/* socket properties */
#define SF_BLOCKING 0x80000000
#define SF_BLOCKINGINPROGRESS 0x40000000
/* STBC_FDCALLBACK */
#define FDCB_FREE 0
#define FDCB_ALLOC 1
#define FDCB_CHECK 2
uae_u32 addstr (uae_u32 * dst, const TCHAR *src);
uae_u32 addstr_ansi (uae_u32 * dst, const uae_char *src);
uae_u32 strncpyha (uae_u32 dst, const uae_char *src, int size);
uae_u32 addmem (uae_u32 * dst, const uae_char *src, int len);
#define SB struct socketbase *sb
extern void bsdsocklib_seterrno (SB, int);
extern void bsdsocklib_setherrno (SB, int);
extern void sockmsg (unsigned int, WPARAM, LPARAM);
extern void sockabort (SB);
extern void addtosigqueue (SB, int);
extern void removefromsigqueue (SB);
extern void sigsockettasks (void);
extern void locksigqueue (void);
extern void unlocksigqueue (void);
extern BOOL checksd(TrapContext*, SB, int sd);
extern void setsd(TrapContext*, SB, int, SOCKET_TYPE);
extern int getsd (TrapContext*, SB, SOCKET_TYPE);
extern SOCKET_TYPE getsock (SB, int);
extern void releasesock (TrapContext*, SB, int);
extern void waitsig (TrapContext *context, SB);
extern void cancelsig (TrapContext *context, SB);
extern int host_sbinit (TrapContext*, SB);
extern void host_sbcleanup (SB);
extern void host_sbreset (void);
extern void host_closesocketquick (SOCKET_TYPE);
extern int host_dup2socket (TrapContext *, SB, int, int);
extern int host_socket (TrapContext *, SB, int, int, int);
extern uae_u32 host_bind (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_listen (TrapContext *, SB, uae_u32, uae_u32);
extern void host_accept (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
extern void host_sendto (TrapContext *, SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern void host_recvfrom (TrapContext *, SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_shutdown (SB, uae_u32, uae_u32);
extern void host_setsockopt (SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getsockopt (SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getsockname (SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getpeername (SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_IoctlSocket (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_shutdown (SB, uae_u32, uae_u32);
extern int host_CloseSocket (TrapContext *, SB, int);
extern void host_connect (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
extern void host_WaitSelect (TrapContext *, SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_SetSocketSignals (void);
extern uae_u32 host_getdtablesize (void);
extern uae_u32 host_ObtainSocket (void);
extern uae_u32 host_ReleaseSocket (void);
extern uae_u32 host_ReleaseCopyOfSocket (void);
extern uae_u32 host_Inet_NtoA (TrapContext *context, SB, uae_u32);
extern uae_u32 host_inet_addr (uae_u32);
extern uae_u32 host_Inet_LnaOf (void);
extern uae_u32 host_Inet_NetOf (void);
extern uae_u32 host_Inet_MakeAddr (void);
extern uae_u32 host_inet_network (void);
extern void host_gethostbynameaddr (TrapContext *, SB, uae_u32, uae_u32, long);
extern uae_u32 host_getnetbyname (void);
extern uae_u32 host_getnetbyaddr (void);
extern void host_getservbynameport (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
extern void host_getprotobyname (TrapContext *, SB, uae_u32);
extern void host_getprotobynumber (TrapContext *, SB, uae_u32);
extern uae_u32 host_vsyslog (void);
extern uae_u32 host_Dup2Socket (void);
extern uae_u32 host_gethostname (uae_u32, uae_u32);
extern uae_u32 callfdcallback (TrapContext *context, SB, uae_u32 fd, uae_u32 action);
extern uaecptr bsdlib_startup (uaecptr);
extern void bsdlib_install (void);
extern void bsdlib_reset (void);
/*
* UAE - The Un*x Amiga Emulator
*
* bsdsocket.library emulation
*
* Copyright 1997,98 Mathias Ortmann
*
*/
#pragma once
#define BSD_TRACING_ENABLED 0
extern int log_bsd;
#define ISBSDTRACE (log_bsd || BSD_TRACING_ENABLED)
#define BSDTRACE(x) do { if (ISBSDTRACE) { write_log x; } } while(0)
extern int init_socket_layer();
extern void deinit_socket_layer();
/* inital size of per-process descriptor table (currently fixed) */
#define DEFAULT_DTABLE_SIZE 64
#define SCRATCHBUFSIZE 128
#define MAXPENDINGASYNC 512
#define MAXADDRLEN 256
//#ifdef _WIN32
//#define SOCKET_TYPE SOCKET
//#else
#define SOCKET_TYPE int
//#endif
/* allocated and maintained on a per-task basis */
struct socketbase
{
struct socketbase* next;
struct socketbase* nextsig; /* queue for tasks to signal */
uaecptr sysbase;
int dosignal; /* signal flag */
uae_u32 ownertask; /* task that opened the library */
int signal; /* signal allocated for that task */
int sb_errno, sb_herrno; /* errno and herrno variables */
uae_u32 errnoptr, herrnoptr; /* pointers */
uae_u32 errnosize, herrnosize; /* pinter sizes */
int dtablesize; /* current descriptor/flag etc. table size */
SOCKET_TYPE* dtable; /* socket descriptor table */
int* ftable; /* socket flags */
int resultval;
uae_u32 hostent; /* pointer to the current hostent structure (Amiga mem) */
uae_u32 hostentsize;
uae_u32 protoent; /* pointer to the current protoent structure (Amiga mem) */
uae_u32 protoentsize;
uae_u32 servent; /* pointer to the current servent structure (Amiga mem) */
uae_u32 serventsize;
uae_u32 sigstosend;
uae_u32 eventsigs; /* EVENT sigmask */
uae_u32 eintrsigs; /* EINTR sigmask */
int eintr; /* interrupted by eintrsigs? */
int eventindex; /* current socket looked at by GetSocketEvents() to prevent starvation */
uae_u32 logstat;
uae_u32 logptr;
uae_u32 logmask;
uae_u32 logfacility;
uaecptr fdcallback;
unsigned int* mtable; /* window messages allocated for asynchronous event notification */
/* host-specific fields below */
//#ifdef _WIN32
// SOCKET_TYPE sockAbort; /* for aborting WinSock2 select() (damn Microsoft) */
// SOCKET_TYPE sockAsync; /* for aborting WSBAsyncSelect() in window message handler */
// int needAbort; /* abort flag */
// void* hAsyncTask; /* async task handle */
// void* hEvent; /* thread event handle */
//#else
uae_sem_t sem; /* semaphore to notify the socket thread of work */
uae_thread_id thread; /* socket thread */
int sockabort[2]; /* pipe used to tell the thread to abort a select */
int action;
int s; /* for accept */
uae_u32 name; /* For gethostbyname */
uae_u32 a_addr; /* gethostbyaddr, accept */
uae_u32 a_addrlen; /* for gethostbyaddr, accept */
uae_u32 flags;
void *buf;
uae_u32 len;
uae_u32 to, tolen, from, fromlen;
int nfds;
uae_u32 sets [3];
uae_u32 timeout;
uae_u32 sigmp;
//#endif
TrapContext* context;
};
#define LIBRARY_SIZEOF 36
struct UAEBSDBase
{
uae_u8 dummy[LIBRARY_SIZEOF];
struct socketbase* sb;
uae_u8 scratchbuf[SCRATCHBUFSIZE];
};
/* socket flags */
/* socket events to report */
#define REP_ACCEPT 0x01 /* there is a connection to accept() */
#define REP_CONNECT 0x02 /* connect() completed */
#define REP_OOB 0x04 /* socket has out-of-band data */
#define REP_READ 0x08 /* socket is readable */
#define REP_WRITE 0x10 /* socket is writeable */
#define REP_ERROR 0x20 /* asynchronous error on socket */
#define REP_CLOSE 0x40 /* connection closed (graceful or not) */
#define REP_ALL 0x7f
/* socket events that occurred */
#define SET_ACCEPT 0x0100 /* there is a connection to accept() */
#define SET_CONNECT 0x0200 /* connect() completed */
#define SET_OOB 0x0400 /* socket has out-of-band data */
#define SET_READ 0x0800 /* socket is readable */
#define SET_WRITE 0x1000 /* socket is writeable */
#define SET_ERROR 0x2000 /* asynchronous error on socket */
#define SET_CLOSE 0x4000 /* connection closed (graceful or not) */
#define SET_ALL 0x7f00
/* socket properties */
#define SF_BLOCKING 0x80000000
#define SF_BLOCKINGINPROGRESS 0x40000000
/* STBC_FDCALLBACK */
#define FDCB_FREE 0
#define FDCB_ALLOC 1
#define FDCB_CHECK 2
uae_u32 addstr(uae_u32* dst, const TCHAR* src);
uae_u32 addstr_ansi(uae_u32* dst, const uae_char* src);
uae_u32 strncpyha(uae_u32 dst, const uae_char* src, int size);
uae_u32 addmem(uae_u32* dst, const uae_char* src, int len);
#define SB struct socketbase *sb
extern void bsdsocklib_seterrno(SB, int);
extern void bsdsocklib_setherrno(SB, int);
extern void sockmsg(unsigned int, WPARAM, LPARAM);
extern void sockabort(SB);
extern void addtosigqueue(SB, int);
extern void removefromsigqueue(SB);
extern void sigsockettasks();
extern void locksigqueue();
extern void unlocksigqueue();
extern BOOL checksd(TrapContext*, SB, int sd);
extern void setsd(TrapContext*, SB, int, SOCKET_TYPE);
extern int getsd(TrapContext*, SB, SOCKET_TYPE);
extern SOCKET_TYPE getsock(SB, int);
extern void releasesock(TrapContext*, SB, int);
extern void waitsig(TrapContext* context, SB);
extern void cancelsig(TrapContext* context, SB);
extern int host_sbinit(TrapContext*, SB);
extern void host_sbcleanup(SB);
extern void host_sbreset();
extern void host_closesocketquick(SOCKET_TYPE);
extern int host_dup2socket(TrapContext*, SB, int, int);
extern int host_socket(TrapContext*, SB, int, int, int);
extern uae_u32 host_bind(TrapContext*, SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_listen(TrapContext*, SB, uae_u32, uae_u32);
extern void host_accept(TrapContext*, SB, uae_u32, uae_u32, uae_u32);
extern void host_sendto(TrapContext*, SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern void host_recvfrom(TrapContext*, SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_shutdown(SB, uae_u32, uae_u32);
extern void host_setsockopt(SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getsockopt(SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getsockname(SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getpeername(SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_IoctlSocket(TrapContext*, SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_shutdown(SB, uae_u32, uae_u32);
extern int host_CloseSocket(TrapContext*, SB, int);
extern void host_connect(TrapContext*, SB, uae_u32, uae_u32, uae_u32);
extern void host_WaitSelect(TrapContext*, SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_SetSocketSignals();
extern uae_u32 host_getdtablesize();
extern uae_u32 host_ObtainSocket();
extern uae_u32 host_ReleaseSocket();
extern uae_u32 host_ReleaseCopyOfSocket();
extern uae_u32 host_Inet_NtoA(TrapContext* context, SB, uae_u32);
extern uae_u32 host_inet_addr(uae_u32);
extern uae_u32 host_Inet_LnaOf();
extern uae_u32 host_Inet_NetOf();
extern uae_u32 host_Inet_MakeAddr();
extern uae_u32 host_inet_network();
extern void host_gethostbynameaddr(TrapContext*, SB, uae_u32, uae_u32, long);
extern uae_u32 host_getnetbyname();
extern uae_u32 host_getnetbyaddr();
extern void host_getservbynameport(TrapContext*, SB, uae_u32, uae_u32, uae_u32);
extern void host_getprotobyname(TrapContext*, SB, uae_u32);
extern void host_getprotobynumber(TrapContext*, SB, uae_u32);
extern uae_u32 host_vsyslog();
extern uae_u32 host_Dup2Socket();
extern uae_u32 host_gethostname(uae_u32, uae_u32);
extern uae_u32 callfdcallback(TrapContext* context, SB, uae_u32 fd, uae_u32 action);
extern uaecptr bsdlib_startup(uaecptr);
extern void bsdlib_install();
extern void bsdlib_reset();

View file

@ -1,4 +1,4 @@
/*
/*
* UAE - The Un*x Amiga Emulator
*
* custom chip support
@ -26,18 +26,18 @@
#define MAXVPOS_LINES_OCS 512
#define HPOS_SHIFT 3
extern void set_speedup_values(void);
extern int custom_init (void);
extern void custom_prepare (void);
extern void custom_reset (bool hardreset, bool keyboardreset);
extern int intlev (void);
extern void set_speedup_values();
extern int custom_init();
extern void custom_prepare();
extern void custom_reset(bool hardreset, bool keyboardreset);
extern int intlev();
extern void do_copper (void);
extern void do_copper();
extern void notice_new_xcolors (void);
extern void init_row_map (void);
extern void init_hz_full (void);
extern void init_custom (void);
extern void notice_new_xcolors();
extern void init_row_map();
extern void init_hz_full();
extern void init_custom();
extern bool picasso_requested_on;
extern bool picasso_on;
@ -49,7 +49,7 @@ extern uae_u16 intreq;
extern int vpos;
STATIC_INLINE int dmaen (unsigned int dmamask)
STATIC_INLINE int dmaen(unsigned int dmamask)
{
return (dmamask & dmacon) && (dmacon & 0x200);
}
@ -72,17 +72,17 @@ STATIC_INLINE int dmaen (unsigned int dmamask)
extern uae_u16 adkcon;
extern void INTREQ (uae_u16);
extern bool INTREQ_0 (uae_u16);
extern void INTREQ_f (uae_u16);
STATIC_INLINE void send_interrupt (int num)
extern void INTREQ(uae_u16);
extern bool INTREQ_0(uae_u16);
extern void INTREQ_f(uae_u16);
STATIC_INLINE void send_interrupt(int num)
{
INTREQ_0 (0x8000 | (1 << num));
INTREQ_0(0x8000 | (1 << num));
}
STATIC_INLINE uae_u16 INTREQR (void)
STATIC_INLINE uae_u16 INTREQR()
{
return intreq;
return intreq;
}
/* maximums for statically allocated tables */
@ -153,32 +153,34 @@ extern unsigned int xredcolors[256], xgreencolors[256], xbluecolors[256];
#define RES_MAX 2
/* get resolution from bplcon0 */
STATIC_INLINE int GET_RES_DENISE (uae_u16 con0)
STATIC_INLINE int GET_RES_DENISE(uae_u16 con0)
{
if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE))
con0 &= ~0x40; // SUPERHIRES
return ((con0) & 0x40) ? RES_SUPERHIRES : ((con0) & 0x8000) ? RES_HIRES : RES_LORES;
}
STATIC_INLINE int GET_RES_AGNUS (uae_u16 con0)
STATIC_INLINE int GET_RES_AGNUS(uae_u16 con0)
{
if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
con0 &= ~0x40; // SUPERHIRES
return ((con0) & 0x40) ? RES_SUPERHIRES : ((con0) & 0x8000) ? RES_HIRES : RES_LORES;
return ((con0) & 0x40) ? RES_SUPERHIRES : ((con0) & 0x8000) ? RES_HIRES : RES_LORES;
}
/* get sprite width from FMODE */
#define GET_SPRITEWIDTH(FMODE) ((((FMODE) >> 2) & 3) == 3 ? 64 : (((FMODE) >> 2) & 3) == 0 ? 16 : 32)
/* Compute the number of bitplanes from a value written to BPLCON0 */
STATIC_INLINE int GET_PLANES(uae_u16 bplcon0)
{
if ((bplcon0 & 0x0010) && (bplcon0 & 0x7000))
return 0; // >8 planes = 0 planes
if (bplcon0 & 0x0010)
return 8; // AGA 8-planes bit
return (bplcon0 >> 12) & 7; // normal planes bits
if ((bplcon0 & 0x0010) && (bplcon0 & 0x7000))
return 0; // >8 planes = 0 planes
if (bplcon0 & 0x0010)
return 8; // AGA 8-planes bit
return (bplcon0 >> 12) & 7; // normal planes bits
}
extern void fpscounter_reset (void);
extern void fpscounter_reset();
extern int current_maxvpos (void);
extern int current_maxvpos();
#endif /* CUSTOM_H */

View file

@ -16,15 +16,15 @@
extern frame_time_t vsyncmintime;
extern int vsynctimebase, syncbase;
extern void reset_frame_rate_hack (void);
extern void reset_frame_rate_hack ();
extern int speedup_timelimit;
extern void compute_vsynctime (void);
extern void init_eventtab (void);
extern void events_schedule (void);
extern void compute_vsynctime ();
extern void init_eventtab ();
extern void events_schedule ();
extern long last_synctime;
typedef void (*evfunc)(void);
typedef void (*evfunc)();
typedef void (*evfunc2)(uae_u32);
typedef void (*do_cycles_func)(unsigned long);
@ -66,7 +66,7 @@ extern int pissoff_value;
extern struct ev eventtab[ev_max];
extern struct ev2 eventtab2[ev2_max];
STATIC_INLINE void cycles_do_special (void)
STATIC_INLINE void cycles_do_special ()
{
#ifdef JIT
if (currprefs.cachesize) {
@ -79,7 +79,7 @@ STATIC_INLINE void cycles_do_special (void)
}
}
STATIC_INLINE unsigned long int get_cycles (void)
STATIC_INLINE unsigned long int get_cycles ()
{
return currcycle;
}
@ -90,13 +90,13 @@ STATIC_INLINE void set_cycles (unsigned long int x)
eventtab[ev_hsync].oldcycles = x;
}
STATIC_INLINE int current_hpos_safe (void)
STATIC_INLINE int current_hpos_safe ()
{
int hp = (get_cycles () - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT;
return hp;
}
STATIC_INLINE int current_hpos (void)
STATIC_INLINE int current_hpos ()
{
int hp = (get_cycles () - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT;
return hp;
@ -105,10 +105,10 @@ STATIC_INLINE int current_hpos (void)
STATIC_INLINE bool cycles_in_range (unsigned long endcycles)
{
signed long c = get_cycles ();
return (signed long)endcycles - c > 0;
return static_cast<signed long>(endcycles) - c > 0;
}
extern void MISC_handler(void);
extern void MISC_handler();
STATIC_INLINE void event2_newevent (int no, evt t, uae_u32 data)
{
@ -120,7 +120,7 @@ STATIC_INLINE void event2_newevent (int no, evt t, uae_u32 data)
STATIC_INLINE void event2_remevent (int no)
{
eventtab2[no].active = 0;
eventtab2[no].active = false;
}
STATIC_INLINE void event_newevent (int no, evt t)
@ -133,7 +133,7 @@ STATIC_INLINE void event_newevent (int no, evt t)
STATIC_INLINE void event_remevent (int no)
{
eventtab[no].active = 0;
eventtab[no].active = false;
}
#endif

View file

@ -23,305 +23,305 @@
#define DIALOG_WIDTH 620
#define DIALOG_HEIGHT 202
static const char *harddisk_filter[] = { ".hdf", "\0" };
static const char* harddisk_filter[] = {".hdf", "\0"};
static bool dialogResult = false;
static bool dialogFinished = false;
static bool fileSelected = false;
static gcn::Window *wndCreateFilesysHardfile;
static gcn::Window* wndCreateFilesysHardfile;
static gcn::Button* cmdOK;
static gcn::Button* cmdCancel;
static gcn::Label *lblDevice;
static gcn::TextField *txtDevice;
static gcn::Label* lblDevice;
static gcn::TextField* txtDevice;
static gcn::UaeCheckBox* chkAutoboot;
static gcn::Label *lblBootPri;
static gcn::TextField *txtBootPri;
static gcn::Label *lblPath;
static gcn::TextField *txtPath;
static gcn::Label* lblBootPri;
static gcn::TextField* txtBootPri;
static gcn::Label* lblPath;
static gcn::TextField* txtPath;
static gcn::Button* cmdPath;
static gcn::Label *lblSize;
static gcn::TextField *txtSize;
static gcn::Label* lblSize;
static gcn::TextField* txtSize;
class CreateFilesysHardfileActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if(actionEvent.getSource() == cmdPath)
{
char tmp[MAX_PATH];
strncpy(tmp, txtPath->getText().c_str(), MAX_PATH);
wndCreateFilesysHardfile->releaseModalFocus();
if(SelectFile("Create harddisk file", tmp, harddisk_filter, true))
{
txtPath->setText(tmp);
fileSelected = true;
}
wndCreateFilesysHardfile->requestModalFocus();
cmdPath->requestFocus();
}
else
{
if (actionEvent.getSource() == cmdOK)
{
if(txtDevice->getText().length() <= 0)
{
wndCreateFilesysHardfile->setCaption("Please enter a device name.");
return;
}
if(!fileSelected)
{
wndCreateFilesysHardfile->setCaption("Please select a new filename.");
return;
}
dialogResult = true;
}
dialogFinished = true;
}
}
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == cmdPath)
{
char tmp[MAX_PATH];
strncpy(tmp, txtPath->getText().c_str(), MAX_PATH);
wndCreateFilesysHardfile->releaseModalFocus();
if (SelectFile("Create harddisk file", tmp, harddisk_filter, true))
{
txtPath->setText(tmp);
fileSelected = true;
}
wndCreateFilesysHardfile->requestModalFocus();
cmdPath->requestFocus();
}
else
{
if (actionEvent.getSource() == cmdOK)
{
if (txtDevice->getText().length() <= 0)
{
wndCreateFilesysHardfile->setCaption("Please enter a device name.");
return;
}
if (!fileSelected)
{
wndCreateFilesysHardfile->setCaption("Please select a new filename.");
return;
}
dialogResult = true;
}
dialogFinished = true;
}
}
};
static CreateFilesysHardfileActionListener* createFilesysHardfileActionListener;
static void InitCreateFilesysHardfile(void)
static void InitCreateFilesysHardfile()
{
wndCreateFilesysHardfile = new gcn::Window("Create");
wndCreateFilesysHardfile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
wndCreateFilesysHardfile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
wndCreateFilesysHardfile->setBaseColor(gui_baseCol + 0x202020);
wndCreateFilesysHardfile->setCaption("Create hardfile");
wndCreateFilesysHardfile->setTitleBarHeight(TITLEBAR_HEIGHT);
wndCreateFilesysHardfile = new gcn::Window("Create");
wndCreateFilesysHardfile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
wndCreateFilesysHardfile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
wndCreateFilesysHardfile->setBaseColor(gui_baseCol + 0x202020);
wndCreateFilesysHardfile->setCaption("Create hardfile");
wndCreateFilesysHardfile->setTitleBarHeight(TITLEBAR_HEIGHT);
createFilesysHardfileActionListener = new CreateFilesysHardfileActionListener();
createFilesysHardfileActionListener = new CreateFilesysHardfileActionListener();
cmdOK = new gcn::Button("Ok");
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdOK->setBaseColor(gui_baseCol + 0x202020);
cmdOK->setId("createHdfOK");
cmdOK->addActionListener(createFilesysHardfileActionListener);
cmdOK = new gcn::Button("Ok");
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdOK->setBaseColor(gui_baseCol + 0x202020);
cmdOK->setId("createHdfOK");
cmdOK->addActionListener(createFilesysHardfileActionListener);
cmdCancel = new gcn::Button("Cancel");
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
cmdCancel->setId("createHdfCancel");
cmdCancel->addActionListener(createFilesysHardfileActionListener);
cmdCancel = new gcn::Button("Cancel");
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
cmdCancel->setId("createHdfCancel");
cmdCancel->addActionListener(createFilesysHardfileActionListener);
lblDevice = new gcn::Label("Device Name:");
lblDevice->setSize(100, LABEL_HEIGHT);
lblDevice->setAlignment(gcn::Graphics::RIGHT);
txtDevice = new gcn::TextField();
txtDevice->setSize(80, TEXTFIELD_HEIGHT);
txtDevice->setId("createHdfDev");
lblDevice = new gcn::Label("Device Name:");
lblDevice->setSize(100, LABEL_HEIGHT);
lblDevice->setAlignment(gcn::Graphics::RIGHT);
txtDevice = new gcn::TextField();
txtDevice->setSize(80, TEXTFIELD_HEIGHT);
txtDevice->setId("createHdfDev");
chkAutoboot = new gcn::UaeCheckBox("Bootable", true);
chkAutoboot->setId("createHdfAutoboot");
chkAutoboot = new gcn::UaeCheckBox("Bootable", true);
chkAutoboot->setId("createHdfAutoboot");
lblBootPri = new gcn::Label("Boot priority:");
lblBootPri->setSize(100, LABEL_HEIGHT);
lblBootPri->setAlignment(gcn::Graphics::RIGHT);
txtBootPri = new gcn::TextField();
txtBootPri->setSize(40, TEXTFIELD_HEIGHT);
txtBootPri->setId("createHdfBootPri");
lblBootPri = new gcn::Label("Boot priority:");
lblBootPri->setSize(100, LABEL_HEIGHT);
lblBootPri->setAlignment(gcn::Graphics::RIGHT);
txtBootPri = new gcn::TextField();
txtBootPri->setSize(40, TEXTFIELD_HEIGHT);
txtBootPri->setId("createHdfBootPri");
lblSize = new gcn::Label("Size (MB):");
lblSize->setSize(100, LABEL_HEIGHT);
lblSize->setAlignment(gcn::Graphics::RIGHT);
txtSize = new gcn::TextField();
txtSize->setSize(60, TEXTFIELD_HEIGHT);
txtSize->setId("createHdfSize");
lblSize = new gcn::Label("Size (MB):");
lblSize->setSize(100, LABEL_HEIGHT);
lblSize->setAlignment(gcn::Graphics::RIGHT);
txtSize = new gcn::TextField();
txtSize->setSize(60, TEXTFIELD_HEIGHT);
txtSize->setId("createHdfSize");
lblPath = new gcn::Label("Path:");
lblPath->setSize(100, LABEL_HEIGHT);
lblPath->setAlignment(gcn::Graphics::RIGHT);
txtPath = new gcn::TextField();
txtPath->setSize(438, TEXTFIELD_HEIGHT);
txtPath->setEnabled(false);
cmdPath = new gcn::Button("...");
cmdPath->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdPath->setBaseColor(gui_baseCol + 0x202020);
cmdPath->setId("createHdfPath");
cmdPath->addActionListener(createFilesysHardfileActionListener);
lblPath = new gcn::Label("Path:");
lblPath->setSize(100, LABEL_HEIGHT);
lblPath->setAlignment(gcn::Graphics::RIGHT);
txtPath = new gcn::TextField();
txtPath->setSize(438, TEXTFIELD_HEIGHT);
txtPath->setEnabled(false);
cmdPath = new gcn::Button("...");
cmdPath->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdPath->setBaseColor(gui_baseCol + 0x202020);
cmdPath->setId("createHdfPath");
cmdPath->addActionListener(createFilesysHardfileActionListener);
int posY = DISTANCE_BORDER;
wndCreateFilesysHardfile->add(lblDevice, DISTANCE_BORDER, posY);
wndCreateFilesysHardfile->add(txtDevice, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
wndCreateFilesysHardfile->add(chkAutoboot, 235, posY + 1);
wndCreateFilesysHardfile->add(lblBootPri, 335, posY);
wndCreateFilesysHardfile->add(txtBootPri, 335 + lblBootPri->getWidth() + 8, posY);
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
wndCreateFilesysHardfile->add(lblPath, DISTANCE_BORDER, posY);
wndCreateFilesysHardfile->add(txtPath, DISTANCE_BORDER + lblPath->getWidth() + 8, posY);
wndCreateFilesysHardfile->add(cmdPath, wndCreateFilesysHardfile->getWidth() - DISTANCE_BORDER - SMALL_BUTTON_WIDTH, posY);
posY += txtPath->getHeight() + DISTANCE_NEXT_Y;
wndCreateFilesysHardfile->add(lblSize, DISTANCE_BORDER, posY);
wndCreateFilesysHardfile->add(txtSize, DISTANCE_BORDER + lblSize->getWidth() + 8, posY);
int posY = DISTANCE_BORDER;
wndCreateFilesysHardfile->add(lblDevice, DISTANCE_BORDER, posY);
wndCreateFilesysHardfile->add(txtDevice, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
wndCreateFilesysHardfile->add(chkAutoboot, 235, posY + 1);
wndCreateFilesysHardfile->add(lblBootPri, 335, posY);
wndCreateFilesysHardfile->add(txtBootPri, 335 + lblBootPri->getWidth() + 8, posY);
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
wndCreateFilesysHardfile->add(lblPath, DISTANCE_BORDER, posY);
wndCreateFilesysHardfile->add(txtPath, DISTANCE_BORDER + lblPath->getWidth() + 8, posY);
wndCreateFilesysHardfile->add(cmdPath, wndCreateFilesysHardfile->getWidth() - DISTANCE_BORDER - SMALL_BUTTON_WIDTH, posY);
posY += txtPath->getHeight() + DISTANCE_NEXT_Y;
wndCreateFilesysHardfile->add(lblSize, DISTANCE_BORDER, posY);
wndCreateFilesysHardfile->add(txtSize, DISTANCE_BORDER + lblSize->getWidth() + 8, posY);
wndCreateFilesysHardfile->add(cmdOK);
wndCreateFilesysHardfile->add(cmdCancel);
wndCreateFilesysHardfile->add(cmdOK);
wndCreateFilesysHardfile->add(cmdCancel);
gui_top->add(wndCreateFilesysHardfile);
gui_top->add(wndCreateFilesysHardfile);
txtDevice->requestFocus();
wndCreateFilesysHardfile->requestModalFocus();
txtDevice->requestFocus();
wndCreateFilesysHardfile->requestModalFocus();
}
static void ExitCreateFilesysHardfile(void)
static void ExitCreateFilesysHardfile()
{
wndCreateFilesysHardfile->releaseModalFocus();
gui_top->remove(wndCreateFilesysHardfile);
wndCreateFilesysHardfile->releaseModalFocus();
gui_top->remove(wndCreateFilesysHardfile);
delete lblDevice;
delete txtDevice;
delete chkAutoboot;
delete lblBootPri;
delete txtBootPri;
delete lblPath;
delete txtPath;
delete cmdPath;
delete lblSize;
delete txtSize;
delete lblDevice;
delete txtDevice;
delete chkAutoboot;
delete lblBootPri;
delete txtBootPri;
delete lblPath;
delete txtPath;
delete cmdPath;
delete lblSize;
delete txtSize;
delete cmdOK;
delete cmdCancel;
delete createFilesysHardfileActionListener;
delete cmdOK;
delete cmdCancel;
delete createFilesysHardfileActionListener;
delete wndCreateFilesysHardfile;
delete wndCreateFilesysHardfile;
}
static void CreateFilesysHardfileLoop(void)
static void CreateFilesysHardfileLoop()
{
while(!dialogFinished)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
if (event.type == SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case VK_ESCAPE:
dialogFinished = true;
break;
while (!dialogFinished)
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
if (event.type == SDL_KEYDOWN)
{
switch (event.key.keysym.sym)
{
case VK_ESCAPE:
dialogFinished = true;
break;
case VK_UP:
if(HandleNavigation(DIRECTION_UP))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case VK_UP:
if (HandleNavigation(DIRECTION_UP))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case VK_DOWN:
if(HandleNavigation(DIRECTION_DOWN))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case VK_DOWN:
if (HandleNavigation(DIRECTION_DOWN))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case VK_LEFT:
if(HandleNavigation(DIRECTION_LEFT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case VK_LEFT:
if (HandleNavigation(DIRECTION_LEFT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case VK_RIGHT:
if(HandleNavigation(DIRECTION_RIGHT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case VK_RIGHT:
if (HandleNavigation(DIRECTION_RIGHT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case VK_X:
case VK_A:
event.key.keysym.sym = SDLK_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
}
}
case VK_X:
case VK_A:
event.key.keysym.sym = SDLK_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
}
}
//-------------------------------------------------
// Send event to guisan-controls
//-------------------------------------------------
gui_input->pushInput(event);
}
//-------------------------------------------------
// Send event to guisan-controls
//-------------------------------------------------
gui_input->pushInput(event);
}
// Now we let the Gui object perform its logic.
uae_gui->logic();
// Now we let the Gui object draw itself.
uae_gui->draw();
// Finally we update the screen.
// wait_for_vsync();
// SDL_Flip(gui_screen);
// Update the texture from the surface
SDL_UpdateTexture(texture, NULL, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, texture, NULL, NULL);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
}
// Now we let the Gui object perform its logic.
uae_gui->logic();
// Now we let the Gui object draw itself.
uae_gui->draw();
// Finally we update the screen.
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, nullptr, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
}
}
bool CreateFilesysHardfile(void)
{
std::string strroot;
char tmp[32];
char zero = 0;
std::string strroot;
char tmp[32];
char zero = 0;
dialogResult = false;
dialogFinished = false;
dialogResult = false;
dialogFinished = false;
InitCreateFilesysHardfile();
InitCreateFilesysHardfile();
CreateDefaultDevicename(tmp);
txtDevice->setText(tmp);
strroot.assign(currentDir);
txtPath->setText(strroot);
fileSelected = false;
CreateDefaultDevicename(tmp);
txtDevice->setText(tmp);
strroot.assign(currentDir);
txtPath->setText(strroot);
fileSelected = false;
txtBootPri->setText("0");
txtSize->setText("100");
txtBootPri->setText("0");
txtSize->setText("100");
CreateFilesysHardfileLoop();
ExitCreateFilesysHardfile();
CreateFilesysHardfileLoop();
ExitCreateFilesysHardfile();
if(dialogResult)
{
char buffer[512];
int size = atoi(txtSize->getText().c_str());
if(size < 1)
size = 1;
if(size > 2048)
size = 2048;
int bp = tweakbootpri(atoi(txtBootPri->getText().c_str()), 1, 0);
extractPath((char *) txtPath->getText().c_str(), currentDir);
if (dialogResult)
{
char buffer[512];
int size = atoi(txtSize->getText().c_str());
if (size < 1)
size = 1;
if (size > 2048)
size = 2048;
int bp = tweakbootpri(atoi(txtBootPri->getText().c_str()), 1, 0);
extractPath(const_cast<char *>(txtPath->getText().c_str()), currentDir);
FILE *newFile = fopen(txtPath->getText().c_str(), "wb");
if(!newFile)
{
ShowMessage("Create Hardfile", "Unable to create new file.", "", "Ok", "");
return false;
}
fseek(newFile, size * 1024 * 1024 - 1, SEEK_SET);
fwrite(&zero, 1, 1, newFile);
fclose(newFile);
FILE * newFile = fopen(txtPath->getText().c_str(), "wb");
if (!newFile)
{
ShowMessage("Create Hardfile", "Unable to create new file.", "", "Ok", "");
return false;
}
fseek(newFile, size * 1024 * 1024 - 1, SEEK_SET);
fwrite(&zero, 1, 1, newFile);
fclose(newFile);
struct uaedev_config_data *uci;
struct uaedev_config_info ci;
struct uaedev_config_data* uci;
struct uaedev_config_info ci;
uci_set_defaults(&ci, false);
strcpy(ci.devname, (char *) txtDevice->getText().c_str());
strcpy(ci.rootdir, (char *) txtPath->getText().c_str());
ci.type = UAEDEV_HDF;
ci.surfaces = (size / 1024) + 1;
ci.bootpri = bp;
uci = add_filesys_config(&changed_prefs, -1, &ci);
if (uci) {
struct hardfiledata *hfd = get_hardfile_data (uci->configoffset);
hardfile_media_change (hfd, &ci, true, false);
}
}
uci_set_defaults(&ci, false);
strcpy(ci.devname, const_cast<char *>(txtDevice->getText().c_str()));
strcpy(ci.rootdir, const_cast<char *>(txtPath->getText().c_str()));
ci.type = UAEDEV_HDF;
ci.surfaces = (size / 1024) + 1;
ci.bootpri = bp;
return dialogResult;
uci = add_filesys_config(&changed_prefs, -1, &ci);
if (uci)
{
struct hardfiledata* hfd = get_hardfile_data(uci->configoffset);
hardfile_media_change(hfd, &ci, true, false);
}
}
return dialogResult;
}

View file

@ -22,46 +22,46 @@
#define DIALOG_WIDTH 520
#define DIALOG_HEIGHT 202
static const char *harddisk_filter[] = { ".hdf", "\0" };
static const char* harddisk_filter[] = {".hdf", "\0"};
static bool dialogResult = false;
static bool dialogFinished = false;
static bool fileSelected = false;
static gcn::Window *wndEditFilesysHardfile;
static gcn::Window* wndEditFilesysHardfile;
static gcn::Button* cmdOK;
static gcn::Button* cmdCancel;
static gcn::Label *lblDevice;
static gcn::TextField *txtDevice;
static gcn::Label* lblDevice;
static gcn::TextField* txtDevice;
static gcn::UaeCheckBox* chkReadWrite;
static gcn::UaeCheckBox* chkAutoboot;
static gcn::Label *lblBootPri;
static gcn::TextField *txtBootPri;
static gcn::Label *lblPath;
static gcn::TextField *txtPath;
static gcn::Label* lblBootPri;
static gcn::TextField* txtBootPri;
static gcn::Label* lblPath;
static gcn::TextField* txtPath;
static gcn::Button* cmdPath;
static gcn::Label *lblSurfaces;
static gcn::TextField *txtSurfaces;
static gcn::Label *lblReserved;
static gcn::TextField *txtReserved;
static gcn::Label *lblSectors;
static gcn::TextField *txtSectors;
static gcn::Label *lblBlocksize;
static gcn::TextField *txtBlocksize;
static gcn::Label* lblSurfaces;
static gcn::TextField* txtSurfaces;
static gcn::Label* lblReserved;
static gcn::TextField* txtReserved;
static gcn::Label* lblSectors;
static gcn::TextField* txtSectors;
static gcn::Label* lblBlocksize;
static gcn::TextField* txtBlocksize;
static void check_rdb(const TCHAR *filename)
static void check_rdb(const TCHAR* filename)
{
bool isrdb = hardfile_testrdb(filename);
if(isrdb)
{
bool isrdb = hardfile_testrdb(filename);
if (isrdb)
{
txtSectors->setText("0");
txtSurfaces->setText("0");
txtReserved->setText("0");
txtBootPri->setText("0");
}
txtSectors->setEnabled(!isrdb);
}
txtSectors->setEnabled(!isrdb);
txtSurfaces->setEnabled(!isrdb);
txtReserved->setEnabled(!isrdb);
txtBootPri->setEnabled(!isrdb);
@ -70,345 +70,347 @@ static void check_rdb(const TCHAR *filename)
class FilesysHardfileActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if(actionEvent.getSource() == cmdPath)
{
char tmp[MAX_PATH];
strncpy(tmp, txtPath->getText().c_str(), MAX_PATH);
wndEditFilesysHardfile->releaseModalFocus();
if(SelectFile("Select harddisk file", tmp, harddisk_filter))
{
txtPath->setText(tmp);
fileSelected = true;
check_rdb(tmp);
}
wndEditFilesysHardfile->requestModalFocus();
cmdPath->requestFocus();
}
else
{
if (actionEvent.getSource() == cmdOK)
{
if(txtDevice->getText().length() <= 0)
{
wndEditFilesysHardfile->setCaption("Please enter a device name.");
return;
}
if(!fileSelected)
{
wndEditFilesysHardfile->setCaption("Please select a filename.");
return;
}
dialogResult = true;
}
dialogFinished = true;
}
}
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == cmdPath)
{
char tmp[MAX_PATH];
strncpy(tmp, txtPath->getText().c_str(), MAX_PATH);
wndEditFilesysHardfile->releaseModalFocus();
if (SelectFile("Select harddisk file", tmp, harddisk_filter))
{
txtPath->setText(tmp);
fileSelected = true;
check_rdb(tmp);
}
wndEditFilesysHardfile->requestModalFocus();
cmdPath->requestFocus();
}
else
{
if (actionEvent.getSource() == cmdOK)
{
if (txtDevice->getText().length() <= 0)
{
wndEditFilesysHardfile->setCaption("Please enter a device name.");
return;
}
if (!fileSelected)
{
wndEditFilesysHardfile->setCaption("Please select a filename.");
return;
}
dialogResult = true;
}
dialogFinished = true;
}
}
};
static FilesysHardfileActionListener* filesysHardfileActionListener;
static void InitEditFilesysHardfile(void)
static void InitEditFilesysHardfile()
{
wndEditFilesysHardfile = new gcn::Window("Edit");
wndEditFilesysHardfile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
wndEditFilesysHardfile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
wndEditFilesysHardfile->setBaseColor(gui_baseCol + 0x202020);
wndEditFilesysHardfile->setCaption("Volume settings");
wndEditFilesysHardfile->setTitleBarHeight(TITLEBAR_HEIGHT);
filesysHardfileActionListener = new FilesysHardfileActionListener();
cmdOK = new gcn::Button("Ok");
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdOK->setBaseColor(gui_baseCol + 0x202020);
cmdOK->setId("hdfOK");
cmdOK->addActionListener(filesysHardfileActionListener);
cmdCancel = new gcn::Button("Cancel");
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
cmdCancel->setId("hdfCancel");
cmdCancel->addActionListener(filesysHardfileActionListener);
wndEditFilesysHardfile = new gcn::Window("Edit");
wndEditFilesysHardfile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
wndEditFilesysHardfile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
wndEditFilesysHardfile->setBaseColor(gui_baseCol + 0x202020);
wndEditFilesysHardfile->setCaption("Volume settings");
wndEditFilesysHardfile->setTitleBarHeight(TITLEBAR_HEIGHT);
lblDevice = new gcn::Label("Device Name:");
lblDevice->setSize(100, LABEL_HEIGHT);
lblDevice->setAlignment(gcn::Graphics::RIGHT);
txtDevice = new gcn::TextField();
txtDevice->setSize(80, TEXTFIELD_HEIGHT);
txtDevice->setId("hdfDev");
filesysHardfileActionListener = new FilesysHardfileActionListener();
chkReadWrite = new gcn::UaeCheckBox("Read/Write", true);
chkReadWrite->setId("hdfRW");
cmdOK = new gcn::Button("Ok");
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdOK->setBaseColor(gui_baseCol + 0x202020);
cmdOK->setId("hdfOK");
cmdOK->addActionListener(filesysHardfileActionListener);
cmdCancel = new gcn::Button("Cancel");
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
cmdCancel->setId("hdfCancel");
cmdCancel->addActionListener(filesysHardfileActionListener);
lblDevice = new gcn::Label("Device Name:");
lblDevice->setSize(100, LABEL_HEIGHT);
lblDevice->setAlignment(gcn::Graphics::RIGHT);
txtDevice = new gcn::TextField();
txtDevice->setSize(80, TEXTFIELD_HEIGHT);
txtDevice->setId("hdfDev");
chkReadWrite = new gcn::UaeCheckBox("Read/Write", true);
chkReadWrite->setId("hdfRW");
chkAutoboot = new gcn::UaeCheckBox("Bootable", true);
chkAutoboot->setId("hdfAutoboot");
chkAutoboot->setId("hdfAutoboot");
lblBootPri = new gcn::Label("Boot priority:");
lblBootPri->setSize(100, LABEL_HEIGHT);
lblBootPri->setAlignment(gcn::Graphics::RIGHT);
txtBootPri = new gcn::TextField();
txtBootPri->setSize(40, TEXTFIELD_HEIGHT);
txtBootPri->setId("hdfBootPri");
lblBootPri = new gcn::Label("Boot priority:");
lblBootPri->setSize(100, LABEL_HEIGHT);
lblBootPri->setAlignment(gcn::Graphics::RIGHT);
txtBootPri = new gcn::TextField();
txtBootPri->setSize(40, TEXTFIELD_HEIGHT);
txtBootPri->setId("hdfBootPri");
lblSurfaces = new gcn::Label("Surfaces:");
lblSurfaces->setSize(100, LABEL_HEIGHT);
lblSurfaces->setAlignment(gcn::Graphics::RIGHT);
txtSurfaces = new gcn::TextField();
txtSurfaces->setSize(40, TEXTFIELD_HEIGHT);
txtSurfaces->setId("hdfSurface");
lblSurfaces = new gcn::Label("Surfaces:");
lblSurfaces->setSize(100, LABEL_HEIGHT);
lblSurfaces->setAlignment(gcn::Graphics::RIGHT);
txtSurfaces = new gcn::TextField();
txtSurfaces->setSize(40, TEXTFIELD_HEIGHT);
txtSurfaces->setId("hdfSurface");
lblReserved = new gcn::Label("Reserved:");
lblReserved->setSize(100, LABEL_HEIGHT);
lblReserved->setAlignment(gcn::Graphics::RIGHT);
txtReserved = new gcn::TextField();
txtReserved->setSize(40, TEXTFIELD_HEIGHT);
txtReserved->setId("hdfReserved");
lblReserved = new gcn::Label("Reserved:");
lblReserved->setSize(100, LABEL_HEIGHT);
lblReserved->setAlignment(gcn::Graphics::RIGHT);
txtReserved = new gcn::TextField();
txtReserved->setSize(40, TEXTFIELD_HEIGHT);
txtReserved->setId("hdfReserved");
lblSectors = new gcn::Label("Sectors:");
lblSectors->setSize(100, LABEL_HEIGHT);
lblSectors->setAlignment(gcn::Graphics::RIGHT);
txtSectors = new gcn::TextField();
txtSectors->setSize(40, TEXTFIELD_HEIGHT);
txtSectors->setId("hdfSectors");
lblSectors = new gcn::Label("Sectors:");
lblSectors->setSize(100, LABEL_HEIGHT);
lblSectors->setAlignment(gcn::Graphics::RIGHT);
txtSectors = new gcn::TextField();
txtSectors->setSize(40, TEXTFIELD_HEIGHT);
txtSectors->setId("hdfSectors");
lblBlocksize = new gcn::Label("Blocksize:");
lblBlocksize->setSize(100, LABEL_HEIGHT);
lblBlocksize->setAlignment(gcn::Graphics::RIGHT);
txtBlocksize = new gcn::TextField();
txtBlocksize->setSize(40, TEXTFIELD_HEIGHT);
txtBlocksize->setId("hdfBlocksize");
lblBlocksize = new gcn::Label("Blocksize:");
lblBlocksize->setSize(100, LABEL_HEIGHT);
lblBlocksize->setAlignment(gcn::Graphics::RIGHT);
txtBlocksize = new gcn::TextField();
txtBlocksize->setSize(40, TEXTFIELD_HEIGHT);
txtBlocksize->setId("hdfBlocksize");
lblPath = new gcn::Label("Path:");
lblPath->setSize(100, LABEL_HEIGHT);
lblPath->setAlignment(gcn::Graphics::RIGHT);
txtPath = new gcn::TextField();
txtPath->setSize(438, TEXTFIELD_HEIGHT);
txtPath->setEnabled(false);
cmdPath = new gcn::Button("...");
cmdPath->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdPath->setBaseColor(gui_baseCol + 0x202020);
cmdPath->setId("hdfPath");
cmdPath->addActionListener(filesysHardfileActionListener);
lblPath = new gcn::Label("Path:");
lblPath->setSize(100, LABEL_HEIGHT);
lblPath->setAlignment(gcn::Graphics::RIGHT);
txtPath = new gcn::TextField();
txtPath->setSize(438, TEXTFIELD_HEIGHT);
txtPath->setEnabled(false);
cmdPath = new gcn::Button("...");
cmdPath->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdPath->setBaseColor(gui_baseCol + 0x202020);
cmdPath->setId("hdfPath");
cmdPath->addActionListener(filesysHardfileActionListener);
int posY = DISTANCE_BORDER;
wndEditFilesysHardfile->add(lblDevice, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtDevice, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
wndEditFilesysHardfile->add(chkReadWrite, 235, posY + 1);
wndEditFilesysHardfile->add(chkAutoboot, 360, posY + 1);
wndEditFilesysHardfile->add(lblBootPri, 460, posY);
wndEditFilesysHardfile->add(txtBootPri, 460 + lblBootPri->getWidth() + 8, posY);
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysHardfile->add(lblPath, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtPath, DISTANCE_BORDER + lblPath->getWidth() + 8, posY);
wndEditFilesysHardfile->add(cmdPath, wndEditFilesysHardfile->getWidth() - DISTANCE_BORDER - SMALL_BUTTON_WIDTH, posY);
posY += txtPath->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysHardfile->add(lblSurfaces, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtSurfaces, DISTANCE_BORDER + lblSurfaces->getWidth() + 8, posY);
wndEditFilesysHardfile->add(lblReserved, 240, posY);
wndEditFilesysHardfile->add(txtReserved, 240 + lblReserved->getWidth() + 8, posY);
posY += txtSurfaces->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysHardfile->add(lblSectors, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtSectors, DISTANCE_BORDER + lblSectors->getWidth() + 8, posY);
wndEditFilesysHardfile->add(lblBlocksize, 240, posY);
wndEditFilesysHardfile->add(txtBlocksize, 240 + lblBlocksize->getWidth() + 8, posY);
posY += txtSectors->getHeight() + DISTANCE_NEXT_Y;
int posY = DISTANCE_BORDER;
wndEditFilesysHardfile->add(lblDevice, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtDevice, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
wndEditFilesysHardfile->add(chkReadWrite, 235, posY + 1);
wndEditFilesysHardfile->add(chkAutoboot, 360, posY + 1);
wndEditFilesysHardfile->add(lblBootPri, 460, posY);
wndEditFilesysHardfile->add(txtBootPri, 460 + lblBootPri->getWidth() + 8, posY);
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysHardfile->add(lblPath, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtPath, DISTANCE_BORDER + lblPath->getWidth() + 8, posY);
wndEditFilesysHardfile->add(cmdPath, wndEditFilesysHardfile->getWidth() - DISTANCE_BORDER - SMALL_BUTTON_WIDTH, posY);
posY += txtPath->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysHardfile->add(lblSurfaces, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtSurfaces, DISTANCE_BORDER + lblSurfaces->getWidth() + 8, posY);
wndEditFilesysHardfile->add(lblReserved, 240, posY);
wndEditFilesysHardfile->add(txtReserved, 240 + lblReserved->getWidth() + 8, posY);
posY += txtSurfaces->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysHardfile->add(lblSectors, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtSectors, DISTANCE_BORDER + lblSectors->getWidth() + 8, posY);
wndEditFilesysHardfile->add(lblBlocksize, 240, posY);
wndEditFilesysHardfile->add(txtBlocksize, 240 + lblBlocksize->getWidth() + 8, posY);
posY += txtSectors->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysHardfile->add(cmdOK);
wndEditFilesysHardfile->add(cmdCancel);
wndEditFilesysHardfile->add(cmdOK);
wndEditFilesysHardfile->add(cmdCancel);
gui_top->add(wndEditFilesysHardfile);
txtDevice->requestFocus();
wndEditFilesysHardfile->requestModalFocus();
gui_top->add(wndEditFilesysHardfile);
txtDevice->requestFocus();
wndEditFilesysHardfile->requestModalFocus();
}
static void ExitEditFilesysHardfile(void)
static void ExitEditFilesysHardfile()
{
wndEditFilesysHardfile->releaseModalFocus();
gui_top->remove(wndEditFilesysHardfile);
wndEditFilesysHardfile->releaseModalFocus();
gui_top->remove(wndEditFilesysHardfile);
delete lblDevice;
delete txtDevice;
delete chkReadWrite;
delete chkAutoboot;
delete lblBootPri;
delete txtBootPri;
delete lblPath;
delete txtPath;
delete cmdPath;
delete lblSurfaces;
delete txtSurfaces;
delete lblReserved;
delete txtReserved;
delete lblSectors;
delete txtSectors;
delete lblBlocksize;
delete txtBlocksize;
delete cmdOK;
delete cmdCancel;
delete filesysHardfileActionListener;
delete wndEditFilesysHardfile;
delete lblDevice;
delete txtDevice;
delete chkReadWrite;
delete chkAutoboot;
delete lblBootPri;
delete txtBootPri;
delete lblPath;
delete txtPath;
delete cmdPath;
delete lblSurfaces;
delete txtSurfaces;
delete lblReserved;
delete txtReserved;
delete lblSectors;
delete txtSectors;
delete lblBlocksize;
delete txtBlocksize;
delete cmdOK;
delete cmdCancel;
delete filesysHardfileActionListener;
delete wndEditFilesysHardfile;
}
static void EditFilesysHardfileLoop(void)
static void EditFilesysHardfileLoop()
{
while(!dialogFinished)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
if (event.type == SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case VK_ESCAPE:
dialogFinished = true;
break;
case VK_UP:
if(HandleNavigation(DIRECTION_UP))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case VK_DOWN:
if(HandleNavigation(DIRECTION_DOWN))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
while (!dialogFinished)
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
if (event.type == SDL_KEYDOWN)
{
switch (event.key.keysym.sym)
{
case VK_ESCAPE:
dialogFinished = true;
break;
case VK_LEFT:
if(HandleNavigation(DIRECTION_LEFT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case VK_RIGHT:
if(HandleNavigation(DIRECTION_RIGHT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case VK_UP:
if (HandleNavigation(DIRECTION_UP))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case VK_X:
case VK_A:
event.key.keysym.sym = SDLK_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
}
}
case VK_DOWN:
if (HandleNavigation(DIRECTION_DOWN))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
//-------------------------------------------------
// Send event to guisan-controls
//-------------------------------------------------
gui_input->pushInput(event);
}
case VK_LEFT:
if (HandleNavigation(DIRECTION_LEFT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
// Now we let the Gui object perform its logic.
uae_gui->logic();
// Now we let the Gui object draw itself.
uae_gui->draw();
// Finally we update the screen.
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, NULL, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, NULL, NULL);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
}
case VK_RIGHT:
if (HandleNavigation(DIRECTION_RIGHT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case VK_X:
case VK_A:
event.key.keysym.sym = SDLK_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
}
}
//-------------------------------------------------
// Send event to guisan-controls
//-------------------------------------------------
gui_input->pushInput(event);
}
// Now we let the Gui object perform its logic.
uae_gui->logic();
// Now we let the Gui object draw itself.
uae_gui->draw();
// Finally we update the screen.
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, nullptr, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
}
}
bool EditFilesysHardfile(int unit_no)
{
struct mountedinfo mi;
struct uaedev_config_data *uci;
std::string strdevname, strroot;
char tmp[32];
dialogResult = false;
dialogFinished = false;
struct mountedinfo mi;
struct uaedev_config_data* uci;
std::string strdevname, strroot;
char tmp[32];
InitEditFilesysHardfile();
dialogResult = false;
dialogFinished = false;
if(unit_no >= 0)
{
struct uaedev_config_info *ci;
InitEditFilesysHardfile();
uci = &changed_prefs.mountconfig[unit_no];
ci = &uci->ci;
get_filesys_unitconfig(&changed_prefs, unit_no, &mi);
if (unit_no >= 0)
{
struct uaedev_config_info* ci;
strdevname.assign(ci->devname);
txtDevice->setText(strdevname);
strroot.assign(ci->rootdir);
txtPath->setText(strroot);
fileSelected = true;
uci = &changed_prefs.mountconfig[unit_no];
ci = &uci->ci;
get_filesys_unitconfig(&changed_prefs, unit_no, &mi);
chkReadWrite->setSelected(!ci->readonly);
chkAutoboot->setSelected(ci->bootpri != BOOTPRI_NOAUTOBOOT);
snprintf(tmp, 32, "%d", ci->bootpri >= -127 ? ci->bootpri : -127);
txtBootPri->setText(tmp);
snprintf(tmp, 32, "%d", ci->surfaces);
txtSurfaces->setText(tmp);
snprintf(tmp, 32, "%d", ci->reserved);
txtReserved->setText(tmp);
snprintf(tmp, 32, "%d", ci->sectors);
txtSectors->setText(tmp);
snprintf(tmp, 32, "%d", ci->blocksize);
txtBlocksize->setText(tmp);
check_rdb(strroot.c_str());
}
else
{
CreateDefaultDevicename(tmp);
txtDevice->setText(tmp);
strroot.assign(currentDir);
txtPath->setText(strroot);
fileSelected = false;
chkReadWrite->setSelected(true);
txtBootPri->setText("0");
txtSurfaces->setText("1");
txtReserved->setText("2");
txtSectors->setText("32");
txtBlocksize->setText("512");
}
strdevname.assign(ci->devname);
txtDevice->setText(strdevname);
strroot.assign(ci->rootdir);
txtPath->setText(strroot);
fileSelected = true;
EditFilesysHardfileLoop();
if(dialogResult)
{
struct uaedev_config_info ci;
int bp = tweakbootpri(atoi(txtBootPri->getText().c_str()), chkAutoboot->isSelected() ? 1 : 0, 0);
extractPath((char *) txtPath->getText().c_str(), currentDir);
chkReadWrite->setSelected(!ci->readonly);
chkAutoboot->setSelected(ci->bootpri != BOOTPRI_NOAUTOBOOT);
snprintf(tmp, 32, "%d", ci->bootpri >= -127 ? ci->bootpri : -127);
txtBootPri->setText(tmp);
snprintf(tmp, 32, "%d", ci->surfaces);
txtSurfaces->setText(tmp);
snprintf(tmp, 32, "%d", ci->reserved);
txtReserved->setText(tmp);
snprintf(tmp, 32, "%d", ci->sectors);
txtSectors->setText(tmp);
snprintf(tmp, 32, "%d", ci->blocksize);
txtBlocksize->setText(tmp);
uci_set_defaults(&ci, false);
strcpy(ci.devname, (char *) txtDevice->getText().c_str());
strcpy(ci.rootdir, (char *) txtPath->getText().c_str());
ci.type = UAEDEV_HDF;
ci.readonly = !chkReadWrite->isSelected();
ci.sectors = atoi(txtSectors->getText().c_str());
ci.surfaces = atoi(txtSurfaces->getText().c_str());
ci.reserved = atoi(txtReserved->getText().c_str());
ci.blocksize = atoi(txtBlocksize->getText().c_str());
ci.bootpri = bp;
uci = add_filesys_config(&changed_prefs, unit_no, &ci);
if (uci) {
struct hardfiledata *hfd = get_hardfile_data (uci->configoffset);
hardfile_media_change (hfd, &ci, true, false);
}
}
check_rdb(strroot.c_str());
}
else
{
CreateDefaultDevicename(tmp);
txtDevice->setText(tmp);
strroot.assign(currentDir);
txtPath->setText(strroot);
fileSelected = false;
ExitEditFilesysHardfile();
chkReadWrite->setSelected(true);
txtBootPri->setText("0");
txtSurfaces->setText("1");
txtReserved->setText("2");
txtSectors->setText("32");
txtBlocksize->setText("512");
}
return dialogResult;
EditFilesysHardfileLoop();
if (dialogResult)
{
struct uaedev_config_info ci;
int bp = tweakbootpri(atoi(txtBootPri->getText().c_str()), chkAutoboot->isSelected() ? 1 : 0, 0);
extractPath(const_cast<char *>(txtPath->getText().c_str()), currentDir);
uci_set_defaults(&ci, false);
strcpy(ci.devname, const_cast<char *>(txtDevice->getText().c_str()));
strcpy(ci.rootdir, const_cast<char *>(txtPath->getText().c_str()));
ci.type = UAEDEV_HDF;
ci.readonly = !chkReadWrite->isSelected();
ci.sectors = atoi(txtSectors->getText().c_str());
ci.surfaces = atoi(txtSurfaces->getText().c_str());
ci.reserved = atoi(txtReserved->getText().c_str());
ci.blocksize = atoi(txtBlocksize->getText().c_str());
ci.bootpri = bp;
uci = add_filesys_config(&changed_prefs, unit_no, &ci);
if (uci)
{
struct hardfiledata* hfd = get_hardfile_data(uci->configoffset);
hardfile_media_change(hfd, &ci, true, false);
}
}
ExitEditFilesysHardfile();
return dialogResult;
}

View file

@ -37,7 +37,7 @@ static const int COLUMN_SIZE[] =
};
static const char *cdfile_filter[] = { ".cue", ".ccd", ".iso", "\0" };
static void AdjustDropDownControls(void);
static void AdjustDropDownControls();
static gcn::Label* lblList[COL_COUNT];
static gcn::Container* listEntry[MAX_HD_DEVICES];
@ -458,7 +458,7 @@ void InitPanelHD(const struct _ConfigCategory& category)
}
void ExitPanelHD(void)
void ExitPanelHD()
{
int row, col;
@ -499,7 +499,7 @@ void ExitPanelHD(void)
}
static void AdjustDropDownControls(void)
static void AdjustDropDownControls()
{
int i;
@ -517,7 +517,7 @@ static void AdjustDropDownControls(void)
}
}
void RefreshPanelHD(void)
void RefreshPanelHD()
{
int row, col;
char tmp[32];
@ -567,9 +567,9 @@ void RefreshPanelHD(void)
if (nosize)
snprintf (tmp, 32, "n/a");
else if (mi.size >= 1024 * 1024 * 1024)
snprintf (tmp, 32, "%.1fG", ((double)(uae_u32)(mi.size / (1024 * 1024))) / 1024.0);
snprintf (tmp, 32, "%.1fG", double(uae_u32(mi.size / (1024 * 1024))) / 1024.0);
else
snprintf (tmp, 32, "%.1fM", ((double)(uae_u32)(mi.size / (1024))) / 1024.0);
snprintf (tmp, 32, "%.1fM", double(uae_u32(mi.size / (1024))) / 1024.0);
listCells[row][COL_SIZE]->setText(tmp);
snprintf(tmp, 32, "%d", ci->bootpri);
listCells[row][COL_BOOTPRI]->setText(tmp);
@ -601,21 +601,5 @@ void RefreshPanelHD(void)
int count_HDs(struct uae_prefs *p)
{
/*
int row;
struct uaedev_config_info *uci;
int cnt = 0;
for(row=0; row<MAX_HD_DEVICES; ++row)
{
uci = &p->mountconfig[row];
if(uci->devname && uci->devname[0])
{
++cnt;
}
}
return cnt;
*/
return p->mountitems;
}

View file

@ -12,7 +12,6 @@
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "include/memory.h"
#include "custom.h"
@ -63,34 +62,34 @@
*/
struct Trap
{
TrapHandler handler; /* Handler function to be invoked for this trap. */
int flags; /* Trap attributes. */
const TCHAR *name; /* For debugging purposes. */
uaecptr addr;
TrapHandler handler; /* Handler function to be invoked for this trap. */
int flags; /* Trap attributes. */
const TCHAR* name; /* For debugging purposes. */
uaecptr addr;
};
#define MAX_TRAPS 4096
/* Defined traps */
static struct Trap traps[MAX_TRAPS];
static struct Trap traps[MAX_TRAPS];
static unsigned int trap_count = 1;
static const int trace_traps = 0;
static void trap_HandleExtendedTrap (TrapHandler, int has_retval);
static void trap_HandleExtendedTrap(TrapHandler, int has_retval);
uaecptr find_trap (const TCHAR *name)
uaecptr find_trap(const TCHAR* name)
{
int i;
int i;
for (i = 0; i < trap_count; i++)
{
struct Trap *trap = &traps[i];
if ((trap->flags & TRAPFLAG_UAERES) && trap->name && !_tcscmp (trap->name, name))
return trap->addr;
}
return 0;
for (i = 0; i < trap_count; i++)
{
struct Trap* trap = &traps[i];
if ((trap->flags & TRAPFLAG_UAERES) && trap->name && !_tcscmp (trap->name, name))
return trap->addr;
}
return 0;
}
@ -103,37 +102,37 @@ uaecptr find_trap (const TCHAR *name)
*
* returns trap number of defined trap
*/
unsigned int define_trap (TrapHandler handler_func, int flags, const TCHAR *name)
unsigned int define_trap(TrapHandler handler_func, int flags, const TCHAR* name)
{
if (trap_count == MAX_TRAPS)
{
write_log (_T("Ran out of emulator traps\n"));
abort ();
return -1;
}
else
{
int i;
unsigned int trap_num;
struct Trap *trap;
uaecptr addr = here ();
if (trap_count == MAX_TRAPS)
{
write_log (_T("Ran out of emulator traps\n"));
abort ();
return -1;
}
else
{
int i;
unsigned int trap_num;
struct Trap* trap;
uaecptr addr = here();
for (i = 0; i < trap_count; i++)
{
if (addr == traps[i].addr)
return i;
}
for (i = 0; i < trap_count; i++)
{
if (addr == traps[i].addr)
return i;
}
trap_num = trap_count++;
trap = &traps[trap_num];
trap_num = trap_count++;
trap = &traps[trap_num];
trap->handler = handler_func;
trap->flags = flags;
trap->name = name;
trap->addr = addr;
trap->handler = handler_func;
trap->flags = flags;
trap->name = name;
trap->addr = addr;
return trap_num;
}
return trap_num;
}
}
@ -143,102 +142,102 @@ unsigned int define_trap (TrapHandler handler_func, int flags, const TCHAR *name
* trap_num = number of trap to invoke
* regs = current 68k state
*/
void REGPARAM2 m68k_handle_trap (unsigned int trap_num)
void REGPARAM2 m68k_handle_trap(unsigned int trap_num)
{
struct Trap *trap = &traps[trap_num];
uae_u32 retval = 0;
struct Trap* trap = &traps[trap_num];
uae_u32 retval;
int has_retval = (trap->flags & TRAPFLAG_NO_RETVAL) == 0;
int implicit_rts = (trap->flags & TRAPFLAG_DORET) != 0;
int has_retval = (trap->flags & TRAPFLAG_NO_RETVAL) == 0;
int implicit_rts = (trap->flags & TRAPFLAG_DORET) != 0;
if (trap->name && trap->name[0] != 0 && trace_traps)
write_log (_T("TRAP: %s\n"), trap->name);
if (trap->name && trap->name[0] != 0 && trace_traps)
write_log (_T("TRAP: %s\n"), trap->name);
if (trap_num < trap_count)
{
if (trap->flags & TRAPFLAG_EXTRA_STACK)
{
/* Handle an extended trap.
* Note: the return value of this trap is passed back to 68k
* space via a separate, dedicated simple trap which the trap
* handler causes to be invoked when it is done.
*/
trap_HandleExtendedTrap (trap->handler, has_retval);
}
else
{
/* Handle simple trap */
retval = (trap->handler) (NULL);
if (trap_num < trap_count)
{
if (trap->flags & TRAPFLAG_EXTRA_STACK)
{
/* Handle an extended trap.
* Note: the return value of this trap is passed back to 68k
* space via a separate, dedicated simple trap which the trap
* handler causes to be invoked when it is done.
*/
trap_HandleExtendedTrap(trap->handler, has_retval);
}
else
{
/* Handle simple trap */
retval = (trap->handler)(nullptr);
if (has_retval)
m68k_dreg (regs, 0) = retval;
if (has_retval)
m68k_dreg (regs, 0) = retval;
if (implicit_rts)
{
m68k_do_rts ();
fill_prefetch ();
}
}
}
else
write_log (_T("Illegal emulator trap\n"));
if (implicit_rts)
{
m68k_do_rts();
fill_prefetch();
}
}
}
else
write_log (_T("Illegal emulator trap\n"));
}
/*
* Implementation of extended traps
*/
struct TrapCPUContext
{
uae_u32 regs[16];
uae_u32 pc;
int intmask;
uae_u32 regs[16];
uae_u32 pc;
int intmask;
};
struct TrapContext
{
/* Trap's working copy of 68k state. This is what the trap handler should
* access to get arguments from 68k space. */
//struct regstruct regs;
/* Trap's working copy of 68k state. This is what the trap handler should
* access to get arguments from 68k space. */
//struct regstruct regs;
/* Trap handler function that gets called on the trap context */
TrapHandler trap_handler;
/* Should the handler return a value to 68k space in D0? */
int trap_has_retval;
/* Return value from trap handler */
uae_u32 trap_retval;
/* Trap handler function that gets called on the trap context */
TrapHandler trap_handler;
/* Should the handler return a value to 68k space in D0? */
int trap_has_retval;
/* Return value from trap handler */
uae_u32 trap_retval;
/* Copy of 68k state at trap entry. */
//struct regstruct saved_regs;
struct TrapCPUContext saved_regs;
/* Copy of 68k state at trap entry. */
//struct regstruct saved_regs;
struct TrapCPUContext saved_regs;
/* Thread which effects the trap context. */
uae_thread_id thread;
/* For IPC between the main emulator. */
uae_sem_t switch_to_emu_sem;
/* context and the trap context. */
uae_sem_t switch_to_trap_sem;
/* Thread which effects the trap context. */
uae_thread_id thread;
/* For IPC between the main emulator. */
uae_sem_t switch_to_emu_sem;
/* context and the trap context. */
uae_sem_t switch_to_trap_sem;
/* When calling a 68k function from a trap handler, this is set to the
* address of the function to call. */
uaecptr call68k_func_addr;
/* And this gets set to the return value of the 68k call. */
uae_u32 call68k_retval;
/* When calling a 68k function from a trap handler, this is set to the
* address of the function to call. */
uaecptr call68k_func_addr;
/* And this gets set to the return value of the 68k call. */
uae_u32 call68k_retval;
};
static void copytocpucontext(struct TrapCPUContext *cpu)
static void copytocpucontext(struct TrapCPUContext* cpu)
{
memcpy (cpu->regs, regs.regs, sizeof (regs.regs));
cpu->intmask = regs.intmask;
cpu->pc = m68k_getpc ();
memcpy(cpu->regs, regs.regs, sizeof (regs.regs));
cpu->intmask = regs.intmask;
cpu->pc = m68k_getpc();
}
static void copyfromcpucontext(struct TrapCPUContext *cpu, uae_u32 pc)
static void copyfromcpucontext(struct TrapCPUContext* cpu, uae_u32 pc)
{
memcpy (regs.regs, cpu->regs, sizeof (regs.regs));
regs.intmask = cpu->intmask;
m68k_setpc (pc);
memcpy(regs.regs, cpu->regs, sizeof (regs.regs));
regs.intmask = cpu->intmask;
m68k_setpc(pc);
}
@ -248,88 +247,88 @@ static uaecptr m68k_return_trapaddr;
static uaecptr exit_trap_trapaddr;
/* For IPC between main thread and trap context */
static uae_sem_t trap_mutex = 0;
static TrapContext *current_context;
static uae_sem_t trap_mutex = nullptr;
static TrapContext* current_context;
/*
* Thread body for trap context
*/
static void *trap_thread (void *arg)
static void* trap_thread(void* arg)
{
TrapContext *context = (TrapContext *) arg;
TrapContext* context = static_cast<TrapContext *>(arg);
/* Wait until main thread is ready to switch to the
* this trap context. */
uae_sem_wait (&context->switch_to_trap_sem);
/* Wait until main thread is ready to switch to the
* this trap context. */
uae_sem_wait (&context->switch_to_trap_sem);
/* Execute trap handler function. */
context->trap_retval = context->trap_handler (context);
/* Execute trap handler function. */
context->trap_retval = context->trap_handler(context);
/* Trap handler is done - we still need to tidy up
* and make sure the handler's return value is propagated
* to the calling 68k thread.
*
* We do this by causing our exit handler to be executed on the 68k context.
*/
/* Trap handler is done - we still need to tidy up
* and make sure the handler's return value is propagated
* to the calling 68k thread.
*
* We do this by causing our exit handler to be executed on the 68k context.
*/
/* Enter critical section - only one trap at a time, please! */
uae_sem_wait (&trap_mutex);
/* Enter critical section - only one trap at a time, please! */
uae_sem_wait (&trap_mutex);
//regs = context->saved_regs;
/* Set PC to address of the exit handler, so that it will be called
* when the 68k context resumes. */
copyfromcpucontext (&context->saved_regs, exit_trap_trapaddr);
/* Don't allow an interrupt and thus potentially another
* trap to be invoked while we hold the above mutex.
* This is probably just being paranoid. */
regs.intmask = 7;
//regs = context->saved_regs;
/* Set PC to address of the exit handler, so that it will be called
* when the 68k context resumes. */
copyfromcpucontext(&context->saved_regs, exit_trap_trapaddr);
/* Don't allow an interrupt and thus potentially another
* trap to be invoked while we hold the above mutex.
* This is probably just being paranoid. */
regs.intmask = 7;
//m68k_setpc (exit_trap_trapaddr);
current_context = context;
//m68k_setpc (exit_trap_trapaddr);
current_context = context;
/* Switch back to 68k context */
uae_sem_post (&context->switch_to_emu_sem);
/* Switch back to 68k context */
uae_sem_post (&context->switch_to_emu_sem);
/* Good bye, cruel world... */
/* Good bye, cruel world... */
/* dummy return value */
write_log("trap_thread: exit (arg=0x%08X)\n", arg);
return 0;
/* dummy return value */
write_log("trap_thread: exit (arg=0x%08X)\n", arg);
return nullptr;
}
/*
* Set up extended trap context and call handler function
*/
static void trap_HandleExtendedTrap (TrapHandler handler_func, int has_retval)
static void trap_HandleExtendedTrap(TrapHandler handler_func, int has_retval)
{
struct TrapContext *context = xcalloc (TrapContext, 1);
struct TrapContext* context = xcalloc (TrapContext, 1);
if (context)
{
uae_sem_init (&context->switch_to_trap_sem, 0, 0);
uae_sem_init (&context->switch_to_emu_sem, 0, 0);
if (context)
{
uae_sem_init(&context->switch_to_trap_sem, 0, 0);
uae_sem_init(&context->switch_to_emu_sem, 0, 0);
context->trap_handler = handler_func;
context->trap_has_retval = has_retval;
context->trap_handler = handler_func;
context->trap_has_retval = has_retval;
//context->saved_regs = regs;
copytocpucontext (&context->saved_regs);
//context->saved_regs = regs;
copytocpucontext(&context->saved_regs);
/* Start thread to handle new trap context. */
uae_start_thread_fast (trap_thread, (void *)context, &context->thread);
/* Start thread to handle new trap context. */
uae_start_thread_fast(trap_thread, static_cast<void *>(context), &context->thread);
/* Switch to trap context to begin execution of
* trap handler function.
*/
uae_sem_post (&context->switch_to_trap_sem);
/* Switch to trap context to begin execution of
* trap handler function.
*/
uae_sem_post (&context->switch_to_trap_sem);
/* Wait for trap context to switch back to us.
*
* It'll do this when the trap handler is done - or when
* the handler wants to call 68k code. */
uae_sem_wait (&context->switch_to_emu_sem);
}
/* Wait for trap context to switch back to us.
*
* It'll do this when the trap handler is done - or when
* the handler wants to call 68k code. */
uae_sem_wait (&context->switch_to_emu_sem);
}
}
/*
@ -337,191 +336,190 @@ static void trap_HandleExtendedTrap (TrapHandler handler_func, int has_retval)
*
* This function is to be called from the trap context.
*/
static uae_u32 trap_Call68k (TrapContext *context, uaecptr func_addr)
static uae_u32 trap_Call68k(TrapContext* context, uaecptr func_addr)
{
/* Enter critical section - only one trap at a time, please! */
uae_sem_wait (&trap_mutex);
current_context = context;
/* Enter critical section - only one trap at a time, please! */
uae_sem_wait (&trap_mutex);
current_context = context;
/* Don't allow an interrupt and thus potentially another
* trap to be invoked while we hold the above mutex.
* This is probably just being paranoid. */
regs.intmask = 7;
/* Don't allow an interrupt and thus potentially another
* trap to be invoked while we hold the above mutex.
* This is probably just being paranoid. */
regs.intmask = 7;
/* Set up function call address. */
context->call68k_func_addr = func_addr;
/* Set up function call address. */
context->call68k_func_addr = func_addr;
/* Set PC to address of 68k call trap, so that it will be
* executed when emulator context resumes. */
m68k_setpc (m68k_call_trapaddr);
fill_prefetch ();
/* Set PC to address of 68k call trap, so that it will be
* executed when emulator context resumes. */
m68k_setpc(m68k_call_trapaddr);
fill_prefetch();
/* Switch to emulator context. */
uae_sem_post (&context->switch_to_emu_sem);
/* Switch to emulator context. */
uae_sem_post (&context->switch_to_emu_sem);
/* Wait for 68k call return handler to switch back to us. */
uae_sem_wait (&context->switch_to_trap_sem);
/* Wait for 68k call return handler to switch back to us. */
uae_sem_wait (&context->switch_to_trap_sem);
/* End critical section. */
uae_sem_post (&trap_mutex);
/* End critical section. */
uae_sem_post (&trap_mutex);
/* Get return value from 68k function called. */
return context->call68k_retval;
/* Get return value from 68k function called. */
return context->call68k_retval;
}
/*
* Handles the emulator's side of a 68k call (from an extended trap)
*/
static uae_u32 REGPARAM2 m68k_call_handler (TrapContext *dummy_ctx)
static uae_u32 REGPARAM2 m68k_call_handler(TrapContext* dummy_ctx)
{
TrapContext *context = current_context;
TrapContext* context = current_context;
uae_u32 sp;
uae_u32 sp;
sp = m68k_areg (regs, 7);
sp = m68k_areg (regs, 7);
/* Push address of trap context on 68k stack. This is
* so the return trap can find this context. */
sp -= sizeof (void *);
put_pointer (sp, context);
/* Push address of trap context on 68k stack. This is
* so the return trap can find this context. */
sp -= sizeof (void *);
put_pointer (sp, context);
/* Push addr to return handler trap on 68k stack.
* When the called m68k function does an RTS, the CPU will pull this
* address off the stack and so call the return handler. */
sp -= 4;
put_long (sp, m68k_return_trapaddr);
/* Push addr to return handler trap on 68k stack.
* When the called m68k function does an RTS, the CPU will pull this
* address off the stack and so call the return handler. */
sp -= 4;
put_long(sp, m68k_return_trapaddr);
m68k_areg (regs, 7) = sp;
m68k_areg (regs, 7) = sp;
/* Set PC to address of 68k function to call. */
m68k_setpc (context->call68k_func_addr);
fill_prefetch ();
/* Set PC to address of 68k function to call. */
m68k_setpc(context->call68k_func_addr);
fill_prefetch();
/* End critical section: allow other traps run. */
uae_sem_post (&trap_mutex);
/* End critical section: allow other traps run. */
uae_sem_post (&trap_mutex);
/* Restore interrupts. */
regs.intmask = context->saved_regs.intmask;
/* Restore interrupts. */
regs.intmask = context->saved_regs.intmask;
/* Dummy return value. */
return 0;
/* Dummy return value. */
return 0;
}
/*
* Handles the return from a 68k call at the emulator's side.
*/
static uae_u32 REGPARAM2 m68k_return_handler (TrapContext *dummy_ctx)
static uae_u32 REGPARAM2 m68k_return_handler(TrapContext* dummy_ctx)
{
TrapContext *context;
uae_u32 sp;
TrapContext* context;
uae_u32 sp;
/* One trap returning at a time, please! */
uae_sem_wait (&trap_mutex);
/* One trap returning at a time, please! */
uae_sem_wait (&trap_mutex);
/* Get trap context from 68k stack. */
sp = m68k_areg (regs, 7);
context = (TrapContext *) get_pointer(sp);
sp += sizeof (void *);
m68k_areg (regs, 7) = sp;
/* Get trap context from 68k stack. */
sp = m68k_areg (regs, 7);
context = static_cast<TrapContext *>(get_pointer(sp));
sp += sizeof (void *);
m68k_areg (regs, 7) = sp;
/* Get return value from the 68k call. */
context->call68k_retval = m68k_dreg (regs, 0);
/* Get return value from the 68k call. */
context->call68k_retval = m68k_dreg (regs, 0);
/* Switch back to trap context. */
uae_sem_post (&context->switch_to_trap_sem);
/* Switch back to trap context. */
uae_sem_post (&context->switch_to_trap_sem);
/* Wait for trap context to switch back to us.
*
* It'll do this when the trap handler is done - or when
* the handler wants to call another 68k function. */
uae_sem_wait (&context->switch_to_emu_sem);
/* Wait for trap context to switch back to us.
*
* It'll do this when the trap handler is done - or when
* the handler wants to call another 68k function. */
uae_sem_wait (&context->switch_to_emu_sem);
/* Dummy return value. */
return 0;
/* Dummy return value. */
return 0;
}
/*
* Handles completion of an extended trap and passes
* return value from trap function to 68k space.
*/
static uae_u32 REGPARAM2 exit_trap_handler (TrapContext *dummy_ctx)
static uae_u32 REGPARAM2 exit_trap_handler(TrapContext* dummy_ctx)
{
TrapContext *context = current_context;
TrapContext* context = current_context;
/* Wait for trap context thread to exit. */
uae_wait_thread (context->thread);
/* Wait for trap context thread to exit. */
uae_wait_thread(context->thread);
/* Restore 68k state saved at trap entry. */
//regs = context->saved_regs;
copyfromcpucontext (&context->saved_regs, context->saved_regs.pc);
/* Restore 68k state saved at trap entry. */
//regs = context->saved_regs;
copyfromcpucontext(&context->saved_regs, context->saved_regs.pc);
/* If trap is supposed to return a value, then store
* return value in D0. */
if (context->trap_has_retval)
m68k_dreg (regs, 0) = context->trap_retval;
/* If trap is supposed to return a value, then store
* return value in D0. */
if (context->trap_has_retval)
m68k_dreg (regs, 0) = context->trap_retval;
uae_sem_destroy (&context->switch_to_trap_sem);
uae_sem_destroy (&context->switch_to_emu_sem);
uae_sem_destroy (&context->switch_to_trap_sem);
uae_sem_destroy (&context->switch_to_emu_sem);
xfree (context);
xfree (context);
/* End critical section */
uae_sem_post (&trap_mutex);
/* End critical section */
uae_sem_post (&trap_mutex);
/* Dummy return value. */
return 0;
/* Dummy return value. */
return 0;
}
/*
* Call a 68k library function from extended trap.
*/
uae_u32 CallLib (TrapContext *context, uaecptr base, uae_s16 offset)
uae_u32 CallLib(TrapContext* context, uaecptr base, uae_s16 offset)
{
uae_u32 retval;
uaecptr olda6 = m68k_areg (regs, 6);
uae_u32 retval;
uaecptr olda6 = m68k_areg (regs, 6);
m68k_areg (regs, 6) = base;
retval = trap_Call68k (context, base + offset);
m68k_areg (regs, 6) = olda6;
m68k_areg (regs, 6) = base;
retval = trap_Call68k(context, base + offset);
m68k_areg (regs, 6) = olda6;
return retval;
return retval;
}
/*
* Call 68k function from extended trap.
*/
uae_u32 CallFunc (TrapContext *context, uaecptr func)
uae_u32 CallFunc(TrapContext* context, uaecptr func)
{
return trap_Call68k (context, func);
return trap_Call68k(context, func);
}
/*
* Initialize trap mechanism.
*/
void init_traps (void)
void init_traps()
{
trap_count = 0;
trap_count = 0;
}
/*
* Initialize the extended trap mechanism.
*/
void init_extended_traps (void)
void init_extended_traps()
{
m68k_call_trapaddr = here ();
calltrap (deftrap2 (m68k_call_handler, TRAPFLAG_NO_RETVAL, _T("m68k_call")));
m68k_call_trapaddr = here();
calltrap(deftrap2 (m68k_call_handler, TRAPFLAG_NO_RETVAL, _T("m68k_call")));
m68k_return_trapaddr = here();
calltrap (deftrap2 (m68k_return_handler, TRAPFLAG_NO_RETVAL, _T("m68k_return")));
m68k_return_trapaddr = here();
calltrap(deftrap2 (m68k_return_handler, TRAPFLAG_NO_RETVAL, _T("m68k_return")));
exit_trap_trapaddr = here();
calltrap (deftrap2 (exit_trap_handler, TRAPFLAG_NO_RETVAL, _T("exit_trap")));
exit_trap_trapaddr = here();
calltrap(deftrap2 (exit_trap_handler, TRAPFLAG_NO_RETVAL, _T("exit_trap")));
if(trap_mutex != 0)
uae_sem_destroy(&trap_mutex);
trap_mutex = 0;
uae_sem_init (&trap_mutex, 0, 1);
if (trap_mutex != nullptr)
uae_sem_destroy(&trap_mutex);
trap_mutex = nullptr;
uae_sem_init(&trap_mutex, 0, 1);
}