Fixed serial (and serial mouse) operation on boards with Super I/O chips;

A few video bug fixes per patches from the mainline PCem forum;
Added CUE/BIN image support per patches from the mainline PCem forum.
This commit is contained in:
OBattler
2017-05-08 04:54:17 +02:00
parent d75d630976
commit 55a294ad37
29 changed files with 610 additions and 1216 deletions

View File

@@ -63,7 +63,7 @@ BEGIN
MENUITEM "E&mpty", IDM_CDROM_1_EMPTY
MENUITEM "&Reload previous disc", IDM_CDROM_1_RELOAD
MENUITEM SEPARATOR
MENUITEM "&ISO...", IDM_CDROM_1_ISO
MENUITEM "&Image...", IDM_CDROM_1_IMAGE
END
POPUP "CD-ROM 2"
BEGIN
@@ -72,7 +72,7 @@ BEGIN
MENUITEM "E&mpty", IDM_CDROM_2_EMPTY
MENUITEM "&Reload previous disc", IDM_CDROM_2_RELOAD
MENUITEM SEPARATOR
MENUITEM "&ISO...", IDM_CDROM_2_ISO
MENUITEM "&Image...", IDM_CDROM_2_IMAGE
END
POPUP "CD-ROM 3"
BEGIN
@@ -81,7 +81,7 @@ BEGIN
MENUITEM "E&mpty", IDM_CDROM_3_EMPTY
MENUITEM "&Reload previous disc", IDM_CDROM_3_RELOAD
MENUITEM SEPARATOR
MENUITEM "&ISO...", IDM_CDROM_3_ISO
MENUITEM "&Image...", IDM_CDROM_3_IMAGE
END
POPUP "CD-ROM 4"
BEGIN
@@ -90,7 +90,7 @@ BEGIN
MENUITEM "E&mpty", IDM_CDROM_4_EMPTY
MENUITEM "&Reload previous disc", IDM_CDROM_4_RELOAD
MENUITEM SEPARATOR
MENUITEM "&ISO...", IDM_CDROM_4_ISO
MENUITEM "&Image...", IDM_CDROM_4_IMAGE
END
END
@@ -808,7 +808,7 @@ BEGIN
2172 "Hard disk images (*.HDI;*.HDX;*.IMA;*.IMG)\0*.HDI;*.HDX;*.IMA;*.IMG\0All files (*.*)\0*.*\0"
2173 "All floppy images (*.0??;*.12;*.144;*.360;*.720;*.86F;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMD;*.IMG;*.TD0;*.VFD;*.XDF)\0*.0??;*.12;*.144;*.360;*.720;*.86F;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMD;*.IMG;*.TD0;*.VFD;*.XDF\0Advanced sector-based images (*.IMD;*.TD0)\0*.IMD;*.TD0\0Basic sector-based images (*.0??;*.12;*.144;*.360;*.720;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMG;*.VFD;*.XDF)\0*.0??;*.12;*.144;*.360;*.720;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMG;*.VFD;*.XDF\0Flux images (*.FDI)\0*.FDI\0Surface-based images (*.86F)\0*.86F\0All files (*.*)\0*.*\0"
2174 "Configuration files (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0"
2175 "CD-ROM image (*.ISO)\0*.ISO\0All files (*.*)\0*.*\0"
2175 "CD-ROM image (*.ISO;*.CUE)\0*.ISO;*.CUE\0All files (*.*)\0*.*\0"
2176 "Use CTRL + ALT + PAGE DOWN to return to windowed mode"
2177 "Olivetti M24 mouse"
2178 "<Placeholder string>"

View File

@@ -128,7 +128,7 @@ DEVOBJ = bugger.o lpt.o serial.o \
disc.o \
disc_86f.o disc_fdi.o disc_imd.o disc_img.o \
disc_random.o disc_td0.o \
cdrom.o cdrom-ioctl.o cdrom-iso.o cdrom-null.o
cdrom.o cdrom-dosbox.o cdrom-image.o cdrom-ioctl.o cdrom-null.o
USBOBJ = usb.o
NETOBJ = network.o net_ne2000.o
SCSIOBJ = scsi.o scsi_disk.o scsi_buslogic.o scsi_aha154x.o

View File

@@ -469,7 +469,7 @@ void *cga_standalone_init()
cga_comp_init(cga->revision);
timer_add(cga_poll, &cga->vidtime, TIMER_ALWAYS_ENABLED, cga);
mem_mapping_add(&cga->mapping, 0xb8000, 0x08000, cga_read, NULL, NULL, cga_write, NULL, NULL, NULL, 0, cga);
mem_mapping_add(&cga->mapping, 0xb8000, 0x08000, cga_read, NULL, NULL, cga_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, cga);
io_sethandler(0x03d0, 0x0010, cga_in, NULL, NULL, cga_out, NULL, NULL, cga);
overscan_x = overscan_y = 16;

View File

@@ -379,7 +379,7 @@ void *colorplus_standalone_init()
cga_comp_init(1);
timer_add(colorplus_poll, &colorplus->cga.vidtime, TIMER_ALWAYS_ENABLED, colorplus);
mem_mapping_add(&colorplus->cga.mapping, 0xb8000, 0x08000, colorplus_read, NULL, NULL, colorplus_write, NULL, NULL, NULL, 0, colorplus);
mem_mapping_add(&colorplus->cga.mapping, 0xb8000, 0x08000, colorplus_read, NULL, NULL, colorplus_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, colorplus);
io_sethandler(0x03d0, 0x0010, colorplus_in, NULL, NULL, colorplus_out, NULL, NULL, colorplus);
return colorplus;

View File

@@ -925,7 +925,7 @@ void *ega_standalone_init()
ega_common_defaults(ega);
mem_mapping_add(&ega->mapping, 0xa0000, 0x20000, ega_read, NULL, NULL, ega_write, NULL, NULL, NULL, 0, ega);
mem_mapping_add(&ega->mapping, 0xa0000, 0x20000, ega_read, NULL, NULL, ega_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, ega);
timer_add(ega_poll, &ega->vidtime, TIMER_ALWAYS_ENABLED, ega);
io_sethandler(0x03c0, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega);
return ega;
@@ -961,7 +961,7 @@ void *cpqega_standalone_init()
ega_common_defaults(ega);
mem_mapping_add(&ega->mapping, 0xa0000, 0x20000, ega_read, NULL, NULL, ega_write, NULL, NULL, NULL, 0, ega);
mem_mapping_add(&ega->mapping, 0xa0000, 0x20000, ega_read, NULL, NULL, ega_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, ega);
timer_add(ega_poll, &ega->vidtime, TIMER_ALWAYS_ENABLED, ega);
io_sethandler(0x03c0, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega);
return ega;
@@ -997,7 +997,7 @@ void *sega_standalone_init()
ega_common_defaults(ega);
mem_mapping_add(&ega->mapping, 0xa0000, 0x20000, ega_read, NULL, NULL, ega_write, NULL, NULL, NULL, 0, ega);
mem_mapping_add(&ega->mapping, 0xa0000, 0x20000, ega_read, NULL, NULL, ega_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, ega);
timer_add(ega_poll, &ega->vidtime, TIMER_ALWAYS_ENABLED, ega);
io_sethandler(0x03c0, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega);
return ega;

View File

@@ -562,7 +562,7 @@ void *genius_init()
/* Occupy memory between 0xB0000 and 0xBFFFF (moves to 0xA0000 in
* high-resolution modes) */
mem_mapping_add(&genius->mapping, 0xb0000, 0x10000, genius_read, NULL, NULL, genius_write, NULL, NULL, NULL, 0, genius);
mem_mapping_add(&genius->mapping, 0xb0000, 0x10000, genius_read, NULL, NULL, genius_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, genius);
/* Respond to both MDA and CGA I/O ports */
io_sethandler(0x03b0, 0x000C, genius_in, NULL, NULL, genius_out, NULL, NULL, genius);
io_sethandler(0x03d0, 0x0010, genius_in, NULL, NULL, genius_out, NULL, NULL, genius);

View File

@@ -320,7 +320,7 @@ void *hercules_init()
hercules->vram = malloc(0x10000);
timer_add(hercules_poll, &hercules->vidtime, TIMER_ALWAYS_ENABLED, hercules);
mem_mapping_add(&hercules->mapping, 0xb0000, 0x08000, hercules_read, NULL, NULL, hercules_write, NULL, NULL, NULL, 0, hercules);
mem_mapping_add(&hercules->mapping, 0xb0000, 0x08000, hercules_read, NULL, NULL, hercules_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, hercules);
io_sethandler(0x03b0, 0x0010, hercules_in, NULL, NULL, hercules_out, NULL, NULL, hercules);
for (c = 0; c < 256; c++)

View File

@@ -667,7 +667,7 @@ void *herculesplus_init()
herculesplus->vram = malloc(0x10000); /* 64k VRAM */
timer_add(herculesplus_poll, &herculesplus->vidtime, TIMER_ALWAYS_ENABLED, herculesplus);
mem_mapping_add(&herculesplus->mapping, 0xb0000, 0x10000, herculesplus_read, NULL, NULL, herculesplus_write, NULL, NULL, NULL, 0, herculesplus);
mem_mapping_add(&herculesplus->mapping, 0xb0000, 0x10000, herculesplus_read, NULL, NULL, herculesplus_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, herculesplus);
io_sethandler(0x03b0, 0x0010, herculesplus_in, NULL, NULL, herculesplus_out, NULL, NULL, herculesplus);
for (c = 0; c < 256; c++)

View File

@@ -1014,7 +1014,7 @@ void *incolor_init()
incolor->vram = malloc(0x40000); /* 4 planes of 64k */
timer_add(incolor_poll, &incolor->vidtime, TIMER_ALWAYS_ENABLED, incolor);
mem_mapping_add(&incolor->mapping, 0xb0000, 0x08000, incolor_read, NULL, NULL, incolor_write, NULL, NULL, NULL, 0, incolor);
mem_mapping_add(&incolor->mapping, 0xb0000, 0x08000, incolor_read, NULL, NULL, incolor_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, incolor);
io_sethandler(0x03b0, 0x0010, incolor_in, NULL, NULL, incolor_out, NULL, NULL, incolor);
for (c = 0; c < 64; c++)

View File

@@ -269,7 +269,7 @@ void *mda_init()
mda->vram = malloc(0x1000);
timer_add(mda_poll, &mda->vidtime, TIMER_ALWAYS_ENABLED, mda);
mem_mapping_add(&mda->mapping, 0xb0000, 0x08000, mda_read, NULL, NULL, mda_write, NULL, NULL, NULL, 0, mda);
mem_mapping_add(&mda->mapping, 0xb0000, 0x08000, mda_read, NULL, NULL, mda_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, mda);
io_sethandler(0x03b0, 0x0010, mda_in, NULL, NULL, mda_out, NULL, NULL, mda);
for (c = 0; c < 256; c++)

View File

