Fixes for the (S)VGA common DAC and some card-specific DAT's (ATi 68860, BT48x family, and the Cirrus Logic DAC), fixes Star Control II among other things.

This commit is contained in:
OBattler
2018-10-04 01:19:43 +02:00
parent 6b938d63c3
commit ed92602dad
883 changed files with 444853 additions and 88 deletions

View File

@@ -0,0 +1,699 @@
#
# 86Box A hypervisor and IBM PC system emulator that specializes in
# running old operating systems and software designed for IBM
# PC systems and compatibles from 1981 through fairly recent
# system designs based on the PCI bus.
#
# This file is part of the 86Box distribution.
#
# Makefile for Win32 (MinGW32) environment.
#
# Version: @(#)Makefile.mingw 1.0.116 2018/05/01
#
# Authors: Miran Grca, <mgrca8@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com>
#
# Various compile-time options.
ifndef STUFF
STUFF :=
endif
# Add feature selections here.
ifndef EXTRAS
EXTRAS :=
endif
ifndef DEV_BUILD
DEV_BUILD := n
endif
ifeq ($(DEV_BUILD), y)
ifndef DEBUG
DEBUG := y
endif
ifndef DEV_BRANCH
DEV_BRANCH := y
endif
ifndef AMD_K
AMD_K := y
endif
ifndef CRASHDUMP
CRASHDUMP := y
endif
ifndef GREENB
GREENB := y
endif
ifndef I686
I686 := y
endif
ifndef LASERXT
LASERXT := y
endif
ifndef MRTHOR
MRTHOR := y
endif
ifndef NV_RIVA
NV_RIVA := y
endif
ifndef PAS16
PAS16 := y
endif
ifndef PORTABLE3
PORTABLE3 := y
endif
ifndef STEALTH32
STEALTH32 := y
endif
ifndef VNC
VNC := y
endif
ifndef XL24
XL24 := y
endif
else
ifndef DEBUG
DEBUG := n
endif
ifndef DEV_BRANCH
DEV_BRANCH := n
endif
ifndef AMD_K
AMD_K := n
endif
ifndef CRASHDUMP
CRASHDUMP := n
endif
ifndef GREENB
GREENB := n
endif
ifndef I686
I686 := n
endif
ifndef LASERXT
LASERXT := n
endif
ifndef MRTHOR
MRTHOR := n
endif
ifndef NV_RIVA
NV_RIVA := n
endif
ifndef PAS16
PAS16 := n
endif
ifndef PORTABLE3
PORTABLE3 := n
endif
ifndef STEALTH32
STEALTH32 := n
endif
ifndef VGAWONDER
VGAWONDER := n
endif
ifndef VNC
VNC := n
endif
ifndef XL24
XL24 := n
endif
endif
# Defaults for several build options (possibly defined in a chained file.)
ifndef AUTODEP
AUTODEP := n
endif
ifndef OPTIM
OPTIM := n
endif
ifndef RELEASE
RELEASE := n
endif
ifndef X64
X64 := n
endif
ifndef WX
WX := n
endif
ifndef USB
USB := n
endif
ifndef RDP
RDP := n
endif
ifndef OPENAL
OPENAL := y
endif
ifndef FLUIDSYNTH
FLUIDSYNTH := y
endif
ifndef MUNT
MUNT := y
endif
ifndef DYNAREC
DYNAREC := y
endif
# Name of the executable.
ifndef PROG
ifneq ($(WX), n)
PROG := Wx86Box
else
PROG := 86Box
endif
endif
# WxWidgets basic info. Extract using the config program.
ifneq ($(WX), n)
EXPATH += wx
WX_CONFIG := wx-config.exe
ifeq ($(WX), y)
WX_PATH := C:/MinGW32/WxWidgets
WX_FLAGS := -I$(WX_PATH)/lib/wx/include/msw-unicode-3.0 \
-I$(WX_PATH)/include/wx-3.0 \
-D__WXMSW__ -DWX_PRECOMP -D_FILE_OFFSET_BITS=64 -pthread
# -lwx_mswu_gl-3.0 -lwxtiff-3.0 -llzma
WX_LIBS := -mwindows -mthreads -L$(WX_PATH)/lib \
-lwx_mswu-3.0.dll \
-lrpcrt4 -loleaut32 -lole32 -luuid \
-lwinspool -lwinmm -lshell32 -lcomctl32 \
-lcomdlg32 -ladvapi32 -lwsock32 -lgdi32
endif
ifeq ($(WX), static)
WX_PATH := C:/MinGW32/WxWidgets
WX_FLAGS := -I$(WX_PATH)/lib/wx/include/msw-unicode-3.0 \
-I$(WX_PATH)/include/wx-3.0 \
-D__WXMSW__ -DWX_PRECOMP -D_FILE_OFFSET_BITS=64 -pthread
# -lwx_mswu_gl-3.0 -lwxtiff-3.0 -llzma
WX_LIBS := -mwindows -mthreads -L$(WX_PATH)/lib \
-lwx_mswu-3.0 -lwxscintilla-3.0 \
-lwxjpeg-3.0 -lwxpng-3.0 -lwxzlib-3.0 \
-lwxregexu-3.0 -lwxexpat-3.0 \
-lrpcrt4 -loleaut32 -lole32 -luuid \
-lwinspool -lwinmm -lshell32 -lcomctl32 \
-lcomdlg32 -ladvapi32 -lwsock32 -lgdi32
endif
endif
#########################################################################
# Nothing should need changing from here on.. #
#########################################################################
VPATH := $(EXPATH) . cpu \
cdrom disk floppy game machine \
sound \
sound/munt sound/munt/c_interface sound/munt/sha1 \
sound/munt/srchelper \
sound/resid-fp \
scsi video network network/slirp win
ifeq ($(X64), y)
CPP := g++ -m64
CC := gcc -m64
else
CPP := g++ -m32
CC := gcc -m32
endif
WINDRES := windres
DEPS = -MMD -MF $*.d -c $<
DEPFILE := win/.depends
# Set up the correct toolchain flags.
OPTS := $(EXTRAS) $(STUFF)
ifdef EXFLAGS
OPTS += $(EXFLAGS)
endif
ifdef EXINC
OPTS += -I$(EXINC)
endif
ifeq ($(X64), y)
ifeq ($(OPTIM), y)
DFLAGS := -march=native
else
DFLAGS :=
endif
else
ifeq ($(OPTIM), y)
DFLAGS := -march=native
else
DFLAGS := -march=i686
endif
endif
ifeq ($(DEBUG), y)
DFLAGS += -ggdb -DDEBUG
AOPTIM :=
ifndef COPTIM
COPTIM := -Og
endif
else
DFLAGS += -g0
ifeq ($(OPTIM), y)
AOPTIM := -mtune=native
ifndef COPTIM
COPTIM := -O3 -flto
endif
else
ifndef COPTIM
COPTIM := -O3
endif
endif
endif
AFLAGS := -msse2 -mfpmath=sse
RFLAGS := --input-format=rc -O coff
ifeq ($(RELEASE), y)
OPTS += -DRELEASE_BUILD
RFLAGS += -DRELEASE_BUILD
endif
ifeq ($(VRAMDUMP), y)
OPTS += -DENABLE_VRAM_DUMP
RFLAGS += -DENABLE_VRAM_DUMP
endif
ifeq ($(X64), y)
PLATCG := codegen_x86-64.o
CGOPS := codegen_ops_x86-64.h
VCG := vid_voodoo_codegen_x86-64.h
else
PLATCG := codegen_x86.o
CGOPS := codegen_ops_x86.h
VCG := vid_voodoo_codegen_x86.h
endif
# Optional modules.
ifeq ($(DYNAREC), y)
OPTS += -DUSE_DYNAREC
RFLAGS += -DUSE_DYNAREC
DYNARECOBJ := 386_dynarec_ops.o \
codegen.o \
codegen_ops.o \
codegen_timing_common.o codegen_timing_486.o \
codegen_timing_686.o codegen_timing_pentium.o \
codegen_timing_winchip.o $(PLATCG)
endif
ifneq ($(WX), n)
OPTS += -DUSE_WX $(WX_FLAGS)
LIBS += $(WX_LIBS)
UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o
else
UIOBJ := win_ui.o win_stbar.o \
win_ddraw.o win_d3d.o \
win_dialog.o win_about.o \
win_settings.o win_devconf.o win_snd_gain.o \
win_new_floppy.o win_jsconf.o
endif
ifeq ($(OPENAL), y)
OPTS += -DUSE_OPENAL
endif
ifeq ($(FLUIDSYNTH), y)
OPTS += -DUSE_FLUIDSYNTH
FSYNTHOBJ := midi_fluidsynth.o
endif
ifeq ($(MUNT), y)
OPTS += -DUSE_MUNT
MUNTOBJ := midi_mt32.o \
Analog.o BReverbModel.o File.o FileStream.o LA32Ramp.o \
LA32FloatWaveGenerator.o LA32WaveGenerator.o \
MidiStreamParser.o Part.o Partial.o PartialManager.o \
Poly.o ROMInfo.o SampleRateConverter_dummy.o Synth.o \
Tables.o TVA.o TVF.o TVP.o sha1.o c_interface.o
endif
ifeq ($(VNC), y)
OPTS += -DUSE_VNC
RFLAGS += -DUSE_VNC
ifneq ($(VNC_PATH), )
OPTS += -I$(VNC_PATH)\INCLUDE
VNCLIB := -L$(VNC_PATH)\LIB
endif
VNCLIB += -lvncserver
VNCOBJ := vnc.o vnc_keymap.o
endif
ifeq ($(RDP), y)
OPTS += -DUSE_RDP
RFLAGS += -DUSE_RDP
ifneq ($(RDP_PATH), )
OPTS += -I$(RDP_PATH)\INCLUDE
RDPLIB := -L$(RDP_PATH)\LIB
endif
RDPLIB += -lrdp
RDPOBJ := rdp.o
endif
# Options for the DEV branch.
ifeq ($(DEV_BRANCH), y)
OPTS += -DDEV_BRANCH
DEVBROBJ :=
ifeq ($(AMD_K), y)
OPTS += -DUSE_AMD_K
endif
ifeq ($(CRASHDUMPOBJ), y)
OPTS += -DUSE_CRASHDUMP
DEVBROBJ += win_crashdump.o
endif
ifeq ($(GREENB), y)
OPTS += -DUSE_GREENB
DEVBROBJ += m_at_4gpv31.o
endif
ifeq ($(I686), y)
OPTS += -DUSE_I686
DEVBROBJ += m_at_440fx.o
endif
ifeq ($(LASERXT), y)
OPTS += -DUSE_LASERXT
DEVBROBJ += m_xt_laserxt.o
endif
ifeq ($(MRTHOR), y)
OPTS += -DUSE_MRTHOR
endif
ifeq ($(NV_RIVA), y)
OPTS += -DUSE_RIVA
DEVBROBJ += vid_nvidia.o
endif
ifeq ($(PAS16), y)
OPTS += -DUSE_PAS16
DEVBROBJ += snd_pas16.o
endif
ifeq ($(PORTABLE3), y)
OPTS += -DUSE_PORTABLE3
endif
ifeq ($(STEALTH32), y)
OPTS += -DUSE_STEALTH32
DEVBROBJ += vid_icd2061.o
endif
ifeq ($(VGAWONDER), y)
OPTS += -DUSE_VGAWONDER
endif
ifeq ($(XL24), y)
OPTS += -DUSE_XL24
endif
endif
# Options for works-in-progress.
ifndef SERIAL
SERIAL := serial.o
endif
# Final versions of the toolchain flags.
CFLAGS := $(WX_FLAGS) $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) \
$(AFLAGS) -fomit-frame-pointer -mstackrealign -Wall \
-fno-strict-aliasing
CFLAGS := $(CFLAGS)
#########################################################################
# Create the (final) list of objects to build. #
#########################################################################
MAINOBJ := pc.o config.o random.o timer.o io.o dma.o nmi.o pic.o \
pit.o ppi.o pci.o mca.o mcr.o mem.o memregs.o rom.o \
device.o nvr.o nvr_at.o nvr_ps2.o $(VNCOBJ) $(RDPOBJ)
INTELOBJ := intel.o \
intel_flash.o \
intel_sio.o intel_piix.o
CPUOBJ := cpu.o cpu_table.o \
808x.o 386.o 386_dynarec.o \
x86seg.o x87.o \
$(DYNARECOBJ)
MCHOBJ := machine.o machine_table.o \
m_xt.o m_xt_compaq.o \
m_xt_t1000.o m_xt_t1000_vid.o \
m_xt_xi8088.o \
m_pcjr.o \
m_amstrad.o \
m_europc.o \
m_olivetti_m24.o m_tandy.o \
m_at.o \
m_at_ali1429.o m_at_commodore.o \
m_at_neat.o m_at_headland.o \
m_at_t3100e.o m_at_t3100e_vid.o \
m_ps1.o m_ps1_hdc.o \
m_ps2_isa.o m_ps2_mca.o \
m_at_opti495.o m_at_scat.o \
m_at_compaq.o m_at_wd76c10.o \
m_at_sis_85c471.o m_at_sis_85c496.o \
m_at_430lx_nx.o m_at_430fx.o \
m_at_430hx.o m_at_430vx.o
DEVOBJ := bugger.o lpt.o $(SERIAL) \
sio_fdc37c66x.o sio_fdc37c669.o sio_fdc37c93x.o \
sio_pc87306.o sio_w83877f.o sio_um8669f.o \
keyboard.o \
keyboard_xt.o keyboard_at.o \
gameport.o \
joystick_standard.o joystick_ch_flightstick_pro.o \
joystick_sw_pad.o joystick_tm_fcs.o \
mouse.o \
mouse_bus.o \
mouse_serial.o mouse_ps2.o
FDDOBJ := fdd.o fdc.o fdi2raw.o \
fdd_common.o fdd_86f.o \
fdd_fdi.o fdd_imd.o fdd_img.o fdd_json.o \
fdd_td0.o
HDDOBJ := hdd.o \
hdd_image.o hdd_table.o \
hdc.o \
hdc_mfm_xt.o hdc_mfm_at.o \
hdc_xta.o \
hdc_esdi_at.o hdc_esdi_mca.o \
hdc_xtide.o hdc_ide.o
CDROMOBJ := cdrom.o \
cdrom_dosbox.o cdrom_image.o cdrom_null.o
ZIPOBJ := zip.o
ifeq ($(USB), y)
USBOBJ := usb.o
endif
SCSIOBJ := scsi.o \
scsi_bus.o scsi_device.o \
scsi_disk.o \
scsi_x54x.o \
scsi_aha154x.o scsi_buslogic.o \
scsi_ncr5380.o scsi_ncr53c810.o
NETOBJ := network.o \
net_pcap.o \
net_slirp.o \
bootp.o ip_icmp.o misc.o socket.o tcp_timer.o cksum.o \
ip_input.o queue.o tcp_input.o debug.o ip_output.o \
sbuf.o tcp_output.o udp.o if.o mbuf.o slirp.o tcp_subr.o \
net_ne2000.o
SNDOBJ := sound.o \
openal.o \
snd_opl.o snd_dbopl.o \
dbopl.o nukedopl.o \
snd_resid.o \
convolve.o convolve-sse.o envelope.o extfilt.o \
filter.o pot.o sid.o voice.o wave6581__ST.o \
wave6581_P_T.o wave6581_PS_.o wave6581_PST.o \
wave8580__ST.o wave8580_P_T.o wave8580_PS_.o \
wave8580_PST.o wave.o \
midi.o midi_system.o \
snd_speaker.o \
snd_pssj.o \
snd_lpt_dac.o snd_lpt_dss.o \
snd_adlib.o snd_adlibgold.o snd_ad1848.o snd_audiopci.o \
snd_cms.o \
snd_gus.o \
snd_sb.o snd_sb_dsp.o \
snd_emu8k.o snd_mpu401.o \
snd_sn76489.o snd_ssi2001.o \
snd_wss.o \
snd_ym7128.o
VIDOBJ := video.o \
vid_table.o \
vid_cga.o vid_cga_comp.o \
vid_compaq_cga.o \
vid_mda.o \
vid_hercules.o vid_herculesplus.o vid_incolor.o \
vid_colorplus.o \
vid_genius.o \
vid_wy700.o \
vid_ega.o vid_ega_render.o \
vid_svga.o vid_svga_render.o \
vid_vga.o \
vid_ati_eeprom.o \
vid_ati18800.o vid_ati28800.o \
vid_ati_mach64.o vid_ati68860_ramdac.o \
vid_ics2595.o \
vid_cl54xx.o \
vid_et4000.o vid_sc1502x_ramdac.o \
vid_et4000w32.o vid_stg_ramdac.o \
vid_oak_oti.o \
vid_paradise.o \
vid_ti_cf62011.o \
vid_tvga.o \
vid_tgui9440.o vid_tkd8001_ramdac.o \
vid_s3.o vid_s3_virge.o \
vid_sdac_ramdac.o \
vid_voodoo.o
PLATOBJ := win.o \
win_dynld.o win_thread.o \
win_cdrom.o win_keyboard.o \
win_mouse.o win_joystick.o win_midi.o
OBJ := $(MAINOBJ) $(INTELOBJ) $(CPUOBJ) $(MCHOBJ) $(DEVOBJ) \
$(FDDOBJ) $(CDROMOBJ) $(ZIPOBJ) $(HDDOBJ) \
$(USBOBJ) $(NETOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) \
$(PLATOBJ) $(UIOBJ) $(FSYNTHOBJ) $(MUNTOBJ) \
$(DEVBROBJ)
ifdef EXOBJ
OBJ += $(EXOBJ)
endif
LIBS := -mwindows \
-lopenal.dll \
-lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 \
-lcomctl32 -lwinmm
ifeq ($(VNC), y)
LIBS += $(VNCLIB) -lws2_32
endif
ifeq ($(RDP), y)
LIBS += $(RDPLIB)
endif
ifneq ($(WX), n)
LIBS += $(WX_LIBS) -lm
endif
LIBS += -lpng -lz -lwsock32 -liphlpapi
LIBS += -static -lstdc++ -lgcc
ifneq ($(X64), y)
LIBS += -Wl,--large-address-aware
endif
# Build module rules.
ifeq ($(AUTODEP), y)
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $(DEPS) -c $<
%.o: %.cc
@echo $<
@$(CPP) $(CXXFLAGS) $(DEPS) -c $<
%.o: %.cpp
@echo $<
@$(CPP) $(CXXFLAGS) $(DEPS) -c $<
else
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) -c $<
%.o: %.cc
@echo $<
@$(CPP) $(CXXFLAGS) -c $<
%.o: %.cpp
@echo $<
@$(CPP) $(CXXFLAGS) -c $<
%.d: %.c $(wildcard $*.d)
@echo $<
@$(CC) $(CFLAGS) $(DEPS) -E $< >NUL
%.d: %.cc $(wildcard $*.d)
@echo $<
@$(CPP) $(CXXFLAGS) $(DEPS) -E $< >NUL
%.d: %.cpp $(wildcard $*.d)
@echo $<
@$(CPP) $(CXXFLAGS) $(DEPS) -E $< >NUL
endif
all: $(PROG).exe pcap_if.exe
86Box.res: 86Box.rc
@echo Processing $<
@$(WINDRES) $(RFLAGS) $(EXTRAS) -i $< -o 86Box.res
$(PROG).exe: $(OBJ) 86Box.res
@echo Linking $(PROG).exe ..
@$(CC) -o $(PROG).exe $(OBJ) 86Box.res $(LIBS)
ifneq ($(DEBUG), y)
@strip $(PROG).exe
endif
pcap_if.res: pcap_if.rc
@echo Processing $<
@$(WINDRES) $(RFLAGS) -i $< -o pcap_if.res
pcap_if.exe: pcap_if.o win_dynld.o pcap_if.res
@echo Linking pcap_if.exe ..
@$(CC) -o pcap_if.exe pcap_if.o win_dynld.o pcap_if.res
ifneq ($(DEBUG), y)
@strip pcap_if.exe
endif
hello.exe: hello.o
$(CXX) $(LDFLAGS) -o hello.exe hello.o $(WXLIBS) $(LIBS)
ifneq ($(DEBUG), y)
@strip hello.exe
endif
clean:
@echo Cleaning objects..
@-rm -f *.o 2>NUL
@-rm -f *.res 2>NUL
clobber: clean
@echo Cleaning executables..
@-rm -f *.d 2>NUL
@-rm -f *.exe 2>NUL
# @-rm -f $(DEPFILE) 2>NUL
ifneq ($(AUTODEP), y)
depclean:
@-rm -f $(DEPFILE) 2>NUL
@echo Creating dependencies..
@echo # Run "make depends" to re-create this file. >$(DEPFILE)
depends: DEPOBJ=$(OBJ:%.o=%.d)
depends: depclean $(OBJ:%.o=%.d)
@-cat $(DEPOBJ) >>$(DEPFILE)
@-rm -f $(DEPOBJ)
$(DEPFILE):
endif
# Module dependencies.
ifeq ($(AUTODEP), y)
#-include $(OBJ:%.o=%.d) (better, but sloooowwwww)
-include *.d
else
include $(wildcard $(DEPFILE))
endif
# End of Makefile.mingw.

