This commit is contained in:
RichardG867
2020-07-19 19:21:12 -03:00
8 changed files with 92 additions and 53 deletions

View File

@@ -87,7 +87,7 @@ inthdc_close(void *priv)
static const device_t inthdc_device = {
"Internal Controller", 0, 0,
"Internal controller", 0, 0,
inthdc_init, inthdc_close, NULL,
NULL, NULL, NULL, NULL
};
@@ -101,7 +101,7 @@ static const struct {
{ "None", "none",
&null_device },
{ "Internal Controller", "internal",
{ "Internal controller", "internal",
&inthdc_device },
{ "[ISA] [MFM] IBM PC Fixed Disk Adapter", "st506_xt",

View File

@@ -346,7 +346,8 @@ image_is_mdi(const wchar_t *s)
int
mo_load(mo_t *dev, wchar_t *fn)
{
int is_mdi, size = 0;
int is_mdi;
uint32_t size = 0;
unsigned int i, found = 0;
is_mdi = image_is_mdi(fn);
@@ -364,16 +365,16 @@ mo_load(mo_t *dev, wchar_t *fn)
}
fseek(dev->drv->f, 0, SEEK_END);
size = ftell(dev->drv->f);
size = (uint32_t) ftello64(dev->drv->f);
if (is_mdi) {
/* This is a MDI image. */
size -= 0x1000;
size -= 0x1000LL;
dev->drv->base = 0x1000;
}
for (i = 0; i < KNOWN_MO_TYPES; i++) {
if (size == mo_types[i].disk_size) {
if (size == (mo_types[i].sectors * mo_types[i].bytes_per_sector)) {
found = 1;
dev->drv->medium_size = mo_types[i].sectors;
dev->drv->sector_size = mo_types[i].bytes_per_sector;
@@ -1037,14 +1038,14 @@ mo_insert(mo_t *dev)
void
mo_format(mo_t *dev)
{
long size;
unsigned long size;
int ret;
int fd;
mo_log("MO %i: Formatting media...\n", dev->id);
fseek(dev->drv->f, 0, SEEK_END);
size = ftell(dev->drv->f);
size = (uint32_t) ftello64(dev->drv->f);
HANDLE fh;
LARGE_INTEGER liSize;

View File

@@ -31,31 +31,29 @@
typedef struct {
uint32_t sectors;
uint16_t bytes_per_sector;
int64_t disk_size;
char name[255];
} mo_type_t;
#define KNOWN_MO_TYPES 10
static const mo_type_t mo_types[KNOWN_MO_TYPES] = {
// 3.5" standard M.O. disks
{ 248826, 512, 127398912, "3.5\" 128Mb M.O. (ISO 10090)" },
{ 446325, 512, 228518400, "3.5\" 230Mb M.O. (ISO 13963)" },
{ 1041500, 512, 533248000, "3.5\" 540Mb M.O. (ISO 15498)" },
{ 310352, 2048, 635600896, "3.5\" 640Mb M.O. (ISO 15498)" },
{ 605846, 2048, 1240772608, "3.5\" 1.3Gb M.O. (GigaMO)" },
{ 1063146, 2048, 2177323008, "3.5\" 2.3Gb M.O. (GigaMO 2)" },
{ 248826, 512 },
{ 446325, 512 },
{ 1041500, 512 },
{ 310352, 2048 },
{ 605846, 2048 },
{ 1063146, 2048 },
// 5.25" M.O. disks
{573624, 512, 293695488, "5.25\" 600Mb M.O."},
{314568, 1024, 322117632, "5.25\" 650Mb M.O."},
{904995, 512, 463357440, "5.25\" 1Gb M.O."},
{637041, 1024, 652329984, "5.25\" 1.3Gb M.O."},
{573624, 512 },
{314568, 1024 },
{904995, 512 },
{637041, 1024 },
};
typedef struct
{
char vendor[8];
char model[16];
char revision[4];
const char vendor[8];
const char model[16];
const char revision[4];
int8_t supported_media[KNOWN_MO_TYPES];
} mo_drive_type_t;

View File

@@ -32,7 +32,7 @@ typedef struct {
#else
void *opl;
#endif
int8_t is_opl3;
int8_t is_opl3, do_cycles;
uint16_t port;
uint8_t status;
@@ -47,6 +47,8 @@ typedef struct {
} opl_t;
extern void opl_set_do_cycles(opl_t *dev, int8_t do_cycles);
extern uint8_t opl2_read(uint16_t port, void *);
extern void opl2_write(uint16_t port, uint8_t val, void *);
extern void opl2_init(opl_t *);

View File

@@ -162,11 +162,20 @@ opl_write(opl_t *dev, uint16_t port, uint8_t val)
}
void
opl_set_do_cycles(opl_t *dev, int8_t do_cycles)
{
dev->do_cycles = do_cycles;
}
static void
opl_init(opl_t *dev, int is_opl3)
{
memset(dev, 0x00, sizeof(opl_t));
dev->is_opl3 = is_opl3;
dev->do_cycles = 1;
/* Create a NukedOPL object. */
dev->opl = nuked_init(48000);
@@ -192,7 +201,8 @@ opl2_read(uint16_t port, void *priv)
{
opl_t *dev = (opl_t *)priv;
cycles -= ISA_CYCLES(8);
if (dev->do_cycles)
sub_cycles((int) (isa_timing * 8));
opl2_update(dev);
@@ -240,7 +250,8 @@ opl3_read(uint16_t port, void *priv)
{
opl_t *dev = (opl_t *)priv;
cycles -= ISA_CYCLES(8);
if (dev->do_cycles)
sub_cycles((int)(isa_timing * 8));
opl3_update(dev);

View File

@@ -1187,6 +1187,8 @@ sb_pro_v1_opl_read(uint16_t port, void *priv)
{
sb_t *sb = (sb_t *)priv;
sub_cycles((int)(isa_timing * 8));
(void)opl2_read(port, &sb->opl2); // read, but ignore
return(opl2_read(port, &sb->opl));
}
@@ -1225,7 +1227,9 @@ void *sb_pro_v1_init(const device_t *info)
sb->opl_enabled = device_get_config_int("opl");
if (sb->opl_enabled) {
opl2_init(&sb->opl);
opl_set_do_cycles(&sb->opl, 0);
opl2_init(&sb->opl2);
opl_set_do_cycles(&sb->opl2, 0);
}
sb_dsp_init(&sb->dsp, SBPRO, SB_SUBTYPE_DEFAULT, sb);
sb_dsp_setaddr(&sb->dsp, addr);

View File

@@ -297,7 +297,7 @@ END
DLG_NEW_FLOPPY DIALOG DISCARDABLE 0, 0, 226, 86
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "New Floppy Image"
CAPTION "New Image"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,74,65,50,14

View File

@@ -526,13 +526,13 @@ create_mo_sector_image(WCHAR *file_name, int8_t disk_size, uint8_t is_mdi, HWND
HWND h;
FILE *f;
const mo_type_t *dp = &mo_types[disk_size];
uint8_t *empty;
uint32_t total_size = 0;
uint8_t *empty, *empty2 = NULL;
uint32_t total_size = 0, total_size2;
uint32_t total_sectors = 0;
uint32_t sector_bytes = 0;
uint16_t base = 0x1000;
uint32_t pbar_max = 0;
uint32_t i;
uint32_t pbar_max = 0, blocks_num;
uint32_t i, j;
MSG msg;
f = plat_fopen(file_name, L"wb");
@@ -543,11 +543,18 @@ create_mo_sector_image(WCHAR *file_name, int8_t disk_size, uint8_t is_mdi, HWND
total_sectors = dp->sectors;
total_size = total_sectors * sector_bytes;
pbar_max = dp->sectors >> 11;
total_size2 = (total_size >> 20) << 20;
total_size2 = total_size - total_size2;
pbar_max = total_size;
pbar_max >>= 20;
blocks_num = pbar_max;
if (is_mdi)
pbar_max += base;
pbar_max >>= 11;
pbar_max--;
pbar_max++;
if (total_size2 == 0)
pbar_max++;
j = is_mdi ? 1 : 0;
h = GetDlgItem(hwnd, IDC_COMBO_RPM_MODE);
EnableWindow(h, FALSE);
@@ -556,7 +563,7 @@ create_mo_sector_image(WCHAR *file_name, int8_t disk_size, uint8_t is_mdi, HWND
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
h = GetDlgItem(hwnd, IDC_PBAR_IMG_CREATE);
SendMessage(h, PBM_SETRANGE32, (WPARAM) 0, (LPARAM) pbar_max);
SendMessage(h, PBM_SETRANGE32, (WPARAM) 0, (LPARAM) pbar_max - 1);
SendMessage(h, PBM_SETPOS, (WPARAM) 0, (LPARAM) 0);
EnableWindow(h, TRUE);
ShowWindow(h, SW_SHOW);
@@ -565,7 +572,6 @@ create_mo_sector_image(WCHAR *file_name, int8_t disk_size, uint8_t is_mdi, HWND
ShowWindow(h, SW_SHOW);
h = GetDlgItem(hwnd, IDC_PBAR_IMG_CREATE);
pbar_max++;
if (is_mdi) {
empty = (unsigned char *) malloc(base);
@@ -589,22 +595,7 @@ create_mo_sector_image(WCHAR *file_name, int8_t disk_size, uint8_t is_mdi, HWND
fwrite(&empty[0x0800], 1, 2048, f);
free(empty);
SendMessage(h, PBM_SETPOS, (WPARAM) 2, (LPARAM) 0);
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
pbar_max -= 2;
}
empty = (unsigned char *) malloc(total_size);
memset(empty, 0x00, total_size);
for (i = 0; i < pbar_max; i++) {
fwrite(&empty[i << 11], 1, 2048, f);
SendMessage(h, PBM_SETPOS, (WPARAM) i + 2, (LPARAM) 0);
SendMessage(h, PBM_SETPOS, (WPARAM) 1, (LPARAM) 0);
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) {
TranslateMessage(&msg);
@@ -612,6 +603,38 @@ create_mo_sector_image(WCHAR *file_name, int8_t disk_size, uint8_t is_mdi, HWND
}
}
empty = (unsigned char *) malloc(1048576);
memset(empty, 0x00, 1048576);
if (total_size2 > 0) {
empty2 = (unsigned char *) malloc(total_size2);
memset(empty, 0x00, total_size2);
}
for (i = 0; i < blocks_num; i++) {
fwrite(empty, 1, 1048576, f);
SendMessage(h, PBM_SETPOS, (WPARAM) i + j, (LPARAM) 0);
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
if (total_size2 > 0) {
fwrite(empty2, 1, total_size2, f);
SendMessage(h, PBM_SETPOS, (WPARAM) pbar_max - 1, (LPARAM) 0);
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
if (empty2 != NULL)
free(empty2);
free(empty);
fclose(f);