1
0
mirror of https://github.com/rcornwell/sims.git synced 2026-01-11 23:52:48 +00:00

SCP: Updated to current.

This commit is contained in:
Richard Cornwell 2020-06-14 19:38:57 -04:00
parent 8886b113f8
commit 4b44a2d832
15 changed files with 429 additions and 173 deletions

View File

@ -125,7 +125,7 @@ struct color color_p29 = { p29, ELEMENTS(p29), 25000 };
/* green phosphor for Tek 611 */
static struct phosphor p31[] = {{0.0, 1.0, 0.77, 0.5, .1}};
struct color color_p31 = { p31, ELEMENTS(p31), 25000 };
struct color color_p31 = { p31, ELEMENTS(p31), 100000 };
/* green phosphor for III */
static struct phosphor p39[] = {{0.2, 1.0, 0.0, 0.5, 0.01}};
@ -251,7 +251,15 @@ static struct display displays[] = {
* III display
* on PDP-10
*/
{ DIS_III, "III Display", &color_p39, NULL, 1024, 1024 }
{ DIS_III, "III Display", &color_p39, NULL, 1024, 1024 },
/*
* Imlac display
* 1024x1024 addressable points.
* P31 phosphor according to "Heads-Up Display for Flight
* Simulator for Advanced Aircraft"
*/
{ DIS_IMLAC, "Imlac Display", &color_p31, NULL, 1024, 1024 }
};
/*

View File

@ -42,6 +42,7 @@ enum display_type {
* of the PDP-1, and thus all DEC machines.
*/
DIS_TX0 = 0,
DIS_IMLAC = 1,
DIS_VR14 = 14,
DIS_VR17 = 17,
DIS_VR20 = 20,

114
display/imlac.c Normal file
View File

@ -0,0 +1,114 @@
/* imlac.c: Imlac display interface.
Copyright (c) 2020, Lars Brinkhoff
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
LARS BRINKHOFF BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Lars Brinkhoff shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Lars Brinkhoff
*/
#include "display.h"
#include "imlac.h"
#if defined(__cplusplus)
extern "C" {
#endif
int imlac_init(void *dev, int debug)
{
return display_init (DIS_IMLAC, 1, dev);
}
void imlac_point (int x, int y)
{
display_point (x, y, DISPLAY_INT_MAX, 0);
}
int imlac_cycle(int us, int slowdown)
{
return display_age (us, slowdown);
}
#define ABS(_X) ((_X) >= 0 ? (_X) : -(_X))
#define SIGN(_X) ((_X) >= 0 ? 1 : -1)
static void
xline (int x, int y, int x2, int dx, int dy)
{
int ix = SIGN(dx);
int iy = SIGN(dy);
int ay;
dx = ABS(dx);
dy = ABS(dy);
ay = dy/2;
for (;;) {
imlac_point (x, y);
if (x == x2)
break;
if (ay > 0) {
y += iy;
ay -= dx;
}
ay += dy;
x += ix;
}
}
static void
yline (int x, int y, int y2, int dx, int dy)
{
int ix = SIGN(dx);
int iy = SIGN(dy);
int ax;
dx = ABS(dx);
dy = ABS(dy);
ax = dx/2;
for (;;) {
imlac_point (x, y);
if (y == y2)
break;
if (ax > 0) {
x += ix;
ax -= dy;
}
ax += dx;
y += iy;
}
}
void
imlac_line (int x1, int y1, int x2, int y2)
{
int dx = x2 - x1;
int dy = y2 - y1;
if (ABS (dx) > ABS(dy))
xline (x1, y1, x2, dx, dy);
else
yline (x1, y1, y2, dx, dy);
}
#if defined(__cplusplus)
}
#endif

38
display/imlac.h Normal file
View File

@ -0,0 +1,38 @@
/* imlac.h: Imlac display interface.
Copyright (c) 2020, Lars Brinkhoff.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
LARS BRINKHOFF BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Lars Brinkhoff shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Lars Brinkhoff
*/
#if defined(__cplusplus)
extern "C" {
#endif
extern int imlac_init(void *, int);
extern int imlac_cycle(int, int);
extern void imlac_point(int, int);
extern void imlac_line(int x1, int y1, int x2, int y2);
#if defined(__cplusplus)
}
#endif

View File