@@ -736,8 +736,10 @@ void s3_out(uint16_t addr, uint8_t val, void *p)
}
if (svga->seqaddr == 4) /*Chain-4 - update banking*/
{
if (val & 8) svga->write_bank = svga->read_bank = s3->bank << 16;
else svga->write_bank = svga->read_bank = s3->bank << 14;
if (val & 8 || (svga->crtc[0x31] & 8))
svga->write_bank = svga->read_bank = s3->bank << 16;
else
svga->write_bank = svga->read_bank = s3->bank << 14;
}
break;
@@ -767,6 +769,10 @@ void s3_out(uint16_t addr, uint8_t val, void *p)
{
case 0x31:
s3->ma_ext = (s3->ma_ext & 0x1c) | ((val & 0x30) >> 4);
if (svga->chain4 || (svga->crtc[0x31] & 8))
svga->write_bank = svga->read_bank = s3->bank << 16;
else
svga->write_bank = svga->read_bank = s3->bank << 14;
break;
case 0x32:
svga->vrammask = (val & 0x40) ? 0x3ffff : s3->vram_mask;
@@ -790,19 +796,25 @@ void s3_out(uint16_t addr, uint8_t val, void *p)
case 0x35:
s3->bank = (s3->bank & 0x70) | (val & 0xf);
if (svga->chain4) svga->write_bank = svga->read_bank = s3->bank << 16;
else svga->write_bank = svga->read_bank = s3->bank << 14;
if (svga->chain4 || (svga->crtc[0x31] & 8))
svga->write_bank = svga->read_bank = s3->bank << 16;
else
svga->write_bank = svga->read_bank = s3->bank << 14;
break;
case 0x51:
s3->bank = (s3->bank & 0x4f) | ((val & 0xc) << 2);
if (svga->chain4) svga->write_bank = svga->read_bank = s3->bank << 16;
else svga->write_bank = svga->read_bank = s3->bank << 14;
if (svga->chain4 || (svga->crtc[0x31] & 8))
svga->write_bank = svga->read_bank = s3->bank << 16;
else
svga->write_bank = svga->read_bank = s3->bank << 14;
s3->ma_ext = (s3->ma_ext & ~0xc) | ((val & 3) << 2);
break;
case 0x6a:
s3->bank = val;
if (svga->chain4) svga->write_bank = svga->read_bank = s3->bank << 16;
else svga->write_bank = svga->read_bank = s3->bank << 14;
if (svga->chain4 || (svga->crtc[0x31] & 8))
svga->write_bank = svga->read_bank = s3->bank << 16;
else
svga->write_bank = svga->read_bank = s3->bank << 14;
break;
case 0x3a:
@@ -981,7 +993,12 @@ void s3_updatemapping(s3_t *s3)
return;
}
switch (svga->gdcreg[6] & 0xc) /*Banked framebuffer*/
if (svga->crtc[0x31] & 0x08)
{
mem_mapping_set_addr(&svga->mapping, 0xa0000, 0x10000);
svga->banked_mask = 0xffff;
}
else switch (svga->gdcreg[6] & 0xc) /*Banked framebuffer*/
{
case 0x0: /*128k at A0000*/
mem_mapping_set_addr(&svga->mapping, 0xa0000, 0x20000);
@@ -1646,9 +1663,9 @@ void s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat
if (s3->accel.dx >= clip_l && s3->accel.dx <= clip_r &&
s3->accel.dy >= clip_t && s3->accel.dy <= clip_b)
{
READ(s3->accel.src + s3->accel.cx, src_dat);
READ(s3->accel.src + s3->accel.cx, dest_dat);
dest_dat = src_dat;
MIX
WRITE(s3->accel.dest + s3->accel.dx);
}
@@ -1672,8 +1689,6 @@ void s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat
if (s3->accel.sy < 0)
{
s3->accel.cur_x = s3->accel.cx;
s3->accel.cur_y = s3->accel.cy;
return;
}
}
@@ -2183,19 +2198,9 @@ int s3_phoenix_trio32_available()
void *s3_trio64_init(wchar_t *bios_fn)
{
int card_id = 0;
s3_t *s3 = s3_init(bios_fn, S3_TRIO64);
card_id = device_get_config_int("card_id");
if (card_id)
{
s3->id = 0xc1; /*Vision864P*/
}
else
{
s3->id = 0xe1; /*Trio64*/
}
s3->id_ext = s3->id_ext_pci = 0x11;
s3->packed_mmio = 1;
@@ -2390,20 +2395,6 @@ static device_config_t s3_phoenix_trio64_config[] =
}
}
},
{
"card_id", "Card ID", CONFIG_SELECTION, "", 0,
{
{
"S3 Trio64", 0
},
{
"S3 Vision864", 1
},
{
""
}
}
},
{
"", "", -1
}

View File

