mirror of
https://github.com/fadden/ciderpress.git
synced 2024-11-26 17:49:21 +00:00
51b5f00f5c
CiderPress and MDC now compile, and execute far enough to open their respective "about" boxes, but I doubt they'll do much more than that. * Switch from MBCS to UNICODE APIs Microsoft switched to UTF-16 (by way of UCS-2) a long time ago, and the support for MBCS seems to be getting phased out. So it's time to switch to wide strings. This is a bit awkward for CiderPress because it works with disk and file archives with 8-bit filenames, and I want NufxLib and DiskImgLib to continue to work on Linux (which has largely taken the UTF-8 approach to Unicode). The libraries will continue to work with 8-bit filenames, with CiderPress/MDC doing the conversion at the appropriate point. There were a couple of places where strings from a structure handed back by one of the libraries were used directly in the UI, or vice-versa, which is a problem because we have nowhere to store the result of the conversion. These currently have fixed place-holder "xyzzy" strings. All UI strings are now wide. Various format strings now use "%ls" and "%hs" to explicitly specify wide and narrow. This doesn't play well with gcc, so only the Windows-specific parts use those. * Various updates to vcxproj files The project-file conversion had some cruft that is now largely gone. The build now has a common output directory for the EXEs and libraries, avoiding the old post-build copy steps. * Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots The old "prebuilts" directory is now gone. The libraries are now built as part of building the apps. I added a minimal set of files for zlib, and a full set for nufxlib. The Linux-specific nufxlib goodies are included for the benefit of the Linux utilities, which are currently broken (don't build). * Replace symbols used for include guards Symbols with a leading "__" are reserved.
309 lines
9.7 KiB
C++
309 lines
9.7 KiB
C++
/*
|
|
* CiderPress
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
* See the file LICENSE for distribution terms.
|
|
*/
|
|
/*
|
|
* Support for disk image conversion dialog
|
|
*/
|
|
#include "StdAfx.h"
|
|
#include "DiskConvertDialog.h"
|
|
#include "HelpTopics.h"
|
|
|
|
using namespace DiskImgLib;
|
|
|
|
BEGIN_MESSAGE_MAP(DiskConvertDialog, CDialog)
|
|
ON_CONTROL_RANGE(BN_CLICKED, IDC_DISKCONV_DOS, IDC_DISKCONV_DDD, OnChangeRadio)
|
|
ON_WM_HELPINFO()
|
|
ON_COMMAND(IDHELP, OnHelp)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
/*
|
|
* Initialize the set of available options based on the source image.
|
|
*/
|
|
void
|
|
DiskConvertDialog::Init(const DiskImg* pDiskImg)
|
|
{
|
|
ASSERT(pDiskImg != nil);
|
|
const int kMagicNibbles = -1234;
|
|
bool hasBlocks = pDiskImg->GetHasBlocks();
|
|
bool hasSectors = pDiskImg->GetHasSectors();
|
|
bool hasNibbles = pDiskImg->GetHasNibbles();
|
|
long diskSizeInSectors;
|
|
|
|
ASSERT(fSizeInBlocks == -1);
|
|
if (hasBlocks) {
|
|
diskSizeInSectors = pDiskImg->GetNumBlocks() * 2;
|
|
fSizeInBlocks = diskSizeInSectors / 2;
|
|
} else if (hasSectors) {
|
|
diskSizeInSectors =
|
|
pDiskImg->GetNumTracks() * pDiskImg->GetNumSectPerTrack();
|
|
if (pDiskImg->GetNumSectPerTrack() != 13)
|
|
fSizeInBlocks = diskSizeInSectors / 2;
|
|
} else {
|
|
ASSERT(hasNibbles);
|
|
diskSizeInSectors = kMagicNibbles;
|
|
}
|
|
|
|
if (diskSizeInSectors >= 8388608) {
|
|
/* no conversions for files 2GB and larger except .PO */
|
|
fDiskDescription.Format(IDS_CDESC_BLOCKS, diskSizeInSectors/4);
|
|
fAllowUnadornedProDOS = true;
|
|
fConvertIdx = kConvProDOSRaw;
|
|
} else if (diskSizeInSectors == 35*16) {
|
|
/* 140K disk image */
|
|
fDiskDescription.LoadString(IDS_CDESC_140K);
|
|
fAllowUnadornedDOS = true;
|
|
fAllowUnadornedProDOS = true;
|
|
fAllowProDOS2MG = true;
|
|
fAllowUnadornedNibble = true;
|
|
fAllowNuFX = true;
|
|
fAllowTrackStar = true;
|
|
fAllowSim2eHDV = true;
|
|
fAllowDDD = true;
|
|
if (hasNibbles)
|
|
fConvertIdx = kConvNibbleRaw;
|
|
else
|
|
fConvertIdx = kConvDOSRaw;
|
|
} else if (diskSizeInSectors == 40*16 &&
|
|
(pDiskImg->GetFileFormat() == DiskImg::kFileFormatTrackStar ||
|
|
pDiskImg->GetFileFormat() == DiskImg::kFileFormatFDI))
|
|
{
|
|
/* 40-track TrackStar or FDI image; allow conversion to 35-track formats */
|
|
fDiskDescription.LoadString(IDS_CDESC_40TRACK);
|
|
ASSERT(pDiskImg->GetHasBlocks());
|
|
fAllowUnadornedDOS = true;
|
|
fAllowUnadornedProDOS = true;
|
|
fAllowProDOS2MG = true;
|
|
fAllowUnadornedNibble = true;
|
|
fAllowNuFX = true;
|
|
fAllowSim2eHDV = true;
|
|
fAllowDDD = true;
|
|
fAllowTrackStar = true;
|
|
fConvertIdx = kConvDOSRaw;
|
|
} else if (diskSizeInSectors == 35*13) {
|
|
/* 13-sector 5.25" floppy */
|
|
fDiskDescription.LoadString(IDS_CDEC_140K_13);
|
|
fAllowUnadornedNibble = true;
|
|
fAllowD13 = true;
|
|
fConvertIdx = kConvNibbleRaw;
|
|
} else if (diskSizeInSectors == kMagicNibbles) {
|
|
/* blob of nibbles with no recognizable format; allow self-convert */
|
|
fDiskDescription.LoadString(IDS_CDEC_RAWNIB);
|
|
if (pDiskImg->GetPhysicalFormat() == DiskImg::kPhysicalFormatNib525_6656)
|
|
{
|
|
fAllowUnadornedNibble = true;
|
|
fConvertIdx = kConvNibbleRaw;
|
|
} else if (pDiskImg->GetPhysicalFormat() == DiskImg::kPhysicalFormatNib525_Var)
|
|
{
|
|
fAllowTrackStar = true;
|
|
fConvertIdx = kConvTrackStar;
|
|
} else if (pDiskImg->GetPhysicalFormat() == DiskImg::kPhysicalFormatNib525_6384)
|
|
{
|
|
/* don't currently allow .nb2 output */
|
|
WMSG0(" GLITCH: we don't allow self-convert of .nb2 files\n");
|
|
ASSERT(false);
|
|
} else {
|
|
/* this should be impossible */
|
|
ASSERT(false);
|
|
}
|
|
} else if (diskSizeInSectors == 3200) {
|
|
/* 800K disk image */
|
|
fDiskDescription.LoadString(IDS_CDESC_800K);
|
|
fAllowUnadornedDOS = true;
|
|
fAllowUnadornedProDOS = true;
|
|
fAllowProDOS2MG = true;
|
|
fAllowDiskCopy42 = true;
|
|
fAllowNuFX = true;
|
|
fAllowSim2eHDV = true;
|
|
fConvertIdx = kConvProDOS2MG;
|
|
} else {
|
|
/* odd-sized disk image; could allow DOS if hasSectors */
|
|
fDiskDescription.Format(IDS_CDESC_BLOCKS, diskSizeInSectors/4);
|
|
fAllowUnadornedProDOS = true;
|
|
fAllowProDOS2MG = true;
|
|
fAllowNuFX = true;
|
|
fAllowSim2eHDV = true;
|
|
fConvertIdx = kConvProDOS2MG;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Initialize options for a bulk transfer.
|
|
*/
|
|
void
|
|
DiskConvertDialog::Init(int fileCount)
|
|
{
|
|
/* allow everything */
|
|
fAllowUnadornedDOS = fAllowUnadornedProDOS = fAllowProDOS2MG =
|
|
fAllowUnadornedNibble = fAllowD13 = fAllowDiskCopy42 =
|
|
fAllowNuFX = fAllowTrackStar = fAllowSim2eHDV = fAllowDDD = true;
|
|
fConvertIdx = kConvDOSRaw; // default choice == first in list
|
|
fBulkFileCount = fileCount;
|
|
fDiskDescription.Format(L"%d images selected", fBulkFileCount);
|
|
}
|
|
|
|
|
|
/*
|
|
* Disable unavailable options.
|
|
*/
|
|
BOOL
|
|
DiskConvertDialog::OnInitDialog(void)
|
|
{
|
|
CWnd* pWnd;
|
|
|
|
ASSERT(fConvertIdx != -1); // must call Init before DoModal
|
|
|
|
if (!fAllowUnadornedDOS) {
|
|
pWnd = GetDlgItem(IDC_DISKCONV_DOS);
|
|
pWnd->EnableWindow(FALSE);
|
|
pWnd = GetDlgItem(IDC_DISKCONV_DOS2MG);
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
if (!fAllowUnadornedProDOS) {
|
|
pWnd = GetDlgItem(IDC_DISKCONV_PRODOS);
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
if (!fAllowProDOS2MG) {
|
|
pWnd = GetDlgItem(IDC_DISKCONV_PRODOS2MG);
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
if (!fAllowUnadornedNibble) {
|
|
pWnd = GetDlgItem(IDC_DISKCONV_NIB);
|
|
pWnd->EnableWindow(FALSE);
|
|
pWnd = GetDlgItem(IDC_DISKCONV_NIB2MG);
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
if (!fAllowD13) {
|
|
pWnd = GetDlgItem(IDC_DISKCONV_D13);
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
if (!fAllowDiskCopy42) {
|
|
pWnd = GetDlgItem(IDC_DISKCONV_DC42);
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
if (!fAllowNuFX) {
|
|
pWnd = GetDlgItem(IDC_DISKCONV_SDK);
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
if (!fAllowTrackStar) {
|
|
pWnd = GetDlgItem(IDC_DISKCONV_TRACKSTAR);
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
if (!fAllowSim2eHDV) {
|
|
pWnd = GetDlgItem(IDC_DISKCONV_HDV);
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
if (!fAllowDDD) {
|
|
pWnd = GetDlgItem(IDC_DISKCONV_DDD);
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
|
|
if (fBulkFileCount < 0) {
|
|
pWnd = GetDlgItem(IDC_IMAGE_TYPE);
|
|
pWnd->SetWindowText(fDiskDescription);
|
|
} else {
|
|
CRect rect;
|
|
int right;
|
|
pWnd = GetDlgItem(IDC_IMAGE_TYPE);
|
|
pWnd->GetWindowRect(&rect);
|
|
ScreenToClient(&rect);
|
|
right = rect.right;
|
|
pWnd->DestroyWindow();
|
|
|
|
pWnd = GetDlgItem(IDC_IMAGE_SIZE_TEXT);
|
|
pWnd->GetWindowRect(&rect);
|
|
ScreenToClient(&rect);
|
|
rect.right = right;
|
|
pWnd->MoveWindow(&rect);
|
|
pWnd->SetWindowText(fDiskDescription);
|
|
}
|
|
|
|
OnChangeRadio(0); // set the gzip box
|
|
|
|
CDialog::OnInitDialog();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/*
|
|
* Convert options in and out.
|
|
*/
|
|
void
|
|
DiskConvertDialog::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
DDX_Check(pDX, IDC_DISKCONV_GZIP, fAddGzip);
|
|
DDX_Radio(pDX, IDC_DISKCONV_DOS, fConvertIdx);
|
|
|
|
if (pDX->m_bSaveAndValidate) {
|
|
switch (fConvertIdx) {
|
|
case kConvDOSRaw: fExtension = L"do"; break;
|
|
case kConvDOS2MG: fExtension = L"2mg"; break;
|
|
case kConvProDOSRaw: fExtension = L"po"; break;
|
|
case kConvProDOS2MG: fExtension = L"2mg"; break;
|
|
case kConvNibbleRaw: fExtension = L"nib"; break;
|
|
case kConvNibble2MG: fExtension = L"2mg"; break;
|
|
case kConvD13: fExtension = L"d13"; break;
|
|
case kConvDiskCopy42: fExtension = L"dsk"; break;
|
|
case kConvNuFX: fExtension = L"sdk"; break;
|
|
case kConvTrackStar: fExtension = L"app"; break;
|
|
case kConvSim2eHDV: fExtension = L"hdv"; break;
|
|
case kConvDDD: fExtension = L"ddd"; break;
|
|
default:
|
|
fExtension = L"???";
|
|
ASSERT(false);
|
|
break;
|
|
}
|
|
|
|
if (fAddGzip && fConvertIdx != kConvNuFX) {
|
|
fExtension += L".gz";
|
|
}
|
|
|
|
WMSG1(" DCD recommending extension '%ls'\n", (LPCWSTR) fExtension);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* If the radio button selection changes, we may need to disable the gzip
|
|
* checkbox to show that NuFX can't be combined with gzip.
|
|
*
|
|
* If the underlying disk is over 32MB, disable gzip, because we won't be
|
|
* able to open the disk we create.
|
|
*/
|
|
void
|
|
DiskConvertDialog::OnChangeRadio(UINT nID)
|
|
{
|
|
CWnd* pGzip = GetDlgItem(IDC_DISKCONV_GZIP);
|
|
ASSERT(pGzip != nil);
|
|
CButton* pNuFX = (CButton*)GetDlgItem(IDC_DISKCONV_SDK);
|
|
ASSERT(pNuFX != nil);
|
|
|
|
if (fSizeInBlocks > DiskImgLib::kGzipMax / 512)
|
|
pGzip->EnableWindow(FALSE);
|
|
else
|
|
pGzip->EnableWindow(pNuFX->GetCheck() == BST_UNCHECKED);
|
|
}
|
|
|
|
/*
|
|
* Context help request (question mark button).
|
|
*/
|
|
BOOL
|
|
DiskConvertDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
|
|
{
|
|
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
|
|
return TRUE; // yes, we handled it
|
|
}
|
|
|
|
/*
|
|
* User pressed the "Help" button.
|
|
*/
|
|
void
|
|
DiskConvertDialog::OnHelp(void)
|
|
{
|
|
if (fBulkFileCount < 0)
|
|
WinHelp(HELP_TOPIC_DISK_CONV, HELP_CONTEXT);
|
|
else
|
|
WinHelp(HELP_TOPIC_BULK_DISK_CONV, HELP_CONTEXT);
|
|
}
|