diff --git a/PDP11/pdp11_rq.c b/PDP11/pdp11_rq.c
index 8bd6044e..e0c54727 100644
--- a/PDP11/pdp11_rq.c
+++ b/PDP11/pdp11_rq.c
@@ -1924,7 +1924,7 @@ if (err != 0) { /* error? */
if (rq_dte (cp, uptr, ST_DRV)) /* post err log */
rq_rw_end (cp, uptr, EF_LOG, ST_DRV); /* if ok, report err */
perror ("RQ I/O error");
- if (!(uptr->flags | UNIT_RAW))
+ if (!(uptr->flags & UNIT_RAW))
clearerr (uptr->fileref);
return SCPE_IOERR;
}
diff --git a/VAX/vax780_stddev.c b/VAX/vax780_stddev.c
index 3a3016fe..814a5f43 100644
--- a/VAX/vax780_stddev.c
+++ b/VAX/vax780_stddev.c
@@ -327,7 +327,7 @@ REG clk_reg[] = {
DEVICE clk_dev = {
"TODR", &clk_unit, clk_reg, NULL,
- 1, 0, 8, 1, 0, 0,
+ 1, 0, 8, 4, 0, 32,
NULL, NULL, &clk_reset,
NULL, &clk_attach, &clk_detach,
NULL, 0
diff --git a/VAX/vax_stddev.c b/VAX/vax_stddev.c
index af05fb8b..204be3fe 100644
--- a/VAX/vax_stddev.c
+++ b/VAX/vax_stddev.c
@@ -101,8 +101,6 @@ int32 clk_tps = 100; /* ticks/second */
int32 todr_reg = 0; /* TODR register */
int32 todr_blow = 1; /* TODR battery low */
struct todr_battery_info {
- char toy_gmtbase_a[16]; /* Platform independent Text format of toy_gmtbase */
- char toy_gmtbasemsec_a[16]; /* Platform independent Text format of toy_gmtbasemsec */
uint32 toy_gmtbase; /* GMT base of set value */
uint32 toy_gmtbasemsec; /* The milliseconds of the set value */
};
@@ -234,7 +232,7 @@ MTAB clk_mod[] = {
DEVICE clk_dev = {
"CLK", &clk_unit, clk_reg, clk_mod,
- 1, 0, 8, 1, 0, 0,
+ 1, 0, 8, 4, 0, 32,
NULL, NULL, &clk_reset,
NULL, &clk_attach, &clk_detach,
&clk_dib, 0
@@ -429,8 +427,6 @@ if (0 == todr_reg) /* clock running? */
#define TOY_MAX_SECS (0x40000000/25)
clock_gettime(CLOCK_REALTIME, &now); /* get curr time */
-toy->toy_gmtbase = strtoul(toy->toy_gmtbase_a, NULL, 0);
-toy->toy_gmtbasemsec = strtoul(toy->toy_gmtbasemsec_a, NULL, 0);
base.tv_sec = toy->toy_gmtbase;
base.tv_nsec = toy->toy_gmtbasemsec * 1000000;
sim_timespec_diff (&val, &now, &base);
@@ -457,8 +453,6 @@ val.tv_nsec = (((uint32)data) % 100) * 10000000;
sim_timespec_diff (&base, &now, &val); /* base = now - data */
toy->toy_gmtbase = (uint32)base.tv_sec;
toy->toy_gmtbasemsec = base.tv_nsec/1000000;
-sprintf(toy->toy_gmtbase_a, "0x%08X", toy->toy_gmtbase);
-sprintf(toy->toy_gmtbasemsec_a, "0x%08X", toy->toy_gmtbasemsec);
todr_reg = data;
if (data)
todr_blow = 0;
diff --git a/Visual Studio Projects/PDP11.vcproj b/Visual Studio Projects/PDP11.vcproj
index ec24e7e4..fc4f4b67 100644
--- a/Visual Studio Projects/PDP11.vcproj
+++ b/Visual Studio Projects/PDP11.vcproj
@@ -26,6 +26,8 @@
>
u6);
WRITE_I (uptr->flags); /* [V2.10] flags */
WRITE_I (uptr->capac); /* [V3.5] capacity */
- if (uptr->flags & UNIT_ATT)
+ if (uptr->flags & UNIT_ATT) {
fputs (uptr->filename, sfile);
+ if ((uptr->flags & UNIT_BUF) && /* writable buffered */
+ uptr->hwmark && /* files need to be */
+ ((uptr->flags & UNIT_RO) == 0)) { /* written on save */
+ uint32 cap = (uptr->hwmark + dptr->aincr - 1) / dptr->aincr;
+ rewind (uptr->fileref);
+ sim_fwrite (uptr->filebuf, SZ_D (dptr), cap, uptr->fileref);
+ fclose (uptr->fileref); /* flush data and state */
+ uptr->fileref = sim_fopen (uptr->filename, "rb+");/* reopen r/w */
+ }
+ }
fputc ('\n', sfile);
if (((uptr->flags & (UNIT_FIX + UNIT_ATTABLE)) == UNIT_FIX) &&
(dptr->examine != NULL) &&
diff --git a/sim_disk.c b/sim_disk.c
index 2f852262..7d95b794 100644
--- a/sim_disk.c
+++ b/sim_disk.c
@@ -2660,7 +2660,7 @@ VHD_DynamicDiskHeader Dynamic;
uint32 *BAT = NULL;
time_t now;
uint32 i;
-FILE *File;
+FILE *File = NULL;
uint32 Status = 0;
uint32 BytesPerSector = 512;
uint64 SizeInBytes = ((uint64)SizeInSectors)*BytesPerSector;
@@ -2833,7 +2833,7 @@ CreateDifferencingVirtualDisk(const char *szVHDPath,
const char *szParentVHDPath)
{
uint32 BytesPerSector = 512;
-VHDHANDLE hVHD;
+VHDHANDLE hVHD = NULL;
VHD_Footer ParentFooter;
VHD_DynamicDiskHeader ParentDynamic;
uint32 ParentTimeStamp;
diff --git a/sim_fio.c b/sim_fio.c
index c80c8020..720bde9e 100644
--- a/sim_fio.c
+++ b/sim_fio.c
@@ -57,7 +57,6 @@
#include "sim_defs.h"
-static unsigned char sim_flip[FLIP_SIZE];
int32 sim_end = 1; /* 1 = little */
/* OS-independent, endian independent binary I/O package
@@ -141,11 +140,13 @@ size_t sim_fwrite (void *bptr, size_t size, size_t count, FILE *fptr)
size_t c, nelem, nbuf, lcnt, total;
int32 i;
unsigned char *sptr;
+unsigned char *sim_flip;
if ((size == 0) || (count == 0)) /* check arguments */
return 0;
if (sim_end || (size == sizeof (char))) /* le or byte? */
return fwrite (bptr, size, count, fptr); /* done */
+sim_flip = (unsigned char *)malloc(FLIP_SIZE);
nelem = FLIP_SIZE / size; /* elements in buffer */
nbuf = count / nelem; /* number buffers */
lcnt = count % nelem; /* count in last buf */
@@ -158,10 +159,13 @@ for (i = (int32)nbuf; i > 0; i--) { /* loop on buffers */
sim_buf_copy_swapped (sim_flip, sptr, size, c);
sptr = sptr + size * count;
c = fwrite (sim_flip, size, c, fptr);
- if (c == 0)
+ if (c == 0) {
+ free(sim_flip);
return total;
+ }
total = total + c;
}
+free(sim_flip);
return total;
}