@@ -971,7 +971,7 @@ int svga_init(svga_t *svga, void *p, int memsize,
svga->hwcursor_draw = hwcursor_draw;
svga->overlay_draw = overlay_draw;
mem_mapping_add(&svga->mapping, 0xa0000, 0x20000, svga_read, svga_readw, svga_readl, svga_write, svga_writew, svga_writel, NULL, 0, svga);
mem_mapping_add(&svga->mapping, 0xa0000, 0x20000, svga_read, svga_readw, svga_readl, svga_write, svga_writew, svga_writel, NULL, MEM_MAPPING_EXTERNAL, svga);
memset(svga->vgapal, 0, sizeof(PALETTE));
@@ -1236,7 +1236,7 @@ uint8_t svga_read(uint32_t addr, void *p)
if (svga->chain4 || svga->fb_only)
{
if (addr >= svga->vram_limit)
return 0xff;
return 0x00;
return svga->vram[svga_mask_addr(addr, svga)];
}
else if (svga->chain2_read)
@@ -1254,7 +1254,7 @@ uint8_t svga_read(uint32_t addr, void *p)
addr<<=2;
if (addr >= svga->vram_limit)
return 0xff;
return 0x00;
addr = svga_mask_addr(addr, svga);

View File

@@ -884,7 +884,7 @@ void *wy700_init()
/* Occupy memory between 0xB0000 and 0xBFFFF (moves to 0xA0000 in
* high-resolution modes) */
mem_mapping_add(&wy700->mapping, 0xb0000, 0x10000, wy700_read, NULL, NULL, wy700_write, NULL, NULL, NULL, 0, wy700);
mem_mapping_add(&wy700->mapping, 0xb0000, 0x10000, wy700_read, NULL, NULL, wy700_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, wy700);
/* Respond to both MDA and CGA I/O ports */
io_sethandler(0x03b0, 0x000C, wy700_in, NULL, NULL, wy700_out, NULL, NULL, wy700);
io_sethandler(0x03d0, 0x0010, wy700_in, NULL, NULL, wy700_out, NULL, NULL, wy700);

View File

@@ -1050,7 +1050,6 @@ static CDROM ioctl_cdrom=
NULL,
ioctl_getcurrentsubchannel,
ioctl_pass_through,
ioctl_sector_data_type,
NULL,
ioctl_playaudio,
ioctl_load,

View File

@@ -1,632 +0,0 @@
/* Copyright holders: RichardG867, Tenshi
see COPYING for more details
*/
/*ISO CD-ROM support*/
#include <stdarg.h>
#include "ibm.h"
#include "cdrom.h"
#include "cdrom-iso.h"
#define __USE_LARGEFILE64
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#include <wchar.h>
static CDROM iso_cdrom;
int cdrom_iso_do_log = 0;
void cdrom_iso_log(const char *format, ...)
{
#ifdef ENABLE_CDROM_ISO_LOG
if (cdrom_iso_do_log)
{
va_list ap;
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
fflush(stdout);
}
#endif
}
void iso_close(uint8_t id);
void iso_audio_callback(uint8_t id, int16_t *output, int len)
{
memset(output, 0, len * 2);
return;
}
void iso_audio_stop(uint8_t id)
{
return;
}
static int iso_ready(uint8_t id)
{
if (wcslen(cdrom_iso[id].iso_path) == 0)
{
return 0;
}
if (cdrom_drives[id].prev_host_drive != cdrom_drives[id].host_drive)
{
return 1;
}
if (cdrom_iso[id].iso_changed)
{
cdrom_iso[id].iso_changed = 0;
return 1;
}
return 1;
}
static int iso_medium_changed(uint8_t id)
{
if (wcslen(cdrom_iso[id].iso_path) == 0)
{
return 0;
}
if (cdrom_drives[id].prev_host_drive != cdrom_drives[id].host_drive)
{
cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive;
return 1;
}
if (cdrom_iso[id].iso_changed)
{
cdrom_iso[id].iso_changed = 0;
return 1;
}
return 0;
}
static void lba_to_msf(uint8_t *buf, int lba)
{
lba += 150;
buf[0] = (lba / 75) / 60;
buf[1] = (lba / 75) % 60;
buf[2] = lba % 75;
}
static uint8_t iso_getcurrentsubchannel(uint8_t id, uint8_t *b, int msf)
{
int pos=0;
int32_t temp;
if (wcslen(cdrom_iso[id].iso_path) == 0)
{
return 0;
}
b[pos++]=0;
b[pos++]=0;
b[pos++]=0;
temp = cdrom[id].seek_pos;
if (msf)
{
memset(&(b[pos]), 0, 8);
lba_to_msf(&(b[pos]), temp);
pos += 4;
lba_to_msf(&(b[pos]), temp);
pos += 4;
}
else
{
b[pos++] = temp >> 24;
b[pos++] = temp >> 16;
b[pos++] = temp >> 8;
b[pos++] = temp;
b[pos++] = temp >> 24;
b[pos++] = temp >> 16;
b[pos++] = temp >> 8;
b[pos++] = temp;
}
return 0x15;
}
static void iso_eject(uint8_t id)
{
return;
}
static void iso_load(uint8_t id)
{
return;
}
static int iso_sector_data_type(uint8_t id, int sector, int ismsf)
{
return 2; /* Always Mode 1 */
}
static void iso_readsector(uint8_t id, uint8_t *b, int sector)
{
uint64_t file_pos = sector;
if (!cdrom_drives[id].host_drive)
{
return;
}
file_pos <<= 11;
memset(b, 0, 2856);
cdrom_iso[id].iso_image = _wfopen(cdrom_iso[id].iso_path, L"rb");
fseeko64(cdrom_iso[id].iso_image, file_pos, SEEK_SET);
fread(b + 16, 2048, 1, cdrom_iso[id].iso_image);
fclose(cdrom_iso[id].iso_image);
/* sync bytes */
b[0] = 0;
memset(b + 1, 0xff, 10);
b[11] = 0;
b += 12;
lba_to_msf(b, sector);
b[3] = 1; /* mode 1 data */
b += 4;
b += 2048;
memset(b, 0, 288);
b += 288;
memset(b, 0, 392);
}
typedef struct __attribute__((__packed__))
{
uint8_t user_data[2048];
uint8_t ecc[288];
} m1_data_t;
typedef struct __attribute__((__packed__))
{
uint8_t sub_header[8];
uint8_t user_data[2328];
} m2_data_t;
typedef union __attribute__((__packed__))
{
m1_data_t m1_data;
m2_data_t m2_data;
uint8_t raw_data[2352];
} sector_data_t;
typedef struct __attribute__((__packed__))
{
uint8_t sync[12];
uint8_t header[4];
sector_data_t data;
uint8_t c2[296];
uint8_t subchannel_raw[96];
uint8_t subchannel_q[16];
uint8_t subchannel_rw[96];
} cdrom_sector_t;
typedef union __attribute__((__packed__))
{
cdrom_sector_t cdrom_sector;
uint8_t buffer[2856];
} sector_buffer_t;
sector_buffer_t cdrom_sector_buffer;
int cdrom_sector_size;
static int iso_readsector_raw(uint8_t id, uint8_t *buffer, int sector, int ismsf, int cdrom_sector_type, int cdrom_sector_flags, int *len)
{
uint8_t *b;
uint8_t *temp_b;
int real_pos;
b = temp_b = buffer;
*len = 0;
if (ismsf)
{
real_pos = cdrom_lba_to_msf_accurate(sector);
}
else
{
real_pos = sector;
}
memset(cdrom_sector_buffer.buffer, 0, 2856);
if ((cdrom_sector_type == 1) || (cdrom_sector_type > 2))
{
if (cdrom_sector_type == 1)
{
cdrom_iso_log("CD-ROM %i: Attempting to read an audio sector from an ISO\n", id);
}
if (cdrom_sector_type >= 2)
{
cdrom_iso_log("CD-ROM %i: Attempting to read a non-mode 1 data sector from an ISO\n", id);
}
return 0;
}
if (!(cdrom_sector_flags & 0xf0)) /* 0x00 and 0x08 are illegal modes */
{
cdrom_iso_log("CD-ROM %i: 0x00 and 0x08 are illegal modes\n", id);
return 0;
}
if ((cdrom_sector_flags & 0x06) == 0x06)
{
cdrom_iso_log("CD-ROM %i: Invalid error flags\n", id);
return 0;
}
if (((cdrom_sector_flags & 0x700) == 0x300) || ((cdrom_sector_flags & 0x700) > 0x400))
{
cdrom_iso_log("CD-ROM %i: Invalid subchannel data flags (%02X)\n", id, cdrom_sector_flags & 0x700);
return 0;
}
if ((cdrom_sector_flags & 0x18) == 0x08) /* EDC/ECC without user data is an illegal mode */
{
cdrom_iso_log("CD-ROM %i: EDC/ECC without user data is an illegal mode\n", id);
return 0;
}
iso_readsector(id, cdrom_sector_buffer.buffer, real_pos);
cdrom_sector_size = 0;
if (cdrom_sector_flags & 0x80) /* Sync */
{
cdrom_iso_log("CD-ROM %i: Sync\n", id);
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.sync, 12);
cdrom_sector_size += 12;
temp_b += 12;
}
if (cdrom_sector_flags & 0x20) /* Header */
{
cdrom_iso_log("CD-ROM %i: Header\n", id);
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.header, 4);
cdrom_sector_size += 4;
temp_b += 4;
}
/* Mode 1 sector, expected type is 1 type. */
if (cdrom_sector_flags & 0x40) /* Sub-header */
{
if (!(cdrom_sector_flags & 0x10)) /* No user data */
{
cdrom_iso_log("CD-ROM %i: Sub-header\n", id);
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m1_data.user_data, 8);
cdrom_sector_size += 8;
temp_b += 8;
}
}
if (cdrom_sector_flags & 0x10) /* User data */
{
cdrom_iso_log("CD-ROM %i: User data\n", id);
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m1_data.user_data, 2048);
cdrom_sector_size += 2048;
temp_b += 2048;
}
if (cdrom_sector_flags & 0x08) /* EDC/ECC */
{
cdrom_iso_log("CD-ROM %i: EDC/ECC\n", id);
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m1_data.ecc, 288);
cdrom_sector_size += 288;
temp_b += 288;
}
if ((cdrom_sector_flags & 0x06) == 0x02)
{
/* Add error flags. */
cdrom_iso_log("CD-ROM %i: Error flags\n", id);
memcpy(b + cdrom_sector_size, cdrom_sector_buffer.cdrom_sector.c2, 294);
cdrom_sector_size += 294;
}
else if ((cdrom_sector_flags & 0x06) == 0x04)
{
/* Add error flags. */
cdrom_iso_log("CD-ROM %i: Full error flags\n", id);
memcpy(b + cdrom_sector_size, cdrom_sector_buffer.cdrom_sector.c2, 296);
cdrom_sector_size += 296;
}
if ((cdrom_sector_flags & 0x700) == 0x100)
{
cdrom_iso_log("CD-ROM %i: Raw subchannel data\n", id);
memcpy(b + cdrom_sector_size, cdrom_sector_buffer.cdrom_sector.subchannel_raw, 96);
cdrom_sector_size += 96;
}
else if ((cdrom_sector_flags & 0x700) == 0x200)
{
cdrom_iso_log("CD-ROM %i: Q subchannel data\n", id);
memcpy(b + cdrom_sector_size, cdrom_sector_buffer.cdrom_sector.subchannel_q, 16);
cdrom_sector_size += 16;
}
else if ((cdrom_sector_flags & 0x700) == 0x400)
{
cdrom_iso_log("CD-ROM %i: R/W subchannel data\n", id);
memcpy(b + cdrom_sector_size, cdrom_sector_buffer.cdrom_sector.subchannel_rw, 96);
cdrom_sector_size += 96;
}
*len = cdrom_sector_size;
return 1;
}
static int iso_readtoc(uint8_t id, unsigned char *buf, unsigned char start_track, int msf, int maxlen, int single)
{
uint8_t *q;
int len;
if (start_track > 1 && start_track != 0xaa)
return -1;
q = buf + 2;
*q++ = 1; /* first session */
*q++ = 1; /* last session */
if (start_track <= 1) {
*q++ = 0; /* reserved */
*q++ = 0x14; /* ADR, control */
*q++ = 1; /* track number */
*q++ = 0; /* reserved */
if (msf) {
*q++ = 0; /* reserved */
lba_to_msf(q, 0);
q += 3;
} else {
/* sector 0 */
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
}
}
/* lead out track */
*q++ = 0; /* reserved */
*q++ = 0x16; /* ADR, control */
*q++ = 0xaa; /* track number */
*q++ = 0; /* reserved */
cdrom_iso[id].last_block = cdrom_iso[id].image_size >> 11;
if (msf) {
*q++ = 0; /* reserved */
lba_to_msf(q, cdrom_iso[id].last_block);
q += 3;
} else {
*q++ = cdrom_iso[id].last_block >> 24;
*q++ = cdrom_iso[id].last_block >> 16;
*q++ = cdrom_iso[id].last_block >> 8;
*q++ = cdrom_iso[id].last_block;
}
len = q - buf;
if (len > maxlen)
{
len = maxlen;
}
buf[0] = (uint8_t)(((len-2) >> 8) & 0xff);
buf[1] = (uint8_t)((len-2) & 0xff);
return len;
}
static int iso_readtoc_session(uint8_t id, unsigned char *buf, int msf, int maxlen)
{
uint8_t *q;
q = buf + 2;
*q++ = 1; /* first session */
*q++ = 1; /* last session */
*q++ = 1; /* session number */
*q++ = 0x14; /* data track */
*q++ = 0; /* track number */
*q++ = 0xa0; /* lead-in */
*q++ = 0; /* min */
*q++ = 0; /* sec */
*q++ = 0; /* frame */
*q++ = 0;
if (maxlen < 12)
{
return maxlen;
}
return 12;
}
static int iso_readtoc_raw(uint8_t id, unsigned char *buf, int msf, int maxlen)
{
uint8_t *q;
int len;
q = buf + 2;
*q++ = 1; /* first session */
*q++ = 1; /* last session */
*q++ = 1; /* session number */
*q++ = 0x14; /* data track */
*q++ = 0; /* track number */
*q++ = 0xa0; /* lead-in */
*q++ = 0; /* min */
*q++ = 0; /* sec */
*q++ = 0; /* frame */
*q++ = 0;
*q++ = 1; /* first track */
*q++ = 0x00; /* disk type */
*q++ = 0x00;
*q++ = 1; /* session number */
*q++ = 0x14; /* data track */
*q++ = 0; /* track number */
*q++ = 0xa1;
*q++ = 0; /* min */
*q++ = 0; /* sec */
*q++ = 0; /* frame */
*q++ = 0;
*q++ = 1; /* last track */
*q++ = 0x00;
*q++ = 0x00;
*q++ = 1; /* session number */
*q++ = 0x14; /* data track */
*q++ = 0; /* track number */
*q++ = 0xa2; /* lead-out */
*q++ = 0; /* min */
*q++ = 0; /* sec */
*q++ = 0; /* frame */
cdrom_iso[id].last_block = cdrom_iso[id].image_size >> 11;
/* this is raw, must be msf */
if (msf)
{
*q++ = 0; /* reserved */
lba_to_msf(q, cdrom_iso[id].last_block);
q += 3;
}
else
{
*q++ = (cdrom_iso[id].last_block >> 24) & 0xff;
*q++ = (cdrom_iso[id].last_block >> 16) & 0xff;
*q++ = (cdrom_iso[id].last_block >> 8) & 0xff;
*q++ = cdrom_iso[id].last_block & 0xff;
}
*q++ = 1; /* session number */
*q++ = 0x14; /* ADR, control */
*q++ = 0; /* track number */
*q++ = 1; /* point */
*q++ = 0; /* min */
*q++ = 0; /* sec */
*q++ = 0; /* frame */
/* same here */
if (msf)
{
*q++ = 0; /* reserved */
lba_to_msf(q, 0);
q += 3;
}
else
{
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
}
len = q - buf;
if (len > maxlen)
{
len = maxlen;
}
buf[0] = (uint8_t)(((len-2) >> 8) & 0xff);
buf[1] = (uint8_t)((len-2) & 0xff);
return len;
}
static uint32_t iso_size(uint8_t id)
{
uint64_t iso_size;
cdrom_iso[id].iso_image = _wfopen(cdrom_iso[id].iso_path, L"rb");
fseeko64(cdrom_iso[id].iso_image, 0, SEEK_END);
iso_size = ftello64(cdrom_iso[id].iso_image);
iso_size >>= 11;
fclose(cdrom_iso[id].iso_image);
return (uint32_t) (iso_size);
}
static int iso_status(uint8_t id)
{
if (!(iso_ready(id)) && (cdrom_drives[id].host_drive != 200)) return CD_STATUS_EMPTY;
return CD_STATUS_DATA_ONLY;
}
void iso_reset(uint8_t id)
{
}
int iso_open(uint8_t id, wchar_t *fn)
{
FILE *f;
if (wcscmp(fn, cdrom_iso[id].iso_path) != 0)
{
cdrom_iso[id].iso_changed = 1;
}
/* Make sure iso_changed stays when changing from ISO to another ISO. */
if (!cdrom_iso[id].iso_inited && (cdrom_drives[id].host_drive != 200)) cdrom_iso[id].iso_changed = 0;
if (!cdrom_iso[id].iso_inited || cdrom_iso[id].iso_changed)
{
_swprintf(cdrom_iso[id].iso_path, L"%ws", fn);
}
cdrom_iso[id].iso_image = _wfopen(cdrom_iso[id].iso_path, L"rb");
cdrom_drives[id].handler = &iso_cdrom;
if (!cdrom_iso[id].iso_inited || cdrom_iso[id].iso_changed)
{
if (!cdrom_iso[id].iso_inited) cdrom_iso[id].iso_inited = 1;
fclose(cdrom_iso[id].iso_image);
}
f = _wfopen(cdrom_iso[id].iso_path, L"rb");
fseeko64(f, 0, SEEK_END);
cdrom_iso[id].image_size = ftello64(f);
fclose(f);
return 0;
}
void iso_close(uint8_t id)
{
if (cdrom_iso[id].iso_image) fclose(cdrom_iso[id].iso_image);
memset(cdrom_iso[id].iso_path, 0, 1024);
}
static void iso_exit(uint8_t id)
{
cdrom_iso[id].iso_inited = 0;
}
static int iso_is_track_audio(uint8_t id, uint32_t pos, int ismsf)
{
return 0;
}
static int iso_media_type_id(uint8_t id)
{
if (iso_size(id) <= 405000)
{
return 1; /* Data CD. */
}
else
{
return 65; /* DVD. */
}
}
static CDROM iso_cdrom =
{
iso_ready,
iso_medium_changed,
iso_media_type_id,
NULL,
NULL,
iso_readtoc,
iso_readtoc_session,
iso_readtoc_raw,
iso_getcurrentsubchannel,
NULL,
iso_sector_data_type,
iso_readsector_raw,
NULL,
iso_load,
iso_eject,
NULL,
NULL,
iso_size,
iso_status,
iso_is_track_audio,
NULL,
iso_exit
};