@ -109,6 +109,10 @@ ifneq (,$(findstring besm6,${MAKECMDGOALS}))
VIDEO_USEFUL = true
BESM6_BUILD = true
endif
# building the Imlac needs video support
ifneq (,$(findstring imlac,${MAKECMDGOALS}))
VIDEO_USEFUL = true
endif
# building the PDP6, KA10 or KI10 needs video support
ifneq (,$(or $(findstring pdp6,${MAKECMDGOALS}),$(findstring pdp10-ka,${MAKECMDGOALS}),$(findstring pdp10-ki,${MAKECMDGOALS})))
VIDEO_USEFUL = true
@ -153,6 +157,19 @@ endif
ifneq ($(NOVIDEO),)
VIDEO_USEFUL =
endif
ifneq ($(findstring Windows,${OS}),)
ifeq ($(findstring .exe,${SHELL}),.exe)
# MinGW
WIN32 := 1
# Tests don't run under MinGW
TESTS := 0
else # Msys or cygwin
ifeq (MINGW,$(findstring MINGW,$(shell uname)))
$(info *** This makefile can not be used with the Msys bash shell)
$(error Use build_mingw.bat ${MAKECMDGOALS} from a Windows command prompt)
endif
endif
endif
find_exe = $(abspath $(strip $(firstword $(foreach dir,$(strip $(subst :, ,${PATH})),$(wildcard $(dir)/$(1))))))
find_lib = $(abspath $(strip $(firstword $(foreach dir,$(strip ${LIBPATH}),$(wildcard $(dir)/lib$(1).${LIBEXT})))))
find_include = $(abspath $(strip $(firstword $(foreach dir,$(strip ${INCPATH}),$(wildcard $(dir)/$(1).h)))))
@ -162,17 +179,6 @@ ifneq (0,$(TESTS))
else
TESTING_FEATURES = - Per simulator tests will be skipped
endif
ifneq ($(findstring Windows,${OS}),)
ifeq ($(findstring .exe,${SHELL}),.exe)
# MinGW
WIN32 := 1
else # Msys or cygwin
ifeq (MINGW,$(findstring MINGW,$(shell uname)))
$(info *** This makefile can not be used with the Msys bash shell)
$(error Use build_mingw.bat ${MAKECMDGOALS} from a Windows command prompt)
endif
endif
endif
ifeq (${WIN32},) #*nix Environments (&& cygwin)
ifeq (${GCC},)
ifeq (,$(shell which gcc 2>/dev/null))
@ -256,8 +262,11 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin)
NEED_COMMIT_ID = need-commit-id
endif
ifeq (need-commit-id,$(NEED_COMMIT_ID))
ifneq (,$(shell git update-index --refresh --))
GIT_EXTRA_FILES=+uncommitted-changes
endif
isodate=$(shell git log -1 --pretty="%ai"|sed -e 's/ /T/'|sed -e 's/ //')
$(shell git log -1 --pretty="SIM_GIT_COMMIT_ID %H%nSIM_GIT_COMMIT_TIME $(isodate)" >.git-commit-id)
$(shell git log -1 --pretty="SIM_GIT_COMMIT_ID %H$(GIT_EXTRA_FILES)%nSIM_GIT_COMMIT_TIME $(isodate)" >.git-commit-id)
endif
endif
LTO_EXCLUDE_VERSIONS =
@ -596,6 +605,7 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin)
DISPLAY340 = ${DISPLAYD}/type340.c
DISPLAYNG = ${DISPLAYD}/ng.c
DISPLAYIII = ${DISPLAYD}/iii.c
DISPLAYIMLAC = ${DISPLAYD}/imlac.c
DISPLAY_OPT += -DUSE_DISPLAY $(VIDEO_CCDEFS) $(VIDEO_LDFLAGS)
$(info using libSDL2: $(call find_include,SDL2/SDL))
ifeq (Darwin,$(OSTYPE))
@ -992,7 +1002,10 @@ else
endif
ifeq (commit-id-exists,$(shell if exist .git-commit-id echo commit-id-exists))
CURRENT_GIT_COMMIT_ID=$(shell for /F "tokens=2" %%i in ("$(shell findstr /C:"SIM_GIT_COMMIT_ID" .git-commit-id)") do echo %%i)
ACTUAL_GIT_COMMIT_ID=$(strip $(shell git log -1 --pretty=%H))
ifneq (, $(shell git update-index --refresh --))
ACTUAL_GIT_COMMIT_EXTRAS=+uncommitted-changes
endif
ACTUAL_GIT_COMMIT_ID=$(strip $(shell git log -1 --pretty=%H))$(ACTUAL_GIT_COMMIT_EXTRAS)
ifneq ($(CURRENT_GIT_COMMIT_ID),$(ACTUAL_GIT_COMMIT_ID))
NEED_COMMIT_ID = need-commit-id
# make sure that the invalidly formatted .git-commit-id file wasn't generated
@ -1005,11 +1018,13 @@ else
NEED_COMMIT_ID = need-commit-id
endif
ifeq (need-commit-id,$(NEED_COMMIT_ID))
commit_id=$(shell git log -1 --pretty=%H)
ifneq (, $(shell git update-index --refresh --))
ACTUAL_GIT_COMMIT_EXTRAS=+uncommitted-changes
endif
ACTUAL_GIT_COMMIT_ID=$(strip $(shell git log -1 --pretty=%H))$(ACTUAL_GIT_COMMIT_EXTRAS)
isodate=$(shell git log -1 --pretty=%ai)
commit_time=$(word 1,$(isodate))T$(word 2,$(isodate))$(word 3,$(isodate))
$(shell echo SIM_GIT_COMMIT_ID $(commit_id)>.git-commit-id)
$(shell echo SIM_GIT_COMMIT_TIME $(commit_time)>>.git-commit-id)
$(shell echo SIM_GIT_COMMIT_ID $(ACTUAL_GIT_COMMIT_ID)>.git-commit-id)
endif
endif
ifneq (,$(shell if exist .git-commit-id echo git-commit-id))
@ -1935,13 +1950,11 @@ ifneq (,$(BESM6_BUILD))
endif
else
ifneq (,$(and $(findstring Linux,$(OSTYPE)),$(call find_exe,apt-get)))
$(info *** Info *** Install the development components of libSDL-ttf or libSDL2-ttf)
$(info *** Info *** Install the development components of libSDL2-ttf)
$(info *** Info *** packaged for your Linux operating system distribution:)
$(info *** Info *** $$ sudo apt-get install libsdl2-ttf-dev)
$(info *** Info *** or)
$(info *** Info *** $$ sudo apt-get install libsdl-ttf-dev)
else
$(info *** Info *** Install the development components of libSDL-ttf packaged by your)
$(info *** Info *** Install the development components of libSDL2-ttf packaged by your)
$(info *** Info *** operating system distribution and rebuild your simulator to)
$(info *** Info *** enable this extra functionality.)
endif
@ -1951,10 +1964,6 @@ ifneq (,$(BESM6_BUILD))
$(info using libSDL2_ttf: $(call find_lib,SDL2_ttf) $(call find_include,SDL2/SDL_ttf))
$(info ***)
BESM6_PANEL_OPT = -DFONTFILE=${FONTFILE} ${VIDEO_CCDEFS} ${VIDEO_LDFLAGS} -lSDL2_ttf
else ifneq (,$(and $(call find_include,SDL/SDL_ttf),$(call find_lib,SDL_ttf)))
$(info using libSDL_ttf: $(call find_lib,SDL_ttf) $(call find_include,SDL/SDL_ttf))
$(info ***)
BESM6_PANEL_OPT = -DFONTFILE=${FONTFILE} ${VIDEO_CCDEFS} ${VIDEO_LDFLAGS} -lSDL_ttf
endif
endif

30
scp.c
View File

