Cleanup of the configuration code, and source tree layout.
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
version="1.20.0.0"
|
||||
processorArchitecture="*"
|
||||
name="86Box.exe"
|
||||
type="win32"
|
||||
/>
|
||||
<description>Emulator for X86-based systems.</description>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
941
src/86Box.rc
941
src/86Box.rc
@@ -1,941 +0,0 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
STATUSBARMENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "FDD 1"
|
||||
BEGIN
|
||||
MENUITEM "&Change...", IDM_DISC_1
|
||||
MENUITEM "Change FDD 1 (&Write-protected)...", IDM_DISC_1_WP
|
||||
MENUITEM "&Eject FDD 1", IDM_EJECT_1
|
||||
END
|
||||
POPUP "FDD 2"
|
||||
BEGIN
|
||||
MENUITEM "&Change...", IDM_DISC_2
|
||||
MENUITEM "Change FDD 2 (&Write-protected)...", IDM_DISC_2_WP
|
||||
MENUITEM "&Eject FDD 2", IDM_EJECT_2
|
||||
END
|
||||
POPUP "FDD 3"
|
||||
BEGIN
|
||||
MENUITEM "&Change...", IDM_DISC_3
|
||||
MENUITEM "Change FDD 3 (&Write-protected)...", IDM_DISC_3_WP
|
||||
MENUITEM "&Eject FDD 3", IDM_EJECT_3
|
||||
END
|
||||
POPUP "FDD 4"
|
||||
BEGIN
|
||||
MENUITEM "&Change...", IDM_DISC_4
|
||||
MENUITEM "Change FDD 4 (&Write-protected)...", IDM_DISC_4_WP
|
||||
MENUITEM "&Eject FDD 4", IDM_EJECT_4
|
||||
END
|
||||
POPUP "CD-ROM 1"
|
||||
BEGIN
|
||||
MENUITEM "&Mute", IDM_CDROM_1_MUTE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&mpty", IDM_CDROM_1_EMPTY
|
||||
MENUITEM "&Reload previous disc", IDM_CDROM_1_RELOAD
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Image...", IDM_CDROM_1_IMAGE
|
||||
END
|
||||
POPUP "CD-ROM 2"
|
||||
BEGIN
|
||||
MENUITEM "&Mute", IDM_CDROM_2_MUTE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&mpty", IDM_CDROM_2_EMPTY
|
||||
MENUITEM "&Reload previous disc", IDM_CDROM_2_RELOAD
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Image...", IDM_CDROM_2_IMAGE
|
||||
END
|
||||
POPUP "CD-ROM 3"
|
||||
BEGIN
|
||||
MENUITEM "&Mute", IDM_CDROM_3_MUTE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&mpty", IDM_CDROM_3_EMPTY
|
||||
MENUITEM "&Reload previous disc", IDM_CDROM_3_RELOAD
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Image...", IDM_CDROM_3_IMAGE
|
||||
END
|
||||
POPUP "CD-ROM 4"
|
||||
BEGIN
|
||||
MENUITEM "&Mute", IDM_CDROM_4_MUTE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&mpty", IDM_CDROM_4_EMPTY
|
||||
MENUITEM "&Reload previous disc", IDM_CDROM_4_RELOAD
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Image...", IDM_CDROM_4_IMAGE
|
||||
END
|
||||
END
|
||||
|
||||
MAINMENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&Action"
|
||||
BEGIN
|
||||
MENUITEM "&Hard Reset", IDM_FILE_HRESET
|
||||
MENUITEM "&Ctrl+Alt+Del\tCtrl+F12", IDM_FILE_RESET_CAD
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", IDM_FILE_EXIT
|
||||
END
|
||||
POPUP "&Tools"
|
||||
BEGIN
|
||||
MENUITEM "&Settings...", IDM_CONFIG
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Load configuration...", IDM_CONFIG_LOAD
|
||||
MENUITEM "&Save configuration...", IDM_CONFIG_SAVE
|
||||
MENUITEM SEPARATOR
|
||||
POPUP "&Video"
|
||||
BEGIN
|
||||
MENUITEM "&Resizeable window", IDM_VID_RESIZE
|
||||
MENUITEM "R&emember size && position", IDM_VID_REMEMBER
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&DirectDraw", IDM_VID_DDRAW
|
||||
MENUITEM "Direct&3D 9", IDM_VID_D3D
|
||||
MENUITEM SEPARATOR
|
||||
POPUP "&Window scale factor"
|
||||
BEGIN
|
||||
MENUITEM "&0.5x", IDM_VID_SCALE_1X
|
||||
MENUITEM "&1x", IDM_VID_SCALE_2X
|
||||
MENUITEM "1.&5x", IDM_VID_SCALE_3X
|
||||
MENUITEM "&2x", IDM_VID_SCALE_4X
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Fullscreen", IDM_VID_FULLSCREEN
|
||||
POPUP "Fullscreen &stretch mode"
|
||||
BEGIN
|
||||
MENUITEM "&Full screen stretch", IDM_VID_FS_FULL
|
||||
MENUITEM "&4:3", IDM_VID_FS_43
|
||||
MENUITEM "&Square pixels", IDM_VID_FS_SQ
|
||||
MENUITEM "&Integer scale", IDM_VID_FS_INT
|
||||
END
|
||||
MENUITEM "&Inverted VGA monitor", IDM_VID_INVERT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "F&orce 4:3 display ratio", IDM_VID_FORCE43
|
||||
MENUITEM "E&GA/(S)VGA overscan", IDM_VID_OVERSCAN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Take s&creenshot\tCtrl+F11", IDM_VID_SCREENSHOT
|
||||
END
|
||||
MENUITEM "S&tatus", IDM_STATUS
|
||||
#ifdef ENABLE_LOG_TOGGLES
|
||||
#if defined ENABLE_BUSLOGIC_LOG || defined ENABLE_CDROM_LOG || defined ENABLE_D86F_LOG || defined ENABLE_FDC_LOG || defined ENABLE_IDE_LOG || defined ENABLE_NE2000_LOG
|
||||
MENUITEM SEPARATOR
|
||||
#endif
|
||||
#ifdef ENABLE_BUSLOGIC_LOG
|
||||
MENUITEM "Enable BusLogic logs\tCtrl+F4", IDM_LOG_BUSLOGIC
|
||||
#endif
|
||||
#ifdef ENABLE_CDROM_LOG
|
||||
MENUITEM "Enable CD-ROM logs\tCtrl+F5", IDM_LOG_CDROM
|
||||
#endif
|
||||
#ifdef ENABLE_D86F_LOG
|
||||
MENUITEM "Enable floppy (86F) logs\tCtrl+F6", IDM_LOG_D86F
|
||||
#endif
|
||||
#ifdef ENABLE_FDC_LOG
|
||||
MENUITEM "Enable floppy controller logs\tCtrl+F7", IDM_LOG_FDC
|
||||
#endif
|
||||
#ifdef ENABLE_IDE_LOG
|
||||
MENUITEM "Enable IDE logs\tCtrl+F8", IDM_LOG_IDE
|
||||
#endif
|
||||
#ifdef ENABLE_NE2000_LOG
|
||||
MENUITEM "Enable NE2000 logs\tCtrl+F9", IDM_LOG_NE2000
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENABLE_LOG_BREAKPOINT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Log breakpoint\tCtrl+F10", IDM_LOG_BREAKPOINT
|
||||
#ifdef ENABLE_VRAM_DUMP
|
||||
MENUITEM "Dump &video RAM\tCtrl+F1", IDM_DUMP_VRAM
|
||||
#endif
|
||||
#else
|
||||
#ifdef ENABLE_VRAM_DUMP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Dump &video RAM\tCtrl+F1", IDM_DUMP_VRAM
|
||||
#endif
|
||||
#endif
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About 86Box...", IDM_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
MAINACCEL ACCELERATORS MOVEABLE PURE
|
||||
BEGIN
|
||||
#ifdef ENABLE_VRAM_DUMP
|
||||
VK_F1, IDM_DUMP_VRAM, CONTROL, VIRTKEY
|
||||
#endif
|
||||
#ifdef ENABLE_LOG_TOGGLES
|
||||
#ifdef ENABLE_BUSLOGIC_LOG
|
||||
VK_F4, IDM_LOG_BUSLOGIC, CONTROL, VIRTKEY
|
||||
#endif
|
||||
#ifdef ENABLE_CDROM_LOG
|
||||
VK_F5, IDM_LOG_CDROM, CONTROL, VIRTKEY
|
||||
#endif
|
||||
#ifdef ENABLE_D86F_LOG
|
||||
VK_F6, IDM_LOG_D86F, CONTROL, VIRTKEY
|
||||
#endif
|
||||
#ifdef ENABLE_FDC_LOG
|
||||
VK_F7, IDM_LOG_FDC, CONTROL, VIRTKEY
|
||||
#endif
|
||||
#ifdef ENABLE_IDE_LOG
|
||||
VK_F8, IDM_LOG_IDE, CONTROL, VIRTKEY
|
||||
#endif
|
||||
#ifdef ENABLE_NE2000_LOG
|
||||
VK_F9, IDM_LOG_NE2000, CONTROL, VIRTKEY
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENABLE_LOG_BREAKPOINT
|
||||
VK_F10, IDM_LOG_BREAKPOINT, CONTROL, VIRTKEY
|
||||
#endif
|
||||
VK_F11, IDM_VID_SCREENSHOT, VIRTKEY, CONTROL
|
||||
VK_F12, IDM_FILE_RESET_CAD, VIRTKEY, CONTROL
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
CONFIGUREDLG_MAIN DIALOG DISCARDABLE 0, 0, 366, 241
|
||||
STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "86Box Settings"
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,246,220,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,307,220,50,14
|
||||
CONTROL "List2",IDC_SETTINGSCATLIST,"SysListView32",LVS_LIST |
|
||||
LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,7,7,90,197
|
||||
CONTROL "",-1,"Static",SS_BLACKFRAME | SS_SUNKEN,1,211,363,1
|
||||
LTEXT "Language:",2047,7,222,41,10
|
||||
COMBOBOX IDC_COMBO_LANG,48,221,108,120,CBS_DROPDOWN | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
END
|
||||
|
||||
CONFIGUREDLG_HARD_DISKS_ADD DIALOG DISCARDABLE 0, 0, 219, 111
|
||||
STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Add Hard Disk"
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,55,89,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,112,89,50,14
|
||||
EDITTEXT IDC_EDIT_HD_FILE_NAME,7,16,153,12
|
||||
PUSHBUTTON "&Specify...",IDC_CFILE,167,16,44,12
|
||||
EDITTEXT IDC_EDIT_HD_SPT,183,34,28,12
|
||||
EDITTEXT IDC_EDIT_HD_HPC,112,34,28,12
|
||||
EDITTEXT IDC_EDIT_HD_CYL,42,34,28,12
|
||||
EDITTEXT IDC_EDIT_HD_SIZE,42,52,28,12
|
||||
COMBOBOX IDC_COMBO_HD_TYPE,113,52,98,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Sectors:",IDC_STATIC,154,35,27,10
|
||||
LTEXT "Heads:",1793,81,35,29,8
|
||||
LTEXT "Cylinders:",1794,7,35,32,12
|
||||
LTEXT "Size (MB):",1795,7,54,33,8
|
||||
LTEXT "Type:",1797,86,54,24,8
|
||||
LTEXT "File name:",-1,7,7,204,9
|
||||
COMBOBOX IDC_COMBO_HD_BUS,33,71,58,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Bus:",1798,7,72,24,8
|
||||
COMBOBOX IDC_COMBO_HD_CHANNEL,134,71,77,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Channel:",1799,99,72,34,8
|
||||
COMBOBOX IDC_COMBO_HD_ID,133,71,26,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "ID:",1800,117,72,15,8
|
||||
COMBOBOX IDC_COMBO_HD_LUN,185,71,26,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "LUN:",1801,168,72,15,8
|
||||
COMBOBOX IDC_COMBO_HD_CHANNEL_IDE,134,71,77,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Channel:",1802,99,72,34,8
|
||||
END
|
||||
|
||||
STATUSDLG DIALOG DISCARDABLE 0, 0, 186, 386
|
||||
STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Status"
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
LTEXT "1",IDC_STEXT_DEVICE,16,16,180,1000
|
||||
LTEXT "1",IDC_STEXT1,16,186,180,1000
|
||||
END
|
||||
|
||||
ABOUTDLG DIALOG DISCARDABLE 0, 0, 209, 114
|
||||
STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About 86Box"
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,129,94,71,12
|
||||
ICON 100,IDC_ABOUT_ICON,7,7,20,20
|
||||
LTEXT "86Box v1.20 - A fork of PCem\n\nAuthors: Sarah Walker, Tohka, waltje, SA1988, MoochMcGee, reenigne, leilei, JohnElliott, greatpsycho, and others.\n\nReleased under the GNU General Public License version 2. See LICENSE for more information.",
|
||||
IDC_ABOUT_ICON,54,7,146,73
|
||||
CONTROL "",IDC_ABOUT_ICON,"Static",SS_BLACKFRAME | SS_SUNKEN,0,
|
||||
86,208,1
|
||||
END
|
||||
|
||||
CONFIGUREDLG_MACHINE DIALOG DISCARDABLE 97, 0, 267, 112
|
||||
STYLE DS_CONTROL | WS_CHILD
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
COMBOBOX IDC_COMBO_MACHINE,71,7,138,120,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Machine:",1794,7,8,60,10
|
||||
PUSHBUTTON "Configure",IDC_CONFIGURE_MACHINE,214,7,46,12
|
||||
COMBOBOX IDC_COMBO_CPU_TYPE,71,25,45,120,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "CPU type:",1796,7,26,59,10
|
||||
COMBOBOX IDC_COMBO_WS,71,44,189,120,CBS_DROPDOWNLIST | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
LTEXT "Wait states:",1798,7,45,60,10
|
||||
COMBOBOX IDC_COMBO_CPU,145,25,115,120,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "CPU:",1797,124,26,18,10
|
||||
CONTROL "Dynamic Recompiler",IDC_CHECK_DYNAREC,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,80,94,10
|
||||
CONTROL "Enable FPU",IDC_CHECK_FPU,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,147,80,113,10
|
||||
EDITTEXT IDC_MEMTEXT,70,63,45,12,ES_AUTOHSCROLL | ES_NUMBER
|
||||
CONTROL "",IDC_MEMSPIN,"msctls_updown32",UDS_SETBUDDYINT |
|
||||
UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,113,63,
|
||||
12,12
|
||||
LTEXT "MB",IDC_TEXT_MB,123,64,10,10
|
||||
LTEXT "Memory:",1802,7,64,30,10
|
||||
CONTROL "Enable time sync",IDC_CHECK_SYNC,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,95,102,10
|
||||
END
|
||||
|
||||
CONFIGUREDLG_VIDEO DIALOG DISCARDABLE 97, 0, 267, 63
|
||||
STYLE DS_CONTROL | WS_CHILD
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
COMBOBOX IDC_COMBO_VIDEO,71,7,140,120,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Video:",1795,7,8,55,10
|
||||
COMBOBOX IDC_COMBO_VIDEO_SPEED,71,25,189,120,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Video speed:",1800,7,26,58,10
|
||||
CONTROL "Voodoo Graphics",IDC_CHECK_VOODOO,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,45,199,10
|
||||
PUSHBUTTON "Configure",IDC_CONFIGURE_VOODOO,214,44,46,12
|
||||
PUSHBUTTON "Configure",IDC_CONFIGUREVID,214,7,46,12
|
||||
END
|
||||
|
||||
CONFIGUREDLG_INPUT DIALOG DISCARDABLE 97, 0, 267, 65
|
||||
STYLE DS_CONTROL | WS_CHILD
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
LTEXT "Mouse :",IDC_STATIC,7,8,57,10
|
||||
COMBOBOX IDC_COMBO_MOUSE,71,7,189,120,CBS_DROPDOWN | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
LTEXT "Joystick :",1793,7,26,58,10
|
||||
COMBOBOX IDC_COMBO_JOYSTICK,71,25,189,120,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
DEFPUSHBUTTON "Joystick 1...",IDC_JOY1,7,44,50,14
|
||||
PUSHBUTTON "Joystick 2...",IDC_JOY2,74,44,50,14
|
||||
DEFPUSHBUTTON "Joystick 3...",IDC_JOY3,141,44,50,14
|
||||
PUSHBUTTON "Joystick 4...",IDC_JOY4,209,44,50,14
|
||||
END
|
||||
|
||||
CONFIGUREDLG_SOUND DIALOG DISCARDABLE 97, 0, 267, 78
|
||||
STYLE DS_CONTROL | WS_CHILD
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
COMBOBOX IDC_COMBOSND,71,7,140,120,CBS_DROPDOWNLIST | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
LTEXT "Sound card:",1800,7,8,59,10
|
||||
PUSHBUTTON "Configure",IDC_CONFIGURESND,214,7,46,12
|
||||
COMBOBOX IDC_COMBO_MIDI,71,25,189,120,CBS_DROPDOWNLIST | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
LTEXT "MIDI Out Device:",1801,7,26,59,10
|
||||
CONTROL "CMS / Game Blaster",IDC_CHECKCMS,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,87,43,80,10
|
||||
CONTROL "Innovation SSI-2001",IDC_CHECKSSI,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,43,80,10
|
||||
CONTROL "Gravis Ultrasound",IDC_CHECKGUS,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,174,43,80,10
|
||||
CONTROL "Use Nuked OPL",IDC_CHECKNUKEDOPL,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,61,80,10
|
||||
END
|
||||
|
||||
CONFIGUREDLG_NETWORK DIALOG DISCARDABLE 97, 0, 267, 63
|
||||
STYLE DS_CONTROL | WS_CHILD
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
LTEXT "Network type:",1800,7,8,59,10
|
||||
COMBOBOX IDC_COMBONETTYPE,71,7,189,120,CBS_DROPDOWNLIST | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
|
||||
LTEXT "PCap device:",1801,7,26,59,10
|
||||
COMBOBOX IDC_COMBOPCAP,71,25,189,120,CBS_DROPDOWNLIST | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
|
||||
LTEXT "Network adapter:",1802,7,44,59,10
|
||||
COMBOBOX IDC_COMBONET,71,43,140,120,CBS_DROPDOWNLIST | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
PUSHBUTTON "Configure",IDC_CONFIGURENET,214,43,46,12
|
||||
END
|
||||
|
||||
CONFIGUREDLG_PERIPHERALS DIALOG DISCARDABLE 97, 0, 267, 115
|
||||
STYLE DS_CONTROL | WS_CHILD
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
LTEXT "SCSI Controller:",1804,7,8,59,10
|
||||
COMBOBOX IDC_COMBO_SCSI,71,7,140,120,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Configure",IDC_CONFIGURE_SCSI,214,7,46,12
|
||||
|
||||
LTEXT "HD Controller:",1799,7,26,61,10
|
||||
COMBOBOX IDC_COMBO_HDC,71,25,189,120,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
|
||||
LTEXT "Tertiary IDE:",1802,7,44,61,10
|
||||
COMBOBOX IDC_COMBO_IDE_TER,71,43,189,120,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
|
||||
LTEXT "Quaternary IDE:",1803,7,62,61,10
|
||||
COMBOBOX IDC_COMBO_IDE_QUA,71,61,189,120,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
|
||||
CONTROL "Serial port 1",IDC_CHECKSERIAL1,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,80,94,10
|
||||
CONTROL "Serial port 2",IDC_CHECKSERIAL2,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,147,80,94,10
|
||||
|
||||
CONTROL "Parallel port",IDC_CHECKPARALLEL,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,98,94,10
|
||||
CONTROL "ISABugger device",IDC_CHECKBUGGER,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,147,98,94,10
|
||||
END
|
||||
|
||||
CONFIGUREDLG_HARD_DISKS DIALOG DISCARDABLE 97, 0, 267, 154
|
||||
STYLE DS_CONTROL | WS_CHILD
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
CONTROL "List1",IDC_LIST_HARD_DISKS,"SysListView32",LVS_REPORT |
|
||||
LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,7,18,253,92
|
||||
LTEXT "Hard disks:",-1,7,7,34,8
|
||||
PUSHBUTTON "&New...",IDC_BUTTON_HDD_ADD_NEW,60,137,62,10
|
||||
PUSHBUTTON "&Existing...",IDC_BUTTON_HDD_ADD,129,137,62,10
|
||||
PUSHBUTTON "&Remove",IDC_BUTTON_HDD_REMOVE,198,137,62,10
|
||||
COMBOBOX IDC_COMBO_HD_BUS,33,117,90,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Bus:",1798,7,118,24,8
|
||||
COMBOBOX IDC_COMBO_HD_CHANNEL,170,117,90,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Channel:",1799,131,118,38,8
|
||||
COMBOBOX IDC_COMBO_HD_ID,170,117,22,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "ID:",1800,131,118,38,8
|
||||
COMBOBOX IDC_COMBO_HD_LUN,239,117,22,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "LUN:",1801,200,118,38,8
|
||||
COMBOBOX IDC_COMBO_HD_CHANNEL_IDE,170,117,90,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Channel:",1802,131,118,38,8
|
||||
END
|
||||
|
||||
CONFIGUREDLG_REMOVABLE_DEVICES DIALOG DISCARDABLE 97, 0, 267, 202
|
||||
STYLE DS_CONTROL | WS_CHILD
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
CONTROL "List1",IDC_LIST_FLOPPY_DRIVES,"SysListView32",
|
||||
LVS_REPORT | LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,
|
||||
7,18,253,60
|
||||
LTEXT "Floppy drives:",-1,7,7,43,8
|
||||
CONTROL "List1",IDC_LIST_CDROM_DRIVES,"SysListView32",LVS_REPORT |
|
||||
LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,7,116,253,60
|
||||
LTEXT "CD-ROM drives:",-1,7,106,50,8
|
||||
COMBOBOX IDC_COMBO_FD_TYPE,33,85,90,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Type:",1803,7,86,24,8
|
||||
COMBOBOX IDC_COMBO_CD_BUS,33,183,90,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Bus:",1798,7,184,24,8
|
||||
COMBOBOX IDC_COMBO_CD_ID,170,183,22,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "ID:",1800,131,184,38,8
|
||||
COMBOBOX IDC_COMBO_CD_LUN,239,183,22,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "LUN:",1801,200,184,38,8
|
||||
COMBOBOX IDC_COMBO_CD_CHANNEL_IDE,170,183,90,12,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Channel:",1802,131,184,38,8
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 24
|
||||
//
|
||||
|
||||
1 24 MOVEABLE PURE "86Box.manifest"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
#ifdef RELEASE_BUILD
|
||||
/* Icon by Devcore - https://commons.wikimedia.org/wiki/File:Icon_PC_256x256.png */
|
||||
100 ICON DISCARDABLE "ICONS/86Box-RB.ico"
|
||||
#else
|
||||
/* Icon by Devcore - https://commons.wikimedia.org/wiki/File:Icon_PC2_256x256.png */
|
||||
100 ICON DISCARDABLE "ICONS/86Box.ico"
|
||||
#endif
|
||||
128 ICON DISCARDABLE "ICONS/floppy_525_1dd.ico"
|
||||
129 ICON DISCARDABLE "ICONS/floppy_525_1dd_active.ico"
|
||||
130 ICON DISCARDABLE "ICONS/floppy_525_2dd.ico"
|
||||
131 ICON DISCARDABLE "ICONS/floppy_525_2dd_active.ico"
|
||||
132 ICON DISCARDABLE "ICONS/floppy_525_2qd.ico"
|
||||
133 ICON DISCARDABLE "ICONS/floppy_525_2qd_active.ico"
|
||||
134 ICON DISCARDABLE "ICONS/floppy_525_2hd.ico"
|
||||
135 ICON DISCARDABLE "ICONS/floppy_525_2hd_active.ico"
|
||||
144 ICON DISCARDABLE "ICONS/floppy_35_1dd.ico"
|
||||
145 ICON DISCARDABLE "ICONS/floppy_35_1dd_active.ico"
|
||||
146 ICON DISCARDABLE "ICONS/floppy_35_2dd.ico"
|
||||
147 ICON DISCARDABLE "ICONS/floppy_35_2dd_active.ico"
|
||||
150 ICON DISCARDABLE "ICONS/floppy_35_2hd.ico"
|
||||
151 ICON DISCARDABLE "ICONS/floppy_35_2hd_active.ico"
|
||||
152 ICON DISCARDABLE "ICONS/floppy_35_2ed.ico"
|
||||
153 ICON DISCARDABLE "ICONS/floppy_35_2ed_active.ico"
|
||||
160 ICON DISCARDABLE "ICONS/cdrom_atapi.ico"
|
||||
161 ICON DISCARDABLE "ICONS/cdrom_atapi_active.ico"
|
||||
162 ICON DISCARDABLE "ICONS/cdrom_atapi_dma.ico"
|
||||
163 ICON DISCARDABLE "ICONS/cdrom_atapi_dma_active.ico"
|
||||
164 ICON DISCARDABLE "ICONS/cdrom_scsi.ico"
|
||||
165 ICON DISCARDABLE "ICONS/cdrom_scsi_active.ico"
|
||||
176 ICON DISCARDABLE "ICONS/hard_disk_mfm.ico"
|
||||
177 ICON DISCARDABLE "ICONS/hard_disk_mfm_active.ico"
|
||||
178 ICON DISCARDABLE "ICONS/hard_disk.ico"
|
||||
179 ICON DISCARDABLE "ICONS/hard_disk_active.ico"
|
||||
180 ICON DISCARDABLE "ICONS/hard_disk_ide.ico"
|
||||
181 ICON DISCARDABLE "ICONS/hard_disk_ide_active.ico"
|
||||
182 ICON DISCARDABLE "ICONS/hard_disk_scsi.ico"
|
||||
183 ICON DISCARDABLE "ICONS/hard_disk_scsi_active.ico"
|
||||
256 ICON DISCARDABLE "ICONS/machine.ico"
|
||||
257 ICON DISCARDABLE "ICONS/video.ico"
|
||||
258 ICON DISCARDABLE "ICONS/input_devices.ico"
|
||||
259 ICON DISCARDABLE "ICONS/sound.ico"
|
||||
260 ICON DISCARDABLE "ICONS/network.ico"
|
||||
261 ICON DISCARDABLE "ICONS/other_peripherals.ico"
|
||||
262 ICON DISCARDABLE "ICONS/hard_disk.ico"
|
||||
263 ICON DISCARDABLE "ICONS/removable_devices.ico"
|
||||
384 ICON DISCARDABLE "ICONS/floppy_525_1dd_empty.ico"
|
||||
385 ICON DISCARDABLE "ICONS/floppy_525_1dd_empty_active.ico"
|
||||
386 ICON DISCARDABLE "ICONS/floppy_525_2dd_empty.ico"
|
||||
387 ICON DISCARDABLE "ICONS/floppy_525_2dd_empty_active.ico"
|
||||
388 ICON DISCARDABLE "ICONS/floppy_525_2qd_empty.ico"
|
||||
389 ICON DISCARDABLE "ICONS/floppy_525_2qd_empty_active.ico"
|
||||
390 ICON DISCARDABLE "ICONS/floppy_525_2hd_empty.ico"
|
||||
391 ICON DISCARDABLE "ICONS/floppy_525_2hd_empty_active.ico"
|
||||
400 ICON DISCARDABLE "ICONS/floppy_35_1dd_empty.ico"
|
||||
401 ICON DISCARDABLE "ICONS/floppy_35_1dd_empty_active.ico"
|
||||
402 ICON DISCARDABLE "ICONS/floppy_35_2dd_empty.ico"
|
||||
403 ICON DISCARDABLE "ICONS/floppy_35_2dd_empty_active.ico"
|
||||
406 ICON DISCARDABLE "ICONS/floppy_35_2hd_empty.ico"
|
||||
407 ICON DISCARDABLE "ICONS/floppy_35_2hd_empty_active.ico"
|
||||
408 ICON DISCARDABLE "ICONS/floppy_35_2ed_empty.ico"
|
||||
409 ICON DISCARDABLE "ICONS/floppy_35_2ed_empty_active.ico"
|
||||
416 ICON DISCARDABLE "ICONS/cdrom_atapi_empty.ico"
|
||||
417 ICON DISCARDABLE "ICONS/cdrom_atapi_empty_active.ico"
|
||||
418 ICON DISCARDABLE "ICONS/cdrom_atapi_dma_empty.ico"
|
||||
419 ICON DISCARDABLE "ICONS/cdrom_atapi_dma_empty_active.ico"
|
||||
420 ICON DISCARDABLE "ICONS/cdrom_scsi_empty.ico"
|
||||
421 ICON DISCARDABLE "ICONS/cdrom_scsi_empty_active.ico"
|
||||
512 ICON DISCARDABLE "ICONS/floppy_disabled.ico"
|
||||
514 ICON DISCARDABLE "ICONS/cdrom_disabled.ico"
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"#include ""windows.h""\r\n"
|
||||
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"#include ""resources.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
CONFIGUREDLG_MAIN, DIALOG
|
||||
BEGIN
|
||||
RIGHTMARGIN, 365
|
||||
END
|
||||
|
||||
ABOUTDLG, DIALOG
|
||||
BEGIN
|
||||
RIGHTMARGIN, 208
|
||||
END
|
||||
|
||||
CONFIGUREDLG_MACHINE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 260
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 105
|
||||
END
|
||||
|
||||
CONFIGUREDLG_VIDEO, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 260
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 56
|
||||
END
|
||||
|
||||
CONFIGUREDLG_INPUT, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 260
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 58
|
||||
END
|
||||
|
||||
CONFIGUREDLG_SOUND, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 260
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 71
|
||||
END
|
||||
|
||||
CONFIGUREDLG_NETWORK, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 260
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 56
|
||||
END
|
||||
|
||||
CONFIGUREDLG_PERIPHERALS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 260
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 102
|
||||
END
|
||||
|
||||
CONFIGUREDLG_HARD_DISKS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 260
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 137
|
||||
END
|
||||
|
||||
CONFIGUREDLG_REMOVABLE_DEVICES, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 260
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 195
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
2048 "86Box"
|
||||
IDS_STRING2049 "86Box Error"
|
||||
IDS_STRING2050 "86Box Fatal Error"
|
||||
IDS_STRING2051 "This will reset 86Box.\nAre you sure you want to save the settings?"
|
||||
IDS_STRING2052 "DirectDraw Screenshot Error"
|
||||
IDS_STRING2053 "Invalid number of sectors (valid values are between 1 and 63)"
|
||||
IDS_STRING2054 "Invalid number of heads (valid values are between 1 and 16)"
|
||||
IDS_STRING2055 "Invalid number of cylinders (valid values are between 1 and 266305)"
|
||||
IDS_STRING2056 "Please enter a valid file name"
|
||||
IDS_STRING2057 "Unable to open the file for write"
|
||||
IDS_STRING2058 "Attempting to create a HDI image larger than 4 GB"
|
||||
IDS_STRING2059 "Remember to partition and format the new drive"
|
||||
IDS_STRING2060 "Unable to open the file for read"
|
||||
IDS_STRING2061 "HDI or HDX image with a sector size that is not 512 are not supported"
|
||||
IDS_STRING2062 "86Box was unable to find any ROMs.\nAt least one ROM set is required to use 86Box."
|
||||
IDS_STRING2063 "Configured ROM set not available.\nDefaulting to an available ROM set."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_STRING2064 "Configured video BIOS not available.\nDefaulting to an available video BIOS."
|
||||
IDS_STRING2065 "Machine"
|
||||
IDS_STRING2066 "Video"
|
||||
IDS_STRING2067 "Input devices"
|
||||
IDS_STRING2068 "Sound"
|
||||
IDS_STRING2069 "Network"
|
||||
IDS_STRING2070 "Other peripherals"
|
||||
IDS_STRING2071 "Hard disks"
|
||||
IDS_STRING2072 "Removable devices"
|
||||
IDS_STRING2073 "%i"" floppy drive: %s"
|
||||
IDS_STRING2074 "Disabled CD-ROM drive"
|
||||
IDS_STRING2075 "%s CD-ROM drive: %s"
|
||||
IDS_STRING2076 "Host CD/DVD Drive (%c:)"
|
||||
IDS_STRING2077 "Click to capture mouse"
|
||||
IDS_STRING2078 "Press F12-F8 to release mouse"
|
||||
IDS_STRING2079 "Press F12-F8 or middle button to release mouse"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
2080 "Drive"
|
||||
2081 "Location"
|
||||
2082 "Bus"
|
||||
2083 "File"
|
||||
2084 "C"
|
||||
2085 "H"
|
||||
2086 "S"
|
||||
2087 "MB"
|
||||
2088 "%i"
|
||||
2089 "Enabled"
|
||||
2090 "Mute"
|
||||
2091 "Type"
|
||||
2092 "Bus"
|
||||
2093 "DMA"
|
||||
2094 "KB"
|
||||
2095 "MFM, RLL, or ESDI CD-ROM drives never existed"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
2096 "Slave"
|
||||
2097 "SCSI (ID %s, LUN %s)"
|
||||
2098 "Adapter Type"
|
||||
2099 "Base Address"
|
||||
2100 "IRQ"
|
||||
2101 "8-bit DMA"
|
||||
2102 "16-bit DMA"
|
||||
2103 "BIOS"
|
||||
2104 "Network Type"
|
||||
2105 "Surround Module"
|
||||
2106 "MPU-401 Base Address"
|
||||
2107 "No PCap devices found"
|
||||
2108 "On-board RAM"
|
||||
2109 "Memory Size"
|
||||
2110 "Display Type"
|
||||
2111 "RGB"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
2112 "Composite"
|
||||
2113 "Composite Type"
|
||||
2114 "Old"
|
||||
2115 "New"
|
||||
2116 "RGB Type"
|
||||
2117 "Color"
|
||||
2118 "Monochrome (Green)"
|
||||
2119 "Monochrome (Amber)"
|
||||
2120 "Monochrome (Gray)"
|
||||
2121 "Color (no brown)"
|
||||
2122 "Monochrome (Default)"
|
||||
2123 "Snow Emulation"
|
||||
2124 "Bilinear Filtering"
|
||||
2125 "Dithering"
|
||||
2126 "Framebuffer Memory Size"
|
||||
2127 "Texture Memory Size"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
2128 "Screen Filter"
|
||||
2129 "Render Threads"
|
||||
2130 "Recompiler"
|
||||
2131 "System Default"
|
||||
2132 "%i Wait state(s)"
|
||||
2133 "8-bit"
|
||||
2134 "Slow 16-bit"
|
||||
2135 "Fast 16-bit"
|
||||
2136 "Slow VLB/PCI"
|
||||
2137 "Mid VLB/PCI"
|
||||
2138 "Fast VLB/PCI"
|
||||
2139 "Microsoft 2-button mouse (serial)"
|
||||
2140 "Mouse Systems mouse (serial)"
|
||||
2141 "2-button mouse (PS/2)"
|
||||
2142 "Microsoft Intellimouse (PS/2)"
|
||||
2143 "Bus mouse"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
2144 "Standard 2-button joystick(s)"
|
||||
2145 "Standard 4-button joystick"
|
||||
2146 "Standard 6-button joystick"
|
||||
2147 "Standard 8-button joystick"
|
||||
2148 "CH Flightstick Pro"
|
||||
2149 "Microsoft SideWinder Pad"
|
||||
2150 "Thrustmaster Flight Control System"
|
||||
2151 "Disabled"
|
||||
2152 "None"
|
||||
2153 "AT Fixed Disk Adapter"
|
||||
2154 "Internal IDE"
|
||||
2155 "IRQ %i"
|
||||
2156 "MFM (%01i:%01i)"
|
||||
2157 "IDE (PIO+DMA) (%01i:%01i)"
|
||||
2158 "SCSI (%02i:%02i)"
|
||||
2159 "Invalid number of cylinders (valid values are between 1 and 1023)"
|
||||
2160 "%" PRIu64
|
||||
2161 "Genius Bus mouse"
|
||||
2162 "Amstrad mouse"
|
||||
2163 "Attempting to create a spuriously large hard disk image"
|
||||
2164 "Invalid number of sectors (valid values are between 1 and 99)"
|
||||
2165 "MFM"
|
||||
2166 "IDE (PIO-only)"
|
||||
2167 "IDE (PIO and DMA)"
|
||||
2168 "SCSI"
|
||||
2169 "%01i:%01i"
|
||||
2170 "Custom..."
|
||||
2171 "%" PRIu64 " MB (CHS: %" PRIu64 ", %" PRIu64 ", %" PRIu64 ")"
|
||||
2172 "Hard disk images (*.HDI;*.HDX;*.IMA;*.IMG)\0*.HDI;*.HDX;*.IMA;*.IMG\0All files (*.*)\0*.*\0"
|
||||
2173 "All floppy images (*.0??;*.12;*.144;*.360;*.720;*.86F;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMD;*.IMG;*.TD0;*.VFD;*.XDF)\0*.0??;*.12;*.144;*.360;*.720;*.86F;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMD;*.IMG;*.TD0;*.VFD;*.XDF\0Advanced sector-based images (*.IMD;*.TD0)\0*.IMD;*.TD0\0Basic sector-based images (*.0??;*.12;*.144;*.360;*.720;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMG;*.VFD;*.XDF)\0*.0??;*.12;*.144;*.360;*.720;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FDF;*.FLP;*.HDM;*.IMA;*.IMG;*.VFD;*.XDF\0Flux images (*.FDI)\0*.FDI\0Surface-based images (*.86F)\0*.86F\0All files (*.*)\0*.*\0"
|
||||
2174 "Configuration files (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0"
|
||||
2175 "CD-ROM image (*.ISO;*.CUE)\0*.ISO;*.CUE\0All files (*.*)\0*.*\0"
|
||||
2176 "Use CTRL + ALT + PAGE DOWN to return to windowed mode"
|
||||
2177 "Olivetti M24 mouse"
|
||||
2178 "This image exists and will be overwritten.\nAre you sure you want to use it?"
|
||||
2179 "Floppy %i (%s): %ws"
|
||||
2180 "CD-ROM %i: %ws"
|
||||
2181 "MFM hard disk"
|
||||
2182 "IDE hard disk (PIO-only)"
|
||||
2183 "IDE hard disk (PIO and DMA)"
|
||||
2184 "SCSI hard disk"
|
||||
2185 "(empty)"
|
||||
2186 "(host drive %c:)"
|
||||
2187 "Custom (large)..."
|
||||
2188 "Type"
|
||||
2189 "ATAPI (PIO-only)"
|
||||
2190 "ATAPI (PIO and DMA)"
|
||||
2191 "ATAPI (PIO-only) (%01i:%01i)"
|
||||
2192 "ATAPI (PIO and DMA) (%01i:%01i)"
|
||||
2193 "Use CTRL + ALT + PAGE DOWN to return to windowed mode"
|
||||
2194 "Unable to create bitmap file: %s"
|
||||
2195 "IDE (PIO-only) (%01i:%01i)"
|
||||
2196 "Add New Hard Disk"
|
||||
2197 "Add Existing Hard Disk"
|
||||
2198 "Removable disk %i: %s"
|
||||
2199 "USB is not yet supported"
|
||||
2200 "Invalid PCap device"
|
||||
2201 "English (United States)"
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,20,0,0
|
||||
PRODUCTVERSION 1,20,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "IRC #SoftHistory\0"
|
||||
VALUE "FileDescription", "86Box - an emulator for X86-based systems\0"
|
||||
VALUE "FileVersion", "1.20\0"
|
||||
VALUE "InternalName", "pc_new\0"
|
||||
VALUE "LegalCopyright", "Copyright <20> SoftHistory, Sarah Walker, 2007-2017, Released under the GNU GPL v2\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "86Box.exe\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "86Box Emulator\0"
|
||||
VALUE "ProductVersion", "1.20\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#
|
||||
# Modified Makefile for Win32 MinGW 32-bit environment.
|
||||
#
|
||||
# Version: @(#)Makefile.mingw 1.0.12 2017/05/12
|
||||
# Version: @(#)Makefile.mingw 1.0.13 2017/05/17
|
||||
#
|
||||
# Authors: Kotori, <oubattler@gmail.com>
|
||||
# Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -33,16 +33,20 @@ DEBUG = n
|
||||
OPTIM = n
|
||||
X64 = n
|
||||
|
||||
# Where is the WinPcap DLL ?
|
||||
PCAPDLL = C:\\Windows\\System32\\wpcap.dll
|
||||
|
||||
|
||||
#########################################################################
|
||||
# Nothing should need changing from here on.. #
|
||||
#########################################################################
|
||||
VPATH = . cpu sound sound/resid-fp video lzf slirp
|
||||
VPATH = . cpu sound sound/resid-fp video lzf slirp win
|
||||
PLAT = win/
|
||||
CPP = g++.exe
|
||||
CC = gcc.exe
|
||||
WINDRES = windres.exe
|
||||
|
||||
OPTS = -DWIN32 $(EXTRAS) $(STUFF)
|
||||
OPTS = -DWIN32 -I$(PLAT) $(EXTRAS) $(STUFF)
|
||||
ifeq ($(DEBUG), y)
|
||||
ifeq ($(VRAMDUMP), y)
|
||||
DFLAGS = -march=i686 -ggdb -DDEBUG -DENABLE_VRAM_DUMP
|
||||
@@ -129,7 +133,7 @@ DEVOBJ = bugger.o lpt.o serial.o \
|
||||
disc_86f.o disc_fdi.o disc_imd.o disc_img.o \
|
||||
disc_random.o disc_td0.o \
|
||||
cdrom.o \
|
||||
cdrom-dosbox.o cdrom-image.o cdrom-ioctl.o cdrom-null.o
|
||||
cdrom_dosbox.o cdrom_image.o cdrom_ioctl.o cdrom_null.o
|
||||
USBOBJ = usb.o
|
||||
NETOBJ = network.o \
|
||||
net_pcap.o net_slirp.o \
|
||||
@@ -173,12 +177,12 @@ VIDOBJ = video.o \
|
||||
vid_pc1512.o vid_pc1640.o vid_pc200.o \
|
||||
vid_tandy.o vid_tandysl.o
|
||||
WINOBJ = win.o \
|
||||
win-d3d.o win-d3d-fs.o \
|
||||
win-ddraw.o win-ddraw-fs.o win-ddraw-screenshot.o \
|
||||
win-language.o win-status.o win-opendir.o \
|
||||
win-video.o win-serial.o win-mouse.o \
|
||||
win-joystick.o win-midi.o \
|
||||
win-settings.o win-deviceconfig.o win-joystickconfig.o \
|
||||
win_d3d.o win_d3d-fs.o \
|
||||
win_ddraw.o win_ddraw-fs.o win_ddraw-screenshot.o \
|
||||
win_language.o win_status.o win_opendir.o \
|
||||
win_video.o win_serial.o win_mouse.o \
|
||||
win_joystick.o win_midi.o \
|
||||
win_settings.o win_deviceconfig.o win_joystickconfig.o \
|
||||
86Box.res
|
||||
OBJ = $(MAINOBJ) $(CPUOBJ) $(SYSOBJ) $(DEVOBJ) $(USBOBJ) \
|
||||
$(NETOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) $(WINOBJ)
|
||||
@@ -235,11 +239,15 @@ clean:
|
||||
|
||||
86Box.res: 86Box.rc
|
||||
@echo Processing $<
|
||||
@$(WINDRES) $(RFLAGS) -i 86Box.rc -o 86Box.res
|
||||
@$(WINDRES) $(RFLAGS) -i win/86Box.rc -o 86Box.res
|
||||
|
||||
libwpcapdelay.a: $(PCAPDLL)
|
||||
@dlltool --export-all-symbols --output-def wpcap.def $(PCAPDLL)
|
||||
@dlltool --def wpcap.def --output-delaylib libwpcapdelay.a
|
||||
|
||||
pcap_if.res: pcap_if.rc
|
||||
@echo Processing $<
|
||||
@$(WINDRES) $(RFLAGS) -i pcap_if.rc -o pcap_if.res
|
||||
@$(WINDRES) $(RFLAGS) -i win/pcap_if.rc -o pcap_if.res
|
||||
|
||||
|
||||
# End of Makefile.mingw.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "../io.h"
|
||||
#include "../pic.h"
|
||||
#include "../timer.h"
|
||||
#include "../plat-midi.h"
|
||||
#include "../win/plat_midi.h" /*YUCK*/
|
||||
#include "snd_mpu401.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "../io.h"
|
||||
#include "../pic.h"
|
||||
#include "../dma.h"
|
||||
#include "../plat-midi.h"
|
||||
#include "../win/plat_midi.h" /*YUCK*/
|
||||
#include "../timer.h"
|
||||
#include "sound.h"
|
||||
#include "snd_mpu401.h"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "vid_cga.h"
|
||||
#include "vid_cga_comp.h"
|
||||
#ifndef __unix
|
||||
#include "../win-cgapal.h"
|
||||
# include "../win/win_cgapal.h" /*YUCK*/
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "video.h"
|
||||
#include "vid_hercules.h"
|
||||
#ifndef __unix
|
||||
#include "../win-cgapal.h"
|
||||
# include "../win/win_cgapal.h" /*YUCK*/
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "video.h"
|
||||
#include "vid_mda.h"
|
||||
#ifndef __unix
|
||||
#include "../win-cgapal.h"
|
||||
# include "../win/win_cgapal.h" /*YUCK*/
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "video.h"
|
||||
#include "vid_svga.h"
|
||||
#ifndef __unix
|
||||
#include "../win-cgapal.h"
|
||||
# include "../win/win_cgapal.h" /*YUCK*/
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,565 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2002-2015 The DOSBox Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* Modified for use with PCem by bit */
|
||||
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <limits.h> //GCC 2.95
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <sys/stat.h>
|
||||
#include "cdrom-dosbox.h"
|
||||
|
||||
#if !defined(WIN32)
|
||||
#include <libgen.h>
|
||||
#else
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define MAX_LINE_LENGTH 512
|
||||
#define MAX_FILENAME_LENGTH 256
|
||||
#define CROSS_LEN 512
|
||||
|
||||
#define safe_strncpy(a,b,n) do { strncpy((a),(b),(n)-1); (a)[(n)-1] = 0; } while (0)
|
||||
|
||||
CDROM_Interface_Image::BinaryFile::BinaryFile(const char *filename, bool &error)
|
||||
{
|
||||
file = new ifstream(filename, ios::in | ios::binary);
|
||||
error = (file == NULL) || (file->fail());
|
||||
}
|
||||
|
||||
CDROM_Interface_Image::BinaryFile::~BinaryFile()
|
||||
{
|
||||
delete file;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::BinaryFile::read(Bit8u *buffer, int seek, int count)
|
||||
{
|
||||
file->seekg(seek, ios::beg);
|
||||
file->read((char*)buffer, count);
|
||||
return !(file->fail());
|
||||
}
|
||||
|
||||
int CDROM_Interface_Image::BinaryFile::getLength()
|
||||
{
|
||||
file->seekg(0, ios::end);
|
||||
int length = (int)file->tellg();
|
||||
if (file->fail()) return -1;
|
||||
return length;
|
||||
}
|
||||
|
||||
CDROM_Interface_Image::CDROM_Interface_Image()
|
||||
{
|
||||
}
|
||||
|
||||
CDROM_Interface_Image::~CDROM_Interface_Image()
|
||||
{
|
||||
ClearTracks();
|
||||
}
|
||||
|
||||
void CDROM_Interface_Image::InitNewMedia()
|
||||
{
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::SetDevice(char* path, int forceCD)
|
||||
{
|
||||
if (LoadCueSheet(path)) return true;
|
||||
if (LoadIsoFile(path)) return true;
|
||||
|
||||
// print error message on dosbox console
|
||||
//printf("Could not load image file: %s\n", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::GetUPC(unsigned char& attr, char* upc)
|
||||
{
|
||||
attr = 0;
|
||||
strcpy(upc, this->mcn.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::GetAudioTracks(int& stTrack, int& end, TMSF& leadOut)
|
||||
{
|
||||
stTrack = 1;
|
||||
end = (int)(tracks.size() - 1);
|
||||
FRAMES_TO_MSF(tracks[tracks.size() - 1].start + 150, &leadOut.min, &leadOut.sec, &leadOut.fr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::GetAudioTrackInfo(int track, int& track_number, TMSF& start, unsigned char& attr)
|
||||
{
|
||||
if (track < 1 || track > (int)tracks.size()) return false;
|
||||
FRAMES_TO_MSF(tracks[track - 1].start + 150, &start.min, &start.sec, &start.fr);
|
||||
track_number = tracks[track - 1].track_number;
|
||||
attr = tracks[track - 1].attr;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::GetAudioSub(int sector, unsigned char& attr, unsigned char& track, unsigned char& index, TMSF& relPos, TMSF& absPos)
|
||||
{
|
||||
int cur_track = GetTrack(sector);
|
||||
if (cur_track < 1) return false;
|
||||
track = (unsigned char)cur_track;
|
||||
attr = tracks[track - 1].attr;
|
||||
index = 1;
|
||||
FRAMES_TO_MSF(sector + 150, &absPos.min, &absPos.sec, &absPos.fr);
|
||||
FRAMES_TO_MSF(sector - tracks[track - 1].start + 150, &relPos.min, &relPos.sec, &relPos.fr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::GetMediaTrayStatus(bool& mediaPresent, bool& mediaChanged, bool& trayOpen)
|
||||
{
|
||||
mediaPresent = true;
|
||||
mediaChanged = false;
|
||||
trayOpen = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::ReadSectors(PhysPt buffer, bool raw, unsigned long sector, unsigned long num)
|
||||
{
|
||||
int sectorSize = raw ? RAW_SECTOR_SIZE : COOKED_SECTOR_SIZE;
|
||||
Bitu buflen = num * sectorSize;
|
||||
Bit8u* buf = new Bit8u[buflen];
|
||||
|
||||
bool success = true; //Gobliiins reads 0 sectors
|
||||
for(unsigned long i = 0; i < num; i++) {
|
||||
success = ReadSector(&buf[i * sectorSize], raw, sector + i);
|
||||
if (!success) break;
|
||||
}
|
||||
|
||||
memcpy((void*)buffer, buf, buflen);
|
||||
delete[] buf;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::LoadUnloadMedia(bool unload)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int CDROM_Interface_Image::GetTrack(int sector)
|
||||
{
|
||||
vector<Track>::iterator i = tracks.begin();
|
||||
vector<Track>::iterator end = tracks.end() - 1;
|
||||
|
||||
while(i != end) {
|
||||
Track &curr = *i;
|
||||
Track &next = *(i + 1);
|
||||
if (curr.start <= sector && sector < next.start) return curr.number;
|
||||
i++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::ReadSector(Bit8u *buffer, bool raw, unsigned long sector)
|
||||
{
|
||||
int track = GetTrack(sector) - 1;
|
||||
if (track < 0) return false;
|
||||
|
||||
int seek = tracks[track].skip + (sector - tracks[track].start) * tracks[track].sectorSize;
|
||||
int length = (raw ? RAW_SECTOR_SIZE : COOKED_SECTOR_SIZE);
|
||||
if (tracks[track].sectorSize != RAW_SECTOR_SIZE && raw) return false;
|
||||
if (tracks[track].sectorSize == RAW_SECTOR_SIZE && !tracks[track].mode2 && !raw) seek += 16;
|
||||
if (tracks[track].mode2 && !raw) seek += 24;
|
||||
|
||||
return tracks[track].file->read(buffer, seek, length);
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::IsMode2(unsigned long sector)
|
||||
{
|
||||
int track = GetTrack(sector) - 1;
|
||||
if (track < 0) return false;
|
||||
|
||||
if (tracks[track].mode2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::LoadIsoFile(char* filename)
|
||||
{
|
||||
int shift = 0;
|
||||
int totalPregap = 0;
|
||||
|
||||
tracks.clear();
|
||||
|
||||
// data track
|
||||
Track track = {0, 0, 0, 0, 0, 0, false, NULL};
|
||||
bool error;
|
||||
track.file = new BinaryFile(filename, error);
|
||||
if (error) {
|
||||
delete track.file;
|
||||
return false;
|
||||
}
|
||||
track.number = 1;
|
||||
track.track_number = 1;//IMPORTANT: This is needed.
|
||||
track.attr = DATA_TRACK;//data
|
||||
|
||||
// try to detect iso type
|
||||
if (CanReadPVD(track.file, COOKED_SECTOR_SIZE, false)) {
|
||||
track.sectorSize = COOKED_SECTOR_SIZE;
|
||||
track.mode2 = false;
|
||||
} else if (CanReadPVD(track.file, RAW_SECTOR_SIZE, false)) {
|
||||
track.sectorSize = RAW_SECTOR_SIZE;
|
||||
track.mode2 = false;
|
||||
} else if (CanReadPVD(track.file, 2336, true)) {
|
||||
track.sectorSize = 2336;
|
||||
track.mode2 = true;
|
||||
} else if (CanReadPVD(track.file, RAW_SECTOR_SIZE, true)) {
|
||||
track.sectorSize = RAW_SECTOR_SIZE;
|
||||
track.mode2 = true;
|
||||
} else return false;
|
||||
|
||||
track.length = track.file->getLength() / track.sectorSize;
|
||||
tracks.push_back(track);
|
||||
|
||||
// leadout track
|
||||
track.number = 2;
|
||||
track.track_number = 0xAA;
|
||||
track.attr = 0x16; /* Was 0x00 but I believe 0x16 is appropriate. */
|
||||
track.start = track.length;
|
||||
track.length = 0;
|
||||
track.file = NULL;
|
||||
tracks.push_back(track);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::CanReadPVD(TrackFile *file, int sectorSize, bool mode2)
|
||||
{
|
||||
Bit8u pvd[COOKED_SECTOR_SIZE];
|
||||
int seek = 16 * sectorSize; // first vd is located at sector 16
|
||||
if (sectorSize == RAW_SECTOR_SIZE && !mode2) seek += 16;
|
||||
if (mode2) seek += 24;
|
||||
file->read(pvd, seek, COOKED_SECTOR_SIZE);
|
||||
// pvd[0] = descriptor type, pvd[1..5] = standard identifier, pvd[6] = iso version (+8 for High Sierra)
|
||||
return ((pvd[0] == 1 && !strncmp((char*)(&pvd[1]), "CD001", 5) && pvd[6] == 1) ||
|
||||
(pvd[8] == 1 && !strncmp((char*)(&pvd[9]), "CDROM", 5) && pvd[14] == 1));
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
static string dirname(char * file) {
|
||||
char * sep = strrchr(file, '\\');
|
||||
if (sep == NULL)
|
||||
sep = strrchr(file, '/');
|
||||
if (sep == NULL)
|
||||
return "";
|
||||
else {
|
||||
int len = (int)(sep - file);
|
||||
char tmp[MAX_FILENAME_LENGTH];
|
||||
safe_strncpy(tmp, file, len+1);
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
|
||||
{
|
||||
Track track = {0, 0, 0, 0, 0, 0, false, NULL};
|
||||
tracks.clear();
|
||||
int shift = 0;
|
||||
int currPregap = 0;
|
||||
int totalPregap = 0;
|
||||
int prestart = 0;
|
||||
bool success;
|
||||
bool canAddTrack = false;
|
||||
char tmp[MAX_FILENAME_LENGTH]; // dirname can change its argument
|
||||
safe_strncpy(tmp, cuefile, MAX_FILENAME_LENGTH);
|
||||
string pathname(dirname(tmp));
|
||||
ifstream in;
|
||||
in.open(cuefile, ios::in);
|
||||
if (in.fail()) return false;
|
||||
|
||||
while(!in.eof()) {
|
||||
// get next line
|
||||
char buf[MAX_LINE_LENGTH];
|
||||
in.getline(buf, MAX_LINE_LENGTH);
|
||||
if (in.fail() && !in.eof()) return false; // probably a binary file
|
||||
istringstream line(buf);
|
||||
|
||||
string command;
|
||||
GetCueKeyword(command, line);
|
||||
|
||||
if (command == "TRACK") {
|
||||
if (canAddTrack) success = AddTrack(track, shift, prestart, totalPregap, currPregap);
|
||||
else success = true;
|
||||
|
||||
track.start = 0;
|
||||
track.skip = 0;
|
||||
currPregap = 0;
|
||||
prestart = 0;
|
||||
|
||||
line >> track.number;
|
||||
track.track_number = track.number;
|
||||
string type;
|
||||
GetCueKeyword(type, line);
|
||||
|
||||
if (type == "AUDIO") {
|
||||
track.sectorSize = RAW_SECTOR_SIZE;
|
||||
track.attr = AUDIO_TRACK;
|
||||
track.mode2 = false;
|
||||
} else if (type == "MODE1/2048") {
|
||||
track.sectorSize = COOKED_SECTOR_SIZE;
|
||||
track.attr = DATA_TRACK;
|
||||
track.mode2 = false;
|
||||
} else if (type == "MODE1/2352") {
|
||||
track.sectorSize = RAW_SECTOR_SIZE;
|
||||
track.attr = DATA_TRACK;
|
||||
track.mode2 = false;
|
||||
} else if (type == "MODE2/2336") {
|
||||
track.sectorSize = 2336;
|
||||
track.attr = DATA_TRACK;
|
||||
track.mode2 = true;
|
||||
} else if (type == "MODE2/2352") {
|
||||
track.sectorSize = RAW_SECTOR_SIZE;
|
||||
track.attr = DATA_TRACK;
|
||||
track.mode2 = true;
|
||||
} else success = false;
|
||||
|
||||
canAddTrack = true;
|
||||
}
|
||||
else if (command == "INDEX") {
|
||||
int index;
|
||||
line >> index;
|
||||
int frame;
|
||||
success = GetCueFrame(frame, line);
|
||||
|
||||
if (index == 1) track.start = frame;
|
||||
else if (index == 0) prestart = frame;
|
||||
// ignore other indices
|
||||
}
|
||||
else if (command == "FILE") {
|
||||
if (canAddTrack) success = AddTrack(track, shift, prestart, totalPregap, currPregap);
|
||||
else success = true;
|
||||
canAddTrack = false;
|
||||
|
||||
string filename;
|
||||
GetCueString(filename, line);
|
||||
GetRealFileName(filename, pathname);
|
||||
string type;
|
||||
GetCueKeyword(type, line);
|
||||
|
||||
track.file = NULL;
|
||||
bool error = true;
|
||||
if (type == "BINARY") {
|
||||
track.file = new BinaryFile(filename.c_str(), error);
|
||||
}
|
||||
if (error) {
|
||||
delete track.file;
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
else if (command == "PREGAP") success = GetCueFrame(currPregap, line);
|
||||
else if (command == "CATALOG") success = GetCueString(mcn, line);
|
||||
// ignored commands
|
||||
else if (command == "CDTEXTFILE" || command == "FLAGS" || command == "ISRC"
|
||||
|| command == "PERFORMER" || command == "POSTGAP" || command == "REM"
|
||||
|| command == "SONGWRITER" || command == "TITLE" || command == "") success = true;
|
||||
// failure
|
||||
else success = false;
|
||||
|
||||
if (!success) return false;
|
||||
}
|
||||
// add last track
|
||||
if (!AddTrack(track, shift, prestart, totalPregap, currPregap)) return false;
|
||||
|
||||
// add leadout track
|
||||
track.number++;
|
||||
track.track_number = 0xAA;
|
||||
// track.attr = 0;//sync with load iso
|
||||
track.attr = 0x16; /* Was 0x00 but I believe 0x16 is appropriate. */
|
||||
track.start = 0;
|
||||
track.length = 0;
|
||||
track.file = NULL;
|
||||
if(!AddTrack(track, shift, 0, totalPregap, 0)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::AddTrack(Track &curr, int &shift, int prestart, int &totalPregap, int currPregap)
|
||||
{
|
||||
// frames between index 0(prestart) and 1(curr.start) must be skipped
|
||||
int skip;
|
||||
if (prestart > 0) {
|
||||
if (prestart > curr.start) return false;
|
||||
skip = curr.start - prestart;
|
||||
} else skip = 0;
|
||||
|
||||
// first track (track number must be 1)
|
||||
if (tracks.empty()) {
|
||||
if (curr.number != 1) return false;
|
||||
curr.skip = skip * curr.sectorSize;
|
||||
curr.start += currPregap;
|
||||
totalPregap = currPregap;
|
||||
tracks.push_back(curr);
|
||||
return true;
|
||||
}
|
||||
|
||||
Track &prev = *(tracks.end() - 1);
|
||||
|
||||
// current track consumes data from the same file as the previous
|
||||
if (prev.file == curr.file) {
|
||||
curr.start += shift;
|
||||
prev.length = curr.start + totalPregap - prev.start - skip;
|
||||
curr.skip += prev.skip + prev.length * prev.sectorSize + skip * curr.sectorSize;
|
||||
totalPregap += currPregap;
|
||||
curr.start += totalPregap;
|
||||
// current track uses a different file as the previous track
|
||||
} else {
|
||||
int tmp = prev.file->getLength() - prev.skip;
|
||||
prev.length = tmp / prev.sectorSize;
|
||||
if (tmp % prev.sectorSize != 0) prev.length++; // padding
|
||||
|
||||
curr.start += prev.start + prev.length + currPregap;
|
||||
curr.skip = skip * curr.sectorSize;
|
||||
shift += prev.start + prev.length;
|
||||
totalPregap = currPregap;
|
||||
}
|
||||
|
||||
// error checks
|
||||
if (curr.number <= 1) return false;
|
||||
if (prev.number + 1 != curr.number) return false;
|
||||
if (curr.start < prev.start + prev.length) return false;
|
||||
if (curr.length < 0) return false;
|
||||
|
||||
tracks.push_back(curr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::HasDataTrack(void)
|
||||
{
|
||||
//Data track has attribute 0x14
|
||||
for(track_it it = tracks.begin(); it != tracks.end(); it++) {
|
||||
if ((*it).attr == DATA_TRACK) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::HasAudioTracks(void)
|
||||
{
|
||||
for(track_it it = tracks.begin(); it != tracks.end(); it++) {
|
||||
if ((*it).attr == AUDIO_TRACK) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CDROM_Interface_Image::GetRealFileName(string &filename, string &pathname)
|
||||
{
|
||||
// check if file exists
|
||||
struct stat test;
|
||||
if (stat(filename.c_str(), &test) == 0) return true;
|
||||
|
||||
// check if file with path relative to cue file exists
|
||||
string tmpstr(pathname + "/" + filename);
|
||||
if (stat(tmpstr.c_str(), &test) == 0) {
|
||||
filename = tmpstr;
|
||||
return true;
|
||||
}
|
||||
#if defined (WIN32) || defined(OS2)
|
||||
//Nothing
|
||||
#else
|
||||
//Consider the possibility that the filename has a windows directory seperator (inside the CUE file)
|
||||
//which is common for some commercial rereleases of DOS games using DOSBox
|
||||
|
||||
string copy = filename;
|
||||
size_t l = copy.size();
|
||||
for (size_t i = 0; i < l;i++) {
|
||||
if(copy[i] == '\\') copy[i] = '/';
|
||||
}
|
||||
|
||||
if (stat(copy.c_str(), &test) == 0) {
|
||||
filename = copy;
|
||||
return true;
|
||||
}
|
||||
|
||||
tmpstr = pathname + "/" + copy;
|
||||
if (stat(tmpstr.c_str(), &test) == 0) {
|
||||
filename = tmpstr;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::GetCueKeyword(string &keyword, istream &in)
|
||||
{
|
||||
in >> keyword;
|
||||
for(Bitu i = 0; i < keyword.size(); i++) keyword[i] = toupper(keyword[i]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::GetCueFrame(int &frames, istream &in)
|
||||
{
|
||||
string msf;
|
||||
in >> msf;
|
||||
int min, sec, fr;
|
||||
bool success = sscanf(msf.c_str(), "%d:%d:%d", &min, &sec, &fr) == 3;
|
||||
frames = MSF_TO_FRAMES(min, sec, fr);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::GetCueString(string &str, istream &in)
|
||||
{
|
||||
int pos = (int)in.tellg();
|
||||
in >> str;
|
||||
if (str[0] == '\"') {
|
||||
if (str[str.size() - 1] == '\"') {
|
||||
str.assign(str, 1, str.size() - 2);
|
||||
} else {
|
||||
in.seekg(pos, ios::beg);
|
||||
char buffer[MAX_FILENAME_LENGTH];
|
||||
in.getline(buffer, MAX_FILENAME_LENGTH, '\"'); // skip
|
||||
in.getline(buffer, MAX_FILENAME_LENGTH, '\"');
|
||||
str = buffer;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDROM_Interface_Image::ClearTracks()
|
||||
{
|
||||
vector<Track>::iterator i = tracks.begin();
|
||||
vector<Track>::iterator end = tracks.end();
|
||||
|
||||
TrackFile* last = NULL;
|
||||
while(i != end) {
|
||||
Track &curr = *i;
|
||||
if (curr.file != last) {
|
||||
delete curr.file;
|
||||
last = curr.file;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
tracks.clear();
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2002-2015 The DOSBox Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* Modified for use with PCem by bit */
|
||||
|
||||
#ifndef __CDROM_INTERFACE__
|
||||
#define __CDROM_INTERFACE__
|
||||
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
//#include "dosbox.h"
|
||||
//#include "mem.h"
|
||||
//#include "mixer.h"
|
||||
//#include "SDL.h"
|
||||
//#include "SDL_thread.h"
|
||||
|
||||
#include <stdint.h>
|
||||
typedef signed int Bits;
|
||||
typedef unsigned int Bitu;
|
||||
typedef int8_t Bit8s;
|
||||
typedef uint8_t Bit8u;
|
||||
typedef int16_t Bit16s;
|
||||
typedef uint16_t Bit16u;
|
||||
typedef int32_t Bit32s;
|
||||
typedef uint32_t Bit32u;
|
||||
|
||||
typedef size_t PhysPt;
|
||||
|
||||
#define RAW_SECTOR_SIZE 2352
|
||||
#define COOKED_SECTOR_SIZE 2048
|
||||
|
||||
#define DATA_TRACK 0x14
|
||||
#define AUDIO_TRACK 0x10
|
||||
|
||||
#define CD_FPS 75
|
||||
#define FRAMES_TO_MSF(f, M,S,F) { \
|
||||
int value = f; \
|
||||
*(F) = value%CD_FPS; \
|
||||
value /= CD_FPS; \
|
||||
*(S) = value%60; \
|
||||
value /= 60; \
|
||||
*(M) = value; \
|
||||
}
|
||||
#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F))
|
||||
|
||||
|
||||
typedef struct SMSF {
|
||||
unsigned char min;
|
||||
unsigned char sec;
|
||||
unsigned char fr;
|
||||
} TMSF;
|
||||
|
||||
typedef struct SCtrl {
|
||||
Bit8u out[4]; // output channel
|
||||
Bit8u vol[4]; // channel volume
|
||||
} TCtrl;
|
||||
|
||||
extern int CDROM_GetMountType(char* path, int force);
|
||||
|
||||
class CDROM_Interface
|
||||
{
|
||||
public:
|
||||
// CDROM_Interface (void);
|
||||
virtual ~CDROM_Interface (void) {};
|
||||
|
||||
virtual bool SetDevice (char* path, int forceCD) = 0;
|
||||
|
||||
virtual bool GetUPC (unsigned char& attr, char* upc) = 0;
|
||||
|
||||
virtual bool GetAudioTracks (int& stTrack, int& end, TMSF& leadOut) = 0;
|
||||
virtual bool GetAudioTrackInfo (int track, int& number, TMSF& start, unsigned char& attr) = 0;
|
||||
virtual bool GetAudioSub (int sector, unsigned char& attr, unsigned char& track, unsigned char& index, TMSF& relPos, TMSF& absPos) = 0;
|
||||
virtual bool GetMediaTrayStatus (bool& mediaPresent, bool& mediaChanged, bool& trayOpen) = 0;
|
||||
|
||||
virtual bool ReadSectors (PhysPt buffer, bool raw, unsigned long sector, unsigned long num) = 0;
|
||||
|
||||
virtual bool LoadUnloadMedia (bool unload) = 0;
|
||||
|
||||
virtual void InitNewMedia (void) {};
|
||||
};
|
||||
|
||||
class CDROM_Interface_Image : public CDROM_Interface
|
||||
{
|
||||
private:
|
||||
class TrackFile {
|
||||
public:
|
||||
virtual bool read(Bit8u *buffer, int seek, int count) = 0;
|
||||
virtual int getLength() = 0;
|
||||
virtual ~TrackFile() { };
|
||||
};
|
||||
|
||||
class BinaryFile : public TrackFile {
|
||||
public:
|
||||
BinaryFile(const char *filename, bool &error);
|
||||
~BinaryFile();
|
||||
bool read(Bit8u *buffer, int seek, int count);
|
||||
int getLength();
|
||||
private:
|
||||
BinaryFile();
|
||||
std::ifstream *file;
|
||||
};
|
||||
|
||||
struct Track {
|
||||
int number;
|
||||
int track_number;
|
||||
int attr;
|
||||
int start;
|
||||
int length;
|
||||
int skip;
|
||||
int sectorSize;
|
||||
bool mode2;
|
||||
TrackFile *file;
|
||||
};
|
||||
|
||||
public:
|
||||
CDROM_Interface_Image ();
|
||||
virtual ~CDROM_Interface_Image (void);
|
||||
void InitNewMedia (void);
|
||||
bool SetDevice (char* path, int forceCD);
|
||||
bool GetUPC (unsigned char& attr, char* upc);
|
||||
bool GetAudioTracks (int& stTrack, int& end, TMSF& leadOut);
|
||||
bool GetAudioTrackInfo (int track, int& number, TMSF& start, unsigned char& attr);
|
||||
bool GetAudioSub (int sector, unsigned char& attr, unsigned char& track, unsigned char& index, TMSF& relPos, TMSF& absPos);
|
||||
bool GetMediaTrayStatus (bool& mediaPresent, bool& mediaChanged, bool& trayOpen);
|
||||
bool ReadSectors (PhysPt buffer, bool raw, unsigned long sector, unsigned long num);
|
||||
bool LoadUnloadMedia (bool unload);
|
||||
bool ReadSector (Bit8u *buffer, bool raw, unsigned long sector);
|
||||
bool IsMode2 (unsigned long sector);
|
||||
bool HasDataTrack (void);
|
||||
bool HasAudioTracks (void);
|
||||
|
||||
int GetTrack (int sector);
|
||||
|
||||
private:
|
||||
// player
|
||||
static void CDAudioCallBack(Bitu len);
|
||||
|
||||
void ClearTracks();
|
||||
bool LoadIsoFile(char *filename);
|
||||
bool CanReadPVD(TrackFile *file, int sectorSize, bool mode2);
|
||||
// cue sheet processing
|
||||
bool LoadCueSheet(char *cuefile);
|
||||
bool GetRealFileName(std::string& filename, std::string& pathname);
|
||||
bool GetCueKeyword(std::string &keyword, std::istream &in);
|
||||
bool GetCueFrame(int &frames, std::istream &in);
|
||||
bool GetCueString(std::string &str, std::istream &in);
|
||||
bool AddTrack(Track &curr, int &shift, int prestart, int &totalPregap, int currPregap);
|
||||
|
||||
std::vector<Track> tracks;
|
||||
typedef std::vector<Track>::iterator track_it;
|
||||
std::string mcn;
|
||||
};
|
||||
|
||||
#endif /* __CDROM_INTERFACE__ */
|
||||
1045
src/cdrom-image.cc
1045
src/cdrom-image.cc
File diff suppressed because it is too large
Load Diff
@@ -1,28 +0,0 @@
|
||||
/* Copyright holders: RichardG867, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#ifndef CDROM_IMAGE_H
|
||||
#define CDROM_IMAGE_H
|
||||
|
||||
/* this header file lists the functions provided by
|
||||
various platform specific cdrom-ioctl files */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int image_open(uint8_t id, wchar_t *fn);
|
||||
extern void image_reset(uint8_t id);
|
||||
|
||||
extern void image_close(uint8_t id);
|
||||
|
||||
void update_status_bar_icon_state(int tag, int state);
|
||||
extern void cdrom_set_null_handler(uint8_t id);
|
||||
|
||||
void pclog(const char *format, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! CDROM_IMAGE_H */
|
||||
@@ -1,725 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
/*Linux CD-ROM support via IOCTL*/
|
||||
|
||||
#include <linux/cdrom.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdlib.h>
|
||||
#include "ibm.h"
|
||||
#include "ide.h"
|
||||
#include "cdrom-ioctl.h"
|
||||
|
||||
static ATAPI ioctl_atapi;
|
||||
|
||||
static uint32_t last_block = 0;
|
||||
static uint32_t cdrom_capacity = 0;
|
||||
static int ioctl_inited = 0;
|
||||
static char ioctl_path[8];
|
||||
static int tocvalid = 0;
|
||||
static struct cdrom_tocentry toc[100];
|
||||
static int first_track, last_track;
|
||||
|
||||
int old_cdrom_drive;
|
||||
|
||||
#define MSFtoLBA(m,s,f) (((((m*60)+s)*75)+f)-150)
|
||||
|
||||
enum
|
||||
{
|
||||
CD_STOPPED = 0,
|
||||
CD_PLAYING,
|
||||
CD_PAUSED
|
||||
};
|
||||
|
||||
static int ioctl_cd_state = CD_STOPPED;
|
||||
static uint32_t ioctl_cd_pos = 0, ioctl_cd_end = 0;
|
||||
#define BUF_SIZE 32768
|
||||
static int16_t cd_buffer[BUF_SIZE];
|
||||
static int cd_buflen = 0;
|
||||
void ioctl_audio_callback(int16_t *output, int len)
|
||||
{
|
||||
int fd;
|
||||
struct cdrom_read_audio read_audio;
|
||||
|
||||
// pclog("Audio callback %08X %08X %i %i %i %04X %i\n", ioctl_cd_pos, ioctl_cd_end, ioctl_cd_state, cd_buflen, len, cd_buffer[4], GetTickCount());
|
||||
if (ioctl_cd_state != CD_PLAYING)
|
||||
{
|
||||
memset(output, 0, len * 2);
|
||||
return;
|
||||
}
|
||||
fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if (fd <= 0)
|
||||
{
|
||||
memset(output, 0, len * 2);
|
||||
return;
|
||||
}
|
||||
|
||||
while (cd_buflen < len)
|
||||
{
|
||||
if (ioctl_cd_pos < ioctl_cd_end)
|
||||
{
|
||||
read_audio.addr.lba = ioctl_cd_pos - 150;
|
||||
read_audio.addr_format = CDROM_LBA;
|
||||
read_audio.nframes = 1;
|
||||
read_audio.buf = (__u8 *)&cd_buffer[cd_buflen];
|
||||
|
||||
if (ioctl(fd, CDROMREADAUDIO, &read_audio) < 0)
|
||||
{
|
||||
// pclog("DeviceIoControl returned false\n");
|
||||
memset(&cd_buffer[cd_buflen], 0, (BUF_SIZE - cd_buflen) * 2);
|
||||
ioctl_cd_state = CD_STOPPED;
|
||||
cd_buflen = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
// pclog("DeviceIoControl returned true\n");
|
||||
ioctl_cd_pos++;
|
||||
cd_buflen += (2352 / 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&cd_buffer[cd_buflen], 0, (BUF_SIZE - cd_buflen) * 2);
|
||||
ioctl_cd_state = CD_STOPPED;
|
||||
cd_buflen = len;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
memcpy(output, cd_buffer, len * 2);
|
||||
// for (c = 0; c < BUF_SIZE - len; c++)
|
||||
// cd_buffer[c] = cd_buffer[c + cd_buflen];
|
||||
memcpy(&cd_buffer[0], &cd_buffer[len], (BUF_SIZE - len) * 2);
|
||||
cd_buflen -= len;
|
||||
// pclog("Done %i\n", GetTickCount());
|
||||
}
|
||||
|
||||
void ioctl_audio_stop()
|
||||
{
|
||||
ioctl_cd_state = CD_STOPPED;
|
||||
}
|
||||
|
||||
static int get_track_nr(uint32_t pos)
|
||||
{
|
||||
int c;
|
||||
int track = 0;
|
||||
|
||||
if (!tocvalid)
|
||||
return 0;
|
||||
|
||||
for (c = first_track; c < last_track; c++)
|
||||
{
|
||||
uint32_t track_address = toc[c].cdte_addr.msf.frame +
|
||||
(toc[c].cdte_addr.msf.second * 75) +
|
||||
(toc[c].cdte_addr.msf.minute * 75 * 60);
|
||||
//pclog("get_track_nr: track=%i pos=%x track_address=%x\n", c, pos, track_address);
|
||||
if (track_address <= pos)
|
||||
track = c;
|
||||
}
|
||||
return track;
|
||||
}
|
||||
|
||||
static int is_track_audio(uint32_t pos)
|
||||
{
|
||||
int c;
|
||||
int control = 0;
|
||||
|
||||
if (!tocvalid)
|
||||
return 0;
|
||||
|
||||
for (c = first_track; c < last_track; c++)
|
||||
{
|
||||
uint32_t track_address = toc[c].cdte_addr.msf.frame +
|
||||
(toc[c].cdte_addr.msf.second * 75) +
|
||||
(toc[c].cdte_addr.msf.minute * 75 * 60);
|
||||
//pclog("get_track_nr: track=%i pos=%x track_address=%x\n", c, pos, track_address);
|
||||
if (track_address <= pos)
|
||||
control = toc[c].cdte_ctrl;
|
||||
}
|
||||
return (control & 4) ? 0 : 1;
|
||||
}
|
||||
|
||||
static int ioctl_is_track_audio(uint32_t pos, int ismsf)
|
||||
{
|
||||
if (ismsf)
|
||||
{
|
||||
int m = (pos >> 16) & 0xff;
|
||||
int s = (pos >> 8) & 0xff;
|
||||
int f = pos & 0xff;
|
||||
pos = MSFtoLBA(m, s, f);
|
||||
}
|
||||
return is_track_audio(pos);
|
||||
}
|
||||
|
||||
static void ioctl_playaudio(uint32_t pos, uint32_t len, int ismsf)
|
||||
{
|
||||
// pclog("Play audio - %08X %08X %i\n", pos, len, ismsf);
|
||||
if (ismsf)
|
||||
{
|
||||
pos = (pos & 0xff) + (((pos >> 8) & 0xff) * 75) + (((pos >> 16) & 0xff) * 75 * 60);
|
||||
len = (len & 0xff) + (((len >> 8) & 0xff) * 75) + (((len >> 16) & 0xff) * 75 * 60);
|
||||
// pclog("MSF - pos = %08X len = %08X\n", pos, len);
|
||||
}
|
||||
else
|
||||
len += pos;
|
||||
ioctl_cd_pos = pos;// + 150;
|
||||
ioctl_cd_end = pos+len;// + 150;
|
||||
ioctl_cd_state = CD_PLAYING;
|
||||
if (ioctl_cd_pos < 150)
|
||||
ioctl_cd_pos = 150;
|
||||
// pclog("Audio start %08X %08X %i %i %i\n", ioctl_cd_pos, ioctl_cd_end, ioctl_cd_state, 0, len);
|
||||
}
|
||||
|
||||
static void ioctl_pause(void)
|
||||
{
|
||||
if (ioctl_cd_state == CD_PLAYING)
|
||||
ioctl_cd_state = CD_PAUSED;
|
||||
}
|
||||
|
||||
static void ioctl_resume(void)
|
||||
{
|
||||
if (ioctl_cd_state == CD_PAUSED)
|
||||
ioctl_cd_state = CD_PLAYING;
|
||||
}
|
||||
|
||||
static void ioctl_stop(void)
|
||||
{
|
||||
ioctl_cd_state = CD_STOPPED;
|
||||
}
|
||||
|
||||
static void ioctl_seek(uint32_t pos)
|
||||
{
|
||||
// pclog("Seek %08X\n", pos);
|
||||
ioctl_cd_pos = pos;
|
||||
ioctl_cd_state = CD_STOPPED;
|
||||
}
|
||||
|
||||
static int read_toc(int fd, struct cdrom_tocentry *btoc)
|
||||
{
|
||||
struct cdrom_tochdr toc_hdr;
|
||||
int track, err;
|
||||
//pclog("read_toc\n");
|
||||
err = ioctl(fd, CDROMREADTOCHDR, &toc_hdr);
|
||||
if (err == -1)
|
||||
{
|
||||
pclog("read_toc: CDROMREADTOCHDR failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
first_track = toc_hdr.cdth_trk0;
|
||||
last_track = toc_hdr.cdth_trk1;
|
||||
//pclog("read_toc: first_track=%i last_track=%i\n", first_track, last_track);
|
||||
memset(btoc, 0, sizeof(cdrom_tocentry));
|
||||
|
||||
for (track = toc_hdr.cdth_trk0; track <= toc_hdr.cdth_trk1; track++)
|
||||
{
|
||||
btoc[track].cdte_track = track;
|
||||
btoc[track].cdte_format = CDROM_MSF;
|
||||
err = ioctl(fd, CDROMREADTOCENTRY, &btoc[track]);
|
||||
if (err == -1)
|
||||
{
|
||||
// pclog("read_toc: CDROMREADTOCENTRY failed on track %i\n", track);
|
||||
return 0;
|
||||
}
|
||||
// pclog("read_toc: Track %02X - number %02X control %02X adr %02X address %02X %02X %02X %02X\n", track, toc[track].cdte_track, toc[track].cdte_ctrl, toc[track].cdte_adr, 0, toc[track].cdte_addr.msf.minute, toc[track].cdte_addr.msf.second, toc[track].cdte_addr.msf.frame);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ioctl_ready(void)
|
||||
{
|
||||
long size;
|
||||
int temp;
|
||||
struct cdrom_tochdr toc_hdr;
|
||||
struct cdrom_tocentry toc_entry;
|
||||
int err;
|
||||
int fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if (fd <= 0)
|
||||
return 0;
|
||||
|
||||
err = ioctl(fd, CDROMREADTOCHDR, &toc_hdr);
|
||||
if (err == -1)
|
||||
{
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
// pclog("CDROMREADTOCHDR: start track=%i end track=%i\n", toc_hdr.cdth_trk0, toc_hdr.cdth_trk1);
|
||||
toc_entry.cdte_track = toc_hdr.cdth_trk1;
|
||||
toc_entry.cdte_format = CDROM_MSF;
|
||||
err = ioctl(fd, CDROMREADTOCENTRY, &toc_entry);
|
||||
if (err == -1)
|
||||
{
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
// pclog("CDROMREADTOCENTRY: addr=%02i:%02i:%02i\n", toc_entry.cdte_addr.msf.minute, toc_entry.cdte_addr.msf.second, toc_entry.cdte_addr.msf.frame);
|
||||
if ((toc_entry.cdte_addr.msf.minute != toc[toc_hdr.cdth_trk1].cdte_addr.msf.minute) ||
|
||||
(toc_entry.cdte_addr.msf.second != toc[toc_hdr.cdth_trk1].cdte_addr.msf.second) ||
|
||||
(toc_entry.cdte_addr.msf.frame != toc[toc_hdr.cdth_trk1].cdte_addr.msf.frame ) ||
|
||||
!tocvalid)
|
||||
{
|
||||
int track;
|
||||
ioctl_cd_state = CD_STOPPED;
|
||||
|
||||
tocvalid = read_toc(fd, toc);
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ioctl_get_last_block(unsigned char starttrack, int msf, int maxlen, int single)
|
||||
{
|
||||
int c;
|
||||
int lb = 0;
|
||||
int tv = 0;
|
||||
struct cdrom_tocentry lbtoc[100];
|
||||
int fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if (fd <= 0)
|
||||
return 0;
|
||||
|
||||
ioctl_cd_state = CD_STOPPED;
|
||||
|
||||
tv = read_toc(fd, lbtoc);
|
||||
|
||||
close(fd);
|
||||
|
||||
if (!tv)
|
||||
return 0;
|
||||
|
||||
last_block = 0;
|
||||
for (c = 0; c <= last_track; c++)
|
||||
{
|
||||
uint32_t address;
|
||||
address = MSFtoLBA(toc[c].cdte_addr.msf.minute, toc[c].cdte_addr.msf.second, toc[c].cdte_addr.msf.frame);
|
||||
if (address > last_block)
|
||||
lb = address;
|
||||
}
|
||||
return lb;
|
||||
}
|
||||
|
||||
static int ioctl_medium_changed(void)
|
||||
{
|
||||
long size;
|
||||
int temp;
|
||||
struct cdrom_tochdr toc_hdr;
|
||||
struct cdrom_tocentry toc_entry;
|
||||
int err;
|
||||
int fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if (fd <= 0)
|
||||
return 0;
|
||||
|
||||
err = ioctl(fd, CDROMREADTOCHDR, &toc_hdr);
|
||||
if (err == -1)
|
||||
{
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
toc_entry.cdte_track = toc_hdr.cdth_trk1;
|
||||
toc_entry.cdte_format = CDROM_MSF;
|
||||
err = ioctl(fd, CDROMREADTOCENTRY, &toc_entry);
|
||||
if (err == -1)
|
||||
{
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
// pclog("CDROMREADTOCENTRY: addr=%02i:%02i:%02i\n", toc_entry.cdte_addr.msf.minute, toc_entry.cdte_addr.msf.second, toc_entry.cdte_addr.msf.frame);
|
||||
if ((toc_entry.cdte_addr.msf.minute != toc[toc_hdr.cdth_trk1].cdte_addr.msf.minute) ||
|
||||
(toc_entry.cdte_addr.msf.second != toc[toc_hdr.cdth_trk1].cdte_addr.msf.second) ||
|
||||
(toc_entry.cdte_addr.msf.frame != toc[toc_hdr.cdth_trk1].cdte_addr.msf.frame ))
|
||||
{
|
||||
cdrom_capacity = ioctl_get_last_block(0, 0, 4096, 0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t ioctl_getcurrentsubchannel(uint8_t *b, int msf)
|
||||
{
|
||||
struct cdrom_subchnl sub;
|
||||
uint32_t cdpos = ioctl_cd_pos;
|
||||
int track = get_track_nr(cdpos);
|
||||
uint32_t track_address = toc[track].cdte_addr.msf.frame +
|
||||
(toc[track].cdte_addr.msf.second * 75) +
|
||||
(toc[track].cdte_addr.msf.minute * 75 * 60);
|
||||
long size;
|
||||
int pos=0;
|
||||
int err;
|
||||
uint8_t ret;
|
||||
//pclog("ioctl_getsubchannel: cdpos=%x track_address=%x track=%i\n", cdpos, track_address, track);
|
||||
if (ioctl_cd_state == CD_PLAYING)
|
||||
ret = 0x11;
|
||||
else if (ioctl_cd_state == CD_PAUSED)
|
||||
ret = 0x12;
|
||||
else
|
||||
ret = 0x13;
|
||||
|
||||
b[pos++] = (toc[track].cdte_adr << 4) | toc[track].cdte_ctrl;
|
||||
b[pos++] = track;
|
||||
b[pos++] = 0;
|
||||
|
||||
if (msf)
|
||||
{
|
||||
uint32_t dat = cdpos;
|
||||
b[pos + 3] = (uint8_t)(dat % 75); dat /= 75;
|
||||
b[pos + 2] = (uint8_t)(dat % 60); dat /= 60;
|
||||
b[pos + 1] = (uint8_t)dat;
|
||||
b[pos] = 0;
|
||||
pos += 4;
|
||||
dat = cdpos - track_address;
|
||||
b[pos + 3] = (uint8_t)(dat % 75); dat /= 75;
|
||||
b[pos + 2] = (uint8_t)(dat % 60); dat /= 60;
|
||||
b[pos + 1] = (uint8_t)dat;
|
||||
b[pos] = 0;
|
||||
pos += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
b[pos++] = (cdpos >> 24) & 0xff;
|
||||
b[pos++] = (cdpos >> 16) & 0xff;
|
||||
b[pos++] = (cdpos >> 8) & 0xff;
|
||||
b[pos++] = cdpos & 0xff;
|
||||
cdpos -= track_address;
|
||||
b[pos++] = (cdpos >> 24) & 0xff;
|
||||
b[pos++] = (cdpos >> 16) & 0xff;
|
||||
b[pos++] = (cdpos >> 8) & 0xff;
|
||||
b[pos++] = cdpos & 0xff;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ioctl_eject(void)
|
||||
{
|
||||
int fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if (fd <= 0)
|
||||
return;
|
||||
|
||||
ioctl(fd, CDROMEJECT);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
static void ioctl_load(void)
|
||||
{
|
||||
int fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if (fd <= 0)
|
||||
return;
|
||||
|
||||
ioctl(fd, CDROMEJECT);
|
||||
|
||||
close(fd);
|
||||
|
||||
cdrom_capacity = ioctl_get_last_block(0, 0, 4096, 0);
|
||||
}
|
||||
|
||||
union
|
||||
{
|
||||
struct cdrom_msf *msf;
|
||||
char b[CD_FRAMESIZE_RAW];
|
||||
} raw_read_params;
|
||||
|
||||
static int lba_to_msf(int lba)
|
||||
{
|
||||
return (((lba / 75) / 60) << 16) + (((lba / 75) % 60) << 8) + (lba % 75);
|
||||
}
|
||||
|
||||
static int ioctl_sector_data_type(int sector, int ismsf)
|
||||
{
|
||||
return 2; /* Always Mode 1 */
|
||||
}
|
||||
|
||||
static void ioctl_readsector_raw(uint8_t *b, int sector)
|
||||
{
|
||||
int err;
|
||||
int imsf = lba_to_msf(sector);
|
||||
int cdrom = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if (cdrom <= 0)
|
||||
return;
|
||||
|
||||
raw_read_params.msf = malloc(sizeof(struct cdrom_msf));
|
||||
raw_read_params.msf->cdmsf_frame0 = imsf & 0xff;
|
||||
raw_read_params.msf->cdmsf_sec0 = (imsf >> 8) & 0xff;
|
||||
raw_read_params.msf->cdmsf_min0 = (imsf >> 16) & 0xff;
|
||||
|
||||
/* This will read the actual raw sectors from the disc. */
|
||||
err = ioctl(cdrom, CDROMREADRAW, (void *) &raw_read_params);
|
||||
if (err == -1)
|
||||
{
|
||||
pclog("read_toc: CDROMREADTOCHDR failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(b, raw_read_params.b, 2352);
|
||||
|
||||
close(cdrom);
|
||||
|
||||
free(raw_read_params.msf);
|
||||
}
|
||||
|
||||
static int ioctl_readtoc(unsigned char *b, unsigned char starttrack, int msf, int maxlen, int single)
|
||||
{
|
||||
int len=4;
|
||||
long size;
|
||||
int c,d;
|
||||
uint32_t temp;
|
||||
int fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if (fd <= 0)
|
||||
return 0;
|
||||
|
||||
ioctl_cd_state = CD_STOPPED;
|
||||
|
||||
tocvalid = read_toc(fd, toc);
|
||||
|
||||
close(fd);
|
||||
|
||||
if (!tocvalid)
|
||||
return 4;
|
||||
|
||||
// pclog("Read TOC done! %i\n",single);
|
||||
b[2] = first_track;
|
||||
b[3] = last_track;
|
||||
d = 0;
|
||||
//pclog("Read TOC starttrack=%i\n", starttrack);
|
||||
for (c = 1; c <= last_track; c++)
|
||||
{
|
||||
if (toc[c].cdte_track >= starttrack)
|
||||
{
|
||||
d = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
b[2] = toc[c].cdte_track;
|
||||
last_block = 0;
|
||||
for (c = d; c <= last_track; c++)
|
||||
{
|
||||
uint32_t address;
|
||||
if ((len + 8) > maxlen)
|
||||
break;
|
||||
// pclog("Len %i max %i Track %02X - %02X %02X %02i:%02i:%02i %08X\n",len,maxlen,toc[c].cdte_track,toc[c].cdte_adr,toc[c].cdte_ctrl,toc[c].cdte_addr.msf.minute, toc[c].cdte_addr.msf.second, toc[c].cdte_addr.msf.frame,MSFtoLBA(toc[c].cdte_addr.msf.minute, toc[c].cdte_addr.msf.second, toc[c].cdte_addr.msf.frame));
|
||||
b[len++] = 0; /*Reserved*/
|
||||
b[len++] = (toc[c].cdte_adr << 4) | toc[c].cdte_ctrl;
|
||||
b[len++] = toc[c].cdte_track;
|
||||
b[len++] = 0; /*Reserved*/
|
||||
address = MSFtoLBA(toc[c].cdte_addr.msf.minute, toc[c].cdte_addr.msf.second, toc[c].cdte_addr.msf.frame);
|
||||
if (address > last_block)
|
||||
last_block = address;
|
||||
|
||||
if (msf)
|
||||
{
|
||||
b[len++] = 0;
|
||||
b[len++] = toc[c].cdte_addr.msf.minute;
|
||||
b[len++] = toc[c].cdte_addr.msf.second;
|
||||
b[len++] = toc[c].cdte_addr.msf.frame;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = MSFtoLBA(toc[c].cdte_addr.msf.minute, toc[c].cdte_addr.msf.second, toc[c].cdte_addr.msf.frame);
|
||||
b[len++] = temp >> 24;
|
||||
b[len++] = temp >> 16;
|
||||
b[len++] = temp >> 8;
|
||||
b[len++] = temp;
|
||||
}
|
||||
if (single)
|
||||
break;
|
||||
}
|
||||
b[0] = (uint8_t)(((len-2) >> 8) & 0xff);
|
||||
b[1] = (uint8_t)((len-2) & 0xff);
|
||||
/* pclog("Table of Contents (%i bytes) : \n", size);
|
||||
pclog("First track - %02X\n", first_track);
|
||||
pclog("Last track - %02X\n", last_track);
|
||||
for (c = 0; c <= last_track; c++)
|
||||
pclog("Track %02X - number %02X control %02X adr %02X address %02X %02X %02X %02X\n", c, toc[c].cdte_track, toc[c].cdte_ctrl, toc[c].cdte_adr, 0, toc[c].cdte_addr.msf.minute, toc[c].cdte_addr.msf.second, toc[c].cdte_addr.msf.frame);
|
||||
for (c = 0;c <= last_track; c++)
|
||||
pclog("Track %02X - number %02X control %02X adr %02X address %06X\n", c, toc[c].cdte_track, toc[c].cdte_ctrl, toc[c].cdte_adr, MSFtoLBA(toc[c].cdte_addr.msf.minute, toc[c].cdte_addr.msf.second, toc[c].cdte_addr.msf.frame));*/
|
||||
return len;
|
||||
}
|
||||
|
||||
static int ioctl_readtoc_session(unsigned char *b, int msf, int maxlen)
|
||||
{
|
||||
struct cdrom_multisession session;
|
||||
int len = 4;
|
||||
int err;
|
||||
int fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if (fd <= 0)
|
||||
return 0;
|
||||
|
||||
session.addr_format = CDROM_MSF;
|
||||
err = ioctl(fd, CDROMMULTISESSION, &session);
|
||||
|
||||
if (err == -1)
|
||||
{
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
b[2] = 0;
|
||||
b[3] = 0;
|
||||
b[len++] = 0; /*Reserved*/
|
||||
b[len++] = (toc[0].cdte_adr << 4) | toc[0].cdte_ctrl;
|
||||
b[len++] = toc[0].cdte_track;
|
||||
b[len++] = 0; /*Reserved*/
|
||||
if (msf)
|
||||
{
|
||||
b[len++] = 0;
|
||||
b[len++] = session.addr.msf.minute;
|
||||
b[len++] = session.addr.msf.second;
|
||||
b[len++] = session.addr.msf.frame;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t temp = MSFtoLBA(session.addr.msf.minute, session.addr.msf.second, session.addr.msf.frame);
|
||||
b[len++] = temp >> 24;
|
||||
b[len++] = temp >> 16;
|
||||
b[len++] = temp >> 8;
|
||||
b[len++] = temp;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static int ioctl_readtoc_raw(unsigned char *b, int maxlen)
|
||||
{
|
||||
struct cdrom_tochdr toc_hdr;
|
||||
struct cdrom_tocentry toc2[100];
|
||||
int track, err;
|
||||
int len = 4;
|
||||
int fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
|
||||
//pclog("read_toc\n");
|
||||
if (fd <= 0)
|
||||
return 0;
|
||||
|
||||
err = ioctl(fd, CDROMREADTOCHDR, &toc_hdr);
|
||||
if (err == -1)
|
||||
{
|
||||
pclog("read_toc: CDROMREADTOCHDR failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
b[2] = toc_hdr.cdth_trk0;
|
||||
b[3] = toc_hdr.cdth_trk1;
|
||||
|
||||
//pclog("read_toc: first_track=%i last_track=%i\n", first_track, last_track);
|
||||
memset(toc, 0, sizeof(toc));
|
||||
|
||||
for (track = toc_hdr.cdth_trk0; track <= toc_hdr.cdth_trk1; track++)
|
||||
{
|
||||
if ((len + 11) > maxlen)
|
||||
{
|
||||
pclog("ioctl_readtocraw: This iteration would fill the buffer beyond the bounds, aborting...\n");
|
||||
close(fd);
|
||||
return len;
|
||||
}
|
||||
|
||||
toc2[track].cdte_track = track;
|
||||
toc2[track].cdte_format = CDROM_MSF;
|
||||
err = ioctl(fd, CDROMREADTOCENTRY, &toc2[track]);
|
||||
if (err == -1)
|
||||
{
|
||||
// pclog("read_toc: CDROMREADTOCENTRY failed on track %i\n", track);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
// pclog("read_toc: Track %02X - number %02X control %02X adr %02X address %02X %02X %02X %02X\n", track, toc[track].cdte_track, toc[track].cdte_ctrl, toc[track].cdte_adr, 0, toc[track].cdte_addr.msf.minute, toc[track].cdte_addr.msf.second, toc[track].cdte_addr.msf.frame);
|
||||
|
||||
b[len++] = toc2[track].cdte_track;
|
||||
b[len++]= (toc2[track].cdte_adr << 4) | toc[track].cdte_ctrl;
|
||||
b[len++]=0;
|
||||
b[len++]=0;
|
||||
b[len++]=0;
|
||||
b[len++]=0;
|
||||
b[len++]=0;
|
||||
b[len++]=0;
|
||||
b[len++] = toc2[track].cdte_addr.msf.minute;
|
||||
b[len++] = toc2[track].cdte_addr.msf.second;
|
||||
b[len++] = toc2[track].cdte_addr.msf.frame;
|
||||
}
|
||||
close(fd);
|
||||
return len;
|
||||
}
|
||||
|
||||
static uint32_t ioctl_size()
|
||||
{
|
||||
return cdrom_capacity;
|
||||
}
|
||||
|
||||
static int ioctl_status()
|
||||
{
|
||||
if (!(ioctl_ready) && (cdrom_drive <= 0)) return CD_STATUS_EMPTY;
|
||||
|
||||
switch(ioctl_cd_state)
|
||||
{
|
||||
case CD_PLAYING:
|
||||
return CD_STATUS_PLAYING;
|
||||
case CD_PAUSED:
|
||||
return CD_STATUS_PAUSED;
|
||||
case CD_STOPPED:
|
||||
return CD_STATUS_STOPPED;
|
||||
}
|
||||
}
|
||||
void ioctl_reset()
|
||||
{
|
||||
int fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
|
||||
//pclog("ioctl_reset: fd=%i\n", fd);
|
||||
tocvalid = 0;
|
||||
|
||||
if (fd <= 0)
|
||||
return;
|
||||
|
||||
tocvalid = read_toc(fd, toc);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
int ioctl_open(char d)
|
||||
{
|
||||
atapi=&ioctl_atapi;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ioctl_close(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void ioctl_exit(void)
|
||||
{
|
||||
ioctl_stop();
|
||||
ioctl_inited = 0;
|
||||
tocvalid=0;
|
||||
}
|
||||
|
||||
static ATAPI ioctl_atapi=
|
||||
{
|
||||
ioctl_ready,
|
||||
ioctl_medium_changed,
|
||||
ioctl_readtoc,
|
||||
ioctl_readtoc_session,
|
||||
ioctl_readtoc_raw,
|
||||
ioctl_getcurrentsubchannel,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
ioctl_sector_data_type,
|
||||
ioctl_readsector_raw,
|
||||
ioctl_playaudio,
|
||||
ioctl_seek,
|
||||
ioctl_load,
|
||||
ioctl_eject,
|
||||
ioctl_pause,
|
||||
ioctl_resume,
|
||||
ioctl_size,
|
||||
ioctl_status,
|
||||
ioctl_is_track_audio,
|
||||
ioctl_stop,
|
||||
ioctl_exit
|
||||
};
|
||||
1099
src/cdrom-ioctl.c
1099
src/cdrom-ioctl.c
File diff suppressed because it is too large
Load Diff
@@ -1,17 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#ifndef CDROM_IOCTL_H
|
||||
#define CDROM_IOCTL_H
|
||||
|
||||
/* this header file lists the functions provided by
|
||||
various platform specific cdrom-ioctl files */
|
||||
|
||||
extern uint32_t cdrom_capacity;
|
||||
|
||||
extern int ioctl_open(uint8_t id, char d);
|
||||
extern void ioctl_reset(uint8_t id);
|
||||
|
||||
extern void ioctl_close(uint8_t id);
|
||||
|
||||
#endif /* ! CDROM_IOCTL_H */
|
||||
130
src/cdrom-null.c
130
src/cdrom-null.c
@@ -1,130 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include "ibm.h"
|
||||
#include "cdrom.h"
|
||||
#include "cdrom-ioctl.h"
|
||||
|
||||
static CDROM null_cdrom;
|
||||
|
||||
static int null_ready(uint8_t id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Always return 0, the contents of a null CD-ROM drive never change. */
|
||||
static int null_medium_changed(uint8_t id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t null_getcurrentsubchannel(uint8_t id, uint8_t *b, int msf)
|
||||
{
|
||||
return 0x13;
|
||||
}
|
||||
|
||||
static void null_eject(uint8_t id)
|
||||
{
|
||||
}
|
||||
|
||||
static void null_load(uint8_t id)
|
||||
{
|
||||
}
|
||||
|
||||
static int null_readsector_raw(uint8_t id, uint8_t *buffer, int sector, int ismsf, int cdrom_sector_type, int cdrom_sector_flags, int *len)
|
||||
{
|
||||
*len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int null_readtoc(uint8_t id, unsigned char *b, unsigned char starttrack, int msf, int maxlen, int single)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int null_readtoc_session(uint8_t id, unsigned char *b, int msf, int maxlen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int null_readtoc_raw(uint8_t id, unsigned char *b, int msf, int maxlen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t null_size(uint8_t id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int null_status(uint8_t id)
|
||||
{
|
||||
return CD_STATUS_EMPTY;
|
||||
}
|
||||
|
||||
void cdrom_null_reset(uint8_t id)
|
||||
{
|
||||
}
|
||||
|
||||
void cdrom_set_null_handler(uint8_t id);
|
||||
|
||||
int cdrom_null_open(uint8_t id, char d)
|
||||
{
|
||||
cdrom_set_null_handler(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void null_close(uint8_t id)
|
||||
{
|
||||
}
|
||||
|
||||
static void null_exit(uint8_t id)
|
||||
{
|
||||
}
|
||||
|
||||
static int null_is_track_audio(uint8_t id, uint32_t pos, int ismsf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int null_pass_through(uint8_t id, uint8_t *in_cdb, uint8_t *b, uint32_t *len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int null_media_type_id(uint8_t id)
|
||||
{
|
||||
return 0x70;
|
||||
}
|
||||
|
||||
void cdrom_set_null_handler(uint8_t id)
|
||||
{
|
||||
cdrom_drives[id].handler = &null_cdrom;
|
||||
cdrom_drives[id].host_drive = 0;
|
||||
update_status_bar_icon_state(0x10 | id, 1);
|
||||
}
|
||||
|
||||
static CDROM null_cdrom =
|
||||
{
|
||||
null_ready,
|
||||
null_medium_changed,
|
||||
null_media_type_id,
|
||||
NULL,
|
||||
NULL,
|
||||
null_readtoc,
|
||||
null_readtoc_session,
|
||||
null_readtoc_raw,
|
||||
null_getcurrentsubchannel,
|
||||
null_pass_through,
|
||||
null_readsector_raw,
|
||||
NULL,
|
||||
null_load,
|
||||
null_eject,
|
||||
NULL,
|
||||
NULL,
|
||||
null_size,
|
||||
null_status,
|
||||
null_is_track_audio,
|
||||
NULL,
|
||||
null_exit
|
||||
};
|
||||
@@ -1,14 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
#ifndef CDROM_NULL_H
|
||||
#define CDROM_NULL_H
|
||||
|
||||
/* this header file lists the functions provided by
|
||||
various platform specific cdrom-ioctl files */
|
||||
|
||||
int cdrom_null_open(uint8_t id, char d);
|
||||
void cdrom_null_reset(uint8_t id);
|
||||
void null_close(uint8_t id);
|
||||
|
||||
#endif /* ! CDROM_NULL_H */
|
||||
515
src/config.c
515
src/config.c
File diff suppressed because it is too large
Load Diff
50
src/config.h
50
src/config.h
@@ -1,37 +1,39 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
int config_get_int(char *head, char *name, int def);
|
||||
char *config_get_string(char *head, char *name, char *def);
|
||||
wchar_t *config_get_wstring(char *head, char *name, wchar_t *def);
|
||||
void config_set_int(char *head, char *name, int val);
|
||||
void config_set_string(char *head, char *name, char *val);
|
||||
void config_set_wstring(char *head, char *name, wchar_t *val);
|
||||
|
||||
char *get_filename(char *s);
|
||||
wchar_t *get_filename_w(wchar_t *s);
|
||||
void append_filename(char *dest, char *s1, char *s2, int size);
|
||||
void append_filename_w(wchar_t *dest, wchar_t *s1, wchar_t *s2, int size);
|
||||
void put_backslash(char *s);
|
||||
void put_backslash_w(wchar_t *s);
|
||||
char *get_extension(char *s);
|
||||
|
||||
extern wchar_t config_file_default[256];
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
wchar_t *get_extension_w(wchar_t *s);
|
||||
extern int config_get_int(char *head, char *name, int def);
|
||||
extern char *config_get_string(char *head, char *name, char *def);
|
||||
extern wchar_t *config_get_wstring(char *head, char *name, wchar_t *def);
|
||||
extern void config_set_int(char *head, char *name, int val);
|
||||
extern void config_set_string(char *head, char *name, char *val);
|
||||
extern void config_set_wstring(char *head, char *name, wchar_t *val);
|
||||
|
||||
extern char *get_filename(char *s);
|
||||
extern wchar_t *get_filename_w(wchar_t *s);
|
||||
extern void append_filename(char *dest, char *s1, char *s2, int size);
|
||||
extern void append_filename_w(wchar_t *dest, wchar_t *s1, wchar_t *s2, int size);
|
||||
extern void put_backslash(char *s);
|
||||
extern void put_backslash_w(wchar_t *s);
|
||||
extern char *get_extension(char *s);
|
||||
|
||||
extern wchar_t *get_extension_w(wchar_t *s);
|
||||
|
||||
extern void config_load(wchar_t *fn);
|
||||
extern void config_save(wchar_t *fn);
|
||||
extern void config_dump(void);
|
||||
|
||||
extern void loadconfig(wchar_t *fn);
|
||||
extern void saveconfig(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
void config_load(wchar_t *fn);
|
||||
void config_save(wchar_t *fn);
|
||||
void config_dump(void);
|
||||
void config_free(void);
|
||||
|
||||
extern wchar_t config_file_default[256];
|
||||
|
||||
void loadconfig(wchar_t *fn);
|
||||
void saveconfig(void);
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
#include "device.h"
|
||||
#include "io.h"
|
||||
#include "timer.h"
|
||||
#include "plat-joystick.h"
|
||||
#include "gameport.h"
|
||||
#include "joystick_ch_flightstick_pro.h"
|
||||
#include "joystick_standard.h"
|
||||
#include "joystick_sw_pad.h"
|
||||
#include "joystick_tm_fcs.h"
|
||||
#include "plat_joystick.h"
|
||||
|
||||
|
||||
int joystick_type;
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include "timer.h"
|
||||
#include "gameport.h"
|
||||
#include "joystick_standard.h"
|
||||
#include "plat-joystick.h"
|
||||
#include "plat_joystick.h"
|
||||
|
||||
|
||||
static void *ch_flightstick_pro_init()
|
||||
{
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include "timer.h"
|
||||
#include "gameport.h"
|
||||
#include "joystick_standard.h"
|
||||
#include "plat-joystick.h"
|
||||
#include "plat_joystick.h"
|
||||
|
||||
|
||||
static void *joystick_standard_init()
|
||||
{
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
#include "timer.h"
|
||||
#include "gameport.h"
|
||||
#include "joystick_sw_pad.h"
|
||||
#include "plat-joystick.h"
|
||||
#include "plat_joystick.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include "timer.h"
|
||||
#include "gameport.h"
|
||||
#include "joystick_standard.h"
|
||||
#include "plat-joystick.h"
|
||||
#include "plat_joystick.h"
|
||||
|
||||
|
||||
static void *tm_fcs_init()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include "ibm.h"
|
||||
#include "plat-keyboard.h"
|
||||
#include "plat_keyboard.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
int keybsendcallback = 0;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
* Based on an early driver for MINIX 1.5.
|
||||
* Based on the 86Box PS/2 mouse driver as a framework.
|
||||
*
|
||||
* Version: @(#)mouse_bus.c 1.0.4 2017/05/06
|
||||
* Version: @(#)mouse_bus.c 1.0.4 2017/05/17
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Copyright 1989-2017 Fred N. van Kempen.
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "pic.h"
|
||||
#include "mouse.h"
|
||||
#include "mouse_bus.h"
|
||||
#include "plat-mouse.h"
|
||||
#include "plat_mouse.h"
|
||||
|
||||
|
||||
#define ENABLE_3BTN 1 /* enable 3-button mode */
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include "keyboard_at.h"
|
||||
#include "mouse.h"
|
||||
#include "mouse_ps2.h"
|
||||
#include "plat-mouse.h"
|
||||
#include "plat_mouse.h"
|
||||
|
||||
|
||||
int mouse_scan = 0;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* NOTE: Its still a mess, but we're getting there. The file will
|
||||
* also implement an NE1000 for 8-bit ISA systems.
|
||||
*
|
||||
* Version: @(#)net_ne2000.c 1.0.3 2017/05/12
|
||||
* Version: @(#)net_ne2000.c 1.0.4 2017/05/17
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Peter Grehan, grehan@iprg.nokia.com>
|
||||
@@ -49,9 +49,6 @@ typedef union {
|
||||
} bar_t;
|
||||
|
||||
|
||||
/* This stuff should go into the struct. --FvK */
|
||||
static uint8_t maclocal[6] = {0xac, 0xde, 0x48, 0x88, 0xbb, 0xaa};
|
||||
static uint8_t maclocal_pci[6] = {0xac, 0xde, 0x48, 0x88, 0xbb, 0xaa};
|
||||
#if ENABLE_NE2000_LOG
|
||||
static int nic_do_log = ENABLE_NE2000_LOG;
|
||||
#else
|
||||
@@ -216,6 +213,7 @@ typedef struct {
|
||||
int disable_netbios;
|
||||
int tx_timer_index;
|
||||
int tx_timer_active;
|
||||
uint8_t maclocal[6]; /* configured MAC (local) address */
|
||||
uint8_t pci_regs[256];
|
||||
uint8_t eeprom[128]; /* for RTL8029AS */
|
||||
rom_t bios_rom;
|
||||
@@ -1767,14 +1765,15 @@ nic_rom_init(nic_t *dev, wchar_t *s)
|
||||
}
|
||||
|
||||
|
||||
uint32_t
|
||||
ne2000_get_maclocal(void)
|
||||
/* Return the 'local' part of our configured MAC address. */
|
||||
static uint32_t
|
||||
nic_get_maclocal(nic_t *dev)
|
||||
{
|
||||
uint32_t temp;
|
||||
|
||||
temp = (((int) maclocal[3]) << 16);
|
||||
temp |= (((int) maclocal[4]) << 8);
|
||||
temp |= ((int) maclocal[5]);
|
||||
temp = (((int) dev->maclocal[3]) << 16);
|
||||
temp |= (((int) dev->maclocal[4]) << 8);
|
||||
temp |= ((int) dev->maclocal[5]);
|
||||
|
||||
return(temp);
|
||||
}
|
||||
@@ -1784,23 +1783,17 @@ static void *
|
||||
nic_init(int board)
|
||||
{
|
||||
uint32_t mac;
|
||||
uint8_t *ptr;
|
||||
nic_t *dev;
|
||||
|
||||
dev = malloc(sizeof(nic_t));
|
||||
memset(dev, 0x00, sizeof(nic_t));
|
||||
dev->board = board;
|
||||
dev->is_rtl8029as = (PCI && (board == NE2K_RTL8029AS)) ? 1 : 0;
|
||||
if (board == NE2K_RTL8029AS)
|
||||
{
|
||||
if (board == NE2K_RTL8029AS) {
|
||||
strcpy(dev->name, "RTL8029AS");
|
||||
}
|
||||
else if (board == NE2K_NE1000)
|
||||
{
|
||||
} else if (board == NE2K_NE1000) {
|
||||
strcpy(dev->name, "NE1000");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
strcpy(dev->name, "NE2000");
|
||||
}
|
||||
|
||||
@@ -1812,32 +1805,35 @@ nic_init(int board)
|
||||
dev->base_address = device_get_config_int("addr");
|
||||
}
|
||||
|
||||
/* See if we have a local MAC address configured. */
|
||||
mac = device_get_config_int_ex("mac", -1);
|
||||
|
||||
/* Set up our MAC address. */
|
||||
if (dev->is_rtl8029as) {
|
||||
maclocal[0] = 0x00; /* 00:20:18 (RTL 8029AS PCI vendor prefix). */
|
||||
maclocal[1] = 0x20;
|
||||
maclocal[2] = 0x18;
|
||||
dev->maclocal[0] = 0x00; /* 00:20:18 (RTL 8029AS PCI vendor prefix). */
|
||||
dev->maclocal[1] = 0x20;
|
||||
dev->maclocal[2] = 0x18;
|
||||
} else {
|
||||
maclocal[0] = 0x00; /* 00:00:D8 (NE2000 ISA vendor prefix). */
|
||||
maclocal[1] = 0x00;
|
||||
maclocal[2] = 0xD8;
|
||||
dev->maclocal[0] = 0x00; /* 00:00:D8 (NE2000 ISA vendor prefix). */
|
||||
dev->maclocal[1] = 0x00;
|
||||
dev->maclocal[2] = 0xD8;
|
||||
}
|
||||
ptr = maclocal;
|
||||
pclog(1, "MAClocal: mac=%08lx\n", mac);
|
||||
if (mac & 0xff000000) {
|
||||
/* Generating new MAC. */
|
||||
ptr[3] = disc_random_generate();
|
||||
ptr[4] = disc_random_generate();
|
||||
ptr[5] = disc_random_generate() | 1;
|
||||
device_set_config_int("mac", ne2000_get_maclocal());
|
||||
dev->maclocal[3] = disc_random_generate();
|
||||
dev->maclocal[4] = disc_random_generate();
|
||||
dev->maclocal[5] = disc_random_generate() | 1;
|
||||
device_set_config_int("mac", nic_get_maclocal(dev));
|
||||
} else {
|
||||
ptr[3] = (mac>>16) & 0xff;
|
||||
ptr[4] = (mac>>8) & 0xff;
|
||||
ptr[5] = (mac & 0xff) | 1;
|
||||
dev->maclocal[3] = (mac>>16) & 0xff;
|
||||
dev->maclocal[4] = (mac>>8) & 0xff;
|
||||
#if 1
|
||||
dev->maclocal[5] = (mac & 0xfe);
|
||||
#else
|
||||
dev->maclocal[5] = (mac & 0xff) | 1;
|
||||
#endif
|
||||
}
|
||||
memcpy(dev->physaddr, ptr, 6);
|
||||
memcpy(dev->physaddr, dev->maclocal, sizeof(dev->maclocal));
|
||||
|
||||
pclog(1,"%s: I/O=%04x, IRQ=%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x BIOS=%d\n",
|
||||
dev->name, dev->base_address, dev->base_irq,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the NE2000 ethernet controller.
|
||||
*
|
||||
* Version: @(#)net_ne2000.h 1.0.2 2017/05/11
|
||||
* Version: @(#)net_ne2000.h 1.0.3 2017/05/17
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*/
|
||||
@@ -26,11 +26,4 @@ extern device_t ne2000_device;
|
||||
extern device_t rtl8029as_device;
|
||||
|
||||
|
||||
extern void ne2000_generate_maclocal(uint32_t mac);
|
||||
extern uint32_t ne2000_get_maclocal(void);
|
||||
|
||||
extern void ne2000_generate_maclocal_pci(uint32_t mac);
|
||||
extern uint32_t ne2000_get_maclocal_pci(void);
|
||||
|
||||
|
||||
#endif /*NET_NE2000_H*/
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handle WinPcap library processing.
|
||||
*
|
||||
* Version: @(#)net_pcap.c 1.0.1 2017/05/11
|
||||
* Version: @(#)net_pcap.c 1.0.2 2017/05/17
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*/
|
||||
@@ -29,9 +29,6 @@ static thread_t *poll_tid;
|
||||
static NETRXCB poll_rx; /* network RX function to call */
|
||||
static void *poll_arg; /* network RX function arg */
|
||||
|
||||
int netdev_num;
|
||||
netdev_t netdev_list[512];
|
||||
|
||||
|
||||
#ifdef WALTJE
|
||||
int pcap_do_log = 1;
|
||||
@@ -108,8 +105,6 @@ poll_thread(void *arg)
|
||||
}
|
||||
|
||||
|
||||
char pcap_dev[512];
|
||||
|
||||
/* Initialize WinPcap for us. */
|
||||
int
|
||||
network_pcap_setup(uint8_t *mac, NETRXCB func, void *arg)
|
||||
@@ -135,11 +130,12 @@ network_pcap_setup(uint8_t *mac, NETRXCB func, void *arg)
|
||||
pclog("Initializing WinPcap, version %s\n", temp);
|
||||
|
||||
/* Get the value of our capture interface. */
|
||||
if (pcap_dev == NULL) {
|
||||
dev = network_pcap;
|
||||
if ((dev[0] == '\0') || !strcmp(dev, "none")) {
|
||||
pclog(" No network device configured!\n");
|
||||
return(-1);
|
||||
}
|
||||
pclog(" Network interface: '%s'\n", pcap_dev);
|
||||
pclog(" Network interface: '%s'\n", dev);
|
||||
|
||||
pcap = pcap_open_live(dev, /* interface name */
|
||||
1518, /* maximum packet size */
|
||||
@@ -227,16 +223,15 @@ network_devlist(netdev_t *list)
|
||||
pcap_if_t *devlist, *dev;
|
||||
int i = 0;
|
||||
|
||||
/* Note by Kotori: Add the first (and guaranteed to be always present) device - "None". */
|
||||
/* Create a first entry that's always there - needed by UI. */
|
||||
strcpy(list->device, "none");
|
||||
strcpy(list->description, "None");
|
||||
list++;
|
||||
i++;
|
||||
list++; i++;
|
||||
|
||||
/* Retrieve the device list from the local machine */
|
||||
if (pcap_findalldevs(&devlist, errbuf) == -1) {
|
||||
pclog("NETWORK: error in pcap_findalldevs_ex: %s\n", errbuf);
|
||||
return(i); /* Note by Kotori: The list will always have at least one entry - "None". */
|
||||
pclog("NETWORK: error in pcap_findalldevs: %s\n", errbuf);
|
||||
return(i);
|
||||
}
|
||||
|
||||
for (dev=devlist; dev!=NULL; dev=dev->next) {
|
||||
@@ -245,8 +240,7 @@ network_devlist(netdev_t *list)
|
||||
strcpy(list->description, dev->description);
|
||||
else
|
||||
memset(list->description, '\0', sizeof(list->description));
|
||||
list++;
|
||||
i++;
|
||||
list++; i++;
|
||||
}
|
||||
|
||||
/* Release the memory. */
|
||||
@@ -254,19 +248,3 @@ network_devlist(netdev_t *list)
|
||||
|
||||
return(i);
|
||||
}
|
||||
|
||||
int network_dev_to_id(char *dev)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < netdev_num; i++)
|
||||
{
|
||||
if (!strcmp(netdev_list[i].device, dev))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the device does not match the list, consider it as if it was set to "none". */
|
||||
return 0;
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handle SLiRP library processing.
|
||||
*
|
||||
* Version: @(#)net_slirp.c 1.0.1 2017/05/11
|
||||
* Version: @(#)net_slirp.c 1.0.2 2017/05/17
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*/
|
||||
@@ -29,7 +29,6 @@ static queueADT slirpq; /* SLiRP library handle */
|
||||
static thread_t *poll_tid;
|
||||
static NETRXCB poll_rx; /* network RX function to call */
|
||||
static void *poll_arg; /* network RX function arg */
|
||||
static int fizz;
|
||||
|
||||
|
||||
/* Instead of calling this and crashing some times
|
||||
@@ -38,27 +37,29 @@ static int fizz;
|
||||
static void
|
||||
slirp_tic(void)
|
||||
{
|
||||
int ret2,nfds;
|
||||
int ret2, nfds;
|
||||
struct timeval tv;
|
||||
fd_set rfds, wfds, xfds;
|
||||
int tmo;
|
||||
nfds=-1;
|
||||
|
||||
/* Let SLiRP create a list of all open sockets. */
|
||||
nfds = -1;
|
||||
FD_ZERO(&rfds);
|
||||
FD_ZERO(&wfds);
|
||||
FD_ZERO(&xfds);
|
||||
tmo = slirp_select_fill(&nfds, &rfds, &wfds, &xfds); /* this can crash */
|
||||
if (tmo < 0) {
|
||||
if (tmo < 0)
|
||||
tmo = 500;
|
||||
}
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = tmo; /* basilisk default 10000 */
|
||||
tv.tv_usec = tmo;
|
||||
|
||||
/* Now wait for something to happen, or at most 'tmo' usec. */
|
||||
ret2 = select(nfds+1, &rfds, &wfds, &xfds, &tv);
|
||||
if (ret2 >= 0) {
|
||||
|
||||
/* If something happened, let SLiRP handle it. */
|
||||
if (ret2 >= 0)
|
||||
slirp_select_poll(&rfds, &wfds, &xfds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,10 +78,8 @@ poll_thread(void *arg)
|
||||
pclog("SLiRP: poll event is %08lx\n", evt);
|
||||
|
||||
while (slirpq != NULL) {
|
||||
if (++fizz > 1200) {
|
||||
fizz = 0;
|
||||
slirp_tic();
|
||||
}
|
||||
/* See if there is any work. */
|
||||
slirp_tic();
|
||||
|
||||
/* Wait for the next packet to arrive. */
|
||||
if (QueuePeek(slirpq) == 0) {
|
||||
@@ -124,8 +123,6 @@ network_slirp_setup(uint8_t *mac, NETRXCB func, void *arg)
|
||||
slirpq = QueueCreate();
|
||||
pclog(" Packet queue is at %08lx\n", &slirpq);
|
||||
|
||||
fizz = 0;
|
||||
|
||||
/* Save the callback info. */
|
||||
poll_rx = func;
|
||||
poll_arg = arg;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* it should be malloc'ed and then linked to the NETCARD def.
|
||||
* Will be done later.
|
||||
*
|
||||
* Version: @(#)network.c 1.0.3 2017/05/12
|
||||
* Version: @(#)network.c 1.0.4 2017/05/17
|
||||
*
|
||||
* Authors: Kotori, <oubattler@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -41,8 +41,12 @@ static netcard_t net_cards[] = {
|
||||
};
|
||||
|
||||
|
||||
int network_card;
|
||||
int network_type;
|
||||
/* Global variables. */
|
||||
int network_card;
|
||||
int network_type;
|
||||
int network_ndev;
|
||||
netdev_t network_devs[32];
|
||||
char network_pcap[512];
|
||||
|
||||
|
||||
/*
|
||||
@@ -55,8 +59,11 @@ int network_type;
|
||||
void
|
||||
network_init(void)
|
||||
{
|
||||
network_type = NET_TYPE_NONE;
|
||||
network_card = 0;
|
||||
network_type = -1;
|
||||
|
||||
/* Initialize list of PCap devices. */
|
||||
network_ndev = network_devlist(network_devs);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,11 +87,11 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
|
||||
|
||||
/* Start the platform module. */
|
||||
switch(network_type) {
|
||||
case 0:
|
||||
case NET_TYPE_PCAP:
|
||||
ret = network_pcap_setup(mac, rx, dev);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case NET_TYPE_SLIRP:
|
||||
ret = network_slirp_setup(mac, rx, dev);
|
||||
break;
|
||||
}
|
||||
@@ -98,11 +105,11 @@ void
|
||||
network_close(void)
|
||||
{
|
||||
switch(network_type) {
|
||||
case 0:
|
||||
case NET_TYPE_PCAP:
|
||||
network_pcap_close();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case NET_TYPE_SLIRP:
|
||||
network_slirp_close();
|
||||
break;
|
||||
}
|
||||
@@ -127,10 +134,11 @@ network_reset(void)
|
||||
network_close();
|
||||
|
||||
/* If no active card, we're done. */
|
||||
if (!network_card || (network_type<0)) return;
|
||||
if ((network_type==NET_TYPE_NONE) || (network_card==0)) return;
|
||||
|
||||
pclog("NETWORK: set up for %s, card=%s\n",
|
||||
(network_type==1)?"SLiRP":"WinPcap", net_cards[network_card].name);
|
||||
(network_type==NET_TYPE_SLIRP)?"SLiRP":"WinPcap",
|
||||
net_cards[network_card].name);
|
||||
|
||||
pclog("NETWORK: reset (card=%d)\n", network_card);
|
||||
/* Add the (new?) card to the I/O system. */
|
||||
@@ -147,11 +155,11 @@ void
|
||||
network_tx(uint8_t *bufp, int len)
|
||||
{
|
||||
switch(network_type) {
|
||||
case 0:
|
||||
case NET_TYPE_PCAP:
|
||||
network_pcap_in(bufp, len);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case NET_TYPE_SLIRP:
|
||||
network_slirp_in(bufp, len);
|
||||
break;
|
||||
}
|
||||
@@ -217,3 +225,19 @@ network_card_get_from_internal_name(char *s)
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
network_dev_to_id(char *dev)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i=0; i<network_ndev; i++) {
|
||||
if (! strcmp(network_devs[i].device, dev)) {
|
||||
return(i);
|
||||
}
|
||||
}
|
||||
|
||||
/* If no match found, assume "none". */
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the network module.
|
||||
*
|
||||
* Version: @(#)network.h 1.0.3 2017/05/12
|
||||
* Version: @(#)network.h 1.0.4 2017/05/17
|
||||
*
|
||||
* Authors: Kotori, <oubattler@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -18,6 +18,12 @@
|
||||
# include <stdint.h>
|
||||
|
||||
|
||||
/* Network provider types. */
|
||||
#define NET_TYPE_NONE 0 /* networking disabled */
|
||||
#define NET_TYPE_PCAP 1 /* use the (Win)Pcap API */
|
||||
#define NET_TYPE_SLIRP 2 /* use the SLiRP port forwarder */
|
||||
|
||||
/* Supported network cards. */
|
||||
#define NE1000 1
|
||||
#define NE2000 2
|
||||
#define RTL8029AS 3
|
||||
@@ -44,11 +50,9 @@ typedef struct {
|
||||
/* Global variables. */
|
||||
extern int network_card;
|
||||
extern int network_type;
|
||||
|
||||
extern char pcap_dev[512];
|
||||
|
||||
extern int netdev_num;
|
||||
extern netdev_t netdev_list[512];
|
||||
extern int network_ndev;
|
||||
extern netdev_t network_devs[32];
|
||||
extern char network_pcap[512];
|
||||
|
||||
|
||||
/* Function prototypes. */
|
||||
@@ -68,13 +72,13 @@ extern void network_slirp_close(void);
|
||||
extern void network_slirp_in(uint8_t *, int);
|
||||
|
||||
extern int network_devlist(netdev_t *);
|
||||
extern int network_dev_to_id(char *);
|
||||
extern int network_card_available(int);
|
||||
extern char *network_card_getname(int);
|
||||
extern int network_card_has_config(int);
|
||||
extern char *network_card_get_internal_name(int);
|
||||
extern int network_card_get_from_internal_name(char *);
|
||||
extern struct device_t *network_card_getdevice(int);
|
||||
extern device_t *network_card_getdevice(int);
|
||||
|
||||
int network_dev_to_id(char *dev);
|
||||
|
||||
#endif /*NETWORK_H*/
|
||||
|
||||
22
src/pc.c
22
src/pc.c
@@ -18,8 +18,6 @@
|
||||
#include "device.h"
|
||||
|
||||
#include "ali1429.h"
|
||||
#include "cdrom.h"
|
||||
#include "cdrom-ioctl.h"
|
||||
#include "disc.h"
|
||||
#include "disc_86f.h"
|
||||
#include "disc_fdi.h"
|
||||
@@ -31,20 +29,21 @@
|
||||
#include "fdc.h"
|
||||
#include "fdd.h"
|
||||
#include "gameport.h"
|
||||
#include "plat-joystick.h"
|
||||
#include "plat-midi.h"
|
||||
#include "plat_joystick.h"
|
||||
#include "plat_midi.h"
|
||||
#include "hdd.h"
|
||||
#include "ide.h"
|
||||
#include "cdrom.h"
|
||||
#include "cdrom-image.h"
|
||||
#include "cdrom-null.h"
|
||||
#include "cdrom_ioctl.h"
|
||||
#include "cdrom_image.h"
|
||||
#include "cdrom_null.h"
|
||||
#include "scsi.h"
|
||||
#include "keyboard.h"
|
||||
#include "plat-keyboard.h"
|
||||
#include "plat_keyboard.h"
|
||||
#include "keyboard_at.h"
|
||||
#include "model.h"
|
||||
#include "mouse.h"
|
||||
#include "plat-mouse.h"
|
||||
#include "plat_mouse.h"
|
||||
#include "network.h"
|
||||
#include "serial.h"
|
||||
#include "sound/sound.h"
|
||||
@@ -60,7 +59,7 @@
|
||||
#include "amstrad.h"
|
||||
#ifdef WALTJE
|
||||
# define UNICODE
|
||||
# include "plat-dir.h"
|
||||
# include "plat_dir.h"
|
||||
#endif
|
||||
|
||||
#ifndef __unix
|
||||
@@ -69,7 +68,7 @@
|
||||
#include <windows.h>
|
||||
#undef BITMAP
|
||||
#include "win.h"
|
||||
#include "win-language.h"
|
||||
#include "win_language.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -288,9 +287,6 @@ void initpc(int argc, wchar_t *argv[])
|
||||
*p=L'\0';
|
||||
pclog("path = %ws\n", pcempath);
|
||||
|
||||
/* Initialize list of PCap devices. */
|
||||
netdev_num = network_devlist(netdev_list);
|
||||
|
||||
for (c = 1; c < argc; c++)
|
||||
{
|
||||
if (!_wcsicmp(argv[c], L"--help"))
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
|
||||
#ifdef RELEASE_BUILD
|
||||
/* Icon by Devcore - https://commons.wikimedia.org/wiki/File:Icon_PC_256x256.png */
|
||||
100 ICON DISCARDABLE "ICONS/86Box-RB.ico"
|
||||
#else
|
||||
/* Icon by Devcore - https://commons.wikimedia.org/wiki/File:Icon_PC2_256x256.png */
|
||||
100 ICON DISCARDABLE "ICONS/86Box.ico"
|
||||
#endif
|
||||
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,2,0
|
||||
PRODUCTVERSION 1,0,2,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "IRC #SoftHistory\0"
|
||||
VALUE "FileDescription", "PCap_IF - test tool for WinPcap\0"
|
||||
VALUE "FileVersion", "1.0.2\0"
|
||||
VALUE "InternalName", "pcap_if\0"
|
||||
VALUE "LegalCopyright", "Copyright 2017 Fred N. van Kempen\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "pcap_if.exe\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "WinPcap Test Tool\0"
|
||||
VALUE "ProductVersion", "1.0.2\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
@@ -1,4 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
extern LPDIRECTINPUT lpdi;
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Definitions for the platform OpenDir module.
|
||||
*
|
||||
* Version: @(#)plat-dir.h 1.0.1 2017/05/12
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
*/
|
||||
#ifndef PLAT_DIR_H
|
||||
# define PLAT_DIR_H
|
||||
|
||||
|
||||
#ifdef _MAX_FNAME
|
||||
# define MAXNAMLEN _MAX_FNAME
|
||||
#else
|
||||
# define MAXNAMLEN 15
|
||||
#endif
|
||||
# define MAXDIRLEN 127
|
||||
|
||||
|
||||
struct direct {
|
||||
long d_ino;
|
||||
unsigned short d_reclen;
|
||||
unsigned short d_off;
|
||||
#ifdef UNICODE
|
||||
wchar_t d_name[MAXNAMLEN + 1];
|
||||
#else
|
||||
char d_name[MAXNAMLEN + 1];
|
||||
#endif
|
||||
};
|
||||
#define d_namlen d_reclen
|
||||
|
||||
|
||||
typedef struct {
|
||||
short flags; /* internal flags */
|
||||
short offset; /* offset of entry into dir */
|
||||
long handle; /* open handle to Win32 system */
|
||||
short sts; /* last known status code */
|
||||
char *dta; /* internal work data */
|
||||
#ifdef UNICODE
|
||||
wchar_t dir[MAXDIRLEN+1]; /* open dir */
|
||||
#else
|
||||
char dir[MAXDIRLEN+1]; /* open dir */
|
||||
#endif
|
||||
struct direct dent; /* actual directory entry */
|
||||
} DIR;
|
||||
|
||||
|
||||
/* Directory routine flags. */
|
||||
#define DIR_F_LOWER 0x0001 /* force to lowercase */
|
||||
#define DIR_F_SANE 0x0002 /* force this to sane path */
|
||||
#define DIR_F_ISROOT 0x0010 /* this is the root directory */
|
||||
|
||||
|
||||
/* Function prototypes. */
|
||||
#ifdef UNICODE
|
||||
extern DIR *opendirw(const wchar_t *);
|
||||
#else
|
||||
extern DIR *opendir(const char *);
|
||||
#endif
|
||||
extern struct direct *readdir(DIR *);
|
||||
extern long telldir(DIR *);
|
||||
extern void seekdir(DIR *, long);
|
||||
extern int closedir(DIR *);
|
||||
|
||||
#define rewinddir(dirp) seekdir(dirp, 0L)
|
||||
|
||||
|
||||
#endif /*PLAT_DIR_H*/
|
||||
@@ -1,69 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void joystick_init();
|
||||
void joystick_close();
|
||||
void joystick_poll();
|
||||
|
||||
typedef struct plat_joystick_t
|
||||
{
|
||||
char name[64];
|
||||
|
||||
int a[8];
|
||||
int b[32];
|
||||
int p[4];
|
||||
|
||||
struct
|
||||
{
|
||||
char name[32];
|
||||
int id;
|
||||
} axis[8];
|
||||
|
||||
struct
|
||||
{
|
||||
char name[32];
|
||||
int id;
|
||||
} button[32];
|
||||
|
||||
struct
|
||||
{
|
||||
char name[32];
|
||||
int id;
|
||||
} pov[4];
|
||||
|
||||
int nr_axes;
|
||||
int nr_buttons;
|
||||
int nr_povs;
|
||||
} plat_joystick_t;
|
||||
|
||||
#define MAX_PLAT_JOYSTICKS 8
|
||||
|
||||
extern plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
|
||||
extern int joysticks_present;
|
||||
|
||||
#define POV_X 0x80000000
|
||||
#define POV_Y 0x40000000
|
||||
|
||||
typedef struct joystick_t
|
||||
{
|
||||
int axis[8];
|
||||
int button[32];
|
||||
int pov[4];
|
||||
|
||||
int plat_joystick_nr;
|
||||
int axis_mapping[8];
|
||||
int button_mapping[32];
|
||||
int pov_mapping[4][2];
|
||||
} joystick_t;
|
||||
|
||||
#define MAX_JOYSTICKS 4
|
||||
extern joystick_t joystick_state[MAX_JOYSTICKS];
|
||||
|
||||
#define JOYSTICK_PRESENT(n) (joystick_state[n].plat_joystick_nr != 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,22 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void keyboard_init();
|
||||
void keyboard_close();
|
||||
void keyboard_poll_host();
|
||||
extern int recv_key[272];
|
||||
extern int rawinputkey[272];
|
||||
|
||||
#ifndef __unix
|
||||
#define KEY_LCONTROL 0x1d
|
||||
#define KEY_RCONTROL (0x1d | 0x80)
|
||||
#define KEY_END (0x4f | 0x80)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
void midi_init();
|
||||
void midi_close();
|
||||
void midi_write(uint8_t val);
|
||||
int midi_get_num_devs();
|
||||
void midi_get_dev_name(int num, char *s);
|
||||
|
||||
extern int midi_id;
|
||||
@@ -1,16 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void mouse_init();
|
||||
void mouse_close();
|
||||
extern int mouse_buttons;
|
||||
void mouse_poll_host();
|
||||
void mouse_get_mickeys(int *x, int *y, int *z);
|
||||
extern int mousecapture;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Definitions for the Bottom Half of the SERIAL card.
|
||||
*
|
||||
* Version: @(#)plat-serial.h 1.0.3 2017/05/06
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
*/
|
||||
#ifndef PLAT_SERIAL_H
|
||||
# define PLAT_SERIAL_H
|
||||
|
||||
|
||||
typedef struct {
|
||||
char name[79]; /* name of open port */
|
||||
void (*rd_done)(void *, int);
|
||||
void *rd_arg;
|
||||
#ifdef BHTTY_C
|
||||
HANDLE handle;
|
||||
OVERLAPPED rov, /* READ and WRITE events */
|
||||
wov;
|
||||
int tmo; /* current timeout value */
|
||||
DCB dcb, /* terminal settings */
|
||||
odcb;
|
||||
#endif
|
||||
} BHTTY;
|
||||
|
||||
|
||||
extern BHTTY *bhtty_open(char *__port, int __tmo);
|
||||
extern void bhtty_close(BHTTY *);
|
||||
extern int bhtty_flush(BHTTY *);
|
||||
extern void bhtty_raw(BHTTY *, void *__arg);
|
||||
extern int bhtty_speed(BHTTY *, long __speed);
|
||||
extern int bhtty_params(BHTTY *, char __dbit, char __par, char __sbit);
|
||||
extern int bhtty_sstate(BHTTY *, void *__arg);
|
||||
extern int bhtty_gstate(BHTTY *, void *__arg);
|
||||
extern int bhtty_crtscts(BHTTY *, char __yesno);
|
||||
|
||||
extern int bhtty_write(BHTTY *, unsigned char);
|
||||
extern int bhtty_read(BHTTY *, unsigned char *, int);
|
||||
|
||||
|
||||
#endif /*PLAT_SERIAL_H*/
|
||||
@@ -10,9 +10,8 @@
|
||||
|
||||
#include "ibm.h"
|
||||
#include "pit.h"
|
||||
|
||||
#include "plat-keyboard.h"
|
||||
#include "plat-mouse.h"
|
||||
#include "plat_keyboard.h"
|
||||
#include "plat_mouse.h"
|
||||
|
||||
void ppi_reset()
|
||||
{
|
||||
|
||||
432
src/resource.h
432
src/resource.h
@@ -1,432 +0,0 @@
|
||||
/* Copyright holders: Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
/* {{NO_DEPENDENCIES}}
|
||||
Microsoft Developer Studio generated include file.
|
||||
Used by 86Box.rc
|
||||
*/
|
||||
#define IDHDCONFIG 3
|
||||
#define IDCDCONFIG 4
|
||||
#define CONFIGUREDLG_MACHINE 101
|
||||
#define CONFIGUREDLG_VIDEO 102
|
||||
#define CONFIGUREDLG_INPUT 103
|
||||
#define CONFIGUREDLG_SOUND 104
|
||||
#define CONFIGUREDLG_NETWORK 105
|
||||
#define CONFIGUREDLG_PERIPHERALS 106
|
||||
#define CONFIGUREDLG_HARD_DISKS 107
|
||||
#define CONFIGUREDLG_REMOVABLE_DEVICES 108
|
||||
#define ABOUTDLG 109
|
||||
#define CONFIGUREDLG_HARD_DISKS_ADD 110
|
||||
#define CONFIGUREDLG_MAIN 117
|
||||
#define IDC_SETTINGSCATLIST 1004
|
||||
#define IDC_LIST_HARD_DISKS 1005
|
||||
#define IDC_COMBO_MACHINE 1006
|
||||
#define IDC_COMBO_CPU_TYPE 1007
|
||||
#define IDC_COMBO_CPU 1008
|
||||
#define IDC_COMBO_WS 1009
|
||||
#define IDC_CHECK_DYNAREC 1010
|
||||
#define IDC_CHECK_FPU 1011
|
||||
#define IDC_COMBO_SCSI 1012
|
||||
#define IDC_CONFIGURE_SCSI 1013
|
||||
#define IDC_COMBO_VIDEO 1014
|
||||
#define IDC_COMBO_VIDEO_SPEED 1015
|
||||
#define IDC_CHECK_VOODOO 1016
|
||||
#define IDC_CHECKCMS 1016
|
||||
#define IDC_CONFIGURE_VOODOO 1017
|
||||
#define IDC_CHECKNUKEDOPL 1018
|
||||
#define IDC_COMBO_JOYSTICK 1018
|
||||
#define IDC_CHECK_SYNC 1019
|
||||
#define IDC_LIST_FLOPPY_DRIVES 1020
|
||||
#define IDC_LIST_CDROM_DRIVES 1021
|
||||
#define IDC_CONFIGURE_MACHINE 1022
|
||||
#define IDC_COMBO_LANG 1023
|
||||
#define IDC_BUTTON_FDD_ADD 1024
|
||||
#define IDC_BUTTON_FDD_EDIT 1025
|
||||
#define IDC_BUTTON_FDD_REMOVE 1026
|
||||
#define IDC_BUTTON_CDROM_ADD 1027
|
||||
#define IDC_BUTTON_HDD_ADD_NEW 1027
|
||||
#define IDC_BUTTON_CDROM_EDIT 1028
|
||||
#define IDC_BUTTON_HDD_ADD 1028
|
||||
#define IDC_BUTTON_CDROM_REMOVE 1029
|
||||
#define IDC_BUTTON_HDD_REMOVE 1029
|
||||
#define IDC_HDIMAGE_NEW 1035
|
||||
#define IDC_HD_BUS 1036
|
||||
#define IDC_HDIMAGE_EXISTING 1037
|
||||
#define IDC_COMBO_HD_BUS 1038
|
||||
#define IDC_EDIT_HD_FILE_NAME 1039
|
||||
#define IDC_EDIT_HD_CYL 1040
|
||||
#define IDC_EDIT_HD_HPC 1041
|
||||
#define IDC_EDIT_HD_SPT 1042
|
||||
#define IDC_EDIT_HD_SIZE 1043
|
||||
#define IDC_COMBO_HD_TYPE 1044
|
||||
#define IDC_COMBO_HD_LOCATION 1045
|
||||
#define IDC_CHECKGUS 1046
|
||||
#define IDC_COMBO_HD_CHANNEL 1047
|
||||
#define IDC_COMBO_HD_CHANNEL_IDE 1048
|
||||
#define IDC_COMBO_HD_ID 1050
|
||||
#define IDC_COMBO_HD_LUN 1051
|
||||
#define IDC_CHECKBUGGER 1052
|
||||
#define IDC_CHECKSERIAL1 1053
|
||||
#define IDC_CHECKPARALLEL 1054
|
||||
#define IDC_CHECKSERIAL2 1055
|
||||
#define IDC_COMBO_HDC 1068
|
||||
#define IDC_COMBO_MOUSE 1069
|
||||
#define IDC_COMBO_IDE_TER 1069
|
||||
#define IDC_COMBO_IDE_QUA 1070
|
||||
#define IDC_COMBO_FD_TYPE 1071
|
||||
#define IDC_COMBO_CD_BUS 1072
|
||||
#define IDC_COMBO_CD_CHANNEL_IDE 1073
|
||||
#define IDC_COMBO_CD_ID 1074
|
||||
#define IDC_COMBO_CD_LUN 1075
|
||||
#define IDC_COMBO_MIDI 1076
|
||||
#define IDC_CHECK_CDROM_1_AUDIO_ENABLED 1584
|
||||
#define IDC_CHECK_CDROM_2_AUDIO_ENABLED 1585
|
||||
#define IDC_CHECK_CDROM_3_AUDIO_ENABLED 1586
|
||||
#define IDC_CHECK_CDROM_4_AUDIO_ENABLED 1587
|
||||
#define IDS_STRING2049 2049
|
||||
#define IDS_STRING2050 2050
|
||||
#define IDS_STRING2051 2051
|
||||
#define IDS_STRING2052 2052
|
||||
#define IDS_STRING2053 2053
|
||||
#define IDS_STRING2054 2054
|
||||
#define IDS_STRING2055 2055
|
||||
#define IDS_STRING2056 2056
|
||||
#define IDS_STRING2057 2057
|
||||
#define IDS_STRING2058 2058
|
||||
#define IDS_STRING2059 2059
|
||||
#define IDS_STRING2060 2060
|
||||
#define IDS_STRING2061 2061
|
||||
#define IDS_STRING2062 2062
|
||||
#define IDS_STRING2063 2063
|
||||
#define IDS_STRING2064 2064
|
||||
#define IDS_STRING2065 2065
|
||||
#define IDS_STRING2066 2066
|
||||
#define IDS_STRING2067 2067
|
||||
#define IDS_STRING2068 2068
|
||||
#define IDS_STRING2069 2069
|
||||
#define IDS_STRING2070 2070
|
||||
#define IDS_STRING2071 2071
|
||||
#define IDS_STRING2072 2072
|
||||
#define IDS_STRING2073 2073
|
||||
#define IDS_STRING2074 2074
|
||||
#define IDS_STRING2075 2075
|
||||
#define IDS_STRING2076 2076
|
||||
#define IDS_STRING2077 2077
|
||||
#define IDS_STRING2078 2078
|
||||
#define IDS_STRING2079 2079
|
||||
#define IDM_ABOUT 40001
|
||||
#define IDC_ABOUT_ICON 65535
|
||||
|
||||
#define IDM_DISC_1 40000
|
||||
#define IDM_DISC_2 40001
|
||||
#define IDM_DISC_3 40002
|
||||
#define IDM_DISC_4 40003
|
||||
#define IDM_DISC_1_WP 40004
|
||||
#define IDM_DISC_2_WP 40005
|
||||
#define IDM_DISC_3_WP 40006
|
||||
#define IDM_DISC_4_WP 40007
|
||||
#define IDM_EJECT_1 40008
|
||||
#define IDM_EJECT_2 40009
|
||||
#define IDM_EJECT_3 40010
|
||||
#define IDM_EJECT_4 40011
|
||||
|
||||
#define IDM_FILE_RESET 40015
|
||||
#define IDM_FILE_HRESET 40016
|
||||
#define IDM_FILE_EXIT 40017
|
||||
#define IDM_FILE_RESET_CAD 40018
|
||||
#define IDM_HDCONF 40019
|
||||
#define IDM_CONFIG 40020
|
||||
#define IDM_CONFIG_LOAD 40021
|
||||
#define IDM_CONFIG_SAVE 40022
|
||||
#define IDM_USE_NUKEDOPL 40023
|
||||
#define IDM_STATUS 40030
|
||||
#define IDM_VID_RESIZE 40050
|
||||
#define IDM_VID_REMEMBER 40051
|
||||
#define IDM_VID_DDRAW 40060
|
||||
#define IDM_VID_D3D 40061
|
||||
#define IDM_VID_SCALE_1X 40064
|
||||
#define IDM_VID_SCALE_2X 40065
|
||||
#define IDM_VID_SCALE_3X 40066
|
||||
#define IDM_VID_SCALE_4X 40067
|
||||
#define IDM_VID_FULLSCREEN 40070
|
||||
#define IDM_VID_FS_FULL 40071
|
||||
#define IDM_VID_FS_43 40072
|
||||
#define IDM_VID_FS_SQ 40073
|
||||
#define IDM_VID_FS_INT 40074
|
||||
#define IDM_VID_FORCE43 40075
|
||||
#define IDM_VID_OVERSCAN 40076
|
||||
#define IDM_VID_FLASH 40077
|
||||
#define IDM_VID_SCREENSHOT 40078
|
||||
#define IDM_VID_INVERT 40079
|
||||
|
||||
#define IDM_CDROM_1_MUTE 40128
|
||||
#define IDM_CDROM_1_IMAGE 40144
|
||||
#define IDM_CDROM_1_RELOAD 40160
|
||||
#define IDM_CDROM_1_EMPTY 40176
|
||||
#define IDM_CDROM_1_REAL 40192
|
||||
#define IDM_CDROM_2_MUTE 40129
|
||||
#define IDM_CDROM_2_IMAGE 40145
|
||||
#define IDM_CDROM_2_RELOAD 40161
|
||||
#define IDM_CDROM_2_EMPTY 40177
|
||||
#define IDM_CDROM_2_REAL 40193
|
||||
#define IDM_CDROM_3_MUTE 40130
|
||||
#define IDM_CDROM_3_IMAGE 40146
|
||||
#define IDM_CDROM_3_RELOAD 40162
|
||||
#define IDM_CDROM_3_EMPTY 40178
|
||||
#define IDM_CDROM_3_REAL 40194
|
||||
#define IDM_CDROM_4_MUTE 40131
|
||||
#define IDM_CDROM_4_IMAGE 40147
|
||||
#define IDM_CDROM_4_RELOAD 40163
|
||||
#define IDM_CDROM_4_EMPTY 40179
|
||||
#define IDM_CDROM_4_REAL 40195
|
||||
|
||||
#define IDM_IDE_TER_ENABLED 44000
|
||||
#define IDM_IDE_TER_IRQ9 44009
|
||||
#define IDM_IDE_TER_IRQ10 44010
|
||||
#define IDM_IDE_TER_IRQ11 44011
|
||||
#define IDM_IDE_TER_IRQ12 44012
|
||||
#define IDM_IDE_TER_IRQ14 44014
|
||||
#define IDM_IDE_TER_IRQ15 44015
|
||||
#define IDM_IDE_QUA_ENABLED 44020
|
||||
#define IDM_IDE_QUA_IRQ9 44029
|
||||
#define IDM_IDE_QUA_IRQ10 44030
|
||||
#define IDM_IDE_QUA_IRQ11 44031
|
||||
#define IDM_IDE_QUA_IRQ12 44032
|
||||
#define IDM_IDE_QUA_IRQ14 44033
|
||||
#define IDM_IDE_QUA_IRQ15 44035
|
||||
|
||||
#ifdef ENABLE_LOG_TOGGLES
|
||||
# ifdef ENABLE_BUSLOGIC_LOG
|
||||
# define IDM_LOG_BUSLOGIC 51200
|
||||
# endif
|
||||
# ifdef ENABLE_CDROM_LOG
|
||||
# define IDM_LOG_CDROM 51201
|
||||
# endif
|
||||
# ifdef ENABLE_D86F_LOG
|
||||
# define IDM_LOG_D86F 51202
|
||||
# endif
|
||||
# ifdef ENABLE_FDC_LOG
|
||||
# define IDM_LOG_FDC 51203
|
||||
# endif
|
||||
# ifdef ENABLE_IDE_LOG
|
||||
# define IDM_LOG_IDE 51204
|
||||
# endif
|
||||
# ifdef ENABLE_NE2000_LOG
|
||||
# define IDM_LOG_NE2000 51205
|
||||
# endif
|
||||
#endif
|
||||
#ifdef ENABLE_LOG_BREAKPOINT
|
||||
# define IDM_LOG_BREAKPOINT 51206
|
||||
#endif
|
||||
#ifdef ENABLE_VRAM_DUMP
|
||||
# define IDM_DUMP_VRAM 51207
|
||||
#endif
|
||||
|
||||
#define IDC_COMBO1 1000
|
||||
#define IDC_COMBOVID 1001
|
||||
#define IDC_COMBO3 1002
|
||||
#define IDC_COMBO4 1003
|
||||
#define IDC_COMBO5 1004
|
||||
#define IDC_COMBO386 1005
|
||||
#define IDC_COMBO486 1006
|
||||
#define IDC_COMBOSND 1007
|
||||
#define IDC_COMBONETTYPE 1008
|
||||
#define IDC_COMBOPCAP 1009
|
||||
#define IDC_COMBONET 1010
|
||||
#define IDC_COMBOCPUM 1060
|
||||
#define IDC_COMBOSPD 1061
|
||||
#define IDC_COMBODR1 1062
|
||||
#define IDC_COMBODR2 1063
|
||||
#define IDC_COMBODR3 1064
|
||||
#define IDC_COMBODR4 1065
|
||||
#define IDC_COMBOJOY 1066
|
||||
#define IDC_COMBOWS 1067
|
||||
#define IDC_COMBOMOUSE 1068
|
||||
#define IDC_COMBOHDD 1069
|
||||
#define IDC_CHECK1 1010
|
||||
#define IDC_CHECK2 1011
|
||||
#define IDC_CHECK3 1012
|
||||
#define IDC_CHECKSSI 1014
|
||||
#define IDC_CHECKVOODOO 1015
|
||||
#define IDC_CHECKDYNAREC 1016
|
||||
#define IDC_CHECKBUSLOGIC 1017
|
||||
#define IDC_CHECKSYNC 1024
|
||||
#define IDC_CHECKXTIDE 1025
|
||||
#define IDC_CHECKFPU 1026
|
||||
#define IDC_EDIT1 1030
|
||||
#define IDC_EDIT2 1031
|
||||
#define IDC_EDIT3 1032
|
||||
#define IDC_EDIT4 1033
|
||||
#define IDC_EDIT5 1034
|
||||
#define IDC_EDIT6 1035
|
||||
#define IDC_COMBOHDT 1036
|
||||
|
||||
#define IDC_EJECTC 1040
|
||||
#define IDC_EDITC 1050
|
||||
#define IDC_CFILE 1060
|
||||
#define IDC_CNEW 1070
|
||||
#define IDC_EDIT_C_SPT 1200
|
||||
#define IDC_EDIT_C_HPC 1210
|
||||
#define IDC_EDIT_C_CYL 1220
|
||||
#define IDC_EDIT_C_FN 1230
|
||||
#define IDC_TEXT_C_SIZE 1240
|
||||
|
||||
#define IDC_EJECTD 1041
|
||||
#define IDC_EDITD 1051
|
||||
#define IDC_DFILE 1061
|
||||
#define IDC_DNEW 1071
|
||||
#define IDC_EDIT_D_SPT 1201
|
||||
#define IDC_EDIT_D_HPC 1211
|
||||
#define IDC_EDIT_D_CYL 1221
|
||||
#define IDC_EDIT_D_FN 1231
|
||||
#define IDC_TEXT_D_SIZE 1241
|
||||
|
||||
#define IDC_EJECTE 1042
|
||||
#define IDC_EDITE 1052
|
||||
#define IDC_EFILE 1062
|
||||
#define IDC_ENEW 1072
|
||||
#define IDC_EDIT_E_SPT 1202
|
||||
#define IDC_EDIT_E_HPC 1212
|
||||
#define IDC_EDIT_E_CYL 1222
|
||||
#define IDC_EDIT_E_FN 1232
|
||||
#define IDC_TEXT_E_SIZE 1242
|
||||
|
||||
#define IDC_EJECTF 1043
|
||||
#define IDC_EDITF 1053
|
||||
#define IDC_FFILE 1063
|
||||
#define IDC_FNEW 1073
|
||||
#define IDC_EDIT_F_SPT 1203
|
||||
#define IDC_EDIT_F_HPC 1213
|
||||
#define IDC_EDIT_F_CYL 1223
|
||||
#define IDC_EDIT_F_FN 1233
|
||||
#define IDC_TEXT_F_SIZE 1243
|
||||
|
||||
#define IDC_EJECTG 1044
|
||||
#define IDC_EDITG 1054
|
||||
#define IDC_GFILE 1064
|
||||
#define IDC_GNEW 1074
|
||||
#define IDC_EDIT_G_SPT 1204
|
||||
#define IDC_EDIT_G_HPC 1214
|
||||
#define IDC_EDIT_G_CYL 1224
|
||||
#define IDC_EDIT_G_FN 1234
|
||||
#define IDC_TEXT_G_SIZE 1244
|
||||
|
||||
#define IDC_EJECTH 1045
|
||||
#define IDC_EDITH 1055
|
||||
#define IDC_HFILE 1065
|
||||
#define IDC_HNEW 1075
|
||||
#define IDC_EDIT_H_SPT 1205
|
||||
#define IDC_EDIT_H_HPC 1215
|
||||
#define IDC_EDIT_H_CYL 1225
|
||||
#define IDC_EDIT_H_FN 1235
|
||||
#define IDC_TEXT_H_SIZE 1245
|
||||
|
||||
#define IDC_EJECTI 1046
|
||||
#define IDC_EDITI 1056
|
||||
#define IDC_IFILE 1066
|
||||
#define IDC_INEW 1076
|
||||
#define IDC_EDIT_I_SPT 1206
|
||||
#define IDC_EDIT_I_HPC 1216
|
||||
#define IDC_EDIT_I_CYL 1226
|
||||
#define IDC_EDIT_I_FN 1236
|
||||
#define IDC_TEXT_I_SIZE 1246
|
||||
|
||||
#define IDC_EJECTJ 1047
|
||||
#define IDC_EDITJ 1057
|
||||
#define IDC_JFILE 1067
|
||||
#define IDC_JNEW 1077
|
||||
#define IDC_EDIT_J_SPT 1207
|
||||
#define IDC_EDIT_J_HPC 1217
|
||||
#define IDC_EDIT_J_CYL 1227
|
||||
#define IDC_EDIT_J_FN 1237
|
||||
#define IDC_TEXT_J_SIZE 1247
|
||||
|
||||
#define IDC_HDTYPE 1280
|
||||
|
||||
#define IDC_RENDER 1281
|
||||
#define IDC_STATUS 1282
|
||||
|
||||
#define IDC_MEMSPIN 1100
|
||||
#define IDC_MEMTEXT 1101
|
||||
#define IDC_STEXT1 1102
|
||||
#define IDC_STEXT2 1103
|
||||
#define IDC_STEXT3 1104
|
||||
#define IDC_STEXT4 1105
|
||||
#define IDC_STEXT5 1106
|
||||
#define IDC_STEXT6 1107
|
||||
#define IDC_STEXT7 1108
|
||||
#define IDC_STEXT8 1109
|
||||
#define IDC_STEXT_DEVICE 1110
|
||||
#define IDC_TEXT_MB 1111
|
||||
#define IDC_TEXT1 1115
|
||||
#define IDC_TEXT2 1116
|
||||
|
||||
#define IDC_CONFIGUREVID 1200
|
||||
#define IDC_CONFIGURESND 1201
|
||||
#define IDC_CONFIGUREVOODOO 1202
|
||||
#define IDC_CONFIGUREMOD 1203
|
||||
#define IDC_CONFIGURENETTYPE 1204
|
||||
#define IDC_CONFIGUREBUSLOGIC 1205
|
||||
#define IDC_CONFIGUREPCAP 1206
|
||||
#define IDC_CONFIGURENET 1207
|
||||
#define IDC_JOY1 1210
|
||||
#define IDC_JOY2 1211
|
||||
#define IDC_JOY3 1212
|
||||
#define IDC_JOY4 1213
|
||||
|
||||
#define IDC_CONFIG_BASE 1200
|
||||
|
||||
#define WM_RESETD3D WM_USER
|
||||
#define WM_LEAVEFULLSCREEN WM_USER + 1
|
||||
|
||||
#define C_BASE 6
|
||||
#define D_BASE 44
|
||||
#define E_BASE 82
|
||||
#define F_BASE 120
|
||||
#define G_BASE 158
|
||||
#define H_BASE 196
|
||||
#define I_BASE 234
|
||||
#define J_BASE 272
|
||||
#define CMD_BASE 314
|
||||
#define DLG_HEIGHT 346
|
||||
|
||||
#define IDC_CHECK_CDROM_1_ENABLED 1536
|
||||
#define IDC_COMBO_CDROM_1_BUS 1544
|
||||
#define IDC_COMBO_CDROM_1_CHANNEL 1552
|
||||
#define IDC_CHECK_CDROM_1_DMA_ENABLED 1560
|
||||
#define IDC_COMBO_CDROM_1_SCSI_ID 1568
|
||||
#define IDC_COMBO_CDROM_1_SCSI_LUN 1576
|
||||
|
||||
#define IDC_CHECK_CDROM_2_ENABLED 1537
|
||||
#define IDC_COMBO_CDROM_2_BUS 1545
|
||||
#define IDC_COMBO_CDROM_2_CHANNEL 1553
|
||||
#define IDC_CHECK_CDROM_2_DMA_ENABLED 1561
|
||||
#define IDC_COMBO_CDROM_2_SCSI_ID 1569
|
||||
#define IDC_COMBO_CDROM_2_SCSI_LUN 1577
|
||||
|
||||
#define IDC_CHECK_CDROM_3_ENABLED 1538
|
||||
#define IDC_COMBO_CDROM_3_BUS 1546
|
||||
#define IDC_COMBO_CDROM_3_CHANNEL 1554
|
||||
#define IDC_CHECK_CDROM_3_DMA_ENABLED 1562
|
||||
#define IDC_COMBO_CDROM_3_SCSI_ID 1570
|
||||
#define IDC_COMBO_CDROM_3_SCSI_LUN 1578
|
||||
|
||||
#define IDC_CHECK_CDROM_4_ENABLED 1539
|
||||
#define IDC_COMBO_CDROM_4_BUS 1547
|
||||
#define IDC_COMBO_CDROM_4_CHANNEL 1555
|
||||
#define IDC_CHECK_CDROM_4_DMA_ENABLED 1563
|
||||
#define IDC_COMBO_CDROM_4_SCSI_ID 1571
|
||||
#define IDC_COMBO_CDROM_4_SCSI_LUN 1579
|
||||
|
||||
#define IDC_STATIC 1792
|
||||
|
||||
/* Next default values for new objects */
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
# ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
# define _APS_NO_MFC 1
|
||||
# define _APS_NEXT_RESOURCE_VALUE 111
|
||||
# define _APS_NEXT_COMMAND_VALUE 40002
|
||||
# define _APS_NEXT_CONTROL_VALUE 1055
|
||||
# define _APS_NEXT_SYMED_VALUE 101
|
||||
# endif
|
||||
#endif
|
||||
@@ -33,7 +33,7 @@
|
||||
*
|
||||
* Based on the 86Box serial port driver as a framework.
|
||||
*
|
||||
* Version: @(#)serial.c 1.0.5 2017/05/07
|
||||
* Version: @(#)serial.c 1.0.5 2017/05/17
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "pic.h"
|
||||
#include "timer.h"
|
||||
#include "serial.h"
|
||||
#include "plat-serial.h"
|
||||
#include "plat_serial.h"
|
||||
|
||||
|
||||
enum {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
extern PALETTE cgapal;
|
||||
extern PALETTE cgapal_mono[6];
|
||||
|
||||
extern uint32_t pal_lookup[256];
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void cgapal_rebuild();
|
||||
void destroy_bitmap(BITMAP *b);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,185 +0,0 @@
|
||||
/* Copyright holders: Riley
|
||||
see COPYING for more details
|
||||
|
||||
win-crashdump.c : Windows exception handler to make a crash dump just before a crash happens.
|
||||
*/
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "86box.h"
|
||||
#include "win-crashdump.h"
|
||||
|
||||
PVOID hExceptionHandler;
|
||||
char* ExceptionHandlerBuffer;
|
||||
#define ExceptionHandlerBufferSize (10240)
|
||||
|
||||
|
||||
LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo) {
|
||||
// Win32-specific functions will be used wherever possible, just in case the C stdlib-equivalents try to allocate memory.
|
||||
// (The Win32-specific functions are generally just wrappers over NT system calls anyway.)
|
||||
|
||||
if ((ExceptionInfo->ExceptionRecord->ExceptionCode >> 28) != 0xC) {
|
||||
// The exception code is not a fatal exception (highest 4 bits of ntstatus = 0xC)
|
||||
// Not going to crash, let's not make a crash dump
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
// So, the program is about to crash. Oh no what do?
|
||||
// Let's create a crash dump file as a debugging-aid.
|
||||
|
||||
// First, get the path to 86Box.exe.
|
||||
char* CurrentBufferPointer;
|
||||
GetModuleFileName(NULL,ExceptionHandlerBuffer,ExceptionHandlerBufferSize);
|
||||
if (GetLastError() != ERROR_SUCCESS) {
|
||||
// Could not get the full path of 86Box.exe. Just create the file in the current directory.
|
||||
CurrentBufferPointer = ExceptionHandlerBuffer;
|
||||
} else {
|
||||
// Walk through the string backwards looking for the last backslash, so as to remove the "86Box.exe" filename from the string.
|
||||
CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)];
|
||||
for (; CurrentBufferPointer > ExceptionHandlerBuffer; CurrentBufferPointer--) {
|
||||
if (CurrentBufferPointer[0] == '\\') {
|
||||
// Found the backslash, null terminate the string after it.
|
||||
CurrentBufferPointer[1] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)];
|
||||
}
|
||||
|
||||
// What would a good filename be? It should contain the current date and time so as to be (hopefully!) unique.
|
||||
SYSTEMTIME SystemTime;
|
||||
GetSystemTime(&SystemTime);
|
||||
sprintf(CurrentBufferPointer,
|
||||
"86box-%d%02d%02d-%02d-%02d-%02d-%03d.dmp",
|
||||
SystemTime.wYear,
|
||||
SystemTime.wMonth,
|
||||
SystemTime.wDay,
|
||||
SystemTime.wHour,
|
||||
SystemTime.wMinute,
|
||||
SystemTime.wSecond,
|
||||
SystemTime.wMilliseconds);
|
||||
|
||||
DWORD Error;
|
||||
|
||||
// Now the filename is in the buffer, the file can be created.
|
||||
HANDLE hDumpFile = CreateFile(
|
||||
ExceptionHandlerBuffer, // The filename of the file to open.
|
||||
GENERIC_WRITE, // The permissions to request.
|
||||
0, // Make sure other processes can't touch the crash dump at all while it's open.
|
||||
NULL, // Leave the security descriptor undefined, it doesn't matter.
|
||||
OPEN_ALWAYS, // Opens the file if it exists, creates a new file if it doesn't.
|
||||
FILE_ATTRIBUTE_NORMAL, // File attributes / etc don't matter.
|
||||
NULL); // A template file is not being used.
|
||||
|
||||
// Check to make sure the file was actually created.
|
||||
if (hDumpFile == INVALID_HANDLE_VALUE) {
|
||||
// CreateFile() failed, so just do nothing more.
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
// Now the file is open, let's write the data we were passed out in a human-readable format.
|
||||
|
||||
// Let's get the name of the module where the exception occured.
|
||||
HMODULE hMods[1024];
|
||||
MODULEINFO modInfo;
|
||||
HMODULE ipModule = 0;
|
||||
DWORD cbNeeded;
|
||||
// Try to get a list of all loaded modules.
|
||||
if (EnumProcessModules(GetCurrentProcess(), hMods, sizeof(hMods), &cbNeeded)) {
|
||||
// The list was obtained, walk through each of the modules.
|
||||
for (DWORD i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
|
||||
// For each module, get the module information (base address, size, entry point)
|
||||
GetModuleInformation(GetCurrentProcess(), hMods[i], &modInfo, sizeof(MODULEINFO));
|
||||
// If the exception address is located in the range of where this module is loaded...
|
||||
if (
|
||||
(ExceptionInfo->ExceptionRecord->ExceptionAddress >= modInfo.lpBaseOfDll) &&
|
||||
(ExceptionInfo->ExceptionRecord->ExceptionAddress < (modInfo.lpBaseOfDll + modInfo.SizeOfImage))
|
||||
) {
|
||||
// ...this is the module we're looking for!
|
||||
ipModule = hMods[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start to put the crash-dump string into the buffer.
|
||||
|
||||
sprintf(ExceptionHandlerBuffer,
|
||||
"86Box version %s crashed on %d-%02d-%02d %02d:%02d:%02d.%03d\r\n\r\n"
|
||||
""
|
||||
"Exception details:\r\n"
|
||||
"Exception NTSTATUS code: 0x%08x\r\n"
|
||||
"Occured at address: 0x%p",
|
||||
emulator_version, SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond, SystemTime.wMilliseconds,
|
||||
|
||||
ExceptionInfo->ExceptionRecord->ExceptionCode,
|
||||
ExceptionInfo->ExceptionRecord->ExceptionAddress);
|
||||
|
||||
|
||||
// If we found the module that the exception occured in, get the full path to the module the exception occured at and include it.
|
||||
CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)];
|
||||
if (ipModule != 0) {
|
||||
sprintf(CurrentBufferPointer," [");
|
||||
GetModuleFileName(ipModule,&CurrentBufferPointer[2],ExceptionHandlerBufferSize - strlen(ExceptionHandlerBuffer));
|
||||
if (GetLastError() == ERROR_SUCCESS) {
|
||||
CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)];
|
||||
sprintf(CurrentBufferPointer,"]");
|
||||
CurrentBufferPointer += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Continue to create the crash-dump string.
|
||||
sprintf(CurrentBufferPointer,
|
||||
"\r\n"
|
||||
"Number of parameters: %d\r\n"
|
||||
"Exception parameters: ",
|
||||
ExceptionInfo->ExceptionRecord->NumberParameters);
|
||||
|
||||
// Add the exception parameters to the crash-dump string.
|
||||
for (int i = 0; i < ExceptionInfo->ExceptionRecord->NumberParameters; i++) {
|
||||
CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)];
|
||||
sprintf(CurrentBufferPointer,"0x%p ",ExceptionInfo->ExceptionRecord->ExceptionInformation[i]);
|
||||
}
|
||||
|
||||
CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer) - 1];
|
||||
|
||||
PCONTEXT Registers = ExceptionInfo->ContextRecord;
|
||||
|
||||
#if defined(__i386__) && !defined(__x86_64)
|
||||
// This binary is being compiled for x86, include a register dump.
|
||||
sprintf(CurrentBufferPointer,
|
||||
"\r\n"
|
||||
"Register dump:\r\n"
|
||||
"eax=0x%08x ebx=0x%08x ecx=0x%08x edx=0x%08x ebp=0x%08x esp=0x%08x esi=0x%08x edi=0x%08x eip=0x%08x\r\n"
|
||||
"\r\n",
|
||||
Registers->Eax, Registers->Ebx, Registers->Ecx, Registers->Edx, Registers->Ebp, Registers->Esp, Registers->Esi, Registers->Edi, Registers->Eip);
|
||||
#else
|
||||
// Register dump is supported by no other architectures right now. MinGW headers seem to lack the x64 CONTEXT structure definition.
|
||||
sprintf(CurrentBufferPointer,"\r\n");
|
||||
#endif
|
||||
|
||||
// The crash-dump string has been created, write it to disk.
|
||||
WriteFile(hDumpFile,
|
||||
ExceptionHandlerBuffer,
|
||||
strlen(ExceptionHandlerBuffer),
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
// Finally, close the file.
|
||||
CloseHandle(hDumpFile);
|
||||
|
||||
// And return, therefore causing the crash, but only after the crash dump has been created.
|
||||
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
void InitCrashDump() {
|
||||
// An exception handler should not allocate memory, so allocate 10kb for it to use if it gets called, an amount which should be more than enough.
|
||||
ExceptionHandlerBuffer = malloc(ExceptionHandlerBufferSize);
|
||||
// Register the exception handler. Zero first argument means this exception handler gets called last, therefore, crash dump is only made, when a crash is going to happen.
|
||||
hExceptionHandler = AddVectoredExceptionHandler(0,MakeCrashDump);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
/* Copyright holders: Riley
|
||||
see COPYING for more details
|
||||
|
||||
win-crashdump.c : Windows crash dump exception handler header file.
|
||||
*/
|
||||
|
||||
void InitCrashDump();
|
||||
@@ -1,587 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#define UNICODE
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <d3d9.h>
|
||||
#undef BITMAP
|
||||
#include <D3dx9tex.h>
|
||||
#include "86box.h"
|
||||
#include "video/video.h"
|
||||
#include "win-d3d-fs.h"
|
||||
#include "win.h"
|
||||
#include "win-cgapal.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
extern "C" void fatal(const char *format, ...);
|
||||
extern "C" void pclog(const char *format, ...);
|
||||
|
||||
extern "C" void device_force_redraw(void);
|
||||
|
||||
static void d3d_fs_init_objects(void);
|
||||
static void d3d_fs_close_objects(void);
|
||||
static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h);
|
||||
static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h);
|
||||
|
||||
extern "C" void video_blit_complete(void);
|
||||
|
||||
|
||||
static LPDIRECT3D9 d3d = NULL;
|
||||
static LPDIRECT3DDEVICE9 d3ddev = NULL;
|
||||
static LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL;
|
||||
static LPDIRECT3DTEXTURE9 d3dTexture = NULL;
|
||||
static D3DPRESENT_PARAMETERS d3dpp;
|
||||
|
||||
static HWND d3d_hwnd;
|
||||
static HWND d3d_device_window;
|
||||
|
||||
static int d3d_fs_w, d3d_fs_h;
|
||||
|
||||
struct CUSTOMVERTEX
|
||||
{
|
||||
FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
|
||||
PALETTE cgapal =
|
||||
{
|
||||
{0,0,0},{0,42,0},{42,0,0},{42,21,0},
|
||||
{0,0,0},{0,42,42},{42,0,42},{42,42,42},
|
||||
{0,0,0},{21,63,21},{63,21,21},{63,63,21},
|
||||
{0,0,0},{21,63,63},{63,21,63},{63,63,63},
|
||||
|
||||
{0,0,0},{0,0,42},{0,42,0},{0,42,42},
|
||||
{42,0,0},{42,0,42},{42,21,00},{42,42,42},
|
||||
{21,21,21},{21,21,63},{21,63,21},{21,63,63},
|
||||
{63,21,21},{63,21,63},{63,63,21},{63,63,63},
|
||||
|
||||
{0,0,0},{0,21,0},{0,0,42},{0,42,42},
|
||||
{42,0,21},{21,10,21},{42,0,42},{42,0,63},
|
||||
{21,21,21},{21,63,21},{42,21,42},{21,63,63},
|
||||
{63,0,0},{42,42,0},{63,21,42},{41,41,41},
|
||||
|
||||
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
|
||||
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
|
||||
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
|
||||
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
|
||||
};
|
||||
|
||||
PALETTE cgapal_mono[6] =
|
||||
{
|
||||
{ // 0 - green, 4-color-optimized contrast
|
||||
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x17,0x05},{0x01,0x1a,0x06},{0x02,0x28,0x09},{0x02,0x2c,0x0a},{0x03,0x39,0x0d},{0x03,0x3c,0x0e},
|
||||
{0x00,0x07,0x01},{0x01,0x13,0x04},{0x01,0x1f,0x07},{0x01,0x23,0x08},{0x02,0x31,0x0b},{0x02,0x35,0x0c},{0x05,0x3f,0x11},{0x0d,0x3f,0x17},
|
||||
},
|
||||
{ // 1 - green, 16-color-optimized contrast
|
||||
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x15,0x05},{0x01,0x17,0x05},{0x01,0x21,0x08},{0x01,0x24,0x08},{0x02,0x2e,0x0b},{0x02,0x31,0x0b},
|
||||
{0x01,0x22,0x08},{0x02,0x28,0x09},{0x02,0x30,0x0b},{0x02,0x32,0x0c},{0x03,0x39,0x0d},{0x03,0x3b,0x0e},{0x09,0x3f,0x14},{0x0d,0x3f,0x17},
|
||||
},
|
||||
{ // 2 - amber, 4-color-optimized contrast
|
||||
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x20,0x0b,0x00},{0x24,0x0d,0x00},{0x33,0x18,0x00},{0x37,0x1b,0x00},{0x3f,0x26,0x01},{0x3f,0x2b,0x06},
|
||||
{0x0b,0x02,0x00},{0x1b,0x08,0x00},{0x29,0x11,0x00},{0x2e,0x14,0x00},{0x3b,0x1e,0x00},{0x3e,0x21,0x00},{0x3f,0x32,0x0a},{0x3f,0x38,0x0d},
|
||||
},
|
||||
{ // 3 - amber, 16-color-optimized contrast
|
||||
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x1e,0x09,0x00},{0x21,0x0b,0x00},{0x2b,0x12,0x00},{0x2f,0x15,0x00},{0x38,0x1c,0x00},{0x3b,0x1e,0x00},
|
||||
{0x2c,0x13,0x00},{0x32,0x17,0x00},{0x3a,0x1e,0x00},{0x3c,0x1f,0x00},{0x3f,0x27,0x01},{0x3f,0x2a,0x04},{0x3f,0x36,0x0c},{0x3f,0x38,0x0d},
|
||||
},
|
||||
{ // 4 - grey, 4-color-optimized contrast
|
||||
{0x00,0x00,0x00},{0x0b,0x0c,0x0a},{0x12,0x14,0x10},{0x15,0x17,0x13},{0x21,0x24,0x1e},{0x23,0x26,0x21},{0x30,0x31,0x2e},{0x34,0x35,0x33},
|
||||
{0x07,0x08,0x07},{0x0e,0x0f,0x0d},{0x19,0x1b,0x16},{0x1c,0x1f,0x1a},{0x28,0x2b,0x26},{0x2b,0x2d,0x2a},{0x37,0x38,0x37},{0x3d,0x3d,0x3c},
|
||||
},
|
||||
{ // 5 - grey, 16-color-optimized contrast
|
||||
{0x00,0x00,0x00},{0x0b,0x0c,0x0a},{0x0f,0x11,0x0e},{0x12,0x14,0x10},{0x1b,0x1d,0x18},{0x1c,0x1f,0x1a},{0x25,0x28,0x23},{0x28,0x2b,0x26},
|
||||
{0x1c,0x1e,0x19},{0x20,0x23,0x1d},{0x27,0x2a,0x25},{0x29,0x2c,0x27},{0x31,0x32,0x30},{0x33,0x34,0x32},{0x3a,0x3b,0x3a},{0x3d,0x3d,0x3c},
|
||||
},
|
||||
};
|
||||
|
||||
uint32_t pal_lookup[256];
|
||||
|
||||
static CUSTOMVERTEX d3d_verts[] =
|
||||
{
|
||||
{ 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f},
|
||||
{2048.0f, 2048.0f, 1.0f, 1.0f, 1.0f, 1.0f},
|
||||
{ 0.0f, 2048.0f, 1.0f, 1.0f, 0.0f, 1.0f},
|
||||
|
||||
{ 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f},
|
||||
{2048.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f},
|
||||
{2048.0f, 2048.0f, 1.0f, 1.0f, 1.0f, 1.0f},
|
||||
};
|
||||
|
||||
void cgapal_rebuild(void)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 256; c++)
|
||||
{
|
||||
pal_lookup[c] = makecol(video_6to8[cgapal[c].r], video_6to8[cgapal[c].g], video_6to8[cgapal[c].b]);
|
||||
}
|
||||
if ((cga_palette > 1) && (cga_palette < 8))
|
||||
{
|
||||
for (c = 0; c < 16; c++)
|
||||
{
|
||||
pal_lookup[c] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], video_6to8[cgapal_mono[cga_palette - 1][c].g], video_6to8[cgapal_mono[cga_palette - 1][c].b]);
|
||||
pal_lookup[c + 16] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], video_6to8[cgapal_mono[cga_palette - 1][c].g], video_6to8[cgapal_mono[cga_palette - 1][c].b]);
|
||||
pal_lookup[c + 32] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], video_6to8[cgapal_mono[cga_palette - 1][c].g], video_6to8[cgapal_mono[cga_palette - 1][c].b]);
|
||||
pal_lookup[c + 48] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], video_6to8[cgapal_mono[cga_palette - 1][c].g], video_6to8[cgapal_mono[cga_palette - 1][c].b]);
|
||||
}
|
||||
}
|
||||
if (cga_palette == 8)
|
||||
{
|
||||
pal_lookup[0x16] = makecol(video_6to8[42], video_6to8[42], video_6to8[0]);
|
||||
}
|
||||
}
|
||||
|
||||
int d3d_fs_init(HWND h)
|
||||
{
|
||||
HRESULT hr;
|
||||
WCHAR emulator_title[200];
|
||||
|
||||
d3d_fs_w = GetSystemMetrics(SM_CXSCREEN);
|
||||
d3d_fs_h = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
cgapal_rebuild();
|
||||
|
||||
d3d_hwnd = h;
|
||||
|
||||
_swprintf(emulator_title, L"86Box v%s", emulator_version_w);
|
||||
d3d_device_window = CreateWindowEx (
|
||||
0,
|
||||
szSubClassName,
|
||||
emulator_title,
|
||||
WS_POPUP,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
640,
|
||||
480,
|
||||
HWND_DESKTOP,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
if (d3d == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&d3dpp, 0, sizeof(d3dpp));
|
||||
|
||||
d3dpp.Flags = 0;
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.hDeviceWindow = d3d_device_window;
|
||||
d3dpp.BackBufferCount = 1;
|
||||
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||
d3dpp.MultiSampleQuality = 0;
|
||||
d3dpp.EnableAutoDepthStencil = false;
|
||||
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
|
||||
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
d3dpp.Windowed = false;
|
||||
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
|
||||
d3dpp.BackBufferWidth = d3d_fs_w;
|
||||
d3dpp.BackBufferHeight = d3d_fs_h;
|
||||
|
||||
hr = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
d3d_fs_init_objects();
|
||||
|
||||
video_blit_memtoscreen_func = d3d_fs_blit_memtoscreen;
|
||||
video_blit_memtoscreen_8_func = d3d_fs_blit_memtoscreen_8;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void d3d_fs_close_objects(void)
|
||||
{
|
||||
if (d3dTexture)
|
||||
{
|
||||
d3dTexture->Release();
|
||||
d3dTexture = NULL;
|
||||
}
|
||||
if (v_buffer)
|
||||
{
|
||||
v_buffer->Release();
|
||||
v_buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void d3d_fs_init_objects(void)
|
||||
{
|
||||
D3DLOCKED_RECT dr;
|
||||
RECT r;
|
||||
|
||||
d3ddev->CreateVertexBuffer(6*sizeof(CUSTOMVERTEX),
|
||||
0,
|
||||
D3DFVF_XYZRHW | D3DFVF_TEX1,
|
||||
D3DPOOL_MANAGED,
|
||||
&v_buffer,
|
||||
NULL);
|
||||
|
||||
d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL);
|
||||
|
||||
// r.top = r.left = 0;
|
||||
r.bottom = 2047;
|
||||
r.right = 2047;
|
||||
|
||||
if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0)))
|
||||
fatal("LockRect failed\n");
|
||||
|
||||
/* for (y = 0; y < 2048; y++)
|
||||
{
|
||||
uint32_t *p = (uint32_t *)(dr.pBits + (y * dr.Pitch));
|
||||
memset(p, 0, 2048 * 4);
|
||||
} */
|
||||
|
||||
d3dTexture->UnlockRect(0);
|
||||
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
}
|
||||
|
||||
/*void d3d_resize(int x, int y)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
d3dpp.BackBufferWidth = x;
|
||||
d3dpp.BackBufferHeight = y;
|
||||
|
||||
d3d_reset();
|
||||
}*/
|
||||
|
||||
void d3d_fs_reset(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
memset(&d3dpp, 0, sizeof(d3dpp));
|
||||
|
||||
d3dpp.Flags = 0;
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.hDeviceWindow = d3d_device_window;
|
||||
d3dpp.BackBufferCount = 1;
|
||||
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||
d3dpp.MultiSampleQuality = 0;
|
||||
d3dpp.EnableAutoDepthStencil = false;
|
||||
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
|
||||
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
d3dpp.Windowed = false;
|
||||
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
|
||||
d3dpp.BackBufferWidth = d3d_fs_w;
|
||||
d3dpp.BackBufferHeight = d3d_fs_h;
|
||||
|
||||
hr = d3ddev->Reset(&d3dpp);
|
||||
|
||||
if (hr == D3DERR_DEVICELOST)
|
||||
return;
|
||||
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
|
||||
device_force_redraw();
|
||||
}
|
||||
|
||||
void d3d_fs_close(void)
|
||||
{
|
||||
if (d3dTexture)
|
||||
{
|
||||
d3dTexture->Release();
|
||||
d3dTexture = NULL;
|
||||
}
|
||||
if (v_buffer)
|
||||
{
|
||||
v_buffer->Release();
|
||||
v_buffer = NULL;
|
||||
}
|
||||
if (d3ddev)
|
||||
{
|
||||
d3ddev->Release();
|
||||
d3ddev = NULL;
|
||||
}
|
||||
if (d3d)
|
||||
{
|
||||
d3d->Release();
|
||||
d3d = NULL;
|
||||
}
|
||||
DestroyWindow(d3d_device_window);
|
||||
}
|
||||
|
||||
static void d3d_fs_size(RECT window_rect, double *l, double *t, double *r, double *b, int w, int h)
|
||||
{
|
||||
int ratio_w, ratio_h;
|
||||
switch (video_fullscreen_scale)
|
||||
{
|
||||
case FULLSCR_SCALE_FULL:
|
||||
*l = -0.5;
|
||||
*t = -0.5;
|
||||
*r = (window_rect.right - window_rect.left) - 0.5;
|
||||
*b = (window_rect.bottom - window_rect.top) - 0.5;
|
||||
break;
|
||||
case FULLSCR_SCALE_43:
|
||||
*t = -0.5;
|
||||
*b = (window_rect.bottom - window_rect.top) - 0.5;
|
||||
*l = ((window_rect.right - window_rect.left) / 2) - (((window_rect.bottom - window_rect.top) * 4) / (3 * 2)) - 0.5;
|
||||
*r = ((window_rect.right - window_rect.left) / 2) + (((window_rect.bottom - window_rect.top) * 4) / (3 * 2)) - 0.5;
|
||||
if (*l < -0.5)
|
||||
{
|
||||
*l = -0.5;
|
||||
*r = (window_rect.right - window_rect.left) - 0.5;
|
||||
*t = ((window_rect.bottom - window_rect.top) / 2) - (((window_rect.right - window_rect.left) * 3) / (4 * 2)) - 0.5;
|
||||
*b = ((window_rect.bottom - window_rect.top) / 2) + (((window_rect.right - window_rect.left) * 3) / (4 * 2)) - 0.5;
|
||||
}
|
||||
break;
|
||||
case FULLSCR_SCALE_SQ:
|
||||
*t = -0.5;
|
||||
*b = (window_rect.bottom - window_rect.top) - 0.5;
|
||||
*l = ((window_rect.right - window_rect.left) / 2) - (((window_rect.bottom - window_rect.top) * w) / (h * 2)) - 0.5;
|
||||
*r = ((window_rect.right - window_rect.left) / 2) + (((window_rect.bottom - window_rect.top) * w) / (h * 2)) - 0.5;
|
||||
if (*l < -0.5)
|
||||
{
|
||||
*l = -0.5;
|
||||
*r = (window_rect.right - window_rect.left) - 0.5;
|
||||
*t = ((window_rect.bottom - window_rect.top) / 2) - (((window_rect.right - window_rect.left) * h) / (w * 2)) - 0.5;
|
||||
*b = ((window_rect.bottom - window_rect.top) / 2) + (((window_rect.right - window_rect.left) * h) / (w * 2)) - 0.5;
|
||||
}
|
||||
break;
|
||||
case FULLSCR_SCALE_INT:
|
||||
ratio_w = (window_rect.right - window_rect.left) / w;
|
||||
ratio_h = (window_rect.bottom - window_rect.top) / h;
|
||||
if (ratio_h < ratio_w)
|
||||
ratio_w = ratio_h;
|
||||
*l = ((window_rect.right - window_rect.left) / 2) - ((w * ratio_w) / 2) - 0.5;
|
||||
*r = ((window_rect.right - window_rect.left) / 2) + ((w * ratio_w) / 2) - 0.5;
|
||||
*t = ((window_rect.bottom - window_rect.top) / 2) - ((h * ratio_w) / 2) - 0.5;
|
||||
*b = ((window_rect.bottom - window_rect.top) / 2) + ((h * ratio_w) / 2) - 0.5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
|
||||
{
|
||||
HRESULT hr = D3D_OK;
|
||||
VOID* pVoid;
|
||||
D3DLOCKED_RECT dr;
|
||||
RECT window_rect;
|
||||
int yy;
|
||||
double l, t, r, b;
|
||||
|
||||
if ((y1 == y2) || (d3dTexture == NULL))
|
||||
{
|
||||
video_blit_complete();
|
||||
return; /*Nothing to do*/
|
||||
}
|
||||
|
||||
if (hr == D3D_OK && !(y1 == 0 && y2 == 0))
|
||||
{
|
||||
RECT lock_rect;
|
||||
|
||||
lock_rect.top = y1;
|
||||
lock_rect.left = 0;
|
||||
lock_rect.bottom = y2;
|
||||
lock_rect.right = 2047;
|
||||
|
||||
if (FAILED(d3dTexture->LockRect(0, &dr, &lock_rect, 0)))
|
||||
fatal("LockRect failed\n");
|
||||
|
||||
for (yy = y1; yy < y2; yy++)
|
||||
memcpy((uint32_t *) &(((uint8_t *) dr.pBits)[(yy - y1) * dr.Pitch]), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
|
||||
|
||||
video_blit_complete();
|
||||
d3dTexture->UnlockRect(0);
|
||||
}
|
||||
else
|
||||
video_blit_complete();
|
||||
|
||||
d3d_verts[0].tu = d3d_verts[2].tu = d3d_verts[3].tu = 0;
|
||||
d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0;
|
||||
d3d_verts[1].tu = d3d_verts[4].tu = d3d_verts[5].tu = (float)w / 2048.0;
|
||||
d3d_verts[1].tv = d3d_verts[2].tv = d3d_verts[5].tv = (float)h / 2048.0;
|
||||
|
||||
GetClientRect(d3d_device_window, &window_rect);
|
||||
d3d_fs_size(window_rect, &l, &t, &r, &b, w, h);
|
||||
|
||||
d3d_verts[0].x = l;
|
||||
d3d_verts[0].y = t;
|
||||
d3d_verts[1].x = r;
|
||||
d3d_verts[1].y = b;
|
||||
d3d_verts[2].x = l;
|
||||
d3d_verts[2].y = b;
|
||||
d3d_verts[3].x = l;
|
||||
d3d_verts[3].y = t;
|
||||
d3d_verts[4].x = r;
|
||||
d3d_verts[4].y = t;
|
||||
d3d_verts[5].x = r;
|
||||
d3d_verts[5].y = b;
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0);
|
||||
if (hr == D3D_OK)
|
||||
memcpy(pVoid, d3d_verts, sizeof(d3d_verts));
|
||||
if (hr == D3D_OK)
|
||||
hr = v_buffer->Unlock();
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->BeginScene();
|
||||
|
||||
if (hr == D3D_OK)
|
||||
{
|
||||
if (hr == D3D_OK)
|
||||
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0, 0);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetTexture(0, d3dTexture);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetTexture(0, NULL);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->EndScene();
|
||||
}
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->Present(NULL, NULL, d3d_device_window, NULL);
|
||||
|
||||
if (hr == D3DERR_DEVICELOST || hr == D3DERR_INVALIDCALL)
|
||||
PostMessage(ghwnd, WM_RESETD3D, 0, 0);
|
||||
}
|
||||
|
||||
static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h)
|
||||
{
|
||||
HRESULT hr = D3D_OK;
|
||||
VOID* pVoid;
|
||||
D3DLOCKED_RECT dr;
|
||||
RECT window_rect;
|
||||
uint32_t *p;
|
||||
int xx, yy;
|
||||
double l, t, r, b;
|
||||
|
||||
if (!h || (d3dTexture == NULL))
|
||||
{
|
||||
video_blit_complete();
|
||||
return; /*Nothing to do*/
|
||||
}
|
||||
|
||||
if (hr == D3D_OK)
|
||||
{
|
||||
RECT lock_rect;
|
||||
|
||||
lock_rect.top = 0;
|
||||
lock_rect.left = 0;
|
||||
lock_rect.bottom = 2047;
|
||||
lock_rect.right = 2047;
|
||||
|
||||
if (FAILED(d3dTexture->LockRect(0, &dr, &lock_rect, 0)))
|
||||
fatal("LockRect failed\n");
|
||||
|
||||
for (yy = 0; yy < h; yy++)
|
||||
{
|
||||
p = (uint32_t *) &(((uint8_t *) dr.pBits)[yy * dr.Pitch]);
|
||||
if ((y + yy) >= 0 && (y + yy) < buffer->h)
|
||||
{
|
||||
for (xx = 0; xx < w; xx++)
|
||||
p[xx] = pal_lookup[buffer->line[y + yy][x + xx]];
|
||||
}
|
||||
}
|
||||
|
||||
video_blit_complete();
|
||||
|
||||
d3dTexture->UnlockRect(0);
|
||||
}
|
||||
else
|
||||
video_blit_complete();
|
||||
|
||||
d3d_verts[0].tu = d3d_verts[2].tu = d3d_verts[3].tu = 0;
|
||||
d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0;
|
||||
d3d_verts[1].tu = d3d_verts[4].tu = d3d_verts[5].tu = (float)w / 2048.0;
|
||||
d3d_verts[1].tv = d3d_verts[2].tv = d3d_verts[5].tv = (float)h / 2048.0;
|
||||
|
||||
GetClientRect(d3d_device_window, &window_rect);
|
||||
d3d_fs_size(window_rect, &l, &t, &r, &b, w, h);
|
||||
|
||||
d3d_verts[0].x = l;
|
||||
d3d_verts[0].y = t;
|
||||
d3d_verts[1].x = r;
|
||||
d3d_verts[1].y = b;
|
||||
d3d_verts[2].x = l;
|
||||
d3d_verts[2].y = b;
|
||||
d3d_verts[3].x = l;
|
||||
d3d_verts[3].y = t;
|
||||
d3d_verts[4].x = r;
|
||||
d3d_verts[4].y = t;
|
||||
d3d_verts[5].x = r;
|
||||
d3d_verts[5].y = b;
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0);
|
||||
if (hr == D3D_OK)
|
||||
memcpy(pVoid, d3d_verts, sizeof(d3d_verts));
|
||||
if (hr == D3D_OK)
|
||||
hr = v_buffer->Unlock();
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->BeginScene();
|
||||
|
||||
if (hr == D3D_OK)
|
||||
{
|
||||
if (hr == D3D_OK)
|
||||
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0, 0);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetTexture(0, d3dTexture);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetTexture(0, NULL);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->EndScene();
|
||||
}
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->Present(NULL, NULL, d3d_device_window, NULL);
|
||||
|
||||
if (hr == D3DERR_DEVICELOST || hr == D3DERR_INVALIDCALL)
|
||||
PostMessage(ghwnd, WM_RESETD3D, 0, 0);
|
||||
}
|
||||
|
||||
void d3d_fs_take_screenshot(wchar_t *fn)
|
||||
{
|
||||
LPDIRECT3DSURFACE9 d3dSurface = NULL;
|
||||
|
||||
if (!d3dTexture) return;
|
||||
|
||||
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &d3dSurface);
|
||||
D3DXSaveSurfaceToFile(fn, D3DXIFF_PNG, d3dSurface, NULL, NULL);
|
||||
|
||||
d3dSurface->Release();
|
||||
d3dSurface = NULL;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int d3d_fs_init(HWND h);
|
||||
void d3d_fs_close();
|
||||
void d3d_fs_reset();
|
||||
void d3d_fs_resize(int x, int y);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
397
src/win-d3d.cc
397
src/win-d3d.cc
@@ -1,397 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#define UNICODE
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <d3d9.h>
|
||||
#undef BITMAP
|
||||
#include <D3dx9tex.h>
|
||||
#include "resource.h"
|
||||
#include "win-d3d.h"
|
||||
#include "video/video.h"
|
||||
#include "win-cgapal.h"
|
||||
|
||||
|
||||
extern "C" void fatal(const char *format, ...);
|
||||
extern "C" void pclog(const char *format, ...);
|
||||
|
||||
extern "C" void device_force_redraw(void);
|
||||
extern "C" void video_blit_complete(void);
|
||||
|
||||
|
||||
void d3d_init_objects(void);
|
||||
void d3d_close_objects(void);
|
||||
void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h);
|
||||
void d3d_blit_memtoscreen_8(int x, int y, int w, int h);
|
||||
|
||||
static LPDIRECT3D9 d3d = NULL;
|
||||
static LPDIRECT3DDEVICE9 d3ddev = NULL;
|
||||
static LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL;
|
||||
static LPDIRECT3DTEXTURE9 d3dTexture = NULL;
|
||||
static D3DPRESENT_PARAMETERS d3dpp;
|
||||
|
||||
static HWND d3d_hwnd;
|
||||
|
||||
struct CUSTOMVERTEX
|
||||
{
|
||||
FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
|
||||
static CUSTOMVERTEX d3d_verts[] =
|
||||
{
|
||||
{ 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f},
|
||||
{2048.0f, 2048.0f, 1.0f, 1.0f, 1.0f, 1.0f},
|
||||
{ 0.0f, 2048.0f, 1.0f, 1.0f, 0.0f, 1.0f},
|
||||
|
||||
{ 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f},
|
||||
{2048.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f},
|
||||
{2048.0f, 2048.0f, 1.0f, 1.0f, 1.0f, 1.0f},
|
||||
};
|
||||
|
||||
int d3d_init(HWND h)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
cgapal_rebuild();
|
||||
|
||||
d3d_hwnd = h;
|
||||
|
||||
d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
if (d3d == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&d3dpp, 0, sizeof(d3dpp));
|
||||
|
||||
d3dpp.Flags = 0;
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.hDeviceWindow = h;
|
||||
d3dpp.BackBufferCount = 1;
|
||||
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||
d3dpp.MultiSampleQuality = 0;
|
||||
d3dpp.EnableAutoDepthStencil = false;
|
||||
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
|
||||
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
d3dpp.Windowed = true;
|
||||
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
|
||||
d3dpp.BackBufferWidth = 0;
|
||||
d3dpp.BackBufferHeight = 0;
|
||||
|
||||
hr = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
d3d_init_objects();
|
||||
|
||||
video_blit_memtoscreen_func = d3d_blit_memtoscreen;
|
||||
video_blit_memtoscreen_8_func = d3d_blit_memtoscreen_8;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void d3d_close_objects(void)
|
||||
{
|
||||
if (d3dTexture)
|
||||
{
|
||||
d3dTexture->Release();
|
||||
d3dTexture = NULL;
|
||||
}
|
||||
if (v_buffer)
|
||||
{
|
||||
v_buffer->Release();
|
||||
v_buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void d3d_init_objects(void)
|
||||
{
|
||||
D3DLOCKED_RECT dr;
|
||||
RECT r;
|
||||
|
||||
d3ddev->CreateVertexBuffer(6*sizeof(CUSTOMVERTEX),
|
||||
0,
|
||||
D3DFVF_XYZRHW | D3DFVF_TEX1,
|
||||
D3DPOOL_MANAGED,
|
||||
&v_buffer,
|
||||
NULL);
|
||||
|
||||
d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL);
|
||||
|
||||
// r.top = r.left = 0;
|
||||
r.bottom = r.right = 2047;
|
||||
|
||||
if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0)))
|
||||
fatal("LockRect failed\n");
|
||||
|
||||
/* for (y = 0; y < 2048; y++)
|
||||
{
|
||||
uint32_t *p = (uint32_t *)(dr.pBits + (y * dr.Pitch));
|
||||
memset(p, 0, 2048 * 4);
|
||||
} */
|
||||
|
||||
d3dTexture->UnlockRect(0);
|
||||
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
}
|
||||
|
||||
void d3d_resize(int x, int y)
|
||||
{
|
||||
d3dpp.BackBufferWidth = x;
|
||||
d3dpp.BackBufferHeight = y;
|
||||
|
||||
d3d_reset();
|
||||
}
|
||||
|
||||
void d3d_reset(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
memset(&d3dpp, 0, sizeof(d3dpp));
|
||||
|
||||
d3dpp.Flags = 0;
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.hDeviceWindow = d3d_hwnd;
|
||||
d3dpp.BackBufferCount = 1;
|
||||
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||
d3dpp.MultiSampleQuality = 0;
|
||||
d3dpp.EnableAutoDepthStencil = false;
|
||||
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
|
||||
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
d3dpp.Windowed = true;
|
||||
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
|
||||
d3dpp.BackBufferWidth = 0;
|
||||
d3dpp.BackBufferHeight = 0;
|
||||
|
||||
hr = d3ddev->Reset(&d3dpp);
|
||||
|
||||
if (hr == D3DERR_DEVICELOST)
|
||||
return;
|
||||
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
|
||||
device_force_redraw();
|
||||
}
|
||||
|
||||
void d3d_close(void)
|
||||
{
|
||||
if (d3dTexture)
|
||||
{
|
||||
d3dTexture->Release();
|
||||
d3dTexture = NULL;
|
||||
}
|
||||
if (v_buffer)
|
||||
{
|
||||
v_buffer->Release();
|
||||
v_buffer = NULL;
|
||||
}
|
||||
if (d3ddev)
|
||||
{
|
||||
d3ddev->Release();
|
||||
d3ddev = NULL;
|
||||
}
|
||||
if (d3d)
|
||||
{
|
||||
d3d->Release();
|
||||
d3d = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
|
||||
{
|
||||
HRESULT hr = D3D_OK;
|
||||
VOID* pVoid;
|
||||
D3DLOCKED_RECT dr;
|
||||
RECT r;
|
||||
int yy;
|
||||
|
||||
if ((w <= 0) || (w > 2048) || (h <= 0) || (h > 2048) || (y1 == y2) || (y1 < 0) || (y1 > 2048) || (y2 < 0) || (y2 > 2048) || (d3dTexture == NULL))
|
||||
{
|
||||
video_blit_complete();
|
||||
return; /*Nothing to do*/
|
||||
}
|
||||
|
||||
r.top = y1;
|
||||
r.left = 0;
|
||||
r.bottom = y2;
|
||||
r.right = 2047;
|
||||
|
||||
if (hr == D3D_OK)
|
||||
{
|
||||
if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0)))
|
||||
fatal("LockRect failed\n");
|
||||
|
||||
for (yy = y1; yy < y2; yy++)
|
||||
memcpy((uint32_t *) &(((uint8_t *) dr.pBits)[(yy - y1) * dr.Pitch]), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
|
||||
|
||||
video_blit_complete();
|
||||
d3dTexture->UnlockRect(0);
|
||||
}
|
||||
else
|
||||
video_blit_complete();
|
||||
|
||||
d3d_verts[0].tu = d3d_verts[2].tu = d3d_verts[3].tu = 0;//0.5 / 2048.0;
|
||||
d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0;//0.5 / 2048.0;
|
||||
d3d_verts[1].tu = d3d_verts[4].tu = d3d_verts[5].tu = (float)w / 2048.0;
|
||||
d3d_verts[1].tv = d3d_verts[2].tv = d3d_verts[5].tv = (float)h / 2048.0;
|
||||
|
||||
GetClientRect(d3d_hwnd, &r);
|
||||
d3d_verts[0].x = d3d_verts[2].x = d3d_verts[3].x = -0.5;
|
||||
d3d_verts[0].y = d3d_verts[3].y = d3d_verts[4].y = -0.5;
|
||||
d3d_verts[1].x = d3d_verts[4].x = d3d_verts[5].x = (r.right - r.left) - 0.5;
|
||||
d3d_verts[1].y = d3d_verts[2].y = d3d_verts[5].y = (r.bottom - r.top) - 0.5;
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0); // lock the vertex buffer
|
||||
if (hr == D3D_OK)
|
||||
memcpy(pVoid, d3d_verts, sizeof(d3d_verts)); // copy the vertices to the locked buffer
|
||||
if (hr == D3D_OK)
|
||||
hr = v_buffer->Unlock(); // unlock the vertex buffer
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->BeginScene();
|
||||
|
||||
if (hr == D3D_OK)
|
||||
{
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetTexture(0, d3dTexture);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetTexture(0, NULL);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->EndScene();
|
||||
}
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->Present(NULL, NULL, d3d_hwnd, NULL);
|
||||
|
||||
if (hr == D3DERR_DEVICELOST || hr == D3DERR_INVALIDCALL)
|
||||
PostMessage(d3d_hwnd, WM_RESETD3D, 0, 0);
|
||||
}
|
||||
|
||||
void d3d_blit_memtoscreen_8(int x, int y, int w, int h)
|
||||
{
|
||||
VOID* pVoid;
|
||||
D3DLOCKED_RECT dr;
|
||||
RECT r;
|
||||
uint32_t *p;
|
||||
int yy, xx;
|
||||
HRESULT hr = D3D_OK;
|
||||
|
||||
if ((w <= 0) || (w > 2048) || (h <= 0) || (h > 2048) || (d3dTexture == NULL))
|
||||
{
|
||||
video_blit_complete();
|
||||
return; /*Nothing to do*/
|
||||
}
|
||||
|
||||
r.top = 0;
|
||||
r.left = 0;
|
||||
r.bottom = h;
|
||||
r.right = 2047;
|
||||
|
||||
if (hr == D3D_OK)
|
||||
{
|
||||
if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0)))
|
||||
fatal("LockRect failed\n");
|
||||
|
||||
for (yy = 0; yy < h; yy++)
|
||||
{
|
||||
p = (uint32_t *) &((((uint8_t *) dr.pBits)[yy * dr.Pitch]));
|
||||
if ((y + yy) >= 0 && (y + yy) < buffer->h)
|
||||
{
|
||||
for (xx = 0; xx < w; xx++)
|
||||
p[xx] = pal_lookup[buffer->line[y + yy][x + xx]];
|
||||
}
|
||||
}
|
||||
video_blit_complete();
|
||||
|
||||
d3dTexture->UnlockRect(0);
|
||||
}
|
||||
else
|
||||
video_blit_complete();
|
||||
|
||||
d3d_verts[0].tu = d3d_verts[2].tu = d3d_verts[3].tu = 0;//0.5 / 2048.0;
|
||||
d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0;//0.5 / 2048.0;
|
||||
d3d_verts[1].tu = d3d_verts[4].tu = d3d_verts[5].tu = (float)w / 2048.0;
|
||||
d3d_verts[1].tv = d3d_verts[2].tv = d3d_verts[5].tv = (float)h / 2048.0;
|
||||
|
||||
GetClientRect(d3d_hwnd, &r);
|
||||
d3d_verts[0].x = d3d_verts[2].x = d3d_verts[3].x = -0.5;
|
||||
d3d_verts[0].y = d3d_verts[3].y = d3d_verts[4].y = -0.5;
|
||||
d3d_verts[1].x = d3d_verts[4].x = d3d_verts[5].x = (r.right - r.left) - 0.5;
|
||||
d3d_verts[1].y = d3d_verts[2].y = d3d_verts[5].y = (r.bottom - r.top) - 0.5;
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0); // lock the vertex buffer
|
||||
if (hr == D3D_OK)
|
||||
memcpy(pVoid, d3d_verts, sizeof(d3d_verts)); // copy the vertices to the locked buffer
|
||||
if (hr == D3D_OK)
|
||||
hr = v_buffer->Unlock(); // unlock the vertex buffer
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->BeginScene();
|
||||
|
||||
if (hr == D3D_OK)
|
||||
{
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetTexture(0, d3dTexture);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->SetTexture(0, NULL);
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->EndScene();
|
||||
}
|
||||
|
||||
if (hr == D3D_OK)
|
||||
hr = d3ddev->Present(NULL, NULL, d3d_hwnd, NULL);
|
||||
|
||||
if (hr == D3DERR_DEVICELOST || hr == D3DERR_INVALIDCALL)
|
||||
PostMessage(d3d_hwnd, WM_RESETD3D, 0, 0);
|
||||
}
|
||||
|
||||
void d3d_take_screenshot(wchar_t *fn)
|
||||
{
|
||||
LPDIRECT3DSURFACE9 d3dSurface = NULL;
|
||||
|
||||
if (!d3dTexture) return;
|
||||
|
||||
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &d3dSurface);
|
||||
D3DXSaveSurfaceToFile(fn, D3DXIFF_PNG, d3dSurface, NULL, NULL);
|
||||
|
||||
d3dSurface->Release();
|
||||
d3dSurface = NULL;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int d3d_init(HWND h);
|
||||
void d3d_close();
|
||||
void d3d_reset();
|
||||
void d3d_resize(int x, int y);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,338 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#define UNICODE
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <ddraw.h>
|
||||
#undef BITMAP
|
||||
#include "win-ddraw-fs.h"
|
||||
#include "win-ddraw-screenshot.h"
|
||||
#include "video/video.h"
|
||||
#include "win-cgapal.h"
|
||||
|
||||
|
||||
extern "C" void fatal(const char *format, ...);
|
||||
extern "C" void pclog(const char *format, ...);
|
||||
|
||||
extern "C" void device_force_redraw(void);
|
||||
|
||||
extern "C" int ddraw_fs_init(HWND h);
|
||||
extern "C" void ddraw_fs_close(void);
|
||||
|
||||
extern "C" void video_blit_complete(void);
|
||||
|
||||
static void ddraw_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h);
|
||||
static void ddraw_fs_blit_memtoscreen_8(int x, int y, int w, int h);
|
||||
|
||||
static LPDIRECTDRAW lpdd = NULL;
|
||||
static LPDIRECTDRAW7 lpdd7 = NULL;
|
||||
static LPDIRECTDRAWSURFACE7 lpdds_pri = NULL;
|
||||
static LPDIRECTDRAWSURFACE7 lpdds_back = NULL;
|
||||
static LPDIRECTDRAWSURFACE7 lpdds_back2 = NULL;
|
||||
static LPDIRECTDRAWCLIPPER lpdd_clipper = NULL;
|
||||
static DDSURFACEDESC2 ddsd;
|
||||
|
||||
static HWND ddraw_hwnd;
|
||||
static int ddraw_w, ddraw_h;
|
||||
|
||||
int ddraw_fs_init(HWND h)
|
||||
{
|
||||
ddraw_w = GetSystemMetrics(SM_CXSCREEN);
|
||||
ddraw_h = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
cgapal_rebuild();
|
||||
|
||||
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
|
||||
return 0;
|
||||
|
||||
if (FAILED(lpdd->QueryInterface(IID_IDirectDraw7, (LPVOID *)&lpdd7)))
|
||||
return 0;
|
||||
|
||||
lpdd->Release();
|
||||
lpdd = NULL;
|
||||
|
||||
atexit(ddraw_fs_close);
|
||||
|
||||
if (FAILED(lpdd7->SetCooperativeLevel(h, DDSCL_SETFOCUSWINDOW |
|
||||
DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT)))
|
||||
return 0;
|
||||
|
||||
if (FAILED(lpdd7->SetDisplayMode(ddraw_w, ddraw_h, 32, 0 ,0)))
|
||||
return 0;
|
||||
|
||||
// memset(&ddsd, 0, sizeof(ddsd));
|
||||
// ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
|
||||
ddsd.dwBackBufferCount = 1;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
|
||||
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_pri, NULL)))
|
||||
return 0;
|
||||
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
|
||||
if (FAILED(lpdds_pri->GetAttachedSurface(&ddsd.ddsCaps, &lpdds_back2)))
|
||||
return 0;
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
|
||||
ddsd.dwWidth = 2048;
|
||||
ddsd.dwHeight = 2048;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
|
||||
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back, NULL)))
|
||||
return 0;
|
||||
|
||||
pclog("DDRAW_INIT complete\n");
|
||||
ddraw_hwnd = h;
|
||||
video_blit_memtoscreen_func = ddraw_fs_blit_memtoscreen;
|
||||
video_blit_memtoscreen_8_func = ddraw_fs_blit_memtoscreen_8;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ddraw_fs_close(void)
|
||||
{
|
||||
if (lpdds_back2)
|
||||
{
|
||||
lpdds_back2->Release();
|
||||
lpdds_back2 = NULL;
|
||||
}
|
||||
if (lpdds_back)
|
||||
{
|
||||
lpdds_back->Release();
|
||||
lpdds_back = NULL;
|
||||
}
|
||||
if (lpdds_pri)
|
||||
{
|
||||
lpdds_pri->Release();
|
||||
lpdds_pri = NULL;
|
||||
}
|
||||
if (lpdd_clipper)
|
||||
{
|
||||
lpdd_clipper->Release();
|
||||
lpdd_clipper = NULL;
|
||||
}
|
||||
if (lpdd7)
|
||||
{
|
||||
lpdd7->Release();
|
||||
lpdd7 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void ddraw_fs_size(RECT window_rect, RECT *r_dest, int w, int h)
|
||||
{
|
||||
int ratio_w, ratio_h;
|
||||
switch (video_fullscreen_scale)
|
||||
{
|
||||
case FULLSCR_SCALE_FULL:
|
||||
r_dest->left = 0;
|
||||
r_dest->top = 0;
|
||||
r_dest->right = (window_rect.right - window_rect.left) - 1;
|
||||
r_dest->bottom = (window_rect.bottom - window_rect.top) - 1;
|
||||
break;
|
||||
case FULLSCR_SCALE_43:
|
||||
r_dest->top = 0;
|
||||
r_dest->bottom = (window_rect.bottom - window_rect.top) - 1;
|
||||
r_dest->left = ((window_rect.right - window_rect.left) / 2) - (((window_rect.bottom - window_rect.top) * 4) / (3 * 2));
|
||||
r_dest->right = ((window_rect.right - window_rect.left) / 2) + (((window_rect.bottom - window_rect.top) * 4) / (3 * 2)) - 1;
|
||||
if (r_dest->left < 0)
|
||||
{
|
||||
r_dest->left = 0;
|
||||
r_dest->right = (window_rect.right - window_rect.left) - 1;
|
||||
r_dest->top = ((window_rect.bottom - window_rect.top) / 2) - (((window_rect.right - window_rect.left) * 3) / (4 * 2));
|
||||
r_dest->bottom = ((window_rect.bottom - window_rect.top) / 2) + (((window_rect.right - window_rect.left) * 3) / (4 * 2)) - 1;
|
||||
}
|
||||
break;
|
||||
case FULLSCR_SCALE_SQ:
|
||||
r_dest->top = 0;
|
||||
r_dest->bottom = (window_rect.bottom - window_rect.top) - 1;
|
||||
r_dest->left = ((window_rect.right - window_rect.left) / 2) - (((window_rect.bottom - window_rect.top) * w) / (h * 2));
|
||||
r_dest->right = ((window_rect.right - window_rect.left) / 2) + (((window_rect.bottom - window_rect.top) * w) / (h * 2)) - 1;
|
||||
if (r_dest->left < 0)
|
||||
{
|
||||
r_dest->left = 0;
|
||||
r_dest->right = (window_rect.right - window_rect.left) - 1;
|
||||
r_dest->top = ((window_rect.bottom - window_rect.top) / 2) - (((window_rect.right - window_rect.left) * h) / (w * 2));
|
||||
r_dest->bottom = ((window_rect.bottom - window_rect.top) / 2) + (((window_rect.right - window_rect.left) * h) / (w * 2)) - 1;
|
||||
}
|
||||
break;
|
||||
case FULLSCR_SCALE_INT:
|
||||
ratio_w = (window_rect.right - window_rect.left) / w;
|
||||
ratio_h = (window_rect.bottom - window_rect.top) / h;
|
||||
if (ratio_h < ratio_w)
|
||||
ratio_w = ratio_h;
|
||||
r_dest->left = ((window_rect.right - window_rect.left) / 2) - ((w * ratio_w) / 2);
|
||||
r_dest->right = ((window_rect.right - window_rect.left) / 2) + ((w * ratio_w) / 2) - 1;
|
||||
r_dest->top = ((window_rect.bottom - window_rect.top) / 2) - ((h * ratio_w) / 2);
|
||||
r_dest->bottom = ((window_rect.bottom - window_rect.top) / 2) + ((h * ratio_w) / 2) - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void ddraw_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
|
||||
{
|
||||
RECT r_src;
|
||||
RECT r_dest;
|
||||
RECT window_rect;
|
||||
int yy;
|
||||
HRESULT hr;
|
||||
DDBLTFX ddbltfx;
|
||||
|
||||
if (lpdds_back == NULL)
|
||||
{
|
||||
video_blit_complete();
|
||||
return; /*Nothing to do*/
|
||||
}
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
hr = lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_back->Restore();
|
||||
lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
device_force_redraw();
|
||||
}
|
||||
if (!ddsd.lpSurface)
|
||||
{
|
||||
video_blit_complete();
|
||||
return;
|
||||
}
|
||||
for (yy = y1; yy < y2; yy++)
|
||||
{
|
||||
if ((y + yy) >= 0) memcpy((unsigned char*)ddsd.lpSurface + (yy * ddsd.lPitch), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
|
||||
}
|
||||
video_blit_complete();
|
||||
lpdds_back->Unlock(NULL);
|
||||
|
||||
window_rect.left = 0;
|
||||
window_rect.top = 0;
|
||||
window_rect.right = ddraw_w;
|
||||
window_rect.bottom = ddraw_h;
|
||||
ddraw_fs_size(window_rect, &r_dest, w, h);
|
||||
|
||||
r_src.left = 0;
|
||||
r_src.top = 0;
|
||||
r_src.right = w;
|
||||
r_src.bottom = h;
|
||||
|
||||
ddbltfx.dwSize = sizeof(ddbltfx);
|
||||
ddbltfx.dwFillColor = 0;
|
||||
|
||||
lpdds_back2->Blt(&window_rect, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &ddbltfx);
|
||||
|
||||
hr = lpdds_back2->Blt(&r_dest, lpdds_back, &r_src, DDBLT_WAIT, NULL);
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_back2->Restore();
|
||||
lpdds_back2->Blt(&r_dest, lpdds_back, &r_src, DDBLT_WAIT, NULL);
|
||||
}
|
||||
|
||||
if (readflash && enable_flash)
|
||||
{
|
||||
RECT r;
|
||||
r.left = window_rect.right - 40;
|
||||
r.right = window_rect.right - 8;
|
||||
r.top = 8;
|
||||
r.bottom = 14;
|
||||
ddbltfx.dwFillColor = 0xffffff;
|
||||
lpdds_back2->Blt(&r, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &ddbltfx);
|
||||
}
|
||||
|
||||
hr = lpdds_pri->Flip(NULL, DDFLIP_NOVSYNC);
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_pri->Restore();
|
||||
lpdds_pri->Flip(NULL, DDFLIP_NOVSYNC);
|
||||
}
|
||||
}
|
||||
|
||||
static void ddraw_fs_blit_memtoscreen_8(int x, int y, int w, int h)
|
||||
{
|
||||
RECT r_src;
|
||||
RECT r_dest;
|
||||
RECT window_rect;
|
||||
int xx, yy;
|
||||
HRESULT hr;
|
||||
DDBLTFX ddbltfx;
|
||||
|
||||
if (lpdds_back == NULL)
|
||||
{
|
||||
video_blit_complete();
|
||||
return; /*Nothing to do*/
|
||||
}
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
hr = lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_back->Restore();
|
||||
lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
device_force_redraw();
|
||||
}
|
||||
if (!ddsd.lpSurface)
|
||||
{
|
||||
video_blit_complete();
|
||||
return;
|
||||
}
|
||||
for (yy = 0; yy < h; yy++)
|
||||
{
|
||||
if ((y + yy) >= 0 && (y + yy) < buffer->h)
|
||||
{
|
||||
uint32_t *p = (uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]);
|
||||
for (xx = 0; xx < w; xx++)
|
||||
{
|
||||
p[xx] = pal_lookup[buffer->line[y + yy][x + xx]];
|
||||
}
|
||||
}
|
||||
}
|
||||
video_blit_complete();
|
||||
lpdds_back->Unlock(NULL);
|
||||
|
||||
window_rect.left = 0;
|
||||
window_rect.top = 0;
|
||||
window_rect.right = ddraw_w;
|
||||
window_rect.bottom = ddraw_h;
|
||||
ddraw_fs_size(window_rect, &r_dest, w, h);
|
||||
|
||||
r_src.left = 0;
|
||||
r_src.top = 0;
|
||||
r_src.right = w;
|
||||
r_src.bottom = h;
|
||||
|
||||
ddbltfx.dwSize = sizeof(ddbltfx);
|
||||
ddbltfx.dwFillColor = 0;
|
||||
|
||||
lpdds_back2->Blt(&window_rect, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &ddbltfx);
|
||||
|
||||
hr = lpdds_back2->Blt(&r_dest, lpdds_back, &r_src, DDBLT_WAIT, NULL);
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_back2->Restore();
|
||||
lpdds_back2->Blt(&r_dest, lpdds_back, &r_src, DDBLT_WAIT, NULL);
|
||||
}
|
||||
|
||||
if (readflash && enable_flash)
|
||||
{
|
||||
RECT r;
|
||||
r.left = window_rect.right - 40;
|
||||
r.right = window_rect.right - 8;
|
||||
r.top = 8;
|
||||
r.bottom = 14;
|
||||
ddbltfx.dwFillColor = 0xffffff;
|
||||
lpdds_back2->Blt(&r, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &ddbltfx);
|
||||
}
|
||||
|
||||
lpdds_pri->Flip(NULL, DDFLIP_NOVSYNC);
|
||||
}
|
||||
|
||||
void ddraw_fs_take_screenshot(wchar_t *fn)
|
||||
{
|
||||
ddraw_common_take_screenshot(fn, lpdds_back2);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int ddraw_fs_init(HWND h);
|
||||
void ddraw_fs_close();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,178 +0,0 @@
|
||||
/* Copyright holders: Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#define UNICODE
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <ddraw.h>
|
||||
#undef BITMAP
|
||||
#include "win.h"
|
||||
#include "win-ddraw-screenshot.h"
|
||||
#include "win-language.h"
|
||||
#include "video/video.h"
|
||||
|
||||
|
||||
extern "C" void fatal(const char *format, ...);
|
||||
extern "C" void pclog(const char *format, ...);
|
||||
|
||||
extern "C" void device_force_redraw(void);
|
||||
|
||||
extern "C" void ddraw_init(HWND h);
|
||||
extern "C" void ddraw_close(void);
|
||||
|
||||
HBITMAP hbitmap;
|
||||
|
||||
int xs, ys, ys2;
|
||||
|
||||
void CopySurface(IDirectDrawSurface7 *pDDSurface)
|
||||
{
|
||||
HDC hdc, hmemdc;
|
||||
|
||||
HBITMAP hprevbitmap;
|
||||
|
||||
DDSURFACEDESC2 ddsd2;
|
||||
|
||||
pDDSurface->GetDC(&hdc);
|
||||
|
||||
hmemdc = CreateCompatibleDC(hdc);
|
||||
|
||||
ZeroMemory(&ddsd2 ,sizeof( ddsd2 )); // better to clear before using
|
||||
|
||||
ddsd2.dwSize = sizeof( ddsd2 ); //initialize with size
|
||||
|
||||
pDDSurface->GetSurfaceDesc(&ddsd2);
|
||||
|
||||
hbitmap = CreateCompatibleBitmap( hdc ,xs ,ys);
|
||||
|
||||
hprevbitmap = (HBITMAP) SelectObject( hmemdc, hbitmap );
|
||||
|
||||
BitBlt(hmemdc,0 ,0 ,xs ,ys ,hdc ,0 ,0,SRCCOPY);
|
||||
|
||||
SelectObject(hmemdc,hprevbitmap); // restore the old bitmap
|
||||
|
||||
DeleteDC(hmemdc);
|
||||
|
||||
pDDSurface->ReleaseDC(hdc);
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
void DoubleLines(uint8_t *dst, uint8_t *src)
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < ys; i++)
|
||||
{
|
||||
memcpy(dst + (i * xs * 8), src + (i * xs * 4), xs * 4);
|
||||
memcpy(dst + ((i * xs * 8) + (xs * 4)), src + (i * xs * 4), xs * 4);
|
||||
}
|
||||
}
|
||||
|
||||
static WCHAR szMessage[2048];
|
||||
|
||||
void SaveBitmap(wchar_t *szFilename,HBITMAP hBitmap)
|
||||
{
|
||||
HDC hdc=NULL;
|
||||
FILE* fp=NULL;
|
||||
LPVOID pBuf=NULL;
|
||||
LPVOID pBuf2=NULL;
|
||||
BITMAPINFO bmpInfo;
|
||||
BITMAPFILEHEADER bmpFileHeader;
|
||||
|
||||
do{
|
||||
|
||||
hdc=GetDC(NULL);
|
||||
|
||||
ZeroMemory(&bmpInfo,sizeof(BITMAPINFO));
|
||||
|
||||
bmpInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
|
||||
|
||||
GetDIBits(hdc,hBitmap,0,0,NULL,&bmpInfo,DIB_RGB_COLORS);
|
||||
|
||||
if(bmpInfo.bmiHeader.biSizeImage<=0)
|
||||
bmpInfo.bmiHeader.biSizeImage=bmpInfo.bmiHeader.biWidth*abs(bmpInfo.bmiHeader.biHeight)*(bmpInfo.bmiHeader.biBitCount+7)/8;
|
||||
|
||||
if((pBuf = malloc(bmpInfo.bmiHeader.biSizeImage))==NULL)
|
||||
{
|
||||
// pclog("ERROR: Unable to Allocate Bitmap Memory");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ys2 <= 250)
|
||||
{
|
||||
pBuf2 = malloc(bmpInfo.bmiHeader.biSizeImage * 2);
|
||||
}
|
||||
|
||||
bmpInfo.bmiHeader.biCompression=BI_RGB;
|
||||
|
||||
GetDIBits(hdc,hBitmap,0,bmpInfo.bmiHeader.biHeight,pBuf, &bmpInfo, DIB_RGB_COLORS);
|
||||
|
||||
if((fp = _wfopen(szFilename,L"wb"))==NULL)
|
||||
{
|
||||
_swprintf(szMessage, win_language_get_string_from_id(2194), szFilename);
|
||||
msgbox_error_wstr(ghwnd, szMessage);
|
||||
break;
|
||||
}
|
||||
|
||||
bmpFileHeader.bfReserved1=0;
|
||||
|
||||
bmpFileHeader.bfReserved2=0;
|
||||
|
||||
if (pBuf2)
|
||||
{
|
||||
bmpInfo.bmiHeader.biSizeImage <<= 1;
|
||||
bmpInfo.bmiHeader.biHeight <<= 1;
|
||||
}
|
||||
|
||||
bmpFileHeader.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+bmpInfo.bmiHeader.biSizeImage;
|
||||
|
||||
bmpFileHeader.bfType=0x4D42;
|
||||
|
||||
bmpFileHeader.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
|
||||
|
||||
fwrite(&bmpFileHeader,sizeof(BITMAPFILEHEADER),1,fp);
|
||||
|
||||
fwrite(&bmpInfo.bmiHeader,sizeof(BITMAPINFOHEADER),1,fp);
|
||||
|
||||
if (pBuf2)
|
||||
{
|
||||
DoubleLines((uint8_t *) pBuf2, (uint8_t *) pBuf);
|
||||
fwrite(pBuf2,bmpInfo.bmiHeader.biSizeImage,1,fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite(pBuf,bmpInfo.bmiHeader.biSizeImage,1,fp);
|
||||
}
|
||||
|
||||
}while(false);
|
||||
|
||||
if(hdc) ReleaseDC(NULL,hdc);
|
||||
|
||||
if(pBuf2) free(pBuf2);
|
||||
|
||||
if(pBuf) free(pBuf);
|
||||
|
||||
if(fp) fclose(fp);
|
||||
}
|
||||
|
||||
void ddraw_common_take_screenshot(wchar_t *fn, IDirectDrawSurface7 *pDDSurface)
|
||||
{
|
||||
xs = xsize;
|
||||
ys = ys2 = ysize;
|
||||
/* For EGA/(S)VGA, the size is NOT adjusted for overscan. */
|
||||
if ((overscan_y > 16) && enable_overscan)
|
||||
{
|
||||
xs += overscan_x;
|
||||
ys += overscan_y;
|
||||
}
|
||||
/* For CGA, the width is adjusted for overscan, but the height is not. */
|
||||
if (overscan_y == 16)
|
||||
{
|
||||
if (ys2 <= 250)
|
||||
ys += (overscan_y >> 1);
|
||||
else
|
||||
ys += overscan_y;
|
||||
}
|
||||
CopySurface(pDDSurface);
|
||||
SaveBitmap(fn, hbitmap);
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/* Copyright holders: Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
void ddraw_common_take_screenshot(wchar_t *fn, IDirectDrawSurface7 *pDDSurface);
|
||||
318
src/win-ddraw.cc
318
src/win-ddraw.cc
@@ -1,318 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#define UNICODE
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <ddraw.h>
|
||||
#undef BITMAP
|
||||
#include "win-ddraw.h"
|
||||
#include "win-ddraw-screenshot.h"
|
||||
#include "video/video.h"
|
||||
#include "win-cgapal.h"
|
||||
|
||||
|
||||
extern "C" void fatal(const char *format, ...);
|
||||
extern "C" void pclog(const char *format, ...);
|
||||
|
||||
extern "C" void device_force_redraw(void);
|
||||
|
||||
extern "C" int ddraw_init(HWND h);
|
||||
extern "C" void ddraw_close(void);
|
||||
|
||||
extern "C" void video_blit_complete(void);
|
||||
|
||||
static void ddraw_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h);
|
||||
static void ddraw_blit_memtoscreen_8(int x, int y, int w, int h);
|
||||
|
||||
static LPDIRECTDRAW lpdd = NULL;
|
||||
static LPDIRECTDRAW7 lpdd7 = NULL;
|
||||
static LPDIRECTDRAWSURFACE7 lpdds_pri = NULL;
|
||||
static LPDIRECTDRAWSURFACE7 lpdds_back = NULL;
|
||||
static LPDIRECTDRAWSURFACE7 lpdds_back2 = NULL;
|
||||
static LPDIRECTDRAWCLIPPER lpdd_clipper = NULL;
|
||||
static DDSURFACEDESC2 ddsd;
|
||||
|
||||
static HWND ddraw_hwnd;
|
||||
|
||||
int ddraw_init(HWND h)
|
||||
{
|
||||
cgapal_rebuild();
|
||||
|
||||
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
|
||||
return 0;
|
||||
|
||||
if (FAILED(lpdd->QueryInterface(IID_IDirectDraw7, (LPVOID *)&lpdd7)))
|
||||
return 0;
|
||||
|
||||
lpdd->Release();
|
||||
lpdd = NULL;
|
||||
|
||||
atexit(ddraw_close);
|
||||
|
||||
if (FAILED(lpdd7->SetCooperativeLevel(h, DDSCL_NORMAL)))
|
||||
return 0;
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
ddsd.dwFlags = DDSD_CAPS;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
||||
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_pri, NULL)))
|
||||
return 0;
|
||||
|
||||
// memset(&ddsd, 0, sizeof(ddsd));
|
||||
// ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
|
||||
ddsd.dwWidth = 2048;
|
||||
ddsd.dwHeight = 2048;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
|
||||
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back, NULL)))
|
||||
return 0;
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
|
||||
ddsd.dwWidth = 2048;
|
||||
ddsd.dwHeight = 2048;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
|
||||
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back2, NULL)))
|
||||
return 0;
|
||||
|
||||
if (FAILED(lpdd7->CreateClipper(0, &lpdd_clipper, NULL)))
|
||||
return 0;
|
||||
if (FAILED(lpdd_clipper->SetHWnd(0, h)))
|
||||
return 0;
|
||||
if (FAILED(lpdds_pri->SetClipper(lpdd_clipper)))
|
||||
return 0;
|
||||
|
||||
pclog("DDRAW_INIT complete\n");
|
||||
ddraw_hwnd = h;
|
||||
video_blit_memtoscreen_func = ddraw_blit_memtoscreen;
|
||||
video_blit_memtoscreen_8_func = ddraw_blit_memtoscreen_8;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ddraw_close(void)
|
||||
{
|
||||
if (lpdds_back2)
|
||||
{
|
||||
lpdds_back2->Release();
|
||||
lpdds_back2 = NULL;
|
||||
}
|
||||
if (lpdds_back)
|
||||
{
|
||||
lpdds_back->Release();
|
||||
lpdds_back = NULL;
|
||||
}
|
||||
if (lpdds_pri)
|
||||
{
|
||||
lpdds_pri->Release();
|
||||
lpdds_pri = NULL;
|
||||
}
|
||||
if (lpdd_clipper)
|
||||
{
|
||||
lpdd_clipper->Release();
|
||||
lpdd_clipper = NULL;
|
||||
}
|
||||
if (lpdd7)
|
||||
{
|
||||
lpdd7->Release();
|
||||
lpdd7 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void ddraw_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
|
||||
{
|
||||
RECT r_src;
|
||||
RECT r_dest;
|
||||
int xx, yy;
|
||||
POINT po;
|
||||
uint32_t *p;
|
||||
HRESULT hr;
|
||||
// pclog("Blit memtoscreen %i,%i %i %i %i,%i\n", x, y, y1, y2, w, h);
|
||||
|
||||
if (lpdds_back == NULL)
|
||||
{
|
||||
video_blit_complete();
|
||||
return; /*Nothing to do*/
|
||||
}
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
hr = lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_back->Restore();
|
||||
lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
device_force_redraw();
|
||||
}
|
||||
if (!ddsd.lpSurface)
|
||||
{
|
||||
video_blit_complete();
|
||||
return;
|
||||
}
|
||||
for (yy = y1; yy < y2; yy++)
|
||||
{
|
||||
if ((y + yy) >= 0 && (y + yy) < buffer->h)
|
||||
memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
|
||||
}
|
||||
video_blit_complete();
|
||||
lpdds_back->Unlock(NULL);
|
||||
|
||||
po.x = po.y = 0;
|
||||
|
||||
ClientToScreen(ddraw_hwnd, &po);
|
||||
GetClientRect(ddraw_hwnd, &r_dest);
|
||||
OffsetRect(&r_dest, po.x, po.y);
|
||||
|
||||
r_src.left = 0;
|
||||
r_src.top = 0;
|
||||
r_src.right = w;
|
||||
r_src.bottom = h;
|
||||
|
||||
hr = lpdds_back2->Blt(&r_src, lpdds_back, &r_src, DDBLT_WAIT, NULL);
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_back2->Restore();
|
||||
lpdds_back2->Blt(&r_src, lpdds_back, &r_src, DDBLT_WAIT, NULL);
|
||||
}
|
||||
|
||||
if (readflash)
|
||||
{
|
||||
readflash = 0;
|
||||
#ifdef LEGACY_READ_FLASH
|
||||
if (enable_flash)
|
||||
{
|
||||
hr = lpdds_back2->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_back2->Restore();
|
||||
lpdds_back2->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
device_force_redraw();
|
||||
}
|
||||
if (!ddsd.lpSurface) return;
|
||||
for (yy = 8; yy < 14; yy++)
|
||||
{
|
||||
p = &(((uint32_t *) ddsd.lpSurface)[yy * ddsd.lPitch]);
|
||||
for (xx = (w - 40); xx < (w - 8); xx++)
|
||||
p[xx] = 0xffffffff;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
lpdds_back2->Unlock(NULL);
|
||||
|
||||
// pclog("Blit from %i,%i %i,%i to %i,%i %i,%i\n", r_src.left, r_src.top, r_src.right, r_src.bottom, r_dest.left, r_dest.top, r_dest.right, r_dest.bottom);
|
||||
hr = lpdds_pri->Blt(&r_dest, lpdds_back2, &r_src, DDBLT_WAIT, NULL);
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_pri->Restore();
|
||||
lpdds_pri->Blt(&r_dest, lpdds_back2, &r_src, DDBLT_WAIT, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void ddraw_blit_memtoscreen_8(int x, int y, int w, int h)
|
||||
{
|
||||
RECT r_src;
|
||||
RECT r_dest;
|
||||
int xx, yy;
|
||||
POINT po;
|
||||
uint32_t *p;
|
||||
HRESULT hr;
|
||||
|
||||
if (lpdds_back == NULL)
|
||||
{
|
||||
video_blit_complete();
|
||||
return; /*Nothing to do*/
|
||||
}
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
hr = lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_back->Restore();
|
||||
lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
device_force_redraw();
|
||||
}
|
||||
if (!ddsd.lpSurface)
|
||||
{
|
||||
video_blit_complete();
|
||||
return;
|
||||
}
|
||||
for (yy = 0; yy < h; yy++)
|
||||
{
|
||||
if ((y + yy) >= 0 && (y + yy) < buffer->h)
|
||||
{
|
||||
p = (uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]);
|
||||
for (xx = 0; xx < w; xx++)
|
||||
{
|
||||
p[xx] = pal_lookup[buffer->line[y + yy][x + xx]];
|
||||
}
|
||||
}
|
||||
}
|
||||
p = &(((uint32_t *) ddsd.lpSurface)[4 * ddsd.lPitch]);
|
||||
lpdds_back->Unlock(NULL);
|
||||
video_blit_complete();
|
||||
|
||||
po.x = po.y = 0;
|
||||
|
||||
ClientToScreen(ddraw_hwnd, &po);
|
||||
GetClientRect(ddraw_hwnd, &r_dest);
|
||||
OffsetRect(&r_dest, po.x, po.y);
|
||||
|
||||
r_src.left = 0;
|
||||
r_src.top = 0;
|
||||
r_src.right = w;
|
||||
r_src.bottom = h;
|
||||
|
||||
hr = lpdds_back2->Blt(&r_src, lpdds_back, &r_src, DDBLT_WAIT, NULL);
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_back2->Restore();
|
||||
lpdds_back2->Blt(&r_src, lpdds_back, &r_src, DDBLT_WAIT, NULL);
|
||||
}
|
||||
|
||||
if (readflash)
|
||||
{
|
||||
readflash = 0;
|
||||
if (enable_flash)
|
||||
{
|
||||
hr = lpdds_back2->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_back2->Restore();
|
||||
lpdds_back2->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
|
||||
device_force_redraw();
|
||||
}
|
||||
if (!ddsd.lpSurface) return;
|
||||
for (yy = 8; yy < 14; yy++)
|
||||
{
|
||||
p = (uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]);
|
||||
for (xx = (w - 40); xx < (w - 8); xx++)
|
||||
p[xx] = 0xffffffff;
|
||||
}
|
||||
lpdds_back2->Unlock(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
hr = lpdds_pri->Blt(&r_dest, lpdds_back2, &r_src, DDBLT_WAIT, NULL);
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
lpdds_pri->Restore();
|
||||
hr = lpdds_pri->Blt(&r_dest, lpdds_back2, &r_src, DDBLT_WAIT, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void ddraw_take_screenshot(wchar_t *fn)
|
||||
{
|
||||
ddraw_common_take_screenshot(fn, lpdds_back2);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int ddraw_init(HWND h);
|
||||
void ddraw_close();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,317 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#undef BITMAP
|
||||
|
||||
#include "ibm.h"
|
||||
#include "config.h"
|
||||
#include "device.h"
|
||||
#include "resource.h"
|
||||
#include "win.h"
|
||||
|
||||
static device_t *config_device;
|
||||
|
||||
static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND h;
|
||||
int val_int;
|
||||
int num;
|
||||
char s[80];
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
int id = IDC_CONFIG_BASE;
|
||||
device_config_t *config = config_device->config;
|
||||
int c;
|
||||
|
||||
while (config->type != -1)
|
||||
{
|
||||
device_config_selection_t *selection = config->selection;
|
||||
h = GetDlgItem(hdlg, id);
|
||||
|
||||
switch (config->type)
|
||||
{
|
||||
case CONFIG_BINARY:
|
||||
val_int = config_get_int(config_device->name, config->name, config->default_int);
|
||||
|
||||
SendMessage(h, BM_SETCHECK, val_int, 0);
|
||||
|
||||
id++;
|
||||
break;
|
||||
|
||||
case CONFIG_SELECTION:
|
||||
val_int = config_get_int(config_device->name, config->name, config->default_int);
|
||||
|
||||
c = 0;
|
||||
while (selection->description[0])
|
||||
{
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)selection->description);
|
||||
if (val_int == selection->value)
|
||||
SendMessage(h, CB_SETCURSEL, c, 0);
|
||||
selection++;
|
||||
c++;
|
||||
}
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
}
|
||||
config++;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
int id = IDC_CONFIG_BASE;
|
||||
device_config_t *config = config_device->config;
|
||||
int c;
|
||||
int changed = 0;
|
||||
|
||||
while (config->type != -1)
|
||||
{
|
||||
device_config_selection_t *selection = config->selection;
|
||||
h = GetDlgItem(hdlg, id);
|
||||
|
||||
switch (config->type)
|
||||
{
|
||||
case CONFIG_BINARY:
|
||||
val_int = config_get_int(config_device->name, config->name, config->default_int);
|
||||
|
||||
if (val_int != SendMessage(h, BM_GETCHECK, 0, 0))
|
||||
changed = 1;
|
||||
|
||||
id++;
|
||||
break;
|
||||
|
||||
case CONFIG_SELECTION:
|
||||
val_int = config_get_int(config_device->name, config->name, config->default_int);
|
||||
|
||||
c = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
|
||||
for (; c > 0; c--)
|
||||
selection++;
|
||||
|
||||
if (val_int != selection->value)
|
||||
changed = 1;
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
}
|
||||
config++;
|
||||
}
|
||||
|
||||
if (!changed)
|
||||
{
|
||||
EndDialog(hdlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (MessageBox(NULL, "This will reset 86Box!\nOkay to continue?", "86Box", MB_OKCANCEL) != IDOK)
|
||||
{
|
||||
EndDialog(hdlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
id = IDC_CONFIG_BASE;
|
||||
config = config_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
{
|
||||
device_config_selection_t *selection = config->selection;
|
||||
h = GetDlgItem(hdlg, id);
|
||||
|
||||
switch (config->type)
|
||||
{
|
||||
case CONFIG_BINARY:
|
||||
config_set_int(config_device->name, config->name, SendMessage(h, BM_GETCHECK, 0, 0));
|
||||
|
||||
id++;
|
||||
break;
|
||||
|
||||
case CONFIG_SELECTION:
|
||||
c = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
for (; c > 0; c--)
|
||||
selection++;
|
||||
config_set_int(config_device->name, config->name, selection->value);
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
}
|
||||
config++;
|
||||
}
|
||||
|
||||
saveconfig();
|
||||
|
||||
resetpchard();
|
||||
|
||||
EndDialog(hdlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
case IDCANCEL:
|
||||
EndDialog(hdlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void deviceconfig_open(HWND hwnd, device_t *device)
|
||||
{
|
||||
device_config_t *config = device->config;
|
||||
uint16_t *data_block = malloc(16384);
|
||||
uint16_t *data;
|
||||
DLGTEMPLATE *dlg = (DLGTEMPLATE *)data_block;
|
||||
DLGITEMTEMPLATE *item;
|
||||
int y = 10;
|
||||
int id = IDC_CONFIG_BASE;
|
||||
|
||||
memset(data_block, 0, 4096);
|
||||
|
||||
dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU;
|
||||
dlg->x = 10;
|
||||
dlg->y = 10;
|
||||
dlg->cx = 220;
|
||||
dlg->cy = 70;
|
||||
|
||||
data = (uint16_t *)(dlg + 1);
|
||||
|
||||
*data++ = 0; /*no menu*/
|
||||
*data++ = 0; /*predefined dialog box class*/
|
||||
data += MultiByteToWideChar(CP_ACP, 0, "Device Configuration", -1, data, 50);
|
||||
|
||||
*data++ = 8; /*Point*/
|
||||
data += MultiByteToWideChar(CP_ACP, 0, "MS Sans Serif", -1, data, 50);
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
while (config->type != -1)
|
||||
{
|
||||
switch (config->type)
|
||||
{
|
||||
case CONFIG_BINARY:
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 10;
|
||||
item->y = y;
|
||||
item->id = id++;
|
||||
|
||||
item->cx = 80;
|
||||
item->cy = 15;
|
||||
|
||||
item->style = WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0080; /* button class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
y += 20;
|
||||
break;
|
||||
|
||||
case CONFIG_SELECTION:
|
||||
/*Combo box*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 70;
|
||||
item->y = y;
|
||||
item->id = id++;
|
||||
|
||||
item->cx = 140;
|
||||
item->cy = 150;
|
||||
|
||||
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0085; /* combo box class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
/*Static text*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 10;
|
||||
item->y = y;
|
||||
item->id = id++;
|
||||
|
||||
item->cx = 60;
|
||||
item->cy = 15;
|
||||
|
||||
item->style = WS_CHILD | WS_VISIBLE;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0082; /* static class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
y += 20;
|
||||
break;
|
||||
}
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
config++;
|
||||
}
|
||||
|
||||
dlg->cdit = (id - IDC_CONFIG_BASE) + 2;
|
||||
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 20;
|
||||
item->y = y;
|
||||
item->cx = 50;
|
||||
item->cy = 14;
|
||||
item->id = IDOK; /* OK button identifier */
|
||||
item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0080; /* button class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, "OK", -1, data, 50);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 80;
|
||||
item->y = y;
|
||||
item->cx = 50;
|
||||
item->cy = 14;
|
||||
item->id = IDCANCEL; /* OK button identifier */
|
||||
item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0080; /* button class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, "Cancel", -1, data, 50);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
dlg->cy = y + 20;
|
||||
|
||||
config_device = device;
|
||||
|
||||
DialogBoxIndirect(hinstance, dlg, hwnd, deviceconfig_dlgproc);
|
||||
|
||||
free(data_block);
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
extern "C" {
|
||||
#include "device.h"
|
||||
#include "gameport.h"
|
||||
}
|
||||
#include "plat-joystick.h"
|
||||
#include "win.h"
|
||||
|
||||
extern "C" int video_fullscreen;
|
||||
|
||||
extern "C" void fatal(const char *format, ...);
|
||||
extern "C" void pclog(const char *format, ...);
|
||||
|
||||
extern "C" void joystick_init();
|
||||
extern "C" void joystick_close();
|
||||
extern "C" void poll_joystick();
|
||||
|
||||
plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
|
||||
joystick_t joystick_state[MAX_JOYSTICKS];
|
||||
|
||||
static LPDIRECTINPUT8 lpdi;
|
||||
static LPDIRECTINPUTDEVICE8 lpdi_joystick[2] = {NULL, NULL};
|
||||
|
||||
int joysticks_present = 0;
|
||||
static GUID joystick_guids[MAX_JOYSTICKS];
|
||||
|
||||
static BOOL CALLBACK joystick_enum_callback(LPCDIDEVICEINSTANCE lpddi, LPVOID data)
|
||||
{
|
||||
if (joysticks_present >= MAX_JOYSTICKS)
|
||||
return DIENUM_STOP;
|
||||
|
||||
pclog("joystick_enum_callback : found joystick %i : %s\n", joysticks_present, lpddi->tszProductName);
|
||||
|
||||
joystick_guids[joysticks_present++] = lpddi->guidInstance;
|
||||
|
||||
if (joysticks_present >= MAX_JOYSTICKS)
|
||||
return DIENUM_STOP;
|
||||
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK DIEnumDeviceObjectsCallback(
|
||||
LPCDIDEVICEOBJECTINSTANCE lpddoi,
|
||||
LPVOID pvRef)
|
||||
{
|
||||
plat_joystick_t *state = (plat_joystick_t *)pvRef;
|
||||
|
||||
if (lpddoi->guidType == GUID_XAxis || lpddoi->guidType == GUID_YAxis || lpddoi->guidType == GUID_ZAxis ||
|
||||
lpddoi->guidType == GUID_RxAxis || lpddoi->guidType == GUID_RyAxis || lpddoi->guidType == GUID_RzAxis ||
|
||||
lpddoi->guidType == GUID_Slider)
|
||||
{
|
||||
strncpy(state->axis[state->nr_axes].name, lpddoi->tszName, sizeof(state->axis[state->nr_axes].name));
|
||||
pclog("Axis %i : %s %x %x\n", state->nr_axes, state->axis[state->nr_axes].name, lpddoi->dwOfs, lpddoi->dwType);
|
||||
if (lpddoi->guidType == GUID_XAxis)
|
||||
state->axis[state->nr_axes].id = 0;
|
||||
else if (lpddoi->guidType == GUID_YAxis)
|
||||
state->axis[state->nr_axes].id = 1;
|
||||
else if (lpddoi->guidType == GUID_ZAxis)
|
||||
state->axis[state->nr_axes].id = 2;
|
||||
else if (lpddoi->guidType == GUID_RxAxis)
|
||||
state->axis[state->nr_axes].id = 3;
|
||||
else if (lpddoi->guidType == GUID_RyAxis)
|
||||
state->axis[state->nr_axes].id = 4;
|
||||
else if (lpddoi->guidType == GUID_RzAxis)
|
||||
state->axis[state->nr_axes].id = 5;
|
||||
state->nr_axes++;
|
||||
}
|
||||
else if (lpddoi->guidType == GUID_Button)
|
||||
{
|
||||
strncpy(state->button[state->nr_buttons].name, lpddoi->tszName, sizeof(state->button[state->nr_buttons].name));
|
||||
pclog("Button %i : %s %x %x\n", state->nr_buttons, state->button[state->nr_buttons].name, lpddoi->dwOfs, lpddoi->dwType);
|
||||
state->nr_buttons++;
|
||||
}
|
||||
else if (lpddoi->guidType == GUID_POV)
|
||||
{
|
||||
strncpy(state->pov[state->nr_povs].name, lpddoi->tszName, sizeof(state->pov[state->nr_povs].name));
|
||||
pclog("POV %i : %s %x %x\n", state->nr_povs, state->pov[state->nr_povs].name, lpddoi->dwOfs, lpddoi->dwType);
|
||||
state->nr_povs++;
|
||||
}
|
||||
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
|
||||
void joystick_init()
|
||||
{
|
||||
int c;
|
||||
|
||||
if (joystick_type == 7) return;
|
||||
|
||||
atexit(joystick_close);
|
||||
|
||||
joysticks_present = 0;
|
||||
|
||||
if (FAILED(DirectInput8Create(hinstance, DIRECTINPUT_VERSION, IID_IDirectInput8A, (void **) &lpdi, NULL)))
|
||||
fatal("joystick_init : DirectInputCreate failed\n");
|
||||
|
||||
if (FAILED(lpdi->EnumDevices(DIDEVTYPE_JOYSTICK, joystick_enum_callback, NULL, DIEDFL_ATTACHEDONLY)))
|
||||
fatal("joystick_init : EnumDevices failed\n");
|
||||
|
||||
pclog("joystick_init: joysticks_present=%i\n", joysticks_present);
|
||||
|
||||
for (c = 0; c < joysticks_present; c++)
|
||||
{
|
||||
LPDIRECTINPUTDEVICE8 lpdi_joystick_temp = NULL;
|
||||
DIPROPRANGE joy_axis_range;
|
||||
DIDEVICEINSTANCE device_instance;
|
||||
DIDEVCAPS devcaps;
|
||||
|
||||
if (FAILED(lpdi->CreateDevice(joystick_guids[c], &lpdi_joystick_temp, NULL)))
|
||||
fatal("joystick_init : CreateDevice failed\n");
|
||||
if (FAILED(lpdi_joystick_temp->QueryInterface(IID_IDirectInputDevice8, (void **)&lpdi_joystick[c])))
|
||||
fatal("joystick_init : CreateDevice failed\n");
|
||||
lpdi_joystick_temp->Release();
|
||||
|
||||
memset(&device_instance, 0, sizeof(device_instance));
|
||||
device_instance.dwSize = sizeof(device_instance);
|
||||
if (FAILED(lpdi_joystick[c]->GetDeviceInfo(&device_instance)))
|
||||
fatal("joystick_init : GetDeviceInfo failed\n");
|
||||
pclog("Joystick %i :\n", c);
|
||||
pclog(" tszInstanceName = %s\n", device_instance.tszInstanceName);
|
||||
pclog(" tszProductName = %s\n", device_instance.tszProductName);
|
||||
strncpy(plat_joystick_state[c].name, device_instance.tszInstanceName, 64);
|
||||
|
||||
memset(&devcaps, 0, sizeof(devcaps));
|
||||
devcaps.dwSize = sizeof(devcaps);
|
||||
if (FAILED(lpdi_joystick[c]->GetCapabilities(&devcaps)))
|
||||
fatal("joystick_init : GetCapabilities failed\n");
|
||||
pclog(" Axes = %i\n", devcaps.dwAxes);
|
||||
pclog(" Buttons = %i\n", devcaps.dwButtons);
|
||||
pclog(" POVs = %i\n", devcaps.dwPOVs);
|
||||
|
||||
lpdi_joystick[c]->EnumObjects(DIEnumDeviceObjectsCallback, &plat_joystick_state[c], DIDFT_ALL);
|
||||
|
||||
if (FAILED(lpdi_joystick[c]->SetCooperativeLevel(ghwnd, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))
|
||||
fatal("joystick_init : SetCooperativeLevel failed\n");
|
||||
if (FAILED(lpdi_joystick[c]->SetDataFormat(&c_dfDIJoystick)))
|
||||
fatal("joystick_init : SetDataFormat failed\n");
|
||||
|
||||
joy_axis_range.lMin = -32768;
|
||||
joy_axis_range.lMax = 32767;
|
||||
joy_axis_range.diph.dwSize = sizeof(DIPROPRANGE);
|
||||
joy_axis_range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
joy_axis_range.diph.dwHow = DIPH_BYOFFSET;
|
||||
joy_axis_range.diph.dwObj = DIJOFS_X;
|
||||
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
|
||||
joy_axis_range.diph.dwObj = DIJOFS_Y;
|
||||
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
|
||||
joy_axis_range.diph.dwObj = DIJOFS_Z;
|
||||
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
|
||||
joy_axis_range.diph.dwObj = DIJOFS_RX;
|
||||
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
|
||||
joy_axis_range.diph.dwObj = DIJOFS_RY;
|
||||
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
|
||||
joy_axis_range.diph.dwObj = DIJOFS_RZ;
|
||||
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
|
||||
|
||||
if (FAILED(lpdi_joystick[c]->Acquire()))
|
||||
fatal("joystick_init : Acquire failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
void joystick_close()
|
||||
{
|
||||
if (lpdi_joystick[1])
|
||||
{
|
||||
lpdi_joystick[1]->Release();
|
||||
lpdi_joystick[1] = NULL;
|
||||
}
|
||||
if (lpdi_joystick[0])
|
||||
{
|
||||
lpdi_joystick[0]->Release();
|
||||
lpdi_joystick[0] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int joystick_get_axis(int joystick_nr, int mapping)
|
||||
{
|
||||
if (mapping & POV_X)
|
||||
{
|
||||
int pov = plat_joystick_state[joystick_nr].p[mapping & 3];
|
||||
|
||||
if (LOWORD(pov) == 0xFFFF)
|
||||
return 0;
|
||||
else
|
||||
return sin((2*M_PI * (double)pov) / 36000.0) * 32767;
|
||||
}
|
||||
else if (mapping & POV_Y)
|
||||
{
|
||||
int pov = plat_joystick_state[joystick_nr].p[mapping & 3];
|
||||
|
||||
if (LOWORD(pov) == 0xFFFF)
|
||||
return 0;
|
||||
else
|
||||
return -cos((2*M_PI * (double)pov) / 36000.0) * 32767;
|
||||
}
|
||||
else
|
||||
return plat_joystick_state[joystick_nr].a[plat_joystick_state[joystick_nr].axis[mapping].id];
|
||||
}
|
||||
|
||||
void joystick_poll()
|
||||
{
|
||||
int c, d;
|
||||
|
||||
for (c = 0; c < joysticks_present; c++)
|
||||
{
|
||||
DIJOYSTATE joystate;
|
||||
int b;
|
||||
|
||||
if (FAILED(lpdi_joystick[c]->Poll()))
|
||||
{
|
||||
lpdi_joystick[c]->Acquire();
|
||||
lpdi_joystick[c]->Poll();
|
||||
}
|
||||
if (FAILED(lpdi_joystick[c]->GetDeviceState(sizeof(DIJOYSTATE), (LPVOID)&joystate)))
|
||||
{
|
||||
lpdi_joystick[c]->Acquire();
|
||||
lpdi_joystick[c]->Poll();
|
||||
lpdi_joystick[c]->GetDeviceState(sizeof(DIJOYSTATE), (LPVOID)&joystate);
|
||||
}
|
||||
|
||||
plat_joystick_state[c].a[0] = joystate.lX;
|
||||
plat_joystick_state[c].a[1] = joystate.lY;
|
||||
plat_joystick_state[c].a[2] = joystate.lZ;
|
||||
plat_joystick_state[c].a[3] = joystate.lRx;
|
||||
plat_joystick_state[c].a[4] = joystate.lRy;
|
||||
plat_joystick_state[c].a[5] = joystate.lRz;
|
||||
|
||||
for (b = 0; b < 16; b++)
|
||||
plat_joystick_state[c].b[b] = joystate.rgbButtons[b] & 0x80;
|
||||
|
||||
for (b = 0; b < 4; b++)
|
||||
plat_joystick_state[c].p[b] = joystate.rgdwPOV[b];
|
||||
// pclog("joystick %i - x=%i y=%i b[0]=%i b[1]=%i %i\n", c, joystick_state[c].x, joystick_state[c].y, joystick_state[c].b[0], joystick_state[c].b[1], joysticks_present);
|
||||
}
|
||||
|
||||
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++)
|
||||
{
|
||||
if (joystick_state[c].plat_joystick_nr)
|
||||
{
|
||||
int joystick_nr = joystick_state[c].plat_joystick_nr - 1;
|
||||
|
||||
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
|
||||
joystick_state[c].axis[d] = joystick_get_axis(joystick_nr, joystick_state[c].axis_mapping[d]);
|
||||
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
|
||||
joystick_state[c].button[d] = plat_joystick_state[joystick_nr].b[joystick_state[c].button_mapping[d]];
|
||||
|
||||
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
|
||||
{
|
||||
int x, y;
|
||||
double angle, magnitude;
|
||||
|
||||
x = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][0]);
|
||||
y = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][1]);
|
||||
|
||||
angle = (atan2((double)y, (double)x) * 360.0) / (2*M_PI);
|
||||
magnitude = sqrt((double)x*(double)x + (double)y*(double)y);
|
||||
|
||||
if (magnitude < 16384)
|
||||
joystick_state[c].pov[d] = -1;
|
||||
else
|
||||
joystick_state[c].pov[d] = ((int)angle + 90 + 360) % 360;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
|
||||
joystick_state[c].axis[d] = 0;
|
||||
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
|
||||
joystick_state[c].button[d] = 0;
|
||||
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
|
||||
joystick_state[c].pov[d] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,541 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#undef BITMAP
|
||||
|
||||
#include "ibm.h"
|
||||
#include "config.h"
|
||||
#include "device.h"
|
||||
#include "gameport.h"
|
||||
#include "plat-joystick.h"
|
||||
#include "resource.h"
|
||||
#include "win.h"
|
||||
|
||||
static int joystick_nr;
|
||||
static int joystick_config_type;
|
||||
#define AXIS_STRINGS_MAX 3
|
||||
static char *axis_strings[AXIS_STRINGS_MAX] = {"X Axis", "Y Axis", "Z Axis"};
|
||||
|
||||
static void rebuild_axis_button_selections(HWND hdlg)
|
||||
{
|
||||
int id = IDC_CONFIG_BASE + 2;
|
||||
HWND h;
|
||||
int joystick;
|
||||
int c, d;
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_CONFIG_BASE);
|
||||
joystick = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
|
||||
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++)
|
||||
{
|
||||
int sel = c;
|
||||
|
||||
h = GetDlgItem(hdlg, id);
|
||||
SendMessage(h, CB_RESETCONTENT, 0, 0);
|
||||
|
||||
if (joystick)
|
||||
{
|
||||
for (d = 0; d < plat_joystick_state[joystick-1].nr_axes; d++)
|
||||
{
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[joystick-1].axis[d].name);
|
||||
if (c < AXIS_STRINGS_MAX)
|
||||
{
|
||||
if (!stricmp(axis_strings[c], plat_joystick_state[joystick-1].axis[d].name))
|
||||
sel = d;
|
||||
}
|
||||
}
|
||||
for (d = 0; d < plat_joystick_state[joystick-1].nr_povs; d++)
|
||||
{
|
||||
char s[80];
|
||||
|
||||
sprintf(s, "%s (X axis)", plat_joystick_state[joystick-1].pov[d].name);
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
|
||||
sprintf(s, "%s (Y axis)", plat_joystick_state[joystick-1].pov[d].name);
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
|
||||
}
|
||||
SendMessage(h, CB_SETCURSEL, sel, 0);
|
||||
EnableWindow(h, TRUE);
|
||||
}
|
||||
else
|
||||
EnableWindow(h, FALSE);
|
||||
|
||||
id += 2;
|
||||
}
|
||||
|
||||
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
|
||||
{
|
||||
h = GetDlgItem(hdlg, id);
|
||||
SendMessage(h, CB_RESETCONTENT, 0, 0);
|
||||
|
||||
if (joystick)
|
||||
{
|
||||
for (d = 0; d < plat_joystick_state[joystick-1].nr_buttons; d++)
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[joystick-1].button[d].name);
|
||||
SendMessage(h, CB_SETCURSEL, c, 0);
|
||||
EnableWindow(h, TRUE);
|
||||
}
|
||||
else
|
||||
EnableWindow(h, FALSE);
|
||||
|
||||
id += 2;
|
||||
}
|
||||
|
||||
for (c = 0; c < joystick_get_pov_count(joystick_config_type)*2; c++)
|
||||
{
|
||||
int sel = c;
|
||||
|
||||
h = GetDlgItem(hdlg, id);
|
||||
SendMessage(h, CB_RESETCONTENT, 0, 0);
|
||||
|
||||
if (joystick)
|
||||
{
|
||||
for (d = 0; d < plat_joystick_state[joystick-1].nr_povs; d++)
|
||||
{
|
||||
char s[80];
|
||||
|
||||
sprintf(s, "%s (X axis)", plat_joystick_state[joystick-1].pov[d].name);
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
|
||||
sprintf(s, "%s (Y axis)", plat_joystick_state[joystick-1].pov[d].name);
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
|
||||
}
|
||||
for (d = 0; d < plat_joystick_state[joystick-1].nr_axes; d++)
|
||||
{
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[joystick-1].axis[d].name);
|
||||
}
|
||||
SendMessage(h, CB_SETCURSEL, sel, 0);
|
||||
EnableWindow(h, TRUE);
|
||||
}
|
||||
else
|
||||
EnableWindow(h, FALSE);
|
||||
|
||||
id += 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int get_axis(HWND hdlg, int id)
|
||||
{
|
||||
HWND h = GetDlgItem(hdlg, id);
|
||||
int axis_sel = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
int nr_axes = plat_joystick_state[joystick_state[joystick_nr].plat_joystick_nr-1].nr_axes;
|
||||
|
||||
if (axis_sel < nr_axes)
|
||||
return axis_sel;
|
||||
|
||||
axis_sel -= nr_axes;
|
||||
if (axis_sel & 1)
|
||||
return POV_Y | (axis_sel >> 1);
|
||||
else
|
||||
return POV_X | (axis_sel >> 1);
|
||||
}
|
||||
|
||||
static int get_pov(HWND hdlg, int id)
|
||||
{
|
||||
HWND h = GetDlgItem(hdlg, id);
|
||||
int axis_sel = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
int nr_povs = plat_joystick_state[joystick_state[joystick_nr].plat_joystick_nr-1].nr_povs*2;
|
||||
|
||||
if (axis_sel < nr_povs)
|
||||
{
|
||||
if (axis_sel & 1)
|
||||
return POV_Y | (axis_sel >> 1);
|
||||
else
|
||||
return POV_X | (axis_sel >> 1);
|
||||
}
|
||||
|
||||
return axis_sel - nr_povs;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK joystickconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND h;
|
||||
int c;
|
||||
int id;
|
||||
int joystick;
|
||||
int nr_axes;
|
||||
int nr_povs;
|
||||
int mapping;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
h = GetDlgItem(hdlg, IDC_CONFIG_BASE);
|
||||
id = IDC_CONFIG_BASE + 2;
|
||||
joystick = joystick_state[joystick_nr].plat_joystick_nr;
|
||||
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"None");
|
||||
|
||||
for (c = 0; c < joysticks_present; c++)
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[c].name);
|
||||
|
||||
SendMessage(h, CB_SETCURSEL, joystick, 0);
|
||||
|
||||
rebuild_axis_button_selections(hdlg);
|
||||
|
||||
if (joystick_state[joystick_nr].plat_joystick_nr)
|
||||
{
|
||||
nr_axes = plat_joystick_state[joystick-1].nr_axes;
|
||||
nr_povs = plat_joystick_state[joystick-1].nr_povs;
|
||||
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++)
|
||||
{
|
||||
int mapping = joystick_state[joystick_nr].axis_mapping[c];
|
||||
|
||||
h = GetDlgItem(hdlg, id);
|
||||
if (mapping & POV_X)
|
||||
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2, 0);
|
||||
else if (mapping & POV_Y)
|
||||
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2 + 1, 0);
|
||||
else
|
||||
SendMessage(h, CB_SETCURSEL, mapping, 0);
|
||||
id += 2;
|
||||
}
|
||||
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
|
||||
{
|
||||
h = GetDlgItem(hdlg, id);
|
||||
SendMessage(h, CB_SETCURSEL, joystick_state[joystick_nr].button_mapping[c], 0);
|
||||
id += 2;
|
||||
}
|
||||
for (c = 0; c < joystick_get_pov_count(joystick_config_type); c++)
|
||||
{
|
||||
h = GetDlgItem(hdlg, id);
|
||||
mapping = joystick_state[joystick_nr].pov_mapping[c][0];
|
||||
if (mapping & POV_X)
|
||||
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2, 0);
|
||||
else if (mapping & POV_Y)
|
||||
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2 + 1, 0);
|
||||
else
|
||||
SendMessage(h, CB_SETCURSEL, mapping + nr_povs*2, 0);
|
||||
id += 2;
|
||||
h = GetDlgItem(hdlg, id);
|
||||
mapping = joystick_state[joystick_nr].pov_mapping[c][1];
|
||||
if (mapping & POV_X)
|
||||
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2, 0);
|
||||
else if (mapping & POV_Y)
|
||||
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2 + 1, 0);
|
||||
else
|
||||
SendMessage(h, CB_SETCURSEL, mapping + nr_povs*2, 0);
|
||||
id += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_CONFIG_BASE:
|
||||
if (HIWORD(wParam) == CBN_SELCHANGE)
|
||||
rebuild_axis_button_selections(hdlg);
|
||||
break;
|
||||
|
||||
case IDOK:
|
||||
{
|
||||
id = IDC_CONFIG_BASE + 2;
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_CONFIG_BASE);
|
||||
joystick_state[joystick_nr].plat_joystick_nr = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
|
||||
if (joystick_state[joystick_nr].plat_joystick_nr)
|
||||
{
|
||||
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++)
|
||||
{
|
||||
joystick_state[joystick_nr].axis_mapping[c] = get_axis(hdlg, id);
|
||||
id += 2;
|
||||
}
|
||||
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
|
||||
{
|
||||
h = GetDlgItem(hdlg, id);
|
||||
joystick_state[joystick_nr].button_mapping[c] = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
id += 2;
|
||||
}
|
||||
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
|
||||
{
|
||||
h = GetDlgItem(hdlg, id);
|
||||
joystick_state[joystick_nr].pov_mapping[c][0] = get_pov(hdlg, id);
|
||||
id += 2;
|
||||
h = GetDlgItem(hdlg, id);
|
||||
joystick_state[joystick_nr].pov_mapping[c][1] = get_pov(hdlg, id);
|
||||
id += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
case IDCANCEL:
|
||||
EndDialog(hdlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void joystickconfig_open(HWND hwnd, int joy_nr, int type)
|
||||
{
|
||||
uint16_t *data_block = malloc(16384);
|
||||
uint16_t *data;
|
||||
DLGTEMPLATE *dlg = (DLGTEMPLATE *)data_block;
|
||||
DLGITEMTEMPLATE *item;
|
||||
int y = 10;
|
||||
int id = IDC_CONFIG_BASE;
|
||||
int c;
|
||||
|
||||
joystick_nr = joy_nr;
|
||||
joystick_config_type = type;
|
||||
|
||||
memset(data_block, 0, 4096);
|
||||
|
||||
dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU;
|
||||
dlg->x = 10;
|
||||
dlg->y = 10;
|
||||
dlg->cx = 220;
|
||||
dlg->cy = 70;
|
||||
|
||||
data = (uint16_t *)(dlg + 1);
|
||||
|
||||
*data++ = 0; /*no menu*/
|
||||
*data++ = 0; /*predefined dialog box class*/
|
||||
data += MultiByteToWideChar(CP_ACP, 0, "Device Configuration", -1, data, 50);
|
||||
|
||||
*data++ = 8; /*Point*/
|
||||
data += MultiByteToWideChar(CP_ACP, 0, "MS Sans Serif", -1, data, 50);
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
|
||||
/*Combo box*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 70;
|
||||
item->y = y;
|
||||
item->id = id++;
|
||||
|
||||
item->cx = 140;
|
||||
item->cy = 150;
|
||||
|
||||
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0085; /* combo box class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, "Device", -1, data, 256);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
/*Static text*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 10;
|
||||
item->y = y;
|
||||
item->id = id++;
|
||||
|
||||
item->cx = 60;
|
||||
item->cy = 15;
|
||||
|
||||
item->style = WS_CHILD | WS_VISIBLE;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0082; /* static class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, "Device :", -1, data, 256);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
y += 20;
|
||||
|
||||
|
||||
for (c = 0; c < joystick_get_axis_count(type); c++)
|
||||
{
|
||||
/*Combo box*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 70;
|
||||
item->y = y;
|
||||
item->id = id++;
|
||||
|
||||
item->cx = 140;
|
||||
item->cy = 150;
|
||||
|
||||
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0085; /* combo box class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_axis_name(type, c), -1, data, 256);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
/*Static text*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 10;
|
||||
item->y = y;
|
||||
item->id = id++;
|
||||
|
||||
item->cx = 60;
|
||||
item->cy = 15;
|
||||
|
||||
item->style = WS_CHILD | WS_VISIBLE;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0082; /* static class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_axis_name(type, c), -1, data, 256);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
y += 20;
|
||||
}
|
||||
|
||||
for (c = 0; c < joystick_get_button_count(type); c++)
|
||||
{
|
||||
/*Combo box*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 70;
|
||||
item->y = y;
|
||||
item->id = id++;
|
||||
|
||||
item->cx = 140;
|
||||
item->cy = 150;
|
||||
|
||||
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0085; /* combo box class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_button_name(type, c), -1, data, 256);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
/*Static text*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 10;
|
||||
item->y = y;
|
||||
item->id = id++;
|
||||
|
||||
item->cx = 60;
|
||||
item->cy = 15;
|
||||
|
||||
item->style = WS_CHILD | WS_VISIBLE;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0082; /* static class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_button_name(type, c), -1, data, 256);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
y += 20;
|
||||
}
|
||||
|
||||
for (c = 0; c < joystick_get_pov_count(type)*2; c++)
|
||||
{
|
||||
char s[80];
|
||||
|
||||
/*Combo box*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 70;
|
||||
item->y = y;
|
||||
item->id = id++;
|
||||
|
||||
item->cx = 140;
|
||||
item->cy = 150;
|
||||
|
||||
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0085; /* combo box class */
|
||||
|
||||
if (c & 1)
|
||||
sprintf(s, "%s (Y axis)", joystick_get_pov_name(type, c/2));
|
||||
else
|
||||
sprintf(s, "%s (X axis)", joystick_get_pov_name(type, c/2));
|
||||
data += MultiByteToWideChar(CP_ACP, 0, s, -1, data, 256);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
/*Static text*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 10;
|
||||
item->y = y;
|
||||
item->id = id++;
|
||||
|
||||
item->cx = 60;
|
||||
item->cy = 15;
|
||||
|
||||
item->style = WS_CHILD | WS_VISIBLE;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0082; /* static class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, s, -1, data, 256);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
y += 20;
|
||||
}
|
||||
|
||||
dlg->cdit = (id - IDC_CONFIG_BASE) + 2;
|
||||
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 20;
|
||||
item->y = y;
|
||||
item->cx = 50;
|
||||
item->cy = 14;
|
||||
item->id = IDOK; /* OK button identifier */
|
||||
item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0080; /* button class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, "OK", -1, data, 50);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
if (((unsigned long)data) & 2)
|
||||
data++;
|
||||
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 80;
|
||||
item->y = y;
|
||||
item->cx = 50;
|
||||
item->cy = 14;
|
||||
item->id = IDCANCEL; /* OK button identifier */
|
||||
item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
|
||||
|
||||
data = (uint16_t *)(item + 1);
|
||||
*data++ = 0xFFFF;
|
||||
*data++ = 0x0080; /* button class */
|
||||
|
||||
data += MultiByteToWideChar(CP_ACP, 0, "Cancel", -1, data, 50);
|
||||
*data++ = 0; /* no creation data */
|
||||
|
||||
dlg->cy = y + 20;
|
||||
|
||||
DialogBoxIndirect(hinstance, dlg, hwnd, joystickconfig_dlgproc);
|
||||
|
||||
free(data_block);
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
#define UNICODE
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#undef BITMAP
|
||||
|
||||
#include <commdlg.h>
|
||||
|
||||
#include "ibm.h"
|
||||
#include "device.h"
|
||||
#include "ide.h"
|
||||
#include "resource.h"
|
||||
#include "win.h"
|
||||
#include "win-language.h"
|
||||
|
||||
LCID dwLanguage;
|
||||
|
||||
uint32_t dwLangID, dwSubLangID;
|
||||
|
||||
#define STRINGS_NUM 154
|
||||
|
||||
WCHAR lpResourceString[STRINGS_NUM][512];
|
||||
|
||||
char openfilestring[260];
|
||||
WCHAR wopenfilestring[260];
|
||||
|
||||
void win_language_set()
|
||||
{
|
||||
SetThreadLocale(dwLanguage);
|
||||
}
|
||||
|
||||
void win_language_load_common_strings()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < STRINGS_NUM; i++)
|
||||
{
|
||||
LoadString(hinstance, 2048 + i, lpResourceString[i], 512);
|
||||
}
|
||||
}
|
||||
|
||||
LPTSTR win_language_get_settings_category(int i)
|
||||
{
|
||||
return lpResourceString[17 + i];
|
||||
}
|
||||
|
||||
void win_language_update()
|
||||
{
|
||||
win_language_set();
|
||||
win_menu_update();
|
||||
win_language_load_common_strings();
|
||||
}
|
||||
|
||||
void win_language_check()
|
||||
{
|
||||
LCID dwLanguageNew = MAKELCID(dwLangID, dwSubLangID);
|
||||
if (dwLanguageNew != dwLanguage)
|
||||
{
|
||||
dwLanguage = dwLanguageNew;
|
||||
win_language_update();
|
||||
}
|
||||
}
|
||||
|
||||
LPTSTR win_language_get_string_from_id(int i)
|
||||
{
|
||||
return lpResourceString[i - 2048];
|
||||
}
|
||||
|
||||
LPTSTR win_language_get_string_from_string(char *str)
|
||||
{
|
||||
return lpResourceString[atoi(str) - 2048];
|
||||
}
|
||||
|
||||
int msgbox_reset(HWND hwndParent)
|
||||
{
|
||||
return MessageBox(hwndParent, lpResourceString[3], lpResourceString[0], MB_YESNOCANCEL | MB_ICONQUESTION);
|
||||
}
|
||||
|
||||
int msgbox_reset_yn(HWND hwndParent)
|
||||
{
|
||||
return MessageBox(hwndParent, lpResourceString[3], lpResourceString[0], MB_YESNO | MB_ICONQUESTION);
|
||||
}
|
||||
|
||||
int msgbox_question(HWND hwndParent, int i)
|
||||
{
|
||||
return MessageBox(hwndParent, win_language_get_string_from_id(i), lpResourceString[0], MB_YESNO | MB_ICONQUESTION);
|
||||
}
|
||||
|
||||
void msgbox_info(HWND hwndParent, int i)
|
||||
{
|
||||
MessageBox(hwndParent, win_language_get_string_from_id(i), lpResourceString[0], MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
|
||||
void msgbox_info_wstr(HWND hwndParent, WCHAR *wstr)
|
||||
{
|
||||
MessageBox(hwndParent, wstr, lpResourceString[0], MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
|
||||
void msgbox_error(HWND hwndParent, int i)
|
||||
{
|
||||
MessageBox(hwndParent, win_language_get_string_from_id(i), lpResourceString[1], MB_OK | MB_ICONWARNING);
|
||||
}
|
||||
|
||||
void msgbox_error_wstr(HWND hwndParent, WCHAR *wstr)
|
||||
{
|
||||
MessageBox(hwndParent, wstr, lpResourceString[1], MB_OK | MB_ICONWARNING);
|
||||
}
|
||||
|
||||
void msgbox_critical(HWND hwndParent, int i)
|
||||
{
|
||||
MessageBox(hwndParent, win_language_get_string_from_id(i), lpResourceString[2], MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
||||
void msgbox_fatal(HWND hwndParent, char *string)
|
||||
{
|
||||
LPTSTR lptsTemp;
|
||||
lptsTemp = (LPTSTR) malloc(512);
|
||||
|
||||
mbstowcs(lptsTemp, string, strlen(string) + 1);
|
||||
|
||||
MessageBox(hwndParent, lptsTemp, lpResourceString[2], MB_OK | MB_ICONERROR);
|
||||
|
||||
free(lptsTemp);
|
||||
}
|
||||
|
||||
int file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, int save)
|
||||
{
|
||||
OPENFILENAME ofn; /* common dialog box structure */
|
||||
BOOL r;
|
||||
DWORD err;
|
||||
|
||||
/* Initialize OPENFILENAME */
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = hwnd;
|
||||
ofn.lpstrFile = wopenfilestring;
|
||||
/*
|
||||
Set lpstrFile[0] to '\0' so that GetOpenFileName does not
|
||||
use the contents of szFile to initialize itself.
|
||||
*/
|
||||
memcpy(ofn.lpstrFile, fn, (wcslen(fn) << 1) + 2);
|
||||
ofn.nMaxFile = 259;
|
||||
ofn.lpstrFilter = f;
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST;
|
||||
if (!save)
|
||||
{
|
||||
ofn.Flags |= OFN_FILEMUSTEXIST;
|
||||
}
|
||||
|
||||
/* Display the Open dialog box. */
|
||||
|
||||
if (save)
|
||||
{
|
||||
pclog("GetSaveFileName - lpstrFile = %s\n", ofn.lpstrFile);
|
||||
r = GetSaveFileName(&ofn);
|
||||
}
|
||||
else
|
||||
{
|
||||
pclog("GetOpenFileName - lpstrFile = %s\n", ofn.lpstrFile);
|
||||
r = GetOpenFileName(&ofn);
|
||||
}
|
||||
if (r)
|
||||
{
|
||||
wcstombs(openfilestring, wopenfilestring, 520);
|
||||
pclog("File dialog return true\n");
|
||||
return 0;
|
||||
}
|
||||
pclog("File dialog return false\n");
|
||||
err = CommDlgExtendedError();
|
||||
pclog("CommDlgExtendedError return %04X\n", err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int file_dlg(HWND hwnd, WCHAR *f, char *fn, int save)
|
||||
{
|
||||
WCHAR ufn[512];
|
||||
mbstowcs(ufn, fn, strlen(fn) + 1);
|
||||
return file_dlg_w(hwnd, f, ufn, save);
|
||||
}
|
||||
|
||||
int file_dlg_w_st(HWND hwnd, int i, WCHAR *fn, int save)
|
||||
{
|
||||
return file_dlg_w(hwnd, win_language_get_string_from_id(i), fn, save);
|
||||
}
|
||||
|
||||
int file_dlg_st(HWND hwnd, int i, char *fn, int save)
|
||||
{
|
||||
return file_dlg(hwnd, win_language_get_string_from_id(i), fn, save);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
LCID dwLanguage;
|
||||
|
||||
int msgbox_reset(HWND hwndParent);
|
||||
int msgbox_reset_yn(HWND hwndParent);
|
||||
int msgbox_question(HWND hwndParent, int i);
|
||||
void msgbox_info(HWND hwndParent, int i);
|
||||
void msgbox_info_wstr(HWND hwndParent, WCHAR *wstr);
|
||||
void msgbox_error(HWND hwndParent, int i);
|
||||
void msgbox_error_wstr(HWND hwndParent, WCHAR *wstr);
|
||||
void msgbox_fatal(HWND hwndParent, char *string);
|
||||
void msgbox_critical(HWND hwndParent, int i);
|
||||
|
||||
int file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, int save);
|
||||
int file_dlg(HWND hwnd, WCHAR *f, char *fn, int save);
|
||||
int file_dlg_w_st(HWND hwnd, int i, WCHAR *fn, int save);
|
||||
int file_dlg_st(HWND hwnd, int i, char *fn, int save);
|
||||
|
||||
void win_language_load_common_strings();
|
||||
LPTSTR win_language_get_settings_category(int i);
|
||||
|
||||
void win_language_update();
|
||||
void win_language_check();
|
||||
|
||||
LPTSTR win_language_get_string_from_id(int i);
|
||||
LPTSTR win_language_get_string_from_string(char *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
279
src/win-midi.c
279
src/win-midi.c
@@ -1,279 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include "ibm.h"
|
||||
#include "config.h"
|
||||
#include "plat-midi.h"
|
||||
|
||||
int midi_id;
|
||||
static HMIDIOUT midi_out_device = NULL;
|
||||
|
||||
HANDLE m_event;
|
||||
|
||||
void midi_close();
|
||||
|
||||
static uint8_t midi_rt_buf[1024];
|
||||
static uint8_t midi_cmd_buf[1024];
|
||||
static int midi_cmd_pos = 0;
|
||||
static int midi_cmd_len = 0;
|
||||
static uint8_t midi_status = 0;
|
||||
static unsigned int midi_sysex_start = 0;
|
||||
static unsigned int midi_sysex_delay = 0;
|
||||
|
||||
uint8_t MIDI_evt_len[256] = {
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x00
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x10
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x20
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x30
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x40
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x50
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x60
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x70
|
||||
|
||||
3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0x80
|
||||
3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0x90
|
||||
3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xa0
|
||||
3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xb0
|
||||
|
||||
2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, // 0xc0
|
||||
2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, // 0xd0
|
||||
|
||||
3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xe0
|
||||
|
||||
0,2,3,2, 0,0,1,0, 1,0,1,1, 1,0,1,0 // 0xf0
|
||||
};
|
||||
|
||||
void midi_init()
|
||||
{
|
||||
MMRESULT hr = MMSYSERR_NOERROR;
|
||||
|
||||
memset(midi_rt_buf, 0, 1024);
|
||||
memset(midi_cmd_buf, 0, 1024);
|
||||
|
||||
midi_cmd_pos = midi_cmd_len = 0;
|
||||
midi_status = 0;
|
||||
|
||||
midi_sysex_start = midi_sysex_delay = 0;
|
||||
|
||||
midi_id = config_get_int(NULL, "midi", 0);
|
||||
|
||||
m_event = CreateEvent(NULL, TRUE, TRUE, NULL);
|
||||
|
||||
hr = midiOutOpen(&midi_out_device, midi_id, (DWORD) m_event,
|
||||
0, CALLBACK_EVENT);
|
||||
if (hr != MMSYSERR_NOERROR) {
|
||||
printf("midiOutOpen error - %08X\n",hr);
|
||||
midi_id = 0;
|
||||
hr = midiOutOpen(&midi_out_device, midi_id, (DWORD) m_event,
|
||||
0, CALLBACK_EVENT);
|
||||
if (hr != MMSYSERR_NOERROR) {
|
||||
printf("midiOutOpen error - %08X\n",hr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
midiOutReset(midi_out_device);
|
||||
}
|
||||
|
||||
void midi_close()
|
||||
{
|
||||
if (midi_out_device != NULL)
|
||||
{
|
||||
midiOutReset(midi_out_device);
|
||||
midiOutClose(midi_out_device);
|
||||
midi_out_device = NULL;
|
||||
CloseHandle(m_event);
|
||||
}
|
||||
}
|
||||
|
||||
int midi_get_num_devs()
|
||||
{
|
||||
return midiOutGetNumDevs();
|
||||
}
|
||||
void midi_get_dev_name(int num, char *s)
|
||||
{
|
||||
MIDIOUTCAPS caps;
|
||||
|
||||
midiOutGetDevCaps(num, &caps, sizeof(caps));
|
||||
strcpy(s, caps.szPname);
|
||||
}
|
||||
|
||||
static int midi_pos, midi_len;
|
||||
static uint32_t midi_command;
|
||||
static int midi_lengths[8] = {3, 3, 3, 3, 2, 2, 3, 1};
|
||||
static int midi_insysex;
|
||||
static char midi_sysex_data[1024+2];
|
||||
|
||||
static void midi_send_sysex()
|
||||
{
|
||||
MIDIHDR hdr;
|
||||
|
||||
hdr.lpData = midi_sysex_data;
|
||||
hdr.dwBufferLength = midi_pos;
|
||||
hdr.dwFlags = 0;
|
||||
|
||||
midiOutPrepareHeader(midi_out_device, &hdr, sizeof(MIDIHDR));
|
||||
midiOutLongMsg(midi_out_device, &hdr, sizeof(MIDIHDR));
|
||||
|
||||
midi_insysex = 0;
|
||||
}
|
||||
|
||||
void PlayMsg(uint8_t *msg)
|
||||
{
|
||||
midiOutShortMsg(midi_out_device, *(uint32_t *) msg);
|
||||
}
|
||||
|
||||
MIDIHDR m_hdr;
|
||||
|
||||
void PlaySysex(uint8_t *sysex, unsigned int len)
|
||||
{
|
||||
MMRESULT result;
|
||||
|
||||
if (WaitForSingleObject(m_event, 2000) == WAIT_TIMEOUT)
|
||||
{
|
||||
pclog("Can't send MIDI message\n");
|
||||
return;
|
||||
}
|
||||
|
||||
midiOutUnprepareHeader(midi_out_device, &m_hdr, sizeof(m_hdr));
|
||||
|
||||
m_hdr.lpData = (char *) sysex;
|
||||
m_hdr.dwBufferLength = len;
|
||||
m_hdr.dwBytesRecorded = len;
|
||||
m_hdr.dwUser = 0;
|
||||
|
||||
result = midiOutPrepareHeader(midi_out_device, &m_hdr, sizeof(m_hdr));
|
||||
|
||||
if (result != MMSYSERR_NOERROR) return;
|
||||
ResetEvent(m_event);
|
||||
result = midiOutLongMsg(midi_out_device, &m_hdr, sizeof(m_hdr));
|
||||
if (result != MMSYSERR_NOERROR)
|
||||
{
|
||||
SetEvent(m_event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#define SYSEX_SIZE 1024
|
||||
#define RAWBUF 1024
|
||||
|
||||
void midi_write(uint8_t val)
|
||||
{
|
||||
uint32_t passed_ticks;
|
||||
|
||||
if (midi_sysex_start)
|
||||
{
|
||||
passed_ticks = GetTickCount() - midi_sysex_start;
|
||||
if (passed_ticks < midi_sysex_delay)
|
||||
{
|
||||
Sleep(midi_sysex_delay - passed_ticks);
|
||||
}
|
||||
}
|
||||
|
||||
/* Test for a realtime MIDI message */
|
||||
if (val >= 0xf8)
|
||||
{
|
||||
midi_rt_buf[0] = val;
|
||||
PlayMsg(midi_rt_buf);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Test for a active sysex transfer */
|
||||
|
||||
if (midi_status == 0xf0)
|
||||
{
|
||||
if (!(val & 0x80))
|
||||
{
|
||||
if (midi_pos < (SYSEX_SIZE-1)) midi_sysex_data[midi_pos++] = val;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
midi_sysex_data[midi_pos++] = 0xf7;
|
||||
|
||||
if ((midi_sysex_start) && (midi_pos >= 4) && (midi_pos <= 9) && (midi_sysex_data[1] == 0x411) && (midi_sysex_data[3] == 0x16))
|
||||
{
|
||||
/* pclog("MIDI: Skipping invalid MT-32 SysEx MIDI message\n"); */
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySysex(midi_sysex_data, midi_pos);
|
||||
if (midi_sysex_start)
|
||||
{
|
||||
if (midi_sysex_data[5] == 0x7f)
|
||||
{
|
||||
midi_sysex_delay = 290; /* All parameters reset */
|
||||
}
|
||||
else if ((midi_sysex_data[5] == 0x10) && (midi_sysex_data[6] == 0x00) && (midi_sysex_data[7] == 0x04))
|
||||
{
|
||||
midi_sysex_delay = 145; /* Viking Child */
|
||||
}
|
||||
else if ((midi_sysex_data[5] == 0x10) && (midi_sysex_data[6] == 0x00) && (midi_sysex_data[7] == 0x01))
|
||||
{
|
||||
midi_sysex_delay = 30; /* Dark Sun 1 */
|
||||
}
|
||||
else
|
||||
midi_sysex_delay = (unsigned int) (((float) (midi_pos) * 1.25f) * 1000.0f / 3125.0f) + 2;
|
||||
|
||||
midi_sysex_start = GetTickCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (val & 0x80)
|
||||
{
|
||||
midi_status = val;
|
||||
midi_cmd_pos = 0;
|
||||
midi_cmd_len = MIDI_evt_len[val];
|
||||
if (midi_status == 0xf0)
|
||||
{
|
||||
midi_sysex_data[0] = 0xf0;
|
||||
midi_pos = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (midi_cmd_len)
|
||||
{
|
||||
midi_cmd_buf[midi_cmd_pos++] = val;
|
||||
if (midi_cmd_pos >= midi_cmd_len)
|
||||
{
|
||||
PlayMsg(midi_cmd_buf);
|
||||
midi_cmd_pos = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void midi_reset()
|
||||
{
|
||||
uint8_t buf[64], used;
|
||||
|
||||
/* Flush buffers */
|
||||
midiOutReset(midi_out_device);
|
||||
|
||||
/* GM1 reset */
|
||||
buf[0] = 0xf0;
|
||||
buf[1] = 0x7e;
|
||||
buf[2] = 0x7f;
|
||||
buf[3] = 0x09;
|
||||
buf[4] = 0x01;
|
||||
buf[5] = 0xf7;
|
||||
PlaySysex((uint8_t *) buf, 6);
|
||||
|
||||
/* GS1 reset */
|
||||
buf[0] = 0xf0;
|
||||
buf[1] = 0x41;
|
||||
buf[2] = 0x10;
|
||||
buf[3] = 0x42;
|
||||
buf[4] = 0x12;
|
||||
buf[5] = 0x40;
|
||||
buf[6] = 0x00;
|
||||
buf[7] = 0x7f;
|
||||
buf[8] = 0x00;
|
||||
buf[9] = 0x41;
|
||||
buf[10] = 0xf7;
|
||||
PlaySysex((uint8_t *) buf, 11);
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
#include "plat-mouse.h"
|
||||
#include "win.h"
|
||||
|
||||
extern "C" int video_fullscreen;
|
||||
|
||||
extern "C" void fatal(const char *format, ...);
|
||||
extern "C" void pclog(const char *format, ...);
|
||||
|
||||
extern "C" void mouse_init();
|
||||
extern "C" void mouse_close();
|
||||
extern "C" void mouse_poll_host();
|
||||
extern "C" void mouse_get_mickeys(int *x, int *y, int *z);
|
||||
|
||||
static LPDIRECTINPUT8 lpdi;
|
||||
static LPDIRECTINPUTDEVICE8 lpdi_mouse = NULL;
|
||||
static DIMOUSESTATE mousestate;
|
||||
static int mouse_x = 0, mouse_y = 0, mouse_z = 0;
|
||||
int mouse_buttons = 0;
|
||||
|
||||
void mouse_init()
|
||||
{
|
||||
atexit(mouse_close);
|
||||
|
||||
if (FAILED(DirectInput8Create(hinstance, DIRECTINPUT_VERSION, IID_IDirectInput8A, (void **) &lpdi, NULL)))
|
||||
fatal("mouse_init : DirectInputCreate failed\n");
|
||||
if (FAILED(lpdi->CreateDevice(GUID_SysMouse, &lpdi_mouse, NULL)))
|
||||
fatal("mouse_init : CreateDevice failed\n");
|
||||
if (FAILED(lpdi_mouse->SetCooperativeLevel(ghwnd, DISCL_FOREGROUND | (video_fullscreen ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE))))
|
||||
fatal("mouse_init : SetCooperativeLevel failed\n");
|
||||
if (FAILED(lpdi_mouse->SetDataFormat(&c_dfDIMouse)))
|
||||
fatal("mouse_init : SetDataFormat failed\n");
|
||||
}
|
||||
|
||||
void mouse_close()
|
||||
{
|
||||
if (lpdi_mouse)
|
||||
{
|
||||
lpdi_mouse->Release();
|
||||
lpdi_mouse = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void mouse_poll_host()
|
||||
{
|
||||
if (FAILED(lpdi_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate)))
|
||||
{
|
||||
lpdi_mouse->Acquire();
|
||||
lpdi_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate);
|
||||
}
|
||||
mouse_buttons = 0;
|
||||
if (mousestate.rgbButtons[0] & 0x80)
|
||||
mouse_buttons |= 1;
|
||||
if (mousestate.rgbButtons[1] & 0x80)
|
||||
mouse_buttons |= 2;
|
||||
if (mousestate.rgbButtons[2] & 0x80)
|
||||
mouse_buttons |= 4;
|
||||
mouse_x += mousestate.lX;
|
||||
mouse_y += mousestate.lY;
|
||||
mouse_z += mousestate.lZ/120;
|
||||
if (!mousecapture && !video_fullscreen)
|
||||
mouse_x = mouse_y = mouse_buttons = 0;
|
||||
}
|
||||
|
||||
void mouse_get_mickeys(int *x, int *y, int *z)
|
||||
{
|
||||
*x = mouse_x;
|
||||
*y = mouse_y;
|
||||
*z = mouse_z;
|
||||
mouse_x = mouse_y = mouse_z = 0;
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Implementation POSIX OpenDir(3) and friends for Win32 API.
|
||||
*
|
||||
* Based on old original code @(#)dir_win32.c 1.2.0 2007/04/19
|
||||
*
|
||||
* Version: @(#)win-opendir.c 1.0.1 2017/05/12
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Copyright 1998-2007 MicroWalt Corporation
|
||||
* Copyright 2017 Fred N. van Kempen
|
||||
*/
|
||||
#define UNICODE
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ibm.h"
|
||||
#include "plat-dir.h"
|
||||
|
||||
|
||||
#ifdef UNICODE
|
||||
# define SUFFIX L"\\*"
|
||||
# define FINDATA struct _wfinddata_t
|
||||
# define FINDFIRST _wfindfirst
|
||||
# define FINDNEXT _wfindnext
|
||||
#else
|
||||
# define SUFFIX "\\*"
|
||||
# define FINDATA struct _finddata_t
|
||||
# define FINDFIRST _findfirst
|
||||
# define FINDNEXT _findnext
|
||||
#endif
|
||||
|
||||
|
||||
/* Open a directory. */
|
||||
DIR *
|
||||
#ifdef UNICODE
|
||||
opendirw(const wchar_t *name)
|
||||
#else
|
||||
opendir(const char *name)
|
||||
#endif
|
||||
{
|
||||
DIR *p;
|
||||
|
||||
/* Create a new control structure. */
|
||||
p = (DIR *) malloc(sizeof(DIR));
|
||||
if (p == NULL)
|
||||
return(NULL);
|
||||
memset(p, 0x00, sizeof(DIR));
|
||||
p->flags = (DIR_F_LOWER | DIR_F_SANE);
|
||||
p->offset = 0;
|
||||
p->sts = 0;
|
||||
|
||||
/* Create a work area. */
|
||||
p->dta = (char *)malloc(sizeof(FINDATA));
|
||||
if (p->dta == NULL) {
|
||||
free(p);
|
||||
return(NULL);
|
||||
}
|
||||
memset(p->dta, 0x00, sizeof(struct _finddata_t));
|
||||
|
||||
/* Add search filespec. */
|
||||
#ifdef UNICODE
|
||||
wcscpy(p->dir, name);
|
||||
wcscat(p->dir, SUFFIX);
|
||||
#else
|
||||
strcpy(p->dir, name);
|
||||
strcat(p->dir, SUFFIX);
|
||||
#endif
|
||||
|
||||
/* Special case: flag if we are in the root directory. */
|
||||
#ifdef UNICODE
|
||||
if (wcslen(p->dir) == 3)
|
||||
#else
|
||||
if (strlen(p->dir) == 3)
|
||||
#endif
|
||||
p->flags |= DIR_F_ISROOT;
|
||||
|
||||
/* Start the searching by doing a FindFirst. */
|
||||
p->handle = FINDFIRST(p->dir, (FINDATA *)p->dta);
|
||||
if (p->handle < 0L) {
|
||||
free(p->dta);
|
||||
free(p);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* All OK. */
|
||||
return(p);
|
||||
}
|
||||
|
||||
|
||||
/* Close an open directory. */
|
||||
int
|
||||
closedir(DIR *p)
|
||||
{
|
||||
if (p == NULL)
|
||||
return(0);
|
||||
|
||||
_findclose(p->handle);
|
||||
|
||||
if (p->dta != NULL)
|
||||
free(p->dta);
|
||||
free(p);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read the next entry from a directory.
|
||||
* Note that the DOS (FAT), Windows (FAT, FAT32) and Windows NTFS
|
||||
* file systems do not have a root directory containing the UNIX-
|
||||
* standard "." and ".." entries. Many applications do assume
|
||||
* this anyway, so we simply fake these entries.
|
||||
*/
|
||||
struct direct *
|
||||
readdir(DIR *p)
|
||||
{
|
||||
FINDATA *ffp;
|
||||
|
||||
if (p == NULL || p->sts == 1)
|
||||
return(NULL);
|
||||
|
||||
/* Format structure with current data. */
|
||||
ffp = (FINDATA *)p->dta;
|
||||
p->dent.d_ino = 1L;
|
||||
p->dent.d_off = p->offset++;
|
||||
switch(p->offset) {
|
||||
case 1: /* . */
|
||||
#ifdef UNICODE
|
||||
wcsncpy(p->dent.d_name, L".", MAXNAMLEN+1);
|
||||
#else
|
||||
strncpy(p->dent.d_name, ".", MAXNAMLEN+1);
|
||||
#endif
|
||||
p->dent.d_reclen = 1;
|
||||
break;
|
||||
|
||||
case 2: /* .. */
|
||||
#ifdef UNICODE
|
||||
wcsncpy(p->dent.d_name, L"..", MAXNAMLEN+1);
|
||||
#else
|
||||
strncpy(p->dent.d_name, "..", MAXNAMLEN+1);
|
||||
#endif
|
||||
p->dent.d_reclen = 2;
|
||||
break;
|
||||
|
||||
default: /* regular entry. */
|
||||
#ifdef UNICODE
|
||||
wcsncpy(p->dent.d_name, ffp->name, MAXNAMLEN+1);
|
||||
#else
|
||||
strncpy(p->dent.d_name, ffp->name, MAXNAMLEN+1);
|
||||
#endif
|
||||
p->dent.d_reclen = (char) wcslen(p->dent.d_name);
|
||||
}
|
||||
|
||||
/* Read next entry. */
|
||||
p->sts = 0;
|
||||
|
||||
/* Fake the "." and ".." entries here.. */
|
||||
if ((p->flags & DIR_F_ISROOT) && (p->offset <= 2))
|
||||
return(&(p->dent));
|
||||
|
||||
/* Get the next entry if we did not fake the above. */
|
||||
if (FINDNEXT(p->handle, ffp) < 0)
|
||||
p->sts = 1;
|
||||
|
||||
return(&(p->dent));
|
||||
}
|
||||
|
||||
|
||||
/* Report current position within the directory. */
|
||||
long
|
||||
telldir(DIR *p)
|
||||
{
|
||||
return(p->offset);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
seekdir(DIR *p, long newpos)
|
||||
{
|
||||
short pos;
|
||||
|
||||
/* First off, rewind to start of directory. */
|
||||
p->handle = FINDFIRST(p->dir, (FINDATA *)p->dta);
|
||||
if (p->handle < 0L) {
|
||||
p->sts = 1;
|
||||
return;
|
||||
}
|
||||
p->offset = 0;
|
||||
p->sts = 0;
|
||||
|
||||
/* If we are rewinding, that's all... */
|
||||
if (newpos == 0L) return;
|
||||
|
||||
/* Nope.. read entries until we hit the right spot. */
|
||||
pos = (short) newpos;
|
||||
while (p->offset != pos) {
|
||||
p->offset++;
|
||||
if (FINDNEXT(p->handle, (FINDATA *)p->dta) < 0) {
|
||||
p->sts = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
606
src/win-serial.c
606
src/win-serial.c
@@ -1,606 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Implementation of host serial port services for Win32.
|
||||
*
|
||||
* This code is based on a universal serial port driver for
|
||||
* Windows and UNIX systems, with support for FTDI and Prolific
|
||||
* USB ports. Support for these has been removed.
|
||||
*
|
||||
* Version: @(#)win-serial.c 1.0.2 2017/05/05
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
*/
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define BHTTY_C
|
||||
#include "plat-serial.h"
|
||||
|
||||
|
||||
extern void pclog(char *__fmt, ...);
|
||||
|
||||
|
||||
/* Set the state of a port. */
|
||||
int
|
||||
bhtty_sstate(BHTTY *pp, void *arg)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
/* Make sure we can do this. */
|
||||
if (pp == NULL || arg == NULL) {
|
||||
pclog("invalid argument\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (SetCommState(pp->handle, (DCB *)arg) == FALSE) {
|
||||
/* Mark an error. */
|
||||
pclog("%s: set state: %d\n", pp->name, GetLastError());
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* Fetch the state of a port. */
|
||||
int
|
||||
bhtty_gstate(BHTTY *pp, void *arg)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
/* Make sure we can do this. */
|
||||
if (pp == NULL || arg == NULL) {
|
||||
pclog("BHTTY: invalid argument\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (GetCommState(pp->handle, (DCB *)arg) == FALSE) {
|
||||
/* Mark an error. */
|
||||
pclog("%s: get state: %d\n", pp->name, GetLastError());
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* Enable or disable RTS/CTS mode (hardware handshaking.) */
|
||||
int
|
||||
bhtty_crtscts(BHTTY *pp, char yesno)
|
||||
{
|
||||
/* Make sure we can do this. */
|
||||
if (pp == NULL) {
|
||||
pclog("invalid handle\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Get the current mode. */
|
||||
if (bhtty_gstate(pp, &pp->dcb) < 0) return(-1);
|
||||
|
||||
switch(yesno) {
|
||||
case 0: /* disable CRTSCTS */
|
||||
pp->dcb.fOutxDsrFlow = 0; /* disable DSR/DCD mode */
|
||||
pp->dcb.fDsrSensitivity = 0;
|
||||
|
||||
pp->dcb.fOutxCtsFlow = 0; /* disable RTS/CTS mode */
|
||||
|
||||
pp->dcb.fTXContinueOnXoff = 0; /* disable XON/XOFF mode */
|
||||
pp->dcb.fOutX = 0;
|
||||
pp->dcb.fInX = 0;
|
||||
break;
|
||||
|
||||
case 1: /* enable CRTSCTS */
|
||||
pp->dcb.fOutxDsrFlow = 0; /* disable DSR/DCD mode */
|
||||
pp->dcb.fDsrSensitivity = 0;
|
||||
|
||||
pp->dcb.fOutxCtsFlow = 1; /* enable RTS/CTS mode */
|
||||
|
||||
pp->dcb.fTXContinueOnXoff = 0; /* disable XON/XOFF mode */
|
||||
pp->dcb.fOutX = 0;
|
||||
pp->dcb.fInX = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
pclog("%s: invalid parameter '%d'!\n", pp->name, yesno);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Set new mode. */
|
||||
if (bhtty_sstate(pp, &pp->dcb) < 0) return(-1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* Set the port parameters. */
|
||||
int
|
||||
bhtty_params(BHTTY *pp, char dbit, char par, char sbit)
|
||||
{
|
||||
/* Make sure we can do this. */
|
||||
if (pp == NULL) {
|
||||
pclog("invalid handle\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Get the current mode. */
|
||||
if (bhtty_gstate(pp, &pp->dcb) < 0) return(-1);
|
||||
|
||||
/* Set the desired word length. */
|
||||
switch((int)dbit) {
|
||||
case -1: /* no change */
|
||||
break;
|
||||
|
||||
case 5: /* FTDI doesnt like these */
|
||||
case 6:
|
||||
case 9:
|
||||
break;
|
||||
|
||||
case 7:
|
||||
case 8:
|
||||
pp->dcb.ByteSize = dbit;
|
||||
break;
|
||||
|
||||
default:
|
||||
pclog("%s: invalid parameter '%d'!\n", pp->name, dbit);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Set the type of parity encoding. */
|
||||
switch((int)par) {
|
||||
case -1: /* no change */
|
||||
case ' ':
|
||||
break;
|
||||
|
||||
case 0:
|
||||
case 'N':
|
||||
pp->dcb.fParity = FALSE;
|
||||
pp->dcb.Parity = NOPARITY;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case 'O':
|
||||
pp->dcb.fParity = TRUE;
|
||||
pp->dcb.Parity = ODDPARITY;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 'E':
|
||||
pp->dcb.fParity = TRUE;
|
||||
pp->dcb.Parity = EVENPARITY;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case 'M':
|
||||
case 4:
|
||||
case 'S':
|
||||
break;
|
||||
|
||||
default:
|
||||
pclog("%s: invalid parameter '%c'!\n", pp->name, par);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Set the number of stop bits. */
|
||||
switch((int)sbit) {
|
||||
case -1: /* no change */
|
||||
break;
|
||||
|
||||
case 1:
|
||||
pp->dcb.StopBits = ONESTOPBIT;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
pp->dcb.StopBits = TWOSTOPBITS;
|
||||
break;
|
||||
|
||||
default:
|
||||
pclog("%s: invalid parameter '%d'!\n", pp->name, sbit);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Set new mode. */
|
||||
if (bhtty_sstate(pp, &pp->dcb) < 0) return(-1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* Put a port in transparent ("raw") state. */
|
||||
void
|
||||
bhtty_raw(BHTTY *pp, void *arg)
|
||||
{
|
||||
DCB *dcb = (DCB *)arg;
|
||||
|
||||
/* Make sure we can do this. */
|
||||
if (pp == NULL || arg == NULL) {
|
||||
pclog("invalid parameter\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Enable BINARY transparent mode. */
|
||||
dcb->fBinary = 1;
|
||||
dcb->fErrorChar = 0; /* disable Error Replacement */
|
||||
dcb->fNull = 0; /* disable NUL stripping */
|
||||
|
||||
/* Disable the DTR and RTS lines. */
|
||||
dcb->fDtrControl = DTR_CONTROL_DISABLE; /* DTR line */
|
||||
dcb->fRtsControl = RTS_CONTROL_DISABLE; /* RTS line */
|
||||
|
||||
/* Disable DSR/DCD handshaking. */
|
||||
dcb->fOutxDsrFlow = 0; /* DSR handshaking */
|
||||
dcb->fDsrSensitivity = 0; /* DSR Sensitivity */
|
||||
|
||||
/* Disable RTS/CTS handshaking. */
|
||||
dcb->fOutxCtsFlow = 0; /* CTS handshaking */
|
||||
|
||||
/* Disable XON/XOFF handshaking. */
|
||||
dcb->fTXContinueOnXoff = 0; /* continue TX after Xoff */
|
||||
dcb->fOutX = 0; /* enable output X-ON/X-OFF */
|
||||
dcb->fInX = 0; /* enable input X-ON/X-OFF */
|
||||
dcb->XonChar = 0x11; /* ASCII XON */
|
||||
dcb->XoffChar = 0x13; /* ASCII XOFF */
|
||||
dcb->XonLim = 100;
|
||||
dcb->XoffLim = 100;
|
||||
|
||||
dcb->fParity = FALSE;
|
||||
dcb->Parity = NOPARITY;
|
||||
dcb->StopBits = ONESTOPBIT;
|
||||
dcb->BaudRate = CBR_1200;
|
||||
}
|
||||
|
||||
|
||||
/* Set the port speed. */
|
||||
int
|
||||
bhtty_speed(BHTTY *pp, long speed)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Make sure we can do this. */
|
||||
if (pp == NULL) {
|
||||
pclog("invalid handle\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Get the current mode and speed. */
|
||||
if (bhtty_gstate(pp, &pp->dcb) < 0) return(-1);
|
||||
|
||||
/*
|
||||
* Set speed.
|
||||
*
|
||||
* This is not entirely correct, we should use a table
|
||||
* with DCB_xxx speed values here, but we removed that
|
||||
* and just hardcode the speed value into DCB. --FvK
|
||||
*/
|
||||
pp->dcb.BaudRate = speed;
|
||||
|
||||
/* Set new speed. */
|
||||
if (bhtty_sstate(pp, &pp->dcb) < 0) return(-1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* Clean up and flush. */
|
||||
int
|
||||
bhtty_flush(BHTTY *pp)
|
||||
{
|
||||
DWORD dwErrs;
|
||||
COMSTAT cs;
|
||||
int i = 0;
|
||||
|
||||
/* Make sure we can do this. */
|
||||
if (pp == NULL) {
|
||||
pclog("invalid handle\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* First, clear any errors. */
|
||||
(void)ClearCommError(pp->handle, &dwErrs, &cs);
|
||||
|
||||
/* Now flush all buffers. */
|
||||
if (PurgeComm(pp->handle,
|
||||
(PURGE_RXABORT | PURGE_TXABORT | \
|
||||
PURGE_RXCLEAR | PURGE_TXCLEAR)) == FALSE) {
|
||||
pclog("%s: flush: %d\n", pp->name, GetLastError());
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Re-clear any errors. */
|
||||
if (ClearCommError(pp->handle, &dwErrs, &cs) == FALSE) {
|
||||
pclog("%s: clear errors: %d\n", pp->name, GetLastError());
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* Close an open serial port. */
|
||||
void
|
||||
bhtty_close(BHTTY *pp)
|
||||
{
|
||||
/* Make sure we can do this. */
|
||||
if (pp == NULL) {
|
||||
pclog("BHTTY: invalid handle\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pp->handle != INVALID_HANDLE_VALUE) {
|
||||
/* Restore the previous port state, if any. */
|
||||
(void)bhtty_sstate(pp, &pp->odcb);
|
||||
|
||||
/* Close the port. */
|
||||
CloseHandle(pp->handle);
|
||||
pp->handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
/* Release the control block. */
|
||||
free(pp);
|
||||
}
|
||||
|
||||
|
||||
/* Open a host serial port for I/O. */
|
||||
BHTTY *
|
||||
bhtty_open(char *port, int tmo)
|
||||
{
|
||||
char buff[64];
|
||||
COMMTIMEOUTS to;
|
||||
#if 0
|
||||
COMMCONFIG conf;
|
||||
DWORD d;
|
||||
#endif
|
||||
BHTTY *pp;
|
||||
int i = 0;
|
||||
|
||||
/* Make sure we can do this. */
|
||||
if (port == NULL) {
|
||||
pclog("invalid argument!\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* First things first... create a control block. */
|
||||
if ((pp = (BHTTY *)malloc(sizeof(BHTTY))) == NULL) {
|
||||
pclog("%s: out of memory!\n", port);
|
||||
return(NULL);
|
||||
}
|
||||
memset(pp, 0x00, sizeof(BHTTY));
|
||||
strncpy(pp->name, port, sizeof(pp->name)-1);
|
||||
|
||||
/* Try a regular Win32 serial port. */
|
||||
sprintf(buff, "\\\\.\\%s", pp->name);
|
||||
pp->handle = CreateFile(buff,
|
||||
(GENERIC_READ|GENERIC_WRITE),
|
||||
0, NULL, OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
0);
|
||||
if (pp->handle == INVALID_HANDLE_VALUE) {
|
||||
pclog("%s: open port: %d\n", pp->name, GetLastError());
|
||||
free(pp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Set up buffer size of the port. */
|
||||
if (SetupComm(pp->handle, 32768L, 32768L) == FALSE) {
|
||||
/* This fails on FTDI-based devices. */
|
||||
pclog("%s: set buffers: %d\n", pp->name, GetLastError());
|
||||
// CloseHandle(pp->handle);
|
||||
// free(pp);
|
||||
// return(NULL);
|
||||
}
|
||||
|
||||
/* Grab default config for the driver and set it. */
|
||||
d = sizeof(COMMCONFIG);
|
||||
memset(&conf, 0x00, d);
|
||||
conf.dwSize = d;
|
||||
if (GetDefaultCommConfig(pp->name, &conf, &d) == TRUE) {
|
||||
/* Change config here... */
|
||||
|
||||
/* Set new configuration. */
|
||||
if (SetCommConfig(pp->handle, &conf, d) == FALSE) {
|
||||
/* This fails on FTDI-based devices. */
|
||||
pclog("%s: set configuration: %d\n", pp->name, GetLastError());
|
||||
// CloseHandle(pp->handle);
|
||||
// free(pp);
|
||||
// return(NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We now have an open port. To allow for clean exit
|
||||
* of the application, we first retrieve the port's
|
||||
* current settings, and save these for later.
|
||||
*/
|
||||
if (bhtty_gstate(pp, &pp->odcb) < 0) {
|
||||
(void)bhtty_close(pp);
|
||||
return(NULL);
|
||||
}
|
||||
memcpy(&pp->dcb, &pp->odcb, sizeof(DCB));
|
||||
|
||||
/* Force the port to BINARY mode. */
|
||||
bhtty_raw(pp, &pp->dcb);
|
||||
|
||||
/* Set new state of this port. */
|
||||
if (bhtty_sstate(pp, &pp->dcb) < 0) {
|
||||
(void)bhtty_close(pp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Just to make sure.. disable RTS/CTS mode. */
|
||||
(void)bhtty_crtscts(pp, 0);
|
||||
|
||||
/* Set new timeout values. */
|
||||
if (GetCommTimeouts(pp->handle, &to) == FALSE) {
|
||||
pclog("%s: error %d while getting current TO\n",
|
||||
pp->name, GetLastError());
|
||||
(void)bhtty_close(pp);
|
||||
return(NULL);
|
||||
}
|
||||
if (tmo < 0) {
|
||||
/* No timeout, immediate return. */
|
||||
to.ReadIntervalTimeout = MAXDWORD;
|
||||
to.ReadTotalTimeoutMultiplier = 0;
|
||||
to.ReadTotalTimeoutConstant = 0;
|
||||
} else if (tmo == 0) {
|
||||
/* No timeout, wait for data. */
|
||||
memset(&to, 0x00, sizeof(to));
|
||||
} else {
|
||||
/* Timeout specified. */
|
||||
to.ReadIntervalTimeout = MAXDWORD;
|
||||
to.ReadTotalTimeoutMultiplier = MAXDWORD;
|
||||
to.ReadTotalTimeoutConstant = tmo;
|
||||
}
|
||||
if (SetCommTimeouts(pp->handle, &to) == FALSE) {
|
||||
pclog("%s: error %d while setting TO\n",
|
||||
pp->name, GetLastError());
|
||||
(void)bhtty_close(pp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Clear all errors and flush all buffers. */
|
||||
if (bhtty_flush(pp) < 0) {
|
||||
(void)bhtty_close(pp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
return(pp);
|
||||
}
|
||||
|
||||
|
||||
/* A pending WRITE has finished, handle it. */
|
||||
static VOID CALLBACK
|
||||
bhtty_write_comp(DWORD err, DWORD num, OVERLAPPED *priv)
|
||||
{
|
||||
BHTTY *pp = (BHTTY *)priv->hEvent;
|
||||
|
||||
//pclog("%s: write complete, status %d, num %d\n", pp->name, err, num);
|
||||
#if 0
|
||||
if (
|
||||
if (GetOverlappedResult(p->handle,
|
||||
&p->rov, &mst, TRUE) == FALSE) {
|
||||
r = GetLastError();
|
||||
if (r != ERROR_OPERATION_ABORTED)
|
||||
/* OK, we're being shut down. */
|
||||
sprintf(serial_errmsg,
|
||||
"%s: I/O read error!", p->name);
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Try to write data to an open port. */
|
||||
int
|
||||
bhtty_write(BHTTY *pp, unsigned char val)
|
||||
{
|
||||
DWORD n;
|
||||
|
||||
/* Make sure we can do this. */
|
||||
if (pp == NULL) {
|
||||
pclog("invalid parameter\n");
|
||||
return(-1);
|
||||
}
|
||||
//pclog("BHwrite(%08lx, %02x, '%c')\n", pp->handle, val, val);
|
||||
|
||||
/* Save the control pointer for later use. */
|
||||
pp->wov.hEvent = (HANDLE)pp;
|
||||
|
||||
if (WriteFileEx(pp->handle,
|
||||
&val, 1,
|
||||
&pp->wov,
|
||||
bhtty_write_comp) == FALSE) {
|
||||
n = GetLastError();
|
||||
pclog("%s: I/O error %d in write!\n", pp->name, n);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Its pending, so handled in the completion routine. */
|
||||
SleepEx(1, TRUE);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* A pending READ has finished, handle it.
|
||||
*/
|
||||
static VOID CALLBACK
|
||||
bhtty_read_comp(DWORD err, DWORD num, OVERLAPPED *priv)
|
||||
{
|
||||
BHTTY *pp = (BHTTY *)priv->hEvent;
|
||||
DWORD r;
|
||||
//pclog("%s: read complete, status %d, num %d\n", pp->name, err, num);
|
||||
|
||||
if (GetOverlappedResult(pp->handle, &pp->rov, &r, TRUE) == FALSE) {
|
||||
r = GetLastError();
|
||||
if (r != ERROR_OPERATION_ABORTED)
|
||||
/* OK, we're being shut down. */
|
||||
pclog("%s: I/O read error!", pp->name);
|
||||
return;
|
||||
}
|
||||
//pclog("%s: read done, num=%d (%d)\n", pp->name, num, r);
|
||||
|
||||
/* Do a callback to let them know. */
|
||||
if (pp->rd_done != NULL)
|
||||
pp->rd_done(pp->rd_arg, num);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Try to read data from an open port.
|
||||
*
|
||||
* For now, we will use one byte per call. Eventually,
|
||||
* we should go back to loading a buffer full of data,
|
||||
* just to speed things up a bit. --FvK
|
||||
*
|
||||
* Also, not that we do not wait here. We just POST a
|
||||
* read operation, and the completion routine will do
|
||||
* the clean-up and notify the caller.
|
||||
*/
|
||||
int
|
||||
bhtty_read(BHTTY *pp, unsigned char *bufp, int max)
|
||||
{
|
||||
DWORD r;
|
||||
|
||||
/* Just one byte. */
|
||||
max = 1;
|
||||
|
||||
/* Make sure we can do this. */
|
||||
if (pp == NULL) {
|
||||
pclog("invalid parameter\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Save the control pointer for later use. */
|
||||
pp->rov.hEvent = (HANDLE)pp;
|
||||
//pclog("%s: read(%08lx, %d)\n", pp->name, pp->handle, max);
|
||||
|
||||
/* Post a READ on the device. */
|
||||
if (ReadFileEx(pp->handle,
|
||||
bufp, (DWORD)max,
|
||||
&pp->rov,
|
||||
bhtty_read_comp) == FALSE) {
|
||||
r = GetLastError();
|
||||
if (r != ERROR_IO_PENDING) {
|
||||
/* OK, we're being shut down. */
|
||||
if (r != ERROR_INVALID_HANDLE)
|
||||
pclog("%s: I/O read error!\n", pp->name);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Make ourself alertable. */
|
||||
SleepEx(1, TRUE);
|
||||
|
||||
/* OK, it's pending, so we are good for now. */
|
||||
return(0);
|
||||
}
|
||||
3674
src/win-settings.c
3674
src/win-settings.c
File diff suppressed because it is too large
Load Diff
@@ -1,95 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#undef BITMAP
|
||||
|
||||
#include "ibm.h"
|
||||
#include "mem.h"
|
||||
#include "cpu/x86_ops.h"
|
||||
#include "cpu/codegen.h"
|
||||
#include "device.h"
|
||||
#include "resource.h"
|
||||
#include "win.h"
|
||||
|
||||
|
||||
HWND status_hwnd;
|
||||
int status_is_open = 0;
|
||||
|
||||
|
||||
extern int sreadlnum, swritelnum, segareads, segawrites, scycles_lost;
|
||||
|
||||
extern uint64_t main_time;
|
||||
static uint64_t status_time;
|
||||
|
||||
|
||||
static BOOL CALLBACK status_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
char device_s[4096];
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
status_is_open = 1;
|
||||
case WM_USER:
|
||||
{
|
||||
uint64_t new_time = timer_read();
|
||||
uint64_t status_diff = new_time - status_time;
|
||||
status_time = new_time;
|
||||
sprintf(device_s,
|
||||
"CPU speed : %f MIPS\n"
|
||||
"FPU speed : %f MFLOPS\n\n"
|
||||
|
||||
"Video throughput (read) : %i bytes/sec\n"
|
||||
"Video throughput (write) : %i bytes/sec\n\n"
|
||||
"Effective clockspeed : %iHz\n\n"
|
||||
"Timer 0 frequency : %fHz\n\n"
|
||||
"CPU time : %f%% (%f%%)\n"
|
||||
|
||||
"New blocks : %i\nOld blocks : %i\nRecompiled speed : %f MIPS\nAverage size : %f\n"
|
||||
"Flushes : %i\nEvicted : %i\nReused : %i\nRemoved : %i\nReal speed : %f MIPS"
|
||||
,mips,
|
||||
flops,
|
||||
segareads,
|
||||
segawrites,
|
||||
clockrate - scycles_lost,
|
||||
pit_timer0_freq(),
|
||||
((double)main_time * 100.0) / status_diff,
|
||||
((double)main_time * 100.0) / timer_freq
|
||||
|
||||
, cpu_new_blocks_latched, cpu_recomp_blocks_latched, (double)cpu_recomp_ins_latched / 1000000.0, (double)cpu_recomp_ins_latched/cpu_recomp_blocks_latched,
|
||||
cpu_recomp_flushes_latched, cpu_recomp_evicted_latched,
|
||||
cpu_recomp_reuse_latched, cpu_recomp_removed_latched,
|
||||
|
||||
((double)cpu_recomp_ins_latched / 1000000.0) / ((double)main_time / timer_freq)
|
||||
);
|
||||
main_time = 0;
|
||||
SendDlgItemMessage(hdlg, IDC_STEXT_DEVICE, WM_SETTEXT, (WPARAM)NULL, (LPARAM)device_s);
|
||||
|
||||
device_s[0] = 0;
|
||||
device_add_status_info(device_s, 4096);
|
||||
SendDlgItemMessage(hdlg, IDC_STEXT1, WM_SETTEXT, (WPARAM)NULL, (LPARAM)device_s);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
status_is_open = 0;
|
||||
EndDialog(hdlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void status_open(HWND hwnd)
|
||||
{
|
||||
status_hwnd = CreateDialog(hinstance, TEXT("StatusDlg"), hwnd, status_dlgproc);
|
||||
ShowWindow(status_hwnd, SW_SHOW);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "video/video.h"
|
||||
#include "win-cgapal.h"
|
||||
|
||||
|
||||
BITMAP *screen;
|
||||
|
||||
|
||||
void hline(BITMAP *b, int x1, int y, int x2, uint32_t col)
|
||||
{
|
||||
if (y < 0 || y >= buffer->h)
|
||||
return;
|
||||
|
||||
if (b == buffer)
|
||||
memset(&b->line[y][x1], col, x2 - x1);
|
||||
else
|
||||
memset(&((uint32_t *)b->line[y])[x1], col, (x2 - x1) * 4);
|
||||
}
|
||||
|
||||
void blit(BITMAP *src, BITMAP *dst, int x1, int y1, int x2, int y2, int xs, int ys)
|
||||
{
|
||||
}
|
||||
|
||||
void stretch_blit(BITMAP *src, BITMAP *dst, int x1, int y1, int xs1, int ys1, int x2, int y2, int xs2, int ys2)
|
||||
{
|
||||
}
|
||||
|
||||
void rectfill(BITMAP *b, int x1, int y1, int x2, int y2, uint32_t col)
|
||||
{
|
||||
}
|
||||
|
||||
void set_palette(PALETTE p)
|
||||
{
|
||||
}
|
||||
|
||||
void destroy_bitmap(BITMAP *b)
|
||||
{
|
||||
}
|
||||
|
||||
BITMAP *create_bitmap(int x, int y)
|
||||
{
|
||||
BITMAP *b = malloc(sizeof(BITMAP) + (y * sizeof(uint8_t *)));
|
||||
int c;
|
||||
b->dat = malloc(x * y * 4);
|
||||
for (c = 0; c < y; c++)
|
||||
{
|
||||
b->line[c] = b->dat + (c * x * 4);
|
||||
}
|
||||
b->w = x;
|
||||
b->h = y;
|
||||
return b;
|
||||
}
|
||||
51
src/win.h
51
src/win.h
@@ -1,51 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
extern HINSTANCE hinstance;
|
||||
extern HWND ghwnd;
|
||||
extern int mousecapture;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define szClassName L"86BoxMainWnd"
|
||||
#define szSubClassName L"86BoxSubWnd"
|
||||
#define szStatusBarClassName L"86BoxStatusBar"
|
||||
|
||||
void leave_fullscreen();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void status_open(HWND hwnd);
|
||||
extern HWND status_hwnd;
|
||||
extern int status_is_open;
|
||||
|
||||
void deviceconfig_open(HWND hwnd, struct device_t *device);
|
||||
void joystickconfig_open(HWND hwnd, int joy_nr, int type);
|
||||
|
||||
extern char openfilestring[260];
|
||||
extern WCHAR wopenfilestring[260];
|
||||
|
||||
int getfile(HWND hwnd, char *f, char *fn);
|
||||
int getsfile(HWND hwnd, char *f, char *fn);
|
||||
|
||||
void get_executable_name(WCHAR *s, int size);
|
||||
void set_window_title(WCHAR *s);
|
||||
|
||||
void startblit();
|
||||
void endblit();
|
||||
|
||||
extern int pause;
|
||||
|
||||
void win_settings_open(HWND hwnd);
|
||||
void win_menu_update();
|
||||
|
||||
void update_status_bar_panes(HWND hwnds);
|
||||
|
||||
int fdd_type_to_icon(int type);
|
||||
|
||||
extern HWND hwndStatus;
|
||||
Reference in New Issue
Block a user