View File

@@ -1,15 +0,0 @@
/* Copyright holders: RichardG867, Tenshi
see COPYING for more details
*/
#ifndef CDROM_ISO_H
#define CDROM_ISO_H
/* this header file lists the functions provided by
various platform specific cdrom-ioctl files */
extern int iso_open(uint8_t id, wchar_t *fn);
extern void iso_reset(uint8_t id);
extern void iso_close(uint8_t id);
#endif /* ! CDROM_ISO_H */

View File

@@ -31,11 +31,6 @@ static void null_load(uint8_t id)
{
}
static int null_sector_data_type(uint8_t id, int sector, int ismsf)
{
return 0;
}
static int null_readsector_raw(uint8_t id, uint8_t *buffer, int sector, int ismsf, int cdrom_sector_type, int cdrom_sector_flags, int *len)
{
*len = 0;
@@ -100,6 +95,13 @@ static int null_media_type_id(uint8_t id)
return 0x70;
}
void cdrom_set_null_handler(uint8_t id)
{
cdrom_drives[id].handler = &null_cdrom;
cdrom_drives[id].host_drive = 0;
update_status_bar_icon_state(0x10 | id, 1);
}
static CDROM null_cdrom =
{
null_ready,
@@ -112,7 +114,6 @@ static CDROM null_cdrom =
null_readtoc_raw,
null_getcurrentsubchannel,
null_pass_through,
null_sector_data_type,
null_readsector_raw,
NULL,
null_load,

View File

@@ -2893,8 +2893,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb)
break;
}
if ((cdrom_drive < 1) || (cdrom_drive == CDROM_ISO) || (cdrom[id].cd_status <= CD_STATUS_DATA_ONLY) ||
!cdrom_drives[id].handler->is_track_audio(id, pos, msf))
if ((cdrom_drive < 1) || (cdrom[id].cd_status <= CD_STATUS_DATA_ONLY) || !cdrom_drives[id].handler->is_track_audio(id, pos, msf))
{
cdrom_illegal_mode(id);
break;

View File

@@ -15,7 +15,7 @@
#define BUF_SIZE 32768
#define CDROM_ISO 200
#define CDROM_IMAGE 200
#define IDE_TIME (5 * 100 * (1 << TIMER_SHIFT))
#define CDROM_TIME (5 * 100 * (1 << TIMER_SHIFT))
@@ -32,7 +32,6 @@ typedef struct CDROM
int (*readtoc_raw)(uint8_t id, uint8_t *b, int msf, int maxlen);
uint8_t (*getcurrentsubchannel)(uint8_t id, uint8_t *b, int msf);
int (*pass_through)(uint8_t id, uint8_t *in_cdb, uint8_t *b, uint32_t *len);
int (*sector_data_type)(uint8_t id, int sector, int ismsf);
int (*readsector_raw)(uint8_t id, uint8_t *buffer, int sector, int ismsf, int cdrom_sector_type, int cdrom_sector_flags, int *len);
void (*playaudio)(uint8_t id, uint32_t pos, uint32_t len, int ismsf);
void (*load)(uint8_t id);
@@ -170,18 +169,23 @@ extern void (*ide_bus_master_set_irq)(int channel);
typedef struct
{
uint32_t last_block;
uint64_t image_size;
int iso_inited;
wchar_t iso_path[1024];
FILE* iso_image;
int iso_changed;
int image_is_iso;
uint32_t last_block;
uint32_t cdrom_capacity;
int image_inited;
wchar_t image_path[1024];
FILE* image;
int image_changed;
int cd_state;
uint32_t cd_pos;
uint32_t cd_end;
} cdrom_iso_t;
int16_t cd_buffer[BUF_SIZE];
int cd_buflen;
} cdrom_image_t;
cdrom_iso_t cdrom_iso[CDROM_NUM];
cdrom_image_t cdrom_image[CDROM_NUM];
typedef struct
{
@@ -211,7 +215,17 @@ void cdrom_command(uint8_t id, uint8_t *cdb);
void cdrom_phase_callback(uint8_t id);
uint32_t cdrom_read(uint8_t channel, int length);
void cdrom_write(uint8_t channel, uint32_t val, int length);
#ifdef __cplusplus
extern "C" {
#endif
int cdrom_lba_to_msf_accurate(int lba);
#ifdef __cplusplus
}
#endif
void cdrom_reset(uint8_t id);
void cdrom_set_signature(int id);
void cdrom_request_sense_for_scsi(uint8_t id, uint8_t *buffer, uint8_t alloc_length);

View File

@@ -2,11 +2,33 @@
see COPYING for more details
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include "cdrom.h"
#include "config.h"
#include "device.h"
#include "disc.h"
#include "fdc.h"
#include "fdd.h"
#include "ibm.h"
#include "cpu/cpu.h"
#include "gameport.h"
#include "ide.h"
#include "hdd.h"
#include "model.h"
#include "mouse.h"
#include "network.h"
#include "net_ne2000.h"
#include "nvr.h"
#include "plat-joystick.h"
#include "scsi.h"
#include "sound/snd_dbopl.h"
#include "sound/snd_opl.h"
#include "sound/sound.h"
#include "video/video.h"
wchar_t config_file_default[256];
@@ -495,3 +517,427 @@ void config_save(wchar_t *fn)
fclose(f);
}
void loadconfig(wchar_t *fn)
{
int c, d;
char s[512];
char *p;
wchar_t *wp, *wq;
char temps[512];
if (!fn)
config_load(config_file_default);
else
config_load(fn);
GAMEBLASTER = config_get_int(NULL, "gameblaster", 0);
GUS = config_get_int(NULL, "gus", 0);
SSI2001 = config_get_int(NULL, "ssi2001", 0);
voodoo_enabled = config_get_int(NULL, "voodoo", 0);
/* SCSI */
p = (char *)config_get_string(NULL, "scsicard", "");
if (p)
scsi_card_current = scsi_card_get_from_internal_name(p);
else
scsi_card_current = 0;
/* network */
ethif = config_get_int(NULL, "netinterface", 1);
if (ethif >= inum)
inum = ethif + 1;
p = (char *)config_get_string(NULL, "netcard", "");
if (p)
network_card_current = network_card_get_from_internal_name(p);
else
network_card_current = 0;
ne2000_generate_maclocal(config_get_int(NULL, "maclocal", -1));
ne2000_generate_maclocal_pci(config_get_int(NULL, "maclocal_pci", -1));
p = (char *)config_get_string(NULL, "model", "");
if (p)
model = model_get_model_from_internal_name(p);
else
model = 0;
if (model >= model_count())
model = model_count() - 1;
romset = model_getromset();
cpu_manufacturer = config_get_int(NULL, "cpu_manufacturer", 0);
cpu = config_get_int(NULL, "cpu", 0);
cpu_use_dynarec = config_get_int(NULL, "cpu_use_dynarec", 0);
cpu_waitstates = config_get_int(NULL, "cpu_waitstates", 0);
p = (char *)config_get_string(NULL, "gfxcard", "");
if (p)
gfxcard = video_get_video_from_internal_name(p);
else
gfxcard = 0;
video_speed = config_get_int(NULL, "video_speed", 3);
p = (char *)config_get_string(NULL, "sndcard", "");
if (p)
sound_card_current = sound_card_get_from_internal_name(p);
else
sound_card_current = 0;
mem_size = config_get_int(NULL, "mem_size", 4096);
if (mem_size < ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram))
mem_size = ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram);
for (c = 0; c < FDD_NUM; c++)
{
sprintf(temps, "fdd_%02i_type", c + 1);
p = (char *)config_get_string(NULL, temps, (c < 2) ? "525_2dd" : "none");
if (p)
fdd_set_type(c, fdd_get_from_internal_name(p));
else
fdd_set_type(c, (c < 2) ? 2 : 0);
sprintf(temps, "fdd_%02i_fn", c + 1);
wp = (wchar_t *)config_get_wstring(NULL, temps, L"");
if (wp) memcpy(discfns[c], wp, 512);
else {
memcpy(discfns[c], L"", 2);
discfns[c][0] = L'\0';
}
printf("Floppy: %ws\n", discfns[c]);
sprintf(temps, "fdd_%02i_writeprot", c + 1);
ui_writeprot[c] = config_get_int(NULL, temps, 0);
}
p = (char *)config_get_string(NULL, "hdd_controller", "");
if (p)
strncpy(hdd_controller_name, p, sizeof(hdd_controller_name)-1);
else
strncpy(hdd_controller_name, "none", sizeof(hdd_controller_name)-1);
memset(temps, 0, 512);
for (c = 2; c < 4; c++)
{
sprintf(temps, "ide_%02i_enable", c + 1);
ide_enable[c] = config_get_int(NULL, temps, 0);
sprintf(temps, "ide_%02i_irq", c + 1);
ide_irq[c] = config_get_int(NULL, temps, 8 + c);
}
memset(temps, 0, 512);
for (c = 0; c < HDC_NUM; c++)
{
sprintf(temps, "hdd_%02i_sectors", c + 1);
hdc[c].spt = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_heads", c + 1);
hdc[c].hpc = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_cylinders", c + 1);
hdc[c].tracks = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_bus_type", c + 1);
hdc[c].bus = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_mfm_channel", c + 1);
hdc[c].mfm_channel = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_ide_channel", c + 1);
hdc[c].ide_channel = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_scsi_device_id", c + 1);
hdc[c].scsi_id = config_get_int(NULL, temps, (c < 7) ? c : ((c < 15) ? (c + 1) : 15));
sprintf(temps, "hdd_%02i_scsi_device_lun", c + 1);
hdc[c].scsi_lun = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_fn", c + 1);
wp = (wchar_t *)config_get_wstring(NULL, temps, L"");
if (wp) memcpy(hdd_fn[c], wp, 512);
else {
memcpy(hdd_fn[c], L"", 2);
hdd_fn[c][0] = L'\0';
}
}
memset(temps, 0, 512);
for (c = 0; c < CDROM_NUM; c++)
{
sprintf(temps, "cdrom_%02i_host_drive", c + 1);
cdrom_drives[c].host_drive = config_get_int(NULL, temps, 0);
cdrom_drives[c].prev_host_drive = cdrom_drives[c].host_drive;
sprintf(temps, "cdrom_%02i_enabled", c + 1);
cdrom_drives[c].enabled = config_get_int(NULL, temps, 0);
sprintf(temps, "cdrom_%02i_sound_on", c + 1);
cdrom_drives[c].sound_on = config_get_int(NULL, temps, 1);
sprintf(temps, "cdrom_%02i_bus_type", c + 1);
cdrom_drives[c].bus_type = config_get_int(NULL, temps, 0);
sprintf(temps, "cdrom_%02i_atapi_dma", c + 1);
cdrom_drives[c].atapi_dma = config_get_int(NULL, temps, 0);
sprintf(temps, "cdrom_%02i_ide_channel", c + 1);
cdrom_drives[c].ide_channel = config_get_int(NULL, temps, 2);
sprintf(temps, "cdrom_%02i_scsi_device_id", c + 1);
cdrom_drives[c].scsi_device_id = config_get_int(NULL, temps, c + 2);
sprintf(temps, "cdrom_%02i_scsi_device_lun", c + 1);
cdrom_drives[c].scsi_device_lun = config_get_int(NULL, temps, 0);
sprintf(temps, "cdrom_%02i_image_path", c + 1);
wp = (wchar_t *)config_get_wstring(NULL, temps, L"");
if (wp) memcpy(cdrom_image[c].image_path, wp, 512);
else {
memcpy(cdrom_image[c].image_path, L"", 2);
cdrom_image[c].image_path[0] = L'\0';
}
}
vid_resize = config_get_int(NULL, "vid_resize", 0);
vid_api = config_get_int(NULL, "vid_api", 0);
video_fullscreen_scale = config_get_int(NULL, "video_fullscreen_scale", 0);
video_fullscreen_first = config_get_int(NULL, "video_fullscreen_first", 1);
force_43 = config_get_int(NULL, "force_43", 0);
scale = config_get_int(NULL, "scale", 1);
enable_overscan = config_get_int(NULL, "enable_overscan", 0);
enable_sync = config_get_int(NULL, "enable_sync", 1);
opl3_type = config_get_int(NULL, "opl3_type", 1);
window_w = config_get_int(NULL, "window_w", 0);
window_h = config_get_int(NULL, "window_h", 0);
window_x = config_get_int(NULL, "window_x", 0);
window_y = config_get_int(NULL, "window_y", 0);
window_remember = config_get_int(NULL, "window_remember", 0);
joystick_type = config_get_int(NULL, "joystick_type", 0);
p = (char *)config_get_string(NULL, "mouse_type", "");
if (p)
mouse_type = mouse_get_from_internal_name(p);
else
mouse_type = 0;
enable_xtide = config_get_int(NULL, "enable_xtide", 1);
enable_external_fpu = config_get_int(NULL, "enable_external_fpu", 0);
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++)
{
sprintf(s, "joystick_%i_nr", c);
joystick_state[c].plat_joystick_nr = config_get_int("Joysticks", s, 0);
if (joystick_state[c].plat_joystick_nr)
{
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_axis_%i", c, d);
joystick_state[c].axis_mapping[d] = config_get_int("Joysticks", s, d);
}
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_button_%i", c, d);
joystick_state[c].button_mapping[d] = config_get_int("Joysticks", s, d);
}
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_pov_%i_x", c, d);
joystick_state[c].pov_mapping[d][0] = config_get_int("Joysticks", s, d);
sprintf(s, "joystick_%i_pov_%i_y", c, d);
joystick_state[c].pov_mapping[d][1] = config_get_int("Joysticks", s, d);
}
}
}
memset(nvr_path, 0, 2048);
wp = (wchar_t *)config_get_wstring(NULL, "nvr_path", L"");
if (wp) {
if (wcslen(wp) && (wcslen(wp) <= 992)) wcscpy(nvr_path, wp);
else
{
append_filename_w(nvr_path, pcempath, L"nvr", 511);
}
}
else append_filename_w(nvr_path, pcempath, L"nvr", 511);
if (nvr_path[wcslen(nvr_path) - 1] != L'/')
{
if (nvr_path[wcslen(nvr_path) - 1] != L'\\')
{
nvr_path[wcslen(nvr_path)] = L'/';
nvr_path[wcslen(nvr_path) + 1] = L'\0';
}
}
path_len = wcslen(nvr_path);
serial_enabled[0] = config_get_int(NULL, "serial1_enabled", 1);
serial_enabled[1] = config_get_int(NULL, "serial2_enabled", 1);
lpt_enabled = config_get_int(NULL, "lpt_enabled", 1);
bugger_enabled = config_get_int(NULL, "bugger_enabled", 0);
}
wchar_t temp_nvr_path[1024];
wchar_t *nvr_concat(wchar_t *to_concat)
{
char *p;
memset(temp_nvr_path, 0, 2048);
wcscpy(temp_nvr_path, nvr_path);
p = (char *) temp_nvr_path;
p += (path_len * 2);
wchar_t *wp = (wchar_t *) p;
wcscpy(wp, to_concat);
return temp_nvr_path;
}
void saveconfig(void)
{
int c, d;
char temps[512];
config_set_int(NULL, "gameblaster", GAMEBLASTER);
config_set_int(NULL, "gus", GUS);
config_set_int(NULL, "ssi2001", SSI2001);
config_set_int(NULL, "voodoo", voodoo_enabled);
config_set_string(NULL, "scsicard", scsi_card_get_internal_name(scsi_card_current));
config_set_int(NULL, "netinterface", ethif);
config_set_string(NULL, "netcard", network_card_get_internal_name(network_card_current));
config_set_int(NULL, "maclocal", net2000_get_maclocal());
config_set_int(NULL, "maclocal_pci", net2000_get_maclocal_pci());
config_set_string(NULL, "model", model_get_internal_name());
config_set_int(NULL, "cpu_manufacturer", cpu_manufacturer);
config_set_int(NULL, "cpu", cpu);
config_set_int(NULL, "cpu_use_dynarec", cpu_use_dynarec);
config_set_int(NULL, "cpu_waitstates", cpu_waitstates);
config_set_string(NULL, "gfxcard", video_get_internal_name(video_old_to_new(gfxcard)));
config_set_int(NULL, "video_speed", video_speed);
config_set_string(NULL, "sndcard", sound_card_get_internal_name(sound_card_current));
config_set_int(NULL, "cpu_speed", cpuspeed);
config_set_int(NULL, "has_fpu", hasfpu);
config_set_int(NULL, "mem_size", mem_size);
memset(temps, 0, 512);
for (c = 0; c < FDD_NUM; c++)
{
sprintf(temps, "fdd_%02i_type", c + 1);
config_set_string(NULL, temps, fdd_get_internal_name(fdd_get_type(c)));
sprintf(temps, "fdd_%02i_fn", c + 1);
config_set_wstring(NULL, temps, discfns[c]);
sprintf(temps, "fdd_%02i_writeprot", c + 1);
config_set_int(NULL, temps, ui_writeprot[c]);
}
config_set_string(NULL, "hdd_controller", hdd_controller_name);
memset(temps, 0, 512);
for (c = 2; c < 4; c++)
{
sprintf(temps, "ide_%02i_enable", c + 1);
config_set_int(NULL, temps, ide_enable[c]);
sprintf(temps, "ide_%02i_irq", c + 1);
config_set_int(NULL, temps, ide_irq[c]);
}
memset(temps, 0, 512);
for (c = 0; c < HDC_NUM; c++)
{
sprintf(temps, "hdd_%02i_sectors", c + 1);
config_set_int(NULL, temps, hdc[c].spt);
sprintf(temps, "hdd_%02i_heads", c + 1);
config_set_int(NULL, temps, hdc[c].hpc);
sprintf(temps, "hdd_%02i_cylinders", c + 1);
config_set_int(NULL, temps, hdc[c].tracks);
sprintf(temps, "hdd_%02i_bus_type", c + 1);
config_set_int(NULL, temps, hdc[c].bus);
sprintf(temps, "hdd_%02i_mfm_channel", c + 1);
config_set_int(NULL, temps, hdc[c].mfm_channel);
sprintf(temps, "hdd_%02i_ide_channel", c + 1);
config_set_int(NULL, temps, hdc[c].ide_channel);
sprintf(temps, "hdd_%02i_scsi_device_id", c + 1);
config_set_int(NULL, temps, hdc[c].scsi_id);
sprintf(temps, "hdd_%02i_scsi_device_lun", c + 1);
config_set_int(NULL, temps, hdc[c].scsi_lun);
sprintf(temps, "hdd_%02i_fn", c + 1);
config_set_wstring(NULL, temps, hdd_fn[c]);
}
memset(temps, 0, 512);
for (c = 0; c < CDROM_NUM; c++)
{
sprintf(temps, "cdrom_%02i_host_drive", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].host_drive);
sprintf(temps, "cdrom_%02i_enabled", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].enabled);
sprintf(temps, "cdrom_%02i_sound_on", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].sound_on);
sprintf(temps, "cdrom_%02i_bus_type", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].bus_type);
sprintf(temps, "cdrom_%02i_atapi_dma", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].atapi_dma);
sprintf(temps, "cdrom_%02i_ide_channel", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].ide_channel);
sprintf(temps, "cdrom_%02i_scsi_device_id", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].scsi_device_id);
sprintf(temps, "cdrom_%02i_scsi_device_lun", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].scsi_device_lun);
sprintf(temps, "cdrom_%02i_image_path", c + 1);
config_set_wstring(NULL, temps, cdrom_image[c].image_path);
}
config_set_int(NULL, "vid_resize", vid_resize);
config_set_int(NULL, "vid_api", vid_api);
config_set_int(NULL, "video_fullscreen_scale", video_fullscreen_scale);
config_set_int(NULL, "video_fullscreen_first", video_fullscreen_first);
config_set_int(NULL, "force_43", force_43);
config_set_int(NULL, "scale", scale);
config_set_int(NULL, "enable_overscan", enable_overscan);
config_set_int(NULL, "enable_sync", enable_sync);
config_set_int(NULL, "opl3_type", opl3_type);
config_set_int(NULL, "joystick_type", joystick_type);
config_set_string(NULL, "mouse_type", mouse_get_internal_name(mouse_type));
config_set_int(NULL, "enable_xtide", enable_xtide);
config_set_int(NULL, "enable_external_fpu", enable_external_fpu);
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++)
{
char s[80];
sprintf(s, "joystick_%i_nr", c);
config_set_int("Joysticks", s, joystick_state[c].plat_joystick_nr);
if (joystick_state[c].plat_joystick_nr)
{
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_axis_%i", c, d);
config_set_int("Joysticks", s, joystick_state[c].axis_mapping[d]);
}
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_button_%i", c, d);
config_set_int("Joysticks", s, joystick_state[c].button_mapping[d]);
}
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_pov_%i_x", c, d);
config_set_int("Joysticks", s, joystick_state[c].pov_mapping[d][0]);
sprintf(s, "joystick_%i_pov_%i_y", c, d);
config_set_int("Joysticks", s, joystick_state[c].pov_mapping[d][1]);
}
}
}
config_set_int(NULL, "window_w", window_w);
config_set_int(NULL, "window_h", window_h);
config_set_int(NULL, "window_x", window_x);
config_set_int(NULL, "window_y", window_y);
config_set_int(NULL, "window_remember", window_remember);
config_set_int(NULL, "serial1_enabled", serial_enabled[0]);
config_set_int(NULL, "serial2_enabled", serial_enabled[1]);
config_set_int(NULL, "lpt_enabled", lpt_enabled);
config_set_int(NULL, "bugger_enabled", bugger_enabled);
config_save(config_file_default);
}

View File

@@ -15,11 +15,23 @@ void append_filename_w(wchar_t *dest, wchar_t *s1, wchar_t *s2, int size);
void put_backslash(char *s);
void put_backslash_w(wchar_t *s);
char *get_extension(char *s);
#ifdef __cplusplus
extern "C" {
#endif
wchar_t *get_extension_w(wchar_t *s);
#ifdef __cplusplus
}
#endif
void config_load(wchar_t *fn);
void config_save(wchar_t *fn);
void config_dump(void);
void config_free(void);
extern wchar_t config_file_default[256];
void loadconfig(wchar_t *fn);
void saveconfig(void);

View File

@@ -443,6 +443,7 @@ void fdc37c932fr_reset(void)
fdc37c932fr_ld_regs[4][0x61] = 0xf8;
fdc37c932fr_ld_regs[4][0x70] = 4;
fdc37c932fr_ld_regs[4][0xF0] = 3;
serial_setup(1, 0x3f8, fdc37c932fr_ld_regs[4][0x70]);
/* Logical device 5: Serial Port 2 */
fdc37c932fr_ld_regs[5][0x30] = 1;
@@ -452,6 +453,7 @@ void fdc37c932fr_reset(void)
fdc37c932fr_ld_regs[5][0x74] = 4;
fdc37c932fr_ld_regs[5][0xF1] = 2;
fdc37c932fr_ld_regs[5][0xF2] = 3;
serial_setup(2, 0x2f8, fdc37c932fr_ld_regs[5][0x70]);
/* Logical device 6: RTC */
fdc37c932fr_ld_regs[6][0x63] = 0x70;