View File

@@ -0,0 +1,154 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Handle the platform-side of CDROM drives.
*
* Version: @(#)win_cdrom.c 1.0.7 2018/03/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2016-2018 Miran Grca.
* Copyright 2017,2018 Fred N. van Kempen.
*/
#define UNICODE
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#undef BITMAP
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include "../config.h"
#include "../disk/hdd.h"
#include "../disk/zip.h"
#include "../scsi/scsi.h"
#include "../cdrom/cdrom.h"
#include "../cdrom/cdrom_image.h"
#include "../cdrom/cdrom_null.h"
#include "../scsi/scsi_disk.h"
#include "../plat.h"
#include "../ui.h"
#include "win.h"
void
cdrom_eject(uint8_t id)
{
if (cdrom_drives[id].host_drive == 0) {
/* Switch from empty to empty. Do nothing. */
return;
}
if (cdrom_image[id].prev_image_path) {
free(cdrom_image[id].prev_image_path);
cdrom_image[id].prev_image_path = NULL;
}
if (cdrom_drives[id].host_drive == 200) {
cdrom_image[id].prev_image_path = (wchar_t *) malloc(1024);
wcscpy(cdrom_image[id].prev_image_path, cdrom_image[id].image_path);
}
cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive;
cdrom[id]->handler->exit(id);
cdrom_close_handler(id);
memset(cdrom_image[id].image_path, 0, 2048);
cdrom_null_open(id);
if (cdrom_drives[id].bus_type) {
/* Signal disc change to the emulated machine. */
cdrom_insert(cdrom[id]);
}
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED);
cdrom_drives[id].host_drive=0;
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 1);
ui_sb_enable_menu_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
ui_sb_update_tip(SB_CDROM|id);
config_save();
}
void
cdrom_reload(uint8_t id)
{
if ((cdrom_drives[id].host_drive == cdrom_drives[id].prev_host_drive) || (cdrom_drives[id].prev_host_drive == 0) || (cdrom_drives[id].host_drive != 0)) {
/* Switch from empty to empty. Do nothing. */
return;
}
cdrom_close_handler(id);
memset(cdrom_image[id].image_path, 0, 2048);
if (cdrom_drives[id].prev_host_drive == 200) {
wcscpy(cdrom_image[id].image_path, cdrom_image[id].prev_image_path);
free(cdrom_image[id].prev_image_path);
cdrom_image[id].prev_image_path = NULL;
image_open(id, cdrom_image[id].image_path);
if (cdrom_drives[id].bus_type) {
/* Signal disc change to the emulated machine. */
cdrom_insert(cdrom[id]);
}
if (wcslen(cdrom_image[id].image_path) == 0) {
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED);
cdrom_drives[id].host_drive = 0;
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 1);
} else {
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_UNCHECKED);
cdrom_drives[id].host_drive = 200;
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_CHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 0);
}
}
ui_sb_enable_menu_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
ui_sb_update_tip(SB_CDROM|id);
config_save();
}
void
zip_eject(uint8_t id)
{
zip_close(id);
if (zip_drives[id].bus_type) {
/* Signal disk change to the emulated machine. */
zip_insert(id);
}
ui_sb_update_icon_state(SB_ZIP | id, 1);
ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
ui_sb_update_tip(SB_ZIP | id);
config_save();
}
void
zip_reload(uint8_t id)
{
zip_disk_reload(id);
if (wcslen(zip_drives[id].image_path) == 0) {
ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
ui_sb_update_icon_state(SB_ZIP|id, 1);
} else {
ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_ENABLED);
ui_sb_update_icon_state(SB_ZIP|id, 0);
}
ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
ui_sb_update_tip(SB_ZIP|id);
config_save();
}

