From 4e9ee6e927d3d3f45edc44539c36f7b3829c5834 Mon Sep 17 00:00:00 2001 From: TomW Date: Mon, 24 Aug 2015 21:09:35 +0100 Subject: [PATCH] Can now select to emulate 1.2MB 5.25" disc drive, with double stepping. --- src/disc.c | 1 + src/disc.h | 1 + src/disc_img.c | 17 +++++++++++++++++ src/pc.c | 7 +++++++ src/pc.rc | 22 +++++++++++++--------- src/resources.h | 2 ++ src/win-config.c | 15 +++++++++++++++ 7 files changed, 56 insertions(+), 9 deletions(-) diff --git a/src/disc.c b/src/disc.c index 6484e28..3e36d38 100644 --- a/src/disc.c +++ b/src/disc.c @@ -14,6 +14,7 @@ int disc_track[2]; int writeprot[2], fwriteprot[2]; DRIVE drives[2]; +int drive_type[2]; int curdrive = 0; diff --git a/src/disc.h b/src/disc.h index d6bae79..31eb3a7 100644 --- a/src/disc.h +++ b/src/disc.h @@ -56,3 +56,4 @@ extern int writeprot[2], fwriteprot[2]; extern int disc_track[2]; extern int disc_changed[2]; extern int drive_empty[2]; +extern int drive_type[2]; diff --git a/src/disc_img.c b/src/disc_img.c index 191fec1..818d605 100644 --- a/src/disc_img.c +++ b/src/disc_img.c @@ -87,7 +87,12 @@ void img_seek(int drive, int track) if (!img[drive].f) return; // pclog("Seek drive=%i track=%i sectors=%i sector_size=%i sides=%i\n", drive, track, img[drive].sectors,img[drive].sector_size, img[drive].sides); + + if (drive_type[drive] && img[drive].tracks == 40) + track /= 2; + disc_track[drive] = track; + if (img[drive].sides == 2) { fseek(img[drive].f, track * img[drive].sectors * img[drive].sector_size * 2, SEEK_SET); @@ -120,6 +125,9 @@ void img_writeback(int drive, int track) void img_readsector(int drive, int sector, int track, int side, int rate) { + if (drive_type[drive] && rate == 1) + rate = 2; + img_sector = sector - 1; img_track = track; img_side = side; @@ -142,6 +150,9 @@ void img_readsector(int drive, int sector, int track, int side, int rate) void img_writesector(int drive, int sector, int track, int side, int rate) { + if (drive_type[drive] && rate == 1) + rate = 2; + // if (imgdblstep[drive]) track/=2; img_sector = sector - 1; img_track = track; @@ -163,6 +174,9 @@ void img_writesector(int drive, int sector, int track, int side, int rate) void img_readaddress(int drive, int track, int side, int rate) { + if (drive_type[drive] && rate == 1) + rate = 2; + img_drive = drive; img_track = track; img_side = side; @@ -183,6 +197,9 @@ void img_readaddress(int drive, int track, int side, int rate) void img_format(int drive, int track, int side, int rate) { + if (drive_type[drive] && rate == 1) + rate = 2; + img_drive = drive; img_track = track; img_side = side; diff --git a/src/pc.c b/src/pc.c index 5389fa4..bfb9944 100644 --- a/src/pc.c +++ b/src/pc.c @@ -7,6 +7,7 @@ #include "ali1429.h" #include "amstrad.h" #include "cdrom-ioctl.h" +#include "disc.h" #include "mem.h" #include "x86_ops.h" #include "codegen.h" @@ -563,6 +564,9 @@ void loadconfig(char *fn) p = (char *)config_get_string(NULL, "hdf_fn", ""); if (p) strcpy(ide_fn[3], p); else strcpy(ide_fn[3], ""); + + drive_type[0] = config_get_int(NULL, "drive_a_type", 0); + drive_type[1] = config_get_int(NULL, "drive_b_type", 0); } void saveconfig() @@ -611,6 +615,9 @@ void saveconfig() config_set_int(NULL, "hdf_heads", hdc[3].hpc); config_set_int(NULL, "hdf_cylinders", hdc[3].tracks); config_set_string(NULL, "hdf_fn", ide_fn[3]); + + config_set_int(NULL, "drive_a_type", drive_type[0]); + config_set_int(NULL, "drive_b_type", drive_type[1]); config_save(config_file_default); } diff --git a/src/pc.rc b/src/pc.rc index 8bb36e8..b6cc209 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -55,13 +55,13 @@ BEGIN END END -ConfigureDlg DIALOGEX 0, 0, 232+40, 292 +ConfigureDlg DIALOGEX 0, 0, 232+40, 292+40 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Configure PCem" FONT 8, "MS Sans Serif" BEGIN - DEFPUSHBUTTON "OK",IDOK,64,268,50,14, WS_TABSTOP - PUSHBUTTON "Cancel",IDCANCEL,128,268,50,14, WS_TABSTOP + DEFPUSHBUTTON "OK",IDOK,64,308,50,14, WS_TABSTOP + PUSHBUTTON "Cancel",IDCANCEL,128,308,50,14, WS_TABSTOP COMBOBOX IDC_COMBO1,62,16,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBOVID,62,36,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Configure", IDC_CONFIGUREVID, 224, 36, 40, 14, WS_TABSTOP @@ -75,12 +75,12 @@ BEGIN EDITTEXT IDC_MEMTEXT, 62, 172, 36, 14, ES_AUTOHSCROLL | ES_NUMBER CONTROL "", IDC_MEMSPIN, UPDOWN_CLASS, UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_SETBUDDYINT, 98, 172, 12, 14 LTEXT "MB", IDC_STATIC, 98, 172, 40, 10 - CONTROL "CMS / Game Blaster",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,192,118,10 - CONTROL "Gravis Ultrasound",IDC_CHECKGUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,208,118,10 - CONTROL "Innovation SSI-2001",IDC_CHECKSSI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,224,118,10 - CONTROL "Composite CGA",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,240,118,10 - CONTROL "Voodoo Graphics",IDC_CHECKVOODOO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,256,118,10 - PUSHBUTTON "Configure", IDC_CONFIGUREVOODOO, 224, 256, 40, 14, WS_TABSTOP + CONTROL "CMS / Game Blaster",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,232,118,10 + CONTROL "Gravis Ultrasound",IDC_CHECKGUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,248,118,10 + CONTROL "Innovation SSI-2001",IDC_CHECKSSI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,264,118,10 + CONTROL "Composite CGA",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,280,118,10 + CONTROL "Voodoo Graphics",IDC_CHECKVOODOO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,296,118,10 + PUSHBUTTON "Configure", IDC_CONFIGUREVOODOO, 224, 296, 40, 14, WS_TABSTOP LTEXT "Machine :",IDC_STATIC,15,16,40,10 LTEXT "Video :",IDC_STATIC,15,36,34,10 LTEXT "CPU type :",IDC_STATIC,15,56,34,10 @@ -89,6 +89,10 @@ BEGIN LTEXT "Video speed :",IDC_STATIC,15,136,40,10 LTEXT "Soundcard :",IDC_STATIC,15,156,40,10 LTEXT "Memory :",IDC_STATIC,15,176,40,10 + LTEXT "Drive A: :",IDC_STATIC,15,196,40,10 + LTEXT "Drive B: :",IDC_STATIC,15,216,40,10 + COMBOBOX IDC_COMBODRA,62,196,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBODRB,62,216,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP END HdConfDlg DIALOGEX 0, 0, 210, 312 diff --git a/src/resources.h b/src/resources.h index 4e271f5..6e06248 100644 --- a/src/resources.h +++ b/src/resources.h @@ -34,6 +34,8 @@ #define IDC_COMBOCHC 1008 #define IDC_COMBOCPUM 1060 #define IDC_COMBOSPD 1061 +#define IDC_COMBODRA 1062 +#define IDC_COMBODRB 1063 #define IDC_CHECK1 1010 #define IDC_CHECK2 1011 #define IDC_CHECK3 1012 diff --git a/src/win-config.c b/src/win-config.c index 70d84d0..998cca3 100644 --- a/src/win-config.c +++ b/src/win-config.c @@ -8,6 +8,7 @@ #include "ibm.h" #include "cpu.h" #include "device.h" +#include "disc.h" #include "model.h" #include "resources.h" #include "sound.h" @@ -181,6 +182,15 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR else EnableWindow(h, FALSE); + h = GetDlgItem(hdlg, IDC_COMBODRA); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"5.25\" 360k / 3.5\""); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"5.25\" 1.2M"); + SendMessage(h, CB_SETCURSEL, drive_type[0], 0); + h = GetDlgItem(hdlg, IDC_COMBODRB); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"5.25\" 360k / 3.5\""); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"5.25\" 1.2M"); + SendMessage(h, CB_SETCURSEL, drive_type[1], 0); + return TRUE; case WM_COMMAND: @@ -273,6 +283,11 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR h = GetDlgItem(hdlg, IDC_COMBOCHC); cache=SendMessage(h, CB_GETCURSEL, 0, 0); mem_updatecache(); + + h = GetDlgItem(hdlg, IDC_COMBODRA); + drive_type[0] = SendMessage(h, CB_GETCURSEL, 0, 0); + h = GetDlgItem(hdlg, IDC_COMBODRB); + drive_type[1] = SendMessage(h, CB_GETCURSEL, 0, 0); saveconfig();