View File

@@ -676,8 +676,6 @@ uint64_t timer_read();
extern uint64_t timer_freq;
void loadconfig(wchar_t *fn);
extern int infocus;
void onesec();

View File

@@ -39,6 +39,9 @@ static NETCARD net_cards[] = {
int network_card_current = 0;
uint8_t ethif;
int inum;
static void
net_poll(void *priv)

View File

@@ -12,6 +12,9 @@
extern int network_card_current;
extern uint8_t ethif;
extern int inum;
extern void network_init(void);
extern void network_reset(void);

451
src/pc.c
View File

@@ -36,7 +36,7 @@
#include "hdd.h"
#include "ide.h"
#include "cdrom.h"
#include "cdrom-iso.h"
#include "cdrom-image.h"
#include "cdrom-null.h"
#include "scsi.h"
#include "keyboard.h"
@@ -70,9 +70,6 @@
#endif
uint8_t ethif;
int inum;
wchar_t nvr_path[1024];
int path_len;
@@ -373,17 +370,7 @@ void initpc(int argc, wchar_t *argv[])
{
if (cdrom_drives[i].host_drive == 200)
{
ff = _wfopen(cdrom_iso[i].iso_path, L"rb");
if (ff)
{
fclose(ff);
iso_open(i, cdrom_iso[i].iso_path);
}
else
{
cdrom_drives[i].host_drive = 0;
cdrom_null_open(i, cdrom_drives[i].host_drive);
}
image_open(i, cdrom_image[i].image_path);
}
else
{
@@ -422,7 +409,7 @@ void initpc(int argc, wchar_t *argv[])
{
if (cdrom_drives[i].host_drive == 200)
{
iso_reset(i);
image_reset(i);
}
else
{
@@ -485,7 +472,6 @@ void resetpchard(void)
disc_reset();
model_init();
mouse_emu_init();
video_init();
speaker_init();
@@ -526,6 +512,7 @@ void resetpchard(void)
device_add(&voodoo_device);
hdd_controller_init(hdd_controller_name);
pc_reset();
mouse_emu_init();
loadnvr();
@@ -542,7 +529,7 @@ void resetpchard(void)
{
if (cdrom_drives[i].host_drive == 200)
{
iso_reset(i);
image_reset(i);
}
else
{
@@ -700,431 +687,3 @@ void closepc(void)
device_close_all();
midi_close();
}
void loadconfig(wchar_t *fn)
{
int c, d;
char s[512];
char *p;
wchar_t *wp, *wq;
char temps[512];
if (!fn)
config_load(config_file_default);
else
config_load(fn);
GAMEBLASTER = config_get_int(NULL, "gameblaster", 0);
GUS = config_get_int(NULL, "gus", 0);
SSI2001 = config_get_int(NULL, "ssi2001", 0);
voodoo_enabled = config_get_int(NULL, "voodoo", 0);
/* SCSI */
p = (char *)config_get_string(NULL, "scsicard", "");
if (p)
scsi_card_current = scsi_card_get_from_internal_name(p);
else
scsi_card_current = 0;
/* network */
ethif = config_get_int(NULL, "netinterface", 1);
if (ethif >= inum)
inum = ethif + 1;
p = (char *)config_get_string(NULL, "netcard", "");
if (p)
network_card_current = network_card_get_from_internal_name(p);
else
network_card_current = 0;
ne2000_generate_maclocal(config_get_int(NULL, "maclocal", -1));
ne2000_generate_maclocal_pci(config_get_int(NULL, "maclocal_pci", -1));
p = (char *)config_get_string(NULL, "model", "");
if (p)
model = model_get_model_from_internal_name(p);
else
model = 0;
if (model >= model_count())
model = model_count() - 1;
romset = model_getromset();
cpu_manufacturer = config_get_int(NULL, "cpu_manufacturer", 0);
cpu = config_get_int(NULL, "cpu", 0);
cpu_use_dynarec = config_get_int(NULL, "cpu_use_dynarec", 0);
cpu_waitstates = config_get_int(NULL, "cpu_waitstates", 0);
p = (char *)config_get_string(NULL, "gfxcard", "");
if (p)
gfxcard = video_get_video_from_internal_name(p);
else
gfxcard = 0;
video_speed = config_get_int(NULL, "video_speed", 3);
p = (char *)config_get_string(NULL, "sndcard", "");
if (p)
sound_card_current = sound_card_get_from_internal_name(p);
else
sound_card_current = 0;
mem_size = config_get_int(NULL, "mem_size", 4096);
if (mem_size < ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram))
mem_size = ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram);
for (c = 0; c < FDD_NUM; c++)
{
sprintf(temps, "fdd_%02i_type", c + 1);
p = (char *)config_get_string(NULL, temps, (c < 2) ? "525_2dd" : "none");
if (p)
fdd_set_type(c, fdd_get_from_internal_name(p));
else
fdd_set_type(c, (c < 2) ? 2 : 0);
sprintf(temps, "fdd_%02i_fn", c + 1);
wp = (WCHAR *)config_get_wstring(NULL, temps, L"");
if (wp) memcpy(discfns[c], wp, 512);
else {
memcpy(discfns[c], L"", 2);
discfns[c][0] = L'\0';
}
printf("Floppy: %ws\n", discfns[c]);
sprintf(temps, "fdd_%02i_writeprot", c + 1);
ui_writeprot[c] = config_get_int(NULL, temps, 0);
}
p = (char *)config_get_string(NULL, "hdd_controller", "");
if (p)
strncpy(hdd_controller_name, p, sizeof(hdd_controller_name)-1);
else
strncpy(hdd_controller_name, "none", sizeof(hdd_controller_name)-1);
memset(temps, 0, 512);
for (c = 2; c < 4; c++)
{
sprintf(temps, "ide_%02i_enable", c + 1);
ide_enable[c] = config_get_int(NULL, temps, 0);
sprintf(temps, "ide_%02i_irq", c + 1);
ide_irq[c] = config_get_int(NULL, temps, 8 + c);
}
memset(temps, 0, 512);
for (c = 0; c < HDC_NUM; c++)
{
sprintf(temps, "hdd_%02i_sectors", c + 1);
hdc[c].spt = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_heads", c + 1);
hdc[c].hpc = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_cylinders", c + 1);
hdc[c].tracks = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_bus_type", c + 1);
hdc[c].bus = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_mfm_channel", c + 1);
hdc[c].mfm_channel = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_ide_channel", c + 1);
hdc[c].ide_channel = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_scsi_device_id", c + 1);
hdc[c].scsi_id = config_get_int(NULL, temps, (c < 7) ? c : ((c < 15) ? (c + 1) : 15));
sprintf(temps, "hdd_%02i_scsi_device_lun", c + 1);
hdc[c].scsi_lun = config_get_int(NULL, temps, 0);
sprintf(temps, "hdd_%02i_fn", c + 1);
wp = (WCHAR *)config_get_wstring(NULL, temps, L"");
if (wp) memcpy(hdd_fn[c], wp, 512);
else {
memcpy(hdd_fn[c], L"", 2);
hdd_fn[c][0] = L'\0';
}
}
memset(temps, 0, 512);
for (c = 0; c < CDROM_NUM; c++)
{
sprintf(temps, "cdrom_%02i_host_drive", c + 1);
cdrom_drives[c].host_drive = config_get_int(NULL, temps, 0);
cdrom_drives[c].prev_host_drive = cdrom_drives[c].host_drive;
sprintf(temps, "cdrom_%02i_enabled", c + 1);
cdrom_drives[c].enabled = config_get_int(NULL, temps, 0);
sprintf(temps, "cdrom_%02i_sound_on", c + 1);
cdrom_drives[c].sound_on = config_get_int(NULL, temps, 1);
sprintf(temps, "cdrom_%02i_bus_type", c + 1);
cdrom_drives[c].bus_type = config_get_int(NULL, temps, 0);
sprintf(temps, "cdrom_%02i_atapi_dma", c + 1);
cdrom_drives[c].atapi_dma = config_get_int(NULL, temps, 0);
sprintf(temps, "cdrom_%02i_ide_channel", c + 1);
cdrom_drives[c].ide_channel = config_get_int(NULL, temps, 2);
sprintf(temps, "cdrom_%02i_scsi_device_id", c + 1);
cdrom_drives[c].scsi_device_id = config_get_int(NULL, temps, c + 2);
sprintf(temps, "cdrom_%02i_scsi_device_lun", c + 1);
cdrom_drives[c].scsi_device_lun = config_get_int(NULL, temps, 0);
sprintf(temps, "cdrom_%02i_iso_path", c + 1);
wp = (WCHAR *)config_get_wstring(NULL, temps, L"");
if (wp) memcpy(cdrom_iso[c].iso_path, wp, 512);
else {
memcpy(cdrom_iso[c].iso_path, L"", 2);
cdrom_iso[c].iso_path[0] = L'\0';
}
}
vid_resize = config_get_int(NULL, "vid_resize", 0);
vid_api = config_get_int(NULL, "vid_api", 0);
video_fullscreen_scale = config_get_int(NULL, "video_fullscreen_scale", 0);
video_fullscreen_first = config_get_int(NULL, "video_fullscreen_first", 1);
force_43 = config_get_int(NULL, "force_43", 0);
scale = config_get_int(NULL, "scale", 1);
enable_overscan = config_get_int(NULL, "enable_overscan", 0);
enable_flash = config_get_int(NULL, "enable_flash", 1);
enable_sync = config_get_int(NULL, "enable_sync", 1);
opl3_type = config_get_int(NULL, "opl3_type", 1);
window_w = config_get_int(NULL, "window_w", 0);
window_h = config_get_int(NULL, "window_h", 0);
window_x = config_get_int(NULL, "window_x", 0);
window_y = config_get_int(NULL, "window_y", 0);
window_remember = config_get_int(NULL, "window_remember", 0);
joystick_type = config_get_int(NULL, "joystick_type", 0);
p = (char *)config_get_string(NULL, "mouse_type", "");
if (p)
mouse_type = mouse_get_from_internal_name(p);
else
mouse_type = 0;
enable_xtide = config_get_int(NULL, "enable_xtide", 1);
enable_external_fpu = config_get_int(NULL, "enable_external_fpu", 0);
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++)
{
sprintf(s, "joystick_%i_nr", c);
joystick_state[c].plat_joystick_nr = config_get_int("Joysticks", s, 0);
if (joystick_state[c].plat_joystick_nr)
{
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_axis_%i", c, d);
joystick_state[c].axis_mapping[d] = config_get_int("Joysticks", s, d);
}
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_button_%i", c, d);
joystick_state[c].button_mapping[d] = config_get_int("Joysticks", s, d);
}
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_pov_%i_x", c, d);
joystick_state[c].pov_mapping[d][0] = config_get_int("Joysticks", s, d);
sprintf(s, "joystick_%i_pov_%i_y", c, d);
joystick_state[c].pov_mapping[d][1] = config_get_int("Joysticks", s, d);
}
}
}
memset(nvr_path, 0, 2048);
wp = (wchar_t *)config_get_wstring(NULL, "nvr_path", L"");
if (wp) {
if (wcslen(wp) && (wcslen(wp) <= 992)) wcscpy(nvr_path, wp);
else
{
append_filename_w(nvr_path, pcempath, L"nvr", 511);
}
}
else append_filename_w(nvr_path, pcempath, L"nvr", 511);
if (nvr_path[wcslen(nvr_path) - 1] != L'/')
{
if (nvr_path[wcslen(nvr_path) - 1] != L'\\')
{
nvr_path[wcslen(nvr_path)] = L'/';
nvr_path[wcslen(nvr_path) + 1] = L'\0';
}
}
path_len = wcslen(nvr_path);
serial_enabled[0] = config_get_int(NULL, "serial1_enabled", 1);
serial_enabled[1] = config_get_int(NULL, "serial2_enabled", 1);
lpt_enabled = config_get_int(NULL, "lpt_enabled", 1);
bugger_enabled = config_get_int(NULL, "bugger_enabled", 0);
}
wchar_t temp_nvr_path[1024];
wchar_t *nvr_concat(wchar_t *to_concat)
{
char *p;
memset(temp_nvr_path, 0, 2048);
wcscpy(temp_nvr_path, nvr_path);
p = (char *) temp_nvr_path;
p += (path_len * 2);
wchar_t *wp = (wchar_t *) p;
wcscpy(wp, to_concat);
return temp_nvr_path;
}
void saveconfig(void)
{
int c, d;
char temps[512];
config_set_int(NULL, "gameblaster", GAMEBLASTER);
config_set_int(NULL, "gus", GUS);
config_set_int(NULL, "ssi2001", SSI2001);
config_set_int(NULL, "voodoo", voodoo_enabled);
config_set_string(NULL, "scsicard", scsi_card_get_internal_name(scsi_card_current));
config_set_int(NULL, "netinterface", ethif);
config_set_string(NULL, "netcard", network_card_get_internal_name(network_card_current));
config_set_int(NULL, "maclocal", net2000_get_maclocal());
config_set_int(NULL, "maclocal_pci", net2000_get_maclocal_pci());
config_set_string(NULL, "model", model_get_internal_name());
config_set_int(NULL, "cpu_manufacturer", cpu_manufacturer);
config_set_int(NULL, "cpu", cpu);
config_set_int(NULL, "cpu_use_dynarec", cpu_use_dynarec);
config_set_int(NULL, "cpu_waitstates", cpu_waitstates);
config_set_string(NULL, "gfxcard", video_get_internal_name(video_old_to_new(gfxcard)));
config_set_int(NULL, "video_speed", video_speed);
config_set_string(NULL, "sndcard", sound_card_get_internal_name(sound_card_current));
config_set_int(NULL, "cpu_speed", cpuspeed);
config_set_int(NULL, "has_fpu", hasfpu);
config_set_int(NULL, "mem_size", mem_size);
memset(temps, 0, 512);
for (c = 0; c < FDD_NUM; c++)
{
sprintf(temps, "fdd_%02i_type", c + 1);
config_set_string(NULL, temps, fdd_get_internal_name(fdd_get_type(c)));
sprintf(temps, "fdd_%02i_fn", c + 1);
config_set_wstring(NULL, temps, discfns[c]);
sprintf(temps, "fdd_%02i_writeprot", c + 1);
config_set_int(NULL, temps, ui_writeprot[c]);
}
config_set_string(NULL, "hdd_controller", hdd_controller_name);
memset(temps, 0, 512);
for (c = 2; c < 4; c++)
{
sprintf(temps, "ide_%02i_enable", c + 1);
config_set_int(NULL, temps, ide_enable[c]);
sprintf(temps, "ide_%02i_irq", c + 1);
config_set_int(NULL, temps, ide_irq[c]);
}
memset(temps, 0, 512);
for (c = 0; c < HDC_NUM; c++)
{
sprintf(temps, "hdd_%02i_sectors", c + 1);
config_set_int(NULL, temps, hdc[c].spt);
sprintf(temps, "hdd_%02i_heads", c + 1);
config_set_int(NULL, temps, hdc[c].hpc);
sprintf(temps, "hdd_%02i_cylinders", c + 1);
config_set_int(NULL, temps, hdc[c].tracks);
sprintf(temps, "hdd_%02i_bus_type", c + 1);
config_set_int(NULL, temps, hdc[c].bus);
sprintf(temps, "hdd_%02i_mfm_channel", c + 1);
config_set_int(NULL, temps, hdc[c].mfm_channel);
sprintf(temps, "hdd_%02i_ide_channel", c + 1);
config_set_int(NULL, temps, hdc[c].ide_channel);
sprintf(temps, "hdd_%02i_scsi_device_id", c + 1);
config_set_int(NULL, temps, hdc[c].scsi_id);
sprintf(temps, "hdd_%02i_scsi_device_lun", c + 1);
config_set_int(NULL, temps, hdc[c].scsi_lun);
sprintf(temps, "hdd_%02i_fn", c + 1);
config_set_wstring(NULL, temps, hdd_fn[c]);
}
memset(temps, 0, 512);
for (c = 0; c < CDROM_NUM; c++)
{
sprintf(temps, "cdrom_%02i_host_drive", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].host_drive);
sprintf(temps, "cdrom_%02i_enabled", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].enabled);
sprintf(temps, "cdrom_%02i_sound_on", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].sound_on);
sprintf(temps, "cdrom_%02i_bus_type", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].bus_type);
sprintf(temps, "cdrom_%02i_atapi_dma", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].atapi_dma);
sprintf(temps, "cdrom_%02i_ide_channel", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].ide_channel);
sprintf(temps, "cdrom_%02i_scsi_device_id", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].scsi_device_id);
sprintf(temps, "cdrom_%02i_scsi_device_lun", c + 1);
config_set_int(NULL, temps, cdrom_drives[c].scsi_device_lun);
sprintf(temps, "cdrom_%02i_iso_path", c + 1);
config_set_wstring(NULL, temps, cdrom_iso[c].iso_path);
}
config_set_int(NULL, "vid_resize", vid_resize);
config_set_int(NULL, "vid_api", vid_api);
config_set_int(NULL, "video_fullscreen_scale", video_fullscreen_scale);
config_set_int(NULL, "video_fullscreen_first", video_fullscreen_first);
config_set_int(NULL, "force_43", force_43);
config_set_int(NULL, "scale", scale);
config_set_int(NULL, "enable_overscan", enable_overscan);
config_set_int(NULL, "enable_flash", enable_flash);
config_set_int(NULL, "enable_sync", enable_sync);
config_set_int(NULL, "opl3_type", opl3_type);
config_set_int(NULL, "joystick_type", joystick_type);
config_set_string(NULL, "mouse_type", mouse_get_internal_name(mouse_type));
config_set_int(NULL, "enable_xtide", enable_xtide);
config_set_int(NULL, "enable_external_fpu", enable_external_fpu);
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++)
{
char s[80];
sprintf(s, "joystick_%i_nr", c);
config_set_int("Joysticks", s, joystick_state[c].plat_joystick_nr);
if (joystick_state[c].plat_joystick_nr)
{
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_axis_%i", c, d);
config_set_int("Joysticks", s, joystick_state[c].axis_mapping[d]);
}
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_button_%i", c, d);
config_set_int("Joysticks", s, joystick_state[c].button_mapping[d]);
}
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
{
sprintf(s, "joystick_%i_pov_%i_x", c, d);
config_set_int("Joysticks", s, joystick_state[c].pov_mapping[d][0]);
sprintf(s, "joystick_%i_pov_%i_y", c, d);
config_set_int("Joysticks", s, joystick_state[c].pov_mapping[d][1]);
}
}
}
config_set_int(NULL, "window_w", window_w);
config_set_int(NULL, "window_h", window_h);
config_set_int(NULL, "window_x", window_x);
config_set_int(NULL, "window_y", window_y);
config_set_int(NULL, "window_remember", window_remember);
config_set_int(NULL, "serial1_enabled", serial_enabled[0]);
config_set_int(NULL, "serial2_enabled", serial_enabled[1]);
config_set_int(NULL, "lpt_enabled", lpt_enabled);
config_set_int(NULL, "bugger_enabled", bugger_enabled);
config_save(config_file_default);
}