@ -6221,8 +6221,12 @@ if (flag) {
#if defined(SIM_GIT_COMMIT_ID)
#define S_xstr(a) S_str(a)
#define S_str(a) #a
fprintf (st, "%sgit commit id: %8.8s", flag ? "\n " : " ", S_xstr(SIM_GIT_COMMIT_ID));
setenv ("SIM_GIT_COMMIT_ID", S_xstr(SIM_GIT_COMMIT_ID), 1);
if (1) {
const char *extras = strchr (S_xstr(SIM_GIT_COMMIT_ID), '+');
fprintf (st, "%sgit commit id: %8.8s%s", flag ? "\n " : " ", S_xstr(SIM_GIT_COMMIT_ID), extras ? extras : "");
setenv ("SIM_GIT_COMMIT_ID", S_xstr(SIM_GIT_COMMIT_ID), 1);
}
#if defined(SIM_GIT_COMMIT_TIME)
setenv ("SIM_GIT_COMMIT_TIME", S_xstr(SIM_GIT_COMMIT_TIME), 1);
if (flag)
@ -8510,12 +8514,8 @@ if (signal (SIGTERM, int_handler) == SIG_ERR) { /* set WRU */
sim_ttcmd ();
return r;
}
if (sim_step) { /* set step timer */
if (sim_switches & SWMASK ('T')) /* stepping for elapsed time? */
sim_activate_after (&sim_step_unit, (uint32)sim_step);/* wall clock based step */
else
sim_activate (&sim_step_unit, sim_step); /* instruction based step */
}
if (sim_step) /* set step timer */
sim_sched_step ();
sim_activate_after (&sim_flush_unit, FLUSH_INTERVAL); /* Enable periodic buffer flushing */
stop_cpu = FALSE;
sim_is_running = TRUE; /* flag running */
@ -8565,7 +8565,7 @@ do {
else
sim_step = 1;
if (sim_step) /* set step timer */
sim_activate (&sim_step_unit, sim_step);
sim_sched_step ();
} while (1);
if ((SCPE_BARE_STATUS(r) == SCPE_STOP) &&
@ -8593,7 +8593,7 @@ signal (SIGHUP, SIG_DFL); /* cancel WRU */
signal (SIGTERM, SIG_DFL); /* cancel WRU */
sim_flush_buffered_files();
sim_cancel (&sim_flush_unit); /* cancel flush timer */
sim_cancel (&sim_step_unit); /* cancel step timer */
sim_cancel_step (); /* cancel step timer */
sim_throt_cancel (); /* cancel throttle */
AIO_UPDATE_QUEUE;
UPDATE_SIM_TIME; /* update sim time */
@ -8732,6 +8732,16 @@ t_stat sim_cancel_step (void)
return sim_cancel (&sim_step_unit);
}
/* schedule step service */
t_stat sim_sched_step (void)
{
if (sim_switches & SWMASK ('T')) /* stepping for elapsed time? */
return sim_activate_after_abs (&sim_step_unit, (uint32)sim_step);/* wall clock based step */
else
return sim_activate_abs (&sim_step_unit, sim_step); /* instruction based step */
}
/* Signal handler for ^C signal - set stop simulation flag */
void int_handler (int sig)

1
scp.h
View File

@ -318,6 +318,7 @@ t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST cha
t_stat sim_add_debug_flags (DEVICE *dptr, DEBTAB *debflags);
const char *sim_error_text (t_stat stat);
t_stat sim_string_to_stat (const char *cptr, t_stat *cond);
t_stat sim_sched_step (void);
t_stat sim_cancel_step (void);
void sim_printf (const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void sim_perror (const char *msg);

View File

@ -39,7 +39,7 @@
*/
struct ROM_File_Descriptor {
const char *BinaryName; const char *IncludeFileName; size_t expected_size; unsigned int checksum; const char *ArrayName; const char *Comments;} ROMs[] = {
{"VAX/ka655x.bin", "VAX/vax_ka655x_bin.h", 131072, 0xFF7672D5, "vax_ka655x_bin"},
{"VAX/ka655x.bin", "VAX/vax_ka655x_bin.h", 131072, 0xFF7673B6, "vax_ka655x_bin"},
{"VAX/ka620.bin", "VAX/vax_ka620_bin.h", 65536, 0xFF7F930F, "vax_ka620_bin"},
{"VAX/ka630.bin", "VAX/vax_ka630_bin.h", 65536, 0xFF7F73EF, "vax_ka630_bin"},
{"VAX/ka610.bin", "VAX/vax_ka610_bin.h", 16384, 0xFFEF3312, "vax_ka610_bin"},

View File

@ -183,7 +183,7 @@ int32 sim_del_char = '\b'; /* delete character */
int32 sim_del_char = 0177;
#endif
t_bool sim_signaled_int_char /* WRU character detected by signal while running */
#if defined (_WIN32) || defined (_VMS) || defined (__CYGWIN__)
#if defined (_WIN32) || defined (_VMS) || defined (__CYGWIN__) || (defined(USE_SIM_VIDEO) && defined(HAVE_LIBSDL))
= FALSE;
#else
= TRUE;
@ -1405,7 +1405,8 @@ for (i=(was_active_command ? sim_rem_cmd_active_line : 0);
sim_rem_cmd_active_line = -1; /* Done with active command */
if (!sim_rem_active_command) { /* STEP command? */
stat = SCPE_STEP;
_sim_rem_message ("STEP", stat); /* produce a STEP complete message */
if (sim_con_stable_registers || !sim_rem_master_mode)
_sim_rem_message ("STEP", stat);/* produce a STEP complete message */
}
_sim_rem_log_out (lp);
sim_rem_active_command = NULL; /* Restart loop to process available input */
@ -1840,8 +1841,14 @@ if (sim_rem_master_was_connected && /* Master mode ever
!sim_rem_con_tmxr.ldsc[0].sock) /* Master Connection lost? */
return sim_messagef (SCPE_EXIT, "Master Session Disconnect");/* simulator has been 'unplugged' */
if (sim_rem_cmd_active_line != -1) {
if (steps)
sim_activate(uptr, steps); /* check again after 'steps' instructions */
if (steps) {
if (!sim_con_stable_registers && sim_rem_master_mode) {
sim_step = steps;
sim_sched_step ();
}
else
sim_activate(uptr, steps); /* check again after 'steps' instructions */
}
else
return SCPE_REMOTE; /* force sim_instr() to exit to process command */
}
@ -2065,8 +2072,11 @@ if (sim_rem_master_mode) {
}
sim_rem_cmd_active_line = 0; /* Make it look like */
sim_rem_consoles[0].single_mode = FALSE;
sim_cancel_step ();
if (stat != SCPE_STEP)
sim_rem_active_command = &allowed_single_remote_cmds[0];/* Dummy */
else
sim_activate_abs (rem_con_data_unit, 0); /* force step completion processing */
sim_last_cmd_stat = SCPE_BARE_STATUS(stat); /* make exit status available to remote console */
}
sim_rem_master_was_enabled = FALSE;

View File

@ -3990,26 +3990,31 @@ return FALSE;
static t_stat sim_os_disk_rdsect (UNIT *uptr, t_lba lba, uint8 *buf, t_seccnt *sectsread, t_seccnt sects)
{
*sectsread = 0;
return SCPE_NOFNC;
}
static t_stat sim_os_disk_read (UNIT *uptr, t_offset addr, uint8 *buf, uint32 *bytesread, uint32 bytes)
{
*bytesread = 0;
return SCPE_NOFNC;
}
static t_stat sim_os_disk_wrsect (UNIT *uptr, t_lba lba, uint8 *buf, t_seccnt *sectswritten, t_seccnt sects)
{
*sectswritten = 0;
return SCPE_NOFNC;
}
static t_stat sim_os_disk_write (UNIT *uptr, t_offset addr, uint8 *buf, uint32 *byteswritten, uint32 bytes)
{
*byteswritten = 0;
return SCPE_NOFNC;
}
static t_stat sim_os_disk_info_raw (FILE *f, uint32 *sector_size, uint32 *removable, uint32 *is_cdrom)
{
*sector_size = *removable = *is_cdrom = 0;
return SCPE_NOFNC;
}
@ -4069,6 +4074,7 @@ return (t_offset)-1;
static t_stat sim_vhd_disk_rdsect (UNIT *uptr, t_lba lba, uint8 *buf, t_seccnt *sectsread, t_seccnt sects)
{
*sectsread = 0;
return SCPE_IOERR;
}
@ -4079,6 +4085,7 @@ return SCPE_IOERR;
static t_stat sim_vhd_disk_wrsect (UNIT *uptr, t_lba lba, uint8 *buf, t_seccnt *sectswritten, t_seccnt sects)
{
*sectswritten = 0;
return SCPE_IOERR;
}
@ -4089,6 +4096,7 @@ return SCPE_NOFNC;
static const char *sim_vhd_disk_get_dtype (FILE *f, uint32 *SectorSize, uint32 *xfer_element_size, char sim_name[64], time_t *creation_time)
{
*SectorSize = *xfer_element_size = 0;
return NULL;
}

View File

@ -56,7 +56,7 @@
Supported/Tested Platforms:
Windows(NT,2K,XP,2K3,Vista,Win7) WinPcap V3.0+
Windows(NT,2K,XP,2K3,Vista,Win7) WinPcap-4.1.3 Npcap-V0.9994
Linux libpcap at least 0.9
OpenBSD,FreeBSD,NetBSD libpcap at least 0.9
MAC OS/X libpcap at least 0.9
@ -67,8 +67,11 @@
Compaq Tru64 Unix ??
VMS Alpha/Itanium VMS only, needs VMS libpcap
WinPcap is available from:
WinPcap is no longer developed or supported by was available from:
http://winpcap.polito.it/
Npcap is a complete replacement for systems running Windows7 and later
and is available from:
https://nmap.org/npcap
libpcap for VMS is available from:
http://simh.trailing-edge.com/sources/vms-pcap.zip
libpcap for other Unix platforms is available at:
@ -82,8 +85,9 @@
Current Version: http://www.tcpdump.org/daily/libpcap-current.tar.gz
Released Version: http://www.tcpdump.org/release/
When necessary (see NOTE above about vendor supplied libpcap),
we've gotten the tarball, unpacked, built and installed it with:
When absolutely necessary (see NOTE above about vendor supplied
libpcap), we've gotten the tarball, unpacked, built and installed
it with:
gzip -dc libpcap-current.tar.gz | tar xvf -
cd libpcap-directory-name
./configure

View File

@ -144,7 +144,7 @@ struct tape_context {
uint32 dbit; /* debugging bit for trace */
uint32 auto_format; /* Format determined dynamically */
#if defined SIM_ASYNCH_IO
int asynch_io; /* Asynchronous Interrupt scheduling enabled */
t_bool asynch_io; /* Asynchronous Interrupt scheduling enabled */
int asynch_io_latency; /* instructions to delay pending interrupt */
pthread_mutex_t lock;
pthread_t io_thread; /* I/O Thread Id */
@ -173,7 +173,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; \
\
if (ctx == NULL) \
return sim_messagef (SCPE_IERR, "Bad Attach\n"); \
if ((!callback) || !ctx->asynch_io)
if ((callback == NULL) || !(ctx->asynch_io))
#define AIO_CALL(op, _buf, _bc, _fc, _max, _vbc, _gaplen, _bpi, _obj, _callback)\
if (ctx->asynch_io) { \
@ -589,7 +589,7 @@ if (!ctx) return SCPE_UNATT;
if (ctx->asynch_io) {
pthread_mutex_lock (&ctx->io_lock);
ctx->asynch_io = 0;
ctx->asynch_io = FALSE;
pthread_cond_signal (&ctx->io_cond);
pthread_mutex_unlock (&ctx->io_lock);
pthread_join (ctx->io_thread, NULL);
@ -636,7 +636,7 @@ DEVICE *dptr;
if ((dptr = find_dev_from_unit (uptr)) == NULL)
return SCPE_NOATT;
return sim_tape_attach_ex (uptr, cptr, ((dptr->flags & DEV_DEBUG) || (dptr->debflags)) ? MTSE_DBG_API : 0, 0);
return sim_tape_attach_ex (uptr, cptr, ((dptr->flags & DEV_DEBUG) || (dptr->debflags != NULL)) ? MTSE_DBG_API : 0, 0);
}
t_stat sim_tape_attach_ex (UNIT *uptr, const char *cptr, uint32 dbit, int completion_delay)
@ -704,7 +704,7 @@ switch (MT_GET_FMT (uptr)) {
}
tape = ansi_create_tape (label, uptr->recsize, MT_GET_ANSI_TYP (uptr));
uptr->fileref = (FILE *)tape;
if (!uptr->fileref)
if (uptr->fileref == NULL)
return SCPE_MEM;
while (*cptr != 0) { /* do all mods */
uint32 initial_file_count = tape->file_count;
@ -761,7 +761,7 @@ switch (MT_GET_FMT (uptr)) {
tape = memory_create_tape ();
uptr->fileref = (FILE *)tape;
if (!uptr->fileref)
if (uptr->fileref == NULL)
return SCPE_MEM;
f = fopen (cptr, "rb");
if (f == NULL) {
@ -769,7 +769,7 @@ switch (MT_GET_FMT (uptr)) {
break;
}
tape_classify_file_contents (f, &max_record_size, &lf_line_endings, &crlf_line_endings);
if ((!lf_line_endings) && (!crlf_line_endings)) { /* binary file? */
if (!lf_line_endings && !crlf_line_endings) { /* binary file? */
if (uptr->recsize == 0) {
r = sim_messagef (SCPE_ARG, "Binary file %s must specify a record size with -B\n", cptr);
fclose (f);
@ -804,7 +804,7 @@ switch (MT_GET_FMT (uptr)) {
if (sim_switches & SWMASK ('C')) {
uint32 i;
for (i=0; i<uptr->recsize; i++)
for (i = 0; i < uptr->recsize; i++)
block[i] = ascii2ebcdic[block[i]];
}
error = memory_tape_add_block (tape, block, uptr->recsize);
@ -835,7 +835,7 @@ switch (MT_GET_FMT (uptr)) {
tape = memory_create_tape();
tape->block_size = uptr->recsize;
uptr->fileref = (FILE *)tape;
if (!uptr->fileref)
if (uptr->fileref == NULL)
return SCPE_MEM;
while (*cptr != 0) {
@ -1017,11 +1017,11 @@ return SCPE_OK;
t_stat sim_tape_attach_help(FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr)
{
fprintf (st, "%s Tape Attach Help\n\n", dptr->name);
if (0 == (uptr-dptr->units)) {
if (0 == (uptr - dptr->units)) {
if (dptr->numunits > 1) {
uint32 i;
for (i=0; i < dptr->numunits; ++i)
for (i = 0; i < dptr->numunits; ++i)
if (dptr->units[i].flags & UNIT_ATTABLE)
fprintf (st, " sim> ATTACH {switches} %s%d tapefile\n\n", dptr->name, i);
}
@ -1499,7 +1499,7 @@ switch (f) { /* otherwise the read method
if (1) {
MEMORY_TAPE *tape = (MEMORY_TAPE *)uptr->fileref;
if (uptr->pos >= tape->record_count)
if (uptr->pos >= tape->record_count)
status = MTSE_EOM;
else {
if (tape->records[uptr->pos]->size == 0)
@ -4306,7 +4306,7 @@ static void ansi_make_HDR2 (HDR2 *hdr, t_bool fixed_record, size_t block_size, s
hdr->record_format = ansi->record_format ? ansi->record_format : (fixed_record ? 'F' : 'D');
sprintf (size, "%05d", (int)block_size);
memcpy (hdr->block_length, size, sizeof (hdr->block_length));
sprintf (size, "%05d", (ansi->zero_record_length)? 0 : (int)record_size);
sprintf (size, "%05d", (ansi->zero_record_length) ? 0 : (int)record_size);
memcpy (hdr->record_length, size, sizeof (hdr->record_length));
hdr->carriage_control = ansi->carriage_control ? ansi->carriage_control : (fixed_record ? 'M' : ' ');
memcpy (hdr->buffer_offset, "00", 2);
@ -4399,7 +4399,7 @@ static void memory_free_tape (void *vtape)
uint32 i;
MEMORY_TAPE *tape = (MEMORY_TAPE *)vtape;
for (i=0; i<tape->record_count; i++) {
for (i = 0; i < tape->record_count; i++) {
free (tape->records[i]);
tape->records[i] = NULL;
}
@ -4530,7 +4530,7 @@ while (year >= 2000)
today = ((year - 70) * 1000) + tm->tm_yday + 1;
sprintf (FullPath, "%s%s", directory, filename);
f = tape_open_and_check_file(FullPath);
f = tape_open_and_check_file (FullPath);
if (f == NULL)
return;
@ -4588,7 +4588,7 @@ memory_tape_add_block (tape, NULL, 0);
++tape->file_count;
}
static FILE *tape_open_and_check_file(const char *filename)
static FILE *tape_open_and_check_file (const char *filename)
{
FILE *file = fopen(filename, "rb");
@ -4621,7 +4621,7 @@ long last_cr = -1;
long last_lf = -1;
long line_start = 0;
int chr;
long non_print_chars = 0;
t_bool non_print_chars = FALSE;
long lf_lines = 0;
long crlf_lines = 0;
@ -4631,8 +4631,10 @@ long crlf_lines = 0;
rewind (f);
while (EOF != (chr = fgetc (f))) {
++pos;
if (!isprint (chr) && (chr != '\r') && (chr != '\n') && (chr != '\t') && (chr != '\f'))
++non_print_chars;
if (!isprint (chr) && (chr != '\r') && (chr != '\n') && (chr != '\t') && (chr != '\f')) {
non_print_chars = TRUE;
break;
}
if (chr == '\r')
last_cr = pos;
if (chr == '\n') {
@ -4700,7 +4702,7 @@ HDR2 hdr2;
HDR3 hdr3;
HDR4 hdr4;
f = tape_open_and_check_file(filename);
f = tape_open_and_check_file (filename);
if (f == NULL)
return TRUE;
@ -4712,22 +4714,22 @@ if (ansi->fixed_text)
max_record_size = 512;
ansi_make_HDR2 (&hdr2, !lf_line_endings && !crlf_line_endings, tape->block_size, max_record_size, tape->ansi_type);
if (!ansi->nohdr3) { /* Need HDR3? */
if (!(ansi->nohdr3)) { /* Need HDR3? */
if (!lf_line_endings && !crlf_line_endings) /* Binary File? */
memcpy (&hdr3, ansi->hdr3_fixed, sizeof (hdr3));
else { /* Text file */
if ((lf_line_endings) && !(ansi->fixed_text))
if (lf_line_endings && !(ansi->fixed_text))
memcpy (&hdr3, ansi->hdr3_lf_line_endings, sizeof (hdr3));
else
memcpy (&hdr3, ansi->hdr3_crlf_line_endings, sizeof (hdr3));
}
}
memory_tape_add_block (tape, (uint8 *)&hdr1, sizeof (hdr1));
if (!ansi->nohdr2)
if (!(ansi->nohdr2))
memory_tape_add_block (tape, (uint8 *)&hdr2, sizeof (hdr2));
if (!ansi->nohdr3)
if (!(ansi->nohdr3))
memory_tape_add_block (tape, (uint8 *)&hdr3, sizeof (hdr3));
if ((0 != memcmp (hdr4.extra_name_used, "00", 2)) && !ansi->nohdr3 && !ansi->nohdr2)
if ((0 != memcmp (hdr4.extra_name_used, "00", 2)) && !(ansi->nohdr3) && !(ansi->nohdr2))
memory_tape_add_block (tape, (uint8 *)&hdr4, sizeof (hdr4));
memory_tape_add_block (tape, NULL, 0); /* Tape Mark */
rewind (f);
@ -4757,11 +4759,11 @@ memcpy (hdr4.type, "EOF", sizeof (hdr4.type));
sprintf (block_count_string, "%06d", block_count);
memcpy (hdr1.block_count, block_count_string, sizeof (hdr1.block_count));
memory_tape_add_block (tape, (uint8 *)&hdr1, sizeof (hdr1));
if (!ansi->nohdr2)
if (!(ansi->nohdr2))
memory_tape_add_block (tape, (uint8 *)&hdr2, sizeof (hdr2));
if (!ansi->nohdr3)
if (!(ansi->nohdr3))
memory_tape_add_block (tape, (uint8 *)&hdr3, sizeof (hdr3));
if ((0 != memcmp (hdr4.extra_name_used, "00", 2)) && !ansi->nohdr3 && !ansi->nohdr2)
if ((0 != memcmp (hdr4.extra_name_used, "00", 2)) && !(ansi->nohdr3) && !(ansi->nohdr2))
memory_tape_add_block (tape, (uint8 *)&hdr4, sizeof (hdr4));
memory_tape_add_block (tape, NULL, 0); /* Tape Mark */
if (sim_switches & SWMASK ('V'))

View File

@ -1620,9 +1620,9 @@ if ((lp->modembits != before_modem_bits) && (sim_deb && lp->mp && dptr)) {
sim_debug (TMXR_DBG_MDM, dptr, " - Line %d - %p\n", (int)(lp-lp->mp->ldsc), lp->txb);
}
if (incoming_bits)
*incoming_bits = lp->modembits;
*incoming_bits = (lp->modembits & TMXR_MDM_INCOMING);
if (lp->mp && lp->modem_control) { /* This API ONLY works on modem_control enabled multiplexer lines */
if (bits_to_set | bits_to_clear) { /* Anything to do? */
if ((bits_to_set | bits_to_clear) || incoming_bits) {/* Anything to do? */
if (lp->loopback) {
if ((lp->modembits ^ before_modem_bits) & TMXR_MDM_DTR) { /* DTR changed? */
lp->ser_connect_pending = (lp->modembits & TMXR_MDM_DTR);
@ -1630,8 +1630,12 @@ if (lp->mp && lp->modem_control) { /* This API ONLY works on mo
}
return SCPE_OK;
}
if (lp->serport)
return sim_control_serial (lp->serport, bits_to_set, bits_to_clear, incoming_bits);
if (lp->serport) {
t_stat r = sim_control_serial (lp->serport, bits_to_set, bits_to_clear, incoming_bits);
if (incoming_bits && (r == SCPE_OK))
lp->modembits = (lp->modembits & ~TMXR_MDM_INCOMING) | *incoming_bits;
return r;
}
if ((lp->sock) || (lp->connecting)) {
if ((before_modem_bits & bits_to_clear & TMXR_MDM_DTR) != 0) { /* drop DTR? */
if (lp->sock)

View File

@ -88,6 +88,11 @@ t_stat vid_show (FILE* st, DEVICE *dptr, UNIT* uptr, int32 val, CONST char* des
return vid_show_video (st, uptr, val, desc);
}
static const char *vid_dname (DEVICE *dev)
{
return dev ? sim_dname(dev) : "Video Device";
}
#if defined(USE_SIM_VIDEO) && defined(HAVE_LIBSDL)
char vid_release_key[64] = "Ctrl-Right-Shift";
@ -349,6 +354,8 @@ t_bool vid_ready;
char vid_title[128];
static void vid_beep_setup (int duration_ms, int tone_frequency);
static void vid_beep_cleanup (void);
static void vid_controllers_setup (void);
static void vid_controllers_cleanup (void);
t_bool vid_key_state[SDL_NUM_SCANCODES];
SDL_Texture *vid_texture; /* video buffer in GPU */
SDL_Renderer *vid_renderer;
@ -356,6 +363,7 @@ SDL_Window *vid_window; /* window handle */
SDL_PixelFormat *vid_format;
uint32 vid_windowID;
SDL_Thread *vid_thread_handle = NULL; /* event thread handle */
SDL_mutex *vid_draw_mutex = NULL; /* window update mutex */
SDL_Cursor *vid_cursor = NULL; /* current cursor */
t_bool vid_cursor_visible = FALSE; /* cursor visibility state */
KEY_EVENT_QUEUE vid_key_events; /* keyboard events */
@ -398,14 +406,17 @@ SDL_SetHint (SDL_HINT_RENDER_DRIVER, "software");
status = SDL_Init (SDL_INIT_VIDEO);
vid_main_thread_handle = SDL_CreateThread (main_thread , "simh-main", NULL);
if (status) {
fprintf (stderr, "SDL Video subsystem can't initialize\n");
fprintf (stderr, "SDL Video subsystem can't initialize: %s\n", SDL_GetError ());
exit (1);
}
sim_os_set_thread_priority (PRIORITY_ABOVE_NORMAL);
vid_main_thread_handle = SDL_CreateThread (main_thread , "simh-main", NULL);
if (vid_main_thread_handle == NULL) {
fprintf (stderr, "SDL_CreateThread failed: %s\n", SDL_GetError ());
exit (1);
}
vid_beep_setup (400, 660);
@ -424,12 +435,8 @@ while (1) {
if (event.user.code == EVENT_SCREENSHOT)
vid_screenshot_event ();
else {
if (event.user.code == EVENT_BEEP)
vid_beep_event ();
else {
sim_printf ("main(): Unexpected User event: %d\n", event.user.code);
break;
}
sim_printf ("main(): Unexpected User event: %d\n", event.user.code);
break;
}
}
}
@ -489,67 +496,78 @@ return SCPE_OK;
}
#endif
static t_stat vid_init_controllers (void)
static void vid_controllers_setup (void)
{
SDL_Joystick *y;
SDL_version ver;
int i, n;
SDL_Joystick *y;
SDL_version ver;
int i, n;
if (vid_gamepad_inited)
return SCPE_OK;
if (vid_gamepad_inited++)
return;
/* Chech that the SDL_GameControllerFromInstanceID function is
available at run time. */
SDL_GetVersion(&ver);
vid_gamepad_ok = (ver.major > 2 ||
(ver.major == 2 && (ver.minor > 0 || ver.patch >= 4)));
/* Chech that the SDL_GameControllerFromInstanceID function is
available at run time. */
SDL_GetVersion(&ver);
vid_gamepad_ok = (ver.major > 2 ||
(ver.major == 2 && (ver.minor > 0 || ver.patch >= 4)));
if (vid_gamepad_ok)
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
else
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
if (SDL_JoystickEventState (SDL_ENABLE) < 0) {
if (vid_gamepad_ok)
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
else
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
sim_printf ("%s: vid_controllers_setup(): SDL_JoystickEventState error: %s\n", vid_dname(vid_dev), SDL_GetError());
return;
}
if (SDL_JoystickEventState (SDL_ENABLE) < 0) {
if (vid_gamepad_ok)
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
else
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
return SCPE_IOERR;
}
if (vid_gamepad_ok && SDL_GameControllerEventState (SDL_ENABLE) < 0) {
if (vid_gamepad_ok)
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
else
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
sim_printf ("%s: vid_controllers_setup(): SDL_GameControllerEventState error: %s\n", vid_dname(vid_dev), SDL_GetError());
return;
}
if (vid_gamepad_ok && SDL_GameControllerEventState (SDL_ENABLE) < 0) {
if (vid_gamepad_ok)
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
else
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
return SCPE_IOERR;
}
n = SDL_NumJoysticks();
n = SDL_NumJoysticks();
for (i = 0; i < n; i++) {
if (vid_gamepad_ok && SDL_IsGameController (i)) {
SDL_GameController *x = SDL_GameControllerOpen (i);
if (x != NULL) {
sim_debug (SIM_VID_DBG_VIDEO, vid_dev,
"Game controller: %s\n", SDL_GameControllerNameForIndex(i));
}
}
else {
y = SDL_JoystickOpen (i);
if (y != NULL) {
sim_debug (SIM_VID_DBG_VIDEO, vid_dev,
"Joystick: %s\n", SDL_JoystickNameForIndex(i));
sim_debug (SIM_VID_DBG_VIDEO, vid_dev,
"Number of axes: %d, buttons: %d\n",
SDL_JoystickNumAxes(y),
SDL_JoystickNumButtons(y));
}
for (i = 0; i < n; i++) {
if (vid_gamepad_ok && SDL_IsGameController (i)) {
SDL_GameController *x = SDL_GameControllerOpen (i);
if (x != NULL) {
sim_debug (SIM_VID_DBG_VIDEO, vid_dev,
"Game controller: %s\n", SDL_GameControllerNameForIndex(i));
}
}
else {
y = SDL_JoystickOpen (i);
if (y != NULL) {
sim_debug (SIM_VID_DBG_VIDEO, vid_dev,
"Joystick: %s\n", SDL_JoystickNameForIndex(i));
sim_debug (SIM_VID_DBG_VIDEO, vid_dev,
"Number of axes: %d, buttons: %d\n",
SDL_JoystickNumAxes(y),
SDL_JoystickNumButtons(y));
}
}
}
}
vid_gamepad_inited = 1;
return SCPE_OK;
static void vid_controllers_cleanup (void)
{
if (0 == (--vid_gamepad_inited)) {
memset (motion_callback, 0, sizeof motion_callback);
memset (button_callback, 0, sizeof button_callback);
if (vid_gamepad_ok)
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
else
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}
}
t_stat vid_open (DEVICE *dptr, const char *title, uint32 width, uint32 height, int flags)
@ -587,11 +605,6 @@ if (!vid_active) {
if (stat != SCPE_OK)
return stat;
if (vid_init_controllers () != SCPE_OK) {
sim_debug (SIM_VID_DBG_VIDEO, vid_dev,
"vid_open() - Failed initializing game controllers\n");
}
sim_debug (SIM_VID_DBG_VIDEO|SIM_VID_DBG_KEY|SIM_VID_DBG_MOUSE, vid_dev, "vid_open() - Success\n");
}
return SCPE_OK;
@ -603,15 +616,7 @@ if (vid_active) {
SDL_Event user_event;
int status;
vid_gamepad_inited = 0;
memset (motion_callback, 0, sizeof motion_callback);
memset (button_callback, 0, sizeof button_callback);
if (vid_gamepad_ok)
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
else
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
vid_active = FALSE;
vid_active = FALSE; /* Signal rendering thread we'd like to exit */
if (vid_ready) {
sim_debug (SIM_VID_DBG_VIDEO|SIM_VID_DBG_KEY|SIM_VID_DBG_MOUSE, vid_dev, "vid_close()\n");
user_event.type = SDL_USEREVENT;
@ -629,6 +634,7 @@ if (vid_active) {
}
while (vid_ready)
sim_os_ms_sleep (10);
if (vid_mouse_events.sem) {
SDL_DestroySemaphore(vid_mouse_events.sem);
vid_mouse_events.sem = NULL;
@ -684,7 +690,7 @@ if (SDL_SemTryWait (vid_mouse_events.sem) == 0) {
}
}
if (SDL_SemPost (vid_mouse_events.sem))
sim_printf ("%s: vid_poll_mouse(): SDL_SemPost error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: vid_poll_mouse(): SDL_SemPost error: %s\n", vid_dname(vid_dev), SDL_GetError());
}
return stat;
}
@ -694,6 +700,9 @@ uint32 vid_map_rgb (uint8 r, uint8 g, uint8 b)
return SDL_MapRGB (vid_format, r, g, b);
}
static SDL_Rect *vid_dst_last;
static uint32 *vid_data_last;
void vid_draw (int32 x, int32 y, int32 w, int32 h, uint32 *buf)
{
SDL_Event user_event;
@ -702,9 +711,19 @@ uint32 *vid_data;
sim_debug (SIM_VID_DBG_VIDEO, vid_dev, "vid_draw(%d, %d, %d, %d)\n", x, y, w, h);
SDL_LockMutex (vid_draw_mutex); /* Synchronize to check region dimensions */
if (vid_dst_last && /* As yet unprocessed draw rectangle? */
(vid_dst_last->x == x) && (vid_dst_last->y == y) && /* AND identical position? */
(vid_dst_last->w == w) && (vid_dst_last->h == h)) { /* AND identical dimensions? */
memcpy (vid_data_last, buf, w*h*sizeof(*buf)); /* Replace region contents */
SDL_UnlockMutex (vid_draw_mutex); /* Done */
return;
}
SDL_UnlockMutex (vid_draw_mutex);
vid_dst = (SDL_Rect *)malloc (sizeof(*vid_dst));
if (!vid_dst) {
sim_printf ("%s: vid_draw() memory allocation error\n", vid_dev ? sim_dname(vid_dev) : "Video Device");
sim_printf ("%s: vid_draw() memory allocation error\n", vid_dname(vid_dev));
return;
}
vid_dst->x = x;
@ -713,7 +732,7 @@ vid_dst->w = w;
vid_dst->h = h;
vid_data = (uint32 *)malloc (w*h*sizeof(*buf));
if (!vid_data) {
sim_printf ("%s: vid_draw() memory allocation error\n", vid_dev ? sim_dname(vid_dev) : "Video Device");
sim_printf ("%s: vid_draw() memory allocation error\n", vid_dname(vid_dev));
free (vid_dst);
return;
}
@ -722,8 +741,12 @@ user_event.type = SDL_USEREVENT;
user_event.user.code = EVENT_DRAW;
user_event.user.data1 = (void *)vid_dst;
user_event.user.data2 = (void *)vid_data;
SDL_LockMutex (vid_draw_mutex); /* protect vid_dst_last & vid_data_last */
vid_dst_last = vid_dst;
vid_data_last = vid_data;
SDL_UnlockMutex (vid_draw_mutex); /* done protection */
if (SDL_PushEvent (&user_event) < 0) {
sim_printf ("%s: vid_draw() SDL_PushEvent error: %s\n", vid_dev ? sim_dname(vid_dev) : "Video Device", SDL_GetError());
sim_printf ("%s: vid_draw() SDL_PushEvent error: %s\n", vid_dname(vid_dev), SDL_GetError());
free (vid_dst);
free (vid_data);
}
@ -757,7 +780,7 @@ user_event.user.data1 = cursor;
user_event.user.data2 = (void *)((size_t)visible);
if (SDL_PushEvent (&user_event) < 0) {
sim_printf ("%s: vid_set_cursor() SDL_PushEvent error: %s\n", vid_dev ? sim_dname(vid_dev) : "Video Device", SDL_GetError());
sim_printf ("%s: vid_set_cursor() SDL_PushEvent error: %s\n", vid_dname(vid_dev), SDL_GetError());
SDL_FreeCursor (cursor);
}
@ -787,10 +810,10 @@ if ((x_delta) || (y_delta)) {
ev->y_rel += y_delta;
}
if (SDL_SemPost (vid_mouse_events.sem))
sim_printf ("%s: vid_set_cursor_position(): SDL_SemPost error: %s\n", vid_dev ? sim_dname(vid_dev) : "Video Device", SDL_GetError());
sim_printf ("%s: vid_set_cursor_position(): SDL_SemPost error: %s\n", vid_dname(vid_dev), SDL_GetError());
}
else {
sim_printf ("%s: vid_set_cursor_position(): SDL_SemWait error: %s\n", vid_dev ? sim_dname(vid_dev) : "Video Device", SDL_GetError());
sim_printf ("%s: vid_set_cursor_position(): SDL_SemWait error: %s\n", vid_dname(vid_dev), SDL_GetError());
}
vid_cursor_x = x;
vid_cursor_y = y;
@ -803,7 +826,7 @@ if ((x_delta) || (y_delta)) {
user_event.user.data2 = NULL;
if (SDL_PushEvent (&user_event) < 0)
sim_printf ("%s: vid_set_cursor_position() SDL_PushEvent error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: vid_set_cursor_position() SDL_PushEvent error: %s\n", vid_dname(vid_dev), SDL_GetError());
sim_debug (SIM_VID_DBG_CURSOR, vid_dev, "vid_set_cursor_position() - Warp Queued\n");
}
else {
@ -824,7 +847,7 @@ user_event.user.data1 = NULL;
user_event.user.data2 = NULL;
if (SDL_PushEvent (&user_event) < 0)
sim_printf ("%s: vid_refresh() SDL_PushEvent error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: vid_refresh() SDL_PushEvent error: %s\n", vid_dname(vid_dev), SDL_GetError());
}
int vid_map_key (int key)
@ -1218,7 +1241,7 @@ if (vid_mouse_captured) {
(KeyStates[SDL_SCANCODE_LCTRL] || KeyStates[SDL_SCANCODE_RCTRL])) {
sim_debug (SIM_VID_DBG_KEY, vid_dev, "vid_key() - Cursor Release\n");
if (SDL_SetRelativeMouseMode(SDL_FALSE) < 0) /* release cursor, show cursor */
sim_printf ("%s: vid_key(): SDL_SetRelativeMouseMode error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: vid_key(): SDL_SetRelativeMouseMode error: %s\n", vid_dname(vid_dev), SDL_GetError());
vid_mouse_captured = FALSE;
return;
}
@ -1250,7 +1273,7 @@ if (SDL_SemWait (vid_key_events.sem) == 0) {
sim_debug (SIM_VID_DBG_KEY, vid_dev, "Keyboard Event DISCARDED: State: %s, Keysym: Scancode: %d, Keysym: %d\n", (event->state == SDL_PRESSED) ? "PRESSED" : "RELEASED", event->keysym.scancode, event->keysym.sym);
}
if (SDL_SemPost (vid_key_events.sem))
sim_printf ("%s: vid_key(): SDL_SemPost error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: vid_key(): SDL_SemPost error: %s\n", vid_dname(vid_dev), SDL_GetError());
}
}
@ -1321,7 +1344,7 @@ if (SDL_SemWait (vid_mouse_events.sem) == 0) {
sim_debug (SIM_VID_DBG_MOUSE, vid_dev, "Mouse Move Event Discarded: Count: %d\n", vid_mouse_events.count);
}
if (SDL_SemPost (vid_mouse_events.sem))
sim_printf ("%s: vid_mouse_move(): SDL_SemPost error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: vid_mouse_move(): SDL_SemPost error: %s\n", vid_dname(vid_dev), SDL_GetError());
}
}
@ -1336,7 +1359,7 @@ if ((!vid_mouse_captured) && (vid_flags & SIM_VID_INPUTCAPTURED)) {
(event->button == SDL_BUTTON_LEFT)) { /* left click and cursor not captured? */
sim_debug (SIM_VID_DBG_KEY, vid_dev, "vid_mouse_button() - Cursor Captured\n");
if (SDL_SetRelativeMouseMode (SDL_TRUE) < 0) /* lock cursor to window, hide cursor */
sim_printf ("%s: vid_mouse_button(): SDL_SetRelativeMouseMode error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: vid_mouse_button(): SDL_SetRelativeMouseMode error: %s\n", vid_dname(vid_dev), SDL_GetError());
SDL_WarpMouseInWindow (NULL, vid_width/2, vid_height/2);/* back to center */
SDL_PumpEvents ();
while (SDL_PeepEvents (&dummy_event, 1, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEMOTION)) {};
@ -1377,7 +1400,7 @@ if (SDL_SemWait (vid_mouse_events.sem) == 0) {
sim_debug (SIM_VID_DBG_MOUSE, vid_dev, "Mouse Button Event Discarded: Count: %d\n", vid_mouse_events.count);
}
if (SDL_SemPost (vid_mouse_events.sem))
sim_printf ("%s: Mouse Button Event: SDL_SemPost error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: Mouse Button Event: SDL_SemPost error: %s\n", vid_dname(vid_dev), SDL_GetError());
}
}
@ -1394,9 +1417,9 @@ sim_debug (SIM_VID_DBG_VIDEO, vid_dev, "Video Update Event: \n");
if (sim_deb)
fflush (sim_deb);
if (SDL_RenderClear (vid_renderer))
sim_printf ("%s: Video Update Event: SDL_RenderClear error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: Video Update Event: SDL_RenderClear error: %s\n", vid_dname(vid_dev), SDL_GetError());
if (SDL_RenderCopy (vid_renderer, vid_texture, NULL, NULL))
sim_printf ("%s: Video Update Event: SDL_RenderCopy error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: Video Update Event: SDL_RenderCopy error: %s\n", vid_dname(vid_dev), SDL_GetError());
SDL_RenderPresent (vid_renderer);
}
@ -1432,8 +1455,15 @@ uint32 *buf = (uint32 *)event->data2;
sim_debug (SIM_VID_DBG_VIDEO, vid_dev, "Draw Region Event: (%d,%d,%d,%d)\n", vid_dst->x, vid_dst->x, vid_dst->w, vid_dst->h);
SDL_LockMutex (vid_draw_mutex);
if (vid_dst == vid_dst_last) {
vid_dst_last = NULL;
vid_data_last = NULL;
}
SDL_UnlockMutex (vid_draw_mutex);
if (SDL_UpdateTexture(vid_texture, vid_dst, buf, vid_dst->w*sizeof(*buf)))
sim_printf ("%s: vid_draw() - SDL_UpdateTexture error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: vid_draw_region() - SDL_UpdateTexture error: %s\n", vid_dname(vid_dev), SDL_GetError());
free (vid_dst);
free (buf);
@ -1565,12 +1595,22 @@ if (!initialized) {
sim_debug (SIM_VID_DBG_VIDEO|SIM_VID_DBG_KEY|SIM_VID_DBG_MOUSE, vid_dev, "vid_thread() - Starting\n");
sim_os_set_thread_priority (PRIORITY_ABOVE_NORMAL);
memset (&vid_key_state, 0, sizeof(vid_key_state));
SDL_CreateWindowAndRenderer (vid_width, vid_height, SDL_WINDOW_SHOWN, &vid_window, &vid_renderer);
if ((vid_window == NULL) || (vid_renderer == NULL)) {
sim_printf ("%s: Error Creating Video Window: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: Error Creating Video Window: %s\n", vid_dname(vid_dev), SDL_GetError());
SDL_Quit ();
return 0;
}
vid_draw_mutex = SDL_CreateMutex();
if (vid_draw_mutex == NULL) {
fprintf (stderr, "%s: SDL_CreateMutex failed: %s\n", vid_dname(vid_dev), SDL_GetError ());
SDL_Quit ();
return 0;
}
@ -1584,7 +1624,7 @@ vid_texture = SDL_CreateTexture (vid_renderer,
SDL_TEXTUREACCESS_STREAMING,
vid_width, vid_height);
if (!vid_texture) {
sim_printf ("%s: Error configuring Video environment: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: Error configuring Video environment: %s\n", vid_dname(vid_dev), SDL_GetError());
SDL_DestroyRenderer(vid_renderer);
vid_renderer = NULL;
SDL_DestroyWindow(vid_window);
@ -1611,6 +1651,9 @@ if (vid_flags & SIM_VID_INPUTCAPTURED) {
else
SDL_SetWindowTitle (vid_window, vid_title);
vid_beep_setup (400, 660);
vid_controllers_setup ();
vid_ready = TRUE;
sim_debug (SIM_VID_DBG_VIDEO|SIM_VID_DBG_KEY|SIM_VID_DBG_MOUSE|SIM_VID_DBG_CURSOR, vid_dev, "vid_thread() - Started\n");
@ -1736,7 +1779,7 @@ if (0) while (SDL_PeepEvents (&event, 1, SDL_GETEVENT, SD
}
else {
if (status < 0)
sim_printf ("%s: vid_thread() - SDL_WaitEvent error: %s\n", sim_dname(vid_dev), SDL_GetError());
sim_printf ("%s: vid_thread() - SDL_WaitEvent error: %s\n", vid_dname(vid_dev), SDL_GetError());
}
}
vid_ready = FALSE;
@ -1750,6 +1793,10 @@ SDL_DestroyRenderer(vid_renderer);
vid_renderer = NULL;
SDL_DestroyWindow(vid_window);
vid_window = NULL;
SDL_DestroyMutex (vid_draw_mutex);
vid_draw_mutex = NULL;
vid_controllers_cleanup ();
vid_beep_cleanup ();
sim_debug (SIM_VID_DBG_VIDEO|SIM_VID_DBG_KEY|SIM_VID_DBG_MOUSE|SIM_VID_DBG_CURSOR, vid_dev, "vid_thread() - Exiting\n");
return 0;
}
@ -1766,9 +1813,7 @@ if (stat) {
sim_printf ("SDL Video subsystem can't initialize\n");
return 0;
}
vid_beep_setup (400, 660);
vid_video_events ();
vid_beep_cleanup ();
SDL_Quit ();
return 0;
}
@ -2194,6 +2239,7 @@ if (!vid_beep_data) {
int i;
SDL_AudioSpec desiredSpec;
SDL_InitSubSystem (SDL_INIT_AUDIO);
memset (&desiredSpec, 0, sizeof(desiredSpec));
desiredSpec.freq = SAMPLE_FREQUENCY;
desiredSpec.format = AUDIO_S16SYS;
@ -2216,6 +2262,7 @@ static void vid_beep_cleanup (void)
SDL_CloseAudio();
free (vid_beep_data);
vid_beep_data = NULL;
SDL_QuitSubSystem (SDL_INIT_AUDIO);
}
void vid_beep_event (void)

View File

@ -344,7 +344,7 @@ else {
if ((rnd_val & 0xFFFF) == 0)
++rnd_val;
sprintf (db_host, "localhost:%d", (int)(rnd_val & 0xFFFF));
slirp->db_chime = sim_connect_sock_ex (db_host, db_host, NULL, NULL, SIM_SOCK_OPT_DATAGRAM);
slirp->db_chime = sim_connect_sock_ex (db_host, db_host, NULL, NULL, SIM_SOCK_OPT_DATAGRAM | SIM_SOCK_OPT_BLOCKING);
} while (slirp->db_chime == INVALID_SOCKET);
memset (&pfd, 0, sizeof (pfd));
pfd.fd = slirp->db_chime;