Numerous CD-ROM fixes (and disc changes now work correctly in Windows 98 SE);

Slight reworking in the mouse and network code (ported from VARCem) in preparation for a major change that will const a lot of things to further reduce RAM usage.
This commit is contained in:
OBattler
2018-03-18 20:48:10 +01:00
parent 0cb43db290
commit b6c393cc91
11 changed files with 196 additions and 191 deletions

View File

@@ -9,7 +9,7 @@
* Implementation of the CD-ROM drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage.
*
* Version: @(#)cdrom.c 1.0.39 2018/03/17
* Version: @(#)cdrom.c 1.0.40 2018/03/18
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -128,7 +128,7 @@ uint8_t cdrom_command_flags[0x100] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,
IMPLEMENTED | CHECK_READY,
IMPLEMENTED | CHECK_READY, /* Read TOC - can get through UNIT_ATTENTION, per VIDE-CDD.SYS
IMPLEMENTED | CHECK_READY | ALLOW_UA, /* Read TOC - can get through UNIT_ATTENTION, per VIDE-CDD.SYS
NOTE: The ATAPI reference says otherwise, but I think this is a question of
interpreting things right - the UNIT ATTENTION condition we have here
is a tradition from not ready to ready, by definition the drive
@@ -232,7 +232,7 @@ static const mode_sense_pages_t cdrom_mode_sense_pages_default =
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 }
{ GPMODE_CAPABILITIES_PAGE, 0x12, 0, 0, 1, 0, 0, 0, 0x02, 0xC2, 1, 0, 0, 0, 0x02, 0xC2, 0, 0, 0, 0 }
} };
static const mode_sense_pages_t cdrom_mode_sense_pages_default_scsi =
@@ -279,7 +279,7 @@ static const mode_sense_pages_t cdrom_mode_sense_pages_default_scsi =
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 }
{ GPMODE_CAPABILITIES_PAGE, 0x12, 0, 0, 1, 0, 0, 0, 0x02, 0xC2, 1, 0, 0, 0, 0x02, 0xC2, 0, 0, 0, 0 }
} };
static const mode_sense_pages_t cdrom_mode_sense_pages_changeable =
@@ -326,12 +326,13 @@ static const mode_sense_pages_t cdrom_mode_sense_pages_changeable =
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 }
{ GPMODE_CAPABILITIES_PAGE, 0x12, 0, 0, 1, 0, 0, 0, 0x02, 0xC2, 1, 0, 0, 0, 0x02, 0xC2, 0, 0, 0, 0 }
} };
static mode_sense_pages_t cdrom_mode_sense_pages_saved[CDROM_NUM];
#define ENABLE_CDROM_LOG 1
#ifdef ENABLE_CDROM_LOG
int cdrom_do_log = ENABLE_CDROM_LOG;
#endif
@@ -475,6 +476,7 @@ void cdrom_init(int id, int cdb_len_setting)
cdrom_sense_key = cdrom_asc = cdrom_ascq = dev->unit_attention = 0;
dev->cdb_len_setting = 0;
dev->cdb_len = 12;
dev->cur_speed = cdrom_drives[id].speed;
}
int cdrom_supports_pio(int id)
@@ -697,8 +699,20 @@ uint32_t cdrom_mode_sense(uint8_t id, uint8_t *buf, uint32_t pos, uint8_t type,
msplen = cdrom_mode_sense_read(id, page_control, i, 1);
buf[pos++] = msplen;
cdrom_log("CD-ROM %i: MODE SENSE: Page [%02X] length %i\n", id, i, msplen);
for (j = 0; j < msplen; j++)
buf[pos++] = cdrom_mode_sense_read(id, page_control, i, 2 + j);
for (j = 0; j < msplen; j++) {
if ((i == GPMODE_CAPABILITIES_PAGE) && (j >= 6) && (j <= 7)) {
if (j & 1)
buf[pos++] = ((cdrom_drives[id].speed * 176) & 0xff);
else
buf[pos++] = ((cdrom_drives[id].speed * 176) >> 8);
} else if ((i == GPMODE_CAPABILITIES_PAGE) && (j >= 12) && (j <= 13)) {
if (j & 1)
buf[pos++] = ((dev->cur_speed * 176) & 0xff);
else
buf[pos++] = ((dev->cur_speed * 176) >> 8);
} else
buf[pos++] = cdrom_mode_sense_read(id, page_control, i, 2 + j);
}
}
}
}
@@ -852,6 +866,7 @@ static void cdrom_command_common(uint8_t id)
dev->callback = 0LL;
} else {
switch(dev->current_cdb[0]) {
case GPCMD_REZERO_UNIT:
case 0x0b:
case 0x2b:
/* Seek time is in us. */
@@ -877,7 +892,7 @@ static void cdrom_command_common(uint8_t id)
case 0xbe:
/* bytes_per_second = 150.0 * 1024.0; */
bytes_per_second = (1000000.0 / 12000.0) * 2048.0; /* Account for seek time. */
bytes_per_second *= (double) cdrom_drives[id].speed;
bytes_per_second *= (double) dev->cur_speed;
break;
default:
bytes_per_second = cdrom_bus_speed(id);
@@ -1434,6 +1449,8 @@ void cdrom_insert(uint8_t id)
cdrom_t *dev = cdrom[id];
dev->unit_attention = 1;
cdrom_log("CD-ROM %i: Media insert\n", id);
}
/*SCSI Sense Initialization*/
@@ -1500,7 +1517,7 @@ skip_ready_check:
/* Only increment the unit attention phase if the command can not pass through it. */
if (!(cdrom_command_flags[cdb[0]] & ALLOW_UA)) {
/* cdrom_log("CD-ROM %i: Unit attention now 2\n", id); */
dev->unit_attention = 2;
dev->unit_attention++;
cdrom_log("CD-ROM %i: UNIT ATTENTION: Command %02X not allowed to pass through\n", id, cdb[0]);
cdrom_unit_attention(id);
return 0;
@@ -1574,6 +1591,9 @@ void cdrom_reset(uint8_t id)
{
cdrom_t *dev = cdrom[id];
if (!dev)
return;
cdrom_rezero(id);
dev->status = 0;
dev->callback = 0LL;
@@ -1771,6 +1791,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb)
if (cdrom_drives[id].handler->stop)
cdrom_drives[id].handler->stop(id);
dev->sector_pos = dev->sector_len = 0;
dev->seek_diff = dev->seek_pos;
cdrom_seek(id, 0);
cdrom_set_phase(id, SCSI_PHASE_STATUS);
break;
@@ -1788,6 +1809,11 @@ void cdrom_command(uint8_t id, uint8_t *cdb)
case GPCMD_SET_SPEED:
case GPCMD_SET_SPEED_ALT:
dev->cur_speed = (cdb[3] | (cdb[2] << 8)) / 176;
if (dev->cur_speed < 1)
dev->cur_speed = 1;
else if (dev->cur_speed > cdrom_drives[id].speed)
dev->cur_speed = cdrom_drives[id].speed;
cdrom_set_phase(id, SCSI_PHASE_STATUS);
cdrom_command_complete(id);
break;

View File

@@ -9,7 +9,7 @@
* Implementation of the CD-ROM drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage.
*
* Version: @(#)cdrom.h 1.0.8 2018/03/17
* Version: @(#)cdrom.h 1.0.9 2018/03/18
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -165,6 +165,8 @@ typedef struct {
int handler_inited;
int disc_changed;
int cur_speed;
} cdrom_t;
typedef struct {
@@ -249,6 +251,7 @@ extern void cdrom_set_signature(int id);
extern void cdrom_request_sense_for_scsi(uint8_t id, uint8_t *buffer, uint8_t alloc_length);
extern void cdrom_update_cdb(uint8_t *cdb, int lba_pos, int number_of_blocks);
extern void cdrom_insert(uint8_t id);
extern void cdrom_new_image(uint8_t id);
extern int find_cdrom_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun);
extern int cdrom_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *len);

View File

@@ -58,41 +58,41 @@ CDROM_Interface_Image::BinaryFile::BinaryFile(const char *filename, bool &error)
{
memset(fn, 0, sizeof(fn));
strcpy(fn, filename);
error = false;
file = fopen64(fn, "rb");
if (file == NULL)
error = true;
else
error = false;
}
CDROM_Interface_Image::BinaryFile::~BinaryFile()
{
fclose(file);
file = NULL;
memset(fn, 0, sizeof(fn));
}
bool CDROM_Interface_Image::BinaryFile::read(Bit8u *buffer, uint64_t seek, uint64_t count)
{
file = fopen64(fn, "rb");
if (file == NULL) return 0;
fseeko64(file, seek, SEEK_SET);
fread(buffer, 1, count, file);
fclose(file);
return 1;
}
uint64_t CDROM_Interface_Image::BinaryFile::getLength()
{
uint64_t ret = 0;
file = fopen64(fn, "rb");
if (file == NULL) return 0;
fseeko64(file, 0, SEEK_END);
ret = ftello64(file);
fclose(file);
return ret;
return ftello64(file);
}
CDROM_Interface_Image::CDROM_Interface_Image()
{
printf("CDROM_Interface_Image constructor\n");
}
CDROM_Interface_Image::~CDROM_Interface_Image()
{
printf("CDROM_Interface_Image destructor\n");
ClearTracks();
}
@@ -357,6 +357,7 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
ifstream in;
in.open(cuefile, ios::in);
if (in.fail()) return false;
int last_attr;
while(!in.eof()) {
// get next line
@@ -427,6 +428,7 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
track.attr = DATA_TRACK;
track.mode2 = true;
} else success = false;
last_attr = track.attr;
canAddTrack = true;
}
@@ -479,7 +481,8 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
track.number++;
track.track_number = 0xAA;
// track.attr = 0;//sync with load iso
track.attr = 0x16; /* Was 0x00 but I believe 0x16 is appropriate. */
// track.attr = 0x16; /* Was 0x00 but I believe 0x16 is appropriate. */
track.attr = last_attr | 0x02;
track.start = 0;
track.length = 0;
track.file = NULL;

View File

@@ -68,6 +68,7 @@ void image_audio_callback(uint8_t id, int16_t *output, int len)
{
cdrom_t *dev = cdrom[id];
return;
if (!cdrom_drives[id].sound_on || (dev->cd_state != CD_PLAYING) || cdrom_image[id].image_is_iso)
{
cdrom_image_log("image_audio_callback(i): Not playing\n", id);
@@ -216,12 +217,6 @@ static int image_ready(uint8_t id)
return 1;
}
if (dev->disc_changed)
{
dev->disc_changed = 0;
return 1;
}
return 1;
}
@@ -267,12 +262,6 @@ static int image_medium_changed(uint8_t id)
cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive;
return 1;
}
if (dev->disc_changed)
{
dev->disc_changed = 0;
return 1;
}
return 0;
}
@@ -848,7 +837,7 @@ static int image_readtoc(uint8_t id, unsigned char *b, unsigned char starttrack,
uint32_t temp;
int first_track;
int last_track;
int last_track, last_track_pos;
int number;
unsigned char attr;
TMSF tmsf;
@@ -881,6 +870,7 @@ static int image_readtoc(uint8_t id, unsigned char *b, unsigned char starttrack,
break;
cdimg[id]->GetAudioTrackInfo(c+1, number, tmsf, attr);
last_track_pos = 0;
b[len++] = 0; /* reserved */
b[len++] = attr;
b[len++] = number; /* track number */
@@ -971,10 +961,8 @@ static int image_readtoc_raw(uint8_t id, unsigned char *b, int maxlen)
cdimg[id]->GetAudioTracks(first_track, last_track, tmsf);
if (maxlen >= 3) b[2] = first_track;
if (maxlen >= 4) b[3] = last_track;
if (maxlen <= 4) return len;
b[2] = first_track;
b[3] = last_track;
for (track = first_track; track <= last_track; track++)
{
@@ -1057,18 +1045,7 @@ int image_open(uint8_t id, wchar_t *fn)
{
cdrom_t *dev = cdrom[id];
if (wcscmp(fn, cdrom_image[id].image_path) != 0)
{
dev->disc_changed = 1;
}
/* Make sure image_changed stays when changing from an image to another image. */
if (!dev->handler_inited && (cdrom_drives[id].host_drive != 200)) dev->disc_changed = 0;
if (!dev->handler_inited || dev->disc_changed)
{
wcscpy(cdrom_image[id].image_path, fn);
}
wcscpy(cdrom_image[id].image_path, fn);
if (! wcscasecmp(plat_get_extension(fn), L"ISO"))
{
@@ -1080,6 +1057,7 @@ int image_open(uint8_t id, wchar_t *fn)
}
cdimg[id] = new CDROM_Interface_Image();
memset(afn, 0, sizeof(afn));
wcstombs(afn, fn, sizeof(afn));
if (!cdimg[id]->SetDevice(afn, false))
{
@@ -1093,12 +1071,6 @@ int image_open(uint8_t id, wchar_t *fn)
dev->cdrom_capacity = image_get_last_block(id, 0, 0, 4096, 0) + 1;
cdrom_drives[id].handler = &image_cdrom;
if (!dev->handler_inited || dev->disc_changed)
{
if (!dev->handler_inited)
dev->handler_inited = 1;
}
return 0;
}

View File

@@ -10,7 +10,7 @@
* data in the form of FM/MFM-encoded transitions) which also
* forms the core of the emulator's floppy disk emulation.
*
* Version: @(#)fdd_86f.c 1.0.17 2018/03/14
* Version: @(#)fdd_86f.c 1.0.18 2018/03/17
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2016-2018 Miran Grca.
@@ -51,7 +51,7 @@ uint64_t table[256];
enum
{
/* 0 ?? ?? ??? */
STATE_IDLE = 0x00,
STATE_IDLE = 0x00,
STATE_SECTOR_NOT_FOUND,
/* 1 00 00 ??? */
@@ -206,17 +206,17 @@ typedef struct
#pragma pack(push,1)
struct
{
FILE *f;
FILE *f;
uint16_t version;
uint16_t disk_flags;
int32_t extra_bit_cells[2];
uint16_t track_encoded_data[2][53048];
uint16_t track_surface_data[2][53048];
uint16_t thin_track_encoded_data[2][2][53048];
uint16_t thin_track_surface_data[2][2][53048];
uint16_t side_flags[2];
uint32_t index_hole_pos[2];
uint32_t track_offset[512];
uint16_t track_encoded_data[2][53048];
uint16_t track_surface_data[2][53048];
uint16_t thin_track_encoded_data[2][2][53048];
uint16_t thin_track_surface_data[2][2][53048];
uint16_t side_flags[2];
uint32_t index_hole_pos[2];
uint32_t track_offset[512];
uint32_t file_size;
sector_id_t format_sector_id;
sector_id_t last_sector;
@@ -728,32 +728,32 @@ uint32_t d86f_header_size(int drive)
static uint16_t d86f_encode_get_data(uint8_t dat)
{
uint16_t temp;
temp = 0;
if (dat & 0x01) temp |= 1;
if (dat & 0x02) temp |= 4;
if (dat & 0x04) temp |= 16;
if (dat & 0x08) temp |= 64;
if (dat & 0x10) temp |= 256;
if (dat & 0x20) temp |= 1024;
if (dat & 0x40) temp |= 4096;
if (dat & 0x80) temp |= 16384;
return temp;
uint16_t temp;
temp = 0;
if (dat & 0x01) temp |= 1;
if (dat & 0x02) temp |= 4;
if (dat & 0x04) temp |= 16;
if (dat & 0x08) temp |= 64;
if (dat & 0x10) temp |= 256;
if (dat & 0x20) temp |= 1024;
if (dat & 0x40) temp |= 4096;
if (dat & 0x80) temp |= 16384;
return temp;
}
static uint16_t d86f_encode_get_clock(uint8_t dat)
{
uint16_t temp;
temp = 0;
if (dat & 0x01) temp |= 2;
if (dat & 0x02) temp |= 8;
if (dat & 0x40) temp |= 32;
if (dat & 0x08) temp |= 128;
if (dat & 0x10) temp |= 512;
if (dat & 0x20) temp |= 2048;
if (dat & 0x40) temp |= 8192;
if (dat & 0x80) temp |= 32768;
return temp;
uint16_t temp;
temp = 0;
if (dat & 0x01) temp |= 2;
if (dat & 0x02) temp |= 8;
if (dat & 0x40) temp |= 32;
if (dat & 0x08) temp |= 128;
if (dat & 0x10) temp |= 512;
if (dat & 0x20) temp |= 2048;
if (dat & 0x40) temp |= 8192;
if (dat & 0x80) temp |= 32768;
return temp;
}
int d86f_format_conditions(int drive)
@@ -1102,17 +1102,17 @@ void d86f_put_bit(int drive, int side, int bit)
static uint8_t decodefm(int drive, uint16_t dat)
{
uint8_t temp = 0;
uint8_t temp = 0;
/* We write the encoded bytes in big endian, so we process the two 8-bit halves swapped here. */
if (dat & 0x0001) temp |= 1;
if (dat & 0x0004) temp |= 2;
if (dat & 0x0010) temp |= 4;
if (dat & 0x0040) temp |= 8;
if (dat & 0x0100) temp |= 16;
if (dat & 0x0400) temp |= 32;
if (dat & 0x1000) temp |= 64;
if (dat & 0x4000) temp |= 128;
return temp;
if (dat & 0x0001) temp |= 1;
if (dat & 0x0004) temp |= 2;
if (dat & 0x0010) temp |= 4;
if (dat & 0x0040) temp |= 8;
if (dat & 0x0100) temp |= 16;
if (dat & 0x0400) temp |= 32;
if (dat & 0x1000) temp |= 64;
if (dat & 0x4000) temp |= 128;
return temp;
}
void fdd_calccrc(uint8_t byte, crc_t *crc_var)
@@ -1458,7 +1458,7 @@ void d86f_compare_byte(int drive, uint8_t received_byte, uint8_t disk_byte)
/* State 4: Read sector data and CRC*/
void d86f_read_sector_data(int drive, int side)
{
int data = 0;
int data = 0;
int recv_data = 0;
int read_status = 0;
uint32_t sector_len = d86f[drive].last_sector.id.n;
@@ -1847,7 +1847,7 @@ void d86f_format_turbo_finish(int drive, int side, int do_write)
void d86f_format_track(int drive, int side, int do_write)
{
int data;
int data;
uint16_t max_len;
int mfm;
@@ -1889,17 +1889,17 @@ void d86f_format_track(int drive, int side, int do_write)
max_len = sync_len;
if (d86f[drive].datac <= 3)
{
data = fdc_getdata(d86f_fdc, 0);
data = fdc_getdata(d86f_fdc, 0);
if (data != -1)
{
data &= 0xff;
}
if ((data == -1) && (d86f[drive].datac < 3))
if ((data == -1) && (d86f[drive].datac < 3))
{
data = 0;
}
d86f[drive].format_sector_id.byte_array[d86f[drive].datac] = data & 0xff;
if (d86f[drive].datac == 3)
if (d86f[drive].datac == 3)
{
fdc_stop_id_request(d86f_fdc);
}
@@ -2968,13 +2968,13 @@ void d86f_zero_track(int drive)
void d86f_seek(int drive, int track)
{
int sides;
int side, thin_track;
int side, thin_track;
sides = d86f_get_sides(drive);
/* If the drive has thick tracks, shift the track number by 1. */
if (!fdd_doublestep_40(drive))
if (!fdd_doublestep_40(drive))
{
track <<= 1;
track <<= 1;
for (thin_track = 0; thin_track < sides; thin_track++)
{
@@ -2993,7 +2993,7 @@ void d86f_seek(int drive, int track)
d86f[drive].cur_track = track;
if (!fdd_doublestep_40(drive))
if (!fdd_doublestep_40(drive))
{
for (side = 0; side < sides; side++)
{
@@ -3059,7 +3059,7 @@ void d86f_set_cur_track(int drive, int track)
void d86f_write_tracks(int drive, FILE **f, uint32_t *track_table)
{
int sides;
int side, thin_track;
int side, thin_track;
int logical_track = 0;
sides = d86f_get_sides(drive);
uint32_t *tbl = d86f[drive].track_offset;
@@ -3067,7 +3067,7 @@ void d86f_write_tracks(int drive, FILE **f, uint32_t *track_table)
tbl = track_table;
int fdd_side = fdd_get_head(drive);
if (!fdd_doublestep_40(drive))
if (!fdd_doublestep_40(drive))
{
for (side = 0; side < sides; side++)
{
@@ -3135,9 +3135,9 @@ void d86f_writeback(int drive)
FILE *cf;
header_size = d86f_header_size(drive);
if (!d86f[drive].f)
if (!d86f[drive].f)
{
return;
return;
}
/* First write the track offsets table. */
@@ -3166,10 +3166,10 @@ void d86f_writeback(int drive)
fseek(d86f[drive].f, header_size, SEEK_SET);
/* Compress data from the temporary uncompressed file to the original, compressed file. */
d86f[drive].filebuf = (uint8_t *) malloc(len);
d86f[drive].outbuf = (uint8_t *) malloc(len - 1);
fread(d86f[drive].filebuf, 1, len, d86f[drive].f);
ret = lzf_compress(d86f[drive].filebuf, len, d86f[drive].outbuf, len - 1);
d86f[drive].filebuf = (uint8_t *) malloc(len);
d86f[drive].outbuf = (uint8_t *) malloc(len - 1);
fread(d86f[drive].filebuf, 1, len, d86f[drive].f);
ret = lzf_compress(d86f[drive].filebuf, len, d86f[drive].outbuf, len - 1);
if (!ret)
{
@@ -3184,15 +3184,15 @@ void d86f_writeback(int drive)
void d86f_stop(int drive)
{
d86f[drive].state = STATE_IDLE;
d86f[drive].state = STATE_IDLE;
}
int d86f_common_command(int drive, int sector, int track, int side, int rate, int sector_size)
{
d86f_log("d86f_common_command (drive %i): fdc_period=%i img_period=%i rate=%i sector=%i track=%i side=%i\n", drive, fdc_get_bitcell_period(d86f_fdc), d86f_get_bitcell_period(drive), rate, sector, track, side);
d86f_log("d86f_common_command (drive %i): fdc_period=%i img_period=%i rate=%i sector=%i track=%i side=%i\n", drive, fdc_get_bitcell_period(d86f_fdc), d86f_get_bitcell_period(drive), rate, sector, track, side);
d86f[drive].req_sector.id.c = track;
d86f[drive].req_sector.id.h = side;
d86f[drive].req_sector.id.c = track;
d86f[drive].req_sector.id.h = side;
if (sector == SECTOR_FIRST)
{
d86f[drive].req_sector.id.r = 1;
@@ -3231,12 +3231,12 @@ void d86f_readsector(int drive, int sector, int track, int side, int rate, int s
ret = d86f_common_command(drive, sector, track, side, rate, sector_size);
if (!ret) return;
if (sector == SECTOR_FIRST)
d86f[drive].state = STATE_02_SPIN_TO_INDEX;
else if (sector == SECTOR_NEXT)
d86f[drive].state = STATE_02_FIND_ID;
if (sector == SECTOR_FIRST)
d86f[drive].state = STATE_02_SPIN_TO_INDEX;
else if (sector == SECTOR_NEXT)
d86f[drive].state = STATE_02_FIND_ID;
else
d86f[drive].state = fdc_is_deleted(d86f_fdc) ? STATE_0C_FIND_ID : (fdc_is_verify(d86f_fdc) ? STATE_16_FIND_ID : STATE_06_FIND_ID);
d86f[drive].state = fdc_is_deleted(d86f_fdc) ? STATE_0C_FIND_ID : (fdc_is_verify(d86f_fdc) ? STATE_16_FIND_ID : STATE_06_FIND_ID);
}
void d86f_writesector(int drive, int sector, int track, int side, int rate, int sector_size)
@@ -3254,7 +3254,7 @@ void d86f_writesector(int drive, int sector, int track, int side, int rate, int
ret = d86f_common_command(drive, sector, track, side, rate, sector_size);
if (!ret) return;
d86f[drive].state = fdc_is_deleted(d86f_fdc) ? STATE_09_FIND_ID : STATE_05_FIND_ID;
d86f[drive].state = fdc_is_deleted(d86f_fdc) ? STATE_09_FIND_ID : STATE_05_FIND_ID;
}
void d86f_comparesector(int drive, int sector, int track, int side, int rate, int sector_size)
@@ -3264,7 +3264,7 @@ void d86f_comparesector(int drive, int sector, int track, int side, int rate, in
ret = d86f_common_command(drive, sector, track, side, rate, sector_size);
if (!ret) return;
d86f[drive].state = STATE_11_FIND_ID;
d86f[drive].state = STATE_11_FIND_ID;
}
void d86f_readaddress(int drive, int side, int rate)
@@ -3283,7 +3283,7 @@ void d86f_readaddress(int drive, int side, int rate)
d86f[drive].id_found = 0;
d86f[drive].dma_over = 0;
d86f[drive].state = STATE_0A_FIND_ID;
d86f[drive].state = STATE_0A_FIND_ID;
}
void d86f_add_track(int drive, int track, int side)
@@ -3384,7 +3384,7 @@ void d86f_common_format(int drive, int side, int rate, uint8_t fill, int proxy)
}
}
d86f[drive].fill = fill;
d86f[drive].fill = fill;
if (!proxy)
{
@@ -3423,20 +3423,20 @@ void d86f_format(int drive, int side, int rate, uint8_t fill)
void d86f_common_handlers(int drive)
{
drives[drive].readsector = d86f_readsector;
drives[drive].writesector = d86f_writesector;
drives[drive].comparesector=d86f_comparesector;
drives[drive].readaddress = d86f_readaddress;
drives[drive].byteperiod = d86f_byteperiod;
drives[drive].poll = d86f_poll;
drives[drive].format = d86f_proxy_format;
drives[drive].stop = d86f_stop;
drives[drive].readsector = d86f_readsector;
drives[drive].writesector = d86f_writesector;
drives[drive].comparesector=d86f_comparesector;
drives[drive].readaddress = d86f_readaddress;
drives[drive].byteperiod = d86f_byteperiod;
drives[drive].poll = d86f_poll;
drives[drive].format = d86f_proxy_format;
drives[drive].stop = d86f_stop;
}
int d86f_export(int drive, wchar_t *fn)
{
FILE *f;
uint32_t tt[512];
uint32_t tt[512];
int tracks = 86;
int i;
@@ -3506,22 +3506,22 @@ void d86f_load(int drive, wchar_t *fn)
d86f_unregister(drive);
writeprot[drive] = 0;
d86f[drive].f = plat_fopen(fn, L"rb+");
if (!d86f[drive].f)
{
d86f[drive].f = plat_fopen(fn, L"rb");
if (!d86f[drive].f)
d86f[drive].f = plat_fopen(fn, L"rb+");
if (!d86f[drive].f)
{
d86f[drive].f = plat_fopen(fn, L"rb");
if (!d86f[drive].f)
{
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
return;
return;
}
writeprot[drive] = 1;
}
writeprot[drive] = 1;
}
if (ui_writeprot[drive])
{
writeprot[drive] = 1;
writeprot[drive] = 1;
}
fwriteprot[drive] = writeprot[drive];
fwriteprot[drive] = writeprot[drive];
fseek(d86f[drive].f, 0, SEEK_END);
len = ftell(d86f[drive].f);
@@ -3620,12 +3620,12 @@ void d86f_load(int drive, wchar_t *fn)
fclose(d86f[drive].f);
d86f[drive].f = NULL;
d86f[drive].f = plat_fopen(temp_file_name, L"wb");
if (!d86f[drive].f)
{
d86f[drive].f = plat_fopen(temp_file_name, L"wb");
if (!d86f[drive].f)
{
d86f_log("86F: Unable to create temporary decompressed file\n");
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
return;
return;
}
tf = plat_fopen(fn, L"rb");
@@ -3693,7 +3693,7 @@ void d86f_load(int drive, wchar_t *fn)
if (!writeprot[drive])
{
writeprot[drive] = (d86f[drive].disk_flags & 0x10) ? 1 : 0;
fwriteprot[drive] = writeprot[drive];
fwriteprot[drive] = writeprot[drive];
}
if (writeprot[drive])
@@ -3790,9 +3790,9 @@ void d86f_load(int drive, wchar_t *fn)
d86f_register_86f(drive);
drives[drive].seek = d86f_seek;
drives[drive].seek = d86f_seek;
d86f_common_handlers(drive);
drives[drive].format = d86f_format;
drives[drive].format = d86f_format;
d86f_log("86F: Disk is %scompressed and %s surface description data\n", d86f[drive].is_compressed ? "" : "not ", d86f_has_surface_desc(drive) ? "has" : "does not have");
}
@@ -3801,8 +3801,8 @@ void d86f_init()
{
int i;
memset(d86f, 0, sizeof(d86f));
d86f_setupcrc(0x1021);
memset(d86f, 0, sizeof(d86f));
d86f_setupcrc(0x1021);
for (i = 0; i < (FDD_NUM + 1); i++)
{
@@ -3822,11 +3822,11 @@ void d86f_close(int drive)
memcpy(temp_file_name, drive ? nvr_path(L"TEMP$$$1.$$$") : nvr_path(L"TEMP$$$0.$$$"), 26);
if (d86f[drive].f)
if (d86f[drive].f)
{
fclose(d86f[drive].f);
fclose(d86f[drive].f);
d86f[drive].f = NULL;
}
if (d86f[drive].is_compressed)
plat_remove(temp_file_name);
plat_remove(temp_file_name);
}

View File

@@ -11,7 +11,7 @@
* TODO: Add the Genius bus- and serial mouse.
* Remove the '3-button' flag from mouse types.
*
* Version: @(#)mouse.c 1.0.21 2018/01/29
* Version: @(#)mouse.c 1.0.22 2018/03/18
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -75,6 +75,7 @@ static mouse_t mouse_devices[] = {
static device_t *mouse_curr;
static void *mouse_priv;
static int mouse_nbut;
static int (*mouse_dev_poll)();
/* Initialize the mouse module. */
@@ -89,6 +90,7 @@ mouse_init(void)
mouse_curr = NULL;
mouse_priv = NULL;
mouse_nbut = 0;
mouse_dev_poll = NULL;
}
@@ -100,6 +102,7 @@ mouse_close(void)
mouse_curr = NULL;
mouse_priv = NULL;
mouse_nbut = 0;
mouse_dev_poll = NULL;
}
@@ -145,8 +148,11 @@ mouse_process(void)
mouse_poll();
if (mouse_curr->available != NULL) {
mouse_curr->available(mouse_x,mouse_y,mouse_z,mouse_buttons, mouse_priv);
if ((mouse_dev_poll != NULL) || (mouse_curr->available != NULL)) {
if (mouse_curr->available != NULL)
mouse_curr->available(mouse_x,mouse_y,mouse_z,mouse_buttons, mouse_priv);
else
mouse_dev_poll(mouse_x,mouse_y,mouse_z,mouse_buttons, mouse_priv);
/* Reset mouse deltas. */
mouse_x = mouse_y = mouse_z = 0;
@@ -161,7 +167,7 @@ mouse_set_poll(int (*func)(int,int,int,int,void *), void *arg)
{
if (mouse_type != MOUSE_TYPE_INTERNAL) return;
mouse_curr->available = func;
mouse_dev_poll = func;
mouse_priv = arg;
}

View File

@@ -8,11 +8,11 @@
*
* Handle WinPcap library processing.
*
* Version: @(#)net_pcap.c 1.0.13 2017/11/04
* Version: @(#)net_pcap.c 1.0.14 2018/03/18
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2017 Fred N. van Kempen.
* Copyright 2017,2018 Fred N. van Kempen.
*/
#include <stdio.h>
#include <stdint.h>
@@ -274,7 +274,7 @@ net_pcap_close(void)
* tries to attach to the network module.
*/
int
net_pcap_reset(netcard_t *card)
net_pcap_reset(netcard_t *card, uint8_t *mac)
{
char errbuf[PCAP_ERRBUF_SIZE];
char filter_exp[255];
@@ -293,14 +293,11 @@ net_pcap_reset(netcard_t *card)
/* Create a MAC address based packet filter. */
pclog("PCAP: installing filter for MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
card->mac[0], card->mac[1], card->mac[2],
card->mac[3], card->mac[4], card->mac[5]);
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
sprintf(filter_exp,
"( ((ether dst ff:ff:ff:ff:ff:ff) or (ether dst %02x:%02x:%02x:%02x:%02x:%02x)) and not (ether src %02x:%02x:%02x:%02x:%02x:%02x) )",
card->mac[0], card->mac[1], card->mac[2],
card->mac[3], card->mac[4], card->mac[5],
card->mac[0], card->mac[1], card->mac[2],
card->mac[3], card->mac[4], card->mac[5]);
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
if (f_pcap_compile((pcap_t *)pcap, &fp, filter_exp, 0, 0xffffffff) != -1) {
if (f_pcap_setfilter((pcap_t *)pcap, &fp) != 0) {
pclog("PCAP: error installing filter (%s) !\n", filter_exp);
@@ -318,7 +315,7 @@ net_pcap_reset(netcard_t *card)
pclog("PCAP: starting thread..\n");
poll_state = thread_create_event();
poll_tid = thread_create(poll_thread, card->mac);
poll_tid = thread_create(poll_thread, mac);
thread_wait_event(poll_state, -1);
return(0);

View File

@@ -8,11 +8,11 @@
*
* Handle SLiRP library processing.
*
* Version: @(#)net_slirp.c 1.0.13 2017/11/04
* Version: @(#)net_slirp.c 1.0.14 2018/03/18
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2017 Fred N. van Kempen.
* Copyright 2017,2018 Fred N. van Kempen.
*/
#include <stdio.h>
#include <stdint.h>
@@ -143,14 +143,14 @@ net_slirp_init(void)
/* Initialize SLiRP for use. */
int
net_slirp_reset(netcard_t *card)
net_slirp_reset(netcard_t *card, uint8_t *mac)
{
/* Save the callback info. */
poll_card = card;
pclog("SLiRP: creating thread..\n");
poll_state = thread_create_event();
poll_tid = thread_create(poll_thread, card->mac);
poll_tid = thread_create(poll_thread, mac);
thread_wait_event(poll_state, -1);
return(0);

View File

@@ -12,7 +12,7 @@
* it should be malloc'ed and then linked to the NETCARD def.
* Will be done later.
*
* Version: @(#)network.c 1.0.21 2018/02/18
* Version: @(#)network.c 1.0.22 2018/03/18
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -51,12 +51,13 @@ static netcard_t net_cards[] = {
int network_type;
int network_ndev;
int network_card;
netdev_t network_devs[32];
char network_pcap[512];
netdev_t network_devs[32];
#ifdef ENABLE_NIC_LOG
int nic_do_log = ENABLE_NIC_LOG;
#endif
static mutex_t *network_mutex;
static uint8_t *network_mac;
static struct {
@@ -98,7 +99,7 @@ network_busy(uint8_t set)
thread_set_event(poll_data.wake_poll_thread);
}
void
network_end(void)
{
@@ -149,7 +150,7 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
/* Save the card's info. */
net_cards[network_card].priv = dev;
net_cards[network_card].rx = rx;
net_cards[network_card].mac = mac;
network_mac = mac;
/* Create the network events. */
poll_data.wake_poll_thread = thread_create_event();
@@ -158,11 +159,11 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
/* Activate the platform module. */
switch(network_type) {
case NET_TYPE_PCAP:
(void)net_pcap_reset(&net_cards[network_card]);
(void)net_pcap_reset(&net_cards[network_card], network_mac);
break;
case NET_TYPE_SLIRP:
(void)net_slirp_reset(&net_cards[network_card]);
(void)net_slirp_reset(&net_cards[network_card], network_mac);
break;
}
}
@@ -194,6 +195,7 @@ network_close(void)
/* Close the network thread mutex. */
thread_close_mutex(network_mutex);
network_mutex = NULL;
network_mac = NULL;
pclog("NETWORK: closed.\n");
}

View File

@@ -8,7 +8,7 @@
*
* Definitions for the network module.
*
* Version: @(#)network.h 1.0.12 2018/02/18
* Version: @(#)network.h 1.0.13 2018/03/18
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*/
@@ -79,12 +79,12 @@ extern void network_tx(uint8_t *, int);
extern int net_pcap_prepare(netdev_t *);
extern int net_pcap_init(void);
extern int net_pcap_reset(netcard_t *);
extern int net_pcap_reset(netcard_t *, uint8_t *);
extern void net_pcap_close(void);
extern void net_pcap_in(uint8_t *, int);
extern int net_slirp_init(void);
extern int net_slirp_reset(netcard_t *);
extern int net_slirp_reset(netcard_t *, uint8_t *);
extern void net_slirp_close(void);
extern void net_slirp_in(uint8_t *, int);

View File

@@ -8,7 +8,7 @@
*
* Implement the application's Status Bar.
*
* Version: @(#)win_stbar.c 1.0.16 2018/03/17
* Version: @(#)win_stbar.c 1.0.17 2018/03/18
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -1072,10 +1072,6 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if (!file_dlg_w_st(hwnd, IDS_2075, cdrom_image[id].image_path, 0)) {
cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive;
wcscpy(temp_path, wopenfilestring);
if ((wcscmp(cdrom_image[id].image_path, temp_path) == 0) && (cdrom_drives[id].host_drive == 200)) {
/* Switching from image to the same image. Do nothing. */
break;
}
if (!cdrom_image[id].prev_image_path)
cdrom_image[id].prev_image_path = (wchar_t *) malloc(1024);
wcscpy(cdrom_image[id].prev_image_path, cdrom_image[id].image_path);