View File

@@ -158,22 +158,22 @@
#define IDM_VID_INVERT 40079
#define IDM_CDROM_1_MUTE 40128
#define IDM_CDROM_1_ISO 40144
#define IDM_CDROM_1_IMAGE 40144
#define IDM_CDROM_1_RELOAD 40160
#define IDM_CDROM_1_EMPTY 40176
#define IDM_CDROM_1_REAL 40192
#define IDM_CDROM_2_MUTE 40129
#define IDM_CDROM_2_ISO 40145
#define IDM_CDROM_2_IMAGE 40145
#define IDM_CDROM_2_RELOAD 40161
#define IDM_CDROM_2_EMPTY 40177
#define IDM_CDROM_2_REAL 40193
#define IDM_CDROM_3_MUTE 40130
#define IDM_CDROM_3_ISO 40146
#define IDM_CDROM_3_IMAGE 40146
#define IDM_CDROM_3_RELOAD 40162
#define IDM_CDROM_3_EMPTY 40178
#define IDM_CDROM_3_REAL 40194
#define IDM_CDROM_4_MUTE 40131
#define IDM_CDROM_4_ISO 40147
#define IDM_CDROM_4_IMAGE 40147
#define IDM_CDROM_4_RELOAD 40163
#define IDM_CDROM_4_EMPTY 40179
#define IDM_CDROM_4_REAL 40195