View File

@@ -0,0 +1,711 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Handle the New Floppy Image dialog.
*
* Version: @(#)win_new_floppy.c 1.0.8 2018/05/25
*
* Authors: Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2016-2018 Miran Grca.
*/
#define UNICODE
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#undef BITMAP
#include <commctrl.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include "../86box.h"
#include "../plat.h"
#include "../random.h"
#include "../ui.h"
#include "../disk/zip.h"
#include "win.h"
typedef struct {
int hole;
int sides;
int data_rate;
int encoding;
int rpm;
int tracks;
int sectors; /* For IMG and Japanese FDI only. */
int sector_len; /* For IMG and Japanese FDI only. */
int media_desc;
int spc;
int num_fats;
int spfat;
int root_dir_entries;
} disk_size_t;
static const disk_size_t disk_sizes[14] = { { 0, 1, 2, 1, 0, 40, 8, 2, 0xfe, 2, 2, 1, 112 }, /* 160k */
{ 0, 1, 2, 1, 0, 40, 9, 2, 0xfc, 2, 2, 1, 112 }, /* 180k */
{ 0, 2, 2, 1, 0, 40, 8, 2, 0xff, 2, 2, 1, 112 }, /* 320k */
{ 0, 2, 2, 1, 0, 40, 9, 2, 0xfd, 2, 2, 2, 112 }, /* 360k */
{ 0, 2, 2, 1, 0, 80, 8, 2, 0xfb, 2, 2, 2, 112 }, /* 640k */
{ 0, 2, 2, 1, 0, 80, 9, 2, 0xf9, 2, 2, 3, 112 }, /* 720k */
{ 1, 2, 0, 1, 1, 80, 15, 2, 0xf9, 1, 2, 7, 224 }, /* 1.2M */
{ 1, 2, 0, 1, 1, 77, 8, 3, 0xfe, 1, 2, 2, 192 }, /* 1.25M */
{ 1, 2, 0, 1, 0, 80, 18, 2, 0xf0, 1, 2, 9, 224 }, /* 1.44M */
{ 1, 2, 0, 1, 0, 80, 21, 2, 0xf0, 2, 2, 5, 16 }, /* DMF cluster 1024 */
{ 1, 2, 0, 1, 0, 80, 21, 2, 0xf0, 4, 2, 3, 16 }, /* DMF cluster 2048 */
{ 2, 2, 3, 1, 0, 80, 36, 2, 0xf0, 2, 2, 9, 240 }, /* 2.88M */
{ 0, 64, 0, 0, 0, 96, 32, 2, 0, 0, 0, 0, 0 }, /* ZIP 100 */
{ 0, 64, 0, 0, 0, 239, 32, 2, 0, 0, 0, 0, 0 } }; /* ZIP 250 */
static unsigned char *empty;
static int
create_86f(WCHAR *file_name, disk_size_t disk_size, uint8_t rpm_mode)
{
FILE *f;
uint32_t magic = 0x46423638;
uint16_t version = 0x020B;
uint16_t dflags = 0;
uint16_t tflags = 0;
uint32_t index_hole_pos = 0;
uint32_t tarray[512];
uint32_t array_size, array_size2;
uint32_t track_base, track_size;
int i;
uint32_t shift = 0;
dflags = 0; /* Has surface data? - Assume no for now. */
dflags |= (disk_size.hole << 1); /* Hole */
dflags |= ((disk_size.sides - 1) << 3); /* Sides. */
dflags |= (0 << 4); /* Write protect? - Assume no for now. */
dflags |= (rpm_mode << 5); /* RPM mode. */
dflags |= (0 << 7); /* Has extra bit cells? - Assume no for now. */
tflags = disk_size.data_rate; /* Data rate. */
tflags |= (disk_size.encoding << 3); /* Encoding. */
tflags |= (disk_size.rpm << 5); /* RPM. */
switch (disk_size.hole) {
case 0:
case 1:
default:
switch(rpm_mode) {
case 1:
array_size = 25250;
break;
case 2:
array_size = 25374;
break;
case 3:
array_size = 25750;
break;
default:
array_size = 25000;
break;
}
break;
case 2:
switch(rpm_mode) {
case 1:
array_size = 50500;
break;
case 2:
array_size = 50750;
break;
case 3:
array_size = 51000;
break;
default:
array_size = 50000;
break;
}
break;
}
array_size2 = (array_size << 3);
array_size = (array_size2 >> 4) << 1;
if (array_size2 & 15)
array_size += 2;
empty = (unsigned char *) malloc(array_size);
memset(tarray, 0, 2048);
memset(empty, 0, array_size);
f = plat_fopen(file_name, L"wb");
if (!f)
return 0;
fwrite(&magic, 4, 1, f);
fwrite(&version, 2, 1, f);
fwrite(&dflags, 2, 1, f);
track_size = array_size + 6;
track_base = 8 + ((disk_size.sides == 2) ? 2048 : 1024);
if (disk_size.tracks <= 43)
shift = 1;
for (i = 0; i < (disk_size.tracks * disk_size.sides) << shift; i++)
tarray[i] = track_base + (i * track_size);
fwrite(tarray, 1, (disk_size.sides == 2) ? 2048 : 1024, f);
for (i = 0; i < (disk_size.tracks * disk_size.sides) << shift; i++) {
fwrite(&tflags, 2, 1, f);
fwrite(&index_hole_pos, 4, 1, f);
fwrite(empty, 1, array_size, f);
}
free(empty);
fclose(f);
return 1;
}
static int is_zip;
static int
create_sector_image(WCHAR *file_name, disk_size_t disk_size, uint8_t is_fdi)
{
FILE *f;
uint32_t total_size = 0;
uint32_t total_sectors = 0;
uint32_t sector_bytes = 0;
uint32_t root_dir_bytes = 0;
uint32_t fat_size = 0;
uint32_t fat1_offs = 0;
uint32_t fat2_offs = 0;
uint32_t zero_bytes = 0;
uint16_t base = 0x1000;
f = plat_fopen(file_name, L"wb");
if (!f)
return 0;
sector_bytes = (128 << disk_size.sector_len);
total_sectors = disk_size.sides * disk_size.tracks * disk_size.sectors;
if (total_sectors > ZIP_SECTORS)
total_sectors = ZIP_250_SECTORS;
total_size = total_sectors * sector_bytes;
root_dir_bytes = (disk_size.root_dir_entries << 5);
fat_size = (disk_size.spfat * sector_bytes);
fat1_offs = sector_bytes;
fat2_offs = fat1_offs + fat_size;
zero_bytes = fat2_offs + fat_size + root_dir_bytes;
if (!is_zip && is_fdi) {
empty = (unsigned char *) malloc(base);
memset(empty, 0, base);
*(uint32_t *) &(empty[0x08]) = (uint32_t) base;
*(uint32_t *) &(empty[0x0C]) = total_size;
*(uint16_t *) &(empty[0x10]) = (uint16_t) sector_bytes;
*(uint8_t *) &(empty[0x14]) = (uint8_t) disk_size.sectors;
*(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sides;
*(uint8_t *) &(empty[0x1C]) = (uint8_t) disk_size.tracks;
fwrite(empty, 1, base, f);
free(empty);
}
empty = (unsigned char *) malloc(total_size);
memset(empty, 0x00, zero_bytes);
if (!is_zip) {
memset(empty + zero_bytes, 0xF6, total_size - zero_bytes);
empty[0x00] = 0xEB; /* Jump to make MS-DOS happy. */
empty[0x01] = 0x58;
empty[0x02] = 0x90;
empty[0x03] = 0x38; /* '86BOX5.0' OEM ID. */
empty[0x04] = 0x36;
empty[0x05] = 0x42;
empty[0x06] = 0x4F;
empty[0x07] = 0x58;
empty[0x08] = 0x35;
empty[0x09] = 0x2E;
empty[0x0A] = 0x30;
*(uint16_t *) &(empty[0x0B]) = (uint16_t) sector_bytes;
*(uint8_t *) &(empty[0x0D]) = (uint8_t) disk_size.spc;
*(uint16_t *) &(empty[0x0E]) = (uint16_t) 1;
*(uint8_t *) &(empty[0x10]) = (uint8_t) disk_size.num_fats;
*(uint16_t *) &(empty[0x11]) = (uint16_t) disk_size.root_dir_entries;
*(uint16_t *) &(empty[0x13]) = (uint16_t) total_sectors;
*(uint8_t *) &(empty[0x15]) = (uint8_t) disk_size.media_desc;
*(uint16_t *) &(empty[0x16]) = (uint16_t) disk_size.spfat;
*(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sectors;
*(uint8_t *) &(empty[0x1A]) = (uint8_t) disk_size.sides;
empty[0x26] = 0x29; /* ')' followed by randomly-generated volume serial number. */
empty[0x27] = random_generate();
empty[0x28] = random_generate();
empty[0x29] = random_generate();
empty[0x2A] = random_generate();
memset(&(empty[0x2B]), 0x20, 11);
empty[0x36] = 'F';
empty[0x37] = 'A';
empty[0x38] = 'T';
empty[0x39] = '1';
empty[0x3A] = '2';
empty[0x3B] = ' ';
empty[0x3C] = ' ';
empty[0x3D] = ' ';
empty[0x1FE] = 0x55;
empty[0x1FF] = 0xAA;
empty[fat1_offs + 0x00] = empty[fat2_offs + 0x00] = empty[0x15];
empty[fat1_offs + 0x01] = empty[fat2_offs + 0x01] = 0xFF;
empty[fat1_offs + 0x02] = empty[fat2_offs + 0x02] = 0xFF;
}
fwrite(empty, 1, total_size, f);
free(empty);
fclose(f);
return 1;
}
static int
create_zip_sector_image(WCHAR *file_name, disk_size_t disk_size, uint8_t is_zdi, HWND hwnd)
{
HWND h;
FILE *f;
uint32_t total_size = 0;
uint32_t total_sectors = 0;
uint32_t sector_bytes = 0;
uint32_t root_dir_bytes = 0;
uint32_t fat_size = 0;
uint32_t fat1_offs = 0;
uint32_t fat2_offs = 0;
uint32_t zero_bytes = 0;
uint16_t base = 0x1000;
uint32_t pbar_max = 0;
uint32_t i;
f = plat_fopen(file_name, L"wb");
if (!f)
return 0;
sector_bytes = (128 << disk_size.sector_len);
total_sectors = disk_size.sides * disk_size.tracks * disk_size.sectors;
if (total_sectors > ZIP_SECTORS)
total_sectors = ZIP_250_SECTORS;
total_size = total_sectors * sector_bytes;
root_dir_bytes = (disk_size.root_dir_entries << 5);
fat_size = (disk_size.spfat * sector_bytes);
fat1_offs = sector_bytes;
fat2_offs = fat1_offs + fat_size;
zero_bytes = fat2_offs + fat_size + root_dir_bytes;
pbar_max = total_size;
if (is_zdi)
pbar_max += base;
pbar_max >>= 11;
pbar_max--;
h = GetDlgItem(hwnd, IDC_COMBO_RPM_MODE);
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
h = GetDlgItem(hwnd, IDT_1751);
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_SETPOS, (WPARAM) 0, (LPARAM) 0);
EnableWindow(h, TRUE);
ShowWindow(h, SW_SHOW);
h = GetDlgItem(hwnd, IDT_1757);
EnableWindow(h, TRUE);
ShowWindow(h, SW_SHOW);
h = GetDlgItem(hwnd, IDC_PBAR_IMG_CREATE);
pbar_max++;
if (is_zdi) {
empty = (unsigned char *) malloc(base);
memset(empty, 0, base);
*(uint32_t *) &(empty[0x08]) = (uint32_t) base;
*(uint32_t *) &(empty[0x0C]) = total_size;
*(uint16_t *) &(empty[0x10]) = (uint16_t) sector_bytes;
*(uint8_t *) &(empty[0x14]) = (uint8_t) disk_size.sectors;
*(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sides;
*(uint8_t *) &(empty[0x1C]) = (uint8_t) disk_size.tracks;
fwrite(empty, 1, 2048, f);
SendMessage(h, PBM_SETPOS, (WPARAM) 1, (LPARAM) 0);
fwrite(&empty[0x0800], 1, 2048, f);
free(empty);
SendMessage(h, PBM_SETPOS, (WPARAM) 2, (LPARAM) 0);
pbar_max -= 2;
}
empty = (unsigned char *) malloc(total_size);
memset(empty, 0x00, zero_bytes);
if (total_sectors == ZIP_SECTORS) {
/* ZIP 100 */
/* MBR */
*(uint64_t *) &(empty[0x0000]) = 0x0000030000025245LL;
*(uint64_t *) &(empty[0x0008]) = 0x0000000000000000LL;
*(uint64_t *) &(empty[0x0010]) = 0x0900E90300000100LL;
*(uint64_t *) &(empty[0x0018]) = 0x726F70726F430100LL;
*(uint64_t *) &(empty[0x0020]) = 0x202D206E6F697461LL;
*(uint64_t *) &(empty[0x0028]) = 0x30392F33322F3131LL;
*(uint64_t *) &(empty[0x01AE]) = 0x0116010100E905E2LL;
*(uint64_t *) &(empty[0x01B6]) = 0x226BEDCE014E0135LL;
*(uint64_t *) &(empty[0x01BE]) = 0x5E203F0600010180LL;
*(uint64_t *) &(empty[0x01C6]) = 0x0002FE6000000020LL;
*(uint16_t *) &(empty[0x01FE]) = 0xAA55;
/* 4 sectors filled with 0xFA */
memset(&(empty[0x0200]), 0xFA, 0x0800);
/* Iomega_Reserved sector */
*(uint64_t *) &(empty[0x0A00]) = 0x0500000000004D50LL;
*(uint64_t *) &(empty[0x0A08]) = 0xAFF9010051060100LL;
*(uint64_t *) &(empty[0x0A30]) = 0x525F6167656D6F49LL;
*(uint64_t *) &(empty[0x0A38]) = 0x0064657672657365LL;
*(uint64_t *) &(empty[0x0A54]) = 0x03000000AFF90100LL;
/* 26 sectors filled with 0x48 */
memset(&(empty[0x0C00]), 0x48, 0x3400);
/* Boot sector */
*(uint64_t *) &(empty[0x4000]) = 0x584F4236389058EBLL;
*(uint64_t *) &(empty[0x4008]) = 0x0001040200302E35LL;
*(uint64_t *) &(empty[0x4010]) = 0x00C0F80000020002LL;
*(uint64_t *) &(empty[0x4018]) = 0x0000002000400020LL;
*(uint32_t *) &(empty[0x4020]) = 0x0002FFE0;
*(uint16_t *) &(empty[0x4024]) = 0x0080;
empty[0x4026] = 0x29; /* ')' followed by randomly-generated volume serial number. */
empty[0x4027] = random_generate();
empty[0x4028] = random_generate();
empty[0x4029] = random_generate();
empty[0x402A] = random_generate();
memset(&(empty[0x402B]), 0x00, 0x000B);
memset(&(empty[0x4036]), 0x20, 0x0008);
empty[0x4036] = 'F';
empty[0x4037] = 'A';
empty[0x4038] = 'T';
empty[0x4039] = '1';
empty[0x403A] = '6';
empty[0x41FE] = 0x55;
empty[0x41FF] = 0xAA;
empty[0x4200] = empty[0x1C200] = empty[0x4015];
empty[0x4201] = empty[0x1C201] = 0xFF;
empty[0x4202] = empty[0x1C202] = 0xFF;
empty[0x4203] = empty[0x1C203] = 0xFF;
/* Root directory = 0x34200
Data = 0x38200 */
} else {
/* ZIP 250 */
/* MBR */
*(uint64_t *) &(empty[0x0000]) = 0x2054524150492EEBLL;
*(uint64_t *) &(empty[0x0008]) = 0x3930302065646F63LL;
*(uint64_t *) &(empty[0x0010]) = 0x67656D6F49202D20LL;
*(uint64_t *) &(empty[0x0018]) = 0x726F70726F432061LL;
*(uint64_t *) &(empty[0x0020]) = 0x202D206E6F697461LL;
*(uint64_t *) &(empty[0x0028]) = 0x30392F33322F3131LL;
*(uint64_t *) &(empty[0x01AE]) = 0x0116010100E900E9LL;
*(uint64_t *) &(empty[0x01B6]) = 0x2E32A7AC014E0135LL;
*(uint64_t *) &(empty[0x01EE]) = 0xEE203F0600010180LL;
*(uint64_t *) &(empty[0x01F6]) = 0x000777E000000020LL;
*(uint16_t *) &(empty[0x01FE]) = 0xAA55;
/* 31 sectors filled with 0x48 */
memset(&(empty[0x0200]), 0x48, 0x3E00);
/* The second sector begins with some strange data
in my reference image. */
*(uint64_t *) &(empty[0x0200]) = 0x3831393230334409LL;
*(uint64_t *) &(empty[0x0208]) = 0x6A57766964483130LL;
*(uint64_t *) &(empty[0x0210]) = 0x3C3A34676063653FLL;
*(uint64_t *) &(empty[0x0218]) = 0x586A56A8502C4161LL;
*(uint64_t *) &(empty[0x0220]) = 0x6F2D702535673D6CLL;
*(uint64_t *) &(empty[0x0228]) = 0x255421B8602D3456LL;
*(uint64_t *) &(empty[0x0230]) = 0x577B22447B52603ELL;
*(uint64_t *) &(empty[0x0238]) = 0x46412CC871396170LL;
*(uint64_t *) &(empty[0x0240]) = 0x704F55237C5E2626LL;
*(uint64_t *) &(empty[0x0248]) = 0x6C7932C87D5C3C20LL;
*(uint64_t *) &(empty[0x0250]) = 0x2C50503E47543D6ELL;
*(uint64_t *) &(empty[0x0258]) = 0x46394E807721536ALL;
*(uint64_t *) &(empty[0x0260]) = 0x505823223F245325LL;
*(uint64_t *) &(empty[0x0268]) = 0x365C79B0393B5B6ELL;
/* Boot sector */
*(uint64_t *) &(empty[0x4000]) = 0x584F4236389058EBLL;
*(uint64_t *) &(empty[0x4008]) = 0x0001080200302E35LL;
*(uint64_t *) &(empty[0x4010]) = 0x00EFF80000020002LL;
*(uint64_t *) &(empty[0x4018]) = 0x0000002000400020LL;
*(uint32_t *) &(empty[0x4020]) = 0x000777E0;
*(uint16_t *) &(empty[0x4024]) = 0x0080;
empty[0x4026] = 0x29; /* ')' followed by randomly-generated volume serial number. */
empty[0x4027] = random_generate();
empty[0x4028] = random_generate();
empty[0x4029] = random_generate();
empty[0x402A] = random_generate();
memset(&(empty[0x402B]), 0x00, 0x000B);
memset(&(empty[0x4036]), 0x20, 0x0008);
empty[0x4036] = 'F';
empty[0x4037] = 'A';
empty[0x4038] = 'T';
empty[0x4039] = '1';
empty[0x403A] = '6';
empty[0x41FE] = 0x55;
empty[0x41FF] = 0xAA;
empty[0x4200] = empty[0x22000] = empty[0x4015];
empty[0x4201] = empty[0x22001] = 0xFF;
empty[0x4202] = empty[0x22002] = 0xFF;
empty[0x4203] = empty[0x22003] = 0xFF;
/* Root directory = 0x3FE00
Data = 0x38200 */
}
for (i = 0; i < pbar_max; i++) {
fwrite(&empty[i << 11], 1, 2048, f);
SendMessage(h, PBM_SETPOS, (WPARAM) i + 2, (LPARAM) 0);
}
free(empty);
fclose(f);
return 1;
}
static int fdd_id, sb_part;
static int file_type = 0; /* 0 = IMG, 1 = Japanese FDI, 2 = 86F */
static wchar_t fd_file_name[512];
/* Show a MessageBox dialog. This is nasty, I know. --FvK */
static int
new_floppy_msgbox(HWND hwnd, int type, void *arg)
{
HWND h;
int i;
h = hwndMain;
hwndMain = hwnd;
i = ui_msgbox(type, arg);
hwndMain = h;
return(i);
}
#ifdef __amd64__
static LRESULT CALLBACK
#else
static BOOL CALLBACK
#endif
NewFloppyDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND h;
int i = 0;
int wcs_len, ext_offs;
wchar_t *ext;
uint8_t disk_size, rpm_mode;
int ret;
FILE *f;
int zip_types;
wchar_t *twcs;
switch (message) {
case WM_INITDIALOG:
plat_pause(1);
memset(fd_file_name, 0, 512 * sizeof(wchar_t));
h = GetDlgItem(hdlg, IDC_COMBO_DISK_SIZE);
if (is_zip) {
zip_types = zip_drives[fdd_id].is_250 ? 2 : 1;
for (i = 0; i < zip_types; i++)
SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_5900 + i));
} else {
for (i = 0; i < 12; i++)
SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_5888 + i));
}
SendMessage(h, CB_SETCURSEL, 0, 0);
EnableWindow(h, FALSE);
h = GetDlgItem(hdlg, IDC_COMBO_RPM_MODE);
for (i = 0; i < 4; i++)
SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_6144 + i));
SendMessage(h, CB_SETCURSEL, 0, 0);
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
h = GetDlgItem(hdlg, IDT_1751);
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
h = GetDlgItem(hdlg, IDOK);
EnableWindow(h, FALSE);
h = GetDlgItem(hdlg, IDC_PBAR_IMG_CREATE);
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
h = GetDlgItem(hdlg, IDT_1757);
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
h = GetDlgItem(hdlg, IDC_COMBO_DISK_SIZE);
disk_size = SendMessage(h, CB_GETCURSEL, 0, 0);
if (is_zip)
disk_size += 12;
if (file_type == 2) {
h = GetDlgItem(hdlg, IDC_COMBO_RPM_MODE);
rpm_mode = SendMessage(h, CB_GETCURSEL, 0, 0);
ret = create_86f(fd_file_name, disk_sizes[disk_size], rpm_mode);
} else {
if (is_zip)
ret = create_zip_sector_image(fd_file_name, disk_sizes[disk_size], file_type, hdlg);
else
ret = create_sector_image(fd_file_name, disk_sizes[disk_size], file_type);
}
if (ret) {
if (is_zip)
ui_sb_mount_zip_img(fdd_id, sb_part, 0, fd_file_name);
else
ui_sb_mount_floppy_img(fdd_id, sb_part, 0, fd_file_name);
} else {
new_floppy_msgbox(hdlg, MBX_ERROR, (wchar_t *)IDS_4108);
return TRUE;
}
case IDCANCEL:
EndDialog(hdlg, 0);
plat_pause(0);
return TRUE;
case IDC_CFILE:
if (!file_dlg_w(hdlg, plat_get_string(is_zip ? IDS_2055 : IDS_2062), L"", 1)) {
if (!wcschr(wopenfilestring, L'.')) {
if (wcslen(wopenfilestring) && (wcslen(wopenfilestring) <= 256)) {
twcs = &wopenfilestring[wcslen(wopenfilestring)];
twcs[0] = L'.';
if (!is_zip && (filterindex == 3)) {
twcs[1] = L'8';
twcs[2] = L'6';
twcs[3] = L'f';
} else {
twcs[1] = L'i';
twcs[2] = L'm';
twcs[3] = L'g';
}
}
}
h = GetDlgItem(hdlg, IDC_EDIT_FILE_NAME);
f = _wfopen(wopenfilestring, L"rb");
if (f != NULL) {
fclose(f);
if (new_floppy_msgbox(hdlg, MBX_QUESTION, (wchar_t *)IDS_4111) != 0) /* yes */
return FALSE;
}
SendMessage(h, WM_SETTEXT, 0, (LPARAM) wopenfilestring);
memset(fd_file_name, 0, sizeof(fd_file_name));
wcscpy(fd_file_name, wopenfilestring);
h = GetDlgItem(hdlg, IDC_COMBO_DISK_SIZE);
if (!is_zip || zip_drives[fdd_id].is_250)
EnableWindow(h, TRUE);
wcs_len = wcslen(wopenfilestring);
ext_offs = wcs_len - 4;
ext = &(wopenfilestring[ext_offs]);
if (is_zip) {
if (((wcs_len >= 4) && !wcsicmp(ext, L".ZDI")))
file_type = 1;
else
file_type = 0;
} else {
if (((wcs_len >= 4) && !wcsicmp(ext, L".FDI")))
file_type = 1;
else if ((((wcs_len >= 4) && !wcsicmp(ext, L".86F")) || (filterindex == 3)))
file_type = 2;
else
file_type = 0;
}
h = GetDlgItem(hdlg, IDT_1751);
if (file_type == 2) {
EnableWindow(h, TRUE);
ShowWindow(h, SW_SHOW);
} else {
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
}
h = GetDlgItem(hdlg, IDC_COMBO_RPM_MODE);
if (file_type == 2) {
EnableWindow(h, TRUE);
ShowWindow(h, SW_SHOW);
} else {
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
}
h = GetDlgItem(hdlg, IDOK);
EnableWindow(h, TRUE);
return TRUE;
} else
return FALSE;
default:
break;
}
break;
}
return(FALSE);
}
void
NewFloppyDialogCreate(HWND hwnd, int id, int part)
{
fdd_id = id & 0x7f;
sb_part = part;
is_zip = !!(id & 0x80);
DialogBox(hinstance, (LPCTSTR)DLG_NEW_FLOPPY, hwnd, NewFloppyDialogProcedure);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff