Merge remote-tracking branch 'origin/master' into netlist_dev

This commit is contained in:
couriersud 2016-06-15 20:11:09 +02:00
commit b961ab0bae
66 changed files with 2699 additions and 2808 deletions

53
hash/pofo.xml Normal file
View File

@ -0,0 +1,53 @@
<?xml version="1.0"?>
<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
<softwarelist name="pofo" description="Atari Portfolio cartridges">
<!--
Undumped Atari cartridges:
Utility-Card HPC-701
Finance-Card HPC-702
Science-Card HPC-703
File Manager / Tutorial HPC-704
PowerBASIC HPC-705
Instant Spell HPC-709
Hyperlist HPC-713
Bridge Baron HPC-724
Wine Companion HPC-725
Diet / Cholesterol Counter HPC-726
Astrologer HPC-728
Stock Tracker HPC-729
Chess HPC-750
Undumped 3rd party cartridges:
Adcalc AAC-1000
Alpha Paging Interface SAMpage
Business Contacts and Information Manager BCIM
Checkwriter
Colossal Cave Adventure
Drug Interactions
Dynapulse 200M-A
Form Letters
FORTH programming system UTIL
FX-3 DUAT Flight Software
FX-4 Flight Planner
Graphics Screens
Marine Device Interface CM380 UMPIRE
Message Mover (Mac) MSG-PKG6
Message Mover (PC) MSG-PKG5
Micro Hedge
Micro-Roentgen Radiation Monitor RM-60
Patient Management
PBase
PDD2 Utilities
Pharmaceuticals
Physician's Reference I
PIPELINE Fuel Management
REACT
Stocks Games
Terminal+
Timekeeper
TIMEPAC-5
-->
</softwarelist>

View File

@ -705,7 +705,7 @@ end
-- this speeds it up a bit by piping between the preprocessor/compiler/assembler
if not ("pnacl" == _OPTIONS["gcc"]) then
buildoptions {
"--pipe",
"-pipe",
}
end
-- add -g if we need symbols, and ensure we have frame pointers

View File

@ -1090,6 +1090,23 @@ if (BUSES["PLUS4"]~=null) then
end
---------------------------------------------------
--
--@src/devices/bus/pofo/exp.h,BUSES["POFO"] = true
---------------------------------------------------
if (BUSES["POFO"]~=null) then
files {
MAME_DIR .. "src/devices/bus/pofo/exp.cpp",
MAME_DIR .. "src/devices/bus/pofo/exp.h",
MAME_DIR .. "src/devices/bus/pofo/hpc101.cpp",
MAME_DIR .. "src/devices/bus/pofo/hpc101.h",
MAME_DIR .. "src/devices/bus/pofo/hpc102.cpp",
MAME_DIR .. "src/devices/bus/pofo/hpc102.h",
}
end
---------------------------------------------------
--
--@src/devices/bus/s100/s100.h,BUSES["S100"] = true

View File

@ -154,8 +154,6 @@ project ("osd_" .. _OPTIONS["osd"])
}
files {
MAME_DIR .. "src/osd/modules/render/d3d/d3d9intf.cpp",
MAME_DIR .. "src/osd/modules/render/d3d/d3dintf.h",
MAME_DIR .. "src/osd/modules/render/d3d/d3dhlsl.cpp",
MAME_DIR .. "src/osd/modules/render/d3d/d3dcomm.h",
MAME_DIR .. "src/osd/modules/render/d3d/d3dhlsl.h",

View File

@ -655,6 +655,7 @@ BUSES["PC_JOY"] = true
BUSES["PC_KBD"] = true
BUSES["PET"] = true
BUSES["PLUS4"] = true
BUSES["POFO"] = true
BUSES["PSX_CONTROLLER"] = true
BUSES["QL"] = true
BUSES["RS232"] = true
@ -1306,8 +1307,7 @@ files {
MAME_DIR .. "src/mame/audio/lynx.cpp",
MAME_DIR .. "src/mame/audio/lynx.h",
MAME_DIR .. "src/mame/machine/lynx.cpp",
MAME_DIR .. "src/mame/drivers/portfoli.cpp",
MAME_DIR .. "src/mame/includes/portfoli.h",
MAME_DIR .. "src/mame/drivers/pofo.cpp",
}
createMESSProjects(_target, _subtarget, "att")

View File

@ -109,7 +109,7 @@ ROM_START( luxor_55_21046 )
ROM_REGION( 0x4000, Z80_TAG, 0 )
ROM_DEFAULT_BIOS( "v107" )
ROM_SYSTEM_BIOS( 0, "v105", "Luxor v1.05 (1984-10-04)" )
ROMX_LOAD( "cntr 105.6cd", 0x0000, 0x4000, CRC(44043025) SHA1(17487ca35b399bb49d4015bbeede0809db8e772f), ROM_BIOS(1) )
ROMX_LOAD( "cntr 105.6cd", 0x2000, 0x2000, CRC(44043025) SHA1(17487ca35b399bb49d4015bbeede0809db8e772f), ROM_BIOS(1) )
ROM_SYSTEM_BIOS( 1, "v107", "Luxor v1.07 (1985-07-03)" )
ROMX_LOAD( "cntr 1.07 6490318-07.6cd", 0x0000, 0x4000, CRC(db8c1c0e) SHA1(8bccd5bc72124984de529ee058df779f06d2c1d5), ROM_BIOS(2) )
ROM_SYSTEM_BIOS( 2, "v108", "Luxor v1.08 (1986-03-12)" )

View File

@ -0,0 +1,103 @@
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
Atari Portfolio Expansion Port emulation
**********************************************************************/
#include "exp.h"
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
const device_type PORTFOLIO_EXPANSION_SLOT = &device_creator<portfolio_expansion_slot_t>;
//**************************************************************************
// CARD INTERFACE
//**************************************************************************
//-------------------------------------------------
// device_portfolio_expansion_slot_interface - constructor
//-------------------------------------------------
device_portfolio_expansion_slot_interface::device_portfolio_expansion_slot_interface(const machine_config &mconfig, device_t &device) :
device_slot_card_interface(mconfig,device)
{
m_slot = dynamic_cast<portfolio_expansion_slot_t *>(device.owner());
}
WRITE_LINE_MEMBER( device_portfolio_expansion_slot_interface::iint_w ) { m_slot->iint_w(state); }
WRITE_LINE_MEMBER( device_portfolio_expansion_slot_interface::eint_w ) { m_slot->eint_w(state); }
WRITE_LINE_MEMBER( device_portfolio_expansion_slot_interface::nmio_w ) { m_slot->nmio_w(state); }
WRITE_LINE_MEMBER( device_portfolio_expansion_slot_interface::wake_w ) { m_slot->wake_w(state); }
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// portfolio_expansion_slot_t - constructor
//-------------------------------------------------
portfolio_expansion_slot_t::portfolio_expansion_slot_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, PORTFOLIO_EXPANSION_SLOT, "Atari Portfolio expansion port", tag, owner, clock, "portfolio_expansion_slot", __FILE__),
device_slot_interface(mconfig, *this),
m_write_iint(*this),
m_write_eint(*this),
m_write_nmio(*this),
m_write_wake(*this),
m_card(nullptr)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void portfolio_expansion_slot_t::device_start()
{
m_card = dynamic_cast<device_portfolio_expansion_slot_interface *>(get_card_device());
// resolve callbacks
m_write_iint.resolve_safe();
m_write_eint.resolve_safe();
m_write_nmio.resolve_safe();
m_write_wake.resolve_safe();
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void portfolio_expansion_slot_t::device_reset()
{
if (m_card != nullptr)
{
m_card->device().reset();
}
}
//-------------------------------------------------
// SLOT_INTERFACE( portfolio_expansion_cards )
//-------------------------------------------------
// slot devices
#include "hpc101.h"
#include "hpc102.h"
SLOT_INTERFACE_START( portfolio_expansion_cards )
SLOT_INTERFACE("lpt", HPC101)
SLOT_INTERFACE("uart", HPC102)
SLOT_INTERFACE_END

170
src/devices/bus/pofo/exp.h Normal file
View File

@ -0,0 +1,170 @@
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
Atari Portfolio Expansion Port emulation
**********************************************************************
ABUF 1 2 5VS
REDY 3 4 VCC
BCOM 5 6 NCC1
NMD1 7 8 WAKE
DTR 9 10 DEN
PDET 11 12 IINT
CCLK 13 14 MRST
HLDA 15 16 HLDO
IACK 17 18 CDET
IOM 19 20 A19
A18 21 22 A17
A16 23 24 A15
A14 25 26 A13
A12 27 28 A11
A10 29 30 A9
A8 31 32 VRAM
HLDI 33 34 ALE
GND 35 36 NMIO
OA7 37 38 OA6
OA5 39 40 OA4
OA3 41 42 OA2
OA1 43 44 OA0
AD0 45 46 AD1
AD2 47 48 AD3
AD4 49 50 AD5
AD6 51 52 AD7
EINT 53 54 NRDI
VEXT 55 56 EACK
BATD 57 58 NWRI
5VS 59 60 BBUF
**********************************************************************/
#pragma once
#ifndef __PORTFOLIO_EXPANSION_SLOT__
#define __PORTFOLIO_EXPANSION_SLOT__
#include "emu.h"
//**************************************************************************
// CONSTANTS
//**************************************************************************
#define PORTFOLIO_EXPANSION_SLOT_TAG "exp"
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_PORTFOLIO_EXPANSION_SLOT_ADD(_tag, _clock, _slot_intf, _def_slot) \
MCFG_DEVICE_ADD(_tag, PORTFOLIO_EXPANSION_SLOT, _clock) \
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
#define MCFG_PORTFOLIO_EXPANSION_SLOT_IINT_CALLBACK(_write) \
devcb = &portfolio_expansion_slot_t::set_iint_wr_callback(*device, DEVCB_##_write);
#define MCFG_PORTFOLIO_EXPANSION_SLOT_EINT_CALLBACK(_write) \
devcb = &portfolio_expansion_slot_t::set_eint_wr_callback(*device, DEVCB_##_write);
#define MCFG_PORTFOLIO_EXPANSION_SLOT_NMIO_CALLBACK(_write) \
devcb = &portfolio_expansion_slot_t::set_nmio_wr_callback(*device, DEVCB_##_write);
#define MCFG_PORTFOLIO_EXPANSION_SLOT_WAKE_CALLBACK(_write) \
devcb = &portfolio_expansion_slot_t::set_wake_wr_callback(*device, DEVCB_##_write);
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> device_portfolio_expansion_slot_interface
class portfolio_expansion_slot_t;
class device_portfolio_expansion_slot_interface : public device_slot_card_interface
{
public:
// construction/destruction
device_portfolio_expansion_slot_interface(const machine_config &mconfig, device_t &device);
virtual ~device_portfolio_expansion_slot_interface() { }
virtual bool nmd1() { return 1; }
virtual bool pdet() { return 0; }
virtual bool cdet() { return 1; }
virtual UINT8 iack_r() { return 0xff; }
virtual UINT8 eack_r() { return 0xff; }
virtual UINT8 nrdi_r(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1) { return data; };
virtual void nwri_w(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1) { };
DECLARE_WRITE_LINE_MEMBER( iint_w );
DECLARE_WRITE_LINE_MEMBER( eint_w );
DECLARE_WRITE_LINE_MEMBER( nmio_w );
DECLARE_WRITE_LINE_MEMBER( wake_w );
protected:
portfolio_expansion_slot_t *m_slot;
};
// ======================> portfolio_expansion_slot_t
class portfolio_expansion_slot_t : public device_t,
public device_slot_interface
{
public:
// construction/destruction
portfolio_expansion_slot_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
virtual ~portfolio_expansion_slot_t() { }
template<class _Object> static devcb_base &set_iint_wr_callback(device_t &device, _Object object) { return downcast<portfolio_expansion_slot_t &>(device).m_write_iint.set_callback(object); }
template<class _Object> static devcb_base &set_eint_wr_callback(device_t &device, _Object object) { return downcast<portfolio_expansion_slot_t &>(device).m_write_eint.set_callback(object); }
template<class _Object> static devcb_base &set_nmio_wr_callback(device_t &device, _Object object) { return downcast<portfolio_expansion_slot_t &>(device).m_write_nmio.set_callback(object); }
template<class _Object> static devcb_base &set_wake_wr_callback(device_t &device, _Object object) { return downcast<portfolio_expansion_slot_t &>(device).m_write_wake.set_callback(object); }
// computer interface
bool nmd1_r() { return (m_card != nullptr) ? m_card->nmd1() : 1; }
bool pdet_r() { return (m_card != nullptr) ? m_card->pdet() : 0; }
bool cdet_r() { return (m_card != nullptr) ? m_card->cdet() : 1; }
UINT8 iack_r() { return (m_card != nullptr) ? m_card->iack_r() : 0xff; };
UINT8 eack_r() { return (m_card != nullptr) ? m_card->eack_r() : 0xff; };
UINT8 nrdi_r(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1) { return (m_card != nullptr) ? m_card->nrdi_r(space, offset, data, iom, bcom, ncc1) : data; }
void nwri_w(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1) { if (m_card != nullptr) m_card->nwri_w(space, offset, data, iom, bcom, ncc1); }
// peripheral interface
WRITE_LINE_MEMBER( iint_w ) { m_write_iint(state); }
WRITE_LINE_MEMBER( eint_w ) { m_write_eint(state); }
WRITE_LINE_MEMBER( nmio_w ) { m_write_nmio(state); }
WRITE_LINE_MEMBER( wake_w ) { m_write_wake(state); }
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
devcb_write_line m_write_iint;
devcb_write_line m_write_eint;
devcb_write_line m_write_nmio;
devcb_write_line m_write_wake;
device_portfolio_expansion_slot_interface *m_card;
};
// device type definition
extern const device_type PORTFOLIO_EXPANSION_SLOT;
SLOT_INTERFACE_EXTERN( portfolio_expansion_cards );
#endif

View File

@ -0,0 +1,141 @@
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
Atari Portfolio HPC-101 parallel interface emulation
**********************************************************************/
#include "hpc101.h"
//**************************************************************************
// MACROS / CONSTANTS
//**************************************************************************
#define LOG 0
#define M82C55A_TAG "u1"
#define CENTRONICS_TAG "centronics"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
const device_type HPC101 = &device_creator<hpc101_t>;
//-------------------------------------------------
// MACHINE_CONFIG_FRAGMENT( hpc101 )
//-------------------------------------------------
static MACHINE_CONFIG_FRAGMENT( hpc101 )
MCFG_DEVICE_ADD(M82C55A_TAG, I8255A, 0)
MCFG_I8255_OUT_PORTA_CB(DEVWRITE8("cent_data_out", output_latch_device, write))
MCFG_I8255_OUT_PORTB_CB(DEVWRITE8("cent_ctrl_out", output_latch_device, write))
MCFG_I8255_IN_PORTC_CB(DEVREAD8("cent_status_in", input_buffer_device, read))
MCFG_CENTRONICS_ADD(CENTRONICS_TAG, centronics_devices, "printer")
MCFG_CENTRONICS_ACK_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit5))
MCFG_CENTRONICS_BUSY_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit4))
MCFG_CENTRONICS_FAULT_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit3))
MCFG_CENTRONICS_SELECT_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit1))
MCFG_CENTRONICS_PERROR_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit0))
MCFG_CENTRONICS_OUTPUT_LATCH_ADD("cent_data_out", CENTRONICS_TAG)
MCFG_DEVICE_ADD("cent_status_in", INPUT_BUFFER, 0)
MCFG_DEVICE_ADD("cent_ctrl_out", OUTPUT_LATCH, 0)
MCFG_OUTPUT_LATCH_BIT0_HANDLER(DEVWRITELINE(CENTRONICS_TAG, centronics_device, write_strobe))
MCFG_OUTPUT_LATCH_BIT1_HANDLER(DEVWRITELINE(CENTRONICS_TAG, centronics_device, write_autofd))
MCFG_OUTPUT_LATCH_BIT2_HANDLER(DEVWRITELINE(CENTRONICS_TAG, centronics_device, write_init))
MCFG_OUTPUT_LATCH_BIT3_HANDLER(DEVWRITELINE(CENTRONICS_TAG, centronics_device, write_select_in))
MACHINE_CONFIG_END
//-------------------------------------------------
// machine_config_additions - device-specific
// machine configurations
//-------------------------------------------------
machine_config_constructor hpc101_t::device_mconfig_additions() const
{
return MACHINE_CONFIG_NAME( hpc101 );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// hpc101_t - constructor
//-------------------------------------------------
hpc101_t::hpc101_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, HPC101, "Atari Portfolio HPC-101", tag, owner, clock, "hpc101", __FILE__),
device_portfolio_expansion_slot_interface(mconfig, *this),
m_ppi(*this, M82C55A_TAG)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void hpc101_t::device_start()
{
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void hpc101_t::device_reset()
{
m_ppi->reset();
}
//-------------------------------------------------
// nrdi_r - read
//-------------------------------------------------
UINT8 hpc101_t::nrdi_r(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1)
{
if (!bcom)
{
if ((offset & 0x0f) == 0x0f)
{
data = 0x02;
}
if ((offset & 0x0c) == 0x08)
{
data = m_ppi->read(space, offset & 0x03);
}
}
return data;
}
//-------------------------------------------------
// nwri_w - write
//-------------------------------------------------
void hpc101_t::nwri_w(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1)
{
if (!bcom)
{
if ((offset & 0x0c) == 0x08)
{
m_ppi->write(space, offset & 0x03, data);
}
}
}

View File

@ -0,0 +1,58 @@
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
Atari Portfolio HPC-101 parallel interface emulation
**********************************************************************/
#pragma once
#ifndef __HPC101__
#define __HPC101__
#include "emu.h"
#include "exp.h"
#include "bus/centronics/ctronics.h"
#include "machine/i8255.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> hpc101_t
class hpc101_t : public device_t,
public device_portfolio_expansion_slot_interface
{
public:
// construction/destruction
hpc101_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// optional information overrides
virtual machine_config_constructor device_mconfig_additions() const override;
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
// device_portfolio_expansion_slot_interface overrides
bool pdet() override { return 1; }
virtual UINT8 nrdi_r(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1) override;
virtual void nwri_w(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1) override;
private:
required_device<i8255_device> m_ppi;
};
// device type definition
extern const device_type HPC101;
#endif

View File

@ -0,0 +1,148 @@
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
Atari Portfolio HPC-102 serial interface emulation
**********************************************************************/
#include "hpc102.h"
//**************************************************************************
// MACROS / CONSTANTS
//**************************************************************************
#define LOG 0
#define M82C50A_TAG "u1"
#define RS232_TAG "rs232"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
const device_type HPC102 = &device_creator<hpc102_t>;
//-------------------------------------------------
// MACHINE_CONFIG_FRAGMENT( hpc102 )
//-------------------------------------------------
static MACHINE_CONFIG_FRAGMENT( hpc102 )
MCFG_DEVICE_ADD(M82C50A_TAG, INS8250, XTAL_1_8432MHz) // should be INS8250A
MCFG_INS8250_OUT_TX_CB(DEVWRITELINE(RS232_TAG, rs232_port_device, write_txd))
MCFG_INS8250_OUT_DTR_CB(DEVWRITELINE(RS232_TAG, rs232_port_device, write_dtr))
MCFG_INS8250_OUT_RTS_CB(DEVWRITELINE(RS232_TAG, rs232_port_device, write_rts))
MCFG_INS8250_OUT_INT_CB(WRITELINE(device_portfolio_expansion_slot_interface, eint_w))
MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, nullptr)
MCFG_RS232_RXD_HANDLER(DEVWRITELINE(M82C50A_TAG, ins8250_uart_device, rx_w))
MCFG_RS232_DCD_HANDLER(DEVWRITELINE(M82C50A_TAG, ins8250_uart_device, dcd_w))
MCFG_RS232_DSR_HANDLER(DEVWRITELINE(M82C50A_TAG, ins8250_uart_device, dsr_w))
MCFG_RS232_RI_HANDLER(DEVWRITELINE(M82C50A_TAG, ins8250_uart_device, ri_w))
MCFG_RS232_CTS_HANDLER(DEVWRITELINE(M82C50A_TAG, ins8250_uart_device, cts_w))
MACHINE_CONFIG_END
//-------------------------------------------------
// machine_config_additions - device-specific
// machine configurations
//-------------------------------------------------
machine_config_constructor hpc102_t::device_mconfig_additions() const
{
return MACHINE_CONFIG_NAME( hpc102 );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// hpc102_t - constructor
//-------------------------------------------------
hpc102_t::hpc102_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, HPC102, "Atari Portfolio HPC-102", tag, owner, clock, "hpc102", __FILE__),
device_portfolio_expansion_slot_interface(mconfig, *this),
m_uart(*this, M82C50A_TAG)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void hpc102_t::device_start()
{
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void hpc102_t::device_reset()
{
m_uart->reset();
}
//-------------------------------------------------
// eack_r - external interrupt acknowledge
//-------------------------------------------------
UINT8 hpc102_t::eack_r()
{
return m_vector;
}
//-------------------------------------------------
// nrdi_r - read
//-------------------------------------------------
UINT8 hpc102_t::nrdi_r(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1)
{
if (!bcom)
{
if ((offset & 0x0f) == 0x0f)
{
data = 0x01;
}
if (!(offset & 0x08))
{
data = m_uart->ins8250_r(space, offset & 0x07);
}
}
return data;
}
//-------------------------------------------------
// nwri_w - write
//-------------------------------------------------
void hpc102_t::nwri_w(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1)
{
if (!bcom)
{
if ((offset & 0x0f) == 0x0f)
{
m_vector = data;
}
if (!(offset & 0x08))
{
m_uart->ins8250_w(space, offset & 0x07, data);
}
}
}

View File

@ -0,0 +1,66 @@
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
Atari Portfolio HPC-102 serial interface emulation
**********************************************************************/
#pragma once
#ifndef __HPC102__
#define __HPC102__
#include "emu.h"
#include "exp.h"
#include "bus/rs232/rs232.h"
#include "machine/ins8250.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> hpc102_t
class hpc102_t : public device_t,
public device_portfolio_expansion_slot_interface
{
public:
// construction/destruction
hpc102_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// optional information overrides
virtual machine_config_constructor device_mconfig_additions() const override;
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
// device_portfolio_expansion_slot_interface overrides
bool pdet() override { return 1; }
virtual UINT8 eack_r() override;
virtual UINT8 nrdi_r(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1) override;
virtual void nwri_w(address_space &space, offs_t offset, UINT8 data, bool iom, bool bcom, bool ncc1) override;
private:
required_device<ins8250_device> m_uart;
UINT8 m_vector;
};
// device type definition
extern const device_type HPC102;
#endif
/*
*/

View File

@ -15,6 +15,7 @@
#include "machine/ldp1000.h"
#define DUMP_BCD 1
#define FIFO_MAX 0x10
ROM_START( ldp1000 )
ROM_REGION( 0x2000, "ldp1000", 0 )
@ -71,6 +72,9 @@ void sony_ldp1000_device::device_reset()
{
laserdisc_device::device_reset();
for(int i=0;i<0x10;i++)
m_internal_bcd[i] = 0;
}
//-------------------------------------------------
@ -119,11 +123,10 @@ READ8_MEMBER( sony_ldp1000_device::status_r )
return res;
}
void sony_ldp1000_device::set_new_player_state(ldp1000_player_state which, UINT8 fifo_size)
void sony_ldp1000_device::set_new_player_state(ldp1000_player_state which)
{
m_player_state = which;
m_index_state = 0;
m_index_size = fifo_size;
printf("set new player state\n");
}
@ -132,18 +135,36 @@ void sony_ldp1000_device::set_new_player_bcd(UINT8 data)
{
m_internal_bcd[m_index_state] = data;
m_index_state ++;
if(m_index_state >= m_index_size)
{
#if DUMP_BCD
for(int i=0;i<m_index_size;i++)
printf("%02x ",m_internal_bcd[i]);
if(m_index_state >= FIFO_MAX)
throw emu_fatalerror("FIFO MAX reached");
printf("[size = %02x]\n",m_index_size);
#endif
m_status = stat_ack;
}
else
m_status = stat_ack;
UINT32 sony_ldp1000_device::bcd_to_raw()
{
UINT32 res = 0;
for(int i=0;i<6;i++)
res |= (m_internal_bcd[i] & 0xf) << i*4;
return res;
}
void sony_ldp1000_device::exec_enter_cmd()
{
//const UINT32 saved_frame = bcd_to_raw();
switch(m_player_state)
{
case player_standby:
throw emu_fatalerror("Unimplemented standby state detected");
case player_search:
// TODO: move to timer
//advance_slider(1);
//set_slider_speed(saved_frame);
break;
}
m_player_state = player_standby;
}
@ -154,7 +175,7 @@ WRITE8_MEMBER( sony_ldp1000_device::command_w )
// 0x30 to 0x69 range causes an ACK, anything else is invalid
m_command = data;
if((m_command & 0xf0) == 0x30)
if((m_command & 0xf0) == 0x30 && (m_command & 0xf) < 0x0a)
{
set_new_player_bcd(data);
return;
@ -162,11 +183,13 @@ WRITE8_MEMBER( sony_ldp1000_device::command_w )
switch(m_command)
{
case 0x40: // enter bcd command, todo
case 0x40: // enter, process BCD command
exec_enter_cmd();
m_status = stat_ack;
break;
case 0x43: // search
set_new_player_state(player_search,5);
set_new_player_state(player_search);
m_status = stat_ack;
break;

View File

@ -72,12 +72,14 @@ private:
ldp1000_status m_status;
ldp1000_player_state m_player_state;
bool m_audio_enable[2];
// TODO: sub-class
void set_new_player_state(ldp1000_player_state which, UINT8 fifo_size);
// TODO: sub-class into a specific internal player state
void set_new_player_state(ldp1000_player_state which);
void set_new_player_bcd(UINT8 data);
UINT32 bcd_to_raw();
void exec_enter_cmd();
UINT8 m_internal_bcd[0x10];
UINT8 m_index_state;
UINT8 m_index_size;
};

View File

@ -63,8 +63,8 @@ const device_type PIONEER_LDV1000 = &device_creator<pioneer_ldv1000_device>;
static ADDRESS_MAP_START( ldv1000_map, AS_PROGRAM, 8, pioneer_ldv1000_device )
AM_RANGE(0x0000, 0x1fff) AM_MIRROR(0x6000) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_MIRROR(0x3800) AM_RAM
AM_RANGE(0xc000, 0xc003) AM_MIRROR(0x9ff0) AM_DEVREADWRITE("ldvppi0", i8255_device, read, write)
AM_RANGE(0xc004, 0xc007) AM_MIRROR(0x9ff0) AM_DEVREADWRITE("ldvppi1", i8255_device, read, write)
AM_RANGE(0xc000, 0xc003) AM_MIRROR(0x1ff0) AM_DEVREADWRITE("ldvppi0", i8255_device, read, write)
AM_RANGE(0xc004, 0xc007) AM_MIRROR(0x1ff0) AM_DEVREADWRITE("ldvppi1", i8255_device, read, write)
ADDRESS_MAP_END
@ -126,6 +126,7 @@ pioneer_ldv1000_device::pioneer_ldv1000_device(const machine_config &mconfig, co
m_z80_cpu(*this, "ldv1000"),
m_z80_ctc(*this, "ldvctc"),
m_multitimer(nullptr),
m_command_strobe_cb(*this),
m_command(0),
m_status(0),
m_vsync(false),
@ -175,6 +176,8 @@ void pioneer_ldv1000_device::device_start()
// allocate timers
m_multitimer = timer_alloc(TID_MULTIJUMP);
m_command_strobe_cb.resolve_safe();
}
@ -648,6 +651,9 @@ WRITE8_MEMBER( pioneer_ldv1000_device::ppi1_portc_w )
printf("\n");
}
// bit 4 sends a command strobe signal to Host CPU
m_command_strobe_cb(bool(data & 0x10));
// video squelch is controlled by bit 3
set_video_squelch((data & 0x08) == 0);

View File

@ -26,6 +26,10 @@
#define MCFG_LASERDISC_LDV1000_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, PIONEER_LDV1000, 0)
#define MCFG_LASERDISC_LDV1000_COMMAND_STROBE_CB(_cb) \
downcast<pioneer_ldv1000_device *>(device)->set_command_strobe_callback(DEVCB_##_cb);
//**************************************************************************
// GLOBAL VARIABLES
@ -49,6 +53,8 @@ public:
// construction/destruction
pioneer_ldv1000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
template<class _cmd_strobe_cb> void set_command_strobe_callback(_cmd_strobe_cb latch) { m_command_strobe_cb.set_callback(latch); }
// input and output
void data_w(UINT8 data);
void enter_w(UINT8 data);
@ -102,6 +108,7 @@ protected:
required_device<z80_device> m_z80_cpu; /* CPU index of the Z80 */
required_device<z80ctc_device> m_z80_ctc; /* CTC device */
emu_timer * m_multitimer; /* multi-jump timer device */
devcb_write_line m_command_strobe_cb;
/* communication status */
UINT8 m_command; /* command byte to the player */
@ -122,6 +129,7 @@ protected:
UINT8 m_vbi[7*3]; /* VBI data */
bool m_vbiready; /* VBI ready flag */
UINT8 m_vbiindex; /* index within the VBI data */
};

View File

@ -801,6 +801,7 @@ int rom_load_manager::read_rom_data(const rom_entry *parent_region, const rom_en
void rom_load_manager::fill_rom_data(const rom_entry *romp)
{
UINT32 numbytes = ROM_GETLENGTH(romp);
int skip = ROM_GETSKIPCOUNT(romp);
UINT8 *base = m_region->base() + ROM_GETOFFSET(romp);
/* make sure we fill within the region space */
@ -812,6 +813,12 @@ void rom_load_manager::fill_rom_data(const rom_entry *romp)
fatalerror("Error in RomModule definition: FILL has an invalid length\n");
/* fill the data (filling value is stored in place of the hashdata) */
if(skip != 0)
{
for (int i = 0; i < numbytes; i+= skip + 1)
base[i] = (FPTR)ROM_GETHASHDATA(romp) & 0xff;
}
else
memset(base, (FPTR)ROM_GETHASHDATA(romp) & 0xff, numbytes);
}

View File

@ -236,6 +236,7 @@ struct rom_entry
#define ROM_CONTINUE(offset,length) { nullptr, nullptr, offset, length, ROMENTRYTYPE_CONTINUE | ROM_INHERITFLAGS },
#define ROM_IGNORE(length) { nullptr, nullptr, 0, length, ROMENTRYTYPE_IGNORE | ROM_INHERITFLAGS },
#define ROM_FILL(offset,length,value) { nullptr, (const char *)value, offset, length, ROMENTRYTYPE_FILL },
#define ROMX_FILL(offset,length,value,flags) { nullptr, (const char *)value, offset, length, ROMENTRYTYPE_FILL | flags },
#define ROM_COPY(srctag,srcoffs,offset,length) { srctag, (const char *)srcoffs, offset, length, ROMENTRYTYPE_COPY },

View File

@ -27,8 +27,8 @@ inline int cs_stricmp(const char *s1, const char *s2)
{
for (;;)
{
int c1 = tolower((UINT8)*s1++);
int c2 = tolower((UINT8)*s2++);
int c1 = tolower(*s1++);
int c2 = tolower(*s2++);
if (c1 == 0 || c1 != c2)
return c1 - c2;
}
@ -36,8 +36,8 @@ inline int cs_stricmp(const char *s1, const char *s2)
bool sorted_game_list(const game_driver *x, const game_driver *y)
{
bool clonex = strcmp(x->parent, "0");
bool cloney = strcmp(y->parent, "0");
bool clonex = (x->parent[0] != '0');
bool cloney = (y->parent[0] != '0');
if (!clonex && !cloney)
return (cs_stricmp(x->description, y->description) < 0);

View File

@ -1002,7 +1002,7 @@ void menu_rgb_ui::inkey_special(const event *menu_event)
}
}
menu_palette_sel::palcolor menu_palette_sel::m_palette[] = {
std::vector<std::pair<const char *, const char *>> menu_palette_sel::m_palette = {
{ __("White"), "FFFFFFFF" },
{ __("Silver"), "FFC0C0C0" },
{ __("Gray"), "FF808080" },
@ -1057,8 +1057,8 @@ void menu_palette_sel::handle()
void menu_palette_sel::populate()
{
for (int x = 0; x < ARRAY_LENGTH(m_palette); ++x)
item_append(_(m_palette[x].name), m_palette[x].argb, FLAG_UI_PALETTE, (void *)(FPTR)(x + 1));
for (int x = 0; x < m_palette.size(); ++x)
item_append(_(m_palette[x].first), m_palette[x].second, FLAG_UI_PALETTE, (void *)(FPTR)(x + 1));
item_append(menu_item_type::SEPARATOR);
}

View File

@ -169,13 +169,8 @@ public:
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
private:
struct palcolor
{
const char *name;
const char *argb;
};
static palcolor m_palette[];
static std::vector<std::pair<const char *, const char *>> m_palette;
rgb_t &m_original;
};

View File

@ -83,7 +83,7 @@ datfile_manager::datfile_manager(running_machine &machine, ui_options &moptions)
void datfile_manager::init_sysinfo()
{
int swcount = 0;
auto count = index_datafile(m_sysidx, swcount);
auto count = index_datafile(m_sysidx, swcount, TAG_SYSINFO_R, m_sysinfo_rev, '.');
osd_printf_verbose("Sysinfo.dat games found = %i\n", count);
osd_printf_verbose("Rev = %s\n", m_sysinfo_rev.c_str());
}
@ -94,7 +94,7 @@ void datfile_manager::init_sysinfo()
void datfile_manager::init_story()
{
int swcount = 0;
auto count = index_datafile(m_storyidx, swcount);
auto count = index_datafile(m_storyidx, swcount, TAG_STORY_R, m_story_rev, 's');
osd_printf_verbose("Story.dat games found = %i\n", count);
}
@ -104,7 +104,7 @@ void datfile_manager::init_story()
void datfile_manager::init_history()
{
int swcount = 0;
auto count = index_datafile(m_histidx, swcount);
auto count = index_datafile(m_histidx, swcount, TAG_HISTORY_R, m_history_rev, ' ');
osd_printf_verbose("History.dat systems found = %i\n", count);
osd_printf_verbose("History.dat software packages found = %i\n", swcount);
osd_printf_verbose("Rev = %s\n", m_history_rev.c_str());
@ -152,7 +152,8 @@ void datfile_manager::init_messinfo()
void datfile_manager::init_command()
{
int swcount = 0;
auto count = index_datafile(m_cmdidx, swcount);
std::string tmp, tmp2;
auto count = index_datafile(m_cmdidx, swcount, tmp, tmp2, 'c');
osd_printf_verbose("Command.dat games found = %i\n", count);
}
@ -398,12 +399,10 @@ int datfile_manager::index_mame_mess_info(dataindex &index, drvindex &index_drv,
// load a game name and offset into an
// indexed array
//-------------------------------------------------
int datfile_manager::index_datafile(dataindex &index, int &swcount)
int datfile_manager::index_datafile(dataindex &index, int &swcount, std::string &tag, std::string &str, char sep)
{
std::string readbuf;
auto t_hist = TAG_HISTORY_R.size();
auto t_story = TAG_STORY_R.size();
auto t_sysinfo = TAG_SYSINFO_R.size();
auto tag_size = tag.size();
auto t_info = TAG_INFO.size();
auto t_bio = TAG_BIO.size();
char rbuf[64 * 1024];
@ -411,21 +410,19 @@ int datfile_manager::index_datafile(dataindex &index, int &swcount)
{
readbuf = chartrimcarriage(rbuf);
if (m_history_rev.empty() && readbuf.compare(0, t_hist, TAG_HISTORY_R) == 0)
if (!tag.empty())
if (str.empty() && readbuf.compare(0, tag_size, tag) == 0)
{
auto found = readbuf.find(" ", t_hist + 1);
m_history_rev = readbuf.substr(t_hist + 1, found - t_hist);
}
else if (m_sysinfo_rev.empty() && readbuf.compare(0, t_sysinfo, TAG_SYSINFO_R) == 0)
if (sep != 's')
{
auto found = readbuf.find(".", t_sysinfo + 1);
m_sysinfo_rev = readbuf.substr(t_sysinfo + 1, found - t_sysinfo);
auto found = readbuf.find(sep, tag_size + 1);
str = readbuf.substr(tag_size + 1, found - tag_size);
}
else if (m_story_rev.empty() && readbuf.compare(0, t_story, TAG_STORY_R) == 0)
{
m_story_rev = readbuf.substr(t_story + 1);
else
str = readbuf.substr(tag_size + 1);
}
else if (readbuf.compare(0, t_info, TAG_INFO) == 0)
if (readbuf.compare(0, t_info, TAG_INFO) == 0)
{
// search for game info
auto rd = readbuf.substr(t_info + 1);
@ -452,6 +449,7 @@ int datfile_manager::index_datafile(dataindex &index, int &swcount)
for (auto & li : token_list)
for (auto & ro : token_roms)
m_swindex[li].emplace(ro, ftell(fp));
swcount++;
}
}
}

View File

@ -79,7 +79,7 @@ private:
void parseclose() { if (fp != nullptr) fclose(fp); }
int index_mame_mess_info(dataindex &index, drvindex &index_drv, int &drvcount);
int index_datafile(dataindex &index, int &swcount);
int index_datafile(dataindex &index, int &swcount, std::string &tag, std::string &str, char sep);
void index_menuidx(const game_driver *drv, dataindex &idx, drvindex &index);
drvindex::const_iterator m_itemsiter;

View File

@ -180,7 +180,7 @@ void menu::exit(running_machine &machine)
for (auto & elem : icons_texture)
mre.texture_free(elem);
for (int i = 0; i < UI_TOOLBAR_BUTTONS; i++)
for (int i = 0; i < UI_TOOLBAR_BUTTONS; ++i)
{
mre.texture_free(sw_toolbar_texture[i]);
mre.texture_free(toolbar_texture[i]);
@ -390,7 +390,7 @@ const menu::event *menu::process(UINT32 flags, float x0, float y0)
{
// read events
if ((item[0].flags & FLAG_UI ) != 0 || (item[0].flags & FLAG_UI_SWLIST ) != 0)
handle_main_events(flags);
handle_main_events();
else
handle_events(flags);
@ -521,9 +521,8 @@ void menu::draw(UINT32 flags, float origx0, float origy0)
// compute the width and height of the full menu
float visible_width = 0;
float visible_main_menu_height = 0;
for (itemnum = 0; itemnum < item.size(); itemnum++)
for (auto & pitem : item)
{
const menu_item &pitem = item[itemnum];
float total_width;
// compute width of left hand side
@ -564,38 +563,6 @@ void menu::draw(UINT32 flags, float origx0, float origy0)
float visible_left = (1.0f - visible_width) * 0.5f;
float visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f;
/* float visible_left;
float visible_top;
if (origx0 == 0.0f && origy0 == 0.0f)
{
visible_left = (1.0f - visible_width) * 0.5f;
visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f;
}
else
{
INT32 mouse_target_x, mouse_target_y;
float m_x, m_y;
render_target *mouse_target = machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button);
if (mouse_target != nullptr)
{
if (mouse_target->map_point_container(origx0, origy0, *container, m_x, m_y))
{
visible_left = m_x;
visible_top = m_y;
}
else
{
visible_left = (1.0f - visible_width) * 0.5f;
visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f;
}
}
else
{
visible_left = (1.0f - visible_width) * 0.5f;
visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f;
}
}
*/
// if the menu is at the bottom of the extra, adjust
visible_top += customtop;
@ -669,19 +636,15 @@ void menu::draw(UINT32 flags, float origx0, float origy0)
// if we're selected, draw with a different background
if (itemnum == selected)
{
fgcolor = UI_SELECTED_COLOR;
fgcolor = fgcolor2 = fgcolor3 = UI_SELECTED_COLOR;
bgcolor = UI_SELECTED_BG_COLOR;
fgcolor2 = UI_SELECTED_COLOR;
fgcolor3 = UI_SELECTED_COLOR;
}
// else if the mouse is over this item, draw with a different background
else if (itemnum == hover)
{
fgcolor = UI_MOUSEOVER_COLOR;
fgcolor = fgcolor2 = fgcolor3 = UI_MOUSEOVER_COLOR;
bgcolor = UI_MOUSEOVER_BG_COLOR;
fgcolor2 = UI_MOUSEOVER_COLOR;
fgcolor3 = UI_MOUSEOVER_COLOR;
}
// if we have some background hilighting to do, add a quad behind everything else
@ -757,13 +720,13 @@ void menu::draw(UINT32 flags, float origx0, float origy0)
// customize subitem text color
if (!core_stricmp(subitem_text, _("On")))
fgcolor2 = rgb_t(0xff,0x00,0xff,0x00);
fgcolor2 = rgb_t(0x00,0xff,0x00);
if (!core_stricmp(subitem_text, _("Off")))
fgcolor2 = rgb_t(0xff,0xff,0x00,0x00);
fgcolor2 = rgb_t(0xff,0x00,0x00);
if (!core_stricmp(subitem_text, _("Auto")))
fgcolor2 = rgb_t(0xff,0xff,0xff,0x00);
fgcolor2 = rgb_t(0xff,0xff,0x00);
// draw the subitem right-justified
ui().draw_text_full(container, subitem_text, effective_left + item_width, line_y, effective_width - item_width,
@ -950,7 +913,7 @@ void menu::handle_events(UINT32 flags)
// if we are hovering over a valid item, fake a UI_SELECT with a double-click
case UI_EVENT_MOUSE_DOUBLE_CLICK:
if ((flags & PROCESS_ONLYCHAR) == 0 && hover >= 0 && hover < item.size())
if (!(flags & PROCESS_ONLYCHAR) && hover >= 0 && hover < item.size())
{
selected = hover;
m_event.iptkey = IPT_UI_SELECT;
@ -965,7 +928,7 @@ void menu::handle_events(UINT32 flags)
// caught scroll event
case UI_EVENT_MOUSE_WHEEL:
if ((flags & PROCESS_ONLYCHAR) == 0)
if (!(flags & PROCESS_ONLYCHAR))
{
if (local_menu_event.zdelta > 0)
{
@ -982,7 +945,7 @@ void menu::handle_events(UINT32 flags)
}
else
{
if ((flags & FLAG_UI_DATS) != 0)
if ((flags & FLAG_UI_DATS))
{
top_line += local_menu_event.num_lines;
return;
@ -1037,7 +1000,7 @@ void menu::handle_keys(UINT32 flags)
}
// bail out
if ((flags & PROCESS_ONLYCHAR) != 0)
if ((flags & PROCESS_ONLYCHAR))
return;
// hitting cancel also pops the stack
@ -1055,7 +1018,7 @@ void menu::handle_keys(UINT32 flags)
bool ignoreleft = ((item[selected].flags & FLAG_LEFT_ARROW) == 0);
bool ignoreright = ((item[selected].flags & FLAG_RIGHT_ARROW) == 0);
if ((item[0].flags & FLAG_UI_DATS) != 0)
if ((item[0].flags & FLAG_UI_DATS))
ignoreleft = ignoreright = false;
// accept left/right keys as-is with repeat
@ -1067,7 +1030,7 @@ void menu::handle_keys(UINT32 flags)
// up backs up by one item
if (exclusive_input_pressed(IPT_UI_UP, 6))
{
if ((item[0].flags & FLAG_UI_DATS) != 0)
if ((item[0].flags & FLAG_UI_DATS))
{
top_line--;
return;
@ -1082,7 +1045,7 @@ void menu::handle_keys(UINT32 flags)
// down advances by one item
if (exclusive_input_pressed(IPT_UI_DOWN, 6))
{
if ((item[0].flags & FLAG_UI_DATS) != 0)
if ((item[0].flags & FLAG_UI_DATS))
{
top_line++;
return;
@ -1371,15 +1334,15 @@ void menu::init_ui(running_machine &machine, ui_options &mopt)
{
render_manager &mrender = machine.render();
// create a texture for hilighting items in main menu
hilight_main_bitmap = std::make_unique<bitmap_rgb32>(1, 26);
hilight_main_bitmap = std::make_unique<bitmap_rgb32>(1, 128);
int r1 = 0, g1 = 169, b1 = 255; //Any start color
int r2 = 0, g2 = 39, b2 = 130; //Any stop color
for (int y = 0; y < 26; y++)
for (int y = 0; y < 128; y++)
{
int r = r1 + (y * (r2 - r1) / 26);
int g = g1 + (y * (g2 - g1) / 26);
int b = b1 + (y * (b2 - b1) / 26);
hilight_main_bitmap->pix32(y, 0) = rgb_t(0xff, r, g, b);
int r = r1 + (y * (r2 - r1) / 128);
int g = g1 + (y * (g2 - g1) / 128);
int b = b1 + (y * (b2 - b1) / 128);
hilight_main_bitmap->pix32(y, 0) = rgb_t(r, g, b);
}
hilight_main_texture = mrender.texture_alloc();
@ -1402,10 +1365,10 @@ void menu::init_ui(running_machine &machine, ui_options &mopt)
star_texture->set_bitmap(*star_bitmap, star_bitmap->cliprect(), TEXFORMAT_ARGB32);
// allocate icons
for (int i = 0; i < MAX_ICONS_RENDER; i++)
for (auto & icons : icons_texture)
{
icons_bitmap.emplace_back(std::make_unique<bitmap_argb32>());
icons_texture[i] = mrender.texture_alloc();
icons = mrender.texture_alloc();
}
// create a texture for main menu background
@ -1473,8 +1436,8 @@ void menu::draw_select_game(UINT32 flags)
float visible_width = 1.0f - 4.0f * UI_BOX_LR_BORDER;
float primary_left = (1.0f - visible_width) * 0.5f;
float primary_width = visible_width;
bool is_swlist = ((item[0].flags & FLAG_UI_SWLIST) != 0);
bool is_favorites = ((item[0].flags & FLAG_UI_FAVORITE) != 0);
bool is_swlist = (item[0].flags & FLAG_UI_SWLIST);
bool is_favorites = (item[0].flags & FLAG_UI_FAVORITE);
// draw background image if available
if (ui().options().use_background_image() && bgrnd_bitmap->valid())
@ -1491,7 +1454,7 @@ void menu::draw_select_game(UINT32 flags)
if (!noinput)
{
mouse_target = machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button);
if (mouse_target != nullptr)
if (mouse_target)
if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, *container, mouse_x, mouse_y))
mouse_hit = true;
}
@ -1549,7 +1512,6 @@ void menu::draw_select_game(UINT32 flags)
float line_y = visible_top + (float)linenum * line_height;
int itemnum = top_line + linenum;
const menu_item &pitem = item[itemnum];
const char *itemtext = pitem.text;
rgb_t fgcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
rgb_t fgcolor3 = UI_CLONE_COLOR;
@ -1565,10 +1527,10 @@ void menu::draw_select_game(UINT32 flags)
// if we're selected, draw with a different background
if (itemnum == selected && m_focus == focused_menu::main)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
fgcolor3 = rgb_t(0xff, 0xcc, 0xcc, 0x00);
ui().draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(255, 43, 43, 43),
fgcolor = rgb_t(0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff);
fgcolor3 = rgb_t(0xcc, 0xcc, 0x00);
ui().draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
}
// else if the mouse is over this item, draw with a different background
@ -1582,7 +1544,7 @@ void menu::draw_select_game(UINT32 flags)
{
fgcolor = fgcolor3 = UI_MOUSEOVER_COLOR;
bgcolor = UI_MOUSEOVER_BG_COLOR;
ui().draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(255, 43, 43, 43),
ui().draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
}
@ -1628,26 +1590,25 @@ void menu::draw_select_game(UINT32 flags)
space = ud_arrow_width * 1.5f;
}
ui().draw_text_full(container, itemtext, effective_left + space, line_y, effective_width - space, JUSTIFY_LEFT, WRAP_TRUNCATE,
ui().draw_text_full(container, pitem.text, effective_left + space, line_y, effective_width - space, JUSTIFY_LEFT, WRAP_TRUNCATE,
DRAW_NORMAL, item_invert ? fgcolor3 : fgcolor, bgcolor, nullptr, nullptr);
}
else
{
int item_invert = pitem.flags & FLAG_INVERT;
const char *subitem_text = pitem.subtext;
float item_width, subitem_width;
// compute right space for subitem
ui().draw_text_full(container, subitem_text, effective_left, line_y, ui().get_string_width(pitem.subtext),
ui().draw_text_full(container, pitem.subtext, effective_left, line_y, ui().get_string_width(pitem.subtext),
JUSTIFY_RIGHT, WRAP_NEVER, DRAW_NONE, item_invert ? fgcolor3 : fgcolor, bgcolor, &subitem_width, nullptr);
subitem_width += gutter_width;
// draw the item left-justified
ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width - subitem_width,
ui().draw_text_full(container, pitem.text, effective_left, line_y, effective_width - subitem_width,
JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, item_invert ? fgcolor3 : fgcolor, bgcolor, &item_width, nullptr);
// draw the subitem right-justified
ui().draw_text_full(container, subitem_text, effective_left + item_width, line_y, effective_width - item_width,
ui().draw_text_full(container, pitem.subtext, effective_left + item_width, line_y, effective_width - item_width,
JUSTIFY_RIGHT, WRAP_NEVER, DRAW_NORMAL, item_invert ? fgcolor3 : fgcolor, bgcolor, nullptr, nullptr);
}
}
@ -1655,7 +1616,6 @@ void menu::draw_select_game(UINT32 flags)
for (size_t count = visible_items; count < item.size(); count++)
{
const menu_item &pitem = item[count];
const char *itemtext = pitem.text;
float line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
float line_y0 = line;
float line_x1 = x2 - 0.5f * UI_LINE_WIDTH;
@ -1669,9 +1629,9 @@ void menu::draw_select_game(UINT32 flags)
// if we're selected, draw with a different background
if (count == selected && m_focus == focused_menu::main)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
ui().draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(255, 43, 43, 43),
fgcolor = rgb_t(0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff);
ui().draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
}
// else if the mouse is over this item, draw with a different background
@ -1686,7 +1646,7 @@ void menu::draw_select_game(UINT32 flags)
container->add_line(visible_left, line + 0.5f * line_height, visible_left + visible_width, line + 0.5f * line_height,
UI_LINE_WIDTH, UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
else
ui().draw_text_full(container, itemtext, effective_left, line, effective_width, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, pitem.text, effective_left, line, effective_width, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
line += line_height;
}
@ -1706,8 +1666,7 @@ void menu::draw_select_game(UINT32 flags)
visitems = visible_lines - (top_line != 0) - (top_line + visible_lines != visible_items);
// reset redraw icon stage
if (!is_swlist)
ui_globals::redraw_icon = false;
if (!is_swlist) ui_globals::redraw_icon = false;
// noinput
if (noinput)
@ -1764,7 +1723,7 @@ void menu::get_title_search(std::string &snaptext, std::string &searchstr)
void menu::handle_main_keys(UINT32 flags)
{
bool ignorepause = menu::stack_has_special_main_menu();
auto ignorepause = menu::stack_has_special_main_menu();
// bail if no items
if (item.size() == 0)
@ -1975,9 +1934,9 @@ void menu::handle_main_keys(UINT32 flags)
// handle input events for main menu
//-------------------------------------------------
void menu::handle_main_events(UINT32 flags)
void menu::handle_main_events()
{
bool stop = false;
auto stop = false;
ui_event local_menu_event;
if (m_pressed)
@ -1985,8 +1944,8 @@ void menu::handle_main_events(UINT32 flags)
bool pressed = mouse_pressed();
INT32 m_target_x, m_target_y;
bool m_button;
render_target *mouse_target = machine().ui_input().find_mouse(&m_target_x, &m_target_y, &m_button);
if (mouse_target != nullptr && m_button && (hover == HOVER_ARROW_DOWN || hover == HOVER_ARROW_UP))
auto mouse_target = machine().ui_input().find_mouse(&m_target_x, &m_target_y, &m_button);
if (mouse_target && m_button && (hover == HOVER_ARROW_DOWN || hover == HOVER_ARROW_UP))
{
if (pressed)
machine().ui_input().push_mouse_down_event(mouse_target, m_target_x, m_target_y);
@ -2181,7 +2140,7 @@ void menu::handle_main_events(UINT32 flags)
float menu::draw_right_box_title(float x1, float y1, float x2, float y2)
{
float line_height = ui().get_line_height();
auto line_height = ui().get_line_height();
float midl = (x2 - x1) * 0.5f;
// add outlined box for options
@ -2198,7 +2157,7 @@ float menu::draw_right_box_title(float x1, float y1, float x2, float y2)
float text_size = 1.0f;
for (auto & elem : buffer)
{
float textlen = ui().get_string_width(elem.c_str()) + 0.01f;
auto textlen = ui().get_string_width(elem.c_str()) + 0.01f;
float tmp_size = (textlen > midl) ? (midl / textlen) : 1.0f;
text_size = MIN(text_size, tmp_size);
}
@ -2228,10 +2187,10 @@ float menu::draw_right_box_title(float x1, float y1, float x2, float y2)
if (m_focus == focused_menu::righttop && ui_globals::rpanel == cells)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
fgcolor = rgb_t(0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff);
ui().draw_textured_box(container, x1 + UI_LINE_WIDTH, y1 + UI_LINE_WIDTH, x1 + midl - UI_LINE_WIDTH, y1 + line_height,
bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
bgcolor, rgb_t(43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
}
else if (bgcolor == UI_MOUSEOVER_BG_COLOR)
container->add_rect(x1 + UI_LINE_WIDTH, y1 + UI_LINE_WIDTH, x1 + midl - UI_LINE_WIDTH, y1 + line_height,
@ -2251,11 +2210,11 @@ float menu::draw_right_box_title(float x1, float y1, float x2, float y2)
std::string menu::arts_render_common(float origx1, float origy1, float origx2, float origy2)
{
float line_height = ui().get_line_height();
auto line_height = ui().get_line_height();
std::string snaptext, searchstr;
float title_size = 0.0f;
float txt_lenght = 0.0f;
float gutter_width = 0.4f * line_height * machine().render().ui_aspect() * 1.3f;
auto title_size = 0.0f;
auto txt_lenght = 0.0f;
auto gutter_width = 0.4f * line_height * machine().render().ui_aspect() * 1.3f;
get_title_search(snaptext, searchstr);
@ -2268,8 +2227,8 @@ std::string menu::arts_render_common(float origx1, float origy1, float origx2, f
title_size = MAX(txt_lenght, title_size);
}
rgb_t fgcolor = (m_focus == focused_menu::rightbottom) ? rgb_t(0xff, 0xff, 0xff, 0x00) : UI_TEXT_COLOR;
rgb_t bgcolor = (m_focus == focused_menu::rightbottom) ? rgb_t(0xff, 0xff, 0xff, 0xff) : UI_TEXT_BG_COLOR;
rgb_t fgcolor = (m_focus == focused_menu::rightbottom) ? rgb_t(0xff, 0xff, 0x00) : UI_TEXT_COLOR;
rgb_t bgcolor = (m_focus == focused_menu::rightbottom) ? rgb_t(0xff, 0xff, 0xff) : UI_TEXT_BG_COLOR;
float middle = origx2 - origx1;
// check size
@ -2279,7 +2238,7 @@ std::string menu::arts_render_common(float origx1, float origy1, float origx2, f
if (bgcolor != UI_TEXT_BG_COLOR)
ui().draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
origy1 + line_height, bgcolor, rgb_t(43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
ui().draw_text_full(container, snaptext.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr, tmp_size);
@ -2350,7 +2309,7 @@ void menu::draw_toolbar(float x1, float y1, float x2, float y2, bool software)
// perform rendering of image
//-------------------------------------------------
void menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float origy1, float origx2, float origy2, bool software)
void menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float origy1, float origx2, float origy2)
{
bool no_available = false;
float line_height = ui().get_line_height();
@ -2461,14 +2420,14 @@ void menu::draw_common_arrow(float origx1, float origy1, float origx2, float ori
// set hover
if (mouse_hit && ar_x0 <= mouse_x && ar_x1 > mouse_x && ar_y0 <= mouse_y && ar_y1 > mouse_y && current != dmax)
{
ui().draw_textured_box(container, ar_x0 + 0.01f, ar_y0, ar_x1 - 0.01f, ar_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(255, 43, 43, 43),
ui().draw_textured_box(container, ar_x0 + 0.01f, ar_y0, ar_x1 - 0.01f, ar_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
hover = HOVER_UI_RIGHT;
fgcolor_right = UI_MOUSEOVER_COLOR;
}
else if (mouse_hit && al_x0 <= mouse_x && al_x1 > mouse_x && al_y0 <= mouse_y && al_y1 > mouse_y && current != dmin)
{
ui().draw_textured_box(container, al_x0 + 0.01f, al_y0, al_x1 - 0.01f, al_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(255, 43, 43, 43),
ui().draw_textured_box(container, al_x0 + 0.01f, al_y0, al_x1 - 0.01f, al_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
hover = HOVER_UI_LEFT;
fgcolor_left = UI_MOUSEOVER_COLOR;
@ -2603,7 +2562,7 @@ void menu::info_arrow(int ub, float origx1, float origx2, float oy1, float line_
if (mouse_hit && origx1 <= mouse_x && origx2 > mouse_x && oy1 <= mouse_y && oy1 + (line_height * text_size) > mouse_y)
{
ui().draw_textured_box(container, origx1 + 0.01f, oy1, origx2 - 0.01f, oy1 + (line_height * text_size), UI_MOUSEOVER_BG_COLOR,
rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
rgb_t(43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
hover = (!ub) ? HOVER_DAT_UP : HOVER_DAT_DOWN;
fgcolor = UI_MOUSEOVER_COLOR;
}

View File

@ -268,7 +268,7 @@ protected:
const event *process(UINT32 flags, float x0 = 0.0f, float y0 = 0.0f);
void process_parent() { m_parent->process(PROCESS_NOINPUT); }
bool is_focus(focused_menu focus) const { return m_focus == focus; }
focused_menu get_focus() const { return m_focus; }
void set_focus(focused_menu focus) { m_focus = focus; }
// draw right box
@ -280,7 +280,7 @@ protected:
// images render
std::string arts_render_common(float origx1, float origy1, float origx2, float origy2);
void arts_render_images(bitmap_argb32 *bitmap, float origx1, float origy1, float origx2, float origy2, bool software);
void arts_render_images(bitmap_argb32 *bitmap, float origx1, float origy1, float origx2, float origy2);
// draw header and footer text
void extra_text_render(float top, float bottom, float origx1, float origy1, float origx2, float origy2, const char *header, const char *footer);
@ -345,7 +345,7 @@ private:
void handle_main_keys(UINT32 flags);
// handle mouse
void handle_main_events(UINT32 flags);
void handle_main_events();
void draw_icon(int linenum, void *selectedref, float x1, float y1);
void extra_text_draw_box(float origx1, float origx2, float origy, float yspan, const char *text, int direction);

View File

@ -821,7 +821,6 @@ void menu_machine_configure::custom_render(void *selectedref, float top, float b
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
// float x1 = origx1;
float x2 = x1 + maxwidth;
float y1 = origy1 - top;
float y2 = origy1 - UI_BOX_TB_BORDER;

View File

@ -217,14 +217,14 @@ void menu_select_game::handle()
else if (menu_event->iptkey == IPT_UI_SELECT)
{
// handle selections
if (is_focus(focused_menu::main))
if (get_focus() == focused_menu::main)
{
if (isfavorite())
inkey_select_favorite(menu_event);
else
inkey_select(menu_event);
}
else if (is_focus(focused_menu::left))
else if (get_focus() == focused_menu::left)
{
l_hover = highlight;
check_filter = true;
@ -422,7 +422,7 @@ void menu_select_game::handle()
inkey_special(menu_event);
}
else if (menu_event->iptkey == IPT_UI_CONFIGURE)
inkey_configure(menu_event);
inkey_navigation();
else if (menu_event->iptkey == IPT_OTHER)
{
@ -440,7 +440,7 @@ void menu_select_game::handle()
}
else if (menu_event->iptkey == IPT_UI_CONFIGURE)
{
inkey_configure(menu_event);
inkey_navigation();
}
else if (menu_event->iptkey == IPT_OTHER)
{
@ -1241,10 +1241,11 @@ void menu_select_game::inkey_special(const event *menu_event)
}
void menu_select_game::inkey_configure(const event *menu_event)
void menu_select_game::inkey_navigation()
{
if (is_focus(focused_menu::main))
switch (get_focus())
{
case focused_menu::main:
if (selected <= visible_items)
{
m_prev_selected = item[selected].ref;
@ -1266,9 +1267,9 @@ void menu_select_game::inkey_configure(const event *menu_event)
set_focus(focused_menu::righttop);
}
}
}
else if (is_focus(focused_menu::left))
{
break;
case focused_menu::left:
if (ui_globals::panels_status != HIDE_RIGHT_PANEL)
{
set_focus(focused_menu::righttop);
@ -1286,13 +1287,13 @@ void menu_select_game::inkey_configure(const event *menu_event)
if (item[x].ref == m_prev_selected)
selected = x;
}
}
else if (is_focus(focused_menu::righttop))
{
break;
case focused_menu::righttop:
set_focus(focused_menu::rightbottom);
}
else if (is_focus(focused_menu::rightbottom))
{
break;
case focused_menu::rightbottom:
set_focus(focused_menu::main);
if (m_prev_selected == nullptr)
{
@ -1303,6 +1304,7 @@ void menu_select_game::inkey_configure(const event *menu_event)
for (int x = 0; x < item.size(); ++x)
if (item[x].ref == m_prev_selected)
selected = x;
break;
}
}
@ -1865,7 +1867,7 @@ float menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2)
menu::highlight(container, x1, y1, x2, y1+ line_height_max, bgcolor);
}
if (highlight == filter && is_focus(focused_menu::left))
if (highlight == filter && get_focus() == focused_menu::left)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
@ -2020,7 +2022,7 @@ void menu_select_game::infos_render(void *selectedref, float origx1, float origy
rgb_t fgcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
if (is_focus(focused_menu::rightbottom))
if (get_focus() == focused_menu::rightbottom)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
@ -2199,7 +2201,7 @@ void menu_select_game::infos_render(void *selectedref, float origx1, float origy
rgb_t fgcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
if (is_focus(focused_menu::rightbottom))
if (get_focus() == focused_menu::rightbottom)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
@ -2407,7 +2409,7 @@ void menu_select_game::arts_render(void *selectedref, float origx1, float origy1
olddriver = driver;
ui_globals::switch_image = false;
arts_render_images(tmp_bitmap, origx1, origy1, origx2, origy2, false);
arts_render_images(tmp_bitmap, origx1, origy1, origx2, origy2);
auto_free(machine(), tmp_bitmap);
}
@ -2496,7 +2498,7 @@ void menu_select_game::arts_render(void *selectedref, float origx1, float origy1
oldsoft = soft;
ui_globals::switch_image = false;
arts_render_images(tmp_bitmap, origx1, origy1, origx2, origy2, true);
arts_render_images(tmp_bitmap, origx1, origy1, origx2, origy2);
auto_free(machine(), tmp_bitmap);
}

View File

@ -81,7 +81,7 @@ private:
void inkey_select_favorite(const event *menu_event);
void inkey_special(const event *menu_event);
void inkey_export();
void inkey_configure(const event *menu_event);
void inkey_navigation();
};
} // namespace ui

View File

@ -184,11 +184,11 @@ void menu_select_software::handle()
else if (menu_event->iptkey == IPT_UI_SELECT)
{
// handle selections
if (is_focus(focused_menu::main))
if (get_focus() == focused_menu::main)
{
inkey_select(menu_event);
}
else if (is_focus(focused_menu::left))
else if (get_focus() == focused_menu::left)
{
l_sw_hover = highlight;
check_filter = true;
@ -300,14 +300,14 @@ void menu_select_software::handle()
}
else if (menu_event->iptkey == IPT_UI_CONFIGURE)
inkey_configure(menu_event);
inkey_navigation();
}
if (menu_event && !menu_event->itemref)
{
if (menu_event->iptkey == IPT_UI_CONFIGURE)
{
inkey_configure(menu_event);
inkey_navigation();
}
else if (menu_event->iptkey == IPT_UI_LEFT)
{
@ -363,7 +363,7 @@ void menu_select_software::handle()
// handle UI_DOWN_FILTER
highlight++;
}
else if (menu_event->iptkey == IPT_OTHER && is_focus(focused_menu::left))
else if (menu_event->iptkey == IPT_OTHER && get_focus() == focused_menu::left)
{
l_sw_hover = highlight;
check_filter = true;
@ -987,10 +987,11 @@ void menu_select_software::inkey_special(const event *menu_event)
}
void menu_select_software::inkey_configure(const event *menu_event)
void menu_select_software::inkey_navigation()
{
if (is_focus(focused_menu::main))
switch (get_focus())
{
case focused_menu::main:
if (selected <= visible_items)
{
m_prev_selected = item[selected].ref;
@ -1012,9 +1013,9 @@ void menu_select_software::inkey_configure(const event *menu_event)
set_focus(focused_menu::righttop);
}
}
}
else if (is_focus(focused_menu::left))
{
break;
case focused_menu::left:
if (ui_globals::panels_status != HIDE_RIGHT_PANEL)
{
set_focus(focused_menu::righttop);
@ -1032,13 +1033,13 @@ void menu_select_software::inkey_configure(const event *menu_event)
if (item[x].ref == m_prev_selected)
selected = x;
}
}
else if (is_focus(focused_menu::righttop))
{
break;
case focused_menu::righttop:
set_focus(focused_menu::rightbottom);
}
else if (is_focus(focused_menu::rightbottom))
{
break;
case focused_menu::rightbottom:
set_focus(focused_menu::main);
if (m_prev_selected == nullptr)
{
@ -1049,6 +1050,7 @@ void menu_select_software::inkey_configure(const event *menu_event)
for (int x = 0; x < item.size(); ++x)
if (item[x].ref == m_prev_selected)
selected = x;
break;
}
}
@ -1446,7 +1448,7 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float
hover = phover + filter;
}
if (highlight == filter && is_focus(focused_menu::left))
if (highlight == filter && get_focus() == focused_menu::left)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
@ -1571,7 +1573,7 @@ void menu_select_software::infos_render(void *selectedref, float origx1, float o
rgb_t fgcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
if (is_focus(focused_menu::rightbottom))
if (get_focus() == focused_menu::rightbottom)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
@ -1605,7 +1607,7 @@ void menu_select_software::infos_render(void *selectedref, float origx1, float o
rgb_t fgcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
if (is_focus(focused_menu::rightbottom))
if (get_focus() == focused_menu::rightbottom)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
@ -1767,7 +1769,7 @@ void menu_select_software::arts_render(void *selectedref, float origx1, float or
olddriver = driver;
ui_globals::switch_image = false;
arts_render_images(tmp_bitmap, origx1, origy1, origx2, origy2, false);
arts_render_images(tmp_bitmap, origx1, origy1, origx2, origy2);
auto_free(machine(), tmp_bitmap);
}
@ -1856,7 +1858,7 @@ void menu_select_software::arts_render(void *selectedref, float origx1, float or
oldsoft = soft;
ui_globals::switch_image = false;
arts_render_images(tmp_bitmap, origx1, origy1, origx2, origy2, true);
arts_render_images(tmp_bitmap, origx1, origy1, origx2, origy2);
auto_free(machine(), tmp_bitmap);
}

View File

@ -61,7 +61,7 @@ private:
// handlers
void inkey_select(const event *menu_event);
void inkey_special(const event *menu_event);
void inkey_configure(const event *menu_event);
void inkey_navigation();
};
class software_parts : public menu

View File

@ -122,7 +122,7 @@ void simple_menu_select_game::handle()
inkey_select(menu_event);
break;
case IPT_UI_CANCEL:
inkey_cancel(menu_event);
inkey_cancel();
break;
case IPT_SPECIAL:
inkey_special(menu_event);
@ -182,7 +182,7 @@ void simple_menu_select_game::inkey_select(const event *menu_event)
// inkey_cancel
//-------------------------------------------------
void simple_menu_select_game::inkey_cancel(const event *menu_event)
void simple_menu_select_game::inkey_cancel()
{
// escape pressed with non-empty text clears the text
if (m_search[0] != 0)

View File

@ -44,7 +44,7 @@ private:
// internal methods
void build_driver_list();
void inkey_select(const event *menu_event);
void inkey_cancel(const event *menu_event);
void inkey_cancel();
void inkey_special(const event *menu_event);
};

View File

@ -249,11 +249,14 @@ static int sol20_handle_cassette(INT16 *buffer, const UINT8 *bytes)
}
sol20_byte_num+=2; // bump to file name
sol20_header[0] = bytes[sol20_byte_num++];
sol20_header[1] = bytes[sol20_byte_num++];
sol20_header[2] = bytes[sol20_byte_num++];
sol20_header[3] = bytes[sol20_byte_num++];
sol20_header[4] = bytes[sol20_byte_num++];
for (i = 0; i < 5; i++)
sol20_header[i] = 0x20;
for (i = 0; i < 5; i++)
{
sol20_header[i] = bytes[sol20_byte_num++];
if (sol20_header[i] == 0x20)
break;
}
sol20_header[5] = 0;
sol20_scan_to_hex(bytes); // bump to file type
sol20_header[6] = sol20_read_hex(bytes, 2);

View File

@ -1413,6 +1413,10 @@ ROM_START( abc802 )
ROMX_LOAD( "abc 32-31.14f", 0x6000, 0x2000, CRC(fc8be7a8) SHA1(a1d4cb45cf5ae21e636dddfa70c99bfd2050ad60), ROM_BIOS(3) )
ROM_SYSTEM_BIOS( 3, "mica620", "MICA DOS v.20 (1984-03-02)" )
ROMX_LOAD( "mica820.14f", 0x6000, 0x2000, CRC(edf998af) SHA1(daae7e1ff6ef3e0ddb83e932f324c56f4a98f79b), ROM_BIOS(4) )
ROM_SYSTEM_BIOS( 4, "luxnet01", "LUXNET 01" )
ROMX_LOAD( "322n01.14f", 0x6000, 0x2000, CRC(0911bc92) SHA1(bf58b3be40ce07638eb265aa2dd97c5562a0c41b), ROM_BIOS(5) )
ROM_SYSTEM_BIOS( 5, "luxnet02", "LUXNET 02" )
ROMX_LOAD( "322n02.14f", 0x6000, 0x2000, CRC(2384baec) SHA1(8ae0371242c201913b2d33a75f670d2bccf29582), ROM_BIOS(6) )
ROM_REGION( 0x1000, MC6845_TAG, 0 )
ROM_LOAD( "abc t02-1.3g", 0x0000, 0x1000, CRC(4d54eed8) SHA1(04cb5fc5f3d7ba9b9a5ae0ec94241d1fe83647f7) ) // 64 90191-01
@ -1443,6 +1447,8 @@ ROM_START( abc806 )
ROMX_LOAD( "mica2006.2k", 0x6000, 0x1000, CRC(58bc2aa8) SHA1(0604bd2396f7d15fcf3d65888b4b673f554037c0), ROM_BIOS(3) )
ROM_SYSTEM_BIOS( 3, "catnet", "CAT-NET" )
ROMX_LOAD( "cmd8_5.2k", 0x6000, 0x1000, CRC(25430ef7) SHA1(03a36874c23c215a19b0be14ad2f6b3b5fb2c839), ROM_BIOS(4) )
ROM_SYSTEM_BIOS( 4, "luxnet", "LUXNET" )
ROMX_LOAD( "ln806.2k", 0x6000, 0x1000, CRC(034b5991) SHA1(ba7f8653f4e516687a4399abef450e361f2bfd20), ROM_BIOS(5) )
ROM_LOAD_OPTIONAL( "abc 76-11.2j", 0x7000, 0x1000, CRC(3eb5f6a1) SHA1(02d4e38009c71b84952eb3b8432ad32a98a7fe16) ) // Options-PROM ABC 76-11 "64 90238-02"
ROM_LOAD( "abc 76-xx.2j", 0x7000, 0x1000, CRC(b364cc49) SHA1(9a2c373778856a31902cdbd2ae3362c200a38e24) ) // Enhanced Options-PROM

View File

@ -14,10 +14,9 @@ Notes:
Eshb has some junk in the IO TEST screen. Maybe a bad dump?
Todo:
- LD TROUBLE message pops up after each cycle in attract. NMI-related?
- LD TROUBLE appears at POST. Sync/timing issue?
- Wrong overlay colors;
- Convert to tilemaps (see next ToDo for feasibility).
- Apparently some tiles blink (in at least two different ways).
- 0xfe and 0xff are pretty obviously not NMI enables. They're likely LED's. Do the NMI right (somehow).
- Rumor has it there's an analog beep hanging off 0xf5? Implement it and finish off 0xf5 bits.
- NVRAM range 0xe000-0xe800 might be too large. It doesn't seem to write past 0xe600...
- Maybe some of the IPT_UNKNOWNs do something?
@ -41,6 +40,7 @@ public:
esh_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_laserdisc(*this, "laserdisc"),
m_screen(*this, "screen"),
m_tile_ram(*this, "tile_ram"),
m_tile_control_ram(*this, "tile_ctrl_ram"),
m_maincpu(*this, "maincpu"),
@ -48,25 +48,28 @@ public:
m_palette(*this, "palette") { }
required_device<pioneer_ldv1000_device> m_laserdisc;
required_device<screen_device> m_screen;
required_shared_ptr<UINT8> m_tile_ram;
required_shared_ptr<UINT8> m_tile_control_ram;
UINT8 m_ld_video_visible;
bool m_ld_video_visible;
DECLARE_READ8_MEMBER(ldp_read);
DECLARE_WRITE8_MEMBER(ldp_write);
DECLARE_WRITE8_MEMBER(misc_write);
DECLARE_WRITE8_MEMBER(led_writes);
DECLARE_WRITE8_MEMBER(nmi_line_w);
DECLARE_DRIVER_INIT(esh);
bool m_nmi_enable;
virtual void machine_start() override;
DECLARE_PALETTE_INIT(esh);
UINT32 screen_update_esh(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(vblank_callback_esh);
DECLARE_WRITE_LINE_MEMBER(ld_command_strobe_cb);
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
//virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
};
@ -78,10 +81,14 @@ protected:
UINT32 esh_state::screen_update_esh(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
int charx, chary;
const UINT8 pal_bank = m_ld_video_visible == true ? 0x10 : 0x00;
const UINT32 trans_mask = m_ld_video_visible == true ? 0 : -1;
gfx_element *gfx;// = m_gfxdecode->gfx(0);
/* clear */
bitmap.fill(0, cliprect);
/* Draw tiles */
for (charx = 0; charx < 32; charx++)
{
@ -91,13 +98,20 @@ UINT32 esh_state::screen_update_esh(screen_device &screen, bitmap_rgb32 &bitmap,
int palIndex = (m_tile_control_ram[current_screen_character] & 0x0f);
int tileOffs = (m_tile_control_ram[current_screen_character] & 0x10) >> 4;
//int blinkLine = (m_tile_control_ram[current_screen_character] & 0x40) >> 6;
bool blinkLine = bool((m_tile_control_ram[current_screen_character] & 0x40) >> 6);
//int blinkChar = (m_tile_control_ram[current_screen_character] & 0x80) >> 7;
m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
// TODO: blink timing
if(blinkLine == true && m_screen->frame_number() & 8)
gfx = m_gfxdecode->gfx(1);
else
gfx = m_gfxdecode->gfx(0);
gfx->transpen(bitmap,cliprect,
m_tile_ram[current_screen_character] + (0x100 * tileOffs),
palIndex,
0, 0, charx*8, chary*8, 0);
palIndex + pal_bank,
0, 0, charx*8, chary*8, trans_mask);
}
}
@ -126,7 +140,7 @@ WRITE8_MEMBER(esh_state::misc_write)
logerror("BEEP!\n");
/* Bit 2 unknown */
m_ld_video_visible = !((data & 0x08) >> 3);
m_ld_video_visible = bool(!((data & 0x08) >> 3));
/* Bits 4-7 unknown */
/* They cycle through a repeating pattern though */
@ -165,13 +179,15 @@ WRITE8_MEMBER(esh_state::led_writes)
WRITE8_MEMBER(esh_state::nmi_line_w)
{
if (data == 0x00)
m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
if (data == 0x01)
m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
// 0 -> 1 transition enables this, else disabled?
m_nmi_enable = (data & 1) == 1;
//if (data == 0x00)
// m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
//if (data == 0x01)
// m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
if (data != 0x00 && data != 0x01)
logerror("NMI line got a weird value!\n");
if (data & 0xfe)
logerror("NMI line unknown bit set %02x\n",data);
}
@ -206,7 +222,7 @@ static INPUT_PORTS_START( esh )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME( "TEST" ) PORT_CODE( KEYCODE_T )
PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
@ -259,25 +275,28 @@ PALETTE_INIT_MEMBER(esh_state, esh)
bit0 = (color_prom[i+0x100] >> 0) & 0x01;
bit1 = (color_prom[i+0x100] >> 1) & 0x01;
bit2 = (color_prom[i+0x100] >> 2) & 0x01;
r = (0x97 * bit2) + (0x47 * bit1) + (0x21 * bit0);
r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* green component */
bit0 = 0;
bit0 = 0; //(color_prom[i+0x100] >> 0) & 0x01;
bit1 = (color_prom[i+0x100] >> 3) & 0x01;
bit2 = (color_prom[i+0x100] >> 4) & 0x01;
g = (0x97 * bit2) + (0x47 * bit1) + (0x21 * bit0);
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* blue component */
bit0 = 0;
if((color_prom[i+0x100] >> 7) & 1)
b = 0xff;
else
{
bit0 = 0; //(color_prom[i+0x100] >> 5) & 0x01;
bit1 = (color_prom[i+0x100] >> 5) & 0x01;
bit2 = (color_prom[i+0x100] >> 6) & 0x01;
b = (0x97 * bit2) + (0x47 * bit1) + (0x21 * bit0);
b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
}
palette.set_pen_color(i,rgb_t(r,g,b));
}
/* make color 0 transparent */
palette.set_pen_color(0, rgb_t(0,0,0,0));
}
static const gfx_layout esh_gfx_layout =
@ -285,7 +304,7 @@ static const gfx_layout esh_gfx_layout =
8,8,
RGN_FRAC(1,3),
3,
{ RGN_FRAC(0,3), RGN_FRAC(1,3), RGN_FRAC(2,3) },
{ RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
{ 0,1,2,3,4,5,6,7 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
8*8
@ -293,8 +312,10 @@ static const gfx_layout esh_gfx_layout =
static GFXDECODE_START( esh )
GFXDECODE_ENTRY("gfx1", 0, esh_gfx_layout, 0x0, 0x20)
GFXDECODE_ENTRY("gfx2", 0, esh_gfx_layout, 0x0, 0x20)
GFXDECODE_END
#if 0
void esh_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
switch (id)
@ -306,12 +327,20 @@ void esh_state::device_timer(emu_timer &timer, device_timer_id id, int param, vo
assert_always(FALSE, "Unknown id in esh_state::device_timer");
}
}
#endif
INTERRUPT_GEN_MEMBER(esh_state::vblank_callback_esh)
{
// IRQ
device.execute().set_input_line(0, ASSERT_LINE);
timer_set(attotime::from_usec(50), TIMER_IRQ_STOP);
device.execute().set_input_line(0, HOLD_LINE);
//timer_set(attotime::from_usec(50), TIMER_IRQ_STOP);
}
// TODO: 0xfe NMI enabled after writing to LD command port, NMI reads LD port.
WRITE_LINE_MEMBER(esh_state::ld_command_strobe_cb)
{
if(m_nmi_enable)
m_maincpu->set_input_line(INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE);
}
void esh_state::machine_start()
@ -321,7 +350,6 @@ void esh_state::machine_start()
/* DRIVER */
static MACHINE_CONFIG_START( esh, esh_state )
/* main cpu */
MCFG_CPU_ADD("maincpu", Z80, PCB_CLOCK/6) /* The denominator is a Daphne guess based on PacMan's hardware */
MCFG_CPU_PROGRAM_MAP(z80_0_mem)
@ -330,8 +358,8 @@ static MACHINE_CONFIG_START( esh, esh_state )
MCFG_NVRAM_ADD_0FILL("nvram")
MCFG_LASERDISC_LDV1000_ADD("laserdisc")
MCFG_LASERDISC_LDV1000_COMMAND_STROBE_CB(WRITELINE(esh_state, ld_command_strobe_cb))
MCFG_LASERDISC_OVERLAY_DRIVER(256, 256, esh_state, screen_update_esh)
MCFG_LASERDISC_OVERLAY_PALETTE("palette")
@ -351,6 +379,11 @@ static MACHINE_CONFIG_START( esh, esh_state )
MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
MACHINE_CONFIG_END
// we just disable even lines so we can simulate line blinking
#define ROM_INTERLACED_GFX \
ROM_REGION( 0x3000, "gfx2", 0 ) \
ROM_COPY( "gfx1", 0, 0, 0x3000 ) \
ROMX_FILL( 0, 0x3000, 0x00, ROM_SKIP(1) ) \
ROM_START( esh )
/* Main program CPU */
@ -364,6 +397,8 @@ ROM_START( esh )
ROM_LOAD( "b.l3", 0x1000, 0x1000, CRC(9366dde7) SHA1(891db65384d47d13355b2eea37f57c34bc775c8f) )
ROM_LOAD( "c.k3", 0x2000, 0x1000, CRC(a936ef01) SHA1(bcacb281ccb72ceb57fb6a79380cc3a9688743c4) )
ROM_INTERLACED_GFX
/* Color (+other) PROMs */
ROM_REGION( 0x400, "proms", 0 )
ROM_LOAD( "rgb.j1", 0x000, 0x200, CRC(1e9f795f) SHA1(61a58694929fa39b2412bc9244e5681d65a0eacb) )
@ -371,7 +406,7 @@ ROM_START( esh )
ROM_LOAD( "v.c6", 0x300, 0x100, CRC(7157ba22) SHA1(07355f30efe46196d216356eda48a59fc622e43f) )
DISK_REGION( "laserdisc" )
DISK_IMAGE_READONLY( "esh", 0, NO_DUMP )
DISK_IMAGE_READONLY( "esh_ver2_en", 0, SHA1(c04709d95fd92259f013ec1cd28e3e36a163abe1) )
ROM_END
ROM_START( esha )
@ -386,6 +421,8 @@ ROM_START( esha )
ROM_LOAD( "b.l3", 0x1000, 0x1000, CRC(9366dde7) SHA1(891db65384d47d13355b2eea37f57c34bc775c8f) )
ROM_LOAD( "c.k3", 0x2000, 0x1000, CRC(a936ef01) SHA1(bcacb281ccb72ceb57fb6a79380cc3a9688743c4) )
ROM_INTERLACED_GFX
/* Color (+other) PROMs */
ROM_REGION( 0x400, "proms", 0 )
ROM_LOAD( "rgb.j1", 0x000, 0x200, CRC(1e9f795f) SHA1(61a58694929fa39b2412bc9244e5681d65a0eacb) )
@ -408,6 +445,8 @@ ROM_START( eshb )
ROM_LOAD( "b.l3", 0x1000, 0x1000, CRC(9366dde7) SHA1(891db65384d47d13355b2eea37f57c34bc775c8f) )
ROM_LOAD( "c.k3", 0x2000, 0x1000, CRC(a936ef01) SHA1(bcacb281ccb72ceb57fb6a79380cc3a9688743c4) )
ROM_INTERLACED_GFX
/* Color (+other) PROMs */
ROM_REGION( 0x400, "proms", 0 )
ROM_LOAD( "rgb.j1", 0x000, 0x200, CRC(1e9f795f) SHA1(61a58694929fa39b2412bc9244e5681d65a0eacb) )
@ -424,6 +463,6 @@ DRIVER_INIT_MEMBER(esh_state,esh)
}
/* YEAR NAME PARENT MACHINE INPUT INIT MONITOR COMPANY FULLNAME FLAGS */
GAME( 1983, esh, 0, esh, esh, esh_state, esh, ROT0, "Funai/Gakken", "Esh's Aurunmilla (set 1)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND)
GAME( 1983, esha, esh, esh, esh, esh_state, esh, ROT0, "Funai/Gakken", "Esh's Aurunmilla (set 2)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND)
GAME( 1983, eshb, esh, esh, esh, esh_state, esh, ROT0, "Funai/Gakken", "Esh's Aurunmilla (set 3)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND)
GAME( 1983, esh, 0, esh, esh, esh_state, esh, ROT0, "Funai/Gakken", "Esh's Aurunmilla (set 1)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_COLORS)
GAME( 1983, esha, esh, esh, esh, esh_state, esh, ROT0, "Funai/Gakken", "Esh's Aurunmilla (set 2)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_COLORS)
GAME( 1983, eshb, esh, esh, esh, esh_state, esh, ROT0, "Funai/Gakken", "Esh's Aurunmilla (set 3)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_COLORS)

View File

@ -7367,6 +7367,30 @@ static const gfx_layout super9_tilelayout = // Green is OK. Red needs normal go
128*8 /* every char takes 128 consecutive bytes */
};
static const gfx_layout flaming7_charlayout =
{
8,8, /* 8*8 characters */
4096, /* 4096 characters */
3, /* 3 bits per pixel */
{ 2, 4, 6 }, /* the bitplanes are packed in one byte */
{ 2*8+1, 2*8+0, 3*8+1, 3*8+0, 0*8+1, 0*8+0, 1*8+1, 1*8+0 },
{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
32*8 /* every char takes 32 consecutive bytes */
};
static const gfx_layout flaming7_tilelayout =
{
8,32, /* 8*32 characters */
256, /* 256 tiles */
4, /* 4 bits per pixel */
{ 0, 2, 4, 6 },
{ 2*8+0, 2*8+1, 3*8+0, 3*8+1, 0, 1, 1*8+0, 1*8+1 },
{ 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8,
32*8, 36*8, 40*8, 44*8, 48*8, 52*8, 56*8, 60*8,
64*8, 68*8, 72*8, 76*8, 80*8, 84*8, 88*8, 92*8,
96*8, 100*8, 104*8, 108*8, 112*8, 116*8, 120*8, 124*8 },
128*8 /* every char takes 128 consecutive bytes */
};
static GFXDECODE_START( goldstar )
@ -7472,6 +7496,11 @@ static GFXDECODE_START( super9 )
GFXDECODE_ENTRY( "gfx2", 0, super9_tilelayout, 128, 8 )
GFXDECODE_END
static GFXDECODE_START( flaming7 )
GFXDECODE_ENTRY( "gfx1", 0, flaming7_charlayout, 0, 16 )
GFXDECODE_ENTRY( "gfx2", 0, flaming7_tilelayout, 128, 8 )
GFXDECODE_END
static const gfx_layout tiles8x32_4bpp_layout =
{
@ -7638,6 +7667,7 @@ WRITE8_MEMBER(goldstar_state::ay8910_outputb_w)
//popmessage("ay8910_outputb_w %02x",data);
}
static MACHINE_CONFIG_START( goldstar, goldstar_state )
/* basic machine hardware */
@ -8186,11 +8216,10 @@ static MACHINE_CONFIG_DERIVED( bingownga, bingowng )
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( flaming7, lucky8 )
static MACHINE_CONFIG_DERIVED( flam7_w4, lucky8 )
/* basic machine hardware */
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_PROGRAM_MAP(flaming7_map)
// MCFG_CPU_IO_MAP(flaming7_readport)
MCFG_DEVICE_MODIFY("ppi8255_0")
MCFG_I8255_OUT_PORTC_CB(WRITE8(wingco_state, fl7w4_outc802_w))
@ -8198,6 +8227,21 @@ static MACHINE_CONFIG_DERIVED( flaming7, lucky8 )
MCFG_DS2401_ADD("fl7w4_id")
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( flaming7, lucky8 )
/* basic machine hardware */
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_PROGRAM_MAP(flaming7_map)
MCFG_GFXDECODE_MODIFY("gfxdecode", flaming7)
// to do serial protection.
MCFG_DEVICE_MODIFY("ppi8255_0")
MCFG_I8255_OUT_PORTC_CB(WRITE8(wingco_state, fl7w4_outc802_w))
MCFG_DS2401_ADD("fl7w4_id")
MACHINE_CONFIG_END
PALETTE_INIT_MEMBER(wingco_state, magodds)
{
@ -14149,6 +14193,8 @@ ROM_END
Flaming 7
Cyberdyne Systems, Inc.
W4 hardware.
GFX sets:
1) Red, White & Blue 7's
2) Hollywood Nights.
@ -14194,6 +14240,119 @@ ROM_START( fl7_3121 ) // Red, White & Blue 7's + Hollywood Nights. Serial 7D063
ROM_END
/*
Flaming 7's
Cyberdyne Systems.
Main - 50.
Custom Hardware.
*/
ROM_START( fl7_50 ) // Serial 00000069A1C9.
ROM_REGION( 0x8000, "maincpu", 0 )
ROM_LOAD( "50-main.u22", 0x0000, 0x8000, CRC(e097e317) SHA1(a903144cc2290b7e22045490784b592adbf9ba97) )
ROM_REGION( 0x20000, "gfx1", 0 )
ROM_LOAD( "27c1001.u6", 0x00000, 0x20000, CRC(00eac3c1) SHA1(1a955f8bc044e17f0885b4b126a66d7ad191e410) )
ROM_REGION( 0x8000, "gfx2", 0 )
ROM_LOAD( "27c256.u3", 0x00000, 0x8000, CRC(cfc8f3e2) SHA1(7dd72e3ffb0904776f3c07635b953e72f4c63068) )
/* Bipolar PROMs from the W4 hardware version */
ROM_REGION( 0x200, "proms", 0 )
ROM_LOAD( "82s129.g13", 0x0000, 0x0100, CRC(3ed8a612) SHA1(4189f1abb0033aeb64b56f63bdbc29d980c43909) )
ROM_LOAD( "82s129.g14", 0x0100, 0x0100, CRC(aa068a22) SHA1(42c6d77e5aa360c529f8aca6b925010c15eedcd7) )
ROM_REGION( 0x20, "proms2", 0 )
ROM_LOAD( "82s123.d13", 0x0000, 0x0020, CRC(c6b41352) SHA1(d7c3b5aa32e4e456c9432a13bede1db6d62eb270) )
ROM_REGION( 0x100, "unkprom", 0 )
ROM_LOAD( "82s129.f3", 0x0000, 0x0100, CRC(1d668d4a) SHA1(459117f78323ea264d3a29f1da2889bbabe9e4be) )
ROM_REGION( 0x20, "unkprom2", 0 )
ROM_LOAD( "82s123.d12", 0x0000, 0x0020, CRC(6df3f972) SHA1(0096a7f7452b70cac6c0752cb62e24b643015b5c) )
ROM_REGION(0x8, "fl7w4_id", 0) /* Electronic Serial DS2401 */
ROM_LOAD( "ds2401.bin", 0x0000, 0x0008, NO_DUMP ) // Hand built to match our ROM set
ROM_END
/*
Flaming 7's
Cyberdyne Systems.
Main - 500.
Custom Hardware.
*/
ROM_START( fl7_500 ) // Serial 000000125873.
ROM_REGION( 0x8000, "maincpu", 0 )
ROM_LOAD( "500-main.u22", 0x0000, 0x8000, CRC(e2c82c67) SHA1(951b0044de9b6104f51aa5a3176d0ea475415f7c) )
ROM_REGION( 0x20000, "gfx1", 0 )
ROM_LOAD( "27c1001.u6", 0x00000, 0x20000, CRC(00eac3c1) SHA1(1a955f8bc044e17f0885b4b126a66d7ad191e410) )
ROM_REGION( 0x8000, "gfx2", 0 )
ROM_LOAD( "27c256.u3", 0x00000, 0x8000, CRC(4e3bd980) SHA1(202d3135da7ab435f487943079d88b170dc10955) )
/* Bipolar PROMs from the W4 hardware version */
ROM_REGION( 0x200, "proms", 0 )
ROM_LOAD( "82s129.g13", 0x0000, 0x0100, CRC(3ed8a612) SHA1(4189f1abb0033aeb64b56f63bdbc29d980c43909) )
ROM_LOAD( "82s129.g14", 0x0100, 0x0100, CRC(aa068a22) SHA1(42c6d77e5aa360c529f8aca6b925010c15eedcd7) )
ROM_REGION( 0x20, "proms2", 0 )
ROM_LOAD( "82s123.d13", 0x0000, 0x0020, CRC(c6b41352) SHA1(d7c3b5aa32e4e456c9432a13bede1db6d62eb270) )
ROM_REGION( 0x100, "unkprom", 0 )
ROM_LOAD( "82s129.f3", 0x0000, 0x0100, CRC(1d668d4a) SHA1(459117f78323ea264d3a29f1da2889bbabe9e4be) )
ROM_REGION( 0x20, "unkprom2", 0 )
ROM_LOAD( "82s123.d12", 0x0000, 0x0020, CRC(6df3f972) SHA1(0096a7f7452b70cac6c0752cb62e24b643015b5c) )
ROM_REGION(0x8, "fl7w4_id", 0) /* Electronic Serial DS2401 */
ROM_LOAD( "ds2401.bin", 0x0000, 0x0008, NO_DUMP ) // Hand built to match our ROM set
ROM_END
/*
Flaming 7's
Cyberdyne Systems.
Main - 2000.
Custom Hardware.
*/
ROM_START( fl7_2000 ) // Serial 00000063A47F.
ROM_REGION( 0x8000, "maincpu", 0 )
ROM_LOAD( "2000_main_27c256.u22", 0x0000, 0x8000, CRC(9659b045) SHA1(801b6733b70b35de65cd8faba6814fa013c05ad0) )
ROM_REGION( 0x20000, "gfx1", 0 )
ROM_LOAD( "m27c1001.u6", 0x00000, 0x20000, CRC(5a2157bb) SHA1(2b170102caf1224df7a6d33bb84d19114f453d89) )
ROM_REGION( 0x8000, "gfx2", 0 )
ROM_LOAD( "27c256.u3", 0x00000, 0x8000, CRC(cfc8f3e2) SHA1(7dd72e3ffb0904776f3c07635b953e72f4c63068) )
/* Bipolar PROMs from the W4 hardware version */
ROM_REGION( 0x200, "proms", 0 )
ROM_LOAD( "82s129.g13", 0x0000, 0x0100, CRC(3ed8a612) SHA1(4189f1abb0033aeb64b56f63bdbc29d980c43909) )
ROM_LOAD( "82s129.g14", 0x0100, 0x0100, CRC(aa068a22) SHA1(42c6d77e5aa360c529f8aca6b925010c15eedcd7) )
ROM_REGION( 0x20, "proms2", 0 )
ROM_LOAD( "82s123.d13", 0x0000, 0x0020, CRC(c6b41352) SHA1(d7c3b5aa32e4e456c9432a13bede1db6d62eb270) )
ROM_REGION( 0x100, "unkprom", 0 )
ROM_LOAD( "82s129.f3", 0x0000, 0x0100, CRC(1d668d4a) SHA1(459117f78323ea264d3a29f1da2889bbabe9e4be) )
ROM_REGION( 0x20, "unkprom2", 0 )
ROM_LOAD( "82s123.d12", 0x0000, 0x0020, CRC(6df3f972) SHA1(0096a7f7452b70cac6c0752cb62e24b643015b5c) )
ROM_REGION(0x8, "fl7w4_id", 0) /* Electronic Serial DS2401 */
ROM_LOAD( "ds2401.bin", 0x0000, 0x0008, NO_DUMP ) // Hand built to match our ROM set
ROM_END
/*********************************************************************************************************************/
@ -14939,7 +15098,10 @@ GAMEL( 1993, bingownga, bingowng, bingownga,bingownga,driver_device, 0,
// --- Flaming 7's hardware (W-4 derivative) ---
GAME( 199?, fl7_3121, 0, flaming7, flaming7, driver_device, 0, ROT0, "Cyberdyne Systems", "Flaming 7 (Red, White & Blue 7's + Hollywood Nights)", 0 )
GAME( 199?, fl7_3121, 0, flam7_w4, flaming7, driver_device, 0, ROT0, "Cyberdyne Systems", "Flaming 7 (W4 Hardware, Red, White & Blue 7's + Hollywood Nights)", 0 )
GAME( 199?, fl7_50, fl7_3121, flaming7, flaming7, driver_device, 0, ROT0, "Cyberdyne Systems", "Flaming 7 (Custom Hardware, Main, 50)", MACHINE_NOT_WORKING )
GAME( 199?, fl7_500, fl7_3121, flaming7, flaming7, driver_device, 0, ROT0, "Cyberdyne Systems", "Flaming 7 (Custom Hardware, Main, 500)", MACHINE_NOT_WORKING )
GAME( 199?, fl7_2000, fl7_3121, flaming7, flaming7, driver_device, 0, ROT0, "Cyberdyne Systems", "Flaming 7 (Custom Hardware, Main, 2000)", MACHINE_NOT_WORKING )
// --- Wing W-8 hardware ---

View File

@ -9,62 +9,12 @@
http://www.best-electronics-ca.com/portfoli.htm
http://www.atari-portfolio.co.uk/pfnews/pf9.txt
Undumped Atari cartridges:
Utility-Card HPC-701
Finance-Card HPC-702
Science-Card HPC-703
File Manager / Tutorial HPC-704
PowerBASIC HPC-705
Instant Spell HPC-709
Hyperlist HPC-713
Bridge Baron HPC-724
Wine Companion HPC-725
Diet / Cholesterol Counter HPC-726
Astrologer HPC-728
Stock Tracker HPC-729
Chess HPC-750
Undumped 3rd party cartridges:
Adcalc AAC-1000
Alpha Paging Interface SAMpage
Business Contacts and Information Manager BCIM
Checkwriter
Colossal Cave Adventure
Drug Interactions
Dynapulse 200M-A
Form Letters
FORTH programming system UTIL
FX-3 DUAT Flight Software
FX-4 Flight Planner
Graphics Screens
Marine Device Interface CM380 UMPIRE
Message Mover (Mac) MSG-PKG6
Message Mover (PC) MSG-PKG5
Micro Hedge
Micro-Roentgen Radiation Monitor RM-60
Patient Management
PBase
PDD2 Utilities
Pharmaceuticals
Physician's Reference I
PIPELINE Fuel Management
REACT
Stocks Games
Terminal+
Timekeeper
TIMEPAC-5
*/
/*
TODO:
- expansion port slot interface
- clock is running too fast
- create chargen ROM from tech manual
- memory error interrupt vector
@ -73,19 +23,74 @@
- system tick frequency selection (1 or 128 Hz)
- speaker
- credit card memory (A:/B:)
- software list
*/
#include "includes/portfoli.h"
#include "bus/rs232/rs232.h"
#include "emu.h"
#include "rendlay.h"
#include "softlist.h"
#include "cpu/i86/i86.h"
#include "bus/generic/slot.h"
#include "bus/generic/carts.h"
#include "bus/pofo/exp.h"
#include "machine/nvram.h"
#include "machine/ram.h"
#include "sound/speaker.h"
#include "video/hd61830.h"
#define M80C88A_TAG "u1"
#define HD61830_TAG "hd61830"
#define TIMER_TICK_TAG "tick"
#define SCREEN_TAG "screen"
//**************************************************************************
// MACROS / CONSTANTS
//**************************************************************************
class portfolio_state : public driver_device
{
public:
portfolio_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_maincpu(*this, M80C88A_TAG),
m_lcdc(*this, HD61830_TAG),
m_speaker(*this, "speaker"),
m_exp(*this, PORTFOLIO_EXPANSION_SLOT_TAG),
m_timer_tick(*this, TIMER_TICK_TAG),
m_rom(*this, M80C88A_TAG),
m_char_rom(*this, HD61830_TAG),
m_y0(*this, "Y0"),
m_y1(*this, "Y1"),
m_y2(*this, "Y2"),
m_y3(*this, "Y3"),
m_y4(*this, "Y4"),
m_y5(*this, "Y5"),
m_y6(*this, "Y6"),
m_y7(*this, "Y7"),
m_battery(*this, "BATTERY"),
m_contrast(*this, "contrast"),
m_ram(*this, RAM_TAG)
{ }
required_device<cpu_device> m_maincpu;
required_device<hd61830_device> m_lcdc;
required_device<speaker_sound_device> m_speaker;
required_device<portfolio_expansion_slot_t> m_exp;
required_device<timer_device> m_timer_tick;
required_region_ptr<UINT8> m_rom;
required_region_ptr<UINT8> m_char_rom;
required_ioport m_y0;
required_ioport m_y1;
required_ioport m_y2;
required_ioport m_y3;
required_ioport m_y4;
required_ioport m_y5;
required_ioport m_y6;
required_ioport m_y7;
required_ioport m_battery;
virtual void machine_start() override;
virtual void machine_reset() override;
void check_interrupt();
void trigger_interrupt(int level);
void scan_keyboard();
enum
{
@ -95,16 +100,50 @@ enum
INT_EXTERNAL
};
enum
{
PID_COMMCARD = 0x00,
PID_SERIAL,
PID_PARALLEL,
PID_PRINTER,
PID_MODEM,
PID_NONE = 0xff
DECLARE_READ8_MEMBER( irq_status_r );
DECLARE_READ8_MEMBER( keyboard_r );
DECLARE_READ8_MEMBER( battery_r );
DECLARE_READ8_MEMBER( counter_r );
DECLARE_WRITE8_MEMBER( irq_mask_w );
DECLARE_WRITE8_MEMBER( speaker_w );
DECLARE_WRITE8_MEMBER( power_w );
DECLARE_WRITE8_MEMBER( unknown_w );
DECLARE_WRITE8_MEMBER( counter_w );
DECLARE_WRITE_LINE_MEMBER( iint_w );
DECLARE_WRITE_LINE_MEMBER( eint_w );
/* interrupt state */
UINT8 m_ip; /* interrupt pending */
UINT8 m_ie; /* interrupt enable */
/* counter state */
UINT16 m_counter;
/* keyboard state */
UINT8 m_keylatch;
/* video state */
required_shared_ptr<UINT8> m_contrast;
/* peripheral state */
DECLARE_PALETTE_INIT(portfolio);
TIMER_DEVICE_CALLBACK_MEMBER(keyboard_tick);
TIMER_DEVICE_CALLBACK_MEMBER(system_tick);
TIMER_DEVICE_CALLBACK_MEMBER(counter_tick);
DECLARE_READ8_MEMBER(hd61830_rd_r);
IRQ_CALLBACK_MEMBER(portfolio_int_ack);
DECLARE_DEVICE_IMAGE_LOAD_MEMBER( portfolio_cart );
required_device<ram_device> m_ram;
};
//**************************************************************************
// MACROS / CONSTANTS
//**************************************************************************
static const UINT8 INTERRUPT_VECTOR[] = { 0x08, 0x09, 0x00 };
@ -161,24 +200,13 @@ WRITE8_MEMBER( portfolio_state::irq_mask_w )
}
//-------------------------------------------------
// sivr_w - serial interrupt vector register
//-------------------------------------------------
WRITE8_MEMBER( portfolio_state::sivr_w )
{
m_sivr = data;
//logerror("SIVR %02x\n", data);
}
//-------------------------------------------------
// IRQ_CALLBACK_MEMBER( portfolio_int_ack )
//-------------------------------------------------
IRQ_CALLBACK_MEMBER(portfolio_state::portfolio_int_ack)
{
UINT8 vector = m_sivr;
UINT8 vector = 0;
for (int i = 0; i < 4; i++)
{
@ -188,7 +216,7 @@ IRQ_CALLBACK_MEMBER(portfolio_state::portfolio_int_ack)
m_ip &= ~(1 << i);
if (i == 3)
vector = m_sivr;
vector = m_exp->eack_r();
else
vector = INTERRUPT_VECTOR[i];
@ -363,7 +391,7 @@ READ8_MEMBER( portfolio_state::battery_r )
UINT8 data = 0;
/* peripheral detect */
data |= (m_pid != PID_NONE) << 5;
data |= m_exp->pdet_r() << 5;
/* battery status */
data |= BIT(m_battery->read(), 0) << 6;
@ -450,60 +478,6 @@ WRITE8_MEMBER( portfolio_state::counter_w )
//**************************************************************************
// EXPANSION
//**************************************************************************
//-------------------------------------------------
// ncc1_w - credit card memory select
//-------------------------------------------------
WRITE8_MEMBER( portfolio_state::ncc1_w )
{
address_space &program = m_maincpu->space(AS_PROGRAM);
if (BIT(data, 0))
{
// system ROM
program.install_rom(0xc0000, 0xdffff, m_rom);
}
else
{
// credit card memory
program.unmap_readwrite(0xc0000, 0xdffff);
}
//logerror("NCC %02x\n", data);
}
//-------------------------------------------------
// pid_r - peripheral identification
//-------------------------------------------------
READ8_MEMBER( portfolio_state::pid_r )
{
/*
PID peripheral
00 communication card
01 serial port
02 parallel port
03 printer peripheral
04 modem
05-3f reserved
40-7f user peripherals
80 file-transfer interface
81-ff reserved
*/
return m_pid;
}
//**************************************************************************
// ADDRESS MAPS
//**************************************************************************
@ -535,10 +509,6 @@ static ADDRESS_MAP_START( portfolio_io, AS_IO, 8, portfolio_state )
AM_RANGE(0x8050, 0x8050) AM_READWRITE(irq_status_r, irq_mask_w)
AM_RANGE(0x8051, 0x8051) AM_READWRITE(battery_r, unknown_w)
AM_RANGE(0x8060, 0x8060) AM_RAM AM_SHARE("contrast")
// AM_RANGE(0x8070, 0x8077) AM_DEVREADWRITE(M82C50A_TAG, ins8250_device, ins8250_r, ins8250_w) // Serial Interface
// AM_RANGE(0x8078, 0x807b) AM_DEVREADWRITE(M82C55A_TAG, i8255_device, read, write) // Parallel Interface
AM_RANGE(0x807c, 0x807c) AM_WRITE(ncc1_w)
AM_RANGE(0x807f, 0x807f) AM_READWRITE(pid_r, sivr_w)
ADDRESS_MAP_END
@ -636,12 +606,6 @@ static INPUT_PORTS_START( portfolio )
PORT_CONFNAME( 0x01, 0x01, "Battery Status" )
PORT_CONFSETTING( 0x01, DEF_STR( Normal ) )
PORT_CONFSETTING( 0x00, "Low Battery" )
PORT_START("PERIPHERAL")
PORT_CONFNAME( 0xff, PID_NONE, "Peripheral" )
PORT_CONFSETTING( PID_NONE, DEF_STR( None ) )
PORT_CONFSETTING( PID_PARALLEL, "Intelligent Parallel Interface (HPC-101)" )
PORT_CONFSETTING( PID_SERIAL, "Serial Interface (HPC-102)" )
INPUT_PORTS_END
@ -700,11 +664,11 @@ GFXDECODE_END
// DEVICE CONFIGURATION
//**************************************************************************
//-------------------------------------------------
// ins8250_interface i8250_intf
//-------------------------------------------------
WRITE_LINE_MEMBER( portfolio_state::iint_w )
{
}
WRITE_LINE_MEMBER( portfolio_state::i8250_intrpt_w )
WRITE_LINE_MEMBER( portfolio_state::eint_w )
{
if (state)
trigger_interrupt(INT_EXTERNAL);
@ -751,17 +715,13 @@ void portfolio_state::machine_start()
/* set initial values */
m_keylatch = 0xff;
m_sivr = 0x2a;
m_pid = 0xff;
/* register for state saving */
save_item(NAME(m_ip));
save_item(NAME(m_ie));
save_item(NAME(m_sivr));
save_item(NAME(m_counter));
save_item(NAME(m_keylatch));
save_pointer(NAME(m_contrast.target()), m_contrast.bytes());
save_item(NAME(m_pid));
}
@ -771,24 +731,6 @@ void portfolio_state::machine_start()
void portfolio_state::machine_reset()
{
address_space &io = m_maincpu->space(AS_IO);
// peripherals
m_pid = ioport("PERIPHERAL")->read();
io.unmap_readwrite(0x8070, 0x807b);
io.unmap_readwrite(0x807d, 0x807e);
switch (m_pid)
{
case PID_SERIAL:
io.install_readwrite_handler(0x8070, 0x8077, READ8_DEVICE_DELEGATE(m_uart, ins8250_device, ins8250_r), WRITE8_DEVICE_DELEGATE(m_uart, ins8250_device, ins8250_w));
break;
case PID_PARALLEL:
io.install_readwrite_handler(0x8078, 0x807b, READ8_DEVICE_DELEGATE(m_ppi, i8255_device, read), WRITE8_DEVICE_DELEGATE(m_ppi, i8255_device, write));
break;
}
}
@ -832,43 +774,16 @@ static MACHINE_CONFIG_START( portfolio, portfolio_state )
MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
/* devices */
MCFG_DEVICE_ADD(M82C55A_TAG, I8255A, 0)
MCFG_I8255_OUT_PORTA_CB(DEVWRITE8("cent_data_out", output_latch_device, write))
MCFG_I8255_OUT_PORTB_CB(DEVWRITE8("cent_ctrl_out", output_latch_device, write))
MCFG_I8255_IN_PORTC_CB(DEVREAD8("cent_status_in", input_buffer_device, read))
// devices
MCFG_PORTFOLIO_EXPANSION_SLOT_ADD(PORTFOLIO_EXPANSION_SLOT_TAG, XTAL_4_9152MHz, portfolio_expansion_cards, nullptr)
MCFG_PORTFOLIO_EXPANSION_SLOT_IINT_CALLBACK(WRITELINE(portfolio_state, iint_w))
MCFG_PORTFOLIO_EXPANSION_SLOT_EINT_CALLBACK(WRITELINE(portfolio_state, eint_w))
MCFG_PORTFOLIO_EXPANSION_SLOT_NMIO_CALLBACK(INPUTLINE(M80C88A_TAG, INPUT_LINE_NMI))
//MCFG_PORTFOLIO_EXPANSION_SLOT_WAKE_CALLBACK()
MCFG_CENTRONICS_ADD(CENTRONICS_TAG, centronics_devices, "printer")
MCFG_CENTRONICS_ACK_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit5))
MCFG_CENTRONICS_BUSY_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit4))
MCFG_CENTRONICS_FAULT_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit3))
MCFG_CENTRONICS_SELECT_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit1))
MCFG_CENTRONICS_PERROR_HANDLER(DEVWRITELINE("cent_status_in", input_buffer_device, write_bit0))
MCFG_CENTRONICS_OUTPUT_LATCH_ADD("cent_data_out", CENTRONICS_TAG)
MCFG_DEVICE_ADD("cent_status_in", INPUT_BUFFER, 0)
MCFG_DEVICE_ADD("cent_ctrl_out", OUTPUT_LATCH, 0)
MCFG_OUTPUT_LATCH_BIT0_HANDLER(DEVWRITELINE(CENTRONICS_TAG, centronics_device, write_strobe))
MCFG_OUTPUT_LATCH_BIT1_HANDLER(DEVWRITELINE(CENTRONICS_TAG, centronics_device, write_autofd))
MCFG_OUTPUT_LATCH_BIT2_HANDLER(DEVWRITELINE(CENTRONICS_TAG, centronics_device, write_init))
MCFG_OUTPUT_LATCH_BIT3_HANDLER(DEVWRITELINE(CENTRONICS_TAG, centronics_device, write_select_in))
MCFG_DEVICE_ADD(M82C50A_TAG, INS8250, XTAL_1_8432MHz) // should be INS8250A
MCFG_INS8250_OUT_TX_CB(DEVWRITELINE(RS232_TAG, rs232_port_device, write_txd))
MCFG_INS8250_OUT_DTR_CB(DEVWRITELINE(RS232_TAG, rs232_port_device, write_dtr))
MCFG_INS8250_OUT_RTS_CB(DEVWRITELINE(RS232_TAG, rs232_port_device, write_rts))
MCFG_INS8250_OUT_INT_CB(WRITELINE(portfolio_state, i8250_intrpt_w))
MCFG_TIMER_DRIVER_ADD_PERIODIC("counter", portfolio_state, counter_tick, attotime::from_hz(XTAL_32_768kHz/16384))
MCFG_TIMER_DRIVER_ADD_PERIODIC(TIMER_TICK_TAG, portfolio_state, system_tick, attotime::from_hz(XTAL_32_768kHz/32768))
MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, nullptr)
MCFG_RS232_RXD_HANDLER(DEVWRITELINE(M82C50A_TAG, ins8250_uart_device, rx_w))
MCFG_RS232_DCD_HANDLER(DEVWRITELINE(M82C50A_TAG, ins8250_uart_device, dcd_w))
MCFG_RS232_DSR_HANDLER(DEVWRITELINE(M82C50A_TAG, ins8250_uart_device, dsr_w))
MCFG_RS232_RI_HANDLER(DEVWRITELINE(M82C50A_TAG, ins8250_uart_device, ri_w))
MCFG_RS232_CTS_HANDLER(DEVWRITELINE(M82C50A_TAG, ins8250_uart_device, cts_w))
/* fake keyboard */
MCFG_TIMER_DRIVER_ADD_PERIODIC("keyboard", portfolio_state, keyboard_tick, attotime::from_usec(2500))
@ -876,19 +791,8 @@ static MACHINE_CONFIG_START( portfolio, portfolio_state )
MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "portfolio_cart")
MCFG_GENERIC_LOAD(portfolio_state, portfolio_cart)
/* memory card */
/* MCFG_MEMCARD_ADD("memcard_a")
MCFG_MEMCARD_EXTENSION_LIST("bin")
MCFG_MEMCARD_LOAD(portfolio_memcard)
MCFG_MEMCARD_SIZE_OPTIONS("32K,64K,128K")
MCFG_MEMCARD_ADD("memcard_b")
MCFG_MEMCARD_EXTENSION_LIST("bin")
MCFG_MEMCARD_LOAD(portfolio_memcard)
MCFG_MEMCARD_SIZE_OPTIONS("32K,64K,128K")*/
/* software lists */
// MCFG_SOFTWARE_LIST_ADD("cart_list", "pofo")
MCFG_SOFTWARE_LIST_ADD("cart_list", "pofo")
/* internal ram */
MCFG_RAM_ADD(RAM_TAG)

View File

@ -1,123 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Curt Coder
#pragma once
#ifndef __PORTFOLIO__
#define __PORTFOLIO__
#include "emu.h"
#include "cpu/i86/i86.h"
#include "bus/centronics/ctronics.h"
#include "machine/i8255.h"
#include "machine/ins8250.h"
#include "machine/nvram.h"
#include "machine/ram.h"
#include "sound/speaker.h"
#include "video/hd61830.h"
#include "bus/generic/slot.h"
#include "bus/generic/carts.h"
#define M80C88A_TAG "u1"
#define M82C55A_TAG "hpc101_u1"
#define M82C50A_TAG "hpc102_u1"
#define HD61830_TAG "hd61830"
#define CENTRONICS_TAG "centronics"
#define TIMER_TICK_TAG "tick"
#define SCREEN_TAG "screen"
#define RS232_TAG "rs232"
class portfolio_state : public driver_device
{
public:
portfolio_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, M80C88A_TAG),
m_lcdc(*this, HD61830_TAG),
m_ppi(*this, M82C55A_TAG),
m_uart(*this, M82C50A_TAG),
m_speaker(*this, "speaker"),
m_timer_tick(*this, TIMER_TICK_TAG),
m_rom(*this, M80C88A_TAG),
m_char_rom(*this, HD61830_TAG),
m_y0(*this, "Y0"),
m_y1(*this, "Y1"),
m_y2(*this, "Y2"),
m_y3(*this, "Y3"),
m_y4(*this, "Y4"),
m_y5(*this, "Y5"),
m_y6(*this, "Y6"),
m_y7(*this, "Y7"),
m_battery(*this, "BATTERY"),
m_contrast(*this, "contrast"),
m_ram(*this, RAM_TAG)
{ }
required_device<cpu_device> m_maincpu;
required_device<hd61830_device> m_lcdc;
required_device<i8255_device> m_ppi;
required_device<ins8250_device> m_uart;
required_device<speaker_sound_device> m_speaker;
required_device<timer_device> m_timer_tick;
required_region_ptr<UINT8> m_rom;
required_region_ptr<UINT8> m_char_rom;
required_ioport m_y0;
required_ioport m_y1;
required_ioport m_y2;
required_ioport m_y3;
required_ioport m_y4;
required_ioport m_y5;
required_ioport m_y6;
required_ioport m_y7;
required_ioport m_battery;
virtual void machine_start() override;
virtual void machine_reset() override;
void check_interrupt();
void trigger_interrupt(int level);
void scan_keyboard();
DECLARE_READ8_MEMBER( irq_status_r );
DECLARE_READ8_MEMBER( keyboard_r );
DECLARE_READ8_MEMBER( battery_r );
DECLARE_READ8_MEMBER( counter_r );
DECLARE_READ8_MEMBER( pid_r );
DECLARE_WRITE8_MEMBER( irq_mask_w );
DECLARE_WRITE8_MEMBER( sivr_w );
DECLARE_WRITE8_MEMBER( speaker_w );
DECLARE_WRITE8_MEMBER( power_w );
DECLARE_WRITE8_MEMBER( unknown_w );
DECLARE_WRITE8_MEMBER( counter_w );
DECLARE_WRITE8_MEMBER( ncc1_w );
DECLARE_WRITE_LINE_MEMBER( i8250_intrpt_w );
/* interrupt state */
UINT8 m_ip; /* interrupt pending */
UINT8 m_ie; /* interrupt enable */
UINT8 m_sivr; /* serial interrupt vector register */
/* counter state */
UINT16 m_counter;
/* keyboard state */
UINT8 m_keylatch;
/* video state */
required_shared_ptr<UINT8> m_contrast;
/* peripheral state */
UINT8 m_pid; /* peripheral identification */
DECLARE_PALETTE_INIT(portfolio);
TIMER_DEVICE_CALLBACK_MEMBER(keyboard_tick);
TIMER_DEVICE_CALLBACK_MEMBER(system_tick);
TIMER_DEVICE_CALLBACK_MEMBER(counter_tick);
DECLARE_READ8_MEMBER(hd61830_rd_r);
IRQ_CALLBACK_MEMBER(portfolio_int_ack);
DECLARE_DEVICE_IMAGE_LOAD_MEMBER( portfolio_cart );
required_device<ram_device> m_ram;
};
#endif

View File

@ -126,7 +126,7 @@ UINT16 atari_xga_device::parity(UINT16 x)
UINT16 atari_xga_device::lfsr1(UINT16 x)
{
UINT16 bit = parity(x & 0x8016);
const UINT16 bit = parity(x & 0x8016);
return (x << 1) | bit;
}
@ -138,8 +138,7 @@ UINT16 atari_xga_device::lfsr2(UINT16 x)
UINT16 atari_xga_device::powers2(UINT8 k, UINT16 x)
{
static const UINT16 L[16] =
{
static const UINT16 L[16] = {
0x5E85,0xBD0B,0x2493,0x17A3,
0x2F47,0x0005,0x000B,0x0017,
0x002F,0x005E,0x00BD,0x017A,
@ -149,16 +148,14 @@ UINT16 atari_xga_device::powers2(UINT8 k, UINT16 x)
UINT16 t = (x == 16) ? (L[4] ^ L[5]) : L[x];
for (size_t i = 0; i < k; ++i)
{
t = lfsr1(t);
}
return t;
}
UINT16 atari_xga_device::decipher(UINT8 k, UINT16 c)
{
UINT16 bit, i, p = 0;
UINT16 p = 0;
/* Only 128 keys internally, if high bit set,
then find the 7-bit "twin" by xor 0xA8. */
@ -168,11 +165,9 @@ UINT16 atari_xga_device::decipher(UINT8 k, UINT16 c)
k = kmap[k];
if ((c & (c - 1)) == 0)
{
return powers2(k, ctz(c));
}
for (bit = 0; bit < 5; ++bit)
for (UINT16 bit = 0; bit < 5; ++bit)
{
if ((c >> bit) & 1)
{
@ -180,7 +175,7 @@ UINT16 atari_xga_device::decipher(UINT8 k, UINT16 c)
}
}
for (bit = 5; bit < 16; ++bit)
for (UINT16 bit = 5; bit < 16; ++bit)
{
if ((c >> bit) & 1)
{
@ -189,7 +184,7 @@ UINT16 atari_xga_device::decipher(UINT8 k, UINT16 c)
}
UINT16 x = 0x8010;
for (i = 0; i < k + 3; ++i)
for (UINT16 i = 0; i < k + 3; ++i)
{
if (x == c)
{
@ -222,7 +217,6 @@ WRITE32_MEMBER(atari_xga_device::write)
m_ram[offset << 1] = UINT16 (data >> 16);
if (ACCESSING_BITS_0_15)
m_ram[(offset << 1) + 1] = UINT16(data & 0xFFFF);
break;
case FPGA_DECIPHER:
@ -243,8 +237,6 @@ WRITE32_MEMBER(atari_xga_device::write)
READ32_MEMBER(atari_xga_device::read)
{
UINT32 plaintext = 0;
switch (offset << 2)
{
case 0x0FC0:
@ -259,10 +251,9 @@ READ32_MEMBER(atari_xga_device::read)
}
if (m_mode == FPGA_RESET)
{
return 0;
}
UINT32 plaintext = 0;
if (m_mode == FPGA_DECIPHER)
{
UINT16 address = (offset << 2) - 0x400;

View File

@ -13453,6 +13453,9 @@ cmwm // (c) 199? Dyna Electronics
crazybon // (c) 199? Sang Ho
fb2010 // (c) 2009 Amcoe
fl7_3121 // (c) 199? Cyberdyne Systems, Inc.
fl7_50 // (c) 199? Cyberdyne Systems, Inc.
fl7_500 // (c) 199? Cyberdyne Systems, Inc.
fl7_2000 // (c) 199? Cyberdyne Systems, Inc.
goldfrui // bootleg
goldstar // (c) 198? IGS
goldstbl // (c) 198? IGS

View File

@ -22,30 +22,21 @@
#include <memory>
#include <vector>
#include "modules/lib/osdlib.h"
#include <windows/winutil.h>
template<typename _FunctionPtr>
class dynamic_bind
{
public:
// constructor which looks up the function
dynamic_bind(const TCHAR *dll, const char *symbol)
: m_function(nullptr)
{
HMODULE module = LoadLibrary(dll);
if (module != nullptr)
m_function = reinterpret_cast<_FunctionPtr>(GetProcAddress(module, symbol));
}
// bool to test if the function is nullptr or not
operator bool() const { return (m_function != nullptr); }
// dereference to get the underlying pointer
_FunctionPtr operator *() const { return m_function; }
private:
_FunctionPtr m_function;
};
// Typedefs for dynamically loaded functions
typedef BOOL (WINAPI *StackWalk64_fn)(DWORD, HANDLE, HANDLE, LPSTACKFRAME64, PVOID, PREAD_PROCESS_MEMORY_ROUTINE64, PFUNCTION_TABLE_ACCESS_ROUTINE64, PGET_MODULE_BASE_ROUTINE64, PTRANSLATE_ADDRESS_ROUTINE64);
typedef BOOL (WINAPI *SymInitialize_fn)(HANDLE, LPCTSTR, BOOL);
typedef PVOID (WINAPI *SymFunctionTableAccess64_fn)(HANDLE, DWORD64);
typedef DWORD64 (WINAPI *SymGetModuleBase64_fn)(HANDLE, DWORD64);
typedef BOOL (WINAPI *SymFromAddr_fn)(HANDLE, DWORD64, PDWORD64, PSYMBOL_INFO);
typedef BOOL (WINAPI *SymGetLineFromAddr64_fn)(HANDLE, DWORD64, PDWORD, PIMAGEHLP_LINE64);
typedef PIMAGE_SECTION_HEADER (WINAPI *ImageRvaToSection_fn)(PIMAGE_NT_HEADERS, PVOID, ULONG);
typedef PIMAGE_NT_HEADERS (WINAPI *ImageNtHeader_fn)(PVOID);
typedef VOID (WINAPI *RtlCaptureContext_fn)(PCONTEXT);
class stack_walker
{
@ -67,12 +58,14 @@ private:
CONTEXT m_context;
bool m_first;
dynamic_bind<BOOL(WINAPI *)(DWORD, HANDLE, HANDLE, LPSTACKFRAME64, PVOID, PREAD_PROCESS_MEMORY_ROUTINE64, PFUNCTION_TABLE_ACCESS_ROUTINE64, PGET_MODULE_BASE_ROUTINE64, PTRANSLATE_ADDRESS_ROUTINE64)>
m_stack_walk_64;
dynamic_bind<BOOL(WINAPI *)(HANDLE, LPCTSTR, BOOL)> m_sym_initialize;
dynamic_bind<PVOID(WINAPI *)(HANDLE, DWORD64)> m_sym_function_table_access_64;
dynamic_bind<DWORD64(WINAPI *)(HANDLE, DWORD64)> m_sym_get_module_base_64;
dynamic_bind<VOID(WINAPI *)(PCONTEXT)> m_rtl_capture_context;
osd::dynamic_module::ptr m_dbghelp_dll;
osd::dynamic_module::ptr m_kernel32_dll;
StackWalk64_fn m_stack_walk_64;
SymInitialize_fn m_sym_initialize;
SymFunctionTableAccess64_fn m_sym_function_table_access_64;
SymGetModuleBase64_fn m_sym_get_module_base_64;
RtlCaptureContext_fn m_rtl_capture_context;
static bool s_initialized;
};
@ -126,8 +119,10 @@ private:
FPTR m_last_base;
FPTR m_text_base;
dynamic_bind<BOOL(WINAPI *)(HANDLE, DWORD64, PDWORD64, PSYMBOL_INFO)> m_sym_from_addr;
dynamic_bind<BOOL(WINAPI *)(HANDLE, DWORD64, PDWORD, PIMAGEHLP_LINE64)> m_sym_get_line_from_addr_64;
osd::dynamic_module::ptr m_dbghelp_dll;
SymFromAddr_fn m_sym_from_addr;
SymGetLineFromAddr64_fn m_sym_get_line_from_addr_64;
};
class sampling_profiler
@ -176,17 +171,21 @@ bool stack_walker::s_initialized = false;
stack_walker::stack_walker()
: m_process(GetCurrentProcess()),
m_thread(GetCurrentThread()),
m_first(true),
m_stack_walk_64(TEXT("dbghelp.dll"), "StackWalk64"),
m_sym_initialize(TEXT("dbghelp.dll"), "SymInitialize"),
m_sym_function_table_access_64(TEXT("dbghelp.dll"), "SymFunctionTableAccess64"),
m_sym_get_module_base_64(TEXT("dbghelp.dll"), "SymGetModuleBase64"),
m_rtl_capture_context(TEXT("kernel32.dll"), "RtlCaptureContext")
m_first(true)
{
// zap the structs
memset(&m_stackframe, 0, sizeof(m_stackframe));
memset(&m_context, 0, sizeof(m_context));
m_dbghelp_dll = osd::dynamic_module::open({ "dbghelp.dll" });
m_kernel32_dll = osd::dynamic_module::open({ "kernel32.dll" });
m_stack_walk_64 = m_dbghelp_dll->bind<StackWalk64_fn>("StackWalk64");
m_sym_initialize = m_dbghelp_dll->bind<SymInitialize_fn>("SymInitialize");
m_sym_function_table_access_64 = m_dbghelp_dll->bind<SymFunctionTableAccess64_fn>("SymFunctionTableAccess64");
m_sym_get_module_base_64 = m_dbghelp_dll->bind<SymGetModuleBase64_fn>("SymGetModuleBase64");
m_rtl_capture_context = m_kernel32_dll->bind<RtlCaptureContext_fn>("RtlCaptureContext");
// initialize the symbols
if (!s_initialized && m_sym_initialize && m_stack_walk_64 && m_sym_function_table_access_64 && m_sym_get_module_base_64)
{
@ -294,9 +293,7 @@ symbol_manager::symbol_manager(const char *argv0)
m_symfile(argv0),
m_process(GetCurrentProcess()),
m_last_base(0),
m_text_base(0),
m_sym_from_addr(TEXT("dbghelp.dll"), "SymFromAddr"),
m_sym_get_line_from_addr_64(TEXT("dbghelp.dll"), "SymGetLineFromAddr64")
m_text_base(0)
{
#ifdef __GNUC__
// compute the name of the mapfile
@ -317,6 +314,11 @@ symbol_manager::symbol_manager(const char *argv0)
// expand the buffer to be decently large up front
m_buffer = string_format("%500s", "");
m_dbghelp_dll = osd::dynamic_module::open({ "dbghelp.dll" });
m_sym_from_addr = m_dbghelp_dll->bind<SymFromAddr_fn>("SymFromAddr");
m_sym_get_line_from_addr_64 = m_dbghelp_dll->bind<SymGetLineFromAddr64_fn>("SymGetLineFromAddr64");
}
@ -603,8 +605,10 @@ void symbol_manager::format_symbol(const char *name, UINT32 displacement, const
FPTR symbol_manager::get_text_section_base()
{
dynamic_bind<PIMAGE_SECTION_HEADER(WINAPI *)(PIMAGE_NT_HEADERS, PVOID, ULONG)> image_rva_to_section(TEXT("dbghelp.dll"), "ImageRvaToSection");
dynamic_bind<PIMAGE_NT_HEADERS(WINAPI *)(PVOID)> image_nt_header(TEXT("dbghelp.dll"), "ImageNtHeader");
osd::dynamic_module::ptr m_dbghelp_dll = osd::dynamic_module::open({ "dbghelp.dll" });
ImageRvaToSection_fn image_rva_to_section = m_dbghelp_dll->bind<ImageRvaToSection_fn>("ImageRvaToSection");
ImageNtHeader_fn image_nt_header = m_dbghelp_dll->bind<ImageNtHeader_fn>("ImageNtHeader");
// start with the image base
PVOID base = reinterpret_cast<PVOID>(GetModuleHandleUni());

View File

@ -7,6 +7,7 @@
#include "font_module.h"
#include "modules/osdmodule.h"
#include "modules/lib/osdlib.h"
// We take dependencies on WRL client headers and
// we can only build with a high enough version
@ -78,8 +79,8 @@ struct osd_deleter
typedef std::unique_ptr<char, osd_deleter> osd_utf8_ptr;
// Typedefs for dynamically loaded functions
typedef lazy_loaded_function_p4<HRESULT, D2D1_FACTORY_TYPE, REFIID, const D2D1_FACTORY_OPTIONS*, void**> d2d_create_factory_fn;
typedef lazy_loaded_function_p3<HRESULT, DWRITE_FACTORY_TYPE, REFIID, IUnknown**> dwrite_create_factory_fn;
typedef HRESULT (WINAPI *d2d_create_factory_fn)(D2D1_FACTORY_TYPE, REFIID, const D2D1_FACTORY_OPTIONS *, void **);
typedef HRESULT (*dwrite_create_factory_fn)(DWRITE_FACTORY_TYPE, REFIID, IUnknown **);
// Debugging functions
#ifdef DWRITE_DEBUGGING
@ -88,7 +89,7 @@ typedef lazy_loaded_function_p3<HRESULT, DWRITE_FACTORY_TYPE, REFIID, IUnknown**
// Save image to file
//-------------------------------------------------
void SaveBitmap(IWICBitmap* bitmap, GUID pixelFormat, const WCHAR *filename)
HRESULT SaveBitmap(IWICBitmap* bitmap, GUID pixelFormat, const WCHAR *filename)
{
HRESULT result = S_OK;
ComPtr<IWICStream> stream;
@ -96,13 +97,17 @@ void SaveBitmap(IWICBitmap* bitmap, GUID pixelFormat, const WCHAR *filename)
ComPtr<IDWriteFactory> dwriteFactory;
ComPtr<IWICImagingFactory> wicFactory;
d2d_create_factory_fn pfn_D2D1CreateFactory("D2D1CreateFactory", L"D2d1.dll");
dwrite_create_factory_fn pfn_DWriteCreateFactory("DWriteCreateFactory", L"Dwrite.dll");
HR_RET(pfn_D2D1CreateFactory.initialize());
HR_RET(pfn_DWriteCreateFactory.initialize());
osd::dynamic_module::ptr d2d1_dll = osd::dynamic_module::open({ "d2d1.dll" });
osd::dynamic_module::ptr dwrite_dll = osd::dynamic_module::open({ "dwrite.dll" });
d2d_create_factory_fn pfn_D2D1CreateFactory = d2d1_dll->bind<d2d_create_factory_fn>("D2D1CreateFactory");
dwrite_create_factory_fn pfn_DWriteCreateFactory = dwrite_dll->bind<dwrite_create_factory_fn>("DWriteCreateFactory");
if (!pfn_D2D1CreateFactory || !pfn_DWriteCreateFactory)
return ERROR_DLL_NOT_FOUND;
// Create a Direct2D factory
HR_RET(pfn_D2D1CreateFactory(
HR_RETHR((*pfn_D2D1CreateFactory)(
D2D1_FACTORY_TYPE_SINGLE_THREADED,
__uuidof(ID2D1Factory1),
nullptr,
@ -112,41 +117,43 @@ void SaveBitmap(IWICBitmap* bitmap, GUID pixelFormat, const WCHAR *filename)
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
// Create a DirectWrite factory.
HR_RET(pfn_DWriteCreateFactory(
HR_RETHR((*pfn_DWriteCreateFactory)(
DWRITE_FACTORY_TYPE_SHARED,
__uuidof(IDWriteFactory),
reinterpret_cast<IUnknown **>(dwriteFactory.GetAddressOf())));
HR_RET(CoCreateInstance(
HR_RETHR(CoCreateInstance(
CLSID_WICImagingFactory,
nullptr,
CLSCTX_INPROC_SERVER,
__uuidof(IWICImagingFactory),
(void**)&wicFactory));
HR_RET(wicFactory->CreateStream(&stream));
HR_RET(stream->InitializeFromFilename(filename, GENERIC_WRITE));
HR_RETHR(wicFactory->CreateStream(&stream));
HR_RETHR(stream->InitializeFromFilename(filename, GENERIC_WRITE));
ComPtr<IWICBitmapEncoder> encoder;
HR_RET(wicFactory->CreateEncoder(GUID_ContainerFormatBmp, nullptr, &encoder));
HR_RET(encoder->Initialize(stream.Get(), WICBitmapEncoderNoCache));
HR_RETHR(wicFactory->CreateEncoder(GUID_ContainerFormatBmp, nullptr, &encoder));
HR_RETHR(encoder->Initialize(stream.Get(), WICBitmapEncoderNoCache));
ComPtr<IWICBitmapFrameEncode> frameEncode;
HR_RET(encoder->CreateNewFrame(&frameEncode, nullptr));
HR_RET(frameEncode->Initialize(nullptr));
HR_RETHR(encoder->CreateNewFrame(&frameEncode, nullptr));
HR_RETHR(frameEncode->Initialize(nullptr));
UINT width, height;
HR_RET(bitmap->GetSize(&width, &height));
HR_RET(frameEncode->SetSize(width, height));
HR_RET(frameEncode->SetPixelFormat(&pixelFormat));
HR_RETHR(bitmap->GetSize(&width, &height));
HR_RETHR(frameEncode->SetSize(width, height));
HR_RETHR(frameEncode->SetPixelFormat(&pixelFormat));
HR_RET(frameEncode->WriteSource(bitmap, nullptr));
HR_RETHR(frameEncode->WriteSource(bitmap, nullptr));
HR_RET(frameEncode->Commit());
HR_RET(encoder->Commit());
HR_RETHR(frameEncode->Commit());
HR_RETHR(encoder->Commit());
return S_OK;
}
void SaveBitmap2(bitmap_argb32 &bitmap, const WCHAR *filename)
HRESULT SaveBitmap2(bitmap_argb32 &bitmap, const WCHAR *filename)
{
HRESULT result;
@ -158,12 +165,12 @@ void SaveBitmap2(bitmap_argb32 &bitmap, const WCHAR *filename)
for (int x = 0; x < bitmap.width(); x++)
{
UINT32 pixel = bitmap.pix32(y, x);
pRow[x] = (pixel == 0xFFFFFFFF) ? rgb_t(0xFF, 0x00, 0x00, 0x00) : pRow[x] = rgb_t(0xFF, 0xFF, 0xFF, 0xFF);
pRow[x] = (pixel == 0xFFFFFFFF) ? rgb_t(0xFF, 0x00, 0x00, 0x00) : rgb_t(0xFF, 0xFF, 0xFF, 0xFF);
}
}
ComPtr<IWICImagingFactory> wicFactory;
HR_RET(CoCreateInstance(
HR_RETHR(CoCreateInstance(
CLSID_WICImagingFactory,
nullptr,
CLSCTX_INPROC_SERVER,
@ -182,6 +189,8 @@ void SaveBitmap2(bitmap_argb32 &bitmap, const WCHAR *filename)
&bmp2);
SaveBitmap(bmp2.Get(), GUID_WICPixelFormat32bppRGBA, filename);
return S_OK;
}
#endif
@ -648,6 +657,8 @@ private:
class font_dwrite : public osd_module, public font_module
{
private:
osd::dynamic_module::ptr m_d2d1_dll;
osd::dynamic_module::ptr m_dwrite_dll;
d2d_create_factory_fn m_pfnD2D1CreateFactory;
dwrite_create_factory_fn m_pfnDWriteCreateFactory;
ComPtr<ID2D1Factory> m_d2dfactory;
@ -658,8 +669,6 @@ public:
font_dwrite() :
osd_module(OSD_FONT_PROVIDER, "dwrite"),
font_module(),
m_pfnD2D1CreateFactory("D2D1CreateFactory", L"D2d1.dll"),
m_pfnDWriteCreateFactory("DWriteCreateFactory", L"Dwrite.dll"),
m_d2dfactory(nullptr),
m_dwriteFactory(nullptr),
m_wicFactory(nullptr)
@ -668,12 +677,15 @@ public:
virtual bool probe() override
{
m_d2d1_dll = osd::dynamic_module::open({ "d2d1.dll" });
m_dwrite_dll = osd::dynamic_module::open({ "dwrite.dll" });
m_pfnD2D1CreateFactory = m_d2d1_dll->bind<d2d_create_factory_fn>("D2D1CreateFactory");
m_pfnDWriteCreateFactory = m_dwrite_dll->bind<dwrite_create_factory_fn>("DWriteCreateFactory");
// This module is available if it can load the expected API Functions
if (m_pfnD2D1CreateFactory.initialize() != 0
|| m_pfnDWriteCreateFactory.initialize() != 0)
{
if (!m_pfnD2D1CreateFactory || !m_pfnDWriteCreateFactory)
return false;
}
return true;
}
@ -685,15 +697,14 @@ public:
osd_printf_verbose("FontProvider: Initializing DirectWrite\n");
// Make sure we can initialize our api functions
if (m_pfnD2D1CreateFactory.initialize()
|| m_pfnDWriteCreateFactory.initialize())
if (!m_pfnD2D1CreateFactory || !m_pfnDWriteCreateFactory)
{
osd_printf_error("ERROR: FontProvider: Failed to load DirectWrite functions.\n");
return -1;
}
// Create a Direct2D factory.
HR_RET1(m_pfnD2D1CreateFactory(
HR_RET1((*m_pfnD2D1CreateFactory)(
D2D1_FACTORY_TYPE_SINGLE_THREADED,
__uuidof(ID2D1Factory),
nullptr,
@ -703,7 +714,7 @@ public:
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
// Create a DirectWrite factory.
HR_RET1(m_pfnDWriteCreateFactory(
HR_RET1((*m_pfnDWriteCreateFactory)(
DWRITE_FACTORY_TYPE_SHARED,
__uuidof(IDWriteFactory),
reinterpret_cast<IUnknown **>(m_dwriteFactory.GetAddressOf())));

View File

@ -136,8 +136,7 @@ void dinput_keyboard_device::reset()
dinput_api_helper::dinput_api_helper(int version)
: m_dinput(nullptr),
m_dinput_version(version),
m_pfn_DirectInputCreate("DirectInputCreateW", L"dinput.dll")
m_dinput_version(version)
{
}
@ -163,18 +162,23 @@ int dinput_api_helper::initialize()
else
#endif
{
result = m_pfn_DirectInputCreate.initialize();
if (result != DI_OK)
return result;
m_dinput_dll = osd::dynamic_module::open({ "dinput.dll" });
m_dinput_create_prt = m_dinput_dll->bind<dinput_create_fn>("DirectInputCreateW");
if (m_dinput_create_prt == nullptr)
{
osd_printf_verbose("Legacy DirectInput library dinput.dll is not available\n");
return ERROR_DLL_NOT_FOUND;
}
// first attempt to initialize DirectInput at v7
m_dinput_version = 0x0700;
result = m_pfn_DirectInputCreate(GetModuleHandleUni(), m_dinput_version, m_dinput.GetAddressOf(), nullptr);
result = (*m_dinput_create_prt)(GetModuleHandleUni(), m_dinput_version, m_dinput.GetAddressOf(), nullptr);
if (result != DI_OK)
{
// if that fails, try version 5
m_dinput_version = 0x0500;
result = m_pfn_DirectInputCreate(GetModuleHandleUni(), m_dinput_version, m_dinput.GetAddressOf(), nullptr);
result = (*m_dinput_create_prt)(GetModuleHandleUni(), m_dinput_version, m_dinput.GetAddressOf(), nullptr);
if (result != DI_OK)
{
m_dinput_version = 0;

View File

@ -2,7 +2,7 @@
#define INPUT_DINPUT_H_
#include "input_common.h"
#include "winutil.h"
#include "modules/lib/osdlib.h"
//============================================================
// dinput_device - base directinput device
@ -43,10 +43,11 @@ public:
virtual BOOL device_enum_callback(LPCDIDEVICEINSTANCE instance, LPVOID ref) = 0;
};
// Typedef for dynamically loaded function
#if DIRECTINPUT_VERSION >= 0x0800
typedef lazy_loaded_function_p4<HRESULT, HMODULE, int, IDirectInput8 **, LPUNKNOWN> pfn_dinput_create;
typedef HRESULT (WINAPI *dinput_create_fn)(HINSTANCE, DWORD, LPDIRECTINPUT8 *, LPUNKNOWN);
#else
typedef lazy_loaded_function_p4<HRESULT, HMODULE, int, IDirectInput **, LPUNKNOWN> pfn_dinput_create;
typedef HRESULT (WINAPI *dinput_create_fn)(HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN);
#endif
class dinput_api_helper
@ -58,7 +59,8 @@ private:
Microsoft::WRL::ComPtr<IDirectInput> m_dinput;
#endif
int m_dinput_version;
pfn_dinput_create m_pfn_DirectInputCreate;
osd::dynamic_module::ptr m_dinput_dll;
dinput_create_fn m_dinput_create_prt;
public:
dinput_api_helper(int version);

View File

@ -26,7 +26,7 @@
#include "strconv.h"
// MAMEOS headers
#include "winutil.h"
#include "modules/lib/osdlib.h"
#include "winmain.h"
#include "window.h"
@ -37,17 +37,11 @@
// MACROS
//============================================================
#ifdef UNICODE
#define UNICODE_SUFFIX "W"
#else
#define UNICODE_SUFFIX "A"
#endif
// RawInput APIs
typedef lazy_loaded_function_p3<INT, PRAWINPUTDEVICELIST, PINT, UINT> get_rawinput_device_list_ptr;
typedef lazy_loaded_function_p5<INT, HRAWINPUT, UINT, LPVOID, PINT, UINT> get_rawinput_data_ptr;
typedef lazy_loaded_function_p4<INT, HANDLE, UINT, LPVOID, PINT> get_rawinput_device_info_ptr;
typedef lazy_loaded_function_p3<BOOL, PCRAWINPUTDEVICE, UINT, UINT> register_rawinput_devices_ptr;
// Typedefs for dynamically loaded functions
typedef UINT (WINAPI *get_rawinput_device_list_ptr)(PRAWINPUTDEVICELIST, PUINT, UINT);
typedef UINT (WINAPI *get_rawinput_data_ptr)( HRAWINPUT, UINT, LPVOID, PUINT, UINT);
typedef UINT (WINAPI *get_rawinput_device_info_ptr)(HANDLE, UINT, LPVOID, PUINT);
typedef BOOL (WINAPI *register_rawinput_devices_ptr)(PCRAWINPUTDEVICE, UINT, UINT);
class safe_regkey
{
@ -395,13 +389,6 @@ public:
}
};
/*
register_rawinput_devices = (register_rawinput_devices_ptr)GetProcAddress(user32, "RegisterRawInputDevices");
get_rawinput_device_list = (get_rawinput_device_list_ptr)GetProcAddress(user32, "GetRawInputDeviceList");
get_rawinput_device_info = (get_rawinput_device_info_ptr)GetProcAddress(user32, "GetRawInputDeviceInfo" UNICODE_SUFFIX);
get_rawinput_data = (get_rawinput_data_ptr)GetProcAddress(user32, "GetRawInputData");
*/
//============================================================
// rawinput_module - base class for rawinput modules
//============================================================
@ -409,7 +396,7 @@ get_rawinput_data = (get_rawinput_data_ptr)GetProcAddress(user32, "GetRawInputDa
class rawinput_module : public wininput_module
{
private:
// RawInput variables
osd::dynamic_module::ptr m_user32_dll;
get_rawinput_device_list_ptr get_rawinput_device_list;
get_rawinput_data_ptr get_rawinput_data;
get_rawinput_device_info_ptr get_rawinput_device_info;
@ -418,23 +405,24 @@ private:
public:
rawinput_module(const char *type, const char* name)
: wininput_module(type, name),
get_rawinput_device_list("GetRawInputDeviceList", L"user32.dll"),
get_rawinput_data("GetRawInputData", L"user32.dll"),
get_rawinput_device_info("GetRawInputDeviceInfoW", L"user32.dll"),
register_rawinput_devices("RegisterRawInputDevices", L"user32.dll")
: wininput_module(type, name)
{
}
bool probe() override
{
int status = get_rawinput_device_list.initialize();
status |= get_rawinput_data.initialize();
status |= get_rawinput_device_info.initialize();
status |= register_rawinput_devices.initialize();
m_user32_dll = osd::dynamic_module::open({ "user32.dll" });
if (status != 0)
get_rawinput_device_list = m_user32_dll->bind<get_rawinput_device_list_ptr>("GetRawInputDeviceList");
get_rawinput_data = m_user32_dll->bind<get_rawinput_data_ptr>("GetRawInputData");
get_rawinput_device_info = m_user32_dll->bind<get_rawinput_device_info_ptr>("GetRawInputDeviceInfoW");
register_rawinput_devices = m_user32_dll->bind<register_rawinput_devices_ptr>("RegisterRawInputDevices");
if (!get_rawinput_device_list || !get_rawinput_data ||
!get_rawinput_device_info || !register_rawinput_devices )
{
return false;
}
return true;
}
@ -442,15 +430,15 @@ public:
void input_init(running_machine &machine) override
{
// get the number of devices, allocate a device list, and fetch it
int device_count = 0;
if (get_rawinput_device_list(nullptr, &device_count, sizeof(RAWINPUTDEVICELIST)) != 0)
UINT device_count = 0;
if ((*get_rawinput_device_list)(nullptr, &device_count, sizeof(RAWINPUTDEVICELIST)) != 0)
return;
if (device_count == 0)
return;
auto rawinput_devices = std::make_unique<RAWINPUTDEVICELIST[]>(device_count);
if (get_rawinput_device_list(rawinput_devices.get(), &device_count, sizeof(RAWINPUTDEVICELIST)) == -1)
if ((*get_rawinput_device_list)(rawinput_devices.get(), &device_count, sizeof(RAWINPUTDEVICELIST)) == -1)
return;
// iterate backwards through devices; new devices are added at the head
@ -478,7 +466,7 @@ public:
registration.hwndTarget = osd_common_t::s_window_list.front()->platform_window<HWND>();
// register the device
register_rawinput_devices(&registration, 1, sizeof(registration));
(*register_rawinput_devices)(&registration, 1, sizeof(registration));
}
protected:
@ -488,13 +476,11 @@ protected:
int init_internal() override
{
// look up the entry points
int status = get_rawinput_device_list.initialize();
status |= get_rawinput_data.initialize();
status |= get_rawinput_device_info.initialize();
status |= register_rawinput_devices.initialize();
if (status != 0)
if (!get_rawinput_device_list || !get_rawinput_data ||
!get_rawinput_device_info || !register_rawinput_devices )
{
return 1;
}
osd_printf_verbose("RawInput: APIs detected\n");
return 0;
@ -504,13 +490,13 @@ protected:
TDevice* create_rawinput_device(running_machine &machine, PRAWINPUTDEVICELIST rawinputdevice)
{
TDevice* devinfo;
INT name_length = 0;
UINT name_length = 0;
// determine the length of the device name, allocate it, and fetch it if not nameless
if (get_rawinput_device_info(rawinputdevice->hDevice, RIDI_DEVICENAME, nullptr, &name_length) != 0)
if ((*get_rawinput_device_info)(rawinputdevice->hDevice, RIDI_DEVICENAME, nullptr, &name_length) != 0)
return nullptr;
std::unique_ptr<TCHAR[]> tname = std::make_unique<TCHAR[]>(name_length + 1);
if (name_length > 1 && get_rawinput_device_info(rawinputdevice->hDevice, RIDI_DEVICENAME, tname.get(), &name_length) == -1)
if (name_length > 1 && (*get_rawinput_device_info)(rawinputdevice->hDevice, RIDI_DEVICENAME, tname.get(), &name_length) == -1)
return nullptr;
// if this is an RDP name, skip it
@ -544,14 +530,14 @@ protected:
std::unique_ptr<BYTE[]> larger_buffer;
LPBYTE data = small_buffer;
BOOL result;
int size;
UINT size;
// ignore if not enabled
if (!input_enabled())
return FALSE;
// determine the size of databuffer we need
if (get_rawinput_data(rawinputdevice, RID_INPUT, nullptr, &size, sizeof(RAWINPUTHEADER)) != 0)
if ((*get_rawinput_data)(rawinputdevice, RID_INPUT, nullptr, &size, sizeof(RAWINPUTHEADER)) != 0)
return FALSE;
// if necessary, allocate a temporary buffer and fetch the data
@ -564,7 +550,7 @@ protected:
}
// fetch the data and process the appropriate message types
result = get_rawinput_data(static_cast<HRAWINPUT>(rawinputdevice), RID_INPUT, data, &size, sizeof(RAWINPUTHEADER));
result = (*get_rawinput_data)(static_cast<HRAWINPUT>(rawinputdevice), RID_INPUT, data, &size, sizeof(RAWINPUTHEADER));
if (result)
{
std::lock_guard<std::mutex> scope_lock(m_module_lock);

View File

@ -218,7 +218,7 @@ protected:
{
XINPUT_STATE state = { 0 };
if (m_xinput_helper->XInputGetState(i, &state) == ERROR_SUCCESS)
if (m_xinput_helper->xinput_get_state(i, &state) == ERROR_SUCCESS)
{
// allocate and link in a new device
devinfo = m_xinput_helper->create_xinput_device(machine, i, *this);

View File

@ -32,50 +32,28 @@
#include "input_windows.h"
#include "input_xinput.h"
xinput_api_helper::xinput_api_helper()
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
: XInputGetState("XInputGetState", xinput_dll_names, ARRAY_LENGTH(xinput_dll_names))
, XInputGetCapabilities("XInputGetCapabilities", xinput_dll_names, ARRAY_LENGTH(xinput_dll_names))
#define XINPUT_LIBRARIES { "xinput1_4.dll", "xinput9_1_0.dll" }
#else
#define XINPUT_LIBRARIES { "xinput1_4.dll" }
#endif
{
}
int xinput_api_helper::initialize()
{
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
int status;
status = XInputGetState.initialize();
if (status != 0)
{
osd_printf_verbose("Failed to initialize function pointer for %s. Error: %d\n", XInputGetState.name(), status);
return -1;
}
m_xinput_dll = osd::dynamic_module::open(XINPUT_LIBRARIES);
status = XInputGetCapabilities.initialize();
if (status != 0)
XInputGetState = m_xinput_dll->bind<xinput_get_state_fn>("XInputGetState");
XInputGetCapabilities = m_xinput_dll->bind<xinput_get_caps_fn>("XInputGetCapabilities");
if (!XInputGetState || !XInputGetCapabilities)
{
osd_printf_verbose("Failed to initialize function pointer for %s. Error: %d\n", XInputGetCapabilities.name(), status);
osd_printf_verbose("Could not find XInput. Please try to reinstall DirectX runtime package.\n");
return -1;
}
#endif
return 0;
}
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// Pass-through functions for Universal Windows
inline DWORD xinput_api_helper::XInputGetState(DWORD dwUserindex, XINPUT_STATE *pState)
{
return ::XInputGetState(dwUserindex, pState);
}
inline DWORD xinput_api_helper::XInputGetCapabilities(DWORD dwUserindex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities)
{
return ::XInputGetCapabilities(dwUserindex, dwFlags, pCapabilities);
}
#endif
//============================================================
// create_xinput_device
//============================================================
@ -85,7 +63,7 @@ xinput_joystick_device * xinput_api_helper::create_xinput_device(running_machine
xinput_joystick_device *devinfo;
XINPUT_CAPABILITIES caps = { 0 };
if (FAILED(XInputGetCapabilities(index, 0, &caps)))
if (FAILED(xinput_get_capabilities(index, 0, &caps)))
{
// If we can't get the capabilities skip this device
return nullptr;
@ -125,7 +103,7 @@ void xinput_joystick_device::poll()
return;
// poll the device first
HRESULT result = m_xinput_helper->XInputGetState(xinput_state.player_index, &xinput_state.xstate);
HRESULT result = m_xinput_helper->xinput_get_state(xinput_state.player_index, &xinput_state.xstate);
// If we can't poll the device, skip
if (FAILED(result))
@ -262,7 +240,7 @@ protected:
{
XINPUT_STATE state = {0};
if (m_xinput_helper->XInputGetState(i, &state) == ERROR_SUCCESS)
if (m_xinput_helper->xinput_get_state(i, &state) == ERROR_SUCCESS)
{
// allocate and link in a new device
devinfo = m_xinput_helper->create_xinput_device(machine, i, *this);

View File

@ -3,6 +3,8 @@
#include <mutex>
#include "modules/lib/osdlib.h"
#define XINPUT_MAX_POV 4
#define XINPUT_MAX_BUTTONS 10
#define XINPUT_MAX_AXIS 4
@ -88,34 +90,30 @@ struct xinput_api_state
XINPUT_CAPABILITIES caps;
};
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// Typedef for pointers to XInput Functions
typedef lazy_loaded_function_p2<DWORD, DWORD, XINPUT_STATE*> xinput_get_state_fn;
typedef lazy_loaded_function_p3<DWORD, DWORD, DWORD, XINPUT_CAPABILITIES*> xinput_get_caps_fn;
#endif
// Typedefs for dynamically loaded functions
typedef DWORD (*xinput_get_state_fn)(DWORD, XINPUT_STATE *);
typedef DWORD (*xinput_get_caps_fn)(DWORD, DWORD, XINPUT_CAPABILITIES *);
class xinput_api_helper : public std::enable_shared_from_this<xinput_api_helper>
{
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
private:
const wchar_t* xinput_dll_names[2] = { L"xinput1_4.dll", L"xinput9_1_0.dll" };
public:
xinput_get_state_fn XInputGetState;
xinput_get_caps_fn XInputGetCapabilities;
#endif
public:
xinput_api_helper();
int initialize();
xinput_joystick_device * create_xinput_device(running_machine &machine, UINT index, wininput_module &module);
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// Pass-through functions for Universal Windows
inline DWORD XInputGetState(DWORD dwUserindex, XINPUT_STATE *pState);
inline DWORD XInputGetCapabilities(DWORD dwUserindex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities);
#endif
inline DWORD xinput_get_state(DWORD dwUserindex, XINPUT_STATE *pState)
{
return (*XInputGetState)(dwUserindex, pState);
}
inline DWORD xinput_get_capabilities(DWORD dwUserindex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities)
{
return (*XInputGetCapabilities)(dwUserindex, dwFlags, pCapabilities);
}
private:
osd::dynamic_module::ptr m_xinput_dll;
xinput_get_state_fn XInputGetState;
xinput_get_caps_fn XInputGetCapabilities;
};
class xinput_joystick_device : public device_info

View File

@ -19,6 +19,10 @@
#ifndef __OSDLIB__
#define __OSDLIB__
#include <string>
#include <type_traits>
#include <vector>
/*-----------------------------------------------------------------------------
osd_process_kill: kill the current process
@ -30,8 +34,10 @@
None.
-----------------------------------------------------------------------------*/
void osd_process_kill(void);
/*-----------------------------------------------------------------------------
osd_setenv: set environment variable
@ -48,14 +54,52 @@ void osd_process_kill(void);
int osd_setenv(const char *name, const char *value, int overwrite);
/*-----------------------------------------------------------------------------
osd_get_clipboard_text: retrieves text from the clipboard
Return value:
the returned string needs to be osd_free()-ed!
-----------------------------------------------------------------------------*/
char *osd_get_clipboard_text(void);
/*-----------------------------------------------------------------------------
dynamic_module: load functions from optional shared libraries
Notes:
- Supports Mac OS X, Unix and Windows (both desktop and Windows
Store universal applications)
- A symbol can be searched in a list of libraries (e.g. more
revisions of a same library)
-----------------------------------------------------------------------------*/
namespace osd {
class dynamic_module
{
public:
typedef std::unique_ptr<dynamic_module> ptr;
static ptr open(std::vector<std::string> &&libraries);
virtual ~dynamic_module() { };
template <typename T>
typename std::enable_if<std::is_pointer<T>::value, T>::type bind(char const *symbol)
{
return reinterpret_cast<T>(get_symbol_address(symbol));
}
protected:
typedef void (*generic_fptr_t)();
virtual generic_fptr_t get_symbol_address(char const *symbol) = 0;
};
} // namespace osd
#endif /* __OSDLIB__ */

View File

@ -13,6 +13,12 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <signal.h>
#include <dlfcn.h>
#include <codecvt>
#include <iomanip>
#include <memory>
#include <mach/mach.h>
#include <mach/mach_time.h>
@ -215,3 +221,71 @@ char *osd_get_clipboard_text(void)
return result;
}
//============================================================
// dynamic_module_posix_impl
//============================================================
namespace osd {
class dynamic_module_posix_impl : public dynamic_module
{
public:
dynamic_module_posix_impl(std::vector<std::string> &libraries)
: m_module(nullptr)
{
m_libraries = libraries;
}
virtual ~dynamic_module_posix_impl() override
{
if (m_module != nullptr)
dlclose(m_module);
};
protected:
virtual generic_fptr_t get_symbol_address(char const *symbol) override
{
/*
* given a list of libraries, if a first symbol is successfully loaded from
* one of them, all additional symbols will be loaded from the same library
*/
if (m_module)
{
return reinterpret_cast<generic_fptr_t>(dlsym(m_module, symbol));
}
for (auto const &library : m_libraries)
{
void *module = dlopen(library.c_str(), RTLD_LAZY);
if (module != nullptr)
{
generic_fptr_t function = reinterpret_cast<generic_fptr_t>(dlsym(module, symbol));
if (function != nullptr)
{
m_module = module;
return function;
}
else
{
dlclose(module);
}
}
}
return nullptr;
}
private:
std::vector<std::string> m_libraries;
void * m_module;
};
dynamic_module::ptr dynamic_module::open(std::vector<std::string> &&names)
{
return std::make_unique<dynamic_module_posix_impl>(names);
}
} // namespace osd

View File

@ -13,12 +13,19 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <signal.h>
#include <dlfcn.h>
#include <codecvt>
#include <iomanip>
#include <memory>
// MAME headers
#include "osdcore.h"
#include "osdlib.h"
#include <SDL2/SDL.h>
//============================================================
// osd_getenv
//============================================================
@ -159,3 +166,71 @@ char *osd_get_clipboard_text(void)
}
#endif
//============================================================
// dynamic_module_posix_impl
//============================================================
namespace osd {
class dynamic_module_posix_impl : public dynamic_module
{
public:
dynamic_module_posix_impl(std::vector<std::string> &libraries)
: m_module(nullptr)
{
m_libraries = libraries;
}
virtual ~dynamic_module_posix_impl() override
{
if (m_module != nullptr)
dlclose(m_module);
};
protected:
virtual generic_fptr_t get_symbol_address(char const *symbol) override
{
/*
* given a list of libraries, if a first symbol is successfully loaded from
* one of them, all additional symbols will be loaded from the same library
*/
if (m_module)
{
return reinterpret_cast<generic_fptr_t>(dlsym(m_module, symbol));
}
for (auto const &library : m_libraries)
{
void *module = dlopen(library.c_str(), RTLD_LAZY);
if (module != nullptr)
{
generic_fptr_t function = reinterpret_cast<generic_fptr_t>(dlsym(module, symbol));
if (function != nullptr)
{
m_module = module;
return function;
}
else
{
dlclose(module);
}
}
}
return nullptr;
}
private:
std::vector<std::string> m_libraries;
void * m_module;
};
dynamic_module::ptr dynamic_module::open(std::vector<std::string> &&names)
{
return std::make_unique<dynamic_module_posix_impl>(names);
}
} // namespace osd

View File

@ -17,6 +17,8 @@
#include <unistd.h>
#endif
#include <memory>
// MAME headers
#include "osdlib.h"
#include "osdcomm.h"
@ -314,3 +316,85 @@ char *osd_get_clipboard_text(void)
return result;
}
//============================================================
// osd_dynamic_bind
//============================================================
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// for classic desktop applications
#define load_library(filename) LoadLibrary(filename)
#else
// for Windows Store universal applications
#define load_library(filename) LoadPackagedLibrary(filename, 0)
#endif
namespace osd {
class dynamic_module_win32_impl : public dynamic_module
{
public:
dynamic_module_win32_impl(std::vector<std::string> &libraries)
: m_module(nullptr)
{
m_libraries = libraries;
}
virtual ~dynamic_module_win32_impl() override
{
if (m_module != nullptr)
FreeLibrary(m_module);
};
protected:
virtual generic_fptr_t get_symbol_address(char const *symbol) override
{
/*
* given a list of libraries, if a first symbol is successfully loaded from
* one of them, all additional symbols will be loaded from the same library
*/
if (m_module)
{
return reinterpret_cast<generic_fptr_t>(GetProcAddress(m_module, symbol));
}
for (auto const &library : m_libraries)
{
TCHAR *tempstr = tstring_from_utf8(library.c_str());
if (!tempstr)
return nullptr;
HMODULE module = load_library(tempstr);
osd_free(tempstr);
if (module != nullptr)
{
generic_fptr_t function = reinterpret_cast<generic_fptr_t>(GetProcAddress(module, symbol));
if (function != nullptr)
{
m_module = module;
return function;
}
else
{
FreeLibrary(module);
}
}
}
return nullptr;
}
private:
std::vector<std::string> m_libraries;
HMODULE m_module;
};
dynamic_module::ptr dynamic_module::open(std::vector<std::string> &&names)
{
return std::make_unique<dynamic_module_win32_impl>(names);
}
} // namespace osd

View File

@ -1,61 +1,47 @@
// license:BSD-3-Clause
// copyright-holders:Carl
#if defined(OSD_NET_USE_PCAP)
#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
#ifdef UNICODE
#define LIB_NAME L"wpcap.dll"
#define LoadDynamicLibrary LoadLibraryW
#else
#define LIB_NAME "wpcap.dll"
#define LoadDynamicLibrary LoadLibraryA
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include <pcap.h>
#include "emu.h"
#include "osdnet.h"
#include "netdev_module.h"
#include "modules/osdmodule.h"
#include "modules/lib/osdlib.h"
#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef interface
#define LIB_NAME "wpcap.dll"
#define LIB_ERROR_STR "Unable to load winpcap: %lx\n"
typedef DWORD except_type;
#else
#include <dlfcn.h>
#ifdef SDLMAME_MACOSX
#elif defined(SDLMAME_MACOSX)
#include <pthread.h>
#include <libkern/OSAtomic.h>
#endif
#ifdef SDLMAME_MACOSX
#define LIB_NAME "libpcap.dylib"
#else
#define LIB_NAME "libpcap.so"
#endif
#define LIB_ERROR_STR "Unable to load pcap: %s\n"
typedef void *HMODULE;
typedef const char *except_type;
#define FreeLibrary(x) dlclose(x)
#define GetLastError() dlerror()
#define GetProcAddress(x, y) dlsym(x, y)
#define LoadDynamicLibrary(x) dlopen(x, RTLD_LAZY)
#include <pcap.h>
#endif
// Typedefs for dynamically loaded functions
typedef int (*pcap_findalldevs_fn)(pcap_if_t **, char *);
typedef pcap_t *(*pcap_open_live_fn)(const char *, int, int, int, char *);
typedef int (*pcap_next_ex_fn)(pcap_t *, struct pcap_pkthdr **, const u_char **);
typedef int (*pcap_compile_fn)(pcap_t *, struct bpf_program *, const char *, int, bpf_u_int32);
typedef void (*pcap_close_fn)(pcap_t *);
typedef int (*pcap_setfilter_fn)(pcap_t *, struct bpf_program *);
typedef int (*pcap_sendpacket_fn)(pcap_t *, const u_char *, int);
typedef int (*pcap_set_datalink_fn)(pcap_t *, int);
typedef int (*pcap_dispatch_fn)(pcap_t *, int, pcap_handler, u_char *);
class pcap_module : public osd_module, public netdev_module
{
public:
pcap_module()
: osd_module(OSD_NETDEV_PROVIDER, "pcap"), netdev_module(), handle(nullptr)
: osd_module(OSD_NETDEV_PROVIDER, "pcap"), netdev_module()
{
}
virtual ~pcap_module() { }
@ -63,32 +49,46 @@ public:
virtual int init(const osd_options &options) override;
virtual void exit() override;
virtual bool probe() override;
virtual bool probe() override
{
pcap_dll = osd::dynamic_module::open({ LIB_NAME });
HMODULE handle;
pcap_findalldevs_dl = pcap_dll->bind<pcap_findalldevs_fn>("pcap_findalldevs");
pcap_open_live_dl = pcap_dll->bind<pcap_open_live_fn>("pcap_open_live");
pcap_next_ex_dl = pcap_dll->bind<pcap_next_ex_fn>("pcap_next_ex");
pcap_compile_dl = pcap_dll->bind<pcap_compile_fn>("pcap_compile");
pcap_close_dl = pcap_dll->bind<pcap_close_fn>("pcap_close");
pcap_setfilter_dl = pcap_dll->bind<pcap_setfilter_fn>("pcap_setfilter");
pcap_sendpacket_dl = pcap_dll->bind<pcap_sendpacket_fn>("pcap_sendpacket");
pcap_set_datalink_dl = pcap_dll->bind<pcap_set_datalink_fn>("pcap_set_datalink");
pcap_dispatch_dl = pcap_dll->bind<pcap_dispatch_fn>("pcap_dispatch");
if (!pcap_findalldevs_dl || !pcap_open_live_dl || !pcap_next_ex_dl ||
!pcap_compile_dl || !pcap_close_dl || !pcap_setfilter_dl ||
!pcap_sendpacket_dl || !pcap_set_datalink_dl || !pcap_dispatch_dl)
{
osd_printf_error("Unable to load the PCAP library\n");
return false;
}
return true;
}
osd::dynamic_module::ptr pcap_dll;
pcap_findalldevs_fn pcap_findalldevs_dl;
pcap_open_live_fn pcap_open_live_dl;
pcap_next_ex_fn pcap_next_ex_dl;
pcap_compile_fn pcap_compile_dl;
pcap_close_fn pcap_close_dl;
pcap_setfilter_fn pcap_setfilter_dl;
pcap_sendpacket_fn pcap_sendpacket_dl;
pcap_set_datalink_fn pcap_set_datalink_dl;
pcap_dispatch_fn pcap_dispatch_dl;
};
static int (*pcap_compile_dl)(pcap_t *, struct bpf_program *, char *, int, bpf_u_int32) = nullptr;
static int (*pcap_findalldevs_dl)(pcap_if_t **, char *) = nullptr;
static pcap_t *(*pcap_open_live_dl)(const char *name, int, int, int, char *) = nullptr;
static int (*pcap_next_ex_dl)(pcap_t *, struct pcap_pkthdr **, const u_char **) = nullptr;
static void (*pcap_close_dl)(pcap_t *) = nullptr;
static int (*pcap_setfilter_dl)(pcap_t *, struct bpf_program *) = nullptr;
static int (*pcap_sendpacket_dl)(pcap_t *, u_char *, int) = nullptr;
static int (*pcap_set_datalink_dl)(pcap_t *, int) = nullptr;
static int (*pcap_dispatch_dl)(pcap_t *, int, pcap_handler callback, u_char *) = nullptr;
#if 0
#define pcap_compile_dl pcap_compile
#define pcap_findalldevs_dl pcap_findalldevs
#define pcap_open_live_dl pcap_open_live
#define pcap_next_ex_dl pcap_next_ex
#define pcap_close_dl pcap_close
#define pcap_setfilter_dl pcap_setfilter
#define pcap_sendpacket_dl pcap_sendpacket
#define pcap_set_datalink_dl pcap_set_datalink
#endif
// FIXME: bridge between pcap_module and netdev_pcap
static pcap_module *module = nullptr;
#ifdef SDLMAME_MACOSX
struct netdev_pcap_context {
@ -140,7 +140,7 @@ static void *netdev_pcap_blocker(void *arg) {
struct netdev_pcap_context *ctx = (struct netdev_pcap_context*)arg;
while(ctx && ctx->p) {
pcap_dispatch_dl(ctx->p, 1, netdev_pcap_handler, (u_char*)ctx);
(*module->pcap_dispatch_dl)(ctx->p, 1, netdev_pcap_handler, (u_char*)ctx);
}
return 0;
@ -152,19 +152,19 @@ netdev_pcap::netdev_pcap(const char *name, class device_network_interface *ifdev
{
char errbuf[PCAP_ERRBUF_SIZE];
#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
m_p = pcap_open_live_dl(name, 65535, 1, -1, errbuf);
m_p = (*module->pcap_open_live_dl)(name, 65535, 1, -1, errbuf);
#else
m_p = pcap_open_live_dl(name, 65535, 1, 1, errbuf);
m_p = (*module->pcap_open_live_dl)(name, 65535, 1, 1, errbuf);
#endif
if(!m_p)
{
osd_printf_error("Unable to open %s: %s\n", name, errbuf);
return;
}
if(pcap_set_datalink_dl(m_p, DLT_EN10MB) == -1)
if ((*module->pcap_set_datalink_dl)(m_p, DLT_EN10MB) == -1)
{
osd_printf_error("Unable to set %s to ethernet", name);
pcap_close_dl(m_p);
(*module->pcap_close_dl)(m_p);
m_p = nullptr;
return;
}
@ -188,10 +188,10 @@ void netdev_pcap::set_mac(const char *mac)
#else
sprintf(filter, "ether dst %.2X:%.2X:%.2X:%.2X:%.2X:%.2X or ether multicast or ether broadcast", (unsigned char)mac[0], (unsigned char)mac[1], (unsigned char)mac[2],(unsigned char)mac[3], (unsigned char)mac[4], (unsigned char)mac[5]);
#endif
if(pcap_compile_dl(m_p, &fp, filter, 1, 0) == -1) {
if ((*module->pcap_compile_dl)(m_p, &fp, filter, 1, 0) == -1) {
osd_printf_error("Error with pcap_compile\n");
}
if(pcap_setfilter_dl(m_p, &fp) == -1) {
if ((*module->pcap_setfilter_dl)(m_p, &fp) == -1) {
osd_printf_error("Error with pcap_setfilter\n");
}
}
@ -203,7 +203,7 @@ int netdev_pcap::send(UINT8 *buf, int len)
printf("send invoked, but no pcap context\n");
return 0;
}
ret = pcap_sendpacket_dl(m_p, buf, len);
ret = (*module->pcap_sendpacket_dl)(m_p, buf, len);
printf("sent packet length %d, returned %d\n", len, ret);
return ret ? len : 0;
//return (!pcap_sendpacket_dl(m_p, buf, len))?len:0;
@ -228,7 +228,7 @@ int netdev_pcap::recv_dev(UINT8 **buf)
#else
struct pcap_pkthdr *header;
if(!m_p) return 0;
return (pcap_next_ex_dl(m_p, &header, (const u_char **)buf) == 1)?header->len:0;
return ((*module->pcap_next_ex_dl)(m_p, &header, (const u_char **)buf) == 1)?header->len:0;
#endif
}
@ -239,7 +239,7 @@ netdev_pcap::~netdev_pcap()
pthread_cancel(m_thread);
pthread_join(m_thread, nullptr);
#endif
if(m_p) pcap_close_dl(m_p);
if(m_p) (*module->pcap_close_dl)(m_p);
m_p = nullptr;
}
@ -249,52 +249,16 @@ static CREATE_NETDEV(create_pcap)
return dynamic_cast<osd_netdev *>(dev);
}
bool pcap_module::probe()
{
if (handle == nullptr)
{
handle = LoadDynamicLibrary(LIB_NAME);
return (handle != nullptr);
}
return true;
}
int pcap_module::init(const osd_options &options)
{
pcap_if_t *devs;
char errbuf[PCAP_ERRBUF_SIZE];
try
// FIXME: bridge between pcap_module and netdev_pcap
module = this;
if ((*pcap_findalldevs_dl)(&devs, errbuf) == -1)
{
if(!(pcap_findalldevs_dl = (int (*)(pcap_if_t **, char *))GetProcAddress(handle, "pcap_findalldevs")))
throw GetLastError();
if(!(pcap_open_live_dl = (pcap_t* (*)(const char *, int, int, int, char *))GetProcAddress(handle, "pcap_open_live")))
throw GetLastError();
if(!(pcap_next_ex_dl = (int (*)(pcap_t *, struct pcap_pkthdr **, const u_char **))GetProcAddress(handle, "pcap_next_ex")))
throw GetLastError();
if(!(pcap_compile_dl = (int (*)(pcap_t *, struct bpf_program *, char *, int, bpf_u_int32))GetProcAddress(handle, "pcap_compile")))
throw GetLastError();
if(!(pcap_close_dl = (void (*)(pcap_t *))GetProcAddress(handle, "pcap_close")))
throw GetLastError();
if(!(pcap_setfilter_dl = (int (*)(pcap_t *, struct bpf_program *))GetProcAddress(handle, "pcap_setfilter")))
throw GetLastError();
if(!(pcap_sendpacket_dl = (int (*)(pcap_t *, u_char *, int))GetProcAddress(handle, "pcap_sendpacket")))
throw GetLastError();
if(!(pcap_set_datalink_dl = (int (*)(pcap_t *, int))GetProcAddress(handle, "pcap_set_datalink")))
throw GetLastError();
if(!(pcap_dispatch_dl = (int (*)(pcap_t *, int, pcap_handler callback, u_char *))GetProcAddress(handle, "pcap_dispatch")))
throw GetLastError();
}
catch (except_type e)
{
FreeLibrary(handle);
osd_printf_error(LIB_ERROR_STR, e);
return 1;
}
if(pcap_findalldevs_dl(&devs, errbuf) == -1)
{
FreeLibrary(handle);
osd_printf_error("Unable to get network devices: %s\n", errbuf);
return 1;
}
@ -314,9 +278,8 @@ int pcap_module::init(const osd_options &options)
void pcap_module::exit()
{
clear_netdev();
//FreeLibrary(handle);
//handle = nullptr;
}
#else
#include "modules/osdmodule.h"
#include "netdev_module.h"

View File

@ -109,17 +109,17 @@ endif
$(BUILD_INTERMEDIATE_DIR)/vs_%.bin : $(SHADERS_DIR)vs_%.sc
@echo [$(<)]
$(SILENT) $(SHADERC) $(VS_FLAGS) --type vertex --depends -o $(@) -f $(<) --disasm
$(SILENT) $(SHADERC) -f $(<) -o $(@) --type vertex $(VS_FLAGS) --depends --disasm
$(SILENT) cp $(@) $(BUILD_OUTPUT_DIR)/$(@F)
$(BUILD_INTERMEDIATE_DIR)/fs_%.bin : $(SHADERS_DIR)fs_%.sc
@echo [$(<)]
$(SILENT) $(SHADERC) $(FS_FLAGS) --type fragment --depends -o $(@) -f $(<) --disasm
$(SILENT) $(SHADERC) -f $(<) -o $(@) --type fragment $(FS_FLAGS) --depends --disasm
$(SILENT) cp $(@) $(BUILD_OUTPUT_DIR)/$(@F)
$(BUILD_INTERMEDIATE_DIR)/cs_%.bin : $(SHADERS_DIR)cs_%.sc
@echo [$(<)]
$(SILENT) $(SHADERC) $(CS_FLAGS) --type compute --depends -o $(@) -f $(<) --disasm
$(SILENT) $(SHADERC) -f $(<) -o $(@) --type compute $(CS_FLAGS) --depends --disasm
$(SILENT) cp $(@) $(BUILD_OUTPUT_DIR)/$(@F)
.PHONY: all

View File

@ -1,619 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
//============================================================
//
// d3d9intf.c - Direct3D 9 abstraction layer
//
//============================================================
// standard windows headers
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#undef interface
// MAME headers
#include "emu.h"
// MAMEOS headers
#include "d3dintf.h"
//============================================================
// TYPE DEFINITIONS
//============================================================
typedef IDirect3D9 *(WINAPI *direct3dcreate9_ptr)(UINT SDKVersion);
//============================================================
// PROTOTYPES
//============================================================
static void set_interfaces(d3d_base *d3dptr);
//============================================================
// INLINES
//============================================================
static inline void convert_present_params(const present_parameters *params, D3DPRESENT_PARAMETERS *d3d9params)
{
memset(d3d9params, 0, sizeof(*d3d9params));
d3d9params->BackBufferWidth = params->BackBufferWidth;
d3d9params->BackBufferHeight = params->BackBufferHeight;
d3d9params->BackBufferFormat = params->BackBufferFormat;
d3d9params->BackBufferCount = params->BackBufferCount;
d3d9params->MultiSampleType = params->MultiSampleType;
d3d9params->MultiSampleQuality = params->MultiSampleQuality;
d3d9params->SwapEffect = params->SwapEffect;
d3d9params->hDeviceWindow = params->hDeviceWindow;
d3d9params->Windowed = params->Windowed;
d3d9params->EnableAutoDepthStencil = params->EnableAutoDepthStencil;
d3d9params->AutoDepthStencilFormat = params->AutoDepthStencilFormat;
d3d9params->Flags = params->Flags;
d3d9params->FullScreen_RefreshRateInHz = params->FullScreen_RefreshRateInHz;
d3d9params->PresentationInterval = params->PresentationInterval;
}
//============================================================
// drawd3d9_init
//============================================================
d3d_base *drawd3d9_init(void)
{
bool post_available = true;
// dynamically grab the create function from d3d9.dll
HINSTANCE dllhandle = LoadLibrary(TEXT("d3d9.dll"));
if (dllhandle == nullptr)
{
osd_printf_verbose("Direct3D: Unable to access d3d9.dll\n");
return nullptr;
}
// import the create function
direct3dcreate9_ptr direct3dcreate9 = (direct3dcreate9_ptr)GetProcAddress(dllhandle, "Direct3DCreate9");
if (direct3dcreate9 == nullptr)
{
osd_printf_verbose("Direct3D: Unable to find Direct3DCreate9\n");
FreeLibrary(dllhandle);
return nullptr;
}
// create our core direct 3d object
IDirect3D9 *d3d9 = (*direct3dcreate9)(D3D_SDK_VERSION);
if (d3d9 == nullptr)
{
osd_printf_verbose("Direct3D: Error attempting to initialize Direct3D9\n");
FreeLibrary(dllhandle);
return nullptr;
}
// dynamically grab the shader load function from d3dx9.dll
HINSTANCE fxhandle = nullptr;
for (int idx = 99; idx >= 0; idx--) // a shameful moogle
{
#ifdef UNICODE
wchar_t dllbuf[13];
wsprintf(dllbuf, TEXT("d3dx9_%d.dll"), idx);
fxhandle = LoadLibrary(dllbuf);
#else
char dllbuf[13];
sprintf(dllbuf, "d3dx9_%d.dll", idx);
fxhandle = LoadLibraryA(dllbuf);
#endif
if (fxhandle != nullptr)
{
break;
}
}
if (fxhandle == nullptr)
{
osd_printf_verbose("Direct3D: Warning - Unable find any D3D9 DLLs; disabling post-effect rendering\n");
post_available = false;
}
// allocate an object to hold our data
auto d3dptr = global_alloc(d3d_base);
d3dptr->version = 9;
d3dptr->d3dobj = d3d9;
d3dptr->dllhandle = dllhandle;
d3dptr->post_fx_available = post_available;
d3dptr->libhandle = fxhandle;
set_interfaces(d3dptr);
osd_printf_verbose("Direct3D: Using Direct3D 9\n");
return d3dptr;
}
//============================================================
// Direct3D interfaces
//============================================================
static HRESULT check_device_format(d3d_base *d3dptr, UINT adapter, D3DDEVTYPE devtype, D3DFORMAT adapterformat, DWORD usage, D3DRESOURCETYPE restype, D3DFORMAT format)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
return IDirect3D9_CheckDeviceFormat(d3d9, adapter, devtype, adapterformat, usage, restype, format);
}
static HRESULT check_device_type(d3d_base *d3dptr, UINT adapter, D3DDEVTYPE devtype, D3DFORMAT format, D3DFORMAT backformat, BOOL windowed)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
return IDirect3D9_CheckDeviceType(d3d9, adapter, devtype, format, backformat, windowed);
}
static HRESULT create_device(d3d_base *d3dptr, UINT adapter, D3DDEVTYPE devtype, HWND focus, DWORD behavior, present_parameters *params, device **dev)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
D3DPRESENT_PARAMETERS d3d9params;
convert_present_params(params, &d3d9params);
return IDirect3D9_CreateDevice(d3d9, adapter, devtype, focus, behavior, &d3d9params, (IDirect3DDevice9 **)dev);
}
static HRESULT enum_adapter_modes(d3d_base *d3dptr, UINT adapter, D3DFORMAT format, UINT index, D3DDISPLAYMODE *mode)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
return IDirect3D9_EnumAdapterModes(d3d9, adapter, format, index, mode);
}
static UINT get_adapter_count(d3d_base *d3dptr)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
return IDirect3D9_GetAdapterCount(d3d9);
}
static HRESULT get_adapter_display_mode(d3d_base *d3dptr, UINT adapter, D3DDISPLAYMODE *mode)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
return IDirect3D9_GetAdapterDisplayMode(d3d9, adapter, mode);
}
static HRESULT get_adapter_identifier(d3d_base *d3dptr, UINT adapter, DWORD flags, adapter_identifier *identifier)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
D3DADAPTER_IDENTIFIER9 id;
HRESULT result = IDirect3D9_GetAdapterIdentifier(d3d9, adapter, flags, &id);
memcpy(identifier->Driver, id.Driver, sizeof(identifier->Driver));
memcpy(identifier->Description, id.Description, sizeof(identifier->Description));
identifier->DriverVersion = id.DriverVersion;
identifier->VendorId = id.VendorId;
identifier->DeviceId = id.DeviceId;
identifier->SubSysId = id.SubSysId;
identifier->Revision = id.Revision;
identifier->DeviceIdentifier = id.DeviceIdentifier;
identifier->WHQLLevel = id.WHQLLevel;
return result;
}
static UINT get_adapter_mode_count(d3d_base *d3dptr, UINT adapter, D3DFORMAT format)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
return IDirect3D9_GetAdapterModeCount(d3d9, adapter, format);
}
static HMONITOR get_adapter_monitor(d3d_base *d3dptr, UINT adapter)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
return IDirect3D9_GetAdapterMonitor(d3d9, adapter);
}
static HRESULT get_caps_dword(d3d_base *d3dptr, UINT adapter, D3DDEVTYPE devtype, caps_index which, DWORD *value)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
D3DCAPS9 caps;
HRESULT result = IDirect3D9_GetDeviceCaps(d3d9, adapter, devtype, &caps);
switch (which)
{
case CAPS_PRESENTATION_INTERVALS: *value = caps.PresentationIntervals; break;
case CAPS_CAPS2: *value = caps.Caps2; break;
case CAPS_DEV_CAPS: *value = caps.DevCaps; break;
case CAPS_SRCBLEND_CAPS: *value = caps.SrcBlendCaps; break;
case CAPS_DSTBLEND_CAPS: *value = caps.DestBlendCaps; break;
case CAPS_TEXTURE_CAPS: *value = caps.TextureCaps; break;
case CAPS_TEXTURE_FILTER_CAPS: *value = caps.TextureFilterCaps; break;
case CAPS_TEXTURE_ADDRESS_CAPS: *value = caps.TextureAddressCaps; break;
case CAPS_TEXTURE_OP_CAPS: *value = caps.TextureOpCaps; break;
case CAPS_MAX_TEXTURE_ASPECT: *value = caps.MaxTextureAspectRatio; break;
case CAPS_MAX_TEXTURE_WIDTH: *value = caps.MaxTextureWidth; break;
case CAPS_MAX_TEXTURE_HEIGHT: *value = caps.MaxTextureHeight; break;
case CAPS_STRETCH_RECT_FILTER: *value = caps.StretchRectFilterCaps; break;
case CAPS_MAX_PS30_INSN_SLOTS: *value = caps.MaxPixelShader30InstructionSlots; break;
}
return result;
}
static ULONG release(d3d_base *d3dptr)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
ULONG result = IDirect3D9_Release(d3d9);
FreeLibrary(d3dptr->dllhandle);
global_free(d3dptr);
return result;
}
static const interface d3d9_interface =
{
check_device_format,
check_device_type,
create_device,
enum_adapter_modes,
get_adapter_count,
get_adapter_display_mode,
get_adapter_identifier,
get_adapter_mode_count,
get_adapter_monitor,
get_caps_dword,
release
};
//============================================================
// Direct3DDevice interfaces
//============================================================
static HRESULT device_begin_scene(device *dev)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_BeginScene(device);
}
static HRESULT device_clear(device *dev, DWORD count, const D3DRECT *rects, DWORD flags, D3DCOLOR color, float z, DWORD stencil)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_Clear(device, count, rects, flags, color, z, stencil);
}
static HRESULT device_create_offscreen_plain_surface(device *dev, UINT width, UINT height, D3DFORMAT format, D3DPOOL pool, surface **surface)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height, format, pool, (IDirect3DSurface9 **)surface, nullptr);
}
static HRESULT device_create_texture(device *dev, UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, texture **texture)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_CreateTexture(device, width, height, levels, usage, format, pool, (IDirect3DTexture9 **)texture, nullptr);
}
static HRESULT device_create_vertex_buffer(device *dev, UINT length, DWORD usage, DWORD fvf, D3DPOOL pool, vertex_buffer **buf)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_CreateVertexBuffer(device, length, usage, fvf, pool, (IDirect3DVertexBuffer9 **)buf, nullptr);
}
static HRESULT device_draw_primitive(device *dev, D3DPRIMITIVETYPE type, UINT start, UINT count)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_DrawPrimitive(device, type, start, count);
}
static HRESULT device_end_scene(device *dev)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_EndScene(device);
}
static HRESULT device_get_raster_status(device *dev, D3DRASTER_STATUS *status)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_GetRasterStatus(device, 0, status);
}
static HRESULT device_get_render_target(device *dev, DWORD index, surface **surface)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_GetRenderTarget(device, index, (IDirect3DSurface9 **)surface);
}
static HRESULT device_get_render_target_data(device *dev, surface *rendertarget, surface *destsurface)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_GetRenderTargetData(device, (IDirect3DSurface9 *)rendertarget, (IDirect3DSurface9 *)destsurface);
}
static HRESULT device_present(device *dev, const RECT *source, const RECT *dest, HWND override, RGNDATA *dirty, DWORD flags)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
if (flags != 0)
{
IDirect3DSwapChain9 *chain;
HRESULT result = IDirect3DDevice9_GetSwapChain(device, 0, &chain);
if (result == D3D_OK)
{
result = IDirect3DSwapChain9_Present(chain, source, dest, override, dirty, flags);
IDirect3DSwapChain9_Release(chain);
return result;
}
}
return IDirect3DDevice9_Present(device, source, dest, override, dirty);
}
static ULONG device_release(device *dev)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_Release(device);
}
static HRESULT device_reset(device *dev, present_parameters *params)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
D3DPRESENT_PARAMETERS d3d9params;
convert_present_params(params, &d3d9params);
return IDirect3DDevice9_Reset(device, &d3d9params);
}
static void device_set_gamma_ramp(device *dev, DWORD flags, const D3DGAMMARAMP *ramp)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
IDirect3DDevice9_SetGammaRamp(device, 0, flags, ramp);
}
static HRESULT device_set_render_state(device *dev, D3DRENDERSTATETYPE state, DWORD value)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_SetRenderState(device, state, value);
}
static HRESULT device_set_render_target(device *dev, DWORD index, surface *surf)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
IDirect3DSurface9 *surface = (IDirect3DSurface9 *)surf;
return IDirect3DDevice9_SetRenderTarget(device, index, surface);
}
static HRESULT device_create_render_target(device *dev, UINT width, UINT height, D3DFORMAT format, surface **surface)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_CreateRenderTarget(device, width, height, format, D3DMULTISAMPLE_NONE, 0, false, (IDirect3DSurface9 **)surface, nullptr);
}
static HRESULT device_set_stream_source(device *dev, UINT number, vertex_buffer *vbuf, UINT stride)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
IDirect3DVertexBuffer9 *vertexbuf = (IDirect3DVertexBuffer9 *)vbuf;
return IDirect3DDevice9_SetStreamSource(device, number, vertexbuf, 0, stride);
}
static HRESULT device_set_texture(device *dev, DWORD stage, texture *tex)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
IDirect3DBaseTexture9 *texture = (IDirect3DBaseTexture9 *)tex;
return IDirect3DDevice9_SetTexture(device, stage, texture);
}
static HRESULT device_set_texture_stage_state(device *dev, DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD value)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
// some state which was here got pushed into sampler state in D3D9
switch ((DWORD)state)
{
case D3DTSS_ADDRESSU:
return IDirect3DDevice9_SetSamplerState(device, stage, D3DSAMP_ADDRESSU, value);
case D3DTSS_ADDRESSV:
return IDirect3DDevice9_SetSamplerState(device, stage, D3DSAMP_ADDRESSV, value);
case D3DTSS_BORDERCOLOR:
return IDirect3DDevice9_SetSamplerState(device, stage, D3DSAMP_BORDERCOLOR, value);
case D3DTSS_MAGFILTER:
return IDirect3DDevice9_SetSamplerState(device, stage, D3DSAMP_MAGFILTER, value);
case D3DTSS_MINFILTER:
return IDirect3DDevice9_SetSamplerState(device, stage, D3DSAMP_MINFILTER, value);
case D3DTSS_MIPFILTER:
return IDirect3DDevice9_SetSamplerState(device, stage, D3DSAMP_MIPFILTER, value);
case D3DTSS_MIPMAPLODBIAS:
return IDirect3DDevice9_SetSamplerState(device, stage, D3DSAMP_MIPMAPLODBIAS, value);
case D3DTSS_MAXMIPLEVEL:
return IDirect3DDevice9_SetSamplerState(device, stage, D3DSAMP_MAXMIPLEVEL, value);
case D3DTSS_MAXANISOTROPY:
return IDirect3DDevice9_SetSamplerState(device, stage, D3DSAMP_MAXANISOTROPY, value);
default:
return IDirect3DDevice9_SetTextureStageState(device, stage, state, value);
}
}
static HRESULT device_set_vertex_format(device *dev, D3DFORMAT format)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_SetFVF(device, format);
}
static HRESULT device_stretch_rect(device *dev, surface *source, const RECT *srcrect, surface *dest, const RECT *dstrect, D3DTEXTUREFILTERTYPE filter)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
IDirect3DSurface9 *ssurface = (IDirect3DSurface9 *)source;
IDirect3DSurface9 *dsurface = (IDirect3DSurface9 *)dest;
return IDirect3DDevice9_StretchRect(device, ssurface, srcrect, dsurface, dstrect, filter);
}
static HRESULT device_test_cooperative_level(device *dev)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_TestCooperativeLevel(device);
}
static const d3d_device_interface d3d9_device_interface =
{
device_begin_scene,
device_clear,
device_create_offscreen_plain_surface,
device_create_texture,
device_create_vertex_buffer,
device_create_render_target,
device_draw_primitive,
device_end_scene,
device_get_raster_status,
device_get_render_target,
device_get_render_target_data,
device_present,
device_release,
device_reset,
device_set_gamma_ramp,
device_set_render_state,
device_set_render_target,
device_set_stream_source,
device_set_texture,
device_set_texture_stage_state,
device_set_vertex_format,
device_stretch_rect,
device_test_cooperative_level
};
//============================================================
// Direct3DSurface interfaces
//============================================================
static HRESULT surface_lock_rect(surface *surf, D3DLOCKED_RECT *locked, const RECT *rect, DWORD flags)
{
IDirect3DSurface9 *surface = (IDirect3DSurface9 *)surf;
return IDirect3DSurface9_LockRect(surface, locked, rect, flags);
}
static ULONG surface_release(surface *surf)
{
IDirect3DSurface9 *surface = (IDirect3DSurface9 *)surf;
return IDirect3DSurface9_Release(surface);
}
static HRESULT surface_unlock_rect(surface *surf)
{
IDirect3DSurface9 *surface = (IDirect3DSurface9 *)surf;
return IDirect3DSurface9_UnlockRect(surface);
}
static const surface_interface d3d9_surface_interface =
{
surface_lock_rect,
surface_release,
surface_unlock_rect
};
//============================================================
// Direct3DTexture interfaces
//============================================================
static HRESULT texture_get_surface_level(texture *tex, UINT level, surface **surface)
{
IDirect3DTexture9 *texture = (IDirect3DTexture9 *)tex;
return IDirect3DTexture9_GetSurfaceLevel(texture, level, (IDirect3DSurface9 **)surface);
}
static HRESULT texture_lock_rect(texture *tex, UINT level, D3DLOCKED_RECT *locked, const RECT *rect, DWORD flags)
{
IDirect3DTexture9 *texture = (IDirect3DTexture9 *)tex;
return IDirect3DTexture9_LockRect(texture, level, locked, rect, flags);
}
static ULONG texture_release(texture *tex)
{
IDirect3DTexture9 *texture = (IDirect3DTexture9 *)tex;
return IDirect3DTexture9_Release(texture);
}
static HRESULT texture_unlock_rect(texture *tex, UINT level)
{
IDirect3DTexture9 *texture = (IDirect3DTexture9 *)tex;
return IDirect3DTexture9_UnlockRect(texture, level);
}
static const texture_interface d3d9_texture_interface =
{
texture_get_surface_level,
texture_lock_rect,
texture_release,
texture_unlock_rect
};
//============================================================
// Direct3DVertexBuffer interfaces
//============================================================
static HRESULT vertex_buffer_lock(vertex_buffer *vbuf, UINT offset, UINT size, VOID **data, DWORD flags)
{
IDirect3DVertexBuffer9 *vertexbuf = (IDirect3DVertexBuffer9 *)vbuf;
return IDirect3DVertexBuffer9_Lock(vertexbuf, offset, size, data, flags);
}
static ULONG vertex_buffer_release(vertex_buffer *vbuf)
{
IDirect3DVertexBuffer9 *vertexbuf = (IDirect3DVertexBuffer9 *)vbuf;
return IDirect3DVertexBuffer9_Release(vertexbuf);
}
static HRESULT vertex_buffer_unlock(vertex_buffer *vbuf)
{
IDirect3DVertexBuffer9 *vertexbuf = (IDirect3DVertexBuffer9 *)vbuf;
return IDirect3DVertexBuffer9_Unlock(vertexbuf);
}
static const vertex_buffer_interface d3d9_vertex_buffer_interface =
{
vertex_buffer_lock,
vertex_buffer_release,
vertex_buffer_unlock
};
//============================================================
// set_interfaces
//============================================================
static void set_interfaces(d3d_base *d3dptr)
{
d3dptr->d3d = d3d9_interface;
d3dptr->device = d3d9_device_interface;
d3dptr->surface = d3d9_surface_interface;
d3dptr->texture = d3d9_texture_interface;
d3dptr->vertexbuf = d3d9_vertex_buffer_interface;
}

View File

@ -64,7 +64,6 @@ public:
{ }
d3d_texture_manager(renderer_d3d9 *d3d);
~d3d_texture_manager();
void update_textures();
@ -142,9 +141,9 @@ public:
int get_cur_frame() const { return m_cur_frame; }
int get_prev_frame() const { return m_prev_frame; }
texture * get_tex() const { return m_d3dtex; }
surface * get_surface() const { return m_d3dsurface; }
texture * get_finaltex() const { return m_d3dfinaltex; }
IDirect3DTexture9 * get_tex() const { return m_d3dtex; }
IDirect3DSurface9 * get_surface() const { return m_d3dsurface; }
IDirect3DTexture9 * get_finaltex() const { return m_d3dfinaltex; }
vec2f & get_uvstart() { return m_start; }
vec2f & get_uvstop() { return m_stop; }
@ -173,9 +172,9 @@ private:
int m_xprescale, m_yprescale; // X/Y prescale factor
int m_cur_frame; // what is our current frame?
int m_prev_frame; // what was our last frame? (used to determine pause state)
texture * m_d3dtex; // Direct3D texture pointer
surface * m_d3dsurface; // Direct3D offscreen plain surface pointer
texture * m_d3dfinaltex; // Direct3D final (post-scaled) texture
IDirect3DTexture9 * m_d3dtex; // Direct3D texture pointer
IDirect3DSurface9 * m_d3dsurface; // Direct3D offscreen plain surface pointer
IDirect3DTexture9 * m_d3dfinaltex; // Direct3D final (post-scaled) texture
};
/* poly_info holds information about a single polygon/d3d primitive */
@ -254,8 +253,8 @@ public:
bool init(renderer_d3d9 *d3d, d3d_base *d3dintf, int source_width, int source_height, int target_width, int target_height);
surface *last_target;
texture *last_texture;
IDirect3DSurface9 *last_target;
IDirect3DTexture9 *last_texture;
int target_width;
int target_height;
@ -293,16 +292,16 @@ public:
int screen_index;
int page_index;
surface *target_surface[2];
texture *target_texture[2];
surface *source_surface[2];
texture *source_texture[2];
IDirect3DSurface9 *target_surface[2];
IDirect3DTexture9 *target_texture[2];
IDirect3DSurface9 *source_surface[2];
IDirect3DTexture9 *source_texture[2];
d3d_render_target *next;
d3d_render_target *prev;
surface *bloom_surface[MAX_BLOOM_COUNT];
texture *bloom_texture[MAX_BLOOM_COUNT];
IDirect3DSurface9 *bloom_surface[MAX_BLOOM_COUNT];
IDirect3DTexture9 *bloom_texture[MAX_BLOOM_COUNT];
float bloom_dims[MAX_BLOOM_COUNT][2];

View File

@ -2,18 +2,10 @@
// copyright-holders:Aaron Giles
//============================================================
//
// d3dhlsl.c - Win32 Direct3D HLSL implementation
// d3dhlsl.cpp - Win32 Direct3D HLSL implementation
//
//============================================================
// Useful info:
// Windows XP/2003 shipped with DirectX 8.1
// Windows 2000 shipped with DirectX 7a
// Windows 98SE shipped with DirectX 6.1a
// Windows 98 shipped with DirectX 5
// Windows NT shipped with DirectX 3.0a
// Windows 95 shipped with DirectX 2
// MAME headers
#include "emu.h"
#include "drivenum.h"
@ -46,14 +38,6 @@
static void get_vector(const char *data, int count, float *out, bool report_error);
//============================================================
// TYPE DEFINITIONS
//============================================================
typedef HRESULT (WINAPI *direct3dx9_loadeffect_ptr)(LPDIRECT3DDEVICE9 pDevice, LPCTSTR pSrcFile, const D3DXMACRO *pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, LPD3DXEFFECTPOOL pPool, LPD3DXEFFECT *ppEffect, LPD3DXBUFFER *ppCompilationErrors);
static direct3dx9_loadeffect_ptr g_load_effect = nullptr;
//============================================================
// shader manager constructor
//============================================================
@ -119,21 +103,21 @@ void shaders::window_save()
return;
}
HRESULT result = (*d3dintf->device.create_texture)(d3d->get_device(), snap_width, snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &snap_copy_texture);
if (result != D3D_OK)
HRESULT result = d3d->get_device()->CreateTexture(snap_width, snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &snap_copy_texture, nullptr);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Unable to init system-memory target for HLSL snapshot (%08x), bailing\n", (UINT32)result);
return;
}
(*d3dintf->texture.get_surface_level)(snap_copy_texture, 0, &snap_copy_target);
snap_copy_texture->GetSurfaceLevel(0, &snap_copy_target);
result = (*d3dintf->device.create_texture)(d3d->get_device(), snap_width, snap_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &snap_texture);
if (result != D3D_OK)
result = d3d->get_device()->CreateTexture(snap_width, snap_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &snap_texture, nullptr);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Unable to init video-memory target for HLSL snapshot (%08x), bailing\n", (UINT32)result);
return;
}
(*d3dintf->texture.get_surface_level)(snap_texture, 0, &snap_target);
snap_texture->GetSurfaceLevel(0, &snap_target);
render_snap = true;
snap_rendered = false;
@ -169,7 +153,7 @@ void shaders::window_record()
// shaders::avi_update_snap
//============================================================
void shaders::avi_update_snap(surface *surface)
void shaders::avi_update_snap(IDirect3DSurface9 *surface)
{
if (!master_enable || !d3dintf->post_fx_available)
{
@ -185,15 +169,15 @@ void shaders::avi_update_snap(surface *surface)
}
// copy the texture
HRESULT result = (*d3dintf->device.get_render_target_data)(d3d->get_device(), surface, avi_copy_surface);
if (result != D3D_OK)
HRESULT result = d3d->get_device()->GetRenderTargetData(surface, avi_copy_surface);
if (FAILED(result))
{
return;
}
// lock the texture
result = (*d3dintf->surface.lock_rect)(avi_copy_surface, &rect, nullptr, D3DLOCK_DISCARD);
if (result != D3D_OK)
result = avi_copy_surface->LockRect(&rect, nullptr, D3DLOCK_DISCARD);
if (FAILED(result))
{
return;
}
@ -211,11 +195,9 @@ void shaders::avi_update_snap(surface *surface)
}
// unlock
result = (*d3dintf->surface.unlock_rect)(avi_copy_surface);
if (result != D3D_OK)
{
osd_printf_verbose("Direct3D: Error %08X during texture unlock_rect call\n", (int)result);
}
result = avi_copy_surface->UnlockRect();
if (FAILED(result))
osd_printf_verbose("Direct3D: Error %08lX during texture UnlockRect call\n", result);
}
@ -224,7 +206,7 @@ void shaders::avi_update_snap(surface *surface)
// hlsl_render_snapshot
//============================================================
void shaders::render_snapshot(surface *surface)
void shaders::render_snapshot(IDirect3DSurface9 *surface)
{
if (!master_enable || !d3dintf->post_fx_available)
{
@ -242,15 +224,15 @@ void shaders::render_snapshot(surface *surface)
}
// copy the texture
HRESULT result = (*d3dintf->device.get_render_target_data)(d3d->get_device(), surface, snap_copy_target);
if (result != D3D_OK)
HRESULT result = d3d->get_device()->GetRenderTargetData(surface, snap_copy_target);
if (FAILED(result))
{
return;
}
// lock the texture
result = (*d3dintf->surface.lock_rect)(snap_copy_target, &rect, nullptr, D3DLOCK_DISCARD);
if (result != D3D_OK)
result = snap_copy_target->LockRect(&rect, nullptr, D3DLOCK_DISCARD);
if (FAILED(result))
{
return;
}
@ -292,30 +274,31 @@ void shaders::render_snapshot(surface *surface)
png_free(&pnginfo);
// unlock
result = (*d3dintf->surface.unlock_rect)(snap_copy_target);
if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during texture unlock_rect call\n", (int)result);
result = snap_copy_target->UnlockRect();
if (FAILED(result))
osd_printf_verbose("Direct3D: Error %08lX during texture UnlockRect call\n", result);
if (snap_texture != nullptr)
{
(*d3dintf->texture.release)(snap_texture);
snap_texture->Release();
snap_texture = nullptr;
}
if (snap_target != nullptr)
{
(*d3dintf->surface.release)(snap_target);
snap_target->Release();
snap_target = nullptr;
}
if (snap_copy_texture != nullptr)
{
(*d3dintf->texture.release)(snap_copy_texture);
snap_copy_texture->Release();
snap_copy_texture = nullptr;
}
if (snap_copy_target != nullptr)
{
(*d3dintf->surface.release)(snap_copy_target);
snap_copy_target->Release();
snap_copy_target = nullptr;
}
}
@ -332,7 +315,7 @@ void shaders::record_texture()
return;
}
surface *surface = avi_final_target;
IDirect3DSurface9 *surface = avi_final_target;
// ignore if nothing to do
if (avi_output_file == nullptr || surface == nullptr)
@ -621,20 +604,17 @@ void shaders::set_texture(texture_info *texture)
void shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *renderer)
{
if (!d3dintf->post_fx_available)
{
return;
}
d3dx9_dll = osd::dynamic_module::open({ "d3dx9_43.dll" });
g_load_effect = (direct3dx9_loadeffect_ptr)GetProcAddress(d3dintf->libhandle, "D3DXCreateEffectFromFileW");
if (g_load_effect == nullptr)
d3dx_create_effect_from_file_ptr = d3dx9_dll->bind<d3dx_create_effect_from_file_fn>("D3DXCreateEffectFromFileW");
if (!d3dx_create_effect_from_file_ptr)
{
printf("Direct3D: Unable to find D3DXCreateEffectFromFileW\n");
d3dintf->post_fx_available = false;
return;
}
d3dintf->post_fx_available = true;
this->d3dintf = d3dintf;
this->machine = machine;
this->d3d = renderer;
@ -837,41 +817,44 @@ int shaders::create_resources(bool reset, std::vector<ui::menu_item>& sliders)
options = &last_options;
}
HRESULT result = (*d3dintf->device.get_render_target)(d3d->get_device(), 0, &backbuffer);
if (result != D3D_OK)
HRESULT result = d3d->get_device()->GetRenderTarget(0, &backbuffer);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Error %08X during device get_render_target call\n", (int)result);
osd_printf_verbose("Direct3D: Error %08lX during device GetRenderTarget call\n", result);
}
result = (*d3dintf->device.create_texture)(d3d->get_device(), 4, 4, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &black_texture);
if (result != D3D_OK)
result = d3d->get_device()->CreateTexture(4, 4, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &black_texture, nullptr);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Unable to init video-memory target for black texture (%08x)\n", (UINT32)result);
return 1;
}
(*d3dintf->texture.get_surface_level)(black_texture, 0, &black_surface);
result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, black_surface);
if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
result = (*d3dintf->device.clear)(d3d->get_device(), 0, nullptr, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, backbuffer);
if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
black_texture->GetSurfaceLevel(0, &black_surface);
result = d3d->get_device()->SetRenderTarget(0, black_surface);
if (FAILED(result))
osd_printf_verbose("Direct3D: Error %08lX during device SetRenderTarget call\n", result);
result = d3d->get_device()->Clear(0, nullptr, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
if (FAILED(result))
osd_printf_verbose("Direct3D: Error %08lX during device clear call\n", result);
result = d3d->get_device()->SetRenderTarget(0, backbuffer);
if (FAILED(result))
osd_printf_verbose("Direct3D: Error %08lX during device SetRenderTarget call\n", result);
result = (*d3dintf->device.create_texture)(d3d->get_device(), (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture);
if (result != D3D_OK)
result = d3d->get_device()->CreateTexture((int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture, nullptr);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Unable to init system-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result);
return 1;
}
(*d3dintf->texture.get_surface_level)(avi_copy_texture, 0, &avi_copy_surface);
avi_copy_texture->GetSurfaceLevel(0, &avi_copy_surface);
result = (*d3dintf->device.create_texture)(d3d->get_device(), (int)snap_width, (int)snap_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &avi_final_texture);
if (result != D3D_OK)
result = d3d->get_device()->CreateTexture((int)snap_width, (int)snap_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &avi_final_texture, nullptr);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Unable to init video-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result);
return 1;
}
(*d3dintf->texture.get_surface_level)(avi_final_texture, 0, &avi_final_target);
avi_final_texture->GetSurfaceLevel(0, &avi_final_target);
emu_file file(machine->options().art_path(), OPEN_FLAG_READ);
render_load_png(shadow_bitmap, file, nullptr, options->shadow_mask_texture);
@ -890,7 +873,7 @@ int shaders::create_resources(bool reset, std::vector<ui::menu_item>& sliders)
texture.seqid = 0;
// now create it (no prescale, no wrap)
shadow_texture = new texture_info(d3d->get_texture_manager(), &texture, 1, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
shadow_texture = global_alloc(texture_info(d3d->get_texture_manager(), &texture, 1, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32)));
}
const char *fx_dir = downcast<windows_options &>(machine->options()).screen_post_fx_dir();
@ -1035,10 +1018,10 @@ void shaders::begin_draw()
downsample_effect->set_technique("DefaultTechnique");
vector_effect->set_technique("DefaultTechnique");
HRESULT result = (*d3dintf->device.get_render_target)(d3d->get_device(), 0, &backbuffer);
if (result != D3D_OK)
HRESULT result = d3d->get_device()->GetRenderTarget(0, &backbuffer);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Error %08X during device get_render_target call\n", (int)result);
osd_printf_verbose("Direct3D: Error %08lX during device GetRenderTarget call\n", result);
}
}
@ -1058,7 +1041,7 @@ void shaders::begin_frame()
//============================================================
void shaders::blit(
surface *dst,
IDirect3DSurface9 *dst,
bool clear_dst,
D3DPRIMITIVETYPE prim_type,
UINT32 prim_index,
@ -1068,18 +1051,18 @@ void shaders::blit(
if (dst != nullptr)
{
result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, dst);
if (result != D3D_OK)
result = d3d->get_device()->SetRenderTarget(0, dst);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
osd_printf_verbose("Direct3D: Error %08lX during device SetRenderTarget call\n", result);
}
if (clear_dst)
{
result = (*d3dintf->device.clear)(d3d->get_device(), 0, nullptr, D3DCLEAR_TARGET, D3DCOLOR_ARGB(1,0,0,0), 0, 0);
if (result != D3D_OK)
result = d3d->get_device()->Clear(0, nullptr, D3DCLEAR_TARGET, D3DCOLOR_ARGB(1,0,0,0), 0, 0);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
osd_printf_verbose("Direct3D: Error %08lX during device clear call\n", result);
}
}
}
@ -1092,10 +1075,10 @@ void shaders::blit(
curr_effect->begin_pass(pass);
// add the primitives
result = (*d3dintf->device.draw_primitive)(d3d->get_device(), prim_type, prim_index, prim_count);
if (result != D3D_OK)
result = d3d->get_device()->DrawPrimitive(prim_type, prim_index, prim_count);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
osd_printf_verbose("Direct3D: Error %08lX during device DrawPrimitive call\n", result);
}
curr_effect->end_pass();
@ -1565,10 +1548,10 @@ int shaders::screen_pass(d3d_render_target *rt, int source_index, poly_info *pol
{
blit(avi_final_target, false, poly->get_type(), vertnum, poly->get_count());
HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, backbuffer);
if (result != D3D_OK)
HRESULT result = d3d->get_device()->SetRenderTarget(0, backbuffer);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
osd_printf_verbose("Direct3D: Error %08lX during device SetRenderTarget call\n", result);
}
}
@ -1576,10 +1559,10 @@ int shaders::screen_pass(d3d_render_target *rt, int source_index, poly_info *pol
{
blit(snap_target, false, poly->get_type(), vertnum, poly->get_count());
HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, backbuffer);
if (result != D3D_OK)
HRESULT result = d3d->get_device()->SetRenderTarget(0, backbuffer);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
osd_printf_verbose("Direct3D: Error %08lX during device SetRenderTarget call\n", result);
}
snap_rendered = true;
@ -1684,10 +1667,10 @@ void shaders::render_quad(poly_info *poly, int vertnum)
next_index = vector_pass(rt, next_index, poly, vertnum);
HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, backbuffer);
if (result != D3D_OK)
HRESULT result = d3d->get_device()->SetRenderTarget(0, backbuffer);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
osd_printf_verbose("Direct3D: Error %08lX during device SetRenderTarget call\n", result);
}
}
else if (PRIMFLAG_GET_VECTORBUF(poly->get_flags()) && vector_enable)
@ -1736,10 +1719,10 @@ void shaders::render_quad(poly_info *poly, int vertnum)
next_index = screen_pass(rt, next_index, poly, vertnum);
d3d->set_wrap(PRIMFLAG_GET_TEXWRAP(curr_texture->get_flags()) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP);
HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, backbuffer);
if (result != D3D_OK)
HRESULT result = d3d->get_device()->SetRenderTarget(0, backbuffer);
if (FAILED(result))
{
osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
osd_printf_verbose("Direct3D: Error %08lX during device SetRenderTarget call\n", result);
}
lines_pending = false;
@ -1770,13 +1753,14 @@ void shaders::end_draw()
return;
}
(*d3dintf->surface.release)(backbuffer);
backbuffer->Release();
}
//============================================================
// shaders::add_cache_target - register a cache target
//============================================================
bool shaders::add_cache_target(renderer_d3d9* d3d, texture_info* texture, int source_width, int source_height, int target_width, int target_height, int screen_index)
{
cache_target* target = (cache_target*)global_alloc_clear<cache_target>();
@ -1803,6 +1787,7 @@ bool shaders::add_cache_target(renderer_d3d9* d3d, texture_info* texture, int so
//============================================================
// shaders::get_texture_target(render_primitive::prim, texture_info::texture)
//============================================================
d3d_render_target* shaders::get_texture_target(render_primitive *prim, texture_info *texture)
{
auto win = d3d->assert_window();
@ -2108,42 +2093,42 @@ void shaders::delete_resources(bool reset)
if (backbuffer != nullptr)
{
(*d3dintf->surface.release)(backbuffer);
backbuffer->Release();
backbuffer = nullptr;
}
if (black_surface != nullptr)
{
(*d3dintf->surface.release)(black_surface);
black_surface->Release();
black_surface = nullptr;
}
if (black_texture != nullptr)
{
(*d3dintf->texture.release)(black_texture);
black_texture->Release();
black_texture = nullptr;
}
if (avi_copy_texture != nullptr)
{
(*d3dintf->texture.release)(avi_copy_texture);
avi_copy_texture->Release();
avi_copy_texture = nullptr;
}
if (avi_copy_surface != nullptr)
{
(*d3dintf->surface.release)(avi_copy_surface);
avi_copy_surface->Release();
avi_copy_surface = nullptr;
}
if (avi_final_texture != nullptr)
{
(*d3dintf->texture.release)(avi_final_texture);
avi_final_texture->Release();
avi_final_texture = nullptr;
}
if (avi_final_target != nullptr)
{
(*d3dintf->surface.release)(avi_final_target);
avi_final_target->Release();
avi_final_target = nullptr;
}
@ -2909,12 +2894,12 @@ void uniform::set(bool x)
m_bval = x;
}
void uniform::set(matrix *mat)
void uniform::set(D3DMATRIX *mat)
{
m_mval = mat;
}
void uniform::set(texture *tex)
void uniform::set(IDirect3DTexture9 *tex)
{
m_texture = tex;
}
@ -2951,9 +2936,8 @@ void uniform::upload()
// effect functions
//============================================================
effect::effect(shaders *shadersys, device *dev, const char *name, const char *path)
effect::effect(shaders *shadersys, IDirect3DDevice9 *dev, const char *name, const char *path)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
LPD3DXBUFFER buffer_errors = nullptr;
m_shaders = shadersys;
@ -2966,7 +2950,7 @@ effect::effect(shaders *shadersys, device *dev, const char *name, const char *pa
sprintf(name_cstr, "%s\\%s", path, name);
TCHAR *effect_name = tstring_from_utf8(name_cstr);
HRESULT hr = (*g_load_effect)(device, effect_name, nullptr, nullptr, 0, nullptr, &m_effect, &buffer_errors);
HRESULT hr = (*shadersys->d3dx_create_effect_from_file_ptr)(dev, effect_name, nullptr, nullptr, 0, nullptr, &m_effect, &buffer_errors);
if (FAILED(hr))
{
if (buffer_errors != nullptr)
@ -3093,14 +3077,14 @@ void effect::set_bool(D3DXHANDLE param, bool value)
m_effect->SetBool(param, value);
}
void effect::set_matrix(D3DXHANDLE param, matrix *matrix)
void effect::set_matrix(D3DXHANDLE param, D3DMATRIX *matrix)
{
m_effect->SetMatrix(param, (D3DXMATRIX*)matrix);
}
void effect::set_texture(D3DXHANDLE param, texture *tex)
void effect::set_texture(D3DXHANDLE param, IDirect3DTexture9 *tex)
{
m_effect->SetTexture(param, (IDirect3DTexture9*)tex);
m_effect->SetTexture(param, tex);
}
D3DXHANDLE effect::get_parameter(D3DXHANDLE param, const char *name)

View File

@ -13,16 +13,15 @@
#include "aviio.h"
#include "../frontend/mame/ui/menuitem.h"
#include "../frontend/mame/ui/slider.h"
//============================================================
// CONSTANTS
//============================================================
#include "modules/lib/osdlib.h"
//============================================================
// TYPE DEFINITIONS
//============================================================
// Typedefs for dynamically loaded functions
typedef HRESULT (*d3dx_create_effect_from_file_fn)(LPDIRECT3DDEVICE9, LPCTSTR, const D3DXMACRO *, LPD3DXINCLUDE, DWORD, LPD3DXEFFECTPOOL, LPD3DXEFFECT *, LPD3DXBUFFER *);
class effect;
class shaders;
@ -115,8 +114,8 @@ public:
void set(float x);
void set(int x);
void set(bool x);
void set(matrix *mat);
void set(texture *tex);
void set(D3DMATRIX *mat);
void set(IDirect3DTexture9 *tex);
void upload();
void update();
@ -127,8 +126,8 @@ protected:
float m_vec[4];
int m_ival;
bool m_bval;
matrix *m_mval;
texture *m_texture;
D3DMATRIX *m_mval;
IDirect3DTexture9 *m_texture;
int m_count;
uniform_type m_type;
int m_id;
@ -142,7 +141,7 @@ class effect
friend class uniform;
public:
effect(shaders *shadersys, device *dev, const char *name, const char *path);
effect(shaders *shadersys, IDirect3DDevice9 *dev, const char *name, const char *path);
~effect();
void begin(UINT *passes, DWORD flags);
@ -157,8 +156,8 @@ public:
void set_float(D3DXHANDLE param, float value);
void set_int(D3DXHANDLE param, int value);
void set_bool(D3DXHANDLE param, bool value);
void set_matrix(D3DXHANDLE param, matrix *matrix);
void set_texture(D3DXHANDLE param, texture *tex);
void set_matrix(D3DXHANDLE param, D3DMATRIX *matrix);
void set_texture(D3DXHANDLE param, IDirect3DTexture9 *tex);
void add_uniform(const char *name, uniform::uniform_type type, int id);
void update_uniforms();
@ -329,8 +328,8 @@ public:
void window_record();
bool recording() const { return avi_output_file != nullptr; }
void avi_update_snap(surface *surface);
void render_snapshot(surface *surface);
void avi_update_snap(IDirect3DSurface9 *surface);
void render_snapshot(IDirect3DSurface9 *surface);
void record_texture();
void init_fsfx_quad(void *vertbuf);
@ -350,7 +349,7 @@ public:
void *get_slider_option(int id, int index = 0);
private:
void blit(surface *dst, bool clear_dst, D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count);
void blit(IDirect3DSurface9 *dst, bool clear_dst, D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count);
void enumerate_screens();
void end_avi_recording();
@ -399,28 +398,28 @@ private:
int avi_frame; // AVI frame
attotime avi_frame_period; // AVI frame period
attotime avi_next_frame_time; // AVI next frame time
surface * avi_copy_surface; // AVI destination surface in system memory
texture * avi_copy_texture; // AVI destination texture in system memory
surface * avi_final_target; // AVI upscaled surface
texture * avi_final_texture; // AVI upscaled texture
IDirect3DSurface9 * avi_copy_surface; // AVI destination surface in system memory
IDirect3DTexture9 * avi_copy_texture; // AVI destination texture in system memory
IDirect3DSurface9 * avi_final_target; // AVI upscaled surface
IDirect3DTexture9 * avi_final_texture; // AVI upscaled texture
surface * black_surface; // black dummy surface
texture * black_texture; // black dummy texture
IDirect3DSurface9 * black_surface; // black dummy surface
IDirect3DTexture9 * black_texture; // black dummy texture
bool render_snap; // whether or not to take HLSL post-render snapshot
bool snap_rendered; // whether we just rendered our HLSL post-render shot or not
surface * snap_copy_target; // snapshot destination surface in system memory
texture * snap_copy_texture; // snapshot destination surface in system memory
surface * snap_target; // snapshot upscaled surface
texture * snap_texture; // snapshot upscaled texture
IDirect3DSurface9 * snap_copy_target; // snapshot destination surface in system memory
IDirect3DTexture9 * snap_copy_texture; // snapshot destination surface in system memory
IDirect3DSurface9 * snap_target; // snapshot upscaled surface
IDirect3DTexture9 * snap_texture; // snapshot upscaled texture
int snap_width; // snapshot width
int snap_height; // snapshot height
bool lines_pending; // whether or not we have lines to flush on the next quad
bool initialized; // whether or not we're initialize
bool initialized; // whether or not we're initialized
// HLSL effects
surface * backbuffer; // pointer to our device's backbuffer
IDirect3DSurface9 * backbuffer; // pointer to our device's backbuffer
effect * curr_effect; // pointer to the currently active effect object
effect * default_effect; // pointer to the primary-effect object
effect * prescale_effect; // pointer to the prescale-effect object
@ -447,6 +446,9 @@ private:
static slider_desc s_sliders[];
static hlsl_options last_options; // last used options
static char last_system_name[16]; // last used system
osd::dynamic_module::ptr d3dx9_dll;
d3dx_create_effect_from_file_fn d3dx_create_effect_from_file_ptr;
};
#endif

View File

@ -1,239 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
//============================================================
//
// d3dintf.h - Direct3D 8/9 interface abstractions
//
//============================================================
#ifndef __WIN_D3DINTF__
#define __WIN_D3DINTF__
// standard windows headers
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
#include <mmsystem.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <math.h>
#undef interface
//============================================================
// CONSTANTS
//============================================================
#ifndef D3DCAPS2_DYNAMICTEXTURES
#define D3DCAPS2_DYNAMICTEXTURES 0x20000000L
#endif
#ifndef D3DPRESENT_DONOTWAIT
#define D3DPRESENT_DONOTWAIT 0x00000001L
#endif
#define D3DTSS_ADDRESSU 13
#define D3DTSS_ADDRESSV 14
#define D3DTSS_BORDERCOLOR 15
#define D3DTSS_MAGFILTER 16
#define D3DTSS_MINFILTER 17
#define D3DTSS_MIPFILTER 18
#define D3DTSS_MIPMAPLODBIAS 19
#define D3DTSS_MAXMIPLEVEL 20
#define D3DTSS_MAXANISOTROPY 21
//============================================================
// TYPE DEFINITIONS
//============================================================
struct d3d_base;
struct device;
struct surface;
struct texture;
struct vertex_buffer;
class effect;
typedef D3DXVECTOR4 vector;
typedef D3DMATRIX matrix;
//============================================================
// Abstracted presentation parameters
//============================================================
struct present_parameters
{
UINT BackBufferWidth;
UINT BackBufferHeight;
D3DFORMAT BackBufferFormat;
UINT BackBufferCount;
D3DMULTISAMPLE_TYPE MultiSampleType;
DWORD MultiSampleQuality;
D3DSWAPEFFECT SwapEffect;
HWND hDeviceWindow;
BOOL Windowed;
BOOL EnableAutoDepthStencil;
D3DFORMAT AutoDepthStencilFormat;
DWORD Flags;
UINT FullScreen_RefreshRateInHz;
UINT PresentationInterval;
};
//============================================================
// Abstracted device identifier
//============================================================
struct adapter_identifier
{
char Driver[512];
char Description[512];
LARGE_INTEGER DriverVersion;
DWORD VendorId;
DWORD DeviceId;
DWORD SubSysId;
DWORD Revision;
GUID DeviceIdentifier;
DWORD WHQLLevel;
};
//============================================================
// Caps enumeration
//============================================================
enum caps_index
{
CAPS_PRESENTATION_INTERVALS,
CAPS_CAPS2,
CAPS_DEV_CAPS,
CAPS_SRCBLEND_CAPS,
CAPS_DSTBLEND_CAPS,
CAPS_TEXTURE_CAPS,
CAPS_TEXTURE_FILTER_CAPS,
CAPS_TEXTURE_ADDRESS_CAPS,
CAPS_TEXTURE_OP_CAPS,
CAPS_MAX_TEXTURE_ASPECT,
CAPS_MAX_TEXTURE_WIDTH,
CAPS_MAX_TEXTURE_HEIGHT,
CAPS_STRETCH_RECT_FILTER,
CAPS_MAX_PS30_INSN_SLOTS
};
//============================================================
// Direct3D interfaces
//============================================================
struct interface
{
HRESULT (*check_device_format)(d3d_base *d3dptr, UINT adapter, D3DDEVTYPE devtype, D3DFORMAT adapterformat, DWORD usage, D3DRESOURCETYPE restype, D3DFORMAT format);
HRESULT (*check_device_type)(d3d_base *d3dptr, UINT adapter, D3DDEVTYPE devtype, D3DFORMAT format, D3DFORMAT backformat, BOOL windowed);
HRESULT (*create_device)(d3d_base *d3dptr, UINT adapter, D3DDEVTYPE devtype, HWND focus, DWORD behavior, present_parameters *params, device **dev);
HRESULT (*enum_adapter_modes)(d3d_base *d3dptr, UINT adapter, D3DFORMAT format, UINT index, D3DDISPLAYMODE *mode);
UINT (*get_adapter_count)(d3d_base *d3dptr);
HRESULT (*get_adapter_display_mode)(d3d_base *d3dptr, UINT adapter, D3DDISPLAYMODE *mode);
HRESULT (*get_adapter_identifier)(d3d_base *d3dptr, UINT adapter, DWORD flags, adapter_identifier *identifier);
UINT (*get_adapter_mode_count)(d3d_base *d3dptr, UINT adapter, D3DFORMAT format);
HMONITOR (*get_adapter_monitor)(d3d_base *d3dptr, UINT adapter);
HRESULT (*get_caps_dword)(d3d_base *d3dptr, UINT adapter, D3DDEVTYPE devtype, caps_index which, DWORD *value);
ULONG (*release)(d3d_base *d3dptr);
};
//============================================================
// Direct3DDevice interfaces
//============================================================
struct d3d_device_interface
{
HRESULT (*begin_scene)(device *dev);
HRESULT (*clear)(device *dev, DWORD count, const D3DRECT *rects, DWORD flags, D3DCOLOR color, float z, DWORD stencil);
HRESULT (*create_offscreen_plain_surface)(device *dev, UINT width, UINT height, D3DFORMAT format, D3DPOOL pool, surface **surface);
HRESULT (*create_texture)(device *dev, UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, texture **texture);
HRESULT (*create_vertex_buffer)(device *dev, UINT length, DWORD usage, DWORD fvf, D3DPOOL pool, vertex_buffer **buf);
HRESULT (*create_render_target)(device *dev, UINT width, UINT height, D3DFORMAT format, surface **surface);
HRESULT (*draw_primitive)(device *dev, D3DPRIMITIVETYPE type, UINT start, UINT count);
HRESULT (*end_scene)(device *dev);
HRESULT (*get_raster_status)(device *dev, D3DRASTER_STATUS *status);
HRESULT (*get_render_target)(device *dev, DWORD index, surface **surface);
HRESULT (*get_render_target_data)(device *dev, surface *rendertarget, surface *destsurface);
HRESULT (*present)(device *dev, const RECT *source, const RECT *dest, HWND override, RGNDATA *dirty, DWORD flags);
ULONG (*release)(device *dev);
HRESULT (*reset)(device *dev, present_parameters *params);
void (*set_gamma_ramp)(device *dev, DWORD flags, const D3DGAMMARAMP *ramp);
HRESULT (*set_render_state)(device *dev, D3DRENDERSTATETYPE state, DWORD value);
HRESULT (*set_render_target)(device *dev, DWORD index, surface *surf);
HRESULT (*set_stream_source)(device *dev, UINT number, vertex_buffer *vbuf, UINT stride);
HRESULT (*set_texture)(device *dev, DWORD stage, texture *tex);
HRESULT (*set_texture_stage_state)(device *dev, DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD value);
HRESULT (*set_vertex_format)(device *dev, D3DFORMAT format);
HRESULT (*stretch_rect)(device *dev, surface *source, const RECT *srcrect, surface *dest, const RECT *dstrect, D3DTEXTUREFILTERTYPE filter);
HRESULT (*test_cooperative_level)(device *dev);
};
//============================================================
// Direct3DSurface interfaces
//============================================================
struct surface_interface
{
HRESULT (*lock_rect)(surface *surf, D3DLOCKED_RECT *locked, const RECT *rect, DWORD flags);
ULONG (*release)(surface *tex);
HRESULT (*unlock_rect)(surface *surf);
};
//============================================================
// Direct3DTexture interfaces
//============================================================
struct texture_interface
{
HRESULT (*get_surface_level)(texture *tex, UINT level, surface **surface);
HRESULT (*lock_rect)(texture *tex, UINT level, D3DLOCKED_RECT *locked, const RECT *rect, DWORD flags);
ULONG (*release)(texture *tex);
HRESULT (*unlock_rect)(texture *tex, UINT level);
};
//============================================================
// Direct3DVertexBuffer interfaces
//============================================================
struct vertex_buffer_interface
{
HRESULT (*lock)(vertex_buffer *vbuf, UINT offset, UINT size, VOID **data, DWORD flags);
ULONG (*release)(vertex_buffer *vbuf);
HRESULT (*unlock)(vertex_buffer *vbuf);
};
//============================================================
// Core D3D object
//============================================================
struct d3d_base
{
// internal objects
int version;
void * d3dobj;
HINSTANCE dllhandle;
bool post_fx_available;
HINSTANCE libhandle;
// interface pointers
interface d3d;
d3d_device_interface device;
surface_interface surface;
texture_interface texture;
vertex_buffer_interface vertexbuf;
};
//============================================================
// PROTOTYPES
//============================================================
d3d_base *drawd3d9_init(void);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -13,8 +13,17 @@
#ifdef OSD_WINDOWS
#include "d3d/d3dintf.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
#include <mmsystem.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <math.h>
#undef interface
#include "d3d/d3dcomm.h"
#include "modules/lib/osdlib.h"
//============================================================
// CONSTANTS
@ -27,14 +36,17 @@
// TYPE DEFINITIONS
//============================================================
struct vertex;
class texture_info;
class texture_manager;
struct device;
struct vertex_buffer;
struct d3d_base
{
// internal objects
IDirect3D9 *d3dobj;
bool post_fx_available;
osd::dynamic_module::ptr d3d9_dll;
};
class shaders;
struct hlsl_options;
class poly_info;
/* renderer is the information about Direct3D for the current screen */
class renderer_d3d9 : public osd_renderer
@ -97,10 +109,10 @@ public:
int get_height() const { return m_height; }
int get_refresh() const { return m_refresh; }
device * get_device() const { return m_device; }
present_parameters * get_presentation() { return &m_presentation; }
IDirect3DDevice9 * get_device() const { return m_device; }
D3DPRESENT_PARAMETERS * get_presentation() { return &m_presentation; }
vertex_buffer * get_vertex_buffer() const { return m_vertexbuf; }
IDirect3DVertexBuffer9 *get_vertex_buffer() const { return m_vertexbuf; }
vertex * get_locked_buffer() const { return m_lockedbuf; }
VOID ** get_locked_buffer_ptr()const { return (VOID **)&m_lockedbuf; }
void set_locked_buffer(vertex *lockedbuf) { m_lockedbuf = lockedbuf; }
@ -128,13 +140,13 @@ private:
int m_refresh; // current refresh rate
int m_create_error_count; // number of consecutive create errors
device * m_device; // pointer to the Direct3DDevice object
IDirect3DDevice9 * m_device; // pointer to the Direct3DDevice object
int m_gamma_supported; // is full screen gamma supported?
present_parameters m_presentation; // set of presentation parameters
D3DPRESENT_PARAMETERS m_presentation; // set of presentation parameters
D3DDISPLAYMODE m_origmode; // original display mode for the adapter
D3DFORMAT m_pixformat; // pixel format we are using
vertex_buffer * m_vertexbuf; // pointer to the vertex buffer object
IDirect3DVertexBuffer9 *m_vertexbuf; // pointer to the vertex buffer object
vertex * m_lockedbuf; // pointer to the locked vertex buffer
int m_numverts; // number of accumulated vertices

View File

@ -360,17 +360,11 @@ static void loadgl_functions(osd_gl_context *context)
osd_gl_dispatch *gl_dispatch;
#endif
#ifdef OSD_WINDOWS
HMODULE win_gl_context::m_module;
#endif
void renderer_ogl::load_gl_lib(running_machine &machine)
{
if (!s_dll_loaded)
{
#ifdef OSD_WINDOWS
win_gl_context::load_library();
#else
#ifndef OSD_WINDOWS
#ifdef USE_DISPATCH_GL
/*
* directfb and and x11 use this env var

View File

@ -14,6 +14,17 @@
#define __WIN_GL_CONTEXT__
#include "modules/opengl/osd_opengl.h"
#include "modules/lib/osdlib.h"
// Typedefs for dynamically loaded functions
typedef PROC (WINAPI *wglGetProcAddress_fn)(LPCSTR);
typedef HGLRC (WINAPI *wglCreateContext_fn)(HDC);
typedef BOOL (WINAPI *wglDeleteContext_fn)(HGLRC);
typedef BOOL (WINAPI *wglMakeCurrent_fn)(HDC, HGLRC);
typedef const char * (WINAPI *wglGetExtensionsStringEXT_fn)(void);
typedef BOOL (WINAPI *wglSwapIntervalEXT_fn)(int);
typedef int (WINAPI *wglGetSwapIntervalEXT_fn)(void);
class win_gl_context : public osd_gl_context
{
@ -22,17 +33,25 @@ public:
{
m_error[0] = 0;
this->pfn_wglGetProcAddress = (PROC (WINAPI *)(LPCSTR lpszProc)) GetProcAddress(m_module, "wglGetProcAddress");
this->pfn_wglCreateContext = (HGLRC (WINAPI *)(HDC hdc)) GetProcAddress(m_module, "wglCreateContext");
this->pfn_wglDeleteContext = (BOOL (WINAPI *)(HGLRC hglrc)) GetProcAddress(m_module, "wglDeleteContext");
this->pfn_wglMakeCurrent = (BOOL (WINAPI *)(HDC hdc, HGLRC hglrc)) GetProcAddress(m_module, "wglMakeCurrent");
opengl32_dll = osd::dynamic_module::open({ "opengl32.dll" });
this->pfn_wglGetExtensionsStringEXT = (const char *(WINAPI *) (void)) pfn_wglGetProcAddress("wglGetExtensionsStringEXT");
pfn_wglGetProcAddress = opengl32_dll->bind<wglGetProcAddress_fn>("wglGetProcAddress");
pfn_wglCreateContext = opengl32_dll->bind<wglCreateContext_fn>("wglCreateContext");
pfn_wglDeleteContext = opengl32_dll->bind<wglDeleteContext_fn>("wglDeleteContext");
pfn_wglMakeCurrent = opengl32_dll->bind<wglMakeCurrent_fn>("wglMakeCurrent");
if (pfn_wglGetProcAddress == nullptr || pfn_wglCreateContext == nullptr ||
pfn_wglDeleteContext == nullptr || pfn_wglMakeCurrent == nullptr)
{
return;
}
pfn_wglGetExtensionsStringEXT = (wglGetExtensionsStringEXT_fn)(*pfn_wglGetProcAddress)("wglGetExtensionsStringEXT");
if (WGLExtensionSupported("WGL_EXT_swap_control"))
{
this->pfn_wglSwapIntervalEXT = (BOOL (WINAPI *) (int)) getProcAddress("wglSwapIntervalEXT");
this->pfn_wglGetSwapIntervalEXT = (int (WINAPI *) (void)) getProcAddress("wglGetSwapIntervalEXT");
pfn_wglSwapIntervalEXT = (BOOL (WINAPI *) (int)) getProcAddress("wglSwapIntervalEXT");
pfn_wglGetSwapIntervalEXT = (int (WINAPI *) (void)) getProcAddress("wglGetSwapIntervalEXT");
}
else
{
@ -43,25 +62,25 @@ public:
m_hdc = GetDC(window);
if (!setupPixelFormat(m_hdc))
{
m_context = this->pfn_wglCreateContext(m_hdc);
m_context = (*pfn_wglCreateContext)(m_hdc);
if (!m_context)
{
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, GetLastError(), 0, m_error, 255, nullptr);
return;
}
this->pfn_wglMakeCurrent(m_hdc, m_context);
(*pfn_wglMakeCurrent)(m_hdc, m_context);
}
}
virtual ~win_gl_context()
{
this->pfn_wglDeleteContext(m_context);
(*pfn_wglDeleteContext)(m_context);
ReleaseDC(m_window, m_hdc);
}
virtual void MakeCurrent() override
{
this->pfn_wglMakeCurrent(m_hdc, m_context);
(*pfn_wglMakeCurrent)(m_hdc, m_context);
}
virtual const char *LastErrorMsg() override
@ -74,17 +93,14 @@ public:
virtual void *getProcAddress(const char *proc) override
{
void *ret = (void *) GetProcAddress(m_module, proc);
if (ret == nullptr)
ret = (void *) this->pfn_wglGetProcAddress(proc);
return ret;
return (void *)(*pfn_wglGetProcAddress)(proc);
}
virtual int SetSwapInterval(const int swap) override
{
if (this->pfn_wglSwapIntervalEXT != nullptr)
if (pfn_wglSwapIntervalEXT != nullptr)
{
this->pfn_wglSwapIntervalEXT(swap ? 1 : 0);
pfn_wglSwapIntervalEXT(swap ? 1 : 0);
}
return 0;
}
@ -95,11 +111,6 @@ public:
//wglSwapLayerBuffers(GetDC(window().m_hwnd), WGL_SWAP_MAIN_PLANE);
}
static void load_library()
{
m_module = LoadLibraryA("opengl32.dll");
}
private:
int setupPixelFormat(HDC hDC)
@ -124,15 +135,17 @@ private:
0, /* reserved */
0, 0, 0, /* no layer, visible, damage masks */
};
int pixelFormat;
pixelFormat = ChoosePixelFormat(hDC, &pfd);
if (pixelFormat == 0) {
strcpy(m_error, "ChoosePixelFormat failed");
int pixelFormat = ChoosePixelFormat(hDC, &pfd);
if (pixelFormat == 0)
{
strcpy(m_error, "ChoosePixelFormat failed.");
return 1;
}
if (SetPixelFormat(hDC, pixelFormat, &pfd) != TRUE) {
if (SetPixelFormat(hDC, pixelFormat, &pfd) != TRUE)
{
strcpy(m_error, "SetPixelFormat failed.");
return 1;
}
@ -141,10 +154,12 @@ private:
bool WGLExtensionSupported(const char *extension_name)
{
//if (pfn_wglGetExtensionsStringEXT != nullptr)
// printf("%s\n", this->pfn_wglGetExtensionsStringEXT());
if (pfn_wglGetExtensionsStringEXT == nullptr)
return false;
if (pfn_wglGetExtensionsStringEXT != nullptr && strstr(pfn_wglGetExtensionsStringEXT(), extension_name) != nullptr)
// printf("%s\n", pfn_wglGetExtensionsStringEXT());
if (strstr(pfn_wglGetExtensionsStringEXT(), extension_name) != nullptr)
return true;
else
return false;
@ -155,16 +170,15 @@ private:
HDC m_hdc;
char m_error[256];
PROC (WINAPI *pfn_wglGetProcAddress)(LPCSTR lpszProc);
HGLRC (WINAPI *pfn_wglCreateContext)(HDC hdc);
BOOL (WINAPI *pfn_wglDeleteContext)(HGLRC hglrc);
BOOL (WINAPI *pfn_wglMakeCurrent)(HDC hdc, HGLRC hglrc);
osd::dynamic_module::ptr opengl32_dll;
wglGetProcAddress_fn pfn_wglGetProcAddress;
wglCreateContext_fn pfn_wglCreateContext;
wglDeleteContext_fn pfn_wglDeleteContext;
wglMakeCurrent_fn pfn_wglMakeCurrent;
const char *(WINAPI *pfn_wglGetExtensionsStringEXT) (void);
BOOL (WINAPI *pfn_wglSwapIntervalEXT) (int interval);
int (WINAPI * pfn_wglGetSwapIntervalEXT) (void);
static HMODULE m_module;
wglGetExtensionsStringEXT_fn pfn_wglGetExtensionsStringEXT;
wglSwapIntervalEXT_fn pfn_wglSwapIntervalEXT;
wglGetSwapIntervalEXT_fn pfn_wglGetSwapIntervalEXT;
};
#endif // __WIN_GL_CONTEXT__

22
src/osd/modules/sound/xaudio2_sound.cpp Normal file → Executable file
View File

@ -33,6 +33,8 @@
#include "winutil.h"
#include "modules/lib/osdlib.h"
//============================================================
// Constants
//============================================================
@ -118,7 +120,7 @@ typedef std::unique_ptr<IXAudio2MasteringVoice, xaudio2_custom_deleter> masterin
typedef std::unique_ptr<IXAudio2SourceVoice, xaudio2_custom_deleter> src_voice_ptr;
// Typedef for pointer to XAudio2Create
typedef lazy_loaded_function_p3<HRESULT, IXAudio2**, UINT32, XAUDIO2_PROCESSOR> xaudio2_create_ptr;
typedef HRESULT (*xaudio2_create_ptr)(IXAudio2 **, UINT32, XAUDIO2_PROCESSOR);
//============================================================
// Helper classes
@ -181,8 +183,6 @@ public:
class sound_xaudio2 : public osd_module, public sound_module, public IXAudio2VoiceCallback
{
private:
const wchar_t* XAUDIO_DLLS[2] = { L"XAudio2_9.dll", L"XAudio2_8.dll" };
Microsoft::WRL::ComPtr<IXAudio2> m_xAudio2;
mastering_voice_ptr m_masterVoice;
src_voice_ptr m_sourceVoice;
@ -201,6 +201,7 @@ private:
UINT32 m_overflows;
UINT32 m_underflows;
BOOL m_in_underflow;
osd::dynamic_module::ptr m_xaudio_dll;
xaudio2_create_ptr XAudio2Create;
BOOL m_initialized;
@ -223,7 +224,6 @@ public:
m_overflows(0),
m_underflows(0),
m_in_underflow(FALSE),
XAudio2Create("XAudio2Create", XAUDIO_DLLS, ARRAY_LENGTH(XAUDIO_DLLS)),
m_initialized(FALSE)
{
}
@ -261,8 +261,13 @@ private:
bool sound_xaudio2::probe()
{
int status = XAudio2Create.initialize();
return status == 0;
m_xaudio_dll = osd::dynamic_module::open({ "XAudio2_9.dll", "XAudio2_8.dll" });
if (m_xaudio_dll == nullptr)
return false;
XAudio2Create = m_xaudio_dll->bind<xaudio2_create_ptr>("XAudio2Create");
return (XAudio2Create ? true : false);
}
//============================================================
@ -276,10 +281,9 @@ int sound_xaudio2::init(osd_options const &options)
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
// Make sure our XAudio2Create entrypoint is bound
int status = XAudio2Create.initialize();
if (status != 0)
if (!XAudio2Create)
{
osd_printf_error("Could not find XAudio2 library\n");
osd_printf_error("Could not find XAudio2. Please try to reinstall DirectX runtime package.\n");
return 1;
}

View File

@ -111,67 +111,3 @@ HMODULE WINAPI GetModuleHandleUni()
VirtualQuery((LPCVOID)GetModuleHandleUni, &mbi, sizeof(mbi));
return (HMODULE)mbi.AllocationBase;
}
//-----------------------------------------------------------
// Lazy loaded function using LoadLibrary / GetProcAddress
//-----------------------------------------------------------
lazy_loaded_function::lazy_loaded_function(const char * name, const wchar_t* dll_name)
: lazy_loaded_function(name, &dll_name, 1)
{
}
lazy_loaded_function::lazy_loaded_function(const char * name, const wchar_t** dll_names, int dll_count)
: m_name(name), m_module(nullptr), m_initialized(false), m_pfn(nullptr)
{
for (int i = 0; i < dll_count; i++)
m_dll_names.push_back(std::wstring(dll_names[i]));
}
lazy_loaded_function::~lazy_loaded_function()
{
if (m_module != nullptr)
{
FreeLibrary(m_module);
m_module = nullptr;
}
}
int lazy_loaded_function::initialize()
{
if (m_module == nullptr)
{
for (int i = 0; i < m_dll_names.size(); i++)
{
m_module = LoadLibraryW(m_dll_names[i].c_str());
if (m_module != nullptr)
break;
}
if (m_module == nullptr)
{
osd_printf_verbose("Could not find DLL to dynamically link function %s.\n", m_name.c_str());
return ERROR_DLL_NOT_FOUND;
}
}
if (m_pfn == nullptr)
{
m_pfn = GetProcAddress(m_module, m_name.c_str());
if (m_pfn == nullptr)
{
osd_printf_verbose("Could not find function address to dynamically link function %s.\n", m_name.c_str());
return ERROR_NOT_FOUND;
}
}
m_initialized = true;
return 0;
}
void lazy_loaded_function::check_init() const
{
if (!m_initialized)
fatalerror("Attempt to use function pointer for function %s prior to init!", name());
}

View File

@ -18,160 +18,4 @@ osd_dir_entry_type win_attributes_to_entry_type(DWORD attributes);
BOOL win_is_gui_application(void);
HMODULE WINAPI GetModuleHandleUni();
//-----------------------------------------------------------
// Lazy loaded function using LoadLibrary / GetProcAddress
//-----------------------------------------------------------
class lazy_loaded_function
{
private:
std::string m_name;
std::vector<std::wstring> m_dll_names;
HMODULE m_module;
bool m_initialized;
protected:
void check_init() const;
FARPROC m_pfn;
public:
lazy_loaded_function(const char * name, const wchar_t* dll_name);
lazy_loaded_function(const char * name, const wchar_t** dll_names, int dll_count);
~lazy_loaded_function();
int initialize();
const char * name() const { return m_name.c_str(); }
};
// No parameters
template <class TRet>
class lazy_loaded_function_ret : public lazy_loaded_function
{
public:
lazy_loaded_function_ret(const char * name, const wchar_t* dll_name)
: lazy_loaded_function(name, &dll_name, 1)
{
}
lazy_loaded_function_ret(const char * name, const wchar_t** dll_names, int dll_count)
: lazy_loaded_function(name, dll_names, dll_count)
{
}
TRet operator ()()
{
check_init();
return ((TRet(__stdcall *) ())m_pfn)();
}
};
// One parameter
template <class TRet, class P1>
class lazy_loaded_function_p1 : public lazy_loaded_function
{
public:
lazy_loaded_function_p1(const char * name, const wchar_t* dll_name)
: lazy_loaded_function(name, &dll_name, 1)
{
}
lazy_loaded_function_p1(const char * name, const wchar_t** dll_names, int dll_count)
: lazy_loaded_function(name, dll_names, dll_count)
{
}
TRet operator ()(P1 p1)
{
check_init();
return ((TRet(__stdcall *) (P1))m_pfn)(p1);
}
};
// Two parameters
template <class TRet, class P1, class P2>
class lazy_loaded_function_p2 : public lazy_loaded_function
{
public:
lazy_loaded_function_p2(const char * name, const wchar_t* dll_name)
: lazy_loaded_function(name, &dll_name, 1)
{
}
lazy_loaded_function_p2(const char * name, const wchar_t** dll_names, int dll_count)
: lazy_loaded_function(name, dll_names, dll_count)
{
}
TRet operator ()(P1 p1, P2 p2)
{
check_init();
return ((TRet(__stdcall *) (P1, P2))m_pfn)(p1, p2);
}
};
// Three parameters
template <class TRet, class P1, class P2, class P3>
class lazy_loaded_function_p3 : public lazy_loaded_function
{
public:
lazy_loaded_function_p3(const char * name, const wchar_t* dll_name)
: lazy_loaded_function(name, &dll_name, 1)
{
}
lazy_loaded_function_p3(const char * name, const wchar_t** dll_names, int dll_count)
: lazy_loaded_function(name, dll_names, dll_count)
{
}
TRet operator ()(P1 p1, P2 p2, P3 p3)
{
check_init();
return ((TRet(__stdcall *) (P1, P2, P3))m_pfn)(p1, p2, p3);
}
};
// Four parameters
template <class TRet, class P1, class P2, class P3, class P4>
class lazy_loaded_function_p4 : public lazy_loaded_function
{
public:
lazy_loaded_function_p4(const char * name, const wchar_t* dll_name)
: lazy_loaded_function(name, &dll_name, 1)
{
}
lazy_loaded_function_p4(const char * name, const wchar_t** dll_names, int dll_count)
: lazy_loaded_function(name, dll_names, dll_count)
{
}
TRet operator ()(P1 p1, P2 p2, P3 p3, P4 p4)
{
check_init();
return ((TRet(__stdcall *) (P1, P2, P3, P4))m_pfn)(p1, p2, p3, p4);
}
};
// Five parameters
template <class TRet, class P1, class P2, class P3, class P4, class P5>
class lazy_loaded_function_p5 : public lazy_loaded_function
{
public:
lazy_loaded_function_p5(const char * name, const wchar_t* dll_name)
: lazy_loaded_function(name, &dll_name, 1)
{
}
lazy_loaded_function_p5(const char * name, const wchar_t** dll_names, int dll_count)
: lazy_loaded_function(name, dll_names, dll_count)
{
}
TRet operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
{
check_init();
return ((TRet(__stdcall *) (P1, P2, P3, P4, P5))m_pfn)(p1, p2, p3, p4, p5);
}
};
#endif // __WINUTIL__