View File

@@ -505,8 +505,7 @@ serial_setup(int port, uint16_t addr, int irq)
serial_read, NULL, NULL,
serial_write, NULL, NULL, sp);
/* No DTR/RTS callback for now. */
sp->rts_callback = NULL;
pclog("Serial%d: RTSCallback=%08X\n", port, sp->rts_callback);
}
@@ -519,13 +518,16 @@ serial_remove(int port)
/* Grab the desired port block. */
sp = (port == 2) ? &serial2 : &serial1;
pclog("Serial%d: Remove I/O=%04x, IRQ=%d\n", port, sp->addr, sp->irq);
// FIXME: stop timer, if enabled!
/* Remove any callbacks. */
sp->rts_callback = NULL;
/* Commented out by Kotori: This messes with the Super I/O chip. */
/* sp->rts_callback = NULL; */
/* Close the host device. */
(void)serial_link(port, NULL);
/* (void)serial_link(port, NULL); */
/* Release our I/O range. */
if (sp->addr != 0x0000) {
@@ -535,6 +537,8 @@ serial_remove(int port)
}
sp->addr = 0x0000;
sp->irq = 0;
pclog("Serial%d: RTSCallback=%08X\n", port, sp->rts_callback);
}
@@ -542,13 +546,19 @@ serial_remove(int port)
void
serial_init(void)
{
pclog("serial_init()\n");
memset(&serial1, 0x00, sizeof(SERIAL));
serial1.port = 1;
serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ);
/* No DTR/RTS callback for now. */
serial1.rts_callback = NULL;
memset(&serial2, 0x00, sizeof(SERIAL));
serial2.port = 2;
serial_setup(2, SERIAL2_ADDR, SERIAL2_IRQ);
/* No DTR/RTS callback for now. */
serial2.rts_callback = NULL;
}
@@ -560,11 +570,17 @@ serial_init(void)
void
serial_reset(void)
{
pclog("serial_reset()\n");
serial1.iir = serial1.ier = serial1.lcr = serial1.mctrl = 0;
serial1.fifo_read = serial1.fifo_write = 0;
/* No DTR/RTS callback for now. */
serial1.rts_callback = NULL;
serial2.iir = serial2.ier = serial2.lcr = serial2.mctrl = 0;
serial2.fifo_read = serial2.fifo_write = 0;
/* No DTR/RTS callback for now. */
serial2.rts_callback = NULL;
}

View File

@@ -33,7 +33,7 @@
#include "cdrom.h"
#include "cdrom-null.h"
#include "cdrom-ioctl.h"
#include "cdrom-iso.h"
#include "cdrom-image.h"
#include "video/video.h"
#include "video/vid_ega.h"
#include "plat-keyboard.h"
@@ -760,7 +760,7 @@ void update_status_bar_icon_state(int tag, int state)
discfns[tag & 0x0f][0] = L'\0';
break;
case 0x10:
cdrom_iso[tag & 0x0f].iso_path[0] = L'\0';
cdrom_image[tag & 0x0f].image_path[0] = L'\0';
break;
}
}
@@ -807,13 +807,13 @@ void create_cdrom_tip(int part)
if (cdrom_drives[drive].host_drive == 200)
{
if (wcslen(cdrom_iso[drive].iso_path) == 0)
if (wcslen(cdrom_image[drive].image_path) == 0)
{
_swprintf(sbTips[part], win_language_get_string_from_id(2180), drive + 1, win_language_get_string_from_id(2185));
}
else
{
_swprintf(sbTips[part], win_language_get_string_from_id(2180), drive + 1, cdrom_iso[drive].iso_path);
_swprintf(sbTips[part], win_language_get_string_from_id(2180), drive + 1, cdrom_image[drive].image_path);
}
}
else if (cdrom_drives[drive].host_drive < 0x41)
@@ -885,7 +885,7 @@ static int get_cd_state(int id)
{
if (cdrom_drives[id].host_drive == 0x200)
{
return (wcslen(cdrom_iso[id].iso_path) == 0) ? 1 : 0;
return (wcslen(cdrom_image[id].image_path) == 0) ? 1 : 0;
}
else
{
@@ -983,7 +983,7 @@ void update_status_bar_panes(HWND hwnds)
{
if (cdrom_drives[id].host_drive == 0x200)
{
sb_icon_flags[i] = (wcslen(cdrom_iso[id].iso_path) == 0) ? 256 : 0;
sb_icon_flags[i] = (wcslen(cdrom_image[id].image_path) == 0) ? 256 : 0;
}
else
{
@@ -1216,7 +1216,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
if (cdrom_drives[e].host_drive == 200)
{
CheckMenuItem(smenu, IDM_CDROM_1_ISO + e, MF_CHECKED);
CheckMenuItem(smenu, IDM_CDROM_1_IMAGE + e, MF_CHECKED);
}
else if (cdrom_drives[e].host_drive >= 65)
{
@@ -1411,8 +1411,6 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
TerminateThread(mainthreadh,0);
savenvr();
saveconfig();
if (save_window_pos && window_remember)
saveconfig();
closepc();
vid_apis[video_fullscreen][vid_api].close();
@@ -1464,7 +1462,7 @@ void cdrom_close(uint8_t id)
ioctl_close(id);
break;
case 200:
iso_close(id);
image_close(id);
break;
}
}
@@ -1547,7 +1545,7 @@ void win_cdrom_eject(uint8_t id)
}
if (cdrom_drives[id].host_drive == 200)
{
CheckMenuItem(hmenu, IDM_CDROM_1_ISO + id, MF_UNCHECKED);
CheckMenuItem(hmenu, IDM_CDROM_1_IMAGE + id, MF_UNCHECKED);
}
else
{
@@ -1574,7 +1572,7 @@ void win_cdrom_reload(uint8_t id)
cdrom_close(id);
if (cdrom_drives[id].prev_host_drive == 200)
{
iso_open(id, cdrom_iso[id].iso_path);
image_open(id, cdrom_image[id].image_path);
if (cdrom_drives[id].enabled)
{
/* Signal disc change to the emulated machine. */
@@ -1582,7 +1580,7 @@ void win_cdrom_reload(uint8_t id)
}
CheckMenuItem(hmenu, IDM_CDROM_1_EMPTY + id, MF_UNCHECKED);
cdrom_drives[id].host_drive = 200;
CheckMenuItem(hmenu, IDM_CDROM_1_ISO + id, MF_CHECKED);
CheckMenuItem(hmenu, IDM_CDROM_1_IMAGE + id, MF_CHECKED);
}
else
{
@@ -2144,7 +2142,7 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR
RECT rc;
POINT pt;
WCHAR temp_iso_path[1024];
WCHAR temp_image_path[1024];
int new_cdrom_drive;
int cdrom_id = 0;
int menu_sub_param = 0;
@@ -2261,24 +2259,24 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR
win_cdrom_reload(cdrom_id);
break;
case IDM_CDROM_1_ISO:
case IDM_CDROM_2_ISO:
case IDM_CDROM_3_ISO:
case IDM_CDROM_4_ISO:
case IDM_CDROM_1_IMAGE:
case IDM_CDROM_2_IMAGE:
case IDM_CDROM_3_IMAGE:
case IDM_CDROM_4_IMAGE:
cdrom_id = LOWORD(wParam) & 3;
hmenu = GetSubMenu(smenu, cdrom_id + 4);
if (!file_dlg_w_st(hwnd, 2175, cdrom_iso[cdrom_id].iso_path, 0))
if (!file_dlg_w_st(hwnd, 2175, cdrom_image[cdrom_id].image_path, 0))
{
cdrom_drives[cdrom_id].prev_host_drive = cdrom_drives[cdrom_id].host_drive;
wcscpy(temp_iso_path, wopenfilestring);
if ((wcscmp(cdrom_iso[cdrom_id].iso_path, temp_iso_path) == 0) && (cdrom_drives[cdrom_id].host_drive == 200))
wcscpy(temp_image_path, wopenfilestring);
if ((wcscmp(cdrom_image[cdrom_id].image_path, temp_image_path) == 0) && (cdrom_drives[cdrom_id].host_drive == 200))
{
/* Switching from ISO to the same ISO. Do nothing. */
/* Switching from image to the same image. Do nothing. */
break;
}
cdrom_drives[cdrom_id].handler->exit(cdrom_id);
cdrom_close(cdrom_id);
iso_open(cdrom_id, temp_iso_path);
image_open(cdrom_id, temp_image_path);
if (cdrom_drives[cdrom_id].enabled)
{
/* Signal disc change to the emulated machine. */
@@ -2290,7 +2288,7 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR
CheckMenuItem(hmenu, IDM_CDROM_1_REAL + cdrom_id + (cdrom_drives[cdrom_id].host_drive << 2), MF_UNCHECKED);
}
cdrom_drives[cdrom_id].host_drive = 200;
CheckMenuItem(hmenu, IDM_CDROM_1_ISO + cdrom_id, MF_CHECKED);
CheckMenuItem(hmenu, IDM_CDROM_1_IMAGE + cdrom_id, MF_CHECKED);
update_status_bar_icon_state(0x10 | cdrom_id, get_cd_state(cdrom_id));
update_tip(0x10 | cdrom_id);
saveconfig();
@@ -2324,7 +2322,7 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR
{
CheckMenuItem(hmenu, IDM_CDROM_1_REAL + cdrom_id + (cdrom_drives[cdrom_id].host_drive << 2), MF_UNCHECKED);
}
CheckMenuItem(hmenu, IDM_CDROM_1_ISO + cdrom_id, MF_UNCHECKED);
CheckMenuItem(hmenu, IDM_CDROM_1_IMAGE + cdrom_id, MF_UNCHECKED);
cdrom_drives[cdrom_id].host_drive = new_cdrom_drive;
CheckMenuItem(hmenu, IDM_CDROM_1_REAL + cdrom_id + (cdrom_drives[cdrom_id].host_drive << 2), MF_CHECKED);
update_status_bar_icon_state(0x10 | cdrom_id, get_cd_state(cdrom_id));