More cleanups to separate main code from platform support and UI support, plus a few bugfixes.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
* Generic floppy disk interface that communicates with the
|
||||
* other handlers.
|
||||
*
|
||||
* Version: @(#)floppy.c 1.0.6 2017/10/09
|
||||
* Version: @(#)floppy.c 1.0.8 2017/10/12
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "../rom.h"
|
||||
#include "../config.h"
|
||||
#include "../timer.h"
|
||||
#include "../plat.h"
|
||||
#include "../ui.h"
|
||||
#include "floppy.h"
|
||||
#include "floppy_86f.h"
|
||||
@@ -136,14 +137,14 @@ void floppy_load(int drive, wchar_t *fn)
|
||||
if (!fn) return;
|
||||
p = get_extension_w(fn);
|
||||
if (!p) return;
|
||||
f = _wfopen(fn, L"rb");
|
||||
f = plat_fopen(fn, L"rb");
|
||||
if (!f) return;
|
||||
fseek(f, -1, SEEK_END);
|
||||
size = ftell(f) + 1;
|
||||
fclose(f);
|
||||
while (loaders[c].ext)
|
||||
{
|
||||
if (!_wcsicmp(p, loaders[c].ext) && (size == loaders[c].size || loaders[c].size == -1))
|
||||
if (!wcscasecmp(p, loaders[c].ext) && (size == loaders[c].size || loaders[c].size == -1))
|
||||
{
|
||||
driveloaders[drive] = c;
|
||||
memcpy(floppyfns[drive], fn, (wcslen(fn) << 1) + 2);
|
||||
|
||||
@@ -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: @(#)floppy_86f.c 1.0.6 2017/10/09
|
||||
* Version: @(#)floppy_86f.c 1.0.7 2017/10/12
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "../dma.h"
|
||||
#include "../nvr.h"
|
||||
#include "../random.h"
|
||||
#include "../plat.h"
|
||||
#include "../ui.h"
|
||||
#include "floppy.h"
|
||||
#include "fdc.h"
|
||||
@@ -3072,7 +3073,7 @@ void d86f_writeback(int drive)
|
||||
/* The image is compressed. */
|
||||
|
||||
/* Open the original, compressed file. */
|
||||
cf = _wfopen(d86f[drive].original_file_name, L"wb");
|
||||
cf = plat_fopen(d86f[drive].original_file_name, L"wb");
|
||||
|
||||
/* Write the header to the original file. */
|
||||
fwrite(header, 1, header_size, cf);
|
||||
@@ -3364,10 +3365,10 @@ void d86f_load(int drive, wchar_t *fn)
|
||||
d86f_unregister(drive);
|
||||
|
||||
writeprot[drive] = 0;
|
||||
d86f[drive].f = _wfopen(fn, L"rb+");
|
||||
d86f[drive].f = plat_fopen(fn, L"rb+");
|
||||
if (!d86f[drive].f)
|
||||
{
|
||||
d86f[drive].f = _wfopen(fn, L"rb");
|
||||
d86f[drive].f = plat_fopen(fn, L"rb");
|
||||
if (!d86f[drive].f)
|
||||
{
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
@@ -3478,7 +3479,7 @@ void d86f_load(int drive, wchar_t *fn)
|
||||
fclose(d86f[drive].f);
|
||||
d86f[drive].f = NULL;
|
||||
|
||||
d86f[drive].f = _wfopen(temp_file_name, L"wb");
|
||||
d86f[drive].f = plat_fopen(temp_file_name, L"wb");
|
||||
if (!d86f[drive].f)
|
||||
{
|
||||
d86f_log("86F: Unable to create temporary decompressed file\n");
|
||||
@@ -3486,7 +3487,7 @@ void d86f_load(int drive, wchar_t *fn)
|
||||
return;
|
||||
}
|
||||
|
||||
tf = _wfopen(fn, L"rb");
|
||||
tf = plat_fopen(fn, L"rb");
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
@@ -3512,12 +3513,12 @@ void d86f_load(int drive, wchar_t *fn)
|
||||
if (!temp)
|
||||
{
|
||||
d86f_log("86F: Error decompressing file\n");
|
||||
_wremove(temp_file_name);
|
||||
plat_remove(temp_file_name);
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
return;
|
||||
}
|
||||
|
||||
d86f[drive].f = _wfopen(temp_file_name, L"rb+");
|
||||
d86f[drive].f = plat_fopen(temp_file_name, L"rb+");
|
||||
}
|
||||
|
||||
if (d86f[drive].disk_flags & 0x100)
|
||||
@@ -3528,7 +3529,7 @@ void d86f_load(int drive, wchar_t *fn)
|
||||
d86f[drive].f = NULL;
|
||||
if (d86f[drive].is_compressed)
|
||||
{
|
||||
_wremove(temp_file_name);
|
||||
plat_remove(temp_file_name);
|
||||
}
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
return;
|
||||
@@ -3542,7 +3543,7 @@ void d86f_load(int drive, wchar_t *fn)
|
||||
d86f[drive].f = NULL;
|
||||
if (d86f[drive].is_compressed)
|
||||
{
|
||||
_wremove(temp_file_name);
|
||||
plat_remove(temp_file_name);
|
||||
}
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
return;
|
||||
@@ -3561,11 +3562,11 @@ void d86f_load(int drive, wchar_t *fn)
|
||||
|
||||
if (d86f[drive].is_compressed)
|
||||
{
|
||||
d86f[drive].f = _wfopen(temp_file_name, L"rb");
|
||||
d86f[drive].f = plat_fopen(temp_file_name, L"rb");
|
||||
}
|
||||
else
|
||||
{
|
||||
d86f[drive].f = _wfopen(fn, L"rb");
|
||||
d86f[drive].f = plat_fopen(fn, L"rb");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3675,5 +3676,5 @@ void d86f_close(int drive)
|
||||
d86f[drive].f = NULL;
|
||||
}
|
||||
if (d86f[drive].is_compressed)
|
||||
_wremove(temp_file_name);
|
||||
plat_remove(temp_file_name);
|
||||
}
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
* Implementation of the FDI floppy stream image format
|
||||
* interface to the FDI2RAW module.
|
||||
*
|
||||
* Version: @(#)floppy_fdi.c 1.0.2 2017/09/24
|
||||
* Version: @(#)floppy_fdi.c 1.0.3 2017/10/12
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
*/
|
||||
@@ -21,6 +22,7 @@
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include "../ibm.h"
|
||||
#include "../plat.h"
|
||||
#include "floppy.h"
|
||||
#include "floppy_86f.h"
|
||||
#include "floppy_img.h"
|
||||
@@ -264,7 +266,7 @@ void fdi_load(int drive, wchar_t *fn)
|
||||
char header[26];
|
||||
|
||||
writeprot[drive] = fwriteprot[drive] = 1;
|
||||
fdi[drive].f = _wfopen(fn, L"rb");
|
||||
fdi[drive].f = plat_fopen(fn, L"rb");
|
||||
if (!fdi[drive].f)
|
||||
{
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Implementation of the IMD floppy image format.
|
||||
*
|
||||
* Version: @(#)floppy_imd.c 1.0.2 2017/09/24
|
||||
* Version: @(#)floppy_imd.c 1.0.3 2017/10/12
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include "../ibm.h"
|
||||
#include "../plat.h"
|
||||
#include "floppy.h"
|
||||
#include "floppy_imd.h"
|
||||
#include "fdc.h"
|
||||
@@ -89,10 +90,10 @@ void imd_load(int drive, wchar_t *fn)
|
||||
d86f_unregister(drive);
|
||||
|
||||
writeprot[drive] = 0;
|
||||
imd[drive].f = _wfopen(fn, L"rb+");
|
||||
imd[drive].f = plat_fopen(fn, L"rb+");
|
||||
if (!imd[drive].f)
|
||||
{
|
||||
imd[drive].f = _wfopen(fn, L"rb");
|
||||
imd[drive].f = plat_fopen(fn, L"rb");
|
||||
if (!imd[drive].f)
|
||||
{
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
* Implementation of the raw sector-based floppy image format,
|
||||
* as well as the Japanese FDI, CopyQM, and FDF formats.
|
||||
*
|
||||
* Version: @(#)floppy_img.c 1.0.2 2017/09/24
|
||||
* Version: @(#)floppy_img.c 1.0.3 2017/10/12
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
*/
|
||||
@@ -23,6 +24,7 @@
|
||||
#include <wchar.h>
|
||||
#include "../ibm.h"
|
||||
#include "../config.h"
|
||||
#include "../plat.h"
|
||||
#include "floppy.h"
|
||||
#include "floppy_img.h"
|
||||
#include "fdc.h"
|
||||
@@ -349,10 +351,10 @@ void img_load(int drive, wchar_t *fn)
|
||||
d86f_unregister(drive);
|
||||
|
||||
writeprot[drive] = 0;
|
||||
img[drive].f = _wfopen(fn, L"rb+");
|
||||
img[drive].f = plat_fopen(fn, L"rb+");
|
||||
if (!img[drive].f)
|
||||
{
|
||||
img[drive].f = _wfopen(fn, L"rb");
|
||||
img[drive].f = plat_fopen(fn, L"rb");
|
||||
if (!img[drive].f)
|
||||
{
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
@@ -370,7 +372,7 @@ void img_load(int drive, wchar_t *fn)
|
||||
|
||||
img[drive].interleave = img[drive].skew = 0;
|
||||
|
||||
if (_wcsicmp(ext, L"FDI") == 0)
|
||||
if (! wcscasecmp(ext, L"FDI"))
|
||||
{
|
||||
/* This is a Japanese FDI image, so let's read the header */
|
||||
pclog("img_load(): File is a Japanese FDI image...\n");
|
||||
@@ -415,7 +417,7 @@ void img_load(int drive, wchar_t *fn)
|
||||
pclog("img_load(): File is a FDF image...\n");
|
||||
fwriteprot[drive] = writeprot[drive] = 1;
|
||||
fclose(img[drive].f);
|
||||
img[drive].f = _wfopen(fn, L"rb");
|
||||
img[drive].f = plat_fopen(fn, L"rb");
|
||||
|
||||
fdf = 1;
|
||||
|
||||
@@ -600,7 +602,7 @@ void img_load(int drive, wchar_t *fn)
|
||||
pclog("img_load(): File is a CopyQM image...\n");
|
||||
fwriteprot[drive] = writeprot[drive] = 1;
|
||||
fclose(img[drive].f);
|
||||
img[drive].f = _wfopen(fn, L"rb");
|
||||
img[drive].f = plat_fopen(fn, L"rb");
|
||||
|
||||
fseek(img[drive].f, 0x03, SEEK_SET);
|
||||
fread(&bpb_bps, 1, 2, img[drive].f);
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
*
|
||||
* Implementation of the PCjs JSON floppy image format.
|
||||
*
|
||||
* Version: @(#)floppy_json.c 1.0.4 2017/10/07
|
||||
* Version: @(#)floppy_json.c 1.0.6 2017/10/12
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
@@ -19,6 +20,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include "../ibm.h"
|
||||
#include "../plat.h"
|
||||
#include "floppy.h"
|
||||
#include "fdc.h"
|
||||
#include "fdd.h"
|
||||
@@ -476,7 +478,7 @@ json_load(int drive, wchar_t *fn)
|
||||
memset(img, 0x00, sizeof(json_t));
|
||||
|
||||
/* Open the image file. */
|
||||
img->f = _wfopen(fn, L"rb");
|
||||
img->f = plat_fopen(fn, L"rb");
|
||||
if (img->f == NULL) {
|
||||
memset(fn, 0x00, sizeof(wchar_t));
|
||||
return;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Implementation of the Teledisk floppy image format.
|
||||
*
|
||||
* Version: @(#)floppy_td0.c 1.0.3 2017/09/24
|
||||
* Version: @(#)floppy_td0.c 1.0.4 2017/10/12
|
||||
*
|
||||
* Authors: Milodrag Milanovic,
|
||||
* Haruhiko OKUMURA,
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include "../ibm.h"
|
||||
#include "../plat.h"
|
||||
#include "floppy.h"
|
||||
#include "floppy_td0.h"
|
||||
#include "fdc.h"
|
||||
@@ -533,7 +534,7 @@ void td0_load(int drive, wchar_t *fn)
|
||||
d86f_unregister(drive);
|
||||
|
||||
writeprot[drive] = 1;
|
||||
td0[drive].f = _wfopen(fn, L"rb");
|
||||
td0[drive].f = plat_fopen(fn, L"rb");
|
||||
if (!td0[drive].f)
|
||||
{
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
|
||||
Reference in New Issue
Block a user